This project is a Linux-compatible implementation of the original Delphi-based CloudTcpServer, providing identical functionality. It serves as a drop-in replacement designed to run in Docker containers on Linux systems.
The system consists of three main components:
- Report Server - A Python-based TCP and HTTP server that handles client connections and communication
- Web Interface - A PHP 8 application (dreport) that provides a web UI for report management
- Database - A MySQL database storing reports and client information
The entire solution is containerized with Docker for easy deployment and management.
The Report Server is implemented in Python and provides the following functionality:
- TCP Server: Handles client connections using the same protocol as the original Delphi server
- HTTP Server: Provides REST API endpoints for report generation and file downloads
- Database Interface: Connects to MySQL database for storing and retrieving reports
The TCP server implements a custom protocol with the following commands:
INIT
- Initialize connection and negotiate encryption keyINFO
- Exchange client information and authenticationPING
- Keep-alive mechanismSRSP
- Handle client responses to server requestsGREQ
- Generate reports based on client parametersVERS
- Check for updates and return file listDWNL
- Download update filesERRL
- Log client-side errors
The communication is secured using a custom encryption mechanism based on a shared cryptographic key negotiated during initialization.
The HTTP server provides the following endpoints:
/
- Server status information/status
- Detailed status including client count and configuration/report
- Generate reports based on parameters/updates
- List available update files/download/{filename}
- Download update files
All endpoints except for the root require basic authentication.
The web interface is located in the dreport
directory and provides a user-friendly way to:
- View and manage reports
- Monitor client connections
- Configure server settings
- Manage update files
The database schema is defined in the dreports(8).sql
file and contains tables for:
- Reports
- Clients
- User accounts
- Configuration settings
The server is configured using the eboCloudReportServer.ini
file in the config
directory. This file contains settings for:
- TCP and HTTP interfaces and ports
- Authentication settings
- Update folder location
- Logging configuration
Environment variables can be used to override configuration settings:
DB_HOST
,DB_PORT
,DB_USER
,DB_PASSWORD
,DB_NAME
- Database connectionAUTH_SERVER_URL
- Authentication server URL
The system is deployed using Docker Compose with three services:
report_server
- The Python-based TCP/HTTP serverweb
- Apache/PHP web server for the dreport interfacedb
- MySQL database server
- Communication between clients and server is encrypted using a custom protocol
- HTTP endpoints require basic authentication
- Database credentials are managed through environment variables
- The server uses rotating logs stored in the
logs
directory - Log files are rotated when they reach 10MB, with up to 10 backup files
- Health checks are performed periodically and logged
- Old logs and update files are automatically cleaned up after 30 days
The server includes robust error handling for:
- Database connectivity issues with automatic reconnection
- Network failures and timeouts
- Malformed client requests
- File system errors
The BosTcpClient application can connect to this server exactly as it did to the original Delphi server. The protocol implementation ensures backward compatibility.
LinuxCloudReportServer/
├── config/
│ └── eboCloudReportServer.ini
├── dreport/
│ └── ... (PHP web interface)
├── server/
│ ├── __init__.py
│ ├── constants.py
│ ├── crypto.py
│ ├── db.py
│ ├── http_server.py
│ ├── server.py
│ └── tcp_server.py
├── .env
├── docker-compose.yml
├── Dockerfile.php
├── Dockerfile.server
├── main.py
├── php.ini
├── README.md
└── setup.py
To start the server, run:
docker-compose up -d
This will start all three containers and make the services available on their configured ports:
- TCP Server: Port 8016
- HTTP Server: Port 8080
- Web Interface: http://localhost:8015/dreport/
To test the server with the original BosTcpClient:
- Ensure the server is running
- Configure the client to connect to the server IP address on port 8016
- The client should connect and function normally
Common issues and solutions:
- Database connection failures: Check environment variables and network connectivity
- HTTP authentication issues: Verify credentials in eboCloudReportServer.ini
- Client connection problems: Ensure TCP port 8016 is accessible
- File permission errors: Check volume mounts in docker-compose.yml
Regular maintenance tasks:
- Check logs for errors
- Monitor disk usage
- Back up the database regularly
- Update security certificates if used
For detailed implementation information, refer to the code comments in each component file.
The project now includes a Go-based TCP server implementation that exactly matches the Windows server's TCP protocol format. This is especially important for the INIT command response format, which needs to be compatible with the Delphi client.
The Go TCP server implementation provides:
- Better format compatibility with the Windows server
- Improved performance and memory efficiency
- Lower latency for client connections
- Native handling of TCP connections without Python's overhead
The docker-compose.yml
file has been updated to include the Go TCP server. To use it:
# Start all services with the Go TCP server
docker-compose up -d
You can also build and run the Go TCP server directly:
# On Linux
chmod +x start_go_server.sh
./start_go_server.sh
# On Windows
start_go_server.bat
# Build the Go server
go build -o tcp_server go_tcp_server.go
# Run the server
./tcp_server
The Go TCP server reads the following environment variables:
TCP_HOST
: TCP interface to listen on (default: 0.0.0.0)TCP_PORT
: TCP port to listen on (default: 8016)
When using the Go TCP server, you should disable the Python TCP server to avoid port conflicts. This is automatically handled in the Docker Compose setup, but if you're running the Python server manually, set the DISABLE_TCP_SERVER
environment variable:
export DISABLE_TCP_SERVER=true
python -m main