Skip to content

Commit

Permalink
all: fix client duplicate uids
Browse files Browse the repository at this point in the history
  • Loading branch information
schzhn committed Apr 24, 2024
1 parent 856cc40 commit fcca9af
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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.
Expand Down
10 changes: 8 additions & 2 deletions internal/client/index.go
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/home/clients.go
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit fcca9af

Please sign in to comment.