30 lines
753 B
Go
30 lines
753 B
Go
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
|
|
}
|