client-config.lua 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820
  1. -- Copyright (C) 2017 yushi studio <[email protected]> github.com/ywb94
  2. -- Licensed to the public under the GNU General Public License v3.
  3. require "nixio.fs"
  4. require "luci.sys"
  5. require "luci.http"
  6. require "luci.model.ipkg"
  7. local m, s, o
  8. local sid = arg[1]
  9. local uuid = luci.sys.exec("cat /proc/sys/kernel/random/uuid")
  10. local function is_finded(e)
  11. return luci.sys.exec('type -t -p "%s"' % e) ~= "" and true or false
  12. end
  13. local function is_installed(e)
  14. return luci.model.ipkg.installed(e)
  15. end
  16. local server_table = {}
  17. local encrypt_methods = {
  18. -- ssr
  19. "none",
  20. "table",
  21. "rc4",
  22. "rc4-md5-6",
  23. "rc4-md5",
  24. "aes-128-cfb",
  25. "aes-192-cfb",
  26. "aes-256-cfb",
  27. "aes-128-ctr",
  28. "aes-192-ctr",
  29. "aes-256-ctr",
  30. "bf-cfb",
  31. "camellia-128-cfb",
  32. "camellia-192-cfb",
  33. "camellia-256-cfb",
  34. "cast5-cfb",
  35. "des-cfb",
  36. "idea-cfb",
  37. "rc2-cfb",
  38. "seed-cfb",
  39. "salsa20",
  40. "chacha20",
  41. "chacha20-ietf"
  42. }
  43. local encrypt_methods_ss = {
  44. -- plain
  45. "none",
  46. "plain",
  47. -- aead
  48. "aes-128-gcm",
  49. "aes-192-gcm",
  50. "aes-256-gcm",
  51. "chacha20-ietf-poly1305",
  52. "xchacha20-ietf-poly1305",
  53. -- aead 2022
  54. "2022-blake3-aes-128-gcm",
  55. "2022-blake3-aes-256-gcm",
  56. "2022-blake3-chacha20-poly1305"
  57. --[[ stream
  58. "none",
  59. "plain",
  60. "table",
  61. "rc4",
  62. "rc4-md5",
  63. "aes-128-cfb",
  64. "aes-192-cfb",
  65. "aes-256-cfb",
  66. "aes-128-ctr",
  67. "aes-192-ctr",
  68. "aes-256-ctr",
  69. "bf-cfb",
  70. "camellia-128-cfb",
  71. "camellia-192-cfb",
  72. "camellia-256-cfb",
  73. "salsa20",
  74. "chacha20",
  75. "chacha20-ietf" ]]
  76. }
  77. local protocol = {
  78. -- ssr
  79. "origin",
  80. "verify_deflate",
  81. "auth_sha1_v4",
  82. "auth_aes128_sha1",
  83. "auth_aes128_md5",
  84. "auth_chain_a",
  85. "auth_chain_b",
  86. "auth_chain_c",
  87. "auth_chain_d",
  88. "auth_chain_e",
  89. "auth_chain_f"
  90. }
  91. local obfs = {
  92. -- ssr
  93. "plain",
  94. "http_simple",
  95. "http_post",
  96. "random_head",
  97. "tls1.2_ticket_auth"
  98. }
  99. local securitys = {
  100. -- vmess
  101. "auto",
  102. "none",
  103. "zero",
  104. "aes-128-gcm",
  105. "chacha20-poly1305"
  106. }
  107. local flows = {
  108. -- xtls
  109. "xtls-rprx-origin",
  110. "xtls-rprx-origin-udp443",
  111. "xtls-rprx-direct",
  112. "xtls-rprx-direct-udp443",
  113. "xtls-rprx-splice",
  114. "xtls-rprx-splice-udp443"
  115. }
  116. local tls_flows = {
  117. -- tls
  118. "xtls-rprx-vision",
  119. "xtls-rprx-vision-udp443"
  120. }
  121. m = Map("shadowsocksr", translate("Edit ShadowSocksR Server"))
  122. m.redirect = luci.dispatcher.build_url("admin/services/shadowsocksr/servers")
  123. if m.uci:get("shadowsocksr", sid) ~= "servers" then
  124. luci.http.redirect(m.redirect)
  125. return
  126. end
  127. -- [[ Servers Setting ]]--
  128. s = m:section(NamedSection, sid, "servers")
  129. s.anonymous = true
  130. s.addremove = false
  131. o = s:option(DummyValue, "ssr_url", "SS/SSR/V2RAY/TROJAN URL")
  132. o.rawhtml = true
  133. o.template = "shadowsocksr/ssrurl"
  134. o.value = sid
  135. o = s:option(ListValue, "type", translate("Server Node Type"))
  136. if is_finded("xray") or is_finded("v2ray") then
  137. o:value("v2ray", translate("V2Ray/XRay"))
  138. end
  139. if is_finded("ssr-redir") then
  140. o:value("ssr", translate("ShadowsocksR"))
  141. end
  142. if is_finded("sslocal") or is_finded("ss-redir") then
  143. o:value("ss", translate("Shadowsocks New Version"))
  144. end
  145. if is_finded("trojan") then
  146. o:value("trojan", translate("Trojan"))
  147. end
  148. if is_finded("naive") then
  149. o:value("naiveproxy", translate("NaiveProxy"))
  150. end
  151. if is_finded("hysteria") then
  152. o:value("hysteria", translate("Hysteria"))
  153. end
  154. if is_finded("ipt2socks") then
  155. o:value("socks5", translate("Socks5"))
  156. end
  157. if is_finded("redsocks2") then
  158. o:value("tun", translate("Network Tunnel"))
  159. end
  160. o.description = translate("Using incorrect encryption mothod may causes service fail to start")
  161. o = s:option(Value, "alias", translate("Alias(optional)"))
  162. o = s:option(ListValue, "iface", translate("Network interface to use"))
  163. for _, e in ipairs(luci.sys.net.devices()) do
  164. if e ~= "lo" then
  165. o:value(e)
  166. end
  167. end
  168. o:depends("type", "tun")
  169. o.description = translate("Redirect traffic to this network interface")
  170. o = s:option(ListValue, "v2ray_protocol", translate("V2Ray/XRay protocol"))
  171. o:value("vless", translate("VLESS"))
  172. o:value("vmess", translate("VMess"))
  173. o:value("trojan", translate("Trojan"))
  174. o:value("shadowsocks", translate("Shadowsocks"))
  175. if is_installed("sagernet-core") then
  176. o:value("shadowsocksr", translate("ShadowsocksR"))
  177. o:value("wireguard", translate("WireGuard"))
  178. end
  179. o:value("socks", translate("Socks"))
  180. o:value("http", translate("HTTP"))
  181. o:depends("type", "v2ray")
  182. o = s:option(Value, "server", translate("Server Address"))
  183. o.datatype = "host"
  184. o.rmempty = false
  185. o:depends("type", "ssr")
  186. o:depends("type", "ss")
  187. o:depends("type", "v2ray")
  188. o:depends("type", "trojan")
  189. o:depends("type", "naiveproxy")
  190. o:depends("type", "hysteria")
  191. o:depends("type", "socks5")
  192. o = s:option(Value, "server_port", translate("Server Port"))
  193. o.datatype = "port"
  194. o.rmempty = false
  195. o:depends("type", "ssr")
  196. o:depends("type", "ss")
  197. o:depends("type", "v2ray")
  198. o:depends("type", "trojan")
  199. o:depends("type", "naiveproxy")
  200. o:depends("type", "hysteria")
  201. o:depends("type", "socks5")
  202. o = s:option(Flag, "auth_enable", translate("Enable Authentication"))
  203. o.rmempty = false
  204. o.default = "0"
  205. o:depends("type", "socks5")
  206. o:depends({type = "v2ray", v2ray_protocol = "http"})
  207. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  208. o = s:option(Value, "username", translate("Username"))
  209. o.rmempty = true
  210. o:depends("type", "naiveproxy")
  211. o:depends({type = "socks5", auth_enable = true})
  212. o:depends({type = "v2ray", v2ray_protocol = "http", auth_enable = true})
  213. o:depends({type = "v2ray", v2ray_protocol = "socks", auth_enable = true})
  214. o = s:option(Value, "password", translate("Password"))
  215. o.password = true
  216. o.rmempty = true
  217. o:depends("type", "ssr")
  218. o:depends("type", "ss")
  219. o:depends("type", "trojan")
  220. o:depends("type", "naiveproxy")
  221. o:depends({type = "socks5", auth_enable = true})
  222. o:depends({type = "v2ray", v2ray_protocol = "http", auth_enable = true})
  223. o:depends({type = "v2ray", v2ray_protocol = "socks", socks_ver = "5", auth_enable = true})
  224. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  225. o:depends({type = "v2ray", v2ray_protocol = "shadowsocksr"})
  226. o:depends({type = "v2ray", v2ray_protocol = "trojan"})
  227. o = s:option(ListValue, "encrypt_method", translate("Encrypt Method"))
  228. for _, v in ipairs(encrypt_methods) do
  229. o:value(v)
  230. end
  231. o.rmempty = true
  232. o:depends("type", "ssr")
  233. o:depends({type = "v2ray", v2ray_protocol = "shadowsocksr"})
  234. o = s:option(ListValue, "encrypt_method_ss", translate("Encrypt Method"))
  235. for _, v in ipairs(encrypt_methods_ss) do
  236. o:value(v)
  237. end
  238. o.rmempty = true
  239. o:depends("type", "ss")
  240. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  241. o = s:option(Flag, "uot", translate("UDP over TCP"))
  242. o.description = translate("Enable the SUoT protocol, requires server support.")
  243. o.rmempty = true
  244. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  245. o.default = "0"
  246. o = s:option(Flag, "ivCheck", translate("Bloom Filter"))
  247. o.rmempty = true
  248. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  249. o.default = "1"
  250. -- Shadowsocks Plugin
  251. o = s:option(Value, "plugin", translate("Obfs"))
  252. o:value("none", translate("None"))
  253. if is_finded("obfs-local") or is_installed("sagernet-core") then
  254. o:value("obfs-local", translate("obfs-local"))
  255. end
  256. if is_finded("v2ray-plugin") or is_installed("sagernet-core") then
  257. o:value("v2ray-plugin", translate("v2ray-plugin"))
  258. end
  259. if is_finded("xray-plugin") then
  260. o:value("xray-plugin", translate("xray-plugin"))
  261. end
  262. o.rmempty = true
  263. o:depends("type", "ss")
  264. if is_installed("sagernet-core") then
  265. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  266. end
  267. o = s:option(Value, "plugin_opts", translate("Plugin Opts"))
  268. o.rmempty = true
  269. o:depends("type", "ss")
  270. if is_installed("sagernet-core") then
  271. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  272. end
  273. o = s:option(ListValue, "protocol", translate("Protocol"))
  274. for _, v in ipairs(protocol) do
  275. o:value(v)
  276. end
  277. o.rmempty = true
  278. o:depends("type", "ssr")
  279. o:depends({type = "v2ray", v2ray_protocol = "shadowsocksr"})
  280. o = s:option(Value, "protocol_param", translate("Protocol param (optional)"))
  281. o:depends("type", "ssr")
  282. o:depends({type = "v2ray", v2ray_protocol = "shadowsocksr"})
  283. o = s:option(ListValue, "obfs", translate("Obfs"))
  284. for _, v in ipairs(obfs) do
  285. o:value(v)
  286. end
  287. o.rmempty = true
  288. o:depends("type", "ssr")
  289. o:depends({type = "v2ray", v2ray_protocol = "shadowsocksr"})
  290. o = s:option(Value, "obfs_param", translate("Obfs param (optional)"))
  291. o:depends("type", "ssr")
  292. o:depends({type = "v2ray", v2ray_protocol = "shadowsocksr"})
  293. -- [[ Hysteria ]]--
  294. o = s:option(ListValue, "hysteria_protocol", translate("Protocol"))
  295. o:depends("type", "hysteria")
  296. o:value("udp", translate("udp"))
  297. o:value("wechat-video", translate("wechat-video"))
  298. o:value("faketcp", translate("faketcp"))
  299. o.default = "udp"
  300. o.rmempty = true
  301. o = s:option(ListValue, "auth_type", translate("Authentication type"))
  302. o:depends("type", "hysteria")
  303. o:value("0", translate("disabled"))
  304. o:value("1", translate("base64"))
  305. o:value("2", translate("string"))
  306. o.rmempty = true
  307. o = s:option(Value, "auth_payload", translate("Authentication payload"))
  308. o:depends({type = "hysteria", auth_type = "1"})
  309. o:depends({type = "hysteria", auth_type = "2"})
  310. o.rmempty = true
  311. o = s:option(Value, "recv_window", translate("QUIC connection receive window"))
  312. o.datatype = "uinteger"
  313. o:depends("type", "hysteria")
  314. o.rmempty = true
  315. o = s:option(Value, "recv_window_conn", translate("QUIC stream receive window"))
  316. o.datatype = "uinteger"
  317. o:depends("type", "hysteria")
  318. o.rmempty = true
  319. o = s:option(Flag, "disable_mtu_discovery", translate("Disable Path MTU discovery"))
  320. o:depends("type", "hysteria")
  321. o.rmempty = true
  322. -- VmessId
  323. o = s:option(Value, "vmess_id", translate("Vmess/VLESS ID (UUID)"))
  324. o.rmempty = true
  325. o.default = uuid
  326. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  327. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  328. -- VLESS Encryption
  329. o = s:option(Value, "vless_encryption", translate("VLESS Encryption"))
  330. o.rmempty = true
  331. o.default = "none"
  332. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  333. -- 加密方式
  334. o = s:option(ListValue, "security", translate("Encrypt Method"))
  335. for _, v in ipairs(securitys) do
  336. o:value(v, v:upper())
  337. end
  338. o.rmempty = true
  339. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  340. -- SOCKS Version
  341. o = s:option(ListValue, "socks_ver", translate("Socks Version"))
  342. o:value("4", "Socks4")
  343. o:value("4a", "Socks4A")
  344. o:value("5", "Socks5")
  345. o.rmempty = true
  346. o.default = "5"
  347. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  348. -- 传输协议
  349. o = s:option(ListValue, "transport", translate("Transport"))
  350. o:value("tcp", "TCP")
  351. o:value("kcp", "mKCP")
  352. o:value("ws", "WebSocket")
  353. o:value("h2", "HTTP/2")
  354. o:value("quic", "QUIC")
  355. o:value("grpc", "gRPC")
  356. o.rmempty = true
  357. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  358. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  359. o:depends({type = "v2ray", v2ray_protocol = "trojan"})
  360. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  361. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  362. o:depends({type = "v2ray", v2ray_protocol = "http"})
  363. -- [[ TCP部分 ]]--
  364. -- TCP伪装
  365. o = s:option(ListValue, "tcp_guise", translate("Camouflage Type"))
  366. o:depends("transport", "tcp")
  367. o:value("none", translate("None"))
  368. o:value("http", "HTTP")
  369. o.rmempty = true
  370. -- HTTP域名
  371. o = s:option(Value, "http_host", translate("HTTP Host"))
  372. o:depends("tcp_guise", "http")
  373. o.rmempty = true
  374. -- HTTP路径
  375. o = s:option(Value, "http_path", translate("HTTP Path"))
  376. o:depends("tcp_guise", "http")
  377. o.rmempty = true
  378. -- [[ WS部分 ]]--
  379. -- WS域名
  380. o = s:option(Value, "ws_host", translate("WebSocket Host"))
  381. o:depends({transport = "ws", tls = false})
  382. o.datatype = "hostname"
  383. o.rmempty = true
  384. -- WS路径
  385. o = s:option(Value, "ws_path", translate("WebSocket Path"))
  386. o:depends("transport", "ws")
  387. o.rmempty = true
  388. if is_finded("v2ray") then
  389. -- 启用WS前置数据
  390. o = s:option(Flag, "ws_ed_enable", translate("Enable early data"))
  391. o:depends("transport", "ws")
  392. -- WS前置数据
  393. o = s:option(Value, "ws_ed", translate("Max Early Data"))
  394. o:depends("ws_ed_enable", true)
  395. o.datatype = "uinteger"
  396. o.default = 2048
  397. o.rmempty = true
  398. -- WS前置数据标头
  399. o = s:option(Value, "ws_ed_header", translate("Early Data Header Name"))
  400. o:depends("ws_ed_enable", true)
  401. o.default = "Sec-WebSocket-Protocol"
  402. o.rmempty = true
  403. end
  404. -- [[ H2部分 ]]--
  405. -- H2域名
  406. o = s:option(Value, "h2_host", translate("HTTP/2 Host"))
  407. o:depends("transport", "h2")
  408. o.rmempty = true
  409. -- H2路径
  410. o = s:option(Value, "h2_path", translate("HTTP/2 Path"))
  411. o:depends("transport", "h2")
  412. o.rmempty = true
  413. -- gRPC
  414. o = s:option(Value, "serviceName", translate("gRPC Service Name"))
  415. o:depends("transport", "grpc")
  416. o.rmempty = true
  417. if is_finded("xray") or is_installed("sagernet-core") then
  418. -- gPRC模式
  419. o = s:option(ListValue, "grpc_mode", translate("gRPC Mode"))
  420. o:depends("transport", "grpc")
  421. o:value("gun", translate("Gun"))
  422. o:value("multi", translate("Multi"))
  423. if is_installed("sagernet-core") then
  424. o:value("raw", translate("Raw"))
  425. end
  426. o.rmempty = true
  427. end
  428. if is_finded("xray") or is_installed("sagernet-core") then
  429. -- gRPC初始窗口
  430. o = s:option(Value, "initial_windows_size", translate("Initial Windows Size"))
  431. o.datatype = "uinteger"
  432. o:depends("transport", "grpc")
  433. o.default = 0
  434. o.rmempty = true
  435. -- H2/gRPC健康检查
  436. o = s:option(Flag, "health_check", translate("H2/gRPC Health Check"))
  437. o:depends("transport", "h2")
  438. o:depends("transport", "grpc")
  439. o.rmempty = true
  440. o = s:option(Value, "read_idle_timeout", translate("H2 Read Idle Timeout"))
  441. o.datatype = "uinteger"
  442. o:depends({health_check = true, transport = "h2"})
  443. o.default = 60
  444. o.rmempty = true
  445. o = s:option(Value, "idle_timeout", translate("gRPC Idle Timeout"))
  446. o.datatype = "uinteger"
  447. o:depends({health_check = true, transport = "grpc"})
  448. o.default = 60
  449. o.rmempty = true
  450. o = s:option(Value, "health_check_timeout", translate("Health Check Timeout"))
  451. o.datatype = "uinteger"
  452. o:depends("health_check", 1)
  453. o.default = 20
  454. o.rmempty = true
  455. o = s:option(Flag, "permit_without_stream", translate("Permit Without Stream"))
  456. o:depends({health_check = true, transport = "grpc"})
  457. o.rmempty = true
  458. end
  459. -- [[ QUIC部分 ]]--
  460. o = s:option(ListValue, "quic_security", translate("QUIC Security"))
  461. o:depends("transport", "quic")
  462. o:value("none", translate("None"))
  463. o:value("aes-128-gcm", translate("aes-128-gcm"))
  464. o:value("chacha20-poly1305", translate("chacha20-poly1305"))
  465. o.rmempty = true
  466. o = s:option(Value, "quic_key", translate("QUIC Key"))
  467. o:depends("transport", "quic")
  468. o.rmempty = true
  469. o = s:option(ListValue, "quic_guise", translate("Header"))
  470. o:depends("transport", "quic")
  471. o.rmempty = true
  472. o:value("none", translate("None"))
  473. o:value("srtp", translate("VideoCall (SRTP)"))
  474. o:value("utp", translate("BitTorrent (uTP)"))
  475. o:value("wechat-video", translate("WechatVideo"))
  476. o:value("dtls", translate("DTLS 1.2"))
  477. o:value("wireguard", translate("WireGuard"))
  478. -- [[ mKCP部分 ]]--
  479. o = s:option(ListValue, "kcp_guise", translate("Camouflage Type"))
  480. o:depends("transport", "kcp")
  481. o:value("none", translate("None"))
  482. o:value("srtp", translate("VideoCall (SRTP)"))
  483. o:value("utp", translate("BitTorrent (uTP)"))
  484. o:value("wechat-video", translate("WechatVideo"))
  485. o:value("dtls", translate("DTLS 1.2"))
  486. o:value("wireguard", translate("WireGuard"))
  487. o.rmempty = true
  488. o = s:option(Value, "mtu", translate("MTU"))
  489. o.datatype = "uinteger"
  490. o:depends("transport", "kcp")
  491. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  492. -- o.default = 1350
  493. o.rmempty = true
  494. o = s:option(Value, "tti", translate("TTI"))
  495. o.datatype = "uinteger"
  496. o:depends("transport", "kcp")
  497. o.default = 50
  498. o.rmempty = true
  499. o = s:option(Value, "uplink_capacity", translate("Uplink Capacity"))
  500. o.datatype = "uinteger"
  501. o:depends("transport", "kcp")
  502. o:depends("type", "hysteria")
  503. o.default = 5
  504. o.rmempty = true
  505. o = s:option(Value, "downlink_capacity", translate("Downlink Capacity"))
  506. o.datatype = "uinteger"
  507. o:depends("transport", "kcp")
  508. o:depends("type", "hysteria")
  509. o.default = 20
  510. o.rmempty = true
  511. o = s:option(Value, "read_buffer_size", translate("Read Buffer Size"))
  512. o.datatype = "uinteger"
  513. o:depends("transport", "kcp")
  514. o.default = 2
  515. o.rmempty = true
  516. o = s:option(Value, "write_buffer_size", translate("Write Buffer Size"))
  517. o.datatype = "uinteger"
  518. o:depends("transport", "kcp")
  519. o.default = 2
  520. o.rmempty = true
  521. o = s:option(Value, "seed", translate("Obfuscate password (optional)"))
  522. o:depends("transport", "kcp")
  523. o:depends("type", "hysteria")
  524. o.rmempty = true
  525. o = s:option(Flag, "congestion", translate("Congestion"))
  526. o:depends("transport", "kcp")
  527. o.rmempty = true
  528. -- [[ WireGuard 部分 ]]--
  529. o = s:option(DynamicList, "local_addresses", translate("Local addresses"))
  530. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  531. o.rmempty = true
  532. o = s:option(Value, "private_key", translate("Private key"))
  533. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  534. o.password = true
  535. o.rmempty = true
  536. o = s:option(Value, "peer_pubkey", translate("Peer public key"))
  537. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  538. o.rmempty = true
  539. o = s:option(Value, "preshared_key", translate("Pre-shared key"))
  540. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  541. o.password = true
  542. o.rmempty = true
  543. -- [[ TLS ]]--
  544. o = s:option(Flag, "tls", translate("TLS"))
  545. o.rmempty = true
  546. o.default = "0"
  547. o:depends({type = "v2ray", v2ray_protocol = "vless", xtls = false})
  548. o:depends({type = "v2ray", v2ray_protocol = "vmess", xtls = false})
  549. o:depends({type = "v2ray", v2ray_protocol = "trojan", xtls = false})
  550. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks", xtls = false})
  551. o:depends({type = "v2ray", v2ray_protocol = "socks", socks_ver = "5", xtls = false})
  552. o:depends({type = "v2ray", v2ray_protocol = "http", xtls = false})
  553. o:depends("type", "trojan")
  554. -- XTLS
  555. if is_finded("xray") then
  556. o = s:option(Flag, "xtls", translate("XTLS"))
  557. o.rmempty = true
  558. o.default = "0"
  559. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "tcp", tls = false})
  560. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "kcp", tls = false})
  561. o:depends({type = "v2ray", v2ray_protocol = "trojan", transport = "tcp", tls = false})
  562. o:depends({type = "v2ray", v2ray_protocol = "trojan", transport = "kcp", tls = false})
  563. -- Flow
  564. o = s:option(Value, "vless_flow", translate("Flow"))
  565. for _, v in ipairs(flows) do
  566. o:value(v, translate(v))
  567. end
  568. o.rmempty = true
  569. o.default = "xtls-rprx-splice"
  570. o:depends("xtls", true)
  571. o = s:option(Value, "tls_flow", translate("Flow"))
  572. for _, v in ipairs(tls_flows) do
  573. o:value(v, translate(v))
  574. end
  575. o.rmempty = true
  576. o:depends({type = "v2ray", v2ray_protocol = "vless", "tls" = true})
  577. end
  578. -- [[ TLS部分 ]] --
  579. o = s:option(Flag, "tls_sessionTicket", translate("Session Ticket"))
  580. o:depends({type = "trojan", tls = true})
  581. o.default = "0"
  582. if is_finded("xray") then
  583. -- [[ uTLS ]]--
  584. o = s:option(ListValue, "fingerprint", translate("Finger Print"))
  585. o:value("disable", translate("disable"))
  586. o:value("firefox", translate("firefox"))
  587. o:value("chrome", translate("chrome"))
  588. o:value("safari", translate("safari"))
  589. o:value("randomized", translate("randomized"))
  590. o:depends({type = "v2ray", tls = true})
  591. o:depends({type = "v2ray", xtls = true})
  592. o.default = "disable"
  593. end
  594. o = s:option(Value, "tls_host", translate("TLS Host"))
  595. o.datatype = "hostname"
  596. o:depends("tls", true)
  597. o:depends("xtls", true)
  598. o:depends("type", "hysteria")
  599. o.rmempty = true
  600. o = s:option(Value, "quic_tls_alpn", translate("QUIC TLS ALPN"))
  601. o:depends("type", "hysteria")
  602. o.rmempty = true
  603. -- [[ allowInsecure ]]--
  604. o = s:option(Flag, "insecure", translate("allowInsecure"))
  605. o.rmempty = false
  606. o:depends("tls", true)
  607. o:depends("xtls", true)
  608. o:depends("type", "hysteria")
  609. o.description = translate("If true, allowss insecure connection at TLS client, e.g., TLS server uses unverifiable certificates.")
  610. -- [[ Mux ]]--
  611. o = s:option(Flag, "mux", translate("Mux"))
  612. o.rmempty = false
  613. o:depends({type = "v2ray", v2ray_protocol = "vless", xtls = false})
  614. o:depends({type = "v2ray", v2ray_protocol = "vmess", xtls = false})
  615. o:depends({type = "v2ray", v2ray_protocol = "trojan", xtls = false})
  616. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks", xtls = false})
  617. o:depends({type = "v2ray", v2ray_protocol = "socks", xtls = false})
  618. o:depends({type = "v2ray", v2ray_protocol = "http", xtls = false})
  619. o = s:option(Value, "concurrency", translate("Concurrency"))
  620. o.datatype = "uinteger"
  621. o.rmempty = true
  622. o.default = "4"
  623. o:depends("mux", "1")
  624. o:depends("type", "naiveproxy")
  625. -- [[ Cert ]]--
  626. o = s:option(Flag, "certificate", translate("Self-signed Certificate"))
  627. o.rmempty = true
  628. o.default = "0"
  629. o:depends({type = "hysteria", insecure = false})
  630. o:depends({type = "trojan", tls = true, insecure = false})
  631. o:depends({type = "v2ray", v2ray_protocol = "vmess", tls = true, insecure = false})
  632. o:depends({type = "v2ray", v2ray_protocol = "vless", tls = true, insecure = false})
  633. o:depends({type = "v2ray", v2ray_protocol = "vmess", xtls = true, insecure = false})
  634. o:depends({type = "v2ray", v2ray_protocol = "vless", xtls = true, insecure = false})
  635. o.description = translate("If you have a self-signed certificate,please check the box")
  636. o = s:option(DummyValue, "upload", translate("Upload"))
  637. o.template = "shadowsocksr/certupload"
  638. o:depends("certificate", 1)
  639. cert_dir = "/etc/ssl/private/"
  640. local path
  641. luci.http.setfilehandler(function(meta, chunk, eof)
  642. if not fd then
  643. if (not meta) or (not meta.name) or (not meta.file) then
  644. return
  645. end
  646. fd = nixio.open(cert_dir .. meta.file, "w")
  647. if not fd then
  648. path = translate("Create upload file error.")
  649. return
  650. end
  651. end
  652. if chunk and fd then
  653. fd:write(chunk)
  654. end
  655. if eof and fd then
  656. fd:close()
  657. fd = nil
  658. path = '/etc/ssl/private/' .. meta.file .. ''
  659. end
  660. end)
  661. if luci.http.formvalue("upload") then
  662. local f = luci.http.formvalue("ulfile")
  663. if #f <= 0 then
  664. path = translate("No specify upload file.")
  665. end
  666. end
  667. o = s:option(Value, "certpath", translate("Current Certificate Path"))
  668. o:depends("certificate", 1)
  669. o:value("/etc/ssl/private/ca.pem")
  670. o.description = translate("Please confirm the current certificate path")
  671. o.default = "/etc/ssl/private/ca.pem"
  672. o = s:option(Flag, "fast_open", translate("TCP Fast Open"))
  673. o.rmempty = true
  674. o.default = "0"
  675. o:depends("type", "ssr")
  676. o:depends("type", "ss")
  677. o:depends("type", "trojan")
  678. if is_installed("sagernet-core") then
  679. o = s:option(ListValue, "packet_encoding", translate("Packet Encoding"))
  680. o:value("none", translate("none"))
  681. o:value("packet", translate("packet (v2ray-core v5+)"))
  682. o:value("xudp", translate("xudp (Xray-core)"))
  683. o.default = "xudp"
  684. o.rmempty = true
  685. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  686. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  687. end
  688. o = s:option(Flag, "switch_enable", translate("Enable Auto Switch"))
  689. o.rmempty = false
  690. o.default = "1"
  691. o = s:option(Value, "local_port", translate("Local Port"))
  692. o.datatype = "port"
  693. o.default = 1234
  694. o.rmempty = false
  695. if is_finded("kcptun-client") then
  696. o = s:option(Flag, "kcp_enable", translate("KcpTun Enable"))
  697. o.rmempty = true
  698. o.default = "0"
  699. o:depends("type", "ssr")
  700. o:depends("type", "ss")
  701. o = s:option(Value, "kcp_port", translate("KcpTun Port"))
  702. o.datatype = "port"
  703. o.default = 4000
  704. o:depends("type", "ssr")
  705. o:depends("type", "ss")
  706. o = s:option(Value, "kcp_password", translate("KcpTun Password"))
  707. o.password = true
  708. o:depends("type", "ssr")
  709. o:depends("type", "ss")
  710. o = s:option(Value, "kcp_param", translate("KcpTun Param"))
  711. o.default = "--nocomp"
  712. o:depends("type", "ssr")
  713. o:depends("type", "ss")
  714. end
  715. return m