| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- require "luci.ip"
- require "nixio.fs"
- local m, s, o
- m = Map("shadowsocksr", translate("IP black-and-white list"))
- s = m:section(TypedSection, "access_control")
- s.anonymous = true
- -- Part of WAN
- s:tab("wan_ac", translate("WAN IP AC"))
- o = s:taboption("wan_ac", DynamicList, "wan_bp_ips", translate("WAN White List IP"))
- o.datatype = "ip4addr"
- o = s:taboption("wan_ac", DynamicList, "wan_fw_ips", translate("WAN Force Proxy IP"))
- o.datatype = "ip4addr"
- -- Part of LAN
- s:tab("lan_ac", translate("LAN IP AC"))
- o = s:taboption("lan_ac", ListValue, "lan_ac_mode", translate("LAN Access Control"))
- o:value("0", translate("Disable"))
- o:value("w", translate("Allow listed only"))
- o:value("b", translate("Allow all except listed"))
- o.rmempty = false
- o = s:taboption("lan_ac", DynamicList, "lan_ac_ips", translate("LAN Host List"))
- o.datatype = "ipaddr"
- luci.ip.neighbors({ family = 4 }, function(entry)
- if entry.reachable then
- o:value(entry.dest:string())
- end
- end)
- o:depends("lan_ac_mode", "w")
- o:depends("lan_ac_mode", "b")
- o = s:taboption("lan_ac", DynamicList, "lan_bp_ips", translate("LAN Bypassed Host List"))
- o.datatype = "ipaddr"
- luci.ip.neighbors({ family = 4 }, function(entry)
- if entry.reachable then
- o:value(entry.dest:string())
- end
- end)
- o = s:taboption("lan_ac", DynamicList, "lan_fp_ips", translate("LAN Force Proxy Host List"))
- o.datatype = "ipaddr"
- luci.ip.neighbors({ family = 4 }, function(entry)
- if entry.reachable then
- o:value(entry.dest:string())
- end
- end)
- o = s:taboption("lan_ac", DynamicList, "lan_gm_ips", translate("Game Mode Host List"))
- o.datatype = "ipaddr"
- luci.ip.neighbors({ family = 4 }, function(entry)
- if entry.reachable then
- o:value(entry.dest:string())
- end
- end)
- -- Part of Self
- -- s:tab("self_ac", translate("Router Self AC"))
- -- o = s:taboption("self_ac",ListValue, "router_proxy", translate("Router Self Proxy"))
- -- o:value("1", translatef("Normal Proxy"))
- -- o:value("0", translatef("Bypassed Proxy"))
- -- o:value("2", translatef("Forwarded Proxy"))
- -- o.rmempty = false
- s:tab("esc", translate("Bypass Domain List"))
- local escconf = "/etc/ssr/white.list"
- o = s:taboption("esc", TextValue, "escconf")
- o.rows = 13
- o.wrap = "off"
- o.rmempty = true
- o.cfgvalue = function(self, section)
- return nixio.fs.readfile(escconf) or ""
- end
- o.write = function(self, section, value)
- nixio.fs.writefile(escconf, value:gsub("\r\n", "\n"))
- end
- o.remove = function(self, section, value)
- nixio.fs.writefile(escconf, "")
- end
- s:tab("block", translate("Black Domain List"))
- local blockconf = "/etc/ssr/black.list"
- o = s:taboption("block", TextValue, "blockconf")
- o.rows = 13
- o.wrap = "off"
- o.rmempty = true
- o.cfgvalue = function(self, section)
- return nixio.fs.readfile(blockconf) or " "
- end
- o.write = function(self, section, value)
- nixio.fs.writefile(blockconf, value:gsub("\r\n", "\n"))
- end
- o.remove = function(self, section, value)
- nixio.fs.writefile(blockconf, "")
- end
- s:tab("netflix", translate("Netflix Domain List"))
- local netflixconf = "/etc/ssr/netflix.list"
- o = s:taboption("netflix", TextValue, "netflixconf")
- o.rows = 13
- o.wrap = "off"
- o.rmempty = true
- o.cfgvalue = function(self, section)
- return nixio.fs.readfile(netflixconf) or " "
- end
- o.write = function(self, section, value)
- nixio.fs.writefile(netflixconf, value:gsub("\r\n", "\n"))
- end
- o.remove = function(self, section, value)
- nixio.fs.writefile(netflixconf, "")
- end
- s:tab("netflixip", translate("Netflix IP List"))
- local netflixipconf = "/etc/ssr/netflixip.list"
- o = s:taboption("netflixip", TextValue, "netflixipconf")
- o.rows = 13
- o.wrap = "off"
- o.rmempty = true
- o.cfgvalue = function(self, section)
- return nixio.fs.readfile(netflixipconf) or " "
- end
- o.write = function(self, section, value)
- nixio.fs.writefile(netflixipconf, value:gsub("\r\n", "\n"))
- end
- o.remove = function(self, section, value)
- nixio.fs.writefile(netflixipconf, "")
- end
- return m
|