client-config.lua 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257
  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.jsonc"
  7. require "luci.model.ipkg"
  8. local m, s, o
  9. local sid = arg[1]
  10. local uuid = luci.sys.exec("cat /proc/sys/kernel/random/uuid")
  11. local function is_finded(e)
  12. return luci.sys.exec('type -t -p "%s"' % e) ~= "" and true or false
  13. end
  14. local function is_installed(e)
  15. return luci.model.ipkg.installed(e)
  16. end
  17. local server_table = {}
  18. local encrypt_methods = {
  19. -- ssr
  20. "none",
  21. "table",
  22. "rc4",
  23. "rc4-md5-6",
  24. "rc4-md5",
  25. "aes-128-cfb",
  26. "aes-192-cfb",
  27. "aes-256-cfb",
  28. "aes-128-ctr",
  29. "aes-192-ctr",
  30. "aes-256-ctr",
  31. "bf-cfb",
  32. "camellia-128-cfb",
  33. "camellia-192-cfb",
  34. "camellia-256-cfb",
  35. "cast5-cfb",
  36. "des-cfb",
  37. "idea-cfb",
  38. "rc2-cfb",
  39. "seed-cfb",
  40. "salsa20",
  41. "chacha20",
  42. "chacha20-ietf"
  43. }
  44. local encrypt_methods_ss = {
  45. -- plain
  46. "none",
  47. "plain",
  48. -- aead
  49. "aes-128-gcm",
  50. "aes-192-gcm",
  51. "aes-256-gcm",
  52. "chacha20-ietf-poly1305",
  53. "xchacha20-ietf-poly1305",
  54. -- aead 2022
  55. "2022-blake3-aes-128-gcm",
  56. "2022-blake3-aes-256-gcm",
  57. "2022-blake3-chacha20-poly1305"
  58. --[[ stream
  59. "none",
  60. "plain",
  61. "table",
  62. "rc4",
  63. "rc4-md5",
  64. "aes-128-cfb",
  65. "aes-192-cfb",
  66. "aes-256-cfb",
  67. "aes-128-ctr",
  68. "aes-192-ctr",
  69. "aes-256-ctr",
  70. "bf-cfb",
  71. "camellia-128-cfb",
  72. "camellia-192-cfb",
  73. "camellia-256-cfb",
  74. "salsa20",
  75. "chacha20",
  76. "chacha20-ietf" ]]
  77. }
  78. local protocol = {
  79. -- ssr
  80. "origin",
  81. "verify_deflate",
  82. "auth_sha1_v4",
  83. "auth_aes128_sha1",
  84. "auth_aes128_md5",
  85. "auth_chain_a",
  86. "auth_chain_b",
  87. "auth_chain_c",
  88. "auth_chain_d",
  89. "auth_chain_e",
  90. "auth_chain_f"
  91. }
  92. local obfs = {
  93. -- ssr
  94. "plain",
  95. "http_simple",
  96. "http_post",
  97. "random_head",
  98. "tls1.2_ticket_auth"
  99. }
  100. local securitys = {
  101. -- vmess
  102. "auto",
  103. "none",
  104. "zero",
  105. "aes-128-gcm",
  106. "chacha20-poly1305"
  107. }
  108. local tls_flows = {
  109. -- tls
  110. "xtls-rprx-vision",
  111. "xtls-rprx-vision-udp443",
  112. "none"
  113. }
  114. m = Map("shadowsocksr", translate("Edit ShadowSocksR Server"))
  115. m.redirect = luci.dispatcher.build_url("admin/services/shadowsocksr/servers")
  116. if m.uci:get("shadowsocksr", sid) ~= "servers" then
  117. luci.http.redirect(m.redirect)
  118. return
  119. end
  120. -- [[ Servers Setting ]]--
  121. s = m:section(NamedSection, sid, "servers")
  122. s.anonymous = true
  123. s.addremove = false
  124. o = s:option(DummyValue, "ssr_url", "SS/SSR/V2RAY/TROJAN URL")
  125. o.rawhtml = true
  126. o.template = "shadowsocksr/ssrurl"
  127. o.value = sid
  128. o = s:option(ListValue, "type", translate("Server Node Type"))
  129. if is_finded("xray") or is_finded("v2ray") then
  130. o:value("v2ray", translate("V2Ray/XRay"))
  131. end
  132. if is_finded("ssr-redir") then
  133. o:value("ssr", translate("ShadowsocksR"))
  134. end
  135. if is_finded("ss-local") or is_finded("ss-redir") then
  136. o:value("ss", translate("Shadowsocks-libev Version"))
  137. end
  138. if is_finded("sslocal") or is_finded("ssmanager") then
  139. o:value("ss", translate("Shadowsocks-rust Version"))
  140. end
  141. if is_finded("trojan") then
  142. o:value("trojan", translate("Trojan"))
  143. end
  144. if is_finded("naive") then
  145. o:value("naiveproxy", translate("NaiveProxy"))
  146. end
  147. if is_finded("hysteria") then
  148. o:value("hysteria", translate("Hysteria"))
  149. end
  150. if is_finded("tuic-client") then
  151. o:value("tuic", translate("TUIC"))
  152. end
  153. if is_finded("shadow-tls") and is_finded("sslocal") then
  154. o:value("shadowtls", translate("Shadow-TLS"))
  155. end
  156. if is_finded("ipt2socks") then
  157. o:value("socks5", translate("Socks5"))
  158. end
  159. if is_finded("redsocks2") then
  160. o:value("tun", translate("Network Tunnel"))
  161. end
  162. o.description = translate("Using incorrect encryption mothod may causes service fail to start")
  163. o = s:option(Value, "alias", translate("Alias(optional)"))
  164. o = s:option(ListValue, "iface", translate("Network interface to use"))
  165. for _, e in ipairs(luci.sys.net.devices()) do
  166. if e ~= "lo" then
  167. o:value(e)
  168. end
  169. end
  170. o:depends("type", "tun")
  171. o.description = translate("Redirect traffic to this network interface")
  172. o = s:option(ListValue, "v2ray_protocol", translate("V2Ray/XRay protocol"))
  173. o:value("vless", translate("VLESS"))
  174. o:value("vmess", translate("VMess"))
  175. o:value("trojan", translate("Trojan"))
  176. o:value("shadowsocks", translate("Shadowsocks"))
  177. if is_finded("xray") then
  178. o:value("wireguard", translate("WireGuard"))
  179. end
  180. o:value("socks", translate("Socks"))
  181. o:value("http", translate("HTTP"))
  182. o:depends("type", "v2ray")
  183. o = s:option(Value, "server", translate("Server Address"))
  184. o.datatype = "host"
  185. o.rmempty = false
  186. o:depends("type", "ssr")
  187. o:depends("type", "ss")
  188. o:depends("type", "v2ray")
  189. o:depends("type", "trojan")
  190. o:depends("type", "naiveproxy")
  191. o:depends("type", "hysteria")
  192. o:depends("type", "tuic")
  193. o:depends("type", "shadowtls")
  194. o:depends("type", "socks5")
  195. o = s:option(Value, "server_port", translate("Server Port"))
  196. o.datatype = "port"
  197. o.rmempty = true
  198. o:depends("type", "ssr")
  199. o:depends("type", "ss")
  200. o:depends("type", "v2ray")
  201. o:depends("type", "trojan")
  202. o:depends("type", "naiveproxy")
  203. o:depends("type", "hysteria")
  204. o:depends("type", "tuic")
  205. o:depends("type", "shadowtls")
  206. o:depends("type", "socks5")
  207. o = s:option(Flag, "auth_enable", translate("Enable Authentication"))
  208. o.rmempty = false
  209. o.default = "0"
  210. o:depends("type", "socks5")
  211. o:depends({type = "v2ray", v2ray_protocol = "http"})
  212. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  213. o = s:option(Value, "username", translate("Username"))
  214. o.rmempty = true
  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", auth_enable = true})
  219. o = s:option(Value, "password", translate("Password"))
  220. o.password = true
  221. o.rmempty = true
  222. o:depends("type", "ssr")
  223. o:depends("type", "ss")
  224. o:depends("type", "trojan")
  225. o:depends("type", "naiveproxy")
  226. o:depends("type", "shadowtls")
  227. o:depends({type = "socks5", auth_enable = true})
  228. o:depends({type = "v2ray", v2ray_protocol = "http", auth_enable = true})
  229. o:depends({type = "v2ray", v2ray_protocol = "socks", socks_ver = "5", auth_enable = true})
  230. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  231. o:depends({type = "v2ray", v2ray_protocol = "trojan"})
  232. o = s:option(ListValue, "encrypt_method", translate("Encrypt Method"))
  233. for _, v in ipairs(encrypt_methods) do
  234. o:value(v)
  235. end
  236. o.rmempty = true
  237. o:depends("type", "ssr")
  238. o = s:option(ListValue, "encrypt_method_ss", translate("Encrypt Method"))
  239. for _, v in ipairs(encrypt_methods_ss) do
  240. o:value(v)
  241. end
  242. o.rmempty = true
  243. o:depends("type", "ss")
  244. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  245. o = s:option(Flag, "uot", translate("UDP over TCP"))
  246. o.description = translate("Enable the SUoT protocol, requires server support.")
  247. o.rmempty = true
  248. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  249. o.default = "0"
  250. o = s:option(Flag, "ivCheck", translate("Bloom Filter"))
  251. o.rmempty = true
  252. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  253. o.default = "1"
  254. -- Shadowsocks Plugin
  255. o = s:option(Value, "plugin", translate("Obfs"))
  256. o:value("none", translate("None"))
  257. if is_finded("obfs-local") then
  258. o:value("obfs-local", translate("obfs-local"))
  259. end
  260. if is_finded("v2ray-plugin") then
  261. o:value("v2ray-plugin", translate("v2ray-plugin"))
  262. end
  263. if is_finded("xray-plugin") then
  264. o:value("xray-plugin", translate("xray-plugin"))
  265. end
  266. o.rmempty = true
  267. o:depends("type", "ss")
  268. o = s:option(Value, "plugin_opts", translate("Plugin Opts"))
  269. o.rmempty = true
  270. o:depends("type", "ss")
  271. o = s:option(ListValue, "protocol", translate("Protocol"))
  272. for _, v in ipairs(protocol) do
  273. o:value(v)
  274. end
  275. o.rmempty = true
  276. o:depends("type", "ssr")
  277. o = s:option(Value, "protocol_param", translate("Protocol param (optional)"))
  278. o:depends("type", "ssr")
  279. o = s:option(ListValue, "obfs", translate("Obfs"))
  280. for _, v in ipairs(obfs) do
  281. o:value(v)
  282. end
  283. o.rmempty = true
  284. o:depends("type", "ssr")
  285. o = s:option(Value, "obfs_param", translate("Obfs param (optional)"))
  286. o:depends("type", "ssr")
  287. -- [[ Hysteria2 ]]--
  288. o = s:option(Value, "hy2_auth", translate("Users Authentication"))
  289. o:depends("type", "hysteria")
  290. o.rmempty = false
  291. o = s:option(Flag, "flag_port_hopping", translate("Enable Port Hopping"))
  292. o:depends("type", "hysteria")
  293. o.rmempty = true
  294. o.default = "0"
  295. o = s:option(Value, "port_range", translate("Port Range"))
  296. o:depends({type = "hysteria", flag_port_hopping = true})
  297. o.datatype = "portrange"
  298. o.rmempty = true
  299. o = s:option(Flag, "flag_transport", translate("Enable Transport Protocol Settings"))
  300. o:depends("type", "hysteria")
  301. o.rmempty = true
  302. o.default = "0"
  303. o = s:option(ListValue, "transport_protocol", translate("Transport Protocol"))
  304. o:depends({type = "hysteria", flag_transport = true})
  305. o:value("udp", translate("UDP"))
  306. o.default = "udp"
  307. o.rmempty = true
  308. o = s:option(Value, "hopinterval", translate("Port Hopping Interval(Unit:Second)"))
  309. o:depends({type = "hysteria", flag_transport = true, flag_port_hopping = true})
  310. o.datatype = "uinteger"
  311. o.rmempty = true
  312. o.default = "30"
  313. o = s:option(Flag, "flag_obfs", translate("Enable Obfuscation"))
  314. o:depends("type", "hysteria")
  315. o.rmempty = true
  316. o.default = "0"
  317. o = s:option(Flag, "lazy_mode", translate("Enable Lazy Mode"))
  318. o:depends("type", "hysteria")
  319. o.rmempty = true
  320. o.default = "0"
  321. o = s:option(Value, "obfs_type", translate("Obfuscation Type"))
  322. o:depends({type = "hysteria", flag_obfs = "1"})
  323. o.rmempty = true
  324. o.default = "salamander"
  325. o = s:option(Value, "salamander", translate("Obfuscation Password"))
  326. o:depends({type = "hysteria", flag_obfs = "1"})
  327. o.rmempty = true
  328. o.default = "cry_me_a_r1ver"
  329. o = s:option(Flag, "flag_quicparam", translate("Hysterir QUIC parameters"))
  330. o:depends("type", "hysteria")
  331. o.rmempty = true
  332. o.default = "0"
  333. o = s:option(Flag, "disablepathmtudiscovery", translate("Disable QUIC path MTU discovery"))
  334. o:depends({type = "hysteria",flag_quicparam = "1"})
  335. o.rmempty = true
  336. o.default = false
  337. --[[Hysteria2 QUIC parameters setting]]
  338. o = s:option(Value, "initstreamreceivewindow", translate("QUIC initStreamReceiveWindow"))
  339. o:depends({type = "hysteria", flag_quicparam = "1"})
  340. o.datatype = "uinteger"
  341. o.rmempty = true
  342. o.default = "8388608"
  343. o = s:option(Value, "maxstreamseceivewindow", translate("QUIC maxStreamReceiveWindow"))
  344. o:depends({type = "hysteria", flag_quicparam = "1"})
  345. o.datatype = "uinteger"
  346. o.rmempty = true
  347. o.default = "8388608"
  348. o = s:option(Value, "initconnreceivewindow", translate("QUIC initConnReceiveWindow"))
  349. o:depends({type = "hysteria", flag_quicparam = "1"})
  350. o.datatype = "uinteger"
  351. o.rmempty = true
  352. o.default = "20971520"
  353. o = s:option(Value, "maxconnreceivewindow", translate("QUIC maxConnReceiveWindow"))
  354. o:depends({type = "hysteria", flag_quicparam = "1"})
  355. o.datatype = "uinteger"
  356. o.rmempty = true
  357. o.default = "20971520"
  358. o = s:option(Value, "maxidletimeout", translate("QUIC maxIdleTimeout(Unit:second)"))
  359. o:depends({type = "hysteria", flag_quicparam = "1"})
  360. o.rmempty = true
  361. o.datatype = "uinteger"
  362. o.default = "30"
  363. o = s:option(Value, "keepaliveperiod", translate("The keep-alive period.(Unit:second)"))
  364. o.description = translate("Default value 0 indicatesno heartbeat.")
  365. o:depends({type = "hysteria", flag_quicparam = "1"})
  366. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  367. o.rmempty = true
  368. o.datatype = "uinteger"
  369. o.default = "10"
  370. --[[ Shadow-TLS Options ]]
  371. o = s:option(ListValue, "shadowtls_protocol", translate("shadowTLS protocol Version"))
  372. o:depends("type", "shadowtls")
  373. o:value("v3", translate("Enable V3 protocol."))
  374. o:value("v2", translate("Enable V2 protocol."))
  375. o.default = "v3"
  376. o.rmempty = true
  377. o = s:option(Flag, "strict", translate("TLS 1.3 Strict mode"))
  378. o:depends("type", "shadowtls")
  379. o.default = "1"
  380. o.rmempty = false
  381. o = s:option(Flag, "fastopen", translate("TCP Fast Open"), translate("Enabling TCP Fast Open Requires Server Support."))
  382. o:depends("type", "shadowtls")
  383. o.default = "0"
  384. o.rmempty = false
  385. o = s:option(Flag, "disable_nodelay", translate("Disable TCP No_delay"))
  386. o:depends("type", "shadowtls")
  387. o.default = "0"
  388. o.rmempty = true
  389. o = s:option(Value, "shadowtls_sni", translate("shadow-TLS SNI"))
  390. o:depends("type", "shadowtls")
  391. o.datatype = "host"
  392. o.rmempty = true
  393. o.default = ""
  394. --[[ add a ListValue for Choose chain type,sslocal or vmess ]]
  395. o = s:option(ListValue, "chain_type", translate("Shadow-TLS ChainPoxy type"))
  396. o:depends("type", "shadowtls")
  397. if is_finded("sslocal") then
  398. o:value("sslocal", translate("Shadowsocks-rust Version"))
  399. end
  400. if is_finded("xray") or is_finded("v2ray") then
  401. o:value("vmess", translate("Vmess Protocol"))
  402. end
  403. o.default = "sslocal"
  404. o.rmempty = false
  405. o = s:option(Value, "sslocal_password",translate("Shadowsocks password"))
  406. o:depends({type = "shadowtls", chain_type = "sslocal"})
  407. o.rmempty = true
  408. o = s:option(ListValue, "sslocal_method", translate("Encrypt Method"))
  409. o:depends({type = "shadowtls", chain_type = "sslocal"})
  410. for _, v in ipairs(encrypt_methods_ss) do
  411. o:value(v)
  412. end
  413. o = s:option(Value, "vmess_uuid", translate("Vmess UUID"))
  414. o:depends({type = "shadowtls", chain_type = "vmess"})
  415. o.rmempty = false
  416. o.default = uuid
  417. o = s:option(ListValue, "vmess_method", translate("Encrypt Method"))
  418. o:depends({type = "shadowtls", chain_type = "vmess"})
  419. for _, v in ipairs(securitys) do
  420. o:value(v, v:lower())
  421. end
  422. o.rmempty = true
  423. o.default="auto"
  424. -- [[ TUIC ]]
  425. -- TuicNameId
  426. o = s:option(Value, "tuic_uuid", translate("TUIC User UUID"))
  427. o.rmempty = true
  428. o.default = uuid
  429. o:depends("type", "tuic")
  430. --Tuic IP
  431. o = s:option(Value, "tuic_ip", translate("TUIC Server IP Address"))
  432. o.rmempty = true
  433. o.datatype = "ip4addr"
  434. o.default = ""
  435. o:depends("type", "tuic")
  436. -- Tuic Password
  437. o = s:option(Value, "tuic_passwd", translate("TUIC User Password"))
  438. o.rmempty = true
  439. o.default = ""
  440. o:depends("type", "tuic")
  441. o = s:option(ListValue, "udp_relay_mode", translate("UDP relay mode"))
  442. o:depends("type", "tuic")
  443. o:value("native", translate("native UDP characteristics"))
  444. o:value("quic", translate("lossless UDP relay using QUIC streams"))
  445. o.default = "native"
  446. o.rmempty = true
  447. o = s:option(ListValue, "congestion_control", translate("Congestion control algorithm"))
  448. o:depends("type", "tuic")
  449. o:value("bbr", translate("BBR"))
  450. o:value("cubic", translate("CUBIC"))
  451. o:value("new_reno", translate("New Reno"))
  452. o.default = "cubic"
  453. o.rmempty = true
  454. o = s:option(Value, "heartbeat", translate("Heartbeat interval(second)"))
  455. o:depends("type", "tuic")
  456. o.datatype = "uinteger"
  457. o.default = "3"
  458. o.rmempty = true
  459. o = s:option(Value, "timeout", translate("Timeout for establishing a connection to server(second)"))
  460. o:depends("type", "tuic")
  461. o.datatype = "uinteger"
  462. o.default = "8"
  463. o.rmempty = true
  464. o = s:option(Value, "gc_interval", translate("Garbage collection interval(second)"))
  465. o:depends("type", "tuic")
  466. o.datatype = "uinteger"
  467. o.default = "3"
  468. o.rmempty = true
  469. o = s:option(Value, "gc_lifetime", translate("Garbage collection lifetime(second)"))
  470. o:depends("type", "tuic")
  471. o.datatype = "uinteger"
  472. o.default = "15"
  473. o.rmempty = true
  474. o = s:option(Value, "send_window", translate("TUIC send window"))
  475. o:depends("type", "tuic")
  476. o.datatype = "uinteger"
  477. o.default = 20971520
  478. o.rmempty = true
  479. o = s:option(Value, "receive_window", translate("TUIC receive window"))
  480. o:depends("type", "tuic")
  481. o.datatype = "uinteger"
  482. o.default = 10485760
  483. o.rmempty = true
  484. o = s:option(Flag, "disable_sni", translate("Disable SNI"))
  485. o:depends("type", "tuic")
  486. o.default = "0"
  487. o.rmempty = true
  488. o = s:option(Flag, "zero_rtt_handshake", translate("Enable 0-RTT QUIC handshake"))
  489. o:depends("type", "tuic")
  490. o.default = "0"
  491. o.rmempty = true
  492. -- Tuic settings for the local inbound socks5 server
  493. o = s:option(Flag, "tuic_dual_stack", translate("Dual-stack Listening Socket"))
  494. o.description = translate("If this option is not set, the socket behavior is platform dependent.")
  495. o:depends("type", "tuic")
  496. o.default = "0"
  497. o.rmempty = true
  498. o = s:option(Value, "tuic_max_package_size", translate("Maximum packet size the socks5 server can receive from external"))
  499. o:depends("type", "tuic")
  500. o.datatype = "uinteger"
  501. o.default = 1500
  502. o.rmempty = true
  503. -- AlterId
  504. o = s:option(Value, "alter_id", translate("AlterId"))
  505. o.datatype = "port"
  506. o.default = 16
  507. o.rmempty = true
  508. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  509. -- VmessId
  510. o = s:option(Value, "vmess_id", translate("Vmess/VLESS ID (UUID)"))
  511. o.rmempty = true
  512. o.default = uuid
  513. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  514. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  515. -- VLESS Encryption
  516. o = s:option(Value, "vless_encryption", translate("VLESS Encryption"))
  517. o.rmempty = true
  518. o.default = "none"
  519. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  520. -- 加密方式
  521. o = s:option(ListValue, "security", translate("Encrypt Method"))
  522. for _, v in ipairs(securitys) do
  523. o:value(v, v:upper())
  524. end
  525. o.rmempty = true
  526. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  527. -- SOCKS Version
  528. o = s:option(ListValue, "socks_ver", translate("Socks Version"))
  529. o:value("4", "Socks4")
  530. o:value("4a", "Socks4A")
  531. o:value("5", "Socks5")
  532. o.rmempty = true
  533. o.default = "5"
  534. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  535. -- 传输协议
  536. o = s:option(ListValue, "transport", translate("Transport"))
  537. o:value("raw", "RAW (TCP)")
  538. o:value("kcp", "mKCP")
  539. o:value("ws", "WebSocket")
  540. o:value("httpupgrade", "HTTPUpgrade")
  541. o:value("splithttp", "SplitHTTP")
  542. o:value("xhttp", "XHTTP")
  543. o:value("h2", "HTTP/2")
  544. o:value("quic", "QUIC")
  545. o:value("grpc", "gRPC")
  546. o.rmempty = true
  547. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  548. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  549. o:depends({type = "v2ray", v2ray_protocol = "trojan"})
  550. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  551. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  552. o:depends({type = "v2ray", v2ray_protocol = "http"})
  553. -- [[ RAW部分 ]]--
  554. -- TCP伪装
  555. o = s:option(ListValue, "tcp_guise", translate("Camouflage Type"))
  556. o:depends("transport", "raw")
  557. o:value("none", translate("None"))
  558. o:value("http", "HTTP")
  559. o.rmempty = true
  560. -- HTTP域名
  561. o = s:option(Value, "http_host", translate("HTTP Host"))
  562. o:depends("tcp_guise", "http")
  563. o.rmempty = true
  564. -- HTTP路径
  565. o = s:option(Value, "http_path", translate("HTTP Path"))
  566. o:depends("tcp_guise", "http")
  567. o.rmempty = true
  568. -- [[ WS部分 ]]--
  569. -- WS域名
  570. o = s:option(Value, "ws_host", translate("WebSocket Host"))
  571. o:depends({transport = "ws", tls = false})
  572. o.datatype = "hostname"
  573. o.rmempty = true
  574. -- WS路径
  575. o = s:option(Value, "ws_path", translate("WebSocket Path"))
  576. o:depends("transport", "ws")
  577. o.rmempty = true
  578. if is_finded("v2ray") then
  579. -- WS前置数据
  580. o = s:option(Value, "ws_ed", translate("Max Early Data"))
  581. o:depends("ws_ed_enable", true)
  582. o.datatype = "uinteger"
  583. o:value("2048")
  584. o.rmempty = true
  585. -- WS前置数据标头
  586. o = s:option(Value, "ws_ed_header", translate("Early Data Header Name"))
  587. o:depends("ws_ed_enable", true)
  588. o:value("Sec-WebSocket-Protocol")
  589. o.rmempty = true
  590. end
  591. -- [[ httpupgrade部分 ]]--
  592. -- httpupgrade域名
  593. o = s:option(Value, "httpupgrade_host", translate("Httpupgrade Host"))
  594. o:depends({transport = "httpupgrade", tls = false})
  595. o.rmempty = true
  596. -- httpupgrade路径
  597. o = s:option(Value, "httpupgrade_path", translate("Httpupgrade Path"))
  598. o:depends("transport", "httpupgrade")
  599. o.rmempty = true
  600. -- [[ splithttp部分 ]]--
  601. -- splithttp域名
  602. o = s:option(Value, "splithttp_host", translate("Splithttp Host"))
  603. o:depends({transport = "splithttp", tls = false})
  604. o.rmempty = true
  605. -- splithttp路径
  606. o = s:option(Value, "splithttp_path", translate("Splithttp Path"))
  607. o:depends("transport", "splithttp")
  608. o.rmempty = true
  609. -- [[ XHTTP部分 ]]--
  610. o = s:option(ListValue, "xhttp_alpn", translate("XHTTP Alpn"))
  611. o.default = ""
  612. o:value("", translate("Default"))
  613. o:value("h3")
  614. o:value("h2")
  615. o:value("h3,h2")
  616. o:value("http/1.1")
  617. o:value("h2,http/1.1")
  618. o:value("h3,h2,http/1.1")
  619. o:depends("transport", "xhttp")
  620. o = s:option(ListValue, "xhttp_mode", translate("XHTTP Mode"))
  621. o:depends("transport", "xhttp")
  622. o.default = "auto"
  623. o:value("auto")
  624. o:value("packet-up")
  625. o:value("stream-up")
  626. o:value("stream-one")
  627. o = s:option(Value, "xhttp_host", translate("XHTTP Host"))
  628. o:depends({transport = "xhttp", tls = false})
  629. o.rmempty = true
  630. o = s:option(Value, "xhttp_path", translate("XHTTP Path"))
  631. o.placeholder = "/"
  632. o:depends("transport", "xhttp")
  633. o.rmempty = true
  634. o = s:option(Flag, "enable_xhttp_extra", translate("XHTTP Extra"))
  635. o.description = translate("Enable this option to configure XHTTP Extra (JSON format).")
  636. o.rmempty = true
  637. o.default = "0"
  638. o:depends("transport", "xhttp")
  639. o = s:option(TextValue, "xhttp_extra", " ")
  640. o.description = translate(
  641. "<font><b>" .. translate("Configure XHTTP Extra Settings (JSON format), see:") .. "</b></font>" ..
  642. " <a href='https://xtls.github.io/config/transports/splithttp.html#extra' target='_blank'>" ..
  643. "<font style='color:green'><b>" .. translate("Click to the page") .. "</b></font></a>")
  644. o:depends("enable_xhttp_extra", true)
  645. o.rmempty = true
  646. o.rows = 10
  647. o.wrap = "off"
  648. o.custom_write = function(self, section, value)
  649. m:set(section, "xhttp_extra", value)
  650. local success, data = pcall(luci.jsonc.parse, value)
  651. if success and data then
  652. local address = (data.extra and data.extra.downloadSettings and data.extra.downloadSettings.address)
  653. or (data.downloadSettings and data.downloadSettings.address)
  654. if address and address ~= "" then
  655. m:set(section, "download_address", address)
  656. else
  657. m:del(section, "download_address")
  658. end
  659. else
  660. m:del(section, "download_address")
  661. end
  662. end
  663. o.validate = function(self, value)
  664. value = value:gsub("\r\n", "\n"):gsub("^[ \t]*\n", ""):gsub("\n[ \t]*$", ""):gsub("\n[ \t]*\n", "\n")
  665. if value:sub(-1) == "\n" then
  666. value = value:sub(1, -2)
  667. end
  668. local success, data = pcall(luci.jsonc.parse, value)
  669. if not success or not data then
  670. return nil, translate("Invalid JSON format")
  671. end
  672. return value
  673. end
  674. -- [[ H2部分 ]]--
  675. -- H2域名
  676. o = s:option(Value, "h2_host", translate("HTTP/2 Host"))
  677. o:depends("transport", "h2")
  678. o.rmempty = true
  679. -- H2路径
  680. o = s:option(Value, "h2_path", translate("HTTP/2 Path"))
  681. o:depends("transport", "h2")
  682. o.rmempty = true
  683. -- gRPC
  684. o = s:option(Value, "serviceName", translate("gRPC Service Name"))
  685. o:depends("transport", "grpc")
  686. o.rmempty = true
  687. if is_finded("xray") then
  688. -- gPRC模式
  689. o = s:option(ListValue, "grpc_mode", translate("gRPC Mode"))
  690. o:depends("transport", "grpc")
  691. o:value("gun", translate("Gun"))
  692. o:value("multi", translate("Multi"))
  693. o.rmempty = true
  694. end
  695. if is_finded("xray") then
  696. -- gRPC初始窗口
  697. o = s:option(Value, "initial_windows_size", translate("Initial Windows Size"))
  698. o.datatype = "uinteger"
  699. o:depends("transport", "grpc")
  700. o.default = 0
  701. o.rmempty = true
  702. -- H2/gRPC健康检查
  703. o = s:option(Flag, "health_check", translate("H2/gRPC Health Check"))
  704. o:depends("transport", "h2")
  705. o:depends("transport", "grpc")
  706. o.rmempty = true
  707. o = s:option(Value, "read_idle_timeout", translate("H2 Read Idle Timeout"))
  708. o.datatype = "uinteger"
  709. o:depends({health_check = true, transport = "h2"})
  710. o.default = 60
  711. o.rmempty = true
  712. o = s:option(Value, "idle_timeout", translate("gRPC Idle Timeout"))
  713. o.datatype = "uinteger"
  714. o:depends({health_check = true, transport = "grpc"})
  715. o.default = 60
  716. o.rmempty = true
  717. o = s:option(Value, "health_check_timeout", translate("Health Check Timeout"))
  718. o.datatype = "uinteger"
  719. o:depends("health_check", 1)
  720. o.default = 20
  721. o.rmempty = true
  722. o = s:option(Flag, "permit_without_stream", translate("Permit Without Stream"))
  723. o:depends({health_check = true, transport = "grpc"})
  724. o.rmempty = true
  725. end
  726. -- [[ QUIC部分 ]]--
  727. o = s:option(ListValue, "quic_security", translate("QUIC Security"))
  728. o:depends("transport", "quic")
  729. o:value("none", translate("None"))
  730. o:value("aes-128-gcm", translate("aes-128-gcm"))
  731. o:value("chacha20-poly1305", translate("chacha20-poly1305"))
  732. o.rmempty = true
  733. o = s:option(Value, "quic_key", translate("QUIC Key"))
  734. o:depends("transport", "quic")
  735. o.rmempty = true
  736. o = s:option(ListValue, "quic_guise", translate("Header"))
  737. o:depends("transport", "quic")
  738. o.rmempty = true
  739. o:value("none", translate("None"))
  740. o:value("srtp", translate("VideoCall (SRTP)"))
  741. o:value("utp", translate("BitTorrent (uTP)"))
  742. o:value("wechat-video", translate("WechatVideo"))
  743. o:value("dtls", translate("DTLS 1.2"))
  744. o:value("wireguard", translate("WireGuard"))
  745. -- [[ mKCP部分 ]]--
  746. o = s:option(ListValue, "kcp_guise", translate("Camouflage Type"))
  747. o:depends("transport", "kcp")
  748. o:value("none", translate("None"))
  749. o:value("srtp", translate("VideoCall (SRTP)"))
  750. o:value("utp", translate("BitTorrent (uTP)"))
  751. o:value("wechat-video", translate("WechatVideo"))
  752. o:value("dtls", translate("DTLS 1.2"))
  753. o:value("wireguard", translate("WireGuard"))
  754. o.rmempty = true
  755. o = s:option(Value, "mtu", translate("MTU"))
  756. o.datatype = "uinteger"
  757. o:depends("transport", "kcp")
  758. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  759. -- o.default = 1350
  760. o.rmempty = true
  761. o = s:option(Value, "tti", translate("TTI"))
  762. o.datatype = "uinteger"
  763. o:depends("transport", "kcp")
  764. o.default = 50
  765. o.rmempty = true
  766. o = s:option(Value, "uplink_capacity", translate("Uplink Capacity(Default:Mbps)"))
  767. o.datatype = "uinteger"
  768. o:depends("transport", "kcp")
  769. o:depends("type", "hysteria")
  770. o.default = 5
  771. o.rmempty = true
  772. o = s:option(Value, "downlink_capacity", translate("Downlink Capacity(Default:Mbps)"))
  773. o.datatype = "uinteger"
  774. o:depends("transport", "kcp")
  775. o:depends("type", "hysteria")
  776. o.default = 20
  777. o.rmempty = true
  778. o = s:option(Value, "read_buffer_size", translate("Read Buffer Size"))
  779. o.datatype = "uinteger"
  780. o:depends("transport", "kcp")
  781. o.default = 2
  782. o.rmempty = true
  783. o = s:option(Value, "write_buffer_size", translate("Write Buffer Size"))
  784. o.datatype = "uinteger"
  785. o:depends("transport", "kcp")
  786. o.default = 2
  787. o.rmempty = true
  788. o = s:option(Value, "seed", translate("Obfuscate password (optional)"))
  789. o:depends("transport", "kcp")
  790. o.rmempty = true
  791. o = s:option(Flag, "congestion", translate("Congestion"))
  792. o:depends("transport", "kcp")
  793. o.rmempty = true
  794. -- [[ WireGuard 部分 ]]--
  795. o = s:option(Flag, "kernelmode", translate("Enabled Kernel virtual NIC TUN(optional)"))
  796. o.description = translate("Virtual NIC TUN of Linux kernel can be used only when system supports and have root permission. If used, IPv6 routing table 1023 is occupied.")
  797. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  798. o.default = "0"
  799. o.rmempty = true
  800. o = s:option(DynamicList, "local_addresses", translate("Local addresses"))
  801. o.datatype = "cidr"
  802. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  803. o.rmempty = true
  804. o = s:option(DynamicList, "reserved", translate("Reserved bytes(optional)"))
  805. o.description = translate("Wireguard reserved bytes.")
  806. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  807. o.rmempty = true
  808. o = s:option(Value, "private_key", translate("Private key"))
  809. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  810. o.password = true
  811. o.rmempty = true
  812. o = s:option(Value, "peer_pubkey", translate("Peer public key"))
  813. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  814. o.rmempty = true
  815. o = s:option(Value, "preshared_key", translate("Pre-shared key"))
  816. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  817. o.password = true
  818. o.rmempty = true
  819. o = s:option(DynamicList, "allowedips", translate("allowedIPs(optional)"))
  820. o.description = translate("Wireguard allows only traffic from specific source IP.")
  821. o.datatype = "cidr"
  822. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  823. o.default = "0.0.0.0/0"
  824. o.rmempty = true
  825. -- [[ TLS ]]--
  826. o = s:option(Flag, "tls", translate("TLS"))
  827. o.rmempty = true
  828. o.default = "0"
  829. o:depends({type = "v2ray", v2ray_protocol = "vless", reality = false})
  830. o:depends({type = "v2ray", v2ray_protocol = "vmess", reality = false})
  831. o:depends({type = "v2ray", v2ray_protocol = "trojan", reality = false})
  832. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks", reality = false})
  833. o:depends({type = "v2ray", v2ray_protocol = "socks", socks_ver = "5", reality = false})
  834. o:depends({type = "v2ray", v2ray_protocol = "http", reality = false})
  835. o:depends("type", "trojan")
  836. o:depends("type", "hysteria")
  837. -- [[ TLS部分 ]] --
  838. o = s:option(Flag, "tls_sessionTicket", translate("Session Ticket"))
  839. o:depends({type = "trojan", tls = true})
  840. o.default = "0"
  841. if is_finded("xray") then
  842. -- [[ REALITY ]]
  843. o = s:option(Flag, "reality", translate("REALITY"))
  844. o.rmempty = true
  845. o.default = "0"
  846. o:depends({type = "v2ray", v2ray_protocol = "vless", tls = false})
  847. o = s:option(Value, "reality_publickey", translate("Public key"))
  848. o.rmempty = true
  849. o:depends({type = "v2ray", v2ray_protocol = "vless", reality = true})
  850. o = s:option(Value, "reality_shortid", translate("Short ID"))
  851. o.rmempty = true
  852. o:depends({type = "v2ray", v2ray_protocol = "vless", reality = true})
  853. o = s:option(Value, "reality_spiderx", translate("spiderX"))
  854. o.rmempty = true
  855. o:depends({type = "v2ray", v2ray_protocol = "vless", reality = true})
  856. -- [[ XTLS ]]--
  857. o = s:option(ListValue, "tls_flow", translate("Flow"))
  858. for _, v in ipairs(tls_flows) do
  859. if v == "none" then
  860. o.default = "none"
  861. o:value("none", translate("none"))
  862. else
  863. o:value(v, translate(v))
  864. end
  865. end
  866. o.rmempty = true
  867. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "raw", tls = true})
  868. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "raw", reality = true})
  869. o = s:option(ListValue, "xhttp_tls_flow", translate("Flow"))
  870. for _, v in ipairs(tls_flows) do
  871. if v == "none" then
  872. o.default = "none"
  873. o:value("none", translate("none"))
  874. else
  875. o:value("xtls-rprx-vision", translate("xtls-rprx-vision"))
  876. end
  877. end
  878. o.rmempty = true
  879. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "xhttp", tls = true})
  880. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "xhttp", reality = true})
  881. -- [[ uTLS ]]--
  882. o = s:option(ListValue, "fingerprint", translate("Finger Print"))
  883. o.default = ""
  884. o:value("chrome", translate("chrome"))
  885. o:value("firefox", translate("firefox"))
  886. o:value("safari", translate("safari"))
  887. o:value("ios", translate("ios"))
  888. o:value("android", translate("android"))
  889. o:value("edge", translate("edge"))
  890. o:value("360", translate("360"))
  891. o:value("qq", translate("qq"))
  892. o:value("random", translate("random"))
  893. o:value("randomized", translate("randomized"))
  894. o:value("", translate("disable"))
  895. o:depends({type = "v2ray", tls = true})
  896. o:depends({type = "v2ray", reality = true})
  897. end
  898. o = s:option(Value, "tls_host", translate("TLS Host"))
  899. o.datatype = "hostname"
  900. o:depends("tls", true)
  901. o:depends("xtls", true)
  902. o:depends("reality", true)
  903. o.rmempty = true
  904. o = s:option(DynamicList, "tls_alpn", translate("TLS ALPN"))
  905. o:depends("type", "tuic")
  906. o.default = "h3"
  907. o.rmempty = true
  908. -- [[ allowInsecure ]]--
  909. o = s:option(Flag, "insecure", translate("allowInsecure"))
  910. o.rmempty = false
  911. o:depends("tls", true)
  912. o:depends("type", "hysteria")
  913. o.description = translate("If true, allowss insecure connection at TLS client, e.g., TLS server uses unverifiable certificates.")
  914. -- [[ Hysteria2 TLS pinSHA256 ]] --
  915. o = s:option(Value, "pinsha256", translate("Certificate fingerprint"))
  916. o:depends({type = "hysteria", insecure = true })
  917. o.rmempty = true
  918. -- [[ Mux.Cool ]] --
  919. o = s:option(Flag, "mux", translate("Mux"), translate("Enable Mux.Cool"))
  920. o.rmempty = false
  921. o.default = false
  922. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "raw"})
  923. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "ws"})
  924. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "kcp"})
  925. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "httpupgrade"})
  926. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "splithttp"})
  927. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "h2"})
  928. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "quic"})
  929. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "grpc"})
  930. o:depends({type = "v2ray", v2ray_protocol = "trojan"})
  931. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  932. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  933. o:depends({type = "v2ray", v2ray_protocol = "http"})
  934. -- [[ XUDP Mux ]] --
  935. o = s:option(Flag, "xmux", translate("Xudp Mux"), translate("Enable Xudp Mux"))
  936. o.rmempty = false
  937. o.default = false
  938. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "xhttp"})
  939. -- [[ TCP 最大并发连接数 ]]--
  940. o = s:option(Value, "concurrency", translate("concurrency"))
  941. o.description = translate(
  942. "<ul>"
  943. .. "<li>" .. translate("Default: disable. When entering a negative number, such as -1, The Mux module will not be used to carry TCP traffic.") .. "</li>"
  944. .. "<li>" .. translate("Min value is 1, Max value is 128. When omitted or set to 0, it equals 8.") .. "</li>"
  945. .. "</ul>")
  946. o.rmempty = true
  947. o.default = "-1"
  948. o:value("-1", translate("disable"))
  949. o:value("8", translate("8"))
  950. o:depends("mux", true)
  951. -- [[ UDP 最大并发连接数 ]]--
  952. o = s:option(Value, "xudpConcurrency", translate("xudpConcurrency"))
  953. o.description = translate(
  954. "<ul>"
  955. .. "<li>" .. translate("Default:16. When entering a negative number, such as -1, The Mux module will not be used to carry UDP traffic, Use original UDP transmission method of proxy protocol.") .. "</li>"
  956. .. "<li>" .. translate("Min value is 1, Max value is 1024. When omitted or set to 0, Will same path as TCP traffic.") .. "</li>"
  957. .. "</ul>")
  958. o.rmempty = true
  959. o.default = "16"
  960. o:value("-1", translate("disable"))
  961. o:value("16", translate("16"))
  962. o:depends("mux", true)
  963. o:depends("xmux", true)
  964. -- [[ 对被代理的 UDP/443 流量处理方式 ]]--
  965. o = s:option(ListValue, "xudpProxyUDP443", translate("xudpProxyUDP443"))
  966. o.description = translate(
  967. "<ul>"
  968. .. "<li>" .. translate("Default reject rejects traffic.") .. "</li>"
  969. .. "<li>" .. translate("allow: Allows use Mux connection.") .. "</li>"
  970. .. "<li>" .. translate("skip: Not use Mux module to carry UDP 443 traffic, Use original UDP transmission method of proxy protocol.") .. "</li>"
  971. .. "</ul>")
  972. o.rmempty = true
  973. o.default = "reject"
  974. o:value("reject", translate("reject"))
  975. o:value("allow", translate("allow"))
  976. o:value("skip", translate("skip"))
  977. o:depends("mux", true)
  978. -- [[ XHTTP TCP Fast Open ]]--
  979. o = s:option(Flag, "tcpfastopen", translate("TCP Fast Open"), translate("Enabling TCP Fast Open Requires Server Support."))
  980. o.rmempty = true
  981. o.default = "0"
  982. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "xhttp"})
  983. -- [[ MPTCP ]]--
  984. o = s:option(Flag, "mptcp", translate("MPTCP"), translate("Enable Multipath TCP, need to be enabled in both server and client configuration."))
  985. o.rmempty = true
  986. o.default = "0"
  987. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  988. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  989. o:depends({type = "v2ray", v2ray_protocol = "trojan"})
  990. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  991. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  992. o:depends({type = "v2ray", v2ray_protocol = "http"})
  993. -- [[ custom_tcpcongestion 连接服务器节点的 TCP 拥塞控制算法 ]]--
  994. o = s:option(ListValue, "custom_tcpcongestion", translate("custom_tcpcongestion"))
  995. o.rmempty = true
  996. o.default = ""
  997. o:value("", translate("comment_tcpcongestion_disable"))
  998. o:value("bbr", translate("BBR"))
  999. o:value("cubic", translate("CUBIC"))
  1000. o:value("reno", translate("Reno"))
  1001. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  1002. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  1003. o:depends({type = "v2ray", v2ray_protocol = "trojan"})
  1004. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  1005. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  1006. o:depends({type = "v2ray", v2ray_protocol = "http"})
  1007. -- [[ Cert ]]--
  1008. o = s:option(Flag, "certificate", translate("Self-signed Certificate"))
  1009. o.rmempty = true
  1010. o.default = "0"
  1011. o:depends("type", "tuic")
  1012. o:depends({type = "hysteria", insecure = false})
  1013. o:depends({type = "trojan", tls = true, insecure = false})
  1014. o:depends({type = "v2ray", v2ray_protocol = "vmess", tls = true, insecure = false})
  1015. o:depends({type = "v2ray", v2ray_protocol = "vless", tls = true, insecure = false})
  1016. o.description = translate("If you have a self-signed certificate,please check the box")
  1017. o = s:option(DummyValue, "upload", translate("Upload"))
  1018. o.template = "shadowsocksr/certupload"
  1019. o:depends("certificate", 1)
  1020. cert_dir = "/etc/ssl/private/"
  1021. local path
  1022. luci.http.setfilehandler(function(meta, chunk, eof)
  1023. if not fd then
  1024. if (not meta) or (not meta.name) or (not meta.file) then
  1025. return
  1026. end
  1027. fd = nixio.open(cert_dir .. meta.file, "w")
  1028. if not fd then
  1029. path = translate("Create upload file error.")
  1030. return
  1031. end
  1032. end
  1033. if chunk and fd then
  1034. fd:write(chunk)
  1035. end
  1036. if eof and fd then
  1037. fd:close()
  1038. fd = nil
  1039. path = '/etc/ssl/private/' .. meta.file .. ''
  1040. end
  1041. end)
  1042. if luci.http.formvalue("upload") then
  1043. local f = luci.http.formvalue("ulfile")
  1044. if #f <= 0 then
  1045. path = translate("No specify upload file.")
  1046. end
  1047. end
  1048. o = s:option(Value, "certpath", translate("Current Certificate Path"))
  1049. o:depends("certificate", 1)
  1050. o:value("/etc/ssl/private/ca.pem")
  1051. o.description = translate("Please confirm the current certificate path")
  1052. o.default = "/etc/ssl/private/ca.pem"
  1053. o = s:option(Flag, "fast_open", translate("TCP Fast Open"), translate("Enabling TCP Fast Open Requires Server Support."))
  1054. o.rmempty = true
  1055. o.default = "0"
  1056. o:depends("type", "ssr")
  1057. o:depends("type", "ss")
  1058. o:depends("type", "trojan")
  1059. o:depends("type", "hysteria")
  1060. o = s:option(Flag, "switch_enable", translate("Enable Auto Switch"))
  1061. o.rmempty = false
  1062. o.default = "1"
  1063. o = s:option(Value, "local_port", translate("Local Port"))
  1064. o.datatype = "port"
  1065. o.default = 1234
  1066. o.rmempty = false
  1067. if is_finded("kcptun-client") then
  1068. o = s:option(Flag, "kcp_enable", translate("KcpTun Enable"))
  1069. o.rmempty = true
  1070. o.default = "0"
  1071. o:depends("type", "ssr")
  1072. o:depends("type", "ss")
  1073. o = s:option(Value, "kcp_port", translate("KcpTun Port"))
  1074. o.datatype = "portrange"
  1075. o.default = 4000
  1076. o:depends("type", "ssr")
  1077. o:depends("type", "ss")
  1078. o = s:option(Value, "kcp_password", translate("KcpTun Password"))
  1079. o.password = true
  1080. o:depends("type", "ssr")
  1081. o:depends("type", "ss")
  1082. o = s:option(Value, "kcp_param", translate("KcpTun Param"))
  1083. o.default = "--nocomp"
  1084. o:depends("type", "ssr")
  1085. o:depends("type", "ss")
  1086. end
  1087. return m