client-config.lua 17 KB

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