diff --git a/src/config.js b/src/config.js index c4b4629d2..ac33534cb 100644 --- a/src/config.js +++ b/src/config.js @@ -30,7 +30,9 @@ function ensurePath (path) { const ipfsAppData = ensurePath(path.join(app.getPath('appData'), 'ipfs-desktop')) const logsPath = ensurePath(path.join(ipfsAppData, 'logs')) -const settingsStore = new KeyValueStore(path.join(ipfsAppData, 'config.json')) +const settingsStore = new KeyValueStore(path.join(ipfsAppData, 'config.json'), { + dhtClient: true +}) if (!settingsStore.get('ipfsPath')) { const p = path.join(process.env.IPFS_PATH || (process.env.HOME || process.env.USERPROFILE), '.ipfs') diff --git a/src/index.js b/src/index.js index 389d5b2de..7831161ae 100644 --- a/src/index.js +++ b/src/index.js @@ -72,7 +72,12 @@ function onStartDaemon (node) { } } - node.start(['--routing=dhtclient'], (err, api) => { + const flags = [] + if (config.settingsStore.get('dhtClient')) { + flags.push('--routing=dhtclient') + } + + node.start(flags, (err, api) => { if (err) { handleKnownErrors(err) return diff --git a/src/panes/Settings.js b/src/panes/Settings.js index 86cf21bfd..7e60a3ec7 100644 --- a/src/panes/Settings.js +++ b/src/panes/Settings.js @@ -41,6 +41,16 @@ const options = [ ) }, + { + title: 'DHT client profile', + setting: 'dhtClient', + description: ( + + Make your IPFS node act as a DHT client and not a DHT server, consuming less network and battery. + Restarting your node is required. + + ) + }, { title: 'Light theme', setting: 'lightTheme' diff --git a/src/utils/key-value-store.js b/src/utils/key-value-store.js index b3603de7e..a81e374fe 100644 --- a/src/utils/key-value-store.js +++ b/src/utils/key-value-store.js @@ -5,8 +5,8 @@ import FileStore from './file-store' * @extends FileStore */ export default class KeyValueStore extends FileStore { - constructor (location) { - super(location, {}) + constructor (location, d = {}) { + super(location, d) } /**