package ipv4 import ( "fmt" csm "git.loafle.net/commons/service_matcher-go" cuej "git.loafle.net/commons/util-go/encoding/json" ocmd "git.loafle.net/overflow/commons-go/model/discovery" "git.loafle.net/overflow/container_discovery/internal/matcher" ) func scanServiceUDP(port *ocmd.Port, ds *ocmd.DiscoverService, 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 := csm.NewMatchInfo(port.Host.IPV4, portNumber) for i := 0; i < len(ms); i++ { m := ms[i] p := csm.NewPacket(port.UDPLayer.LayerPayload(), len(port.UDPLayer.LayerPayload())) if m.Match(mi, 0, p) { s := &ocmd.Service{ ServiceName: m.Name(), } s.Port = port resultChan <- s return true } } return false }