LuCI - OpenWrt Configuration Interface
Revisão | e50588790ab4d256e659068c7338f416d241dc61 (tree) |
---|---|
Hora | 2022-05-23 13:16:56 |
Autor | Tianling Shen <cnsztl@immo...> |
Commiter | Tianling Shen |
luci-app-turboacc: cleanup cbi code
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
(cherry picked from commit 6c728bf693806e1df786b7c0e79880726d189480)
@@ -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 | |
2 | 5 | |
3 | 6 | m = Map("turboacc") |
4 | 7 | m.title = translate("Turbo ACC Acceleration Settings") |
@@ -10,70 +13,70 @@ s = m:section(TypedSection, "turboacc", "") | ||
10 | 13 | s.addremove = false |
11 | 14 | s.anonymous = true |
12 | 15 | |
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) | |
19 | 21 | |
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 | |
25 | 28 | end |
26 | 29 | |
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) | |
33 | 35 | |
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) | |
38 | 40 | |
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 | |
44 | 47 | end |
45 | 48 | |
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") | |
50 | 53 | end |
51 | 54 | |
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") | |
56 | 59 | end |
57 | 60 | |
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") | |
62 | 65 | |
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")) | |
67 | 70 | 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")) | |
70 | 73 | 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) | |
73 | 76 | |
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) | |
78 | 81 | |
79 | 82 | return m |
@@ -9,7 +9,7 @@ extra_command "check_status" "Check running status of utils" | ||
9 | 9 | |
10 | 10 | restart_utils="true" |
11 | 11 | |
12 | -inital_conf(){ | |
12 | +initial_conf(){ | |
13 | 13 | config_load "turboacc" |
14 | 14 | config_get "sw_flow" "config" "sw_flow" "0" |
15 | 15 | config_get "hw_flow" "config" "hw_flow" "0" |
@@ -229,7 +229,7 @@ revert_dns() { | ||
229 | 229 | } |
230 | 230 | |
231 | 231 | start(){ |
232 | - inital_conf | |
232 | + initial_conf | |
233 | 233 | |
234 | 234 | uci set firewall.@defaults[0].flow_offloading="${sw_flow}" |
235 | 235 | uci set firewall.@defaults[0].flow_offloading_hw="${hw_flow}" |
@@ -281,7 +281,7 @@ start(){ | ||
281 | 281 | } |
282 | 282 | |
283 | 283 | stop(){ |
284 | - inital_conf | |
284 | + initial_conf | |
285 | 285 | |
286 | 286 | uci set firewall.@defaults[0].flow_offloading="${sw_flow}" |
287 | 287 | uci set firewall.@defaults[0].flow_offloading_hw="${hw_flow}" |