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

Add option to disable gateway and server ping check for status page

This commit is contained in:
Ycarus (Yannick Chabanois) 2019-08-16 10:33:38 +02:00
parent c9327c9214
commit 5a644babf8
3 changed files with 32 additions and 5 deletions

View file

@ -597,12 +597,19 @@ function settings_add()
-- Enable/disable external check
local externalcheck = luci.http.formvalue("externalcheck") or "1"
ucic:set("openmptcprouter","settings","external_check",externalcheck)
ucic:commit("openmptcprouter")
-- Enable/disable external check
local savevnstat = luci.http.formvalue("savevnstat") or "0"
luci.sys.exec("uci -q set vnstat.@vnstat[0].backup=%s" % savevnstat)
ucic:commit("openmptcprouter")
ucic:commit("vnstat")
-- Enable/disable gateway ping
local disablegwping = luci.http.formvalue("disablegwping") or "0"
ucic:set("openmtpcprouter","settings","disablegwping",disablegwping)
-- Enable/disable server ping
local disableserverping = luci.http.formvalue("disableserverping") or "0"
ucic:set("openmtpcprouter","settings","disableserverping",disableserverping)
-- Enable/disable fast open
local disablefastopen = luci.http.formvalue("disablefastopen") or "0"

View file

@ -167,6 +167,26 @@
</div>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title"><%:Disable gateway ping%></label>
<div class="cbi-value-field">
<input type="checkbox" name="disablegwping" class="cbi-input-checkbox" value="0" <% if luci.model.uci.cursor():get("openmptcprouter","settings","disablegwping") == "1" then %>checked<% end %>>
<br />
<div class="cbi-value-description">
<%:Disable gateway ping status check%>
</div>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title"><%:Disable server ping%></label>
<div class="cbi-value-field">
<input type="checkbox" name="disableserverping" class="cbi-input-checkbox" value="0" <% if luci.model.uci.cursor():get("openmptcprouter","settings","disableserverping") == "1" then %>checked<% end %>>
<br />
<div class="cbi-value-description">
<%:Disable server ping status check%>
</div>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title"><%:Master interface selection%></label>
<div class="cbi-value-field">

View file

@ -457,7 +457,7 @@ end
function savevnstat(savevnstat)
-- Enable/disable save vnstat
luci.sys.exec("uci -q set vnstat.@vnstat[0].backup=%s" % savevnstat)
ucic:commit("openmptcprouter")
ucic:commit("vnstat")
end
function disablefastopen(disablefastopen)
@ -964,7 +964,7 @@ function interfaces_status()
end
end
end
if gateway ~= "" then
if gateway ~= "" and uci:get("openmptcprouter", "settings", "disablegwping") ~= "1" 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"
@ -984,7 +984,7 @@ function interfaces_status()
if serverip == "127.0.0.1" then
serverip = mArray.openmptcprouter["wan_addr"]
end
if serverip ~= "" then
if serverip ~= "" and uci:get("openmptcprouter", "settings", "disableserverping") ~= "1" then
local server_ping_test = sys.exec("ping -w 1 -c 1 -I " .. ifname .. " " .. serverip)
local server_ping_result = ut.trim(sys.exec("echo '" .. server_ping_test .. "' | grep '100% packet loss'"))
if server_ping_result ~= "" then