diff options
-rw-r--r-- | core/dnsserver/onstartup.go | 29 | ||||
-rw-r--r-- | core/dnsserver/server-grpc.go | 6 | ||||
-rw-r--r-- | core/dnsserver/server-tls.go | 6 | ||||
-rw-r--r-- | core/dnsserver/server.go | 20 |
4 files changed, 41 insertions, 20 deletions
diff --git a/core/dnsserver/onstartup.go b/core/dnsserver/onstartup.go new file mode 100644 index 000000000..05adf290c --- /dev/null +++ b/core/dnsserver/onstartup.go @@ -0,0 +1,29 @@ +package dnsserver + +import "fmt" + +// startUpZones create the text that we show when starting up: +// grpc://example.com.:1055 +// example.com.:1053 on 127.0.0.1 +func startUpZones(protocol, addr string, zones map[string]*Config) string { + s := "" + + for zone := range zones { + // split addr into protocol, IP and Port + _, ip, port, err := SplitProtocolHostPort(addr) + + if err != nil { + // this should not happen, but we need to take care of it anyway + s += fmt.Sprintln(protocol + zone + ":" + addr) + continue + } + if ip == "" { + s += fmt.Sprintln(protocol + zone + ":" + port) + continue + } + // if the server is listening on a specific address let's make it visible in the log, + // so one can differentiate between all active listeners + s += fmt.Sprintln(protocol + zone + ":" + port + " on " + ip) + } + return s +} diff --git a/core/dnsserver/server-grpc.go b/core/dnsserver/server-grpc.go index ba9519cdb..c2f20dcc2 100644 --- a/core/dnsserver/server-grpc.go +++ b/core/dnsserver/server-grpc.go @@ -88,9 +88,11 @@ func (s *ServergRPC) OnStartupComplete() { return } - for zone, config := range s.zones { - fmt.Println(TransportGRPC + "://" + zone + ":" + config.Port) + out := startUpZones(TransportGRPC+"://", s.Addr, s.zones) + if out != "" { + fmt.Print(out) } + return } // Stop stops the server. It blocks until the server is diff --git a/core/dnsserver/server-tls.go b/core/dnsserver/server-tls.go index 55802d158..12b063661 100644 --- a/core/dnsserver/server-tls.go +++ b/core/dnsserver/server-tls.go @@ -72,7 +72,9 @@ func (s *ServerTLS) OnStartupComplete() { return } - for zone, config := range s.zones { - fmt.Println(TransportTLS + "://" + zone + ":" + config.Port) + out := startUpZones(TransportTLS+"://", s.Addr, s.zones) + if out != "" { + fmt.Print(out) } + return } diff --git a/core/dnsserver/server.go b/core/dnsserver/server.go index 868aa1bdc..16be955b3 100644 --- a/core/dnsserver/server.go +++ b/core/dnsserver/server.go @@ -294,23 +294,11 @@ func (s *Server) OnStartupComplete() { return } - for zone := range s.zones { - // split addr into protocol, IP and Port - _, ip, port, err := SplitProtocolHostPort(s.Addr) - - if err != nil { - // this should not happen, but we need to take care of it anyway - fmt.Println(zone + ":" + s.Addr) - continue - } - if ip == "" { - fmt.Println(zone + ":" + port) - continue - } - // if the server is listening on a specific address let's make it visible in the log, - // so one can differentiate between all active listeners - fmt.Println(zone + ":" + port + " on " + ip) + out := startUpZones("", s.Addr, s.zones) + if out != "" { + fmt.Print(out) } + return } // Tracer returns the tracer in the server if defined. |