From a29e9a784520822973c59fb8cb5da1e3455293b1 Mon Sep 17 00:00:00 2001
From: linkwik
Date: Tue, 15 Jan 2019 10:45:16 +0800
Subject: [PATCH 1/2] Support for specified range ports
---
core/session.go | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/core/session.go b/core/session.go
index ee5a924..64f2cb4 100644
--- a/core/session.go
+++ b/core/session.go
@@ -192,8 +192,31 @@ func (s *Session) initPorts() {
for _, p := range strings.Split(*s.Options.Ports, ",") {
port, err := strconv.Atoi(strings.TrimSpace(p))
if err != nil {
- s.Out.Fatal("Invalid port range given\n")
- os.Exit(1)
+ ranges := strings.Split(p, "-")
+
+ if len(ranges) > 1 {
+ start_port, err := strconv.Atoi(strings.TrimSpace(ranges[0]))
+ if err != nil {
+ s.Out.Fatal("[start port] Invalid port range given")
+ os.Exit(1)
+ }
+
+ end_port, err := strconv.Atoi(strings.TrimSpace(ranges[1]))
+ if err != nil {
+ s.Out.Fatal("[end port] Invalid port range given")
+ os.Exit(1)
+ }
+
+ for i:= start_port; i <= end_port; i++ {
+ if i < 1 || i > 65535 {
+ s.Out.Fatal("Invalid port give: %v\n", i)
+ os.Exit(1)
+ }
+ ports = append(ports, i)
+ }
+
+ continue
+ }
}
if port < 1 || port > 65535 {
s.Out.Fatal("Invalid port given: %v\n", port)
From a227fdcca962b878a928a94003c00baa2c0c0dc6 Mon Sep 17 00:00:00 2001
From: linkwik
Date: Tue, 15 Jan 2019 10:48:30 +0800
Subject: [PATCH 2/2] Invalid port range given
---
core/session.go | 3 +++
1 file changed, 3 insertions(+)
diff --git a/core/session.go b/core/session.go
index 64f2cb4..893279e 100644
--- a/core/session.go
+++ b/core/session.go
@@ -217,6 +217,9 @@ func (s *Session) initPorts() {
continue
}
+
+ s.Out.Fatal("Invalid port range given\n")
+ os.Exit(1)
}
if port < 1 || port > 65535 {
s.Out.Fatal("Invalid port given: %v\n", port)