This repository has been archived by the owner on Jan 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch from glide to dep for dependency management
- Loading branch information
Dan Vittegleo
committed
Jul 26, 2017
1 parent
e5abd63
commit a65d232
Showing
10 changed files
with
191 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
# Gopkg.toml example | ||
# | ||
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md | ||
# for detailed Gopkg.toml documentation. | ||
# | ||
# required = ["github.com/user/thing/cmd/thing"] | ||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project" | ||
# version = "1.0.0" | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project2" | ||
# branch = "dev" | ||
# source = "github.com/myfork/project2" | ||
# | ||
# [[override]] | ||
# name = "github.com/x/y" | ||
# version = "2.4.0" | ||
|
||
|
||
[[constraint]] | ||
name = "github.com/digitalocean/godo" | ||
version = "1.0.0" | ||
|
||
[[constraint]] | ||
branch = "master" | ||
name = "golang.org/x/crypto" | ||
|
||
[[constraint]] | ||
branch = "master" | ||
name = "golang.org/x/oauth2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"log" | ||
"math/rand" | ||
"net/http" | ||
"os" | ||
"os/exec" | ||
"strconv" | ||
|
||
"github.com/dan-v/dosxvpn" | ||
) | ||
|
||
var ( | ||
flagCli = flag.Bool("cli", false, "Deploy using CLI. Must define DIGITALOCEAN_ACCESS_TOKEN") | ||
flagDelete = flag.Bool("delete", false, "Delete all dosxvpn instances") | ||
flagRegion = flag.String("region", "sfo2", "Region to deploy VPN (e.g. ams2,ams3,nyc1,nyc2,nyc3,sfo1,sfo2)") | ||
) | ||
|
||
const ( | ||
digitalOceanClientId = "e731e4858af83d074073a9bb8507c5aed08611121b90ed6d602a6d4ce43d5c8c" | ||
port = 8999 | ||
) | ||
|
||
func main() { | ||
flag.Parse() | ||
|
||
if *flagDelete { | ||
deleteAllInstances() | ||
return | ||
} | ||
|
||
if *flagCli { | ||
cliDeployment(*flagRegion) | ||
return | ||
} | ||
|
||
host := "http://localhost:" + strconv.Itoa(port) | ||
exec.Command("open", host).Start() | ||
handler := dosxvpn.Handler(digitalOceanClientId, host) | ||
err := http.ListenAndServe(":"+strconv.Itoa(port), handler) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
func getCliToken() string { | ||
token := os.Getenv("DIGITALOCEAN_ACCESS_TOKEN") | ||
if token == "" { | ||
log.Fatal("Must have environment variable DIGITALOCEAN_ACCESS_TOKEN set") | ||
} | ||
return token | ||
} | ||
|
||
func deleteAllInstances() { | ||
token := getCliToken() | ||
instances, err := dosxvpn.RemoveAllDroplets(token) | ||
if err != nil { | ||
log.Fatal("Failed to remove instances.", err) | ||
} | ||
log.Println("Removed following instances: ", instances) | ||
} | ||
|
||
func cliDeployment(region string) { | ||
token := getCliToken() | ||
|
||
droplet, err := dosxvpn.Deploy(token, dosxvpn.DropletName("dosxvpn-"+randomString(6)+"-"+region), dosxvpn.DropletRegion(region)) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
log.Println("Created DigitalOcean droplet", droplet.DropletID) | ||
|
||
log.Println("Waiting for SSH to start...") | ||
err = dosxvpn.WaitForSSH(droplet) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
log.Println("Getting VPN details...") | ||
vpnDetails, err := dosxvpn.GetVPNDetails(droplet, region) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
log.Println("Adding VPN to OSX...") | ||
err = dosxvpn.SetupVPN(vpnDetails) | ||
if err != nil { | ||
log.Println(err) | ||
} | ||
|
||
log.Println("##############################") | ||
log.Println("VPN IP:", droplet.IPv4Address) | ||
log.Println("##############################") | ||
} | ||
|
||
func randomString(n int) string { | ||
return strconv.Itoa(rand.Int())[:n] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/bin/bash | ||
|
||
platypus -y --quit-after-execution --app-icon 'appicon.icns' --name 'dosxvpn' --interface-type 'None' --interpreter '/bin/bash' --bundled-file '../build/osx/x86-64/dosxvpn' --bundled-file '../static' 'run.sh' ../build/osx/x86-64/dosxvpn | ||
./platypus -y --quit-after-execution --app-icon 'appicon.icns' --name 'dosxvpn' --interface-type 'None' --interpreter '/bin/bash' --bundled-file '../build/osx/x86-64/dosxvpn' --bundled-file '../static' 'run.sh' ../build/osx/x86-64/dosxvpn |
Binary file not shown.