client-config.lua 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206
  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(ListValue, "transport_protocol", translate("Protocol"))
  291. o:depends("type", "hysteria")
  292. o:value("udp", translate("udp"))
  293. o.default = "udp"
  294. o.rmempty = true
  295. o = s:option(Flag, "port_hopping", translate("Enable Port Hopping"))
  296. o:depends("type", "hysteria")
  297. o.rmempty = true
  298. o.default = "0"
  299. o = s:option(Value, "hopinterval", translate("Port Hopping Interval(Unit:Second)"))
  300. o:depends({type = "hysteria", port_hopping = true})
  301. o.datatype = "uinteger"
  302. o.rmempty = true
  303. o.default = "30"
  304. o = s:option(Value, "port_range", translate("Port Range"))
  305. o:depends({type = "hysteria", port_hopping = true})
  306. o.rmempty = true
  307. o = s:option(Flag, "lazy_mode", translate("Enable Lazy Mode"))
  308. o:depends("type", "hysteria")
  309. o.rmempty = true
  310. o.default = "0"
  311. o = s:option(Flag, "flag_obfs", translate("Enable Obfuscation"))
  312. o:depends("type", "hysteria")
  313. o.rmempty = true
  314. o.default = "0"
  315. o = s:option(Value, "obfs_type", translate("Obfuscation Type"))
  316. o:depends({type = "hysteria", flag_obfs = "1"})
  317. o.rmempty = true
  318. o.default = "salamander"
  319. o = s:option(Value, "salamander", translate("Obfuscation Password"))
  320. o:depends({type = "hysteria", flag_obfs = "1"})
  321. o.rmempty = true
  322. o.default = "cry_me_a_r1ver"
  323. o = s:option(Flag, "flag_quicparam", translate("Hysterir QUIC parameters"))
  324. o:depends("type", "hysteria")
  325. o.rmempty = true
  326. o.default = "0"
  327. --[[Hysteria2 QUIC parameters setting]]
  328. o = s:option(Value, "initstreamreceivewindow", translate("QUIC initStreamReceiveWindow"))
  329. o:depends({type = "hysteria", flag_quicparam = "1"})
  330. o.datatype = "uinteger"
  331. o.rmempty = true
  332. o.default = "8388608"
  333. o = s:option(Value, "maxstreamseceivewindow", translate("QUIC maxStreamReceiveWindow"))
  334. o:depends({type = "hysteria", flag_quicparam = "1"})
  335. o.datatype = "uinteger"
  336. o.rmempty = true
  337. o.default = "8388608"
  338. o = s:option(Value, "initconnreceivewindow", translate("QUIC initConnReceiveWindow"))
  339. o:depends({type = "hysteria", flag_quicparam = "1"})
  340. o.datatype = "uinteger"
  341. o.rmempty = true
  342. o.default = "20971520"
  343. o = s:option(Value, "maxconnreceivewindow", translate("QUIC maxConnReceiveWindow"))
  344. o:depends({type = "hysteria", flag_quicparam = "1"})
  345. o.datatype = "uinteger"
  346. o.rmempty = true
  347. o.default = "20971520"
  348. o = s:option(Value, "maxidletimeout", translate("QUIC maxIdleTimeout(Unit:second)"))
  349. o:depends({type = "hysteria", flag_quicparam = "1"})
  350. o.rmempty = true
  351. o.datatype = "uinteger"
  352. o.default = "30"
  353. o = s:option(Value, "keepaliveperiod", translate("The keep-alive period.(Unit:second)"))
  354. o:depends({type = "hysteria", flag_quicparam = "1"})
  355. o.rmempty = true
  356. o.datatype = "uinteger"
  357. o.default = "10"
  358. o = s:option(Flag, "disablepathmtudiscovery", translate("Disable Path MTU discovery"))
  359. o:depends({type = "hysteria", flag_quicparam = "1"})
  360. o.rmempty = true
  361. o.default = false
  362. --[[ Shadow-TLS Options ]]
  363. o = s:option(ListValue, "shadowtls_protocol", translate("shadowTLS protocol Version"))
  364. o:depends("type", "shadowtls")
  365. o:value("v3", translate("Enable V3 protocol."))
  366. o:value("v2", translate("Enable V2 protocol."))
  367. o.default = "v3"
  368. o.rmempty = true
  369. o = s:option(Flag, "strict", translate("TLS 1.3 Strict mode"))
  370. o:depends("type", "shadowtls")
  371. o.default = "1"
  372. o.rmempty = false
  373. o = s:option(Flag, "fastopen", translate("TCP Fast Open"))
  374. o:depends("type", "shadowtls")
  375. o.default = "0"
  376. o.rmempty = false
  377. o = s:option(Flag, "disable_nodelay", translate("Disable TCP No_delay"))
  378. o:depends("type", "shadowtls")
  379. o.default = "0"
  380. o.rmempty = true
  381. o = s:option(Value, "shadowtls_sni", translate("shadow-TLS SNI"))
  382. o:depends("type", "shadowtls")
  383. o.datatype = "host"
  384. o.rmempty = true
  385. o.default = ""
  386. --[[ add a ListValue for Choose chain type,sslocal or vmess ]]
  387. o = s:option(ListValue, "chain_type", translate("Shadow-TLS ChainPoxy type"))
  388. o:depends("type", "shadowtls")
  389. if is_finded("sslocal") then
  390. o:value("sslocal", translate("Shadowsocks-rust Version"))
  391. end
  392. if is_finded("xray") or is_finded("v2ray") then
  393. o:value("vmess", translate("Vmess Protocol"))
  394. end
  395. o.default = "sslocal"
  396. o.rmempty = false
  397. o = s:option(Value, "sslocal_password",translate("Shadowsocks password"))
  398. o:depends({type = "shadowtls", chain_type = "sslocal"})
  399. o.rmempty = true
  400. o = s:option(ListValue, "sslocal_method", translate("Encrypt Method"))
  401. o:depends({type = "shadowtls", chain_type = "sslocal"})
  402. for _, v in ipairs(encrypt_methods_ss) do
  403. o:value(v)
  404. end
  405. o = s:option(Value, "vmess_uuid", translate("Vmess UUID"))
  406. o:depends({type = "shadowtls", chain_type = "vmess"})
  407. o.rmempty = false
  408. o.default = uuid
  409. o = s:option(ListValue, "vmess_method", translate("Encrypt Method"))
  410. o:depends({type = "shadowtls", chain_type = "vmess"})
  411. for _, v in ipairs(securitys) do
  412. o:value(v, v:lower())
  413. end
  414. o.rmempty = true
  415. o.default="auto"
  416. -- [[ TUIC ]]
  417. -- TuicNameId
  418. o = s:option(Value, "tuic_uuid", translate("TUIC User UUID"))
  419. o.rmempty = true
  420. o.default = uuid
  421. o:depends("type", "tuic")
  422. --Tuic IP
  423. o = s:option(Value, "tuic_ip", translate("TUIC Server IP Address"))
  424. o.rmempty = true
  425. o.datatype = "ip4addr"
  426. o.default = ""
  427. o:depends("type", "tuic")
  428. -- Tuic Password
  429. o = s:option(Value, "tuic_passwd", translate("TUIC User Password"))
  430. o.rmempty = true
  431. o.default = ""
  432. o:depends("type", "tuic")
  433. o = s:option(ListValue, "udp_relay_mode", translate("UDP relay mode"))
  434. o:depends("type", "tuic")
  435. o:value("native", translate("native UDP characteristics"))
  436. o:value("quic", translate("lossless UDP relay using QUIC streams"))
  437. o.default = "native"
  438. o.rmempty = true
  439. o = s:option(ListValue, "congestion_control", translate("Congestion control algorithm"))
  440. o:depends("type", "tuic")
  441. o:value("bbr", translate("BBR"))
  442. o:value("cubic", translate("CUBIC"))
  443. o:value("new_reno", translate("New Reno"))
  444. o.default = "cubic"
  445. o.rmempty = true
  446. o = s:option(Value, "heartbeat", translate("Heartbeat interval(second)"))
  447. o:depends("type", "tuic")
  448. o.datatype = "uinteger"
  449. o.default = "3"
  450. o.rmempty = true
  451. o = s:option(Value, "timeout", translate("Timeout for establishing a connection to server(second)"))
  452. o:depends("type", "tuic")
  453. o.datatype = "uinteger"
  454. o.default = "8"
  455. o.rmempty = true
  456. o = s:option(Value, "gc_interval", translate("Garbage collection interval(second)"))
  457. o:depends("type", "tuic")
  458. o.datatype = "uinteger"
  459. o.default = "3"
  460. o.rmempty = true
  461. o = s:option(Value, "gc_lifetime", translate("Garbage collection lifetime(second)"))
  462. o:depends("type", "tuic")
  463. o.datatype = "uinteger"
  464. o.default = "15"
  465. o.rmempty = true
  466. o = s:option(Value, "send_window", translate("TUIC send window"))
  467. o:depends("type", "tuic")
  468. o.datatype = "uinteger"
  469. o.default = 20971520
  470. o.rmempty = true
  471. o = s:option(Value, "receive_window", translate("TUIC receive window"))
  472. o:depends("type", "tuic")
  473. o.datatype = "uinteger"
  474. o.default = 10485760
  475. o.rmempty = true
  476. o = s:option(Flag, "disable_sni", translate("Disable SNI"))
  477. o:depends("type", "tuic")
  478. o.default = "0"
  479. o.rmempty = true
  480. o = s:option(Flag, "zero_rtt_handshake", translate("Enable 0-RTT QUIC handshake"))
  481. o:depends("type", "tuic")
  482. o.default = "0"
  483. o.rmempty = true
  484. -- Tuic settings for the local inbound socks5 server
  485. o = s:option(Flag, "tuic_dual_stack", translate("Dual-stack Listening Socket"))
  486. o:depends("type", "tuic")
  487. o.default = "0"
  488. o.rmempty = true
  489. o = s:option(Value, "tuic_max_package_size", translate("Maximum packet size the socks5 server can receive from external"))
  490. o:depends("type", "tuic")
  491. o.datatype = "uinteger"
  492. o.default = 1500
  493. o.rmempty = true
  494. -- AlterId
  495. o = s:option(Value, "alter_id", translate("AlterId"))
  496. o.datatype = "port"
  497. o.default = 16
  498. o.rmempty = true
  499. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  500. -- VmessId
  501. o = s:option(Value, "vmess_id", translate("Vmess/VLESS ID (UUID)"))
  502. o.rmempty = true
  503. o.default = uuid
  504. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  505. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  506. -- VLESS Encryption
  507. o = s:option(Value, "vless_encryption", translate("VLESS Encryption"))
  508. o.rmempty = true
  509. o.default = "none"
  510. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  511. -- 加密方式
  512. o = s:option(ListValue, "security", translate("Encrypt Method"))
  513. for _, v in ipairs(securitys) do
  514. o:value(v, v:upper())
  515. end
  516. o.rmempty = true
  517. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  518. -- SOCKS Version
  519. o = s:option(ListValue, "socks_ver", translate("Socks Version"))
  520. o:value("4", "Socks4")
  521. o:value("4a", "Socks4A")
  522. o:value("5", "Socks5")
  523. o.rmempty = true
  524. o.default = "5"
  525. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  526. -- 传输协议
  527. o = s:option(ListValue, "transport", translate("Transport"))
  528. o:value("tcp", "TCP")
  529. o:value("kcp", "mKCP")
  530. o:value("ws", "WebSocket")
  531. o:value("h2", "HTTP/2")
  532. o:value("quic", "QUIC")
  533. o:value("grpc", "gRPC")
  534. o.rmempty = true
  535. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  536. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  537. o:depends({type = "v2ray", v2ray_protocol = "trojan"})
  538. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  539. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  540. o:depends({type = "v2ray", v2ray_protocol = "http"})
  541. -- [[ TCP部分 ]]--
  542. -- TCP伪装
  543. o = s:option(ListValue, "tcp_guise", translate("Camouflage Type"))
  544. o:depends("transport", "tcp")
  545. o:value("none", translate("None"))
  546. o:value("http", "HTTP")
  547. o.rmempty = true
  548. -- HTTP域名
  549. o = s:option(Value, "http_host", translate("HTTP Host"))
  550. o:depends("tcp_guise", "http")
  551. o.rmempty = true
  552. -- HTTP路径
  553. o = s:option(Value, "http_path", translate("HTTP Path"))
  554. o:depends("tcp_guise", "http")
  555. o.rmempty = true
  556. -- [[ WS部分 ]]--
  557. -- WS域名
  558. o = s:option(Value, "ws_host", translate("WebSocket Host"))
  559. o:depends({transport = "ws", tls = false})
  560. o.datatype = "hostname"
  561. o.rmempty = true
  562. -- WS路径
  563. o = s:option(Value, "ws_path", translate("WebSocket Path"))
  564. o:depends("transport", "ws")
  565. o.rmempty = true
  566. if is_finded("v2ray") then
  567. -- WS前置数据
  568. o = s:option(Value, "ws_ed", translate("Max Early Data"))
  569. o:depends("ws_ed_enable", true)
  570. o.datatype = "uinteger"
  571. o:value("2048")
  572. o.rmempty = true
  573. -- WS前置数据标头
  574. o = s:option(Value, "ws_ed_header", translate("Early Data Header Name"))
  575. o:depends("ws_ed_enable", true)
  576. o:value("Sec-WebSocket-Protocol")
  577. o.rmempty = true
  578. end
  579. -- [[ H2部分 ]]--
  580. -- H2域名
  581. o = s:option(Value, "h2_host", translate("HTTP/2 Host"))
  582. o:depends("transport", "h2")
  583. o.rmempty = true
  584. -- H2路径
  585. o = s:option(Value, "h2_path", translate("HTTP/2 Path"))
  586. o:depends("transport", "h2")
  587. o.rmempty = true
  588. -- gRPC
  589. o = s:option(Value, "serviceName", translate("gRPC Service Name"))
  590. o:depends("transport", "grpc")
  591. o.rmempty = true
  592. if is_finded("xray") then
  593. -- gPRC模式
  594. o = s:option(ListValue, "grpc_mode", translate("gRPC Mode"))
  595. o:depends("transport", "grpc")
  596. o:value("gun", translate("Gun"))
  597. o:value("multi", translate("Multi"))
  598. o.rmempty = true
  599. end
  600. if is_finded("xray") then
  601. -- gRPC初始窗口
  602. o = s:option(Value, "initial_windows_size", translate("Initial Windows Size"))
  603. o.datatype = "uinteger"
  604. o:depends("transport", "grpc")
  605. o.default = 0
  606. o.rmempty = true
  607. -- H2/gRPC健康检查
  608. o = s:option(Flag, "health_check", translate("H2/gRPC Health Check"))
  609. o:depends("transport", "h2")
  610. o:depends("transport", "grpc")
  611. o.rmempty = true
  612. o = s:option(Value, "read_idle_timeout", translate("H2 Read Idle Timeout"))
  613. o.datatype = "uinteger"
  614. o:depends({health_check = true, transport = "h2"})
  615. o.default = 60
  616. o.rmempty = true
  617. o = s:option(Value, "idle_timeout", translate("gRPC Idle Timeout"))
  618. o.datatype = "uinteger"
  619. o:depends({health_check = true, transport = "grpc"})
  620. o.default = 60
  621. o.rmempty = true
  622. o = s:option(Value, "health_check_timeout", translate("Health Check Timeout"))
  623. o.datatype = "uinteger"
  624. o:depends("health_check", 1)
  625. o.default = 20
  626. o.rmempty = true
  627. o = s:option(Flag, "permit_without_stream", translate("Permit Without Stream"))
  628. o:depends({health_check = true, transport = "grpc"})
  629. o.rmempty = true
  630. end
  631. -- [[ QUIC部分 ]]--
  632. o = s:option(ListValue, "quic_security", translate("QUIC Security"))
  633. o:depends("transport", "quic")
  634. o:value("none", translate("None"))
  635. o:value("aes-128-gcm", translate("aes-128-gcm"))
  636. o:value("chacha20-poly1305", translate("chacha20-poly1305"))
  637. o.rmempty = true
  638. o = s:option(Value, "quic_key", translate("QUIC Key"))
  639. o:depends("transport", "quic")
  640. o.rmempty = true
  641. o = s:option(ListValue, "quic_guise", translate("Header"))
  642. o:depends("transport", "quic")
  643. o.rmempty = true
  644. o:value("none", translate("None"))
  645. o:value("srtp", translate("VideoCall (SRTP)"))
  646. o:value("utp", translate("BitTorrent (uTP)"))
  647. o:value("wechat-video", translate("WechatVideo"))
  648. o:value("dtls", translate("DTLS 1.2"))
  649. o:value("wireguard", translate("WireGuard"))
  650. -- [[ mKCP部分 ]]--
  651. o = s:option(ListValue, "kcp_guise", translate("Camouflage Type"))
  652. o:depends("transport", "kcp")
  653. o:value("none", translate("None"))
  654. o:value("srtp", translate("VideoCall (SRTP)"))
  655. o:value("utp", translate("BitTorrent (uTP)"))
  656. o:value("wechat-video", translate("WechatVideo"))
  657. o:value("dtls", translate("DTLS 1.2"))
  658. o:value("wireguard", translate("WireGuard"))
  659. o.rmempty = true
  660. o = s:option(Value, "mtu", translate("MTU"))
  661. o.datatype = "uinteger"
  662. o:depends("transport", "kcp")
  663. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  664. -- o.default = 1350
  665. o.rmempty = true
  666. o = s:option(Value, "tti", translate("TTI"))
  667. o.datatype = "uinteger"
  668. o:depends("transport", "kcp")
  669. o.default = 50
  670. o.rmempty = true
  671. o = s:option(Value, "uplink_capacity", translate("Uplink Capacity(Default:Mbps)"))
  672. o.datatype = "uinteger"
  673. o:depends("transport", "kcp")
  674. o:depends("type", "hysteria")
  675. o.default = 5
  676. o.rmempty = true
  677. o = s:option(Value, "downlink_capacity", translate("Downlink Capacity(Default:Mbps)"))
  678. o.datatype = "uinteger"
  679. o:depends("transport", "kcp")
  680. o:depends("type", "hysteria")
  681. o.default = 20
  682. o.rmempty = true
  683. o = s:option(Value, "read_buffer_size", translate("Read Buffer Size"))
  684. o.datatype = "uinteger"
  685. o:depends("transport", "kcp")
  686. o.default = 2
  687. o.rmempty = true
  688. o = s:option(Value, "write_buffer_size", translate("Write Buffer Size"))
  689. o.datatype = "uinteger"
  690. o:depends("transport", "kcp")
  691. o.default = 2
  692. o.rmempty = true
  693. o = s:option(Value, "seed", translate("Obfuscate password (optional)"))
  694. o:depends("transport", "kcp")
  695. o.rmempty = true
  696. o = s:option(Flag, "congestion", translate("Congestion"))
  697. o:depends("transport", "kcp")
  698. o.rmempty = true
  699. -- [[ WireGuard 部分 ]]--
  700. o = s:option(DynamicList, "local_addresses", translate("Local addresses"))
  701. o.datatype = "cidr"
  702. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  703. o.rmempty = true
  704. o = s:option(Value, "private_key", translate("Private key"))
  705. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  706. o.password = true
  707. o.rmempty = true
  708. o = s:option(Value, "peer_pubkey", translate("Peer public key"))
  709. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  710. o.rmempty = true
  711. o = s:option(Value, "preshared_key", translate("Pre-shared key"))
  712. o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
  713. o.password = true
  714. o.rmempty = true
  715. -- [[ TLS ]]--
  716. o = s:option(Flag, "tls", translate("TLS"))
  717. o.rmempty = true
  718. o.default = "0"
  719. o:depends({type = "v2ray", v2ray_protocol = "vless", reality = false})
  720. o:depends({type = "v2ray", v2ray_protocol = "vmess", reality = false})
  721. o:depends({type = "v2ray", v2ray_protocol = "trojan", reality = false})
  722. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks", reality = false})
  723. o:depends({type = "v2ray", v2ray_protocol = "socks", socks_ver = "5", reality = false})
  724. o:depends({type = "v2ray", v2ray_protocol = "http", reality = false})
  725. o:depends("type", "trojan")
  726. o:depends("type", "hysteria")
  727. -- [[ TLS部分 ]] --
  728. o = s:option(Flag, "tls_sessionTicket", translate("Session Ticket"))
  729. o:depends({type = "trojan", tls = true})
  730. o.default = "0"
  731. if is_finded("xray") then
  732. -- [[ REALITY ]]
  733. o = s:option(Flag, "reality", translate("REALITY"))
  734. o.rmempty = true
  735. o.default = "0"
  736. o:depends({type = "v2ray", v2ray_protocol = "vless", tls = false})
  737. o = s:option(Value, "reality_publickey", translate("Public key"))
  738. o.rmempty = true
  739. o:depends({type = "v2ray", v2ray_protocol = "vless", reality = true})
  740. o = s:option(Value, "reality_shortid", translate("Short ID"))
  741. o.rmempty = true
  742. o:depends({type = "v2ray", v2ray_protocol = "vless", reality = true})
  743. o = s:option(Value, "reality_spiderx", translate("spiderX"))
  744. o.rmempty = true
  745. o:depends({type = "v2ray", v2ray_protocol = "vless", reality = true})
  746. -- [[ XTLS ]]--
  747. o = s:option(ListValue, "tls_flow", translate("Flow"))
  748. for _, v in ipairs(tls_flows) do
  749. o:value(v, translate(v))
  750. end
  751. o.rmempty = true
  752. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "tcp", tls = true})
  753. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "tcp", reality = true})
  754. -- [[ uTLS ]]--
  755. o = s:option(Value, "fingerprint", translate("Finger Print"))
  756. o.default = "chrome"
  757. o:value("chrome", translate("chrome"))
  758. o:value("firefox", translate("firefox"))
  759. o:value("safari", translate("safari"))
  760. o:value("ios", translate("ios"))
  761. o:value("android", translate("android"))
  762. o:value("edge", translate("edge"))
  763. o:value("360", translate("360"))
  764. o:value("qq", translate("qq"))
  765. o:value("random", translate("random"))
  766. o:value("randomized", translate("randomized"))
  767. o:value("", translate("disable"))
  768. o:depends({type = "v2ray", tls = true})
  769. o:depends({type = "v2ray", reality = true})
  770. end
  771. o = s:option(Value, "tls_host", translate("TLS Host"))
  772. o.datatype = "hostname"
  773. o:depends("tls", true)
  774. o:depends("reality", true)
  775. o.rmempty = true
  776. o = s:option(DynamicList, "tls_alpn", translate("TLS ALPN"))
  777. o:depends("tls", true)
  778. o:depends("type", "tuic")
  779. o:depends("type", "hysteria")
  780. o.rmempty = true
  781. -- [[ allowInsecure ]]--
  782. o = s:option(Flag, "insecure", translate("allowInsecure"))
  783. o.rmempty = false
  784. o:depends("tls", true)
  785. o:depends("type", "hysteria")
  786. o.description = translate("If true, allowss insecure connection at TLS client, e.g., TLS server uses unverifiable certificates.")
  787. -- [[ Hysteria2 TLS pinSHA256 ]] --
  788. o = s:option(Value, "pinsha256", translate("Certificate fingerprint"))
  789. o:depends({type = "hysteria", insecure = true })
  790. o.rmempty = true
  791. -- [[ Mux ]]--
  792. o = s:option(Flag, "mux", translate("Mux"))
  793. o.rmempty = false
  794. o.default = false
  795. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  796. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  797. o:depends({type = "v2ray", v2ray_protocol = "trojan"})
  798. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  799. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  800. o:depends({type = "v2ray", v2ray_protocol = "http"})
  801. o = s:option(ListValue, "concurrency", translate("concurrency"))
  802. o.rmempty = true
  803. o.default = "-1"
  804. o:value("-1", translate("disable"))
  805. o:value("8", translate("8"))
  806. o:depends("mux", true)
  807. o = s:option(ListValue, "xudpConcurrency", translate("xudpConcurrency"))
  808. o.rmempty = true
  809. o.default = "16"
  810. o:value("16", translate("16"))
  811. o:value("-1", translate("disable"))
  812. o:depends("mux", true)
  813. o = s:option(ListValue, "xudpProxyUDP443", translate("xudpProxyUDP443"))
  814. o.rmempty = true
  815. o.default = "reject"
  816. o:value("reject", translate("reject"))
  817. o:value("allow", translate("allow"))
  818. o:value("skip", translate("skip"))
  819. o:depends("mux", true)
  820. -- [[ MPTCP ]]--
  821. o = s:option(Flag, "mptcp", translate("MPTCP"))
  822. o.rmempty = false
  823. o.default = false
  824. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  825. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  826. o:depends({type = "v2ray", v2ray_protocol = "trojan"})
  827. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  828. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  829. o:depends({type = "v2ray", v2ray_protocol = "http"})
  830. -- [[ custom_tcpcongestion 连接服务器节点的 TCP 拥塞控制算法 ]]--
  831. o = s:option(ListValue, "custom_tcpcongestion", translate("custom_tcpcongestion"))
  832. o.rmempty = true
  833. o.default = ""
  834. o:value("", translate("comment_tcpcongestion_disable"))
  835. o:value("bbr", translate("BBR"))
  836. o:value("cubic", translate("CUBIC"))
  837. o:value("reno", translate("Reno"))
  838. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  839. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  840. o:depends({type = "v2ray", v2ray_protocol = "trojan"})
  841. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  842. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  843. o:depends({type = "v2ray", v2ray_protocol = "http"})
  844. -- [[ custom_sniffing 流量嗅探 ]]--
  845. o = s:option(Flag, "custom_sniffing", translate("custom_sniffing"))
  846. o.rmempty = false
  847. o.default = true
  848. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  849. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  850. o:depends({type = "v2ray", v2ray_protocol = "trojan"})
  851. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  852. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  853. o:depends({type = "v2ray", v2ray_protocol = "http"})
  854. -- [[ custom_domainsExcluded 流量嗅探域名排除列表 ]]--
  855. o = s:option(Flag, "custom_domainsExcluded", translate("custom_domainsExcluded"))
  856. o.rmempty = false
  857. o.default = true
  858. o:depends("custom_sniffing", true)
  859. -- [[ custom_routeOnly 嗅探得到的域名仅用于 Xray 路由 ]]--
  860. o = s:option(Flag, "custom_routeOnly", translate("custom_routeOnly"))
  861. o.rmempty = false
  862. o.default = false
  863. o:depends("custom_sniffing", true)
  864. -- [[ custom_dns_enable Xray DNS 功能 ]]--
  865. o = s:option(Flag, "custom_dns_enable", translate("custom_dns_enable"))
  866. o.rmempty = false
  867. o.default = false
  868. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  869. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  870. o:depends({type = "v2ray", v2ray_protocol = "trojan"})
  871. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  872. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  873. o:depends({type = "v2ray", v2ray_protocol = "http"})
  874. o.description = translate("comment_dns_inbound_enable")
  875. -- [[ custom_dns_local 本地 DNS ]]--
  876. o = s:option(ListValue, "custom_dns_local", translate("custom_dns_local"))
  877. o.rmempty = true
  878. o.default = "https+local://223.5.5.5/dns-query"
  879. o:value("https+local://223.5.5.5/dns-query", translate("https+local://223.5.5.5/dns-query"))
  880. o:value("https+local://119.29.29.29/dns-query", translate("https+local://119.29.29.29/dns-query"))
  881. o:depends("custom_dns_enable", true)
  882. -- [[ custom_dns_remote 远端 DNS ]]--
  883. o = s:option(ListValue, "custom_dns_remote", translate("custom_dns_remote"))
  884. o.rmempty = true
  885. o.default = "https://1.1.1.1/dns-query"
  886. o:value("https://1.1.1.1/dns-query", translate("https://1.1.1.1/dns-query"))
  887. o:value("https://8.8.8.8/dns-query", translate("https://8.8.8.8/dns-query"))
  888. o:depends("custom_dns_enable", true)
  889. -- [[ custom_dns_remote_domains 远端 DNS 域名列表 ]]--
  890. o = s:option(ListValue, "custom_dns_remote_domains", translate("custom_dns_remote_domains"))
  891. o.rmempty = true
  892. o.default = "geosite:geolocation-!cn"
  893. o:value("geosite:geolocation-!cn", translate("geosite:geolocation-!cn"))
  894. o:depends("custom_dns_enable", true)
  895. -- [[ custom_nonIPQuery 非 A 和 AAAA 记录处理方式 ]]--
  896. o = s:option(ListValue, "custom_nonIPQuery", translate("custom_nonIPQuery"))
  897. o.rmempty = true
  898. o.default = "skip"
  899. o:value("skip", translate("skip"))
  900. o:value("drop", translate("drop"))
  901. o:depends("custom_dns_enable", true)
  902. -- [[ custom_nonIPQuery_outbound_tag 非 A 和 AAAA 记录查询方式 ]]--
  903. o = s:option(ListValue, "custom_nonIPQuery_outbound_tag", translate("custom_nonIPQuery_outbound_tag"))
  904. o.rmempty = true
  905. o.default = "direct"
  906. o:value("direct", translate("direct"))
  907. o:value("proxy", translate("proxy"))
  908. o:depends({custom_nonIPQuery = "skip"})
  909. -- [[ custom_dokodemo_door_dns_address 查询非 A 和 AAAA 记录 DNS ]]--
  910. o = s:option(ListValue, "custom_dokodemo_door_dns_address", translate("custom_dokodemo_door_dns_address"))
  911. o.rmempty = true
  912. o.default = "223.5.5.5"
  913. o:value("223.5.5.5", translate("223.5.5.5"))
  914. o:value("119.29.29.29", translate("119.29.29.29"))
  915. o:value("1.1.1.1", translate("1.1.1.1"))
  916. o:value("8.8.8.8", translate("8.8.8.8"))
  917. o:depends({custom_nonIPQuery = "skip"})
  918. -- [[ custom_log Xray 日志功能 ]]--
  919. o = s:option(Flag, "custom_log", translate("custom_log"))
  920. o.rmempty = false
  921. o.default = false
  922. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  923. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  924. o:depends({type = "v2ray", v2ray_protocol = "trojan"})
  925. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  926. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  927. o:depends({type = "v2ray", v2ray_protocol = "http"})
  928. -- [[ custom_loglevel 日志级别 ]]--
  929. o = s:option(ListValue, "custom_loglevel", translate("custom_loglevel"))
  930. o.rmempty = true
  931. o.default = "warning"
  932. o:value("error", translate("error"))
  933. o:value("warning", translate("warning"))
  934. o:value("info", translate("info"))
  935. o:value("debug", translate("debug"))
  936. o:depends("custom_log", true)
  937. -- [[ custom_dnsLog DNS 查询记录 ]]--
  938. o = s:option(Flag, "custom_dnsLog", translate("custom_dnsLog"))
  939. o.rmempty = true
  940. o.default = true
  941. o:depends("custom_log", true)
  942. -- [[ custom_access 访问记录 ]]--
  943. o = s:option(ListValue, "custom_access", translate("custom_access"))
  944. o.rmempty = true
  945. o.default = "/tmp/access.log"
  946. o:value("/tmp/access.log", translate("/tmp/access.log"))
  947. o:value("none", translate("none"))
  948. o:depends("custom_log", true)
  949. -- [[ custom_error 错误记录 ]]--
  950. o = s:option(ListValue, "custom_error", translate("custom_error"))
  951. o.rmempty = true
  952. o.default = "/tmp/error.log"
  953. o:value("/tmp/error.log", translate("/tmp/error.log"))
  954. o:value("none", translate("none"))
  955. o:depends("custom_log", true)
  956. -- [[ Cert ]]--
  957. o = s:option(Flag, "certificate", translate("Self-signed Certificate"))
  958. o.rmempty = true
  959. o.default = "0"
  960. o:depends("type", "tuic")
  961. o:depends({type = "hysteria", insecure = false})
  962. o:depends({type = "trojan", tls = true, insecure = false})
  963. o:depends({type = "v2ray", v2ray_protocol = "vmess", tls = true, insecure = false})
  964. o:depends({type = "v2ray", v2ray_protocol = "vless", tls = true, insecure = false})
  965. o.description = translate("If you have a self-signed certificate,please check the box")
  966. o = s:option(DummyValue, "upload", translate("Upload"))
  967. o.template = "shadowsocksr/certupload"
  968. o:depends("certificate", 1)
  969. cert_dir = "/etc/ssl/private/"
  970. local path
  971. luci.http.setfilehandler(function(meta, chunk, eof)
  972. if not fd then
  973. if (not meta) or (not meta.name) or (not meta.file) then
  974. return
  975. end
  976. fd = nixio.open(cert_dir .. meta.file, "w")
  977. if not fd then
  978. path = translate("Create upload file error.")
  979. return
  980. end
  981. end
  982. if chunk and fd then
  983. fd:write(chunk)
  984. end
  985. if eof and fd then
  986. fd:close()
  987. fd = nil
  988. path = '/etc/ssl/private/' .. meta.file .. ''
  989. end
  990. end)
  991. if luci.http.formvalue("upload") then
  992. local f = luci.http.formvalue("ulfile")
  993. if #f <= 0 then
  994. path = translate("No specify upload file.")
  995. end
  996. end
  997. o = s:option(Value, "certpath", translate("Current Certificate Path"))
  998. o:depends("certificate", 1)
  999. o:value("/etc/ssl/private/ca.pem")
  1000. o.description = translate("Please confirm the current certificate path")
  1001. o.default = "/etc/ssl/private/ca.pem"
  1002. o = s:option(Flag, "fast_open", translate("TCP Fast Open"))
  1003. o.rmempty = true
  1004. o.default = "0"
  1005. o:depends("type", "ssr")
  1006. o:depends("type", "ss")
  1007. o:depends("type", "trojan")
  1008. o:depends("type", "hysteria")
  1009. o = s:option(Flag, "switch_enable", translate("Enable Auto Switch"))
  1010. o.rmempty = false
  1011. o.default = "1"
  1012. o = s:option(Value, "local_port", translate("Local Port"))
  1013. o.datatype = "port"
  1014. o.default = 1234
  1015. o.rmempty = false
  1016. if is_finded("kcptun-client") then
  1017. o = s:option(Flag, "kcp_enable", translate("KcpTun Enable"))
  1018. o.rmempty = true
  1019. o.default = "0"
  1020. o:depends("type", "ssr")
  1021. o:depends("type", "ss")
  1022. o = s:option(Value, "kcp_port", translate("KcpTun Port"))
  1023. o.datatype = "portrange"
  1024. o.default = 4000
  1025. o:depends("type", "ssr")
  1026. o:depends("type", "ss")
  1027. o = s:option(Value, "kcp_password", translate("KcpTun Password"))
  1028. o.password = true
  1029. o:depends("type", "ssr")
  1030. o:depends("type", "ss")
  1031. o = s:option(Value, "kcp_param", translate("KcpTun Param"))
  1032. o.default = "--nocomp"
  1033. o:depends("type", "ssr")
  1034. o:depends("type", "ss")
  1035. end
  1036. return m