diff options
author | kali kaneko (leap communications) <kali@leap.se> | 2021-11-30 21:14:44 +0100 |
---|---|---|
committer | kali kaneko (leap communications) <kali@leap.se> | 2021-11-30 21:22:48 +0100 |
commit | 9c2453b05a98bc5131c37c5dfb535f10bf1054f5 (patch) | |
tree | a6ffa3d2107f9eafb1d9a5643d34dcc432ccf46b | |
parent | aae8c839c62ea39adc16ee844f59b90264b6aab1 (diff) |
[bug] initialize bitmask with persisted udp option
-rw-r--r-- | pkg/backend/api.go | 1 | ||||
-rw-r--r-- | pkg/backend/init.go | 5 | ||||
-rw-r--r-- | pkg/bitmask/init.go | 17 |
3 files changed, 23 insertions, 0 deletions
diff --git a/pkg/backend/api.go b/pkg/backend/api.go index 6d5ceee..52c23c3 100644 --- a/pkg/backend/api.go +++ b/pkg/backend/api.go @@ -148,6 +148,7 @@ type InitOpts struct { ProviderOptions *bitmask.ProviderOpts SkipLaunch bool Obfs4 bool + UDP bool DisableAutostart bool StartVPN string } diff --git a/pkg/backend/init.go b/pkg/backend/init.go index c6d713b..fae5ff1 100644 --- a/pkg/backend/init.go +++ b/pkg/backend/init.go @@ -58,6 +58,7 @@ func initializeBitmask(errCh chan string, opts *InitOpts) { bitmask.InitializeLogger() ctx.cfg = config.ParseConfig() setConfigOpts(opts, ctx.cfg) + ctx.UseUDP = ctx.cfg.UDP err := pid.AcquirePID() if err != nil { @@ -92,6 +93,7 @@ func initializeBitmask(errCh chan string, opts *InitOpts) { ctx.IsReady = true } +// transfer initialization options from the config json to the config object func setConfigOpts(opts *InitOpts, conf *config.Config) { conf.SkipLaunch = opts.SkipLaunch if opts.StartVPN != "" { @@ -104,6 +106,9 @@ func setConfigOpts(opts *InitOpts, conf *config.Config) { if opts.Obfs4 { conf.Obfs4 = opts.Obfs4 } + if opts.UDP { + conf.UDP = opts.UDP + } if opts.DisableAutostart { conf.DisableAutostart = opts.DisableAutostart } diff --git a/pkg/bitmask/init.go b/pkg/bitmask/init.go index bc7d47d..a03a64b 100644 --- a/pkg/bitmask/init.go +++ b/pkg/bitmask/init.go @@ -95,6 +95,11 @@ func InitializeBitmask(conf *config.Config) (Bitmask, error) { return nil, err } + err = setUDP(b, conf) + if err != nil { + return nil, err + } + if !conf.SkipLaunch { err := maybeStartVPN(b, conf) if err != nil { @@ -119,6 +124,18 @@ func setTransport(b Bitmask, conf *config.Config) error { return nil } +func setUDP(b Bitmask, conf *config.Config) error { + if conf.UDP { + log.Printf("Use UDP") + err := b.UseUDP(true) + if err != nil { + log.Printf("Error setting UDP: %v", err) + return err + } + } + return nil +} + func maybeStartVPN(b Bitmask, conf *config.Config) error { if !conf.StartVPN { return nil |