wifictld-analyzer/controller/handler.go

30 lines
630 B
Go

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