Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / templates / simplerule.epp @ 316bc3f8

Historique | Voir | Annoter | Télécharger (892 octets)

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
| -%>
6 316bc3f8 Nacho Barrientos
<%- 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 3a52fb41 Nacho Barrientos
<%- if $proto and $dport {
20
  if $dport =~ Array {
21 316bc3f8 Nacho Barrientos
    $_destination = "${_proto} dport {${dport.join(', ')}}"
22 3a52fb41 Nacho Barrientos
  } else {
23 316bc3f8 Nacho Barrientos
    $_destination = "${_proto} dport $dport"
24 3a52fb41 Nacho Barrientos
  }
25 83382bb5 Nacho Barrientos
} else {
26
  $_destination = undef
27
} -%>
28
<%- if $comment {
29
  $_comment = "comment \"${comment}\""
30
} else {
31
  $_comment = undef
32
} -%>
33 316bc3f8 Nacho Barrientos
<%= regsubst(strip([$_ip_version_filter, $_destination, $_comment, $action].join(' ')), '\s+', ' ', 'G') -%>