librespeed / speedtest-cli

Command line client for LibreSpeed
GNU Lesser General Public License v3.0
485 stars 59 forks source link

speedtest-cli and proxies #49

Open servidge opened 2 years ago

servidge commented 2 years ago

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 commented 2 years ago

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("HTTPPROXY")) 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.