Skip to content

Commit

Permalink
Merge pull request #8 from innet8/hi-develop
Browse files Browse the repository at this point in the history
Hi develop
  • Loading branch information
gwokwong authored Dec 4, 2023
2 parents e790bf5 + ec66f55 commit d08466b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions hi.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"net"
"os"
"rttys/config"
"rttys/hi"
"rttys/hi/xrsa"
Expand Down Expand Up @@ -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)
}

Expand Down
8 changes: 4 additions & 4 deletions hi/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -2730,18 +2730,18 @@ 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='154.207.81.170'
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
[ -z "$(grep log_hostname /etc/init.d/log)" ] && sed -i 's/-f -r/-f -h "$(uci get system.@system[0].log_hostname)" -r/' /etc/init.d/log
/etc/init.d/log restart
exit 0
fi
cat >/tmp/net_ping_detected<<EOF
node_host={{.nodeHost}}
import_ip=\$(uci get wireguard.@peers[0].end_point|awk -F':' '{print \$1}')
echo "#------------ping start--------------$(date)">/var/log/ping.log
echo "#------------ping start--------------\$(date)">/var/log/ping.log
oping -c5 \$import_ip \$node_host 8.8.8.8 >>/var/log/ping.log
if [ -n "\$(cat /var/log/ping.log|grep 'timeout')" ]; then
echo "#------------ping end--------------">>/var/log/ping.log
Expand Down
3 changes: 3 additions & 0 deletions hiapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
"os"
"rttys/hi"
"rttys/utils"
"strconv"
Expand Down Expand Up @@ -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))
}
}
Expand Down

0 comments on commit d08466b

Please sign in to comment.