1
0
forked from boos/BoosAPI

fix(proxy): skip dispatcher cache for account-level proxy URLs

This commit is contained in:
Hureru
2026-03-19 01:39:35 +08:00
parent 619df14291
commit bece34ae5b
2 changed files with 19 additions and 8 deletions
+11 -5
View File
@@ -154,19 +154,23 @@ async function getCachedSiteProxyRows(nowMs = Date.now()): Promise<SiteProxyRow[
return siteProxyCache.rows;
}
function getDispatcherByProxyUrl(proxyUrl: string): Dispatcher | undefined {
function getDispatcherByProxyUrl(proxyUrl: string, skipCache = false): Dispatcher | undefined {
const normalized = normalizeSiteProxyUrl(proxyUrl);
if (!normalized) return undefined;
if (!skipCache) {
const cached = dispatcherCache.get(normalized);
if (cached) return cached;
}
try {
const parsedProxyUrl = new URL(normalized);
const dispatcher = SOCKS_PROXY_PROTOCOLS.has(parsedProxyUrl.protocol.toLowerCase())
? createSocksDispatcher(parsedProxyUrl)
: new ProxyAgent(normalized);
if (!skipCache) {
dispatcherCache.set(normalized, dispatcher);
}
return dispatcher;
} catch {
return undefined;
@@ -413,7 +417,7 @@ export async function withSiteProxyRequestInit(
return nextOptions;
}
const dispatcher = getDispatcherByProxyUrl(proxyUrl);
const dispatcher = getDispatcherByProxyUrl(proxyUrl, alsOverride != null);
if (!dispatcher) {
return nextOptions;
}
@@ -427,11 +431,12 @@ export async function withSiteProxyRequestInit(
export function withExplicitProxyRequestInit(
proxyUrl: string | null | undefined,
options?: UndiciRequestInit,
skipCache = false,
): UndiciRequestInit {
const normalized = normalizeSiteProxyUrl(proxyUrl);
if (!normalized) return options ?? {};
const dispatcher = getDispatcherByProxyUrl(normalized);
const dispatcher = getDispatcherByProxyUrl(normalized, skipCache);
if (!dispatcher) return options ?? {};
return {
@@ -457,8 +462,9 @@ export function withSiteRecordProxyRequestInit(
if (mergedHeaders) {
nextOptions.headers = mergedHeaders;
}
const proxyUrl = normalizeSiteProxyUrl(accountProxyUrl) || resolveProxyUrlForSite(site);
return withExplicitProxyRequestInit(proxyUrl, nextOptions);
const accountNormalized = normalizeSiteProxyUrl(accountProxyUrl);
const proxyUrl = accountNormalized || resolveProxyUrlForSite(site);
return withExplicitProxyRequestInit(proxyUrl, nextOptions, !!accountNormalized);
}
export function resolveChannelProxyUrl(
+5
View File
@@ -2235,6 +2235,11 @@ body[data-tooltip-portal="true"] [data-tooltip]::before {
color: var(--color-text-muted);
}
[data-theme="dark"] .badge-purple {
background: #2e1065;
color: #c4b5fd;
}
[data-theme="dark"] .badge-link:hover .badge-muted,
[data-theme="dark"] .badge-link:focus-visible .badge-muted {
background: rgba(96, 165, 250, 0.2);