From f25639f1fc6e4a082f8ab6042053bc7b11ab8ccf Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Mon, 27 May 2019 18:48:33 +0300 Subject: [PATCH 1/4] + app: disable new version check and auto-update by command line switch --- AGHTechDoc.md | 6 ++++++ app.go | 3 +++ config.go | 1 + control_update.go | 5 +++++ 4 files changed, 15 insertions(+) diff --git a/AGHTechDoc.md b/AGHTechDoc.md index 7564a007..e88bb055 100644 --- a/AGHTechDoc.md +++ b/AGHTechDoc.md @@ -256,6 +256,12 @@ Response: If `can_autoupdate` is true, then the server can automatically upgrade to a new version. +Response with empty body: + + 200 OK + +It means that update check is disabled by user. UI should do nothing. + ### Update command diff --git a/app.go b/app.go index 1c32aa52..6345564e 100644 --- a/app.go +++ b/app.go @@ -79,6 +79,7 @@ func run(args options) { log.Info("AdGuard Home is running as a service") } config.runningAsService = args.runningAsService + config.disableUpdate = args.disableUpdate config.firstRun = detectFirstRun() if config.firstRun { @@ -408,6 +409,7 @@ type options struct { logFile string // Path to the log file. If empty, write to stdout. If "syslog", writes to syslog pidFile string // File name to save PID to checkConfig bool // Check configuration and exit + disableUpdate bool // If set, don't check for updates // service control action (see service.ControlAction array + "status" command) serviceControlAction string @@ -446,6 +448,7 @@ func loadOptions() options { }, nil}, {"pidfile", "", "Path to a file where PID is stored", func(value string) { o.pidFile = value }, nil}, {"check-config", "", "Check configuration and exit", nil, func() { o.checkConfig = true }}, + {"no-check-update", "", "Don't check for updates", nil, func() { o.disableUpdate = true }}, {"verbose", "v", "Enable verbose output", nil, func() { o.verbose = true }}, {"help", "", "Print this help", nil, func() { printHelp() diff --git a/config.go b/config.go index 49ffe93a..c6edde0f 100644 --- a/config.go +++ b/config.go @@ -39,6 +39,7 @@ type configuration struct { firstRun bool // if set to true, don't run any services except HTTP web inteface, and serve only first-run html // runningAsService flag is set to true when options are passed from the service runner runningAsService bool + disableUpdate bool // If set, don't check for updates BindHost string `yaml:"bind_host"` // BindHost is the IP address of the HTTP server to bind to BindPort int `yaml:"bind_port"` // BindPort is the port the HTTP server diff --git a/control_update.go b/control_update.go index 247eb043..987457da 100644 --- a/control_update.go +++ b/control_update.go @@ -52,6 +52,11 @@ func getVersionResp(data []byte) []byte { func handleGetVersionJSON(w http.ResponseWriter, r *http.Request) { log.Tracef("%s %v", r.Method, r.URL) + if config.disableUpdate { + log.Tracef("New app version check is disabled by user") + return + } + now := time.Now() controlLock.Lock() cached := now.Sub(versionCheckLastTime) <= versionCheckPeriod && len(versionCheckJSON) != 0 From 5b29cae1331d5c49974f7f2861d378bd63a716e7 Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Tue, 28 May 2019 11:41:36 +0300 Subject: [PATCH 2/4] * openapi: update /version.json description --- openapi/openapi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index 6fd9503f..2f0f98db 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -144,7 +144,7 @@ paths: - 'application/json' responses: 200: - description: 'Version info' + description: 'Version info. If response message is empty, UI doesn't show a version update message.' schema: $ref: "#/definitions/VersionInfo" 500: From 6ab8aa4da179a14997a289045dd8ca1fbe95ddb5 Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Tue, 28 May 2019 11:42:50 +0300 Subject: [PATCH 3/4] * docker: use --no-check-update --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8b89e11b..97b4ac30 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,4 +29,4 @@ WORKDIR /opt/adguardhome/work #USER nobody ENTRYPOINT ["/opt/adguardhome/AdGuardHome"] -CMD ["-c", "/opt/adguardhome/conf/AdGuardHome.yaml", "-w", "/opt/adguardhome/work"] +CMD ["-c", "/opt/adguardhome/conf/AdGuardHome.yaml", "-w", "/opt/adguardhome/work", "--no-check-update"] From 9f75146eaba9d9a3ce085c884d7f18a2c628dc50 Mon Sep 17 00:00:00 2001 From: Ildar Kamalov Date: Tue, 28 May 2019 15:22:48 +0300 Subject: [PATCH 4/4] * client: check for empty versions response --- client/src/reducers/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/reducers/index.js b/client/src/reducers/index.js index 58b16e94..09c93a99 100644 --- a/client/src/reducers/index.js +++ b/client/src/reducers/index.js @@ -122,7 +122,7 @@ const dashboard = handleActions({ [actions.getVersionSuccess]: (state, { payload }) => { const currentVersion = state.dnsVersion === 'undefined' ? 0 : state.dnsVersion; - if (versionCompare(currentVersion, payload.version) === -1) { + if (payload && versionCompare(currentVersion, payload.version) === -1) { const { version, announcement_url: announcementUrl,