From e85f3d273bb59030ef4ee49a1f1d0867f96bb0dd Mon Sep 17 00:00:00 2001 From: sbwml Date: Tue, 27 May 2025 19:08:41 +0800 Subject: [PATCH] luci-app-sqm: displays a list of scripts and descriptions based on iptables system functions Signed-off-by: sbwml --- .../luci-static/resources/view/network/sqm.js | 46 +++++++++++-------- po/zh_Hans/sqm.po | 33 +++++++++++++ 2 files changed, 60 insertions(+), 19 deletions(-) diff --git a/htdocs/luci-static/resources/view/network/sqm.js b/htdocs/luci-static/resources/view/network/sqm.js index 6acb25f..c39b909 100644 --- a/htdocs/luci-static/resources/view/network/sqm.js +++ b/htdocs/luci-static/resources/view/network/sqm.js @@ -8,13 +8,6 @@ 'require tools.widgets as widgets'; return view.extend({ - handleGetHelpText: function(script_name, tbl) { - return fs.read("/usr/lib/sqm/" + script_name + ".help").then(function (text) { - if (text) - return [script_name, text]; - }); - }, - handleEnableSQM: rpc.declare({ object: 'luci', method: 'setInitAction', @@ -26,13 +19,11 @@ return view.extend({ return Promise.all([ L.resolveDefault(fs.list('/var/run/sqm/available_qdiscs'), []), L.resolveDefault(fs.list('/usr/lib/sqm'), []).then(L.bind(function(scripts) { - var tasks = [], scriptHelpTbl = {}; - + var result = []; for (var i = 0; i < scripts.length; i++) if (scripts[i].name.search(/\.qos$/) != -1) - tasks.push(L.resolveDefault(this.handleGetHelpText(scripts[i].name, scriptHelpTbl), [scripts[i].name, null])); - - return Promise.all(tasks); + result.push([scripts[i].name]); + return result; }, this)), uci.load('sqm') ]); @@ -117,14 +108,31 @@ return view.extend({ o.rmempty = false; var qos_desc = ""; + var hasIptables = L.hasSystemFeature('iptables'); + var helpTexts = { + "layer_cake.qos": _("This uses the cake qdisc as a replacement for both htb as shaper and fq_codel as leaf qdisc.") + "
" + + _("This exercises cake's diffserv profile(s) as different \"layers\" of priority.") + "
" + + _("This script requires that cake is selected as qdisc, and forces its usage.") + "
" + + _("See:") + " http://www.bufferbloat.net/projects/codel/wiki/Cake " + _("for more information"), + "piece_of_cake.qos": _("This just uses the cake qdisc as a replacement for both htb as shaper and fq_codel as leaf qdisc.") + "
" + + _("It just does not come any simpler than this, in other words it truely is a \"piece of cake\".") + "
" + + _("This script requires that cake is selected as qdisc, and forces its usage.") + "
" + + _("See:") + " http://www.bufferbloat.net/projects/codel/wiki/Cake " + _("for more information"), + "simple.qos": _("BW-limited three-tier prioritisation scheme with your qdisc on each queue."), + "simplest.qos": _("Simplest possible configuration: HTB rate limiter with your qdisc attached."), + "simplest_tbf.qos": _("Simplest possible configuration (TBF): TBF rate limiter with your qdisc attached.") + "
" + + _("TBF may give better performance than HTB on some architectures. This script forces fq_codel usage if cake is selected as qdisc.") + }; o = s.taboption("tab_qdisc", form.ListValue, "script", _("Queue setup script")); - for (i = 0; i < scripts.length; i++) { - o.value(scripts[i][0]); - qos_desc += "

" + scripts[i][0] + ":
"; - if (scripts[i][1]) - qos_desc += scripts[i][1] + "

"; - else - qos_desc += "No help text

"; + for (var i = 0; i < scripts.length; i++) { + var scriptName = scripts[i][0]; + if (!hasIptables && scriptName.indexOf("simple") === 0) { + continue; + } + o.value(scriptName); + qos_desc += "" + scriptName + ":
"; + if (helpTexts[scriptName]) + qos_desc += helpTexts[scriptName] + "

"; } o.default = "piece_of_cake.qos"; o.rmempty = false; diff --git a/po/zh_Hans/sqm.po b/po/zh_Hans/sqm.po index 0ddf65f..7dcd0e4 100644 --- a/po/zh_Hans/sqm.po +++ b/po/zh_Hans/sqm.po @@ -304,3 +304,36 @@ msgstr "" #: applications/luci-app-sqm/htdocs/luci-static/resources/view/network/sqm.js:219 msgid "default" msgstr "默认" + +msgid "This uses the cake qdisc as a replacement for both htb as shaper and fq_codel as leaf qdisc." +msgstr "该脚本使用 cake 队列规则(qdisc)来替代 htb(分层令牌桶)作为流量整形器,同时取代 fq_codel 作为叶节点队列规则。" + +msgid "This exercises cake's diffserv profile(s) as different \"layers\" of priority." +msgstr "它通过 cake 的差异化服务(diffserv)策略来模拟不同"层级"的流量优先级。" + +msgid "This script requires that cake is selected as qdisc, and forces its usage." +msgstr "该脚本要求并强制使用 cake 作为队列规则(qdisc)。" + +msgid "See:" +msgstr "参考:" + +msgid "for more information" +msgstr "了解更多信息" + +msgid "This just uses the cake qdisc as a replacement for both htb as shaper and fq_codel as leaf qdisc." +msgstr "该脚本仅使用 cake 队列规则(qdisc),同时替代 htb 作为整形器和 fq_codel 作为叶队列规则。" + +msgid "It just does not come any simpler than this, in other words it truely is a \"piece of cake\"." +msgstr "这已经是最简单的配置了,换句话说,这真的是“小菜一碟”。" + +msgid "BW-limited three-tier prioritisation scheme with your qdisc on each queue." +msgstr "带宽受限的三层优先级方案,每个队列都可使用您选择的 qdisc。" + +msgid "Simplest possible configuration: HTB rate limiter with your qdisc attached." +msgstr "最简单的配置:HTB 限速器,并绑定您选择的 qdisc。" + +msgid "Simplest possible configuration (TBF): TBF rate limiter with your qdisc attached." +msgstr "最简单的配置(TBF):TBF 限速器,并绑定您选择的 qdisc。" + +msgid "TBF may give better performance than HTB on some architectures. This script forces fq_codel usage if cake is selected as qdisc." +msgstr "在某些架构上,TBF 可能比 HTB 有更好的性能。当 cake 被选为 qdisc 时,该脚本会强制使用 fq_codel。"