AdGuardHome/internal/client/index.go

369 lines
8.3 KiB
Go
Raw Permalink Normal View History

package client
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
import (
"fmt"
"net"
"net/netip"
Pull request 2208: AG-27492-client-persistent-list Squashed commit of the following: commit 1b1a21b07baa15499e5e4963d35bfd2e542533ed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:32:38 2024 +0300 client: imp tests commit 7e6d17158a254aa29bf4033fb68171d4209bb954 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:27:00 2024 +0300 client: imp tests commit 5e4cd2b3ca9557929b9b79a0610151ce09c792f9 Merge: 7faddd8aa 1a62ce471 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 15:57:33 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 7faddd8aade2b1b791beec694b88513b0a2a520e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:55:43 2024 +0300 client: imp code commit 54212e975b700f792a53fc3bfe1c2970778e05ea Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:24:18 2024 +0300 all: imp code commit 3f23c9af470036c2166e20c8d0b5d84810b35b6e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 17:07:40 2024 +0300 home: imp tests commit 39b99fc050047cebadc51ae64e220ec1cb873d83 Merge: 76469ac59 17c4eeb64 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 16:39:56 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 76469ac59400aae2f7563750a981138b8cbf3aa1 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 14:36:22 2024 +0300 home: imp naming commit 4e4aa5802c9aafc67c52b8a290d8046531f8a1c8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:50:45 2024 +0300 client: imp docs commit bf5c23a72c93e58c8bc7e0ca896b2ea28519cf54 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:40:53 2024 +0300 home: add tests commit c6cdba7a8d0dfce22634f88258f61abb09ecca5a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:21:44 2024 +0300 all: add tests commit 1fc43cb45efbd428abaae9eba030f9bea818dfe3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 19:19:48 2024 +0300 all: add tests commit ccc423b296d9037f0aa23a125a5ad3af95b8c9f3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 15:37:15 2024 +0300 all: client persistent list
2024-05-13 18:09:18 +01:00
"slices"
"strings"
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
"github.com/AdguardTeam/AdGuardHome/internal/aghalg"
"github.com/AdguardTeam/golibs/errors"
Pull request 2208: AG-27492-client-persistent-list Squashed commit of the following: commit 1b1a21b07baa15499e5e4963d35bfd2e542533ed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:32:38 2024 +0300 client: imp tests commit 7e6d17158a254aa29bf4033fb68171d4209bb954 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:27:00 2024 +0300 client: imp tests commit 5e4cd2b3ca9557929b9b79a0610151ce09c792f9 Merge: 7faddd8aa 1a62ce471 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 15:57:33 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 7faddd8aade2b1b791beec694b88513b0a2a520e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:55:43 2024 +0300 client: imp code commit 54212e975b700f792a53fc3bfe1c2970778e05ea Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:24:18 2024 +0300 all: imp code commit 3f23c9af470036c2166e20c8d0b5d84810b35b6e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 17:07:40 2024 +0300 home: imp tests commit 39b99fc050047cebadc51ae64e220ec1cb873d83 Merge: 76469ac59 17c4eeb64 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 16:39:56 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 76469ac59400aae2f7563750a981138b8cbf3aa1 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 14:36:22 2024 +0300 home: imp naming commit 4e4aa5802c9aafc67c52b8a290d8046531f8a1c8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:50:45 2024 +0300 client: imp docs commit bf5c23a72c93e58c8bc7e0ca896b2ea28519cf54 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:40:53 2024 +0300 home: add tests commit c6cdba7a8d0dfce22634f88258f61abb09ecca5a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:21:44 2024 +0300 all: add tests commit 1fc43cb45efbd428abaae9eba030f9bea818dfe3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 19:19:48 2024 +0300 all: add tests commit ccc423b296d9037f0aa23a125a5ad3af95b8c9f3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 15:37:15 2024 +0300 all: client persistent list
2024-05-13 18:09:18 +01:00
"golang.org/x/exp/maps"
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
)
// macKey contains MAC as byte array of 6, 8, or 20 bytes.
type macKey any
// macToKey converts mac into key of type macKey, which is used as the key of
// the [clientIndex.macToUID]. mac must be valid MAC address.
func macToKey(mac net.HardwareAddr) (key macKey) {
switch len(mac) {
case 6:
return [6]byte(mac)
case 8:
return [8]byte(mac)
case 20:
return [20]byte(mac)
default:
panic(fmt.Errorf("invalid mac address %#v", mac))
}
}
// Index stores all information about persistent clients.
type Index struct {
Pull request 2208: AG-27492-client-persistent-list Squashed commit of the following: commit 1b1a21b07baa15499e5e4963d35bfd2e542533ed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:32:38 2024 +0300 client: imp tests commit 7e6d17158a254aa29bf4033fb68171d4209bb954 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:27:00 2024 +0300 client: imp tests commit 5e4cd2b3ca9557929b9b79a0610151ce09c792f9 Merge: 7faddd8aa 1a62ce471 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 15:57:33 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 7faddd8aade2b1b791beec694b88513b0a2a520e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:55:43 2024 +0300 client: imp code commit 54212e975b700f792a53fc3bfe1c2970778e05ea Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:24:18 2024 +0300 all: imp code commit 3f23c9af470036c2166e20c8d0b5d84810b35b6e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 17:07:40 2024 +0300 home: imp tests commit 39b99fc050047cebadc51ae64e220ec1cb873d83 Merge: 76469ac59 17c4eeb64 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 16:39:56 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 76469ac59400aae2f7563750a981138b8cbf3aa1 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 14:36:22 2024 +0300 home: imp naming commit 4e4aa5802c9aafc67c52b8a290d8046531f8a1c8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:50:45 2024 +0300 client: imp docs commit bf5c23a72c93e58c8bc7e0ca896b2ea28519cf54 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:40:53 2024 +0300 home: add tests commit c6cdba7a8d0dfce22634f88258f61abb09ecca5a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:21:44 2024 +0300 all: add tests commit 1fc43cb45efbd428abaae9eba030f9bea818dfe3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 19:19:48 2024 +0300 all: add tests commit ccc423b296d9037f0aa23a125a5ad3af95b8c9f3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 15:37:15 2024 +0300 all: client persistent list
2024-05-13 18:09:18 +01:00
// nameToUID maps client name to UID.
nameToUID map[string]UID
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
// clientIDToUID maps client ID to UID.
clientIDToUID map[string]UID
// ipToUID maps IP address to UID.
ipToUID map[netip.Addr]UID
// macToUID maps MAC address to UID.
macToUID map[macKey]UID
// uidToClient maps UID to the persistent client.
uidToClient map[UID]*Persistent
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
// subnetToUID maps subnet to UID.
subnetToUID aghalg.SortedMap[netip.Prefix, UID]
}
// NewIndex initializes the new instance of client index.
func NewIndex() (ci *Index) {
return &Index{
Pull request 2208: AG-27492-client-persistent-list Squashed commit of the following: commit 1b1a21b07baa15499e5e4963d35bfd2e542533ed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:32:38 2024 +0300 client: imp tests commit 7e6d17158a254aa29bf4033fb68171d4209bb954 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:27:00 2024 +0300 client: imp tests commit 5e4cd2b3ca9557929b9b79a0610151ce09c792f9 Merge: 7faddd8aa 1a62ce471 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 15:57:33 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 7faddd8aade2b1b791beec694b88513b0a2a520e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:55:43 2024 +0300 client: imp code commit 54212e975b700f792a53fc3bfe1c2970778e05ea Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:24:18 2024 +0300 all: imp code commit 3f23c9af470036c2166e20c8d0b5d84810b35b6e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 17:07:40 2024 +0300 home: imp tests commit 39b99fc050047cebadc51ae64e220ec1cb873d83 Merge: 76469ac59 17c4eeb64 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 16:39:56 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 76469ac59400aae2f7563750a981138b8cbf3aa1 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 14:36:22 2024 +0300 home: imp naming commit 4e4aa5802c9aafc67c52b8a290d8046531f8a1c8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:50:45 2024 +0300 client: imp docs commit bf5c23a72c93e58c8bc7e0ca896b2ea28519cf54 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:40:53 2024 +0300 home: add tests commit c6cdba7a8d0dfce22634f88258f61abb09ecca5a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:21:44 2024 +0300 all: add tests commit 1fc43cb45efbd428abaae9eba030f9bea818dfe3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 19:19:48 2024 +0300 all: add tests commit ccc423b296d9037f0aa23a125a5ad3af95b8c9f3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 15:37:15 2024 +0300 all: client persistent list
2024-05-13 18:09:18 +01:00
nameToUID: map[string]UID{},
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
clientIDToUID: map[string]UID{},
ipToUID: map[netip.Addr]UID{},
subnetToUID: aghalg.NewSortedMap[netip.Prefix, UID](subnetCompare),
macToUID: map[macKey]UID{},
uidToClient: map[UID]*Persistent{},
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
}
}
// Add stores information about a persistent client in the index. c must be
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
// non-nil and contain UID.
func (ci *Index) Add(c *Persistent) {
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
if (c.UID == UID{}) {
panic("client must contain uid")
}
Pull request 2208: AG-27492-client-persistent-list Squashed commit of the following: commit 1b1a21b07baa15499e5e4963d35bfd2e542533ed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:32:38 2024 +0300 client: imp tests commit 7e6d17158a254aa29bf4033fb68171d4209bb954 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:27:00 2024 +0300 client: imp tests commit 5e4cd2b3ca9557929b9b79a0610151ce09c792f9 Merge: 7faddd8aa 1a62ce471 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 15:57:33 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 7faddd8aade2b1b791beec694b88513b0a2a520e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:55:43 2024 +0300 client: imp code commit 54212e975b700f792a53fc3bfe1c2970778e05ea Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:24:18 2024 +0300 all: imp code commit 3f23c9af470036c2166e20c8d0b5d84810b35b6e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 17:07:40 2024 +0300 home: imp tests commit 39b99fc050047cebadc51ae64e220ec1cb873d83 Merge: 76469ac59 17c4eeb64 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 16:39:56 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 76469ac59400aae2f7563750a981138b8cbf3aa1 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 14:36:22 2024 +0300 home: imp naming commit 4e4aa5802c9aafc67c52b8a290d8046531f8a1c8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:50:45 2024 +0300 client: imp docs commit bf5c23a72c93e58c8bc7e0ca896b2ea28519cf54 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:40:53 2024 +0300 home: add tests commit c6cdba7a8d0dfce22634f88258f61abb09ecca5a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:21:44 2024 +0300 all: add tests commit 1fc43cb45efbd428abaae9eba030f9bea818dfe3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 19:19:48 2024 +0300 all: add tests commit ccc423b296d9037f0aa23a125a5ad3af95b8c9f3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 15:37:15 2024 +0300 all: client persistent list
2024-05-13 18:09:18 +01:00
ci.nameToUID[c.Name] = c.UID
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
for _, id := range c.ClientIDs {
ci.clientIDToUID[id] = c.UID
}
for _, ip := range c.IPs {
ci.ipToUID[ip] = c.UID
}
for _, pref := range c.Subnets {
ci.subnetToUID.Set(pref, c.UID)
}
for _, mac := range c.MACs {
k := macToKey(mac)
ci.macToUID[k] = c.UID
}
ci.uidToClient[c.UID] = c
}
Pull request 2208: AG-27492-client-persistent-list Squashed commit of the following: commit 1b1a21b07baa15499e5e4963d35bfd2e542533ed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:32:38 2024 +0300 client: imp tests commit 7e6d17158a254aa29bf4033fb68171d4209bb954 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:27:00 2024 +0300 client: imp tests commit 5e4cd2b3ca9557929b9b79a0610151ce09c792f9 Merge: 7faddd8aa 1a62ce471 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 15:57:33 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 7faddd8aade2b1b791beec694b88513b0a2a520e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:55:43 2024 +0300 client: imp code commit 54212e975b700f792a53fc3bfe1c2970778e05ea Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:24:18 2024 +0300 all: imp code commit 3f23c9af470036c2166e20c8d0b5d84810b35b6e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 17:07:40 2024 +0300 home: imp tests commit 39b99fc050047cebadc51ae64e220ec1cb873d83 Merge: 76469ac59 17c4eeb64 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 16:39:56 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 76469ac59400aae2f7563750a981138b8cbf3aa1 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 14:36:22 2024 +0300 home: imp naming commit 4e4aa5802c9aafc67c52b8a290d8046531f8a1c8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:50:45 2024 +0300 client: imp docs commit bf5c23a72c93e58c8bc7e0ca896b2ea28519cf54 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:40:53 2024 +0300 home: add tests commit c6cdba7a8d0dfce22634f88258f61abb09ecca5a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:21:44 2024 +0300 all: add tests commit 1fc43cb45efbd428abaae9eba030f9bea818dfe3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 19:19:48 2024 +0300 all: add tests commit ccc423b296d9037f0aa23a125a5ad3af95b8c9f3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 15:37:15 2024 +0300 all: client persistent list
2024-05-13 18:09:18 +01:00
// ClashesUID returns existing persistent client with the same UID as c. Note
// that this is only possible when configuration contains duplicate fields.
func (ci *Index) ClashesUID(c *Persistent) (err error) {
p, ok := ci.uidToClient[c.UID]
if ok {
return fmt.Errorf("another client %q uses the same uid", p.Name)
}
return nil
}
// Clashes returns an error if the index contains a different persistent client
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
// with at least a single identifier contained by c. c must be non-nil.
func (ci *Index) Clashes(c *Persistent) (err error) {
Pull request 2208: AG-27492-client-persistent-list Squashed commit of the following: commit 1b1a21b07baa15499e5e4963d35bfd2e542533ed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:32:38 2024 +0300 client: imp tests commit 7e6d17158a254aa29bf4033fb68171d4209bb954 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:27:00 2024 +0300 client: imp tests commit 5e4cd2b3ca9557929b9b79a0610151ce09c792f9 Merge: 7faddd8aa 1a62ce471 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 15:57:33 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 7faddd8aade2b1b791beec694b88513b0a2a520e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:55:43 2024 +0300 client: imp code commit 54212e975b700f792a53fc3bfe1c2970778e05ea Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:24:18 2024 +0300 all: imp code commit 3f23c9af470036c2166e20c8d0b5d84810b35b6e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 17:07:40 2024 +0300 home: imp tests commit 39b99fc050047cebadc51ae64e220ec1cb873d83 Merge: 76469ac59 17c4eeb64 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 16:39:56 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 76469ac59400aae2f7563750a981138b8cbf3aa1 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 14:36:22 2024 +0300 home: imp naming commit 4e4aa5802c9aafc67c52b8a290d8046531f8a1c8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:50:45 2024 +0300 client: imp docs commit bf5c23a72c93e58c8bc7e0ca896b2ea28519cf54 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:40:53 2024 +0300 home: add tests commit c6cdba7a8d0dfce22634f88258f61abb09ecca5a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:21:44 2024 +0300 all: add tests commit 1fc43cb45efbd428abaae9eba030f9bea818dfe3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 19:19:48 2024 +0300 all: add tests commit ccc423b296d9037f0aa23a125a5ad3af95b8c9f3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 15:37:15 2024 +0300 all: client persistent list
2024-05-13 18:09:18 +01:00
if p := ci.clashesName(c); p != nil {
return fmt.Errorf("another client uses the same name %q", p.Name)
}
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
for _, id := range c.ClientIDs {
Pull request 2208: AG-27492-client-persistent-list Squashed commit of the following: commit 1b1a21b07baa15499e5e4963d35bfd2e542533ed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:32:38 2024 +0300 client: imp tests commit 7e6d17158a254aa29bf4033fb68171d4209bb954 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:27:00 2024 +0300 client: imp tests commit 5e4cd2b3ca9557929b9b79a0610151ce09c792f9 Merge: 7faddd8aa 1a62ce471 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 15:57:33 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 7faddd8aade2b1b791beec694b88513b0a2a520e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:55:43 2024 +0300 client: imp code commit 54212e975b700f792a53fc3bfe1c2970778e05ea Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:24:18 2024 +0300 all: imp code commit 3f23c9af470036c2166e20c8d0b5d84810b35b6e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 17:07:40 2024 +0300 home: imp tests commit 39b99fc050047cebadc51ae64e220ec1cb873d83 Merge: 76469ac59 17c4eeb64 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 16:39:56 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 76469ac59400aae2f7563750a981138b8cbf3aa1 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 14:36:22 2024 +0300 home: imp naming commit 4e4aa5802c9aafc67c52b8a290d8046531f8a1c8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:50:45 2024 +0300 client: imp docs commit bf5c23a72c93e58c8bc7e0ca896b2ea28519cf54 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:40:53 2024 +0300 home: add tests commit c6cdba7a8d0dfce22634f88258f61abb09ecca5a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:21:44 2024 +0300 all: add tests commit 1fc43cb45efbd428abaae9eba030f9bea818dfe3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 19:19:48 2024 +0300 all: add tests commit ccc423b296d9037f0aa23a125a5ad3af95b8c9f3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 15:37:15 2024 +0300 all: client persistent list
2024-05-13 18:09:18 +01:00
existing, ok := ci.clientIDToUID[id]
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
if ok && existing != c.UID {
p := ci.uidToClient[existing]
return fmt.Errorf("another client %q uses the same ClientID %q", p.Name, id)
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
}
}
p, ip := ci.clashesIP(c)
if p != nil {
return fmt.Errorf("another client %q uses the same IP %q", p.Name, ip)
}
p, s := ci.clashesSubnet(c)
if p != nil {
return fmt.Errorf("another client %q uses the same subnet %q", p.Name, s)
}
p, mac := ci.clashesMAC(c)
if p != nil {
return fmt.Errorf("another client %q uses the same MAC %q", p.Name, mac)
}
return nil
}
Pull request 2208: AG-27492-client-persistent-list Squashed commit of the following: commit 1b1a21b07baa15499e5e4963d35bfd2e542533ed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:32:38 2024 +0300 client: imp tests commit 7e6d17158a254aa29bf4033fb68171d4209bb954 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:27:00 2024 +0300 client: imp tests commit 5e4cd2b3ca9557929b9b79a0610151ce09c792f9 Merge: 7faddd8aa 1a62ce471 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 15:57:33 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 7faddd8aade2b1b791beec694b88513b0a2a520e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:55:43 2024 +0300 client: imp code commit 54212e975b700f792a53fc3bfe1c2970778e05ea Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:24:18 2024 +0300 all: imp code commit 3f23c9af470036c2166e20c8d0b5d84810b35b6e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 17:07:40 2024 +0300 home: imp tests commit 39b99fc050047cebadc51ae64e220ec1cb873d83 Merge: 76469ac59 17c4eeb64 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 16:39:56 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 76469ac59400aae2f7563750a981138b8cbf3aa1 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 14:36:22 2024 +0300 home: imp naming commit 4e4aa5802c9aafc67c52b8a290d8046531f8a1c8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:50:45 2024 +0300 client: imp docs commit bf5c23a72c93e58c8bc7e0ca896b2ea28519cf54 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:40:53 2024 +0300 home: add tests commit c6cdba7a8d0dfce22634f88258f61abb09ecca5a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:21:44 2024 +0300 all: add tests commit 1fc43cb45efbd428abaae9eba030f9bea818dfe3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 19:19:48 2024 +0300 all: add tests commit ccc423b296d9037f0aa23a125a5ad3af95b8c9f3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 15:37:15 2024 +0300 all: client persistent list
2024-05-13 18:09:18 +01:00
// clashesName returns existing persistent client with the same name as c or
// nil. c must be non-nil.
func (ci *Index) clashesName(c *Persistent) (existing *Persistent) {
existing, ok := ci.FindByName(c.Name)
if !ok {
return nil
}
if existing.UID != c.UID {
return existing
}
return nil
}
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
// clashesIP returns a previous client with the same IP address as c. c must be
// non-nil.
func (ci *Index) clashesIP(c *Persistent) (p *Persistent, ip netip.Addr) {
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
for _, ip := range c.IPs {
existing, ok := ci.ipToUID[ip]
if ok && existing != c.UID {
return ci.uidToClient[existing], ip
}
}
return nil, netip.Addr{}
}
// clashesSubnet returns a previous client with the same subnet as c. c must be
// non-nil.
func (ci *Index) clashesSubnet(c *Persistent) (p *Persistent, s netip.Prefix) {
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
for _, s = range c.Subnets {
var existing UID
var ok bool
ci.subnetToUID.Range(func(p netip.Prefix, uid UID) (cont bool) {
if s == p {
existing = uid
ok = true
return false
}
return true
})
if ok && existing != c.UID {
return ci.uidToClient[existing], s
}
}
return nil, netip.Prefix{}
}
// clashesMAC returns a previous client with the same MAC address as c. c must
// be non-nil.
func (ci *Index) clashesMAC(c *Persistent) (p *Persistent, mac net.HardwareAddr) {
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
for _, mac = range c.MACs {
k := macToKey(mac)
existing, ok := ci.macToUID[k]
if ok && existing != c.UID {
return ci.uidToClient[existing], mac
}
}
return nil, nil
}
// Find finds persistent client by string representation of the client ID, IP
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
// address, or MAC.
func (ci *Index) Find(id string) (c *Persistent, ok bool) {
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
uid, found := ci.clientIDToUID[id]
if found {
return ci.uidToClient[uid], true
}
ip, err := netip.ParseAddr(id)
if err == nil {
// MAC addresses can be successfully parsed as IP addresses.
c, found = ci.findByIP(ip)
if found {
return c, true
}
}
mac, err := net.ParseMAC(id)
if err == nil {
Pull request 2208: AG-27492-client-persistent-list Squashed commit of the following: commit 1b1a21b07baa15499e5e4963d35bfd2e542533ed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:32:38 2024 +0300 client: imp tests commit 7e6d17158a254aa29bf4033fb68171d4209bb954 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:27:00 2024 +0300 client: imp tests commit 5e4cd2b3ca9557929b9b79a0610151ce09c792f9 Merge: 7faddd8aa 1a62ce471 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 15:57:33 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 7faddd8aade2b1b791beec694b88513b0a2a520e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:55:43 2024 +0300 client: imp code commit 54212e975b700f792a53fc3bfe1c2970778e05ea Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:24:18 2024 +0300 all: imp code commit 3f23c9af470036c2166e20c8d0b5d84810b35b6e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 17:07:40 2024 +0300 home: imp tests commit 39b99fc050047cebadc51ae64e220ec1cb873d83 Merge: 76469ac59 17c4eeb64 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 16:39:56 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 76469ac59400aae2f7563750a981138b8cbf3aa1 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 14:36:22 2024 +0300 home: imp naming commit 4e4aa5802c9aafc67c52b8a290d8046531f8a1c8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:50:45 2024 +0300 client: imp docs commit bf5c23a72c93e58c8bc7e0ca896b2ea28519cf54 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:40:53 2024 +0300 home: add tests commit c6cdba7a8d0dfce22634f88258f61abb09ecca5a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:21:44 2024 +0300 all: add tests commit 1fc43cb45efbd428abaae9eba030f9bea818dfe3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 19:19:48 2024 +0300 all: add tests commit ccc423b296d9037f0aa23a125a5ad3af95b8c9f3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 15:37:15 2024 +0300 all: client persistent list
2024-05-13 18:09:18 +01:00
return ci.FindByMAC(mac)
}
return nil, false
}
// FindByName finds persistent client by name.
func (ci *Index) FindByName(name string) (c *Persistent, found bool) {
uid, found := ci.nameToUID[name]
if found {
return ci.uidToClient[uid], true
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
}
return nil, false
}
Pull request 2208: AG-27492-client-persistent-list Squashed commit of the following: commit 1b1a21b07baa15499e5e4963d35bfd2e542533ed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:32:38 2024 +0300 client: imp tests commit 7e6d17158a254aa29bf4033fb68171d4209bb954 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:27:00 2024 +0300 client: imp tests commit 5e4cd2b3ca9557929b9b79a0610151ce09c792f9 Merge: 7faddd8aa 1a62ce471 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 15:57:33 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 7faddd8aade2b1b791beec694b88513b0a2a520e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:55:43 2024 +0300 client: imp code commit 54212e975b700f792a53fc3bfe1c2970778e05ea Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:24:18 2024 +0300 all: imp code commit 3f23c9af470036c2166e20c8d0b5d84810b35b6e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 17:07:40 2024 +0300 home: imp tests commit 39b99fc050047cebadc51ae64e220ec1cb873d83 Merge: 76469ac59 17c4eeb64 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 16:39:56 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 76469ac59400aae2f7563750a981138b8cbf3aa1 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 14:36:22 2024 +0300 home: imp naming commit 4e4aa5802c9aafc67c52b8a290d8046531f8a1c8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:50:45 2024 +0300 client: imp docs commit bf5c23a72c93e58c8bc7e0ca896b2ea28519cf54 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:40:53 2024 +0300 home: add tests commit c6cdba7a8d0dfce22634f88258f61abb09ecca5a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:21:44 2024 +0300 all: add tests commit 1fc43cb45efbd428abaae9eba030f9bea818dfe3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 19:19:48 2024 +0300 all: add tests commit ccc423b296d9037f0aa23a125a5ad3af95b8c9f3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 15:37:15 2024 +0300 all: client persistent list
2024-05-13 18:09:18 +01:00
// findByIP finds persistent client by IP address.
func (ci *Index) findByIP(ip netip.Addr) (c *Persistent, found bool) {
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
uid, found := ci.ipToUID[ip]
if found {
return ci.uidToClient[uid], true
}
Pull request 2200: 6312-client-ipv6-zone Updates #6312. Squashed commit of the following: commit bd9146ee161a67fa41763070f985e1e73b85823b Merge: 58d2fd98d 856cc40cf Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 18:09:19 2024 +0300 Merge branch 'master' into 6312-client-ipv6-zone commit 58d2fd98d3e82c84638d58dd4d74d13a9a8fbca6 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 18:00:56 2024 +0300 client: imp naming commit 922a14b036d829c2775feb7bb3e6beb6aa49692e Merge: 6f4d58fe1 60f48e2d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:29:00 2024 +0300 Merge branch 'master' into 6312-client-ipv6-zone commit 6f4d58fe1c42504e8345bff24dbb3f523e8c5f85 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:27:55 2024 +0300 client: imp docs commit fa292eee828cd6f27f62b782675aa1f998e44518 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Apr 22 19:20:28 2024 +0300 client: fix typo commit 599414be0ccd3f9deb044e022a8ac0006c96b467 Merge: 502571756 762ef4a6d Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Apr 22 18:42:06 2024 +0300 Merge branch 'master' into 6312-client-ipv6-zone commit 502571756400a00445086b5ba412e03fca65e39f Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Apr 22 18:39:22 2024 +0300 all: imp code; add tests commit 155b2fef500a0d835f49957d9f30b0870712f6f2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Apr 16 19:56:00 2024 +0300 all: upd chlog; imp code commit 7a4426c5d0a511cd3865884c00328b8c130746bf Merge: e9c1cbb85 48c6242a7 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Apr 16 19:52:00 2024 +0300 Merge branch 'master' into 6312-client-ipv6-zone commit e9c1cbb85e4afa173969d5bedfaaaf92716b7fad Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 10 16:23:07 2024 +0300 client: client ipv6 zone
2024-04-24 17:08:54 +01:00
ipWithoutZone := ip.WithZone("")
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
ci.subnetToUID.Range(func(pref netip.Prefix, id UID) (cont bool) {
Pull request 2200: 6312-client-ipv6-zone Updates #6312. Squashed commit of the following: commit bd9146ee161a67fa41763070f985e1e73b85823b Merge: 58d2fd98d 856cc40cf Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 18:09:19 2024 +0300 Merge branch 'master' into 6312-client-ipv6-zone commit 58d2fd98d3e82c84638d58dd4d74d13a9a8fbca6 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 18:00:56 2024 +0300 client: imp naming commit 922a14b036d829c2775feb7bb3e6beb6aa49692e Merge: 6f4d58fe1 60f48e2d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:29:00 2024 +0300 Merge branch 'master' into 6312-client-ipv6-zone commit 6f4d58fe1c42504e8345bff24dbb3f523e8c5f85 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:27:55 2024 +0300 client: imp docs commit fa292eee828cd6f27f62b782675aa1f998e44518 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Apr 22 19:20:28 2024 +0300 client: fix typo commit 599414be0ccd3f9deb044e022a8ac0006c96b467 Merge: 502571756 762ef4a6d Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Apr 22 18:42:06 2024 +0300 Merge branch 'master' into 6312-client-ipv6-zone commit 502571756400a00445086b5ba412e03fca65e39f Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Apr 22 18:39:22 2024 +0300 all: imp code; add tests commit 155b2fef500a0d835f49957d9f30b0870712f6f2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Apr 16 19:56:00 2024 +0300 all: upd chlog; imp code commit 7a4426c5d0a511cd3865884c00328b8c130746bf Merge: e9c1cbb85 48c6242a7 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Apr 16 19:52:00 2024 +0300 Merge branch 'master' into 6312-client-ipv6-zone commit e9c1cbb85e4afa173969d5bedfaaaf92716b7fad Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 10 16:23:07 2024 +0300 client: client ipv6 zone
2024-04-24 17:08:54 +01:00
// Remove zone before checking because prefixes strip zones.
if pref.Contains(ipWithoutZone) {
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
uid, found = id, true
return false
}
return true
})
if found {
return ci.uidToClient[uid], true
}
return nil, false
}
Pull request 2208: AG-27492-client-persistent-list Squashed commit of the following: commit 1b1a21b07baa15499e5e4963d35bfd2e542533ed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:32:38 2024 +0300 client: imp tests commit 7e6d17158a254aa29bf4033fb68171d4209bb954 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:27:00 2024 +0300 client: imp tests commit 5e4cd2b3ca9557929b9b79a0610151ce09c792f9 Merge: 7faddd8aa 1a62ce471 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 15:57:33 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 7faddd8aade2b1b791beec694b88513b0a2a520e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:55:43 2024 +0300 client: imp code commit 54212e975b700f792a53fc3bfe1c2970778e05ea Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:24:18 2024 +0300 all: imp code commit 3f23c9af470036c2166e20c8d0b5d84810b35b6e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 17:07:40 2024 +0300 home: imp tests commit 39b99fc050047cebadc51ae64e220ec1cb873d83 Merge: 76469ac59 17c4eeb64 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 16:39:56 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 76469ac59400aae2f7563750a981138b8cbf3aa1 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 14:36:22 2024 +0300 home: imp naming commit 4e4aa5802c9aafc67c52b8a290d8046531f8a1c8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:50:45 2024 +0300 client: imp docs commit bf5c23a72c93e58c8bc7e0ca896b2ea28519cf54 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:40:53 2024 +0300 home: add tests commit c6cdba7a8d0dfce22634f88258f61abb09ecca5a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:21:44 2024 +0300 all: add tests commit 1fc43cb45efbd428abaae9eba030f9bea818dfe3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 19:19:48 2024 +0300 all: add tests commit ccc423b296d9037f0aa23a125a5ad3af95b8c9f3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 15:37:15 2024 +0300 all: client persistent list
2024-05-13 18:09:18 +01:00
// FindByMAC finds persistent client by MAC.
func (ci *Index) FindByMAC(mac net.HardwareAddr) (c *Persistent, found bool) {
k := macToKey(mac)
uid, found := ci.macToUID[k]
if found {
return ci.uidToClient[uid], true
}
return nil, false
}
Pull request 2200: 6312-client-ipv6-zone Updates #6312. Squashed commit of the following: commit bd9146ee161a67fa41763070f985e1e73b85823b Merge: 58d2fd98d 856cc40cf Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 18:09:19 2024 +0300 Merge branch 'master' into 6312-client-ipv6-zone commit 58d2fd98d3e82c84638d58dd4d74d13a9a8fbca6 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 18:00:56 2024 +0300 client: imp naming commit 922a14b036d829c2775feb7bb3e6beb6aa49692e Merge: 6f4d58fe1 60f48e2d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:29:00 2024 +0300 Merge branch 'master' into 6312-client-ipv6-zone commit 6f4d58fe1c42504e8345bff24dbb3f523e8c5f85 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:27:55 2024 +0300 client: imp docs commit fa292eee828cd6f27f62b782675aa1f998e44518 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Apr 22 19:20:28 2024 +0300 client: fix typo commit 599414be0ccd3f9deb044e022a8ac0006c96b467 Merge: 502571756 762ef4a6d Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Apr 22 18:42:06 2024 +0300 Merge branch 'master' into 6312-client-ipv6-zone commit 502571756400a00445086b5ba412e03fca65e39f Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Apr 22 18:39:22 2024 +0300 all: imp code; add tests commit 155b2fef500a0d835f49957d9f30b0870712f6f2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Apr 16 19:56:00 2024 +0300 all: upd chlog; imp code commit 7a4426c5d0a511cd3865884c00328b8c130746bf Merge: e9c1cbb85 48c6242a7 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Apr 16 19:52:00 2024 +0300 Merge branch 'master' into 6312-client-ipv6-zone commit e9c1cbb85e4afa173969d5bedfaaaf92716b7fad Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 10 16:23:07 2024 +0300 client: client ipv6 zone
2024-04-24 17:08:54 +01:00
// FindByIPWithoutZone finds a persistent client by IP address without zone. It
// strips the IPv6 zone index from the stored IP addresses before comparing,
// because querylog entries don't have it. See TODO on [querylog.logEntry.IP].
//
// Note that multiple clients can have the same IP address with different zones.
// Therefore, the result of this method is indeterminate.
func (ci *Index) FindByIPWithoutZone(ip netip.Addr) (c *Persistent) {
if (ip == netip.Addr{}) {
return nil
}
for addr, uid := range ci.ipToUID {
if addr.WithZone("") == ip {
return ci.uidToClient[uid]
}
}
return nil
}
// Delete removes information about persistent client from the index. c must be
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
// non-nil.
func (ci *Index) Delete(c *Persistent) {
Pull request 2208: AG-27492-client-persistent-list Squashed commit of the following: commit 1b1a21b07baa15499e5e4963d35bfd2e542533ed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:32:38 2024 +0300 client: imp tests commit 7e6d17158a254aa29bf4033fb68171d4209bb954 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:27:00 2024 +0300 client: imp tests commit 5e4cd2b3ca9557929b9b79a0610151ce09c792f9 Merge: 7faddd8aa 1a62ce471 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 15:57:33 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 7faddd8aade2b1b791beec694b88513b0a2a520e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:55:43 2024 +0300 client: imp code commit 54212e975b700f792a53fc3bfe1c2970778e05ea Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:24:18 2024 +0300 all: imp code commit 3f23c9af470036c2166e20c8d0b5d84810b35b6e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 17:07:40 2024 +0300 home: imp tests commit 39b99fc050047cebadc51ae64e220ec1cb873d83 Merge: 76469ac59 17c4eeb64 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 16:39:56 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 76469ac59400aae2f7563750a981138b8cbf3aa1 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 14:36:22 2024 +0300 home: imp naming commit 4e4aa5802c9aafc67c52b8a290d8046531f8a1c8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:50:45 2024 +0300 client: imp docs commit bf5c23a72c93e58c8bc7e0ca896b2ea28519cf54 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:40:53 2024 +0300 home: add tests commit c6cdba7a8d0dfce22634f88258f61abb09ecca5a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:21:44 2024 +0300 all: add tests commit 1fc43cb45efbd428abaae9eba030f9bea818dfe3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 19:19:48 2024 +0300 all: add tests commit ccc423b296d9037f0aa23a125a5ad3af95b8c9f3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 15:37:15 2024 +0300 all: client persistent list
2024-05-13 18:09:18 +01:00
delete(ci.nameToUID, c.Name)
Pull request 2138: AG-27492-client-persistent-storage Squashed commit of the following: commit 37e33ec761cfa30164125af2c5bb40789412355e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:25:25 2024 +0300 aghalg: imp code commit 6b2f09a44298b474ec1bdf3d027fb4941d2f7bea Merge: b8ea924aa 37736289e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 14 15:04:59 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-storage commit b8ea924aa7ed4c052760a6068f945d83d184e7e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 19:07:52 2024 +0300 home: imp tests commit aa6fec03b1a1ead96bc76919b7ad51ae19626633 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 13 14:54:28 2024 +0300 home: imp docs commit 10637fdec47d0b035cf5c7949ddcd9ec564851a3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 8 20:16:11 2024 +0300 all: imp code commit b45c7d868ddb1be73e119b3260e2a866d57baa91 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 7 19:15:11 2024 +0300 aghalg: add tests commit 7abe33dbaa7221ddbc8b7d802dbfa7f951d90cf8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Feb 6 20:50:22 2024 +0300 all: imp code, tests commit 4a44e993c9bd393d2cb9853108eae1ad91e64402 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 1 14:59:11 2024 +0300 all: persistent client index commit 66b16e216e03e9f3d5e69496a89b18a9d732b564 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Jan 31 15:06:05 2024 +0300 aghalg: ordered map
2024-02-15 11:08:05 +00:00
for _, id := range c.ClientIDs {
delete(ci.clientIDToUID, id)
}
for _, ip := range c.IPs {
delete(ci.ipToUID, ip)
}
for _, pref := range c.Subnets {
ci.subnetToUID.Del(pref)
}
for _, mac := range c.MACs {
k := macToKey(mac)
delete(ci.macToUID, k)
}
delete(ci.uidToClient, c.UID)
}
Pull request 2208: AG-27492-client-persistent-list Squashed commit of the following: commit 1b1a21b07baa15499e5e4963d35bfd2e542533ed Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:32:38 2024 +0300 client: imp tests commit 7e6d17158a254aa29bf4033fb68171d4209bb954 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 17:27:00 2024 +0300 client: imp tests commit 5e4cd2b3ca9557929b9b79a0610151ce09c792f9 Merge: 7faddd8aa 1a62ce471 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed May 8 15:57:33 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 7faddd8aade2b1b791beec694b88513b0a2a520e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:55:43 2024 +0300 client: imp code commit 54212e975b700f792a53fc3bfe1c2970778e05ea Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 20:24:18 2024 +0300 all: imp code commit 3f23c9af470036c2166e20c8d0b5d84810b35b6e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 17:07:40 2024 +0300 home: imp tests commit 39b99fc050047cebadc51ae64e220ec1cb873d83 Merge: 76469ac59 17c4eeb64 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 16:39:56 2024 +0300 Merge branch 'master' into AG-27492-client-persistent-list commit 76469ac59400aae2f7563750a981138b8cbf3aa1 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon May 6 14:36:22 2024 +0300 home: imp naming commit 4e4aa5802c9aafc67c52b8a290d8046531f8a1c8 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:50:45 2024 +0300 client: imp docs commit bf5c23a72c93e58c8bc7e0ca896b2ea28519cf54 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu May 2 19:40:53 2024 +0300 home: add tests commit c6cdba7a8d0dfce22634f88258f61abb09ecca5a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Apr 24 14:21:44 2024 +0300 all: add tests commit 1fc43cb45efbd428abaae9eba030f9bea818dfe3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 19:19:48 2024 +0300 all: add tests commit ccc423b296d9037f0aa23a125a5ad3af95b8c9f3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Apr 19 15:37:15 2024 +0300 all: client persistent list
2024-05-13 18:09:18 +01:00
// Size returns the number of persistent clients.
func (ci *Index) Size() (n int) {
return len(ci.uidToClient)
}
// Range calls f for each persistent client, unless cont is false. The order is
// undefined.
func (ci *Index) Range(f func(c *Persistent) (cont bool)) {
for _, c := range ci.uidToClient {
if !f(c) {
return
}
}
}
// RangeByName is like [Index.Range] but sorts the persistent clients by name
// before iterating ensuring a predictable order.
func (ci *Index) RangeByName(f func(c *Persistent) (cont bool)) {
cs := maps.Values(ci.uidToClient)
slices.SortFunc(cs, func(a, b *Persistent) (n int) {
return strings.Compare(a.Name, b.Name)
})
for _, c := range cs {
if !f(c) {
break
}
}
}
// CloseUpstreams closes upstream configurations of persistent clients.
func (ci *Index) CloseUpstreams() (err error) {
var errs []error
ci.RangeByName(func(c *Persistent) (cont bool) {
err = c.CloseUpstreams()
if err != nil {
errs = append(errs, err)
}
return true
})
return errors.Join(errs...)
}