mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-29 21:03:45 +03:00
Address immutability issues on connect
This commit is contained in:
parent
f5f0c84553
commit
fe941cb940
|
@ -7,6 +7,7 @@ import platform
|
||||||
import time
|
import time
|
||||||
import typing
|
import typing
|
||||||
import ipaddress
|
import ipaddress
|
||||||
|
import dataclasses
|
||||||
|
|
||||||
from .. import version, __name__ as __base_name__, _tl
|
from .. import version, __name__ as __base_name__, _tl
|
||||||
from .._crypto import rsa
|
from .._crypto import rsa
|
||||||
|
@ -342,7 +343,7 @@ async def connect(self: 'TelegramClient') -> None:
|
||||||
return
|
return
|
||||||
|
|
||||||
if self._sender.auth_key.key != dc.auth:
|
if self._sender.auth_key.key != dc.auth:
|
||||||
dc.auth = self._sender.auth_key.key
|
dc = dataclasses.replace(dc, auth=self._sender.auth_key.key)
|
||||||
|
|
||||||
# Need to send invokeWithLayer for things to work out.
|
# Need to send invokeWithLayer for things to work out.
|
||||||
# Make the most out of this opportunity by also refreshing our state.
|
# Make the most out of this opportunity by also refreshing our state.
|
||||||
|
@ -359,11 +360,10 @@ async def connect(self: 'TelegramClient') -> None:
|
||||||
|
|
||||||
ip = int(ipaddress.ip_address(dc.ip_address))
|
ip = int(ipaddress.ip_address(dc.ip_address))
|
||||||
if dc.id in self._all_dcs:
|
if dc.id in self._all_dcs:
|
||||||
self._all_dcs[dc.id].port = dc.port
|
|
||||||
if dc.ipv6:
|
if dc.ipv6:
|
||||||
self._all_dcs[dc.id].ipv6 = ip
|
self._all_dcs[dc.id] = dataclasses.replace(self._all_dcs[dc.id], port=dc.port, ipv6=ip)
|
||||||
else:
|
else:
|
||||||
self._all_dcs[dc.id].ipv4 = ip
|
self._all_dcs[dc.id] = dataclasses.replace(self._all_dcs[dc.id], port=dc.port, ipv4=ip)
|
||||||
elif dc.ipv6:
|
elif dc.ipv6:
|
||||||
self._all_dcs[dc.id] = DataCenter(dc.id, None, ip, dc.port, b'')
|
self._all_dcs[dc.id] = DataCenter(dc.id, None, ip, dc.port, b'')
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user