A simple peer-to-peer chat application built using Rust and libp2p. This application allows users to discover peers on the local network via mDNS and exchange messages through the GossipSub protocol.
- Automatic peer discovery using mDNS
- Message broadcasting via GossipSub protocol
- Support for both TCP and QUIC transport protocols
- Terminal-based interface for sending and receiving messages
- Rust and Cargo installed
- Network connection with mDNS capability
- libp2p: Core P2P networking framework
- tokio: Asynchronous runtime
- futures: Asynchronous programming utilities
- tracing-subscriber: Logging and diagnostics
- Clone the repository and navigate to the project directory:
git clone https://github.com/Cyberking99/libp2p-chat.git cd libp2p-chat
- Build the application:
cargo build
- Run the application:
cargo run
- The application will start listening on available network interfaces
- Type messages in the terminal and press Enter to broadcast them to all connected peers
- Messages from other peers will be displayed in your terminal automatically
- The application creates a libp2p swarm with GossipSub and mDNS behaviors
- It automatically discovers other peers running the same application on the local network
- When a peer is discovered, it's added to the GossipSub mesh
- Messages typed into STDIN are published to all connected peers via GossipSub
- Incoming messages from other peers are displayed in the terminal
- The application listens on TCP and QUIC protocols
- Default topic channel is "test-net"
- Messages are identified by their content hash