fix loopback check
This commit is contained in:
parent
a29e969eed
commit
9df2cf7bfe
|
@ -7,6 +7,11 @@ package api
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
log "github.com/cihub/seelog"
|
log "github.com/cihub/seelog"
|
||||||
"infini.sh/console/modules/agent/client"
|
"infini.sh/console/modules/agent/client"
|
||||||
common2 "infini.sh/console/modules/agent/common"
|
common2 "infini.sh/console/modules/agent/common"
|
||||||
|
@ -21,10 +26,6 @@ import (
|
||||||
"infini.sh/framework/core/util"
|
"infini.sh/framework/core/util"
|
||||||
elastic2 "infini.sh/framework/modules/elastic"
|
elastic2 "infini.sh/framework/modules/elastic"
|
||||||
"infini.sh/framework/modules/elastic/common"
|
"infini.sh/framework/modules/elastic/common"
|
||||||
"net"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type APIHandler struct {
|
type APIHandler struct {
|
||||||
|
@ -122,7 +123,6 @@ func (h *APIHandler) createInstance(w http.ResponseWriter, req *http.Request, ps
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (h *APIHandler) getInstance(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
func (h *APIHandler) getInstance(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||||
id := ps.MustGetParameter("instance_id")
|
id := ps.MustGetParameter("instance_id")
|
||||||
|
|
||||||
|
@ -342,7 +342,6 @@ func (h *APIHandler) updateInstance(w http.ResponseWriter, req *http.Request, ps
|
||||||
}, 200)
|
}, 200)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (h *APIHandler) searchInstance(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
func (h *APIHandler) searchInstance(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -498,7 +497,7 @@ func (h *APIHandler) authESNode(w http.ResponseWriter, req *http.Request, ps htt
|
||||||
h.WriteError(w, err.Error(), http.StatusInternalServerError)
|
h.WriteError(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !util.StringInArray(inst.IPS, host) {
|
if !util.StringInArray(inst.IPS, host) && !net.ParseIP(host).IsLoopback() {
|
||||||
h.WriteError(w, fmt.Sprintf("got node host %s not match any ip of %v", host, inst.IPS), http.StatusInternalServerError)
|
h.WriteError(w, fmt.Sprintf("got node host %s not match any ip of %v", host, inst.IPS), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -731,7 +730,6 @@ func getNodesInfoFromES(agentID string) (map[int]*agent.ESNodeInfo, error){
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
q := orm.Query{
|
q := orm.Query{
|
||||||
RawQuery: util.MustToJSONBytes(query),
|
RawQuery: util.MustToJSONBytes(query),
|
||||||
|
|
Loading…
Reference in New Issue