SetMatch¶
Example:
>>> from linuxnet.iptables import SetMatch
>>> m = SetMatch()
>>> m.match_set().equals('foo', 'src,dst')
<linuxnet.iptables.matches.setmatch.SetMatch object at 0x7f886d7cf9a0>
>>> m.to_iptables_args()
['-m', 'set', '--match-set', 'foo', 'src,dst']
- class SetMatch[source]¶
Match against IP sets defined via ipset(8)
- match_set() MatchSetCriterion[source]¶
Returns the criterion to identify the IPset and flags
- return_nomatch() BooleanCriterion[source]¶
Specify the
--return-nomatchoption.
- update_counters() BooleanCriterion[source]¶
Specify update of packet/byte counters
- update_subcounters() BooleanCriterion[source]¶
Specify update of packet/byte counters of the matching element in the member set of a list type
- packet_counter() PacketCounterCriterion[source]¶
Returns the criterion comparing against the set’s packet counter
- byte_counter() ByteCounterCriterion[source]¶
Returns the criterion comparing against the set’s byte counter
MatchSetCriterion¶
- class MatchSetCriterion(match: Match)[source]¶
Match against a set defined by ipset(8)
- get_value() Tuple[str, str][source]¶
The value is the tuple (set-name, flags)
- Return type:
tuple of
(str, str)
- equals(name: str, flags: str) Match[source]¶
Check against the specified ipset name using the specified flags
- Parameters:
name – ipset(8) name
flags – comma-separated list of src and/or dst specifications
- any() Match¶
Match any value.
This method is used when creating a
Criterionin order to search an existing chain for rules that try to match against certain packet properties (e.g. input interface) without being particular about the specific property value (e.g.eth0).
- compare(is_equal: bool, *args, **kwargs) Match¶
Alternative method used for comparisons. It invokes
equals()(ornot_equals()) withargsandkwargsifis_equalisTrue(orFalse).
- is_positive() bool¶
Returns the ‘polarity’ of the criterion:
Trueforequals()orFalsefornot_equals()Raises
IptablesErrorif the criterion is not set
- is_set() bool¶
Returns
Trueif the criterion has been set
PacketCounterCriterion¶
- class PacketCounterCriterion(match: Match)[source]¶
A criterion for a packet counter value comparison used by
SetMatch.- any() Match¶
Match any value.
This method is used when creating a
Criterionin order to search an existing chain for rules that try to match against certain packet properties (e.g. input interface) without being particular about the specific property value (e.g.eth0).
- compare(is_equal: bool, *args, **kwargs) Match¶
Alternative method used for comparisons. It invokes
equals()(ornot_equals()) withargsandkwargsifis_equalisTrue(orFalse).
- equals(value: int) Match¶
Check if the counter is equal to
value- Parameters:
value – the counter value
- get_value() Tuple[int, str]¶
Returns the value that the criterion is comparing against and the comparison operation (as a string)
- Return type:
tuple of
(int, str)
- greater_than(value: int) Match¶
Check if the counter is greater than
value- Parameters:
value – the counter value
- is_positive() bool¶
Returns the ‘polarity’ of the criterion:
Trueforequals()orFalsefornot_equals()Raises
IptablesErrorif the criterion is not set
- is_set() bool¶
Returns
Trueif the criterion has been set
ByteCounterCriterion¶
- class ByteCounterCriterion(match: Match)[source]¶
A criterion for a byte counter value comparison used by
SetMatch.- any() Match¶
Match any value.
This method is used when creating a
Criterionin order to search an existing chain for rules that try to match against certain packet properties (e.g. input interface) without being particular about the specific property value (e.g.eth0).
- compare(is_equal: bool, *args, **kwargs) Match¶
Alternative method used for comparisons. It invokes
equals()(ornot_equals()) withargsandkwargsifis_equalisTrue(orFalse).
- equals(value: int) Match¶
Check if the counter is equal to
value- Parameters:
value – the counter value
- get_value() Tuple[int, str]¶
Returns the value that the criterion is comparing against and the comparison operation (as a string)
- Return type:
tuple of
(int, str)
- greater_than(value: int) Match¶
Check if the counter is greater than
value- Parameters:
value – the counter value
- is_positive() bool¶
Returns the ‘polarity’ of the criterion:
Trueforequals()orFalsefornot_equals()Raises
IptablesErrorif the criterion is not set
- is_set() bool¶
Returns
Trueif the criterion has been set