From 0da61804f765dc829002bcf24eb6b7dbd757b547 Mon Sep 17 00:00:00 2001 From: Niklas Date: Sat, 26 Dec 2020 21:34:11 +0100 Subject: [PATCH] moved blocking wait --- coolDns.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/coolDns.go b/coolDns.go index 1e1a913..67113dc 100644 --- a/coolDns.go +++ b/coolDns.go @@ -224,12 +224,6 @@ func listenAndServer(server *dns.ServeMux, address string) { log.Fatalf("Failed to set tcp listener %s\n", err.Error()) } }() - - sig := make(chan os.Signal) - signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM) - s := <-sig - log.Printf("Signal (%v) received, stopping\n", s) - os.Exit(0) } func checkACL(alcRules []string, aclList map[string]*net.IPNet, ip net.IP) bool { @@ -331,21 +325,28 @@ func main() { config, err := loadConfig(*configPath) if err != nil { - log.Fatalf("Failed to load config: %s", err.Error()) + log.Fatalf("Failed to load config: %s\n", err.Error()) } zones, err := loadZones(config.Zones) if err != nil { - log.Fatalf("Failed to load zones: %s", err.Error()) + log.Fatalf("Failed to load zones: %s\n", err.Error()) } aclList, err := createACLList(config.ACL) if err != nil { - log.Fatalf("Failed to parse ACL rules: %s", err.Error()) + log.Fatalf("Failed to parse ACL rules: %s\n", err.Error()) } server := createServer(zones, *config, aclList) - log.Printf("Start listening on udp %s and tcp %s\n", config.Address, config.Address) listenAndServer(server, config.Address) + + log.Printf("Start listening on udp %s and tcp %s\n", config.Address, config.Address) + + sig := make(chan os.Signal) + signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM) + s := <-sig + log.Printf("Signal (%v) received, stopping\n", s) + os.Exit(0) }