From 8aa2f8613af6bb27a57728eddfe677fa7c70186a Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Wed, 25 Apr 2018 22:46:05 +0200 Subject: [PATCH] File transfer example --- Examples/Filetransfer.py | 4 +++- RNS/Packet.py | 2 +- RNS/Reticulum.py | 12 +++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Examples/Filetransfer.py b/Examples/Filetransfer.py index 9fb876b..d4a7f09 100644 --- a/Examples/Filetransfer.py +++ b/Examples/Filetransfer.py @@ -86,8 +86,10 @@ def client_connected(link): # We pack a list of files for sending in a packet data = umsgpack.packb(list_files()) + RNS.log(str(len(data))) + # Check the size of the packed data - if len(data) <= RNS.Resource.SDU: + if len(data) <= RNS.Reticulum.LINK_MDU: # If it fits in one packet, we will just # send it as a single packet over the link. list_packet = RNS.Packet(link, data) diff --git a/RNS/Packet.py b/RNS/Packet.py index 38321ea..c9f8e26 100755 --- a/RNS/Packet.py +++ b/RNS/Packet.py @@ -39,7 +39,7 @@ class Packet: # This is used to calculate allowable # payload sizes - HEADER_MAXSIZE = 23 + HEADER_MAXSIZE = RNS.Reticulum.HEADER_MAXSIZE # TODO: This should be calculated # more intelligently diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index 3e1b6a7..0eea757 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -1,6 +1,7 @@ from Interfaces import * import ConfigParser from vendor.configobj import ConfigObj +import RNS import atexit import struct import array @@ -11,9 +12,14 @@ import RNS #import traceback class Reticulum: - MTU = 500 - router = None - config = None + MTU = 500 + HEADER_MAXSIZE = 23 + + PAD_AES_HMAC = 64 + MDU = MTU - HEADER_MAXSIZE + LINK_MDU = MDU - PAD_AES_HMAC + router = None + config = None configdir = os.path.expanduser("~")+"/.reticulum" configpath = ""