From cb0cdbfe975b5c336934bce8fe3c9d25a87db4ce Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 11 Oct 2024 22:42:14 +0200 Subject: [PATCH] update docs --- docs/content/docs/dns/_index.md | 3 ++ pkg/roles/dns/handler_etcd_test.go | 44 +++++++++++++++--------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/docs/content/docs/dns/_index.md b/docs/content/docs/dns/_index.md index 8eee9f9f8..fbaa62371 100644 --- a/docs/content/docs/dns/_index.md +++ b/docs/content/docs/dns/_index.md @@ -31,6 +31,9 @@ A record belongs to one zone and stores one response. To support multiple respon To create a record at the root of the zone, set the name of the record to `@`. +To create a wildcard record, set the name of the record to `*`. Note that if a more specific record exists for the queried name, it will have a higher priority and the wildcard record will not be returned. +Wildcard records can also be used for multiple levels, for example creating a record called `*.*` in a zone `example.com` will be matched for a query to `foo.bar.example.com`. Here the first wildcard record, sorted by the least amount of depth (amount of `.`) will be returned, and no other records will be returned. + A single record holds the following data: - `data`: The actual response, an IP for A/AAAA records, text for TXT records, etc. diff --git a/pkg/roles/dns/handler_etcd_test.go b/pkg/roles/dns/handler_etcd_test.go index dc4317476..dbbd8ba66 100644 --- a/pkg/roles/dns/handler_etcd_test.go +++ b/pkg/roles/dns/handler_etcd_test.go @@ -24,7 +24,7 @@ func TestRoleDNS_Etcd(t *testing.T) { inst.KV().Key( types.KeyRole, types.KeyZones, - ".", + TestZone, ).String(), tests.MustJSON(dns.Zone{ HandlerConfigs: []map[string]string{ @@ -39,7 +39,7 @@ func TestRoleDNS_Etcd(t *testing.T) { inst.KV().Key( types.KeyRole, types.KeyZones, - ".", + TestZone, "foo", types.DNSRecordTypeA, "0", @@ -58,7 +58,7 @@ func TestRoleDNS_Etcd(t *testing.T) { role.Handler(fw, &d.Msg{ Question: []d.Question{ { - Name: "foo.", + Name: "foo.example.com.", Qtype: d.TypeA, Qclass: d.ClassINET, }, @@ -133,7 +133,7 @@ func TestRoleDNS_Etcd_Wildcard(t *testing.T) { inst.KV().Key( types.KeyRole, types.KeyZones, - ".", + TestZone, ).String(), tests.MustJSON(dns.Zone{ HandlerConfigs: []map[string]string{ @@ -148,7 +148,7 @@ func TestRoleDNS_Etcd_Wildcard(t *testing.T) { inst.KV().Key( types.KeyRole, types.KeyZones, - ".", + TestZone, "*", types.DNSRecordTypeA, "0", @@ -167,7 +167,7 @@ func TestRoleDNS_Etcd_Wildcard(t *testing.T) { role.Handler(fw, &d.Msg{ Question: []d.Question{ { - Name: "foo.", + Name: "foo.example.com.", Qtype: d.TypeA, Qclass: d.ClassINET, }, @@ -187,7 +187,7 @@ func TestRoleDNS_Etcd_CNAME(t *testing.T) { inst.KV().Key( types.KeyRole, types.KeyZones, - "test.", + TestZone, ).String(), tests.MustJSON(dns.Zone{ HandlerConfigs: []map[string]string{ @@ -202,13 +202,13 @@ func TestRoleDNS_Etcd_CNAME(t *testing.T) { inst.KV().Key( types.KeyRole, types.KeyZones, - "test.", + TestZone, "foo", types.DNSRecordTypeCNAME, "0", ).String(), tests.MustJSON(dns.Record{ - Data: "bar.test.", + Data: "bar.example.com.", }), )) tests.PanicIfError(inst.KV().Put( @@ -216,7 +216,7 @@ func TestRoleDNS_Etcd_CNAME(t *testing.T) { inst.KV().Key( types.KeyRole, types.KeyZones, - "test.", + TestZone, "bar", types.DNSRecordTypeA, "0", @@ -235,7 +235,7 @@ func TestRoleDNS_Etcd_CNAME(t *testing.T) { role.Handler(fw, &d.Msg{ Question: []d.Question{ { - Name: "bar.test.", + Name: "bar.example.com.", Qtype: d.TypeA, Qclass: d.ClassINET, }, @@ -248,14 +248,14 @@ func TestRoleDNS_Etcd_CNAME(t *testing.T) { role.Handler(fw, &d.Msg{ Question: []d.Question{ { - Name: "foo.test.", + Name: "foo.example.com.", Qtype: d.TypeCNAME, Qclass: d.ClassINET, }, }, }) ans = fw.Msg().Answer[0] - assert.Equal(t, "bar.test.", ans.(*d.CNAME).Target) + assert.Equal(t, "bar.example.com.", ans.(*d.CNAME).Target) } func TestRoleDNS_Etcd_WildcardNested(t *testing.T) { @@ -268,7 +268,7 @@ func TestRoleDNS_Etcd_WildcardNested(t *testing.T) { inst.KV().Key( types.KeyRole, types.KeyZones, - ".", + TestZone, ).String(), tests.MustJSON(dns.Zone{ HandlerConfigs: []map[string]string{ @@ -283,7 +283,7 @@ func TestRoleDNS_Etcd_WildcardNested(t *testing.T) { inst.KV().Key( types.KeyRole, types.KeyZones, - ".", + TestZone, "*.*", types.DNSRecordTypeA, "0", @@ -302,7 +302,7 @@ func TestRoleDNS_Etcd_WildcardNested(t *testing.T) { role.Handler(fw, &d.Msg{ Question: []d.Question{ { - Name: "foo.bar.", + Name: "foo.bar.example.com.", Qtype: d.TypeA, Qclass: d.ClassINET, }, @@ -322,7 +322,7 @@ func TestRoleDNS_Etcd_MixedCase(t *testing.T) { inst.KV().Key( types.KeyRole, types.KeyZones, - "TesT.", + "eXaMpLe.CoM.", ).String(), tests.MustJSON(dns.Zone{ HandlerConfigs: []map[string]string{ @@ -337,7 +337,7 @@ func TestRoleDNS_Etcd_MixedCase(t *testing.T) { inst.KV().Key( types.KeyRole, types.KeyZones, - "TesT.", + "eXaMpLe.CoM.", "bar", types.DNSRecordTypeA, "0", @@ -356,7 +356,7 @@ func TestRoleDNS_Etcd_MixedCase(t *testing.T) { role.Handler(fw, &d.Msg{ Question: []d.Question{ { - Name: "bar.test.", + Name: "bar.example.com.", Qtype: d.TypeA, Qclass: d.ClassINET, }, @@ -376,7 +376,7 @@ func TestRoleDNS_Etcd_MixedCase_Reverse(t *testing.T) { inst.KV().Key( types.KeyRole, types.KeyZones, - "test.", + TestZone, ).String(), tests.MustJSON(dns.Zone{ HandlerConfigs: []map[string]string{ @@ -391,7 +391,7 @@ func TestRoleDNS_Etcd_MixedCase_Reverse(t *testing.T) { inst.KV().Key( types.KeyRole, types.KeyZones, - "test.", + TestZone, "bar", types.DNSRecordTypeA, "0", @@ -410,7 +410,7 @@ func TestRoleDNS_Etcd_MixedCase_Reverse(t *testing.T) { role.Handler(fw, &d.Msg{ Question: []d.Question{ { - Name: "bar.TesT.", + Name: "bar.eXaMpLe.CoM.", Qtype: d.TypeA, Qclass: d.ClassINET, },