diff --git a/main.go b/main.go index b3dc45c..00031a4 100644 --- a/main.go +++ b/main.go @@ -13,8 +13,8 @@ import ( "time" "github.com/genuinetools/pkg/cli" - "github.com/jessfraz/netscan/pkg/scanner" - "github.com/jessfraz/netscan/version" + "github.com/bizmate-oss/netscan/pkg/scanner" + "github.com/bizmate-oss/netscan/version" "github.com/sirupsen/logrus" ) diff --git a/pkg/scanner/scanner.go b/pkg/scanner/scanner.go index 38d8ee4..3f68790 100644 --- a/pkg/scanner/scanner.go +++ b/pkg/scanner/scanner.go @@ -106,15 +106,13 @@ func (s *Scanner) Scan() []AddressSet { for _, ip := range s.ips { for _, port := range s.ports { for _, proto := range s.protocols { - addr := fmt.Sprintf("%s:%d", ip, port) - + guard <- struct{}{} wg.Add(1) - go func(proto, addr string) { + go func(ip net.IP, port int, proto string) { + addr := fmt.Sprintf("%s:%d", ip, port) defer wg.Done() - guard <- struct{}{} c, err := net.DialTimeout(proto, addr, s.timeout) - <-guard if err == nil { c.Close() resultsMutex.Lock() @@ -125,7 +123,8 @@ func (s *Scanner) Scan() []AddressSet { }) resultsMutex.Unlock() } - }(proto, addr) + <-guard + }(ip, port, proto) } } }