netarch/dumbdecode.py

21 lines
397 B
Python
Raw Normal View History

2018-07-16 08:55:58 -06:00
#! /usr/bin/python3
2018-07-09 17:14:19 -06:00
import sys
from netarch import ip
from netarch import *
class DumbPacket(ip.Packet):
def parse(self, data):
self.payload = data
class DumbSession(ip.Session):
Packet = DumbPacket
2018-07-09 17:14:19 -06:00
s = None
reseq = ip.Dispatch(*sys.argv[1:])
for h, d in reseq:
srv, first, chunk = d
if not s:
s = DumbSession(first)
2018-07-09 17:14:19 -06:00
s.handle(srv, first, chunk, reseq.last)