feat(app): 添加服务端和客户端更新功能以及系统状态监控
Some checks failed
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Has been cancelled
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Has been cancelled
Build Multi-Platform Binaries / build-frontend (push) Has been cancelled

- 在App.vue中新增服务端更新模态框和相关功能
- 添加applyServerUpdate API调用和更新确认对话框
- 实现客户端版本信息显示和更新检测功能
- 添加系统状态监控包括CPU、内存和磁盘使用情况
- 新增getClientSystemStats API接口获取客户端系统统计信息
- 更新go.mod和go.sum文件添加必要的依赖包
- 优化UI界面样式和交互体验
This commit is contained in:
Flik
2026-01-22 21:32:03 +08:00
parent 7cddb7b3e7
commit 9f13b0d4e9
21 changed files with 731 additions and 232 deletions

View File

@@ -86,6 +86,7 @@ type ClientSession struct {
RemoteAddr string // 客户端 IP 地址
OS string // 客户端操作系统
Arch string // 客户端架构
Version string // 客户端版本
Session *yamux.Session
Rules []protocol.ProxyRule
Listeners map[int]net.Listener
@@ -289,11 +290,11 @@ func (s *Server) handleConnection(conn net.Conn) {
}
security.LogAuthSuccess(clientIP, clientID)
s.setupClientSession(conn, clientID, authReq.OS, authReq.Arch, rules)
s.setupClientSession(conn, clientID, authReq.OS, authReq.Arch, authReq.Version, rules)
}
// setupClientSession 建立客户端会话
func (s *Server) setupClientSession(conn net.Conn, clientID, clientOS, clientArch string, rules []protocol.ProxyRule) {
func (s *Server) setupClientSession(conn net.Conn, clientID, clientOS, clientArch, clientVersion string, rules []protocol.ProxyRule) {
session, err := yamux.Server(conn, nil)
if err != nil {
log.Printf("[Server] Yamux error: %v", err)
@@ -311,6 +312,7 @@ func (s *Server) setupClientSession(conn net.Conn, clientID, clientOS, clientArc
RemoteAddr: remoteAddr,
OS: clientOS,
Arch: clientArch,
Version: clientVersion,
Session: session,
Rules: rules,
Listeners: make(map[int]net.Listener),
@@ -571,16 +573,16 @@ func (s *Server) sendHeartbeat(cs *ClientSession) bool {
}
// GetClientStatus 获取客户端状态
func (s *Server) GetClientStatus(clientID string) (online bool, lastPing, remoteAddr, clientOS, clientArch string) {
func (s *Server) GetClientStatus(clientID string) (online bool, lastPing, remoteAddr, clientOS, clientArch, clientVersion string) {
s.mu.RLock()
defer s.mu.RUnlock()
if cs, ok := s.clients[clientID]; ok {
cs.mu.Lock()
defer cs.mu.Unlock()
return true, cs.LastPing.Format(time.RFC3339), cs.RemoteAddr, cs.OS, cs.Arch
return true, cs.LastPing.Format(time.RFC3339), cs.RemoteAddr, cs.OS, cs.Arch, cs.Version
}
return false, "", "", "", ""
return false, "", "", "", "", ""
}
// GetClientPluginStatus 获取客户端插件运行状态
@@ -633,6 +635,7 @@ func (s *Server) GetAllClientStatus() map[string]struct {
RemoteAddr string
OS string
Arch string
Version string
} {
// 先复制客户端引用,避免嵌套锁
s.mu.RLock()
@@ -648,6 +651,7 @@ func (s *Server) GetAllClientStatus() map[string]struct {
RemoteAddr string
OS string
Arch string
Version string
})
for _, cs := range clients {
@@ -658,12 +662,14 @@ func (s *Server) GetAllClientStatus() map[string]struct {
RemoteAddr string
OS string
Arch string
Version string
}{
Online: true,
LastPing: cs.LastPing.Format(time.RFC3339),
RemoteAddr: cs.RemoteAddr,
OS: cs.OS,
Arch: cs.Arch,
Version: cs.Version,
}
cs.mu.Unlock()
}
@@ -1869,3 +1875,46 @@ func (s *Server) StopClientLogStream(sessionID string) {
func boolPtr(b bool) *bool {
return &b
}
// GetClientSystemStats 获取客户端系统状态
func (s *Server) GetClientSystemStats(clientID string) (*protocol.SystemStatsResponse, error) {
s.mu.RLock()
cs, ok := s.clients[clientID]
s.mu.RUnlock()
if !ok {
return nil, fmt.Errorf("client %s not online", clientID)
}
stream, err := cs.Session.Open()
if err != nil {
return nil, err
}
defer stream.Close()
// 设置超时
stream.SetDeadline(time.Now().Add(10 * time.Second))
// 发送请求
msg, _ := protocol.NewMessage(protocol.MsgTypeSystemStatsRequest, nil)
if err := protocol.WriteMessage(stream, msg); err != nil {
return nil, err
}
// 读取响应
resp, err := protocol.ReadMessage(stream)
if err != nil {
return nil, err
}
if resp.Type != protocol.MsgTypeSystemStatsResponse {
return nil, fmt.Errorf("unexpected response type: %d", resp.Type)
}
var stats protocol.SystemStatsResponse
if err := resp.ParsePayload(&stats); err != nil {
return nil, err
}
return &stats, nil
}