1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Add Cake Autorate

This commit is contained in:
Ycarus (Yannick Chabanois) 2022-06-16 19:28:25 +02:00
parent c4157bfc0f
commit b8c8658720
44 changed files with 8689 additions and 7 deletions

View file

@ -283,6 +283,7 @@ function wizard_add()
local auth = luci.http.formvalue("cbid.network.%s.auth" % intf) or ""
local mode = luci.http.formvalue("cbid.network.%s.mode" % intf) or ""
local sqmenabled = luci.http.formvalue("cbid.sqm.%s.enabled" % intf) or "0"
local sqmautorate = luci.http.formvalue("cbid.sqm.%s.autorate" % intf) or "0"
local qosenabled = luci.http.formvalue("cbid.qos.%s.enabled" % intf) or "0"
local multipath = luci.http.formvalue("cbid.network.%s.multipath" % intf) or "on"
local lan = luci.http.formvalue("cbid.network.%s.lan" % intf) or "0"
@ -439,10 +440,21 @@ function wizard_add()
--ucic:set("sqm",intf,"iqdisc_opts","autorate-ingress dual-dsthost")
--ucic:set("sqm",intf,"eqdisc_opts","dual-srchost")
end
ucic:set("sqm",intf,"autorate",sqmautorate)
if sqmautorate == "1" then
ucic:set("sqm",intf,"qdisc","cake")
ucic:set("sqm",intf,"script","piece_of_cake.qos")
end
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
ucic:set("sqm",intf,"download",math.ceil(downloadspeed*65/100))
ucic:set("sqm",intf,"min_download",math.ceil(downloadspeed*10/100))
ucic:set("sqm",intf,"max_download",downloadspeed)
elseif sqmautorate ~= "1" then
ucic:set("sqm",intf,"download",math.ceil(downloadspeed*95/100))
end
ucic:set("network",intf,"downloadspeed",downloadspeed)
ucic:set("sqm",intf,"download",math.ceil(downloadspeed*95/100))
ucic:set("qos",intf,"download",math.ceil(downloadspeed*95/100))
else
ucic:delete("network",intf,"downloadspeed")
@ -450,8 +462,14 @@ function wizard_add()
ucic:set("qos",intf,"download","0")
end
if uploadspeed ~= "0" and uploadspeed ~= "" then
if sqmautorate == "1" and (ucic:get("network",intf,"uploadspeed") ~= uploadspeed or ucic:get("sqm",intf,"max_upload") == "" or ucic:get("sqm",intf,"upload") == "0") then
ucic:set("sqm",intf,"upload",math.ceil(uploadspeed*65/100))
ucic:set("sqm",intf,"min_upload",math.ceil(uploadspeed*10/100))
ucic:set("sqm",intf,"max_upload",uploadspeed)
elseif sqmautorate ~= "1" then
ucic:set("sqm",intf,"upload",math.ceil(uploadspeed*95/100))
end
ucic:set("network",intf,"uploadspeed",uploadspeed)
ucic:set("sqm",intf,"upload",math.ceil(uploadspeed*95/100))
ucic:set("qos",intf,"upload",math.ceil(uploadspeed*95/100))
else
ucic:delete("network",intf,"uploadspeed")
@ -998,6 +1016,7 @@ function wizard_add()
luci.sys.call("/etc/init.d/omr-6in4 restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/vnstat restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/v2ray restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/sqm-autorate restart >/dev/null 2>/dev/null")
luci.sys.call("/etc/init.d/sysntpd restart >/dev/null 2>/dev/null")
luci.http.redirect(luci.dispatcher.build_url("admin/system/" .. menuentry:lower() .. "/status"))
else

View file

@ -914,6 +914,7 @@
local upload = "0"
download = uci:get("network",ifname,"downloadspeed") or "0"
upload = uci:get("network",ifname,"uploadspeed") or "0"
cake = uci:get("sqm",ifname,"qdisc") or "cake"
--if download == "0" or upload == "0" then
-- if nixio.fs.access("/etc/init.d/sqm") then
-- download = uci:get("sqm",ifname,"download")
@ -940,11 +941,27 @@
<div class="cbi-value" data-index="16">
<label class="cbi-value-title"><%:Enable SQM%></label>
<div class="cbi-value-field">
<input class="cbi-input-checkbox" type="checkbox" name="cbid.sqm.<%=ifname%>.enabled" value="1" <% if uci:get("sqm",ifname,"enabled") == "1" then %>checked<% end %> />
<input class="cbi-input-checkbox" type="checkbox" name="cbid.sqm.<%=ifname%>.enabled" id="cbid.sqm.<%=ifname%>.enabled" value="1" <% if uci:get("sqm",ifname,"enabled") == "1" then %>checked<% end %> />
<br />
<div class="cbi-value-description">
<%:SQM control bufferloat: the undesirable latency that arises when the router buffers too much data.%>
<%:You should disable SQM for LTE or any interfaces with variable speed.%>
</div>
</div>
</div>
<div class="cbi-value" data-index="17">
<label class="cbi-value-title"><%:Enable SQM autorate%></label>
<div class="cbi-value-field">
<input class="cbi-input-checkbox" type="checkbox" name="cbid.sqm.<%=ifname%>.autorate" id="cbid.sqm.<%=ifname%>.autorate" value="1" <% if uci:get("sqm",ifname,"autorate") == "1" then %>checked<% end %> />
<br />
<div class="cbi-value-description">
<%:SQM autorate is for LTE and connection without a stable speed.%>
<%
if cake ~= "cake" then
%>
<%:Cake queue discipline is not set, autorate will only work after a reboot if enabled here.%>
<%
end
%>
</div>
</div>
</div>
@ -954,7 +971,7 @@
<%
if qos == "1" then
%>
<div class="cbi-value" data-index="16">
<div class="cbi-value" data-index="18">
<label class="cbi-value-title"><%:Enable QoS%></label>
<div class="cbi-value-field">
<input class="cbi-input-checkbox" type="checkbox" name="cbid.qos.<%=ifname%>.enabled" value="1" <% if uci:get("qos",ifname,"enabled") == "1" then %>checked<% end %> />
@ -967,7 +984,7 @@
<%
end
%>
<div class="cbi-value" data-index="17">
<div class="cbi-value" data-index="19">
<label class="cbi-value-title"><%:Download speed (Kb/s)%></label>
<div class="cbi-value-field">
<input type="text" name="cbid.sqm.<%=ifname%>.download" class="cbi-input-text" value="<%=download%>" data-type="uinteger">
@ -983,7 +1000,7 @@
-->
</div>
</div>
<div class="cbi-value" data-index="18">
<div class="cbi-value" data-index="20">
<label class="cbi-value-title"><%:Upload speed (Kb/s)%></label>
<div class="cbi-value-field">
<input type="text" name="cbid.sqm.<%=ifname%>.upload" class="cbi-input-text" value="<%=upload%>" data-type="uinteger">