client-config.lua 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  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, kcp_enable
  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. -- aead
  45. "aes-128-gcm",
  46. "aes-192-gcm",
  47. "aes-256-gcm",
  48. "chacha20-ietf-poly1305",
  49. "xchacha20-ietf-poly1305"
  50. --[[ stream
  51. "none",
  52. "plain",
  53. "table",
  54. "rc4",
  55. "rc4-md5",
  56. "aes-128-cfb",
  57. "aes-192-cfb",
  58. "aes-256-cfb",
  59. "aes-128-ctr",
  60. "aes-192-ctr",
  61. "aes-256-ctr",
  62. "bf-cfb",
  63. "camellia-128-cfb",
  64. "camellia-192-cfb",
  65. "camellia-256-cfb",
  66. "salsa20",
  67. "chacha20",
  68. "chacha20-ietf" ]]
  69. }
  70. local encrypt_methods_v2ray_ss = {
  71. -- xray_ss
  72. "none",
  73. "plain",
  74. -- aead
  75. "aes-128-gcm",
  76. "aes-256-gcm",
  77. "chacha20-poly1305",
  78. "chacha20-ietf-poly1305",
  79. "xchacha20-ietf-poly1305",
  80. "aead_aes_128_gcm",
  81. "aead_aes_256_gcm",
  82. "aead_chacha20_poly1305",
  83. "aead_xchacha20_poly1305"
  84. }
  85. local protocol = {
  86. -- ssr
  87. "origin",
  88. "verify_deflate",
  89. "auth_sha1_v4",
  90. "auth_aes128_sha1",
  91. "auth_aes128_md5",
  92. "auth_chain_a",
  93. "auth_chain_b",
  94. "auth_chain_c",
  95. "auth_chain_d",
  96. "auth_chain_e",
  97. "auth_chain_f"
  98. }
  99. obfs = {
  100. -- ssr
  101. "plain",
  102. "http_simple",
  103. "http_post",
  104. "random_head",
  105. "tls1.2_ticket_auth"
  106. }
  107. local securitys = {
  108. -- vmess
  109. "auto",
  110. "none",
  111. "zero",
  112. "aes-128-gcm",
  113. "chacha20-poly1305"
  114. }
  115. local flows = {
  116. -- xlts
  117. "xtls-rprx-origin",
  118. "xtls-rprx-origin-udp443",
  119. "xtls-rprx-direct",
  120. "xtls-rprx-direct-udp443",
  121. "xtls-rprx-splice",
  122. "xtls-rprx-splice-udp443"
  123. }
  124. m = Map("shadowsocksr", translate("Edit ShadowSocksR Server"))
  125. m.redirect = luci.dispatcher.build_url("admin/services/shadowsocksr/servers")
  126. if m.uci:get("shadowsocksr", sid) ~= "servers" then
  127. luci.http.redirect(m.redirect)
  128. return
  129. end
  130. -- [[ Servers Setting ]]--
  131. s = m:section(NamedSection, sid, "servers")
  132. s.anonymous = true
  133. s.addremove = false
  134. o = s:option(DummyValue, "ssr_url", "SS/SSR/V2RAY/TROJAN URL")
  135. o.rawhtml = true
  136. o.template = "shadowsocksr/ssrurl"
  137. o.value = sid
  138. o = s:option(ListValue, "type", translate("Server Node Type"))
  139. if is_finded("xray") or is_finded("v2ray") then
  140. o:value("v2ray", translate("V2Ray/XRay"))
  141. end
  142. if is_finded("ssr-redir") then
  143. o:value("ssr", translate("ShadowsocksR"))
  144. end
  145. if is_finded("sslocal") or is_finded("ss-redir") then
  146. o:value("ss", translate("Shadowsocks New Version"))
  147. end
  148. if is_finded("trojan") then
  149. o:value("trojan", translate("Trojan"))
  150. end
  151. if is_finded("naive") then
  152. o:value("naiveproxy", translate("NaiveProxy"))
  153. end
  154. if is_finded("ipt2socks") then
  155. o:value("socks5", translate("Socks5"))
  156. end
  157. if is_finded("redsocks2") then
  158. o:value("tun", translate("Network Tunnel"))
  159. end
  160. o.description = translate("Using incorrect encryption mothod may causes service fail to start")
  161. o = s:option(Value, "alias", translate("Alias(optional)"))
  162. o = s:option(ListValue, "iface", translate("Network interface to use"))
  163. for _, e in ipairs(luci.sys.net.devices()) do
  164. if e ~= "lo" then
  165. o:value(e)
  166. end
  167. end
  168. o:depends("type", "tun")
  169. o.description = translate("Redirect traffic to this network interface")
  170. o = s:option(ListValue, "v2ray_protocol", translate("V2Ray/XRay protocol"))
  171. o:value("vless", translate("VLESS"))
  172. o:value("vmess", translate("VMess"))
  173. o:value("trojan", translate("Trojan"))
  174. o:value("shadowsocks", translate("Shadowsocks"))
  175. o:value("socks", translate("Socks"))
  176. o:value("http", translate("HTTP"))
  177. o:depends("type", "v2ray")
  178. o = s:option(Value, "server", translate("Server Address"))
  179. o.datatype = "host"
  180. o.rmempty = false
  181. o:depends("type", "ssr")
  182. o:depends("type", "ss")
  183. o:depends("type", "v2ray")
  184. o:depends("type", "trojan")
  185. o:depends("type", "naiveproxy")
  186. o:depends("type", "socks5")
  187. o = s:option(Value, "server_port", translate("Server Port"))
  188. o.datatype = "port"
  189. o.rmempty = false
  190. o:depends("type", "ssr")
  191. o:depends("type", "ss")
  192. o:depends("type", "v2ray")
  193. o:depends("type", "trojan")
  194. o:depends("type", "naiveproxy")
  195. o:depends("type", "socks5")
  196. o = s:option(Flag, "auth_enable", translate("Enable Authentication"))
  197. o.rmempty = false
  198. o.default = "0"
  199. o:depends("type", "socks5")
  200. o:depends({type = "v2ray", v2ray_protocol = "http"})
  201. o:depends({type = "v2ray", v2ray_protocol = "socks"})
  202. o = s:option(Value, "username", translate("Username"))
  203. o.rmempty = true
  204. o:depends("type", "naiveproxy")
  205. o:depends({type = "socks5", auth_enable = true})
  206. o:depends({type = "v2ray", v2ray_protocol = "http", auth_enable = true})
  207. o:depends({type = "v2ray", v2ray_protocol = "socks", auth_enable = true})
  208. o = s:option(Value, "password", translate("Password"))
  209. o.password = true
  210. o.rmempty = true
  211. o:depends("type", "ssr")
  212. o:depends("type", "ss")
  213. o:depends("type", "trojan")
  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:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  219. o:depends({type = "v2ray", v2ray_protocol = "trojan"})
  220. o = s:option(ListValue, "encrypt_method", translate("Encrypt Method"))
  221. for _, v in ipairs(encrypt_methods) do
  222. o:value(v)
  223. end
  224. o.rmempty = true
  225. o:depends("type", "ssr")
  226. o = s:option(ListValue, "encrypt_method_ss", translate("Encrypt Method"))
  227. for _, v in ipairs(encrypt_methods_ss) do
  228. o:value(v)
  229. end
  230. o.rmempty = true
  231. o:depends("type", "ss")
  232. o = s:option(ListValue, "encrypt_method_v2ray_ss", translate("Encrypt Method"))
  233. for _, v in ipairs(encrypt_methods_v2ray_ss) do
  234. o:value(v)
  235. end
  236. o.rmempty = true
  237. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  238. o = s:option(Flag, "ivCheck", translate("Bloom Filter"))
  239. o.rmempty = true
  240. o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
  241. o.default = "1"
  242. -- Shadowsocks Plugin
  243. o = s:option(Value, "plugin", translate("Obfs"))
  244. o:value("none", translate("None"))
  245. if is_finded("obfs-local") then
  246. o:value("obfs-local", translate("obfs-local"))
  247. end
  248. if is_finded("v2ray-plugin") then
  249. o:value("v2ray-plugin", translate("v2ray-plugin"))
  250. end
  251. if is_finded("xray-plugin") then
  252. o:value("xray-plugin", translate("xray-plugin"))
  253. end
  254. o.rmempty = true
  255. o:depends("type", "ss")
  256. o = s:option(Value, "plugin_opts", translate("Plugin Opts"))
  257. o.rmempty = true
  258. o:depends({type = "ss", plugin = "obfs-local"})
  259. o:depends({type = "ss", plugin = "v2ray-plugin"})
  260. o:depends({type = "ss", plugin = "xray-plugin"})
  261. o = s:option(ListValue, "protocol", translate("Protocol"))
  262. for _, v in ipairs(protocol) do
  263. o:value(v)
  264. end
  265. o.rmempty = true
  266. o:depends("type", "ssr")
  267. o = s:option(Value, "protocol_param", translate("Protocol param(optional)"))
  268. o:depends("type", "ssr")
  269. o = s:option(ListValue, "obfs", translate("Obfs"))
  270. for _, v in ipairs(obfs) do
  271. o:value(v)
  272. end
  273. o.rmempty = true
  274. o:depends("type", "ssr")
  275. o = s:option(Value, "obfs_param", translate("Obfs param(optional)"))
  276. o:depends("type", "ssr")
  277. -- VmessId
  278. o = s:option(Value, "vmess_id", translate("Vmess/VLESS ID (UUID)"))
  279. o.rmempty = true
  280. o.default = uuid
  281. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  282. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  283. -- VLESS Encryption
  284. o = s:option(Value, "vless_encryption", translate("VLESS Encryption"))
  285. o.rmempty = true
  286. o.default = "none"
  287. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  288. -- 加密方式
  289. o = s:option(ListValue, "security", translate("Encrypt Method"))
  290. for _, v in ipairs(securitys) do
  291. o:value(v, v:upper())
  292. end
  293. o.rmempty = true
  294. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  295. -- 传输协议
  296. o = s:option(ListValue, "transport", translate("Transport"))
  297. o:value("tcp", "TCP")
  298. o:value("kcp", "mKCP")
  299. o:value("ws", "WebSocket")
  300. o:value("h2", "HTTP/2")
  301. o:value("quic", "QUIC")
  302. o:value("grpc", "gRPC")
  303. o.rmempty = true
  304. o:depends("type", "v2ray")
  305. -- [[ TCP部分 ]]--
  306. -- TCP伪装
  307. o = s:option(ListValue, "tcp_guise", translate("Camouflage Type"))
  308. o:depends("transport", "tcp")
  309. o:value("none", translate("None"))
  310. o:value("http", "HTTP")
  311. o.rmempty = true
  312. -- HTTP域名
  313. o = s:option(Value, "http_host", translate("HTTP Host"))
  314. o:depends("tcp_guise", "http")
  315. o.rmempty = true
  316. -- HTTP路径
  317. o = s:option(Value, "http_path", translate("HTTP Path"))
  318. o:depends("tcp_guise", "http")
  319. o.rmempty = true
  320. -- [[ WS部分 ]]--
  321. -- WS域名
  322. o = s:option(Value, "ws_host", translate("WebSocket Host"))
  323. o:depends({transport = "ws", tls = false})
  324. o.datatype = "hostname"
  325. o.rmempty = true
  326. -- WS路径
  327. o = s:option(Value, "ws_path", translate("WebSocket Path"))
  328. o:depends("transport", "ws")
  329. o.rmempty = true
  330. -- [[ H2部分 ]]--
  331. -- H2域名
  332. o = s:option(Value, "h2_host", translate("HTTP/2 Host"))
  333. o:depends("transport", "h2")
  334. o.rmempty = true
  335. -- H2路径
  336. o = s:option(Value, "h2_path", translate("HTTP/2 Path"))
  337. o:depends("transport", "h2")
  338. o.rmempty = true
  339. -- gRPC
  340. o = s:option(Value, "serviceName", translate("serviceName"))
  341. o:depends("transport", "grpc")
  342. o.rmempty = true
  343. -- gRPC初始窗口
  344. o = s:option(Value, "initial_windows_size", translate("Initial Windows Size"))
  345. o.datatype = "uinteger"
  346. o:depends("transport", "grpc")
  347. o.default = 0
  348. o.rmempty = true
  349. -- H2/gRPC健康检查
  350. o = s:option(Flag, "health_check", translate("H2/gRPC Health Check"))
  351. o:depends("transport", "h2")
  352. o:depends("transport", "grpc")
  353. o.rmempty = true
  354. o = s:option(Value, "read_idle_timeout", translate("H2 Read Idle Timeout"))
  355. o.datatype = "uinteger"
  356. o:depends({health_check = true, transport = "h2"})
  357. o.default = 60
  358. o.rmempty = true
  359. o = s:option(Value, "idle_timeout", translate("gRPC Idle Timeout"))
  360. o.datatype = "uinteger"
  361. o:depends({health_check = true, transport = "grpc"})
  362. o.default = 60
  363. o.rmempty = true
  364. o = s:option(Value, "health_check_timeout", translate("Health Check Timeout"))
  365. o.datatype = "uinteger"
  366. o:depends("health_check", 1)
  367. o.default = 20
  368. o.rmempty = true
  369. o = s:option(Flag, "permit_without_stream", translate("Permit Without Stream"))
  370. o:depends({health_check = true, transport = "grpc"})
  371. o.rmempty = true
  372. -- [[ QUIC部分 ]]--
  373. o = s:option(ListValue, "quic_security", translate("QUIC Security"))
  374. o:depends("transport", "quic")
  375. o:value("none", translate("None"))
  376. o:value("aes-128-gcm", translate("aes-128-gcm"))
  377. o:value("chacha20-poly1305", translate("chacha20-poly1305"))
  378. o.rmempty = true
  379. o = s:option(Value, "quic_key", translate("QUIC Key"))
  380. o:depends("transport", "quic")
  381. o.rmempty = true
  382. o = s:option(ListValue, "quic_guise", translate("Header"))
  383. o:depends("transport", "quic")
  384. o.rmempty = true
  385. o:value("none", translate("None"))
  386. o:value("srtp", translate("VideoCall (SRTP)"))
  387. o:value("utp", translate("BitTorrent (uTP)"))
  388. o:value("wechat-video", translate("WechatVideo"))
  389. o:value("dtls", translate("DTLS 1.2"))
  390. o:value("wireguard", translate("WireGuard"))
  391. -- [[ mKCP部分 ]]--
  392. o = s:option(ListValue, "kcp_guise", translate("Camouflage Type"))
  393. o:depends("transport", "kcp")
  394. o:value("none", translate("None"))
  395. o:value("srtp", translate("VideoCall (SRTP)"))
  396. o:value("utp", translate("BitTorrent (uTP)"))
  397. o:value("wechat-video", translate("WechatVideo"))
  398. o:value("dtls", translate("DTLS 1.2"))
  399. o:value("wireguard", translate("WireGuard"))
  400. o.rmempty = true
  401. o = s:option(Value, "mtu", translate("MTU"))
  402. o.datatype = "uinteger"
  403. o:depends("transport", "kcp")
  404. o.default = 1350
  405. o.rmempty = true
  406. o = s:option(Value, "tti", translate("TTI"))
  407. o.datatype = "uinteger"
  408. o:depends("transport", "kcp")
  409. o.default = 50
  410. o.rmempty = true
  411. o = s:option(Value, "uplink_capacity", translate("Uplink Capacity"))
  412. o.datatype = "uinteger"
  413. o:depends("transport", "kcp")
  414. o.default = 5
  415. o.rmempty = true
  416. o = s:option(Value, "downlink_capacity", translate("Downlink Capacity"))
  417. o.datatype = "uinteger"
  418. o:depends("transport", "kcp")
  419. o.default = 20
  420. o.rmempty = true
  421. o = s:option(Value, "read_buffer_size", translate("Read Buffer Size"))
  422. o.datatype = "uinteger"
  423. o:depends("transport", "kcp")
  424. o.default = 2
  425. o.rmempty = true
  426. o = s:option(Value, "write_buffer_size", translate("Write Buffer Size"))
  427. o.datatype = "uinteger"
  428. o:depends("transport", "kcp")
  429. o.default = 2
  430. o.rmempty = true
  431. o = s:option(Value, "seed", translate("Obfuscate password (optional)"))
  432. o:depends({v2ray_protocol = "vless", transport = "kcp"})
  433. o.rmempty = true
  434. o = s:option(Flag, "congestion", translate("Congestion"))
  435. o:depends("transport", "kcp")
  436. o.rmempty = true
  437. -- [[ TLS ]]--
  438. o = s:option(Flag, "tls", translate("TLS"))
  439. o.rmempty = true
  440. o.default = "0"
  441. o:depends({type = "v2ray", xtls = false})
  442. -- o:depends({type = "v2ray", v2ray_protocol = "vless", xtls = false})
  443. o:depends("type", "trojan")
  444. -- XTLS
  445. if is_finded("xray") then
  446. o = s:option(Flag, "xtls", translate("XTLS"))
  447. o.rmempty = true
  448. o.default = "0"
  449. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "tcp", tls = false})
  450. o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "kcp", tls = false})
  451. o:depends({type = "v2ray", v2ray_protocol = "trojan", transport = "tcp", tls = false})
  452. o:depends({type = "v2ray", v2ray_protocol = "trojan", transport = "kcp", tls = false})
  453. end
  454. -- Flow
  455. o = s:option(Value, "vless_flow", translate("Flow"))
  456. for _, v in ipairs(flows) do
  457. o:value(v, translate(v))
  458. end
  459. o.rmempty = true
  460. o.default = "xtls-rprx-splice"
  461. o:depends("xtls", true)
  462. -- [[ TLS部分 ]] --
  463. o = s:option(Flag, "tls_sessionTicket", translate("Session Ticket"))
  464. o:depends({type = "trojan", tls = true})
  465. o.default = "0"
  466. -- [[ uTLS ]]--
  467. o = s:option(ListValue, "fingerprint", translate("Finger Print"))
  468. o:value("disable", translate("disable"))
  469. o:value("firefox", translate("firefox"))
  470. o:value("chrome", translate("chrome"))
  471. o:value("safari", translate("safari"))
  472. o:value("randomized", translate("randomized"))
  473. o:depends({type = "v2ray", tls = true})
  474. o.default = "disable"
  475. o = s:option(Value, "tls_host", translate("TLS Host"))
  476. o.datatype = "hostname"
  477. o:depends("tls", true)
  478. o:depends("xtls", true)
  479. o.rmempty = true
  480. -- [[ allowInsecure ]]--
  481. o = s:option(Flag, "insecure", translate("allowInsecure"))
  482. o.rmempty = false
  483. o:depends("tls", true)
  484. o:depends("xtls", true)
  485. o.description = translate("If true, allowss insecure connection at TLS client, e.g., TLS server uses unverifiable certificates.")
  486. -- [[ Mux ]]--
  487. o = s:option(Flag, "mux", translate("Mux"))
  488. o.rmempty = false
  489. o:depends({type = "v2ray", xtls = false})
  490. o = s:option(Value, "concurrency", translate("Concurrency"))
  491. o.datatype = "uinteger"
  492. o.rmempty = true
  493. o.default = "4"
  494. o:depends("mux", "1")
  495. o:depends("type", "naiveproxy")
  496. -- [[ Cert ]]--
  497. o = s:option(Flag, "certificate", translate("Self-signed Certificate"))
  498. o.rmempty = true
  499. o.default = "0"
  500. o:depends({type = "trojan", tls = true, insecure = false})
  501. o:depends({type = "v2ray", v2ray_protocol = "vmess", tls = true, insecure = false})
  502. o:depends({type = "v2ray", v2ray_protocol = "vless", tls = true, insecure = false})
  503. o:depends({type = "v2ray", v2ray_protocol = "vmess", xtls = true, insecure = false})
  504. o:depends({type = "v2ray", v2ray_protocol = "vless", xtls = true, insecure = false})
  505. o.description = translate("If you have a self-signed certificate,please check the box")
  506. o = s:option(DummyValue, "upload", translate("Upload"))
  507. o.template = "shadowsocksr/certupload"
  508. o:depends("certificate", 1)
  509. cert_dir = "/etc/ssl/private/"
  510. local path
  511. luci.http.setfilehandler(function(meta, chunk, eof)
  512. if not fd then
  513. if (not meta) or (not meta.name) or (not meta.file) then
  514. return
  515. end
  516. fd = nixio.open(cert_dir .. meta.file, "w")
  517. if not fd then
  518. path = translate("Create upload file error.")
  519. return
  520. end
  521. end
  522. if chunk and fd then
  523. fd:write(chunk)
  524. end
  525. if eof and fd then
  526. fd:close()
  527. fd = nil
  528. path = '/etc/ssl/private/' .. meta.file .. ''
  529. end
  530. end)
  531. if luci.http.formvalue("upload") then
  532. local f = luci.http.formvalue("ulfile")
  533. if #f <= 0 then
  534. path = translate("No specify upload file.")
  535. end
  536. end
  537. o = s:option(Value, "certpath", translate("Current Certificate Path"))
  538. o:depends("certificate", 1)
  539. o:value("/etc/ssl/private/ca.pem")
  540. o.description = translate("Please confirm the current certificate path")
  541. o.default = "/etc/ssl/private/ca.pem"
  542. o = s:option(Flag, "fast_open", translate("TCP Fast Open"))
  543. o.rmempty = true
  544. o.default = "0"
  545. o:depends("type", "ssr")
  546. o:depends("type", "ss")
  547. o:depends("type", "trojan")
  548. if is_installed("sagernet-core") then
  549. o = s:option(ListValue, "packet_encoding", translate("Packet Encoding"))
  550. o:value("none", translate("none"))
  551. o:value("packet", translate("packet (v2ray-core v5+)"))
  552. o:value("xudp", translate("xudp (Xray-core)"))
  553. o.default = "xudp"
  554. o.rmempty = true
  555. o:depends({type = "v2ray", v2ray_protocol = "vless"})
  556. o:depends({type = "v2ray", v2ray_protocol = "vmess"})
  557. end
  558. o = s:option(Flag, "switch_enable", translate("Enable Auto Switch"))
  559. o.rmempty = false
  560. o.default = "1"
  561. o = s:option(Value, "local_port", translate("Local Port"))
  562. o.datatype = "port"
  563. o.default = 1234
  564. o.rmempty = false
  565. if is_finded("kcptun-client") then
  566. kcp_enable = s:option(Flag, "kcp_enable", translate("KcpTun Enable"))
  567. kcp_enable.rmempty = true
  568. kcp_enable.default = "0"
  569. kcp_enable:depends("type", "ssr")
  570. kcp_enable:depends("type", "ss")
  571. o = s:option(Value, "kcp_port", translate("KcpTun Port"))
  572. o.datatype = "port"
  573. o.default = 4000
  574. o:depends("type", "ssr")
  575. o:depends("type", "ss")
  576. o = s:option(Value, "kcp_password", translate("KcpTun Password"))
  577. o.password = true
  578. o:depends("type", "ssr")
  579. o:depends("type", "ss")
  580. o = s:option(Value, "kcp_param", translate("KcpTun Param"))
  581. o.default = "--nocomp"
  582. o:depends("type", "ssr")
  583. o:depends("type", "ss")
  584. end
  585. return m