add host field in getExecutionNodes api

This commit is contained in:
liugq 2022-10-25 19:38:35 +08:00
parent c916a6a55e
commit 71f0871e5a
1 changed files with 12 additions and 3 deletions

View File

@ -18,6 +18,7 @@ import (
"infini.sh/framework/core/util" "infini.sh/framework/core/util"
"infini.sh/framework/modules/elastic" "infini.sh/framework/modules/elastic"
"net/http" "net/http"
"net/url"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -413,9 +414,10 @@ func (h *GatewayAPI) getExecutionNodes(w http.ResponseWriter, req *http.Request,
if keyword != "" { if keyword != "" {
boolQ["must"] = []util.MapStr{ boolQ["must"] = []util.MapStr{
{ {
"query_string": util.MapStr{ "prefix": util.MapStr{
"default_field":"*", "name": util.MapStr{
"query": keyword, "value": keyword,
},
}, },
}, },
} }
@ -474,6 +476,13 @@ func (h *GatewayAPI) getExecutionNodes(w http.ResponseWriter, req *http.Request,
node["type"] = "agent" node["type"] = "agent"
endpoint = fmt.Sprintf("%s://%s:%v", hit.Source["schema"], hit.Source["remote_ip"], hit.Source["port"]) endpoint = fmt.Sprintf("%s://%s:%v", hit.Source["schema"], hit.Source["remote_ip"], hit.Source["port"])
} }
ul, err := url.Parse(endpoint)
if err != nil {
log.Error(err)
}else{
node["host"] = ul.Host
}
if !hasErr { if !hasErr {
available, err := isNodeAvailable(endpoint) available, err := isNodeAvailable(endpoint)
if err != nil { if err != nil {