merge conflict fixed

This commit is contained in:
Miek Gieben
2016-11-24 21:51:38 +01:00
13 changed files with 158 additions and 13 deletions

View File

@@ -13,6 +13,8 @@ zonefile. New zones or changed zone are automatically picked up from disk.
~~~
auto [ZONES...] {
directory DIR [REGEXP ORIGIN_TEMPLATE [TIMEOUT]]
no_reload
upstream ADDRESS...
}
~~~
@@ -26,6 +28,10 @@ are used.
name `db.example.com`, the extracted origin will be `example.com`. **TIMEOUT** specifies how often
CoreDNS should scan the directory, the default is every 60 seconds. This value is in seconds.
The minimum value is 1 second.
* `no_reload` by default CoreDNS will reload a zone from disk whenever it detects a change to the
file. This option disables that behavior.
* `upstream` defines upstream resolvers to be used resolve external names found (think CNAMEs)
pointing to external names.
All directives from the *file* middleware are supported. Note that *auto* will load all zones found,
even though the directive might only receive queries for a specific zone. I.e:

View File

@@ -9,6 +9,7 @@ import (
"github.com/miekg/coredns/middleware"
"github.com/miekg/coredns/middleware/file"
"github.com/miekg/coredns/middleware/metrics"
"github.com/miekg/coredns/middleware/proxy"
"github.com/miekg/coredns/request"
"github.com/miekg/dns"
@@ -33,6 +34,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
duration time.Duration
}
@@ -73,7 +75,7 @@ func (a Auto) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i
return xfr.ServeDNS(ctx, w, r)
}
answer, ns, extra, result := z.Lookup(qname, state.QType(), state.Do())
answer, ns, extra, result := z.Lookup(state, qname)
m := new(dns.Msg)
m.SetReply(r)

View File

@@ -2,6 +2,7 @@ package auto
import (
"log"
"net"
"os"
"path"
"regexp"
@@ -12,6 +13,7 @@ import (
"github.com/miekg/coredns/middleware"
"github.com/miekg/coredns/middleware/file"
"github.com/miekg/coredns/middleware/metrics"
"github.com/miekg/coredns/middleware/proxy"
"github.com/mholt/caddy"
)
@@ -142,6 +144,19 @@ func autoParse(c *caddy.Controller) (Auto, error) {
case "no_reload":
a.loader.noReload = true
case "upstream":
args := c.RemainingArgs()
if len(args) == 0 {
return a, c.ArgErr()
}
for i := 0; i < len(args); i++ {
h, p, e := net.SplitHostPort(args[i])
if e != nil && p == "" {
args[i] = h + ":53"
}
}
a.loader.proxy = proxy.New(args)
default:
t, _, e := file.TransferParse(c, false)
if e != nil {

View File

@@ -39,6 +39,7 @@ func TestAutoParse(t *testing.T) {
directory /tmp (.*) bliep
transfer to 127.0.0.1
transfer to 127.0.0.2
upstream 8.8.8.8
}`,
false, "/tmp", "bliep", `(.*)`, []string{"127.0.0.1:53", "127.0.0.2:53"},
},

View File

@@ -52,6 +52,7 @@ func (a Auto) Walk() error {
}
zo.NoReload = a.loader.noReload
zo.Proxy = a.loader.proxy
zo.TransferTo = a.loader.transferTo
a.Zones.Add(zo, origin)