mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Add automatic speedtest in wizard
This commit is contained in:
parent
da603e9310
commit
2d3b37888d
3 changed files with 62 additions and 5 deletions
|
@ -415,6 +415,7 @@ function wizard_add()
|
||||||
|
|
||||||
local downloadspeed = luci.http.formvalue("cbid.sqm.%s.download" % intf) or "0"
|
local downloadspeed = luci.http.formvalue("cbid.sqm.%s.download" % intf) or "0"
|
||||||
local uploadspeed = luci.http.formvalue("cbid.sqm.%s.upload" % intf) or "0"
|
local uploadspeed = luci.http.formvalue("cbid.sqm.%s.upload" % intf) or "0"
|
||||||
|
local testspeed = luci.http.formvalue("cbid.sqm.%s.testspeed" % intf) or "0"
|
||||||
|
|
||||||
if not ucic:get("qos",intf) ~= "" then
|
if not ucic:get("qos",intf) ~= "" then
|
||||||
ucic:set("qos",intf,"interface")
|
ucic:set("qos",intf,"interface")
|
||||||
|
@ -438,7 +439,7 @@ function wizard_add()
|
||||||
ucic:set("sqm",intf,"script","piece_of_cake.qos")
|
ucic:set("sqm",intf,"script","piece_of_cake.qos")
|
||||||
ucic:set("sqm",intf,"qdisc_advanced","0")
|
ucic:set("sqm",intf,"qdisc_advanced","0")
|
||||||
ucic:set("sqm",intf,"linklayer","atm")
|
ucic:set("sqm",intf,"linklayer","atm")
|
||||||
ucic:set("sqm",intf,"overhead","40")
|
ucic:set("sqm",intf,"overhead","44")
|
||||||
ucic:set("sqm",intf,"enabled","0")
|
ucic:set("sqm",intf,"enabled","0")
|
||||||
ucic:set("sqm",intf,"debug_logging","0")
|
ucic:set("sqm",intf,"debug_logging","0")
|
||||||
ucic:set("sqm",intf,"verbosity","5")
|
ucic:set("sqm",intf,"verbosity","5")
|
||||||
|
@ -454,6 +455,10 @@ function wizard_add()
|
||||||
ucic:set("sqm",intf,"qdisc","cake")
|
ucic:set("sqm",intf,"qdisc","cake")
|
||||||
ucic:set("sqm",intf,"script","piece_of_cake.qos")
|
ucic:set("sqm",intf,"script","piece_of_cake.qos")
|
||||||
end
|
end
|
||||||
|
ucic:set("openmptcprouter",intf,"testspeed",testspeed)
|
||||||
|
if testspeed == "1" then
|
||||||
|
ucic:set("openmptcprouter",intf,"testspeed_lc")
|
||||||
|
end
|
||||||
if downloadspeed ~= "0" and downloadspeed ~= "" then
|
if downloadspeed ~= "0" and downloadspeed ~= "" then
|
||||||
if sqmautorate == "1" and (ucic:get("network",intf,"downloadspeed") ~= downloadspeed or ucic:get("sqm",intf,"max_download") == "" or ucic:get("sqm",intf,"download") == "0") then
|
if sqmautorate == "1" and (ucic:get("network",intf,"downloadspeed") ~= downloadspeed or ucic:get("sqm",intf,"max_download") == "" or ucic:get("sqm",intf,"download") == "0") then
|
||||||
ucic:set("sqm",intf,"download",math.ceil(downloadspeed*65/100))
|
ucic:set("sqm",intf,"download",math.ceil(downloadspeed*65/100))
|
||||||
|
|
|
@ -272,7 +272,7 @@
|
||||||
local method=uci:get("openmptcprouter","settings","encryption")
|
local method=uci:get("openmptcprouter","settings","encryption")
|
||||||
if method == nil and ut.trim(sys.exec("cat /proc/cpuinfo | grep aes")) ~= "" then
|
if method == nil and ut.trim(sys.exec("cat /proc/cpuinfo | grep aes")) ~= "" then
|
||||||
method="aes-256-gcm"
|
method="aes-256-gcm"
|
||||||
else
|
elseif method == nil then
|
||||||
method="chacha20"
|
method="chacha20"
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
|
@ -993,12 +993,22 @@
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
<div class="cbi-value" data-index="19">
|
<div class="cbi-value" data-index="19">
|
||||||
|
<label class="cbi-value-title"><%:Calculate speed%></label>
|
||||||
|
<div class="cbi-value-field">
|
||||||
|
<input class="cbi-input-checkbox" type="checkbox" name="cbid.sqm.<%=ifname%>.testspeed" value="1" <% if uci:get("openmptcprouter",ifname,"testspeed") == "1" or uci:get("openmptcprouter",ifname,"testspeed") == nil then %>checked<% end %> />
|
||||||
|
<br />
|
||||||
|
<div class="cbi-value-description">
|
||||||
|
<%:Run an automatic speedtest to calculate max speed.%>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="cbi-value" data-index="20">
|
||||||
<label class="cbi-value-title"><%:Download speed (Kb/s)%></label>
|
<label class="cbi-value-title"><%:Download speed (Kb/s)%></label>
|
||||||
<div class="cbi-value-field">
|
<div class="cbi-value-field">
|
||||||
<input type="text" name="cbid.sqm.<%=ifname%>.download" class="cbi-input-text" value="<%=download%>" data-type="uinteger">
|
<input type="text" name="cbid.sqm.<%=ifname%>.download" class="cbi-input-text" value="<%=download%>" data-type="uinteger">
|
||||||
<br />
|
<br />
|
||||||
<div class="cbi-value-description">
|
<div class="cbi-value-description">
|
||||||
<%:Used by Glorytun UDP and SQM/QoS if enabled. 0 to use default value.%>
|
<%:Used by Glorytun UDP and SQM/QoS if enabled.%>
|
||||||
</div>
|
</div>
|
||||||
<!--
|
<!--
|
||||||
<br />
|
<br />
|
||||||
|
@ -1008,13 +1018,13 @@
|
||||||
-->
|
-->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="cbi-value" data-index="20">
|
<div class="cbi-value" data-index="21">
|
||||||
<label class="cbi-value-title"><%:Upload speed (Kb/s)%></label>
|
<label class="cbi-value-title"><%:Upload speed (Kb/s)%></label>
|
||||||
<div class="cbi-value-field">
|
<div class="cbi-value-field">
|
||||||
<input type="text" name="cbid.sqm.<%=ifname%>.upload" class="cbi-input-text" value="<%=upload%>" data-type="uinteger">
|
<input type="text" name="cbid.sqm.<%=ifname%>.upload" class="cbi-input-text" value="<%=upload%>" data-type="uinteger">
|
||||||
<br />
|
<br />
|
||||||
<div class="cbi-value-description">
|
<div class="cbi-value-description">
|
||||||
<%:Used by Glorytun UDP and SQM/QoS if enabled. 0 to use default value.%>
|
<%:Used by Glorytun UDP and SQM/QoS if enabled.%>
|
||||||
</div>
|
</div>
|
||||||
<!--
|
<!--
|
||||||
<br />
|
<br />
|
||||||
|
|
|
@ -1609,6 +1609,48 @@ if [ -n "$OMR_TRACKER_INTERFACE" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$(pgrep -f omr-test-speed-server)" = "" ] && [ "$(uci -q get openmptcprouter.${OMR_TRACKER_INTERFACE}.testspeed)" = "1" ] && [ -z "$(uci -q get openmptcprouter.${OMR_TRACKER_INTERFACE}.testspeed_lc)" ]; then
|
||||||
|
download_speed=$(/bin/omr-test-speed-server vps ${OMR_TRACKER_DEVICE} fasttest | tr -d '\n')
|
||||||
|
download_speed2=$(/bin/omr-test-speed-server vps ${OMR_TRACKER_DEVICE} fasttest | tr -d '\n')
|
||||||
|
download_speed3=$(/bin/omr-test-speed-server vps ${OMR_TRACKER_DEVICE} fasttest | tr -d '\n')
|
||||||
|
[ "$download_speed2" -gt "$download_speed" ] && download_speed=${download_speed2}
|
||||||
|
[ "$download_speed3" -gt "$download_speed" ] && download_speed=${download_speed3}
|
||||||
|
download_speed=$((download_speed/1000))
|
||||||
|
if [ -n "$download_speed" ] && [ "$download_speed" != "0" ]; then
|
||||||
|
if [ "$(uci -q get sqm.${OMR_TRACKER_INTERFACE}.autorate)" = "1" ]; then
|
||||||
|
uci -q set sqm.${OMR_TRACKER_INTERFACE}.download=$((download_speed*65/100))
|
||||||
|
uci -q set sqm.${OMR_TRACKER_INTERFACE}.max_download=${download_speed}
|
||||||
|
uci -q set sqm.${OMR_TRACKER_INTERFACE}.min_download=$((download_speed*10/100))
|
||||||
|
else
|
||||||
|
uci -q set sqm.${OMR_TRACKER_INTERFACE}.download=$((download_speed*95/100))
|
||||||
|
fi
|
||||||
|
_log "Calculated ${OMR_TRACKER_INTERFACE} download speed: ${download_speed}"
|
||||||
|
uci -q set network.${OMR_TRACKER_INTERFACE}.downloadspeed=${download_speed}
|
||||||
|
upload_speed=$(/bin/omr-test-speed-server vps ${OMR_TRACKER_DEVICE} fasttest upload | tr -d '\n')
|
||||||
|
upload_speed2=$(/bin/omr-test-speed-server vps ${OMR_TRACKER_DEVICE} fasttest upload | tr -d '\n')
|
||||||
|
upload_speed3=$(/bin/omr-test-speed-server vps ${OMR_TRACKER_DEVICE} fasttest upload | tr -d '\n')
|
||||||
|
[ "$upload_speed2" -gt "$upload_speed" ] && upload_speed=${upload_speed2}
|
||||||
|
[ "$upload_speed3" -gt "$upload_speed" ] && upload_speed=${upload_speed3}
|
||||||
|
upload_speed=$((upload_speed/1000))
|
||||||
|
if [ -n "$upload_speed" ] && [ "$upload_speed" != "0" ]; then
|
||||||
|
if [ "$(uci -q get sqm.${OMR_TRACKER_INTERFACE}.autorate)" = "1" ]; then
|
||||||
|
uci -q set sqm.${OMR_TRACKER_INTERFACE}.upload=$((upload_speed*65/100))
|
||||||
|
uci -q set sqm.${OMR_TRACKER_INTERFACE}.max_upload=${upload_speed}
|
||||||
|
uci -q set sqm.${OMR_TRACKER_INTERFACE}.min_upload=$((upload_speed*10/100))
|
||||||
|
else
|
||||||
|
uci -q set sqm.${OMR_TRACKER_INTERFACE}.upload=$((upload_speed*95/100))
|
||||||
|
fi
|
||||||
|
_log "Calculated ${OMR_TRACKER_INTERFACE} upload speed: ${upload_speed}"
|
||||||
|
uci -q set network.${OMR_TRACKER_INTERFACE}.uploadspeed=${upload_speed}
|
||||||
|
fi
|
||||||
|
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.testspeed_lc=$(date +"%s")
|
||||||
|
uci commit network
|
||||||
|
uci commit openmptcprouter
|
||||||
|
fi
|
||||||
|
sleep 5
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# If a service is down, force restart it
|
# If a service is down, force restart it
|
||||||
if [ -f /etc/init.d/shadowsocks-libev ] && [ "$(pgrep -f omr-tracker-ss)" = "" ] && [ "$(pgrep -f ss-redir)" = "" ] && [ "$(pgrep -f ss-local)" = "" ] && [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "192.18.1.3" ] && [ "$(uci -q get shadowsocks-libev.sss0.key)" != "" ]; then
|
if [ -f /etc/init.d/shadowsocks-libev ] && [ "$(pgrep -f omr-tracker-ss)" = "" ] && [ "$(pgrep -f ss-redir)" = "" ] && [ "$(pgrep -f ss-local)" = "" ] && [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "" ] && [ "$(uci -q get shadowsocks-libev.sss0.server)" != "192.18.1.3" ] && [ "$(uci -q get shadowsocks-libev.sss0.key)" != "" ]; then
|
||||||
_log "Can't find Shadowsocks, restart it..."
|
_log "Can't find Shadowsocks, restart it..."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue