mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-11-25 13:51:18 +01:00
fix(proxy): ignore inactive pool input validation in fixed mode
This commit is contained in:
1 parent
3afff5ed8a
commit
1609ac21bf
2 files changed
+13
-2
No files matched your search
@@ -30,8 +30,9 @@ async function saveProxySettings() {
|
||||
for (const key of ['mode', 'proxy_url', 'proxy_pool', 'proxy_source', 'strategy']) proxy[key] = document.getElementById(`proxy-setting-${key}`).value.trim();
|
||||
for (const key of ['max_attempts', 'cooldown', 'min_switch_interval']) {
|
||||
const input = document.getElementById(`proxy-setting-${key}`);
|
||||
if (!input.checkValidity() || input.value === '') throw new Error(window.t('proxySettings.invalidNumber'));
|
||||
proxy[key] = Number(input.value);
|
||||
const valid = input.checkValidity() && input.value !== '';
|
||||
if (!valid && proxy.mode === 'pool') throw new Error(window.t('proxySettings.invalidNumber'));
|
||||
proxy[key] = valid ? Number(input.value) : ({max_attempts: 3, cooldown: 60, min_switch_interval: 60})[key];
|
||||
}
|
||||
const response = await apiFetch('/api/config', {method: 'PUT', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({proxy})});
|
||||
if (!response.ok) throw new Error((await response.json()).error || window.t('proxySettings.saveError'));
|
||||
|
||||
@@ -23,3 +23,13 @@ test('masked credentials survive save without restarting other services',async()
|
||||
assert.equal(f.calls.some(x=>x.url==='/api/config/apply'),false);
|
||||
assert.equal(f.elements['proxy-settings-save'].disabled,false);
|
||||
});
|
||||
test('hidden pool validation does not prevent switching to a fixed proxy',async()=>{
|
||||
const f=fixture({mode:'pool'});await f.ctx.loadProxySettings();
|
||||
f.elements['proxy-setting-max_attempts'].value='';
|
||||
f.elements['proxy-setting-max_attempts'].checkValidity=()=>false;
|
||||
f.elements['proxy-setting-mode'].value='fixed';
|
||||
f.elements['proxy-setting-proxy_url'].value='http://localhost:8080';
|
||||
await f.ctx.saveProxySettings();
|
||||
const write=f.calls.find(x=>x.options?.method==='PUT');assert.ok(write);
|
||||
assert.equal(JSON.parse(write.options.body).proxy.max_attempts,3);
|
||||
});
|
||||
Reference in new issue
Block a user