mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 21:10:29 +00:00
Improve TakeoutClient proxy and takeout functionality (#1106)
This commit is contained in:

committed by
Lonami

parent
274fa72a8c
commit
9a98d41a2c
@@ -5,12 +5,16 @@ import struct
|
||||
from .memory import MemorySession
|
||||
from ..crypto import AuthKey
|
||||
|
||||
_STRUCT_PREFORMAT = '>B{}sH256s'
|
||||
|
||||
CURRENT_VERSION = '1'
|
||||
|
||||
|
||||
class StringSession(MemorySession):
|
||||
"""
|
||||
This minimal session file can be easily saved and loaded as a string.
|
||||
This session file can be easily saved and loaded as a string. According
|
||||
to the initial design, it contains only the data that is necessary for
|
||||
successful connection and authentication, so takeout ID is not stored.
|
||||
|
||||
It is thought to be used where you don't want to create any on-disk
|
||||
files but would still like to be able to save and load existing sessions
|
||||
@@ -33,7 +37,7 @@ class StringSession(MemorySession):
|
||||
string = string[1:]
|
||||
ip_len = 4 if len(string) == 352 else 16
|
||||
self._dc_id, ip, self._port, key = struct.unpack(
|
||||
'>B{}sH256s'.format(ip_len), StringSession.decode(string))
|
||||
_STRUCT_PREFORMAT.format(ip_len), StringSession.decode(string))
|
||||
|
||||
self._server_address = ipaddress.ip_address(ip).compressed
|
||||
if any(key):
|
||||
@@ -45,7 +49,7 @@ class StringSession(MemorySession):
|
||||
|
||||
ip = ipaddress.ip_address(self._server_address).packed
|
||||
return CURRENT_VERSION + StringSession.encode(struct.pack(
|
||||
'>B{}sH256s'.format(len(ip)),
|
||||
_STRUCT_PREFORMAT.format(len(ip)),
|
||||
self._dc_id,
|
||||
ip,
|
||||
self._port,
|
||||
|
Reference in New Issue
Block a user