From 098460702b793ee79a6e52d6ff729fc1ad0a0b64 Mon Sep 17 00:00:00 2001 From: Ullaakut Date: Thu, 24 Jan 2019 09:43:13 +0100 Subject: [PATCH] Fix environment key delimiter & fix environment overrides in docker image --- Dockerfile | 6 +++++- cameradar/cameradar.go | 15 ++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index a437ed6..959f280 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,4 +29,8 @@ RUN apk --update add --no-cache nmap \ WORKDIR /app/cameradar COPY --from=build-env /go/src/github.com/Ullaakut/cameradar/dictionaries/ /app/dictionaries/ COPY --from=build-env /go/src/github.com/Ullaakut/cameradar/cameradar/ /app/cameradar/ -ENTRYPOINT ["/app/cameradar/cameradar", "-r", "/app/dictionaries/routes", "-c", "/app/dictionaries/credentials.json"] + +ENV CAMERADAR_CUSTOM_ROUTES="/app/dictionaries/routes" +ENV CAMERADAR_CUSTOM_CREDENTIALS="/app/dictionaries/credentials.json" + +ENTRYPOINT ["/app/cameradar/cameradar"] diff --git a/cameradar/cameradar.go b/cameradar/cameradar.go index b9390bb..6fe7a88 100644 --- a/cameradar/cameradar.go +++ b/cameradar/cameradar.go @@ -7,7 +7,7 @@ import ( "strings" "time" - "github.com/Ullaakut/cameradar" + "github.com/ullaakut/cameradar" curl "github.com/andelf/go-curl" "github.com/fatih/color" @@ -28,17 +28,10 @@ type options struct { } func parseArguments() error { - viper.SetEnvPrefix("cameradar") - viper.BindEnv("targets") - viper.BindEnv("ports") - viper.BindEnv("custom-routes") - viper.BindEnv("custom-credentials") - viper.BindEnv("speed") - viper.BindEnv("timeout") - viper.BindEnv("logging") - - pflag.StringSliceP("targets", "t", nil, "The targets on which to scan for open RTSP streams - required (ex: 172.16.100.0/24)") + viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_")) + + pflag.StringSliceP("targets", "t", []string{}, "The targets on which to scan for open RTSP streams - required (ex: 172.16.100.0/24)") pflag.StringSliceP("ports", "p", []string{"554", "5554", "8554"}, "The ports on which to search for RTSP streams") pflag.StringP("custom-routes", "r", "/src/github.com/Ullaakut/cameradar/dictionaries/routes", "The path on which to load a custom routes dictionary") pflag.StringP("custom-credentials", "c", "/src/github.com/Ullaakut/cameradar/dictionaries/credentials.json", "The path on which to load a custom credentials JSON dictionary")