summaryrefslogtreecommitdiff
path: root/bitmask/vpn.go
diff options
context:
space:
mode:
Diffstat (limited to 'bitmask/vpn.go')
-rw-r--r--bitmask/vpn.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/bitmask/vpn.go b/bitmask/vpn.go
index 9d12f85..7922d6a 100644
--- a/bitmask/vpn.go
+++ b/bitmask/vpn.go
@@ -1,5 +1,9 @@
package bitmask
+import (
+ "errors"
+)
+
// StartVPN for provider
func (b *Bitmask) StartVPN(provider string) error {
_, err := b.send("vpn", "start", provider)
@@ -20,3 +24,28 @@ func (b *Bitmask) GetStatus() (string, error) {
}
return res["status"].(string), nil
}
+
+// ListGateways return the names of the gateways
+func (b *Bitmask) ListGateways(provider string) ([]string, error) {
+ res, err := b.send("vpn", "list")
+ if err != nil {
+ return nil, err
+ }
+
+ names := []string{}
+ locations, ok := res[provider].([]interface{})
+ if !ok {
+ return nil, errors.New("Can't read the locations for provider " + provider)
+ }
+ for i := range locations {
+ loc := locations[i].(map[string]interface{})
+ names = append(names, loc["name"].(string))
+ }
+ return names, nil
+}
+
+// UseGateway selects name as the default gateway
+func (b *Bitmask) UseGateway(name string) error {
+ _, err := b.send("vpn", "locations", name)
+ return err
+}