From c970092aba12ece06ca466a11c8c45492fc357a4 Mon Sep 17 00:00:00 2001 From: Jonney Date: Mon, 27 Mar 2023 19:58:03 +0800 Subject: [PATCH] Compatible with Python 3.11 In Python 3.11, asyncio.sslproto.SSLProtocol inherits from asyncio.protocols.BufferedProtocol. In SSLProtocol, data_received() is no longer used and has been replaced with get_buffer() and buffer_updated(). --- pproxy/proto.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pproxy/proto.py b/pproxy/proto.py index eb40287..a1bd1bb 100644 --- a/pproxy/proto.py +++ b/pproxy/proto.py @@ -616,12 +616,21 @@ def abort(self): self.close() ssl.connection_made(Transport()) async def channel(): + read_size=65536 + buffer=None + if hasattr(ssl,'get_buffer'): + buffer=ssl.get_buffer(read_size) try: while not reader.at_eof() and not ssl._app_transport._closed: - data = await reader.read(65536) + data = await reader.read(read_size) if not data: break - ssl.data_received(data) + if buffer!=None: + data_len=len(data) + buffer[:data_len]=data + ssl.buffer_updated(data_len) + else: + ssl.data_received(data) except Exception: pass finally: