From 816acb9d8dd8f5348c8d7245d2352893335c9018 Mon Sep 17 00:00:00 2001 From: Alison Winters Date: Wed, 30 Oct 2019 21:34:00 +0800 Subject: [PATCH] move ConfigLoad into AppMain --- dnscrypt-proxy/main.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/dnscrypt-proxy/main.go b/dnscrypt-proxy/main.go index 98af05d8..94b0de82 100644 --- a/dnscrypt-proxy/main.go +++ b/dnscrypt-proxy/main.go @@ -23,6 +23,7 @@ type App struct { wg sync.WaitGroup quit chan struct{} proxy *Proxy + flags *ConfigFlags } func main() { @@ -67,7 +68,9 @@ func main() { os.Exit(0) } - app := &App{} + app := &App{ + flags: &flags, + } svc, err := service.New(app, svcConfig) if err != nil { svc = nil @@ -75,9 +78,6 @@ func main() { } app.proxy = NewProxy() _ = ServiceManagerStartNotify() - if err := ConfigLoad(app.proxy, &flags); err != nil { - dlog.Fatal(err) - } if len(*svcFlag) != 0 { if svc == nil { dlog.Fatal("Built-in service installation is not supported on this platform") @@ -108,11 +108,6 @@ func main() { } func (app *App) Start(service service.Service) error { - if err := app.proxy.InitPluginsGlobals(); err != nil { - dlog.Fatal(err) - } - app.quit = make(chan struct{}) - app.wg.Add(1) if service != nil { go func() { app.AppMain() @@ -124,6 +119,14 @@ func (app *App) Start(service service.Service) error { } func (app *App) AppMain() { + if err := ConfigLoad(app.proxy, app.flags); err != nil { + dlog.Fatal(err) + } + if err := app.proxy.InitPluginsGlobals(); err != nil { + dlog.Fatal(err) + } + app.quit = make(chan struct{}) + app.wg.Add(1) pidfile.Write() app.proxy.StartProxy() <-app.quit