使用方法:command [options] addr
options:
-p 使用指定协议,如:tcp、udp,默认为tcp
-c 使用指定cpu数量,默认为1
-t 使用指定线程数,默认为1(使用多线程扫描,速度会更快)
-d 扫描单个端口超时控制,单位:秒,默认为5秒
package main
import (
"fmt"
"net"
"time"
"sync"
"flag"
"os"
"runtime"
)
type PortScan struct {
timeOut time.Duration
protocol string
cores int
threads int
addr string
availablePort []int
wasteTime int64
rwLocker sync.RWMutex
}
var protocol = flag.String("p", "tcp", "Use the specified protocol")
var cores = flag.Int("c", 1, "Use the specified core number")
var threads = flag.Int("t", 0, "Use the specified thread number")
var timeout = flag.Int("d", 5, "Use the specifi