Updated error handlign

This commit is contained in:
danogentili 2016-08-10 13:56:35 +02:00
parent e1fc751728
commit ad1552df63
3 changed files with 10 additions and 10 deletions

View File

@ -12,7 +12,5 @@ addons:
packages: packages:
- python3 - python3
before_script:
- composer update --dev
script: script:
- ./testing.php - ./testing.php

View File

@ -184,7 +184,7 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
} }
if (fstat($payload)['size'] == 4) { if (fstat($payload)['size'] == 4) {
throw new Exception('Server response error: '.$this->struct->unpack('<I', fread($payload, 4))[0]); throw new Exception('Server response error: '.abs($this->struct->unpack('<i', fread($payload, 4))[0]));
} }
$auth_key_id = fread($payload, 8); $auth_key_id = fread($payload, 8);
if ($auth_key_id == Tools::string2bin('\x00\x00\x00\x00\x00\x00\x00\x00')) { if ($auth_key_id == Tools::string2bin('\x00\x00\x00\x00\x00\x00\x00\x00')) {
@ -286,12 +286,15 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
$this->log->log('Starting Diffie Hellman key exchange'); $this->log->log('Starting Diffie Hellman key exchange');
$server_dh_params = $this->method_call('req_DH_params', $server_dh_params = $this->method_call('req_DH_params',
['nonce' => $nonce, [
'server_nonce' => $server_nonce, 'nonce' => $nonce,
'p' => $p_bytes, 'server_nonce' => $server_nonce,
'q' => $q_bytes, 'p' => $p_bytes,
'public_key_fingerprint' => $public_key_fingerprint, 'q' => $q_bytes,
'encrypted_data' => $encrypted_data]); 'public_key_fingerprint' => $public_key_fingerprint,
'encrypted_data' => $encrypted_data
]
);
if ($nonce != $server_dh_params['nonce']) { if ($nonce != $server_dh_params['nonce']) {
throw new Exception('Handshake: wrong nonce.'); throw new Exception('Handshake: wrong nonce.');

View File

@ -98,7 +98,6 @@ class TL
if (!is_numeric($value)) { if (!is_numeric($value)) {
throw new Exception("serialize_param: given value isn't numeric"); throw new Exception("serialize_param: given value isn't numeric");
} }
return \danog\PHP\Struct::pack('<q', $value); return \danog\PHP\Struct::pack('<q', $value);
break; break;
case 'int128': case 'int128':