Support for multiple records with the same name

This commit is contained in:
Magnus Åhall 2026-02-23 12:58:55 +01:00
parent ab08d745a1
commit 42c5d43610

12
dns.go
View file

@ -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,6 +192,7 @@ func (dp *DomainPart) ToHTMLElements(parts []string) []HTMLElement {
}
if len(subpart.Subparts) == 0 {
for _, rec := range subpart.Record {
html := fmt.Sprintf(
`
<div class="record" style="padding-left: %dpx" data-top="%s"><span>%s</span><span>%s</span></div>
@ -202,11 +203,12 @@ func (dp *DomainPart) ToHTMLElements(parts []string) []HTMLElement {
restPart, // data-top
mostSpecificPart,
restPart,
subpart.Record.Type,
subpart.Record.String(),
rec.Type,
rec.String(),
)
lines = append(lines, HTMLElement{Header: false, HTML: html})
}
}
}