Merge branch 'develop' into 'master'
增加mitm 用allProxies 接口 See merge request mt-data/ipcenter!4
This commit is contained in:
commit
dae7521e26
30
switch.go
30
switch.go
|
@ -44,6 +44,7 @@ func NewSwitch() *Switch {
|
||||||
http.HandleFunc("/ippool/switch/imactive", swi.imActive)
|
http.HandleFunc("/ippool/switch/imactive", swi.imActive)
|
||||||
http.HandleFunc("/ippool/switch/update", swi.updateActives)
|
http.HandleFunc("/ippool/switch/update", swi.updateActives)
|
||||||
http.HandleFunc("/ippool/switch/actives", swi.switchActives)
|
http.HandleFunc("/ippool/switch/actives", swi.switchActives)
|
||||||
|
http.HandleFunc("/ippool/switch/allproxies", swi.allProxies)
|
||||||
|
|
||||||
return &swi
|
return &swi
|
||||||
}
|
}
|
||||||
|
@ -221,3 +222,32 @@ func (swi *Switch) switchActives(w http.ResponseWriter, req *http.Request) {
|
||||||
ErrorLog(err)
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user