aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugin/auto/README.md5
-rw-r--r--plugin/auto/auto.go6
-rw-r--r--plugin/auto/setup.go7
-rw-r--r--plugin/auto/walk.go2
-rw-r--r--plugin/file/README.md3
-rw-r--r--plugin/file/cname_test.go4
-rw-r--r--plugin/file/file.go2
-rw-r--r--plugin/file/lookup.go2
-rw-r--r--plugin/file/setup.go14
-rw-r--r--plugin/file/zone.go4
-rw-r--r--plugin/secondary/README.md3
-rw-r--r--plugin/secondary/setup.go14
12 files changed, 30 insertions, 36 deletions
diff --git a/plugin/auto/README.md b/plugin/auto/README.md
index 1b6f82a20..9bb6f553e 100644
--- a/plugin/auto/README.md
+++ b/plugin/auto/README.md
@@ -17,7 +17,7 @@ zonefile. New or changed zones are automatically picked up from disk.
auto [ZONES...] {
directory DIR [REGEXP ORIGIN_TEMPLATE [TIMEOUT]]
no_reload
- upstream ADDRESS...
+ upstream [ADDRESS...]
}
~~~
@@ -35,7 +35,8 @@ are used.
SOA's serial has changed. This option disables that behavior.
* `upstream` defines upstream resolvers to be used resolve external names found (think CNAMEs)
pointing to external names. **ADDRESS** can be an IP address, an IP:port or a string pointing to
- a file that is structured as /etc/resolv.conf.
+ a file that is structured as /etc/resolv.conf. If no **ADDRESS** is given, CoreDNS will resolve CNAMEs
+ against itself.
All directives from the *file* plugin are supported. Note that *auto* will load all zones found,
even though the directive might only receive queries for a specific zone. I.e:
diff --git a/plugin/auto/auto.go b/plugin/auto/auto.go
index e9cab1950..ae1ce98d3 100644
--- a/plugin/auto/auto.go
+++ b/plugin/auto/auto.go
@@ -8,7 +8,7 @@ import (
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/file"
"github.com/coredns/coredns/plugin/metrics"
- "github.com/coredns/coredns/plugin/proxy"
+ "github.com/coredns/coredns/plugin/pkg/upstream"
"github.com/coredns/coredns/request"
"github.com/miekg/dns"
@@ -33,7 +33,7 @@ type (
// In the future this should be something like ZoneMeta that contains all this stuff.
transferTo []string
noReload bool
- proxy proxy.Proxy // Proxy for looking up names during the resolution process
+ upstream upstream.Upstream // Upstream for looking up names during the resolution process
duration time.Duration
}
@@ -41,7 +41,7 @@ type (
// ServeDNS implements the plugin.Handle interface.
func (a Auto) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
- state := request.Request{W: w, Req: r}
+ state := request.Request{W: w, Req: r, Context: ctx}
qname := state.Name()
// TODO(miek): match the qname better in the map
diff --git a/plugin/auto/setup.go b/plugin/auto/setup.go
index 7f673f915..c4ccf1900 100644
--- a/plugin/auto/setup.go
+++ b/plugin/auto/setup.go
@@ -11,9 +11,8 @@ import (
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/metrics"
- "github.com/coredns/coredns/plugin/pkg/dnsutil"
"github.com/coredns/coredns/plugin/pkg/parse"
- "github.com/coredns/coredns/plugin/proxy"
+ "github.com/coredns/coredns/plugin/pkg/upstream"
"github.com/mholt/caddy"
)
@@ -151,11 +150,11 @@ func autoParse(c *caddy.Controller) (Auto, error) {
if len(args) == 0 {
return a, c.ArgErr()
}
- ups, err := dnsutil.ParseHostPortOrFile(args...)
+ var err error
+ a.loader.upstream, err = upstream.NewUpstream(args)
if err != nil {
return a, err
}
- a.loader.proxy = proxy.NewLookup(ups)
default:
t, _, e := parse.Transfer(c, false)
diff --git a/plugin/auto/walk.go b/plugin/auto/walk.go
index a98f2318e..fa07e6aeb 100644
--- a/plugin/auto/walk.go
+++ b/plugin/auto/walk.go
@@ -53,7 +53,7 @@ func (a Auto) Walk() error {
}
zo.NoReload = a.loader.noReload
- zo.Proxy = a.loader.proxy
+ zo.Upstream = a.loader.upstream
zo.TransferTo = a.loader.transferTo
a.Zones.Add(zo, origin)
diff --git a/plugin/file/README.md b/plugin/file/README.md
index e3b1bb99d..1643251c2 100644
--- a/plugin/file/README.md
+++ b/plugin/file/README.md
@@ -28,7 +28,7 @@ If you want to round robin A and AAAA responses look at the *loadbalance* plugin
file DBFILE [ZONES... ] {
transfer to ADDRESS...
no_reload
- upstream ADDRESS...
+ upstream [ADDRESS...]
}
~~~
@@ -42,6 +42,7 @@ file DBFILE [ZONES... ] {
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, and 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.
## Examples
diff --git a/plugin/file/cname_test.go b/plugin/file/cname_test.go
index f3b3a7731..1dcc491ae 100644
--- a/plugin/file/cname_test.go
+++ b/plugin/file/cname_test.go
@@ -5,7 +5,7 @@ import (
"testing"
"github.com/coredns/coredns/plugin/pkg/dnstest"
- "github.com/coredns/coredns/plugin/proxy"
+ "github.com/coredns/coredns/plugin/pkg/upstream"
"github.com/coredns/coredns/plugin/test"
"github.com/miekg/dns"
@@ -74,7 +74,7 @@ func TestLookupCNAMEExternal(t *testing.T) {
if err != nil {
t.Fatalf("Expected no error when reading zone, got %q", err)
}
- zone.Proxy = proxy.NewLookup([]string{"8.8.8.8:53"}) // TODO(miek): point to local instance
+ zone.Upstream, _ = upstream.NewUpstream([]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()
diff --git a/plugin/file/file.go b/plugin/file/file.go
index 6fb2e42fb..ec7857ca5 100644
--- a/plugin/file/file.go
+++ b/plugin/file/file.go
@@ -29,7 +29,7 @@ type (
// ServeDNS implements the plugin.Handle interface.
func (f File) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
- state := request.Request{W: w, Req: r}
+ state := request.Request{W: w, Req: r, Context: ctx}
qname := state.Name()
// TODO(miek): match the qname better in the map
diff --git a/plugin/file/lookup.go b/plugin/file/lookup.go
index 28594f300..943b1d52f 100644
--- a/plugin/file/lookup.go
+++ b/plugin/file/lookup.go
@@ -378,7 +378,7 @@ 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.Proxy.Lookup(state, target, qtype)
+ m, e := z.Upstream.Lookup(state, target, qtype)
if e != nil {
// TODO(miek): debugMsg for this as well? Log?
return nil
diff --git a/plugin/file/setup.go b/plugin/file/setup.go
index 3c25b4f7d..5f55eebe3 100644
--- a/plugin/file/setup.go
+++ b/plugin/file/setup.go
@@ -6,9 +6,8 @@ import (
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/plugin"
- "github.com/coredns/coredns/plugin/pkg/dnsutil"
"github.com/coredns/coredns/plugin/pkg/parse"
- "github.com/coredns/coredns/plugin/proxy"
+ "github.com/coredns/coredns/plugin/pkg/upstream"
"github.com/mholt/caddy"
)
@@ -90,7 +89,7 @@ func fileParse(c *caddy.Controller) (Zones, error) {
}
noReload := false
- prxy := proxy.Proxy{}
+ upstr := upstream.Upstream{}
t := []string{}
var e error
@@ -107,14 +106,11 @@ func fileParse(c *caddy.Controller) (Zones, error) {
case "upstream":
args := c.RemainingArgs()
- if len(args) == 0 {
- return Zones{}, c.ArgErr()
- }
- ups, err := dnsutil.ParseHostPortOrFile(args...)
+ upstr, err = upstream.NewUpstream(args)
if err != nil {
return Zones{}, err
}
- prxy = proxy.NewLookup(ups)
+
default:
return Zones{}, c.Errf("unknown property '%s'", c.Val())
}
@@ -124,7 +120,7 @@ func fileParse(c *caddy.Controller) (Zones, error) {
z[origin].TransferTo = append(z[origin].TransferTo, t...)
}
z[origin].NoReload = noReload
- z[origin].Proxy = prxy
+ z[origin].Upstream = upstr
}
}
}
diff --git a/plugin/file/zone.go b/plugin/file/zone.go
index 540c65f0b..3447a942c 100644
--- a/plugin/file/zone.go
+++ b/plugin/file/zone.go
@@ -8,7 +8,7 @@ import (
"sync"
"github.com/coredns/coredns/plugin/file/tree"
- "github.com/coredns/coredns/plugin/proxy"
+ "github.com/coredns/coredns/plugin/pkg/upstream"
"github.com/coredns/coredns/request"
"github.com/miekg/dns"
@@ -30,7 +30,7 @@ type Zone struct {
NoReload bool
reloadMu sync.RWMutex
ReloadShutdown chan bool
- Proxy proxy.Proxy // Proxy for looking up names during the resolution process
+ Upstream upstream.Upstream // Upstream for looking up names during the resolution process
}
// Apex contains the apex records of a zone: SOA, NS and their potential signatures.
diff --git a/plugin/secondary/README.md b/plugin/secondary/README.md
index b49e676e0..59ac23aea 100644
--- a/plugin/secondary/README.md
+++ b/plugin/secondary/README.md
@@ -23,7 +23,7 @@ A working syntax would be:
secondary [zones...] {
transfer from ADDRESS
transfer to ADDRESS
- upstream ADDRESS...
+ upstream [ADDRESS...]
}
~~~
@@ -34,6 +34,7 @@ secondary [zones...] {
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, and 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.
When a zone is due to be refreshed (Refresh timer fires) a random jitter of 5 seconds is
applied, before fetching. In the case of retry this will be 2 seconds. If there are any errors
diff --git a/plugin/secondary/setup.go b/plugin/secondary/setup.go
index 1e9a3f5fd..1ccc09648 100644
--- a/plugin/secondary/setup.go
+++ b/plugin/secondary/setup.go
@@ -4,10 +4,9 @@ import (
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/file"
- "github.com/coredns/coredns/plugin/pkg/dnsutil"
"github.com/coredns/coredns/plugin/pkg/parse"
- "github.com/coredns/coredns/plugin/proxy"
+ "github.com/coredns/coredns/plugin/pkg/upstream"
"github.com/mholt/caddy"
)
@@ -51,7 +50,7 @@ func secondaryParse(c *caddy.Controller) (file.Zones, error) {
z := make(map[string]*file.Zone)
names := []string{}
origins := []string{}
- prxy := proxy.Proxy{}
+ upstr := upstream.Upstream{}
for c.Next() {
if c.Val() == "secondary" {
@@ -81,14 +80,11 @@ func secondaryParse(c *caddy.Controller) (file.Zones, error) {
}
case "upstream":
args := c.RemainingArgs()
- if len(args) == 0 {
- return file.Zones{}, c.ArgErr()
- }
- ups, err := dnsutil.ParseHostPortOrFile(args...)
+ var err error
+ upstr, err = upstream.NewUpstream(args)
if err != nil {
return file.Zones{}, err
}
- prxy = proxy.NewLookup(ups)
default:
return file.Zones{}, c.Errf("unknown property '%s'", c.Val())
}
@@ -100,7 +96,7 @@ func secondaryParse(c *caddy.Controller) (file.Zones, error) {
if f != nil {
z[origin].TransferFrom = append(z[origin].TransferFrom, f...)
}
- z[origin].Proxy = prxy
+ z[origin].Upstream = upstr
}
}
}