probe/discovery/target/host/host.go
crusader 7535e7ffc1 ing
2018-09-05 03:58:33 +09:00

49 lines
942 B
Go

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
}
if nil != discoverySession.PCapScanner() {
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
}