diff --git a/cmd/maincmd/main.go b/cmd/maincmd/main.go index ebe53a0..6e0505f 100644 --- a/cmd/maincmd/main.go +++ b/cmd/maincmd/main.go @@ -17,7 +17,7 @@ import ( ) const defaultHost = "0.0.0.0" -const defaultPort = 8080 +const defaultPort = 8088 var ( host string diff --git a/httpbin/handlers.go b/httpbin/handlers.go index e528464..cc5e58e 100644 --- a/httpbin/handlers.go +++ b/httpbin/handlers.go @@ -137,6 +137,16 @@ func (h *HTTPBin) IP10(w http.ResponseWriter, r *http.Request) { writeJSON(w, body, http.StatusOK) } +func (h *HTTPBin) IP20(w http.ResponseWriter, r *http.Request) { + cmip := models.QueryIp10() + ret := models.Ret20{Data: []string{}} + ret.Ret = "ok" + ret.Ip = cmip.Ip + ret.Updatetime = cmip.Updatetime + body, _ := json.Marshal(ret) + writeJSON(w, body, http.StatusOK) +} + func (h *HTTPBin) Ssh(w http.ResponseWriter, r *http.Request) { cmip := models.QueryIp10() result := fmt.Sprintf("ssh -p 221 root@%s",cmip.Ip) diff --git a/httpbin/httpbin.go b/httpbin/httpbin.go index ef9c6ab..c04dc4b 100644 --- a/httpbin/httpbin.go +++ b/httpbin/httpbin.go @@ -132,6 +132,7 @@ func (h *HTTPBin) Handler() http.Handler { mux.HandleFunc("/ip", h.IP) mux.HandleFunc("/ip10", h.IP10) + mux.HandleFunc("/ip20", h.IP20) mux.HandleFunc("/ssh", h.Ssh) mux.HandleFunc("/sftp", h.Sftp) mux.HandleFunc("/user-agent", h.UserAgent) diff --git a/models/ret.go b/models/ret.go index 54588b2..d89ab30 100644 --- a/models/ret.go +++ b/models/ret.go @@ -8,4 +8,11 @@ type Ret struct { Ret string `json:"ret"` Ip string `json:"ip"` Data []string `json:"data"` -} \ No newline at end of file +} + +type Ret20 struct { + Ret string `json:"ret"` + Ip string `json:"ip"` + Updatetime string `json:"updatetime"` + Data []string `json:"data"` +}