A robust HTTP server for receiving and processing Lineage 2 crash reports. This application accepts multipart/form-data POST requests containing crash dump files and error descriptions, then saves them to the local filesystem for analysis.
- Security: Input validation, path traversal protection, and file size limits
- Configurability: Command-line configuration for port and upload directory
- Thread Safety: Concurrent request handling with configurable thread pool
- Proper Logging: Comprehensive logging using Java logging framework
- Graceful Shutdown: Clean resource cleanup on application termination
- Java 8 Compatible: Uses only Java 8 features and standard library
The application is organized into several components:
L2CrashReceiver- Main entry point with command-line argument parsingCrashReportServer- HTTP server managing connections and lifecycleHttpRequestHandler- Individual request processing logicMultipartParser- Utility for parsing multipart/form-dataFileService- File operations with validation and security checksHttpResponse- HTTP response model with proper formattingServerConfiguration- Configuration management with builder pattern
# Start server on default port 80 with default upload directory 'crashes/'
java l2.tools.L2CrashReceiver
# Start server on custom host, port
java l2.tools.L2CrashReceiver 0.0.0.0 80
# Start server with custom host, port and upload directory
java l2.tools.L2CrashReceiver 0.0.0.0 8080 crashes/# Build the application
./gradlew build
# Run the application
./gradlew run
# Create a JAR file
./gradlew jarThe server accepts POST requests to any path with the following requirements:
- Method: POST
- Content-Type: multipart/form-data
- Fields:
CRVersion: Version informationerror: Error description textdumpfile: Binary dump filegamelog(optional): Game log file(l2.log)networklog(optional): Network log file(Network.log)
- 200 OK: Crash report processed successfully
- 400 Bad Request: Invalid request format or missing required fields
- 413 Payload Too Large: File size exceeds configured maximum
- 500 Internal Server Error: Server-side processing error
POST / HTTP/1.1
Content-Type: multipart/form-data; boundary=MULTIPART-DATA-BOUNDARY
--MULTIPART-DATA-BOUNDARY
Content-Disposition: form-data; name="CRVersion"
1.0.0
--MULTIPART-DATA-BOUNDARY
Content-Disposition: form-data; name="error"
Exception occurred in game engine...
--MULTIPART-DATA-BOUNDARY
Content-Disposition: form-data; name="upload_file_minidump"; filename="crash.dmp"
Content-Type: application/octet-stream
[binary dump data]
--MULTIPART-DATA-BOUNDARY--Default configuration values:
- Host: 0.0.0.0
- Port: 80
- Upload Directory:
crashes/ - Max File Size: Integer.Max
- Thread Pool Size: 10 threads
- Path Traversal Protection: Prevents files from being saved outside the upload directory
- Filename Sanitization: Removes dangerous characters from uploaded filenames
- File Size Limits: Configurable maximum file size to prevent DoS attacks
- Input Validation: Comprehensive validation of all input parameters
- Resource Management: Proper cleanup of resources to prevent memory leaks
- Crash dump files are saved with their original names (sanitized)
- Error descriptions are saved as text files with
.txtextension - Duplicate filenames are handled by appending timestamps
- All files are saved in the configured upload directory
The application uses Java's built-in logging framework with the following levels:
- INFO: Server startup, configuration, and successful operations
- WARNING: Non-fatal errors and unusual conditions
- SEVERE: Fatal errors and exceptions
- Java 8 or higher
- Write permissions to the upload directory
- Network permissions to bind to the specified host, port