A modern peer-to-peer chat application built with C++23, featuring end-to-end encryption, colored terminal output, and vi-like CLI interaction.
- Decentralized P2P Architecture: Direct peer-to-peer connections without central servers
- Cryptographic Security: ECDSA key pairs, digital signatures, and encryption via OpenSSL
- Modern C++23: Leverages latest language features for clean, efficient code
- Colored Terminal UI: Beautiful colored output with lambda (λ) prompt
- Vi-like Interface: Replxx library provides vi keybindings and command history
- Comprehensive Testing: 55 unit tests covering all major components
- Thread-Safe Operations: Concurrent peer management and network operations
- Persistent State: Save and restore peer lists between sessions
- C++23 compatible compiler (GCC 13+, Clang 16+, or MSVC 2022+)
- CMake 3.20 or higher
- Boost 1.75+ (system, thread, filesystem, chrono, program_options)
- OpenSSL development libraries
- Internet connection (for automatic dependency fetching)
CppP2PChat/
├── Include/ # Header files
├── Source/ # Implementation files
├── Tests/ # Unit tests
├── external/ # Third-party headers (rang.hpp)
├── build/ # Build output directory
├── CMakeLists.txt # Build configuration
├── b # Quick build script
└── r # Run script with tmux
./b # Uses the included build scriptmkdir -p build
cd build
cmake ..
make -j$(nproc)cmake -DBUILD_TESTS=OFF .. # Build without tests
cmake -DCMAKE_BUILD_TYPE=Debug .. # Debug buildAll executables are output to build/Bin/ directory.
Run all 55 unit tests:
cd build
ctest --verboseRun specific test suite:
./Bin/TestCrypto # Cryptography tests
./Bin/TestMessage # Message protocol tests
./Bin/TestPeerManager # Peer management tests
./Bin/TestNetwork # Network layer tests
./Bin/TestCliInterface # CLI interface tests./build/Bin/p2pchat./build/Bin/p2pchat --port 8081 --connect localhost:8080 --peers-file mypeers.txtRun two peers in a tmux session:
./r # Starts two peers that auto-connectconnect <address> <port>- Connect to a peerdisconnect <peer_id>- Disconnect from a peerlist- Show all peers and connection status
send <peer_id> <message>- Send to specific peerbroadcast <message>- Send to all connected peers
info- Display local peer informationhelp- Show all available commandsquitorexit- Exit the application
ESC- Enter normal modeh,j,k,l- Vi movement keysi- Return to insert modeCtrl+W- Delete wordCtrl+U- Delete to beginning of line
- CryptoManager - Handles ECDSA key pairs, signatures, and encryption
- NetworkManager - Manages TCP connections with Boost.Asio
- PeerManager - Thread-safe peer tracking and persistence
- Message - Protocol implementation with serialization
- CLIInterface - Colored terminal UI with vi-like input
[Type:1][PayloadSize:4][Timestamp:8][Payload:N]
Supported message types:
- TEXT (0x01) - Chat messages
- HANDSHAKE (0x02) - Peer introduction
- PEER_LIST (0x03) - Share known peers
- PING (0x04) - Keepalive
- PONG (0x05) - Keepalive response
- Key Generation: Each peer generates ECDSA keypair on startup
- Peer Identity: IDs derived from public key SHA-256 hash
- Message Signing: All messages can be digitally signed
- Encryption: Point-to-point encryption using ECDH shared secrets
- No Central Authority: Fully decentralized trust model
External dependencies (auto-fetched):
- Google Test - Unit testing framework
- Replxx - Vi-like CLI library
- rang - Terminal color library
System dependencies:
- Boost libraries
- OpenSSL
- pthreads
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Add tests for new functionality
- Ensure all tests pass (
ctest) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Boost.Asio for excellent async networking
- OpenSSL for cryptographic primitives
- Google Test for testing framework
- Replxx for vi-like CLI experience
- rang for beautiful terminal colors