I’m working with IPFS and need to ensure my IPFS daemon does not automatically connect to other nodes. I’ve managed to remove default bootstrap nodes by modifying the config file, but the daemon still connects to local nodes due to the mDNS function and other automatic connection behaviors.
Here’s what I’ve tried so far:
Removed default bootstrap nodes by modifying the config file.
Set Discovery.MDNS.Enabled to false in the config file.
However, these steps didn’t fully stop the automatic connections. I understand that changes in the config files alone are not sufficient and that further modification of the source code (specifically around go-libp2p-kad-dht) might be necessary to stop new connections without affecting the basic functionality of IPFS.
How can I modify the go-IPFS (KUBO) source code to achieve this? Are there specific files or functions I should look into? Any guidance on rebuilding the IPFS daemon to ensure no automatic connections are made would be greatly appreciated.
I meant to absolutely connect to no one. I found a directory “go-libp2p-kad-dht,” which I added to make that possible. Now my next problem is to get the WebUI to work for my KUBO .
ok to explain in detail. I deleted the content of the Bootstrap in .ipfs config file and disabled the Discovery.MDNS. additional in the go-libp2p-kad-dht directory, i made some changes/configurations in the kubo/go-libp2p-kad-dht/internal/net/message_manager.go file. i replaced the line “nstr, err := ms.m.host.NewStream(ctx, ms.p, ms.m.protocols…)” with “nstr, err := ms.m.host.NewStream(network.WithNoDial(ctx, “Don’t auto dial”), ms.p, ms.m.protocols…)” and in the kubo/go-libp2p-kad-dht/rtrefresh/rt_refresh_manager.go file, i replaced
´if err := r.h.Connect(livelinessCtx, peer.AddrInfo{ID: ps.Id}); err != nil {
logger.Debugw(“evicting peer after failed connection”, “peer”, peerIdStr, “error”, err)
span.RecordError(err)
r.rt.RemovePeer(ps.Id)
return
}´
Now it is not stopping the auto connections yet and my Web UI is working again because i added the
´API": {
“HTTPHeaders”: {
“Access-Control-Allow-Methods”: [
“PUT”,
“POST”
],
“Access-Control-Allow-Origin”: [
My IP Address here with the relevant port
]
}
},´
and also added my IP address to the Addresses.API list too.
But now the Web UI is accessible when I run ´ipfs daemon,´ but I see peers connected. dynamic number of peers and not a fixed number of peers/nodes. I hope I did not confuse you more now and was able to explain everything in great detail enough.
exactly i am recompling the kubo. It is a learning process. I have not done it before, but there is not also much information on how to do it online. I am trying to “customize the ipfs daemon”.
and I am not doing ipfs --offline daemon because it is not fulfilling my purpose.
The IPFS daemon can be configured by modifying the ”config” file in its
default directory. By doing this, you can remove those
default bootstrap nodes before the start of an IPFS daemon. Unfortunately, changes to config files are not enough to turn off the bootstrap function. The reason is that IPFS enables an mDNS function where nodes continuously find nodes in the local network and connect to them. Although you can set ”Discovery.MDNS.Enabled” to false in the config file, it does not stop the bootstrap function entirely. In some cases, a node is uploading a file for
For example, this node will still connect to other nodes in the local network. This is because every time a new uploading or downing event happens, the IPFS daemon will store the corresponding addresses in a local DHT table, and this DHT table is used to route contents. Hence, I am inspecting the source code of KUBO first to see where new connections are constructed. Then, i can
modify those codes carefully to stop the automatic new connection construction
without influencing the basic function of IPFS. After my modifications, I can rebuild the IPFS daemon from the source. At end, I should now have a version of the daemon that does not automatically start the bootstrapping process.