Projet

Général

Profil

Révision 6793d286

ID6793d28675445d3b6d3785c4f1d1f9a12edf6b78
Parent 467ea4e2
Enfant fb58f7b3

Ajouté par Nacho Barrientos il y a plus de 4 ans

Handle dport internally always as an array

Voir les différences:

spec/defines/simplerule_spec.rb
46 46
        it { is_expected.to compile }
47 47
        it {
48 48
          is_expected.to contain_nftables__rule('default_out-my_big_rule').with(
49
            content: 'udp dport 333 ip6 daddr 2001:1458::/32 counter accept comment "this is my rule"',
49
            content: 'udp dport {333} ip6 daddr 2001:1458::/32 counter accept comment "this is my rule"',
50 50
            order: '50',
51 51
          )
52 52
        }
......
63 63
        it { is_expected.to compile }
64 64
        it {
65 65
          is_expected.to contain_nftables__rule('default_in-my_default_rule_name').with(
66
            content: 'tcp dport 333-334 accept',
66
            content: 'tcp dport {333-334} accept',
67 67
          )
68 68
        }
69 69
      end
......
95 95
        it { is_expected.to compile }
96 96
        it {
97 97
          is_expected.to contain_nftables__rule('default_in-my_default_rule_name').with(
98
            content: 'ip version 4 tcp dport 333 accept',
98
            content: 'ip version 4 tcp dport {333} accept',
99 99
          )
100 100
        }
101 101
      end
......
111 111
        it { is_expected.to compile }
112 112
        it {
113 113
          is_expected.to contain_nftables__rule('default_in-my_default_rule_name').with(
114
            content: 'ip version 6 udp dport 33 accept',
114
            content: 'ip version 6 udp dport {33} accept',
115 115
          )
116 116
        }
117 117
      end
......
128 128
        it { is_expected.to compile }
129 129
        it {
130 130
          is_expected.to contain_nftables__rule('default_in-my_default_rule_name').with(
131
            content: 'tcp dport 33 ip daddr 192.168.0.1/24 accept',
131
            content: 'tcp dport {33} ip daddr 192.168.0.1/24 accept',
132 132
          )
133 133
        }
134 134
      end
templates/simplerule.epp
34 34
  $_dst_hosts = undef
35 35
} -%>
36 36
<%- if $proto and $dport {
37
  if $dport =~ Array {
38
    $_dst_port = "${_proto} dport {${dport.join(', ')}}"
39
  } else {
40
    $_dst_port = "${_proto} dport $dport"
41
  }
37
  $_dst_port = "${_proto} dport {${Array($dport, true).join(', ')}}"
42 38
} else {
43 39
  $_dst_port = undef
44 40
} -%>

Formats disponibles : Unified diff