• R/O
  • HTTP
  • SSH
  • HTTPS

luci: Commit

LuCI - OpenWrt Configuration Interface


Commit MetaInfo

Revisãoe50588790ab4d256e659068c7338f416d241dc61 (tree)
Hora2022-05-23 13:16:56
AutorTianling Shen <cnsztl@immo...>
CommiterTianling Shen

Mensagem de Log

luci-app-turboacc: cleanup cbi code

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
(cherry picked from commit 6c728bf693806e1df786b7c0e79880726d189480)

Mudança Sumário

Diff

--- a/applications/luci-app-turboacc/luasrc/model/cbi/turboacc.lua
+++ b/applications/luci-app-turboacc/luasrc/model/cbi/turboacc.lua
@@ -1,4 +1,7 @@
1-local kernel_version = luci.sys.exec("echo -n $(uname -r)")
1+local fs = require "nixio.fs"
2+
3+local boardinfo = luci.util.ubus("system", "board") or {}
4+local m, s, o
25
36 m = Map("turboacc")
47 m.title = translate("Turbo ACC Acceleration Settings")
@@ -10,70 +13,70 @@ s = m:section(TypedSection, "turboacc", "")
1013 s.addremove = false
1114 s.anonymous = true
1215
13-if nixio.fs.access("/lib/modules/" .. kernel_version .. "/xt_FLOWOFFLOAD.ko") then
14-sw_flow = s:option(Flag, "sw_flow", translate("Software flow offloading"))
15-sw_flow.default = 0
16-sw_flow.description = translate("Software based offloading for routing/NAT")
17-sw_flow:depends("sfe_flow", 0)
18-end
16+if fs.access("/lib/modules/" .. boardinfo.kernel .. "/xt_FLOWOFFLOAD.ko") then
17+ o = s:option(Flag, "sw_flow", translate("Software flow offloading"))
18+ o.default = 0
19+ o.description = translate("Software based offloading for routing/NAT")
20+ o:depends("sfe_flow", 0)
1921
20-if luci.sys.call("cat /etc/openwrt_release | grep -q mt762") == 0 then
21-hw_flow = s:option(Flag, "hw_flow", translate("Hardware flow offloading"))
22-hw_flow.default = 0
23-hw_flow.description = translate("Requires hardware NAT support. Implemented at least for mt762x")
24-hw_flow:depends("sw_flow", 1)
22+ if boardinfo.release.target:match("(mt762[0-9])$") then
23+ o = s:option(Flag, "hw_flow", translate("Hardware flow offloading"))
24+ o.default = 0
25+ o.description = translate("Requires hardware NAT support. Implemented at least for mt762x")
26+ o:depends("sw_flow", 1)
27+ end
2528 end
2629
27-if nixio.fs.access("/lib/modules/" .. kernel_version .. "/fast-classifier.ko") then
28-sfe_flow = s:option(Flag, "sfe_flow", translate("Shortcut-FE flow offloading"))
29-sfe_flow.default = 0
30-sfe_flow.description = translate("Shortcut-FE based offloading for routing/NAT")
31-sfe_flow:depends("sw_flow", 0)
32-end
30+if fs.access("/lib/modules/" .. boardinfo.kernel .. "/fast-classifier.ko") then
31+ o = s:option(Flag, "sfe_flow", translate("Shortcut-FE flow offloading"))
32+ o.default = 0
33+ o.description = translate("Shortcut-FE based offloading for routing/NAT")
34+ o:depends("sw_flow", 0)
3335
34-sfe_bridge = s:option(Flag, "sfe_bridge", translate("Bridge Acceleration"))
35-sfe_bridge.default = 0
36-sfe_bridge.description = translate("Enable Bridge Acceleration (may be functional conflict with bridge-mode VPN server)")
37-sfe_bridge:depends("sfe_flow", 1)
36+ o = s:option(Flag, "sfe_bridge", translate("Bridge Acceleration"))
37+ o.default = 0
38+ o.description = translate("Enable Bridge Acceleration (may be functional conflict with bridge-mode VPN server)")
39+ o:depends("sfe_flow", 1)
3840
39-if nixio.fs.access("/proc/sys/net/ipv6") then
40-sfe_ipv6 = s:option(Flag, "sfe_ipv6", translate("IPv6 Acceleration"))
41-sfe_ipv6.default = 0
42-sfe_ipv6.description = translate("Enable IPv6 Acceleration")
43-sfe_ipv6:depends("sfe_flow", 1)
41+ if fs.access("/proc/sys/net/ipv6") then
42+ o = s:option(Flag, "sfe_ipv6", translate("IPv6 Acceleration"))
43+ o.default = 0
44+ o.description = translate("Enable IPv6 Acceleration")
45+ o:depends("sfe_flow", 1)
46+ end
4447 end
4548
46-if nixio.fs.access("/lib/modules/" .. kernel_version .. "/tcp_bbr.ko") then
47-bbr_cca = s:option(Flag, "bbr_cca", translate("BBR CCA"))
48-bbr_cca.default = 0
49-bbr_cca.description = translate("Using BBR CCA can improve TCP network performance effectively")
49+if fs.access("/lib/modules/" .. boardinfo.kernel .. "/tcp_bbr.ko") then
50+ o = s:option(Flag, "bbr_cca", translate("BBR CCA"))
51+ o.default = 0
52+ o.description = translate("Using BBR CCA can improve TCP network performance effectively")
5053 end
5154
52-if nixio.fs.access("/lib/modules/" .. kernel_version .. "/xt_FULLCONENAT.ko") then
53-fullcone_nat = s:option(Flag, "fullcone_nat", translate("FullCone NAT"))
54-fullcone_nat.default = 0
55-fullcone_nat.description = translate("Using FullCone NAT can improve gaming performance effectively")
55+if fs.access("/lib/modules/" .. boardinfo.kernel .. "/xt_FULLCONENAT.ko") then
56+ o = s:option(Flag, "fullcone_nat", translate("FullCone NAT"))
57+ o.default = 0
58+ o.description = translate("Using FullCone NAT can improve gaming performance effectively")
5659 end
5760
58-dns_caching = s:option(Flag, "dns_caching", translate("DNS Caching"))
59-dns_caching.default = 0
60-dns_caching.rmempty = false
61-dns_caching.description = translate("Enable DNS Caching and anti ISP DNS pollution")
61+o = s:option(Flag, "dns_caching", translate("DNS Caching"))
62+o.default = 0
63+o.rmempty = false
64+o.description = translate("Enable DNS Caching and anti ISP DNS pollution")
6265
63-dns_caching_mode = s:option(ListValue, "dns_caching_mode", translate("Resolve DNS Mode"), translate("DNS Program"))
64-dns_caching_mode:value("1", translate("Using PDNSD to query and cache"))
65-if nixio.fs.access("/usr/bin/dnsforwarder") then
66-dns_caching_mode:value("2", translate("Using DNSForwarder to query and cache"))
66+o = s:option(ListValue, "dns_caching_mode", translate("Resolve DNS Mode"), translate("DNS Program"))
67+o:value("1", translate("Using PDNSD to query and cache"))
68+if fs.access("/usr/bin/dnsforwarder") then
69+ o:value("2", translate("Using DNSForwarder to query and cache"))
6770 end
68-if nixio.fs.access("/usr/bin/dnsproxy") then
69-dns_caching_mode:value("3", translate("Using DNSProxy to query and cache"))
71+if fs.access("/usr/bin/dnsproxy") then
72+ o:value("3", translate("Using DNSProxy to query and cache"))
7073 end
71-dns_caching_mode.default = 1
72-dns_caching_mode:depends("dns_caching", 1)
74+o.default = 1
75+o:depends("dns_caching", 1)
7376
74-dns_caching_dns = s:option(Value, "dns_caching_dns", translate("Upsteam DNS Server"))
75-dns_caching_dns.default = "114.114.114.114,114.114.115.115,223.5.5.5,223.6.6.6,180.76.76.76,119.29.29.29,119.28.28.28,1.2.4.8,210.2.4.8"
76-dns_caching_dns.description = translate("Muitiple DNS server can saperate with ','")
77-dns_caching_dns:depends("dns_caching", 1)
77+o = s:option(Value, "dns_caching_dns", translate("Upsteam DNS Server"))
78+o.default = "114.114.114.114,114.114.115.115,223.5.5.5,223.6.6.6,180.76.76.76,119.29.29.29,119.28.28.28,1.2.4.8,210.2.4.8"
79+o.description = translate("Muitiple DNS server can saperate with ','")
80+o:depends("dns_caching", 1)
7881
7982 return m
--- a/applications/luci-app-turboacc/root/etc/init.d/turboacc
+++ b/applications/luci-app-turboacc/root/etc/init.d/turboacc
@@ -9,7 +9,7 @@ extra_command "check_status" "Check running status of utils"
99
1010 restart_utils="true"
1111
12-inital_conf(){
12+initial_conf(){
1313 config_load "turboacc"
1414 config_get "sw_flow" "config" "sw_flow" "0"
1515 config_get "hw_flow" "config" "hw_flow" "0"
@@ -229,7 +229,7 @@ revert_dns() {
229229 }
230230
231231 start(){
232- inital_conf
232+ initial_conf
233233
234234 uci set firewall.@defaults[0].flow_offloading="${sw_flow}"
235235 uci set firewall.@defaults[0].flow_offloading_hw="${hw_flow}"
@@ -281,7 +281,7 @@ start(){
281281 }
282282
283283 stop(){
284- inital_conf
284+ initial_conf
285285
286286 uci set firewall.@defaults[0].flow_offloading="${sw_flow}"
287287 uci set firewall.@defaults[0].flow_offloading_hw="${hw_flow}"
Show on old repository browser