fix: ensureDaemon 自动检测并重启过期守护进程
问题: 重新构建后 IPv6 等新功能不生效,客户端仍运行旧代码。 根因: ensureDaemon() 通过 IPC socket 拨号时,若旧 daemon 进程仍在 运行(重建后未退出),GUI 会直接复用旧进程,永不启动新二进制。 日志证实旧 daemon 处理连接(init 日志无 ip6 字段),新代码从未执行。 解决方案: 新增版本握手协议,GUI 启动时查询 daemon 构建版本, 版本不匹配则自动关闭旧进程并启动新的。 - 新建 internal/version 包,GUI 与 daemon 共享同一 Version 变量, 均通过 Makefile ldflags 注入 - IPC 新增 CmdVersion 命令,daemon 返回 version.Version; Response 增加 Version 字段,Client 新增 QueryVersion() 方法 - ensureDaemon() 拨号后查询版本,不匹配则发 CmdShutdown、等待 socket 释放、重新启动 daemon;旧 daemon 不识别 CmdVersion 时 返回错误,同样触发重启 - Makefile LDFLAGS 改为注入 lmvpn/internal/version.Version
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
// Package version holds the build version string shared by the GUI
|
||||
// (lmvpn) and daemon (lmvpnd) binaries. The value is injected at link
|
||||
// time via ldflags:
|
||||
//
|
||||
// -X lmvpn/internal/version.Version=$(VERSION)
|
||||
//
|
||||
// Both binaries are built with the same LDFLAGS, so a version mismatch
|
||||
// between the running daemon and the GUI indicates a stale daemon
|
||||
// process that predates the current build.
|
||||
package version
|
||||
|
||||
// Version is the application version. Overridden at link time; "dev"
|
||||
// when running an untagged build (e.g. go run / go build without
|
||||
// ldflags).
|
||||
var Version = "dev"
|
||||
Reference in New Issue
Block a user