mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Add SRV Record Type (#136)
* Add support for SRV records for NAMEDOTCOM and ROUTE53. * Improve docs * Rename RR() to ToRR(). * Rename RecordConfig Priority to MxPreference (affects json IR data)
This commit is contained in:
@@ -39,18 +39,36 @@ func (z *zoneGenData) Less(i, j int) bool {
|
||||
if rrtypeA != rrtypeB {
|
||||
return zoneRrtypeLess(rrtypeA, rrtypeB)
|
||||
}
|
||||
if rrtypeA == dns.TypeA {
|
||||
switch rrtypeA {
|
||||
case dns.TypeNS, dns.TypeTXT:
|
||||
// pass through.
|
||||
case dns.TypeA:
|
||||
ta2, tb2 := a.(*dns.A), b.(*dns.A)
|
||||
ipa, ipb := ta2.A.To4(), tb2.A.To4()
|
||||
if ipa == nil || ipb == nil {
|
||||
log.Fatalf("should not happen: IPs are not 4 bytes: %#v %#v", ta2, tb2)
|
||||
}
|
||||
return bytes.Compare(ipa, ipb) == -1
|
||||
}
|
||||
if rrtypeA == dns.TypeMX {
|
||||
case dns.TypeMX:
|
||||
ta2, tb2 := a.(*dns.MX), b.(*dns.MX)
|
||||
pa, pb := ta2.Preference, tb2.Preference
|
||||
return pa < pb
|
||||
case dns.TypeSRV:
|
||||
ta2, tb2 := a.(*dns.SRV), b.(*dns.SRV)
|
||||
pa, pb := ta2.Port, tb2.Port
|
||||
if pa != pb {
|
||||
return pa < pb
|
||||
}
|
||||
pa, pb = ta2.Priority, tb2.Priority
|
||||
if pa != pb {
|
||||
return pa < pb
|
||||
}
|
||||
pa, pb = ta2.Weight, tb2.Weight
|
||||
if pa != pb {
|
||||
return pa < pb
|
||||
}
|
||||
default:
|
||||
panic(fmt.Sprintf("zoneGenData Less: unimplemented rtype %v", dns.TypeToString[rrtypeA]))
|
||||
}
|
||||
return a.String() < b.String()
|
||||
}
|
||||
@@ -92,6 +110,7 @@ func WriteZoneFile(w io.Writer, records []dns.RR, origin string) error {
|
||||
// be easy to read and pleasant to the eye.
|
||||
// * Within a label, SOA and NS records are listed first.
|
||||
// * MX records are sorted numericly by preference value.
|
||||
// * SRV records are sorted numericly by port, then priority, then weight.
|
||||
// * A records are sorted by IP address, not lexicographically.
|
||||
// * Repeated labels are removed.
|
||||
// * $TTL is used to eliminate clutter. The most common TTL value is used.
|
||||
@@ -148,7 +167,7 @@ func (z *zoneGenData) generateZoneFileHelper(w io.Writer) error {
|
||||
|
||||
// items[2]: class
|
||||
if hdr.Class != dns.ClassINET {
|
||||
log.Fatalf("Unimplemented class=%v", items[2])
|
||||
log.Fatalf("generateZoneFileHelper: Unimplemented class=%v", items[2])
|
||||
}
|
||||
|
||||
// items[3]: type
|
||||
|
Reference in New Issue
Block a user