mirror of https://github.com/dirtbags/netarch.git
add DumbSession and DropSession
add a magic method to instantiate Sessions
This commit is contained in:
parent
f9c8ea9d45
commit
a86ad843c2
|
@ -691,6 +691,11 @@ class Session(object):
|
||||||
|
|
||||||
self.setup()
|
self.setup()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def session(*args, **kwargs):
|
||||||
|
cls, args = args[0], args[1:]
|
||||||
|
return cls(*args, **kwargs)
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
"""Set things up."""
|
"""Set things up."""
|
||||||
|
|
||||||
|
@ -772,6 +777,18 @@ class Session(object):
|
||||||
self.done()
|
self.done()
|
||||||
|
|
||||||
|
|
||||||
|
class DumbSession(Session):
|
||||||
|
''' Just a dumb Session '''
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class DropSession(Session):
|
||||||
|
''' a Session that drops all data passed to it '''
|
||||||
|
|
||||||
|
def process(self, packet):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class HtmlSession(Session):
|
class HtmlSession(Session):
|
||||||
def __init__(self, frame, packetClass=Packet, debug=True):
|
def __init__(self, frame, packetClass=Packet, debug=True):
|
||||||
Session.__init__(self, frame, packetClass)
|
Session.__init__(self, frame, packetClass)
|
||||||
|
|
Loading…
Reference in New Issue