control.lua 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. local m, s, o
  2. local NXFS = require "nixio.fs"
  3. m = Map("shadowsocksr", translate("IP black-and-white list"))
  4. s = m:section(TypedSection, "access_control")
  5. s.anonymous = true
  6. -- Part of WAN
  7. s:tab("wan_ac", translate("WAN IP AC"))
  8. o = s:taboption("wan_ac", DynamicList, "wan_bp_ips", translate("WAN White List IP"))
  9. o.datatype = "ip4addr"
  10. o = s:taboption("wan_ac", DynamicList, "wan_fw_ips", translate("WAN Force Proxy IP"))
  11. o.datatype = "ip4addr"
  12. -- Part of LAN
  13. s:tab("lan_ac", translate("LAN IP AC"))
  14. o = s:taboption("lan_ac", ListValue, "lan_ac_mode", translate("LAN Access Control"))
  15. o:value("0", translate("Disable"))
  16. o:value("w", translate("Allow listed only"))
  17. o:value("b", translate("Allow all except listed"))
  18. o.rmempty = false
  19. o = s:taboption("lan_ac", DynamicList, "lan_ac_ips", translate("LAN Host List"))
  20. o.datatype = "ipaddr"
  21. luci.ip.neighbors({ family = 4 }, function(entry)
  22. if entry.reachable then
  23. o:value(entry.dest:string())
  24. end
  25. end)
  26. o:depends("lan_ac_mode", "w")
  27. o:depends("lan_ac_mode", "b")
  28. o = s:taboption("lan_ac", DynamicList, "lan_bp_ips", translate("LAN Bypassed Host List"))
  29. o.datatype = "ipaddr"
  30. luci.ip.neighbors({ family = 4 }, function(entry)
  31. if entry.reachable then
  32. o:value(entry.dest:string())
  33. end
  34. end)
  35. o = s:taboption("lan_ac", DynamicList, "lan_fp_ips", translate("LAN Force Proxy Host List"))
  36. o.datatype = "ipaddr"
  37. luci.ip.neighbors({ family = 4 }, function(entry)
  38. if entry.reachable then
  39. o:value(entry.dest:string())
  40. end
  41. end)
  42. o = s:taboption("lan_ac", DynamicList, "lan_gm_ips", translate("Game Mode Host List"))
  43. o.datatype = "ipaddr"
  44. luci.ip.neighbors({ family = 4 }, function(entry)
  45. if entry.reachable then
  46. o:value(entry.dest:string())
  47. end
  48. end)
  49. -- Part of Self
  50. -- s:tab("self_ac", translate("Router Self AC"))
  51. -- o = s:taboption("self_ac",ListValue, "router_proxy", translate("Router Self Proxy"))
  52. -- o:value("1", translatef("Normal Proxy"))
  53. -- o:value("0", translatef("Bypassed Proxy"))
  54. -- o:value("2", translatef("Forwarded Proxy"))
  55. -- o.rmempty = false
  56. s:tab("esc", translate("Bypass Domain List"))
  57. local escconf = "/etc/config/white.list"
  58. o = s:taboption("esc", TextValue, "escconf")
  59. o.rows = 13
  60. o.wrap = "off"
  61. o.rmempty = true
  62. o.cfgvalue = function(self, section)
  63. return NXFS.readfile(escconf) or ""
  64. end
  65. o.write = function(self, section, value)
  66. NXFS.writefile(escconf, value:gsub("\r\n", "\n"))
  67. end
  68. o.remove = function(self, section, value)
  69. NXFS.writefile(escconf, "")
  70. end
  71. s:tab("block", translate("Black Domain List"))
  72. local blockconf = "/etc/config/black.list"
  73. o = s:taboption("block", TextValue, "blockconf")
  74. o.rows = 13
  75. o.wrap = "off"
  76. o.rmempty = true
  77. o.cfgvalue = function(self, section)
  78. return NXFS.readfile(blockconf) or " "
  79. end
  80. o.write = function(self, section, value)
  81. NXFS.writefile(blockconf, value:gsub("\r\n", "\n"))
  82. end
  83. o.remove = function(self, section, value)
  84. NXFS.writefile(blockconf, "")
  85. end
  86. s:tab("netflix", translate("Netflix Domain List"))
  87. local netflixconf = "/etc/config/netflix.list"
  88. o = s:taboption("netflix", TextValue, "netflixconf")
  89. o.rows = 13
  90. o.wrap = "off"
  91. o.rmempty = true
  92. o.cfgvalue = function(self, section)
  93. return NXFS.readfile(netflixconf) or " "
  94. end
  95. o.write = function(self, section, value)
  96. NXFS.writefile(netflixconf, value:gsub("\r\n", "\n"))
  97. end
  98. o.remove = function(self, section, value)
  99. NXFS.writefile(netflixconf, "")
  100. end
  101. s:tab("netflixip", translate("Netflix IP List"))
  102. local netflixipconf = "/etc/config/netflixip.list"
  103. o = s:taboption("netflixip", TextValue, "netflixipconf")
  104. o.rows = 13
  105. o.wrap = "off"
  106. o.rmempty = true
  107. o.cfgvalue = function(self, section)
  108. return NXFS.readfile(netflixipconf) or " "
  109. end
  110. o.write = function(self, section, value)
  111. NXFS.writefile(netflixipconf, value:gsub("\r\n", "\n"))
  112. end
  113. o.remove = function(self, section, value)
  114. NXFS.writefile(netflixipconf, "")
  115. end
  116. return m