Reticulum/FPE/Transport.py
2018-03-19 20:51:26 +01:00

36 lines
926 B
Python
Executable File

import FPE
class Transport:
# Constants
BROADCAST = 0x00;
TRANSPORT = 0x01;
RELAY = 0x02;
TUNNEL = 0x03;
types = [BROADCAST, TRANSPORT, RELAY, TUNNEL]
packet_hashlist = []
@staticmethod
def outbound(raw):
FPE.FlexPE.outbound(raw)
@staticmethod
def inbound(raw):
packet_hash = FPE.Identity.fullHash(raw)
if not packet_hash in Transport.packet_hashlist:
Transport.packet_hashlist.append(packet_hash)
packet = FPE.Packet(None, raw)
packet.unpack()
if packet.packet_type == FPE.Packet.ANNOUNCE:
FPE.Identity.validateAnnounce(packet)
if packet.packet_type == FPE.Packet.RESOURCE:
for destination in FlexPE.destinations:
if destination.hash == packet.destination_hash and destination.type == packet.destination_type:
destination.receive(packet.data)
@staticmethod
def registerDestination(destination):
FPE.FlexPE.addDestination(destination)