aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coremain/run.go3
-rw-r--r--plugin/acl/acl.go3
-rw-r--r--plugin/auto/walk.go2
-rw-r--r--plugin/cancel/cancel.go4
-rw-r--r--plugin/dnssec/dnssec_test.go14
-rw-r--r--plugin/dnstap/handler.go6
-rw-r--r--plugin/dnstap/setup.go3
-rw-r--r--plugin/etcd/setup.go3
-rw-r--r--plugin/forward/proxy.go5
-rw-r--r--plugin/rewrite/name.go2
-rw-r--r--plugin/rewrite/rewrite.go1
-rw-r--r--plugin/rewrite/setup.go3
-rw-r--r--plugin/rewrite/ttl.go2
-rw-r--r--plugin/template/template.go6
-rw-r--r--plugin/trace/trace_test.go2
-rw-r--r--test/doc.go2
-rw-r--r--test/external_test.go72
-rw-r--r--test/plugin_test.go43
-rw-r--r--test/server.go3
19 files changed, 14 insertions, 165 deletions
diff --git a/coremain/run.go b/coremain/run.go
index b62878c3a..5dcb3c013 100644
--- a/coremain/run.go
+++ b/coremain/run.go
@@ -173,8 +173,7 @@ func setVersion() {
// Only set the appVersion if -ldflags was used
if gitNearestTag != "" || gitTag != "" {
if devBuild && gitNearestTag != "" {
- appVersion = fmt.Sprintf("%s (+%s %s)",
- strings.TrimPrefix(gitNearestTag, "v"), GitCommit, buildDate)
+ appVersion = fmt.Sprintf("%s (+%s %s)", strings.TrimPrefix(gitNearestTag, "v"), GitCommit, buildDate)
} else if gitTag != "" {
appVersion = strings.TrimPrefix(gitTag, "v")
}
diff --git a/plugin/acl/acl.go b/plugin/acl/acl.go
index b25138a30..2eea0a27c 100644
--- a/plugin/acl/acl.go
+++ b/plugin/acl/acl.go
@@ -6,15 +6,12 @@ import (
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/metrics"
- clog "github.com/coredns/coredns/plugin/pkg/log"
"github.com/coredns/coredns/request"
"github.com/infobloxopen/go-trees/iptree"
"github.com/miekg/dns"
)
-var log = clog.NewWithPlugin("acl")
-
// ACL enforces access control policies on DNS queries.
type ACL struct {
Next plugin.Handler
diff --git a/plugin/auto/walk.go b/plugin/auto/walk.go
index d4002a46d..40c62e514 100644
--- a/plugin/auto/walk.go
+++ b/plugin/auto/walk.go
@@ -20,7 +20,7 @@ func (a Auto) Walk() error {
toDelete[n] = true
}
- filepath.Walk(a.loader.directory, func(path string, info os.FileInfo, err error) error {
+ filepath.Walk(a.loader.directory, func(path string, info os.FileInfo, _ error) error {
if info == nil || info.IsDir() {
return nil
}
diff --git a/plugin/cancel/cancel.go b/plugin/cancel/cancel.go
index 98f4f2367..9ded73e82 100644
--- a/plugin/cancel/cancel.go
+++ b/plugin/cancel/cancel.go
@@ -16,13 +16,13 @@ import (
func init() { plugin.Register("cancel", setup) }
func setup(c *caddy.Controller) error {
- ca := Cancel{timeout: 5001 * time.Millisecond}
+ ca := Cancel{}
for c.Next() {
args := c.RemainingArgs()
switch len(args) {
case 0:
- break
+ ca.timeout = 5001 * time.Millisecond
case 1:
dur, err := time.ParseDuration(args[0])
if err != nil {
diff --git a/plugin/dnssec/dnssec_test.go b/plugin/dnssec/dnssec_test.go
index e60b5ee7e..fb8a128de 100644
--- a/plugin/dnssec/dnssec_test.go
+++ b/plugin/dnssec/dnssec_test.go
@@ -153,20 +153,6 @@ func testMsgCname() *dns.Msg {
}
}
-func testDelegationMsg() *dns.Msg {
- return &dns.Msg{
- Ns: []dns.RR{
- test.NS("miek.nl. 3600 IN NS linode.atoom.net."),
- test.NS("miek.nl. 3600 IN NS ns-ext.nlnetlabs.nl."),
- test.NS("miek.nl. 3600 IN NS omval.tednet.nl."),
- },
- Extra: []dns.RR{
- test.A("omval.tednet.nl. 3600 IN A 185.49.141.42"),
- test.AAAA("omval.tednet.nl. 3600 IN AAAA 2a04:b900:0:100::42"),
- },
- }
-}
-
func testMsgDname() *dns.Msg {
return &dns.Msg{
Answer: []dns.RR{
diff --git a/plugin/dnstap/handler.go b/plugin/dnstap/handler.go
index 1178dad79..0dde3a346 100644
--- a/plugin/dnstap/handler.go
+++ b/plugin/dnstap/handler.go
@@ -30,13 +30,9 @@ type (
TapMessage(message *tap.Message)
Pack() bool
}
- tapContext struct {
- context.Context
- Dnstap
- }
)
-// ContextKey defines the type of key that is used to save data into the context
+// ContextKey defines the type of key that is used to save data into the context.
type ContextKey string
const (
diff --git a/plugin/dnstap/setup.go b/plugin/dnstap/setup.go
index 11269b291..ee481fe11 100644
--- a/plugin/dnstap/setup.go
+++ b/plugin/dnstap/setup.go
@@ -6,14 +6,11 @@ import (
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/dnstap/dnstapio"
- clog "github.com/coredns/coredns/plugin/pkg/log"
"github.com/coredns/coredns/plugin/pkg/parse"
"github.com/caddyserver/caddy"
)
-var log = clog.NewWithPlugin("dnstap")
-
func init() { plugin.Register("dnstap", wrapSetup) }
func wrapSetup(c *caddy.Controller) error {
diff --git a/plugin/etcd/setup.go b/plugin/etcd/setup.go
index c2916de51..a95549f32 100644
--- a/plugin/etcd/setup.go
+++ b/plugin/etcd/setup.go
@@ -5,7 +5,6 @@ import (
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/plugin"
- clog "github.com/coredns/coredns/plugin/pkg/log"
mwtls "github.com/coredns/coredns/plugin/pkg/tls"
"github.com/coredns/coredns/plugin/pkg/upstream"
@@ -13,8 +12,6 @@ import (
etcdcv3 "go.etcd.io/etcd/clientv3"
)
-var log = clog.NewWithPlugin("etcd")
-
func init() { plugin.Register("etcd", setup) }
func setup(c *caddy.Controller) error {
diff --git a/plugin/forward/proxy.go b/plugin/forward/proxy.go
index 78b2cf3b8..6485d8d72 100644
--- a/plugin/forward/proxy.go
+++ b/plugin/forward/proxy.go
@@ -12,11 +12,8 @@ import (
// Proxy defines an upstream host.
type Proxy struct {
fails uint32
+ addr string
- addr string
-
- // Connection caching
- expire time.Duration
transport *Transport
// health checking
diff --git a/plugin/rewrite/name.go b/plugin/rewrite/name.go
index 9302d563a..7a8f9ad7c 100644
--- a/plugin/rewrite/name.go
+++ b/plugin/rewrite/name.go
@@ -195,7 +195,7 @@ func newNameRule(nextAction string, args ...string) (Rule, error) {
},
}, nil
default:
- return nil, fmt.Errorf("A name rule supports only exact, prefix, suffix, substring, and regex name matching, received: %s", matchType)
+ return nil, fmt.Errorf("name rule supports only exact, prefix, suffix, substring, and regex name matching, received: %s", matchType)
}
}
if len(args) == 7 {
diff --git a/plugin/rewrite/rewrite.go b/plugin/rewrite/rewrite.go
index 2eabf6df2..13e1d2092 100644
--- a/plugin/rewrite/rewrite.go
+++ b/plugin/rewrite/rewrite.go
@@ -61,7 +61,6 @@ func (rw Rewrite) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
return plugin.NextOrFailure(rw.Name(), rw.Next, ctx, wr, r)
}
case RewriteIgnored:
- break
}
}
if rw.noRevert || len(wr.ResponseRules) == 0 {
diff --git a/plugin/rewrite/setup.go b/plugin/rewrite/setup.go
index 6b6bcce66..8c2890c62 100644
--- a/plugin/rewrite/setup.go
+++ b/plugin/rewrite/setup.go
@@ -3,13 +3,10 @@ package rewrite
import (
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/plugin"
- clog "github.com/coredns/coredns/plugin/pkg/log"
"github.com/caddyserver/caddy"
)
-var log = clog.NewWithPlugin("rewrite")
-
func init() { plugin.Register("rewrite", setup) }
func setup(c *caddy.Controller) error {
diff --git a/plugin/rewrite/ttl.go b/plugin/rewrite/ttl.go
index 73445dfc9..59ed9f52a 100644
--- a/plugin/rewrite/ttl.go
+++ b/plugin/rewrite/ttl.go
@@ -159,7 +159,7 @@ func newTTLRule(nextAction string, args ...string) (Rule, error) {
},
}, nil
default:
- return nil, fmt.Errorf("A ttl rule supports only exact, prefix, suffix, substring, and regex name matching")
+ return nil, fmt.Errorf("ttl rule supports only exact, prefix, suffix, substring, and regex name matching")
}
}
if len(args) > 3 {
diff --git a/plugin/template/template.go b/plugin/template/template.go
index eaa291f7f..f2a7b186f 100644
--- a/plugin/template/template.go
+++ b/plugin/template/template.go
@@ -73,7 +73,7 @@ func (h Handler) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
}
for _, template := range h.Templates {
- data, match, fthrough := template.match(ctx, state, zone)
+ data, match, fthrough := template.match(ctx, state)
if !match {
if !fthrough {
return dns.RcodeNameError, nil
@@ -143,11 +143,11 @@ func executeRRTemplate(server, section string, template *gotmpl.Template, data *
return rr, nil
}
-func (t template) match(ctx context.Context, state request.Request, zone string) (*templateData, bool, bool) {
+func (t template) match(ctx context.Context, state request.Request) (*templateData, bool, bool) {
q := state.Req.Question[0]
data := &templateData{md: metadata.ValueFuncs(ctx)}
- zone = plugin.Zones(t.zones).Matches(state.Name())
+ zone := plugin.Zones(t.zones).Matches(state.Name())
if zone == "" {
return data, false, true
}
diff --git a/plugin/trace/trace_test.go b/plugin/trace/trace_test.go
index 48a4d7e78..7ea49a255 100644
--- a/plugin/trace/trace_test.go
+++ b/plugin/trace/trace_test.go
@@ -14,8 +14,6 @@ import (
"github.com/opentracing/opentracing-go/mocktracer"
)
-const server = "coolServer"
-
func TestStartup(t *testing.T) {
m, err := traceParse(caddy.NewTestController("dns", `trace`))
if err != nil {
diff --git a/test/doc.go b/test/doc.go
index ba09e8772..528092a85 100644
--- a/test/doc.go
+++ b/test/doc.go
@@ -1,2 +1,2 @@
-// Package test contains function and types useful for writing tests
+// Package test contains function and types useful for writing tests.
package test
diff --git a/test/external_test.go b/test/external_test.go
deleted file mode 100644
index 8e6adab91..000000000
--- a/test/external_test.go
+++ /dev/null
@@ -1,72 +0,0 @@
-package test
-
-import (
- "fmt"
- "os"
- "os/exec"
- "strings"
- "testing"
-)
-
-// Go get external example plugin, compile it into CoreDNS
-// and check if it is really there, but running coredns -plugins.
-
-// Dangerous test as it messes with your git tree, maybe use tag?
-func testExternalPluginCompile(t *testing.T) {
- if err := addExamplePlugin(); err != nil {
- t.Fatal(err)
- }
- defer run(t, gitReset)
-
- if _, err := run(t, goGet); err != nil {
- t.Fatal(err)
- }
-
- if _, err := run(t, goGen); err != nil {
- t.Fatal(err)
- }
-
- if _, err := run(t, goBuild); err != nil {
- t.Fatal(err)
- }
-
- out, err := run(t, coredns)
- if err != nil {
- t.Fatal(err)
- }
-
- if !strings.Contains(string(out), "dns.example") {
- t.Fatal("Plugin dns.example should be there")
- }
-}
-
-func run(t *testing.T, c *exec.Cmd) ([]byte, error) {
- c.Dir = ".."
- out, err := c.Output()
- if err != nil {
- return nil, fmt.Errorf("run: failed to run %s %s: %q", c.Args[0], c.Args[1], err)
- }
- return out, nil
-
-}
-
-func addExamplePlugin() error {
- f, err := os.OpenFile("../plugin.cfg", os.O_APPEND|os.O_WRONLY, os.ModeAppend)
- if err != nil {
- return err
- }
- defer f.Close()
-
- _, err = f.WriteString(example)
- return err
-}
-
-var (
- goBuild = exec.Command("go", "build")
- goGen = exec.Command("go", "generate")
- goGet = exec.Command("go", "get", "github.com/coredns/example")
- gitReset = exec.Command("git", "checkout", "core/*")
- coredns = exec.Command("./coredns", "-plugins")
-)
-
-const example = "1001:example:github.com/coredns/example"
diff --git a/test/plugin_test.go b/test/plugin_test.go
deleted file mode 100644
index 4003a958f..000000000
--- a/test/plugin_test.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package test
-
-import (
- "testing"
-
- "github.com/coredns/coredns/plugin/test"
-
- "github.com/miekg/dns"
-
- // Load all managed plugins in github.com/coredns/coredns
- _ "github.com/coredns/coredns/core/plugin"
-)
-
-func benchmarkLookupBalanceRewriteCache(b *testing.B) {
- t := new(testing.T)
- name, rm, err := test.TempFile(".", exampleOrg)
- if err != nil {
- t.Fatalf("Failed to create zone: %s", err)
- }
- defer rm()
-
- corefile := `example.org:0 {
- file ` + name + `
- rewrite type ANY HINFO
- loadbalance
-}
-`
-
- ex, udp, _, err := CoreDNSServerAndPorts(corefile)
- if err != nil {
- t.Fatalf("Could not get CoreDNS serving instance: %s", err)
- }
- defer ex.Stop()
-
- c := new(dns.Client)
- m := new(dns.Msg)
- m.SetQuestion("example.org.", dns.TypeA)
-
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- c.Exchange(m, udp)
- }
-}
diff --git a/test/server.go b/test/server.go
index 93016501d..9908285d1 100644
--- a/test/server.go
+++ b/test/server.go
@@ -4,9 +4,10 @@ import (
"sync"
"github.com/coredns/coredns/core/dnsserver"
-
// Hook in CoreDNS.
_ "github.com/coredns/coredns/core"
+ // Load all managed plugins in github.com/coredns/coredns
+ _ "github.com/coredns/coredns/core/plugin"
"github.com/caddyserver/caddy"
)