11package scanner
22
3- import "C"
43import (
54 config "CFScanner/configuration"
65 "CFScanner/logger"
76 "CFScanner/speedtest"
87 "CFScanner/utils"
98 "CFScanner/vpn"
109 "fmt"
11- "github.com/eiannone/keyboard"
1210 "math"
1311 "os"
1412 "runtime"
1513 "strconv"
1614 "strings"
1715 "sync"
1816 "time"
17+
18+ "github.com/eiannone/keyboard"
1919)
2020
2121var results [][]string
2727 uploadLatency float64
2828)
2929
30- type Result struct {
30+ type ScanResult struct {
3131 IP string
3232 Download struct {
3333 Speed []float64
4646)
4747
4848// const WorkerCount = 48
49- func scanner (ip string , Config config.Configuration , Worker config.Worker ) * Result {
49+ func scanner (ip string , Config config.Configuration , Worker config.Worker ) * ScanResult {
5050
51- result := & Result {
51+ result := & ScanResult {
5252 IP : ip ,
5353 }
5454
@@ -67,11 +67,7 @@ func scanner(ip string, Config config.Configuration, Worker config.Worker) *Resu
6767 proxies = vpn .ProxyBind (listen , port )
6868
6969 // wait for port
70- waitPort := utils .WaitForPort (listen , port , time .Duration (5 ))
71-
72- if waitPort != nil {
73- fmt .Errorf (waitPort .Error ())
74- }
70+ utils .WaitForPort (listen , port , time .Duration (5 ))
7571
7672 var err error
7773 process = vpn .XRayInstance (xrayConfigPath )
@@ -142,7 +138,7 @@ func scanner(ip string, Config config.Configuration, Worker config.Worker) *Resu
142138 return result
143139}
144140
145- func uploader (ip string , Upload * config.Upload , proxies map [string ]string , result * Result ) (* Result , bool ) {
141+ func uploader (ip string , Upload * config.Upload , proxies map [string ]string , result * ScanResult ) (* ScanResult , bool ) {
146142 var err error
147143 nBytes := Upload .MinUlSpeed * 1000 * Upload .MaxUlTime
148144 uploadSpeed , uploadLatency , err = speedtest .UploadSpeedTest (int (nBytes ), proxies ,
@@ -188,7 +184,7 @@ func uploader(ip string, Upload *config.Upload, proxies map[string]string, resul
188184 return nil , false
189185}
190186
191- func downloader (ip string , Download * config.Download , proxies map [string ]string , result * Result ) (* Result , bool ) {
187+ func downloader (ip string , Download * config.Download , proxies map [string ]string , result * ScanResult ) (* ScanResult , bool ) {
192188 nBytes := Download .MinDlSpeed * 1000 * Download .MaxDlTime
193189 var err error
194190
@@ -312,7 +308,7 @@ func scan(Config *config.Configuration, worker *config.Worker, ip string) {
312308 MeanUploadLatency : meanUploadLatency ,
313309 }
314310 default :
315- cause := fmt .Errorf ("Invalid writer type: %s\n " , Config .Config .Writer )
311+ cause := fmt .Errorf ("invalid writer type: %s" , Config .Config .Writer )
316312 ld := logger.ScannerManage {
317313 IP : "" ,
318314 Status : logger .ErrorStatus ,
0 commit comments