Refactor
This commit is contained in:
parent
1eb730d281
commit
bf93251ee6
@ -132,6 +132,9 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
|
||||
}
|
||||
$packet_length = $this->struct->unpack('<I', $packet_length_data)[0];
|
||||
$packet = $this->sock->read($packet_length - 4);
|
||||
if ($packet_length == 4) {
|
||||
throw new Exception("Server response error: " . $this->struct->unpack('<I', $packet)[0]);
|
||||
}
|
||||
if (!($this->newcrc32($packet_length_data.substr($packet, 0, -4)) == $this->struct->unpack('<I', substr($packet, -4))[0])) {
|
||||
throw new Exception('CRC32 was not correct!');
|
||||
}
|
||||
@ -156,6 +159,7 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
|
||||
$message_data_length = $this->struct->unpack('<I', substr($decrypted_data, 28, 32 - 28)) [0];
|
||||
$data = substr($decrypted_data, 32, (32 + $message_data_length) - 32);
|
||||
} else {
|
||||
DebugFunctions::hex_dump($packet);
|
||||
throw new Exception('Got unknown auth_key id');
|
||||
}
|
||||
|
||||
@ -233,7 +237,9 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
|
||||
|
||||
// req_DH_params
|
||||
$this->log->log('Starting Diffie Hellman key exchange');
|
||||
|
||||
$server_dh_params = $this->method_call('req_DH_params', ['nonce' => $nonce, 'server_nonce' => $server_nonce, 'p' => $p_bytes, 'q' => $q_bytes, 'public_key_fingerprint' => $public_key_fingerprint, 'encrypted_data' => $encrypted_data]);
|
||||
|
||||
if ($nonce != $server_dh_params['nonce']) {
|
||||
throw new Exception('Handshake: wrong nonce.');
|
||||
}
|
||||
|
@ -60,10 +60,16 @@ class TL
|
||||
throw new Exception('Could not extract type: '.$type_);
|
||||
}
|
||||
$bytes_io .= \danog\PHP\Struct::pack('<i', $tl_method->id);
|
||||
foreach ($tl_method->params as $arg) {
|
||||
$bytes_io .= $this->serialize_param($arg['type'], $kwargs[$arg['name']]);
|
||||
if (count(array_filter(array_keys($kwargs), 'is_string')) > 0) {
|
||||
foreach ($tl_method->params as $arg) {
|
||||
$bytes_io .= $this->serialize_param($arg['type'], $kwargs[$arg['name']]);
|
||||
}
|
||||
} else {
|
||||
$argcount = 0;
|
||||
foreach ($tl_method->params as $arg) {
|
||||
$bytes_io .= $this->serialize_param($arg['type'], $kwargs[$argcount++]);
|
||||
}
|
||||
}
|
||||
|
||||
return $bytes_io;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user