server-config.lua 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. -- Copyright (C) 2017 yushi studio <[email protected]>
  2. -- Licensed to the public under the GNU General Public License v3.
  3. require "luci.http"
  4. require "luci.dispatcher"
  5. require "nixio.fs"
  6. local m, s, o
  7. local shadowsocksr = "shadowsocksr"
  8. local sid = arg[1]
  9. local encrypt_methods = {
  10. "rc4-md5",
  11. "rc4-md5-6",
  12. "rc4",
  13. "table",
  14. "aes-128-cfb",
  15. "aes-192-cfb",
  16. "aes-256-cfb",
  17. "aes-128-ctr",
  18. "aes-192-ctr",
  19. "aes-256-ctr",
  20. "bf-cfb",
  21. "camellia-128-cfb",
  22. "camellia-192-cfb",
  23. "camellia-256-cfb",
  24. "cast5-cfb",
  25. "des-cfb",
  26. "idea-cfb",
  27. "rc2-cfb",
  28. "seed-cfb",
  29. "salsa20",
  30. "chacha20",
  31. "chacha20-ietf",
  32. }
  33. local protocol = {
  34. "origin",
  35. }
  36. obfs = {
  37. "plain",
  38. "http_simple",
  39. "http_post",
  40. }
  41. m = Map(shadowsocksr, translate("Edit ShadowSocksR Server"))
  42. m.redirect = luci.dispatcher.build_url("admin/services/shadowsocksr/server")
  43. if m.uci:get(shadowsocksr, sid) ~= "server_config" then
  44. luci.http.redirect(m.redirect)
  45. return
  46. end
  47. -- [[ Server Setting ]]--
  48. s = m:section(NamedSection, sid, "server_config")
  49. s.anonymous = true
  50. s.addremove = false
  51. o = s:option(Flag, "enable", translate("Enable"))
  52. o.default = 1
  53. o.rmempty = false
  54. o = s:option(ListValue, "type", translate("Server Type"))
  55. o:value("socks5", translate("Socks5"))
  56. if nixio.fs.access("/usr/bin/ss-server") then
  57. o:value("ssr", translate("ShadowsocksR"))
  58. end
  59. o.default = "socks5"
  60. o = s:option(Value, "server_port", translate("Server Port"))
  61. o.datatype = "port"
  62. o.default = 8388
  63. o.rmempty = false
  64. o = s:option(Value, "timeout", translate("Connection Timeout"))
  65. o.datatype = "uinteger"
  66. o.default = 60
  67. o.rmempty = false
  68. o:depends("type", "ssr")
  69. o = s:option(Value, "username", translate("Username"))
  70. o.rmempty = false
  71. o:depends("type", "socks5")
  72. o = s:option(Value, "password", translate("Password"))
  73. o.password = true
  74. o.rmempty = false
  75. o = s:option(ListValue, "encrypt_method", translate("Encrypt Method"))
  76. for _, v in ipairs(encrypt_methods) do o:value(v) end
  77. o.rmempty = false
  78. o:depends("type", "ssr")
  79. o = s:option(ListValue, "protocol", translate("Protocol"))
  80. for _, v in ipairs(protocol) do o:value(v) end
  81. o.rmempty = false
  82. o:depends("type", "ssr")
  83. o = s:option(ListValue, "obfs", translate("Obfs"))
  84. for _, v in ipairs(obfs) do o:value(v) end
  85. o.rmempty = false
  86. o:depends("type", "ssr")
  87. o = s:option(Value, "obfs_param", translate("Obfs param(optional)"))
  88. o:depends("type", "ssr")
  89. o = s:option(Flag, "fast_open", translate("TCP Fast Open"))
  90. o.rmempty = false
  91. o:depends("type", "ssr")
  92. return m