root / templates / simplerule.epp @ 316bc3f8
Historique | Voir | Annoter | Télécharger (892 octets)
1 |
<%- | String $action, |
---|---|
2 |
Optional[String] $comment, |
3 |
Optional[Variant[Array[Stdlib::Port, 1], Stdlib::Port, String]] $dport, |
4 |
Optional[String] $proto, |
5 |
| -%> |
6 |
<%- if $proto { |
7 |
$_proto = $proto ? { |
8 |
/tcp(4|6)?/ => 'tcp', |
9 |
/udp(4|6)?/ => 'udp', |
10 |
} |
11 |
$_ip_version_filter = $proto ? { |
12 |
/(tcp4|udp4)/ => 'ip version 4', |
13 |
/(tcp6|udp6)/ => 'ip version 6', |
14 |
default => undef, |
15 |
} |
16 |
} else { |
17 |
$_ip_version_filter = undef |
18 |
} -%> |
19 |
<%- if $proto and $dport { |
20 |
if $dport =~ Array { |
21 |
$_destination = "${_proto} dport {${dport.join(', ')}}" |
22 |
} else { |
23 |
$_destination = "${_proto} dport $dport" |
24 |
} |
25 |
} else { |
26 |
$_destination = undef |
27 |
} -%> |
28 |
<%- if $comment { |
29 |
$_comment = "comment \"${comment}\"" |
30 |
} else { |
31 |
$_comment = undef |
32 |
} -%> |
33 |
<%= regsubst(strip([$_ip_version_filter, $_destination, $_comment, $action].join(' ')), '\s+', ' ', 'G') -%> |