High-performance IRC server implementation based on Spring Boot and Java 21 virtual threads.
- ✅ Java 21 Virtual Threads: Uses the latest Java 21 virtual thread technology for high concurrency
- ✅ Authentication: Complete user authentication and permission management system
- ✅ Admin Operations: Supports admin commands and REST API management
- ✅ Minimal Dependencies: Uses only Spring Boot core components, no additional external dependencies
- ✅ IRC Protocol Compatible: Supports standard IRC protocol commands
- ✅ Channel Management: Complete channel creation, joining, leaving, kicking functionality
- ✅ Real-time Messaging: Supports private messages and channel messages
- ✅ REST API: Provides complete management REST API interface
- Java 21 or higher
- Maven 3.6+
- Memory: Minimum 512MB
git clone <repository-url>
cd irc4springmvn clean package# Using startup script
./start.sh
# Or run JAR directly
java -jar target/irc-server-1.0.0.jarAfter server startup:
- IRC port:
6667 - HTTP API port:
8081 - Default admin account:
admin/admin123
Use an IRC client to connect to localhost:6667
Edit the src/main/resources/application.yml file to modify configuration:
By setting irc.auth.allow-unregistered-channels: true, you can allow unregistered users to enter and create channels. In this mode:
- Users only need to set a nickname (NICK command) to join channels
- No complete user registration (USER command) required
- No password authentication needed
- Still supports all channel features (sending messages, setting topics, etc.)
This is particularly useful for temporary chat or testing environments.
server:
port: 8081 # HTTP API port
irc:
server:
name: "IRC4Spring"
port: 6667 # IRC server port
max-connections: 1000
max-channels: 100
max-nickname-length: 30
max-channel-name-length: 50
admin:
default-username: "admin"
default-password: "admin123"
auth:
require-registration: false
session-timeout: 3600000 # 1 hour
allow-unregistered-channels: true # Allow unregistered users to enter/create channelsNICK <nickname>- Set nicknameUSER <username> <hostname> <servername> <realname>- User registrationPASS <password>- Set passwordQUIT [message]- Quit serverPING <server>- Heartbeat checkPONG <server>- Heartbeat response
JOIN <channel>[,<channel>] [key]- Join channelPART <channel>[,<channel>] [message]- Leave channelPRIVMSG <target> <message>- Send messageNOTICE <target> <message>- Send noticeTOPIC <channel> [topic]- View/set channel topicNAMES [channel]- View channel user listLIST- List all channelsKICK <channel> <user> [reason]- Kick userINVITE <user> <channel>- Invite user
WHO [target]- Query user informationWHOIS <nickname>- Query detailed user informationMODE <target> [modes]- View/set modes
OPER <username> <password>- Get operator privilegesKILL <user> [reason]- Force disconnect userWALLOPS <message>- Send message to all operators
GET /api/admin/statusGET /api/admin/users # Get all users
GET /api/admin/users/{nickname} # Get user information
POST /api/admin/users/{nickname}/kick # Kick user
POST /api/admin/users/{nickname}/role # Set user role
POST /api/admin/users # Create user account
DELETE /api/admin/users/{username} # Delete user accountGET /api/admin/channels # Get all channels
GET /api/admin/channels/{channelName} # Get channel information
DELETE /api/admin/channels/{channelName} # Delete channel
POST /api/admin/channels/{channelName}/message # Send admin messagePOST /api/admin/broadcast # Server-wide broadcast
POST /api/admin/shutdown # Shutdown server
GET /api/admin/runtime # Get runtime informationThe project fully utilizes Java 21's virtual thread features:
- Connection Handling: Each client connection uses an independent virtual thread
- Command Processing: Each IRC command is processed in an independent virtual thread
- Message Broadcasting: Asynchronous message sending uses virtual thread pools
- IrcServer: Main TCP server class, handles client connections
- IrcCommandHandler: IRC command parsing and processing
- UserService: User management service
- ChannelService: Channel management service
- AuthenticationService: Authentication and permission management
- AdminController: REST API management interface
- IrcUser: User model, contains nickname, permissions, connection info
- IrcChannel: Channel model, contains user list, topic, modes
- IrcMessage: IRC message model, supports protocol parsing
- UserRole: User role enumeration (USER, OPERATOR, ADMIN)
- High Concurrency: Supports 1000+ concurrent connections
- Low Latency: Virtual threads reduce thread switching overhead
- Memory Efficiency: Virtual threads use less memory
- Scalable: Based on Spring Boot, easy to extend
- Password Encryption: Uses SHA-256 + salt for encrypted storage
- Permission Control: Role-based permission management
- Session Management: Automatic cleanup of timeout connections
- Input Validation: Nickname and channel name format validation
src/main/java/com/irc4spring/
├── IrcServerApplication.java # Main application class
├── constant/
│ └── IrcCommand.java # IRC command constants
├── controller/
│ └── AdminController.java # REST API controller
├── handler/
│ └── IrcCommandHandler.java # IRC command handler
├── model/
│ ├── IrcChannel.java # Channel model
│ ├── IrcMessage.java # Message model
│ ├── IrcUser.java # User model
│ └── UserRole.java # User role
├── server/
│ └── IrcServer.java # TCP server
└── service/
├── AuthenticationService.java # Authentication service
├── ChannelService.java # Channel service
└── UserService.java # User service
# Compile
mvn compile
# Run tests
mvn test
# Package
mvn package
# Run
java -jar target/irc-server-1.0.0.jarNICK testuser
USER testuser 0 * :Test User
JOIN #general
PRIVMSG #general :Hello, world!
# Get server status
curl http://localhost:8081/api/admin/status
# Kick user
curl -X POST http://localhost:8081/api/admin/users/testuser/kick \
-H "Content-Type: application/json" \
-d '{"reason": "Violation"}'
# Server-wide broadcast
curl -X POST http://localhost:8081/api/admin/broadcast \
-H "Content-Type: application/json" \
-d '{"message": "Server maintenance notice"}'- Java Version Error: Ensure using Java 21 or higher
- Port Occupied: Check if ports 6667 and 8081 are in use
- Insufficient Memory: Increase JVM memory setting
-Xmx1g - Connection Timeout: Check firewall settings
Adjust log levels in application.yml:
logging:
level:
com.irc4spring: DEBUG # Detailed logs
org.springframework: INFOIssues and Pull Requests are welcome!
This project is licensed under the MIT License.
- Initial release
- Basic IRC protocol support
- User authentication and permission management
- Channel management functionality
- REST API management interface
- Java 21 virtual thread support