robrix icon indicating copy to clipboard operation
robrix copied to clipboard

Detect and use the system-configured network proxy when Robrix makes any Matrix API calls

Open alanpoon opened this issue 10 months ago • 5 comments

Currently, Matrix API does not come with System proxies detection. If the user needs to use a VPN, he needs to set environmental variables HTTP_PROXYS. Setting Wifi proxies would be useless. Makepad's http request might already be respecting system proxies since it is making HTTP requests using platform specific libraries. By default, Electron respects the system-wide proxy settings configured on the operating system. These settings are used by Chromium to route all network requests made by the Electron app.

alanpoon avatar Jan 23 '25 08:01 alanpoon

Ah interesting, I have no experience using a proxy. Is this something that the Matrix SDK needs to support, or are you saying we need to add explicit support for this into Robrix?

kevinaboos avatar Jan 23 '25 20:01 kevinaboos

Ah interesting, I have no experience using a proxy. Is this something that the Matrix SDK needs to support, or are you saying we need to add explicit support for this into Robrix?

I suggest adding explicit support for this into Robrix. I think Matrix Client allows customized reqwest Client including proxy.

use std::process::Command;

fn get_macos_proxies() {
    let output = Command::new("scutil")
        .arg("--proxy")
        .output()
        .expect("Failed to execute scutil");
    println!("{}", String::from_utf8_lossy(&output.stdout));
}

Might need to find the system proxy manually and customize the reqwest client for Matrix Client.

alanpoon avatar Jan 24 '25 02:01 alanpoon

ah ok, so this requires a new robius-proxy crate or something like that to detect/query the platform-maintained proxy, and then we'd need to apply it to Matrix SDK calls from Robrix.

I have seen proxy arguments explicitly supported in some matrix SDK functions; Robrix currently accepts it on the command line and passes it into the client builder, but it's certainly not yet getting it from the underlying platform.

kevinaboos avatar Jan 24 '25 20:01 kevinaboos

Image

I use the Proxifier.app tool with a VPN to open the packaged Mac version of the Robrix client without issues. I think this problem may not need to be solved, since 99.9% of Matrix users are outside China, and users in China likely make up less than 0.1%. Only in China is an internet proxy generally required.

I use the Proxifier.app tool together with a VPN, and I can open the packaged Mac version of the Robrix client without any problems. I think this issue may not need to be addressed, because 99.9% of Matrix users are outside of China—users in China probably account for less than 0.1%. Globally, it’s mainly in China where an internet proxy is needed.

However, Moly needs a proxy because accessing AI APIs is a global requirement. You could consider adding a relevant library in Robius to handle proxy settings in a unified way. Previously, Moly added proxy configuration directly in the code.

We also need to support bypassing the proxy when accessing configured local services; previously, moly-server was a local service.

ZhangHanDong avatar Jul 22 '25 06:07 ZhangHanDong

You could consider adding a relevant library in Robius to handle proxy settings in a unified way. Previously, Moly added proxy configuration directly in the code.

Yep, agreed, this should be a separate Robius crate. That's why I marked it as blocked-on-robius.

However, this particular platform feature is quite low-priority, unfortunately, just because there are so many other things to work on. If you or someone under your purview wants to work on a robius-proxy crate (or something similar), I can certainly help mentor them.

kevinaboos avatar Jul 24 '25 18:07 kevinaboos