client-config.lua 36 KB

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