From e0b557eda2680e63037ae0eee2106a1f9466d141 Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Wed, 2 Mar 2022 14:21:33 +0300 Subject: [PATCH] Pull request: 4166 udp upstream Merge in DNS/adguard-home from 4166-udp-upstream to master Closes #4166. Squashed commit of the following: commit b8b6d1c7ac1e11e83c0c68e46e7f66fdc6043839 Merge: e5f01273 ea6e033d Author: Eugene Burkov Date: Tue Mar 1 20:36:40 2022 +0300 Merge branch 'master' into 4166-udp-upstream commit e5f0127384d84c4395da5b79a1fd4a47acbe122c Author: Eugene Burkov Date: Tue Mar 1 19:41:33 2022 +0300 client: upd upstream examples commit bd974f22231f11f4c57e19d6d13bc45dbfdf2fdf Author: Eugene Burkov Date: Tue Mar 1 18:36:10 2022 +0300 all: upd proxy commit badf1325090ecd1dc86e42e7406dfb6653e07bf1 Author: Eugene Burkov Date: Fri Feb 4 14:36:50 2022 +0300 WIP --- CHANGELOG.md | 3 +++ client/src/__locales/en.json | 2 ++ .../src/components/Settings/Dns/Upstream/Examples.js | 12 +++++++++--- go.mod | 4 ++-- go.sum | 9 ++++----- internal/dnsforward/http.go | 2 +- internal/dnsforward/http_test.go | 10 +++++++++- 7 files changed, 30 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b83fc01..57adf5bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ and this project adheres to ### Added +- Support for hostnames for plain UDP upstream servers using the `udp://` scheme + ([#4166]). - Logs are now collected by default on FreeBSD and OpenBSD when AdGuard Home is installed as a service ([#4213]). - `windows/arm64` support ([#3057]). @@ -82,6 +84,7 @@ In this release, the schema version has changed from 12 to 13. [#3367]: https://github.com/AdguardTeam/AdGuardHome/issues/3367 [#3381]: https://github.com/AdguardTeam/AdGuardHome/issues/3381 [#3503]: https://github.com/AdguardTeam/AdGuardHome/issues/3503 +[#4166]: https://github.com/AdguardTeam/AdGuardHome/issues/4166 [#4213]: https://github.com/AdguardTeam/AdGuardHome/issues/4213 [#4221]: https://github.com/AdguardTeam/AdGuardHome/issues/4221 [#4238]: https://github.com/AdguardTeam/AdGuardHome/issues/4238 diff --git a/client/src/__locales/en.json b/client/src/__locales/en.json index 1559a24e..f1e1eac0 100644 --- a/client/src/__locales/en.json +++ b/client/src/__locales/en.json @@ -210,11 +210,13 @@ "example_comment_hash": "# Also a comment.", "example_regex_meaning": "block access to domains matching the specified regular expression.", "example_upstream_regular": "regular DNS (over UDP);", + "example_upstream_udp": "regular DNS (over UDP, hostname);", "example_upstream_dot": "encrypted <0>DNS-over-TLS;", "example_upstream_doh": "encrypted <0>DNS-over-HTTPS;", "example_upstream_doq": "encrypted <0>DNS-over-QUIC (experimental);", "example_upstream_sdns": "<0>DNS Stamps for <1>DNSCrypt or <2>DNS-over-HTTPS resolvers;", "example_upstream_tcp": "regular DNS (over TCP);", + "example_upstream_tcp_hostname": "regular DNS (over TCP, hostname);", "all_lists_up_to_date_toast": "All lists are already up-to-date", "updated_upstream_dns_toast": "Upstream servers successfully saved", "dns_test_ok_toast": "Specified DNS servers are working correctly", diff --git a/client/src/components/Settings/Dns/Upstream/Examples.js b/client/src/components/Settings/Dns/Upstream/Examples.js index 2f145b3a..b4e0ce09 100644 --- a/client/src/components/Settings/Dns/Upstream/Examples.js +++ b/client/src/components/Settings/Dns/Upstream/Examples.js @@ -10,6 +10,15 @@ const Examples = (props) => (
  • 94.140.14.140: {props.t('example_upstream_regular')}
  • +
  • + udp://dns-unfiltered.adguard.com: example_upstream_udp +
  • +
  • + tcp://94.140.14.140: example_upstream_tcp +
  • +
  • + tcp://dns-unfiltered.adguard.com: example_upstream_tcp_hostname +
  • tls://dns-unfiltered.adguard.com: @@ -67,9 +76,6 @@ const Examples = (props) => (
  • -
  • - tcp://94.140.14.140: example_upstream_tcp -
  • sdns://...: diff --git a/go.mod b/go.mod index 00182235..91fee199 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/AdguardTeam/AdGuardHome go 1.17 require ( - github.com/AdguardTeam/dnsproxy v0.41.1 - github.com/AdguardTeam/golibs v0.10.5 + github.com/AdguardTeam/dnsproxy v0.41.3 + github.com/AdguardTeam/golibs v0.10.6 github.com/AdguardTeam/urlfilter v0.15.2 github.com/NYTimes/gziphandler v1.1.1 github.com/ameshkov/dnscrypt/v2 v2.2.3 diff --git a/go.sum b/go.sum index 99f20fd1..4ae0c523 100644 --- a/go.sum +++ b/go.sum @@ -7,14 +7,13 @@ dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBr dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4= dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= -github.com/AdguardTeam/dnsproxy v0.41.1 h1:sDWami83ZNp0XNdWsLECwIX/hPI5UnVrotRtPnrgDuo= -github.com/AdguardTeam/dnsproxy v0.41.1/go.mod h1:PZ9l22h3Er+5mxFQB7oHZMTvx+aa9R6LbzA/ikXQlS0= +github.com/AdguardTeam/dnsproxy v0.41.3 h1:FJnIf2pHaABUjAvB0P79nIXN5sBAvsUf2368NNw50+s= +github.com/AdguardTeam/dnsproxy v0.41.3/go.mod h1:GCdEbTw683vBqksJIccPSYzBg2yIFbRiDnXltyIinug= github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.4.2/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= -github.com/AdguardTeam/golibs v0.10.3/go.mod h1:rSfQRGHIdgfxriDDNgNJ7HmE5zRoURq8R+VdR81Zuzw= github.com/AdguardTeam/golibs v0.10.4/go.mod h1:rSfQRGHIdgfxriDDNgNJ7HmE5zRoURq8R+VdR81Zuzw= -github.com/AdguardTeam/golibs v0.10.5 h1:4/nl1yIBJOv5luVu9SURW8LfgOjI3zQ2moIUy/1k0y4= -github.com/AdguardTeam/golibs v0.10.5/go.mod h1:rSfQRGHIdgfxriDDNgNJ7HmE5zRoURq8R+VdR81Zuzw= +github.com/AdguardTeam/golibs v0.10.6 h1:6UG6LxWFnG7TfjNzeApw+T68Kqqov0fcDYk9RjhTdhc= +github.com/AdguardTeam/golibs v0.10.6/go.mod h1:rSfQRGHIdgfxriDDNgNJ7HmE5zRoURq8R+VdR81Zuzw= github.com/AdguardTeam/gomitmproxy v0.2.0/go.mod h1:Qdv0Mktnzer5zpdpi5rAwixNJzW2FN91LjKJCkVbYGU= github.com/AdguardTeam/urlfilter v0.15.2 h1:LZGgrm4l4Ys9eAqB+UUmZfiC6vHlDlYFhx0WXqo6LtQ= github.com/AdguardTeam/urlfilter v0.15.2/go.mod h1:46YZDOV1+qtdRDuhZKVPSSp7JWWes0KayqHrKAFBdEI= diff --git a/internal/dnsforward/http.go b/internal/dnsforward/http.go index d653fa1e..b7fb66a6 100644 --- a/internal/dnsforward/http.go +++ b/internal/dnsforward/http.go @@ -459,7 +459,7 @@ func ValidateUpstreamsPrivate(upstreams []string, lnc LocalNetChecker) (err erro return nil } -var protocols = []string{"tls://", "https://", "tcp://", "sdns://", "quic://"} +var protocols = []string{"udp://", "tcp://", "tls://", "https://", "sdns://", "quic://"} func validateUpstream(u string) (useDefault bool, err error) { // Check if the user tries to specify upstream for domain. diff --git a/internal/dnsforward/http_test.go b/internal/dnsforward/http_test.go index 66931f4d..6e28ab41 100644 --- a/internal/dnsforward/http_test.go +++ b/internal/dnsforward/http_test.go @@ -306,6 +306,14 @@ func TestValidateUpstream(t *testing.T) { name: "valid_default", upstream: "sdns://AQMAAAAAAAAAFDE3Ni4xMDMuMTMwLjEzMDo1NDQzINErR_JS3PLCu_iZEIbq95zkSV2LFsigxDIuUso_OQhzIjIuZG5zY3J5cHQuZGVmYXVsdC5uczEuYWRndWFyZC5jb20", wantErr: ``, + }, { + wantDef: assert.True, + name: "default_udp_host", + upstream: "udp://dns.google", + }, { + wantDef: assert.True, + name: "default_udp_ip", + upstream: "udp://8.8.8.8", }, { wantDef: assert.False, name: "valid", @@ -389,7 +397,7 @@ func TestValidateUpstreams(t *testing.T) { }, }, { name: "invalid", - wantErr: `cannot prepare the upstream dhcp://fake.dns ([]): unsupported URL scheme: dhcp`, + wantErr: `cannot prepare the upstream dhcp://fake.dns ([]): unsupported url scheme: dhcp`, set: []string{"dhcp://fake.dns"}, }}