This commit is contained in:
crusader 2018-09-28 19:57:13 +09:00
parent dfdc9bdf82
commit 50c7d862c6
3 changed files with 17 additions and 9 deletions

View File

@ -20,11 +20,19 @@ const (
defaultUlimit = 1024 defaultUlimit = 1024
) )
var (
discovererType = omm.ToMetaDiscovererType(omm.MetaDiscovererTypeEnumTCPConnection)
)
func Scan(discoverySession session.DiscoverySession, targetHost *omd.Host) error { func Scan(discoverySession session.DiscoverySession, targetHost *omd.Host) error {
if nil == targetHost || nil == discoverySession.DiscoverPort() || !discoverySession.DiscoverPort().IncludeTCP { if nil == targetHost || nil == discoverySession.DiscoverPort() || !discoverySession.DiscoverPort().IncludeTCP {
return nil return nil
} }
if !discoverySession.HostNeedScan(targetHost, discovererType) {
return nil
}
dp := discoverySession.DiscoverPort() dp := discoverySession.DiscoverPort()
lock := semaphore.NewWeighted(Ulimit()) lock := semaphore.NewWeighted(Ulimit())
@ -101,7 +109,7 @@ func tryConnect(discoverySession session.DiscoverySession, ports map[int]*omd.Po
ports[port] = p ports[port] = p
go discoverySession.AddPort(omm.ToMetaDiscovererType(omm.MetaDiscovererTypeEnumTCPConnection), p, nil) go discoverySession.AddPort(discovererType, p, nil)
} }
func Ulimit() int64 { func Ulimit() int64 {

View File

@ -6,11 +6,19 @@ import (
"git.loafle.net/overflow_scanner/probe/discovery/session" "git.loafle.net/overflow_scanner/probe/discovery/session"
) )
var (
discovererType = omm.ToMetaDiscovererType(omm.MetaDiscovererTypeEnumTCPSyn)
)
func Scan(discoverySession session.DiscoverySession, targetHost *omd.Host) error { func Scan(discoverySession session.DiscoverySession, targetHost *omd.Host) error {
if nil == targetHost || nil == discoverySession.DiscoverPort() || !discoverySession.DiscoverPort().IncludeTCP { if nil == targetHost || nil == discoverySession.DiscoverPort() || !discoverySession.DiscoverPort().IncludeTCP {
return nil return nil
} }
if !discoverySession.HostNeedScan(targetHost, discovererType) {
return nil
}
metaIPTypeEnum := omm.ToMetaIPTypeEnum(discoverySession.Zone().MetaIPType) metaIPTypeEnum := omm.ToMetaIPTypeEnum(discoverySession.Zone().MetaIPType)
switch metaIPTypeEnum { switch metaIPTypeEnum {

View File

@ -16,15 +16,7 @@ import (
"github.com/google/gopacket/layers" "github.com/google/gopacket/layers"
) )
var (
discovererType = omm.ToMetaDiscovererType(omm.MetaDiscovererTypeEnumTCPSyn)
)
func scanV4(discoverySession session.DiscoverySession, targetHost *omd.Host) (err error) { func scanV4(discoverySession session.DiscoverySession, targetHost *omd.Host) (err error) {
if !discoverySession.HostNeedScan(targetHost, discovererType) {
return nil
}
ps := discoverySession.PCapScanner() ps := discoverySession.PCapScanner()
if nil == ps { if nil == ps {
err = fmt.Errorf("Cannot retain pcap instance") err = fmt.Errorf("Cannot retain pcap instance")