Skip to content

Commit

Permalink
add new parameter 'ctstate' to replicate some Docker rule
Browse files Browse the repository at this point in the history
iptables syntax:
  ```
  -A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
  ```

ferm syntax:
  ```
  table filter FORWARD outerface docker0 mod conntrack ctstate (ESTABLISHED RELATED) ACCEPT;
  ```
  • Loading branch information
kengelhardt-godaddy committed Jan 29, 2024
1 parent 4d02a2f commit 35f4bf1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions manifests/rule.pp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
# @param saddr_type
# Match source packets based on their address type
#
# @param ctstate
# Check conntrack information for ctstate, e.g. [ 'RELATED', 'ESTABLISHED' ]
#
# @param ensure
# Set the rule to present or absent
#
Expand Down Expand Up @@ -103,6 +106,7 @@
Optional[String[1]] $outerface = undef,
Optional[Ferm::Addr_Type] $daddr_type = undef,
Optional[Ferm::Addr_Type] $saddr_type = undef,
Optional[Variant[String[1], Array]] $ctstate = undef,
Enum['absent','present'] $ensure = 'present',
Ferm::Tables $table = 'filter',
Optional[Ferm::Negation] $negate = undef,
Expand Down Expand Up @@ -172,6 +176,11 @@
default => '',
}

$ctstate_real = $ctstate ? {
Variant[String[1], Array] => "mod conntrack ctstate (${join(flatten([$ctstate]).unique, ' ')})",
default => '',
}

$comment_real = "mod comment comment '${comment}'"

# prevent unmanaged files due to new naming schema
Expand All @@ -194,6 +203,7 @@
${saddr_real} \
${saddr_type_real} \
${outerface_real} \
${ctstate_real} \
${action_real};
|- END

Expand Down

0 comments on commit 35f4bf1

Please sign in to comment.