Improved link request/response handling.

This commit is contained in:
Mark Qvist 2021-09-03 16:23:31 +02:00
parent ecf0c55fd6
commit 58d48c18f4
2 changed files with 41 additions and 41 deletions

View File

@ -245,7 +245,7 @@ class Link:
RNS.log("Link "+str(self)+" established with "+str(self.destination)+", RTT is "+str(self.rtt), RNS.LOG_VERBOSE) RNS.log("Link "+str(self)+" established with "+str(self.destination)+", RTT is "+str(self.rtt), RNS.LOG_VERBOSE)
rtt_data = umsgpack.packb(self.rtt) rtt_data = umsgpack.packb(self.rtt)
rtt_packet = RNS.Packet(self, rtt_data, context=RNS.Packet.LRRTT) rtt_packet = RNS.Packet(self, rtt_data, context=RNS.Packet.LRRTT)
rtt_packet.send() #rtt_packet.send()
self.had_outbound() self.had_outbound()
self.status = Link.ACTIVE self.status = Link.ACTIVE
@ -491,6 +491,7 @@ class Link:
self.had_outbound() self.had_outbound()
def handle_request(self, request_id, unpacked_request): def handle_request(self, request_id, unpacked_request):
if self.status == Link.ACTIVE:
requested_at = unpacked_request[0] requested_at = unpacked_request[0]
path_hash = unpacked_request[1] path_hash = unpacked_request[1]
request_data = unpacked_request[2] request_data = unpacked_request[2]
@ -525,6 +526,7 @@ class Link:
RNS.log("Request "+RNS.prettyhexrep(request_id)+" from "+identity_string+" not allowed for: "+str(path), RNS.LOG_DEBUG) RNS.log("Request "+RNS.prettyhexrep(request_id)+" from "+identity_string+" not allowed for: "+str(path), RNS.LOG_DEBUG)
def handle_response(self, request_id, response_data): def handle_response(self, request_id, response_data):
if self.status == Link.ACTIVE:
remove = None remove = None
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:

View File

@ -46,8 +46,6 @@ class Resource:
# bz2 before sending. # bz2 before sending.
AUTO_COMPRESS_MAX_SIZE = MAX_EFFICIENT_SIZE AUTO_COMPRESS_MAX_SIZE = MAX_EFFICIENT_SIZE
# TODO: Should be allocated more
# intelligently
PART_TIMEOUT_FACTOR = 3 PART_TIMEOUT_FACTOR = 3
MAX_RETRIES = 5 MAX_RETRIES = 5
SENDER_GRACE_TIME = 10 SENDER_GRACE_TIME = 10