Simple peer-to-peer chat application built with Python using asyncio for asynchronous network communication.
- Asynchronous peer-to-peer architecture
- No central server required
- Direct messaging between peers
- Command-line interface
- Automatic peer discovery on local network
- Encrypted messages using TLS
- Python 3.7+
- pytest
- poetry
git clone url cd async-p2p-chat poetry install
- Start the chat client:
poetry run python chat.py
- Available commands:
connect <ip:port>
- Connect to a peer
disconnect <per>
- Disconnect from current peer
list
- List connected peers
send <message> <per>
- Send message to a peer
quit
- Exit application
help
- Show available commands
The application uses asyncio to handle multiple concurrent connections. Each peer acts as both server and client, allowing direct communication between nodes. Messages are encrypted using TLS to ensure security.
Key components:
- Network discovery service
- Async message handler
- Peer connection manager
- Encryption layer
. ├── chat.py # Main application file ├── peer.py # Peer connection handling ├── discovery.py # Network discovery service ├── crypto.py # Encryption utilities ├── config.py # Configuration settings ├── pyproject.toml # Poetry configuration └── poetry.lock # Poetry lock file
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.