Fixed missing check on malformed advertisement packets
This commit is contained in:
parent
8fa6ec144c
commit
038c696db9
46
RNS/Link.py
46
RNS/Link.py
@ -835,10 +835,11 @@ class Link:
|
|||||||
for pending_request in self.pending_requests:
|
for pending_request in self.pending_requests:
|
||||||
if pending_request.request_id == request_id:
|
if pending_request.request_id == request_id:
|
||||||
response_resource = RNS.Resource.accept(packet, callback=self.response_resource_concluded, progress_callback=pending_request.response_resource_progress, request_id = request_id)
|
response_resource = RNS.Resource.accept(packet, callback=self.response_resource_concluded, progress_callback=pending_request.response_resource_progress, request_id = request_id)
|
||||||
pending_request.response_size = RNS.ResourceAdvertisement.read_size(packet)
|
if response_resource != None:
|
||||||
pending_request.response_transfer_size = RNS.ResourceAdvertisement.read_transfer_size(packet)
|
pending_request.response_size = RNS.ResourceAdvertisement.read_size(packet)
|
||||||
pending_request.started_at = time.time()
|
pending_request.response_transfer_size = RNS.ResourceAdvertisement.read_transfer_size(packet)
|
||||||
pending_request.response_resource_progress(response_resource)
|
pending_request.started_at = time.time()
|
||||||
|
pending_request.response_resource_progress(response_resource)
|
||||||
|
|
||||||
elif self.resource_strategy == Link.ACCEPT_NONE:
|
elif self.resource_strategy == Link.ACCEPT_NONE:
|
||||||
pass
|
pass
|
||||||
@ -1173,25 +1174,26 @@ class RequestReceipt():
|
|||||||
|
|
||||||
|
|
||||||
def response_resource_progress(self, resource):
|
def response_resource_progress(self, resource):
|
||||||
if not self.status == RequestReceipt.FAILED:
|
if resource != None:
|
||||||
self.status = RequestReceipt.RECEIVING
|
if not self.status == RequestReceipt.FAILED:
|
||||||
if self.packet_receipt != None:
|
self.status = RequestReceipt.RECEIVING
|
||||||
if self.packet_receipt.status != RNS.PacketReceipt.DELIVERED:
|
if self.packet_receipt != None:
|
||||||
self.packet_receipt.status = RNS.PacketReceipt.DELIVERED
|
if self.packet_receipt.status != RNS.PacketReceipt.DELIVERED:
|
||||||
self.packet_receipt.proved = True
|
self.packet_receipt.status = RNS.PacketReceipt.DELIVERED
|
||||||
self.packet_receipt.concluded_at = time.time()
|
self.packet_receipt.proved = True
|
||||||
if self.packet_receipt.callbacks.delivery != None:
|
self.packet_receipt.concluded_at = time.time()
|
||||||
self.packet_receipt.callbacks.delivery(self.packet_receipt)
|
if self.packet_receipt.callbacks.delivery != None:
|
||||||
|
self.packet_receipt.callbacks.delivery(self.packet_receipt)
|
||||||
|
|
||||||
self.progress = resource.get_progress()
|
self.progress = resource.get_progress()
|
||||||
|
|
||||||
if self.callbacks.progress != None:
|
if self.callbacks.progress != None:
|
||||||
try:
|
try:
|
||||||
self.callbacks.progress(self)
|
self.callbacks.progress(self)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Error while executing response progress callback from "+str(self)+". The contained exception was: "+str(e), RNS.LOG_ERROR)
|
RNS.log("Error while executing response progress callback from "+str(self)+". The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
else:
|
else:
|
||||||
resource.cancel()
|
resource.cancel()
|
||||||
|
|
||||||
|
|
||||||
def response_received(self, response):
|
def response_received(self, response):
|
||||||
|
Loading…
Reference in New Issue
Block a user