From 7ce7e908654579789f23ea5302416b67885494ae Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Mon, 30 May 2022 16:04:28 +0300 Subject: [PATCH] Pull request: dnsforward: fix ddr target Updates #4463. Squashed commit of the following: commit 047155b585a1c762d709874f44abb2d8c5a9dbca Author: Eugene Burkov Date: Mon May 30 15:34:38 2022 +0300 dnsforward: imp code commit b0508ffec13ccf5fc5d3d2e37c9e1bd83c3c039e Author: Eugene Burkov Date: Mon May 30 15:27:02 2022 +0300 dnsforward: fix ddr target --- internal/dnsforward/dns.go | 4 +++- internal/dnsforward/dns_test.go | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/dnsforward/dns.go b/internal/dnsforward/dns.go index e049bef0..2865bc84 100644 --- a/internal/dnsforward/dns.go +++ b/internal/dnsforward/dns.go @@ -278,7 +278,9 @@ func (s *Server) processDDRQuery(ctx *dnsContext) (rc resultCode) { // makeDDRResponse creates DDR answer according to server configuration. func (s *Server) makeDDRResponse(req *dns.Msg) (resp *dns.Msg) { resp = s.makeResponse(req) - domainName := s.conf.ServerName + // TODO(e.burkov): Think about stroing the FQDN version of the server's + // name somewhere. + domainName := dns.Fqdn(s.conf.ServerName) for _, addr := range s.dnsProxy.HTTPSListenAddr { values := []dns.SVCBKeyValue{ diff --git a/internal/dnsforward/dns_test.go b/internal/dnsforward/dns_test.go index b40b7bc2..129e3c2f 100644 --- a/internal/dnsforward/dns_test.go +++ b/internal/dnsforward/dns_test.go @@ -14,12 +14,15 @@ import ( "github.com/stretchr/testify/require" ) -const ddrTestDomainName = "dns.example.net" +const ( + ddrTestDomainName = "dns.example.net" + ddrTestFQDN = ddrTestDomainName + "." +) func TestServer_ProcessDDRQuery(t *testing.T) { dohSVCB := &dns.SVCB{ Priority: 1, - Target: ddrTestDomainName, + Target: ddrTestFQDN, Value: []dns.SVCBKeyValue{ &dns.SVCBAlpn{Alpn: []string{"h2"}}, &dns.SVCBPort{Port: 8044}, @@ -29,7 +32,7 @@ func TestServer_ProcessDDRQuery(t *testing.T) { dotSVCB := &dns.SVCB{ Priority: 2, - Target: ddrTestDomainName, + Target: ddrTestFQDN, Value: []dns.SVCBKeyValue{ &dns.SVCBAlpn{Alpn: []string{"dot"}}, &dns.SVCBPort{Port: 8043}, @@ -38,7 +41,7 @@ func TestServer_ProcessDDRQuery(t *testing.T) { doqSVCB := &dns.SVCB{ Priority: 3, - Target: ddrTestDomainName, + Target: ddrTestFQDN, Value: []dns.SVCBKeyValue{ &dns.SVCBAlpn{Alpn: []string{"doq"}}, &dns.SVCBPort{Port: 8042},