Skip to content
Snippets Groups Projects
Unverified Commit 9c2453b0 authored by Kali Kaneko's avatar Kali Kaneko
Browse files

[bug] initialize bitmask with persisted udp option

parent aae8c839
No related branches found
No related tags found
No related merge requests found
......@@ -148,6 +148,7 @@ type InitOpts struct {
ProviderOptions *bitmask.ProviderOpts
SkipLaunch bool
Obfs4 bool
UDP bool
DisableAutostart bool
StartVPN string
}
......
......@@ -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
}
......
......@@ -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
......
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