Skip to content

Commit

Permalink
Compatible with Python 3.11
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
Jonney authored Mar 27, 2023
1 parent 7c96730 commit c970092
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pproxy/proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit c970092

Please sign in to comment.