40 lines
730 B
Go
40 lines
730 B
Go
package controller
|
|
|
|
import (
|
|
"net"
|
|
"time"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
"dev.sum7.eu/wifictld/analyzer/data"
|
|
"dev.sum7.eu/wifictld/analyzer/database"
|
|
)
|
|
|
|
type Controller struct {
|
|
SendTo func(addr *net.UDPAddr, msg *data.SocketMSG)
|
|
Send func(msg *data.SocketMSG)
|
|
db *database.DB
|
|
ticker *time.Ticker
|
|
central bool
|
|
}
|
|
|
|
func NewController(db *database.DB, central bool) *Controller {
|
|
ctl := &Controller{
|
|
ticker: time.NewTicker(60 * time.Second),
|
|
db: db,
|
|
central: central,
|
|
}
|
|
go ctl.Repeated()
|
|
return ctl
|
|
}
|
|
|
|
func (c *Controller) Close() {
|
|
c.ticker.Stop()
|
|
}
|
|
|
|
func (c *Controller) Repeated() {
|
|
for range c.ticker.C {
|
|
log.Infof("lerned: %d APs, %d Clients", len(c.db.APs), len(c.db.Clients))
|
|
}
|
|
}
|