SetTarget

class SetTarget(operation: int, ipset_name: str, ipset_flags: List[str], *, timeout: Optional[int] = None, exist: Optional[bool] = False)[source]

This class provides access to the SET target

Parameters:
  • operation – identifies what ipset operation to perform; possible values include SetTarget.ADD_SET or SetTarget.DEL_SET

  • ipset_name – name of ipset

  • ipset_flags – list of flags identifying packet data; at least one flag must be present, otherwise an IptablesError exception will be raised

  • timeout – timeout value for added entries

  • exist – if True, reset timeout when adding an entry that exists already

ADD_SET = 1

Add operation

DEL_SET = 2

Delete operation

get_ipset_name() str[source]

Returns the ipset name

get_ipset_flags() List[str][source]

Returns the ipset flags

get_operation() int[source]

Returns the operation

is_updating_existing() bool[source]

Returns True if the --exist option is set.

update_existing() Target[source]

Set the --exist option.

get_timeout() Optional[int][source]

Returns the timeout, or None

set_timeout(timeout: Optional[int]) Target[source]

Set the timeout value for entries added to the ipset.

to_iptables_args() List[str][source]

Returns a list of iptables(8) arguments

get_target_name() str

Returns the target name

is_terminating() bool

Returns True if this is a terminating target