Skip to content

Commit 09beec4

Browse files
Add files via upload
1 parent 376568e commit 09beec4

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

core_engine/main.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,26 @@ func testProxy(listenIP string, port int) (int64, string) {
117117
timeout := 8 * time.Second
118118
dialer, err := proxy.SOCKS5("tcp", fmt.Sprintf("%s:%d", listenIP, port), nil, proxy.Direct)
119119
if err != nil { return -1, fmt.Sprintf("failed_dialer: %v", err) }
120-
httpClient := &http.Client{ Transport: &http.Transport{DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { return dialer.Dial(network, addr) }}, Timeout: timeout}
120+
121+
httpClient := &http.Client{
122+
Transport: &http.Transport{
123+
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
124+
return dialer.Dial(network, addr)
125+
},
126+
},
127+
Timeout: timeout,
128+
}
129+
121130
start := time.Now()
122131
resp, err := httpClient.Get(targetURL)
123-
if err != nil { return -1, fmt.Sprintf("failed_http: %v", err) }
132+
if err != nil {
133+
return -1, fmt.Sprintf("failed_http: %v", err)
134+
}
124135
defer resp.Body.Close()
125-
if resp.StatusCode != http.StatusNoContent { return -1, fmt.Sprintf("bad_status_%d", resp.StatusCode) }
136+
137+
if resp.StatusCode != http.StatusNoContent {
138+
return -1, fmt.Sprintf("bad_status_%d", resp.StatusCode)
139+
}
140+
126141
return time.Since(start).Milliseconds(), "success"
127142
}

0 commit comments

Comments
 (0)