From 42c5d436105b9bcdc41cf3c3392ba893598831aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20=C3=85hall?= Date: Mon, 23 Feb 2026 12:58:55 +0100 Subject: [PATCH] Support for multiple records with the same name --- dns.go | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/dns.go b/dns.go index 9b86886..66bb0f7 100644 --- a/dns.go +++ b/dns.go @@ -21,12 +21,11 @@ type DNSRecord struct { } type DomainPart struct { - Record DNSRecord + Record []DNSRecord Subparts map[string]*DomainPart `json:",omitempty"` } type RecordsTree struct { - Record DNSRecord Children []RecordsTree } @@ -106,11 +105,12 @@ func BuildRecordsTree(records []DNSRecord) *DomainPart { for _, part := range currentDomainNameSplit { if nextDomainPart, found := curPart.Subparts[part]; !found { newPart := new(DomainPart) - newPart.Record = record + newPart.Record = []DNSRecord{record} newPart.Subparts = make(map[string]*DomainPart) curPart.Subparts[strings.ToLower(part)] = newPart curPart = newPart } else { + nextDomainPart.Record = append(nextDomainPart.Record, record) curPart = nextDomainPart } } @@ -192,20 +192,22 @@ func (dp *DomainPart) ToHTMLElements(parts []string) []HTMLElement { } if len(subpart.Subparts) == 0 { - html := fmt.Sprintf( - ` -
%s%s
-
%s
-
%s
- `, - (len(newParts)-1)*32, - restPart, // data-top - mostSpecificPart, - restPart, - subpart.Record.Type, - subpart.Record.String(), - ) - lines = append(lines, HTMLElement{Header: false, HTML: html}) + for _, rec := range subpart.Record { + html := fmt.Sprintf( + ` +
%s%s
+
%s
+
%s
+ `, + (len(newParts)-1)*32, + restPart, // data-top + mostSpecificPart, + restPart, + rec.Type, + rec.String(), + ) + lines = append(lines, HTMLElement{Header: false, HTML: html}) + } } }