@@ -54,7 +54,6 @@ func TestDNSOrIPPair_Spec(t *testing.T) {
54
54
} {
55
55
if res := tc .d .Spec (tc .f ); ! reflect .DeepEqual (res , tc .r ) {
56
56
t .Errorf ("test %d:\n \t exp=%q\n \t got=%q\n " , i , tc .r , res )
57
-
58
57
}
59
58
}
60
59
}
@@ -84,7 +83,6 @@ func TestStringPair_Spec(t *testing.T) {
84
83
} {
85
84
if res := tc .p .Spec (tc .f ); ! reflect .DeepEqual (res , tc .r ) {
86
85
t .Errorf ("test %d:\n \t exp=%q\n \t got=%q\n " , i , tc .r , res )
87
-
88
86
}
89
87
}
90
88
}
@@ -114,7 +112,6 @@ func TestFlag_String(t *testing.T) {
114
112
} {
115
113
if res := tc .p .String (tc .f ); ! reflect .DeepEqual (res , tc .r ) {
116
114
t .Errorf ("test %d:\n \t exp=%q\n \t got=%q\n " , i , tc .r , res )
117
-
118
115
}
119
116
}
120
117
}
@@ -128,7 +125,7 @@ func TestMatch_String(t *testing.T) {
128
125
p : Match {
129
126
Type : "comment" ,
130
127
Flags : map [string ]Flag {
131
- "comment" : Flag {
128
+ "comment" : {
132
129
Values : []string {"hallo" },
133
130
},
134
131
},
@@ -139,7 +136,7 @@ func TestMatch_String(t *testing.T) {
139
136
p : Match {
140
137
Type : "tcp" ,
141
138
Flags : map [string ]Flag {
142
- "tcp-options" : Flag {
139
+ "tcp-options" : {
143
140
Not : true ,
144
141
Values : []string {"bla" , "blub" },
145
142
},
@@ -150,7 +147,6 @@ func TestMatch_String(t *testing.T) {
150
147
} {
151
148
if res := tc .p .String (); ! reflect .DeepEqual (res , tc .r ) {
152
149
t .Errorf ("test %d:\n \t exp=%q\n \t got=%q\n " , i , tc .r , res )
153
-
154
150
}
155
151
}
156
152
}
@@ -165,7 +161,7 @@ func TestTarget_String(t *testing.T) {
165
161
p : Target {
166
162
Name : "foo" ,
167
163
Flags : map [string ]Flag {
168
- "bar" : Flag {
164
+ "bar" : {
169
165
Values : []string {"foo" },
170
166
},
171
167
},
@@ -177,7 +173,7 @@ func TestTarget_String(t *testing.T) {
177
173
p : Target {
178
174
Name : "foo" ,
179
175
Flags : map [string ]Flag {
180
- "bar" : Flag {
176
+ "bar" : {
181
177
Not : true ,
182
178
Values : []string {"foo" , "bar" },
183
179
},
@@ -189,7 +185,6 @@ func TestTarget_String(t *testing.T) {
189
185
} {
190
186
if res := tc .p .String (tc .f ); ! reflect .DeepEqual (res , tc .r ) {
191
187
t .Errorf ("test %d:\n \t exp=%q\n \t got=%q\n " , i , tc .r , res )
192
-
193
188
}
194
189
}
195
190
}
@@ -202,18 +197,19 @@ func TestRule_Spec(t *testing.T) {
202
197
{
203
198
rule : Rule {
204
199
Chain : "foo" ,
205
- Source : & DNSOrIPPair {Value : DNSOrIP {
206
- iP : parseCIDR ("192.168.178.2" ),
200
+ Source : & DNSOrIPPair {
201
+ Value : DNSOrIP {
202
+ iP : parseCIDR ("192.168.178.2" ),
203
+ },
204
+ Not : true ,
207
205
},
208
- Not : true },
209
206
Destination : & DNSOrIPPair {Value : DNSOrIP {iP : parseCIDR ("1.1.1.1" )}, Not : true },
210
207
},
211
208
res : []string {"!" , "-s" , "192.168.178.2/32" , "!" , "-d" , "1.1.1.1/32" },
212
209
},
213
210
} {
214
211
if res := tc .rule .Spec (); ! reflect .DeepEqual (res , tc .res ) {
215
212
t .Errorf ("test %d:\n \t exp=%q\n \t got=%q\n " , i , tc .res , res )
216
-
217
213
}
218
214
}
219
215
}
@@ -226,10 +222,12 @@ func TestRule_String(t *testing.T) {
226
222
{
227
223
rule : Rule {
228
224
Chain : "foo" ,
229
- Source : & DNSOrIPPair {Value : DNSOrIP {
230
- iP : parseCIDR ("192.168.178.2" ),
225
+ Source : & DNSOrIPPair {
226
+ Value : DNSOrIP {
227
+ iP : parseCIDR ("192.168.178.2" ),
228
+ },
229
+ Not : true ,
231
230
},
232
- Not : true },
233
231
Destination : & DNSOrIPPair {Value : DNSOrIP {iP : parseCIDR ("1.1.1.1" )}, Not : true },
234
232
},
235
233
res : "-A foo ! -s 192.168.178.2/32 ! -d 1.1.1.1/32" ,
@@ -241,14 +239,14 @@ func TestRule_String(t *testing.T) {
241
239
{
242
240
Type : "comment" ,
243
241
Flags : map [string ]Flag {
244
- "comment" : Flag {Values : []string {`kubernetes service traffic requiring SNAT` }},
242
+ "comment" : {Values : []string {`kubernetes service traffic requiring SNAT` }},
245
243
},
246
244
},
247
245
},
248
246
Jump : & Target {
249
247
Name : "MASQUERADE" ,
250
248
Flags : map [string ]Flag {
251
- "to-ports" : Flag {
249
+ "to-ports" : {
252
250
Values : []string {"200-1000" },
253
251
},
254
252
},
@@ -259,7 +257,6 @@ func TestRule_String(t *testing.T) {
259
257
} {
260
258
if res := tc .rule .String (); ! reflect .DeepEqual (res , tc .res ) {
261
259
t .Errorf ("test %d:\n \t exp=%q\n \t got=%q\n " , i , tc .res , res )
262
-
263
260
}
264
261
}
265
262
}
@@ -333,7 +330,8 @@ func TestParser_Parse(t *testing.T) {
333
330
Counter : & Counter {
334
331
packets : 10 ,
335
332
bytes : 100 ,
336
- }},
333
+ },
334
+ },
337
335
err : nil ,
338
336
},
339
337
{
@@ -345,7 +343,8 @@ func TestParser_Parse(t *testing.T) {
345
343
Counter : & Counter {
346
344
packets : 0 ,
347
345
bytes : 100 ,
348
- }},
346
+ },
347
+ },
349
348
err : nil ,
350
349
},
351
350
{
@@ -372,10 +371,12 @@ func TestParser_Parse(t *testing.T) {
372
371
s : "-A foo ! -s 192.168.178.2 ! --dst 1.1.1.1" ,
373
372
r : Rule {
374
373
Chain : "foo" ,
375
- Source : & DNSOrIPPair {Value : DNSOrIP {
376
- iP : parseCIDR ("192.168.178.2" ),
374
+ Source : & DNSOrIPPair {
375
+ Value : DNSOrIP {
376
+ iP : parseCIDR ("192.168.178.2" ),
377
+ },
378
+ Not : true ,
377
379
},
378
- Not : true },
379
380
Destination : & DNSOrIPPair {Value : DNSOrIP {iP : parseCIDR ("1.1.1.1" )}, Not : true },
380
381
},
381
382
err : nil ,
@@ -418,7 +419,7 @@ func TestParser_Parse(t *testing.T) {
418
419
{
419
420
Type : "comment" ,
420
421
Flags : map [string ]Flag {
421
- "comment" : Flag {
422
+ "comment" : {
422
423
Values : []string {`this crazy\` },
423
424
},
424
425
},
@@ -448,7 +449,7 @@ func TestParser_Parse(t *testing.T) {
448
449
{
449
450
Type : "comment" ,
450
451
Flags : map [string ]Flag {
451
- "comment" : Flag {
452
+ "comment" : {
452
453
Values : []string {`this crazy` },
453
454
},
454
455
},
@@ -478,7 +479,7 @@ func TestParser_Parse(t *testing.T) {
478
479
{
479
480
Type : "comment" ,
480
481
Flags : map [string ]Flag {
481
- "comment" : Flag {
482
+ "comment" : {
482
483
Values : []string {`--this-crazy` },
483
484
},
484
485
},
@@ -506,7 +507,7 @@ func TestParser_Parse(t *testing.T) {
506
507
{
507
508
Type : "comment" ,
508
509
Flags : map [string ]Flag {
509
- "comment" : Flag {
510
+ "comment" : {
510
511
Values : []string {`this \"crazy\"` },
511
512
},
512
513
},
@@ -527,7 +528,7 @@ func TestParser_Parse(t *testing.T) {
527
528
{
528
529
Type : "comment" ,
529
530
Flags : map [string ]Flag {
530
- "comment" : Flag {
531
+ "comment" : {
531
532
Values : []string {`this \"crazy\"` },
532
533
},
533
534
},
@@ -560,9 +561,9 @@ func TestParser_Parse(t *testing.T) {
560
561
{
561
562
Type : "tcp" ,
562
563
Flags : map [string ]Flag {
563
- "destination-port" : Flag {Values : []string {"8080:9000" }},
564
- "source-port" : Flag {Values : []string {"1010" }},
565
- "tcp-flags" : Flag {Values : []string {"SYN,FIN" , "ACK" }},
564
+ "destination-port" : {Values : []string {"8080:9000" }},
565
+ "source-port" : {Values : []string {"1010" }},
566
+ "tcp-flags" : {Values : []string {"SYN,FIN" , "ACK" }},
566
567
},
567
568
},
568
569
},
@@ -579,12 +580,12 @@ func TestParser_Parse(t *testing.T) {
579
580
{
580
581
Type : "tcp" ,
581
582
Flags : map [string ]Flag {
582
- "source-port" : Flag {Values : []string {"1010" }},
583
- "destination-port" : Flag {
583
+ "source-port" : {Values : []string {"1010" }},
584
+ "destination-port" : {
584
585
Values : []string {"1000" },
585
586
Not : true ,
586
587
},
587
- "tcp-flags" : Flag {Values : []string {"SYN,FIN" , "ACK" }},
588
+ "tcp-flags" : {Values : []string {"SYN,FIN" , "ACK" }},
588
589
},
589
590
},
590
591
},
@@ -601,17 +602,17 @@ func TestParser_Parse(t *testing.T) {
601
602
{
602
603
Type : "tcp" ,
603
604
Flags : map [string ]Flag {
604
- "source-port" : Flag {Values : []string {"1010" }},
605
- "destination-port" : Flag {
605
+ "source-port" : {Values : []string {"1010" }},
606
+ "destination-port" : {
606
607
Values : []string {"1000:1010" },
607
608
Not : true ,
608
609
},
609
- "tcp-flags" : Flag {Values : []string {"SYN,FIN" , "ACK" }},
610
- "tcp-option" : Flag {
610
+ "tcp-flags" : {Values : []string {"SYN,FIN" , "ACK" }},
611
+ "tcp-option" : {
611
612
Not : true ,
612
613
Values : []string {"1" },
613
614
},
614
- "syn" : Flag {
615
+ "syn" : {
615
616
Not : true ,
616
617
},
617
618
},
@@ -630,21 +631,21 @@ func TestParser_Parse(t *testing.T) {
630
631
{
631
632
Type : "tcp" ,
632
633
Flags : map [string ]Flag {
633
- "source-port" : Flag {
634
+ "source-port" : {
634
635
Not : true ,
635
636
Values : []string {"1010" },
636
637
},
637
- "destination-port" : Flag {
638
+ "destination-port" : {
638
639
Values : []string {"1000:1010" },
639
640
},
640
- "tcp-flags" : Flag {
641
+ "tcp-flags" : {
641
642
Not : true ,
642
643
Values : []string {"SYN,FIN" , "ACK" },
643
644
},
644
- "tcp-option" : Flag {
645
+ "tcp-option" : {
645
646
Values : []string {"1" },
646
647
},
647
- "syn" : Flag {},
648
+ "syn" : {},
648
649
},
649
650
},
650
651
},
@@ -676,29 +677,29 @@ func TestParser_Parse(t *testing.T) {
676
677
{
677
678
Type : "tcp" ,
678
679
Flags : map [string ]Flag {
679
- "source-port" : Flag {
680
+ "source-port" : {
680
681
Not : true ,
681
682
Values : []string {"1010" },
682
683
},
683
- "destination-port" : Flag {
684
+ "destination-port" : {
684
685
Values : []string {"1000:1010" },
685
686
},
686
- "tcp-flags" : Flag {
687
+ "tcp-flags" : {
687
688
Not : true ,
688
689
Values : []string {"SYN,FIN" , "ACK" },
689
690
},
690
- "tcp-option" : Flag {
691
+ "tcp-option" : {
691
692
Values : []string {"1" },
692
693
},
693
- "syn" : Flag {},
694
+ "syn" : {},
694
695
},
695
696
},
696
697
},
697
698
Jump : & Target {
698
699
Name : "DNAT" ,
699
700
Flags : map [string ]Flag {
700
- "random" : Flag {},
701
- "to-destination" : Flag {
701
+ "random" : {},
702
+ "to-destination" : {
702
703
Values : []string {"192.168.1.1-192.168.1.2:80-81" },
703
704
},
704
705
},
@@ -718,7 +719,7 @@ func TestParser_Parse(t *testing.T) {
718
719
Jump : & Target {
719
720
Name : "SNAT" ,
720
721
Flags : map [string ]Flag {
721
- "to-source" : Flag {
722
+ "to-source" : {
722
723
Values : []string {"192.168.1.1" },
723
724
},
724
725
},
@@ -738,10 +739,10 @@ func TestParser_Parse(t *testing.T) {
738
739
Jump : & Target {
739
740
Name : "SNAT" ,
740
741
Flags : map [string ]Flag {
741
- "to-source" : Flag {
742
+ "to-source" : {
742
743
Values : []string {"192.168.1.1" },
743
744
},
744
- "random-fully" : Flag {},
745
+ "random-fully" : {},
745
746
},
746
747
},
747
748
},
@@ -756,13 +757,13 @@ func TestParser_Parse(t *testing.T) {
756
757
{
757
758
Type : "comment" ,
758
759
Flags : map [string ]Flag {
759
- "comment" : Flag {Values : []string {`kubernetes service nodeports; NOTE: this must be the last rule in this chain` }},
760
+ "comment" : {Values : []string {`kubernetes service nodeports; NOTE: this must be the last rule in this chain` }},
760
761
},
761
762
},
762
763
{
763
764
Type : "addrtype" ,
764
765
Flags : map [string ]Flag {
765
- "dst-type" : Flag {
766
+ "dst-type" : {
766
767
Values : []string {"LOCAL" },
767
768
},
768
769
},
@@ -791,13 +792,13 @@ func TestParser_Parse(t *testing.T) {
791
792
{
792
793
Type : "comment" ,
793
794
Flags : map [string ]Flag {
794
- "comment" : Flag {Values : []string {`kube-system/kube-dns:dns cluster IP` }},
795
+ "comment" : {Values : []string {`kube-system/kube-dns:dns cluster IP` }},
795
796
},
796
797
},
797
798
{
798
799
Type : "udp" ,
799
800
Flags : map [string ]Flag {
800
- "destination-port" : Flag {
801
+ "destination-port" : {
801
802
Values : []string {"53" },
802
803
},
803
804
},
@@ -818,14 +819,14 @@ func TestParser_Parse(t *testing.T) {
818
819
{
819
820
Type : "comment" ,
820
821
Flags : map [string ]Flag {
821
- "comment" : Flag {Values : []string {`kubernetes service traffic requiring SNAT` }},
822
+ "comment" : {Values : []string {`kubernetes service traffic requiring SNAT` }},
822
823
},
823
824
},
824
825
},
825
826
Jump : & Target {
826
827
Name : "MASQUERADE" ,
827
828
Flags : map [string ]Flag {
828
- "random-fully" : Flag {},
829
+ "random-fully" : {},
829
830
},
830
831
},
831
832
},
@@ -840,16 +841,16 @@ func TestParser_Parse(t *testing.T) {
840
841
{
841
842
Type : "comment" ,
842
843
Flags : map [string ]Flag {
843
- "comment" : Flag {Values : []string {`kubernetes service traffic requiring SNAT` }},
844
+ "comment" : {Values : []string {`kubernetes service traffic requiring SNAT` }},
844
845
},
845
846
},
846
847
},
847
848
Jump : & Target {
848
849
Name : "MASQUERADE" ,
849
850
Flags : map [string ]Flag {
850
- "random-fully" : Flag {},
851
- "random" : Flag {},
852
- "to-ports" : Flag {
851
+ "random-fully" : {},
852
+ "random" : {},
853
+ "to-ports" : {
853
854
Values : []string {"200-1000" },
854
855
},
855
856
},
@@ -862,12 +863,15 @@ func TestParser_Parse(t *testing.T) {
862
863
s : "-A foo ! -s 192.168.178.2 ! --dst 1.1.1.1 -m statistic --mode random --probability 0.50000000000 --every 10 --packet 5" ,
863
864
r : Rule {
864
865
Chain : "foo" ,
865
- Source : & DNSOrIPPair {Value : DNSOrIP {
866
- iP : parseCIDR ("192.168.178.2" ),
866
+ Source : & DNSOrIPPair {
867
+ Value : DNSOrIP {
868
+ iP : parseCIDR ("192.168.178.2" ),
869
+ },
870
+ Not : true ,
867
871
},
868
- Not : true },
869
872
Destination : & DNSOrIPPair {Value : DNSOrIP {iP : parseCIDR ("1.1.1.1" )}, Not : true },
870
- Matches : []Match {{Type : "statistic" ,
873
+ Matches : []Match {{
874
+ Type : "statistic" ,
871
875
Flags : map [string ]Flag {
872
876
"mode" : {
873
877
Values : []string {`random` },
@@ -881,7 +885,8 @@ func TestParser_Parse(t *testing.T) {
881
885
"every" : {
882
886
Values : []string {`10` },
883
887
},
884
- }}},
888
+ },
889
+ }},
885
890
},
886
891
err : nil ,
887
892
},
@@ -894,7 +899,8 @@ func TestParser_Parse(t *testing.T) {
894
899
Counter : & Counter {
895
900
packets : 0 ,
896
901
bytes : 100 ,
897
- }},
902
+ },
903
+ },
898
904
err : nil ,
899
905
},
900
906
{
@@ -910,7 +916,7 @@ func TestParser_Parse(t *testing.T) {
910
916
{
911
917
Type : "addrtype" ,
912
918
Flags : map [string ]Flag {
913
- "dst-type" : Flag {Values : []string {"LOCAL" }},
919
+ "dst-type" : {Values : []string {"LOCAL" }},
914
920
},
915
921
},
916
922
},
@@ -974,7 +980,7 @@ func TestParser_Parse(t *testing.T) {
974
980
{
975
981
Type : "tcp" ,
976
982
Flags : map [string ]Flag {
977
- "destination-port" : Flag {
983
+ "destination-port" : {
978
984
Values : []string {"6443" },
979
985
},
980
986
},
@@ -1034,7 +1040,8 @@ func TestParser_ParseMore(t *testing.T) {
1034
1040
Counter : & Counter {
1035
1041
packets : 10 ,
1036
1042
bytes : 100 ,
1037
- }},
1043
+ },
1044
+ },
1038
1045
Rule {
1039
1046
Chain : "foo" ,
1040
1047
Destination : & DNSOrIPPair {Value : DNSOrIP {iP : parseCIDR ("192.168.178.2" )}},
@@ -1052,7 +1059,7 @@ func TestParser_ParseMore(t *testing.T) {
1052
1059
{
1053
1060
Type : "comment" ,
1054
1061
Flags : map [string ]Flag {
1055
- "comment" : Flag {
1062
+ "comment" : {
1056
1063
Values : []string {`this crazy` },
1057
1064
},
1058
1065
},
@@ -1067,16 +1074,16 @@ func TestParser_ParseMore(t *testing.T) {
1067
1074
{
1068
1075
Type : "comment" ,
1069
1076
Flags : map [string ]Flag {
1070
- "comment" : Flag {Values : []string {"kubernetes service traffic requiring SNAT" }},
1077
+ "comment" : {Values : []string {"kubernetes service traffic requiring SNAT" }},
1071
1078
},
1072
1079
},
1073
1080
},
1074
1081
Jump : & Target {
1075
1082
Name : "MASQUERADE" ,
1076
1083
Flags : map [string ]Flag {
1077
- "random-fully" : Flag {},
1078
- "random" : Flag {},
1079
- "to-ports" : Flag {
1084
+ "random-fully" : {},
1085
+ "random" : {},
1086
+ "to-ports" : {
1080
1087
Values : []string {"200-1000" },
1081
1088
},
1082
1089
},
@@ -1103,7 +1110,7 @@ func TestParser_ParseMore(t *testing.T) {
1103
1110
{
1104
1111
Type : "addrtype" ,
1105
1112
Flags : map [string ]Flag {
1106
- "dst-type" : Flag {Values : []string {"LOCAL" }},
1113
+ "dst-type" : {Values : []string {"LOCAL" }},
1107
1114
},
1108
1115
},
1109
1116
},
@@ -1152,7 +1159,7 @@ func TestParser_ParseMore(t *testing.T) {
1152
1159
{
1153
1160
Type : "tcp" ,
1154
1161
Flags : map [string ]Flag {
1155
- "destination-port" : Flag {
1162
+ "destination-port" : {
1156
1163
Values : []string {"6443" },
1157
1164
},
1158
1165
},
0 commit comments