Applied fixes from StyleCI
This commit is contained in:
parent
f331931365
commit
f27a79561f
@ -17,53 +17,63 @@ namespace danog\MadelineProto;
|
|||||||
*/
|
*/
|
||||||
class DataCenter extends Tools
|
class DataCenter extends Tools
|
||||||
{
|
{
|
||||||
public function __construct($dclist, $settings) {
|
public function __construct($dclist, $settings)
|
||||||
|
{
|
||||||
$this->dclist = $dclist;
|
$this->dclist = $dclist;
|
||||||
$this->settings = $settings;
|
$this->settings = $settings;
|
||||||
if (isset($this->settings["all"])) {
|
if (isset($this->settings['all'])) {
|
||||||
foreach ($this->range(1, 6) as $n) {
|
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) {
|
foreach ($this->range(1, 6) as $n) {
|
||||||
if (!isset($this->settings[$n])) {
|
if (!isset($this->settings[$n])) {
|
||||||
$this->settings[$n] = [
|
$this->settings[$n] = [
|
||||||
'protocol' => 'tcp_full',
|
'protocol' => 'tcp_full',
|
||||||
'port' => '443',
|
'port' => '443',
|
||||||
'test_mode' => true
|
'test_mode' => true,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->connect(2);
|
$this->connect(2);
|
||||||
}
|
}
|
||||||
public function connnect($dc_number, $settings = []) {
|
|
||||||
|
public function connnect($dc_number, $settings = [])
|
||||||
|
{
|
||||||
if ($settings == []) {
|
if ($settings == []) {
|
||||||
$settings = $this->settings[$dc_number];
|
$settings = $this->settings[$dc_number];
|
||||||
}
|
}
|
||||||
$address = $settings["test_mode"] ? $this->dclist["test"][$dc_number] : $this->dclist["main"][$dc_number];
|
$address = $settings['test_mode'] ? $this->dclist['test'][$dc_number] : $this->dclist['main'][$dc_number];
|
||||||
if ($settings["protocol"] == "https") {
|
if ($settings['protocol'] == 'https') {
|
||||||
$subdomain = $this->dclist["ssl_subdomains"][$dc_number] . ($settings["upload"] ? '-1' : '');
|
$subdomain = $this->dclist['ssl_subdomains'][$dc_number].($settings['upload'] ? '-1' : '');
|
||||||
$path = $settings["test_mode"] ? 'apiw_test1' : 'apiw1';
|
$path = $settings['test_mode'] ? 'apiw_test1' : 'apiw1';
|
||||||
$address = 'https://' . $subdomain . '.web.telegram.org/' . $path;
|
$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;
|
$this->curdc = $dc_number;
|
||||||
}
|
}
|
||||||
public function send_message($message, $dc_number = -1) {
|
|
||||||
|
public function send_message($message, $dc_number = -1)
|
||||||
|
{
|
||||||
if ($dc_number == -1) {
|
if ($dc_number == -1) {
|
||||||
$dc_number = $this->curdc;
|
$dc_number = $this->curdc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->sockets[$dc_number]->send_message($message);
|
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) {
|
if ($dc_number == -1) {
|
||||||
$dc_number = $this->curdc;
|
$dc_number = $this->curdc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->sockets[$dc_number]->read_message();
|
return $this->sockets[$dc_number]->read_message();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __destroy() {
|
public function __destroy()
|
||||||
|
{
|
||||||
foreach ($this->sockets as $n => $socket) {
|
foreach ($this->sockets as $n => $socket) {
|
||||||
unset($this->sockets[$n]);
|
unset($this->sockets[$n]);
|
||||||
}
|
}
|
||||||
|
@ -38,30 +38,30 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
|
|||||||
-----END RSA PUBLIC KEY-----',
|
-----END RSA PUBLIC KEY-----',
|
||||||
],
|
],
|
||||||
'connection' => [
|
'connection' => [
|
||||||
'ssl_subdomains' => [
|
'ssl_subdomains' => [
|
||||||
1 => 'pluto',
|
1 => 'pluto',
|
||||||
2 => 'venus',
|
2 => 'venus',
|
||||||
3 => 'aurora',
|
3 => 'aurora',
|
||||||
4 => 'vesta',
|
4 => 'vesta',
|
||||||
5 => 'flora'
|
5 => 'flora',
|
||||||
],
|
],
|
||||||
'test' => [
|
'test' => [
|
||||||
1 => '149.154.175.10',
|
1 => '149.154.175.10',
|
||||||
2 => '149.154.167.40',
|
2 => '149.154.167.40',
|
||||||
3 => '149.154.175.117'
|
3 => '149.154.175.117',
|
||||||
],
|
],
|
||||||
'main' => [
|
'main' => [
|
||||||
1 => '149.154.175.50',
|
1 => '149.154.175.50',
|
||||||
2 => '149.154.167.51',
|
2 => '149.154.167.51',
|
||||||
3 => '149.154.175.100',
|
3 => '149.154.175.100',
|
||||||
4 => '149.154.167.91',
|
4 => '149.154.167.91',
|
||||||
5 => '149.154.171.5'
|
5 => '149.154.171.5',
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
'connection_settings' => [
|
'connection_settings' => [
|
||||||
'all' => [
|
'all' => [
|
||||||
'protocol' => 'tcp_full',
|
'protocol' => 'tcp_full',
|
||||||
'test_mode' => true
|
'test_mode' => true,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'app_info' => [
|
'app_info' => [
|
||||||
|
@ -431,6 +431,7 @@ class AuthKeyHandler extends AckHandler
|
|||||||
|
|
||||||
$this->log->log('Auth key generated');
|
$this->log->log('Auth key generated');
|
||||||
$this->timedelta = 0;
|
$this->timedelta = 0;
|
||||||
|
|
||||||
return $res_authorization;
|
return $res_authorization;
|
||||||
case 'dh_gen_retry':
|
case 'dh_gen_retry':
|
||||||
if ($Set_client_DH_params_answer['new_nonce_hash2'] != $new_nonce_hash2) {
|
if ($Set_client_DH_params_answer['new_nonce_hash2'] != $new_nonce_hash2) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user