@@ -9531,23 +9531,22 @@ func (mTCP *MatchTCP) Short() string {
9531
9531
func (mTCP * MatchTCP ) ShortArgs () []string {
9532
9532
args := make ([]string , 0 , 17 )
9533
9533
args = append (args , "-m" , mTCP .matchType .String ())
9534
- if mTCP .SrcPortMin > - 1 {
9534
+ if mTCP .SrcPortMin > - 1 && mTCP .SrcPortMax > - 1 {
9535
+ args = append (args , "--sport" , strconv .Itoa (mTCP .SrcPortMin )+ ":" + strconv .Itoa (mTCP .SrcPortMax ))
9536
+ } else if mTCP .SrcPortMin > - 1 {
9535
9537
if mTCP .SrcPortInvert {
9536
9538
args = append (args , "!" )
9537
9539
}
9538
9540
args = append (args , "--sport" , strconv .Itoa (mTCP .SrcPortMin ))
9539
- if mTCP .SrcPortMax > - 1 {
9540
- args = append (args , ":" + strconv .Itoa (mTCP .SrcPortMax ))
9541
- }
9542
9541
}
9543
- if mTCP .DstPortMin > - 1 {
9542
+
9543
+ if mTCP .DstPortMin > - 1 && mTCP .DstPortMax > - 1 {
9544
+ args = append (args , "--dport" , strconv .Itoa (mTCP .DstPortMin )+ ":" + strconv .Itoa (mTCP .DstPortMax ))
9545
+ } else if mTCP .DstPortMin > - 1 {
9544
9546
if mTCP .DstPortInvert {
9545
9547
args = append (args , "!" )
9546
9548
}
9547
9549
args = append (args , "--dport" , strconv .Itoa (mTCP .DstPortMin ))
9548
- if mTCP .DstPortMax > - 1 {
9549
- args = append (args , ":" + strconv .Itoa (mTCP .DstPortMax ))
9550
- }
9551
9550
}
9552
9551
if mTCP .FlagsMask != 0 && mTCP .FlagsSet != 0 {
9553
9552
if mTCP .FlagsInvert {
@@ -9571,24 +9570,24 @@ func (mTCP *MatchTCP) Long() string {
9571
9570
func (mTCP * MatchTCP ) LongArgs () []string {
9572
9571
args := make ([]string , 0 , 17 )
9573
9572
args = append (args , "-m" , mTCP .matchType .String ())
9574
- if mTCP .SrcPortMin > - 1 {
9573
+ if mTCP .SrcPortMin > - 1 && mTCP .SrcPortMax > - 1 {
9574
+ args = append (args , "--source-port" , strconv .Itoa (mTCP .SrcPortMin )+ ":" + strconv .Itoa (mTCP .SrcPortMax ))
9575
+ } else if mTCP .SrcPortMin > - 1 {
9575
9576
if mTCP .SrcPortInvert {
9576
9577
args = append (args , "!" )
9577
9578
}
9578
9579
args = append (args , "--source-port" , strconv .Itoa (mTCP .SrcPortMin ))
9579
- if mTCP .SrcPortMax > - 1 {
9580
- args = append (args , ":" + strconv .Itoa (mTCP .SrcPortMax ))
9581
- }
9582
9580
}
9583
- if mTCP .DstPortMin > - 1 {
9581
+
9582
+ if mTCP .DstPortMin > - 1 && mTCP .DstPortMax > - 1 {
9583
+ args = append (args , "--destination-port" , strconv .Itoa (mTCP .DstPortMin )+ ":" + strconv .Itoa (mTCP .DstPortMax ))
9584
+ } else if mTCP .DstPortMin > - 1 {
9584
9585
if mTCP .DstPortInvert {
9585
9586
args = append (args , "!" )
9586
9587
}
9587
9588
args = append (args , "--destination-port" , strconv .Itoa (mTCP .DstPortMin ))
9588
- if mTCP .DstPortMax > - 1 {
9589
- args = append (args , ":" + strconv .Itoa (mTCP .DstPortMax ))
9590
- }
9591
9589
}
9590
+
9592
9591
if mTCP .FlagsMask != 0 && mTCP .FlagsSet != 0 {
9593
9592
if mTCP .FlagsInvert {
9594
9593
args = append (args , "!" )
@@ -10315,23 +10314,28 @@ func (mUDP *MatchUDP) Short() string {
10315
10314
func (mUDP * MatchUDP ) ShortArgs () []string {
10316
10315
args := make ([]string , 0 , 17 )
10317
10316
args = append (args , "-m" , mUDP .matchType .String ())
10318
- if mUDP .SrcPortMin > - 1 {
10317
+ if mUDP .SrcPortMin > - 1 && mUDP . SrcPortMax > - 1 {
10319
10318
if mUDP .SrcPortInvert {
10320
10319
args = append (args , "!" )
10321
10320
}
10322
- args = append (args , "--sport" , strconv .Itoa (mUDP .SrcPortMin ))
10323
- if mUDP .SrcPortMax > - 1 {
10324
- args = append (args , ":" + strconv .Itoa (mUDP .SrcPortMax ))
10321
+ args = append (args , "--sport" , strconv .Itoa (mUDP .SrcPortMin )+ ":" + strconv .Itoa (mUDP .SrcPortMax ))
10322
+ } else if mUDP .SrcPortMin > - 1 {
10323
+ if mUDP .SrcPortInvert {
10324
+ args = append (args , "!" )
10325
10325
}
10326
+ args = append (args , "--sport" , strconv .Itoa (mUDP .SrcPortMin ))
10326
10327
}
10327
- if mUDP .DstPortMin > - 1 {
10328
+
10329
+ if mUDP .DstPortMin > - 1 && mUDP .DstPortMax > - 1 {
10328
10330
if mUDP .DstPortInvert {
10329
10331
args = append (args , "!" )
10330
10332
}
10331
- args = append (args , "--dport" , strconv .Itoa (mUDP .DstPortMin ))
10332
- if mUDP .DstPortMax > - 1 {
10333
- args = append (args , ":" + strconv .Itoa (mUDP .DstPortMax ))
10333
+ args = append (args , "--dport" , strconv .Itoa (mUDP .DstPortMin )+ ":" + strconv .Itoa (mUDP .DstPortMax ))
10334
+ } else if mUDP .DstPortMin > - 1 {
10335
+ if mUDP .DstPortInvert {
10336
+ args = append (args , "!" )
10334
10337
}
10338
+ args = append (args , "--dport" , strconv .Itoa (mUDP .DstPortMin ))
10335
10339
}
10336
10340
return args
10337
10341
}
@@ -10343,23 +10347,28 @@ func (mUDP *MatchUDP) Long() string {
10343
10347
func (mUDP * MatchUDP ) LongArgs () []string {
10344
10348
args := make ([]string , 0 , 17 )
10345
10349
args = append (args , "-m" , mUDP .matchType .String ())
10346
- if mUDP .SrcPortMin > - 1 {
10350
+ if mUDP .SrcPortMin > - 1 && mUDP . SrcPortMax > - 1 {
10347
10351
if mUDP .SrcPortInvert {
10348
10352
args = append (args , "!" )
10349
10353
}
10350
- args = append (args , "--source-port" , strconv .Itoa (mUDP .SrcPortMin ))
10351
- if mUDP .SrcPortMax > - 1 {
10352
- args = append (args , ":" + strconv .Itoa (mUDP .SrcPortMax ))
10354
+ args = append (args , "--source-port" , strconv .Itoa (mUDP .SrcPortMin )+ ":" + strconv .Itoa (mUDP .SrcPortMax ))
10355
+ } else if mUDP .SrcPortMin > - 1 {
10356
+ if mUDP .SrcPortInvert {
10357
+ args = append (args , "!" )
10353
10358
}
10359
+ args = append (args , "--source-port" , strconv .Itoa (mUDP .SrcPortMin ))
10354
10360
}
10355
- if mUDP .DstPortMin > - 1 {
10361
+
10362
+ if mUDP .DstPortMin > - 1 && mUDP .DstPortMax > - 1 {
10356
10363
if mUDP .DstPortInvert {
10357
10364
args = append (args , "!" )
10358
10365
}
10359
- args = append (args , "--destination-port" , strconv .Itoa (mUDP .DstPortMin ))
10360
- if mUDP .DstPortMax > - 1 {
10361
- args = append (args , ":" + strconv .Itoa (mUDP .DstPortMax ))
10366
+ args = append (args , "--destination-port" , strconv .Itoa (mUDP .DstPortMin )+ ":" + strconv .Itoa (mUDP .DstPortMax ))
10367
+ } else if mUDP .DstPortMin > - 1 {
10368
+ if mUDP .DstPortInvert {
10369
+ args = append (args , "!" )
10362
10370
}
10371
+ args = append (args , "--destination-port" , strconv .Itoa (mUDP .DstPortMin ))
10363
10372
}
10364
10373
return args
10365
10374
}
0 commit comments