This commit is contained in:
crusader 2018-09-28 19:41:11 +09:00
parent ab53243acf
commit dfdc9bdf82
2 changed files with 11 additions and 6 deletions

View File

@ -51,7 +51,7 @@ func scanV4(discoverySession session.DiscoverySession, targetHost *omd.Host) (er
var delay atomic.Value
delay.Store(false)
ticker := time.NewTicker(time.Millisecond * 1000)
ticker := time.NewTicker(time.Millisecond * 3000)
defer func() {
ticker.Stop()
}()

View File

@ -90,7 +90,8 @@ type ofDiscoverySession struct {
services map[*omd.Port]map[string]*omd.Service
privileged bool
hostScanned sync.Map
hostScanned map[string]map[string]bool
hostScannedMtx sync.Mutex
stopped atomic.Value
stopChan chan struct{}
@ -113,6 +114,7 @@ func (ds *ofDiscoverySession) init(request types.DiscoveryRequest) {
ds.includeMacHosts = make(map[string]*omd.Host)
ds.ports = make(map[*omd.Host]map[json.Number]map[string]*omd.Port)
ds.services = make(map[*omd.Port]map[string]*omd.Service)
ds.hostScanned = make(map[string]map[string]bool)
ds.stopped.Store(false)
ds.stopChan = make(chan struct{})
@ -301,15 +303,17 @@ func (ds *ofDiscoverySession) IsTargetService(service *omd.Service) bool {
}
func (ds *ofDiscoverySession) HostNeedScan(host *omd.Host, discovererType *omm.MetaDiscovererType) bool {
_sd, ok := ds.hostScanned.Load(host.Address)
ds.hostScannedMtx.Lock()
defer ds.hostScannedMtx.Unlock()
sd, ok := ds.hostScanned[host.Address]
if !ok {
sd := make(map[string]bool)
sd = make(map[string]bool)
sd[discovererType.Key] = true
ds.hostScanned.Store(host.Address, sd)
ds.hostScanned[host.Address] = sd
return true
}
sd := _sd.(map[string]bool)
_, ok = sd[discovererType.Key]
if !ok {
sd[discovererType.Key] = true
@ -1055,6 +1059,7 @@ func ReleaseDiscoverySession(ds *ofDiscoverySession) {
ds.hosts = nil
ds.ports = nil
ds.services = nil
ds.hostScanned = nil
discoverySessionPool.Put(ds)
}