Warn other user is the data contains a zero

This commit is contained in:
Yohann D'ANELLO 2021-01-09 20:09:53 +01:00
parent c136f34d9c
commit eb97a47a25
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 6 additions and 0 deletions

View File

@ -301,6 +301,12 @@ class DataTLV(TLV):
"You are not my neighbour, I don't listen to your DataTLV. Please say me Hello before.")))
return
if 0 in self.data:
user.send_packet(sender, Packet.construct(WarningTLV.construct(
f"The length of your DataTLV mismatches. You told me that the length is {len(self.data)} "
f"while a zero was found at index {self.data.index(0)}.")))
self.data = self.data[:self.data.index(0)]
msg = self.data.decode('UTF-8')
# Acknowledge the packet