package main import ( "context" "fmt" "github.com/docker/docker/client" ) const ( fixedDockerVersion = "1.38" ) var ( compiledContainerNetworkName string compiledChallengeNetworkName string ) var ( dockerCtx context.Context dockerCli *client.Client ) func setupContext() { if dockerCtx == nil { dockerCtx = context.Background() } } func setupDockerCLI() (err error) { if dockerCli == nil { dockerCli, err = client.NewClientWithOpts(client.WithVersion(fixedDockerVersion)) } return err } // Returns the network name for the companion<=>vpn network func getVPNNetworkName() (string) { if compiledContainerNetworkName == "" { compiledContainerNetworkName = fmt.Sprintf("circus-vpnnet-%s", getUsernameHash()) } return compiledContainerNetworkName } func getChallengeNetworkName() (string) { if compiledChallengeNetworkName == "" { compiledChallengeNetworkName = fmt.Sprintf("circus-vpnhostnet-%s", getUsernameHash()) } return compiledChallengeNetworkName }