Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(vscode): add useVSCodeProxy option to control whether to use Vscode Proxy #3440

Merged
merged 8 commits into from
Nov 22, 2024
1 change: 1 addition & 0 deletions clients/tabby-agent/src/http/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function createProxyForUrl(url: string, configs: ProxyConfig[]): Dispatch
logger.info("Using proxy from environment variables.");
return new EnvHttpProxyAgent();
} else if ("url" in config && config["url"]) {
// "item1, item2 item3".split(/,|\s+/). Results in: ["item1", "item2", "item3"]
const noProxyList = config["noProxy"]?.split(/,|\s+/).map((item) => item.trim());
if (!noProxyList || !noProxyList.includes(host)) {
logger.info(`Using proxy ${config["url"]}.`);
Expand Down
11 changes: 11 additions & 0 deletions clients/vscode/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ export class Config extends EventEmitter {
const https = workspace.getConfiguration("https");
const httpsProxy = https.get("proxy", "");
const httpProxy = this.httpConfig.get("proxy", "");
// noProxy bypass
if (this.noProxy.includes(httpsProxy) || this.noProxy.includes(httpProxy)) return "";

return httpsProxy || httpProxy;
}
Expand All @@ -183,6 +185,15 @@ export class Config extends EventEmitter {
}
}

// To fit createProxyForUrl function's signature in agent.
get noProxy(): string[] {
return this.httpConfig.get("noProxy", []);
}

set noProxy(value: string[]) {
this.httpConfig.update("noProxy", value);
}

buildClientProvidedConfig(): ClientProvidedConfig {
return {
// Note: current we only support http.proxy | http.authorization
Expand Down
Loading