- 项目原仓库(C++ 基线):https://github.com/Qsgs-Fans/freekill-asio
- 本仓库:上述项目的 Sengoo 重写版本
- Sengoo 语言仓库:https://github.com/Hyper66666/Sengoo
当前仓库公开历史仅保留核心实现代码与必要脚本。 文档资产、OpenSpec 资产与测试资产不在当前发布历史中。
当前默认生产路径是 native 常驻服务(不依赖 Python 托管进程)。
已落地能力:
- Sengoo native 入口与常驻事件循环(TCP/UDP 默认端口 9527/9528)
- native 构建、健康检查、验收、soak、release gate
- Windows 计划任务 / Linux systemd 安装脚本
- 包管理兼容命令:
install/remove/pkgs/syncpkgs/enable/disable/upgrade - 包兼容预检:
packages/init.sql+packages/freekill-core/lua/server/rpc/entry.lua - Lua 扩展生命周期链路:
discover/load/call/hot_reload/unload - 原生 Protobuf/RPC 回归(PowerShell,无 Python)
- 登录鉴权增强:用户库校验(支持明文与
SHA256+salt)、同名重复登录踢线、白名单/黑词用户名策略、过期封禁自动解封回写 - 扩展实测矩阵(逐扩展 install/enable/run/hot_reload/unload/upgrade)
- ABI/Hook 清单、映射与校验脚本(可接 release gate enforce)
- legacy Python runtime 链路脚本已移除,仓库默认仅维护 native 运行链
src/:Sengoo 实现代码scripts/:构建、运行、验收、发布、包管理与兼容校验脚本scripts/fixtures/:回归/矩阵用例数据packages/:包目录(含init.sql、packages.registry.json、freekill-core结构)release/:本地构建产物
sgc(Sengoo 编译器)clang(native 链接)git(包安装/升级)
说明:
- native 主路径默认不依赖 Python。
scripts/build_native_release.ps1会优先使用仓库内runtime/runtime.c(包含实时print刷新修复)。- 如果
sgc不能自动定位 runtime C 文件,可设置:
$env:SENGOO_RUNTIME = "绝对路径\\runtime.c"- 构建 native 产物。
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/build_native_release.ps1- 初始化包目录。
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/package_manager_native.ps1 -Command init- 安装核心包(请替换为真实仓库)。
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/package_manager_native.ps1 -Command install -Url https://github.com/<org>/freekill-core.git- 包兼容预检。
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/check_package_compatibility_native.ps1- 后台启动 native 服务。
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/start_runtime_host_native.ps1 -Detached前台直接看实时输出(不静默):
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/start_runtime_host_native.ps1前台日志为文本格式(接近原服风格):
[YYYY-MM-DD HH:MM:SS][INFO][SERVER] server is starting[YYYY-MM-DD HH:MM:SS][INFO][NET] server is ready to listen on [0.0.0.0]:9527[YYYY-MM-DD HH:MM:SS][INFO][NET] udp is ready to listen on [0.0.0.0]:9528[YYYY-MM-DD HH:MM:SS][INFO][NET] client <ip>:<port> connected ...[YYYY-MM-DD HH:MM:SS][INFO][NET] client disconnected ...
客户端首次 TCP 连接后,服务端会主动下发扩展同步首包:
{"event":"extension_sync","registry":[{"name":"freekill-core","enabled":true,"builtin":true}]}说明:
- 通过
scripts/start_runtime_host_native.ps1启动时,会自动扫描扩展并生成同步注册表(默认输出.tmp/runtime_host/extension_sync.registry.json)。 - 扫描根目录包含
packages/与packages/packages/,并优先使用packages/packages/(兼容你现在的嵌套扩展布局与原仓库扩展组织方式)。 - 发现规则(按优先级):
lua/server/rpc/entry.lua->init.lua->lua/init.lua,任一存在即纳入同步列表。 - 这允许直接同步多数原仓库包结构(如
standard、maneuvering、standard_cards这类init.lua包)。 - 自动将生成的注册表路径注入
SENGOO_EXTENSION_REGISTRY环境变量给 native runtime。 - 如果不走启动脚本而是直接运行 exe,默认读取
packages/packages.registry.json。 - 自动去除 UTF-8 BOM,避免客户端解析异常。
- 当注册表为空/缺失时,若存在
packages/freekill-core/lua/server/rpc/entry.lua,会回退同步freekill-core基线扩展信息。 - native runtime 会按注册表尝试执行扩展引导钩子(优先调用
on_server_start,其次bootstrap/init),用于把原生 Lua 扩展接入服务启动链。 - 对
entry.lua类型入口会以loadfile(..., bootstrap-arg)方式加载,避免触发if not ... then mainLoop()造成启动阻塞。 - runtime 常驻期间会按
SENGOO_EXTENSION_REFRESH_MS(默认3000ms)周期刷新扩展注册表并触发热更同步(不依赖新客户端连接)。 - 服务停机时会对已加载扩展尝试触发
on_server_stop钩子(若扩展未定义该函数则跳过)。 - 可通过环境变量
SENGOO_EXTENSION_BOOTSTRAP=0关闭该行为;Lua 解释器路径可用SENGOO_LUA_EXE指定(默认lua5.4)。 - 如需兼容原客户端 RSA 密码包,可启用
SENGOO_AUTH_RSA_DECRYPT_ENABLE=1,并配置:SENGOO_AUTH_OPENSSL_EXE(默认openssl)SENGOO_AUTH_RSA_PRIVATE_KEY_PATH(默认server/rsa)
默认会写入日志文件(可直接排障):
- 事件日志:
.tmp/runtime_host/native_runtime.events.log - 标准输出:
.tmp/runtime_host/native_runtime.stdout.log - 错误输出:
.tmp/runtime_host/native_runtime.stderr.log
查看日志:
Get-Content .tmp/runtime_host/native_runtime.events.log -Tail 50
Get-Content .tmp/runtime_host/native_runtime.stderr.log -Tail 50- 健康检查。
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/healthcheck_runtime_host_native.ps1- 停止服务进程。
Get-Process -Name "freekill-asio-sengoo-runtime" -ErrorAction SilentlyContinue | Stop-Process -Force- Native 验收:
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/runtime_host_acceptance_native.ps1- 包管理 smoke:
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/package_manager_smoke_native.ps1- Lua 生命周期 smoke:
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/lua_extension_lifecycle_smoke_native.ps1- Protobuf/RPC 原生回归:
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/run_protobuf_rpc_regression_native.ps1 -StartRuntime- 鉴权用户库 smoke(含同名踢线、用户名白名单/黑词):
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/auth_userdb_smoke_native.ps1- 扩展实测矩阵:
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/run_extension_matrix_native.ps1真实仓库模式(推荐):
- 编辑
scripts/fixtures/extension_matrix_targets.json,填入真实扩展仓库name/url。 - 然后执行:
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/run_extension_matrix_native.ps1 -TargetsPath scripts/fixtures/extension_matrix_targets.json离线本地夹具模式:
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/run_extension_matrix_native.ps1 -UseLocalFixture- ABI/Hook 校验(默认只出报告;加
-Enforce才会阻断):
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/validate_extension_abi_hook_compatibility.ps1
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/validate_extension_abi_hook_compatibility.ps1 -Enforce- 契约覆盖率报告(发布历史不含
docs/时使用scripts/fixtures默认映射):
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/contract_coverage_report.ps1- Native soak:
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/runtime_host_soak_native.ps1 -DurationSeconds 60- Release gate:
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/runtime_host_release_gate.ps1 -SoakDurationSeconds 60指定真实扩展矩阵目标清单:
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/runtime_host_release_gate.ps1 -SoakDurationSeconds 60 -ExtensionMatrixTargetsPath scripts/fixtures/extension_matrix_targets.json- 最终替换门禁(启用 ABI/Hook enforce):
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/runtime_host_replacement_gate_native.ps1 -SoakDurationSeconds 60runtime_host_release_gate.ps1(native 模式)当前覆盖:
- native acceptance
- package compatibility
- ABI/Hook compatibility(支持
-EnforceAbiHookCompatibility) - Lua lifecycle smoke
- Protobuf/RPC regression
- extension matrix
- dependency audit
- native soak
默认输出目录:release/native/windows-x64/
关键产物:
bin/freekill-asio-sengoo-runtime.execonfig/runtime_host.config.jsonscripts/start_runtime_host.ps1scripts/healthcheck_runtime_host.ps1scripts/install_runtime_host_service.ps1scripts/uninstall_runtime_host_service.ps1scripts/package_manager.ps1scripts/check_package_compatibility.ps1scripts/package_manager_smoke.ps1scripts/lua_extension_lifecycle.ps1scripts/lua_extension_lifecycle_smoke.ps1scripts/run_protobuf_rpc_regression.ps1scripts/run_extension_matrix.ps1scripts/runtime_host_replacement_gate.ps1scripts/build_extension_abi_hook_inventory.ps1scripts/build_extension_abi_hook_compat_map.ps1scripts/validate_extension_abi_hook_compatibility.ps1scripts/fixtures/protobuf_rpc_regression_cases.jsonscripts/fixtures/extension_matrix_targets.jsonscripts/fixtures/extension_matrix_targets.example.jsonpackages/init.sqlpackages/packages.registry.jsonmanifest.jsonchecksums.sha256
- Windows(计划任务):
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/install_runtime_host_windows_task_native.ps1 -StartNow -Force- Linux(systemd):
sudo bash scripts/install_runtime_host_systemd_native.sh- 现阶段已经具备 native 可执行发布与无 Python 主链路运行能力。
- “可替换原服”的最终门禁仍应以:ABI/Hook、Lua 生命周期、Protobuf/RPC、扩展矩阵、性能稳定性全部达标为准。
packages/freekill-core/lua/server/rpc/entry.lua在仓库内是结构占位,生产环境应替换为真实核心包内容。