增加真机mitm用allProxies接口

This commit is contained in:
chiufung 2019-03-14 14:46:44 +08:00
parent b52adf23f3
commit 5882bab2f3

View File

@ -44,6 +44,7 @@ func NewSwitch() *Switch {
http.HandleFunc("/ippool/switch/imactive", swi.imActive)
http.HandleFunc("/ippool/switch/update", swi.updateActives)
http.HandleFunc("/ippool/switch/actives", swi.switchActives)
http.HandleFunc("/ippool/switch/allproxies", swi.allProxies)
return &swi
}
@ -221,3 +222,32 @@ func (swi *Switch) switchActives(w http.ResponseWriter, req *http.Request) {
ErrorLog(err)
}
func (swi *Switch) allProxies(w http.ResponseWriter, req *http.Request) {
defer req.Body.Close()
swi.Worker.Mutex.Lock()
defer swi.Worker.Mutex.Unlock()
now := time.Now().Unix()
content := make(map[string]map[string]interface{})
for addr, group := range swi.Worker.ForLoop {
addrmap := make(map[string]interface{})
content[addr] = addrmap
isappend := int64(0)
var hosts []string
for _, dhost := range group.Group {
hosts = append(hosts, dhost.Host)
}
addrmap["group"] = hosts
addrmap["city"] = group.City
}
jdata, err := json.Marshal(content)
ErrorLog(err)
_, err = w.Write(jdata)
ErrorLog(err)
}