advanced.lua 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. local shadowsocksr = "shadowsocksr"
  2. local uci = luci.model.uci.cursor()
  3. local server_table = {}
  4. uci:foreach(shadowsocksr, "servers", function(s)
  5. if s.alias then
  6. server_table[s[".name"]] = "[%s]:%s" %{string.upper(s.type), s.alias}
  7. elseif s.server and s.server_port then
  8. server_table[s[".name"]] = "[%s]:%s:%s" %{string.upper(s.type), s.server, s.server_port}
  9. end
  10. end)
  11. local key_table = {}
  12. for key,_ in pairs(server_table) do
  13. table.insert(key_table,key)
  14. end
  15. table.sort(key_table)
  16. m = Map("shadowsocksr")
  17. -- [[ global ]]--
  18. s = m:section(TypedSection, "global", translate("Server failsafe auto swith and custom update settings"))
  19. s.anonymous = true
  20. -- o = s:option(Flag, "monitor_enable", translate("Enable Process Deamon"))
  21. -- o.rmempty = false
  22. -- o.default = "1"
  23. o = s:option(Flag, "enable_switch", translate("Enable Auto Switch"))
  24. o.rmempty = false
  25. o.default = "1"
  26. o = s:option(Value, "switch_time", translate("Switch check cycly(second)"))
  27. o.datatype = "uinteger"
  28. o:depends("enable_switch", "1")
  29. o.default = 667
  30. o = s:option(Value, "switch_timeout", translate("Check timout(second)"))
  31. o.datatype = "uinteger"
  32. o:depends("enable_switch", "1")
  33. o.default = 5
  34. o = s:option(Value, "switch_try_count", translate("Check Try Count"))
  35. o.datatype = "uinteger"
  36. o:depends("enable_switch", "1")
  37. o.default = 3
  38. o = s:option(Flag, "adblock", translate("Enable adblock"))
  39. o.rmempty = false
  40. o = s:option(Value, "adblock_url", translate("adblock_url"))
  41. o:value("https://anti-ad.net/anti-ad-for-dnsmasq.conf", translate("anti-AD"))
  42. o.default = "https://anti-ad.net/anti-ad-for-dnsmasq.conf"
  43. o:depends("adblock", "1")
  44. o.description = translate("Support AdGuardHome and DNSMASQ format list")
  45. o = s:option(Value, "gfwlist_url", translate("gfwlist Update url"))
  46. o:value("https://cdn.jsdelivr.net/gh/Loukky/gfwlist-by-loukky/gfwlist.txt", translate("Loukky/gfwlist-by-loukky"))
  47. o:value("https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt", translate("gfwlist/gfwlist"))
  48. o.default = "https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt"
  49. o = s:option(Value, "chnroute_url", translate("Chnroute Update url"))
  50. o:value("https://ispip.clang.cn/all_cn.txt", translate("Clang.CN"))
  51. o:value("https://ispip.clang.cn/all_cn_cidr.txt", translate("Clang.CN.CIDR"))
  52. o.default = "https://ispip.clang.cn/all_cn.txt"
  53. o = s:option(Value, "nfip_url", translate("nfip_url"))
  54. o:value("https://cdn.jsdelivr.net/gh/QiuSimons/Netflix_IP/NF_only.txt", translate("Netflix IP Only"))
  55. o:value("https://cdn.jsdelivr.net/gh/QiuSimons/Netflix_IP/getflix.txt", translate("Netflix and AWS"))
  56. o.default = "https://cdn.jsdelivr.net/gh/QiuSimons/Netflix_IP/NF_only.txt"
  57. o.description = translate("Customize Netflix IP Url")
  58. -- [[ SOCKS5 Proxy ]]--
  59. s = m:section(TypedSection, "socks5_proxy", translate("Global SOCKS5 Proxy Server"))
  60. s.anonymous = true
  61. o = s:option(ListValue, "server", translate("Server"))
  62. o:value("nil", translate("Disable"))
  63. o:value("same", translate("Same as Global Server"))
  64. for _,key in pairs(key_table) do o:value(key,server_table[key]) end
  65. o.default = "nil"
  66. o.rmempty = false
  67. o = s:option(Value, "local_port", translate("Local Port"))
  68. o.datatype = "port"
  69. o.default = 1080
  70. o.rmempty = false
  71. return m