LoginServer class is the main entry point for the authentication server, managing client connections, account validation, and GameServer registration.
Source: org.l2jmobius.loginserver.LoginServerLocation:
java/org/l2jmobius/loginserver/LoginServer.java:47
Overview
LoginServer is a singleton service that:- Accepts client connections on port 2106
- Validates account credentials against the database
- Manages GameServer registrations on port 9014
- Enforces flood protection and security policies
- Handles banned accounts and IP addresses
Class Structure
Key Constants
Login protocol revision number (258)
Logger instance for LoginServer events
Initialization Sequence
The LoginServer follows this startup sequence:Core Methods
getInstance()
shutdown()
Whether to restart after shutdown
- Stops accepting new connections
- Disconnects all active clients
- Saves server state to database
- Closes database connections
- Exits JVM (if not restarting)
addGameServerLogin()
GameServer ID (1-127)
Hexadecimal authentication key
GameServer IP address
Configuration
LoginServer is configured throughlogin/config/Server.ini:
Security Features
Flood Protection
The LoginServer implements several flood protection mechanisms:Connection Rate Limiting
Connection Rate Limiting
IP-Based Restrictions
IP-Based Restrictions
Failed Login Bans
Failed Login Bans
Automatically bans IPs after repeated failed login attemptsConfigurable thresholds in
LoginConfig.javaPassword Encryption
Client passwords are encrypted using RSA before transmission:Database Schema
LoginServer uses these tables: accountslogin- Account usernamepassword- Hashed password (SHA-256)access_level- Account privilege levellastactive- Last login timestamplastIP- Last login IP address
server_id- GameServer ID (1-127)hexid- Authentication hexadecimal keyhost- Internal server IP
Usage Example
Starting the LoginServer
Monitoring Logs
Stopping the Server
Related Classes
- GameServer - Game server that connects to LoginServer
- DatabaseFactory - Database connection management
- LoginController - Account authentication and validation
- GameServerTable - Registry of connected GameServers
- LoginClient - Represents a connected client session
Troubleshooting
Port 2106 already in use
Port 2106 already in use
Solution: Check if another service is using the portChange
LoginPort in Server.ini if neededGameServer cannot connect
GameServer cannot connect
Solution: Verify GameServer hexid and IP configuration
- Check
gameserverstable in database - Verify
GameServerLoginHostandGameServerLoginPortinServer.ini - Ensure firewall allows port 9014
Database connection failed
Database connection failed
Solution: Check Test connection:
Database.ini configurationAuto-create accounts not working
Auto-create accounts not working
Solution: Enable in Restart LoginServer for changes to take effect
Server.iniBest Practices
Production Deployment:
- Disable auto-create accounts (
AutoCreateAccounts = False) - Enable flood protection
- Use strong database passwords
- Configure firewall rules (allow 2106 for clients, 9014 for GameServers only)
- Monitor failed login attempts
- Schedule regular database backups
- Use RSA key rotation for enhanced security
Performance Monitoring
Monitor LoginServer health with these metrics:- Active connections - Track concurrent users
- Failed logins per hour - Detect brute force attacks
- Average login time - Database performance indicator
- Memory usage - JVM heap monitoring