about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/access.go15
-rw-r--r--src/main.go1
2 files changed, 16 insertions, 0 deletions
diff --git a/src/access.go b/src/access.go
index 6072025..ddb032d 100644
--- a/src/access.go
+++ b/src/access.go
@@ -8,10 +8,18 @@ import (
 	"net/http"
 	"fmt"
 	"github.com/docker/docker/api/types/network"
+	"flag"
 )
 
 var vpnContainerID string
 var vpnNetworkID string
+var remoteAddress* string
+var remotePort* int
+
+func registerAccessFlags() {
+	remoteAddress = flag.String("vpnRemoteAddress", "", "The remote domain name or IP the VPN will run on")
+	remotePort = flag.Int("vpnRemotePort", 1194, "The port the VPN should listen on")
+}
 
 func startVPN() (err error) {
 	// Set up our context and Docker CLI connection
@@ -23,12 +31,19 @@ func startVPN() (err error) {
 	// Create container
 	resp, err := dockerCli.ContainerCreate(dockerCtx, &container.Config{
 		Image: "circus-vpn",
+		Env: []string{
+			fmt.Sprintf("remoteAddress=%s", *remoteAddress),
+			fmt.Sprintf("remotePort=%d", *remotePort),
+		},
 	}, &container.HostConfig{
 		Privileged: true,
 	}, &network.NetworkingConfig{
 		EndpointsConfig: map[string]*network.EndpointSettings{
 			"endpoint": {
 				NetworkID: vpnNetworkID,
+				Links: []string{
+					fmt.Sprintf("%d:1194/tcp", *remotePort),
+				},
 			},
 		},
 	}, "")
diff --git a/src/main.go b/src/main.go
index a06ee66..ae50632 100644
--- a/src/main.go
+++ b/src/main.go
@@ -11,6 +11,7 @@ func main() {
 	registerSessionFlags()
 	registerCredentialsFlags()
 	registerSeedFlags()
+	registerAccessFlags()
 	flag.Parse()
 
 	// Read challenges from file