Fixed some bugs
This commit is contained in:
parent
270a8acec1
commit
f037212ac8
@ -132,14 +132,15 @@ 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!');
|
||||
}
|
||||
$x = $this->struct->unpack('<I', substr($packet, 0, 4));
|
||||
$auth_key_id = substr($packet, 4, 8);
|
||||
$payload = substr($packet, 4, strlen($packet) - 8);
|
||||
if (strlen($payload) == 4) {
|
||||
throw new Exception('Server response error: '.$this->struct->unpack('<I', $payload)[0]);
|
||||
}
|
||||
$auth_key_id = substr($payload, 0, 8);
|
||||
if ($auth_key_id == Tools::string2bin('\x00\x00\x00\x00\x00\x00\x00\x00')) {
|
||||
list($message_id, $message_length) = $this->struct->unpack('<8sI', substr($packet, 12, 12));
|
||||
$data = substr($packet, 24, (24 + $message_length) - 24);
|
||||
@ -224,8 +225,8 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
|
||||
$this->log->log(sprintf('Factorization %s = %s * %s', $pq, $p, $q));
|
||||
|
||||
// Serialize object for req_DH_params
|
||||
$p_bytes = $this->struct->pack('>Q', (string) $p);
|
||||
$q_bytes = $this->struct->pack('>Q', (string) $q);
|
||||
$p_bytes = $this->struct->pack('>I', (string) $p);
|
||||
$q_bytes = $this->struct->pack('>I', (string) $q);
|
||||
$new_nonce = \phpseclib\Crypt\Random::string(32);
|
||||
$data = $this->tl->serialize_obj('p_q_inner_data', ['pq' => $pq_bytes, 'p' => $p_bytes, 'q' => $q_bytes, 'nonce' => $nonce, 'server_nonce' => $server_nonce, 'new_nonce' => $new_nonce]);
|
||||
$sha_digest = sha1($data, true);
|
||||
|
40
src/danog/MadelineProto/TL/Exception.php
Normal file
40
src/danog/MadelineProto/TL/Exception.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright 2016 Daniil Gentili
|
||||
(https://daniil.it)
|
||||
This file is part of MadelineProto.
|
||||
MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
The PWRTelegram API is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License along with the MadelineProto.
|
||||
If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace danog\MadelineProto\TL;
|
||||
|
||||
class Exception extends \Exception
|
||||
{
|
||||
public function __construct($message, $code = 0, Exception $previous = null)
|
||||
{
|
||||
// some code
|
||||
if (isset($GLOBALS['doingphptests']) && $GLOBALS['doingphptests']) {
|
||||
var_dump($message);
|
||||
}
|
||||
// make sure everything is assigned properly
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* ExceptionErrorHandler.
|
||||
*
|
||||
* Error handler
|
||||
*/
|
||||
public function ExceptionErrorHandler($errno = 0, $errstr = null, $errfile = null, $errline = null)
|
||||
{
|
||||
// If error is suppressed with @, don't throw an exception
|
||||
if (error_reporting() === 0) {
|
||||
return true; // return true to continue through the others error handlers
|
||||
}
|
||||
throw new self($errstr.' on line '.$errline.' of file '.$errfile, $errno);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user