1
Some checks failed
Build Multi-Platform Binaries / build (push) Has been cancelled

This commit is contained in:
Flik
2025-12-26 23:12:10 +08:00
parent 4a5603e5b7
commit 622f30b381

View File

@@ -144,11 +144,15 @@ func (s *Server) handleConnection(conn net.Conn) {
return
}
// 如果客户端没有提供 ID则生成一个新的
// 处理客户端 ID
clientID := authReq.ClientID
if clientID == "" {
clientID = generateClientID()
// 创建新客户端记录
}
// 检查客户端是否存在,不存在则自动创建
exists, err := s.clientStore.ClientExists(clientID)
if err != nil || !exists {
newClient := &db.Client{ID: clientID, Rules: []protocol.ProxyRule{}}
if err := s.clientStore.CreateClient(newClient); err != nil {
log.Printf("[Server] Create client error: %v", err)
@@ -158,13 +162,6 @@ func (s *Server) handleConnection(conn net.Conn) {
log.Printf("[Server] New client registered: %s", clientID)
}
// 检查客户端是否存在
exists, err := s.clientStore.ClientExists(clientID)
if err != nil || !exists {
s.sendAuthResponse(conn, false, "client not found", "")
return
}
rules, _ := s.clientStore.GetClientRules(clientID)
if rules == nil {
rules = []protocol.ProxyRule{}