From 0e1015a4ee7f4101ef21cb2b2688beb50a11dc83 Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Mon, 13 Dec 2021 14:56:48 +0300 Subject: [PATCH] all: doc changes, imp names --- CHANGELOG.md | 2 ++ internal/home/clients.go | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 044b9688..b0a6d96d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ and this project adheres to ### Changed +- Client objects in the configuration file are now sorted ([#3933]). - Responses from cache are now labeled ([#3772]). - Better error message for ED25519 private keys, which are not widely supported ([#3737]). @@ -229,6 +230,7 @@ In this release, the schema version has changed from 10 to 12. [#3772]: https://github.com/AdguardTeam/AdGuardHome/issues/3772 [#3815]: https://github.com/AdguardTeam/AdGuardHome/issues/3815 [#3890]: https://github.com/AdguardTeam/AdGuardHome/issues/3890 +[#3933]: https://github.com/AdguardTeam/AdGuardHome/pull/3933 diff --git a/internal/home/clients.go b/internal/home/clients.go index 09472fbd..78cc7101 100644 --- a/internal/home/clients.go +++ b/internal/home/clients.go @@ -224,9 +224,9 @@ func (clients *clientsContainer) WriteDiskConfig(objects *[]clientObject) { clients.lock.Lock() defer clients.lock.Unlock() - clientObjects := []clientObject{} + var clientObjects []clientObject for _, cli := range clients.list { - cy := clientObject{ + cliObj := clientObject{ Name: cli.Name, UseGlobalSettings: !cli.UseOwnSettings, FilteringEnabled: cli.FilteringEnabled, @@ -236,18 +236,18 @@ func (clients *clientsContainer) WriteDiskConfig(objects *[]clientObject) { UseGlobalBlockedServices: !cli.UseOwnBlockedServices, } - cy.Tags = stringutil.CloneSlice(cli.Tags) - cy.IDs = stringutil.CloneSlice(cli.IDs) - cy.BlockedServices = stringutil.CloneSlice(cli.BlockedServices) - cy.Upstreams = stringutil.CloneSlice(cli.Upstreams) + cliObj.Tags = stringutil.CloneSlice(cli.Tags) + cliObj.IDs = stringutil.CloneSlice(cli.IDs) + cliObj.BlockedServices = stringutil.CloneSlice(cli.BlockedServices) + cliObj.Upstreams = stringutil.CloneSlice(cli.Upstreams) - clientObjects = append(clientObjects, cy) + clientObjects = append(clientObjects, cliObj) } // Maps aren't guaranteed to iterate in the same order each time, so the - // above loop can generate different orderings when writing to the - // config file: this produces lots of diffs in config files, so sort - // objects by name before writing. + // above loop can generate different orderings when writing to the config + // file: this produces lots of diffs in config files, so sort objects by + // name before writing. sort.Slice(clientObjects, func(i, j int) bool { return clientObjects[i].Name < clientObjects[j].Name })