Пример #1
0
    def __init__(self, listeniface, listenport, fwrulefile, keydir):
        """Set up the logic.

        This is expected to be run with root privileges. Stuff like
        opening listening sockets is done here.

        @param listeniface: the ip address to listen on for incoming connections
        @type  listeniface: str
        @param listenport: tcp port number to listen on
        @type  listenport: int
        @param fwrulefile: name of the hip firewall's rulefile
        @type  fwrulefile: str
        @param keydir: directory where src_hi-keys are stored
        @type  keydir: str
        """
        # Run as root
        self.fwrulefile = fwrulefile
        self.keydir = keydir
        self.server = ConfigurationInterfaceServer(self, listeniface,
                                                   listenport)
Пример #2
0
    def __init__(self, listeniface, listenport, fwrulefile, keydir):
        """Set up the logic.

        This is expected to be run with root privileges. Stuff like
        opening listening sockets is done here.

        @param listeniface: the ip address to listen on for incoming connections
        @type  listeniface: str
        @param listenport: tcp port number to listen on
        @type  listenport: int
        @param fwrulefile: name of the hip firewall's rulefile
        @type  fwrulefile: str
        @param keydir: directory where src_hi-keys are stored
        @type  keydir: str
        """
        # Run as root
        self.fwrulefile = fwrulefile
        self.keydir = keydir
        self.server = ConfigurationInterfaceServer(
            self, listeniface, listenport)
Пример #3
0
class ManagementLogic(object):
    """Logic for operating on the firewall.
    """
    
    def __init__(self, listeniface, listenport, fwrulefile, keydir):
        """Set up the logic.

        This is expected to be run with root privileges. Stuff like
        opening listening sockets is done here.

        @param listeniface: the ip address to listen on for incoming connections
        @type  listeniface: str
        @param listenport: tcp port number to listen on
        @type  listenport: int
        @param fwrulefile: name of the hip firewall's rulefile
        @type  fwrulefile: str
        @param keydir: directory where src_hi-keys are stored
        @type  keydir: str
        """
        # Run as root
        self.fwrulefile = fwrulefile
        self.keydir = keydir
        self.server = ConfigurationInterfaceServer(
            self, listeniface, listenport)

    def run(self):
        """ManagementLogic's main loop.

        This is expected to run with user privileges.

        Note: the user needs to have enough privileges to create a new
        rulefile in the directory containing fwrulefile and to replace
        the old file with the new one.
        """
        # Run as user
        print 'testmessage'
        sys.stdout.flush()
        self.server.run()

    def enable_debugging(self):
        """Enable more verbose logging."""
        self.server.enable_debugging()

    def reload_firewall(self):
        """Send a request of reloading the firewall rules."""
        print 'reloadfw'
	sys.stdout.flush()
	syslog.syslog("requested firewall reload")
	
    def list_rules(self):
        """List current firewall rules.

        If the rulefile does not exist, it is created.

        @return: list of rules
        @rtype:  [Rule()]
        """
        try:
            return _list_rules(self.fwrulefile)
        except StandardError, e:
            syslog.syslog("list_rules() failed: %s" % e)
            return []
Пример #4
0
class ManagementLogic(object):
    """Logic for operating on the firewall.
    """
    def __init__(self, listeniface, listenport, fwrulefile, keydir):
        """Set up the logic.

        This is expected to be run with root privileges. Stuff like
        opening listening sockets is done here.

        @param listeniface: the ip address to listen on for incoming connections
        @type  listeniface: str
        @param listenport: tcp port number to listen on
        @type  listenport: int
        @param fwrulefile: name of the hip firewall's rulefile
        @type  fwrulefile: str
        @param keydir: directory where src_hi-keys are stored
        @type  keydir: str
        """
        # Run as root
        self.fwrulefile = fwrulefile
        self.keydir = keydir
        self.server = ConfigurationInterfaceServer(self, listeniface,
                                                   listenport)

    def run(self):
        """ManagementLogic's main loop.

        This is expected to run with user privileges.

        Note: the user needs to have enough privileges to create a new
        rulefile in the directory containing fwrulefile and to replace
        the old file with the new one.
        """
        # Run as user
        print 'testmessage'
        sys.stdout.flush()
        self.server.run()

    def enable_debugging(self):
        """Enable more verbose logging."""
        self.server.enable_debugging()

    def reload_firewall(self):
        """Send a request of reloading the firewall rules."""
        print 'reloadfw'
        sys.stdout.flush()
        syslog.syslog("requested firewall reload")

    def list_rules(self):
        """List current firewall rules.

        If the rulefile does not exist, it is created.

        @return: list of rules
        @rtype:  [Rule()]
        """
        try:
            return _list_rules(self.fwrulefile)
        except StandardError, e:
            syslog.syslog("list_rules() failed: %s" % e)
            return []