mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Enable PTR records for BIND driver (#146)
* WIP * Enable PTR records in dnsconfig.js, in BIND provider. * Rename REVERSE() to REV(). * More accurate PTR target checking * Document REV() * Fix broken test
This commit is contained in:
committed by
Craig Peterson
parent
bce99a1c25
commit
aa92817116
@@ -81,6 +81,8 @@ func rrToRecord(rr dns.RR, origin string, replaceSerial uint32) (models.RecordCo
|
||||
rc.Priority = v.Preference
|
||||
case *dns.NS:
|
||||
rc.Target = v.Ns
|
||||
case *dns.PTR:
|
||||
rc.Target = v.Ptr
|
||||
case *dns.SOA:
|
||||
old_serial = v.Serial
|
||||
if old_serial == 0 {
|
||||
|
@@ -8,6 +8,7 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
@@ -180,6 +181,11 @@ func formatLine(lengths []int, fields []string) string {
|
||||
return strings.TrimRight(result, " ")
|
||||
}
|
||||
|
||||
func isNumeric(s string) bool {
|
||||
_, err := strconv.ParseFloat(s, 64)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
func zoneLabelLess(a, b string) bool {
|
||||
// Compare two zone labels for the purpose of sorting the RRs in a Zone.
|
||||
|
||||
@@ -221,8 +227,30 @@ func zoneLabelLess(a, b string) bool {
|
||||
|
||||
// Skip the matching highest elements, then compare the next item.
|
||||
for i, j := ia, ib; min >= 0; i, j, min = i-1, j-1, min-1 {
|
||||
// Compare as[i] < bs[j]
|
||||
// Sort @ at the top, then *, then everything else.
|
||||
// i.e. @ always is less. * is is less than everything but @.
|
||||
// If both are numeric, compare as integers, otherwise as strings.
|
||||
|
||||
if as[i] != bs[j] {
|
||||
return as[i] < bs[j]
|
||||
|
||||
// If the first element is *, it is always less.
|
||||
if i == 0 && as[i] == "*" {
|
||||
return true
|
||||
}
|
||||
if j == 0 && bs[j] == "*" {
|
||||
return false
|
||||
}
|
||||
|
||||
// If the elements are both numeric, compare as integers:
|
||||
au, aerr := strconv.ParseUint(as[i], 10, 64)
|
||||
bu, berr := strconv.ParseUint(bs[j], 10, 64)
|
||||
if aerr == nil && berr == nil {
|
||||
return au < bu
|
||||
} else {
|
||||
// otherwise, compare as strings:
|
||||
return as[i] < bs[j]
|
||||
}
|
||||
}
|
||||
}
|
||||
// The min top elements were equal, so the shorter name is less.
|
||||
|
@@ -266,6 +266,10 @@ func TestZoneLabelLess(t *testing.T) {
|
||||
mup
|
||||
a.mup
|
||||
bzt.mup
|
||||
*.bzt.mup
|
||||
1.bzt.mup
|
||||
2.bzt.mup
|
||||
10.bzt.mup
|
||||
aaa.bzt.mup
|
||||
zzz.bzt.mup
|
||||
nnn.mup
|
||||
@@ -293,6 +297,10 @@ func TestZoneLabelLess(t *testing.T) {
|
||||
{"a.mup", "aa.mup", true},
|
||||
{"zt.mup", "aaa.bzt.mup", false},
|
||||
{"aaa.bzt.mup", "mup", false},
|
||||
{"*.bzt.mup", "aaa.bzt.mup", true},
|
||||
{"1.bzt.mup", "aaa.bzt.mup", true},
|
||||
{"1.bzt.mup", "2.bzt.mup", true},
|
||||
{"10.bzt.mup", "2.bzt.mup", false},
|
||||
{"nnn.mup", "aaa.bzt.mup", false},
|
||||
{`www\.miek.nl`, `www.miek.nl`, false},
|
||||
}
|
||||
|
Reference in New Issue
Block a user