feat(nat): Allow unspecified NAT protocols
This commit is contained in:
parent
d76b0d2bb4
commit
eb3865cb23
1 changed files with 8 additions and 7 deletions
15
firewall.py
15
firewall.py
|
@ -175,7 +175,7 @@ class SNat(RestrictiveBaseModel):
|
||||||
|
|
||||||
|
|
||||||
class Nat(RestrictiveBaseModel):
|
class Nat(RestrictiveBaseModel):
|
||||||
protocols: set[str] = {"icmp", "udp", "tcp"}
|
protocols: set[str] | None = {"icmp", "udp", "tcp"}
|
||||||
src: AutoSet[IPv4Network | ZoneName]
|
src: AutoSet[IPv4Network | ZoneName]
|
||||||
dst: AutoSet[IPv4Network | ZoneName]
|
dst: AutoSet[IPv4Network | ZoneName]
|
||||||
snat: SNat
|
snat: SNat
|
||||||
|
@ -573,13 +573,14 @@ def parse_nat(nat: list[Nat], zones: Zones) -> nft.Table:
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
rule.stmts.append(
|
if entry.protocols is not None:
|
||||||
nft.Match(
|
rule.stmts.append(
|
||||||
op="==",
|
nft.Match(
|
||||||
left=nft.Payload(protocol="ip", field="protocol"),
|
op="==",
|
||||||
right=entry.protocols,
|
left=nft.Payload(protocol="ip", field="protocol"),
|
||||||
|
right=entry.protocols,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
rule.stmts.append(
|
rule.stmts.append(
|
||||||
nft.Snat(
|
nft.Snat(
|
||||||
|
|
Loading…
Reference in a new issue