Cleaning files.

This commit is contained in:
eichhornchen 2021-01-09 21:32:17 +01:00
parent 83998e639b
commit 6aa714ef4c
2 changed files with 7 additions and 9 deletions

View File

@ -32,7 +32,6 @@ class TLV:
"""
Ensure that the TLV is well-formed.
Raises a ValueError if it is not the case.
TODO: Make some tests
"""
return True
@ -76,7 +75,7 @@ class Pad1TLV(TLV):
if not sender.active or not sender.symmetric or not sender.id:
# It doesn't say hello, we don't listen to it
user.send_packet(sender, Packet.construct(WarningTLV.construct(
"You are not my neighbour, I don't listen to your Pad1TLV. Please say me Hello before.")))
"You are not my neighbour, I won't listen to your Pad1TLV. Please say Hello to me before.")))
return
user.add_system_message("I received a Pad1TLV, how disapointing.")
@ -126,7 +125,7 @@ class PadNTLV(TLV):
if not sender.active or not sender.symmetric or not sender.id:
# It doesn't say hello, we don't listen to it
user.send_packet(sender, Packet.construct(WarningTLV.construct(
"You are not my neighbour, I don't listen to your PadNTLV. Please say me Hello before.")))
"You are not my neighbour, I won't listen to your PadNTLV. Please say Hello to me before.")))
return
user.add_system_message(f"I received {self.length} zeros.")
@ -242,7 +241,7 @@ class NeighbourTLV(TLV):
if not sender.active or not sender.symmetric or not sender.id:
# It doesn't say hello, we don't listen to it
user.send_packet(sender, Packet.construct(WarningTLV.construct(
"You are not my neighbour, I don't listen to your NeighbourTLV. Please say me Hello before.")))
"You are not my neighbour, I won't listen to your NeighbourTLV. Please say Hello to me before.")))
return
if (self.ip_address, self.port) in user.addresses:
@ -301,7 +300,7 @@ class DataTLV(TLV):
if not sender.active or not sender.symmetric or not sender.id:
# It doesn't say hello, we don't listen to it
user.send_packet(sender, Packet.construct(WarningTLV.construct(
"You are not my neighbour, I don't listen to your DataTLV. Please say me Hello before.")))
"You are not my neighbour, I won't listen to your DataTLV. Please say Hello to me before.")))
return
if 0 in self.data:
@ -376,7 +375,7 @@ class AckTLV(TLV):
if not sender.active or not sender.symmetric or not sender.id:
# It doesn't say hello, we don't listen to it
user.send_packet(sender, Packet.construct(WarningTLV.construct(
"You are not my neighbour, I don't listen to your AckTLV. Please say me Hello before.")))
"You are not my neighbour, I won't listen to your AckTLV. Please say Hello to me before.")))
return
user.add_system_message(f"I received an AckTLV from {sender}")
@ -421,13 +420,13 @@ class GoAwayTLV(TLV):
if not sender.active or not sender.symmetric or not sender.id:
# It doesn't say hello, we don't listen to it
user.send_packet(sender, Packet.construct(WarningTLV.construct(
"You are not my neighbour, I don't listen to your GoAwayTLV. Please say me Hello before.")))
"You are not my neighbour, I won't listen to your GoAwayTLV. Please say Hello to me before.")))
return
if sender.active:
sender.active = False
user.update_peer_table(sender)
user.add_system_message("Some told me that he went away : " + self.message)
user.add_system_message("Someone told me that he went away : " + self.message)
@staticmethod
def construct(ga_type: GoAwayType, message: str) -> "GoAwayTLV":

View File

@ -1203,7 +1203,6 @@ class Message:
This is useful to check unicity or to save and load messages.
"""
content: str
# TODO: Replace the id by the good (potential) peer
sender_id: int
nonce: int
created_at: datetime