Improved malformed packet detection
This commit is contained in:
parent
4253175627
commit
fdaa58a6fa
|
@ -765,7 +765,7 @@ class Link:
|
||||||
return plaintext
|
return plaintext
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Decryption failed on link "+str(self)+". The contained exception was: "+str(e), RNS.LOG_ERROR)
|
RNS.log("Decryption failed on link "+str(self)+". The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
RNS.log(traceback.format_exc(), RNS.LOG_ERROR)
|
# RNS.log(traceback.format_exc(), RNS.LOG_ERROR)
|
||||||
# TODO: Think long about implications here
|
# TODO: Think long about implications here
|
||||||
# self.teardown()
|
# self.teardown()
|
||||||
|
|
||||||
|
|
|
@ -185,6 +185,7 @@ class Packet:
|
||||||
|
|
||||||
|
|
||||||
def unpack(self):
|
def unpack(self):
|
||||||
|
try:
|
||||||
self.flags = self.raw[0]
|
self.flags = self.raw[0]
|
||||||
self.hops = self.raw[1]
|
self.hops = self.raw[1]
|
||||||
|
|
||||||
|
@ -206,6 +207,11 @@ class Packet:
|
||||||
|
|
||||||
self.packed = False
|
self.packed = False
|
||||||
self.update_hash()
|
self.update_hash()
|
||||||
|
return True
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
RNS.log("Received malformed packet, dropping it. The contained exception was: "+str(e), RNS.LOG_EXTREME)
|
||||||
|
return False
|
||||||
|
|
||||||
def send(self):
|
def send(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -585,7 +585,9 @@ class Transport:
|
||||||
Transport.jobs_locked = True
|
Transport.jobs_locked = True
|
||||||
|
|
||||||
packet = RNS.Packet(None, raw)
|
packet = RNS.Packet(None, raw)
|
||||||
packet.unpack()
|
if not packet.unpack():
|
||||||
|
return
|
||||||
|
|
||||||
packet.receiving_interface = interface
|
packet.receiving_interface = interface
|
||||||
packet.hops += 1
|
packet.hops += 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue