server.lua 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. local m, sec, o
  6. local shadowsocksr = "shadowsocksr"
  7. local encrypt_methods = {
  8. "table",
  9. "rc4",
  10. "rc4-md5",
  11. "rc4-md5-6",
  12. "aes-128-cfb",
  13. "aes-192-cfb",
  14. "aes-256-cfb",
  15. "aes-128-ctr",
  16. "aes-192-ctr",
  17. "aes-256-ctr",
  18. "bf-cfb",
  19. "camellia-128-cfb",
  20. "camellia-192-cfb",
  21. "camellia-256-cfb",
  22. "cast5-cfb",
  23. "des-cfb",
  24. "idea-cfb",
  25. "rc2-cfb",
  26. "seed-cfb",
  27. "salsa20",
  28. "chacha20",
  29. "chacha20-ietf",
  30. }
  31. local protocol = {
  32. "origin",
  33. "verify_deflate",
  34. "auth_sha1_v4",
  35. "auth_aes128_sha1",
  36. "auth_aes128_md5",
  37. "auth_chain_a",
  38. }
  39. obfs = {
  40. "plain",
  41. "http_simple",
  42. "http_post",
  43. "random_head",
  44. "tls1.2_ticket_auth",
  45. "tls1.2_ticket_fastauth",
  46. }
  47. m = Map(shadowsocksr)
  48. -- [[ Global Setting ]]--
  49. sec = m:section(TypedSection, "server_global", translate("Global Setting"))
  50. sec.anonymous = true
  51. o = sec:option(Flag, "enable_server", translate("Enable Server"))
  52. o.rmempty = false
  53. -- [[ Server Setting ]]--
  54. sec = m:section(TypedSection, "server_config", translate("Server Setting"))
  55. sec.anonymous = true
  56. sec.addremove = true
  57. sec.template = "cbi/tblsection"
  58. sec.extedit = luci.dispatcher.build_url("admin/services/shadowsocksr/server/%s")
  59. function sec.create(...)
  60. local sid = TypedSection.create(...)
  61. if sid then
  62. luci.http.redirect(sec.extedit % sid)
  63. return
  64. end
  65. end
  66. o = sec:option(Flag, "enable", translate("Enable"))
  67. function o.cfgvalue(...)
  68. return Value.cfgvalue(...) or translate("0")
  69. end
  70. o.rmempty = false
  71. o = sec:option(DummyValue, "type", translate("Server Type"))
  72. function o.cfgvalue(...)
  73. return Value.cfgvalue(...) or "ssr"
  74. end
  75. o = sec:option(DummyValue, "server_port", translate("Server Port"))
  76. function o.cfgvalue(...)
  77. return Value.cfgvalue(...) or "-"
  78. end
  79. o = sec:option(DummyValue, "username", translate("Username"))
  80. function o.cfgvalue(...)
  81. return Value.cfgvalue(...) or "-"
  82. end
  83. o = sec:option(DummyValue, "encrypt_method", translate("Encrypt Method"))
  84. function o.cfgvalue(...)
  85. local v = Value.cfgvalue(...)
  86. return v and v:upper() or "-"
  87. end
  88. o = sec:option(DummyValue, "protocol", translate("Protocol"))
  89. function o.cfgvalue(...)
  90. return Value.cfgvalue(...) or "-"
  91. end
  92. o = sec:option(DummyValue, "obfs", translate("Obfs"))
  93. function o.cfgvalue(...)
  94. return Value.cfgvalue(...) or "-"
  95. end
  96. return m