Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pysocks is ignoring the relay host provided by the socks proxy #172

Open
mvanholsteijn opened this issue Nov 17, 2024 · 2 comments
Open

Comments

@mvanholsteijn
Copy link

mvanholsteijn commented Nov 17, 2024

We have 3 socks proxies behind a load balancer for HA purposes. It works fine for TCP proxy requests, but fails for UDP proxy request. The socks proxy returns the correct IP address and port for the UDP proxy port, but PySocks overrides the hostname with the hostname of the loadbalancer.

PySocks/socks.py

Lines 355 to 358 in 91dcdf0

# The relay is most likely on the same host as the SOCKS proxy,
# but some proxies return a private IP address (10.x.y.z)
host, _ = proxy
_, port = relay

The comment suggests this is intentional, but the SOCKS5 proxy is allowed to return a different IP address to bind to, so the fix in the client code hides a misconfiguration in the SOCKS proxy.

@vadmium
Copy link

vadmium commented Nov 17, 2024

That sounds like my fault: commit 2f4fb3b. I haven’t used this library for a long time, but I suspect you are right that I was working around a misconfiguration (or misuse?) of a publicly accessible proxy.

Maybe it would be cleaner to undo that commit, or add an option to opt in to the overriding.

@mvanholsteijn
Copy link
Author

mvanholsteijn commented Nov 17, 2024

I was looking at adding it as an option, but i think we would to need extend the set_proxy() method with an extra parameter, which will propagate to set_default_proxy().

I would suggest applying the KISS principle and rollback the commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants