overflow_discovery/discovery/ipv4/service_udp.go

30 lines
753 B
Go
Raw Normal View History

2017-11-22 10:04:04 +00:00
package ipv4
import (
"git.loafle.net/overflow/overflow_discovery/api/module/discovery/model"
"git.loafle.net/overflow/overflow_discovery/service"
"git.loafle.net/overflow/overflow_discovery/service/matcher"
)
func scanServiceUDP(port *model.Port, ds *model.DiscoveryService, resultChan chan interface{}, errChan chan error, stopChan chan struct{}) bool {
ms := service.GetUDPMatchers()
mi := matcher.NewMatchInfo(port.Host.IP, port.PortNumber)
for i := 0; i < len(ms); i++ {
m := ms[i]
p := matcher.NewPacket(port.UDPLayer.LayerPayload(), len(port.UDPLayer.LayerPayload()))
if m.Match(mi, 0, p) {
s := &model.Service{
ServiceName: m.ServiceName(),
}
s.Port = port
resultChan <- s
return true
}
}
return false
}