32 bit bugfixes

This commit is contained in:
Daniil Gentili 2017-03-26 05:15:41 +02:00
parent fa987e718b
commit 432fc32d05
4 changed files with 14 additions and 4 deletions

View File

@ -48,7 +48,6 @@ class MTProto
public $bigint = false;
public $run_workers = false;
public $threads = false;
public $readers = [];
public function __construct($settings = [])
{
@ -116,6 +115,9 @@ class MTProto
if (!isset($this->reader_pool)) {
$this->reader_pool = new \Pool(count($dcs));
}
if (!isset($this->readers)) {
$this->readers = [];
}
foreach ($dcs as $dc) {
if (!isset($this->readers[$dc])) {
$this->readers[$dc] = new \danog\MadelineProto\Threads\SocketReader($this, $dc);
@ -137,6 +139,9 @@ class MTProto
if (isset($t['reader_pool'])) {
unset($t['reader_pool']);
}
if (isset($t['readers'])) {
unset($t['readers']);
}
return array_keys($t);
}

View File

@ -29,6 +29,9 @@ trait CallHandler
throw new \danog\MadelineProto\Exception('No datacenter provided');
}
$args = $this->botAPI_to_MTProto($args);
if (isset($args['ping_id']) && is_integer($args['ping_id'])) {
$args['ping_id'] = \danog\PHP\Struct::pack('<q', $args['ping_id']);
}
$serialized = $this->serialize_method($method, $args);
$content_related = $this->content_related($method);
$type = $this->methods->find_by_method($method)['type'];

View File

@ -22,12 +22,13 @@ trait SeqNoHandler
$in = $content_related ? 1 : 0;
$value = $this->datacenter->sockets[$datacenter]->session_out_seq_no;
$this->datacenter->sockets[$datacenter]->session_out_seq_no += $in;
//var_dump("OUT $datacenter: $value + $in = ".$this->datacenter->sockets[$datacenter]->session_out_seq_no);
return ($value * 2) + $in;
}
public function check_in_seq_no($datacenter, $current_msg_id)
{
if (isset($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['seq_no']) && ($seq_no = $this->generate_in_seq_no($datacenter, $this->content_related($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['_']))) !== $this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['seq_no']) {
\danog\MadelineProto\Logger::log(['SECURITY WARNING: Seqno mismatch (should be '.$seq_no.', is '.$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['seq_no'].', '.$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['_'].')'], \danog\MadelineProto\Logger::ERROR);
}
@ -38,12 +39,13 @@ trait SeqNoHandler
$in = $content_related ? 1 : 0;
$value = $this->datacenter->sockets[$datacenter]->session_in_seq_no;
$this->datacenter->sockets[$datacenter]->session_in_seq_no += $in;
//var_dump("IN $datacenter: $value + $in = ".$this->datacenter->sockets[$datacenter]->session_in_seq_no);
return ($value * 2) + $in;
}
public function content_related($method)
{
//var_dump($method);
return !in_array(
$method,
[

View File

@ -554,7 +554,7 @@ trait TL
break;
}
}
if (in_array($arg['name'], ['msg_ids', 'msg_id', 'bad_msg_id', 'req_msg_id', 'answer_msg_id', 'first_msg_id', 'key_fingerprint', 'server_salt', 'new_server_salt', 'server_public_key_fingerprints'])) {
if (in_array($arg['name'], ['msg_ids', 'msg_id', 'bad_msg_id', 'req_msg_id', 'answer_msg_id', 'first_msg_id', 'key_fingerprint', 'server_salt', 'new_server_salt', 'server_public_key_fingerprints', 'ping_id'])) {
$arg['strlong'] = true;
}
$x[$arg['name']] = $this->deserialize($bytes_io, $arg);