root / templates / simplerule.epp @ aaa37172
Historique | Voir | Annoter | Télécharger (1,36 ko)
1 | 83382bb5 | Nacho Barrientos | <%- | String $action, |
---|---|---|---|
2 | Optional[String] $comment, |
||
3 | 3a52fb41 | Nacho Barrientos | Optional[Variant[Array[Stdlib::Port, 1], Stdlib::Port, String]] $dport, |
4 | 83382bb5 | Nacho Barrientos | Optional[String] $proto, |
5 | aaa37172 | Nacho Barrientos | Optional[Variant[Stdlib::IP::Address::V6, Stdlib::IP::Address::V4, Pattern[/^@[-a-zA-Z0-9_]+$/]]] $daddr, |
6 | Enum['ip', 'ip6'] $set_type, |
||
7 | 83382bb5 | Nacho Barrientos | | -%> |
8 | 316bc3f8 | Nacho Barrientos | <%- if $proto { |
9 | $_proto = $proto ? { |
||
10 | /tcp(4|6)?/ => 'tcp', |
||
11 | /udp(4|6)?/ => 'udp', |
||
12 | } |
||
13 | $_ip_version_filter = $proto ? { |
||
14 | /(tcp4|udp4)/ => 'ip version 4', |
||
15 | /(tcp6|udp6)/ => 'ip version 6', |
||
16 | default => undef, |
||
17 | } |
||
18 | } else { |
||
19 | $_ip_version_filter = undef |
||
20 | } -%> |
||
21 | aaa37172 | Nacho Barrientos | <%- if $daddr { |
22 | if $daddr =~ Stdlib::IP::Address::V6 { |
||
23 | $_dst_hosts = "ip6 daddr ${daddr}" |
||
24 | } elsif $daddr =~ Stdlib::IP::Address::V4 { |
||
25 | $_dst_hosts = "ip daddr ${daddr}" |
||
26 | } else { |
||
27 | $_dst_hosts = $set_type ? { |
||
28 | 'ip' => "ip daddr ${daddr}", |
||
29 | 'ip6' => "ip6 daddr ${daddr}", |
||
30 | } |
||
31 | } |
||
32 | } else { |
||
33 | $_dst_hosts = undef |
||
34 | } -%> |
||
35 | 3a52fb41 | Nacho Barrientos | <%- if $proto and $dport { |
36 | if $dport =~ Array { |
||
37 | aaa37172 | Nacho Barrientos | $_dst_port = "${_proto} dport {${dport.join(', ')}}" |
38 | 3a52fb41 | Nacho Barrientos | } else { |
39 | aaa37172 | Nacho Barrientos | $_dst_port = "${_proto} dport $dport" |
40 | 3a52fb41 | Nacho Barrientos | } |
41 | 83382bb5 | Nacho Barrientos | } else { |
42 | aaa37172 | Nacho Barrientos | $_dst_port = undef |
43 | 83382bb5 | Nacho Barrientos | } -%> |
44 | <%- if $comment { |
||
45 | $_comment = "comment \"${comment}\"" |
||
46 | } else { |
||
47 | $_comment = undef |
||
48 | } -%> |
||
49 | aaa37172 | Nacho Barrientos | <%= regsubst(strip([$_ip_version_filter, $_dst_port, $_dst_hosts, $action, $_comment].join(' ')), '\s+', ' ', 'G') -%> |