client-config.lua 17 KB

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