package port import ( "sync" omd "git.loafle.net/overflow/model/discovery" "git.loafle.net/overflow_scanner/probe/discovery/protocol/tcp/connection" "git.loafle.net/overflow_scanner/probe/discovery/protocol/tcp/syn" "git.loafle.net/overflow_scanner/probe/discovery/session" ) func Scan(discoverySession session.DiscoverySession, targetHost *omd.Host) error { if nil == targetHost || nil == discoverySession.DiscoverPort() { return nil } if nil != discoverySession.PCapScanner() { return privilegedScan(discoverySession, targetHost) } return unprivilegedScan(discoverySession, targetHost) } func privilegedScan(discoverySession session.DiscoverySession, targetHost *omd.Host) error { var wg sync.WaitGroup wg.Add(1) go func() { defer wg.Done() syn.Scan(discoverySession, targetHost) }() wg.Wait() return nil } func unprivilegedScan(discoverySession session.DiscoverySession, targetHost *omd.Host) error { var wg sync.WaitGroup wg.Add(1) go func() { defer wg.Done() connection.Scan(discoverySession, targetHost) }() wg.Wait() return nil }