luci-app-shadowsocks-libev: support for option dst_forward_recentrst 1323/head
authorYousong Zhou <yszhou4tech@gmail.com>
Mon, 21 Aug 2017 14:58:40 +0000 (22:58 +0800)
committerYousong Zhou <yszhou4tech@gmail.com>
Tue, 22 Aug 2017 12:19:50 +0000 (20:19 +0800)
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
applications/luci-app-shadowsocks-libev/luasrc/model/cbi/shadowsocks-libev/rules.lua

index 1e2a491bcbf80915c53aca2ee660106523dd21f7..4a01bed24798c9cced771199809b4e786ecfd4ba 100644 (file)
@@ -88,4 +88,22 @@ o = s:taboption('dst', ListValue, "dst_default",
        translate("Default action for packets whose dst address do not match any of the dst ip list"))
 ss.values_actions(o)
 
+local installed = os.execute("iptables -m recent -h &>/dev/null") == 0
+if installed then
+       o = s:taboption('dst', Flag, "dst_forward_recentrst")
+else
+       m:set('ss_rules', 'dst_forward_recentrst', "0")
+       o = s:taboption("dst", Button, "_install")
+       o.inputtitle = translate("Install package iptables-mod-conntrack-extra")
+       o.inputstyle = "apply"
+       o.write = function()
+               return luci.http.redirect(
+                       luci.dispatcher.build_url("admin/system/packages") ..
+                       "?submit=1&install=iptables-mod-conntrack-extra"
+               )
+       end
+end
+o.title = translate("Forward recentrst")
+o.description = translate("Forward those packets whose dst have recently sent to us multiple tcp-rst")
+
 return m