2018-06-03 20:37:52 +02:00
|
|
|
package controller
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
"time"
|
|
|
|
|
2019-02-28 16:24:29 +01:00
|
|
|
"github.com/bdlm/log"
|
2018-06-03 20:37:52 +02:00
|
|
|
|
2019-02-28 16:22:55 +01:00
|
|
|
"dev.sum7.eu/genofire/wifictld-analyzer/data"
|
|
|
|
"dev.sum7.eu/genofire/wifictld-analyzer/database"
|
2018-06-03 20:37:52 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type Controller struct {
|
2018-07-16 13:00:37 +02:00
|
|
|
SendTo func(addr *net.UDPAddr, msg *data.SocketMSG)
|
|
|
|
Send func(msg *data.SocketMSG)
|
|
|
|
db *database.DB
|
|
|
|
ticker *time.Ticker
|
2018-06-03 20:37:52 +02:00
|
|
|
}
|
|
|
|
|
2018-07-10 21:40:38 +02:00
|
|
|
func NewController(db *database.DB) *Controller {
|
2018-06-03 20:37:52 +02:00
|
|
|
ctl := &Controller{
|
2018-07-10 21:40:38 +02:00
|
|
|
ticker: time.NewTicker(time.Minute),
|
|
|
|
db: db,
|
2018-06-03 20:37:52 +02:00
|
|
|
}
|
|
|
|
go ctl.Repeated()
|
|
|
|
return ctl
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Controller) Close() {
|
|
|
|
c.ticker.Stop()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Controller) Repeated() {
|
|
|
|
for range c.ticker.C {
|
2018-07-16 13:00:37 +02:00
|
|
|
log.Debugf("lerned: %d APs, %d Clients", len(c.db.APs), len(c.db.Clients))
|
2018-06-03 20:37:52 +02:00
|
|
|
}
|
|
|
|
}
|