38 lines
1004 B
Go
38 lines
1004 B
Go
package ipv4
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
cnsm "git.loafle.net/commons_go/network_service_matcher"
|
|
cuej "git.loafle.net/commons_go/util/encoding/json"
|
|
discoveryM "git.loafle.net/overflow/overflow_commons_go/modules/discovery/model"
|
|
"git.loafle.net/overflow/overflow_discovery/matcher"
|
|
)
|
|
|
|
func scanServiceUDP(port *discoveryM.Port, ds *discoveryM.DiscoveryService, resultChan chan interface{}, errChan chan error, stopChan chan struct{}) bool {
|
|
portNumber, err := cuej.NumberToInt(port.PortNumber)
|
|
if err != nil {
|
|
errChan <- fmt.Errorf("Discovery: Service scan port[%s] error %v ", port.PortNumber, err)
|
|
return false
|
|
}
|
|
|
|
ms := matcher.GetUDPMatchers()
|
|
mi := cnsm.NewMatchInfo(port.Host.IP, portNumber)
|
|
|
|
for i := 0; i < len(ms); i++ {
|
|
m := ms[i]
|
|
p := cnsm.NewPacket(port.UDPLayer.LayerPayload(), len(port.UDPLayer.LayerPayload()))
|
|
|
|
if m.Match(mi, 0, p) {
|
|
s := &discoveryM.Service{
|
|
ServiceName: m.ServiceName(),
|
|
}
|
|
s.Port = port
|
|
resultChan <- s
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|