From f422849567179a7985ea7356ce0af1cbc31f4810 Mon Sep 17 00:00:00 2001 From: Sir Darkrengarius Date: Wed, 12 Aug 2020 17:49:50 +0300 Subject: [PATCH 1/2] Make app exit on VPN server failure --- cmd/apps/vpn-server/vpn-server.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/apps/vpn-server/vpn-server.go b/cmd/apps/vpn-server/vpn-server.go index d11d116ad2..664c86f89b 100644 --- a/cmd/apps/vpn-server/vpn-server.go +++ b/cmd/apps/vpn-server/vpn-server.go @@ -78,11 +78,19 @@ func main() { log.WithError(err).Errorln("Error closing server") } }() + + errCh := make(chan error) go func() { if err := srv.Serve(l); err != nil { - log.WithError(err).Errorln("Error serving") + errCh <- err } + + close(errCh) }() - <-osSigs + select { + case <-osSigs: + case err := <-errCh: + log.WithError(err).Errorln("Error serving") + } } From fad4a0c4634e8cbb9145b80d30e114a7ad009529 Mon Sep 17 00:00:00 2001 From: Sir Darkrengarius Date: Thu, 13 Aug 2020 16:44:26 +0300 Subject: [PATCH 2/2] Make VPN server exit immediately on non-Linux OS --- cmd/apps/vpn-server/vpn-server.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/apps/vpn-server/vpn-server.go b/cmd/apps/vpn-server/vpn-server.go index 664c86f89b..b934addee2 100644 --- a/cmd/apps/vpn-server/vpn-server.go +++ b/cmd/apps/vpn-server/vpn-server.go @@ -4,6 +4,7 @@ import ( "flag" "os" "os/signal" + "runtime" "syscall" "github.com/sirupsen/logrus" @@ -32,6 +33,10 @@ var ( ) func main() { + if runtime.GOOS != "linux" { + log.Fatalln("OS is not supported") + } + flag.Parse() localPK := cipher.PubKey{}