Martchus / syncthingtray

Tray application and Dolphin/Plasma integration for Syncthing
https://martchus.github.io/syncthingtray/
Other
1.5k stars 42 forks source link

Environment variables do not go through to Syncthing when using libsyncthing #255

Closed daniele-athome closed 2 months ago

daniele-athome commented 2 months ago

Relevant components

Environment and versions

Bug description I can't find a way to pass environment variables to syncthing. I'd like to set all_proxy to use a SOCKS5 proxy and I can't set global environment variables due to OS policy configuration. I tried writing a simple .bat file:

@echo off
setlocal
  set all_proxy=http://127.0.0.1:9090/ && set ALL_PROXY_NO_FALLBACK=1 && start syncthingtray-1.5.2-x86_64-w64-mingw32.exe
endlocal

I also tried other another approach (several actually):

@echo off
set all_proxy=http://127.0.0.1:9090/
set ALL_PROXY_NO_FALLBACK=1
start syncthingtray-1.5.2-x86_64-w64-mingw32.exe

I also tried without using "start".

Syncthing logs at INFO level whether a proxy configuration is present, but it never does.

Steps to reproduce

  1. set environment variable in cmd or in a .bat script
  2. launch Syncthing via libsyncthing

Expected behavior Libsyncthing should be using proxy settings from all_proxy environment variable.

Screenshots N/A

Additional context N/A

Martchus commented 2 months ago

Does this work when starting the regular syncthing.exe? E.g. when you use:

@echo off
set all_proxy=http://127.0.0.1:9090/
set ALL_PROXY_NO_FALLBACK=1
start syncthing.exe

where syncthing.exe is from https://github.com/syncthing/syncthing/releases/tag/v1.27.6.

Note that I don't think that libsyncthing will unset any environment variables. I'm also not sure where these two environment variables are actually supposed to be evaluated. Are they normally supported by Syncthing or Go in general?

daniele-athome commented 2 months ago

I'm an idiot. all_proxy needs to use the socks5 scheme otherwise it won't work.

set all_proxy=socks5://127.0.0.1:9090

It works now. Sorry :-)