Use a random squirrel id and an incremental nonce

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

View File

@ -227,13 +227,17 @@ class DataTLV(TLV):
sender.nickname = nickname
@staticmethod
def construct(message: str) -> "DataTLV":
def construct(message: str, squirrel: Any) -> "DataTLV":
tlv = DataTLV()
tlv.type = 4
tlv.sender_id = 42 # FIXME Use the good sender id
tlv.nonce = 42 # FIXME Use an incremental nonce
tlv.sender_id = squirrel.id if squirrel else 0
tlv.nonce = squirrel.incr_nonce if squirrel else 0
tlv.data = message.encode("UTF-8")
tlv.length = 12 + len(tlv.data)
if squirrel:
squirrel.incr_nonce += 1
return tlv