client-config.lua 24 KB

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