diff --git a/optionsTargetSpecification.go b/optionsTargetSpecification.go index 190214c..f86de5e 100644 --- a/optionsTargetSpecification.go +++ b/optionsTargetSpecification.go @@ -2,6 +2,7 @@ package nmap import ( "fmt" + "strings" ) // WithTargets sets the target of a scanner. @@ -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) } } diff --git a/optionsTargetSpecification_test.go b/optionsTargetSpecification_test.go index ca49462..2096625 100644 --- a/optionsTargetSpecification_test.go +++ b/optionsTargetSpecification_test.go @@ -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{