Skip to content

Commit

Permalink
Change WithTargetExclusion to a variadic function (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
zrquan authored Aug 2, 2024
1 parent 58d9339 commit 5c4bceb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions optionsTargetSpecification.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package nmap

import (
"fmt"
"strings"
)

// WithTargets sets the target of a scanner.
Expand All @@ -11,11 +12,13 @@ func WithTargets(targets ...string) Option {
}
}

// WithTargetExclusion sets the excluded targets of a scanner.
func WithTargetExclusion(target string) Option {
// WithTargetExclusions sets the excluded targets of a scanner.
func WithTargetExclusions(targets ...string) Option {
targetList := strings.Join(targets, ",")

return func(s *Scanner) {
s.args = append(s.args, "--exclude")
s.args = append(s.args, target)
s.args = append(s.args, targetList)
}
}

Expand Down
2 changes: 1 addition & 1 deletion optionsTargetSpecification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestTargetSpecification(t *testing.T) {
description: "target exclusion",

options: []Option{
WithTargetExclusion("192.168.0.1,172.16.100.0/24"),
WithTargetExclusions("192.168.0.1", "172.16.100.0/24"),
},

expectedArgs: []string{
Expand Down

0 comments on commit 5c4bceb

Please sign in to comment.