Hello 👋 If you are interested in how this project was conceived, take a look to the ADR document.
A CLI tool for making handshakes to p2p nodes. Currently, supporting the Bitcoin network handshake.
Full example usage and output:
$ p2p-handshake -t 200 btc 192.168.1.10:8333 192.168.1.11:8333 192.168.1.12:8333 127.0.0.1:8333
⚠️ received message type not part of handshake: alert
✅ - 192.168.1.10:8333 || version 🛫 -- 34.999911ms --> version 🛬 (vers:70016 user-agent:/Satoshi:23.0.0/) -- 13.004µs --> verack 🛬 -- 121.845µs --> verack 🛫 || total time 35.13476ms.
✅ - 192.168.1.11:8333 || version 🛫 -- 112.816965ms --> version 🛬 (vers:70016 user-agent:/Satoshi:23.0.0/) -- 48.267µs --> verack 🛫 -- 15.745µs --> verack 🛬 || total time 112.880977ms.
❌ 🕐 - 192.168.1.12:8333 || version 🛫 -- 217.600713ms --> version 🛬 (vers:70016 user-agent:/Satoshi:23.0.0/) -- 239.585µs --> verack 🛫 || total time 217.840298ms.
❌ 127.0.0.1:8333: P2P error: Connection refused (os error 111)
Per each provided node, a time line of handshake messages is shown indicating the orientative time spent among handshake messages from the CLI point of view.
✅ Indicates the operation was completed.
🛬 An incoming message.
🛫 An outgoing message.
❌ The operation failed.
❌ 🕐 The operation timed out and may be incomplete.
Currently, a rust installation its needed. There are 2 options:
$ cargo run --release -- btc <ip_address:port> <ip_address:port>
$ cargo install --path .
$ p2p-handshake btc <ip_address:port> <ip_address:port>
The help with all available options can be printed out with --help
$ p2p-handshake --help
Usage: p2p-handshake [OPTIONS] <COMMAND>
Commands:
btc
help Print this message or the help of the given subcommand(s)
Options:
-t, --timeout <TIMEOUT> maximum time per handshake operation in ms [default: 500]
-h, --help Print help information
-V, --version Print version information
The code should be properly formatted and linted. This project makes use of clippy and cargo fmt for that. In order to enforce our development workflows, one could just configure the following cargo make check as a pre-commit hook:
cargo make --makefile workflow.toml code-check
A node/s from the list of nodes should be elected. After that, just run:
TEST_NODES="<ip_addr:port> <ip_addr:port>" cargo test