Skip to content

Commit 8f5ffbe

Browse files
committed
coredns(plugin): Add NS record type support
Enables inserting NS record endpoint types into the zone. Signed-off-by: Michael Nairn <[email protected]>
1 parent 6ad8463 commit 8f5ffbe

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

coredns/plugin/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,4 @@ require (
169169
sigs.k8s.io/yaml v1.4.0 // indirect
170170
)
171171

172-
replace github.com/coredns/coredns => github.com/mikenairn/coredns v0.0.0-20250219164557-7d3a43ba6bee
172+
replace github.com/coredns/coredns => github.com/mikenairn/coredns v0.0.0-20250225081735-144d171bb58f

coredns/plugin/go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfr
246246
github.com/miekg/dns v1.1.31/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
247247
github.com/miekg/dns v1.1.63 h1:8M5aAw6OMZfFXTT7K5V0Eu5YiiL8l7nUAkyN6C9YwaY=
248248
github.com/miekg/dns v1.1.63/go.mod h1:6NGHfjhpmr5lt3XPLuyfDJi5AXbNIPM9PY6H6sF1Nfs=
249-
github.com/mikenairn/coredns v0.0.0-20250219164557-7d3a43ba6bee h1:cMEVd5FHgStdFkQDG4dXMVNOobcwH7vkS9dxcQ2sV8M=
250-
github.com/mikenairn/coredns v0.0.0-20250219164557-7d3a43ba6bee/go.mod h1:sbfww1dS+4Uh0fxreDaqQTszOPc9qjVZ0CBuzLo304Y=
249+
github.com/mikenairn/coredns v0.0.0-20250225081735-144d171bb58f h1:97nsbEfk+/WngFtBH0eyj4zCrjbGB/UnYiMyYNo7Seo=
250+
github.com/mikenairn/coredns v0.0.0-20250225081735-144d171bb58f/go.mod h1:sbfww1dS+4Uh0fxreDaqQTszOPc9qjVZ0CBuzLo304Y=
251251
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
252252
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
253253
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=

coredns/plugin/zone.go

+8
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ func NewZone(name string) *Zone {
7272
func (z *Zone) InsertEndpoint(ep *endpoint.Endpoint) error {
7373
rrs := []dns.RR{}
7474

75+
if ep.RecordType == endpoint.RecordTypeNS {
76+
for _, t := range ep.Targets {
77+
ns := &dns.NS{Hdr: dns.RR_Header{Name: dns.Fqdn(ep.DNSName), Rrtype: dns.TypeNS, Class: dns.ClassINET, Ttl: uint32(ep.RecordTTL)},
78+
Ns: dns.Fqdn(t)}
79+
rrs = append(rrs, ns)
80+
}
81+
}
82+
7583
if ep.RecordType == endpoint.RecordTypeA {
7684
for _, t := range ep.Targets {
7785
a := &dns.A{Hdr: dns.RR_Header{Name: dns.Fqdn(ep.DNSName), Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: uint32(ep.RecordTTL)},

0 commit comments

Comments
 (0)