Skip to content

Conversation

@tyreseluo
Copy link

@tyreseluo tyreseluo commented Aug 17, 2025

PR Content

Add cross-platform proxy crate with macOS backend and docs.

Currently, only macOS-related proxy enablement and retrieval have been added.

Usage

use robius_proxy::{BypassList, ProxyEndpoint, ProxyManager, ProxyMode, ProxySettings, ProxyState};

let manager = ProxyManager::new()?;
let current = manager.current()?;

println!("Current mode: {:?}", current.mode);

// Get proxy configuration.
match &state.mode {
        ProxyMode::Direct => println!("  mode: Direct (no proxy)"),
        ProxyMode::Manual(settings) => {
            println!("  mode: Manual");
            if let Some(http) = &settings.http {
                println!("    http: {}:{}", http.host, http.port);
            }
            if let Some(https) = &settings.https {
                println!("    https: {}:{}", https.host, https.port);
            }
            if let Some(socks) = &settings.socks {
                println!("    socks: {}:{}", socks.host, socks.port);
            }
            if settings.bypass.entries.is_empty() {
                println!("    bypass: (none)");
            } else {
                println!("    bypass:");
                for entry in &settings.bypass.entries {
                    println!("      - {entry}");
                }
            }
        }
        ProxyMode::AutoConfigUrl { url, bypass } => {
            println!("  mode: PAC url");
            println!("    url: {url}");
            if bypass.entries.is_empty() {
                println!("    bypass: (none)");
            } else {
                println!("    bypass:");
                for entry in &bypass.entries {
                    println!("      - {entry}");
                }
            }
        }
        ProxyMode::AutoDiscovery { bypass } => {
            println!("  mode: Auto-discovery (WPAD)");
            if bypass.entries.is_empty() {
                println!("    bypass: (none)");
            } else {
                println!("    bypass:");
                for entry in &bypass.entries {
                    println!("      - {entry}");
                }
            }
        }
    }

// Apply proxy configuration.
let state = ProxyState::manual(ProxySettings {
    http: Some(ProxyEndpoint::new("proxy.local", 8080)),
    https: None,
    socks: None,
    bypass: BypassList::new(vec!["localhost".into(), "127.0.0.1".into()]),
});

manager.apply(state)?;

@tyreseluo tyreseluo changed the title [WIP] Add robius-proxy crate for cross-platform system proxy detection [WIP] Add robius-proxy crate for cross-platform system proxy detection (Desktop) Aug 18, 2025
@tyreseluo tyreseluo changed the title [WIP] Add robius-proxy crate for cross-platform system proxy detection (Desktop) Add cross-platform proxy crate (For macOS) Dec 17, 2025
@tyreseluo tyreseluo marked this pull request as ready for review December 17, 2025 13:14
@tyreseluo tyreseluo marked this pull request as draft December 18, 2025 01:13
@tyreseluo tyreseluo marked this pull request as ready for review December 29, 2025 09:53
@tyreseluo
Copy link
Author

Hi! @kevinaboos the proxy crate for macOS proxy retrieval is now complete. Users can now obtain the currently applied proxy information on macOS.

By enhancing the proxy crate to support proxy requests for cross-platform applications from users in the China region.

For instance, after packaging and distributing Robrix, we discovered that users in China cannot connect to the matrix.org network. Although the system applies a proxy, the running Robrix instance operates in a sandboxed environment and cannot access the proxy configuration. Therefore, we should provide such a proxy crate—one that is at least useful and uncomplicated.

I will submit PRs for the proxy crate on each platform separately and gradually improve and finish this proxy crate.

@tyreseluo tyreseluo requested a review from kevinaboos December 29, 2025 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant