I’m getting my hands dirty on the source code (copy of cmd/syncthing -> https://github.com/xor-gate/syncthingsrv). The current syncthing client/server is not sufficient for my use-case. As I want a dropbox-like experience and have a NAS which acts as a “central-storage” place. I would like to allow only as list of devices which can auto-share with their files with the NAS. Currently the config is fairly deep woven into the lib. I’m a bit lost how lib/model works as you can AddFolder, StartFolder but this will not start syncing. I already found out the event system which emits a rejected folder event and can act on this to add it automaticly.
I’m not sure what direction I should take as probably other people would like this kind of setup (as alternative for dropbox). With the server-only daemon I could also expose a file-listing and file-link sharing which is currently not possible.
If there is something not clear in my post, I would like to describe further in detail.
I think you need to do that, because it’s not clear to me what you’re trying to do. If you’re talking about automatically adding folders based on them being shared from a device, look into what happens in ClusterConfig() (that’s where you see what another device is sharing with you), and add them to the config as if they were added from the GUI.
Accepting only selected devices is of course the default, the discovery stuff can all be disabled by config, and the GUI you can remove I guess but it’s really just bundled HTML/JS files so no big deal.
The automatic adding of new shares is the one that requires some development, and you could indeed do it based on the FolderRejected event. I’d create a specific event listener for that if you want to do it cleanly - basically just copy and paste verboseservice.go into folderadderservice.go or whatever, remove the handling of all other events, change the subscribe call to be only for FolderRejected, and wire it up in main in the same manner as the verbose service.
But you should not be reaching into the model hairball from there. Instead, get a reference to the global-ish cfg object, modify it to create the folder and add it to devices as appropriate, and call Save() on it. The folder gets added to the config, the config gets saved, the model reloads everything as necessary to start the folders - because it subscribes to config updates.
I have it sort-of working now, I still would like to (re)use the code of the model.ClusterConfig for introducers adding shared folders. It would be nice if we could create a function out if this code for reusability: