testHTTPTraffic tests that HTTP requests work through the proxy
()
| 119 | |
| 120 | // testHTTPTraffic tests that HTTP requests work through the proxy |
| 121 | func testHTTPTraffic() error { |
| 122 | // Set up HTTP client with SOCKS5 proxy |
| 123 | proxyURL, _ := url.Parse("socks5://localhost:8080") |
| 124 | client := &http.Client{ |
| 125 | Transport: &http.Transport{ |
| 126 | Proxy: http.ProxyURL(proxyURL), |
| 127 | }, |
| 128 | Timeout: 30 * time.Second, |
| 129 | } |
| 130 | |
| 131 | // Test HTTP request |
| 132 | resp, err := client.Get("http://httpbin.org/ip") |
| 133 | if err != nil { |
| 134 | return err |
| 135 | } |
| 136 | defer resp.Body.Close() |
| 137 | |
| 138 | // Read response to make sure it works |
| 139 | _, err = io.ReadAll(resp.Body) |
| 140 | if err != nil { |
| 141 | return err |
| 142 | } |
| 143 | |
| 144 | if resp.StatusCode != 200 { |
| 145 | return http.ErrNotSupported |
| 146 | } |
| 147 | |
| 148 | return nil |
| 149 | } |
no outgoing calls
no test coverage detected