diff --git a/pkg/engine/v1/server.go b/pkg/engine/v1/server.go index fd90078..c5abba9 100644 --- a/pkg/engine/v1/server.go +++ b/pkg/engine/v1/server.go @@ -86,15 +86,16 @@ func (s *Server) ServeDNS(w dns.ResponseWriter, m *dns.Msg) { goto RESPONSE } - log.WithFields(log.Fields{ - "req_id": reqID, - "name": m.Question[0].Name, - "type": m.Question[0].Qtype, - }).Debug("Receive request") - context = plugin.NewContext(w, m, reqID) context.MustRegisterPluginsOnce(s.plugins) + log.WithFields(log.Fields{ + "req_id": reqID, + "name": m.Question[0].Name, + "type": m.Question[0].Qtype, + "client_ip": context.ClientIP(), + }).Debug("Receive request") + context.Warmup() context.Patch() diff --git a/plugin/mupstream/plugin.go b/plugin/mupstream/plugin.go index fcef181..25a0ba2 100644 --- a/plugin/mupstream/plugin.go +++ b/plugin/mupstream/plugin.go @@ -33,7 +33,7 @@ func (p *Plugin) Patch(c *plugin.Context) { up := p.bestUpstream() resp, rtt, err := up.forward(c.Msg) if err != nil { - c.Error(err) + // c.Error(err) return } resp.CopyTo(c.Msg) diff --git a/plugin/mupstream/upstream.go b/plugin/mupstream/upstream.go index 5400f54..d63e444 100644 --- a/plugin/mupstream/upstream.go +++ b/plugin/mupstream/upstream.go @@ -28,7 +28,7 @@ func newUpstream(addr string) *upstream { Dialer: &net.Dialer{ KeepAlive: time.Minute, }, - Timeout: time.Second, + Timeout: 300 * time.Millisecond, }, } } diff --git a/plugin/statistics/plugin.go b/plugin/statistics/plugin.go index 9eb5872..86a0234 100644 --- a/plugin/statistics/plugin.go +++ b/plugin/statistics/plugin.go @@ -64,9 +64,12 @@ func (p *Plugin) AfterResponse(c *plugin.Context, err error) { }).Info("Response time usage statistics") // write influxdb go func(responseTime int64) { + if len(c.Msg.Question) < 1 { + return + } err := p.pushResponsePoint(c.Msg.Question[0].Qtype, c.Msg.Question[0].Name, responseTime, !c.HasError()) if err != nil { - + logrus.Error(err) } }(responseTime) } @@ -116,5 +119,8 @@ func (p *Plugin) writeResponse() { p.points = make([]*client.Point, 0) p.writeLock.Unlock() - influxdbClient.Write(bp) // ignore error + err = influxdbClient.Write(bp) // ignore error + if err != nil { + logrus.Error(err) + } }