修复 -p 参数在某些情况下以范围指定端口时(如 -p 8000-10000)解析错误问题

This commit is contained in:
7TEN7 2021-03-06 01:13:46 +08:00
parent 34706e6bca
commit 089502eb52

View File

@ -1,7 +1,6 @@
package common
import (
"sort"
"strconv"
"strings"
)
@ -17,9 +16,17 @@ func ParsePort(ports string) []int {
if len(ranges) < 2 {
continue
}
sort.Strings(ranges)
port = ranges[0]
upper = ranges[1]
startPort, _ := strconv.Atoi(ranges[0])
endPort, _ := strconv.Atoi(ranges[1])
if startPort < endPort {
port = ranges[0]
upper = ranges[1]
} else {
port = ranges[1]
upper = ranges[0]
}
}
start, _ := strconv.Atoi(port)
end, _ := strconv.Atoi(upper)