moved blocking wait

This commit is contained in:
Niklas 2020-12-26 21:34:11 +01:00
parent 5ce381f370
commit 0da61804f7

View File

@ -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)
}