File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change 4
4
"fmt"
5
5
"log"
6
6
"net"
7
- "sync"
8
7
"time"
9
8
10
9
"github.com/fatih/color"
@@ -108,9 +107,9 @@ func inc(ip net.IP) {
108
107
}
109
108
}
110
109
111
- // Function Scan(address string, wg *sync.WaitGroup )
110
+ // Function Scan(address string)
112
111
// Perform SYN scanning on a given IP range
113
- func Scan (address string , wg * sync. WaitGroup ) {
112
+ func Scan (address string ) {
114
113
ip , ipnet , err := net .ParseCIDR (address )
115
114
if err != nil {
116
115
log .Fatal (err )
@@ -127,6 +126,4 @@ func Scan(address string, wg *sync.WaitGroup) {
127
126
}
128
127
}
129
128
}
130
-
131
- wg .Done ()
132
129
}
Original file line number Diff line number Diff line change @@ -34,11 +34,23 @@ func main() {
34
34
35
35
country := parser .Parse ()
36
36
IPs := loader .Load (country )
37
+ tasks := make (chan string )
37
38
38
- for i := len ( IPs ) - 1 ; i >= 0 ; i -- {
39
+ for i := 0 ; i < 100 ; i ++ {
39
40
wg .Add (1 )
40
- go scanner .Scan (IPs [i ], & wg )
41
+ go func () {
42
+ for task := range tasks {
43
+ scanner .Scan (task )
44
+ }
45
+ wg .Done ()
46
+ }()
41
47
}
42
48
49
+ for i := len (IPs ) - 1 ; i >= 0 ; i -- {
50
+ tasks <- IPs [i ]
51
+ }
52
+
53
+ close (tasks )
54
+
43
55
wg .Wait ()
44
56
}
You can’t perform that action at this time.
0 commit comments