mirror of
https://github.com/DarrylNixon/drawbridge
synced 2024-04-22 12:17:07 -07:00
Adjust iptc for match-all
This commit is contained in:
parent
d4d9147b23
commit
7f21bb8225
1 changed files with 6 additions and 5 deletions
|
@ -35,20 +35,21 @@ class NetQueue:
|
||||||
|
|
||||||
def _create_rule(self) -> iptc.Rule:
|
def _create_rule(self) -> iptc.Rule:
|
||||||
rule = iptc.Rule()
|
rule = iptc.Rule()
|
||||||
match = iptc.Match(rule, self.protocol)
|
|
||||||
target = iptc.Target(rule, "NFQUEUE")
|
target = iptc.Target(rule, "NFQUEUE")
|
||||||
target.set_parameter("queue-num", str(self.queue))
|
target.set_parameter("queue-num", str(self.queue))
|
||||||
rule.add_match(match)
|
if self.protocol:
|
||||||
|
match = iptc.Match(rule, self.protocol)
|
||||||
|
rule.add_match(match)
|
||||||
rule.target = target
|
rule.target = target
|
||||||
return rule
|
return rule
|
||||||
|
|
||||||
def write_rule(self):
|
def write_rule(self):
|
||||||
table = iptc.Table(iptc.Table.FILTER)
|
table = iptc.Table(iptc.Table.MANGLE)
|
||||||
chain = iptc.Chain(table, "INPUT")
|
chain = iptc.Chain(table, "INPUT")
|
||||||
chain.insert_rule(self.rule)
|
chain.insert_rule(self.rule)
|
||||||
|
|
||||||
def delete_rule(self):
|
def delete_rule(self):
|
||||||
table = iptc.Table(iptc.Table.FILTER)
|
table = iptc.Table(iptc.Table.MANGLE)
|
||||||
chain = iptc.Chain(table, "INPUT")
|
chain = iptc.Chain(table, "INPUT")
|
||||||
try:
|
try:
|
||||||
chain.delete_rule(self.rule)
|
chain.delete_rule(self.rule)
|
||||||
|
@ -82,7 +83,7 @@ class NetQueue:
|
||||||
def validate_protocol(protocol: Optional[str]) -> Union[str, None]:
|
def validate_protocol(protocol: Optional[str]) -> Union[str, None]:
|
||||||
if protocol:
|
if protocol:
|
||||||
try:
|
try:
|
||||||
Protocols(protocol)
|
Protocols[protocol]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise KeyError(f"Invalid protocol: {protocol}")
|
raise KeyError(f"Invalid protocol: {protocol}")
|
||||||
return protocol
|
return protocol
|
||||||
|
|
Loading…
Reference in a new issue