Logo Search packages:      
Sourcecode: ufw version File versions

def src::frontend::UFWFrontend::set_rule (   self,
  rule,
  ip_version 
)

Updates firewall with rule

Definition at line 346 of file frontend.py.

00346                                         :
        '''Updates firewall with rule'''
        res = ""
        try:
            if self.backend.use_ipv6():
                if ip_version == "v4":
                    rule.set_v6(False)
                    res = self.backend.set_rule(rule)
                elif ip_version == "v6":
                    rule.set_v6(True)
                    res = self.backend.set_rule(rule)
                elif ip_version == "both":
                    rule.set_v6(False)
                    res = self.backend.set_rule(rule)
                    rule.set_v6(True)
                    res += "\n" + str(self.backend.set_rule(rule))
                else:
                    err_msg = _("Invalid IP version '%s'") % (ip_version)
                    raise UFWError(err_msg)
            else:
                if ip_version == "v4" or ip_version == "both":
                    rule.set_v6(False)
                    res = self.backend.set_rule(rule)
                elif ip_version == "v6":
                    err_msg = _("IPv6 support not enabled")
                    raise UFWError(err_msg)
                else:
                    err_msg = _("Invalid IP version '%s'") % (ip_version)
                    raise UFWError(err_msg)
        except UFWError, e:
            error(e.value)

        if rule.updated:
            warn_msg = _("Rule changed after normalization")
            warnings.warn(warn_msg)

        return res

    def do_action(self, action, rule, ip_version):


Generated by  Doxygen 1.6.0   Back to index