Skip to content
Snippets Groups Projects
Commit 0f43c044 authored by Pea Nut's avatar Pea Nut Committed by jkito
Browse files

Use v5 implementation if configured or env is set

parent 8ef9441d
No related branches found
No related tags found
1 merge request!198v5 implementation with a single Bitmask struct
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment