Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consume config as JSON alternatively #2

Open
acolomb opened this issue Jan 8, 2023 · 4 comments
Open

Consume config as JSON alternatively #2

acolomb opened this issue Jan 8, 2023 · 4 comments
Labels
feature new feature

Comments

@acolomb
Copy link

acolomb commented Jan 8, 2023

This is an idea, you could optionally fill the data structures from a JSON representation of the config file. That's what the GUI uses to manage configuration, and could easily be downloaded as a file from a running instance, or even piped to syncthing-map directly.

That would give an easier / more standardized way of retrieving the config from remote devices.

Look at https://docs.syncthing.net/rest/system-config-get.html for what the JSON looks like. It is serialized from the same Go structures as the XML format (actually with a common protobuf definition), so you can definitely parse it with your existing structures as well with maybe some JSON-specific annotations.

@wsw70
Copy link
Owner

wsw70 commented Jan 9, 2023

(...) and could easily be downloaded as a file from a running instance, or even piped to syncthing-map directly.

That would give an easier / more standardized way of retrieving the config from remote devices.

I had a look at the API, I wanted to use it initially instead of the XML. The problem I have is that this is an endpoint local to the network (at best) so reaching it from outside that network is difficult (port forwarding, ...) or impossible (Android).

This is the reason I went for parsing config.xml directly (after having retrieved it one way or another) but I would be glad to be corrected if my understanding is incorrect.

I also contemplated running syncting-map locally, retrieving config.xml, parsing it, and then sending it to a centralized syncthing-map instance and automatically generating an updated map. This is not going to be easy on Android.

Ultimately, I also considered (and still consider) sharing config.xml via the normal sharing features and processing the changes automatically. This requires extra sharing, though.

Anyway, I am really open to suggestions.

@acolomb
Copy link
Author

acolomb commented Jan 9, 2023

Well my thought was that having access to config.xml OR the API is a thing the user will need to take care of one way or another. I personally would probably favor tunneling the API port through SSH and accessing the config from there, piped directly to a local syncthing-map read --json process. I find that more appealing than copying XML files around through the same SSH setup. If the API ports are accessible from remote directly, it gets even easier.

I wouldn't actually consider syncing the config files permanently (since they all have the same name for example), and running the mapper is a not a continuous process either.

Anyway, I think the additional flexibility outweighs the relatively simple implementation of adding a command line switch and annotating the structs with JSON attributes. I might have a stab at doing a PR for this when time allows and you don't beat me to it 😉

@wsw70 wsw70 added the feature new feature label Jan 9, 2023
@wsw70
Copy link
Owner

wsw70 commented Jan 9, 2023

I personally would probably favor tunneling the API port through SSH and accessing the config from there, piped directly to a local syncthing-map read --json process.

Yes, this is a solution, but it will be limited to devices that offer an ssh endpoint - which mostly means Linux. Windows 10 would be possible by starting the services, and Android is really difficult because of sandboxing. I do not know about iOS but it will probably be even worse.

This ssh endpoint also needs to be available on the Internet (possibly from networks one does not control), or connected via something like Tailscale.

This is to say that yes, why not, but the useage may be somehow limited for the normal population.

@wsw70
Copy link
Owner

wsw70 commented Jan 10, 2023

You may want to try the new experimental feature server

Binaries are available in the development stable release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature new feature
Projects
None yet
Development

No branches or pull requests

2 participants