Initial sanitized code sync
This commit is contained in:
109
cmd/conntest/main.go
Normal file
109
cmd/conntest/main.go
Normal file
@@ -0,0 +1,109 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/proxy"
|
||||
)
|
||||
|
||||
func main() {
|
||||
proxyURL := "socks5://8uk59M1TIb-us-sid-testconn01:RabyyxxkRxXZ@us.nexip.cc:443"
|
||||
|
||||
parsed, _ := url.Parse(proxyURL)
|
||||
auth := &proxy.Auth{
|
||||
User: parsed.User.Username(),
|
||||
Password: "",
|
||||
}
|
||||
if p, ok := parsed.User.Password(); ok {
|
||||
auth.Password = p
|
||||
}
|
||||
|
||||
dialer, err := proxy.SOCKS5("tcp", parsed.Host, auth, proxy.Direct)
|
||||
if err != nil {
|
||||
fmt.Printf("SOCKS5 dialer error: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
targets := []string{
|
||||
"m.stripe.com:443",
|
||||
"api.stripe.com:443",
|
||||
"chatgpt.com:443",
|
||||
"auth.openai.com:443",
|
||||
"myip.ipip.net:80",
|
||||
}
|
||||
|
||||
fmt.Println("=== SOCKS5 proxy (us.nexip.cc:443) ===")
|
||||
for _, target := range targets {
|
||||
start := time.Now()
|
||||
conn, err := dialer.Dial("tcp", target)
|
||||
elapsed := time.Since(start)
|
||||
if err != nil {
|
||||
fmt.Printf("FAIL %-30s %v (%v)\n", target, err, elapsed.Round(time.Millisecond))
|
||||
} else {
|
||||
conn.Close()
|
||||
fmt.Printf("OK %-30s (%v)\n", target, elapsed.Round(time.Millisecond))
|
||||
}
|
||||
}
|
||||
|
||||
// Test multiple sessions to see if it's session-dependent
|
||||
fmt.Println("\n=== m.stripe.com with different sessions ===")
|
||||
sessions := []string{"sess001", "sess002", "sess003", "sess004", "sess005"}
|
||||
for _, sid := range sessions {
|
||||
pURL := fmt.Sprintf("socks5://8uk59M1TIb-us-sid-%s:RabyyxxkRxXZ@us.nexip.cc:443", sid)
|
||||
p, _ := url.Parse(pURL)
|
||||
a := &proxy.Auth{User: p.User.Username()}
|
||||
a.Password, _ = p.User.Password()
|
||||
d, err := proxy.SOCKS5("tcp", p.Host, a, proxy.Direct)
|
||||
if err != nil {
|
||||
fmt.Printf("FAIL session=%-10s dialer error: %v\n", sid, err)
|
||||
continue
|
||||
}
|
||||
start := time.Now()
|
||||
conn, err := d.Dial("tcp", "m.stripe.com:443")
|
||||
elapsed := time.Since(start)
|
||||
if err != nil {
|
||||
fmt.Printf("FAIL session=%-10s %v (%v)\n", sid, err, elapsed.Round(time.Millisecond))
|
||||
} else {
|
||||
conn.Close()
|
||||
fmt.Printf("OK session=%-10s (%v)\n", sid, elapsed.Round(time.Millisecond))
|
||||
}
|
||||
}
|
||||
|
||||
// Also test port 3010 for comparison
|
||||
fmt.Println("\n=== Port 3010 comparison (m.stripe.com) ===")
|
||||
p3010 := "socks5://8uk59M1TIb-us-sid-testport3010:RabyyxxkRxXZ@us.nexip.cc:3010"
|
||||
p2, _ := url.Parse(p3010)
|
||||
a2 := &proxy.Auth{User: p2.User.Username()}
|
||||
a2.Password, _ = p2.User.Password()
|
||||
d2, err := proxy.SOCKS5("tcp", p2.Host, a2, proxy.Direct)
|
||||
if err != nil {
|
||||
fmt.Printf("FAIL port 3010 dialer error: %v\n", err)
|
||||
} else {
|
||||
start := time.Now()
|
||||
conn, err := d2.Dial("tcp", "m.stripe.com:443")
|
||||
elapsed := time.Since(start)
|
||||
if err != nil {
|
||||
fmt.Printf("FAIL port=3010 %v (%v)\n", err, elapsed.Round(time.Millisecond))
|
||||
} else {
|
||||
conn.Close()
|
||||
fmt.Printf("OK port=3010 (%v)\n", elapsed.Round(time.Millisecond))
|
||||
}
|
||||
}
|
||||
|
||||
// Direct connection (no proxy)
|
||||
fmt.Println("\n=== Direct (no proxy) ===")
|
||||
for _, target := range []string{"m.stripe.com:443", "api.stripe.com:443"} {
|
||||
start := time.Now()
|
||||
conn, err := net.DialTimeout("tcp", target, 10*time.Second)
|
||||
elapsed := time.Since(start)
|
||||
if err != nil {
|
||||
fmt.Printf("FAIL %-30s %v (%v)\n", target, err, elapsed.Round(time.Millisecond))
|
||||
} else {
|
||||
conn.Close()
|
||||
fmt.Printf("OK %-30s (%v)\n", target, elapsed.Round(time.Millisecond))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user