advanced.lua 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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, "adblock", translate("Enable adblock"))
  95. o.rmempty = false
  96. o = s:option(Value, "adblock_url", translate("adblock_url"))
  97. o:value("https://raw.githubusercontent.com/neodevpro/neodevhost/master/lite_dnsmasq.conf", translate("NEO DEV HOST Lite"))
  98. o:value("https://raw.githubusercontent.com/neodevpro/neodevhost/master/dnsmasq.conf", translate("NEO DEV HOST Full"))
  99. o:value("https://anti-ad.net/anti-ad-for-dnsmasq.conf", translate("anti-AD"))
  100. o.default = "https://raw.githubusercontent.com/neodevpro/neodevhost/master/lite_dnsmasq.conf"
  101. o:depends("adblock", "1")
  102. o.description = translate("Support AdGuardHome and DNSMASQ format list")
  103. o = s:option(Button, "reset", translate("Reset to defaults"))
  104. o.rawhtml = true
  105. o.template = "shadowsocksr/reset"
  106. -- [[ SOCKS5 Proxy ]]--
  107. s = m:section(TypedSection, "socks5_proxy", translate("Global SOCKS5 Proxy Server"))
  108. s.anonymous = true
  109. o = s:option(ListValue, "server", translate("Server"))
  110. o:value("nil", translate("Disable"))
  111. o:value("same", translate("Same as Global Server"))
  112. for _, key in pairs(key_table) do
  113. o:value(key, server_table[key])
  114. end
  115. o.default = "nil"
  116. o.rmempty = false
  117. o = s:option(Value, "local_port", translate("Local Port"))
  118. o.datatype = "port"
  119. o.default = 1080
  120. o.rmempty = false
  121. return m