From ddbe382aa58505d7822ff9d4f8bdbc4c3b4e988a Mon Sep 17 00:00:00 2001 From: Emile Date: Fri, 11 Oct 2019 11:56:08 +0200 Subject: vpnremoteport as flag --- src/docker.go | 11 +++++------ src/http.go | 6 ++++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/docker.go b/src/docker.go index e3ff19c..adc94fb 100644 --- a/src/docker.go +++ b/src/docker.go @@ -20,9 +20,8 @@ const ( ) var ( - dockerCtx context.Context - dockerCLI *client.Client - currentVpnRemptePort = 1194 + dockerCtx context.Context + dockerCLI *client.Client ) func setupContext() { @@ -49,9 +48,9 @@ func spawnCompanion(username string, accesscode string) { vpnRemoteAddress := os.Getenv("HOSTNAME") // get the vpnRemoteport and increment it - vpnRemotePort := currentVpnRemptePort - log.Println("vpnRemptePort ", currentVpnRemptePort) - currentVpnRemptePort++ + vpnRemotePort := *currentVpnRemotePort + log.Println("vpnRemptePort ", *currentVpnRemotePort) + *currentVpnRemotePort++ log.Println("Generating the container config") diff --git a/src/http.go b/src/http.go index 2c62eaf..13276f7 100644 --- a/src/http.go +++ b/src/http.go @@ -15,8 +15,9 @@ import ( ) var ( - port *int // port the http server listens on - usernames []string // list of usernames + port *int // port the http server listens on + usernames []string // list of usernames + currentVpnRemotePort *int ) // Credentials stores user credentials @@ -28,6 +29,7 @@ type Credentials struct { func registerHTTPFlags() { port = flag.Int("port", 8081, "The port the http server should listen on") + currentVpnRemotePort = flag.Int("initialVPNPort", 1194, "the initial vpn port") } func setupHTTPServer() http.Server { -- cgit 1.4.1