Applied fixes from StyleCI
This commit is contained in:
parent
f331931365
commit
f27a79561f
@ -17,55 +17,65 @@ namespace danog\MadelineProto;
|
||||
*/
|
||||
class DataCenter extends Tools
|
||||
{
|
||||
public function __construct($dclist, $settings) {
|
||||
public function __construct($dclist, $settings)
|
||||
{
|
||||
$this->dclist = $dclist;
|
||||
$this->settings = $settings;
|
||||
if (isset($this->settings["all"])) {
|
||||
if (isset($this->settings['all'])) {
|
||||
foreach ($this->range(1, 6) as $n) {
|
||||
$this->settings[$n] = $this->settings["all"];
|
||||
$this->settings[$n] = $this->settings['all'];
|
||||
}
|
||||
unset($this->settings["all"]);
|
||||
unset($this->settings['all']);
|
||||
}
|
||||
foreach ($this->range(1, 6) as $n) {
|
||||
if (!isset($this->settings[$n])) {
|
||||
$this->settings[$n] = [
|
||||
'protocol' => 'tcp_full',
|
||||
'port' => '443',
|
||||
'test_mode' => true
|
||||
'protocol' => 'tcp_full',
|
||||
'port' => '443',
|
||||
'test_mode' => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
$this->connect(2);
|
||||
}
|
||||
public function connnect($dc_number, $settings = []) {
|
||||
|
||||
public function connnect($dc_number, $settings = [])
|
||||
{
|
||||
if ($settings == []) {
|
||||
$settings = $this->settings[$dc_number];
|
||||
}
|
||||
$address = $settings["test_mode"] ? $this->dclist["test"][$dc_number] : $this->dclist["main"][$dc_number];
|
||||
if ($settings["protocol"] == "https") {
|
||||
$subdomain = $this->dclist["ssl_subdomains"][$dc_number] . ($settings["upload"] ? '-1' : '');
|
||||
$path = $settings["test_mode"] ? 'apiw_test1' : 'apiw1';
|
||||
$address = 'https://' . $subdomain . '.web.telegram.org/' . $path;
|
||||
$address = $settings['test_mode'] ? $this->dclist['test'][$dc_number] : $this->dclist['main'][$dc_number];
|
||||
if ($settings['protocol'] == 'https') {
|
||||
$subdomain = $this->dclist['ssl_subdomains'][$dc_number].($settings['upload'] ? '-1' : '');
|
||||
$path = $settings['test_mode'] ? 'apiw_test1' : 'apiw1';
|
||||
$address = 'https://'.$subdomain.'.web.telegram.org/'.$path;
|
||||
}
|
||||
$this->sockets[$dc_number] = new Connection($address, $settings["port"], $settings["protocol"]);
|
||||
$this->sockets[$dc_number] = new Connection($address, $settings['port'], $settings['protocol']);
|
||||
$this->curdc = $dc_number;
|
||||
}
|
||||
public function send_message($message, $dc_number = -1) {
|
||||
|
||||
public function send_message($message, $dc_number = -1)
|
||||
{
|
||||
if ($dc_number == -1) {
|
||||
$dc_number = $this->curdc;
|
||||
}
|
||||
|
||||
return $this->sockets[$dc_number]->send_message($message);
|
||||
}
|
||||
public function read_message($dc_number = -1) {
|
||||
|
||||
public function read_message($dc_number = -1)
|
||||
{
|
||||
if ($dc_number == -1) {
|
||||
$dc_number = $this->curdc;
|
||||
}
|
||||
|
||||
return $this->sockets[$dc_number]->read_message();
|
||||
}
|
||||
|
||||
public function __destroy() {
|
||||
public function __destroy()
|
||||
{
|
||||
foreach ($this->sockets as $n => $socket) {
|
||||
unset($this->sockets[$n]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,30 +38,30 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
|
||||
-----END RSA PUBLIC KEY-----',
|
||||
],
|
||||
'connection' => [
|
||||
'ssl_subdomains' => [
|
||||
'ssl_subdomains' => [
|
||||
1 => 'pluto',
|
||||
2 => 'venus',
|
||||
3 => 'aurora',
|
||||
4 => 'vesta',
|
||||
5 => 'flora'
|
||||
5 => 'flora',
|
||||
],
|
||||
'test' => [
|
||||
1 => '149.154.175.10',
|
||||
2 => '149.154.167.40',
|
||||
3 => '149.154.175.117'
|
||||
3 => '149.154.175.117',
|
||||
],
|
||||
'main' => [
|
||||
1 => '149.154.175.50',
|
||||
2 => '149.154.167.51',
|
||||
3 => '149.154.175.100',
|
||||
4 => '149.154.167.91',
|
||||
5 => '149.154.171.5'
|
||||
]
|
||||
1 => '149.154.175.50',
|
||||
2 => '149.154.167.51',
|
||||
3 => '149.154.175.100',
|
||||
4 => '149.154.167.91',
|
||||
5 => '149.154.171.5',
|
||||
],
|
||||
],
|
||||
'connection_settings' => [
|
||||
'all' => [
|
||||
'protocol' => 'tcp_full',
|
||||
'test_mode' => true
|
||||
'protocol' => 'tcp_full',
|
||||
'test_mode' => true,
|
||||
],
|
||||
],
|
||||
'app_info' => [
|
||||
|
@ -431,6 +431,7 @@ class AuthKeyHandler extends AckHandler
|
||||
|
||||
$this->log->log('Auth key generated');
|
||||
$this->timedelta = 0;
|
||||
|
||||
return $res_authorization;
|
||||
case 'dh_gen_retry':
|
||||
if ($Set_client_DH_params_answer['new_nonce_hash2'] != $new_nonce_hash2) {
|
||||
|
@ -73,7 +73,7 @@ class CallHandler extends AuthKeyHandler
|
||||
$this->outgoing_messages[$int_message_id]['content'] = ['object' => $object, 'args' => $args];
|
||||
// $server_answer = $this->wait_for_response($int_message_id);
|
||||
} catch (Exception $e) {
|
||||
$this->log->log('An error occurred while calling object '.$object.': '.$e->getMessage().' in '.$e->getFile().':'.$e->getLine().'. Recreating connection and retrying to call object...');
|
||||
$this->log->log('An error occurred while calling object '.$object.': '.$e->getMessage().' in '.$e->getFile().':'.$e->getLine().'. Recreating connection and retrying to call object...');
|
||||
unset($this->connection);
|
||||
$this->connection = new DataCenter($this->settings['connection'], $this->settings['connection_settings']);
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user