mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-07-13 17:42:29 +03:00
Implement reset method in transport classes and add logging for state resets
This commit is contained in:
parent
602bb6381a
commit
05af28d5e1
|
@ -15,6 +15,10 @@ class Transport(ABC):
|
|||
def unpack(self, input: bytes | bytearray | memoryview, output: bytearray) -> int:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def reset(self):
|
||||
pass
|
||||
|
||||
|
||||
class MissingBytesError(ValueError):
|
||||
def __init__(self, *, expected: int, got: int) -> None:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import logging
|
||||
import struct
|
||||
|
||||
from .abcs import BadStatusError, MissingBytesError, OutFn, Transport
|
||||
|
@ -60,3 +61,7 @@ class Abridged(Transport):
|
|||
|
||||
output += memoryview(input)[header_len : header_len + length]
|
||||
return header_len + length
|
||||
|
||||
def reset(self):
|
||||
logging.info("Resetting sending of header in abridged transport")
|
||||
self._init = False
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import logging
|
||||
import struct
|
||||
from zlib import crc32
|
||||
|
||||
|
@ -61,3 +62,8 @@ class Full(Transport):
|
|||
self._recv_seq += 1
|
||||
output += memoryview(input)[8 : length - 4]
|
||||
return length
|
||||
|
||||
def reset(self):
|
||||
logging.info("Resetting recv and send seqs in full transport")
|
||||
self._send_seq = 0
|
||||
self._recv_seq = 0
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import logging
|
||||
import struct
|
||||
|
||||
from .abcs import BadStatusError, MissingBytesError, OutFn, Transport
|
||||
|
@ -52,3 +53,7 @@ class Intermediate(Transport):
|
|||
|
||||
output += memoryview(input)[4 : 4 + length]
|
||||
return length + 4
|
||||
|
||||
def reset(self):
|
||||
logging.info("Resetting sending of header in intermediate transport")
|
||||
self._init = False
|
||||
|
|
Loading…
Reference in New Issue
Block a user