Skip to main content

Terminal-based LAN chat client with rooms, private messaging, and CTF flag detection

Project description

Drevoid LAN Chat Application

A robust terminal-based LAN chat application built with Python sockets, featuring room management, private messaging, CTF flag detection, and an interactive command shell.

๐Ÿš€ Features

Core Features

  • Multi-user support - Handle multiple concurrent users
  • Room management - Create and join public/private rooms
  • Private messaging - Send direct messages to specific users
  • Interactive shell - Command-based interface using Python's cmd module
  • Real-time messaging - Instant message delivery
  • User authentication - Username-based connection system
  • CTF flag detection - Automatic detection and tracking of CTF flags
  • Emoji support - Use emoji aliases in messages (e.g., :heart:, :fire:)
  • Cross-platform notifications - Desktop notifications for important events

Advanced Features

  • Public & Private Rooms - Create password-protected private rooms
  • Room moderation - Kick and ban users (for moderators)
  • Message history - Room event tracking
  • User roles - Admin, Moderator, and User roles
  • Connection management - Robust connection handling
  • Colorized interface - ANSI color codes for better UX
  • Server admin console - Administrative server management
  • Thread-safe operations - Safe concurrent access to shared resources

๐Ÿ“ Project Structure

drevoid_client/
โ”œโ”€โ”€ drevoid/
โ”‚   โ”œโ”€โ”€ __init__.py              # Package initialization
โ”‚   โ”œโ”€โ”€ core/                    # Core protocol and utilities
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ””โ”€โ”€ protocol.py         # Message protocol, serialization, colors
โ”‚   โ”œโ”€โ”€ client/                  # Client-side modules
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ chat_client.py      # Main client logic
โ”‚   โ”‚   โ”œโ”€โ”€ connection.py       # Connection management
โ”‚   โ”‚   โ”œโ”€โ”€ flag_detector.py    # CTF flag detection
โ”‚   โ”‚   โ”œโ”€โ”€ message_handler.py  # Message processing
โ”‚   โ”‚   โ”œโ”€โ”€ room_manager.py     # Room operations
โ”‚   โ”‚   โ””โ”€โ”€ shell.py            # Interactive shell interface
โ”‚   โ”œโ”€โ”€ server/                  # Server-side modules
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ””โ”€โ”€ chat_server.py      # Main server implementation
โ”‚   โ””โ”€โ”€ utils/                   # Utility modules
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ”œโ”€โ”€ emojis.py           # Emoji alias system
โ”‚       โ””โ”€โ”€ notifications.py    # Cross-platform notifications
โ”œโ”€โ”€ tests/                       # Test files
โ”œโ”€โ”€ scripts/                     # Utility scripts
โ”œโ”€โ”€ docs/                        # Documentation
โ”œโ”€โ”€ start_client.py             # Client entry point
โ”œโ”€โ”€ start_server.py             # Server entry point
โ”œโ”€โ”€ install.py                  # Installation script
โ”œโ”€โ”€ requirements.txt            # Python dependencies
โ”œโ”€โ”€ README.md                   # This file
โ””โ”€โ”€ LICENSE                     # License file

๐Ÿƒโ€โ™‚๏ธ Quick Start

Installation

  1. Clone the repository:
git clone <repository-url>
cd drevoid_client
  1. Install dependencies (optional, uses only standard library):
pip install -r requirements.txt
  1. Install the drevoid command globally (optional):
python install.py

Running the Server

python start_server.py

# Or with custom host/port
python start_server.py --host 0.0.0.0 --port 8891

Running the Client

python start_client.py

# Or with auto-connect
python start_client.py localhost 8891 myusername

3. Basic Usage

# Connect to server
> connect localhost 12345 myusername

# Join the general room
> join general

# Send a message
> Hello everyone!

# Create a private room
> create myroom private mypassword

# Send private message
> msg username Hey there!

# List available commands
> help

๐ŸŽฏ Commands Reference

Connection Commands

  • connect [host] [port] [username] - Connect to server
  • disconnect - Disconnect from server
  • quit/exit - Exit the application

Room Management

  • join <room_name> [password] - Join a room
  • leave - Leave current room
  • create <room_name> [private] [password] - Create a room
  • rooms - List available rooms
  • users - List users in current room

Messaging

  • <message> - Send message to current room
  • msg <username> <message> - Send private message
  • pm <username> <message> - Send private message (alias)

Moderation (Moderators only)

  • kick <username> - Kick user from room
  • ban <username> - Ban user from room

Utility

  • status - Show connection status
  • clear - Clear screen
  • help - Show all commands

๐Ÿ–ฅ๏ธ Server Commands

While the server is running, you can use these commands:

  • help - Show server commands
  • stats - Show server statistics
  • users - List connected users
  • rooms - List active rooms
  • shutdown - Shutdown server

๐Ÿ› ๏ธ Technical Details

Architecture

  • Server: Multi-threaded server handling concurrent connections
  • Client: Event-driven client with separate threads for sending/receiving
  • Protocol: JSON-based message protocol with length prefixing
  • Threading: Thread-safe data structures and proper synchronization

Message Types

  • CONNECT/DISCONNECT - Connection management
  • MESSAGE - Room messages
  • PRIVATE_MESSAGE - Direct messages
  • JOIN_ROOM/LEAVE_ROOM - Room management
  • CREATE_ROOM - Room creation
  • LIST_ROOMS/LIST_USERS - Information queries
  • KICK_USER/BAN_USER - Moderation actions
  • NOTIFICATION - System notifications
  • SUCCESS/ERROR - Response messages

Security Features

  • Password hashing for room protection
  • User role management
  • Ban/kick functionality
  • Input validation and sanitization

๐ŸŽจ Customization

Adding New Commands

  1. Add new message type to common/protocol.py
  2. Implement handler in server/server.py
  3. Add command method to client shell in client/client.py

Extending Room Features

  • Modify the Room class in server/server.py
  • Add new room properties and methods
  • Update client commands as needed

๐Ÿšง System Requirements

  • Python 3.6+
  • No external dependencies (uses only standard library)
  • Terminal with ANSI color support (optional, for colors)

๐Ÿ“ License

This project is open source and available under the MIT License.

๐Ÿค Contributing

Feel free to fork this project and submit pull requests for improvements!

๐Ÿ› Troubleshooting

Common Issues

Connection refused

  • Check if server is running
  • Verify host and port settings
  • Check firewall settings

Messages not appearing

  • Ensure you're connected and in a room
  • Check network connectivity
  • Restart client if needed

Permission denied errors

  • Check user roles and permissions
  • Ensure you're a moderator for kick/ban commands

Debug Mode

Add debug prints in the code to trace message flow and connection issues.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drevoid-1.0.2.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drevoid-1.0.2-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file drevoid-1.0.2.tar.gz.

File metadata

  • Download URL: drevoid-1.0.2.tar.gz
  • Upload date:
  • Size: 26.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for drevoid-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c43f94901ecdd6b3b26944b879c7f4f7a50600ca09553148e86f23b0ad4a5d1a
MD5 e5b93b5aa5676c2281cab6b9443d22da
BLAKE2b-256 affb3609f92bb38971c842c4ccc94c69950d3bae5a44c43a5d354aaaf1a16dae

See more details on using hashes here.

File details

Details for the file drevoid-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: drevoid-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 26.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for drevoid-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 77baa7d4301f24747cdd93337bcabbb87468170c657c685e6c5d12eea11690b0
MD5 03324972d3d224fba2c9713718d778b4
BLAKE2b-256 adacb914583e1771dbf6735d8d7d40ce24d9c58fa4a2093c190f26b5ded52b7d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page