wifictld-analyzer/controller/handler.go

30 lines
621 B
Go

package controller
import (
"net"
// log "github.com/sirupsen/logrus"
"dev.sum7.eu/wifictld/analyzer/data"
)
func (c *Controller) Handler(addr *net.UDPAddr, msg *data.SocketMSG) (*data.SocketMSG, error) {
ignore := false
if msg.Types.Is(data.SocketMSGTypeClient) && msg.Client != nil {
ignore = c.db.LearnClient(addr.IP, msg.Client)
}
if !msg.Types.Is(data.SocketMSGTypeRequest) {
return nil, nil
}
msg = &data.SocketMSG{
Types: (data.SocketMSGTypeResponse | data.SocketMSGTypeClient),
Client: c.db.GetClient(msg.Client.Addr),
}
if c.central || !ignore {
return msg, nil
}
return nil, nil
}