Repository navigation
Conversation
Currently only the remote side's view of our own device and of themselves is filtered from the ClusterConfig message. Extend those checks for devices that would be good candidates for additional sharing links within the cluster, since they share the same folder ID, but not directly with our local device. Those might be completely unknown devices so far. Relevant discussion: https://forum.syncthing.net/t/manual-intervention-for-introducer-feature/12212
Use the accessor methods with a device argument instead of looking up in a temporary map of the same data.
Include a list of candidate devices that share the folder, but not directly with us. Implemented as a slice internally, and serialized to XML as repeated candidateDevice tags; to JSON as an array. A candidate device can be recorded for this folder through the new AddOrUpdateCandidateDevice() method, optionally with additional info such as the introducer and its name for the candidate device. Passed addresses are collected into a list for possibly trying to contact the device later.
Add convenience method AddOrUpdateFolderCandidateDevice() to record the given device after finding the right FolderConfiguration object. Handles config locking and saving atomically.
Add "omitempty" to the address XML attribute. Allows for reusing the datatype when no address needs to be stored.
Modeled after the pending device mechanism, the new ObservedCandidateDevice structure stores information about remote devices which were advertised by other remote nodes. From the ClusterConfig message, it can collect the advertised certName and the address list. A list of introducers may be included, reusing the ObservedDevice structure type. In contrast to the pending device entries, the Name field should hold the candidate device's name as the introducer calls it, not the candidate's own advertised name. Functions for maintaining duplicate-free introducer entries and address lists are defined along with the structure type.
When iterating over a ClusterConfig message, implement the cases for known or unknown devices that the sender mentions where a missing cluster link may be established. Only concerns devices that are already linked to us indirectly through a folder. Add some FIXME comments for branches that skip to the next folder before we had a chance to record the candidate devices.
Instead of repeating the complete looping code, use an optional boolean argument in selectAllDevices(). deSelectAllDevices() just flips it to false and reuses the other function.
Split the device list into two sections, for currently shared and unshared devices. Makes it clearer what changes are being made, just by looking at the checkmarks. Initially the first section has all checked and the second section has all unchecked. An empty section is hidden. Implement device list filters for the separated categories, temporarily stored within the GUI model's currentFolder object while the folder editing modal dialog is active. Adjust bulk selection functions.
Include a third category (if non-empty) in the folder sharing device
list. List the devices collected in the candidateDevices config in
two possible formats:
For already configured devices, show a check mark and the friendly
name; effectively just move entries from the "unrelated" section.
For previously unknown candidate devices, list the complete device ID
as a clickable link, which should open the "Add Device" modal dialog,
but that is not implemented yet [TODO]. If all devices listed under
introducedBy agree on a common name, show that as an alias hint after
the ID.
The lists of suggested devices are temporarily stored within the
currentFolder object, until the folder edit dialog is saved and
closed.
Implement additional {de}selectAllSuggestedDevices() functions that
only operate on the checkmarks, not the unknown devices.
Implement addDeviceAndShare() to show a partially pre-filled dialog when clicking on a suggested yet unknown candidate device for a folder. WARNING: This does not work correctly yet, mainly because the editingExisting flag is shared between folder and device editing dialogs. This change is little tested and has more issues.
|
|
||
| func (w *wrapper) AddOrUpdateFolderCandidateDevice(folder string, | ||
| device, introducer protocol.DeviceID, name, certName string, addresses []string) { | ||
| defer w.Save() |
There was a problem hiding this comment.
Error return value of w.Save is not checked (from errcheck)
There was a problem hiding this comment.
Copied verbatim from AddOrUpdatePendingDevice() and others. Sorry I'm new to Go and have no idea how that should be checked in conjunction with defer.
This will not live in the config anyway, long-term.
Fix missing method reported in CI test. go fmt to wrap closing curly brace for whatever reason when it does not wrap for the two methods above...
761e883 to
59174cf
Compare
Incorporate suggestions from syncthing#5756.
|
What's the status of this PR? |
|
I haven't found much time to work on this. Two kids keeping me busy ;-) Plus the unexpected backlash on #5756 (for such a small change) did not exactly boost my motivation. I'd like to have some reassurance that people will actually welcome this addition and I'm heading in the right direction. Given that the idea has been up for discussion on the forum for over a year now. Technically only the collected data needs to be stored in the database instead of the config. Lack of experience with schema-less databases being the main hurdle there. Plus some cleanup code to dump outdated entries. |
|
If you are not motivated, then we should revert #5756, as without the epiphany of the idea, I think it's actually a detrimental change for small set of devices. |
|
I can help with the db if needed, that shouldn't be a showstopper. |
|
@AudriusButkevicius seeing that one finally merged today was actually a very positive sign ;-) |
|
🤖 beep boop I'm going to close this pull request as it has been idle for more than 90 days. This is not a rejection, merely a removal from the list of active pull requests that is periodically reviewed by humans. The pull request can be reopened when there is new activity, and merged once any remaining issues are resolved. |
|
Just pushed two commits to keep this prototype work up-to-date with master. Just in case anyone wants to try it out. I'm still trying to get my head around how to move this stuff from config to the database, but time is very limited. Kindly asking for patience. Once there are some meaningful commits toward a better implementation, I will open a new draft PR. |
Thanks for the offer, @imsodin. I hope it still stands? I've looked at the DB storage code now and then, and finally managed to make it build with my custom protobuf messages to hold the information about candidate devices. Defined some additional types in So where to go from here?
Please excuse if these questions seem trivial. I find it hard to wrap my head around the overall architecture with all these layers involved and could use some mentoring. Just in case it makes a difference to the answers: My plan is to restructure / move the pending devices / folders stuff first "for practice", then add the candidate devices on top of that, since they are similar in nature IMHO. The former goal is based on @AudriusButkevicius' comment that storing the pending stuff in the config instead of the DB was a mistake in the first place. |
Sure does. Can you push your experimental changes somewhere, regardless of how unfinished/broken it is. It makes understanding of what you do and giving useful answers easier.
The plan of first moving the pending stuff from config to db sounds very reasonable. And don't apologize for asking questions, and definitely for them being "trivial" - anything gets trivial if you stare long enough at it, and so by corollary nothing is initially trivial (I fondly remember one math prof that was honest enough during a proof to state "And now, if we stare long enough at this line, the next step is evident: ..."). |
|
Thanks for your taking time to answer thoroughly.
Will do when I had the next time slice available for staring and pushing to a WIP branch on my fork.
The candidate devices are definitely information about already shared folders, in the sense of "whom else you might want to share this with". For pending devices you are right and I'm considering For pending folders, it is not clear at all, though I agree that
So my gut feeling says the helper functions will live in The information of interest will be structured already in the DB, so it seems odd to mirror it with another API structure type. The The next steps are becoming more an more evident, your prof was right ;-) |
|
One more generic question: I don't see what benefit the If we want to store a protobuf message structure as suggested by @calmh, the last part (field names) is already defined through that mechanism and the key is just: So would it still be a good idea to go through I'm leaning toward just implementing the DB key generation myself, independent of the |
|
|
|
A first draft of the REST API for the pending folders and devices lives in my fork of the docs repository: Thought it would be a good place since that will need documentation anyway. Should I open a draft PR for the docs repo as a new place for the discussion or shall we keep it here? Kindly asking for comments on the API design. Candidate devices (which this PR is actually about) will be modeled on top of that. |
Please do, so one can comment directly on the relevant sections. |
|
Done at syncthing/docs#498. Comments welcome. |
I've started pushing some draft work to #6443 for only the pending folders / devices stuff. Let's continue the related discussion there. |
Purpose
This is an early prototype of the "suggested devices" feature discussed on the forum. The PR includes:
The backend changes for collecting info about device candidates to suggest, from the ClusterConfig messages. Currently stored inside the config, because it is easy to experiment and debug. This needs to be moved to the database though, since on a large cluster this dumps a lot of data to the XML and it touches the config for every received ClusterConfig message with additional candidates. The general structure of collected data could be reused, though.
PR gui: Split device list in folder sharing options by shared / unshared #5756 as a prerequisite for splitting the GUI's folder sharing device list in groups.
Another section (hidden if empty) in the GUI's Edit Folder dialog - Sharing tab. It lists both known devices that have only an indirect link to this folder (category 2 from the forum discussion), as well as completely unknown devices (category 4) that would have been added if the Introducer feature was used. The latter are included as clickable device IDs, with an appended alias hint only if all introducers agree on the name.
Known Issues
Actually adding unknown devices does not work correctly. The folder and device editing dialogs share a
editingExistingflag, which obviously needs to be separate when launching one modal dialog from the other. Pre-filling some form fields is also non-functional, see FIXMEs in the code.The new section is currently only used when editing a folder, not when adding a pending folder shared from another device. In theory, there could already be candidate devices, so showing them in that incarnation of the dialog would make sense.
This should not be released to the userbase at large because of the inefficient storage of candidate devices in the configuration. Large clusters will experience horrible performance!
Noticed while testing: The ClusterConfig message currently includes any remote device (B) which the sender (A) "shares" the folder with. This should possibly be limited to "mutually shared" links, where B also shares with A. Once the device suggestions are merged, this extra data could make it easier to trick people into sharing data with the wrong device maybe?
Collected candidate devices are not being cleaned up yet. Need to decide on a strategy for keeping these records clean.
Some smaller issues and questions marked
FIXMEin the code. RFC.Testing
All devices are listed under the expected category in a cluster with five devices. Selecting the suggested devices works, except for unknown devices. Verified the config entries both in the XML as well as over the JSON API.
Screenshots
Documentation
TODO: Once the data storage is agreed upon, any additions need to go to the API docs. Also need a new section explaining the concept of "suggested devices" in the Usage guide. Note that this is not a major addition to the inner workings of Syncthing, just exposing data that was already available.