1 -- Copyright 2017 Yousong Zhou <yszhou4tech@gmail.com>
2 -- Licensed to the public under the Apache License 2.0.
4 local ss = require("luci.model.shadowsocks-libev")
8 m = Map("shadowsocks-libev",
9 translate("Redir Rules"),
10 translate("On this page you can configure how traffics are to be \
11 forwarded to ss-redir instances. \
12 If enabled, packets will first have their source ip addresses checked \
13 against <em>Src ip bypass</em>, <em>Src ip forward</em>, \
14 <em>Src ip checkdst</em> and if none matches <em>Src default</em> \
15 will give the default action to be taken. \
16 If the prior check results in action <em>checkdst</em>, packets will continue \
17 to have their destination addresses checked."))
19 local sdata = m:get('ss_rules')
21 m:set('ss_rules', nil, 'ss_rules')
22 m:set('ss_rules', 'disabled', true)
25 s = m:section(NamedSection, "ss_rules", "ss_rules")
26 s:tab("general", translate("General Settings"))
27 s:tab("srcip", translate("Source Settings"))
28 s:tab("dstip", translate("Destination Settings"))
30 s:taboption('general', Flag, "disabled", translate("Disable"))
31 ss.option_install_package(s, 'general')
33 o = s:taboption('general', ListValue, "redir_tcp",
34 translate("ss-redir for TCP"))
35 ss.values_redir(o, 'tcp')
36 o = s:taboption('general', ListValue, "redir_udp",
37 translate("ss-redir for UDP"))
38 ss.values_redir(o, 'udp')
40 o = s:taboption('general', ListValue, "local_default",
41 translate("Local-out default"),
42 translate("Default action for locally generated TCP packets"))
44 o = s:taboption('general', DynamicList, "ifnames",
45 translate("Ingress interfaces"),
46 translate("Only apply rules on packets from these network interfaces"))
48 s:taboption('general', Value, "ipt_args",
49 translate("Extra arguments"),
50 translate("Passes additional arguments to iptables. Use with care!"))
52 s:taboption('srcip', DynamicList, "src_ips_bypass",
53 translate("Src ip bypass"),
54 translate("Bypass redir action for packets with source addresses in this list"))
55 s:taboption('srcip', DynamicList, "src_ips_forward",
56 translate("Src ip forward"),
57 translate("Go through redir action for packets with source addresses in this list"))
58 s:taboption('srcip', DynamicList, "src_ips_checkdst",
59 translate("Src ip checkdst"),
60 translate("Continue to have dst address checked for packets with source addresses in this list"))
61 o = s:taboption('srcip', ListValue, "src_default",
62 translate("Src default"),
63 translate("Default action for packets whose source addresses do not match any of the source ip list"))
66 s:taboption('dstip', DynamicList, "dst_ips_bypass",
67 translate("Dst ip bypass"),
68 translate("Bypass redir action for packets with destination addresses in this list"))
69 s:taboption('dstip', DynamicList, "dst_ips_forward",
70 translate("Dst ip forward"),
71 translate("Go through redir action for packets with destination addresses in this list"))
73 o = s:taboption('dstip', FileBrowser, "dst_ips_bypass_file",
74 translate("Dst ip bypass file"),
75 translate("File containing ip addresses for the purposes as with <em>Dst ip bypass</em>"))
77 s:taboption('dstip', FileBrowser, "dst_ips_forward_file",
78 translate("Dst ip forward file"),
79 translate("File containing ip addresses for the purposes as with <em>Dst ip forward</em>"))
81 o = s:taboption('dstip', ListValue, "dst_default",
82 translate("Dst default"),
83 translate("Default action for packets whose destination addresses do not match any of the destination ip list"))