This commit is contained in:
crusader
2018-09-05 03:58:33 +09:00
parent a1ecf315c6
commit 7535e7ffc1
16 changed files with 158 additions and 159 deletions

View File

@@ -25,15 +25,11 @@ func Scan(discoverySession session.DiscoverySession) error {
zone := discoverySession.Zone()
ps, err := pcap.RetainScanner(zone)
if nil != err {
return fmt.Errorf("Cannot retain pcap instance %v", err)
ps := discoverySession.PCapScanner()
if nil == ps {
return fmt.Errorf("Cannot retain pcap instance")
}
defer func() {
pcap.ReleaseScanner(zone)
}()
arpChan := ps.OpenARP()
defer func() {
ps.CloseARP(arpChan)
@@ -57,16 +53,13 @@ func Scan(discoverySession session.DiscoverySession) error {
delay.Store(true)
if h := handlePacketARP(zone, targetHosts, hosts, packet); nil != h {
if h != nil {
// log.Print("Host ", h)
discoverySession.AddHost(h)
}
// resultChan <- h
}
case <-ticker.C:
if false == delay.Load().(bool) {
ticker.Stop()
timerStopped <- struct{}{}
close(timerStopped)
return
}
delay.Store(false)