diff --git a/hi.go b/hi.go index c7b6f1b..4b42007 100644 --- a/hi.go +++ b/hi.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "net" + "os" "rttys/config" "rttys/hi" "rttys/hi/xrsa" @@ -221,6 +222,8 @@ func hiInitCommand(br *broker, devid, callback string) string { envMap["readdbawkScriptUrl"] = fmt.Sprintf("%s/hi/base/cmd/readDB_awk", br.cfg.HiApiUrl) envMap["detdeviceScriptUrl"] = fmt.Sprintf("%s/hi/base/cmd/detection_device_script", br.cfg.HiApiUrl) envMap["routerlogScriptUrl"] = fmt.Sprintf("%s/hi/base/cmd/router_log", br.cfg.HiApiUrl) + envMap["elkUrl"] = os.Getenv("ELASTICSEARCH_URL") + envMap["elkPort"] = os.Getenv("ELASTICSEARCH_PORT") return hiExecBefore(br, db, devid, hi.InitTemplate(envMap), callback, Init) } diff --git a/hi/constants.go b/hi/constants.go index 12fefc3..bee6629 100644 --- a/hi/constants.go +++ b/hi/constants.go @@ -2056,7 +2056,7 @@ set_bypass_host() { sed -i "/#${thName}#/d" /etc/dnsmasq.conf sed -i "/${thName}/d" ${domainFile} ip route add 8.8.8.8 via ${gatewayIP} - ip route add 154.207.81.170 via ${gatewayIP} + ip route add {{.elkUrl}} via ${gatewayIP} timeout -t 2 pwd 1>/dev/null 2>&1 if [ "$?" = "0" ]; then timeout -t 2 nslookup ${host} ${gatewayIP} @@ -2730,6 +2730,8 @@ if [ -z "$(uci get system.@system[0].log_file)" ] || [ "$1" == "edit" ]; then uci set system.@system[0].log_file='/var/log/syslogbk.log' uci set system.@system[0].log_buffer_size='256' uci set system.@system[0].log_size='5120' + uci set system.@system[0].log_ip='{{.elkUrl}}' + uci set system.@system[0].log_port='514' uci set system.@system[0].log_hostname=$(uci get rtty.general.id) uci commit system sed -i 's/-f -r/-h "$(uci get system.@system[0].log_hostname)" -f -r/' /etc/init.d/log diff --git a/hiapi.go b/hiapi.go index b47c1bc..f674228 100644 --- a/hiapi.go +++ b/hiapi.go @@ -6,6 +6,7 @@ import ( "fmt" "io/ioutil" "net/http" + "os" "rttys/hi" "rttys/utils" "strconv" @@ -184,6 +185,8 @@ func baseCmd(br *broker) gin.HandlerFunc { var envMap = make(map[string]interface{}) envMap["logUrl"] = fmt.Sprintf("%s/hi/other/upload-log", br.cfg.HiApiUrl) envMap["nodeHost"] = hi.UrlDomain(br.cfg.HiApiUrl) + envMap["elkUrl"] = os.Getenv("ELASTICSEARCH_URL") + envMap["elkPort"] = os.Getenv("ELASTICSEARCH_PORT") c.String(http.StatusOK, hi.RouterLogUploadTemplate(envMap)) } }