mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-03 13:14:31 +03:00
Fix CDN downloads not always calling GetCdnConfigRequest (#222)
On previous tests, Telegram didn't return information about CDNs on the initial GetConfigRequest. However, it may do so, and it's necessary to call GetCdnConfigRequest even when a second call to GetConfigRequest isn't required.
This commit is contained in:
parent
d5cd59de8a
commit
2924912931
|
@ -213,6 +213,11 @@ class TelegramBareClient:
|
||||||
'Stabilise a successful initial connection first.')
|
'Stabilise a successful initial connection first.')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if cdn:
|
||||||
|
# Ensure we have the latest keys for the CDNs
|
||||||
|
for pk in self(GetCdnConfigRequest()).public_keys:
|
||||||
|
rsa.add_key(pk.public_key)
|
||||||
|
|
||||||
return next(
|
return next(
|
||||||
dc for dc in self.dc_options if dc.id == dc_id and
|
dc for dc in self.dc_options if dc.id == dc_id and
|
||||||
bool(dc.ipv6) == ipv6 and bool(dc.cdn) == cdn
|
bool(dc.ipv6) == ipv6 and bool(dc.cdn) == cdn
|
||||||
|
@ -221,9 +226,7 @@ class TelegramBareClient:
|
||||||
if not cdn:
|
if not cdn:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
for pk in self(GetCdnConfigRequest()).public_keys:
|
# New configuration, perhaps a new CDN was added?
|
||||||
rsa.add_key(pk.public_key)
|
|
||||||
|
|
||||||
self.dc_options = self(GetConfigRequest()).dc_options
|
self.dc_options = self(GetConfigRequest()).dc_options
|
||||||
return self._get_dc(dc_id, ipv6=ipv6, cdn=cdn)
|
return self._get_dc(dc_id, ipv6=ipv6, cdn=cdn)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user