diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index 6910deaa..9faf34c1 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -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); } diff --git a/src/danog/MadelineProto/MTProtoTools/CallHandler.php b/src/danog/MadelineProto/MTProtoTools/CallHandler.php index 8d0463a4..82dc1498 100644 --- a/src/danog/MadelineProto/MTProtoTools/CallHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/CallHandler.php @@ -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('serialize_method($method, $args); $content_related = $this->content_related($method); $type = $this->methods->find_by_method($method)['type']; diff --git a/src/danog/MadelineProto/MTProtoTools/SeqNoHandler.php b/src/danog/MadelineProto/MTProtoTools/SeqNoHandler.php index a461ce0b..ebfcfd22 100644 --- a/src/danog/MadelineProto/MTProtoTools/SeqNoHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/SeqNoHandler.php @@ -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, [ diff --git a/src/danog/MadelineProto/TL/TL.php b/src/danog/MadelineProto/TL/TL.php index b3edc330..45ccb1a9 100644 --- a/src/danog/MadelineProto/TL/TL.php +++ b/src/danog/MadelineProto/TL/TL.php @@ -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);