This commit is contained in:
crusader 2018-09-18 10:24:54 +09:00
parent ab15aa25a3
commit a07e7e7b93

View File

@ -26,8 +26,19 @@ func scanTCP(discoverySession session.DiscoverySession, targetPort *omd.Port) er
return fmt.Errorf("Service scan on %s:%s error has occurred %v ", hostAddress, targetPort.PortNumber, err)
}
var limitedMatchers []osm.Matcher
if omm.MetaHostTypeEnumPrinter.String() == targetPort.Host.HostType {
if 9100 == portNumber || 515 == portNumber || 7 == portNumber {
switch portNumber {
case 7:
return nil
case 515:
limitedMatchers = []osm.Matcher{
matcher.GetMatcherByKey("LPD"),
}
case 8290:
return nil
case 9100:
return nil
}
}
@ -56,10 +67,10 @@ LOOP:
}
if 0 < n {
discoveredMatcher = hadlePrePacket(matchCtx, _connector, conn, osm.NewPacket(buf, n), stopChan)
discoveredMatcher = hadlePrePacket(matchCtx, _connector, conn, osm.NewPacket(buf, n), limitedMatchers, stopChan)
} else {
conn.Close()
discoveredMatcher = hadlePostPacket(matchCtx, _connector, targetPort, nil, stopChan)
discoveredMatcher = hadlePostPacket(matchCtx, _connector, targetPort, limitedMatchers, stopChan)
}
if nil != discoveredMatcher {
@ -108,12 +119,16 @@ LOOP:
return nil
}
func hadlePrePacket(matchCtx *osm.MatchCtx, _connector connector, conn net.Conn, packet *osm.Packet, stopChan <-chan struct{}) osm.Matcher {
func hadlePrePacket(matchCtx *osm.MatchCtx, _connector connector, conn net.Conn, packet *osm.Packet, limitedMatchers []osm.Matcher, stopChan <-chan struct{}) osm.Matcher {
defer func() {
conn.Close()
}()
matchers := matcher.GetTCPMatchers(true)
if nil != limitedMatchers {
matchers = limitedMatchers
}
buf := make([]byte, 1024)
var discoveredMatcher osm.Matcher