A high-performance, RFC 2812-compliant IRC server written in C++98 with advanced security features and non-blocking I/O.
viberc is a fully-featured Internet Relay Chat (IRC) server implementation built from scratch as part of the 42 School curriculum. The server handles multiple concurrent client connections using efficient poll-based I/O multiplexing, implements the complete IRC protocol specification, and includes comprehensive security measures such as rate limiting and input validation.
This project demonstrates expertise in network programming, concurrent connection handling, and protocol implementation. The architecture follows a single-threaded, event-driven model that efficiently manages hundreds of simultaneous connections without the complexity of multi-threading.
- RFC 2812 Protocol Compliance: Full implementation of the IRC protocol specification with proper numeric reply codes
- Non-blocking I/O: Event-driven architecture using
poll()for efficient handling of 100+ concurrent connections - 26 IRC Commands: Complete command set including registration, messaging, channel operations, and user management
- Advanced Security: Rate limiting, flood protection, input sanitization, and ban mask pattern matching
- Channel Modes: Support for
+i(invite-only),+t(topic restriction),+k(channel key),+l(user limit),+o(operator),+b(ban) - RAII Resource Management: Automatic cleanup of sockets and memory with modern C++ patterns in C++98
- Comprehensive Logging: Configurable logging levels with color-coded output and file rotation support
- Client Compatibility: Tested with irssi, WeeChat, LimeChat, and nc/netcat
- Networking: Non-blocking socket I/O with poll-based multiplexing, buffered partial send/receive handling
- Protocol Implementation: Strict RFC 2812 message parsing with proper prefix, command, and parameter extraction
- Security: Multi-layer protection including message rate limiting, command throttling, join flood prevention, and wildcard ban pattern matching
- Performance: Optimized ban pattern compilation, efficient client lookup using STL containers, minimal memory footprint
┌─────────────────────────────────────────────────────────────────┐
│ IRC Clients │
│ (irssi, WeeChat, LimeChat, etc.) │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Socket Layer (poll()) │
│ Non-blocking I/O multiplexing for all clients │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Message Processing │
│ Buffer management → Message parsing → Command dispatch │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Command Handlers │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
│ │Essential │ │ Channel │ │ Operator │ │ Advanced │ │
│ │NICK,USER │ │JOIN,PART │ │KICK,MODE │ │ AWAY,WHOIS │ │
│ │PASS,QUIT │ │PRIVMSG │ │TOPIC,BAN │ │ WHO,LIST │ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Data Management │
│ ┌────────────────┐ ┌────────────────┐ ┌────────────────┐ │
│ │ Clients │ │ Channels │ │ Security │ │
│ │ State, Buffers │ │ Members, Modes │ │ Rate Limiting │ │
│ └────────────────┘ └────────────────┘ └────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
| Command | Description |
|---|---|
CAP |
Capability negotiation for modern IRC clients |
PASS |
Server password authentication |
NICK |
Set or change nickname |
USER |
Complete user registration |
QUIT |
Disconnect from server |
| Command | Description |
|---|---|
PRIVMSG |
Send private messages to users or channels |
NOTICE |
Send notices (no automatic replies) |
| Command | Description |
|---|---|
JOIN |
Join one or more channels |
PART |
Leave one or more channels |
TOPIC |
View or set channel topic |
NAMES |
List users in channel |
LIST |
List available channels |
MODE |
Set channel or user modes |
KICK |
Remove user from channel |
INVITE |
Invite user to channel |
| Command | Description |
|---|---|
WHO |
Query user information |
WHOIS |
Detailed user information |
ISON |
Check if users are online |
USERHOST |
Get user host information |
| Command | Description |
|---|---|
PING |
Connection keepalive request |
PONG |
Connection keepalive response |
AWAY |
Set away status and message |
MOTD |
Display message of the day |
TIME |
Server time query |
VERSION |
Server version information |
HELP |
Command help |
- Operating System: Linux, macOS
- Compiler: GCC 9+ or Clang 12+ with C++98 support
- Build Tools: GNU Make
- clang-tidy (static analysis)
- clang-format (code formatting)
- cppcheck (additional static analysis)
- Valgrind (memory debugging)
git clone https://github.com/TheValiant/viberc.git
cd viberc
makemake # Standard build
make debug # Debug build with AddressSanitizer and UBSan
make release # Optimized release build
make tidy-build # Build with integrated clang-tidy checks./ircserv <port> <password> [options]Arguments:
port: TCP port to listen on (1024-65535)password: Server connection password
Options:
--verbose: Enable verbose logging--max-clients=N: Set maximum client limit (default: 100)--no-rate-limit: Disable rate limiting (for testing)--no-security: Disable security checks (for testing)--allow-weak-passwords: Skip password strength validation
# Start server on port 6667 with password "mypassword"
./ircserv 6667 mypassword
# Start with verbose logging and higher client limit
./ircserv 6667 mypassword --verbose --max-clients=200
# Connect with irssi
irssi -c localhost -p 6667 -w mypassword
# Connect with netcat (for testing)
nc localhost 6667
PASS mypassword
NICK testuser
USER testuser 0 * :Test UserThe project includes comprehensive test scripts:
# Quick functionality test
./quick_comprehensive_test.sh
# Run with Valgrind for memory leak detection
valgrind --leak-check=full --show-leak-kinds=all ./ircserv 6667 passwordmake tidy # Run clang-tidy analysis
make cppcheck # Run cppcheck analysis
make analyze-all # Run all static analyzers
make format # Format code with clang-formatTested and compatible with:
- irssi - Terminal-based IRC client
- WeeChat - Extensible chat client
- LimeChat - macOS IRC client
- HexChat - Cross-platform graphical client
- netcat - For protocol-level testing
- Rate Limiting: Configurable message and command rate limits
- Flood Protection: Prevention of join flooding and message spam
- Input Validation: Strict parameter validation for all commands
- Buffer Overflow Protection: Size limits on all input buffers
- Ban Pattern Matching: Wildcard support for host-based banning
- Password Security: Optional weak password rejection
This project provided deep experience in:
- POSIX socket programming and network I/O
- Event-driven architecture design with poll/select
- Protocol implementation from RFC specifications
- Security-conscious systems programming
- Memory management in constrained C++98 environment
- Static analysis and code quality tooling
- 42 School for the project specifications and learning environment
- RFC 2812 authors for the IRC protocol specification
- The irssi and WeeChat projects for reference implementations
This project is available under the MIT License. See LICENSE for details.
Note: This project was completed as part of the 42 School curriculum, which emphasizes peer-to-peer learning and project-based education in software engineering.