main
wenfei 3 months ago
parent 6040c359c0
commit 8df0a2fd8f

@ -11,8 +11,8 @@ import (
func ConnectDb() *sql.DB {
//db, _ := sql.Open("mysql", "root:Skyinno251,@tcp(47.242.184.139:3306)/goftp")
db, _ := sql.Open("mysql", "root:Skyinno251,@tcp(127.0.0.1:3306)/goftp")
db, _ := sql.Open("mysql", "root:Skyinno251,@tcp(47.242.184.139:3306)/goftp")
//db, _ := sql.Open("mysql", "root:Skyinno251,@tcp(127.0.0.1:3306)/goftp")
//if err != nil {
// fmt.Println(err.Error())
// return

@ -128,6 +128,36 @@ func (h *HTTPBin) IP(w http.ResponseWriter, r *http.Request) {
writeJSON(w, body, http.StatusOK)
}
func (h *HTTPBin) IP1(w http.ResponseWriter, r *http.Request) {
ret := models.Ret{Data: []string{}}
ret.Ret = "ok"
ret.Ip = ""
origin := getOrigin(r)
if len(origin) > 0 {
ipArray := strings.Split(origin, ":")
if len(ipArray) > 1 {
ret.Ip = ipArray[0]
}
}
body, _ := json.Marshal(ret)
writeJSON(w, body, http.StatusOK)
}
func (h *HTTPBin) IP2(w http.ResponseWriter, r *http.Request) {
ret := models.Ret{Data: []string{}}
ret.Ret = "ok"
ret.Ip = ""
origin := getOrigin(r)
if len(origin) > 0 {
ipArray := strings.Split(origin, ":")
if len(ipArray) > 1 {
ret.Ip = ipArray[0]
}
}
body, _ := json.Marshal(ret)
writeJSON(w, body, http.StatusOK)
}
func (h *HTTPBin) IP10(w http.ResponseWriter, r *http.Request) {
cmip := models.QueryIp10()
ret := models.Ret{Data: []string{}}

@ -131,6 +131,8 @@ func (h *HTTPBin) Handler() http.Handler {
mux.HandleFunc("/delete", methods(h.RequestWithBody, "DELETE"))
mux.HandleFunc("/ip", h.IP)
mux.HandleFunc("/ip1", h.IP1)
mux.HandleFunc("/ip2", h.IP2)
mux.HandleFunc("/ip10", h.IP10)
mux.HandleFunc("/ip20", h.IP20)
mux.HandleFunc("/ssh", h.Ssh)

Loading…
Cancel
Save