Skip to content

Commit

Permalink
Use variadic strings instead of slices in examples and README
Browse files Browse the repository at this point in the history
  • Loading branch information
Ullaakut committed Jan 21, 2019
1 parent 99567c8 commit 9a86a80
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 8 deletions.
48 changes: 48 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
dist: trusty
sudo: required
language: go

env:
- DEP_VERSION="0.5.0"

services:
- docker

before_install:
- go get github.com/mattn/goveralls
- go get github.com/pkg/errors
- go get gopkg.in/go-playground/validator.v9
- go get github.com/stretchr/testify/assert
- docker version
- curl -L -s https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 -o $GOPATH/bin/dep
- chmod +x $GOPATH/bin/dep

install:
- dep ensure
- docker build -t cameradar .

script:
# Run unit tests
- go test -v -covermode=count -coverprofile=coverage.out
- $HOME/gopath/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken=$COVERALLS_TOKEN
# Launch a fake camera to check if cameradar is able to access it
- docker run -d --name=fake_camera -e RTSP_USERNAME=admin -e RTSP_PASSWORD=12345 -p 8554:8554 ullaakut/rtspatt
# Launch cameradar on the local machine
- docker run --net=host -t cameradar -t 0.0.0.0 -l > logs.txt
- docker logs fake_camera > camera_logs.txt
# Stop the fake camera
- docker stop fake_camera
# Print logs
- cat camera_logs.txt
- cat logs.txt
# check if file contains more than one line
# 1 line: Error message because no streams were found
# More lines: Logs for all found cameras
- if [[ $(wc -l <logs.txt) -lt 2 ]]; then exit 1; fi

notifications:
email:
recipients:
- brendan.le-glaunec@epitech.eu
on_success: never
on_failure: always
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func main() {
scanner, err := nmap.New(
nmap.WithBinaryPath("/usr/local/bin/nmap"),
nmap.WithTarget("172.17.100.0/24"),
nmap.WithPorts("554,8554,18554-18654"),
nmap.WithPorts("554","8554","18554-18654"),
nmap.WithContext(ctx),
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion examples/basic_scan/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func main() {
scanner, err := nmap.New(
nmap.WithBinaryPath("/usr/local/bin/nmap"),
nmap.WithTarget("172.17.100.0/24"),
nmap.WithPorts("554,8554,18554-18654"),
nmap.WithPorts("554", "8554", "18554-18654"),
nmap.WithContext(ctx),
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion examples/service_detection/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func main() {
// nmap -sV -T4 192.168.0.0/24 with a filter to remove non-RTSP ports.
scanner, err := nmap.New(
nmap.WithTarget("192.168.0.0/24"),
nmap.WithPorts("554,8554"),
nmap.WithPorts("554", "8554"),
nmap.WithServiceInfo(),
nmap.WithTimingTemplate(nmap.TimingFast),
// Filter out ports that are not RTSP
Expand Down
4 changes: 2 additions & 2 deletions examples/spoof_and_decoys/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ func main() {
scanner, err := nmap.New(
nmap.WithTarget("192.168.0.72"),
nmap.WithSpoofIPAddress("192.168.0.10"),
nmap.WithDecoys([]string{
nmap.WithDecoys(
"192.168.0.2",
"192.168.0.3",
"192.168.0.4",
"192.168.0.5",
"192.168.0.6",
"ME",
"192.168.0.8",
}),
),
)
if err != nil {
log.Fatalf("unable to create nmap scanner: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion nmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ func WithMTU(offset int) func(*Scanner) {
// for your real IP address.
// If you put ME in the sixth position or later, some common port scan
// detectors are unlikely to show your IP address at all.
func WithDecoys(decoys []string) func(*Scanner) {
func WithDecoys(decoys ...string) func(*Scanner) {
decoyList := strings.Join(decoys, ",")

return func(s *Scanner) {
Expand Down
4 changes: 2 additions & 2 deletions nmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ func TestFirewallAndIDSEvasionAndSpoofing(t *testing.T) {
description: "enable decoys",

options: []func(*Scanner){
WithDecoys([]string{
WithDecoys(
"192.168.1.1",
"192.168.1.2",
"192.168.1.3",
Expand All @@ -1284,7 +1284,7 @@ func TestFirewallAndIDSEvasionAndSpoofing(t *testing.T) {
"192.168.1.6",
"ME",
"192.168.1.8",
}),
),
},

expectedArgs: []string{
Expand Down

0 comments on commit 9a86a80

Please sign in to comment.