From d2839070d89f9fae613001d0730cd34b7946f98f Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sat, 24 Feb 2018 19:39:45 +0000 Subject: [PATCH] Improve management of media DCs and HTTP errors --- src/danog/MadelineProto/DataCenter.php | 3 +-- src/danog/MadelineProto/MTProtoTools/CallHandler.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/danog/MadelineProto/DataCenter.php b/src/danog/MadelineProto/DataCenter.php index 96aaff329..5d6cda7d1 100644 --- a/src/danog/MadelineProto/DataCenter.php +++ b/src/danog/MadelineProto/DataCenter.php @@ -68,7 +68,6 @@ class DataCenter $ipv6 = $this->settings[$dc_config_number]['ipv6'] ? 'ipv6' : 'ipv4'; if (!isset($this->dclist[$test][$ipv6][$dc_number]['ip_address'])) { unset($this->sockets[$dc_number]); - return false; } $address = $this->dclist[$test][$ipv6][$dc_number]['ip_address']; @@ -83,7 +82,7 @@ class DataCenter $this->settings[$dc_config_number]['protocol'] = 'obfuscated2'; } if (strpos($this->settings[$dc_config_number]['protocol'], 'https') === 0) { - $subdomain = $this->dclist['ssl_subdomains'][$dc_number]; + $subdomain = $this->dclist['ssl_subdomains'][preg_replace('/\D+/', '', $dc_number)]; $path = $this->settings[$dc_config_number]['test_mode'] ? 'apiw_test1' : 'apiw1'; $address = 'https://'.$subdomain.'.web.telegram.org/'.$path; $port = 443; diff --git a/src/danog/MadelineProto/MTProtoTools/CallHandler.php b/src/danog/MadelineProto/MTProtoTools/CallHandler.php index 7c922f474..eaf505913 100644 --- a/src/danog/MadelineProto/MTProtoTools/CallHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/CallHandler.php @@ -165,7 +165,7 @@ trait CallHandler $only_updates = $this->handle_messages($aargs['datacenter']); // This method receives data from the socket, and parses stuff } catch (\danog\MadelineProto\Exception $e) { - if ($e->getMessage() === 'I had to recreate the temporary authorization key') { + if ($e->getMessage() === 'I had to recreate the temporary authorization key' || $e->getCode() === 404) { continue 2; } \danog\MadelineProto\Logger::log(['An error getting response of method '.$method.': '.$e->getMessage().' in '.basename($e->getFile(), '.php').' on line '.$e->getLine().'. Retrying...'], \danog\MadelineProto\Logger::WARNING);