Repository navigation
lib: Handle adding enc folders on an existing conn (fixes #7509) - #7510
Conversation
| func newFolderKeyRegistry() *folderKeyRegistry { | ||
| return &folderKeyRegistry{ | ||
| keys: make(map[string]*[keySize]byte), | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Don't really need a constructor for this one, nil map is fine until reset() happens
There was a problem hiding this comment.
I don't really want a nil-check in folderKeyRegistry.get though.
There was a problem hiding this comment.
I'd expect key, ok := r.keys[folder] to panic. And without checking I am not 100% that model.AddConnection is guaranteed to initialize the passwords before any message comes in from a remote. Expressing that thought makes it clear that I should keep initializing passwords when creating the connection. Likely it's all irrelevant practically, as the early messages aren't encrypted, but still.
There was a problem hiding this comment.
It doesn't panic though, a nil map is equivalent to a non-nil but empty map when reading.
There was a problem hiding this comment.
Cool, wasn't aware of that. I didn't really internalize that aspect of go (treating nil as a valid state), I treat nil as "do not touch".
Any ways, it does now get initialized at connection construction time with a valid map of passwords.
* main: (36 commits) etc: Fix start-limit parameters location in systemd units (ref syncthing#7439) (syncthing#7529) gui: Add confirmation dialog for revert/override (fixes syncthing#7520) (syncthing#7522) readme: Larger link for Fitt's law, still semantic (syncthing#7523) gui, man, authors: Update docs, translations, and contributors lib/model: Reset conn when enc token is missing (fixes syncthing#7198) (syncthing#7518) lib: Handle adding enc folders on an existing conn (fixes syncthing#7509) (syncthing#7510) cmd/strelaysrv: Increase default strelaysrv network buffer size (fixes syncthing#7514) (syncthing#7517) lib/ur: Prevent panic when blocksResult is nil (ref syncthing#7495) (syncthing#7515) lib/model: Encrypted fileinfo trailer needs to be in wire format (syncthing#7505) lib/model: Error check in test (syncthing#7508) lib/osutil: Fix raising max FDs on macOS (syncthing#7507) lib/connections: Silence "connected to myself" messages. (syncthing#7500) lib/osutil: Remove unused code all: Simplify some method calls (syncthing#7499) cmd/uraggregate: Ignore errors harder (syncthing#7498) cmd/syncthing: Error handling on upgrade (syncthing#7497) Remove unnecessary guard around `delete` (syncthing#7496) all: Remove miscellaneous vestigial code (syncthing#7495) all: Remove crypto/md5 (syncthing#7493) lib/api: Missing error handling in API delete-device (syncthing#7494) ...
Fixes #7509 by adding a method to the connection to set new folder passwords. This means that any connection may become (partly) encrypted. Thus there's no longer two separate factory methods, but every connection is a
encryptedConnection.The passwords on the connection are (re-)set when sending cluster-configs, meaning when a new connection is added, when a new folder is added or when a folder changes.