aboutsummaryrefslogtreecommitdiff
path: root/plugin/file
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/file')
-rw-r--r--plugin/file/README.md10
-rw-r--r--plugin/file/cname_test.go124
-rw-r--r--plugin/file/dname_test.go4
-rw-r--r--plugin/file/lookup.go1
-rw-r--r--plugin/file/setup.go9
-rw-r--r--plugin/file/setup_test.go4
-rw-r--r--plugin/file/zone.go2
7 files changed, 14 insertions, 140 deletions
diff --git a/plugin/file/README.md b/plugin/file/README.md
index 4a7cc3483..a1330ffbc 100644
--- a/plugin/file/README.md
+++ b/plugin/file/README.md
@@ -29,7 +29,7 @@ file DBFILE [ZONES... ] {
transfer to ADDRESS...
reload DURATION
no_reload
- upstream [ADDRESS...]
+ upstream
}
~~~
@@ -41,11 +41,9 @@ file DBFILE [ZONES... ] {
Value of `0` means to not scan for changes and reload. For example, `30s` checks the zonefile every 30 seconds
and reloads the zone when serial changes.
* `no_reload` deprecated. Sets reload to 0.
-* `upstream` defines upstream resolvers to be used resolve external names found (think CNAMEs)
- pointing to external names. This is only really useful when CoreDNS is configured as a proxy; for
- normal authoritative serving you don't need *or* want to use this. **ADDRESS** can be an IP
- address, an IP:port or a string pointing to a file that is structured as /etc/resolv.conf.
- If no **ADDRESS** is given, CoreDNS will resolve CNAMEs against itself.
+* `upstream` resolve external names found (think CNAMEs) pointing to external names. This is only
+ really useful when CoreDNS is configured as a proxy; for normal authoritative serving you don't
+ need *or* want to use this. CoreDNS will resolve CNAMEs against itself.
## Examples
diff --git a/plugin/file/cname_test.go b/plugin/file/cname_test.go
deleted file mode 100644
index 10eb7d934..000000000
--- a/plugin/file/cname_test.go
+++ /dev/null
@@ -1,124 +0,0 @@
-package file
-
-import (
- "context"
- "strings"
- "testing"
-
- "github.com/coredns/coredns/plugin/pkg/dnstest"
- "github.com/coredns/coredns/plugin/pkg/upstream"
- "github.com/coredns/coredns/plugin/test"
-
- "github.com/miekg/dns"
-)
-
-func TestLookupCNAMEChain(t *testing.T) {
- name := "example.org."
- zone, err := Parse(strings.NewReader(dbExampleCNAME), name, "stdin", 0)
- if err != nil {
- t.Fatalf("Expected no error when reading zone, got %q", err)
- }
-
- fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{name: zone}, Names: []string{name}}}
- ctx := context.TODO()
-
- for _, tc := range cnameTestCases {
- m := tc.Msg()
-
- rec := dnstest.NewRecorder(&test.ResponseWriter{})
- _, err := fm.ServeDNS(ctx, rec, m)
- if err != nil {
- t.Errorf("Expected no error, got %v\n", err)
- return
- }
-
- resp := rec.Msg
- test.SortAndCheck(t, resp, tc)
- }
-}
-
-var cnameTestCases = []test.Case{
- {
- Qname: "a.example.org.", Qtype: dns.TypeA,
- Answer: []dns.RR{
- test.A("a.example.org. 1800 IN A 127.0.0.1"),
- },
- },
- {
- Qname: "www3.example.org.", Qtype: dns.TypeCNAME,
- Answer: []dns.RR{
- test.CNAME("www3.example.org. 1800 IN CNAME www2.example.org."),
- },
- },
- {
- Qname: "dangling.example.org.", Qtype: dns.TypeA,
- Answer: []dns.RR{
- test.CNAME("dangling.example.org. 1800 IN CNAME foo.example.org."),
- },
- },
- {
- Qname: "www3.example.org.", Qtype: dns.TypeA,
- Answer: []dns.RR{
- test.A("a.example.org. 1800 IN A 127.0.0.1"),
- test.CNAME("www.example.org. 1800 IN CNAME a.example.org."),
- test.CNAME("www1.example.org. 1800 IN CNAME www.example.org."),
- test.CNAME("www2.example.org. 1800 IN CNAME www1.example.org."),
- test.CNAME("www3.example.org. 1800 IN CNAME www2.example.org."),
- },
- },
-}
-
-func TestLookupCNAMEExternal(t *testing.T) {
- name := "example.org."
- zone, err := Parse(strings.NewReader(dbExampleCNAME), name, "stdin", 0)
- if err != nil {
- t.Fatalf("Expected no error when reading zone, got %q", err)
- }
- zone.Upstream, _ = upstream.New([]string{"8.8.8.8:53"}) // TODO(miek): point to local instance
-
- fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{name: zone}, Names: []string{name}}}
- ctx := context.TODO()
-
- for _, tc := range exernalTestCases {
- m := tc.Msg()
-
- rec := dnstest.NewRecorder(&test.ResponseWriter{})
- _, err := fm.ServeDNS(ctx, rec, m)
- if err != nil {
- t.Errorf("Expected no error, got %v\n", err)
- return
- }
-
- resp := rec.Msg
- test.SortAndCheck(t, resp, tc)
- }
-}
-
-var exernalTestCases = []test.Case{
- {
- Qname: "external.example.org.", Qtype: dns.TypeA,
- Answer: []dns.RR{
- test.CNAME("external.example.org. 1800 CNAME www.example.net."),
- // magic 303 TTL that says: don't check TTL.
- test.A("www.example.net. 303 IN A 93.184.216.34"),
- },
- },
-}
-
-const dbExampleCNAME = `
-$TTL 30M
-$ORIGIN example.org.
-@ IN SOA linode.atoom.net. miek.miek.nl. (
- 1282630057 ; Serial
- 4H ; Refresh
- 1H ; Retry
- 7D ; Expire
- 4H ) ; Negative Cache TTL
-
-a IN A 127.0.0.1
-www3 IN CNAME www2
-www2 IN CNAME www1
-www1 IN CNAME www
-www IN CNAME a
-dangling IN CNAME foo
-external IN CNAME www.example.net.`
diff --git a/plugin/file/dname_test.go b/plugin/file/dname_test.go
index 85dc9d360..c372d14de 100644
--- a/plugin/file/dname_test.go
+++ b/plugin/file/dname_test.go
@@ -1,5 +1,8 @@
package file
+/*
+TODO(miek): move to test/ for full server testing
+
import (
"context"
"strings"
@@ -294,3 +297,4 @@ ns.example.org. 1800 IN A 127.0.0.1
RXpMdvaE6ZDwalWldLjC3h8QDywDoFdndoRY
eHOsmTvvtWWqtO6Fa5A8gmHT5HA= )
`
+*/
diff --git a/plugin/file/lookup.go b/plugin/file/lookup.go
index d15ff5b6a..d020b7788 100644
--- a/plugin/file/lookup.go
+++ b/plugin/file/lookup.go
@@ -374,7 +374,6 @@ func cnameForType(targets []dns.RR, origQtype uint16) []dns.RR {
func (z *Zone) externalLookup(state request.Request, target string, qtype uint16) []dns.RR {
m, e := z.Upstream.Lookup(state, target, qtype)
if e != nil {
- // TODO(miek): Log, or return error here?
return nil
}
if m == nil {
diff --git a/plugin/file/setup.go b/plugin/file/setup.go
index 5c371babc..e74bab7a5 100644
--- a/plugin/file/setup.go
+++ b/plugin/file/setup.go
@@ -93,7 +93,7 @@ func fileParse(c *caddy.Controller) (Zones, error) {
}
reload := 1 * time.Minute
- upstr := upstream.Upstream{}
+ upstr := upstream.New()
t := []string{}
var e error
@@ -116,11 +116,8 @@ func fileParse(c *caddy.Controller) (Zones, error) {
reload = 0
case "upstream":
- args := c.RemainingArgs()
- upstr, err = upstream.New(args)
- if err != nil {
- return Zones{}, err
- }
+ // ignore args, will be error later.
+ c.RemainingArgs() // clear buffer
default:
return Zones{}, c.Errf("unknown property '%s'", c.Val())
diff --git a/plugin/file/setup_test.go b/plugin/file/setup_test.go
index 39cadaaf2..1a3cba0e8 100644
--- a/plugin/file/setup_test.go
+++ b/plugin/file/setup_test.go
@@ -57,8 +57,8 @@ func TestFileParse(t *testing.T) {
`file ` + zoneFileName1 + ` example.net. {
upstream a
}`,
- true,
- Zones{Names: []string{}},
+ false, // OK for now as we disregard any options for the `upstream`.
+ Zones{Names: []string{"example.net."}},
},
{
`file ` + zoneFileName1 + ` example.net. {
diff --git a/plugin/file/zone.go b/plugin/file/zone.go
index e94a00f16..e323350f3 100644
--- a/plugin/file/zone.go
+++ b/plugin/file/zone.go
@@ -32,7 +32,7 @@ type Zone struct {
LastReloaded time.Time
reloadMu sync.RWMutex
reloadShutdown chan bool
- Upstream upstream.Upstream // Upstream for looking up names during the resolution process
+ Upstream *upstream.Upstream // Upstream for looking up external names during the resolution process
}
// Apex contains the apex records of a zone: SOA, NS and their potential signatures.