diff --git a/internal/dnsforward/dnsrewrite_test.go b/internal/dnsforward/dnsrewrite_test.go index 2609e055..df38ebe8 100644 --- a/internal/dnsforward/dnsrewrite_test.go +++ b/internal/dnsforward/dnsrewrite_test.go @@ -23,14 +23,14 @@ func TestServer_FilterDNSRewrite(t *testing.T) { } svcbVal := &rules.DNSSVCB{ Params: map[string]string{"alpn": "h3"}, - Target: domain, + Target: dns.Fqdn(domain), Priority: 32, } srvVal := &rules.DNSSRV{ Priority: 32, Weight: 60, Port: 8080, - Target: domain, + Target: dns.Fqdn(domain), } // Helper functions and entities. @@ -113,7 +113,7 @@ func TestServer_FilterDNSRewrite(t *testing.T) { assert.Equal(t, dns.RcodeSuccess, d.Res.Rcode) require.Len(t, d.Res.Answer, 1) - assert.Equal(t, domain, d.Res.Answer[0].(*dns.PTR).Ptr) + assert.Equal(t, dns.Fqdn(domain), d.Res.Answer[0].(*dns.PTR).Ptr) }) t.Run("noerror_txt", func(t *testing.T) { @@ -142,7 +142,7 @@ func TestServer_FilterDNSRewrite(t *testing.T) { ans, ok := d.Res.Answer[0].(*dns.MX) require.True(t, ok) - assert.Equal(t, mxVal.Exchange, ans.Mx) + assert.Equal(t, dns.Fqdn(mxVal.Exchange), ans.Mx) assert.Equal(t, mxVal.Preference, ans.Preference) }) diff --git a/internal/dnsforward/msg.go b/internal/dnsforward/msg.go index 31a1afce..47adb307 100644 --- a/internal/dnsforward/msg.go +++ b/internal/dnsforward/msg.go @@ -138,14 +138,14 @@ func (s *Server) genAnswerMX(req *dns.Msg, mx *rules.DNSMX) (ans *dns.MX) { return &dns.MX{ Hdr: s.hdr(req, dns.TypeMX), Preference: mx.Preference, - Mx: mx.Exchange, + Mx: dns.Fqdn(mx.Exchange), } } func (s *Server) genAnswerPTR(req *dns.Msg, ptr string) (ans *dns.PTR) { return &dns.PTR{ Hdr: s.hdr(req, dns.TypePTR), - Ptr: ptr, + Ptr: dns.Fqdn(ptr), } } @@ -155,7 +155,7 @@ func (s *Server) genAnswerSRV(req *dns.Msg, srv *rules.DNSSRV) (ans *dns.SRV) { Priority: srv.Priority, Weight: srv.Weight, Port: srv.Port, - Target: srv.Target, + Target: dns.Fqdn(srv.Target), } } diff --git a/internal/dnsforward/svcbmsg.go b/internal/dnsforward/svcbmsg.go index 2a8c27b4..99413ed3 100644 --- a/internal/dnsforward/svcbmsg.go +++ b/internal/dnsforward/svcbmsg.go @@ -137,7 +137,7 @@ func (s *Server) genAnswerSVCB(req *dns.Msg, svcb *rules.DNSSVCB) (ans *dns.SVCB ans = &dns.SVCB{ Hdr: s.hdr(req, dns.TypeSVCB), Priority: svcb.Priority, - Target: svcb.Target, + Target: dns.Fqdn(svcb.Target), } if len(svcb.Params) == 0 { return ans diff --git a/internal/dnsforward/svcbmsg_test.go b/internal/dnsforward/svcbmsg_test.go index 392e92ac..db6994c3 100644 --- a/internal/dnsforward/svcbmsg_test.go +++ b/internal/dnsforward/svcbmsg_test.go @@ -57,7 +57,7 @@ func TestGenAnswerHTTPS_andSVCB(t *testing.T) { want = &dns.SVCB{ Hdr: s.hdr(req, dns.TypeSVCB), Priority: prio, - Target: host, + Target: dns.Fqdn(host), } if kv == nil { @@ -122,7 +122,7 @@ func TestGenAnswerHTTPS_andSVCB(t *testing.T) { }, { svcb: dnssvcb("no-default-alpn", ""), want: wantsvcb(&dns.SVCBNoDefaultAlpn{}), - name: "no-default-alpn", + name: "no_default_alpn", }, { svcb: dnssvcb("port", "8080"), want: wantsvcb(&dns.SVCBPort{Port: 8080}), @@ -130,7 +130,7 @@ func TestGenAnswerHTTPS_andSVCB(t *testing.T) { }, { svcb: dnssvcb("port", "1005008080"), want: wantsvcb(nil), - name: "port", + name: "bad_port", }} for _, tc := range testCases {