author | Alberto Bertogli
<albertito@blitiri.com.ar> 2016-05-28 15:30:16 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2016-05-28 15:32:12 UTC |
parent | 0032ea8fedf36e1d87eda90626eb75730ad7f9aa |
dnss.go | +2 | -0 |
internal/dnstox/resolver.go | +7 | -7 |
diff --git a/dnss.go b/dnss.go index 900579d..3912fa0 100644 --- a/dnss.go +++ b/dnss.go @@ -106,6 +106,7 @@ func main() { if *enableDNStoGRPC { r := dnstox.NewGRPCResolver(*grpcUpstream, *grpcClientCAFile) cr := dnstox.NewCachingResolver(r) + cr.RegisterDebugHandlers() dtg := dnstox.New(*dnsListenAddr, cr, *dnsUnqualifiedUpstream) dtg.SetFallback( *fallbackUpstream, strings.Split(*fallbackDomains, " ")) @@ -135,6 +136,7 @@ func main() { if *enableDNStoHTTPS { r := dnstox.NewHTTPSResolver(*httpsUpstream, *httpsClientCAFile) cr := dnstox.NewCachingResolver(r) + cr.RegisterDebugHandlers() dth := dnstox.New(*dnsListenAddr, cr, *dnsUnqualifiedUpstream) dth.SetFallback( *fallbackUpstream, strings.Split(*fallbackDomains, " ")) diff --git a/internal/dnstox/resolver.go b/internal/dnstox/resolver.go index a25a289..831d8b4 100644 --- a/internal/dnstox/resolver.go +++ b/internal/dnstox/resolver.go @@ -336,16 +336,16 @@ func init() { } func (c *cachingResolver) Init() error { - if err := c.back.Init(); err != nil { - return err - } + return c.back.Init() +} - // We register the debug handlers. - // Note these are global by nature, if you create more than once resolver, - // the last one will prevail. +// RegisterDebugHandlers registers http debug handlers, which can be accessed +// from the monitoring server. +// Note these are global by nature, if you try to register them multiple +// times, you will get a panic. +func (c *cachingResolver) RegisterDebugHandlers() { http.HandleFunc("/debug/dnstox/cache/dump", c.DumpCache) http.HandleFunc("/debug/dnstox/cache/flush", c.FlushCache) - return nil } func (c *cachingResolver) DumpCache(w http.ResponseWriter, r *http.Request) {