Skip to content

Commit

Permalink
added rtt threshold for scan
Browse files Browse the repository at this point in the history
  • Loading branch information
uoosef committed Feb 11, 2024
1 parent 9f90b73 commit 4acdf2b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
6 changes: 2 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions wiresocks/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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",
Expand Down

0 comments on commit 4acdf2b

Please sign in to comment.