From e8af996b2e01e673d792f00a8a93738b8927a5e1 Mon Sep 17 00:00:00 2001 From: pi-rho Date: Fri, 25 Jan 2013 20:03:33 -0600 Subject: [PATCH] added packet.text, packet.html into ip.Packet added processing for packet.text, packet.html into ip.HtmlSession added debug mode into ip.HtmlSession::__init__ updated start-here.py to document the above changes --- extra/start-here.py | 31 ++++++++++++++++++++++--------- netarch/ip.py | 28 ++++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/extra/start-here.py b/extra/start-here.py index 03f5e5c..36a780c 100644 --- a/extra/start-here.py +++ b/extra/start-here.py @@ -24,16 +24,19 @@ class StinkyPinkyPacket(ip.Packet): is deemed to not be part of the packet's data, it should be returned. Likewise, if the Packet needs more data, raise ip.NeedsMoreData - self.parts - a magic bag of values. self.parts[:-1] is highlighted when - printed iff the value == length(self.payload) - + self.parts - a magic bag of values; (!) when the value matches len(self.payload) self.payload - non-header packet data + self.opcode - an integer that triggers additional parsing + self.text - text to be displayed without prep (i.e. shell output) + self.html - html information for logging - self.opcode - an integer that triggers additional parsing, or special - display + return: + + If you need more data, raise ip.NeedMoreData() + If you have excess data, return it from this function ''' - self.parts = unpack(" .time { float: right; margin-left: 1em; font-size: 75%%; } .server { background-color: white; color: black; } - .client { background-color: #884; color: white; } + .client { background-color: #a8a8a8; color: black; } @@ -806,3 +816,13 @@ class HtmlSession(Session): self.sessfd.write('%s' % (cls, ts, cls)) self.sessfd.write(p.replace('\r\n', '\n')) self.sessfd.write('') + + def process(self, packet): + if self.debug: + packet.show() + if hasattr(packet, "html") and packet.html is not None: + self.log(packet.firstframe, packet.html, False) + if hasattr(packet, "text") and packet.text is not None: + if self.debug: + sys.stdout.write(packet.text) + self.log(packet.firstframe, packet.text, True)