wifictld-analyzer/controller/handler.go

30 lines
608 B
Go
Raw Normal View History

2018-06-03 20:37:52 +02:00
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),
}
2018-07-16 13:00:37 +02:00
if !ignore {
2018-06-03 20:37:52 +02:00
return msg, nil
}
return nil, nil
}