From b29f320fd466715d02041a4753223ad4f2105f76 Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Wed, 23 Feb 2022 22:42:03 +0800 Subject: [PATCH 01/79] Simplify Dockerfile Alpine Linux apk usage Remove additional `--update` and manual clean up for apk in Dockerfile --- scripts/make/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/make/Dockerfile b/scripts/make/Dockerfile index f5a543a2..a731e3a6 100644 --- a/scripts/make/Dockerfile +++ b/scripts/make/Dockerfile @@ -21,8 +21,7 @@ LABEL\ org.opencontainers.image.version=$VERSION # Update certificates. -RUN apk --no-cache --update add ca-certificates libcap tzdata && \ - rm -rf /var/cache/apk/* && \ +RUN apk --no-cache add ca-certificates libcap tzdata && \ mkdir -p /opt/adguardhome/conf /opt/adguardhome/work && \ chown -R nobody: /opt/adguardhome From c346216424d6571f96d80f47a9224da4c47dbbf9 Mon Sep 17 00:00:00 2001 From: bakito Date: Sat, 12 Mar 2022 12:46:15 +0100 Subject: [PATCH 02/79] correct openapi schema --- internal/home/controlfiltering.go | 2 +- openapi/openapi.yaml | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/internal/home/controlfiltering.go b/internal/home/controlfiltering.go index 639403d8..51d86146 100644 --- a/internal/home/controlfiltering.go +++ b/internal/home/controlfiltering.go @@ -316,7 +316,7 @@ type filterJSON struct { URL string `json:"url"` Name string `json:"name"` RulesCount uint32 `json:"rules_count"` - LastUpdated string `json:"last_updated"` + LastUpdated string `json:"last_updated,omitempty"` } type filteringConfig struct { diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index 8b21a01f..bb3bfe09 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -1396,7 +1396,6 @@ 'required': - 'enabled' - 'id' - - 'last_updated' - 'name' - 'rules_count' - 'url' @@ -1434,6 +1433,10 @@ 'type': 'array' 'items': '$ref': '#/components/schemas/Filter' + 'whitelist_filters': + 'type': 'array' + 'items': + '$ref': '#/components/schemas/Filter' 'user_rules': 'type': 'array' 'items': @@ -1451,14 +1454,7 @@ 'description': 'Filtering URL settings' 'properties': 'data': - 'properties': - 'enabled': - 'type': 'boolean' - 'name': - 'type': 'string' - 'url': - 'type': 'string' - 'type': 'object' + '$ref': '#/components/schemas/Filter' 'url': 'type': 'string' 'whitelist': @@ -1860,6 +1856,8 @@ 'description': 'Previously added URL containing filtering rules' 'type': 'string' 'example': 'https://filters.adtidy.org/windows/filters/15.txt' + 'whitelist': + 'type': 'boolean' 'QueryLogItem': 'type': 'object' 'description': 'Query log item' From 047970e5eef1f054441b3ca50becdbe137fb41e4 Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Wed, 30 Mar 2022 18:02:50 +0800 Subject: [PATCH 03/79] Enable code block syntax hightlight in README.md It'll make it just a little bit easier to read it --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 00664365..7044eece 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ It operates as a DNS server that re-routes tracking domains to a "black hole", t ### Automated install (Linux and Mac) Run the following command in your terminal: -``` +```sh curl -s -S -L https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -v ``` @@ -212,11 +212,11 @@ Check the [`Makefile`](https://github.com/AdguardTeam/AdGuardHome/blob/master/Ma In order to do this, specify `GOOS` and `GOARCH` env variables before running make. For example: -``` +```sh env GOOS='linux' GOARCH='arm64' make ``` Or: -``` +```sh make GOOS='linux' GOARCH='arm64' ``` @@ -228,7 +228,7 @@ You'll need this to prepare a release build: Commands: -``` +```sh make build-release CHANNEL='...' VERSION='...' ``` @@ -271,12 +271,12 @@ There are three options how you can install an unstable version: 3. Standalone builds. Use the automated installation script or look for the available builds below. Beta: -``` +```sh curl -s -S -L https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -c beta ``` Edge: -``` +```sh curl -s -S -L https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -c edge ``` From f289f4b1b6f91f38d99ac8b9e3f9bdc9536609e7 Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Thu, 12 May 2022 17:41:39 +0300 Subject: [PATCH 04/79] Pull request: websvc: add system info Merge in DNS/adguard-home from websvc-system-info to master Squashed commit of the following: commit 333aaa0602da254e25e0262a10080bf44a3718a7 Author: Ainar Garipov Date: Thu May 12 16:32:32 2022 +0300 websvc: fmt commit d8a35bf71dcc59fdd595494e5b220e3d24516728 Author: Ainar Garipov Date: Thu May 12 16:10:11 2022 +0300 websvc: refactor, imp tests commit dfeb24f3f35513bf51323d3ab6f717f582a1defc Author: Ainar Garipov Date: Wed May 11 20:52:02 2022 +0300 websvc: add system info --- go.mod | 1 + go.sum | 2 + internal/v1/cmd/cmd.go | 4 +- internal/v1/websvc/json.go | 61 +++++++++++++++++++++++++++++++ internal/v1/websvc/middleware.go | 16 ++++++++ internal/v1/websvc/path.go | 8 ++++ internal/v1/websvc/system.go | 35 ++++++++++++++++++ internal/v1/websvc/system_test.go | 36 ++++++++++++++++++ internal/v1/websvc/websvc.go | 46 ++++++++++++++++++++++- internal/v1/websvc/websvc_test.go | 52 ++++++++++++++++++++------ openapi/v1.yaml | 16 +++++++- 11 files changed, 260 insertions(+), 17 deletions(-) create mode 100644 internal/v1/websvc/json.go create mode 100644 internal/v1/websvc/middleware.go create mode 100644 internal/v1/websvc/path.go create mode 100644 internal/v1/websvc/system.go create mode 100644 internal/v1/websvc/system_test.go diff --git a/go.mod b/go.mod index 3b64e7db..8da34653 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/NYTimes/gziphandler v1.1.1 github.com/ameshkov/dnscrypt/v2 v2.2.3 github.com/digineo/go-ipset/v2 v2.2.1 + github.com/dimfeld/httptreemux/v5 v5.4.0 github.com/fsnotify/fsnotify v1.5.4 github.com/go-ping/ping v0.0.0-20211130115550-779d1e919534 github.com/google/go-cmp v0.5.7 diff --git a/go.sum b/go.sum index 06ae9b96..807a6849 100644 --- a/go.sum +++ b/go.sum @@ -52,6 +52,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/digineo/go-ipset/v2 v2.2.1 h1:k6skY+0fMqeUjjeWO/m5OuWPSZUAn7AucHMnQ1MX77g= github.com/digineo/go-ipset/v2 v2.2.1/go.mod h1:wBsNzJlZlABHUITkesrggFnZQtgW5wkqw1uo8Qxe0VU= +github.com/dimfeld/httptreemux/v5 v5.4.0 h1:IiHYEjh+A7pYbhWyjmGnj5HZK6gpOOvyBXCJ+BE8/Gs= +github.com/dimfeld/httptreemux/v5 v5.4.0/go.mod h1:QeEylH57C0v3VO0tkKraVz9oD3Uu93CKPnTLbsidvSw= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/fanliao/go-promise v0.0.0-20141029170127-1890db352a72/go.mod h1:PjfxuH4FZdUyfMdtBio2lsRr1AKEaVPwelzuHuh8Lqc= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= diff --git a/internal/v1/cmd/cmd.go b/internal/v1/cmd/cmd.go index 4c4e252f..1f1cc64e 100644 --- a/internal/v1/cmd/cmd.go +++ b/internal/v1/cmd/cmd.go @@ -20,7 +20,8 @@ import ( func Main(clientBuildFS fs.FS) { // # Initial Configuration - rand.Seed(time.Now().UnixNano()) + start := time.Now() + rand.Seed(start.UnixNano()) // TODO(a.garipov): Set up logging. @@ -35,6 +36,7 @@ func Main(clientBuildFS fs.FS) { IP: net.IP{127, 0, 0, 1}, Port: 3001, }}, + Start: start, Timeout: 60 * time.Second, }) diff --git a/internal/v1/websvc/json.go b/internal/v1/websvc/json.go new file mode 100644 index 00000000..beb7f7ec --- /dev/null +++ b/internal/v1/websvc/json.go @@ -0,0 +1,61 @@ +package websvc + +import ( + "encoding/json" + "fmt" + "io" + "net/http" + "strconv" + "time" + + "github.com/AdguardTeam/golibs/log" +) + +// JSON Utilities + +// jsonTime is a time.Time that can be decoded from JSON and encoded into JSON +// according to our API conventions. +type jsonTime time.Time + +// type check +var _ json.Marshaler = jsonTime{} + +// nsecPerMsec is the number of nanoseconds in a millisecond. +const nsecPerMsec = float64(time.Millisecond / time.Nanosecond) + +// MarshalJSON implements the json.Marshaler interface for jsonTime. err is +// always nil. +func (t jsonTime) MarshalJSON() (b []byte, err error) { + msec := float64(time.Time(t).UnixNano()) / nsecPerMsec + b = strconv.AppendFloat(nil, msec, 'f', 3, 64) + + return b, nil +} + +// type check +var _ json.Unmarshaler = (*jsonTime)(nil) + +// UnmarshalJSON implements the json.Marshaler interface for *jsonTime. +func (t *jsonTime) UnmarshalJSON(b []byte) (err error) { + if t == nil { + return fmt.Errorf("json time is nil") + } + + msec, err := strconv.ParseFloat(string(b), 64) + if err != nil { + return fmt.Errorf("parsing json time: %w", err) + } + + *t = jsonTime(time.Unix(0, int64(msec*nsecPerMsec)).UTC()) + + return nil +} + +// writeJSONResponse encodes v into w and logs any errors it encounters. r is +// used to get additional information from the request. +func writeJSONResponse(w io.Writer, r *http.Request, v interface{}) { + err := json.NewEncoder(w).Encode(v) + if err != nil { + log.Error("websvc: writing resp to %s %s: %s", r.Method, r.URL.Path, err) + } +} diff --git a/internal/v1/websvc/middleware.go b/internal/v1/websvc/middleware.go new file mode 100644 index 00000000..c87c57d5 --- /dev/null +++ b/internal/v1/websvc/middleware.go @@ -0,0 +1,16 @@ +package websvc + +import "net/http" + +// Middlewares + +// jsonMw sets the content type of the response to application/json. +func jsonMw(h http.Handler) (wrapped http.HandlerFunc) { + f := func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + + h.ServeHTTP(w, r) + } + + return http.HandlerFunc(f) +} diff --git a/internal/v1/websvc/path.go b/internal/v1/websvc/path.go new file mode 100644 index 00000000..cfd67fd9 --- /dev/null +++ b/internal/v1/websvc/path.go @@ -0,0 +1,8 @@ +package websvc + +// Path constants +const ( + PathHealthCheck = "/health-check" + + PathV1SystemInfo = "/api/v1/system/info" +) diff --git a/internal/v1/websvc/system.go b/internal/v1/websvc/system.go new file mode 100644 index 00000000..47d0c63c --- /dev/null +++ b/internal/v1/websvc/system.go @@ -0,0 +1,35 @@ +package websvc + +import ( + "net/http" + "runtime" + + "github.com/AdguardTeam/AdGuardHome/internal/version" +) + +// System Handlers + +// RespGetV1SystemInfo describes the response of the GET /api/v1/system/info +// HTTP API. +type RespGetV1SystemInfo struct { + Arch string `json:"arch"` + Channel string `json:"channel"` + OS string `json:"os"` + NewVersion string `json:"new_version,omitempty"` + Start jsonTime `json:"start"` + Version string `json:"version"` +} + +// handleGetV1SystemInfo is the handler for the GET /api/v1/system/info HTTP +// API. +func (svc *Service) handleGetV1SystemInfo(w http.ResponseWriter, r *http.Request) { + writeJSONResponse(w, r, &RespGetV1SystemInfo{ + Arch: runtime.GOARCH, + Channel: version.Channel(), + OS: runtime.GOOS, + // TODO(a.garipov): Fill this when we have an updater. + NewVersion: "", + Start: jsonTime(svc.start), + Version: version.Version(), + }) +} diff --git a/internal/v1/websvc/system_test.go b/internal/v1/websvc/system_test.go new file mode 100644 index 00000000..49579ca5 --- /dev/null +++ b/internal/v1/websvc/system_test.go @@ -0,0 +1,36 @@ +package websvc_test + +import ( + "encoding/json" + "net/http" + "net/url" + "runtime" + "testing" + "time" + + "github.com/AdguardTeam/AdGuardHome/internal/v1/websvc" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestService_handleGetV1SystemInfo(t *testing.T) { + _, addr := newTestServer(t) + u := &url.URL{ + Scheme: "http", + Host: addr, + Path: websvc.PathV1SystemInfo, + } + + body := httpGet(t, u, http.StatusOK) + resp := &websvc.RespGetV1SystemInfo{} + err := json.Unmarshal(body, resp) + require.NoError(t, err) + + // TODO(a.garipov): Consider making version.Channel and version.Version + // testable and test these better. + assert.NotEmpty(t, resp.Channel) + + assert.Equal(t, resp.Arch, runtime.GOARCH) + assert.Equal(t, resp.OS, runtime.GOOS) + assert.Equal(t, testStart, time.Time(resp.Start)) +} diff --git a/internal/v1/websvc/websvc.go b/internal/v1/websvc/websvc.go index e741ff3d..9af22a15 100644 --- a/internal/v1/websvc/websvc.go +++ b/internal/v1/websvc/websvc.go @@ -17,6 +17,7 @@ import ( "github.com/AdguardTeam/golibs/errors" "github.com/AdguardTeam/golibs/log" "github.com/AdguardTeam/golibs/netutil" + httptreemux "github.com/dimfeld/httptreemux/v5" ) // Config is the AdGuard Home web service configuration structure. @@ -32,6 +33,9 @@ type Config struct { // SecureAddresses is not empty, TLS must not be nil. SecureAddresses []*netutil.IPPort + // Start is the time of start of AdGuard Home. + Start time.Time + // Timeout is the timeout for all server operations. Timeout time.Duration } @@ -41,6 +45,7 @@ type Config struct { type Service struct { tls *tls.Config servers []*http.Server + start time.Time timeout time.Duration } @@ -53,11 +58,11 @@ func New(c *Config) (svc *Service) { svc = &Service{ tls: c.TLS, + start: c.Start, timeout: c.Timeout, } - mux := http.NewServeMux() - mux.HandleFunc("/health-check", svc.handleGetHealthCheck) + mux := newMux(svc) for _, a := range c.Addresses { addr := a.String() @@ -91,6 +96,43 @@ func New(c *Config) (svc *Service) { return svc } +// newMux returns a new HTTP request multiplexor for the AdGuard Home web +// service. +func newMux(svc *Service) (mux *httptreemux.ContextMux) { + mux = httptreemux.NewContextMux() + + routes := []struct { + handler http.HandlerFunc + method string + path string + isJSON bool + }{{ + handler: svc.handleGetHealthCheck, + method: http.MethodGet, + path: PathHealthCheck, + isJSON: false, + }, { + handler: svc.handleGetV1SystemInfo, + method: http.MethodGet, + path: PathV1SystemInfo, + isJSON: true, + }} + + for _, r := range routes { + var h http.HandlerFunc + if r.isJSON { + // TODO(a.garipov): Consider using httptreemux's MiddlewareFunc. + h = jsonMw(r.handler) + } else { + h = r.handler + } + + mux.Handle(r.method, r.path, h) + } + + return mux +} + // Addrs returns all addresses on which this server serves the HTTP API. Addrs // must not be called until Start returns. func (svc *Service) Addrs() (addrs []string) { diff --git a/internal/v1/websvc/websvc_test.go b/internal/v1/websvc/websvc_test.go index 01b892cd..459ffd14 100644 --- a/internal/v1/websvc/websvc_test.go +++ b/internal/v1/websvc/websvc_test.go @@ -18,7 +18,17 @@ import ( const testTimeout = 1 * time.Second -func TestService_Start_getHealthCheck(t *testing.T) { +// testStart is the server start value for tests. +var testStart = time.Date(2022, 1, 1, 0, 0, 0, 0, time.UTC) + +// newTestServer creates and starts a new web service instance as well as its +// sole address. It also registers a cleanup procedure, which shuts the +// instance down. +// +// TODO(a.garipov): Use svc or remove it. +func newTestServer(t testing.TB) (svc *websvc.Service, addr string) { + t.Helper() + c := &websvc.Config{ TLS: nil, Addresses: []*netutil.IPPort{{ @@ -27,9 +37,10 @@ func TestService_Start_getHealthCheck(t *testing.T) { }}, SecureAddresses: nil, Timeout: testTimeout, + Start: testStart, } - svc := websvc.New(c) + svc = websvc.New(c) err := svc.Start() require.NoError(t, err) @@ -44,26 +55,43 @@ func TestService_Start_getHealthCheck(t *testing.T) { addrs := svc.Addrs() require.Len(t, addrs, 1) - u := &url.URL{ - Scheme: "http", - Host: addrs[0], - Path: "/health-check", - } + return svc, addrs[0] +} + +// httpGet is a helper that performs an HTTP GET request and returns the body of +// the response as well as checks that the status code is correct. +// +// TODO(a.garipov): Add helpers for other methods. +func httpGet(t testing.TB, u *url.URL, wantCode int) (body []byte) { + t.Helper() + req, err := http.NewRequest(http.MethodGet, u.String(), nil) - require.NoError(t, err) + require.NoErrorf(t, err, "creating req") httpCli := &http.Client{ Timeout: testTimeout, } resp, err := httpCli.Do(req) - require.NoError(t, err) + require.NoErrorf(t, err, "performing req") + require.Equal(t, wantCode, resp.StatusCode) testutil.CleanupAndRequireSuccess(t, resp.Body.Close) - assert.Equal(t, http.StatusOK, resp.StatusCode) + body, err = io.ReadAll(resp.Body) + require.NoErrorf(t, err, "reading body") - body, err := io.ReadAll(resp.Body) - require.NoError(t, err) + return body +} + +func TestService_Start_getHealthCheck(t *testing.T) { + _, addr := newTestServer(t) + u := &url.URL{ + Scheme: "http", + Host: addr, + Path: websvc.PathHealthCheck, + } + + body := httpGet(t, u, http.StatusOK) assert.Equal(t, []byte("OK"), body) } diff --git a/openapi/v1.yaml b/openapi/v1.yaml index 30c318bc..a9092c98 100644 --- a/openapi/v1.yaml +++ b/openapi/v1.yaml @@ -3393,11 +3393,17 @@ 'description': > Information about the AdGuard Home server. 'example': + 'arch': 'amd64' 'channel': 'release' - 'new_version': 'v0.106.1' + 'new_version': 'v0.108.1' + 'os': 'linux' 'start': 1614345496000 - 'version': 'v0.106.0' + 'version': 'v0.108.0' 'properties': + 'arch': + 'description': > + CPU architecture. + 'type': 'string' 'channel': '$ref': '#/components/schemas/Channel' 'new_version': @@ -3405,6 +3411,10 @@ New available version of AdGuard Home to which the server can be updated, if any. If there are none, this field is absent. 'type': 'string' + 'os': + 'description': > + Operating system type. + 'type': 'string' 'start': 'description': > Unix time at which AdGuard Home started working, in milliseconds. @@ -3415,7 +3425,9 @@ Current AdGuard Home version. 'type': 'string' 'required': + - 'arch' - 'channel' + - 'os' - 'start' - 'version' 'type': 'object' From 79d85a24e970450767997d2e3a1b1876f652f0f7 Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Wed, 18 May 2022 15:00:36 +0300 Subject: [PATCH 05/79] Pull request: all: log changes Updates #4273. Squashed commit of the following: commit ebae1a4d0944fa348b7dcb7e73e59d083c7a5e97 Author: Eugene Burkov Date: Wed May 18 14:48:16 2022 +0300 all: log changes --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c2fa06c..d183c45d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -127,6 +127,7 @@ In this release, the schema version has changed from 12 to 14. ### Fixed +- Detection of the stopped service status on macOS and Linux ([#4273]). - Case-sensitive ClientID ([#4542]). - Slow version update queries making other HTTP APIs unresponsible ([#4499]). - ARP tables refreshing process causing excessive PTR requests ([#3157]). @@ -146,6 +147,7 @@ In this release, the schema version has changed from 12 to 14. [#4213]: https://github.com/AdguardTeam/AdGuardHome/issues/4213 [#4221]: https://github.com/AdguardTeam/AdGuardHome/issues/4221 [#4238]: https://github.com/AdguardTeam/AdGuardHome/issues/4238 +[#4273]: https://github.com/AdguardTeam/AdGuardHome/issues/4273 [#4276]: https://github.com/AdguardTeam/AdGuardHome/issues/4276 [#4499]: https://github.com/AdguardTeam/AdGuardHome/issues/4499 [#4533]: https://github.com/AdguardTeam/AdGuardHome/issues/4533 From 24d7dc8e8a36654bc8d2d64c2014419bd7a9eb25 Mon Sep 17 00:00:00 2001 From: Dimitry Kolyshev Date: Mon, 23 May 2022 16:04:14 +0300 Subject: [PATCH 06/79] Pull request: all: upd dnsproxy Merge in DNS/adguard-home from 4503-upstream-conf to master Squashed commit of the following: commit c6cb1babd4cbf9aacafe902e3d54ce17e8d2cc81 Merge: 75d85ed1 79d85a24 Author: Dimitry Kolyshev Date: Mon May 23 13:06:00 2022 +0200 Merge remote-tracking branch 'origin/master' into 4503-upstream-conf commit 75d85ed1f4d8d5060800b2f8a4cde662db02ae30 Author: Dimitry Kolyshev Date: Fri May 20 13:14:16 2022 +0200 all: upd dnsproxy commit 781768d639388a60fc90631f819cfc5dd90b9eba Author: Dimitry Kolyshev Date: Mon May 16 16:27:25 2022 +0200 all: docs commit 0dafb5b3fe11b1952d9a04294bcaaa8091b9c2a7 Author: Dimitry Kolyshev Date: Mon May 16 16:17:35 2022 +0200 all: docs commit 0d5463e4157132b0e6be78fd97eaf5a5cb8d1edc Merge: e2c86909 f289f4b1 Author: Dimitry Kolyshev Date: Mon May 16 16:01:40 2022 +0200 Merge remote-tracking branch 'origin/master' into 4503-upstream-conf # Conflicts: # go.mod # go.sum commit e2c869091b1386065076f44dbf9498a31c9d5451 Author: Dimitry Kolyshev Date: Mon May 16 15:29:17 2022 +0200 all: upd dnsrpoxy --- CHANGELOG.md | 2 ++ go.mod | 2 +- go.sum | 4 ++-- internal/dnsforward/http.go | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d183c45d..8aca8f15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to ### Added +- Support upstreams for subdomains of a domain only ([#4503]). - Support for Discovery of Designated Resolvers (DDR) according to the [RFC draft][ddr-draft-06] ([#4463]). - The ability to control each source of runtime clients separately via @@ -150,6 +151,7 @@ In this release, the schema version has changed from 12 to 14. [#4273]: https://github.com/AdguardTeam/AdGuardHome/issues/4273 [#4276]: https://github.com/AdguardTeam/AdGuardHome/issues/4276 [#4499]: https://github.com/AdguardTeam/AdGuardHome/issues/4499 +[#4503]: https://github.com/AdguardTeam/AdGuardHome/issues/4503 [#4533]: https://github.com/AdguardTeam/AdGuardHome/issues/4533 [#4542]: https://github.com/AdguardTeam/AdGuardHome/issues/4542 diff --git a/go.mod b/go.mod index 8da34653..4d9d2191 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/AdguardTeam/AdGuardHome go 1.17 require ( - github.com/AdguardTeam/dnsproxy v0.42.2 + github.com/AdguardTeam/dnsproxy v0.42.4 github.com/AdguardTeam/golibs v0.10.8 github.com/AdguardTeam/urlfilter v0.16.0 github.com/NYTimes/gziphandler v1.1.1 diff --git a/go.sum b/go.sum index 807a6849..73accb25 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,8 @@ 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.42.2 h1:aBhbuvqg/rZN8Rab5ILSfPFJDkiTviWXXcceJgajnNs= -github.com/AdguardTeam/dnsproxy v0.42.2/go.mod h1:thHuk3599mgmucsv5J9HR9lBVQHnf4YleE08EbxNrN0= +github.com/AdguardTeam/dnsproxy v0.42.4 h1:Rf45a3H6U/8XqWMYAMEsC1g/dVudyfgx4WY8N2syJMw= +github.com/AdguardTeam/dnsproxy v0.42.4/go.mod h1:thHuk3599mgmucsv5J9HR9lBVQHnf4YleE08EbxNrN0= 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.4/go.mod h1:rSfQRGHIdgfxriDDNgNJ7HmE5zRoURq8R+VdR81Zuzw= diff --git a/internal/dnsforward/http.go b/internal/dnsforward/http.go index 2b7cfd13..50ab9643 100644 --- a/internal/dnsforward/http.go +++ b/internal/dnsforward/http.go @@ -510,6 +510,7 @@ func separateUpstream(upstreamStr string) (upstream string, isDomainSpec bool, e continue } + host = strings.TrimPrefix(host, "*.") err = netutil.ValidateDomainName(host) if err != nil { return "", true, fmt.Errorf("domain at index %d: %w", i, err) From c0ac82be6a91cd4f5e43e7de6281d2854bbf63c2 Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Tue, 24 May 2022 14:43:54 +0300 Subject: [PATCH 07/79] Pull request: 4480 fix sysv service script Merge in DNS/adguard-home from 4480-sysv-boot to master Updates #4480. Squashed commit of the following: commit c9645b1f3bd22a249c666e4485818bab6769f32d Author: Eugene Burkov Date: Tue May 24 14:25:09 2022 +0300 home: imp sysv script commit cc323364ba6cce0284cbc6be9133a50a51b71f56 Author: Eugene Burkov Date: Mon May 23 21:13:06 2022 +0300 home: fix sysv service script --- CHANGELOG.md | 2 ++ internal/home/service.go | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8aca8f15..9d837c95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -128,6 +128,7 @@ In this release, the schema version has changed from 12 to 14. ### Fixed +- Service startup on boot on systems using SysV-init ([#4480]). - Detection of the stopped service status on macOS and Linux ([#4273]). - Case-sensitive ClientID ([#4542]). - Slow version update queries making other HTTP APIs unresponsible ([#4499]). @@ -150,6 +151,7 @@ In this release, the schema version has changed from 12 to 14. [#4238]: https://github.com/AdguardTeam/AdGuardHome/issues/4238 [#4273]: https://github.com/AdguardTeam/AdGuardHome/issues/4273 [#4276]: https://github.com/AdguardTeam/AdGuardHome/issues/4276 +[#4480]: https://github.com/AdguardTeam/AdGuardHome/issues/4480 [#4499]: https://github.com/AdguardTeam/AdGuardHome/issues/4499 [#4503]: https://github.com/AdguardTeam/AdGuardHome/issues/4503 [#4533]: https://github.com/AdguardTeam/AdGuardHome/issues/4533 diff --git a/internal/home/service.go b/internal/home/service.go index 70ab3c78..831a80d0 100644 --- a/internal/home/service.go +++ b/internal/home/service.go @@ -433,8 +433,11 @@ EnvironmentFile=-/etc/sysconfig/{{.Name}} WantedBy=multi-user.target ` -// Note: we should keep it in sync with the template from service_sysv_linux.go file -// Use "ps | grep -v grep | grep $(get_pid)" because "ps PID" may not work on OpenWrt +// sysvScript is the source of the daemon script for SysV-based Linux systems. +// Keep as close as possible to the https://github.com/kardianos/service/blob/29f8c79c511bc18422bb99992779f96e6bc33921/service_sysv_linux.go#L187. +// +// Use ps command instead of reading the procfs since it's a more +// implementation-independent approach. const sysvScript = `#!/bin/sh # For RedHat and cousins: # chkconfig: - 99 01 @@ -465,7 +468,7 @@ get_pid() { } is_running() { - [ -f "$pid_file" ] && ps | grep -v grep | grep $(get_pid) > /dev/null 2>&1 + [ -f "$pid_file" ] && ps -p "$(get_pid)" > /dev/null 2>&1 } case "$1" in From a82ec09afdfbc66a8f07614b77e825f527a3b35b Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Tue, 24 May 2022 19:47:09 +0300 Subject: [PATCH 08/79] Pull request: all: upd dnsproxy, supp rfc 9250 Updates #4592. Squashed commit of the following: commit 1a80875d6aa7811d7d1d978f6fa8d558dec1ca87 Author: Ainar Garipov Date: Tue May 24 19:28:27 2022 +0300 all: upd dnsproxy, supp rfc 9250 --- CHANGELOG.md | 10 ++++++---- go.mod | 4 ++-- go.sum | 14 ++++---------- internal/dnsforward/clientid.go | 12 ++++++------ internal/dnsforward/clientid_test.go | 25 +++++++++++++------------ 5 files changed, 31 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d837c95..e0c32ce7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to ### Added +- Support for the final DNS-over-QUIC standard, [RFC 9250][rfc-9250] ([#4592]). - Support upstreams for subdomains of a domain only ([#4503]). - Support for Discovery of Designated Resolvers (DDR) according to the [RFC draft][ddr-draft-06] ([#4463]). @@ -45,7 +46,7 @@ and this project adheres to instead of the `/bin/sh` one ([#4533]). To apply this change, backup your data and run `AdGuardHome -s uninstall && AdGuardHome -s install`. - The default DNS-over-QUIC port number is now `853` instead of `754` in - accordance with the latest [RFC draft][doq-draft-10] ([#4276]). + accordance with [RFC 9250][rfc-9250] ([#4276]). - Reverse DNS now has a greater priority as the source of runtime clients' information than ARP neighborhood. - Improved detection of runtime clients through more resilient ARP processing @@ -100,7 +101,7 @@ In this release, the schema version has changed from 12 to 14. `dns.resolve_clients` property. To rollback this change, remove the `runtime_sources` property, move the contents of `persistent` into the `clients` itself, the value of `clients.runtime_sources.rdns` into the - `dns.resolve_clietns`, and change the `schema_version` back to `13`. + `dns.resolve_clients`, and change the `schema_version` back to `13`. - Property `local_domain_name`, which in schema versions 12 and earlier used to be a part of the `dns` object, is now a part of the `dhcp` object: @@ -131,7 +132,7 @@ In this release, the schema version has changed from 12 to 14. - Service startup on boot on systems using SysV-init ([#4480]). - Detection of the stopped service status on macOS and Linux ([#4273]). - Case-sensitive ClientID ([#4542]). -- Slow version update queries making other HTTP APIs unresponsible ([#4499]). +- Slow version update queries making other HTTP APIs unresponsive ([#4499]). - ARP tables refreshing process causing excessive PTR requests ([#3157]). [#1730]: https://github.com/AdguardTeam/AdGuardHome/issues/1730 @@ -156,9 +157,10 @@ In this release, the schema version has changed from 12 to 14. [#4503]: https://github.com/AdguardTeam/AdGuardHome/issues/4503 [#4533]: https://github.com/AdguardTeam/AdGuardHome/issues/4533 [#4542]: https://github.com/AdguardTeam/AdGuardHome/issues/4542 +[#4592]: https://github.com/AdguardTeam/AdGuardHome/issues/4592 +[rfc-9250]: https://datatracker.ietf.org/doc/html/rfc9250 [ddr-draft-06]: https://www.ietf.org/archive/id/draft-ietf-add-ddr-06.html -[doq-draft-10]: https://datatracker.ietf.org/doc/html/draft-ietf-dprive-dnsoquic-10#section-10.2 [repr]: https://reproducible-builds.org/docs/source-date-epoch/ diff --git a/go.mod b/go.mod index 4d9d2191..d3c3e1de 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/AdguardTeam/AdGuardHome go 1.17 require ( - github.com/AdguardTeam/dnsproxy v0.42.4 + github.com/AdguardTeam/dnsproxy v0.43.0 github.com/AdguardTeam/golibs v0.10.8 github.com/AdguardTeam/urlfilter v0.16.0 github.com/NYTimes/gziphandler v1.1.1 @@ -17,7 +17,7 @@ require ( github.com/google/renameio v1.0.1 github.com/insomniacslk/dhcp v0.0.0-20220405050111-12fbdcb11b41 github.com/kardianos/service v1.2.1 - github.com/lucas-clemente/quic-go v0.26.0 + github.com/lucas-clemente/quic-go v0.27.1 github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118 github.com/mdlayher/netlink v1.6.0 // TODO(a.garipov): This package is deprecated; find a new one or use diff --git a/go.sum b/go.sum index 73accb25..ae65fdab 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,8 @@ 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.42.4 h1:Rf45a3H6U/8XqWMYAMEsC1g/dVudyfgx4WY8N2syJMw= -github.com/AdguardTeam/dnsproxy v0.42.4/go.mod h1:thHuk3599mgmucsv5J9HR9lBVQHnf4YleE08EbxNrN0= +github.com/AdguardTeam/dnsproxy v0.43.0 h1:K082nx37DaNqSyT3kDtAfgBACNWc+ZDI1Yr/kGppu1k= +github.com/AdguardTeam/dnsproxy v0.43.0/go.mod h1:JUGTm5dmlll47JltztsT0N//pVJjdg6zu0SNeUeaA7g= 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.4/go.mod h1:rSfQRGHIdgfxriDDNgNJ7HmE5zRoURq8R+VdR81Zuzw= @@ -143,21 +143,15 @@ github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/lucas-clemente/quic-go v0.25.0/go.mod h1:YtzP8bxRVCBlO77yRanE264+fY/T2U9ZlW1AaHOsMOg= -github.com/lucas-clemente/quic-go v0.26.0 h1:ALBQXr9UJ8A1LyzvceX4jd9QFsHvlI0RR6BkV16o00A= -github.com/lucas-clemente/quic-go v0.26.0/go.mod h1:AzgQoPda7N+3IqMMMkywBKggIFo2KT6pfnlrQ2QieeI= +github.com/lucas-clemente/quic-go v0.27.1 h1:sOw+4kFSVrdWOYmUjufQ9GBVPqZ+tu+jMtXxXNmRJyk= +github.com/lucas-clemente/quic-go v0.27.1/go.mod h1:AzgQoPda7N+3IqMMMkywBKggIFo2KT6pfnlrQ2QieeI= github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/marten-seemann/qpack v0.2.1/go.mod h1:F7Gl5L1jIgN1D11ucXefiuJS9UMVP2opoCp2jDKb7wc= -github.com/marten-seemann/qtls-go1-15 v0.1.4/go.mod h1:GyFwywLKkRt+6mfU99csTEY1joMZz5vmB1WNZH3P81I= -github.com/marten-seemann/qtls-go1-16 v0.1.4/go.mod h1:gNpI2Ol+lRS3WwSOtIUUtRwZEQMXjYK+dQSBFbethAk= github.com/marten-seemann/qtls-go1-16 v0.1.5 h1:o9JrYPPco/Nukd/HpOHMHZoBDXQqoNtUCmny98/1uqQ= github.com/marten-seemann/qtls-go1-16 v0.1.5/go.mod h1:gNpI2Ol+lRS3WwSOtIUUtRwZEQMXjYK+dQSBFbethAk= -github.com/marten-seemann/qtls-go1-17 v0.1.0/go.mod h1:fz4HIxByo+LlWcreM4CZOYNuz3taBQ8rN2X6FqvaWo8= github.com/marten-seemann/qtls-go1-17 v0.1.1 h1:DQjHPq+aOzUeh9/lixAGunn6rIOQyWChPSI4+hgW7jc= github.com/marten-seemann/qtls-go1-17 v0.1.1/go.mod h1:C2ekUKcDdz9SDWxec1N/MvcXBpaX9l3Nx67XaR84L5s= -github.com/marten-seemann/qtls-go1-18 v0.1.0-beta.1/go.mod h1:PUhIQk19LoFt2174H4+an8TYvWOGjb/hHwphBeaDHwI= -github.com/marten-seemann/qtls-go1-18 v0.1.0/go.mod h1:PUhIQk19LoFt2174H4+an8TYvWOGjb/hHwphBeaDHwI= github.com/marten-seemann/qtls-go1-18 v0.1.1 h1:qp7p7XXUFL7fpBvSS1sWD+uSqPvzNQK43DH+/qEkj0Y= github.com/marten-seemann/qtls-go1-18 v0.1.1/go.mod h1:mJttiymBAByA49mhlNZZGrH5u1uXYZJ+RW28Py7f4m4= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= diff --git a/internal/dnsforward/clientid.go b/internal/dnsforward/clientid.go index bb687a41..16bac881 100644 --- a/internal/dnsforward/clientid.go +++ b/internal/dnsforward/clientid.go @@ -112,8 +112,8 @@ type tlsConn interface { ConnectionState() (cs tls.ConnectionState) } -// quicSession is a narrow interface for quic.Session to simplify testing. -type quicSession interface { +// quicConnection is a narrow interface for quic.Connection to simplify testing. +type quicConnection interface { ConnectionState() (cs quic.ConnectionState) } @@ -148,16 +148,16 @@ func (s *Server) clientIDFromDNSContext(pctx *proxy.DNSContext) (clientID string cliSrvName = tc.ConnectionState().ServerName case proxy.ProtoQUIC: - qs, ok := pctx.QUICSession.(quicSession) + conn, ok := pctx.QUICConnection.(quicConnection) if !ok { return "", fmt.Errorf( - "proxy ctx quic session of proto %s is %T, want quic.Session", + "proxy ctx quic conn of proto %s is %T, want quic.Connection", proto, - pctx.QUICSession, + pctx.QUICConnection, ) } - cliSrvName = qs.ConnectionState().TLS.ServerName + cliSrvName = conn.ConnectionState().TLS.ServerName } clientID, err = clientIDFromClientServerName( diff --git a/internal/dnsforward/clientid_test.go b/internal/dnsforward/clientid_test.go index 6e23d639..31c55fcd 100644 --- a/internal/dnsforward/clientid_test.go +++ b/internal/dnsforward/clientid_test.go @@ -29,17 +29,18 @@ func (c testTLSConn) ConnectionState() (cs tls.ConnectionState) { return cs } -// testQUICSession is a quicSession for tests. -type testQUICSession struct { - // Session is embedded here simply to make testQUICSession a quic.Session - // without actually implementing all methods. - quic.Session +// testQUICConnection is a quicConnection for tests. +type testQUICConnection struct { + // Connection is embedded here simply to make testQUICConnection a + // quic.Connection without actually implementing all methods. + quic.Connection serverName string } -// ConnectionState implements the quicSession interface for testQUICSession. -func (c testQUICSession) ConnectionState() (cs quic.ConnectionState) { +// ConnectionState implements the quicConnection interface for +// testQUICConnection. +func (c testQUICConnection) ConnectionState() (cs quic.ConnectionState) { cs.TLS.ServerName = c.serverName return cs @@ -179,17 +180,17 @@ func TestServer_clientIDFromDNSContext(t *testing.T) { } } - var qs quic.Session + var qconn quic.Connection if tc.proto == proxy.ProtoQUIC { - qs = testQUICSession{ + qconn = testQUICConnection{ serverName: tc.cliSrvName, } } pctx := &proxy.DNSContext{ - Proto: tc.proto, - Conn: conn, - QUICSession: qs, + Proto: tc.proto, + Conn: conn, + QUICConnection: qconn, } clientID, err := srv.clientIDFromDNSContext(pctx) From 75f01d51f7312601cd323bdbdd4648dfd673ea75 Mon Sep 17 00:00:00 2001 From: Dimitry Kolyshev Date: Wed, 25 May 2022 14:31:32 +0300 Subject: [PATCH 09/79] Pull request: all: filters json Merge in DNS/adguard-home from 4581-filters-json to master Squashed commit of the following: commit da0b86983432ac1791645da328df5848daac5ea6 Merge: 62fa4fc6 a82ec09a Author: Dimitry Kolyshev Date: Wed May 25 12:58:25 2022 +0200 Merge remote-tracking branch 'origin/master' into 4581-filters-json commit 62fa4fc6ff150ebb8dbd8888a58819fb644d43ad Author: Dimitry Kolyshev Date: Wed May 25 11:55:52 2022 +0200 all: filters json commit 96486ffbb41947b5e748f6e35eb96ee73867eba1 Merge: 9956f0af c0ac82be Author: Dimitry Kolyshev Date: Tue May 24 15:57:52 2022 +0200 Merge branch 'master' into 4581-filters-json commit 9956f0aff1b7029f336d22013a62f2871a964322 Author: Dimitry Kolyshev Date: Tue May 24 15:53:43 2022 +0200 all: filters json --- client/src/helpers/filters/filters.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/helpers/filters/filters.json b/client/src/helpers/filters/filters.json index 565cd74d..63fe0995 100644 --- a/client/src/helpers/filters/filters.json +++ b/client/src/helpers/filters/filters.json @@ -81,8 +81,8 @@ "urlhaus-filter-online": { "name": "Online Malicious URL Blocklist", "categoryId": "security", - "homepage": "https://gitlab.com/curben/urlhaus-filter", - "source": "https://curben.gitlab.io/malware-filter/urlhaus-filter-agh-online.txt" + "homepage": "https://gitlab.com/malware-filter/urlhaus-filter", + "source": "https://malware-filter.gitlab.io/malware-filter/urlhaus-filter-agh-online.txt" }, "dandelion-sprouts-anti-malware-list": { "name": "Dandelion Sprout's Anti-Malware List", From 549b20bdea3c3215bb355ffc39546f7bb3260d80 Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Wed, 25 May 2022 18:00:50 +0300 Subject: [PATCH 10/79] Pull request: querylog: fix oldest calc Updates #4591. Squashed commit of the following: commit 70b70c78c85311363535536c7ea12336b21accf8 Author: Ainar Garipov Date: Wed May 25 17:35:54 2022 +0300 querylog: fix oldest calc --- CHANGELOG.md | 2 ++ internal/dnsforward/stats.go | 2 +- internal/home/dns.go | 2 +- internal/querylog/http.go | 2 +- internal/querylog/qlog.go | 2 +- internal/querylog/qlog_test.go | 2 +- internal/querylog/querylog.go | 18 +++++++++--------- internal/querylog/search.go | 17 ++++++++++++----- 8 files changed, 28 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0c32ce7..4a72447c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -129,6 +129,7 @@ In this release, the schema version has changed from 12 to 14. ### Fixed +- Query log occasionally going into an infinite loop ([#4591]). - Service startup on boot on systems using SysV-init ([#4480]). - Detection of the stopped service status on macOS and Linux ([#4273]). - Case-sensitive ClientID ([#4542]). @@ -157,6 +158,7 @@ In this release, the schema version has changed from 12 to 14. [#4503]: https://github.com/AdguardTeam/AdGuardHome/issues/4503 [#4533]: https://github.com/AdguardTeam/AdGuardHome/issues/4533 [#4542]: https://github.com/AdguardTeam/AdGuardHome/issues/4542 +[#4591]: https://github.com/AdguardTeam/AdGuardHome/issues/4591 [#4592]: https://github.com/AdguardTeam/AdGuardHome/issues/4592 [rfc-9250]: https://datatracker.ietf.org/doc/html/rfc9250 diff --git a/internal/dnsforward/stats.go b/internal/dnsforward/stats.go index 56cc19c5..9a7b1ddb 100644 --- a/internal/dnsforward/stats.go +++ b/internal/dnsforward/stats.go @@ -64,9 +64,9 @@ func (s *Server) logQuery( Answer: pctx.Res, OrigAnswer: dctx.origResp, Result: dctx.result, - Elapsed: elapsed, ClientID: dctx.clientID, ClientIP: ip, + Elapsed: elapsed, AuthenticatedData: dctx.responseAD, } diff --git a/internal/home/dns.go b/internal/home/dns.go index 1c04c6c3..9eabfefa 100644 --- a/internal/home/dns.go +++ b/internal/home/dns.go @@ -58,6 +58,7 @@ func initDNSServer() (err error) { } conf := querylog.Config{ + Anonymizer: anonymizer, ConfigModified: onConfigModified, HTTPRegister: httpRegister, FindClient: Context.clients.findMultiple, @@ -67,7 +68,6 @@ func initDNSServer() (err error) { Enabled: config.DNS.QueryLogEnabled, FileEnabled: config.DNS.QueryLogFileEnabled, AnonymizeClientIP: config.DNS.AnonymizeClientIP, - Anonymizer: anonymizer, } Context.queryLog = querylog.New(conf) diff --git a/internal/querylog/http.go b/internal/querylog/http.go index 6a2bdcee..11f62d0d 100644 --- a/internal/querylog/http.go +++ b/internal/querylog/http.go @@ -19,10 +19,10 @@ import ( ) type qlogConfig struct { - Enabled bool `json:"enabled"` // Use float64 here to support fractional numbers and not mess the API // users by changing the units. Interval float64 `json:"interval"` + Enabled bool `json:"enabled"` AnonymizeClientIP bool `json:"anonymize_client_ip"` } diff --git a/internal/querylog/qlog.go b/internal/querylog/qlog.go index 8856fd9c..24eec40e 100644 --- a/internal/querylog/qlog.go +++ b/internal/querylog/qlog.go @@ -149,7 +149,7 @@ func (l *queryLog) clear() { log.Error("removing log file %q: %s", l.logFile, err) } - log.Debug("Query log: cleared") + log.Debug("querylog: cleared") } func (l *queryLog) Add(params *AddParams) { diff --git a/internal/querylog/qlog_test.go b/internal/querylog/qlog_test.go index fbfc459d..6beed1be 100644 --- a/internal/querylog/qlog_test.go +++ b/internal/querylog/qlog_test.go @@ -285,8 +285,8 @@ func addEntry(l *queryLog, host string, answerStr, client net.IP) { Answer: &a, OrigAnswer: &a, Result: &res, - ClientIP: client, Upstream: "upstream", + ClientIP: client, } l.Add(params) diff --git a/internal/querylog/querylog.go b/internal/querylog/querylog.go index bd6e1569..a854c2c4 100644 --- a/internal/querylog/querylog.go +++ b/internal/querylog/querylog.go @@ -28,8 +28,11 @@ type QueryLog interface { WriteDiskConfig(c *Config) } -// Config - configuration object +// Config is the query log configuration structure. type Config struct { + // Anonymizer processes the IP addresses to anonymize those if needed. + Anonymizer *aghnet.IPMut + // ConfigModified is called when the configuration is changed, for // example by HTTP requests. ConfigModified func() @@ -68,9 +71,6 @@ type Config struct { // AnonymizeClientIP tells if the query log should anonymize clients' IP // addresses. AnonymizeClientIP bool - - // Anonymizer processes the IP addresses to anonymize those if needed. - Anonymizer *aghnet.IPMut } // AddParams is the parameters for adding an entry. @@ -91,18 +91,18 @@ type AddParams struct { // Result is the filtering result (optional). Result *filtering.Result - // Elapsed is the time spent for processing the request. - Elapsed time.Duration - ClientID string - ClientIP net.IP - // Upstream is the URL of the upstream DNS server. Upstream string ClientProto ClientProto + ClientIP net.IP + + // Elapsed is the time spent for processing the request. + Elapsed time.Duration + // Cached indicates if the response is served from cache. Cached bool diff --git a/internal/querylog/search.go b/internal/querylog/search.go index 4a3de979..8fb32e60 100644 --- a/internal/querylog/search.go +++ b/internal/querylog/search.go @@ -73,7 +73,7 @@ func (l *queryLog) searchMemory(params *searchParams, cache clientCache) (entrie // search - searches log entries in the query log using specified parameters // returns the list of entries found + time of the oldest entry -func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) { +func (l *queryLog) search(params *searchParams) (entries []*logEntry, oldest time.Time) { now := time.Now() if params.limit == 0 { @@ -88,7 +88,7 @@ func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) { totalLimit := params.offset + params.limit // now let's get a unified collection - entries := append(memoryEntries, fileEntries...) + entries = append(memoryEntries, fileEntries...) if len(entries) > totalLimit { // remove extra records entries = entries[:totalLimit] @@ -111,13 +111,18 @@ func (l *queryLog) search(params *searchParams) ([]*logEntry, time.Time) { } } - if len(entries) > 0 && len(entries) <= totalLimit { + if len(entries) > 0 { // Update oldest after merging in the memory buffer. oldest = entries[len(entries)-1].Time } - log.Debug("QueryLog: prepared data (%d/%d) older than %s in %s", - len(entries), total, params.olderThan, time.Since(now)) + log.Debug( + "querylog: prepared data (%d/%d) older than %s in %s", + len(entries), + total, + params.olderThan, + time.Since(now), + ) return entries, oldest } @@ -180,6 +185,8 @@ func (l *queryLog) searchFiles( e, ts, err = l.readNextEntry(r, params, cache) if err != nil { if err == io.EOF { + oldestNano = 0 + break } From 1a49d2f0c9eff0e084de83598e5e5825125d5905 Mon Sep 17 00:00:00 2001 From: Ildar Kamalov Date: Thu, 26 May 2022 12:49:13 +0300 Subject: [PATCH 11/79] Pull request: client: reset filtered logs on url params clear Merge in DNS/adguard-home from fix-querylog-link to master Squashed commit of the following: commit fc4043258eb1e427a76ee44d2a4a525a6d659ab9 Merge: 25b91504 549b20bd Author: Ildar Kamalov Date: Thu May 26 12:42:02 2022 +0300 Merge branch 'master' into fix-querylog-link commit 25b91504e8949bd381e6774148e4a7ecbb81610e Author: Ildar Kamalov Date: Thu May 26 12:21:57 2022 +0300 fix commit f567b9b1e4eeb6499c79b05e4d837e905850a6b9 Author: Ildar Kamalov Date: Thu May 26 12:20:48 2022 +0300 client: reset filtered logs on url params clear --- client/src/components/Logs/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client/src/components/Logs/index.js b/client/src/components/Logs/index.js index c3b30703..3e89c3b1 100644 --- a/client/src/components/Logs/index.js +++ b/client/src/components/Logs/index.js @@ -152,6 +152,16 @@ const Logs = () => { }; }, []); + useEffect(() => { + if (!history.location.search) { + (async () => { + setIsLoading(true); + await dispatch(setFilteredLogs()); + setIsLoading(false); + })(); + } + }, [history.location.search]); + const renderPage = () => <> Date: Thu, 26 May 2022 14:20:36 +0300 Subject: [PATCH 12/79] Pull request: client: upd i18n Merge in DNS/adguard-home from upd-i18n to master Squashed commit of the following: commit 7ddd8cb01f8136ad4690a439ee3b810043af749e Author: Ainar Garipov Date: Thu May 26 14:10:31 2022 +0300 client: upd i18n --- client/src/__locales/cs.json | 2 +- client/src/__locales/fi.json | 4 +-- client/src/__locales/pt-br.json | 2 +- client/src/__locales/pt-pt.json | 2 +- client/src/__locales/sl.json | 4 +-- client/src/__locales/tr.json | 12 ++++---- client/src/__locales/uk.json | 50 ++++++++++++++++----------------- client/src/__locales/zh-cn.json | 1 + 8 files changed, 39 insertions(+), 38 deletions(-) diff --git a/client/src/__locales/cs.json b/client/src/__locales/cs.json index 8331dd50..8467df91 100644 --- a/client/src/__locales/cs.json +++ b/client/src/__locales/cs.json @@ -85,7 +85,7 @@ "form_enter_hostname": "Zadejte název hostitele", "error_details": "Podrobnosti chyby", "response_details": "Detail odpovědi", - "request_details": "Detail požadavku", + "request_details": "Detaily požadavku", "client_details": "Detaily klienta", "details": "Detaily", "back": "Zpět", diff --git a/client/src/__locales/fi.json b/client/src/__locales/fi.json index 3141b12a..a5f3fa01 100644 --- a/client/src/__locales/fi.json +++ b/client/src/__locales/fi.json @@ -9,7 +9,7 @@ "bootstrap_dns": "Bootstrap DNS-palvelimet", "bootstrap_dns_desc": "Bootstrap DNS-palvelimia käytetään ylävirroiksi määritettyjen DoH/DoT-resolvereiden IP-osoitteiden selvitykseen.", "local_ptr_title": "Yksityiset käänteiset DNS-palvelimet", - "local_ptr_desc": "DNS-palvelimet, joita AdGuard Home käyttää paikallisille PTR-pyynnöille. Näitä palvelimia käytetään yksityistä IP-osoitetta käyttävien päätelaitteiden osoitteiden, kuten \"192.168.12.34\", selvitykseen käänteisen DNS:n avulla. Jos ei käytössä, käyttää AdGuard Home käyttöjärjestelmän oletusarvoisia DNS-resolvereita, poislukien AdGuard Homen omat osoitteet.", + "local_ptr_desc": "DNS-palvelimet, joita AdGuard Home käyttää paikallisille PTR-kyselyille. Näitä palvelimia käytetään yksityistä IP-osoitetta käyttävien PTR-kyselyiden osoitteiden, kuten \"192.168.12.34\", selvitykseen käänteisen DNS:n avulla. Jos ei käytössä, AdGuard Home käyttää käyttöjärjestelmän oletusarvoisia DNS-resolvereita, poislukien AdGuard Homen omat osoitteet.", "local_ptr_default_resolver": "Oletusarvoisesti AdGuard Home käyttää seuraavia käänteisiä DNS-resolvereita: {{ip}}.", "local_ptr_no_default_resolver": "AdGuard Home ei voinut määrittää tälle järjestelmälle sopivaa yksityistä käänteistä DNS-resolveria.", "local_ptr_placeholder": "Syötä yksi palvelimen osoite per rivi", @@ -351,7 +351,7 @@ "install_devices_android_list_5": "Syötä \"DNS 1\" ja \"DNS 2\" -kenttiin AdGuard Home -palvelimesi osoitteet.", "install_devices_ios_list_1": "Napauta aloitusnäytöstä \"Asetukset\".", "install_devices_ios_list_2": "Valitse vasemmalta \"Wi-Fi\" (mobiiliverkolle ei ole mahdollista määrittää omaa DNS-palvelinta).", - "install_devices_ios_list_3": "Valitse yhdistetty verkko.", + "install_devices_ios_list_3": "Valitse tällä hetkellä aktiivinen verkko.", "install_devices_ios_list_4": "Syötä \"DNS\" -kenttään AdGuard Home -palvelimesi osoitteet.", "get_started": "Aloita", "next": "Seuraava", diff --git a/client/src/__locales/pt-br.json b/client/src/__locales/pt-br.json index 48d82e0d..d52d6961 100644 --- a/client/src/__locales/pt-br.json +++ b/client/src/__locales/pt-br.json @@ -9,7 +9,7 @@ "bootstrap_dns": "Servidores DNS de inicialização", "bootstrap_dns_desc": "Servidores DNS de inicialização são usados para resolver endereços IP dos resolvedores DoH/DoT que você especifica como upstreams.", "local_ptr_title": "Servidores DNS reversos privados", - "local_ptr_desc": "Os servidores DNS que o AdGuard Home usa para consultas PTR locais. Esses servidores são usados para resolver os nomes de host de clientes com endereços IP privados, por exemplo \"192.168.12.34\", usando DNS reverso. Se não for definido, o AdGuard Home usa os endereços dos resolvedores DNS padrão do seu sistema operacional, exceto os endereços do AdGuard Home.", + "local_ptr_desc": "Os servidores DNS que o AdGuard Home usa para consultas PTR locais. Esses servidores são usados para resolver solicitações de PTR para endereços em intervalos de IP privados, por exemplo \"192.168.12.34\", usando DNS reverso. Se não estiver definido, o AdGuard Home usa os endereços dos resolvedores de DNS padrão do seu sistema operacional, exceto os endereços do próprio AdGuard Home.", "local_ptr_default_resolver": "Por padrão, o AdGuard Home usa os seguintes resolvedores de DNS reverso: {{ip}}.", "local_ptr_no_default_resolver": "A página inicial do AdGuard não conseguiu determinar resolvedores DNS reversos privados adequados para este sistema.", "local_ptr_placeholder": "Insira um endereço de servidor por linha", diff --git a/client/src/__locales/pt-pt.json b/client/src/__locales/pt-pt.json index 1a2d5c7c..6502f9f9 100644 --- a/client/src/__locales/pt-pt.json +++ b/client/src/__locales/pt-pt.json @@ -9,7 +9,7 @@ "bootstrap_dns": "Servidores DNS de arranque", "bootstrap_dns_desc": "Servidores DNS de inicialização são usados para resolver endereços IP dos resolvedores DoH/DoT que especifica como upstreams.", "local_ptr_title": "Servidores DNS reversos privados", - "local_ptr_desc": "Os servidores DNS que o AdGuard Home usa para consultas PTR locais. Esses servidores são usados para resolver os nomes de host de clientes com endereços IP privados, por exemplo \"192.168.12.34\", usando DNS reverso. Se não for definido, o AdGuard Home usa os endereços dos resolvedores DNS padrão do seu sistema operacional, exceto os endereços do AdGuard Home.", + "local_ptr_desc": "Os servidores DNS que o AdGuard Home usa para consultas PTR locais. Esses servidores são usados para resolver solicitações de PTR para endereços em intervalos de IP privados, por exemplo \"192.168.12.34\", usando DNS reverso. Se não estiver definido, o AdGuard Home usa os endereços dos resolvedores de DNS padrão do seu sistema operacional, exceto os endereços do próprio AdGuard Home.", "local_ptr_default_resolver": "Por predefinição, o AdGuard Home usa os seguintes resolvedores de DNS reverso: {{ip}}.", "local_ptr_no_default_resolver": "A página inicial do AdGuard não conseguiu determinar resolvedores DNS reversos privados adequados para este sistema.", "local_ptr_placeholder": "Insira um endereço de servidor por linha", diff --git a/client/src/__locales/sl.json b/client/src/__locales/sl.json index 8dffefc7..80dfd9aa 100644 --- a/client/src/__locales/sl.json +++ b/client/src/__locales/sl.json @@ -9,7 +9,7 @@ "bootstrap_dns": "Zagonski DNS strežniki", "bootstrap_dns_desc": "Zagonski DNS strežniki se uporabljajo za razreševanje IP naslovov DoH/DoT reševalcev, ki jih določite kot navzgornje.", "local_ptr_title": "Zasebni povratni strežniki DNS", - "local_ptr_desc": "Strežniki DNS, ki jih AdGuard Home uporablja za lokalne poizvedbe PTR. Ti strežniki se uporabljajo za razreševanje imen gostiteljev z zasebnimi naslovi IP, na primer \"192.168.12.34\" uporablja DNS. Če ni nastavljen, uporablja naslove privzetih razreševalnikov DNS vašega OS, razen naslovov samega AdGuard Home.", + "local_ptr_desc": "Strežniki DNS, ki jih AdGuard Home uporablja za lokalne PTR poizvedbe. Ti strežniki se uporabljajo za reševanje zahtev PTR za naslove v zasebnih obsegih IP, na primer \"192.168.12.34\", z uporabo obratnega DNS. Če ni nastavljen, AdGuard Home uporablja naslove privzetih razreševalnikov DNS vašega OS, razen naslovov samega AdGuard Home.", "local_ptr_default_resolver": "AdGuard Home privzeto uporablja te povratne razreševalnike DNS: {{ip}}.", "local_ptr_no_default_resolver": "AdGuard Home ni mogel določiti ustreznih zasebnih povratnih reševalcev DNS za ta sistem.", "local_ptr_placeholder": "V vrstico vnesite en naslov strežnika", @@ -351,7 +351,7 @@ "install_devices_android_list_5": "Spremeni nastavitev vrednosti DNS 1 in DNS 2 na naslove strežnikov AdGuard Home.", "install_devices_ios_list_1": "Na začetnem zaslonu izberite Nastavitve.", "install_devices_ios_list_2": "V levem meniju izberite Wi-Fi (nemogoče je konfigurirati DNS za mobilna omrežja).", - "install_devices_ios_list_3": "Dotaknite se imena trenutno aktivnega omrežja.", + "install_devices_ios_list_3": "Tapnite na ime trenutno aktivnega omrežja.", "install_devices_ios_list_4": "V polje DNS vnesite vaše naslove AdGuard Home strežnika.", "get_started": "Začnimo", "next": "Naprej", diff --git a/client/src/__locales/tr.json b/client/src/__locales/tr.json index f26e0011..6fd679ac 100644 --- a/client/src/__locales/tr.json +++ b/client/src/__locales/tr.json @@ -336,16 +336,16 @@ "install_devices_router_list_4": "Bazı yönlendirici türlerinde özel bir DNS sunucusu ayarlanamaz. Bu durumda, AdGuard Home'u <0>DHCP sunucusu olarak ayarlamak yardımcı olabilir. Aksi takdirde, yönlendirici modeliniz için DNS sunucularını nasıl ayarlayacağınız konusunda yönlendirici kılavuzuna bakmalısınız.", "install_devices_windows_list_1": "Başlat menüsünden veya Windows araması aracılığıyla Denetim Masası'nı açın.", "install_devices_windows_list_2": "Ağ ve İnternet kategorisine girin ve ardından Ağ ve Paylaşım Merkezi'ne girin.", - "install_devices_windows_list_3": "Sol panelde \"Bağdaştırıcı ayarlarını değiştirin'e\" tıklayın.", + "install_devices_windows_list_3": "Sol panelde \"Bağdaştırıcı ayarlarını değiştirin\" öğesine tıklayın.", "install_devices_windows_list_4": "Kullandığınız aktif bağlantının üzerine sağ tıklayın ve Özellikler öğesine tıklayın.", - "install_devices_windows_list_5": "Listede \"İnternet Protokolü Sürüm 4 (TCP/IPv4)\" (veya IPv6 için \"İnternet Protokolü Sürüm 6 (TCP/IPv6)\") öğesini bulun, seçin ve ardından tekrar Özellikler'e tıklayın.", + "install_devices_windows_list_5": "Listede \"İnternet Protokolü Sürüm 4 (TCP/IPv4)\" (veya IPv6 için \"İnternet Protokolü Sürüm 6 (TCP/IPv6)\") öğesini bulun, seçin ve ardından tekrar Özellikler öğesine tıklayın.", "install_devices_windows_list_6": "\"Aşağıdaki DNS sunucu adreslerini kullan\"ı seçin ve AdGuard Home sunucu adreslerinizi girin.", - "install_devices_macos_list_1": "Apple simgesine tıklayın ve Sistem Tercihleri'ne gidin.", - "install_devices_macos_list_2": "Ağ'a tıklayın.", + "install_devices_macos_list_1": "Apple simgesine tıklayın ve Sistem Tercihleri öğesine gidin.", + "install_devices_macos_list_2": "Ağ öğesine tıklayın.", "install_devices_macos_list_3": "Listedeki ilk bağlantıyı seçin ve Gelişmiş öğesine tıklayın.", "install_devices_macos_list_4": "DNS sekmesini seçin ve AdGuard Home sunucunuzun adreslerini girin.", "install_devices_android_list_1": "Android Menüsü ana ekranından Ayarlar'a dokunun.", - "install_devices_android_list_2": "Menüde bulunan Wi-Fi seçeneğine dokunun. Mevcut tüm ağlar listelenecektir (mobil ağlar için özel DNS sunucusu ayarlanamaz).", + "install_devices_android_list_2": "Menüde bulunan Wi-Fi öğesine dokunun. Mevcut tüm ağlar listelenecektir (mobil ağlar için özel DNS sunucusu ayarlanamaz).", "install_devices_android_list_3": "Bağlı olduğunuz ağın üzerine basılı tutun ve Ağı Değiştir'e dokunun.", "install_devices_android_list_4": "Bazı cihazlarda, diğer ayarları görmek için \"Gelişmiş\" seçeneğini seçmeniz gerekebilir. Android DNS ayarlarınızı yapmak için IP ayarlarını DHCP modundan Statik moda almanız gerekecektir.", "install_devices_android_list_5": "DNS 1 ve DNS 2 değerlerini AdGuard Home sunucunuzun adresleriyle değiştirin.", @@ -453,7 +453,7 @@ "setup_dns_privacy_2": "<0>DNS-over-HTTPS: <1>{{address}} dizesini kullan.", "setup_dns_privacy_3": "<0>İşte, kullanabileceğiniz yazılımların bir listesi.", "setup_dns_privacy_4": "Bir iOS 14 veya macOS Big Sur cihazında, DNS ayarlarına DNS-over-HTTPS veya DNS-over-TLS sunucuları ekleyen özel '.mobileconfig' dosyasını indirebilirsiniz.", - "setup_dns_privacy_android_1": "Android 9, yerel olarak DNS-over-TLS protokolünü destekler. Yapılandırmak için Ayarlar → Ağ ve İnternet → Gelişmiş → Özel DNS seçeneğine gidin ve alan adınızı girin.", + "setup_dns_privacy_android_1": "Android 9, yerel olarak DNS-over-TLS protokolünü destekler. Yapılandırmak için Ayarlar → Ağ ve İnternet → Gelişmiş → Özel DNS öğesine gidin ve alan adınızı girin.", "setup_dns_privacy_android_2": "<0>Android için AdGuard, <1>DNS-over-HTTPS ve <1>DNS-over-TLS protokolünü destekler.", "setup_dns_privacy_android_3": "<0>Intra Android'e <1>DNS-over-HTTPS protokol desteğini ekler.", "setup_dns_privacy_ios_1": "<0>DNSCloak, <1>DNS-over-HTTPS protokolünü destekler, ancak kendi sunucunuzu kullanacak şekilde yapılandırmak için bir <2>DNS Damgası oluşturmanız gerekir.", diff --git a/client/src/__locales/uk.json b/client/src/__locales/uk.json index 9fcbd460..84a6974e 100644 --- a/client/src/__locales/uk.json +++ b/client/src/__locales/uk.json @@ -7,16 +7,16 @@ "load_balancing": "Балансування навантаження", "load_balancing_desc": "Запитувати один сервер за раз. AdGuard Home використовуватиме зважений випадковий алгоритм для вибору сервера, щоб найшвидший сервер використовувався частіше.", "bootstrap_dns": "Bootstrap DNS-сервери", - "bootstrap_dns_desc": "Bootstrap DNS-сервери використовуються для пошуку IP-адреси DoH/DoT серверів, які ви встановили.", + "bootstrap_dns_desc": "Bootstrap DNS-сервери використовуються для вирішення IP-адрес встановлених серверів DoH/DoT.", "local_ptr_title": "Приватні сервери для зворотного DNS", - "local_ptr_desc": "DNS-сервери, які AdGuard Home використовує для локальних PTR-запитів. Ці сервери, використовуючи rDNS, використовуються для отримання доменних імен клієнтів у приватних мережах, наприклад, «192.168.12.34». Якщо список порожній, буде використовуватись системний DNS-сервер.", - "local_ptr_default_resolver": "AdGuard Home усталено використовує такі зворотні DNS-резолвери: {{ip}}.", - "local_ptr_no_default_resolver": "AdGuard Home не зміг визначити приватні реверсивні DNS-резолвери, що були б придатними для цієї системи.", + "local_ptr_desc": "DNS-сервери, які AdGuard Home використовує для локальних PTR-запитів. Ці сервери використовуються для вирішення PTR-запитів для адрес у приватних мережах, наприклад, «192.168.12.34». Якщо список порожній, AdGuard Home буде усталено використовувати системний DNS-сервер.", + "local_ptr_default_resolver": "Стандартно AdGuard Home користується такими зворотними DNS-вирішувачами: {{ip}}.", + "local_ptr_no_default_resolver": "AdGuard Home не зміг визначити приватні зворотні DNS-вирішувачі, які підійшли б для цієї системи.", "local_ptr_placeholder": "Вводьте одну адресу на рядок", - "resolve_clients_title": "Увімкнути запитування доменних імен для IP-адрес клієнтів", + "resolve_clients_title": "Увімкнути зворотне вирішення IP-адрес клієнтів", "resolve_clients_desc": "Визначати доменні імена клієнтів за допомогою PTR-запитів до відповідних серверів — приватних DNS-серверів для локальних клієнтів та upstream-серверів для клієнтів з публічними IP-адресами.", "use_private_ptr_resolvers_title": "Використовувати приватні зворотні DNS-резолвери", - "use_private_ptr_resolvers_desc": "Надсилати зворотні DNS-запити до вказаних серверів для клієнтів, що обслуговуються локально. Якщо вимкнено, AdGuard Home буде відповідати NXDOMAIN на всі такі PTR-запити, окрім запитів про клієнтів, що уже відомі по DHCP, /etc/hosts тощо.", + "use_private_ptr_resolvers_desc": "Надсилати зворотні DNS-запити до вказаних серверів для клієнтів, що обслуговуються локально. Якщо вимкнено, AdGuard Home буде відповідати NXDOMAIN на всі такі PTR-запити, окрім запитів про клієнтів, що уже відомі завдяки DHCP, /etc/hosts тощо.", "check_dhcp_servers": "Перевірити DHCP-сервери", "save_config": "Зберегти конфігурацію", "enabled_dhcp": "DHCP-сервер увімкнено", @@ -60,7 +60,7 @@ "dhcp_form_range_end": "Кінець діапазону", "dhcp_form_lease_title": "Час оренди DHCP (в секундах)", "dhcp_form_lease_input": "Тривалість оренди", - "dhcp_interface_select": "Оберіть інтерфейс DHCP", + "dhcp_interface_select": "Вибрати DHCP-інтерфейс", "dhcp_hardware_address": "Апаратна адреса", "dhcp_ip_addresses": "IP-адреси", "ip": "IP", @@ -117,11 +117,11 @@ "stats_adult": "Заблоковано вебсайтів для дорослих", "stats_query_domain": "Найчастіші запити доменів", "for_last_24_hours": "за останні 24 години", - "for_last_days": "за останній день", + "for_last_days": "за останній {{count}} день", "for_last_days_plural": "за останні {{count}} днів", "stats_disabled": "Статистику вимкнено. Ви можете увімкнути її на <0>сторінці налаштувань.", "stats_disabled_short": "Статистику вимкнено", - "no_domains_found": "Доменів не знайдено", + "no_domains_found": "Не знайдено жодного домену", "requests_count": "Кількість запитів", "top_blocked_domains": "Найчастіше блоковані домени", "top_clients": "Найактивніші клієнти", @@ -131,7 +131,7 @@ "number_of_dns_query_days_plural": "Кількість DNS-запитів, оброблених за останні {{count}} днів", "number_of_dns_query_24_hours": "Кількість DNS-запитів, оброблених за останні 24 години", "number_of_dns_query_blocked_24_hours": "Кількість DNS-запитів, заблокованих фільтрами і списками блокування hosts", - "number_of_dns_query_blocked_24_hours_by_sec": "Кількість DNS-запитів, заблокованих модулем безпеки перегляду AdGuard", + "number_of_dns_query_blocked_24_hours_by_sec": "Кількість DNS-запитів, заблокованих модулем «Безпека перегляду» AdGuard", "number_of_dns_query_blocked_24_hours_adult": "Кількість заблокованих вебсайтів для дорослих", "enforced_save_search": "Примусовий безпечний пошук", "number_of_dns_query_to_safe_search": "Кількість DNS-запитів до пошукових систем, для яких примусово застосований безпечний пошук", @@ -139,10 +139,10 @@ "average_processing_time_hint": "Середній час обробки DNS запиту в мілісекундах", "block_domain_use_filters_and_hosts": "Блокування доменів за допомогою фільтрів та hosts-файлів", "filters_block_toggle_hint": "Ви можете налаштувати правила блокування в розділі Фільтри.", - "use_adguard_browsing_sec": "Використовувати Безпечну навігацію AdGuard", - "use_adguard_browsing_sec_hint": "AdGuard Home перевірятиме, чи додано домен до списку веб-служби безпечного перегляду браузера. Він використовуватиме API для перевірки — на сервер надсилається лише короткий префікс хешу SHA256 доменного імені.", - "use_adguard_parental": "Використовувати вебсервіс Батьківського контролю AdGuard", - "use_adguard_parental_hint": "AdGuard Home перевірить, чи містить домен матеріали для дорослих. Він використовує то же API, що й Безпечна навігація AdGuard.", + "use_adguard_browsing_sec": "Використовувати вебслужбу «Безпека перегляду» AdGuard", + "use_adguard_browsing_sec_hint": "AdGuard Home перевірятиме, чи підлягає домен блокуванню завдяки вебслужбі «Безпека перегляду». Для перевірки буде використано безпечний API — на сервер надсилається лише короткий префікс хешу SHA256 доменного імені.", + "use_adguard_parental": "Використовувати вебслужбу «Батьківський контроль» AdGuard", + "use_adguard_parental_hint": "AdGuard Home перевірить, чи містить домен матеріали для дорослих. Буде використано той же безпечний API, що й для «Безпеки перегляду» AdGuard.", "enforce_safe_search": "Використовувати Безпечний пошук", "enforce_save_search_hint": "AdGuard Home може примусово застосовувати безпечний пошук в таких пошукових системах: Google, YouTube, Bing, DuckDuckGo, Yandex, Pixabay.", "no_servers_specified": "Сервери не вказано", @@ -165,8 +165,8 @@ "enabled_filtering_toast": "Фільтрування увімкнено", "disabled_safe_browsing_toast": "Безпечний перегляд вимкнено", "enabled_safe_browsing_toast": "Безпечний перегляд увімкнено", - "disabled_parental_toast": "Батьківський контроль вимкнено", - "enabled_parental_toast": "Батьківський контроль увімкнено", + "disabled_parental_toast": "«Батьківський контроль» вимкнено", + "enabled_parental_toast": "«Батьківський контроль» увімкнено", "disabled_safe_search_toast": "Безпечний пошук вимкнено", "enabled_save_search_toast": "Безпечний пошук увімкнено", "enabled_table_header": "Увімкнено", @@ -193,7 +193,7 @@ "edit_blocklist": "Змінити список блокування", "edit_allowlist": "Змінити список дозволів", "choose_blocklist": "Виберіть списки блокування", - "choose_allowlist": "Обрати списки дозволених сайтів", + "choose_allowlist": "Виберіть списки дозволів", "enter_valid_blocklist": "Введіть дійсну URL-адресу в список блокування.", "enter_valid_allowlist": "Введіть дійсну URL-адресу в список дозволів.", "form_error_url_format": "Неправильний формат URL", @@ -214,7 +214,7 @@ "example_upstream_dot": "зашифрований <0>DNS-over-TLS;", "example_upstream_doh": "зашифрований <0>DNS-over-HTTPS;", "example_upstream_doq": "зашифрований <0>DNS-over-QUIC (експериментальний);", - "example_upstream_sdns": "<0>DNS Stamps для <1>DNSCrypt або <2>DNS-over-HTTPS серверів;", + "example_upstream_sdns": "<0>DNS Stamps для <1>DNSCrypt- або <2>DNS-over-HTTPS-вирішувачів;", "example_upstream_tcp": "звичайний DNS (через TCP);", "example_upstream_tcp_hostname": "звичайний DNS (поверх TCP, з назвою вузла);", "all_lists_up_to_date_toast": "Всі списки вже оновлені", @@ -351,7 +351,7 @@ "install_devices_android_list_5": "Змініть встановлені значення DNS 1 і DNS 2 на адреси вашого домашнього сервера AdGuard.", "install_devices_ios_list_1": "На головному екрані торкніться Налаштування.", "install_devices_ios_list_2": "Виберіть Wi-Fi у меню ліворуч (неможливо налаштувати DNS для мобільних мереж).", - "install_devices_ios_list_3": "Натисніть на назву поточно активної мережі.", + "install_devices_ios_list_3": "Натисніть на назву поточної активної мережі.", "install_devices_ios_list_4": "У полі DNS введіть адреси вашого сервера AdGuard Home.", "get_started": "Розпочати", "next": "Наступні", @@ -372,7 +372,7 @@ "encryption_doq": "Порт DNS-over-QUIC (експериментальний)", "encryption_doq_desc": "Якщо цей порт налаштовано, AdGuard Home запустить на цьому порту сервер DNS-over-QUIC. Це експериментально і може бути ненадійним. Крім того, зараз не так багато клієнтів, які це підтримують.", "encryption_certificates": "Сертифікати", - "encryption_certificates_desc": "Для використання шифрування потрібно надати дійсний ланцюжок сертифікатів SSL для вашого домену. Ви можете отримати безкоштовний сертифікат на <0>{{link}} або придбати його в одному з надійних Центрів Сертифікації.", + "encryption_certificates_desc": "Для використання шифрування потрібно надати дійсний ланцюжок сертифікатів SSL для вашого домену. Ви можете отримати безплатний сертифікат на <0>{{link}} або придбати його в одному з надійних Центрів Сертифікації.", "encryption_certificates_input": "Скопіюйте/вставте сюди свої кодовані PEM сертифікати.", "encryption_status": "Статус", "encryption_expire": "Закінчується", @@ -552,16 +552,16 @@ "fastest_addr": "Найшвидша IP-адреса", "fastest_addr_desc": "Опитати всі DNS-сервери й повернути найшвидшу IP-адресу серед усіх наданих. Це сповільнить швидкість DNS-запитів, оскільки AdGuard Home повинен буде чекати відповіді усіх DNS-серверів, але водночас може покращити якість з'єднання.", "autofix_warning_text": "Якщо ви натиснете «Виправити», AdGuard Home налаштує вашу систему на використання DNS-сервера AdGuard Home.", - "autofix_warning_list": "Це виконає наступні завдання: <0>Деактивує систему DNSStubListener <0>Змінить адресу DNS сервера на 127.0.0.1 <0>Замінить символічне посилання /etc/resolv.conf на /run/systemd/resolve/resolv.conf <0>Зупинить DNSStubListener (перезапустить сервіс systemd-resolved)", + "autofix_warning_list": "Будуть виконані такі дії: <0>Деактивація системи DNSStubListener <0>Зміна адреси DNS-сервера на «127.0.0.1» <0>Заміна символічного посилання «/etc/resolv.conf» на «/run/systemd/resolve/resolv.conf» <0>Зупинка DNSStubListener (перезапуск системної служби systemd-resolved)", "autofix_warning_result": "В результаті буде усталено, що усі DNS-запити вашої системи будуть опрацьовані AdGuard Home.", "tags_title": "Теги", "tags_desc": "Ви можете вибрати теги, які відповідають клієнту. Теги можна використати в правилах фільтрування, щоб точніше застосовувати їх. <0>Докладніше.", "form_select_tags": "Виберіть теги клієнта", - "check_title": "Перевірте фільтрування", + "check_title": "Перевірити фільтрування", "check_desc": "Перевірити чи фільтрується назва вузла.", "check": "Перевірити", "form_enter_host": "Введіть назву вузла", - "filtered_custom_rules": "Відфільтровано за власними правилами фільтрування", + "filtered_custom_rules": "Відфільтровано завдяки власним правилам фільтрування", "choose_from_list": "Виберіть зі списку", "add_custom_list": "Додати власний список", "host_whitelisted": "Вузол додано до списку дозволів", @@ -585,14 +585,14 @@ "list_updated": "{{count}} список оновлено", "list_updated_plural": "{{count}} списки оновлено", "dnssec_enable": "Увімкнути DNSSEC", - "dnssec_enable_desc": "Встановити прапорець DNSSEC для вихідних DNS запитів та перевірити результат (потрібен розпізнавач з підтримкою DNSSEC).", + "dnssec_enable_desc": "Увімкнути DNSSEC для вихідних DNS-запитів та перевірити результат (потрібен вирішувач з підтримкою DNSSEC).", "validated_with_dnssec": "Засвідчено DNSSEC", "all_queries": "Усі запити", "show_blocked_responses": "Заблоковані", "show_whitelisted_responses": "Дозволені", "show_processed_responses": "Оброблені", "blocked_safebrowsing": "Заблоковано Безпечним переглядом", - "blocked_adult_websites": "Заблоковано Батьківським контролем", + "blocked_adult_websites": "Заблоковано «Батьківським контролем»", "blocked_threats": "Заблоковано загроз", "allowed": "Дозволено", "filtered": "Відфільтровано", diff --git a/client/src/__locales/zh-cn.json b/client/src/__locales/zh-cn.json index 4640432f..8903052f 100644 --- a/client/src/__locales/zh-cn.json +++ b/client/src/__locales/zh-cn.json @@ -351,6 +351,7 @@ "install_devices_android_list_5": "将 DNS 1 和 DNS 2 的值改为您的 AdGuard Home 服务器地址。", "install_devices_ios_list_1": "从主屏幕中点击「设置」。", "install_devices_ios_list_2": "从左侧目录中选择「无线局域网」(移动数据网络环境下不支持修改 DNS )。", + "install_devices_ios_list_3": "点击当前已连接网络的名称。", "install_devices_ios_list_4": "在 DNS 字段中输入您的 AdGuard Home 服务器地址。", "get_started": "开始配置", "next": "下一步", From c3d5fcc6692bbbf7271c5ee44dac7d984fa7cd80 Mon Sep 17 00:00:00 2001 From: Dimitry Kolyshev Date: Thu, 26 May 2022 16:21:59 +0300 Subject: [PATCH 13/79] Pull request: locales: DoQ status Merge in DNS/adguard-home from 4592-doq-status to master Squashed commit of the following: commit 96bc041b736a45711419160aebb79296f13ff84d Author: Dimitry Kolyshev Date: Thu May 26 14:21:10 2022 +0200 all: locales --- client/src/__locales/en.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/__locales/en.json b/client/src/__locales/en.json index f39d2f51..a5c21109 100644 --- a/client/src/__locales/en.json +++ b/client/src/__locales/en.json @@ -213,7 +213,7 @@ "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_doq": "encrypted <0>DNS-over-QUIC;", "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);", @@ -369,8 +369,8 @@ "encryption_https_desc": "If HTTPS port is configured, AdGuard Home admin interface will be accessible via HTTPS, and it will also provide DNS-over-HTTPS on '/dns-query' location.", "encryption_dot": "DNS-over-TLS port", "encryption_dot_desc": "If this port is configured, AdGuard Home will run a DNS-over-TLS server on this port.", - "encryption_doq": "DNS-over-QUIC port (experimental)", - "encryption_doq_desc": "If this port is configured, AdGuard Home will run a DNS-over-QUIC server on this port. It's experimental and may not be reliable. Also, there are not too many clients that support it at the moment.", + "encryption_doq": "DNS-over-QUIC port", + "encryption_doq_desc": "If this port is configured, AdGuard Home will run a DNS-over-QUIC server on this port.", "encryption_certificates": "Certificates", "encryption_certificates_desc": "In order to use encryption, you need to provide a valid SSL certificates chain for your domain. You can get a free certificate on <0>{{link}} or you can buy it from one of the trusted Certificate Authorities.", "encryption_certificates_input": "Copy/paste your PEM-encoded certificates here.", From 756c932e372e36b5a6814d73fa6dac6c8799c9a1 Mon Sep 17 00:00:00 2001 From: Dimitry Kolyshev Date: Thu, 26 May 2022 17:53:11 +0300 Subject: [PATCH 14/79] 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 Date: Thu May 26 16:42:06 2022 +0200 dnsforward: add doq alpn commit 9dcd6fee615a1a5ac1f80641ac16c18371b67096 Merge: 2564c870 c3d5fcc6 Author: Dimitry Kolyshev Date: Thu May 26 15:24:07 2022 +0200 Merge remote-tracking branch 'origin/master' into 4592-doq-alpn commit 2564c870e704ff453d0ad2fb22fa295ef725dd13 Author: Dimitry Kolyshev Date: Thu May 26 15:20:16 2022 +0200 dnsforward: add doq alpn --- internal/dnsforward/dns.go | 21 ++++++++++++++++++--- internal/dnsforward/dns_test.go | 26 ++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/internal/dnsforward/dns.go b/internal/dnsforward/dns.go index 19d54d91..e049bef0 100644 --- a/internal/dnsforward/dns.go +++ b/internal/dnsforward/dns.go @@ -260,9 +260,8 @@ func (s *Server) processDDRQuery(ctx *dnsContext) (rc resultCode) { } if question.Name == ddrHostFQDN { - // TODO(a.garipov): Check DoQ support in next RFC drafts. - if s.dnsProxy.TLSListenAddr == nil && s.dnsProxy.HTTPSListenAddr == nil || - question.Qtype != dns.TypeSVCB { + if s.dnsProxy.TLSListenAddr == nil && s.dnsProxy.HTTPSListenAddr == nil && + s.dnsProxy.QUICListenAddr == nil || question.Qtype != dns.TypeSVCB { d.Res = s.makeResponse(d.Req) return resultCodeFinish @@ -314,6 +313,22 @@ func (s *Server) makeDDRResponse(req *dns.Msg) (resp *dns.Msg) { resp.Answer = append(resp.Answer, ans) } + for _, addr := range s.dnsProxy.QUICListenAddr { + values := []dns.SVCBKeyValue{ + &dns.SVCBAlpn{Alpn: []string{"doq"}}, + &dns.SVCBPort{Port: uint16(addr.Port)}, + } + + ans := &dns.SVCB{ + Hdr: s.hdr(req, dns.TypeSVCB), + Priority: 3, + Target: domainName, + Value: values, + } + + resp.Answer = append(resp.Answer, ans) + } + return resp } diff --git a/internal/dnsforward/dns_test.go b/internal/dnsforward/dns_test.go index 8ab7501c..b40b7bc2 100644 --- a/internal/dnsforward/dns_test.go +++ b/internal/dnsforward/dns_test.go @@ -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, From 7ce7e908654579789f23ea5302416b67885494ae Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Mon, 30 May 2022 16:04:28 +0300 Subject: [PATCH 15/79] Pull request: dnsforward: fix ddr target Updates #4463. Squashed commit of the following: commit 047155b585a1c762d709874f44abb2d8c5a9dbca Author: Eugene Burkov Date: Mon May 30 15:34:38 2022 +0300 dnsforward: imp code commit b0508ffec13ccf5fc5d3d2e37c9e1bd83c3c039e Author: Eugene Burkov Date: Mon May 30 15:27:02 2022 +0300 dnsforward: fix ddr target --- internal/dnsforward/dns.go | 4 +++- internal/dnsforward/dns_test.go | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/dnsforward/dns.go b/internal/dnsforward/dns.go index e049bef0..2865bc84 100644 --- a/internal/dnsforward/dns.go +++ b/internal/dnsforward/dns.go @@ -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{ diff --git a/internal/dnsforward/dns_test.go b/internal/dnsforward/dns_test.go index b40b7bc2..129e3c2f 100644 --- a/internal/dnsforward/dns_test.go +++ b/internal/dnsforward/dns_test.go @@ -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}, From 4b884ace622f86fa2b77efb7c5ade513ff5ae3b5 Mon Sep 17 00:00:00 2001 From: Dimitry Kolyshev Date: Tue, 31 May 2022 17:28:50 +0300 Subject: [PATCH 16/79] Pull request: all: fix doh ddr Merge in DNS/adguard-home from fix-ddr-doh to master Squashed commit of the following: commit 53d3147b22044061d78b3bf4badca60505ac245a Author: Dimitry Kolyshev Date: Tue May 31 15:02:17 2022 +0200 all: fix doh ddr --- internal/dnsforward/config.go | 5 +++-- internal/dnsforward/dns.go | 6 +++--- internal/dnsforward/dns_test.go | 8 ++++---- internal/home/dns.go | 4 ++++ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/internal/dnsforward/config.go b/internal/dnsforward/config.go index 16a6325e..f9234155 100644 --- a/internal/dnsforward/config.go +++ b/internal/dnsforward/config.go @@ -134,8 +134,9 @@ type FilteringConfig struct { // TLSConfig is the TLS configuration for HTTPS, DNS-over-HTTPS, and DNS-over-TLS type TLSConfig struct { - TLSListenAddrs []*net.TCPAddr `yaml:"-" json:"-"` - QUICListenAddrs []*net.UDPAddr `yaml:"-" json:"-"` + TLSListenAddrs []*net.TCPAddr `yaml:"-" json:"-"` + QUICListenAddrs []*net.UDPAddr `yaml:"-" json:"-"` + HTTPSListenAddrs []*net.TCPAddr `yaml:"-" json:"-"` // Reject connection if the client uses server name (in SNI) that doesn't match the certificate StrictSNICheck bool `yaml:"strict_sni_check" json:"-"` diff --git a/internal/dnsforward/dns.go b/internal/dnsforward/dns.go index 2865bc84..55a38a2f 100644 --- a/internal/dnsforward/dns.go +++ b/internal/dnsforward/dns.go @@ -260,7 +260,7 @@ func (s *Server) processDDRQuery(ctx *dnsContext) (rc resultCode) { } if question.Name == ddrHostFQDN { - if s.dnsProxy.TLSListenAddr == nil && s.dnsProxy.HTTPSListenAddr == nil && + if s.dnsProxy.TLSListenAddr == nil && s.conf.HTTPSListenAddrs == nil && s.dnsProxy.QUICListenAddr == nil || question.Qtype != dns.TypeSVCB { d.Res = s.makeResponse(d.Req) @@ -278,11 +278,11 @@ 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) - // TODO(e.burkov): Think about stroing the FQDN version of the server's + // TODO(e.burkov): Think about storing 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.conf.HTTPSListenAddrs { values := []dns.SVCBKeyValue{ &dns.SVCBAlpn{Alpn: []string{"h2"}}, &dns.SVCBPort{Port: uint16(addr.Port)}, diff --git a/internal/dnsforward/dns_test.go b/internal/dnsforward/dns_test.go index 129e3c2f..b9c7e47b 100644 --- a/internal/dnsforward/dns_test.go +++ b/internal/dnsforward/dns_test.go @@ -156,10 +156,6 @@ func prepareTestServer(t *testing.T, portDoH, portDoT, portDoQ int, ddrEnabled b proxyConf := proxy.Config{} - if portDoH > 0 { - proxyConf.HTTPSListenAddr = []*net.TCPAddr{{Port: portDoH}} - } - if portDoT > 0 { proxyConf.TLSListenAddr = []*net.TCPAddr{{Port: portDoT}} } @@ -182,6 +178,10 @@ func prepareTestServer(t *testing.T, portDoH, portDoT, portDoQ int, ddrEnabled b }, } + if portDoH > 0 { + s.conf.TLSConfig.HTTPSListenAddrs = []*net.TCPAddr{{Port: portDoH}} + } + return s } diff --git a/internal/home/dns.go b/internal/home/dns.go index 9eabfefa..d51a6dd2 100644 --- a/internal/home/dns.go +++ b/internal/home/dns.go @@ -221,6 +221,10 @@ func generateServerConfig() (newConf dnsforward.ServerConfig, err error) { newConf.TLSConfig = tlsConf.TLSConfig newConf.TLSConfig.ServerName = tlsConf.ServerName + if tlsConf.PortHTTPS != 0 { + newConf.HTTPSListenAddrs = ipsToTCPAddrs(hosts, tlsConf.PortHTTPS) + } + if tlsConf.PortDNSOverTLS != 0 { newConf.TLSListenAddrs = ipsToTCPAddrs(hosts, tlsConf.PortDNSOverTLS) } From f46c9f74d5b03f8caa60d8e648bbc46fe306714d Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Thu, 2 Jun 2022 15:57:06 +0300 Subject: [PATCH 17/79] Pull request: all: upd go Merge in DNS/adguard-home from upd-go to master Squashed commit of the following: commit b0bec8926508fb7ee3f26c2303d9628e21f0b62f Author: Ainar Garipov Date: Thu Jun 2 15:47:51 2022 +0300 all: upd go --- CHANGELOG.md | 15 +++++++++++---- bamboo-specs/release.yaml | 6 +++--- bamboo-specs/test.yaml | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a72447c..3bdd37ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,9 @@ and this project adheres to ### Security +- Go version was updated to prevent the possibility of exploiting the + [CVE-2022-29526], [CVE-2022-30634], [CVE-2022-30629], [CVE-2022-30580], and + [CVE-2022-29804] vulnerabilities. - Enforced password strength policy ([#3503]). - Weaker cipher suites that use the CBC (cipher block chaining) mode of operation have been disabled ([#2993]). @@ -161,10 +164,14 @@ In this release, the schema version has changed from 12 to 14. [#4591]: https://github.com/AdguardTeam/AdGuardHome/issues/4591 [#4592]: https://github.com/AdguardTeam/AdGuardHome/issues/4592 -[rfc-9250]: https://datatracker.ietf.org/doc/html/rfc9250 -[ddr-draft-06]: https://www.ietf.org/archive/id/draft-ietf-add-ddr-06.html -[repr]: https://reproducible-builds.org/docs/source-date-epoch/ - +[CVE-2022-29526]: https://www.cvedetails.com/cve/CVE-2022-29526 +[CVE-2022-29804]: https://www.cvedetails.com/cve/CVE-2022-29804 +[CVE-2022-30580]: https://www.cvedetails.com/cve/CVE-2022-30580 +[CVE-2022-30629]: https://www.cvedetails.com/cve/CVE-2022-30629 +[CVE-2022-30634]: https://www.cvedetails.com/cve/CVE-2022-30634 +[ddr-draft-06]: https://www.ietf.org/archive/id/draft-ietf-add-ddr-06.html +[repr]: https://reproducible-builds.org/docs/source-date-epoch/ +[rfc-9250]: https://datatracker.ietf.org/doc/html/rfc9250 ### Security +- Weaker cipher suites that use the CBC (cipher block chaining) mode of + operation have been disabled ([#2993]). + +### Added + +- Support for Discovery of Designated Resolvers (DDR) according to the [RFC + draft][ddr-draft-06] ([#4463]). +- `windows/arm64` support ([#3057]). + +### Deprecated + +- Go 1.17 support. v0.109.0 will require at least Go 1.18 to build. + +[#2993]: https://github.com/AdguardTeam/AdGuardHome/issues/2993 +[#3057]: https://github.com/AdguardTeam/AdGuardHome/issues/3057 + +[ddr-draft-06]: https://www.ietf.org/archive/id/draft-ietf-add-ddr-06.html + + + + + + + +## [v0.107.7] - 2022-06-06 + +See also the [v0.107.7 GitHub milestone][ms-v0.107.7]. + +### Security + - Go version was updated to prevent the possibility of exploiting the [CVE-2022-29526], [CVE-2022-30634], [CVE-2022-30629], [CVE-2022-30580], and [CVE-2022-29804] vulnerabilities. - Enforced password strength policy ([#3503]). -- Weaker cipher suites that use the CBC (cipher block chaining) mode of - operation have been disabled ([#2993]). ### Added - Support for the final DNS-over-QUIC standard, [RFC 9250][rfc-9250] ([#4592]). - Support upstreams for subdomains of a domain only ([#4503]). -- Support for Discovery of Designated Resolvers (DDR) according to the [RFC - draft][ddr-draft-06] ([#4463]). - The ability to control each source of runtime clients separately via `clients.runtime_sources` configuration object ([#3020]). - The ability to customize the set of networks that are considered private @@ -41,7 +69,6 @@ and this project adheres to ([#4166]). - Logs are now collected by default on FreeBSD and OpenBSD when AdGuard Home is installed as a service ([#4213]). -- `windows/arm64` support ([#3057]). ### Changed @@ -125,10 +152,9 @@ In this release, the schema version has changed from 12 to 14. ### Deprecated -- The `--no-etc-hosts` option. Its' functionality is now controlled by +- The `--no-etc-hosts` option. Its functionality is now controlled by `clients.runtime_sources.hosts` configuration property. v0.109.0 will remove the flag completely. -- Go 1.17 support. v0.109.0 will require at least Go 1.18 to build. ### Fixed @@ -140,9 +166,7 @@ In this release, the schema version has changed from 12 to 14. - ARP tables refreshing process causing excessive PTR requests ([#3157]). [#1730]: https://github.com/AdguardTeam/AdGuardHome/issues/1730 -[#2993]: https://github.com/AdguardTeam/AdGuardHome/issues/2993 [#3020]: https://github.com/AdguardTeam/AdGuardHome/issues/3020 -[#3057]: https://github.com/AdguardTeam/AdGuardHome/issues/3057 [#3142]: https://github.com/AdguardTeam/AdGuardHome/issues/3142 [#3157]: https://github.com/AdguardTeam/AdGuardHome/issues/3157 [#3367]: https://github.com/AdguardTeam/AdGuardHome/issues/3367 @@ -169,20 +193,10 @@ In this release, the schema version has changed from 12 to 14. [CVE-2022-30580]: https://www.cvedetails.com/cve/CVE-2022-30580 [CVE-2022-30629]: https://www.cvedetails.com/cve/CVE-2022-30629 [CVE-2022-30634]: https://www.cvedetails.com/cve/CVE-2022-30634 -[ddr-draft-06]: https://www.ietf.org/archive/id/draft-ietf-add-ddr-06.html -[repr]: https://reproducible-builds.org/docs/source-date-epoch/ +[ms-v0.107.7]: https://github.com/AdguardTeam/AdGuardHome/milestone/43?closed=1 [rfc-9250]: https://datatracker.ietf.org/doc/html/rfc9250 - - - ## [v0.107.6] - 2022-04-13 @@ -234,6 +248,7 @@ See also the [v0.107.6 GitHub milestone][ms-v0.107.6]. [CVE-2022-28327]: https://www.cvedetails.com/cve/CVE-2022-28327 [dns-draft-02]: https://datatracker.ietf.org/doc/html/draft-ietf-add-svcb-dns-02#section-5.1 [ms-v0.107.6]: https://github.com/AdguardTeam/AdGuardHome/milestone/42?closed=1 +[repr]: https://reproducible-builds.org/docs/source-date-epoch/ [svcb-draft-08]: https://www.ietf.org/archive/id/draft-ietf-dnsop-svcb-https-08.html @@ -995,11 +1010,12 @@ See also the [v0.104.2 GitHub milestone][ms-v0.104.2]. -[Unreleased]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.6...HEAD +[Unreleased]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.7...HEAD +[v0.107.7]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.6...v0.107.7 [v0.107.6]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.5...v0.107.6 [v0.107.5]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.4...v0.107.5 [v0.107.4]: https://github.com/AdguardTeam/AdGuardHome/compare/v0.107.3...v0.107.4 From 1c1ca1c6e3d490ddfaf2f176a54f5b93b24a9c1a Mon Sep 17 00:00:00 2001 From: Ildar Kamalov Date: Thu, 9 Jun 2022 11:57:58 +0300 Subject: [PATCH 22/79] Pull request: 4641 fix button clickable area Updates #4641 Squashed commit of the following: commit f9f018388a198d7712e5caabba94035e42e393c4 Author: Ildar Kamalov Date: Tue Jun 7 16:21:37 2022 +0300 client: fix button clickable area --- client/src/components/Settings/Settings.css | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/components/Settings/Settings.css b/client/src/components/Settings/Settings.css index 4efb0868..3fd560f9 100644 --- a/client/src/components/Settings/Settings.css +++ b/client/src/components/Settings/Settings.css @@ -113,6 +113,7 @@ width: 30px; height: 30px; background-color: transparent; + overflow: hidden; } .btn-icon--green { From 302faca32f849cb1d63202b0a905077fba56bfa9 Mon Sep 17 00:00:00 2001 From: Ildar Kamalov Date: Thu, 9 Jun 2022 12:07:29 +0300 Subject: [PATCH 23/79] Pull request: 4642 update dns addresses on encryption update Updates #4642 Squashed commit of the following: commit 75729120d3532dc2bd12b6c9e724a691043a1870 Merge: 5b681867 1c1ca1c6 Author: Ildar Kamalov Date: Thu Jun 9 11:58:13 2022 +0300 Merge branch 'master' into 4642-dns-privacy commit 5b68186705c3a9287a44e33c8cf7ab79060f35a4 Author: Ildar Kamalov Date: Tue Jun 7 18:39:02 2022 +0300 fix commit 46a9346154d33206e829a97021f3ef47ac2a5611 Author: Ildar Kamalov Date: Tue Jun 7 18:18:18 2022 +0300 client: update dns addresses on encryption update --- client/src/actions/encryption.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/src/actions/encryption.js b/client/src/actions/encryption.js index 36faf2ec..2f58abd3 100644 --- a/client/src/actions/encryption.js +++ b/client/src/actions/encryption.js @@ -24,6 +24,7 @@ export const getTlsStatus = () => async (dispatch) => { export const setTlsConfigRequest = createAction('SET_TLS_CONFIG_REQUEST'); export const setTlsConfigFailure = createAction('SET_TLS_CONFIG_FAILURE'); export const setTlsConfigSuccess = createAction('SET_TLS_CONFIG_SUCCESS'); +export const dnsStatusSuccess = createAction('DNS_STATUS_SUCCESS'); export const setTlsConfig = (config) => async (dispatch, getState) => { dispatch(setTlsConfigRequest()); @@ -39,6 +40,12 @@ export const setTlsConfig = (config) => async (dispatch, getState) => { const response = await apiClient.setTlsConfig(values); response.certificate_chain = atob(response.certificate_chain); response.private_key = atob(response.private_key); + + const dnsStatus = await apiClient.getGlobalStatus(); + if (dnsStatus) { + dispatch(dnsStatusSuccess(dnsStatus)); + } + dispatch(setTlsConfigSuccess(response)); dispatch(addSuccessToast('encryption_config_saved')); redirectToCurrentProtocol(response, httpPort); From e738508d7a5e09e257724c557069000506e055ad Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Thu, 9 Jun 2022 17:47:05 +0300 Subject: [PATCH 24/79] Pull request: all: imp updater Merge in DNS/adguard-home from imp-updater to master Squashed commit of the following: commit 6ed487359e56a35b36f13dcbf2efbf2a7a2d8734 Author: Ainar Garipov Date: Thu Jun 9 16:29:35 2022 +0300 all: imp logs, err handling commit e930044cb619a43e5a44c230dadbe2228e9a93f5 Author: Ainar Garipov Date: Thu Jun 9 15:53:35 2022 +0300 all: imp updater --- client/src/__locales/en.json | 2 +- internal/aghalg/nullbool.go | 59 +++++++++++++++++++++ internal/{dhcpd => aghalg}/nullbool_test.go | 23 ++++---- internal/dhcpd/http.go | 19 +++---- internal/dhcpd/nullbool.go | 58 -------------------- internal/home/controlupdate.go | 7 +-- internal/updater/check.go | 30 +++++------ internal/updater/updater.go | 34 +++++++----- internal/updater/updater_test.go | 16 ++---- scripts/make/build-release.sh | 1 + 10 files changed, 124 insertions(+), 125 deletions(-) create mode 100644 internal/aghalg/nullbool.go rename internal/{dhcpd => aghalg}/nullbool_test.go (72%) delete mode 100644 internal/dhcpd/nullbool.go diff --git a/client/src/__locales/en.json b/client/src/__locales/en.json index a5c21109..dd885677 100644 --- a/client/src/__locales/en.json +++ b/client/src/__locales/en.json @@ -445,7 +445,7 @@ "access_blocked_title": "Disallowed domains", "access_blocked_desc": "Not to be confused with filters. AdGuard Home drops DNS queries matching these domains, and these queries don't even appear in the query log. You can specify exact domain names, wildcards, or URL filter rules, e.g. \"example.org\", \"*.example.org\", or \"||example.org^\" correspondingly.", "access_settings_saved": "Access settings successfully saved", - "updates_checked": "Updates successfully checked", + "updates_checked": "A new version of AdGuard Home is available", "updates_version_equal": "AdGuard Home is up-to-date", "check_updates_now": "Check for updates now", "dns_privacy": "DNS Privacy", diff --git a/internal/aghalg/nullbool.go b/internal/aghalg/nullbool.go new file mode 100644 index 00000000..3c5633e3 --- /dev/null +++ b/internal/aghalg/nullbool.go @@ -0,0 +1,59 @@ +package aghalg + +import ( + "bytes" + "encoding/json" + "fmt" +) + +// NullBool is a nullable boolean. Use these in JSON requests and responses +// instead of pointers to bool. +type NullBool uint8 + +// NullBool values +const ( + NBNull NullBool = iota + NBTrue + NBFalse +) + +// String implements the fmt.Stringer interface for NullBool. +func (nb NullBool) String() (s string) { + switch nb { + case NBNull: + return "null" + case NBTrue: + return "true" + case NBFalse: + return "false" + } + + return fmt.Sprintf("!invalid NullBool %d", uint8(nb)) +} + +// BoolToNullBool converts a bool into a NullBool. +func BoolToNullBool(cond bool) (nb NullBool) { + if cond { + return NBTrue + } + + return NBFalse +} + +// type check +var _ json.Unmarshaler = (*NullBool)(nil) + +// UnmarshalJSON implements the json.Unmarshaler interface for *NullBool. +func (nb *NullBool) UnmarshalJSON(b []byte) (err error) { + if len(b) == 0 || bytes.Equal(b, []byte("null")) { + *nb = NBNull + } else if bytes.Equal(b, []byte("true")) { + *nb = NBTrue + } else if bytes.Equal(b, []byte("false")) { + *nb = NBFalse + } else { + return fmt.Errorf("unmarshalling json data into aghalg.NullBool: bad value %q", b) + } + + return nil +} diff --git a/internal/dhcpd/nullbool_test.go b/internal/aghalg/nullbool_test.go similarity index 72% rename from internal/dhcpd/nullbool_test.go rename to internal/aghalg/nullbool_test.go index 549df608..0fe7f203 100644 --- a/internal/dhcpd/nullbool_test.go +++ b/internal/aghalg/nullbool_test.go @@ -1,9 +1,10 @@ -package dhcpd +package aghalg_test import ( "encoding/json" "testing" + "github.com/AdguardTeam/AdGuardHome/internal/aghalg" "github.com/AdguardTeam/golibs/testutil" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -14,37 +15,37 @@ func TestNullBool_UnmarshalJSON(t *testing.T) { name string wantErrMsg string data []byte - want nullBool + want aghalg.NullBool }{{ name: "empty", wantErrMsg: "", data: []byte{}, - want: nbNull, + want: aghalg.NBNull, }, { name: "null", wantErrMsg: "", data: []byte("null"), - want: nbNull, + want: aghalg.NBNull, }, { name: "true", wantErrMsg: "", data: []byte("true"), - want: nbTrue, + want: aghalg.NBTrue, }, { name: "false", wantErrMsg: "", data: []byte("false"), - want: nbFalse, + want: aghalg.NBFalse, }, { name: "invalid", - wantErrMsg: `invalid nullBool value "invalid"`, + wantErrMsg: `unmarshalling json data into aghalg.NullBool: bad value "invalid"`, data: []byte("invalid"), - want: nbNull, + want: aghalg.NBNull, }} for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - var got nullBool + var got aghalg.NullBool err := got.UnmarshalJSON(tc.data) testutil.AssertErrorMsg(t, tc.wantErrMsg, err) @@ -53,9 +54,9 @@ func TestNullBool_UnmarshalJSON(t *testing.T) { } t.Run("json", func(t *testing.T) { - want := nbTrue + want := aghalg.NBTrue var got struct { - A nullBool + A aghalg.NullBool } err := json.Unmarshal([]byte(`{"A":true}`), &got) diff --git a/internal/dhcpd/http.go b/internal/dhcpd/http.go index e340addb..62a08f66 100644 --- a/internal/dhcpd/http.go +++ b/internal/dhcpd/http.go @@ -10,6 +10,7 @@ import ( "strings" "time" + "github.com/AdguardTeam/AdGuardHome/internal/aghalg" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/AdGuardHome/internal/aghnet" "github.com/AdguardTeam/golibs/errors" @@ -145,7 +146,7 @@ type dhcpServerConfigJSON struct { V4 *v4ServerConfJSON `json:"v4"` V6 *v6ServerConfJSON `json:"v6"` InterfaceName string `json:"interface_name"` - Enabled nullBool `json:"enabled"` + Enabled aghalg.NullBool `json:"enabled"` } func (s *Server) handleDHCPSetConfigV4( @@ -156,7 +157,7 @@ func (s *Server) handleDHCPSetConfigV4( } v4Conf := v4JSONToServerConf(conf.V4) - v4Conf.Enabled = conf.Enabled == nbTrue + v4Conf.Enabled = conf.Enabled == aghalg.NBTrue if len(v4Conf.RangeStart) == 0 { v4Conf.Enabled = false } @@ -183,7 +184,7 @@ func (s *Server) handleDHCPSetConfigV6( } v6Conf := v6JSONToServerConf(conf.V6) - v6Conf.Enabled = conf.Enabled == nbTrue + v6Conf.Enabled = conf.Enabled == aghalg.NBTrue if len(v6Conf.RangeStart) == 0 { v6Conf.Enabled = false } @@ -206,7 +207,7 @@ func (s *Server) handleDHCPSetConfigV6( func (s *Server) handleDHCPSetConfig(w http.ResponseWriter, r *http.Request) { conf := &dhcpServerConfigJSON{} - conf.Enabled = boolToNullBool(s.conf.Enabled) + conf.Enabled = aghalg.BoolToNullBool(s.conf.Enabled) conf.InterfaceName = s.conf.InterfaceName err := json.NewDecoder(r.Body).Decode(conf) @@ -230,7 +231,7 @@ func (s *Server) handleDHCPSetConfig(w http.ResponseWriter, r *http.Request) { return } - if conf.Enabled == nbTrue && !v4Enabled && !v6Enabled { + if conf.Enabled == aghalg.NBTrue && !v4Enabled && !v6Enabled { aghhttp.Error(r, w, http.StatusBadRequest, "dhcpv4 or dhcpv6 configuration must be complete") return @@ -243,8 +244,8 @@ func (s *Server) handleDHCPSetConfig(w http.ResponseWriter, r *http.Request) { return } - if conf.Enabled != nbNull { - s.conf.Enabled = conf.Enabled == nbTrue + if conf.Enabled != aghalg.NBNull { + s.conf.Enabled = conf.Enabled == aghalg.NBTrue } if conf.InterfaceName != "" { @@ -279,11 +280,11 @@ func (s *Server) handleDHCPSetConfig(w http.ResponseWriter, r *http.Request) { type netInterfaceJSON struct { Name string `json:"name"` - GatewayIP net.IP `json:"gateway_ip"` HardwareAddr string `json:"hardware_address"` + Flags string `json:"flags"` + GatewayIP net.IP `json:"gateway_ip"` Addrs4 []net.IP `json:"ipv4_addresses"` Addrs6 []net.IP `json:"ipv6_addresses"` - Flags string `json:"flags"` } func (s *Server) handleDHCPInterfaces(w http.ResponseWriter, r *http.Request) { diff --git a/internal/dhcpd/nullbool.go b/internal/dhcpd/nullbool.go deleted file mode 100644 index b07f6768..00000000 --- a/internal/dhcpd/nullbool.go +++ /dev/null @@ -1,58 +0,0 @@ -package dhcpd - -import ( - "bytes" - "fmt" -) - -// nullBool is a nullable boolean. Use these in JSON requests and responses -// instead of pointers to bool. -// -// TODO(a.garipov): Inspect uses of *bool, move this type into some new package -// if we need it somewhere else. -type nullBool uint8 - -// nullBool values -const ( - nbNull nullBool = iota - nbTrue - nbFalse -) - -// String implements the fmt.Stringer interface for nullBool. -func (nb nullBool) String() (s string) { - switch nb { - case nbNull: - return "null" - case nbTrue: - return "true" - case nbFalse: - return "false" - } - - return fmt.Sprintf("!invalid nullBool %d", uint8(nb)) -} - -// boolToNullBool converts a bool into a nullBool. -func boolToNullBool(cond bool) (nb nullBool) { - if cond { - return nbTrue - } - - return nbFalse -} - -// UnmarshalJSON implements the json.Unmarshaler interface for *nullBool. -func (nb *nullBool) UnmarshalJSON(b []byte) (err error) { - if len(b) == 0 || bytes.Equal(b, []byte("null")) { - *nb = nbNull - } else if bytes.Equal(b, []byte("true")) { - *nb = nbTrue - } else if bytes.Equal(b, []byte("false")) { - *nb = nbFalse - } else { - return fmt.Errorf("invalid nullBool value %q", b) - } - - return nil -} diff --git a/internal/home/controlupdate.go b/internal/home/controlupdate.go index ae469598..08ddd455 100644 --- a/internal/home/controlupdate.go +++ b/internal/home/controlupdate.go @@ -12,6 +12,7 @@ import ( "syscall" "time" + "github.com/AdguardTeam/AdGuardHome/internal/aghalg" "github.com/AdguardTeam/AdGuardHome/internal/aghhttp" "github.com/AdguardTeam/AdGuardHome/internal/aghnet" "github.com/AdguardTeam/AdGuardHome/internal/updater" @@ -147,8 +148,8 @@ type versionResponse struct { // setAllowedToAutoUpdate sets CanAutoUpdate to true if AdGuard Home is actually // allowed to perform an automatic update by the OS. func (vr *versionResponse) setAllowedToAutoUpdate() (err error) { - if vr.CanAutoUpdate == nil || !*vr.CanAutoUpdate { - return + if vr.CanAutoUpdate != aghalg.NBTrue { + return nil } tlsConf := &tlsConfigSettings{} @@ -162,7 +163,7 @@ func (vr *versionResponse) setAllowedToAutoUpdate() (err error) { } } - vr.CanAutoUpdate = &canUpdate + vr.CanAutoUpdate = aghalg.BoolToNullBool(canUpdate) return nil } diff --git a/internal/updater/check.go b/internal/updater/check.go index ec7176b2..2bac6153 100644 --- a/internal/updater/check.go +++ b/internal/updater/check.go @@ -5,9 +5,9 @@ import ( "fmt" "io" "net/http" - "strings" "time" + "github.com/AdguardTeam/AdGuardHome/internal/aghalg" "github.com/AdguardTeam/AdGuardHome/internal/aghio" "github.com/AdguardTeam/golibs/errors" ) @@ -17,11 +17,12 @@ const versionCheckPeriod = 8 * time.Hour // VersionInfo contains information about a new version. type VersionInfo struct { - CanAutoUpdate *bool `json:"can_autoupdate,omitempty"` - NewVersion string `json:"new_version,omitempty"` - Announcement string `json:"announcement,omitempty"` - AnnouncementURL string `json:"announcement_url,omitempty"` - SelfUpdateMinVersion string `json:"-"` + NewVersion string `json:"new_version,omitempty"` + Announcement string `json:"announcement,omitempty"` + AnnouncementURL string `json:"announcement_url,omitempty"` + // TODO(a.garipov): See if the frontend actually still cares about + // nullability. + CanAutoUpdate aghalg.NullBool `json:"can_autoupdate,omitempty"` } // MaxResponseSize is responses on server's requests maximum length in bytes. @@ -67,15 +68,13 @@ func (u *Updater) VersionInfo(forceRecheck bool) (vi VersionInfo, err error) { } func (u *Updater) parseVersionResponse(data []byte) (VersionInfo, error) { - var canAutoUpdate bool info := VersionInfo{ - CanAutoUpdate: &canAutoUpdate, + CanAutoUpdate: aghalg.NBFalse, } versionJSON := map[string]string{ - "version": "", - "announcement": "", - "announcement_url": "", - "selfupdate_min_version": "", + "version": "", + "announcement": "", + "announcement_url": "", } err := json.Unmarshal(data, &versionJSON) if err != nil { @@ -91,14 +90,9 @@ func (u *Updater) parseVersionResponse(data []byte) (VersionInfo, error) { info.NewVersion = versionJSON["version"] info.Announcement = versionJSON["announcement"] info.AnnouncementURL = versionJSON["announcement_url"] - info.SelfUpdateMinVersion = versionJSON["selfupdate_min_version"] packageURL, ok := u.downloadURL(versionJSON) - if ok && - info.NewVersion != u.version && - strings.TrimPrefix(u.version, "v") >= strings.TrimPrefix(info.SelfUpdateMinVersion, "v") { - canAutoUpdate = true - } + info.CanAutoUpdate = aghalg.BoolToNullBool(ok && info.NewVersion != u.version) u.newVersion = info.NewVersion u.packageURL = packageURL diff --git a/internal/updater/updater.go b/internal/updater/updater.go index 0cc49f9e..d975d977 100644 --- a/internal/updater/updater.go +++ b/internal/updater/updater.go @@ -104,11 +104,14 @@ func NewUpdater(conf *Config) *Updater { } // Update performs the auto-update. -func (u *Updater) Update() error { +func (u *Updater) Update() (err error) { u.mu.Lock() defer u.mu.Unlock() - err := u.prepare() + log.Info("updater: updating") + defer func() { log.Info("updater: finished; errors: %v", err) }() + + err = u.prepare() if err != nil { return err } @@ -178,7 +181,12 @@ func (u *Updater) prepare() (err error) { u.backupExeName = filepath.Join(u.backupDir, exeName) u.updateExeName = filepath.Join(u.updateDir, exeName) - log.Info("Updating from %s to %s. URL:%s", version.Version(), u.newVersion, u.packageURL) + log.Debug( + "updater: updating from %s to %s using url: %s", + version.Version(), + u.newVersion, + u.packageURL, + ) // TODO(a.garipov): Use os.Args[0] instead? u.currentExeName = filepath.Join(u.workDir, exeName) @@ -194,7 +202,7 @@ func (u *Updater) unpack() error { var err error _, pkgNameOnly := filepath.Split(u.packageURL) - log.Debug("updater: unpacking the package") + log.Debug("updater: unpacking package") if strings.HasSuffix(pkgNameOnly, ".zip") { u.unpackedFiles, err = zipFileUnpack(u.packageName, u.updateDir) if err != nil { @@ -229,7 +237,7 @@ func (u *Updater) check() error { } func (u *Updater) backup() error { - log.Debug("updater: backing up the current configuration") + log.Debug("updater: backing up current configuration") _ = os.Mkdir(u.backupDir, 0o755) err := copyFile(u.confName, filepath.Join(u.backupDir, "AdGuardHome.yaml")) if err != nil { @@ -252,7 +260,7 @@ func (u *Updater) replace() error { return fmt.Errorf("copySupportingFiles(%s, %s) failed: %s", u.updateDir, u.workDir, err) } - log.Debug("updater: renaming: %s -> %s", u.currentExeName, u.backupExeName) + log.Debug("updater: renaming: %s to %s", u.currentExeName, u.backupExeName) err = os.Rename(u.currentExeName, u.backupExeName) if err != nil { return err @@ -268,7 +276,7 @@ func (u *Updater) replace() error { return err } - log.Debug("updater: renamed: %s -> %s", u.updateExeName, u.currentExeName) + log.Debug("updater: renamed: %s to %s", u.updateExeName, u.currentExeName) return nil } @@ -297,7 +305,7 @@ func (u *Updater) downloadPackageFile(url, filename string) (err error) { return fmt.Errorf("http request failed: %w", err) } - log.Debug("updater: reading HTTP body") + log.Debug("updater: reading http body") // This use of ReadAll is now safe, because we limited body's Reader. body, err := io.ReadAll(r) if err != nil { @@ -343,7 +351,7 @@ func tarGzFileUnpackOne(outDir string, tr *tar.Reader, hdr *tar.Header) (name st } if hdr.Typeflag != tar.TypeReg { - log.Debug("updater: %s: unknown file type %d, skipping", name, hdr.Typeflag) + log.Info("updater: %s: unknown file type %d, skipping", name, hdr.Typeflag) return "", nil } @@ -364,7 +372,7 @@ func tarGzFileUnpackOne(outDir string, tr *tar.Reader, hdr *tar.Header) (name st return "", fmt.Errorf("io.Copy(): %w", err) } - log.Tracef("updater: created file %s", outputName) + log.Debug("updater: created file %q", outputName) return name, nil } @@ -440,7 +448,7 @@ func zipFileUnpackOne(outDir string, zf *zip.File) (name string, err error) { return "", fmt.Errorf("os.Mkdir(%q): %w", outputName, err) } - log.Tracef("created directory %q", outputName) + log.Debug("updater: created directory %q", outputName) return "", nil } @@ -457,7 +465,7 @@ func zipFileUnpackOne(outDir string, zf *zip.File) (name string, err error) { return "", fmt.Errorf("io.Copy(): %w", err) } - log.Tracef("created file %s", outputName) + log.Debug("updater: created file %q", outputName) return name, nil } @@ -516,7 +524,7 @@ func copySupportingFiles(files []string, srcdir, dstdir string) error { return err } - log.Debug("updater: copied: %q -> %q", src, dst) + log.Debug("updater: copied: %q to %q", src, dst) } return nil diff --git a/internal/updater/updater_test.go b/internal/updater/updater_test.go index 3a29d277..771fb6d4 100644 --- a/internal/updater/updater_test.go +++ b/internal/updater/updater_test.go @@ -10,6 +10,7 @@ import ( "strconv" "testing" + "github.com/AdguardTeam/AdGuardHome/internal/aghalg" "github.com/AdguardTeam/AdGuardHome/internal/aghtest" "github.com/AdguardTeam/AdGuardHome/internal/version" "github.com/AdguardTeam/golibs/testutil" @@ -92,10 +93,7 @@ func TestUpdateGetVersion(t *testing.T) { assert.Equal(t, "v0.103.0-beta.2", info.NewVersion) assert.Equal(t, "AdGuard Home v0.103.0-beta.2 is now available!", info.Announcement) assert.Equal(t, "https://github.com/AdguardTeam/AdGuardHome/internal/releases", info.AnnouncementURL) - assert.Equal(t, "v0.0", info.SelfUpdateMinVersion) - if assert.NotNil(t, info.CanAutoUpdate) { - assert.True(t, *info.CanAutoUpdate) - } + assert.Equal(t, aghalg.NBTrue, info.CanAutoUpdate) // check cached _, err = u.VersionInfo(false) @@ -290,10 +288,7 @@ func TestUpdater_VersionInto_ARM(t *testing.T) { assert.Equal(t, "v0.103.0-beta.2", info.NewVersion) assert.Equal(t, "AdGuard Home v0.103.0-beta.2 is now available!", info.Announcement) assert.Equal(t, "https://github.com/AdguardTeam/AdGuardHome/internal/releases", info.AnnouncementURL) - assert.Equal(t, "v0.0", info.SelfUpdateMinVersion) - if assert.NotNil(t, info.CanAutoUpdate) { - assert.True(t, *info.CanAutoUpdate) - } + assert.Equal(t, aghalg.NBTrue, info.CanAutoUpdate) } func TestUpdater_VersionInto_MIPS(t *testing.T) { @@ -330,8 +325,5 @@ func TestUpdater_VersionInto_MIPS(t *testing.T) { assert.Equal(t, "v0.103.0-beta.2", info.NewVersion) assert.Equal(t, "AdGuard Home v0.103.0-beta.2 is now available!", info.Announcement) assert.Equal(t, "https://github.com/AdguardTeam/AdGuardHome/internal/releases", info.AnnouncementURL) - assert.Equal(t, "v0.0", info.SelfUpdateMinVersion) - if assert.NotNil(t, info.CanAutoUpdate) { - assert.True(t, *info.CanAutoUpdate) - } + assert.Equal(t, aghalg.NBTrue, info.CanAutoUpdate) } diff --git a/scripts/make/build-release.sh b/scripts/make/build-release.sh index 36fc98f7..2cf95086 100644 --- a/scripts/make/build-release.sh +++ b/scripts/make/build-release.sh @@ -363,6 +363,7 @@ else fi readonly announcement_url +# TODO(a.garipov): Remove "selfupdate_min_version" in future versions. rm -f "$version_json" echo "{ \"version\": \"${version}\", From d3f39b0aa168ddf89755e769a1477ae3c91ece3a Mon Sep 17 00:00:00 2001 From: Ildar Kamalov Date: Fri, 10 Jun 2022 12:41:20 +0300 Subject: [PATCH 25/79] Pull request: 4637 fix blocked services icons and actions highlight Updates #4637 Squashed commit of the following: commit d69887586d15582406fab642e576a46f8984107b Merge: 65453371 e738508d Author: Ildar Kamalov Date: Fri Jun 10 12:07:29 2022 +0300 Merge branch 'master' into 4637-table commit 65453371fc7309e772a12fb9f522247e1392a64a Author: Ildar Kamalov Date: Thu Jun 9 18:43:44 2022 +0300 client: fix blocked services icons and actions highlight --- client/src/components/Filters/Rewrites/Table.js | 2 ++ client/src/components/Filters/Table.js | 4 +++- client/src/components/Logs/Logs.css | 9 +++++++++ client/src/components/Settings/Clients/ClientsTable.js | 4 +++- .../src/components/Settings/Dhcp/StaticLeases/index.js | 2 ++ 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/client/src/components/Filters/Rewrites/Table.js b/client/src/components/Filters/Rewrites/Table.js index 45638ec0..28009ca3 100644 --- a/client/src/components/Filters/Rewrites/Table.js +++ b/client/src/components/Filters/Rewrites/Table.js @@ -29,6 +29,8 @@ class Table extends Component { Header: this.props.t('actions_table_header'), accessor: 'actions', maxWidth: 100, + sortable: false, + resizable: false, Cell: (value) => (
@@ -101,6 +103,7 @@ Form.propTypes = { ip: PropTypes.string.isRequired, hostname: PropTypes.string.isRequired, cidr: PropTypes.string.isRequired, + gatewayIp: PropTypes.string, }), pristine: PropTypes.bool.isRequired, handleSubmit: PropTypes.func.isRequired, diff --git a/client/src/components/Settings/Dhcp/StaticLeases/Modal.js b/client/src/components/Settings/Dhcp/StaticLeases/Modal.js index 8ad0f009..0baf487e 100644 --- a/client/src/components/Settings/Dhcp/StaticLeases/Modal.js +++ b/client/src/components/Settings/Dhcp/StaticLeases/Modal.js @@ -13,6 +13,7 @@ const Modal = ({ cidr, rangeStart, rangeEnd, + gatewayIp, }) => { const dispatch = useDispatch(); @@ -42,6 +43,7 @@ const Modal = ({ cidr, rangeStart, rangeEnd, + gatewayIp, }} onSubmit={handleSubmit} processingAdding={processingAdding} @@ -61,6 +63,7 @@ Modal.propTypes = { cidr: PropTypes.string.isRequired, rangeStart: PropTypes.string, rangeEnd: PropTypes.string, + gatewayIp: PropTypes.string, }; export default withTranslation()(Modal); diff --git a/client/src/components/Settings/Dhcp/StaticLeases/index.js b/client/src/components/Settings/Dhcp/StaticLeases/index.js index a63f78cd..2374f044 100644 --- a/client/src/components/Settings/Dhcp/StaticLeases/index.js +++ b/client/src/components/Settings/Dhcp/StaticLeases/index.js @@ -24,6 +24,7 @@ const StaticLeases = ({ cidr, rangeStart, rangeEnd, + gatewayIp, }) => { const [t] = useTranslation(); const dispatch = useDispatch(); @@ -106,6 +107,7 @@ const StaticLeases = ({ cidr={cidr} rangeStart={rangeStart} rangeEnd={rangeEnd} + gatewayIp={gatewayIp} /> ); @@ -119,6 +121,7 @@ StaticLeases.propTypes = { cidr: PropTypes.string.isRequired, rangeStart: PropTypes.string, rangeEnd: PropTypes.string, + gatewayIp: PropTypes.string, }; cellWrap.propTypes = { diff --git a/client/src/components/Settings/Dhcp/index.js b/client/src/components/Settings/Dhcp/index.js index a84e0a93..bd3a45e3 100644 --- a/client/src/components/Settings/Dhcp/index.js +++ b/client/src/components/Settings/Dhcp/index.js @@ -278,6 +278,7 @@ const Dhcp = () => { cidr={cidr} rangeStart={dhcp?.values?.v4?.range_start} rangeEnd={dhcp?.values?.v4?.range_end} + gatewayIp={dhcp?.values?.v4?.gateway_ip} />
; + const blockButton = ( + <> +
+ + + ); const blockForClientButton =