summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui/providers/providers.json2
-rw-r--r--pkg/vpn/main.go3
-rw-r--r--pkg/vpn/openvpn.go30
-rw-r--r--pkg/vpn/status.go15
4 files changed, 37 insertions, 13 deletions
diff --git a/gui/providers/providers.json b/gui/providers/providers.json
index 0de5900..727eca7 100644
--- a/gui/providers/providers.json
+++ b/gui/providers/providers.json
@@ -15,7 +15,7 @@
"apiURL": "https://api.black.riseup.net/",
"geolocationAPI": "https://api.black.riseup.net:9001/json",
"caCertString": "-----BEGIN CERTIFICATE-----\nMIIFjTCCA3WgAwIBAgIBATANBgkqhkiG9w0BAQ0FADBZMRgwFgYDVQQKDA9SaXNl\ndXAgTmV0d29ya3MxGzAZBgNVBAsMEmh0dHBzOi8vcmlzZXVwLm5ldDEgMB4GA1UE\nAwwXUmlzZXVwIE5ldHdvcmtzIFJvb3QgQ0EwHhcNMTQwNDI4MDAwMDAwWhcNMjQw\nNDI4MDAwMDAwWjBZMRgwFgYDVQQKDA9SaXNldXAgTmV0d29ya3MxGzAZBgNVBAsM\nEmh0dHBzOi8vcmlzZXVwLm5ldDEgMB4GA1UEAwwXUmlzZXVwIE5ldHdvcmtzIFJv\nb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC76J4ciMJ8Sg0m\nTP7DF2DT9zNe0Csk4myoMFC57rfJeqsAlJCv1XMzBmXrw8wq/9z7XHv6n/0sWU7a\n7cF2hLR33ktjwODlx7vorU39/lXLndo492ZBhXQtG1INMShyv+nlmzO6GT7ESfNE\nLliFitEzwIegpMqxCIHXFuobGSCWF4N0qLHkq/SYUMoOJ96O3hmPSl1kFDRMtWXY\niw1SEKjUvpyDJpVs3NGxeLCaA7bAWhDY5s5Yb2fA1o8ICAqhowurowJpW7n5ZuLK\n5VNTlNy6nZpkjt1QycYvNycffyPOFm/Q/RKDlvnorJIrihPkyniV3YY5cGgP+Qkx\nHUOT0uLA6LHtzfiyaOqkX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pf/rIlgbAjarnJ\nUN9SaWRlWKSdP4haujnzCoJbM7dU9bjvlGZNyXEekgeT0W2qFeGGp+yyUWw8tNsp\n0BuC1b7uW/bBn/xKm319wXVDvBgZgcktMolak39V7DVO\n-----END CERTIFICATE-----",
- "timeStamp": "2021-05-04 12:59:11"
+ "timeStamp": "2021-05-04 15:00:51"
}
]
} \ No newline at end of file
diff --git a/pkg/vpn/main.go b/pkg/vpn/main.go
index 5f5117a..f40366c 100644
--- a/pkg/vpn/main.go
+++ b/pkg/vpn/main.go
@@ -30,6 +30,7 @@ import (
type Bitmask struct {
tempdir string
onGateway bonafide.Gateway
+ ptGateway bonafide.Gateway
statusCh chan string
managementClient *openvpn.MgmtClient
bonafide *bonafide.Bonafide
@@ -52,7 +53,7 @@ func Init() (*Bitmask, error) {
if err != nil {
return nil, err
}
- b := Bitmask{tempdir, bonafide.Gateway{}, statusCh, nil, bf, launch, "", nil, "", []string{}}
+ b := Bitmask{tempdir, bonafide.Gateway{}, bonafide.Gateway{}, statusCh, nil, bf, launch, "", nil, "", []string{}}
b.launch.firewallStop()
/*
diff --git a/pkg/vpn/openvpn.go b/pkg/vpn/openvpn.go
index 2e552a1..4dad0e2 100644
--- a/pkg/vpn/openvpn.go
+++ b/pkg/vpn/openvpn.go
@@ -59,7 +59,8 @@ func (b *Bitmask) CanStartVPN() bool {
return !b.bonafide.NeedsCredentials()
}
-func (b *Bitmask) startTransport() (proxy string, err error) {
+func (b *Bitmask) startTransport(host string) (proxy string, err error) {
+ // TODO configure port if not available
proxy = "127.0.0.1:4430"
if b.shapes != nil {
return proxy, nil
@@ -75,9 +76,13 @@ func (b *Bitmask) startTransport() (proxy string, err error) {
}
for _, gw := range gateways {
+ if gw.Host != host {
+ continue
+ }
if _, ok := gw.Options["cert"]; !ok {
continue
}
+ log.Println("Selected Gateway:", gw.Host, gw.IPAddress)
b.shapes = &shapeshifter.ShapeShifter{
Cert: gw.Options["cert"],
Target: gw.IPAddress + ":" + gw.Ports[0],
@@ -95,6 +100,7 @@ func (b *Bitmask) startTransport() (proxy string, err error) {
log.Printf("Can't connect to transport %s: %v", b.transport, err)
continue
}
+ log.Println("Connected via obfs4 to", gw.IPAddress, "(", gw.Host, ")")
return proxy, nil
}
return "", fmt.Errorf("No working gateway for transport %s: %v", b.transport, err)
@@ -112,8 +118,10 @@ func (b *Bitmask) listenShapeErr() {
}
func (b *Bitmask) startOpenVPN() error {
- arg := b.openvpnArgs
+ arg := []string{}
+ // Empty transport means we get only the openvpn gateways
if b.transport == "" {
+ arg = b.openvpnArgs
gateways, err := b.bonafide.GetGateways("openvpn")
if err != nil {
return err
@@ -129,15 +137,23 @@ func (b *Bitmask) startOpenVPN() error {
}
}
} else {
- proxy, err := b.startTransport()
+ // For now, obf4 is the only supported Pluggable Transport
+ gateways, err := b.bonafide.GetGateways(b.transport)
if err != nil {
return err
}
+ if len(gateways) == 0 {
+ log.Printf("ERROR No gateway for transport %s in provider", b.transport)
+ return errors.New("ERROR: cannot find any gateway for selected transport")
+ }
- gateways, err := b.bonafide.GetGateways(b.transport)
+ gw := gateways[0]
+ proxy, err := b.startTransport(gw.Host)
if err != nil {
return err
}
+ b.ptGateway = gw
+
err = b.launch.firewallStart(gateways)
if err != nil {
return err
@@ -145,14 +161,16 @@ func (b *Bitmask) startOpenVPN() error {
proxyArgs := strings.Split(proxy, ":")
arg = append(arg, "--remote", proxyArgs[0], proxyArgs[1], "tcp4")
+ arg = append(arg, "--route", gw.IPAddress, "255.255.255.255", "net_gateway")
}
arg = append(arg,
- "--verb", "1",
+ "--verb", "3",
"--management-client",
"--management", openvpnManagementAddr, openvpnManagementPort,
"--ca", b.getCaCertPath(),
"--cert", b.certPemPath,
- "--key", b.certPemPath)
+ "--key", b.certPemPath,
+ "--persist-tun")
return b.launch.openvpnStart(arg...)
}
diff --git a/pkg/vpn/status.go b/pkg/vpn/status.go
index 647cf27..0b04c3b 100644
--- a/pkg/vpn/status.go
+++ b/pkg/vpn/status.go
@@ -74,12 +74,17 @@ func (b *Bitmask) eventHandler(eventCh <-chan openvpn.Event) {
}
if statusName == "CONNECTED" {
ip := strings.Split(stateEvent.String(), ": ")[1]
- gw, err := b.bonafide.GetGatewayByIP(ip)
- if err == nil {
- b.onGateway = gw
- log.Println("Connected to gateway:", b.onGateway.Host)
+ if ip == "127.0.0.1" {
+ // we're using pluggable transports
+ b.onGateway = b.ptGateway
} else {
- log.Println("ERROR: connected to unknown gateway", ip)
+ gw, err := b.bonafide.GetGatewayByIP(ip)
+ if err == nil {
+ b.onGateway = gw
+ log.Println("Connected to gateway:", b.onGateway.Host)
+ } else {
+ log.Println("ERROR: connected to unknown gateway", ip)
+ }
}
}
}