speedtest-cli icon indicating copy to clipboard operation
speedtest-cli copied to clipboard

speedtest-cli and proxies

Open servidge opened this issue 3 years ago • 1 comments

Is there a reliable way to use speedtest-cli with proxies? Under certain circumstances the environment parameter http_proxy seems to be taken into account on different operating systems if this is configured. Tested it mainly on windows. but even there on different systems there were different test results with the same exe. However, the actual download of the server list or the transmission of the statistics at the end (--share) does not seem to run via the proxy at all. Maybe someone has a solution before I start tinkering.

servidge avatar Feb 22 '22 20:02 servidge

Seems only partially complicated with my knowledge of go. But that is rather ephemeral, if i be honest. The following botch works but the code is not suitable for production in my mind. I tested this in my fork. It works but it's not yet worthy of a pull request.

Insert the transport.Proxy = nil at line 158 in speedtest.go and no proxy is used at all. That's where the easy part ends. More or less. Insert the following at the same line and the HTTP_PROXY environment variable will be respected except the --share part. proxyUrl, _ := url.Parse(os.Getenv("HTTP_PROXY")) transport.Proxy = http.ProxyURL(proxyUrl) After that, at least the speedtest server list download and the test itself are transported via the proxy. Something similar could be realized with a start parameter like --proxy-http. But at the end the --share still needs some tinkering.

servidge avatar Mar 22 '22 22:03 servidge