Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expand the protection interval for new connections to 3m #2096

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/daemon/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,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

Expand Down Expand Up @@ -153,7 +153,7 @@ const getGatewayPort = (config) => getHttpPort(config.Addresses.Gateway)
*/
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)

Expand Down Expand Up @@ -221,6 +221,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 } = config.Swarm.ConnMgr
if (GracePeriod === '1m') {
config.Swarm.ConnMgr.GracePeriod = '3m'
changed = true
}
}

if (changed) {
try {
writeConfigFile(ipfsd, config)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/launch.e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,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)
})
Expand Down