This commit is contained in:
Daniil Gentili 2017-12-28 13:12:58 +01:00
commit 27eb6c1a29
No known key found for this signature in database
GPG Key ID: 259900308520B573
4 changed files with 14 additions and 5 deletions

View File

@ -157,7 +157,9 @@ class Connection
case 'http':
case 'https':
$this->parsed = parse_url($ip);
if ($this->parsed['host'][0] === '[') $this->parsed['host'] = substr($this->parsed['host'], 1, -1);
if ($this->parsed['host'][0] === '[') {
$this->parsed['host'] = substr($this->parsed['host'], 1, -1);
}
$this->sock = new $proxy($ipv6 ? \AF_INET6 : \AF_INET, \SOCK_STREAM, getprotobyname($this->protocol === 'https' ? 'tls' : 'tcp'));
if ($has_proxy && $this->extra !== []) {
$this->sock->setExtra($this->extra);

View File

@ -100,7 +100,9 @@ class DataCenter
}
if ($this->settings[$dc_config_number]['protocol'] === 'http') {
if ($ipv6) $address = '['.$address.']';
if ($ipv6) {
$address = '['.$address.']';
}
$address = $this->settings[$dc_config_number]['protocol'].'://'.$address.'/api';
}
\danog\MadelineProto\Logger::log([sprintf(\danog\MadelineProto\Lang::$current_lang['dc_con_test_start'], $dc_number, $test, $ipv6, $this->settings[$dc_config_number]['protocol'])], \danog\MadelineProto\Logger::VERBOSE);

View File

@ -630,11 +630,14 @@ class MTProto
$socket->new_incoming = [];
}
}
public function is_http($datacenter) {
public function is_http($datacenter)
{
return in_array($this->datacenter->sockets[$datacenter]->protocol, ['http', 'https']);
}
public function close_and_reopen($datacenter) {
public function close_and_reopen($datacenter)
{
$this->datacenter->sockets[$datacenter]->close_and_reopen();
if ($this->is_http($datacenter)) {
$this->method_call('http_wait', ['max_wait' => 0, 'wait_after' => 0, 'max_delay' => 0], ['datacenter' => $datacenter]);

View File

@ -553,7 +553,9 @@ trait AuthKeyHandler
if ($res === true) {
\danog\MadelineProto\Logger::log(['Successfully binded temporary and permanent authorization keys, DC '.$datacenter], \danog\MadelineProto\Logger::NOTICE);
if ($this->is_http($datacenter)) $this->close_and_reopen($datacenter);
if ($this->is_http($datacenter)) {
$this->close_and_reopen($datacenter);
}
return true;
}