wifictld-analyzer/controller/handler.go

30 lines
630 B
Go
Raw Normal View History

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
"dev.sum7.eu/genofire/wifictld-analyzer/capture"
2018-06-03 20:37:52 +02:00
)
func (c *Controller) Handler(addr *net.UDPAddr, msg *capture.SocketMSG) (*capture.SocketMSG, error) {
2018-06-03 20:37:52 +02:00
ignore := false
if msg.Types.Is(capture.SocketMSGTypeClient) && msg.Client != nil {
2018-06-03 20:37:52 +02:00
ignore = c.db.LearnClient(addr.IP, msg.Client)
}
if !msg.Types.Is(capture.SocketMSGTypeRequest) {
2018-06-03 20:37:52 +02:00
return nil, nil
}
msg = &capture.SocketMSG{
Types: (capture.SocketMSGTypeResponse | capture.SocketMSGTypeClient),
2018-06-03 20:37:52 +02:00
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
}