advanced.lua 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. local uci = luci.model.uci.cursor()
  2. local server_table = {}
  3. local function is_finded(e)
  4. return luci.sys.exec('type -t -p "%s"' % e) ~= "" and true or false
  5. end
  6. uci:foreach("shadowsocksr", "servers", function(s)
  7. if s.alias then
  8. server_table[s[".name"]] = "[%s]:%s" % {string.upper(s.v2ray_protocol or s.type), s.alias}
  9. elseif s.server and s.server_port then
  10. server_table[s[".name"]] = "[%s]:%s:%s" % {string.upper(s.v2ray_protocol or s.type), s.server, s.server_port}
  11. end
  12. end)
  13. local key_table = {}
  14. for key, _ in pairs(server_table) do
  15. table.insert(key_table, key)
  16. end
  17. table.sort(key_table)
  18. m = Map("shadowsocksr")
  19. -- [[ global ]]--
  20. s = m:section(TypedSection, "global", translate("Server failsafe auto swith and custom update settings"))
  21. s.anonymous = true
  22. -- o = s:option(Flag, "monitor_enable", translate("Enable Process Deamon"))
  23. -- o.rmempty = false
  24. -- o.default = "1"
  25. o = s:option(Flag, "enable_switch", translate("Enable Auto Switch"))
  26. o.rmempty = false
  27. o.default = "1"
  28. o = s:option(Value, "switch_time", translate("Switch check cycly(second)"))
  29. o.datatype = "uinteger"
  30. o:depends("enable_switch", "1")
  31. o.default = 667
  32. o = s:option(Value, "switch_timeout", translate("Check timout(second)"))
  33. o.datatype = "uinteger"
  34. o:depends("enable_switch", "1")
  35. o.default = 5
  36. o = s:option(Value, "switch_try_count", translate("Check Try Count"))
  37. o.datatype = "uinteger"
  38. o:depends("enable_switch", "1")
  39. o.default = 3
  40. o = s:option(Value, "gfwlist_url", translate("gfwlist Update url"))
  41. o:value("https://fastly.jsdelivr.net/gh/YW5vbnltb3Vz/domain-list-community@release/gfwlist.txt", translate("v2fly/domain-list-community"))
  42. o:value("https://fastly.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/gfw.txt", translate("Loyalsoldier/v2ray-rules-dat"))
  43. o:value("https://fastly.jsdelivr.net/gh/Loukky/gfwlist-by-loukky/gfwlist.txt", translate("Loukky/gfwlist-by-loukky"))
  44. o:value("https://fastly.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt", translate("gfwlist/gfwlist"))
  45. o.default = "https://fastly.jsdelivr.net/gh/YW5vbnltb3Vz/domain-list-community@release/gfwlist.txt"
  46. o = s:option(Value, "chnroute_url", translate("Chnroute Update url"))
  47. o:value("https://ispip.clang.cn/all_cn.txt", translate("Clang.CN"))
  48. o:value("https://ispip.clang.cn/all_cn_cidr.txt", translate("Clang.CN.CIDR"))
  49. o:value("https://fastly.jsdelivr.net/gh/gaoyifan/china-operator-ip@ip-lists/china.txt", translate("china-operator-ip"))
  50. o.default = "https://ispip.clang.cn/all_cn.txt"
  51. o = s:option(Flag, "netflix_enable", translate("Enable Netflix Mode"))
  52. o.rmempty = false
  53. o = s:option(Value, "nfip_url", translate("nfip_url"))
  54. o:value("https://fastly.jsdelivr.net/gh/QiuSimons/Netflix_IP/NF_only.txt", translate("Netflix IP Only"))
  55. o:value("https://fastly.jsdelivr.net/gh/QiuSimons/Netflix_IP/getflix.txt", translate("Netflix and AWS"))
  56. o.default = "https://fastly.jsdelivr.net/gh/QiuSimons/Netflix_IP/NF_only.txt"
  57. o.description = translate("Customize Netflix IP Url")
  58. o:depends("netflix_enable", "1")
  59. o = s:option(ListValue, "shunt_dns_mode", translate("DNS Query Mode For Shunt Mode"))
  60. o:value("1", translate("Use DNS2SOCKS query and cache"))
  61. if is_finded("mosdns") then
  62. o:value("2", translate("Use MOSDNS query"))
  63. end
  64. o:depends("netflix_enable", "1")
  65. o.default = 1
  66. o = s:option(Value, "shunt_dnsserver", translate("Anti-pollution DNS Server For Shunt Mode"))
  67. o:value("8.8.4.4:53", translate("Google Public DNS (8.8.4.4)"))
  68. o:value("8.8.8.8:53", translate("Google Public DNS (8.8.8.8)"))
  69. o:value("208.67.222.222:53", translate("OpenDNS (208.67.222.222)"))
  70. o:value("208.67.220.220:53", translate("OpenDNS (208.67.220.220)"))
  71. o:value("209.244.0.3:53", translate("Level 3 Public DNS (209.244.0.3)"))
  72. o:value("209.244.0.4:53", translate("Level 3 Public DNS (209.244.0.4)"))
  73. o:value("4.2.2.1:53", translate("Level 3 Public DNS (4.2.2.1)"))
  74. o:value("4.2.2.2:53", translate("Level 3 Public DNS (4.2.2.2)"))
  75. o:value("4.2.2.3:53", translate("Level 3 Public DNS (4.2.2.3)"))
  76. o:value("4.2.2.4:53", translate("Level 3 Public DNS (4.2.2.4)"))
  77. o:value("1.1.1.1:53", translate("Cloudflare DNS (1.1.1.1)"))
  78. o:depends("shunt_dns_mode", "1")
  79. o.description = translate("Custom DNS Server format as IP:PORT (default: 8.8.4.4:53)")
  80. o.datatype = "ip4addrport"
  81. o = s:option(ListValue, "shunt_mosdns_dnsserver", translate("Anti-pollution DNS Server"))
  82. o:value("tcp://8.8.4.4:53,tcp://8.8.8.8:53", translate("Google Public DNS"))
  83. o:value("tcp://208.67.222.222:53,tcp://208.67.220.220:53", translate("OpenDNS"))
  84. o:value("tcp://209.244.0.3:53,tcp://209.244.0.4:53", translate("Level 3 Public DNS-1 (209.244.0.3-4)"))
  85. o:value("tcp://4.2.2.1:53,tcp://4.2.2.2:53", translate("Level 3 Public DNS-2 (4.2.2.1-2)"))
  86. o:value("tcp://4.2.2.3:53,tcp://4.2.2.4:53", translate("Level 3 Public DNS-3 (4.2.2.3-4)"))
  87. o:value("tcp://1.1.1.1:53,tcp://1.0.0.1:53", translate("Cloudflare DNS"))
  88. o:depends("shunt_dns_mode", "2")
  89. o.description = translate("Custom DNS Server for mosdns")
  90. o = s:option(Flag, "shunt_mosdns_ipv6", translate("Disable IPv6 In MOSDNS Query Mode (Shunt Mode)"))
  91. o:depends("shunt_dns_mode", "2")
  92. o.rmempty = false
  93. o.default = "0"
  94. o = s:option(Flag, "apple_optimization", translate("Apple domains optimization"), translate("For Apple domains equipped with Chinese mainland CDN, always responsive to Chinese CDN IP addresses"))
  95. o.rmempty = false
  96. o.default = "1"
  97. o = s:option(Flag, "adblock", translate("Enable adblock"))
  98. o.rmempty = false
  99. o = s:option(Value, "adblock_url", translate("adblock_url"))
  100. o:value("https://raw.githubusercontent.com/neodevpro/neodevhost/master/lite_dnsmasq.conf", translate("NEO DEV HOST Lite"))
  101. o:value("https://raw.githubusercontent.com/neodevpro/neodevhost/master/dnsmasq.conf", translate("NEO DEV HOST Full"))
  102. o:value("https://anti-ad.net/anti-ad-for-dnsmasq.conf", translate("anti-AD"))
  103. o.default = "https://raw.githubusercontent.com/neodevpro/neodevhost/master/lite_dnsmasq.conf"
  104. o:depends("adblock", "1")
  105. o.description = translate("Support AdGuardHome and DNSMASQ format list")
  106. o = s:option(Button, "reset", translate("Reset to defaults"))
  107. o.rawhtml = true
  108. o.template = "shadowsocksr/reset"
  109. -- [[ SOCKS5 Proxy ]]--
  110. s = m:section(TypedSection, "socks5_proxy", translate("Global SOCKS5 Proxy Server"))
  111. s.anonymous = true
  112. o = s:option(ListValue, "server", translate("Server"))
  113. o:value("nil", translate("Disable"))
  114. o:value("same", translate("Same as Global Server"))
  115. for _, key in pairs(key_table) do
  116. o:value(key, server_table[key])
  117. end
  118. o.default = "nil"
  119. o.rmempty = false
  120. o = s:option(Value, "local_port", translate("Local Port"))
  121. o.datatype = "port"
  122. o.default = 1080
  123. o.rmempty = false
  124. -- [[ fragmen Settings ]]--
  125. if is_finded("xray") then
  126. s = m:section(TypedSection, "global_xray_fragment", translate("Xray Fragment Settings"))
  127. s.anonymous = true
  128. o = s:option(Flag, "fragment", translate("Fragment"), translate("TCP fragments, which can deceive the censorship system in some cases, such as bypassing SNI blacklists."))
  129. o.default = 0
  130. o = s:option(ListValue, "fragment_packets", translate("Fragment Packets"), translate("\"1-3\" is for segmentation at TCP layer, applying to the beginning 1 to 3 data writes by the client. \"tlshello\" is for TLS client hello packet fragmentation."))
  131. o.default = "tlshello"
  132. o:value("tlshello", "tlshello")
  133. o:value("1-2", "1-2")
  134. o:value("1-3", "1-3")
  135. o:value("1-5", "1-5")
  136. o:depends("fragment", true)
  137. o = s:option(Value, "fragment_length", translate("Fragment Length"), translate("Fragmented packet length (byte)"))
  138. o.default = "100-200"
  139. o:depends("fragment", true)
  140. o = s:option(Value, "fragment_interval", translate("Fragment Interval"), translate("Fragmentation interval (ms)"))
  141. o.default = "10-20"
  142. o:depends("fragment", true)
  143. o = s:option(Flag, "noise", translate("Noise"), translate("UDP noise, Under some circumstances it can bypass some UDP based protocol restrictions."))
  144. o.default = 0
  145. s = m:section(TypedSection, "xray_noise_packets", translate("Xray Noise Packets"))
  146. s.description = translate(
  147. "<font style='color:red'>" .. translate("To send noise packets, select \"Noise\" in Xray Settings.") .. "</font>" ..
  148. "<br/><font><b>" .. translate("For specific usage, see: ") .. "</b></font>" ..
  149. "<a href='https://xtls.github.io/config/outbounds/freedom.html' target='_blank'>" ..
  150. "<font style='color:green'><b>" .. translate("Click to the page") .. "</b></font></a>")
  151. s.template = "cbi/tblsection"
  152. s.sortable = true
  153. s.anonymous = true
  154. s.addremove = true
  155. s.remove = function(self, section)
  156. for k, v in pairs(self.children) do
  157. v.rmempty = true
  158. v.validate = nil
  159. end
  160. TypedSection.remove(self, section)
  161. end
  162. o = s:option(Flag, "enabled", translate("Enable"))
  163. o.default = 1
  164. o.rmempty = false
  165. o = s:option(ListValue, "type", translate("Type"))
  166. o.default = "base64"
  167. o:value("rand", "rand")
  168. o:value("str", "str")
  169. o:value("base64", "base64")
  170. o = s:option(Value, "domainStrategy", translate("Domain Strategy"))
  171. o.default = "UseIP"
  172. o:value("AsIs", "AsIs")
  173. o:value("UseIP", "UseIP")
  174. o:value("UseIPv4", "UseIPv4")
  175. o:value("ForceIP", "ForceIP")
  176. o:value("ForceIPv4", "ForceIPv4")
  177. o.rmempty = false
  178. o = s:option(Value, "packet", translate("Packet"))
  179. o.datatype = "minlength(1)"
  180. o.rmempty = false
  181. o = s:option(Value, "delay", translate("Delay (ms)"))
  182. o.datatype = "or(uinteger,portrange)"
  183. o.rmempty = false
  184. end
  185. return m