(self, rule, name=None, target=None, revision=None, goto=None)
*rule* is the Rule object this match belongs to; it can be changed
        later via *set_rule()*.  *name* is the name of the iptables target
        extension (in upper case), *target* is the raw buffer of the target
        structure if the caller has it.  Either *name* or *target* must be
        provided.  *revision* is the revision number of the extension that
        should be used; different revisions use different structures in C and
        they usually only work with certain kernel versions. Python-iptables
        by default will use the latest revision available.
        If goto is True, then it converts '-j' to '-g'.
*rule* is the Rule object this match belongs to; it can be changed
        later via *set_rule()*.  *name* is the name of the iptables target
        extension (in upper case), *target* is the raw buffer of the target
        structure if the caller has it.  Either *name* or *target* must be
        provided.  *revision* is the revision number of the extension that
        should be used; different revisions use different structures in C and
        they usually only work with certain kernel versions. Python-iptables
        by default will use the latest revision available.
        If goto is True, then it converts '-j' to '-g'.
* rule * is the Rule object this match belongs to ; it can be changed later via * set_rule () * . * name * is the name of the iptables target extension ( in upper case ) * target * is the raw buffer of the target structure if the caller has it . Either * name * or * target * must be provided . * revision * is the revision number of the extension that should be used ; different revisions use different structures in C and they usually only work with certain kernel versions . Python - iptables by default will use the latest revision available . If goto is True then it converts - j to - g .
def __init__(self, rule, name=None, target=None, revision=None, goto=None):
        """
        *rule* is the Rule object this match belongs to; it can be changed
        later via *set_rule()*.  *name* is the name of the iptables target
        extension (in upper case), *target* is the raw buffer of the target
        structure if the caller has it.  Either *name* or *target* must be
        provided.  *revision* is the revision number of the extension that
        should be used; different revisions use different structures in C and
        they usually only work with certain kernel versions. Python-iptables
        by default will use the latest revision available.
        If goto is True, then it converts '-j' to '-g'.
        """
        if name is None and target is None:
            raise ValueError("can't create target based on nothing")
        if name is None:
            name = target.u.user.name.decode()
        self._name = name
        self._rule = rule
        self._orig_parse = None
        self._orig_options = None

        # NOTE:
        # get_ip() returns the 'ip' structure that contains (1)the 'flags' field, and
        # (2)the value for the GOTO flag.
        # We *must* use get_ip() because the actual name of the field containing the
        # structure apparently differs between implementation
        ipstruct = rule.get_ip()
        f_goto_attrs = [a for a in dir(ipstruct) if a.endswith('_F_GOTO')]
        if len(f_goto_attrs) == 0:
            raise RuntimeError('What kind of struct is this? It does not have "*_F_GOTO" constant!')
        _F_GOTO = getattr(ipstruct, f_goto_attrs[0])

        if target is not None or goto is None:
            # We are 'decoding' existing Target
            self._goto = bool(ipstruct.flags & _F_GOTO)
        if goto is not None:
            assert isinstance(goto, bool)
            self._goto = goto
            if goto:
                ipstruct.flags |= _F_GOTO
            else:
                ipstruct.flags &= ~_F_GOTO

        self._xt = xtables(rule.nfproto)

        module = (self._is_standard_target() and
                  self._xt.find_target('') or
                  self._xt.find_target(name))
        real_name = module and getattr(module[0], 'real_name', None) or None
        if real_name:
            # Alias name, look up real module.
            self._name = real_name.decode()
            self._orig_parse = getattr(module[0], 'x6_parse', None)
            self._orig_options = getattr(module[0], 'x6_options', None)
            module = self._xt.find_target(real_name)
        if not module:
            raise XTablesError("can't find target %s" % (name))

        self._module = module[0]
        self._module.tflags = 0
        if revision is not None:
            self._revision = revision
        else:
            self._revision = self._module.revision

        self._create_buffer(target)

        if self._is_standard_target():
            self.standard_target = name
        elif target:
            self._check_alias()
def __init__ ( self , rule , name = None , target = None , revision = None , goto = None ) : if name is None and target is None : raise ValueError ( "can't create target based on nothing" ) if name is None : name = target . u . user . name . decode ( ) self . _name = name self . _rule = rule self . _orig_parse = None self . _orig_options = None # NOTE: # get_ip() returns the 'ip' structure that contains (1)the 'flags' field, and # (2)the value for the GOTO flag. # We *must* use get_ip() because the actual name of the field containing the # structure apparently differs between implementation ipstruct = rule . get_ip ( ) f_goto_attrs = [ a for a in dir ( ipstruct ) if a . endswith ( '_F_GOTO' ) ] if len ( f_goto_attrs ) == 0 : raise RuntimeError ( 'What kind of struct is this? It does not have "*_F_GOTO" constant!' ) _F_GOTO = getattr ( ipstruct , f_goto_attrs [ 0 ] ) if target is not None or goto is None : # We are 'decoding' existing Target self . _goto = bool ( ipstruct . flags & _F_GOTO ) if goto is not None : assert isinstance ( goto , bool ) self . _goto = goto if goto : ipstruct . flags |= _F_GOTO else : ipstruct . flags &= ~ _F_GOTO self . _xt = xtables ( rule . nfproto ) module = ( self . _is_standard_target ( ) and self . _xt . find_target ( '' ) or self . _xt . find_target ( name ) ) real_name = module and getattr ( module [ 0 ] , 'real_name' , None ) or None if real_name : # Alias name, look up real module. self . _name = real_name . decode ( ) self . _orig_parse = getattr ( module [ 0 ] , 'x6_parse' , None ) self . _orig_options = getattr ( module [ 0 ] , 'x6_options' , None ) module = self . _xt . find_target ( real_name ) if not module : raise XTablesError ( "can't find target %s" % ( name ) ) self . _module = module [ 0 ] self . _module . tflags = 0 if revision is not None : self . _revision = revision else : self . _revision = self . _module . revision self . _create_buffer ( target ) if self . _is_standard_target ( ) : self . standard_target = name elif target : self . _check_alias ( )