Logo Search packages:      
Sourcecode: ufw version File versions

def src::common::UFWRule::format_rule (   self  ) 

Format rule for for later parsing

Definition at line 63 of file common.py.

00063                          :
        '''Format rule for for later parsing'''
        str = ""

        # Protocol is handled below
        if self.protocol == "any":
            str = " -p all"
        else:
            str = " -p " + self.protocol

            if self.multi:
                str += " -m multiport"
                if self.dport != "any" and self.sport != "any":
                    str += " --dports " + self.dport
                    str += " -m multiport"
                    str += " --sports " + self.sport
                elif self.dport != "any":
                    str += " --dports " + self.dport
                elif self.sport != "any":
                    str += " --sports " + self.sport

        if self.dst != "0.0.0.0/0" and self.dst != "::/0":
            str += " -d " + self.dst
        if not self.multi and self.dport != "any":
            str += " --dport " + self.dport
        if self.src != "0.0.0.0/0" and self.src != "::/0":
            str += " -s " + self.src
        if not self.multi and self.sport != "any":
            str += " --sport " + self.sport
        if self.action == "allow":
            str += " -j ACCEPT"
        elif self.action == "limit":
            # Caller needs to change this
            str += " -j LIMIT"
        else:
            str += " -j DROP"

        return str.strip()

    def set_action(self, action):


Generated by  Doxygen 1.6.0   Back to index