Skip to content

Commit b947d05

Browse files
committed
add backward auth
1 parent daa1808 commit b947d05

2 files changed

Lines changed: 4 additions & 2 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.0"
2+
__version__ = "2.3.1"
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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ async def server_run(self, handler):
221221
wait = asyncio.open_connection(host=self.uri.host_name, port=self.uri.port, local_addr=(self.uri.lbind, 0) if self.uri.lbind else None)
222222
try:
223223
reader, writer = await asyncio.wait_for(wait, timeout=SOCKET_TIMEOUT)
224+
writer.write(self.uri.auth)
224225
self.writer = writer
225226
try:
226227
data = await reader.read_n(1)
@@ -242,7 +243,8 @@ async def server_run(self, handler):
242243
errwait = min(errwait*1.3 + 0.1, 30)
243244
def client_run(self, args):
244245
async def handler(reader, writer):
245-
await self.conn.put((reader, writer))
246+
if not self.uri.auth or self.uri.auth == (await reader.read_n(len(self.uri.auth))):
247+
await self.conn.put((reader, writer))
246248
if self.uri.unix:
247249
return asyncio.start_unix_server(handler, path=self.uri.bind)
248250
else:

0 commit comments

Comments
 (0)