Skip to content
This repository has been archived by the owner on Jan 31, 2021. It is now read-only.

Commit

Permalink
Switch from glide to dep for dependency management
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Vittegleo committed Jul 26, 2017
1 parent e5abd63 commit a65d232
Show file tree
Hide file tree
Showing 10 changed files with 191 additions and 100 deletions.
41 changes: 1 addition & 40 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@

# Created by https://www.gitignore.io/api/go,intellij

### Go ###
# Binaries for programs and plugins
*.exe
*.dll
*.so
*.dylib

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
.glide/

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
Expand Down Expand Up @@ -59,30 +40,10 @@ atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
.idea/sonarlint

# End of https://www.gitignore.io/api/go,intellij

.idea/*
.DS_Store
dosxvpn
*.mobileconfig
static/dosxvpn.mobileconfig
dosxvpn.app
platypus/dosxvpn.app
build/*
platypus/dosxvpn.app
54 changes: 54 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions Gopkg.toml
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"
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ all: osx
osx:
GOOS=darwin GOARCH=amd64 go build -o ./build/osx/x86-64/dosxvpn ./cmd/dosxvpn
cd platypus && ./build.sh
cd build/osx/x86-64 && zip -r ./dosxvpn.zip ./dosxvpn.app

clean:
rm -rf build
Expand Down
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@ The easiest way is to download a pre-built binary from the [GitHub Releases](htt
go get github.com/dan-v/dosxvpn
cd $GOPATH/src/github.com/dan-v/dosxvpn
```

2. Install dependencies (using [Glide](https://github.com/Masterminds/glide) for dependency management)

```sh
glide install
```

3. Run make to build (will need to install [platypus cli](http://www.sveinbjorn.org/platypus)). CLI and OSX app can then be found under build/osx/x86-64.
2. Run make to build (will need to install [platypus cli](http://www.sveinbjorn.org/platypus)). CLI and OSX app can then be found under build/osx/x86-64.

```sh
make
Expand Down
99 changes: 99 additions & 0 deletions cmd/dosxvpn/main.go
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]
}
44 changes: 0 additions & 44 deletions glide.lock

This file was deleted.

8 changes: 0 additions & 8 deletions glide.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion platypus/build.sh
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 added platypus/platypus
Binary file not shown.

0 comments on commit a65d232

Please sign in to comment.