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

ipv6 #159

Open
issasalman opened this issue Feb 17, 2022 · 2 comments
Open

ipv6 #159

issasalman opened this issue Feb 17, 2022 · 2 comments

Comments

@issasalman
Copy link

issasalman commented Feb 17, 2022

I cant use proxy ipv6 with pysocks
Please I need to fix the code to use ipv6

@sunshe35
Copy link

I find the way to solve ipv6 socks5 proxy.
refer to:
woo200/sockslib#1 (comment)

The author of sockslib was very kind and helped me solve this problem.

@TrueWatcher
Copy link

TrueWatcher commented Jun 19, 2024

I'm trying to send ipv6 DNS requests to yggstack(https://github.com/yggdrasil-network/yggstack) 127.0.0.1:1080.

I've just discovered that PySocks's socket works fine for ipv6 tcp, if created without arguments:

s = socks.socksocket()
s.set_proxy(socks.SOCKS5, socksServer, socksPort)
s.connect(("300:6223::53", 53))
result = dns.query.tcp(qm, where = "300:6223::53", timeout = 15, sock = s)

but gives errors if created with (socket.AF_INET6, socket.SOCK_STREAM)

More than that, I managed to make PySocks work for ipv6 udp:

s = socks.socksocket(socket.AF_INET6,  socket.SOCK_DGRAM)
s.set_proxy(socks.SOCKS5, socksServer, socksPort)
result = dns.query.udp(qm, where = "300:6223::53", port = 53, timeout = 15, sock = s)

it's as simple as debugging and patching the library's socks.py:

345c345
<         _, port = self.getsockname()
---
>         _, port = self.getsockname()[0:2]
346a347
>         if ':' in  _ :  dst = ('::', port)
549c550
<         host, port = addr
---
>         host, port = addr[0:2]

sockslib(https://github.com/woo200/sockslib) also worked for me with ipv6 tcp, but I failed to make it work with udp (both ipv6 and ipv4)

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

3 participants