This commit is contained in:
danogentili 2016-09-24 17:58:17 +02:00
parent bedab1388d
commit b0a0e6d70c
5 changed files with 14 additions and 10 deletions

View File

@ -38,9 +38,13 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
-----END RSA PUBLIC KEY-----',
],
'connection' => [
'ip_address' => '149.154.167.50',
'port' => '443',
'protocol' => 'tcp_full',
'dc_list' => [
2 => [
'ip_address' => '149.154.167.50',
'port' => '443',
'protocol' => 'tcp_full',
],
],
],
'app_info' => [
'api_id' => 25628,

View File

@ -48,6 +48,7 @@ class CallHandler extends AuthKeyHandler
try {
$int_message_id = $this->send_message($this->tl->serialize_method($method, $args), $this->tl->content_related($method));
$this->outgoing_messages[$int_message_id]['content'] = ['method' => $method, 'args' => $args];
var_dump($this->outgoing_messages);
$server_answer = $this->wait_for_response($int_message_id);
} catch (Exception $e) {
$this->log->log('An error occurred while calling method '.$method.': '.$e->getMessage().' in '.$e->getFile().':'.$e->getLine().$e->getTraceAsString().'. Recreating connection and retrying to call method...');

View File

@ -31,7 +31,7 @@ class MessageHandler extends Crypt
} else {
$seq_no = $this->generate_seq_no($content_related);
var_dump($this->settings['authorization']['temp_auth_key']['server_salt']);
$encrypted_data = $this->struct->pack('<Q', $this->settings['authorization']['temp_auth_key']['server_salt']).$this->settings['authorization']['session_id'].$message_id.$this->struct->pack('<II', $seq_no, strlen($message_data)).$message_data;
$encrypted_data = $this->struct->pack('<q', $this->settings['authorization']['temp_auth_key']['server_salt']).$this->settings['authorization']['session_id'].$message_id.$this->struct->pack('<II', $seq_no, strlen($message_data)).$message_data;
$message_key = substr(sha1($encrypted_data, true), -16);
$padding = \phpseclib\Crypt\Random::string(\danog\MadelineProto\Tools::posmod(-strlen($encrypted_data), 16));
list($aes_key, $aes_iv) = $this->aes_calculate($message_key);
@ -63,7 +63,7 @@ class MessageHandler extends Crypt
list($aes_key, $aes_iv) = $this->aes_calculate($message_key, 'from server');
$decrypted_data = $this->ige_decrypt($encrypted_data, $aes_key, $aes_iv);
$server_salt = $this->struct->unpack('<Q', substr($decrypted_data, 0, 8))[0];
$server_salt = $this->struct->unpack('<q', substr($decrypted_data, 0, 8))[0];
if ($server_salt != $this->settings['authorization']['temp_auth_key']['server_salt']) {
throw new Exception('Server salt mismatch (my server salt '.$this->settings['authorization']['temp_auth_key']['server_salt'].' is not equal to server server salt '.$server_salt.').');
}

View File

@ -48,7 +48,10 @@ class ResponseHandler extends MsgIdHandler
break;
case 'pong':
foreach ($this->outgoing_messages as $msg_id => &$omessage) {
var_dump($this->outgoing_messages);
foreach ($this->outgoing_messages as $msg_id => &$omessage) {
if (isset($omessage['content']['args']['ping_id']) && $omessage['content']['args']['ping_id'] == $response['ping_id']) {
$omessage['response'] = $response['msg_id'];
$this->incoming_messages[$response['msg_id']]['content'] = $response;

View File

@ -8,8 +8,4 @@ if (!$config) {
exit(-1);
}
function base64url_decode($data)
{
return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT));
}
$MadelineProto = new \danog\MadelineProto\API($config);