ing
This commit is contained in:
parent
5b5a780fcc
commit
59add71a72
|
@ -653,9 +653,18 @@ func (ds *ofDiscoverySession) findPort(port *omd.Port) (p *omd.Port, modified bo
|
|||
|
||||
if "" == p.DefaultService {
|
||||
portNumber, _ := ouej.NumberToInt(port.PortNumber)
|
||||
if dName, ok := layers.TCPPortNames[layers.TCPPort(portNumber)]; ok {
|
||||
p.DefaultService = dName
|
||||
modified = true
|
||||
switch omm.ToMetaPortTypeEnum(port.MetaPortType) {
|
||||
case omm.MetaPortTypeEnumTCP:
|
||||
if dName, ok := layers.TCPPortNames[layers.TCPPort(portNumber)]; ok {
|
||||
p.DefaultService = dName
|
||||
modified = true
|
||||
}
|
||||
case omm.MetaPortTypeEnumUDP:
|
||||
if dName, ok := layers.UDPPortNames[layers.UDPPort(portNumber)]; ok {
|
||||
p.DefaultService = dName
|
||||
modified = true
|
||||
}
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ func scanTCP(discoverySession session.DiscoverySession, targetPort *omd.Port) er
|
|||
}
|
||||
|
||||
var limitedMatchers []osm.Matcher
|
||||
matchCtx := osm.NewMatchCtx(hostAddress, portNumber)
|
||||
|
||||
if omm.MetaHostTypeEnumPrinter.String() == targetPort.Host.HostType {
|
||||
switch portNumber {
|
||||
|
@ -34,7 +35,7 @@ func scanTCP(discoverySession session.DiscoverySession, targetPort *omd.Port) er
|
|||
// return nil
|
||||
case 515:
|
||||
limitedMatchers = []osm.Matcher{
|
||||
matcher.GetMatcherByKey("LPD"),
|
||||
matcher.GetMatcherByKey(matchCtx, "LPD"),
|
||||
}
|
||||
case 8290:
|
||||
discoverySession.AddServiceUnknown(
|
||||
|
@ -47,7 +48,6 @@ func scanTCP(discoverySession session.DiscoverySession, targetPort *omd.Port) er
|
|||
}
|
||||
}
|
||||
|
||||
matchCtx := osm.NewMatchCtx(hostAddress, portNumber)
|
||||
connectors := newConnectors()
|
||||
stopChan := make(chan struct{})
|
||||
buf := make([]byte, 1024)
|
||||
|
@ -82,7 +82,7 @@ LOOP:
|
|||
}
|
||||
|
||||
if nil != discoveredMatcher {
|
||||
if "HTTP" == discoveredMatcher.Key() {
|
||||
if "HTTP" == discoveredMatcher.Key(matchCtx) {
|
||||
hsm := matcher.GetHTTPSubMatchers()
|
||||
if _discoveredMatcher := hadlePostPacket(matchCtx, _connector, targetPort, hsm, stopChan); _discoveredMatcher != nil {
|
||||
discoveredMatcher = _discoveredMatcher
|
||||
|
@ -104,10 +104,10 @@ LOOP:
|
|||
s := omd.NewService(
|
||||
targetPort,
|
||||
discoveredConnector.metaCryptoType(),
|
||||
discoveredMatcher.Key(),
|
||||
discoveredMatcher.Key(matchCtx),
|
||||
)
|
||||
s.Name = discoveredMatcher.Name(matchCtx)
|
||||
s.ServiceType = discoveredMatcher.Type()
|
||||
s.ServiceType = discoveredMatcher.Type(matchCtx)
|
||||
s.ServiceVendor = discoveredMatcher.Vendor(matchCtx)
|
||||
s.ServiceVersion = discoveredMatcher.Version(matchCtx)
|
||||
s.DiscoveredDate = omu.NowPtr()
|
||||
|
|
|
@ -28,10 +28,10 @@ func scanUDP(discoverySession session.DiscoverySession, targetPort *omd.Port) er
|
|||
s := omd.NewService(
|
||||
targetPort,
|
||||
omm.ToMetaCryptoType(omm.MetaCryptoTypeEnumNONE),
|
||||
_matcher.Key(),
|
||||
_matcher.Key(matchCtx),
|
||||
)
|
||||
s.Name = _matcher.Name(matchCtx)
|
||||
s.ServiceType = _matcher.Type()
|
||||
s.ServiceType = _matcher.Type(matchCtx)
|
||||
s.ServiceVendor = _matcher.Vendor(matchCtx)
|
||||
s.ServiceVersion = _matcher.Version(matchCtx)
|
||||
s.DiscoveredDate = omu.NowPtr()
|
||||
|
|
|
@ -87,9 +87,9 @@ func GetHTTPSubMatchers() []osm.Matcher {
|
|||
return HTTPSubMatchers
|
||||
}
|
||||
|
||||
func GetMatcherByKey(key string) osm.Matcher {
|
||||
func GetMatcherByKey(matchCtx *osm.MatchCtx, key string) osm.Matcher {
|
||||
for _, m := range AllMatchers {
|
||||
if m.Key() == key {
|
||||
if m.Key(matchCtx) == key {
|
||||
return m
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ func matcherPingFunc(service *omd.Service, pingOption ounp.Option) (ttl int, err
|
|||
}
|
||||
|
||||
matchCtx := osm.NewMatchCtx(service.Port.Host.Address, portNumber)
|
||||
_matcher := matcher.GetMatcherByKey(service.Key)
|
||||
_matcher := matcher.GetMatcherByKey(matchCtx, service.Key)
|
||||
|
||||
if _matcher.IsPrePacket() {
|
||||
return processPrepacket(service, pingOption, matchCtx, _matcher)
|
||||
|
|
Loading…
Reference in New Issue
Block a user