diff options
Diffstat (limited to 'src/Channel.cpp')
-rw-r--r-- | src/Channel.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Channel.cpp b/src/Channel.cpp index 41233ad..5043665 100644 --- a/src/Channel.cpp +++ b/src/Channel.cpp @@ -52,7 +52,7 @@ namespace dchat u64 pingTimestamp = unsignedDeserializer.extract<u64>(); // TODO: A malicious peer can capture the packets and reply them after the user has reconnect and counter has reset, need to fix this somehow. // One solution is for the user to store the counter locally in file and continue using it when reconnecting - if(pingCounter > user->pingCounter) + if(pingTimestamp > user->pingTimestamp) { user->pingCounter = pingCounter; user->pingTimestamp = pingTimestamp; @@ -64,6 +64,12 @@ namespace dchat } return result; }); + + if(localUser->type == User::Type::ONLINE_LOCAL_USER) + { + auto onlineLocalUser = static_cast<OnlineLocalUser*>(localUser); + sendPing(onlineLocalUser->pingCounter + 1, database->getSyncedTimestampUtc().getCombined()); + } } } |