From eb10f126a2003e724a371be878852c26d9aa6a58 Mon Sep 17 00:00:00 2001 From: RubenKelevra Date: Thu, 7 Apr 2022 12:24:39 +0200 Subject: [PATCH 1/2] expand the protection interval for new connections to 3m The protection interval was previously set to 1m, which was deemed too low. Rationale: https://github.com/ipfs/ipfs-desktop/pull/2055#issuecomment-1090327377 --- src/daemon/config.js | 14 ++++++++++++-- test/e2e/launch.e2e.test.js | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/daemon/config.js b/src/daemon/config.js index d828adcd2..6ae2273c2 100644 --- a/src/daemon/config.js +++ b/src/daemon/config.js @@ -47,7 +47,7 @@ function applyDefaults (ipfsd) { config.Swarm = config.Swarm || {} config.Swarm.DisableNatPortMap = false config.Swarm.ConnMgr = config.Swarm.ConnMgr || {} - config.Swarm.ConnMgr.GracePeriod = '1m' + config.Swarm.ConnMgr.GracePeriod = '3m' config.Swarm.ConnMgr.LowWater = 20 config.Swarm.ConnMgr.HighWater = 40 @@ -77,7 +77,7 @@ function getHttpPort (addrs) { // This is the place where we execute fixes and performance tweaks for existing users. function migrateConfig (ipfsd) { // Bump revision number when new migration rule is added - const REVISION = 4 + const REVISION = 5 const REVISION_KEY = 'daemonConfigRevision' const CURRENT_REVISION = store.get(REVISION_KEY, 0) @@ -149,6 +149,16 @@ function migrateConfig (ipfsd) { } } + if (CURRENT_REVISION < 5) { + // expand pretection interval for new connections. + // Rationale: https://github.com/ipfs/ipfs-desktop/pull/2055#issuecomment-1090327377 + const { GracePeriod, LowWater, HighWater } = config.Swarm.ConnMgr + if (GracePeriod === '1m') { + config.Swarm.ConnMgr.GracePeriod = '3m' + changed = true + } + } + if (changed) { try { writeConfigFile(ipfsd, config) diff --git a/test/e2e/launch.e2e.test.js b/test/e2e/launch.e2e.test.js index fced640e2..60b00fb62 100644 --- a/test/e2e/launch.e2e.test.js +++ b/test/e2e/launch.e2e.test.js @@ -186,7 +186,7 @@ test.describe.serial('Application launch', async () => { const config = fs.readJsonSync(configPath) // ensure app has migrated config - expect(config.Swarm.ConnMgr.GracePeriod).toEqual('1m') + expect(config.Swarm.ConnMgr.GracePeriod).toEqual('3m') expect(config.Swarm.ConnMgr.LowWater).toEqual(20) expect(config.Swarm.ConnMgr.HighWater).toEqual(40) }) From ae9df4ec7ffd650a541aef69a4fa0cfcc562c8d1 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 13 Sep 2022 12:03:07 -0700 Subject: [PATCH 2/2] fix: use standard style --- src/daemon/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/daemon/config.js b/src/daemon/config.js index f226530f0..20df91de4 100644 --- a/src/daemon/config.js +++ b/src/daemon/config.js @@ -224,7 +224,7 @@ function migrateConfig (ipfsd) { if (CURRENT_REVISION < 5) { // expand pretection interval for new connections. // Rationale: https://github.com/ipfs/ipfs-desktop/pull/2055#issuecomment-1090327377 - const { GracePeriod, LowWater, HighWater } = config.Swarm.ConnMgr + const { GracePeriod } = config.Swarm.ConnMgr if (GracePeriod === '1m') { config.Swarm.ConnMgr.GracePeriod = '3m' changed = true