diff --git a/td/mtproto/AuthData.cpp b/td/mtproto/AuthData.cpp index aa769d1d..115b99c8 100644 --- a/td/mtproto/AuthData.cpp +++ b/td/mtproto/AuthData.cpp @@ -23,7 +23,7 @@ Status MessageIdDuplicateChecker::check(int64 message_id) { if (saved_message_ids_.size() == MAX_SAVED_MESSAGE_IDS) { auto oldest_message_id = *saved_message_ids_.begin(); if (message_id < oldest_message_id) { - return Status::Error(1, PSLICE() << "Ignore very old message_id " << tag("oldest message_id", oldest_message_id) + return Status::Error(2, PSLICE() << "Ignore very old message_id " << tag("oldest message_id", oldest_message_id) << tag("got message_id", message_id)); } } diff --git a/td/mtproto/SessionConnection.cpp b/td/mtproto/SessionConnection.cpp index 4a20035c..b86167a4 100644 --- a/td/mtproto/SessionConnection.cpp +++ b/td/mtproto/SessionConnection.cpp @@ -488,6 +488,11 @@ Status SessionConnection::on_slice_packet(const MsgInfo &info, Slice packet) { // It is an update... I hope. auto status = auth_data_->check_update(info.message_id); if (status.is_error()) { + if (status.code() == 2) { + LOG(WARNING) << "Receive too old update: " << status; + callback_->on_session_failed(Status::Error("Receive too old update")); + return status; + } VLOG(mtproto) << "Skip update " << info.message_id << " from " << get_name() << " created in " << (Time::now() - created_at_) << ": " << status; return Status::OK(); @@ -666,6 +671,10 @@ Status SessionConnection::on_raw_packet(const td::mtproto::PacketInfo &info, Buf LOG(WARNING) << "Packet ignored " << status; send_ack(info.message_id); return Status::OK(); + } else if (status.code() == 2) { + LOG(WARNING) << "Receive too old packet: " << status; + callback_->on_session_failed(Status::Error("Receive too old packet")); + return status; } else { return status; }