diff --git a/src/danog/MadelineProto/Connection.php b/src/danog/MadelineProto/Connection.php index 907860568..22b4a1946 100644 --- a/src/danog/MadelineProto/Connection.php +++ b/src/danog/MadelineProto/Connection.php @@ -441,7 +441,7 @@ class Connection extends Session if ($message['method']) { $body = yield $this->API->getTL()->serializeMethod($message['_'], $body); } else { - $body = yield $this->API->getTL()->serializeObject(['type' => $message['_']], $body, $message['_']); + $body = yield $this->API->getTL()->serializeObject(['type' => ''], $body, $message['_']); } if ($refreshNext) { $this->API->referenceDatabase->refreshNext(false); diff --git a/src/danog/MadelineProto/Loop/Connection/WriteLoop.php b/src/danog/MadelineProto/Loop/Connection/WriteLoop.php index 3c5068555..39534537c 100644 --- a/src/danog/MadelineProto/Loop/Connection/WriteLoop.php +++ b/src/danog/MadelineProto/Loop/Connection/WriteLoop.php @@ -182,7 +182,7 @@ class WriteLoop extends ResumableSignalLoop $temporary_keys = []; if (\count($to_ack = $connection->ack_queue)) { foreach (\array_chunk($connection->ack_queue, 8192) as $acks) { - $connection->pending_outgoing[$connection->pending_outgoing_key] = ['_' => 'msgs_ack', 'serialized_body' => yield $this->API->getTL()->serializeObject(['type' => 'msgs_ack'], ['msg_ids' => $acks], 'msgs_ack'), 'contentRelated' => false, 'unencrypted' => false, 'method' => false]; + $connection->pending_outgoing[$connection->pending_outgoing_key] = ['_' => 'msgs_ack', 'serialized_body' => yield $this->API->getTL()->serializeObject(['type' => ''], ['_' => 'msgs_ack','msg_ids' => $acks], 'msgs_ack'), 'contentRelated' => false, 'unencrypted' => false, 'method' => false]; $temporary_keys[$connection->pending_outgoing_key] = true; $API->logger->logger("Adding msgs_ack {$connection->pending_outgoing_key}", Logger::ULTRA_VERBOSE); $connection->pending_outgoing_key++; @@ -280,7 +280,7 @@ class WriteLoop extends ResumableSignalLoop // TODO /* if ($API->settings['requests']['gzip_encode_if_gt'] !== -1 && ($l = strlen($MTmessage['body'])) > $API->settings['requests']['gzip_encode_if_gt']) { if (($g = strlen($gzipped = gzencode($MTmessage['body']))) < $l) { - $MTmessage['body'] = yield $API->getTL()->serializeObject(['type' => 'gzip_packed'], ['packed_data' => $gzipped], 'gzipped data'); + $MTmessage['body'] = yield $API->getTL()->serializeObject(['type' => ''], ['_' => 'gzip_packed', 'packed_data' => $gzipped], 'gzipped data'); $API->logger->logger('Using GZIP compression for ' . $message['_'] . ', saved ' . ($l - $g) . ' bytes of data, reduced call size by ' . $g * 100 / $l . '%', \danog\MadelineProto\Logger::ULTRA_VERBOSE); } unset($gzipped); diff --git a/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php b/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php index e3ad04c13..c23765dca 100644 --- a/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php @@ -186,8 +186,8 @@ trait AuthKeyHandler $q_bytes = $q->toBytes(); $new_nonce = \danog\MadelineProto\Tools::random(32); - $data_unserialized = ['pq' => $pq_bytes, 'p' => $p_bytes, 'q' => $q_bytes, 'nonce' => $nonce, 'server_nonce' => $server_nonce, 'new_nonce' => $new_nonce, 'expires_in' => $expires_in, 'dc' => \preg_replace('|_.*|', '', $datacenter)]; - $p_q_inner_data = yield $this->TL->serializeObject(['type' => 'p_q_inner_data'.($expires_in < 0 ? '' : '_temp')], $data_unserialized, 'p_q_inner_data'); + $data_unserialized = ['_' => 'p_q_inner_data'.($expires_in < 0 ? '' : '_temp'), 'pq' => $pq_bytes, 'p' => $p_bytes, 'q' => $q_bytes, 'nonce' => $nonce, 'server_nonce' => $server_nonce, 'new_nonce' => $new_nonce, 'expires_in' => $expires_in, 'dc' => \preg_replace('|_.*|', '', $datacenter)]; + $p_q_inner_data = yield $this->TL->serializeObject(['type' => ''], $data_unserialized, 'p_q_inner_data'); /* * *********************************************************************** * Encrypt serialized object @@ -324,7 +324,7 @@ trait AuthKeyHandler * string $g_b : g^b mod dh_prime * ] */ - $data = yield $this->TL->serializeObject(['type' => 'client_DH_inner_data'], ['nonce' => $nonce, 'server_nonce' => $server_nonce, 'retry_id' => $retry_id, 'g_b' => $g_b_str], 'client_DH_inner_data'); + $data = yield $this->TL->serializeObject(['type' => ''], ['_' => 'client_DH_inner_data', 'nonce' => $nonce, 'server_nonce' => $server_nonce, 'retry_id' => $retry_id, 'g_b' => $g_b_str], 'client_DH_inner_data'); /* * *********************************************************************** * encrypt client_DH_inner_data @@ -554,7 +554,7 @@ trait AuthKeyHandler $temp_auth_key_id = $datacenterConnection->getTempAuthKey()->getID(); $perm_auth_key_id = $datacenterConnection->getPermAuthKey()->getID(); $temp_session_id = $connection->session_id; - $message_data = yield $this->TL->serializeObject(['type' => 'bind_auth_key_inner'], ['nonce' => $nonce, 'temp_auth_key_id' => $temp_auth_key_id, 'perm_auth_key_id' => $perm_auth_key_id, 'temp_session_id' => $temp_session_id, 'expires_at' => $expires_at], 'bindTempAuthKey_inner'); + $message_data = yield $this->TL->serializeObject(['type' => ''], ['_' => 'bind_auth_key_inner','nonce' => $nonce, 'temp_auth_key_id' => $temp_auth_key_id, 'perm_auth_key_id' => $perm_auth_key_id, 'temp_session_id' => $temp_session_id, 'expires_at' => $expires_at], 'bindTempAuthKey_inner'); $message_id = $connection->generateMessageId(); $seq_no = 0; $encrypted_data = \danog\MadelineProto\Tools::random(16).$message_id.\pack('VV', $seq_no, \strlen($message_data)).$message_data; diff --git a/src/danog/MadelineProto/Stream/Common/HashedBufferedStream.php b/src/danog/MadelineProto/Stream/Common/HashedBufferedStream.php index 63d7e932b..9fe74be82 100644 --- a/src/danog/MadelineProto/Stream/Common/HashedBufferedStream.php +++ b/src/danog/MadelineProto/Stream/Common/HashedBufferedStream.php @@ -236,9 +236,9 @@ class HashedBufferedStream implements BufferedProxyStreamInterface, BufferInterf public function getReadBufferGenerator(&$length): \Generator { //if ($this->read_hash) { - $this->read_buffer = yield $this->stream->getReadBuffer($length); + $this->read_buffer = yield $this->stream->getReadBuffer($length); - return $this; + return $this; //} //return yield $this->stream->getReadBuffer($length); @@ -254,9 +254,9 @@ class HashedBufferedStream implements BufferedProxyStreamInterface, BufferInterf public function getWriteBufferGenerator(int $length, string $append = ''): \Generator { //if ($this->write_hash) { - $this->write_buffer = yield $this->stream->getWriteBuffer($length, $append); + $this->write_buffer = yield $this->stream->getWriteBuffer($length, $append); - return $this; + return $this; //} //return yield $this->stream->getWriteBuffer($length, $append); diff --git a/src/danog/MadelineProto/Stream/MTProtoTransport/ObfuscatedStream.php b/src/danog/MadelineProto/Stream/MTProtoTransport/ObfuscatedStream.php index a66632b5a..e2f6e7c0f 100644 --- a/src/danog/MadelineProto/Stream/MTProtoTransport/ObfuscatedStream.php +++ b/src/danog/MadelineProto/Stream/MTProtoTransport/ObfuscatedStream.php @@ -23,7 +23,6 @@ use danog\MadelineProto\Stream\BufferedProxyStreamInterface; use danog\MadelineProto\Stream\Common\CtrStream; use danog\MadelineProto\Stream\ConnectionContext; - /** * Obfuscated2 stream wrapper. * diff --git a/src/danog/MadelineProto/TON/Lite.php b/src/danog/MadelineProto/TON/Lite.php index dc07e118a..0d870bdec 100644 --- a/src/danog/MadelineProto/TON/Lite.php +++ b/src/danog/MadelineProto/TON/Lite.php @@ -105,10 +105,11 @@ class Lite } } - public function methodCall(string $methodName, array $args = [], array $aargs = []) { + public function methodCall(string $methodName, array $args = [], array $aargs = []) + { $data = yield $this->TL->serializeMethod($methodName, $args); $data = yield $this->TL->serializeMethod('liteServer.query', ['data' => $data]); - return yield $this->connections[rand(0, count($this->connections) - 1)]->query($data); + return yield $this->connections[\rand(0, \count($this->connections) - 1)]->query($data); } /** @@ -134,9 +135,9 @@ class Lite { return $parameters; } - + /** - * Get TL method namespaces + * Get TL method namespaces. * * @return void */ diff --git a/ton/lite-client.php b/ton/lite-client.php index c4e45ae48..7faebbc79 100644 --- a/ton/lite-client.php +++ b/ton/lite-client.php @@ -17,6 +17,6 @@ $API->async(true); $API->loop( function () use ($API) { yield $API->connect(__DIR__.'/ton-lite-client-test1.config.json'); - var_dump(yield $API->liteServer->getTime()); + \var_dump(yield $API->liteServer->getTime()); } );