1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-27 03:14:39 +01:00
This commit is contained in:
Daniil Gentili 2016-10-18 17:11:33 +00:00
parent 9a11d42657
commit 37fa11e81a
4 changed files with 8 additions and 5 deletions

View File

@ -484,7 +484,7 @@ class AuthKeyHandler extends AckHandler
list($aes_key, $aes_iv) = $this->aes_calculate($message_key, $this->settings['authorization']['auth_key']['auth_key']);
$encrypted_message = $this->settings['authorization']['auth_key']['id'].$message_key.$this->ige_encrypt($encrypted_data.$padding, $aes_key, $aes_iv);
if ($this->method_call('auth.bindTempAuthKey', ['perm_auth_key_id' => $perm_auth_key_id, 'nonce' => $nonce, 'expires_at' => $expires_at, 'encrypted_message' => $encrypted_message])) {
if ($this->method_call('auth.bindTempAuthKey', ['perm_auth_key_id' => $perm_auth_key_id, 'nonce' => $nonce, 'expires_at' => $expires_at, 'encrypted_message' => $encrypted_message], $message_id)) {
$this->log->log('Successfully binded temporary and permanent authorization keys.');
$this->write_client_info();

View File

@ -45,12 +45,12 @@ class CallHandler extends AuthKeyHandler
}
}
public function method_call($method, $args)
public function method_call($method, $args, $message_id = null)
{
foreach (range(1, $this->settings['max_tries']['query']) as $i) {
try {
$args = $this->tl->get_named_method_args($method, $args);
$int_message_id = $this->send_message($this->tl->serialize_method($method, $args), $this->tl->content_related($method));
$int_message_id = $this->send_message($this->tl->serialize_method($method, $args), $this->tl->content_related($method), $message_id);
$this->outgoing_messages[$int_message_id]['content'] = ['method' => $method, 'args' => $args];
$server_answer = $this->wait_for_response($int_message_id, $method);
} catch (Exception $e) {

View File

@ -21,9 +21,11 @@ class MessageHandler extends Crypt
* Forming the message frame and sending message to server
* :param message: byte string to send.
*/
public function send_message($message_data, $content_related)
public function send_message($message_data, $content_related, $int_message_id = null)
{
$int_message_id = $this->generate_message_id();
if ($int_message_id == null) {
$int_message_id = $this->generate_message_id();
}
$message_id = $this->struct->pack('<Q', $int_message_id);
if (($this->settings['authorization']['temp_auth_key']['auth_key'] == null) || ($this->settings['authorization']['temp_auth_key']['server_salt'] == null)) {
$message = $this->string2bin('\x00\x00\x00\x00\x00\x00\x00\x00').$message_id.$this->struct->pack('<I', strlen($message_data)).$message_data;

View File

@ -41,6 +41,7 @@ class ResponseHandler extends MsgIdHandler
break;
case 'bad_msg_notification':
throw new Exception('Received bad_msg_notification '.var_export($response, true));
break;
case 'bad_server_salt':
$this->settings['authorization']['temp_auth_key']['server_salt'] = $response['new_server_salt'];