From be77667225991e5965afc549ae94a148ea4246e1 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Sun, 13 Aug 2017 12:28:37 +0800 Subject: luci-app-shadowsocks-libev: add a ss_rules section if none exists When there is no ss_rules section, the "Redir Rules" tab will have empty form in the generated page. This is especialy the case when the shadowsocks-libev config is from an earlier version before 3.0.6-2 Signed-off-by: Yousong Zhou --- .../luasrc/model/cbi/shadowsocks-libev/rules.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'applications/luci-app-shadowsocks-libev') diff --git a/applications/luci-app-shadowsocks-libev/luasrc/model/cbi/shadowsocks-libev/rules.lua b/applications/luci-app-shadowsocks-libev/luasrc/model/cbi/shadowsocks-libev/rules.lua index fe5f9c31b8..5df59cb0ad 100644 --- a/applications/luci-app-shadowsocks-libev/luasrc/model/cbi/shadowsocks-libev/rules.lua +++ b/applications/luci-app-shadowsocks-libev/luasrc/model/cbi/shadowsocks-libev/rules.lua @@ -16,8 +16,13 @@ m = Map("shadowsocks-libev", If the prior check results in action checkdst, packets will continue \ to have their destination addresses checked.")) +local sdata = m:get('ss_rules') +if not sdata then + m:set('ss_rules', nil, 'ss_rules') + m:set('ss_rules', 'ss_rules', 'disabled', true) +end -s = m:section(NamedSection, "ss_rules", "ss-rules") +s = m:section(NamedSection, "ss_rules", "ss_rules") s:tab("general", translate("General Settings")) s:tab("srcip", translate("Source Settings")) s:tab("dstip", translate("Destination Settings")) -- cgit v1.2.3 From 0a2fa7b16f61f74cd6a9c3814e49ab237854765e Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Sun, 13 Aug 2017 12:34:46 +0800 Subject: luci-app-shadowsocks-libev: assume ss-redir has default mode tcp_only This is in accordance with the current actual implementation of ss-redir. Signed-off-by: Yousong Zhou --- .../luci-app-shadowsocks-libev/luasrc/model/shadowsocks-libev.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'applications/luci-app-shadowsocks-libev') diff --git a/applications/luci-app-shadowsocks-libev/luasrc/model/shadowsocks-libev.lua b/applications/luci-app-shadowsocks-libev/luasrc/model/shadowsocks-libev.lua index 0a14f33554..6608ee8d35 100644 --- a/applications/luci-app-shadowsocks-libev/luasrc/model/shadowsocks-libev.lua +++ b/applications/luci-app-shadowsocks-libev/luasrc/model/shadowsocks-libev.lua @@ -22,7 +22,7 @@ end function values_redir(o, xmode) o.map.uci.foreach("shadowsocks-libev", "ss_redir", function(sdata) local sname = sdata[".name"] - local mode = sdata["mode"] + local mode = sdata["mode"] or "tcp_only" if mode and mode:find(xmode) then local desc = "%s - %s" % {sname, mode} o:value(sname, desc) -- cgit v1.2.3