Skip to content

Commit

Permalink
feat: default minimum and maximum connections (#828)
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias authored Feb 18, 2019
1 parent d7ff2d0 commit de00907
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/utils/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,27 @@ async function spawn ({ type, path, keysize }) {
keysize: keysize
}, e => {
if (e) return reject(e)

try {
// Set default mininum and maximum of connections to mantain
// by default. This only applies to repositories created by
// IPFS Desktop. Existing ones shall remain intact.
const configFile = join(ipfsd.repoPath, 'config')
let config = fs.readJsonSync(configFile)
config.Swarm = config.Swarm || {}
config.Swarm.DisableNatPortMap = false
config.Swarm.ConnMgr = config.Swarm.ConnMgr || {}
config.Swarm.ConnMgr.GracePeriod = '300s'
config.Swarm.ConnMgr.LowWater = 50
config.Swarm.ConnMgr.HighWater = 300
config.Discovery = config.Discovery || {}
config.Discovery.MDNS = config.Discovery.MDNS || {}
config.Discovery.MDNS.enabled = true
fs.writeJsonSync(configFile, config)
} catch (e) {
return reject(e)
}

resolve(ipfsd)
})
})
Expand Down

0 comments on commit de00907

Please sign in to comment.