mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-13 05:37:29 +08:00
nodes api: dedupe synthetic local node to avoid duplicate display
This commit is contained in:
@@ -468,7 +468,19 @@ func (s *RegistryServer) handleWebUINodes(w http.ResponseWriter, r *http.Request
|
||||
if ip := detectLocalIP(); ip != "" {
|
||||
local.Endpoint = ip
|
||||
}
|
||||
list = append([]NodeInfo{local}, list...)
|
||||
hostLower := strings.ToLower(strings.TrimSpace(host))
|
||||
hasLocal := false
|
||||
for _, n := range list {
|
||||
id := strings.ToLower(strings.TrimSpace(n.ID))
|
||||
name := strings.ToLower(strings.TrimSpace(n.Name))
|
||||
if id == "local" || name == "local" || (hostLower != "" && name == hostLower) {
|
||||
hasLocal = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !hasLocal {
|
||||
list = append([]NodeInfo{local}, list...)
|
||||
}
|
||||
_ = json.NewEncoder(w).Encode(map[string]interface{}{"ok": true, "nodes": list})
|
||||
case http.MethodPost:
|
||||
var body struct {
|
||||
|
||||
Reference in New Issue
Block a user