mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-18 13:34:54 +00:00
Make TCPAbridged async
This commit is contained in:
parent
a28ab0e8a8
commit
ee06907bda
@ -27,30 +27,30 @@ class TCPAbridged(TCP):
|
|||||||
def __init__(self, ipv6: bool, proxy: dict):
|
def __init__(self, ipv6: bool, proxy: dict):
|
||||||
super().__init__(ipv6, proxy)
|
super().__init__(ipv6, proxy)
|
||||||
|
|
||||||
def connect(self, address: tuple):
|
async def connect(self, address: tuple):
|
||||||
super().connect(address)
|
await super().connect(address)
|
||||||
super().sendall(b"\xef")
|
await super().send(b"\xef")
|
||||||
|
|
||||||
def sendall(self, data: bytes, *args):
|
async def send(self, data: bytes, *args):
|
||||||
length = len(data) // 4
|
length = len(data) // 4
|
||||||
|
|
||||||
super().sendall(
|
await super().send(
|
||||||
(bytes([length])
|
(bytes([length])
|
||||||
if length <= 126
|
if length <= 126
|
||||||
else b"\x7f" + length.to_bytes(3, "little"))
|
else b"\x7f" + length.to_bytes(3, "little"))
|
||||||
+ data
|
+ data
|
||||||
)
|
)
|
||||||
|
|
||||||
def recvall(self, length: int = 0) -> bytes or None:
|
async def recv(self, length: int = 0) -> bytes or None:
|
||||||
length = super().recvall(1)
|
length = await super().recv(1)
|
||||||
|
|
||||||
if length is None:
|
if length is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if length == b"\x7f":
|
if length == b"\x7f":
|
||||||
length = super().recvall(3)
|
length = await super().recv(3)
|
||||||
|
|
||||||
if length is None:
|
if length is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return super().recvall(int.from_bytes(length, "little") * 4)
|
return await super().recv(int.from_bytes(length, "little") * 4)
|
||||||
|
Loading…
Reference in New Issue
Block a user