mirror of
https://github.com/markqvist/Reticulum.git
synced 2026-11-24 17:06:23 -05:00
Initial commit
This commit is contained in:
commit
9a9630cfd2
3 changed files with 218 additions and 0 deletions
24
Packet.py
Normal file
24
Packet.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import struct
|
||||
from Transport import *
|
||||
|
||||
class Packet:
|
||||
MTU = 960
|
||||
|
||||
def __init__(self, destination, data):
|
||||
self.destination = destination
|
||||
self.data = data
|
||||
self.flags = 0x00
|
||||
self.header = 0x00
|
||||
self.raw = None
|
||||
self.sent = False
|
||||
|
||||
def send(self):
|
||||
self.header = struct.pack("!B", self.header ^ self.destination.type ^ self.flags)
|
||||
self.header += self.destination.hash
|
||||
self.ciphertext = self.destination.encrypt(self.data)
|
||||
self.raw = self.header + self.ciphertext
|
||||
|
||||
if len(self.raw) > Packet.MTU:
|
||||
raise IOError("Packet size exceeds MTU of "+Packet.MTU+" bytes")
|
||||
|
||||
Transport.outbound(self.raw)
|
||||
Loading…
Add table
Add a link
Reference in a new issue