Add basic proxy settings (#11852)
Adding `proxy` keyword to configure proxy while using zed. After setting the proxy, restart Zed to acctually use the proxy. Example setting: ```rust "proxy" = "socks5://localhost:10808" "proxy" = "http://127.0.0.1:10809" ``` Closes #9424, closes #9422, closes #8650, closes #5032, closes #6701, closes #11890 Release Notes: - Added settings to configure proxy in Zed --------- Co-authored-by: Jason Lee <huacnlee@gmail.com>
This commit is contained in:
parent
90b631ff3e
commit
1b261608c6
8 changed files with 110 additions and 20 deletions
|
@ -114,10 +114,36 @@ impl Settings for ClientSettings {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct ProxySettingsContent {
|
||||
proxy: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default)]
|
||||
pub struct ProxySettings {
|
||||
pub proxy: Option<String>,
|
||||
}
|
||||
|
||||
impl Settings for ProxySettings {
|
||||
const KEY: Option<&'static str> = None;
|
||||
|
||||
type FileContent = ProxySettingsContent;
|
||||
|
||||
fn load(sources: SettingsSources<Self::FileContent>, _: &mut AppContext) -> Result<Self> {
|
||||
Ok(Self {
|
||||
proxy: sources
|
||||
.user
|
||||
.and_then(|value| value.proxy.clone())
|
||||
.or(sources.default.proxy.clone()),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init_settings(cx: &mut AppContext) {
|
||||
TelemetrySettings::register(cx);
|
||||
cx.update_global(|store: &mut SettingsStore, cx| {
|
||||
store.register_setting::<ClientSettings>(cx);
|
||||
store.register_setting::<ProxySettings>(cx);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -512,6 +538,7 @@ impl Client {
|
|||
let clock = Arc::new(clock::RealSystemClock);
|
||||
let http = Arc::new(HttpClientWithUrl::new(
|
||||
&ClientSettings::get_global(cx).server_url,
|
||||
ProxySettings::get_global(cx).proxy.clone(),
|
||||
));
|
||||
Self::new(clock, http.clone(), cx)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue