fix(settings): harden Torrent network validation

- Align the DHT message-timeout range with bundled Aria2 1.37.0.
- Validate and canonicalize Torrent network text settings at the native boundary.
- Fence delayed input responses and reject contradictory IPv6 bind state.
- Add regression coverage for malformed settings and cross-field races.
This commit is contained in:
NimBold
2026-08-13 16:40:46 +03:30
parent 4b43e8ed5c
commit 314f4e2e00
16 changed files with 389 additions and 164 deletions
+27
View File
@@ -133,6 +133,33 @@ describe('Torrent peer discovery preferences', () => {
});
});
it('clears an IPv6 bind address when IPv6 transport is disabled', () => {
useSettingsStore.setState({
torrentIpv6Enabled: true,
torrentBindAddress: '2001:db8::10'
});
useSettingsStore.getState().setTorrentIpv6Enabled(false);
expect(useSettingsStore.getState()).toMatchObject({
torrentIpv6Enabled: false,
torrentBindAddress: ''
});
});
it('rejects an IPv6 bind address entered after IPv6 transport is disabled', () => {
useSettingsStore.setState({
torrentIpv6Enabled: false,
torrentBindAddress: ''
});
expect(useSettingsStore.getState().setTorrentBindAddress('2001:db8::10')).toBe(false);
expect(useSettingsStore.getState().torrentBindAddress).toBe('');
expect(useSettingsStore.getState().setTorrentBindAddress('192.0.2.10')).toBe(true);
expect(useSettingsStore.getState().torrentBindAddress).toBe('192.0.2.10');
});
it('matches Aria2 defaults and persists explicit changes', async () => {
expect(useSettingsStore.getState().torrentEnableDht).toBe(true);
expect(useSettingsStore.getState().torrentEnableDht6).toBe(false);