client-config.lua 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881
  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(Value, "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("tuic-client") then
  155. o:value("tuic", translate("TUIC"))
  156. end
  157. if is_finded("ipt2socks") then
  158. o:value("socks5", translate("Socks5"))
  159. end
  160. if is_finded("redsocks2") then
  161. o:value("tun", translate("Network Tunnel"))
  162. end
  163. o.description = translate("Using incorrect encryption mothod may causes service fail to start")
  164. o = s:option(Value, "alias", translate("Alias(optional)"))
  165. o = s:option(ListValue, "iface", translate("Network interface to use"))
  166. for _, e in ipairs(luci.sys.net.devices()) do
  167. if e ~= "lo" then
  168. o:value(e)
  169. end
  170. end
  171. o:depends("type", "tun")
  172. o.description = translate("Redirect traffic to this network interface")
  173. o = s:option(ListValue, "v2ray_protocol", translate("V2Ray/XRay protocol"))
  174. o:value("vless", translate("VLESS"))
  175. o:value("vmess", translate("VMess"))
  176. o:value("trojan", translate("Trojan"))
  177. o:value("shadowsocks", translate("Shadowsocks"))
  178. if is_installed("sagernet-core") then
  179. o:value("shadowsocksr", translate("ShadowsocksR"))
  180. end
  181. if is_finded("xray") then
  182. o:value("wireguard", translate("WireGuard"))
  183. end
  184. o:value("socks", translate("Socks"))
  185. o:value("http", translate("HTTP"))
  186. o:depends("type", "v2ray")
  187. o = s:option(Value, "server", translate("Server Address"))
  188. o.datatype = "host"
  189. o.rmempty = false
  190. o:depends("type", "ssr")
  191. o:depends("type", "ss")
  192. o:depends("type", "v2ray")
  193. o:depends("type", "trojan")
  194. o:depends("type", "naiveproxy")
  195. o:depends("type", "hysteria")
  196. o:depends("type", "tuic")
  197. o:depends("type", "socks5")
  198. o = s:option(Value, "server_port", translate("Server Port"))
  199. o.datatype = "port"
  200. o.rmempty = false
  201. o:depends("type", "ssr")
  202. o:depends("type", "ss")
  203. o:depends("type", "v2ray")
  204. o:depends("type", "trojan")
  205. o:depends("type", "naiveproxy")
  206. o:depends("type", "hysteria")
  207. o:depends("type", "tuic")
  208. o:depends("type", "socks5")
  209. o = s:option(Flag, "auth_enable", translate("Enable Authentication"))
  210. o.rmempty = false
  211. o.default = "0"
  212. o:depends("type", "socks5")
  213. o:depends({type = "v2ray", v2ray_protocol = "http"})
  214. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  215. o = s:option(Value, "username", translate("Username"))
  216. o.rmempty = true
  217. o:depends("type", "naiveproxy")
  218. o:depends({type = "socks5", auth_enable = true})
  219. o:depends({type = "v2ray", v2ray_protocol = "http", auth_enable = true})
  220. o:depends({type = "v2ray", v2ray_protocol = "socks", auth_enable = true})
  221. o = s:option(Value, "password", translate("Password"))
  222. o.password = true
  223. o.rmempty = true
  224. o:depends("type", "ssr")
  225. o:depends("type", "ss")
  226. o:depends("type", "trojan")
  227. o:depends("type", "naiveproxy")
  228. o:depends("type", "tuic")
  229. o:depends({type = "socks5", auth_enable = true})
  230. o:depends({type = "v2ray", v2ray_protocol = "http", auth_enable = true})
  231. o:depends({type = "v2ray", v2ray_protocol = "socks", socks_ver = "5", auth_enable = true})
  232. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  233. o:depends({type = "v2ray", v2ray_protocol = "shadowsocksr"})
  234. o:depends({type = "v2ray", v2ray_protocol = "trojan"})
  235. o = s:option(ListValue, "encrypt_method", translate("Encrypt Method"))
  236. for _, v in ipairs(encrypt_methods) do
  237. o:value(v)
  238. end
  239. o.rmempty = true
  240. o:depends("type", "ssr")
  241. o:depends({type = "v2ray", v2ray_protocol = "shadowsocksr"})
  242. o = s:option(ListValue, "encrypt_method_ss", translate("Encrypt Method"))
  243. for _, v in ipairs(encrypt_methods_ss) do
  244. o:value(v)
  245. end
  246. o.rmempty = true
  247. o:depends("type", "ss")
  248. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  249. o = s:option(Flag, "uot", translate("UDP over TCP"))
  250. o.description = translate("Enable the SUoT protocol, requires server support.")
  251. o.rmempty = true
  252. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  253. o.default = "0"
  254. o = s:option(Flag, "ivCheck", translate("Bloom Filter"))
  255. o.rmempty = true
  256. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  257. o.default = "1"
  258. -- Shadowsocks Plugin
  259. o = s:option(Value, "plugin", translate("Obfs"))
  260. o:value("none", translate("None"))
  261. if is_finded("obfs-local") or is_installed("sagernet-core") then
  262. o:value("obfs-local", translate("obfs-local"))
  263. end
  264. if is_finded("v2ray-plugin") or is_installed("sagernet-core") then
  265. o:value("v2ray-plugin", translate("v2ray-plugin"))
  266. end
  267. if is_finded("xray-plugin") then
  268. o:value("xray-plugin", translate("xray-plugin"))
  269. end
  270. o.rmempty = true
  271. o:depends("type", "ss")
  272. if is_installed("sagernet-core") then
  273. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  274. end
  275. o = s:option(Value, "plugin_opts", translate("Plugin Opts"))
  276. o.rmempty = true
  277. o:depends("type", "ss")
  278. if is_installed("sagernet-core") then
  279. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  280. end
  281. o = s:option(ListValue, "protocol", translate("Protocol"))
  282. for _, v in ipairs(protocol) do
  283. o:value(v)
  284. end
  285. o.rmempty = true
  286. o:depends("type", "ssr")
  287. o:depends({type = "v2ray", v2ray_protocol = "shadowsocksr"})
  288. o = s:option(Value, "protocol_param", translate("Protocol param (optional)"))
  289. o:depends("type", "ssr")
  290. o:depends({type = "v2ray", v2ray_protocol = "shadowsocksr"})
  291. o = s:option(ListValue, "obfs", translate("Obfs"))
  292. for _, v in ipairs(obfs) do
  293. o:value(v)
  294. end
  295. o.rmempty = true
  296. o:depends("type", "ssr")
  297. o:depends({type = "v2ray", v2ray_protocol = "shadowsocksr"})
  298. o = s:option(Value, "obfs_param", translate("Obfs param (optional)"))
  299. o:depends("type", "ssr")
  300. o:depends({type = "v2ray", v2ray_protocol = "shadowsocksr"})
  301. -- [[ Hysteria ]]--
  302. o = s:option(ListValue, "hysteria_protocol", translate("Protocol"))
  303. o:depends("type", "hysteria")
  304. o:value("udp", translate("udp"))
  305. o:value("wechat-video", translate("wechat-video"))
  306. o:value("faketcp", translate("faketcp"))
  307. o.default = "udp"
  308. o.rmempty = true
  309. o = s:option(ListValue, "auth_type", translate("Authentication type"))
  310. o:depends("type", "hysteria")
  311. o:value("0", translate("disabled"))
  312. o:value("1", translate("base64"))
  313. o:value("2", translate("string"))
  314. o.rmempty = true
  315. o = s:option(Value, "auth_payload", translate("Authentication payload"))
  316. o:depends({type = "hysteria", auth_type = "1"})
  317. o:depends({type = "hysteria", auth_type = "2"})
  318. o.rmempty = true
  319. o = s:option(Value, "recv_window", translate("QUIC connection receive window"))
  320. o.datatype = "uinteger"
  321. o:depends("type", "hysteria")
  322. o.rmempty = true
  323. o = s:option(Value, "recv_window_conn", translate("QUIC stream receive window"))
  324. o.datatype = "uinteger"
  325. o:depends("type", "hysteria")
  326. o.rmempty = true
  327. o = s:option(Flag, "disable_mtu_discovery", translate("Disable Path MTU discovery"))
  328. o:depends("type", "hysteria")
  329. o.rmempty = true
  330. -- [[ TUIC ]]
  331. o = s:option(ListValue, "udp_relay_mode", translate("UDP relay mode"))
  332. o:depends("type", "tuic")
  333. o:value("native", translate("native"))
  334. o:value("quic", translate("QUIC"))
  335. o.default = "native"
  336. o.rmempty = true
  337. o = s:option(ListValue, "congestion_controller", translate("Congestion control algorithm"))
  338. o:depends("type", "tuic")
  339. o:value("bbr", translate("BBR"))
  340. o:value("cubic", translate("CUBIC"))
  341. o:value("new_reno", translate("New Reno"))
  342. o.default = "cubic"
  343. o.rmempty = true
  344. o = s:option(Value, "heartbeat_interval", translate("Heartbeat interval"))
  345. o:depends("type", "tuic")
  346. o.datatype = "uinteger"
  347. o.default = "10000"
  348. o.rmempty = true
  349. o = s:option(Flag, "disable_sni", translate("Disable SNI"))
  350. o:depends("type", "tuic")
  351. o.default = 0
  352. o.rmempty = true
  353. o = s:option(Flag, "reduce_rtt", translate("Enable 0-RTT QUIC handshake"))
  354. o:depends("type", "tuic")
  355. o.default = 0
  356. o.rmempty = true
  357. o = s:option(Value, "max_udp_relay_packet_size", translate("Max UDP relay packet size"))
  358. o:depends("type", "tuic")
  359. o.datatype = "uinteger"
  360. o.default = "1500"
  361. o.rmempty = true
  362. -- VmessId
  363. o = s:option(Value, "vmess_id", translate("Vmess/VLESS ID (UUID)"))
  364. o.rmempty = true
  365. o.default = uuid
  366. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  367. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  368. -- VLESS Encryption
  369. o = s:option(Value, "vless_encryption", translate("VLESS Encryption"))
  370. o.rmempty = true
  371. o.default = "none"
  372. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  373. -- 加密方式
  374. o = s:option(ListValue, "security", translate("Encrypt Method"))
  375. for _, v in ipairs(securitys) do
  376. o:value(v, v:upper())
  377. end
  378. o.rmempty = true
  379. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  380. -- SOCKS Version
  381. o = s:option(ListValue, "socks_ver", translate("Socks Version"))
  382. o:value("4", "Socks4")
  383. o:value("4a", "Socks4A")
  384. o:value("5", "Socks5")
  385. o.rmempty = true
  386. o.default = "5"
  387. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  388. -- 传输协议
  389. o = s:option(ListValue, "transport", translate("Transport"))
  390. o:value("tcp", "TCP")
  391. o:value("kcp", "mKCP")
  392. o:value("ws", "WebSocket")
  393. o:value("h2", "HTTP/2")
  394. o:value("quic", "QUIC")
  395. o:value("grpc", "gRPC")
  396. o.rmempty = true
  397. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  398. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  399. o:depends({type = "v2ray", v2ray_protocol = "trojan"})
  400. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  401. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  402. o:depends({type = "v2ray", v2ray_protocol = "http"})
  403. -- [[ TCP部分 ]]--
  404. -- TCP伪装
  405. o = s:option(ListValue, "tcp_guise", translate("Camouflage Type"))
  406. o:depends("transport", "tcp")
  407. o:value("none", translate("None"))
  408. o:value("http", "HTTP")
  409. o.rmempty = true
  410. -- HTTP域名
  411. o = s:option(Value, "http_host", translate("HTTP Host"))
  412. o:depends("tcp_guise", "http")
  413. o.rmempty = true
  414. -- HTTP路径
  415. o = s:option(Value, "http_path", translate("HTTP Path"))
  416. o:depends("tcp_guise", "http")
  417. o.rmempty = true
  418. -- [[ WS部分 ]]--
  419. -- WS域名
  420. o = s:option(Value, "ws_host", translate("WebSocket Host"))
  421. o:depends({transport = "ws", tls = false})
  422. o.datatype = "hostname"
  423. o.rmempty = true
  424. -- WS路径
  425. o = s:option(Value, "ws_path", translate("WebSocket Path"))
  426. o:depends("transport", "ws")
  427. o.rmempty = true
  428. if is_finded("v2ray") then
  429. -- 启用WS前置数据
  430. o = s:option(Flag, "ws_ed_enable", translate("Enable early data"))
  431. o:depends("transport", "ws")
  432. -- WS前置数据
  433. o = s:option(Value, "ws_ed", translate("Max Early Data"))
  434. o:depends("ws_ed_enable", true)
  435. o.datatype = "uinteger"
  436. o.default = 2048
  437. o.rmempty = true
  438. -- WS前置数据标头
  439. o = s:option(Value, "ws_ed_header", translate("Early Data Header Name"))
  440. o:depends("ws_ed_enable", true)
  441. o.default = "Sec-WebSocket-Protocol"
  442. o.rmempty = true
  443. end
  444. -- [[ H2部分 ]]--
  445. -- H2域名
  446. o = s:option(Value, "h2_host", translate("HTTP/2 Host"))
  447. o:depends("transport", "h2")
  448. o.rmempty = true
  449. -- H2路径
  450. o = s:option(Value, "h2_path", translate("HTTP/2 Path"))
  451. o:depends("transport", "h2")
  452. o.rmempty = true
  453. -- gRPC
  454. o = s:option(Value, "serviceName", translate("gRPC Service Name"))
  455. o:depends("transport", "grpc")
  456. o.rmempty = true
  457. if is_finded("xray") or is_installed("sagernet-core") then
  458. -- gPRC模式
  459. o = s:option(ListValue, "grpc_mode", translate("gRPC Mode"))
  460. o:depends("transport", "grpc")
  461. o:value("gun", translate("Gun"))
  462. o:value("multi", translate("Multi"))
  463. if is_installed("sagernet-core") then
  464. o:value("raw", translate("Raw"))
  465. end
  466. o.rmempty = true
  467. end
  468. if is_finded("xray") or is_installed("sagernet-core") then
  469. -- gRPC初始窗口
  470. o = s:option(Value, "initial_windows_size", translate("Initial Windows Size"))
  471. o.datatype = "uinteger"
  472. o:depends("transport", "grpc")
  473. o.default = 0
  474. o.rmempty = true
  475. -- H2/gRPC健康检查
  476. o = s:option(Flag, "health_check", translate("H2/gRPC Health Check"))
  477. o:depends("transport", "h2")
  478. o:depends("transport", "grpc")
  479. o.rmempty = true
  480. o = s:option(Value, "read_idle_timeout", translate("H2 Read Idle Timeout"))
  481. o.datatype = "uinteger"
  482. o:depends({health_check = true, transport = "h2"})
  483. o.default = 60
  484. o.rmempty = true
  485. o = s:option(Value, "idle_timeout", translate("gRPC Idle Timeout"))
  486. o.datatype = "uinteger"
  487. o:depends({health_check = true, transport = "grpc"})
  488. o.default = 60
  489. o.rmempty = true
  490. o = s:option(Value, "health_check_timeout", translate("Health Check Timeout"))
  491. o.datatype = "uinteger"
  492. o:depends("health_check", 1)
  493. o.default = 20
  494. o.rmempty = true
  495. o = s:option(Flag, "permit_without_stream", translate("Permit Without Stream"))
  496. o:depends({health_check = true, transport = "grpc"})
  497. o.rmempty = true
  498. end
  499. -- [[ QUIC部分 ]]--
  500. o = s:option(ListValue, "quic_security", translate("QUIC Security"))
  501. o:depends("transport", "quic")
  502. o:value("none", translate("None"))
  503. o:value("aes-128-gcm", translate("aes-128-gcm"))
  504. o:value("chacha20-poly1305", translate("chacha20-poly1305"))
  505. o.rmempty = true
  506. o = s:option(Value, "quic_key", translate("QUIC Key"))
  507. o:depends("transport", "quic")
  508. o.rmempty = true
  509. o = s:option(ListValue, "quic_guise", translate("Header"))
  510. o:depends("transport", "quic")
  511. o.rmempty = true
  512. o:value("none", translate("None"))
  513. o:value("srtp", translate("VideoCall (SRTP)"))
  514. o:value("utp", translate("BitTorrent (uTP)"))
  515. o:value("wechat-video", translate("WechatVideo"))
  516. o:value("dtls", translate("DTLS 1.2"))
  517. o:value("wireguard", translate("WireGuard"))
  518. -- [[ mKCP部分 ]]--
  519. o = s:option(ListValue, "kcp_guise", translate("Camouflage Type"))
  520. o:depends("transport", "kcp")
  521. o:value("none", translate("None"))
  522. o:value("srtp", translate("VideoCall (SRTP)"))
  523. o:value("utp", translate("BitTorrent (uTP)"))
  524. o:value("wechat-video", translate("WechatVideo"))
  525. o:value("dtls", translate("DTLS 1.2"))
  526. o:value("wireguard", translate("WireGuard"))
  527. o.rmempty = true
  528. o = s:option(Value, "mtu", translate("MTU"))
  529. o.datatype = "uinteger"
  530. o:depends("transport", "kcp")
  531. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  532. -- o.default = 1350
  533. o.rmempty = true
  534. o = s:option(Value, "tti", translate("TTI"))
  535. o.datatype = "uinteger"
  536. o:depends("transport", "kcp")
  537. o.default = 50
  538. o.rmempty = true
  539. o = s:option(Value, "uplink_capacity", translate("Uplink Capacity"))
  540. o.datatype = "uinteger"
  541. o:depends("transport", "kcp")
  542. o:depends("type", "hysteria")
  543. o.default = 5
  544. o.rmempty = true
  545. o = s:option(Value, "downlink_capacity", translate("Downlink Capacity"))
  546. o.datatype = "uinteger"
  547. o:depends("transport", "kcp")
  548. o:depends("type", "hysteria")
  549. o.default = 20
  550. o.rmempty = true
  551. o = s:option(Value, "read_buffer_size", translate("Read Buffer Size"))
  552. o.datatype = "uinteger"
  553. o:depends("transport", "kcp")
  554. o.default = 2
  555. o.rmempty = true
  556. o = s:option(Value, "write_buffer_size", translate("Write Buffer Size"))
  557. o.datatype = "uinteger"
  558. o:depends("transport", "kcp")
  559. o.default = 2
  560. o.rmempty = true
  561. o = s:option(Value, "seed", translate("Obfuscate password (optional)"))
  562. o:depends("transport", "kcp")
  563. o:depends("type", "hysteria")
  564. o.rmempty = true
  565. o = s:option(Flag, "congestion", translate("Congestion"))
  566. o:depends("transport", "kcp")
  567. o.rmempty = true
  568. -- [[ WireGuard 部分 ]]--
  569. o = s:option(DynamicList, "local_addresses", translate("Local addresses"))
  570. o.datatype = "cidr"
  571. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  572. o.rmempty = true
  573. o = s:option(Value, "private_key", translate("Private key"))
  574. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  575. o.password = true
  576. o.rmempty = true
  577. o = s:option(Value, "peer_pubkey", translate("Peer public key"))
  578. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  579. o.rmempty = true
  580. o = s:option(Value, "preshared_key", translate("Pre-shared key"))
  581. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  582. o.password = true
  583. o.rmempty = true
  584. -- [[ TLS ]]--
  585. o = s:option(Flag, "tls", translate("TLS"))
  586. o.rmempty = true
  587. o.default = "0"
  588. o:depends({type = "v2ray", v2ray_protocol = "vless", xtls = false})
  589. o:depends({type = "v2ray", v2ray_protocol = "vmess", xtls = false})
  590. o:depends({type = "v2ray", v2ray_protocol = "trojan", xtls = false})
  591. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks", xtls = false})
  592. o:depends({type = "v2ray", v2ray_protocol = "socks", socks_ver = "5", xtls = false})
  593. o:depends({type = "v2ray", v2ray_protocol = "http", xtls = false})
  594. o:depends("type", "trojan")
  595. -- XTLS
  596. if is_finded("xray") then
  597. o = s:option(Flag, "xtls", translate("XTLS"))
  598. o.rmempty = true
  599. o.default = "0"
  600. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "tcp", tls = false})
  601. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "kcp", tls = false})
  602. o:depends({type = "v2ray", v2ray_protocol = "trojan", transport = "tcp", tls = false})
  603. o:depends({type = "v2ray", v2ray_protocol = "trojan", transport = "kcp", tls = false})
  604. -- Flow
  605. o = s:option(Value, "vless_flow", translate("Flow"))
  606. for _, v in ipairs(flows) do
  607. o:value(v, translate(v))
  608. end
  609. o.rmempty = true
  610. o.default = "xtls-rprx-splice"
  611. o:depends("xtls", true)
  612. o = s:option(Value, "tls_flow", translate("Flow"))
  613. for _, v in ipairs(tls_flows) do
  614. o:value(v, translate(v))
  615. end
  616. o.rmempty = true
  617. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "tcp", tls = true})
  618. end
  619. -- [[ TLS部分 ]] --
  620. o = s:option(Flag, "tls_sessionTicket", translate("Session Ticket"))
  621. o:depends({type = "trojan", tls = true})
  622. o.default = "0"
  623. if is_finded("xray") then
  624. -- [[ uTLS ]]--
  625. o = s:option(ListValue, "fingerprint", translate("Finger Print"))
  626. o:value("", translate("disable"))
  627. o:value("chrome", translate("chrome"))
  628. o:value("firefox", translate("firefox"))
  629. o:value("safari", translate("safari"))
  630. o:value("ios", translate("ios"))
  631. o:value("android", translate("android"))
  632. o:value("edge", translate("edge"))
  633. o:value("360", translate("360"))
  634. o:value("qq", translate("qq"))
  635. o:value("random", translate("random"))
  636. o:value("randomized", translate("randomized"))
  637. o:depends({type = "v2ray", tls = true})
  638. o:depends({type = "v2ray", xtls = true})
  639. o.default = ""
  640. end
  641. o = s:option(Value, "tls_host", translate("TLS Host"))
  642. o.datatype = "hostname"
  643. o:depends("tls", true)
  644. o:depends("xtls", true)
  645. o:depends("type", "hysteria")
  646. o.rmempty = true
  647. o = s:option(DynamicList, "tls_alpn", translate("TLS ALPN"))
  648. o:depends("tls", true)
  649. o:depends("xtls", true)
  650. o:depends("type", "tuic")
  651. o.rmempty = true
  652. o = s:option(Value, "quic_tls_alpn", translate("QUIC TLS ALPN"))
  653. o:depends("type", "hysteria")
  654. o.rmempty = true
  655. -- [[ allowInsecure ]]--
  656. o = s:option(Flag, "insecure", translate("allowInsecure"))
  657. o.rmempty = false
  658. o:depends("tls", true)
  659. o:depends("xtls", true)
  660. o:depends("type", "hysteria")
  661. o.description = translate("If true, allowss insecure connection at TLS client, e.g., TLS server uses unverifiable certificates.")
  662. -- [[ Mux ]]--
  663. o = s:option(Flag, "mux", translate("Mux"))
  664. o.rmempty = false
  665. o:depends({type = "v2ray", v2ray_protocol = "vless", xtls = false})
  666. o:depends({type = "v2ray", v2ray_protocol = "vmess", xtls = false})
  667. o:depends({type = "v2ray", v2ray_protocol = "trojan", xtls = false})
  668. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks", xtls = false})
  669. o:depends({type = "v2ray", v2ray_protocol = "socks", xtls = false})
  670. o:depends({type = "v2ray", v2ray_protocol = "http", xtls = false})
  671. o = s:option(Value, "concurrency", translate("Concurrency"))
  672. o.datatype = "uinteger"
  673. o.rmempty = true
  674. o.default = "4"
  675. o:depends("mux", "1")
  676. o:depends("type", "naiveproxy")
  677. -- [[ Cert ]]--
  678. o = s:option(Flag, "certificate", translate("Self-signed Certificate"))
  679. o.rmempty = true
  680. o.default = "0"
  681. o:depends("type", "tuic")
  682. o:depends({type = "hysteria", insecure = false})
  683. o:depends({type = "trojan", tls = true, insecure = false})
  684. o:depends({type = "v2ray", v2ray_protocol = "vmess", tls = true, insecure = false})
  685. o:depends({type = "v2ray", v2ray_protocol = "vless", tls = true, insecure = false})
  686. o:depends({type = "v2ray", v2ray_protocol = "vmess", xtls = true, insecure = false})
  687. o:depends({type = "v2ray", v2ray_protocol = "vless", xtls = true, insecure = false})
  688. o.description = translate("If you have a self-signed certificate,please check the box")
  689. o = s:option(DummyValue, "upload", translate("Upload"))
  690. o.template = "shadowsocksr/certupload"
  691. o:depends("certificate", 1)
  692. cert_dir = "/etc/ssl/private/"
  693. local path
  694. luci.http.setfilehandler(function(meta, chunk, eof)
  695. if not fd then
  696. if (not meta) or (not meta.name) or (not meta.file) then
  697. return
  698. end
  699. fd = nixio.open(cert_dir .. meta.file, "w")
  700. if not fd then
  701. path = translate("Create upload file error.")
  702. return
  703. end
  704. end
  705. if chunk and fd then
  706. fd:write(chunk)
  707. end
  708. if eof and fd then
  709. fd:close()
  710. fd = nil
  711. path = '/etc/ssl/private/' .. meta.file .. ''
  712. end
  713. end)
  714. if luci.http.formvalue("upload") then
  715. local f = luci.http.formvalue("ulfile")
  716. if #f <= 0 then
  717. path = translate("No specify upload file.")
  718. end
  719. end
  720. o = s:option(Value, "certpath", translate("Current Certificate Path"))
  721. o:depends("certificate", 1)
  722. o:value("/etc/ssl/private/ca.pem")
  723. o.description = translate("Please confirm the current certificate path")
  724. o.default = "/etc/ssl/private/ca.pem"
  725. o = s:option(Flag, "fast_open", translate("TCP Fast Open"))
  726. o.rmempty = true
  727. o.default = "0"
  728. o:depends("type", "ssr")
  729. o:depends("type", "ss")
  730. o:depends("type", "trojan")
  731. o:depends("type", "hysteria")
  732. if is_installed("sagernet-core") then
  733. o = s:option(ListValue, "packet_encoding", translate("Packet Encoding"))
  734. o:value("none", translate("none"))
  735. o:value("packet", translate("packet (v2ray-core v5+)"))
  736. o:value("xudp", translate("xudp (Xray-core)"))
  737. o.default = "xudp"
  738. o.rmempty = true
  739. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  740. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  741. end
  742. o = s:option(Flag, "switch_enable", translate("Enable Auto Switch"))
  743. o.rmempty = false
  744. o.default = "1"
  745. o = s:option(Value, "local_port", translate("Local Port"))
  746. o.datatype = "port"
  747. o.default = 1234
  748. o.rmempty = false
  749. if is_finded("kcptun-client") then
  750. o = s:option(Flag, "kcp_enable", translate("KcpTun Enable"))
  751. o.rmempty = true
  752. o.default = "0"
  753. o:depends("type", "ssr")
  754. o:depends("type", "ss")
  755. o = s:option(Value, "kcp_port", translate("KcpTun Port"))
  756. o.datatype = "port"
  757. o.default = 4000
  758. o:depends("type", "ssr")
  759. o:depends("type", "ss")
  760. o = s:option(Value, "kcp_password", translate("KcpTun Password"))
  761. o.password = true
  762. o:depends("type", "ssr")
  763. o:depends("type", "ss")
  764. o = s:option(Value, "kcp_param", translate("KcpTun Param"))
  765. o.default = "--nocomp"
  766. o:depends("type", "ssr")
  767. o:depends("type", "ss")
  768. end
  769. return m