This is a refactored version of the QKMJ system, originally created by sywu (吳先祐). This version is forked from 0.94 beta and has been modernized for portability, security, and maintainability.
- Modern C Standards: Refactored code to adhere to C11/C17 standards.
- UTF-8 Support: Migrated from Big-5 to UTF-8 encoding, with
ncurseswsupport. - Security:
- Replaced unsafe string functions (
strcpy,sprintf,strcat,gets) with safer alternatives (strncpy,snprintf,strncat,fgets). - Implemented constant-time string comparison for password checks to prevent timing attacks.
- Added checks for
malloc,accept, and file operations. - Replaced deprecated functions (
bzero,bcopy) with standard ones (memset,memmove).
- Replaced unsafe string functions (
- Build System: Switched to CMake for better portability and build management.
- Maintainability: Refactored large functions and applied consistent code style.
- CMake (>= 3.10)
- C Compiler (GCC or Clang)
ncurseswlibrary (for wide character support)pkg-config
mkdir build
cd build
cmake ..
makeThis will produce the following executables:
qkmj: The client application.mjgps: The server application.mjrec: The record management utility.kifu: The MongoDB match record browser.
./mjgps [port]Default port is 7001.
./qkmj [server_ip] [port]Default server is 0.0.0.0 and port 7001.
./mjrec [record_file]To browse game records stored in MongoDB:
./kifuInteractive commands:
list: Show recent matches.show <match_id>: Replay moves and show final result/score.dump <match_id> [move_serial]: Dump AI-ready JSON state for all moves or a specific move.debug on: Enable verbose diagnostics.
PORT: Server listening port (default:7001or first argument).MONGO_URI: MongoDB connection string.LOGIN_LIMIT: Maximum concurrent users (default:200).SSL_CERT_FILE: Path to SSL CA certificate (overrides auto-detection).MONGO_LOG_LEVEL: Minimum log level for MongoDB (DEBUG,INFO,WARN,ERROR,FATAL; default:INFO).
QKMJRC_PATH: Custom path to configuration file (overrides~/.qkmjrc).HOME: Used to locate the default.qkmjrcconfiguration file.AI_MODE: Enable AI features (1to enable).AI_ENDPOINT: Endpoint URL for the AI backend.AI_DEBUG: Enable verbose AI debugging logs (1to enable).
MONGO_URI: MongoDB connection string.
See COMMANDS.md for details on the client-server communication protocol.
- Original Author: sywu (吳先祐)
- Forked from: TonyQ (0.94 beta)
- Remaster/Docker: gjchen.tw@gmail.com