mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-14 03:41:46 +00:00
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:
21
src/index.ts
21
src/index.ts
@ -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
|
||||
|
||||
Reference in New Issue
Block a user