about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-10-11 11:56:08 +0200
committerEmile <hanemile@protonmail.com>2019-10-11 11:56:08 +0200
commitddbe382aa58505d7822ff9d4f8bdbc4c3b4e988a (patch)
tree588fcbbbff67938e68de091112b061aded9e43fd /src
parentc76b16a9c10565306477b91fb359c6d31442dfe5 (diff)
vpnremoteport as flag
Diffstat (limited to 'src')
-rw-r--r--src/docker.go11
-rw-r--r--src/http.go6
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 {