Skip to content

Commit ac87924

Browse files
committed
fix socks5 issue
1 parent 73d7fbd commit ac87924

2 files changed

Lines changed: 10 additions & 4 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.3.8"
2+
__version__ = "2.3.9"
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: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,20 @@ async def parse(self, reader, writer, auth, authtable, **kw):
198198
writer.write(b'\x05\x00')
199199
if auth:
200200
authtable.set_authed()
201-
assert (await reader.read_n(3)) == b'\x05\x01\x00', 'Unknown SOCKS protocol'
201+
assert await reader.read_n(3) == b'\x05\x01\x00', 'Unknown SOCKS protocol'
202202
header = await reader.read_n(1)
203203
host_name, port, data = await socks_address_stream(reader, header[0])
204204
writer.write(b'\x05\x00\x00' + header + data)
205205
return host_name, port
206206
async def connect(self, reader_remote, writer_remote, rauth, host_name, port, **kw):
207-
writer_remote.write((b'\x05\x01\x02\x01' + b''.join(packstr(i) for i in rauth.split(b':', 1)) if rauth else b'\x05\x01\x00') + b'\x05\x01\x00\x03' + packstr(host_name.encode()) + port.to_bytes(2, 'big'))
208-
await reader_remote.read_until(b'\x00\x05\x00\x00')
207+
if rauth:
208+
writer_remote.write(b'\x05\x01\x02\x01' + b''.join(packstr(i) for i in rauth.split(b':', 1)))
209+
assert await reader_remote.read_n(2) == b'\x01\x00'
210+
else:
211+
writer_remote.write(b'\x05\x01\x00')
212+
assert await reader_remote.read_n(2) == b'\x05\x00'
213+
writer_remote.write(b'\x05\x01\x00\x03' + packstr(host_name.encode()) + port.to_bytes(2, 'big'))
214+
assert await reader_remote.read_n(3) == b'\x05\x00\x00'
209215
header = (await reader_remote.read_n(1))[0]
210216
await reader_remote.read_n(6 if header == 1 else (18 if header == 4 else (await reader_remote.read_n(1))[0]+2))
211217
def udp_parse(self, data, **kw):

0 commit comments

Comments
 (0)