1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-14 19:41:51 +00:00

Fix and add huawei signal power

This commit is contained in:
Ycarus (Yannick Chabanois) 2020-02-21 09:30:43 +01:00
parent 59f8161292
commit 1274791cc1
5 changed files with 53 additions and 14 deletions

View file

@ -48,7 +48,7 @@ function wizard_add()
-- Remove existing server
local delete_server = luci.http.formvaluetable("deleteserver") or ""
if delete_server ~= "" then
if delete_server ~= "" and next(delete_server) ~= nil then
for serverdel, _ in pairs(delete_server) do
ucic:foreach("network", "interface", function(s)
local sectionname = s[".name"]
@ -66,9 +66,9 @@ function wizard_add()
ucic:foreach("openmptcprouter", "server", function(s)
local servername = s[".name"]
nbserver = nbserver + 1
server_ip = ucic("openmptcprouter",servername,"ip")
server_ip = ucic:get("openmptcprouter",servername,"ip")
end)
if nbserver == 1 and server_ip ~= "" then
if nbserver == 1 and server_ip ~= "" and server_ip ~= nil then
ucic:set("shadowsocks-libev","sss0","server",server_ip)
ucic:set("glorytun","vpn","host",server_ip)
ucic:set("dsvpn","vpn","host",server_ip)

View file

@ -358,6 +358,7 @@
ipaddr=replaceLastNChars(ipaddr,"x",6);
}
var whois = mArray.wans[i].whois;
var signal = mArray.wans[i].signal;
var multipath = mArray.wans[i].multipath;
if(multipath == 'master')
{
@ -412,23 +413,36 @@
{
content += String.format('%s %s<br />',_('mtu:'), mtu);
}
if(signal !== '')
{
if (signal <= 0)
title += ' <img src="/luci-static/resources/icons/signal-0.png" />';
else if (signal < 25)
title += ' <img src="/luci-static/resources/icons/signal-0-25.png" />';
else if (signal < 50)
title += ' <img src="/luci-static/resources/icons/signal-25-50.png" />';
else if (signal < 75)
title += ' <img src="/luci-static/resources/icons/signal-50-75.png" />';
else
title += ' <img src="/luci-static/resources/icons/signal-75-100.png" />';
}
if(ipaddr == '')
{
statusMessage += _('No IP defined') + '<br />'
statusMessage += _('No IP defined') + '<br />';
}
if(gateway == '')
{
statusMessage += _('No gateway defined') + '<br />'
statusMessage += _('No gateway defined') + '<br />';
} else if(gw_ping == 'DOWN')
{
statusMessage += _('Gateway DOWN') + '<br />'
statusMessage += _('Gateway DOWN') + '<br />';
} else if(multipath_available == 'ERROR')
{
statusMessage += _('Multipath seems to be blocked on the connection') + '<br />'
statusMessage += _('Multipath seems to be blocked on the connection') + '<br />';
}
if(server_ping == 'DOWN')
{
statusMessage += _('No Server ping response after 1 second') + '<br />'
statusMessage += _('No Server ping response after 1 second') + '<br />';
}
if (stat == 'Offline' && ipaddr != '' && ipaddr == mArray.wans[i].gateway)
{

View file

@ -0,0 +1,13 @@
#!/bin/sh
MODEM_IP=`echo $1 | grep -E '^(192\.168|10\.|172\.1[6789]\.|172\.2[0-9]\.|172\.3[01]\.)'`
[ -z "$MODEM_IP" ] && return
SESTOK=$(curl -s -m 1 -X GET "http://$MODEM_IP/api/webserver/SesTokInfo")
COOKIE=$(echo $SESTOK | sed -ne '/SesInfo/{s/.*<SesInfo>\(.*\)<\/SesInfo>.*/\1/p;q;}')
COOKIE=$(echo $COOKIE | sed 's:SessionID=::')
TOKEN=$(echo $SESTOK | sed -ne '/TokInfo/{s/.*<TokInfo>\(.*\)<\/TokInfo>.*/\1/p;q;}')
curl -s -m 1 -X GET "http://$MODEM_IP/api/monitoring/status" -H "Cookie: SessionID=$COOKIE" -H "__RequestVerificationToken: $TOKEN" -H "Content-Type: text/xml" > /tmp/huawei-$1-status
SIGNAL_ICON=$(cat /tmp/huawei-$1-status | grep SignalIcon | sed -e 's/<[^>]*>//g')
MAX_SIGNAL=$(cat /tmp/huawei-$1-status | grep maxsignal | sed -e 's/<[^>]*>//g')
if [ -n "$SIGNAL_ICON" ] && [ -n "$MAX_SIGNAL" ]; then
echo $((100 * ${SIGNAL_ICON} / ${MAX_SIGNAL}))
fi

View file

@ -1001,14 +1001,20 @@ function interfaces_status()
end
end
end
if gateway ~= "" and uci:get("openmptcprouter", "settings", "disablegwping") ~= "1" and connectivity ~= "ERROR" then
local gw_ping_test = ut.trim(sys.exec("ping -w 1 -c 1 " .. gateway .. " | grep '100% packet loss'"))
if gw_ping_test ~= "" then
gw_ping = "DOWN"
if connectivity == "OK" then
connectivity = "WARNING"
local signal = ""
if gateway ~= "" then
if uci:get("openmptcprouter", "settings", "disablegwping") ~= "1" and connectivity ~= "ERROR" then
local gw_ping_test = ut.trim(sys.exec("ping -w 1 -c 1 " .. gateway .. " | grep '100% packet loss'"))
if gw_ping_test ~= "" then
gw_ping = "DOWN"
if connectivity == "OK" then
connectivity = "WARNING"
end
end
end
if uci:get("openmptcprouter", interface, "manufacturer") ~= "huawei" then
signal = sys.exec("omr-huawei " .. gateway)
end
elseif gateway == "" then
gw_ping = "DOWN"
connectivity = "ERROR"
@ -1150,6 +1156,7 @@ function interfaces_status()
multipath_available = multipath_available,
multipath_state = current_multipath_state,
duplicateif = duplicateif,
signal = signal,
}
if ifname ~= nil and ifname:match("^tun.*") then
table.insert(mArray.tunnels, data);

View file

@ -537,6 +537,11 @@ if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc)" = "" ] || [ $(($(
}
}
fi
if [ -n "$(curl -s -m 1 -X GET "http://$OMR_TRACKER_DEVICE_GATEWAY/api/webserver/SesTokInfo)" ]; then
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.manufacturer='huawei'
else
uci -q delete openmptcprouter.$OMR_TRACKER_INTERFACE.manufacturer
fi
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.lc=$(date +"%s")
}
if [ "$(uci -q get shadowsocks-libev.sss0.server)" != "" ] && [ "$(uci -q get openmptcprouter.settings.external_check)" = "0" ]; then