From f5ae714d9d7e33436613912c75fae6fc99c195ba Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Sun, 20 Aug 2017 02:19:02 +0800 Subject: [PATCH] luci-app-shadowsocks-libev: support ss_rules options: dst_default, ifnames Signed-off-by: Yousong Zhou --- .../model/cbi/shadowsocks-libev/rules.lua | 10 ++++++++- .../luasrc/model/shadowsocks-libev.lua | 21 +++++++++++-------- 2 files changed, 21 insertions(+), 10 deletions(-) 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 1a3dcb883..998579017 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 @@ -39,8 +39,12 @@ ss.values_redir(o, 'udp') o = s:taboption('general', ListValue, "local_default", translate("Local-out default"), - translate("Default action for locally generated packets")) + translate("Default action for locally generated TCP packets")) ss.values_actions(o) +o = s:taboption('general', DynamicList, "ifnames", + translate("Ingress interfaces"), + translate("Only apply rules on packets from these network interfaces")) +ss.values_ifnames(o) s:taboption('general', Value, "ipt_args", translate("Extra arguments"), translate("Passes additional arguments to iptables. Use with care!")) @@ -74,5 +78,9 @@ s:taboption('dstip', FileBrowser, "dst_ips_forward_file", translate("Dst ip forward file"), translate("File containing ip addresses for the purposes as with Dst ip forward")) o.datatype = "file" +o = s:taboption('dstip', ListValue, "dst_default", + translate("Dst default"), + translate("Default action for packets whose destination addresses do not match any of the destination ip list")) +ss.values_actions(o) return m 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 e1bde6008..650ff6356 100644 --- a/applications/luci-app-shadowsocks-libev/luasrc/model/shadowsocks-libev.lua +++ b/applications/luci-app-shadowsocks-libev/luasrc/model/shadowsocks-libev.lua @@ -14,8 +14,10 @@ module("luci.model.shadowsocks-libev", function(m) end) function values_actions(o) - for _, a in ipairs(actions) do - o:value(a) + o:value("bypass") + o:value("forward") + if o.option ~= "dst_default" then + o:value("checkdst") end end @@ -43,7 +45,6 @@ function values_serverlist(o) end function values_ipaddr(o) - local keys, vals = {}, {} for _, v in ipairs(nw:get_interfaces()) do for _, a in ipairs(v:ipaddrs()) do o:value(a:host():string(), '%s (%s)' %{ a:host(), v:shortname() }) @@ -51,6 +52,14 @@ function values_ipaddr(o) end end +function values_ifnames(o) + for _, v in ipairs(nw:get_interfaces()) do + if v.dev then + o:value(v.dev.name) + end + end +end + function options_client(s, tab) local o @@ -226,12 +235,6 @@ modes = { "udp_only", } -actions = { - "bypass", - "forward", - "checkdst", -} - methods = { -- aead "aes-128-gcm", -- 2.25.1