validate node publish address with agent instance ip list
This commit is contained in:
parent
4d56a1121f
commit
365dd690ab
|
@ -21,6 +21,7 @@ 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"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
@ -491,6 +492,16 @@ 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
|
||||||
}
|
}
|
||||||
|
host, _, err := net.SplitHostPort(nodeInfo.PublishAddress)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
h.WriteError(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !util.StringInArray(inst.IPS, host) {
|
||||||
|
h.WriteError(w, fmt.Sprintf("got node host %s not match any ip of %v", host, inst.IPS), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
nodeInfo.ID = oldNodeInfo.ID
|
nodeInfo.ID = oldNodeInfo.ID
|
||||||
nodeInfo.AgentID = inst.ID
|
nodeInfo.AgentID = inst.ID
|
||||||
err = orm.Save(nil, nodeInfo)
|
err = orm.Save(nil, nodeInfo)
|
||||||
|
|
Loading…
Reference in New Issue