mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 05:58:58 +01:00
Improve logs
This commit is contained in:
parent
42d66c09ec
commit
f19af54820
2
docs
2
docs
@ -1 +1 @@
|
||||
Subproject commit 326dc6dee0cc0303db36c4bd5e74a241f8f9ad57
|
||||
Subproject commit 821000468d14f943496b8bbc7183360c83630d6b
|
2
schemas
2
schemas
@ -1 +1 @@
|
||||
Subproject commit 8662116b0ada741008f19cb073ea4a4a6c29f807
|
||||
Subproject commit 86b054b6f2790f42dfeeb033fa8f2288657ab3d9
|
@ -394,10 +394,10 @@ final class DataCenterConnection implements JsonSerializable
|
||||
/**
|
||||
* Reset MTProto sessions.
|
||||
*/
|
||||
public function resetSession(): void
|
||||
public function resetSession(string $why): void
|
||||
{
|
||||
foreach ($this->connections as $socket) {
|
||||
$socket->resetSession();
|
||||
$socket->resetSession($why);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -78,7 +78,7 @@ final class ReadLoop extends Loop
|
||||
});
|
||||
return self::STOP;
|
||||
} catch (SecurityException $e) {
|
||||
$this->connection->resetSession();
|
||||
$this->connection->resetSession("security exception {$e->getMessage()}");
|
||||
$this->API->logger("Got security exception in DC {$this->datacenter}, reconnecting...", Logger::ERROR);
|
||||
$this->connection->reconnect();
|
||||
throw $e;
|
||||
@ -89,7 +89,7 @@ final class ReadLoop extends Loop
|
||||
if ($this->shared->hasTempAuthKey()) {
|
||||
$this->API->logger("WARNING: Resetting auth key in DC {$this->datacenter}...", Logger::WARNING);
|
||||
$this->shared->setTempAuthKey(null);
|
||||
$this->shared->resetSession();
|
||||
$this->shared->resetSession("-404");
|
||||
foreach ($this->connection->new_outgoing as $message) {
|
||||
$message->resetSent();
|
||||
}
|
||||
@ -201,7 +201,7 @@ final class ReadLoop extends Loop
|
||||
$session_id = substr($decrypted_data, 8, 8);
|
||||
if ($session_id !== $this->connection->session_id) {
|
||||
$this->API->logger('Session ID mismatch', Logger::FATAL_ERROR);
|
||||
$this->connection->resetSession();
|
||||
$this->connection->resetSession("session ID mismatch");
|
||||
throw new NothingInTheSocketException();
|
||||
}
|
||||
$message_id = Tools::unpackSignedLong(substr($decrypted_data, 16, 8));
|
||||
|
@ -936,7 +936,7 @@ final class MTProto implements TLCallback, LoggerGetter, SettingsGetter
|
||||
}
|
||||
$this->settings->setSchema(new TLSchema);
|
||||
|
||||
$this->resetMTProtoSession(true, true);
|
||||
$this->resetMTProtoSession("upgrading madelineproto", true, true);
|
||||
$this->config = ['expires' => -1];
|
||||
$this->dh_config = ['version' => 0];
|
||||
$this->initialize($this->settings);
|
||||
@ -1013,7 +1013,7 @@ final class MTProto implements TLCallback, LoggerGetter, SettingsGetter
|
||||
Lang::$currentPercentage = 0;
|
||||
}
|
||||
// Reset MTProto session (not related to user session)
|
||||
$this->resetMTProtoSession();
|
||||
$this->resetMTProtoSession("wakeup");
|
||||
// Update settings from constructor
|
||||
$this->updateSettings($settings);
|
||||
// Update TL callbacks
|
||||
@ -1250,14 +1250,14 @@ final class MTProto implements TLCallback, LoggerGetter, SettingsGetter
|
||||
* @param boolean $auth_key Whether to reset the auth key
|
||||
* @internal
|
||||
*/
|
||||
public function resetMTProtoSession(bool $de = true, bool $auth_key = false): void
|
||||
public function resetMTProtoSession(string $why, bool $de = true, bool $auth_key = false): void
|
||||
{
|
||||
if (!\is_object($this->datacenter)) {
|
||||
throw new Exception(Lang::$current_lang['session_corrupted']);
|
||||
}
|
||||
foreach ($this->datacenter->getDataCenterConnections() as $id => $socket) {
|
||||
if ($de) {
|
||||
$socket->resetSession();
|
||||
$socket->resetSession("resetMTProtoSession: $why");
|
||||
}
|
||||
if ($auth_key) {
|
||||
$socket->setTempAuthKey(null);
|
||||
|
@ -225,7 +225,7 @@ trait ResponseHandler
|
||||
case 17:
|
||||
$this->time_delta = ($message->getMsgId() >> 32) - time();
|
||||
$this->API->logger('Set time delta to ' . $this->time_delta, Logger::WARNING);
|
||||
$this->API->resetMTProtoSession();
|
||||
$this->API->resetMTProtoSession("time delta update");
|
||||
$this->shared->setTempAuthKey(null);
|
||||
EventLoop::queue($this->shared->initAuthorization(...));
|
||||
EventLoop::queue($this->methodRecall(...), $requestId);
|
||||
|
@ -99,9 +99,9 @@ trait Session
|
||||
/**
|
||||
* Reset MTProto session.
|
||||
*/
|
||||
public function resetSession(): void
|
||||
public function resetSession(string $why): void
|
||||
{
|
||||
$this->API->logger("Resetting session in DC {$this->datacenterId}...", Logger::WARNING);
|
||||
$this->API->logger("Resetting session in DC {$this->datacenterId} due to $why...", Logger::WARNING);
|
||||
$this->session_id = Tools::random(8);
|
||||
$this->session_in_seq_no = 0;
|
||||
$this->session_out_seq_no = 0;
|
||||
@ -172,7 +172,7 @@ trait Session
|
||||
public function createSession(): void
|
||||
{
|
||||
if ($this->session_id === null) {
|
||||
$this->resetSession();
|
||||
$this->resetSession("creating initial session");
|
||||
}
|
||||
$this->abstractionQueueMutex ??= new LocalKeyedMutex;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user