Pull request: dnsforward: fix ddr target

Updates #4463.

Squashed commit of the following:

commit 047155b585a1c762d709874f44abb2d8c5a9dbca
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Mon May 30 15:34:38 2022 +0300

    dnsforward: imp code

commit b0508ffec13ccf5fc5d3d2e37c9e1bd83c3c039e
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Mon May 30 15:27:02 2022 +0300

    dnsforward: fix ddr target
This commit is contained in:
Eugene Burkov 2022-05-30 16:04:28 +03:00 committed by Ainar Garipov
parent 756c932e37
commit 7ce7e90865
2 changed files with 10 additions and 5 deletions

View File

@ -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{

View File

@ -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},