server.lua 2.9 KB

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