diff options
author | kali kaneko (leap communications) <kali@leap.se> | 2021-10-08 11:55:15 +0200 |
---|---|---|
committer | kali kaneko (leap communications) <kali@leap.se> | 2021-11-23 21:51:20 +0100 |
commit | ef683e13aaefebd9cd1f267d5339e1ef574c42d0 (patch) | |
tree | a1e8460fe872fa72750e285101fbdf7d70b92531 /pkg/vpn | |
parent | 49755a3271a19ab8e441406c7095e283a2d6241e (diff) |
[feat] pass udp flag to bitmask-root
Diffstat (limited to 'pkg/vpn')
-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 |
3 files changed, 13 insertions, 3 deletions
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") } } |