From 4acdf2b40dd5ae4ebf1160cb7e3d8fe84d5e57b8 Mon Sep 17 00:00:00 2001 From: uoosef Date: Sun, 11 Feb 2024 18:08:37 +0330 Subject: [PATCH] added rtt threshold for scan --- app/app.go | 6 ++---- main.go | 3 ++- wiresocks/scanner.go | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/app.go b/app/app.go index 4faf6f9de..0966eb9b9 100644 --- a/app/app.go +++ b/app/app.go @@ -15,7 +15,7 @@ import ( "time" ) -func RunWarp(psiphonEnabled, gool, scan, verbose bool, country, bindAddress, endpoint, license string, ctx context.Context) error { +func RunWarp(psiphonEnabled, gool, scan, verbose bool, country, bindAddress, endpoint, license string, ctx context.Context, rtThreshold int) error { // check if user input is not correct if (psiphonEnabled && gool) || (!psiphonEnabled && country != "") { log.Println("Wrong combination of flags!") @@ -51,12 +51,10 @@ func RunWarp(psiphonEnabled, gool, scan, verbose bool, country, bindAddress, end if scan { var err error - endpoints, err = wiresocks.RunScan(&ctx) + endpoints, err = wiresocks.RunScan(&ctx, rtThreshold) if err != nil { return err } - log.Println("Cooling down please wait 5 seconds...") - time.Sleep(5 * time.Second) } if !psiphonEnabled && !gool { diff --git a/main.go b/main.go index 4cd85577b..40e27a18c 100644 --- a/main.go +++ b/main.go @@ -25,6 +25,7 @@ func main() { psiphonEnabled = flag.Bool("cfon", false, "enable psiphonEnabled over warp") gool = flag.Bool("gool", false, "enable warp gooling") scan = flag.Bool("scan", false, "enable warp scanner(experimental)") + rtt = flag.Int("rtt", 1000, "scanner rtt threshold, default 1000") ) flag.Usage = usage @@ -35,7 +36,7 @@ func main() { ctx, cancel := context.WithCancel(context.Background()) go func() { - err := app.RunWarp(*psiphonEnabled, *gool, *scan, *verbose, *country, *bindAddress, *endpoint, *license, ctx) + err := app.RunWarp(*psiphonEnabled, *gool, *scan, *verbose, *country, *bindAddress, *endpoint, *license, ctx, *rtt) if err != nil { log.Fatal(err) } diff --git a/wiresocks/scanner.go b/wiresocks/scanner.go index abe7ba254..d9010c6d9 100644 --- a/wiresocks/scanner.go +++ b/wiresocks/scanner.go @@ -25,7 +25,7 @@ func canConnectIPv6(remoteAddr string) bool { return true } -func RunScan(ctx *context.Context) (result []string, err error) { +func RunScan(ctx *context.Context, rtt int) (result []string, err error) { cfg, err := ini.Load("./primary/wgcf-profile.ini") if err != nil { log.Printf("Failed to read file: %v", err) @@ -45,7 +45,7 @@ func RunScan(ctx *context.Context) (result []string, err error) { ipscanner.WithWarpPeerPublicKey(publicKey), ipscanner.WithUseIPv6(canConnectIPv6("[2001:4860:4860::8888]:80")), ipscanner.WithUseIPv4(true), - ipscanner.WithMaxDesirableRTT(500), + ipscanner.WithMaxDesirableRTT(rtt), ipscanner.WithCidrList([]string{ "162.159.192.0/24", "162.159.193.0/24",