probe/discovery/target/host/host.go

49 lines
942 B
Go
Raw Normal View History

2018-08-31 14:00:08 +00:00
package host
import (
"sync"
"git.loafle.net/overflow_scanner/probe/discovery/protocol/arp"
"git.loafle.net/overflow_scanner/probe/discovery/protocol/icmp"
"git.loafle.net/overflow_scanner/probe/discovery/session"
)
func Scan(discoverySession session.DiscoverySession) error {
targetHosts := discoverySession.TargetHosts()
if nil == targetHosts || 0 == len(targetHosts) || nil == discoverySession.DiscoverHost() {
return nil
}
2018-09-04 18:58:33 +00:00
if nil != discoverySession.PCapScanner() {
2018-08-31 14:00:08 +00:00
return privilegedScan(discoverySession)
}
return unprivilegedScan(discoverySession)
}
func privilegedScan(discoverySession session.DiscoverySession) error {
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
arp.Scan(discoverySession)
}()
wg.Add(1)
go func() {
defer wg.Done()
icmp.Scan(discoverySession)
}()
wg.Wait()
return nil
}
func unprivilegedScan(discoverySession session.DiscoverySession) error {
return nil
}