Skip to content

Commit b22f098

Browse files
authored
Merge pull request #19 from robgonnella/minor-update
Minor update to ports flag
2 parents 0d72dc0 + ca5df27 commit b22f098

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

internal/cli/root.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package cli
55
import (
66
"fmt"
77
"os"
8-
"strings"
98
"time"
109

1110
"github.com/jedib0t/go-pretty/table"
@@ -102,7 +101,7 @@ func Root(
102101
) (*cobra.Command, error) {
103102
var printJson bool
104103
var noProgress bool
105-
var ports string
104+
var ports []string
106105
var timing string
107106
var idleTimeoutSeconds int
108107
var listenPort uint16
@@ -119,8 +118,6 @@ func Root(
119118
RunE: func(cmd *cobra.Command, args []string) error {
120119
log := logger.New()
121120

122-
portList := strings.Split(ports, ",")
123-
124121
if ifaceName != userNet.Interface().Name {
125122
uNet, err := network.NewNetworkFromInterfaceName(ifaceName)
126123

@@ -147,7 +144,7 @@ func Root(
147144
coreScanner = scanner.NewFullScanner(
148145
userNet,
149146
targets,
150-
portList,
147+
ports,
151148
listenPort,
152149
scanner.WithIdleTimeout(time.Second*time.Duration(idleTimeoutSeconds)),
153150
)
@@ -166,7 +163,7 @@ func Root(
166163

167164
coreScanner.SetTiming(timingDuration)
168165

169-
portLen := util.PortTotal(portList)
166+
portLen := util.PortTotal(ports)
170167

171168
targetLen := util.TotalTargets(targets)
172169

@@ -189,7 +186,7 @@ func Root(
189186
coreScanner,
190187
targets,
191188
userNet.Cidr(),
192-
portList,
189+
ports,
193190
userNet.Interface().Name,
194191
listenPort,
195192
timing,
@@ -209,7 +206,7 @@ func Root(
209206
cmd.Flags().BoolVar(&printJson, "json", false, "output json instead of table text")
210207
cmd.Flags().BoolVar(&arpOnly, "arp-only", false, "only perform arp scanning (skip syn scanning)")
211208
cmd.Flags().BoolVar(&noProgress, "no-progress", false, "disable all output except for final results")
212-
cmd.Flags().StringVarP(&ports, "ports", "p", "1-65535", "target ports")
209+
cmd.Flags().StringSliceVarP(&ports, "ports", "p", []string{"1-65535"}, "target ports")
213210
cmd.Flags().IntVar(&idleTimeoutSeconds, "idle-timeout", 5, "timeout when no expected packets are received for this duration")
214211
cmd.Flags().Uint16Var(&listenPort, "listen-port", 54321, "set the port on which the scanner will listen for packets")
215212
cmd.Flags().StringVarP(&ifaceName, "interface", "i", userNet.Interface().Name, "set the interface for scanning")

0 commit comments

Comments
 (0)