package main import ( "fmt" "net/http" "os" "os/signal" "syscall" "github.com/miekg/dns" ) var BASE_DOMAIN string var DNS_SERVER string var db *DB func init() { if BASE_DOMAIN == "" { BASE_DOMAIN = "misconfigured.acme-dns.example.com." } if DNS_SERVER == "" { DNS_SERVER = "misconfigured.acme-dns.example.com." } } func runServer(server interface { ListenAndServe() error }, name string) { fmt.Printf("starting %s listener\n", name) if err := server.ListenAndServe(); err != nil { fmt.Printf("got error in %s listener: %s\n", name, err) os.Exit(1) } fmt.Printf("%s listener stopped\n", name) os.Exit(1) } func main() { go runServer(&http.Server{}, "http") go runServer(&dns.Server{Net: "tcp"}, "dns-tcp") go runServer(&dns.Server{Net: "udp"}, "dns-udp") sig := make(chan os.Signal) signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM) <-sig os.Exit(0) }