Run an Amino DHT boostrapper with js-libp2p
$ npm i @libp2p/amino-dht-bootstrapper
EPIC tracking issue: https://github.com/protocol/bifrost-infra/issues/2778
Find more info at https://github.com/protocol/bifrost-infra/blob/master/docs/bootstrap.md
Rust bootstrapper: https://github.com/libp2p/rust-libp2p/tree/master/misc/server
- The Peer IDs of the default bootstrap nodes are set explicitly, to assert that you only trust a specific peer at a given ip or dns entry.
- This makes it harder for attackers to spoof or otherwise MITM attack, as they would also have to compromise our infrastructure to steal the private key behind the Peer ID.
- Defaults
- The default addresses for the bootstrap nodes are set in the ipfs/go-ipfs-config configuration
$ npx --package=@libp2p/amino-dht-bootstrapper -- amino
Options:
--config <CONFIG> Path to IPFS config file (required)
--metrics-path <METRICS_PATH> Metric endpoint path [default: /metrics]
--metrics-port <PORT> Metric endpoint path [default: 8888]
--enable-kademlia Whether to run the libp2p Kademlia protocol and join the IPFS DHT
--enable-autonat Whether to run the libp2p Autonat protocol
--api-port <PORT> Port to serve the RPC API [default: 8899]
--api-host <HOST> Host to serve the RPC API on [default: 127.0.0.1]
-h, --help Print help
To make a request via CURL, you can use the following command:
# run garbage collection
$ curl http://${HOST}:${RPC_PORT}/api/v0/nodejs/gc
# execute a heapdump
$ curl http://${HOST}:${RPC_PORT}/api/v0/nodejs/heapdump
# change the log level
$ curl http://${HOST}:${RPC_PORT}/api/v0/nodejs/log?namespace=libp2p:*
Please note that the RPC API server only listens on the loopback interface (127.0.0.1) by default. If you decide to change the api-host
option, please make sure that the RPC API server is only used for development purposes and is not accessible publicly.
{
"config": {
"description": "Path to IPFS config file",
"type": "string"
},
"enable-kademlia": {
"description": "Whether to run the libp2p Kademlia protocol and join the IPFS DHT",
"type": "boolean"
},
"enable-autonat": {
"description": "Whether to run the libp2p Autonat protocol",
"type": "boolean"
},
"metrics-path": {
"description": "Metric endpoint path",
"default": "/metrics",
"type": "string"
},
"metrics-port": {
"description": "Port to serve metrics",
"default": "8888",
"type": "string"
},
"api-port": {
"description": "Port for api endpoint",
"default": "8899",
"type": "string"
},
"api-host": {
"description": "The listen address hostname for the RPC API server",
"default": "127.0.0.1",
"type": "string"
},
"help": {
"description": "Show help text",
"type": "boolean"
}
A config file will be generated for you automatically, and stored at $HOME/.config/@libp2p/amino-dht-bootstrapper/config.json
. The default config we generate looks like this:
{
"addresses": {
"announce": [],
"noAnnounce": [],
"listen": [
"/ip4/0.0.0.0/tcp/4003/ws",
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4004/ws",
"/ip6/::/tcp/4001",
"/ip4/0.0.0.0/udp/4002/webrtc"
]
},
"bootstrap": {
"list": [
"/dns4/am6.bootstrap.libp2p.io/tcp/443/wss/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
"/dns4/sg1.bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
"/dns4/sv15.bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN"
]
},
"privateKey": "generated by `auto-config.ts`",
"connectionManager": {
"inboundConnectionThreshold": 100,
"maxIncomingPendingConnections": 100,
"maxConnections": 500
}
}
Building should be straightforward from the root of the repository:
$ docker build . --tag amino
$ docker run -it amino
By default, the config file is stored at $HOME/.config/@libp2p/amino-dht-bootstrapper/config.json
. You can mount this file into the container by running:
$ docker run -v $HOME/.config/@libp2p/amino-dht-bootstrapper/:/root/.config/@libp2p/amino-dht-bootstrapper/ -it amino
To pass args:
$ docker run -it amino [--enable-kademlia] [--enable-autonat]
To expose the metrics port:
$ docker run -p 8888:8888 -it amino
$ docker compose --profile dashboard up -d
Licensed under either of
- Apache 2.0, (LICENSE-APACHE / http://www.apache.org/licenses/LICENSE-2.0)
- MIT (LICENSE-MIT / http://opensource.org/licenses/MIT)
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.