from pymin.seqtools import Sequence
from pymin.dispatcher import Handler, handler, HandlerError
from pymin.services.util import Restorable, ConfigWriter, RestartHandler, \
ReloadHandler, TransactionalHandler, \
from pymin.seqtools import Sequence
from pymin.dispatcher import Handler, handler, HandlerError
from pymin.services.util import Restorable, ConfigWriter, RestartHandler, \
ReloadHandler, TransactionalHandler, \
class PortForward(Sequence):
r"""PortForward(dev, protocol, port, dst[, dst_port[, ...]]) -> PortForward.
class PortForward(Sequence):
r"""PortForward(dev, protocol, port, dst[, dst_port[, ...]]) -> PortForward.
-class NatHandler(Restorable, ConfigWriter, RestartHandler, ReloadHandler,
- TransactionalHandler):
+class NatHandler(Restorable, ConfigWriter, ReloadHandler, ServiceHandler,
+ TransactionalHandler):
r"""NatHandler([pickle_dir[, config_dir]]) -> NatHandler instance.
Handles NAT commands using iptables.
r"""NatHandler([pickle_dir[, config_dir]]) -> NatHandler instance.
Handles NAT commands using iptables.
- @handler(u'Start the service.')
- def start(self):
+ def _service_start(self):
+ log.debug(u'NatHandler._service_start(): flushing nat table')
+ call(('iptables', '-t', 'nat', '-F'))
call(['iptables'] + port.as_call_list(index+1))
for (index, snat) in enumerate(self.snats):
call(['iptables'] + port.as_call_list(index+1))
for (index, snat) in enumerate(self.snats):
call(['iptables'] + snat.as_call_list(index+1))
for (index, masq) in enumerate(self.masqs):
call(['iptables'] + snat.as_call_list(index+1))
for (index, masq) in enumerate(self.masqs):
call(('iptables', '-t', 'nat', '-F'))
call(('iptables', '-t', 'nat', '-F'))
def __init__(self, pickle_dir='.'):
r"Initialize the object, see class documentation for details."
def __init__(self, pickle_dir='.'):
r"Initialize the object, see class documentation for details."
self.forward = PortForwardHandler(self)
self.snat = SNatHandler(self)
self.masq = MasqHandler(self)
self.forward = PortForwardHandler(self)
self.snat = SNatHandler(self)
self.masq = MasqHandler(self)