@@ -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