Unable to remove default boostraps in ipfs setup

Hello,

Is it possible to create a ‘private’ IPFS between several computers in a local network (without internet access) ?
To this purpose, I am trying first to clear the defaults ipfs bootstraps :

ipfs = await create({
    bootstrap: [],
});
await ipfs.bootstrap.clear();

But I still see in logs that it connects to default bootstraps :

  libp2p:dialer creating dial target for QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ +0ms
  libp2p:peer-store:address-book:trace get wait for read lock +1ms
  libp2p:dialer creating dial target for QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN +1ms
  libp2p:peer-store:address-book:trace get wait for read lock +1ms
  libp2p:dialer creating dial target for QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb +0ms
  libp2p:peer-store:address-book:trace get wait for read lock +0ms
  libp2p:dialer creating dial target for QmZa1sAxajnQjVM8WjWXoMbmPd7NsWhfKsPkErzpm9wGkp +0ms
  libp2p:peer-store:address-book:trace get wait for read lock +0ms
  libp2p:dialer creating dial target for QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa +0ms
  libp2p:peer-store:address-book:trace get wait for read lock +0ms
  libp2p:dialer creating dial target for QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt +0ms
  libp2p:peer-store:address-book:trace get wait for read lock +0ms
  libp2p:dialer creating dial target for QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic +0ms
  libp2p:peer-store:address-book:trace get wait for read lock +0ms
  libp2p:dialer creating dial target for Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6 +0ms
  libp2p:peer-store:address-book:trace get wait for read lock +0ms
  libp2p:dialer creating dial target for QmV7gnbW5VTcJ3oyM2Xk1rdFBJ3kTkvxc87UFGsun29STS +0ms
  libp2p:peer-store:address-book:trace get wait for read lock +0ms
  libp2p:dialer creating dial target for QmY7JB6MQXhxHvq7dBDh4HpbH29v4yE9JRadAVpndvzySN +0ms

How is it possible ? Something I may have misunderstood ?

Thanks

1 Like

I don’t know if it is the solution, but the only way I’ve found to force ipfs with no default Bootstrap peers is to edit the file node_modules/ipfs-core-config/src/config.js to remove the Delegates and the Bootstraps default lists.

Now, I will try to add my owns from the setup…

Feedback is welcome to know if this solution is relevant. Thanks

Your example uses the wrong key to set the bootstrap nodes.

This is how you would change the defaults (notice that Bootsrap is in the config key):

const ipfs = await create({
  config: {
    Bootstrap: [],
  }
})

The full options of the config key can be found js-ipfs/CONFIG.md at master · ipfs/js-ipfs · GitHub

1 Like

Unfortunately no.

  • It looks like the config parameter is not used anymore (even if some examples still use it). You can see it in the default config.js file here. The CONFIG.md does not show config key anymore.
  • Moreover, the Boostrap setup only merge the setup with this default config, as you can see it in the repo init code. So, when bootstrap setup is set to [] the final setup still contains the default bootstraps
    For now, the only way I’ve found is to edit the config.js

See here that it loads the config is loaded from initOptions.config :

Moreover, the Boostrap setup only merge the setup with this default config, as you can see it in the repo init code. So, when bootstrap setup is set to [] the final setup still contains the default bootstraps

That’s incorrect. setting Bootstrap to [] will override the default. mergeOptions overrides arrays rather than merging them. See the following example:

To answer your original question about a private IPFS network, you can use the pnet libp2p option to secure the network with a shared key:

Example

Thanks for your answer. I’ve therefore tried the following setup (trying also with init.allowNew:true or preload.enabled=false):

  ipfs = await createIpfs({
    libp2p: options,
    start: false,
    config: {
      Bootstrap: [],
    },
  });

(having erased .jsipfs first to be sure not to have a old setup)
Unfortunately again, the default bootstraps are again there :
Capture d’écran 2022-09-09 à 13.39.04

And I can even see in the logs the ipfs node tries to connect to them :

libp2p:bootstrap Starting bootstrap node discovery +0ms
  libp2p:peer-store:address-book:trace add await write lock +0ms
  libp2p:dialer:auto-dialer auto-dialing discovered peer QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ with timeout 10000 +0ms
  libp2p:connection-manager dial to QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ +18ms
  libp2p:dialer check multiaddrs QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ +0ms
  libp2p:peer-store:address-book:trace add await write lock +1ms
  libp2p:dialer:auto-dialer auto-dialing discovered peer QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN with timeout 10000 +1ms
  libp2p:connection-manager dial to QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN +1ms
  libp2p:dialer check multiaddrs QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN +0ms

Btw, I use the latest ipfs release : "ipfs": "^0.64.0" with "electron": "^20.0.3", node:v16.17.0

I totally agree with your analysis, but I still don’t understand what happens here as the storage.repo.config.getAll() returns default Bootstraps…

Can you please share a reproduction repo?

In the screenshot you shared, it seems that you instantiate the storage before IPFS with the config which is why it might be instantiating with the default config.

It’s hard to say without looking at the rest of your code.

Another thing to try is disabling autoDial:

const node = await create({
  config: {
    Bootstrap: [],
  },
  libp2p: {
    connectionManager: {
      autoDial: false,
    },
  },
})

This will disable auto dialing peers that your node receives from connected peers.

1 Like

Hello,

Thanks again, and sorry for the delay to answer : I’ve tried to make a repo to show it, but unfortunately, it works now as you said : the config.Boostrap replaces the default setup indeed. I may have been confused by the following comment which says the config is merged. May be this file should be updated ?

Dealing with default setup, I am now faced with the fact that the storage ~/.jsipfs/config file shows an peerId identity which is not the same as the one set in options. And (another subject), that ipfs features look broken when a .jsipfs directory is already present (I have opened an issue here)

Thanks again for your help. I think the bootstrap setup subject is solved.

1 Like