plugin/file: allow README.md testing (#3052)
* Fix corefile usage * plugin/file: allow README.md testing Allow readme testing for the file plugin and fix bugs that where found: * the reader wasn't reset when re-reading the same io.reader for a different origin. Signed-off-by: Miek Gieben <miek@miek.nl> * Update test/example_test.go Co-Authored-By: Michael Grosser <development@stp-ip.net>
This commit is contained in:
parent
cfc4948f92
commit
7a3371d740
4 changed files with 18 additions and 16 deletions
|
@ -44,7 +44,7 @@ file DBFILE [ZONES... ] {
|
||||||
Load the `example.org` zone from `example.org.signed` and allow transfers to the internet, but send
|
Load the `example.org` zone from `example.org.signed` and allow transfers to the internet, but send
|
||||||
notifies to 10.240.1.1
|
notifies to 10.240.1.1
|
||||||
|
|
||||||
~~~ txt
|
~~~ corefile
|
||||||
example.org {
|
example.org {
|
||||||
file example.org.signed {
|
file example.org.signed {
|
||||||
transfer to *
|
transfer to *
|
||||||
|
@ -55,7 +55,7 @@ example.org {
|
||||||
|
|
||||||
Or use a single zone file for multiple zones:
|
Or use a single zone file for multiple zones:
|
||||||
|
|
||||||
~~~ txt
|
~~~ corefile
|
||||||
. {
|
. {
|
||||||
file example.org.signed example.org example.net {
|
file example.org.signed example.org example.net {
|
||||||
transfer to *
|
transfer to *
|
||||||
|
@ -67,7 +67,7 @@ Or use a single zone file for multiple zones:
|
||||||
Note that if you have a configuration like the following you may run into a problem of the origin
|
Note that if you have a configuration like the following you may run into a problem of the origin
|
||||||
not being correctly recognized:
|
not being correctly recognized:
|
||||||
|
|
||||||
~~~ txt
|
~~~ corefile
|
||||||
. {
|
. {
|
||||||
file db.example.org
|
file db.example.org
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ which, in this case, is the root zone. Any contents of `db.example.org` will the
|
||||||
origin set; this may or may not do what you want.
|
origin set; this may or may not do what you want.
|
||||||
It's better to be explicit here and specify the correct origin. This can be done in two ways:
|
It's better to be explicit here and specify the correct origin. This can be done in two ways:
|
||||||
|
|
||||||
~~~ txt
|
~~~ corefile
|
||||||
. {
|
. {
|
||||||
file db.example.org example.org
|
file db.example.org example.org
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ It's better to be explicit here and specify the correct origin. This can be done
|
||||||
|
|
||||||
Or
|
Or
|
||||||
|
|
||||||
~~~ txt
|
~~~ corefile
|
||||||
example.org {
|
example.org {
|
||||||
file db.example.org
|
file db.example.org
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,7 +145,7 @@ func Parse(f io.Reader, origin, fileName string, serial int64) (*Zone, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !seenSOA {
|
if !seenSOA {
|
||||||
return nil, fmt.Errorf("file %q has no SOA record", fileName)
|
return nil, fmt.Errorf("file %q has no SOA record for origin %s", fileName, origin)
|
||||||
}
|
}
|
||||||
|
|
||||||
return z, nil
|
return z, nil
|
||||||
|
|
|
@ -87,6 +87,7 @@ func fileParse(c *caddy.Controller) (Zones, error) {
|
||||||
origins[i] = plugin.Host(origins[i]).Normalize()
|
origins[i] = plugin.Host(origins[i]).Normalize()
|
||||||
z[origins[i]] = NewZone(origins[i], fileName)
|
z[origins[i]] = NewZone(origins[i], fileName)
|
||||||
if openErr == nil {
|
if openErr == nil {
|
||||||
|
reader.Seek(0, 0)
|
||||||
zone, err := Parse(reader, origins[i], fileName, 0)
|
zone, err := Parse(reader, origins[i], fileName, 0)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
z[origins[i]] = zone
|
z[origins[i]] = zone
|
||||||
|
|
|
@ -2,14 +2,15 @@ package test
|
||||||
|
|
||||||
const exampleOrg = `; example.org test file
|
const exampleOrg = `; example.org test file
|
||||||
$TTL 3600
|
$TTL 3600
|
||||||
example.org. IN SOA sns.dns.icann.org. noc.dns.icann.org. 2015082541 7200 3600 1209600 3600
|
@ IN SOA sns.dns.icann.org. noc.dns.icann.org. 2015082541 7200 3600 1209600 3600
|
||||||
example.org. IN NS b.iana-servers.net.
|
@ IN NS b.iana-servers.net.
|
||||||
example.org. IN NS a.iana-servers.net.
|
@ IN NS a.iana-servers.net.
|
||||||
example.org. IN A 127.0.0.1
|
@ IN A 127.0.0.1
|
||||||
example.org. IN A 127.0.0.2
|
@ IN A 127.0.0.2
|
||||||
short.example.org. 1 IN A 127.0.0.3
|
short 1 IN A 127.0.0.3
|
||||||
*.w.example.org. IN TXT "Wildcard"
|
|
||||||
a.b.c.w.example.org. IN TXT "Not a wildcard"
|
*.w 3600 IN TXT "Wildcard"
|
||||||
cname.example.org. IN CNAME www.example.net.
|
a.b.c.w IN TXT "Not a wildcard"
|
||||||
service.example.org. IN SRV 8080 10 10 example.org.
|
cname IN CNAME www.example.net.
|
||||||
|
service IN SRV 8080 10 10 @
|
||||||
`
|
`
|
||||||
|
|
Loading…
Add table
Reference in a new issue