Pull request 2307: AGDNS-2556 Custom updater URL
Squashed commit of the following: commit 73f946138ccb4f89141f192b6cb1a21887604ab4 Merge: c58847bfbd578c713fAuthor: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Nov 26 17:42:29 2024 +0300 Merge branch 'master' into AGDNS-2556-custom-update-url commit c58847bfb08131263e1cff4813eb4a466f613d91 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Nov 26 17:34:11 2024 +0300 home: imp logging commit 0d451621d76fdf2c363d223eb29c4442d8f36dc8 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Nov 26 15:12:04 2024 +0300 home: rename config field commit c7f3822929e9199f8f411f1a0ad072c643feb42f Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Nov 26 15:07:09 2024 +0300 all: enable updater for some cases commit 872cd3a18c876076ea643624336cfc0a4296a81d Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Fri Nov 22 19:09:18 2024 +0300 updater: imp test commit c9efb412e7411b769df54b7247fe168047fb9799 Merge: c989eef71abb738013Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Fri Nov 22 17:51:46 2024 +0300 Merge branch 'master' into AGDNS-2556-custom-update-url commit c989eef715ae7edd98d7b2d5df06fd3d04153209 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Fri Nov 22 17:46:34 2024 +0300 all: imp code commit 0452d8b356e6d0b73b097d43b97b7027fcca752d Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Fri Nov 22 15:37:21 2024 +0300 all: add custom url to updater
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/AdguardTeam/golibs/errors"
|
||||
"github.com/AdguardTeam/golibs/ioutil"
|
||||
"github.com/AdguardTeam/golibs/log"
|
||||
"github.com/c2h5oh/datasize"
|
||||
)
|
||||
|
||||
// TODO(a.garipov): Make configurable.
|
||||
@@ -28,8 +29,9 @@ type VersionInfo struct {
|
||||
CanAutoUpdate aghalg.NullBool `json:"can_autoupdate,omitempty"`
|
||||
}
|
||||
|
||||
// MaxResponseSize is responses on server's requests maximum length in bytes.
|
||||
const MaxResponseSize = 64 * 1024
|
||||
// maxVersionRespSize is the maximum length in bytes for version information
|
||||
// response.
|
||||
const maxVersionRespSize datasize.ByteSize = 64 * datasize.KB
|
||||
|
||||
// VersionInfo downloads the latest version information. If forceRecheck is
|
||||
// false and there are cached results, those results are returned.
|
||||
@@ -51,7 +53,7 @@ func (u *Updater) VersionInfo(forceRecheck bool) (vi VersionInfo, err error) {
|
||||
}
|
||||
defer func() { err = errors.WithDeferred(err, resp.Body.Close()) }()
|
||||
|
||||
r := ioutil.LimitReader(resp.Body, MaxResponseSize)
|
||||
r := ioutil.LimitReader(resp.Body, maxVersionRespSize.Bytes())
|
||||
|
||||
// This use of ReadAll is safe, because we just limited the appropriate
|
||||
// ReadCloser.
|
||||
|
||||
Reference in New Issue
Block a user