1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

Fix REV and PTR (#979)

* Fix REV and PTR
This commit is contained in:
Tom Limoncelli
2020-12-03 08:33:37 -05:00
committed by GitHub
parent 2e7311078c
commit 6443a31ca8
9 changed files with 318 additions and 133 deletions

View File

@@ -8,6 +8,17 @@ import (
// ReverseDomainName turns a CIDR block into a reversed (in-addr) name.
func ReverseDomainName(cidr string) (string, error) {
// If it is an IP address, add the /32 or /128
ip := net.ParseIP(cidr)
if ip != nil {
if ip.To4() != nil {
cidr = cidr + "/32"
} else {
cidr = cidr + "/128"
}
}
a, c, err := net.ParseCIDR(cidr)
if err != nil {
return "", err