Skip to content

Commit dfc2651

Browse files
authored
fix: exclude duplicate values in NS records (#470)
Fixes #469 Signed-off-by: Aurora Gaffney <aurora@blinklabs.io>
1 parent a4f8765 commit dfc2651

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

internal/dns/dns.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"math/big"
1515
"net"
1616
"os"
17+
"slices"
1718
"strconv"
1819
"strings"
1920

@@ -444,9 +445,16 @@ func findNameserversForDomain(
444445
return "", nil, err
445446
}
446447
for _, aRecord := range aRecords {
448+
tmpIp := net.ParseIP(aRecord.Rhs)
449+
// Skip duplicate IPs
450+
if slices.ContainsFunc(ret[nsRecord.Rhs], func(x net.IP) bool {
451+
return x.Equal(tmpIp)
452+
}) {
453+
continue
454+
}
447455
ret[nsRecord.Rhs] = append(
448456
ret[nsRecord.Rhs],
449-
net.ParseIP(aRecord.Rhs),
457+
tmpIp,
450458
)
451459
}
452460
}
@@ -468,9 +476,16 @@ func findNameserversForDomain(
468476
return "", nil, err
469477
}
470478
for _, aRecord := range aRecords {
479+
tmpIp := net.ParseIP(aRecord.Rhs)
480+
// Skip duplicate IPs
481+
if slices.ContainsFunc(ret[nsRecord.Rhs], func(x net.IP) bool {
482+
return x.Equal(tmpIp)
483+
}) {
484+
continue
485+
}
471486
ret[nsRecord.Rhs] = append(
472487
ret[nsRecord.Rhs],
473-
net.ParseIP(aRecord.Rhs),
488+
tmpIp,
474489
)
475490
}
476491
}

0 commit comments

Comments
 (0)