Skip to content

Commit 78a768f

Browse files
committed
Make TCPAbridgedO async
1 parent 1bf0d93 commit 78a768f

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

pyrogram/connection/transport/tcp/tcp_abridged_o.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def __init__(self, ipv6: bool, proxy: dict):
3434
self.encrypt = None
3535
self.decrypt = None
3636

37-
def connect(self, address: tuple):
38-
super().connect(address)
37+
async def connect(self, address: tuple):
38+
await super().connect(address)
3939

4040
while True:
4141
nonce = bytearray(os.urandom(64))
@@ -53,12 +53,12 @@ def connect(self, address: tuple):
5353

5454
nonce[56:64] = AES.ctr256_encrypt(nonce, *self.encrypt)[56:64]
5555

56-
super().sendall(nonce)
56+
await super().send(nonce)
5757

58-
def sendall(self, data: bytes, *args):
58+
async def send(self, data: bytes, *args):
5959
length = len(data) // 4
6060

61-
super().sendall(
61+
await super().send(
6262
AES.ctr256_encrypt(
6363
(bytes([length])
6464
if length <= 126
@@ -68,23 +68,23 @@ def sendall(self, data: bytes, *args):
6868
)
6969
)
7070

71-
def recvall(self, length: int = 0) -> bytes or None:
72-
length = super().recvall(1)
71+
async def recv(self, length: int = 0) -> bytes or None:
72+
length = await super().recv(1)
7373

7474
if length is None:
7575
return None
7676

7777
length = AES.ctr256_decrypt(length, *self.decrypt)
7878

7979
if length == b"\x7f":
80-
length = super().recvall(3)
80+
length = await super().recv(3)
8181

8282
if length is None:
8383
return None
8484

8585
length = AES.ctr256_decrypt(length, *self.decrypt)
8686

87-
data = super().recvall(int.from_bytes(length, "little") * 4)
87+
data = await super().recv(int.from_bytes(length, "little") * 4)
8888

8989
if data is None:
9090
return None

0 commit comments

Comments
 (0)