29 lines
790 B
Go
29 lines
790 B
Go
package service
|
|
|
|
import (
|
|
omd "git.loafle.net/overflow/model/discovery"
|
|
omm "git.loafle.net/overflow/model/meta"
|
|
ounp "git.loafle.net/overflow/util-go/net/ping"
|
|
"git.loafle.net/overflow_scanner/probe/ping/service/connection"
|
|
"git.loafle.net/overflow_scanner/probe/ping/service/matcher"
|
|
)
|
|
|
|
func Ping(service *omd.Service, pingOption ounp.Option) (ounp.Result, error) {
|
|
if isDiscoveredByMatcher(service) {
|
|
return matcher.Ping(service, pingOption)
|
|
}
|
|
|
|
return connection.Ping(service, pingOption)
|
|
}
|
|
|
|
func isDiscoveredByMatcher(service *omd.Service) bool {
|
|
for _, discoveredBy := range service.DiscoveredBy {
|
|
switch omm.ToMetaDiscovererTypeEnum(discoveredBy) {
|
|
case omm.MetaDiscovererTypeEnumUDPMatcher, omm.MetaDiscovererTypeEnumTCPMatcher:
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|