远程列表web
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user