client-config.lua 35 KB

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