shadowsocks-libev.lua 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. -- Copyright 2015 Jian Chang <aa65535@live.com>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local m, s, o, e, a
  4. if luci.sys.call("pidof ss-redir >/dev/null") == 0 then
  5. m = Map("shadowsocks-libev", translate("ShadowSocks-libev"), translate("ShadowSocks-libev is running"))
  6. else
  7. m = Map("shadowsocks-libev", translate("ShadowSocks-libev"), translate("ShadowSocks-libev is not running"))
  8. end
  9. e = {
  10. "table",
  11. "rc4",
  12. "rc4-md5",
  13. "aes-128-cfb",
  14. "aes-192-cfb",
  15. "aes-256-cfb",
  16. "bf-cfb",
  17. "camellia-128-cfb",
  18. "camellia-192-cfb",
  19. "camellia-256-cfb",
  20. "cast5-cfb",
  21. "des-cfb",
  22. "idea-cfb",
  23. "rc2-cfb",
  24. "seed-cfb",
  25. "salsa20",
  26. "chacha20",
  27. }
  28. -- Global Setting
  29. s = m:section(TypedSection, "shadowsocks-libev", translate("Global Setting"))
  30. s.anonymous = true
  31. o = s:option(Flag, "enable", translate("Enable"))
  32. o.default = 1
  33. o.rmempty = false
  34. o = s:option(Value, "server", translate("Server Address"))
  35. o.datatype = "ipaddr"
  36. o.rmempty = false
  37. o = s:option(Value, "server_port", translate("Server Port"))
  38. o.datatype = "port"
  39. o.rmempty = false
  40. o = s:option(Value, "local_port", translate("Local Port"))
  41. o.datatype = "port"
  42. o.default = 1080
  43. o.rmempty = false
  44. o = s:option(Value, "timeout", translate("Connection Timeout"))
  45. o.datatype = "uinteger"
  46. o.default = 60
  47. o.rmempty = false
  48. o = s:option(Value, "password", translate("Password"))
  49. o.password = true
  50. o.rmempty = false
  51. o = s:option(ListValue, "encrypt_method", translate("Encrypt Method"))
  52. for i,v in ipairs(e) do
  53. o:value(v)
  54. end
  55. o.rmempty = false
  56. o = s:option(Value, "ignore_list", translate("Ignore List"))
  57. o:value("/dev/null", translate("Disabled"))
  58. o.default = "/dev/null"
  59. o.rmempty = false
  60. -- UDP Relay
  61. s = m:section(TypedSection, "shadowsocks-libev", translate("UDP Relay"))
  62. s.anonymous = true
  63. o = s:option(ListValue, "udp_mode", translate("Relay Mode"))
  64. o:value("0", translate("Disabled"))
  65. o:value("1", translate("Enabled"))
  66. o:value("2", translate("Custom"))
  67. o.default = 0
  68. o.rmempty = false
  69. o = s:option(Value, "udp_server", translate("Server Address"))
  70. o.datatype = "ipaddr"
  71. o:depends("udp_mode", 2)
  72. o = s:option(Value, "udp_server_port", translate("Server Port"))
  73. o.datatype = "port"
  74. o:depends("udp_mode", 2)
  75. o = s:option(Value, "udp_local_port", translate("Local Port"))
  76. o.datatype = "port"
  77. o.default = 1081
  78. o:depends("udp_mode", 2)
  79. o = s:option(Value, "udp_timeout", translate("Connection Timeout"))
  80. o.datatype = "uinteger"
  81. o.default = 60
  82. o:depends("udp_mode", 2)
  83. o = s:option(Value, "udp_password", translate("Password"))
  84. o.password = true
  85. o:depends("udp_mode", 2)
  86. o = s:option(ListValue, "udp_encrypt_method", translate("Encrypt Method"))
  87. for i,v in ipairs(e) do
  88. o:value(v)
  89. end
  90. o:depends("udp_mode", 2)
  91. -- UDP Forward
  92. s = m:section(TypedSection, "shadowsocks-libev", translate("UDP Forward"))
  93. s.anonymous = true
  94. o = s:option(Flag, "tunnel_enable", translate("Enable"))
  95. o.default = 1
  96. o.rmempty = false
  97. o = s:option(Value, "tunnel_port", translate("UDP Local Port"))
  98. o.datatype = "port"
  99. o.default = 5300
  100. o = s:option(Value, "tunnel_forward", translate("Forwarding Tunnel"))
  101. o.default = "8.8.4.4:53"
  102. -- Access Control
  103. s = m:section(TypedSection, "shadowsocks-libev", translate("Access Control"))
  104. s.anonymous = true
  105. s:tab("lan_ac", translate("LAN"))
  106. o = s:taboption("lan_ac", ListValue, "lan_ac_mode", translate("Access Control"))
  107. o:value("0", translate("Disabled"))
  108. o:value("1", translate("Allow listed only"))
  109. o:value("2", translate("Allow all except listed"))
  110. o.default = 0
  111. o.rmempty = false
  112. a = luci.sys.net.arptable() or {}
  113. o = s:taboption("lan_ac", DynamicList, "lan_ac_ip", translate("LAN IP List"))
  114. o.datatype = "ipaddr"
  115. for i,v in ipairs(a) do
  116. o:value(v["IP address"])
  117. end
  118. s:tab("wan_ac", translate("WAN"))
  119. o = s:taboption("wan_ac", DynamicList, "wan_bp_ip", translate("Bypassed IP"))
  120. o.datatype = "ip4addr"
  121. o = s:taboption("wan_ac", DynamicList, "wan_fw_ip", translate("Forwarded IP"))
  122. o.datatype = "ip4addr"
  123. return m