Skip to content

Commit 0aa4e4c

Browse files
committed
fix ipv6 http issue
1 parent 9eac7cb commit 0aa4e4c

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

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.3.4"
2+
__version__ = "2.3.5"
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/proto.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,16 @@ async def parse(self, header, reader, writer, auth, authtable, httpget=None, **k
248248
raise Exception('Unauthorized HTTP')
249249
authtable.set_authed()
250250
if method == 'CONNECT':
251-
host_name, port = path.split(':', 1)
251+
host_name, port = path.rsplit(':', 1)
252252
port = int(port)
253253
return host_name, port, f'{ver} 200 OK\r\nConnection: close\r\n\r\n'.encode()
254254
else:
255255
url = urllib.parse.urlparse(path)
256-
host_name = url.hostname
257-
port = url.port or 80
256+
if ':' in url.netloc:
257+
host_name, port = url.netloc.rsplit(':', 1)
258+
port = int(port)
259+
else:
260+
host_name, port = url.netloc, 80
258261
newpath = url._replace(netloc='', scheme='').geturl()
259262
return host_name, port, b'', f'{method} {newpath} {ver}\r\n{lines}\r\n\r\n'.encode()
260263
async def connect(self, reader_remote, writer_remote, rauth, host_name, port, myhost, **kw):

0 commit comments

Comments
 (0)