diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/backend/api.go | 1 | ||||
-rw-r--r-- | pkg/bitmask/bitmask.go | 1 | ||||
-rw-r--r-- | pkg/vpn/launcher_linux.go | 3 | ||||
-rw-r--r-- | pkg/vpn/main.go | 8 | ||||
-rw-r--r-- | pkg/vpn/openvpn.go | 5 |
5 files changed, 15 insertions, 3 deletions
diff --git a/pkg/backend/api.go b/pkg/backend/api.go index 51fa377..dc7cbbf 100644 --- a/pkg/backend/api.go +++ b/pkg/backend/api.go @@ -95,6 +95,7 @@ func SetTransport(label string) { func SetUDP(udp bool) { log.Println("DEBUG setting UDP") ctx.cfg.SetUseUDP(udp) + ctx.bm.UseUDP(udp) go trigger(OnStatusChanged) } diff --git a/pkg/bitmask/bitmask.go b/pkg/bitmask/bitmask.go index 1d7217c..5597efb 100644 --- a/pkg/bitmask/bitmask.go +++ b/pkg/bitmask/bitmask.go @@ -34,6 +34,7 @@ type Bitmask interface { UseAutomaticGateway() GetTransport() string SetTransport(string) error + UseUDP(bool) error GetCurrentGateway() string GetCurrentLocation() string GetCurrentCountry() string diff --git a/pkg/vpn/launcher_linux.go b/pkg/vpn/launcher_linux.go index 52c87f7..57bbe78 100644 --- a/pkg/vpn/launcher_linux.go +++ b/pkg/vpn/launcher_linux.go @@ -215,7 +215,8 @@ func runBitmaskRoot(arg ...string) error { } arg = append([]string{bitmaskRoot}, arg...) - out, err := exec.Command("pkexec", arg...).Output() + cmd := exec.Command("pkexec", arg...) + out, err := cmd.Output() if err != nil && arg[2] != "isup" { log.Println("Error while running bitmask-root:") log.Println("args: ", arg) diff --git a/pkg/vpn/main.go b/pkg/vpn/main.go index 0671877..0b1d316 100644 --- a/pkg/vpn/main.go +++ b/pkg/vpn/main.go @@ -39,6 +39,7 @@ type Bitmask struct { shapes *shapeshifter.ShapeShifter certPemPath string openvpnArgs []string + udp bool failed bool } @@ -54,7 +55,7 @@ func Init() (*Bitmask, error) { if err != nil { return nil, err } - b := Bitmask{tempdir, bonafide.Gateway{}, bonafide.Gateway{}, statusCh, nil, bf, launch, "", nil, "", []string{}, false} + b := Bitmask{tempdir, bonafide.Gateway{}, bonafide.Gateway{}, statusCh, nil, bf, launch, "", nil, "", []string{}, false, false} b.launch.firewallStop() /* @@ -107,3 +108,8 @@ func (b *Bitmask) NeedsCredentials() bool { func (b *Bitmask) DoLogin(username, password string) (bool, error) { return b.bonafide.DoLogin(username, password) } + +func (b *Bitmask) UseUDP(udp bool) error { + b.udp = udp + return nil +} diff --git a/pkg/vpn/openvpn.go b/pkg/vpn/openvpn.go index e2695a3..673dc2c 100644 --- a/pkg/vpn/openvpn.go +++ b/pkg/vpn/openvpn.go @@ -145,6 +145,7 @@ func (b *Bitmask) startOpenVPN() error { } proxyArgs := strings.Split(proxy, ":") + // TODO pass UDP flag arg = append(arg, "--remote", proxyArgs[0], proxyArgs[1], "tcp4") arg = append(arg, "--route", gw.IPAddress, "255.255.255.255", "net_gateway") } else { @@ -162,9 +163,11 @@ func (b *Bitmask) startOpenVPN() error { for _, gw := range gateways { for _, port := range gw.Ports { if port != "53" { - if os.Getenv("UDP") == "1" { + if b.udp { + os.Setenv("UDP", "1") arg = append(arg, "--remote", gw.IPAddress, port, "udp4") } else { + os.Setenv("UDP", "0") arg = append(arg, "--remote", gw.IPAddress, port, "tcp4") } } |