feat(plugin): support authenticated proxy (#3175)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: JellyBrick <shlee1503@naver.com>
Co-authored-by: qiye45 <qiye45@users.noreply.github.com>
This commit is contained in:
qiye45
2025-05-11 01:04:00 +08:00
committed by GitHub
parent b9269bf085
commit 852933d4d7
10 changed files with 434 additions and 1 deletions

View File

@ -57,6 +57,8 @@ import { loadI18n, setLanguage, t } from '@/i18n';
import ErrorHtmlAsset from '@assets/error.html?asset';
import { defaultAuthProxyConfig } from '@/plugins/auth-proxy-adapter/config';
import type { PluginConfig } from '@/types/plugins';
if (!is.macOS()) {
@ -141,7 +143,24 @@ if (is.linux()) {
}
if (config.get('options.proxy')) {
app.commandLine.appendSwitch('proxy-server', config.get('options.proxy'));
const authProxyEnabled = config.plugins.isEnabled('auth-proxy-adapter');
let proxyToUse = '';
if (authProxyEnabled) {
// Use proxy from Auth-Proxy-Adapter plugin
const authProxyConfig = deepmerge(
defaultAuthProxyConfig,
config.get('plugins.auth-proxy-adapter') ?? {},
) as typeof defaultAuthProxyConfig;
const { hostname, port } = authProxyConfig;
proxyToUse = `socks5://${hostname}:${port}`;
} else if (config.get('options.proxy')) {
// Use global proxy settings
proxyToUse = config.get('options.proxy');
}
console.log(LoggerPrefix, `Using proxy: ${proxyToUse}`);
app.commandLine.appendSwitch('proxy-server', proxyToUse);
}
// Adds debug features like hotkeys for triggering dev tools and reload