Pull request: dnsforward: add doq alpn

Merge in DNS/adguard-home from 4592-doq-alpn to master

Squashed commit of the following:

commit 5985445dbf5158ae1e5b0235b404dd188c856e60
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Thu May 26 16:42:06 2022 +0200

    dnsforward: add doq alpn

commit 9dcd6fee615a1a5ac1f80641ac16c18371b67096
Merge: 2564c870 c3d5fcc6
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Thu May 26 15:24:07 2022 +0200

    Merge remote-tracking branch 'origin/master' into 4592-doq-alpn

commit 2564c870e704ff453d0ad2fb22fa295ef725dd13
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Thu May 26 15:20:16 2022 +0200

    dnsforward: add doq alpn
This commit is contained in:
Dimitry Kolyshev
2022-05-26 17:53:11 +03:00
parent c3d5fcc669
commit 756c932e37
2 changed files with 42 additions and 5 deletions

View File

@@ -36,6 +36,15 @@ func TestServer_ProcessDDRQuery(t *testing.T) {
},
}
doqSVCB := &dns.SVCB{
Priority: 3,
Target: ddrTestDomainName,
Value: []dns.SVCBKeyValue{
&dns.SVCBAlpn{Alpn: []string{"doq"}},
&dns.SVCBPort{Port: 8042},
},
}
testCases := []struct {
name string
host string
@@ -43,6 +52,7 @@ func TestServer_ProcessDDRQuery(t *testing.T) {
wantRes resultCode
portDoH int
portDoT int
portDoQ int
qtype uint16
ddrEnabled bool
}{{
@@ -88,6 +98,14 @@ func TestServer_ProcessDDRQuery(t *testing.T) {
qtype: dns.TypeSVCB,
ddrEnabled: true,
portDoH: 8044,
}, {
name: "doq",
wantRes: resultCodeFinish,
want: []*dns.SVCB{doqSVCB},
host: ddrHostFQDN,
qtype: dns.TypeSVCB,
ddrEnabled: true,
portDoQ: 8042,
}, {
name: "dot_doh",
wantRes: resultCodeFinish,
@@ -101,7 +119,7 @@ func TestServer_ProcessDDRQuery(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
s := prepareTestServer(t, tc.portDoH, tc.portDoT, tc.ddrEnabled)
s := prepareTestServer(t, tc.portDoH, tc.portDoT, tc.portDoQ, tc.ddrEnabled)
req := createTestMessageWithType(tc.host, tc.qtype)
@@ -130,7 +148,7 @@ func TestServer_ProcessDDRQuery(t *testing.T) {
}
}
func prepareTestServer(t *testing.T, portDoH, portDoT int, ddrEnabled bool) (s *Server) {
func prepareTestServer(t *testing.T, portDoH, portDoT, portDoQ int, ddrEnabled bool) (s *Server) {
t.Helper()
proxyConf := proxy.Config{}
@@ -143,6 +161,10 @@ func prepareTestServer(t *testing.T, portDoH, portDoT int, ddrEnabled bool) (s *
proxyConf.TLSListenAddr = []*net.TCPAddr{{Port: portDoT}}
}
if portDoQ > 0 {
proxyConf.QUICListenAddr = []*net.UDPAddr{{Port: portDoQ}}
}
s = &Server{
dnsProxy: &proxy.Proxy{
Config: proxyConf,