diff --git a/.travis.yml b/.travis.yml index 8fda1805..cb8cf732 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ script: - zip -9 -r dnscrypt-proxy-win64-${TRAVIS_TAG:-dev}.zip win64 - go clean - - env GOOS=openbsd GOARCH=386 go build -ldflags="-s -w" + - env GO386=387 GOOS=openbsd GOARCH=386 go build -ldflags="-s -w" - mkdir openbsd-i386 - ln dnscrypt-proxy openbsd-i386/ - ln ../LICENSE dnscrypt-proxy.toml forwarding-rules.txt blacklist.txt openbsd-i386/ diff --git a/dnscrypt-proxy/main.go b/dnscrypt-proxy/main.go index 250c3a02..88da39dd 100644 --- a/dnscrypt-proxy/main.go +++ b/dnscrypt-proxy/main.go @@ -61,7 +61,8 @@ func main() { app := &App{} svc, err := service.New(app, svcConfig) if err != nil { - dlog.Fatal(err) + svc = nil + dlog.Debug(err) } app.proxy = Proxy{} if err := ConfigLoad(&app.proxy, svcFlag, "dnscrypt-proxy.toml"); err != nil { @@ -84,8 +85,12 @@ func main() { } return } - if err = svc.Run(); err != nil { - dlog.Fatal(err) + if svc != nil { + if err = svc.Run(); err != nil { + dlog.Fatal(err) + } + } else { + app.Start(nil) } } @@ -99,15 +104,23 @@ func (app *App) Start(service service.Service) error { } app.quit = make(chan struct{}) app.wg.Add(1) - go func() { - proxy.StartProxy() - <-app.quit - dlog.Notice("Quit signal received...") - app.wg.Done() - }() + if service != nil { + go func() { + app.AppMain(&proxy) + }() + } else { + app.AppMain(&proxy) + } return nil } +func (app *App) AppMain(proxy *Proxy) { + proxy.StartProxy() + <-app.quit + dlog.Notice("Quit signal received...") + app.wg.Done() +} + func (app *App) Stop(service service.Service) error { dlog.Notice("Stopped.") return nil