luci-app-shadowsocks-libev: tweak list of redir instances
authorYousong Zhou <yszhou4tech@gmail.com>
Tue, 22 Aug 2017 01:50:10 +0000 (09:50 +0800)
committerYousong Zhou <yszhou4tech@gmail.com>
Tue, 22 Aug 2017 12:19:49 +0000 (20:19 +0800)
 - Skip disabled ones
 - Allow empty value

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
applications/luci-app-shadowsocks-libev/luasrc/model/shadowsocks-libev.lua

index 650ff6356e457a79a2abbf10a2155ad69dca3b41..e2a07adae185007626d546f2bec073cbc35a8f02 100644 (file)
@@ -23,13 +23,16 @@ end
 
 function values_redir(o, xmode)
        o.map.uci.foreach("shadowsocks-libev", "ss_redir", function(sdata)
+               local disabled = ucival_to_bool(sdata["disabled"])
                local sname = sdata[".name"]
                local mode = sdata["mode"] or "tcp_only"
-               if mode and mode:find(xmode) then
+               if not disabled and mode:find(xmode) then
                        local desc = "%s - %s" % {sname, mode}
                        o:value(sname, desc)
                end
        end)
+       o:value("", "<unset>")
+       o.default = ""
 end
 
 function values_serverlist(o)