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