mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-05 13:50:14 +00:00
36 lines
926 B
Python
Executable File
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) |