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

View File

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

View File

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