Closed engageub closed 1 year ago
Looks like the changes in the following file is throwing this error message. Looking at the difference in two lines for headers "Basic" keyword is missing in the headers for Proxy-Authorization.
v 2.5.0
req.Header.Add("Proxy-Authorization",
fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(auth))))
v 2.5.1
req.Header.Set("Proxy-Authorization", basicAuth(h.user, h.pass))
func basicAuth(username, password string) string {
auth := username + ":" + password
return base64.StdEncoding.EncodeToString([]byte(auth))
}
https://github.com/xjasonlyu/tun2socks/commit/8e20770bec3b8db4c49611bd4a712c3075da5cbc
https://github.com/xjasonlyu/tun2socks/compare/v2.5.0...v2.5.1 Thank you
Thanks! Would you like to submit a PR to fix this? 🤗
I have limited access to the resources and have not setup anything yet so far on this code. I just had a look at the code with the difference in the files from github. This requires lot of testing since there are other files in the code where changes have been made, so the functionality of them also needs to be tested just in case there is a dependency on this file directly or indirectly.
Thank you
No worries about the dependency or anything else.
Basically, there's only one-line code change required, from
req.Header.Set("Proxy-Authorization", basicAuth(h.user, h.pass))
to
req.Header.Set("Proxy-Authorization", fmt.Sprintf("Basic %s", basicAuth(h.user, h.pass)))
Yes, I think the return statement should be changed this way for basicAuth function. But you may have your own coding standards, so it can be written in different ways.
return "Basic " + base64.StdEncoding.EncodeToString([]byte(auth))
The basicAuth
function was copied from the go std net/http
package, so I think it's better to keep it untouched.
Anyway, a PR is always welcome!
I'm gonna close this issue. Reopen if this bug still exists.
Could you please draft a new release for this change to become available to packages and third-parties that do not build from source?
Thanks a lot in advance.
@blechschmidt no problem! just released a minor fixed version.
Awesome, thanks a lot!
Verify steps
Version
2.5.1
What OS are you seeing the problem on?
Linux
Description
After the recent docker update to v2.5.1 http authentication issues are seen while using http protocol with username and password. However socks5 protocol is working fine.
Switching back to v2.5.0 in docker, http proxies with username and password work fine.
Thank you
CLI or Config
Working Version with http username and password: xjasonlyu/tun2socks:v2.5.0 Buggy Version: xjasonlyu/tun2socks:v2.5.1
Logs
How to Reproduce
Register to traffmonetizer from https://github.com/engageub/InternetIncome and input your token below. If v.2.5.0 is used in the container version, it works fine without any Auth issues.