diff --git a/pkg/vpn/bitmask.go b/pkg/vpn/bitmask.go index d40a601346e4732e60d502cbbd2263c847d9a546..7fd32d4ce28271ee644ab9942e8b8fc711f5c8ec 100644 --- a/pkg/vpn/bitmask.go +++ b/pkg/vpn/bitmask.go @@ -29,6 +29,7 @@ import ( "0xacab.org/leap/bitmask-vpn/pkg/snowflake" "0xacab.org/leap/bitmask-vpn/pkg/vpn/bonafide" "0xacab.org/leap/bitmask-vpn/pkg/vpn/management" + "0xacab.org/leap/bitmask-vpn/pkg/vpn/menshen" obfsvpn "0xacab.org/leap/obfsvpn/client" ) @@ -61,7 +62,29 @@ func Init() (*Bitmask, error) { return nil, err } - api := bonafide.New() + var api apiInterface + if os.Getenv("API_VERSION") == "5" { + config.ApiVersion = 5 + log.Debug().Msg("Enforcing API v5 by env variable") + } + log.Debug(). + Int("apiVersion", config.ApiVersion). + Msg("Using specific API backend version") + + if config.ApiVersion == 5 { + api, err = menshen.New() + if err != nil { + return nil, err + } + } else if config.ApiVersion == 3 { + api = bonafide.New() + } else { + log.Warn(). + Int("apiVersion", config.ApiVersion). + Msg("ApiVersion of provider was not set correctly. Version 3 and 5 is supported. Using v3 for backwards compatiblity") + api = bonafide.New() + } + launch, err := launcher.NewLauncher() if err != nil { return nil, err diff --git a/pkg/vpn/openvpn.go b/pkg/vpn/openvpn.go index 0f90770e87020fb2b0a54d37481f5ba2a19b98dc..edf333ef71cd782f57c35b051d417fe34ae65c5c 100644 --- a/pkg/vpn/openvpn.go +++ b/pkg/vpn/openvpn.go @@ -204,6 +204,15 @@ func (b *Bitmask) startOpenVPN(ctx context.Context) error { */ b.statusCh <- Starting if b.GetTransport() == "obfs4" { + + if config.ApiVersion == 5 { + // if I return an error, the GUI state does not get updated properly to Failed/Stopped and + // continues to stay in state Connecting (also clicking Cancel doesnot work) + log.Fatal().Msg("Could not start OpenVPN with obfs4. This is currently not supported via v5") + // menshen/v5 has different api endpoints: gateways and bridges + // gw.Options is always empty right now + } + var gw bonafide.Gateway var gateways []bonafide.Gateway var proxy string