client-config.lua 40 KB

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