package database import ( "net" "time" // log "github.com/sirupsen/logrus" "dev.sum7.eu/wifictld/analyzer/data" ) type Client struct { Addr net.HardwareAddr Time time.Time TryProbe uint16 TryAuth uint16 Connected bool Authed bool FreqHighest uint16 SignalLowFreq int16 SignalHighFreq int16 } func (db *DB) LearnClient(apIP net.IP, clientWifictl *data.WifiClient) bool { ret := false apAddr := apIP.String() ap, ok := db.APs[apAddr] if !ok { ap = &AP{} db.APs[apAddr] = ap } clientAddr := clientWifictl.Addr.String() client, ok := db.Clients[clientAddr] if !ok { client = &Client{ Addr: clientWifictl.Addr, } db.Clients[clientAddr] = client } client.Time = time.Now() if client.FreqHighest < clientWifictl.FreqHighest { ret = (client.FreqHighest != 0) client.FreqHighest = clientWifictl.FreqHighest } return ret } func (db *DB) GetClient(addr net.HardwareAddr) *data.WifiClient { client, ok := db.Clients[addr.String()] wClient := &data.WifiClient{ Addr: addr, Time: time.Now(), } if ok { wClient.TryProbe = client.TryProbe } return wClient }