Don't log banned users too much
This commit is contained in:
parent
dc9f836932
commit
edb738bffb
|
@ -193,9 +193,7 @@ class Squirrel(Hazelnut):
|
||||||
hazelnut = self.find_hazelnut(addr[0], addr[1])
|
hazelnut = self.find_hazelnut(addr[0], addr[1])
|
||||||
if hazelnut.banned:
|
if hazelnut.banned:
|
||||||
# The client already sent errored packets
|
# The client already sent errored packets
|
||||||
self.send_packet(hazelnut, Packet.construct(WarningTLV.construct(
|
return Packet.construct(), hazelnut
|
||||||
"You got banned since you sent too much errored packets.")))
|
|
||||||
raise ValueError("Client is banned.")
|
|
||||||
try:
|
try:
|
||||||
pkt = Packet.unmarshal(data)
|
pkt = Packet.unmarshal(data)
|
||||||
except ValueError as error:
|
except ValueError as error:
|
||||||
|
@ -203,6 +201,10 @@ class Squirrel(Hazelnut):
|
||||||
hazelnut.errors += 1
|
hazelnut.errors += 1
|
||||||
self.send_packet(hazelnut, Packet.construct(WarningTLV.construct(
|
self.send_packet(hazelnut, Packet.construct(WarningTLV.construct(
|
||||||
f"An error occured while reading your packet: {error}")))
|
f"An error occured while reading your packet: {error}")))
|
||||||
|
if hazelnut.banned:
|
||||||
|
self.send_packet(hazelnut, Packet.construct(WarningTLV.construct(
|
||||||
|
"You got banned since you sent too much errored packets.")))
|
||||||
|
raise ValueError("Client is banned since there were too many errors.", error)
|
||||||
raise error
|
raise error
|
||||||
else:
|
else:
|
||||||
return pkt, hazelnut
|
return pkt, hazelnut
|
||||||
|
@ -761,7 +763,13 @@ class Worm(Thread):
|
||||||
pkt, hazelnut = self.squirrel.receive_packet()
|
pkt, hazelnut = self.squirrel.receive_packet()
|
||||||
except ValueError as error:
|
except ValueError as error:
|
||||||
self.squirrel.add_system_message("An error occurred while receiving a packet: {}".format(error))
|
self.squirrel.add_system_message("An error occurred while receiving a packet: {}".format(error))
|
||||||
|
self.squirrel.refresh_history()
|
||||||
|
self.squirrel.refresh_input()
|
||||||
else:
|
else:
|
||||||
|
if hazelnut.banned:
|
||||||
|
# Ignore banned hazelnuts
|
||||||
|
continue
|
||||||
|
|
||||||
for tlv in pkt.body:
|
for tlv in pkt.body:
|
||||||
tlv.handle(self.squirrel, hazelnut)
|
tlv.handle(self.squirrel, hazelnut)
|
||||||
self.squirrel.refresh_history()
|
self.squirrel.refresh_history()
|
||||||
|
|
Loading…
Reference in New Issue