summaryrefslogtreecommitdiff
path: root/pkg/vpn
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2021-05-31 02:34:21 +0200
committerkali kaneko (leap communications) <kali@leap.se>2021-06-01 12:34:07 +0200
commit3fdbb895b8372caa080044cade00f2de6b00ce91 (patch)
treed7415f43414a42135ed7dde190a1d66cf2501acc /pkg/vpn
parent00be891d3b0cb401e642a5331aedcc399641b8ef (diff)
[feat] obfs4 selectable from gui
Diffstat (limited to 'pkg/vpn')
-rw-r--r--pkg/vpn/openvpn.go29
1 files changed, 15 insertions, 14 deletions
diff --git a/pkg/vpn/openvpn.go b/pkg/vpn/openvpn.go
index d69f4e6..1a92d66 100644
--- a/pkg/vpn/openvpn.go
+++ b/pkg/vpn/openvpn.go
@@ -319,15 +319,25 @@ func (b *Bitmask) UseAutomaticGateway() {
b.bonafide.SetAutomaticGateway()
}
-// UseTransport selects an obfuscation transport to use
-func (b *Bitmask) UseTransport(transport string) error {
- if transport != "obfs4" {
- return fmt.Errorf("Transport %s not implemented", transport)
+// SetTransport selects an obfuscation transport to use
+func (b *Bitmask) SetTransport(t string) error {
+ if t != "openvpn" && t != "obfs4" {
+ return fmt.Errorf("Transport %s not implemented", t)
+ }
+ log.Println("Setting transport to", t)
+ // compare and set string looks strange, but if assigning directly
+ // we're getting some kind of corruption with the transport string.
+ // I suspect something's
+ // not quite right with the c<->go char pointers handling.
+ if t == "obfs4" {
+ b.transport = "obfs4"
+ } else if t == "openvpn" {
+ b.transport = "openvpn"
}
- b.transport = transport
return nil
}
+// GetTransport gets the obfuscation transport to use. Only obfs4 available for now.
func (b *Bitmask) GetTransport() string {
if b.transport == "obfs4" {
return "obfs4"
@@ -336,15 +346,6 @@ func (b *Bitmask) GetTransport() string {
}
}
-func (b *Bitmask) SetTransport(t string) error {
- if t != "openvpn" && t != "obfs4" {
- return errors.New("Transport not supported: " + t)
- }
- log.Println("Setting transport to", t)
- b.transport = t
- return nil
-}
-
func (b *Bitmask) getTempCertPemPath() string {
return path.Join(b.tempdir, "openvpn.pem")
}