Skip to content

Commit 2efed7e

Browse files
committed
fix ipv6 issue
1 parent 644b20c commit 2efed7e

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

pproxy/__doc__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__title__ = "pproxy"
2-
__version__ = "2.0.7"
2+
__version__ = "2.0.8"
33
__license__ = "MIT"
44
__description__ = "Proxy server that can tunnel among remote servers by regex rules."
55
__keywords__ = "proxy socks http shadowsocks shadowsocksr ssr redirect pf tunnel cipher ssl udp"

pproxy/server.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,16 @@ async def open_connection(self, host, port, local_addr, lbind):
321321
if host == 'tunnel':
322322
raise Exception('Unknown tunnel endpoint')
323323
local_addr = local_addr if lbind == 'in' else (lbind, 0) if lbind else None
324-
wait = asyncio.open_connection(host=host, port=port, local_addr=local_addr)
324+
family = 0 if local_addr is None else 30 if ':' in local_addr[0] else 2
325+
wait = asyncio.open_connection(host=host, port=port, local_addr=local_addr, family=family)
325326
elif self.backward:
326327
wait = self.backward.open_connection()
327328
elif self.unix:
328329
wait = asyncio.open_unix_connection(path=self.bind, ssl=self.sslclient, server_hostname='' if self.sslclient else None)
329330
else:
330331
local_addr = local_addr if self.lbind == 'in' else (self.lbind, 0) if self.lbind else None
331-
wait = asyncio.open_connection(host=self.host_name, port=self.port, ssl=self.sslclient, local_addr=local_addr)
332+
family = 0 if local_addr is None else 30 if ':' in local_addr[0] else 2
333+
wait = asyncio.open_connection(host=self.host_name, port=self.port, ssl=self.sslclient, local_addr=local_addr, family=family)
332334
reader, writer = await asyncio.wait_for(wait, timeout=SOCKET_TIMEOUT)
333335
except Exception as ex:
334336
if self.reuse:

0 commit comments

Comments
 (0)