all: fix client duplicate uids

This commit is contained in:
Stanislav Chzhen 2024-04-24 18:56:34 +03:00
parent 856cc40cf3
commit fcca9afe0c
3 changed files with 11 additions and 3 deletions

View File

@ -34,6 +34,8 @@ NOTE: Add new changes BELOW THIS COMMENT.
### Fixed
- Acceptance of duplicate UIDs for persistent clients at startup. See also a
section on client settings on the [Wiki page][wiki-config].
- Issues with QUIC and HTTP/3 upstreams on older Linux kernel versions
([#6422]).
- YouTube restricted mode is not enforced by HTTPS queries on Firefox.

View File

@ -85,10 +85,16 @@ func (ci *Index) Add(c *Persistent) {
// Clashes returns an error if the index contains a different persistent client
// with at least a single identifier contained by c. c must be non-nil.
func (ci *Index) Clashes(c *Persistent) (err error) {
p, ok := ci.uidToClient[c.UID]
if ok {
return fmt.Errorf("another client %q uses the same UID", p.Name)
}
for _, id := range c.ClientIDs {
existing, ok := ci.clientIDToUID[id]
var existing UID
existing, ok = ci.clientIDToUID[id]
if ok && existing != c.UID {
p := ci.uidToClient[existing]
p = ci.uidToClient[existing]
return fmt.Errorf("another client %q uses the same ID %q", p.Name, id)
}

View File

@ -286,7 +286,7 @@ func (clients *clientsContainer) addFromConfig(
_, err = clients.add(cli)
if err != nil {
log.Error("clients: adding client at index %d %s: %s", i, cli.Name, err)
return fmt.Errorf("clients: adding client at index %d %s: %w", i, cli.Name, err)
}
}