fix(settings): restrict custom proxy to http

Remove the SOCKS5 example from the Network settings custom proxy field until normal file downloads support it end to end.

Reject non-HTTP custom proxy URLs in frontend normalization so Settings cannot emit unsupported proxy schemes to aria2-backed downloads.

Update proxy dispatch tests to preserve the HTTP path and cover rejected SOCKS5 and HTTPS custom inputs.
This commit is contained in:
NimBold
2026-07-06 00:55:03 +03:30
parent c13f993150
commit 579174c5b5
3 changed files with 7 additions and 5 deletions
+2 -2
View File
@@ -802,13 +802,13 @@ runEngineChecks(false);
<div className="mac-settings-row settings-network-row">
<div className="settings-row-label">
<span>Proxy host</span>
<small>Host name, IP address, or URL with scheme.</small>
<small>Host name, IP address, or HTTP proxy URL.</small>
</div>
<input
type="text"
value={settings.proxyHost}
onChange={(e) => settings.setProxyHost(e.target.value)}
placeholder="127.0.0.1 or socks5://127.0.0.1"
placeholder="127.0.0.1 or http://127.0.0.1"
className="app-control settings-network-input font-mono"
/>
</div>
+4 -3
View File
@@ -68,8 +68,9 @@ describe('useDownloadStore', () => {
it('normalizes proxy settings for download dispatch', async () => {
expect(normalizeCustomProxy('127.0.0.1', 8080)).toBe('http://127.0.0.1:8080');
expect(normalizeCustomProxy(' socks5://127.0.0.1 ', 1080)).toBe('socks5://127.0.0.1:1080');
expect(normalizeCustomProxy('http://proxy.local:9000', 8080)).toBe('http://proxy.local:9000');
expect(normalizeCustomProxy(' socks5://127.0.0.1 ', 1080)).toBeNull();
expect(normalizeCustomProxy('https://proxy.local', 8443)).toBeNull();
expect(normalizeCustomProxy('127.0.0.1', NaN)).toBeNull();
expect(await getProxyArgs({
@@ -87,9 +88,9 @@ describe('useDownloadStore', () => {
expect(await getProxyArgs({
proxyMode: 'custom',
proxyHost: 'socks5://127.0.0.1',
proxyHost: 'http://127.0.0.1',
proxyPort: 1080
} as ReturnType<typeof useSettingsStore.getState>)).toBe('socks5://127.0.0.1:1080');
} as ReturnType<typeof useSettingsStore.getState>)).toBe('http://127.0.0.1:1080');
});
it('matches site logins by host, wildcard host, path, and full URL patterns', () => {
+1
View File
@@ -102,6 +102,7 @@ export const normalizeCustomProxy = (host: string, port: number): string | null
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(trimmedHost)) {
try {
const parsed = new URL(trimmedHost);
if (parsed.protocol !== 'http:') return null;
if (!parsed.port) parsed.port = String(normalizedPort);
return parsed.toString().replace(/\/$/, '');
} catch {