Document the package, exported constants, and remaining helpers.
godoc now covers ActionAdd/ActionDelete, internal helpers, and UDP-then-TCP UPDATE behaviour. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -124,6 +124,7 @@ func PTR(owner string, ttl uint32, target string) (Record, error) {
|
||||
return fromRR(&dns.PTR{Hdr: rrHeader(owner, dns.TypePTR, ttl), Ptr: name})
|
||||
}
|
||||
|
||||
// rrHeader builds an INET header. Owner ASCII is checked in fromRR.
|
||||
func rrHeader(owner string, typ uint16, ttl uint32) dns.RR_Header {
|
||||
name, err := fqdnASCII(owner)
|
||||
if err != nil {
|
||||
@@ -134,6 +135,7 @@ func rrHeader(owner string, typ uint16, ttl uint32) dns.RR_Header {
|
||||
return dns.RR_Header{Name: name, Rrtype: typ, Class: dns.ClassINET, Ttl: ttl}
|
||||
}
|
||||
|
||||
// fromRR maps a miekg/dns RR onto the public Record type.
|
||||
func fromRR(rr dns.RR) (Record, error) {
|
||||
hdr := rr.Header()
|
||||
if err := asciiName("owner", strings.TrimSuffix(hdr.Name, ".")); err != nil {
|
||||
@@ -151,6 +153,7 @@ func fromRR(rr dns.RR) (Record, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
// recordToRR encodes a Record as a miekg/dns RR for UPDATE.
|
||||
func recordToRR(rec Record) (dns.RR, error) {
|
||||
if err := asciiName("owner", rec.Owner); err != nil {
|
||||
return nil, err
|
||||
@@ -162,6 +165,7 @@ func recordToRR(rec Record) (dns.RR, error) {
|
||||
return rr, nil
|
||||
}
|
||||
|
||||
// fqdnASCII validates ASCII and returns a trailing-dot FQDN.
|
||||
func fqdnASCII(name string) (string, error) {
|
||||
if err := asciiName("name", name); err != nil {
|
||||
return "", err
|
||||
@@ -169,6 +173,7 @@ func fqdnASCII(name string) (string, error) {
|
||||
return dns.Fqdn(strings.TrimSpace(name)), nil
|
||||
}
|
||||
|
||||
// isASCII reports whether s contains only bytes <= 127.
|
||||
func isASCII(s string) bool {
|
||||
for i := 0; i < len(s); i++ {
|
||||
if s[i] > 127 {
|
||||
|
||||
Reference in New Issue
Block a user