mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-26 21:21:53 +08:00
flags to struct
This commit is contained in:
+8
-8
@@ -15,10 +15,10 @@ type Addr struct {
|
||||
port int
|
||||
}
|
||||
|
||||
func PortScan(hostslist []string, ports string, timeout int64) []string {
|
||||
func PortScan(hostslist []string, ports string, flags common.Flags) []string {
|
||||
var AliveAddress []string
|
||||
probePorts := common.ParsePort(ports)
|
||||
noPorts := common.ParsePort(common.NoPorts)
|
||||
noPorts := common.ParsePort(flags.NoPorts)
|
||||
if len(noPorts) > 0 {
|
||||
temp := map[int]struct{}{}
|
||||
for _, port := range probePorts {
|
||||
@@ -36,7 +36,7 @@ func PortScan(hostslist []string, ports string, timeout int64) []string {
|
||||
probePorts = newDatas
|
||||
sort.Ints(probePorts)
|
||||
}
|
||||
workers := common.Threads
|
||||
workers := flags.Threads
|
||||
Addrs := make(chan Addr, len(hostslist)*len(probePorts))
|
||||
results := make(chan string, len(hostslist)*len(probePorts))
|
||||
var wg sync.WaitGroup
|
||||
@@ -53,7 +53,7 @@ func PortScan(hostslist []string, ports string, timeout int64) []string {
|
||||
for i := 0; i < workers; i++ {
|
||||
go func() {
|
||||
for addr := range Addrs {
|
||||
PortConnect(addr, results, timeout, &wg)
|
||||
PortConnect(addr, common.Socks5{Address: flags.Socks5Proxy}, results, flags.Timeout, &wg)
|
||||
wg.Done()
|
||||
}
|
||||
}()
|
||||
@@ -75,9 +75,9 @@ func PortScan(hostslist []string, ports string, timeout int64) []string {
|
||||
return AliveAddress
|
||||
}
|
||||
|
||||
func PortConnect(addr Addr, respondingHosts chan<- string, adjustedTimeout int64, wg *sync.WaitGroup) {
|
||||
func PortConnect(addr Addr, socks5Proxy common.Socks5, respondingHosts chan<- string, adjustedTimeout int64, wg *sync.WaitGroup) {
|
||||
host, port := addr.ip, addr.port
|
||||
conn, err := common.WrapperTcpWithTimeout("tcp4", fmt.Sprintf("%s:%v", host, port), time.Duration(adjustedTimeout)*time.Second)
|
||||
conn, err := common.WrapperTcpWithTimeout("tcp4", fmt.Sprintf("%s:%v", host, port), socks5Proxy, time.Duration(adjustedTimeout)*time.Second)
|
||||
defer func() {
|
||||
if conn != nil {
|
||||
conn.Close()
|
||||
@@ -92,9 +92,9 @@ func PortConnect(addr Addr, respondingHosts chan<- string, adjustedTimeout int64
|
||||
}
|
||||
}
|
||||
|
||||
func NoPortScan(hostslist []string, ports string) (AliveAddress []string) {
|
||||
func NoPortScan(hostslist []string, ports string, flags common.Flags) (AliveAddress []string) {
|
||||
probePorts := common.ParsePort(ports)
|
||||
noPorts := common.ParsePort(common.NoPorts)
|
||||
noPorts := common.ParsePort(flags.NoPorts)
|
||||
if len(noPorts) > 0 {
|
||||
temp := map[int]struct{}{}
|
||||
for _, port := range probePorts {
|
||||
|
||||
Reference in New Issue
Block a user