# macOS
**SOCKSv5**
- host: c_char
- port: c_char
**HTTP**
- host: c_char
- port: c_char
- tls_options?: // optional, will enable HTTPS
**Relay (MASQUE)**
- relay: [RelayHop] (max: 2)
**Oblivious HTTP**
- relay: RelayHop
- relay_resource_path: c_char
- gateway_key_config: *const u8
- gateway_key_config_length: i32 / i64
```rs!
struct RelayHop {
http3: c_char,
// optional, fallback
http2: Option<c_char>,
tls_options: TlsConfig,
// optional, need to \check what we can use
additional_HTTP_headers: Option<HashMap<String, String>,
}
```
# Windows (WebView2)
Uses `--proxy-server` argument to pass through uri, currently doesn't support authentication.
Uses `--proxy-bypass-list=(<trailing_domain>|<ip-address>)[:<port>][;...]` argument to bypass specific hosts
Can pass on argument with `wry::webview::WebViewBuilderExtWindows::with_additional_browser_args` (available in wry 0.30.0)
# Linux (Webkit2gtk)
Quick test using `webkit2gtk-rs`:
``` Rust
let context = WebContext::default().unwrap();
let x = context.website_data_manager();
match x{
Some(i) => {
let mut settings = NetworkProxySettings::new(Some("protocol://username:password@ipaddress:port"),&[""]);
i.set_network_proxy_settings(NetworkProxyMode::Custom, Some(&mut settings));
},
_ => println!("Doesn't have WDM"),
}
```
Use `set_network_proxy_settings` and pass in `NetworkProxyMode` and `NetworkProxySettings`.
`NetworkProxySettings` need to be constructed with `default_proxy_uri` (Option<&str>) and `ignore_hosts` (&[&str]).
"protocol://username:password@ipaddress:port" can be used directly in uri for authentication.
# Wry API
First thought from macOS API
```rs!
impl<'a> WebViewBuilder<'a> {
pub fn with_proxy_configuration(mut self, configuration: ProxyConfig) -> Self {
self.webview.proxy_configuration = configuration;
}
}
// Is it possible to proxy set after the webview created?
impl WebView {
pub fn set_proxy_configuration(&self, configuration: Option<ProxyConfig>) {
self.webview.set_proxy_configuration(configuration)
}
}
pub enum ProxyType {
Http,
Socks5,
// TBD, macOS only
ObliviousHttp,
// TBD, macOS only, MASQUE
Relay,
}
pub struct TlsConfig {
// TBD, need to check what configuration we could use
}
pub struct ProxyEndpoint {
host: String,
port: String,
}
pub struct ProxyRelayHop {
http3: ProxyEndpoint,
http2: Option<ProxyEndpoint>, // optional, fallback
tls_config: TlsConfig,
additional_HTTP_headers: Option<HashMap<String, String>>, // optional
}
pub enum ProxyConnection {
Http(ProxyEndpoint),
Http(ProxyEndpoint, TlsConfig),
Socks5(ProxyEndpoint),
// tls not support in macOS
Socks5(ProxyEndpoint, TlsConfig),
// TBD, macOS only
ObliviousHttp(ProxyRelayHop, ObliviousHttpConfig),
// TBD, macOS only, max: 2 hops
Relay(Vec<ProxyRelayHop>),
}
pub struct ProxyConfig {
type: ProxyType,
connection: ProxyConnection,
// authentication: Option<ProxyAuthentication>
// TBD, default using ProxyType + TLS to guess the protocol (http / https / socks5 / ...), but provide some flexbility if we make mistakes (linux / windows only).
protocol: Option<String>,
}
```