Startup notification (#250)

Stop the caddy message and start our own init notifications.
Log the version of CoreDNS when starting up.
Fix all middleware's setup functions so that return the error prefixed
with *which* middleware was failing; leads to better debuggable errors
when starting up.
This commit is contained in:
Miek Gieben 2016-09-10 09:16:25 +01:00 committed by GitHub
parent 5216ab6b58
commit 2dd8a687b3
19 changed files with 82 additions and 34 deletions

View file

@ -12,6 +12,7 @@ import (
"github.com/miekg/dns"
)
// TCPServer returns a generic DNS server listening for TCP connections on laddr.
func TCPServer(t *testing.T, laddr string) (*dns.Server, string, error) {
l, err := net.Listen("tcp", laddr)
if err != nil {
@ -33,6 +34,7 @@ func TCPServer(t *testing.T, laddr string) (*dns.Server, string, error) {
return server, l.Addr().String(), nil
}
// UDPServer returns a generic DNS server listening for UDP connections on laddr.
func UDPServer(t *testing.T, laddr string) (*dns.Server, string, error) {
pc, err := net.ListenPacket("udp", laddr)
if err != nil {
@ -53,8 +55,11 @@ func UDPServer(t *testing.T, laddr string) (*dns.Server, string, error) {
return server, pc.LocalAddr().String(), nil
}
// CoreDNSServer returns a test server. It just takes a normal Corefile as input.
func CoreDNSServer(corefile string) (*caddy.Instance, error) { return caddy.Start(NewInput(corefile)) }
// CoreDNSServer returns a CoreDNS test server. It just takes a normal Corefile as input.
func CoreDNSServer(corefile string) (*caddy.Instance, error) {
caddy.Quiet = true
return caddy.Start(NewInput(corefile))
}
// CoreDNSSserverStop stops a server.
func CoreDNSServerStop(i *caddy.Instance) { i.Stop() }