syncthing / syncthing-macos

Official frugal and native macOS Syncthing application bundle
https://syncthing.net
MIT License
2.72k stars 145 forks source link

Setting Syncthing environment variable `all_proxy` #98

Open jiajunhuang opened 5 years ago

jiajunhuang commented 5 years ago

how can I use proxy in syncthing-macos? I can set a all_proxy=... in systemd service file, but it does not provide a way to set environment variable in syncthing-macos.

xor-gate commented 5 years ago

Currently setting a proxy is not possible. So it is a missing feature.

opensource21 commented 3 years ago

As a workaround you could follow https://github.com/syncthing/syncthing-macos/issues/154#issuecomment-832946496

xor-gate commented 3 years ago

@opensource21 setting environment variables is not possible with #154 only commandline parameters

opensource21 commented 3 years ago

@xor-gate This why I link to the workaround where a shell-script is called. Otherwise, I had written it's solved with #154

AlliotTech commented 2 months ago

Here is a less elegant way to achieve the goal: export all_proxy=socks5://127.0.0.1:1234 && open /Applications/Syncthing.app;

xor-gate commented 2 months ago

Yeah I understand you need to bypass the (corporate) firewall or proxy via e.g Tor using the SOCKS5 protocol. For my own reference we need to inject the all_proxy envvar.

Code need to be touched located here:

https://github.com/syncthing/syncthing-macos/blob/c1387cb5a6854dc87b9dd49c3971244840eba935/syncthing/STApplication.m#L69

https://github.com/syncthing/syncthing-macos/blob/c1387cb5a6854dc87b9dd49c3971244840eba935/syncthing/STApplication.m#L35

https://github.com/syncthing/syncthing-macos/blob/c1387cb5a6854dc87b9dd49c3971244840eba935/syncthing/DaemonProcess.swift#L63

AlliotTech commented 2 months ago

Yeah I understand you need to bypass the (corporate) firewall or proxy via e.g Tor using the SOCKS5 protocol. For my own reference we need to inject the all_proxy envvar.

Yes, I have checked the documentation on environment variables for a specific agent. Is there another way to specify the agent through the application, rather than, as I mentioned earlier, using the command line to start the app to achieve the purpose of injecting environment variables?

xor-gate commented 2 months ago

No currently the only environment variable we set/inject is STNOUPGRADE. As a intermediate solution we could use the hidden turning knob like settings commandline argument as documented here https://github.com/syncthing/syncthing-macos?tab=readme-ov-file#preferences. We then could add something like:

defaults write com.github.xor-gate.syncthing-macosx Proxy 'socks5://127.0.0.1:1234'

It would be more nice to have two turning knobs in the GUI so you can set the URL and enable/disable proxying.

I can't promise when I implement this, but its not that hard. Syncthing macOS is a one man show, I do it in my (expensive) free time.

xor-gate commented 2 months ago

Maybe we should also detect system wide proxy: https://apple.stackexchange.com/a/396066.

AlliotTech commented 2 months ago

No currently the only environment variable we set/inject is STNOUPGRADE. As a intermediate solution we could use the hidden turning knob like settings commandline argument as documented here https://github.com/syncthing/syncthing-macos?tab=readme-ov-file#preferences. We then could add something like:

defaults write com.github.xor-gate.syncthing-macosx Proxy 'socks5://127.0.0.1:1234'

It would be more nice to have two turning knobs in the GUI so you can set the URL and enable/disable proxying.

I can't promise when I implement this, but its not that hard. Syncthing macOS is a one man show, I do it in my (expensive) free time.

Thank you sir. Unfortunately, after tested, the command "defaults write com.github.xor-gate.syncthing-macosx Proxy 'socks5://127.0.0.1:1234'" did not work.

xor-gate commented 2 months ago

Thank you sir. Unfortunately, after tested, the command "defaults write com.github.xor-gate.syncthing-macosx Proxy 'socks5://127.0.0.1:1234'" did not work.

Sure it doesn't work, it was a proposal for myself if that was not clear. It has not been implemented yet to inject the proxy environment variable.