Ignore duplicate messages

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
2020-12-21 16:04:16 +01:00
parent 17ca4d105f
commit ebd6c18032
2 changed files with 37 additions and 2 deletions

View File

@ -208,7 +208,10 @@ class DataTLV(TLV):
TODO: Check that the tuple (sender_id, nonce) is unique to avoid duplicates.
"""
msg = self.data.decode('UTF-8')
squirrel.add_message(msg)
if not squirrel.receive_message_from(msg, self.sender_id, self.nonce):
# The message was already received
return
nickname_match = re.match("(.*): (.*)", msg)
if nickname_match is None:
squirrel.send_packet(sender, Packet.construct(WarningTLV.construct(