远程列表web

This commit is contained in:
Alex Yang
2025-11-24 00:00:47 +08:00
parent fcd4fc9e68
commit f499a4a84a
7 changed files with 328 additions and 21 deletions

View File

@@ -304,12 +304,21 @@ func (s *Server) handleShieldHosts(w http.ResponseWriter, r *http.Request) {
case http.MethodGet:
// 获取hosts条目列表
// 注意这需要在shieldManager中添加一个获取所有hosts条目的方法
// 暂时返回统计信息
stats := s.shieldManager.GetStats()
hosts := s.shieldManager.GetAllHosts()
hostsCount := s.shieldManager.GetHostsCount()
// 转换为数组格式,便于前端展示
hostsList := make([]map[string]string, 0, len(hosts))
for domain, ip := range hosts {
hostsList = append(hostsList, map[string]string{
"domain": domain,
"ip": ip,
})
}
json.NewEncoder(w).Encode(map[string]interface{}{
"hostsCount": stats["hostsRules"],
"message": "获取hosts列表功能待实现",
"hosts": hostsList,
"hostsCount": hostsCount,
})
default: