Hi , I am new to golang and joined this forum today.
I was writing the TCP scanner and just want to know is there anyway to speed up the script like really fast?
Now , it is so slow .
Below is my script
func main() {
var hostName string
var concurrency int
logo()
flag.StringVar(&hostName, "i" , "" , "Run with your hostname or IP")
flag.IntVar(&concurrency , "c" , 50 , "Set the concurrency for greater speed")
flag.Parse()
var wg sync.WaitGroup
for i:=0; i<= concurrency; i++ {
wg.Add(1)
go func () {
Fullscan(hostName)
wg.Done()
}()
wg.Wait()
}
}
func Fullscan(hostName string) {
for i := 1; i <= 65535; i++ {
address := hostName + ":" + strconv.Itoa(i)
conn, err := net.DialTimeout("tcp" , address , 60*time.Second)
if err == nil {
fmt.Println("Port" , strconv.Itoa(i)+"/open")
conn.Close()
}
}
}