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. // makeDDRResponse creates DDR answer according to server configuration.
func (s *Server) makeDDRResponse(req *dns.Msg) (resp *dns.Msg) { func (s *Server) makeDDRResponse(req *dns.Msg) (resp *dns.Msg) {
resp = s.makeResponse(req) 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 { for _, addr := range s.dnsProxy.HTTPSListenAddr {
values := []dns.SVCBKeyValue{ values := []dns.SVCBKeyValue{

View File

@ -14,12 +14,15 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
const ddrTestDomainName = "dns.example.net" const (
ddrTestDomainName = "dns.example.net"
ddrTestFQDN = ddrTestDomainName + "."
)
func TestServer_ProcessDDRQuery(t *testing.T) { func TestServer_ProcessDDRQuery(t *testing.T) {
dohSVCB := &dns.SVCB{ dohSVCB := &dns.SVCB{
Priority: 1, Priority: 1,
Target: ddrTestDomainName, Target: ddrTestFQDN,
Value: []dns.SVCBKeyValue{ Value: []dns.SVCBKeyValue{
&dns.SVCBAlpn{Alpn: []string{"h2"}}, &dns.SVCBAlpn{Alpn: []string{"h2"}},
&dns.SVCBPort{Port: 8044}, &dns.SVCBPort{Port: 8044},
@ -29,7 +32,7 @@ func TestServer_ProcessDDRQuery(t *testing.T) {
dotSVCB := &dns.SVCB{ dotSVCB := &dns.SVCB{
Priority: 2, Priority: 2,
Target: ddrTestDomainName, Target: ddrTestFQDN,
Value: []dns.SVCBKeyValue{ Value: []dns.SVCBKeyValue{
&dns.SVCBAlpn{Alpn: []string{"dot"}}, &dns.SVCBAlpn{Alpn: []string{"dot"}},
&dns.SVCBPort{Port: 8043}, &dns.SVCBPort{Port: 8043},
@ -38,7 +41,7 @@ func TestServer_ProcessDDRQuery(t *testing.T) {
doqSVCB := &dns.SVCB{ doqSVCB := &dns.SVCB{
Priority: 3, Priority: 3,
Target: ddrTestDomainName, Target: ddrTestFQDN,
Value: []dns.SVCBKeyValue{ Value: []dns.SVCBKeyValue{
&dns.SVCBAlpn{Alpn: []string{"doq"}}, &dns.SVCBAlpn{Alpn: []string{"doq"}},
&dns.SVCBPort{Port: 8042}, &dns.SVCBPort{Port: 8042},