Add Support for Proxy and Redirects in Updater-Script
Hi,
i've had some problems getting this to work behind a corporate proxy. Maybe you could switch to cURL (instead of wget) in the Updater-Script to fix these issues for others in the future?
- First i had to set an EnvVar for wget to use the proxy: set http_proxy=http://#host#:#port#
- Then i ran into a problem, because github sends a 302 Redirect, which isn't followed by wget
- Other Versions of wget seems to have a parameter for this (--max-redirect=20), but your version (thru busybox) doenst support this parameter
- The solution in the end was to use curl instead of wget for the download.
Here are my changes to the Updater.bat - Script:
set http_proxy=http://localhost:3128 set CURL="%HERE%App\Utils\curl.exe" %CURL% --insecure --location --proxy %http_proxy% %OBSIDIAN% -o TMP\Obsidian-%LATEST%.exe
Hi, thanks for the info, yeah maybe i should go back to CURL. But also need to add some checks for the presence of proxy, or leave it to manual edit.
What proxy are you using? Is this a standard WinHTTP proxy or something else? Is authorization required? Can you show me the CMD output of this command:
-
netsh winhttp show proxy
Do you use WGET with -Y or -e use_proxy=on / -e use_proxy=yes (for newer versions) flag after URL?
Change line 97 of the updater.bat
%BUSYBOX% wget %OBSIDIAN% -O TMP\Obsidian-%LATEST%.exe
to this
:Your proxy without http / https set http_proxy=localhost:3128 %BUSYBOX% wget %OBSIDIAN% -Y -O TMP\Obsidian-%LATEST%.exe
I'm not really sure which proxy-software is used, i think it's squid-cache. For development i've added https://github.com/genotrance/px as "ntlm-proxy" running on my local machine. Because our corporate proxy needs NTLM-authentifaction (Microsoft AD) and we need to regularly change ours password. And in a lot of tools (e.g. IDEA IntelliJ) you need to manually configure the proxy (including user/pw)... And then i change my pwd, forgot to update my IntelliJ-Settings and after 3 wrong attempt my AD-Domain accout is locked and i need to submit a ticket :-(. So PX to the rescue ;-) App -> PX -> Squid -> Web
C:>netsh winhttp show proxy Aktuelle WinHTTP-Proxyeinstellungen: DirectAccess (kein Proxyserver).
The -Y switch for wget is working, you have to add the "on" parameter
%BUSYBOX% wget %OBSIDIAN% -Y on -O TMP\Obsidian-%LATEST%.exe
But then i still get a Textfile with the "HTTP/1.1 302 Found" Response instead of the Obsidian.exe
There seems to be a "--max-redirect=20"-Parameter which could help, but unfortunately it isn't supported by your version of busybox :-(.
I would suggest...
- to use cURL
- the user has to manually set the EnvVar "http_proxy" (or "https_proxy")
- your script checks if this var is set and build the commandline for cURL accordingly
- maybe some hint / documentation at the top of the script
- and maybe some more "exists" checks in the following steps. In my case 7-Zip failed, because the Textfile could not be extracted. After that, the next 7-Zip (for "ARCH") fails, because the file doesnt exists.
I forgot that Windows 10/11 has CURL by default, so no additions are required. CURL can only be used if PROXY is set to true. I changed the bat file, can you check?
Almost ;-)
You're still using wget for obtaining the latest version. So wget needs to pick up the proxy too. For this, the variable needs to have the name "HTTP_PROXY" (with underscore).
Here's my modifications...
At the start:
:::::: PROXY rem uncomment and modify the following line to use a proxy for internet access rem set HTTP_PROXY=http://127.0.0.1:3128
And later on
set OBSIDIAN="https://github.com/obsidianmd/obsidian-releases/releases/download/v%LATEST%/Obsidian-%LATEST%.exe" if "%HTTP_PROXY" NEQ "" ( set CURL_OPTS=-x %HTTP_PROXY% ) %CURL% -k -L %CURL_OPTS% %OBSIDIAN% -o TMP\Obsidian-%LATEST%.exe
In the default case (no proxy) the variable CURL_OPTS is empty, so it should work like before (can't test this here). In case of a proxy, the commandline is expanded, so that curl uses the proxy. And the EnvVar itself is used by wget for the other downloads though a proxy ;-)
Back to cURL, because busybox wget only supports http proxy. The http_proxy, HTTP_PROXY variables used by many apps, so I don't set it yet. In the future they can be used to separate proxies. Everything should work now, if not, try adding --insecure to cURL or set http_proxy variable again to check.
@Numstr
Uhm, the latest version with curl and proxy outputs this:
.\Updater.bat
Check Your Network Connection
Press any key to continue . . .
is there a release version with wget before this proxy feature added? I dont see an older releases in release page, did you delete it?
How to turn off proxy in the latest version?
Proxy is disabled by default. I think problem in https://www.w3.org try replace it with google.
line 30
%CURL% -I -s %CURL_PROXY% https://www.google.com | %BUSYBOX% grep -q "HTTP"
Okay. Uhm, sorry, the error only happened once. maybe it was because I'm sleepy and didnt set it up correctly. The new version worked flawlessly, actually. My vault settings also didnt get reset. thanks for the update on the fork.
proxy or vpn split-tunneling are too time consuming for me, RN. There's tunnlTo to make a vpn config has split tunnel feature since split tunneling in most vpn are paid feature. but it's not really stable. same thing with rethinkDns in mobile.
e.g., protonVpn doesnt have split tunneling in the desktop app in free tier. the extension only tunneled browser connection.
BTW, this proxy method use what service or backend, e.g, Tor, etc?
is it possible to use proxy, or hook obsidianPortable connection with protonVpn wireguard connection using the wireguard app, or TunnlTo?
or is it possible to tunneled obsidianPortable through Tor expert bundle app? IG, split tunneling of Tor expert bundle is not possible either. most split tunnel socks options are abandonware, or I haven't searched them enough.
this doesnt need to be answered now, tho. I just wanted to leave some self-notes here. I'm just gonna run VPN on untrusted network/public network fully, since split tunneling is not stable enough for me.
edit: wait, does torsocks works like split tunneling for programs, instead of full system-wide tor expert bundle's tor connection?