diff options
author | 2018-10-31 21:03:46 +0000 | |
---|---|---|
committer | 2018-10-31 21:03:46 +0000 | |
commit | 1ef0a02b467ac234b9f99ed3060d31ff6a2ca546 (patch) | |
tree | 7b91f6ee6a975375628f623c74d92b815e7ea0bd | |
parent | e332c8d8cbef30f07b74e07dc5efd18c37b7da2a (diff) | |
download | coredns-1ef0a02b467ac234b9f99ed3060d31ff6a2ca546.tar.gz coredns-1ef0a02b467ac234b9f99ed3060d31ff6a2ca546.tar.zst coredns-1ef0a02b467ac234b9f99ed3060d31ff6a2ca546.zip |
Revert "log/forward plugins: Extend dns query logging (#2240)" (#2256)
This reverts commit 8045aa279b510793a7c083a50de66e1df8871564.
-rw-r--r-- | plugin/forward/README.md | 4 | ||||
-rw-r--r-- | plugin/forward/forward.go | 12 | ||||
-rw-r--r-- | plugin/log/README.md | 4 | ||||
-rw-r--r-- | plugin/log/log.go | 2 | ||||
-rw-r--r-- | plugin/pkg/replacer/replacer.go | 32 | ||||
-rw-r--r-- | plugin/pkg/replacer/replacer_test.go | 4 | ||||
-rw-r--r-- | plugin/rewrite/condition.go | 2 |
7 files changed, 5 insertions, 55 deletions
diff --git a/plugin/forward/README.md b/plugin/forward/README.md index 39c00bce8..c0a426aab 100644 --- a/plugin/forward/README.md +++ b/plugin/forward/README.md @@ -91,10 +91,6 @@ On each endpoint, the timeouts of the communication are set by default and autom * dialTimeout by default is 30 sec, and can decrease automatically down to 100ms * readTimeout by default is 2 sec, and can decrease automatically down to 200ms -## Metadata - -* forward/resolving_proxy : provide the IP address and port of the upstream resolver used to resolve the current DNS query. - ## Metrics If monitoring is enabled (via the *prometheus* directive) then the following metric are exported: diff --git a/plugin/forward/forward.go b/plugin/forward/forward.go index 02824d184..dfa1aaca1 100644 --- a/plugin/forward/forward.go +++ b/plugin/forward/forward.go @@ -12,7 +12,6 @@ import ( "github.com/coredns/coredns/plugin" "github.com/coredns/coredns/plugin/debug" - "github.com/coredns/coredns/plugin/metadata" clog "github.com/coredns/coredns/plugin/pkg/log" "github.com/coredns/coredns/request" @@ -60,15 +59,6 @@ func (f *Forward) Len() int { return len(f.proxies) } // Name implements plugin.Handler. func (f *Forward) Name() string { return "forward" } -//declareMetadata adds to the context a metadata parameter which will return the passed value. -func (f *Forward) declareMetadata(ctx context.Context, name string, value string) bool { - label := f.Name()+"/"+name - if metadata.IsLabel(label) { - return metadata.SetValueFunc(ctx, label, func() string { return value }) - } - return false -} - // ServeDNS implements plugin.Handler. func (f *Forward) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { @@ -158,12 +148,10 @@ func (f *Forward) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg formerr := state.ErrorMessage(dns.RcodeFormatError) w.WriteMsg(formerr) - f.declareMetadata(ctx, "resolving_proxy", proxy.addr) return 0, nil } w.WriteMsg(ret) - f.declareMetadata(ctx, "resolving_proxy", proxy.addr) return 0, nil } diff --git a/plugin/log/README.md b/plugin/log/README.md index 787ec49a2..65cca19c8 100644 --- a/plugin/log/README.md +++ b/plugin/log/README.md @@ -72,10 +72,6 @@ The following place holders are supported: * `{>do}`: is the EDNS0 DO (DNSSEC OK) bit set in the query * `{>id}`: query ID * `{>opcode}`: query OPCODE -* `{local}`: server's IP address, for IPv6 addresses these are enclosed in brackets: `[::1]` -* `{A}`: number of the A type answers in the response -* `{AAAA}`: number of the AAAA type answers in the response -* `{forward/resolving_proxy}`: if the query was forwarded to a resolver, the IP address and port of that replied resolver, else empty. The metadata plugin needs to be enabled to use this placeholder The default Common Log Format is: diff --git a/plugin/log/log.go b/plugin/log/log.go index 028188d51..f52a70344 100644 --- a/plugin/log/log.go +++ b/plugin/log/log.go @@ -57,7 +57,7 @@ func (l Logger) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) // If we don't set up a class in config, the default "all" will be added // and we shouldn't have an empty rule.Class. if rule.Class[response.All] || rule.Class[class] { - rep := replacer.New(ctx, r, rrw, CommonLogEmptyValue) + rep := replacer.New(r, rrw, CommonLogEmptyValue) rule.Log.Println(rep.Replace(rule.Format)) } diff --git a/plugin/pkg/replacer/replacer.go b/plugin/pkg/replacer/replacer.go index 1d65967e0..b9e1fcaa6 100644 --- a/plugin/pkg/replacer/replacer.go +++ b/plugin/pkg/replacer/replacer.go @@ -1,13 +1,11 @@ package replacer import ( - "context" "strconv" "strings" "time" "github.com/coredns/coredns/plugin/pkg/dnstest" - "github.com/coredns/coredns/plugin/metadata" "github.com/coredns/coredns/request" "github.com/miekg/dns" @@ -33,7 +31,7 @@ type replacer struct { // values into the replacer. rr may be nil if it is not // available. emptyValue should be the string that is used // in place of empty string (can still be empty string). -func New(ctx context.Context, r *dns.Msg, rr *dnstest.Recorder, emptyValue string) Replacer { +func New(r *dns.Msg, rr *dnstest.Recorder, emptyValue string) Replacer { req := request.Request{W: rr, Req: r} rep := replacer{ replacements: map[string]string{ @@ -47,8 +45,6 @@ func New(ctx context.Context, r *dns.Msg, rr *dnstest.Recorder, emptyValue strin "{size}": strconv.Itoa(req.Len()), "{remote}": addrToRFC3986(req.IP()), "{port}": req.Port(), - "{local}": addrToRFC3986(req.LocalIP()), - "{forward/resolving_proxy}": getMetadata(ctx, "forward/resolving_proxy"), }, emptyValue: emptyValue, } @@ -62,8 +58,6 @@ func New(ctx context.Context, r *dns.Msg, rr *dnstest.Recorder, emptyValue strin rep.replacements["{duration}"] = strconv.FormatFloat(time.Since(rr.Start).Seconds(), 'f', -1, 64) + "s" if rr.Msg != nil { rep.replacements[headerReplacer+"rflags}"] = flagsToString(rr.Msg.MsgHdr) - rep.replacements["{A}"] = answersCount(rr.Msg, dns.TypeA) - rep.replacements["{AAAA}"] = answersCount(rr.Msg, dns.TypeAAAA) } } @@ -169,30 +163,6 @@ func addrToRFC3986(addr string) string { return addr } -//getMetadata will return value from Metadata or empty string -func getMetadata(ctx context.Context, label string) string { - if ctx != nil { - valueFunc := metadata.ValueFunc(ctx, label) - if valueFunc != nil { - return valueFunc() - } - } - return "" -} - -//answersCount will calculate a number of answers which have the type passed -func answersCount(m *dns.Msg, rtype uint16) string { - count := 0 - if m != nil { - for i := 0; i < len(m.Answer); i++ { - if m.Answer[i].Header().Rrtype == rtype { - count++ - } - } - } - return strconv.Itoa(count) -} - const ( timeFormat = "02/Jan/2006:15:04:05 -0700" headerReplacer = "{>" diff --git a/plugin/pkg/replacer/replacer_test.go b/plugin/pkg/replacer/replacer_test.go index 53b41510f..2fcaafc92 100644 --- a/plugin/pkg/replacer/replacer_test.go +++ b/plugin/pkg/replacer/replacer_test.go @@ -17,7 +17,7 @@ func TestNewReplacer(t *testing.T) { r.SetQuestion("example.org.", dns.TypeHINFO) r.MsgHdr.AuthenticatedData = true - replaceValues := New(nil, r, w, "") + replaceValues := New(r, w, "") switch v := replaceValues.(type) { case replacer: @@ -47,7 +47,7 @@ func TestSet(t *testing.T) { r.SetQuestion("example.org.", dns.TypeHINFO) r.MsgHdr.AuthenticatedData = true - repl := New(nil, r, w, "") + repl := New(r, w, "") repl.Set("name", "coredns.io.") repl.Set("type", "A") diff --git a/plugin/rewrite/condition.go b/plugin/rewrite/condition.go index fc5bd2c66..f8d2a9f08 100644 --- a/plugin/rewrite/condition.go +++ b/plugin/rewrite/condition.go @@ -22,7 +22,7 @@ const ( NotMatch = "not_match" ) -func newReplacer(r *dns.Msg) replacer.Replacer { return replacer.New(nil, r, nil, "") } +func newReplacer(r *dns.Msg) replacer.Replacer { return replacer.New(r, nil, "") } // condition is a rewrite condition. type condition func(string, string) bool |