2018-06-03 20:37:52 +02:00
|
|
|
package controller
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
|
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"
|
2018-06-03 20:37:52 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|