gen_config.lua 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. #!/usr/bin/lua
  2. local ucursor = require "luci.model.uci".cursor()
  3. local json = require "luci.jsonc"
  4. local server_section = arg[1]
  5. local proto = arg[2]
  6. local local_port = arg[3] or "0"
  7. local socks_port = arg[4] or "0"
  8. local chain = arg[5] or "0"
  9. local chain_local_port = string.split(chain, "/")[2] or "0"
  10. local server = ucursor:get_all("shadowsocksr", server_section)
  11. local outbound_settings = nil
  12. function vmess_vless()
  13. outbound_settings = {
  14. vnext = {
  15. {
  16. address = server.server,
  17. port = tonumber(server.server_port),
  18. users = {
  19. {
  20. id = server.vmess_id,
  21. alterId = (server.v2ray_protocol == "vmess" or not server.v2ray_protocol) and tonumber(server.alter_id) or nil,
  22. security = (server.v2ray_protocol == "vmess" or not server.v2ray_protocol) and server.security or nil,
  23. encryption = (server.v2ray_protocol == "vless") and server.vless_encryption or nil,
  24. flow = ((server.tls == '1') or (server.reality == '1')) and server.tls_flow or nil
  25. }
  26. }
  27. }
  28. }
  29. }
  30. end
  31. function trojan_shadowsocks()
  32. outbound_settings = {
  33. servers = {
  34. {
  35. address = server.server,
  36. port = tonumber(server.server_port),
  37. password = server.password,
  38. method = ((server.v2ray_protocol == "shadowsocks") and server.encrypt_method_ss) or nil,
  39. uot = (server.v2ray_protocol == "shadowsocks") and (server.uot == '1') or nil,
  40. ivCheck = (server.v2ray_protocol == "shadowsocks") and (server.ivCheck == '1') or nil,
  41. }
  42. }
  43. }
  44. end
  45. function socks_http()
  46. outbound_settings = {
  47. version = server.socks_ver or nil,
  48. servers = {
  49. {
  50. address = server.server,
  51. port = tonumber(server.server_port),
  52. users = (server.auth_enable == "1") and {
  53. {
  54. user = server.username,
  55. pass = server.password
  56. }
  57. } or nil
  58. }
  59. }
  60. }
  61. end
  62. function wireguard()
  63. outbound_settings = {
  64. secretKey = server.private_key,
  65. address = server.local_addresses,
  66. peers = {
  67. {
  68. publicKey = server.peer_pubkey,
  69. preSharedKey = server.preshared_key,
  70. endpoint = server.server .. ":" .. server.server_port
  71. }
  72. },
  73. mtu = tonumber(server.mtu)
  74. }
  75. end
  76. local outbound = {}
  77. function outbound:new(o)
  78. o = o or {}
  79. setmetatable(o, self)
  80. self.__index = self
  81. return o
  82. end
  83. function outbound:handleIndex(index)
  84. local switch = {
  85. vmess = function()
  86. vmess_vless()
  87. end,
  88. vless = function()
  89. vmess_vless()
  90. end,
  91. trojan = function()
  92. trojan_shadowsocks()
  93. end,
  94. shadowsocks = function()
  95. trojan_shadowsocks()
  96. end,
  97. socks = function()
  98. socks_http()
  99. end,
  100. http = function()
  101. socks_http()
  102. end,
  103. wireguard = function()
  104. wireguard()
  105. end
  106. }
  107. if switch[index] then
  108. switch[index]()
  109. end
  110. end
  111. local settings = outbound:new()
  112. settings:handleIndex(server.v2ray_protocol)
  113. local Xray = {
  114. -- 日志
  115. log = (server.custom_log == "1") and {
  116. loglevel = server.custom_loglevel, -- 日志级别
  117. dnsLog = (server.custom_dnsLog == "1") and true or false, -- DNS 查询记录
  118. access = server.custom_access, -- 访问记录
  119. error = server.custom_error -- 错误记录
  120. } or nil,
  121. -- DNS
  122. dns = {
  123. hosts = {
  124. ["dns.alidns.com"] = "223.5.5.5",
  125. ["doh.pub"] = "119.29.29.29"
  126. },
  127. servers = (server.custom_dns_enable == "1") and { -- Xray 内置 DNS
  128. server.custom_dns_local, -- 本地 DNS
  129. {
  130. address = server.custom_dns_remote, -- 远端 DNS
  131. domains = {
  132. server.custom_dns_remote_domains -- 远端 DNS 域名列表
  133. },
  134. skipFallback = true,
  135. queryStrategy = "UseIP"
  136. }
  137. } or nil,
  138. queryStrategy = "UseIP"
  139. },
  140. -- 路由
  141. routing = {
  142. domainStrategy = "AsIs",
  143. rules = {
  144. {
  145. type = "field",
  146. inboundTag = {
  147. "dns-in"
  148. },
  149. outboundTag = "dns-out"
  150. }
  151. }
  152. },
  153. -- 传入连接
  154. inbounds = {
  155. (local_port ~= "0") and {
  156. -- listening
  157. port = tonumber(local_port),
  158. protocol = "dokodemo-door",
  159. settings = {network = proto, followRedirect = true},
  160. sniffing = {
  161. enabled = (server.custom_sniffing == "1") and true or false, -- 流量嗅探
  162. routeOnly = (server.custom_routeOnly == "1") and true or false, -- 嗅探得到的域名仅用于 Xray 内部路由
  163. destOverride = {"http", "tls", "quic"},
  164. domainsExcluded = (server.custom_domainsExcluded == "1") and { -- 流量嗅探域名排除列表
  165. "courier.push.apple.com",
  166. "rbsxbxp-mim.vivox.com",
  167. "rbsxbxp.www.vivox.com",
  168. "rbsxbxp-ws.vivox.com",
  169. "rbspsxp.www.vivox.com",
  170. "rbspsxp-mim.vivox.com",
  171. "rbspsxp-ws.vivox.com",
  172. "rbswxp.www.vivox.com",
  173. "rbswxp-mim.vivox.com",
  174. "disp-rbspsp-5-1.vivox.com",
  175. "disp-rbsxbp-5-1.vivox.com",
  176. "proxy.rbsxbp.vivox.com",
  177. "proxy.rbspsp.vivox.com",
  178. "proxy.rbswp.vivox.com",
  179. "rbswp.vivox.com",
  180. "rbsxbp.vivox.com",
  181. "rbspsp.vivox.com",
  182. "rbspsp.www.vivox.com",
  183. "rbswp.www.vivox.com",
  184. "rbsxbp.www.vivox.com",
  185. "rbsxbxp.vivox.com",
  186. "rbspsxp.vivox.com",
  187. "rbswxp.vivox.com",
  188. "Mijia Cloud",
  189. "dlg.io.mi.com"
  190. } or nil,
  191. }
  192. } or nil,
  193. (server.custom_dns_enable == "1") and { -- Xray 内置 DNS
  194. port = 5335,
  195. protocol = "dokodemo-door",
  196. settings = {
  197. address = server.custom_dokodemo_door_dns_address, -- 查询非 A 和 AAAA 记录DNS
  198. port = 53,
  199. network = "udp"
  200. },
  201. tag = "dns-in"
  202. } or nil,
  203. },
  204. -- 开启 socks 代理
  205. inboundDetour = (proto:find("tcp") and socks_port ~= "0") and {
  206. {
  207. -- socks
  208. protocol = "socks",
  209. port = tonumber(socks_port),
  210. settings = {auth = "noauth", udp = true}
  211. }
  212. } or nil,
  213. -- 传出连接
  214. outbounds = {
  215. {
  216. tag = "proxy",
  217. protocol = server.v2ray_protocol,
  218. settings = outbound_settings,
  219. -- 底层传输配置
  220. streamSettings = {
  221. network = server.transport or "tcp",
  222. security = (server.tls == '1') and "tls" or (server.reality == '1') and "reality" or nil,
  223. tlsSettings = (server.tls == '1') and {
  224. -- tls
  225. alpn = server.tls_alpn,
  226. fingerprint = server.fingerprint,
  227. allowInsecure = (server.insecure == "1"),
  228. serverName = server.tls_host,
  229. certificates = server.certificate and {
  230. usage = "verify",
  231. certificateFile = server.certpath
  232. } or nil,
  233. } or nil,
  234. realitySettings = (server.reality == '1') and {
  235. publicKey = server.reality_publickey,
  236. shortId = server.reality_shortid,
  237. spiderX = server.reality_spiderx,
  238. fingerprint = server.fingerprint,
  239. serverName = server.tls_host
  240. } or nil,
  241. tcpSettings = (server.transport == "tcp" and server.tcp_guise == "http") and {
  242. -- tcp
  243. header = {
  244. type = server.tcp_guise,
  245. request = {
  246. -- request
  247. path = {server.http_path} or {"/"},
  248. headers = {Host = {server.http_host} or {}}
  249. }
  250. }
  251. } or nil,
  252. kcpSettings = (server.transport == "kcp") and {
  253. -- kcp
  254. mtu = tonumber(server.mtu),
  255. tti = tonumber(server.tti),
  256. uplinkCapacity = tonumber(server.uplink_capacity),
  257. downlinkCapacity = tonumber(server.downlink_capacity),
  258. congestion = (server.congestion == "1") and true or false,
  259. readBufferSize = tonumber(server.read_buffer_size),
  260. writeBufferSize = tonumber(server.write_buffer_size),
  261. header = {type = server.kcp_guise},
  262. seed = server.seed or nil
  263. } or nil,
  264. wsSettings = (server.transport == "ws") and (server.ws_path or server.ws_host or server.tls_host) and {
  265. -- ws
  266. headers = (server.ws_host or server.tls_host) and {
  267. -- headers
  268. Host = server.ws_host or server.tls_host
  269. } or nil,
  270. path = server.ws_path,
  271. maxEarlyData = tonumber(server.ws_ed) or nil,
  272. earlyDataHeaderName = server.ws_ed_header or nil
  273. } or nil,
  274. httpSettings = (server.transport == "h2") and {
  275. -- h2
  276. path = server.h2_path or "",
  277. host = {server.h2_host} or nil,
  278. read_idle_timeout = tonumber(server.read_idle_timeout) or nil,
  279. health_check_timeout = tonumber(server.health_check_timeout) or nil
  280. } or nil,
  281. quicSettings = (server.transport == "quic") and {
  282. -- quic
  283. security = server.quic_security,
  284. key = server.quic_key,
  285. header = {type = server.quic_guise}
  286. } or nil,
  287. grpcSettings = (server.transport == "grpc") and {
  288. -- grpc
  289. serviceName = server.serviceName or "",
  290. multiMode = (server.grpc_mode == "multi") and true or false,
  291. idle_timeout = tonumber(server.idle_timeout) or nil,
  292. health_check_timeout = tonumber(server.health_check_timeout) or nil,
  293. permit_without_stream = (server.permit_without_stream == "1") and true or nil,
  294. initial_windows_size = tonumber(server.initial_windows_size) or nil
  295. } or nil,
  296. sockopt = {
  297. tcpMptcp = (server.mptcp == "1") and true or false, -- MPTCP
  298. tcpNoDelay = (server.mptcp == "1") and true or false, -- MPTCP
  299. tcpcongestion = server.custom_tcpcongestion -- 连接服务器节点的 TCP 拥塞控制算法
  300. }
  301. },
  302. mux = {
  303. enabled = (server.mux == "1") and true or false, -- Mux
  304. concurrency = tonumber(server.concurrency), -- TCP 最大并发连接数
  305. xudpConcurrency = tonumber(server.xudpConcurrency), -- UDP 最大并发连接数
  306. xudpProxyUDP443 = server.xudpProxyUDP443 -- 对被代理的 UDP/443 流量处理方式
  307. }
  308. },
  309. {
  310. protocol = "freedom",
  311. settings = {
  312. domainStrategy = "ForceIPv6v4"
  313. },
  314. streamSettings = {
  315. sockopt = {
  316. tcpFastOpen = true
  317. }
  318. },
  319. tag = "direct"
  320. },
  321. {
  322. protocol = "blackhole",
  323. tag = "block"
  324. },
  325. (server.custom_dns_enable == "1") and { -- Xray 内置 DNS
  326. protocol = "dns",
  327. settings = {
  328. nonIPQuery = server.custom_nonIPQuery -- 非 A 和 AAAA 记录处理方式
  329. },
  330. proxySettings = (server.custom_nonIPQuery == "skip") and {
  331. tag = server.custom_nonIPQuery_outbound_tag -- 非 A 和 AAAA 记录查询方式
  332. } or nil,
  333. tag = "dns-out"
  334. } or nil,
  335. }
  336. }
  337. local cipher = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:AES128-SHA:AES256-SHA:DES-CBC3-SHA"
  338. local cipher13 = "TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384"
  339. local trojan = {
  340. log_level = 3,
  341. run_type = (proto == "nat" or proto == "tcp") and "nat" or "client",
  342. local_addr = "0.0.0.0",
  343. local_port = tonumber(local_port),
  344. remote_addr = server.server,
  345. remote_port = tonumber(server.server_port),
  346. udp_timeout = 60,
  347. -- 传入连接
  348. password = {server.password},
  349. -- 传出连接
  350. ssl = {
  351. verify = (server.insecure == "0") and true or false,
  352. verify_hostname = (server.tls == "1") and true or false,
  353. cert = (server.certificate) and server.certpath or nil,
  354. cipher = cipher,
  355. cipher_tls13 = cipher13,
  356. sni = server.tls_host,
  357. alpn = server.tls_alpn or {"h2", "http/1.1"},
  358. curve = "",
  359. reuse_session = true,
  360. session_ticket = (server.tls_sessionTicket == "1") and true or false
  361. },
  362. udp_timeout = 60,
  363. tcp = {
  364. -- tcp
  365. no_delay = true,
  366. keep_alive = true,
  367. reuse_port = true,
  368. fast_open = (server.fast_open == "1") and true or false,
  369. fast_open_qlen = 20
  370. }
  371. }
  372. local naiveproxy = {
  373. proxy = (server.username and server.password and server.server and server.server_port) and "https://" .. server.username .. ":" .. server.password .. "@" .. server.server .. ":" .. server.server_port,
  374. listen = (proto == "redir") and "redir" .. "://0.0.0.0:" .. tonumber(local_port) or "socks" .. "://0.0.0.0:" .. tonumber(local_port),
  375. ["insecure-concurrency"] = tonumber(server.concurrency) or 1
  376. }
  377. local ss = {
  378. server = (server.kcp_enable == "1") and "127.0.0.1" or server.server,
  379. server_port = tonumber(server.server_port),
  380. local_address = "0.0.0.0",
  381. local_port = tonumber(local_port),
  382. mode = (proto == "tcp,udp") and "tcp_and_udp" or proto .. "_only",
  383. password = server.password,
  384. method = server.encrypt_method_ss,
  385. timeout = tonumber(server.timeout),
  386. fast_open = (server.fast_open == "1") and true or false,
  387. reuse_port = true
  388. }
  389. local hysteria = {
  390. server = (server.port_range and (server.server .. ":" .. server.port_range)) or (server.server_port and (server.server .. ":" .. server.server_port)),
  391. bandwidth = {
  392. up = tonumber(server.uplink_capacity) and tonumber(server.uplink_capacity) .. " mbps" or nil,
  393. down = tonumber(server.downlink_capacity) and tonumber(server.downlink_capacity) .. " mbps" or nil
  394. },
  395. socks5 = (proto:find("tcp") and tonumber(socks_port) and tonumber(socks_port) ~= 0) and {
  396. listen = "0.0.0.0:" .. tonumber(socks_port),
  397. disable_udp = false
  398. } or nil,
  399. transport = {
  400. type = server.transport_protocol,
  401. udp = {
  402. hopInterval = tonumber(server.hopinterval) and tonumber(server.hopinterval) .. "s" or "30s"
  403. }
  404. },
  405. --[[
  406. tcpTProxy = (proto:find("tcp") and local_port ~= "0") and {
  407. listen = "0.0.0.0:" .. tonumber(local_port)
  408. } or nil,
  409. ]]
  410. tcpRedirect = (proto:find("tcp") and local_port ~= "0") and {
  411. listen = "0.0.0.0:" .. tonumber(local_port)
  412. } or nil,
  413. udpTProxy = (proto:find("udp") and local_port ~= "0") and {
  414. listen = "0.0.0.0:" .. tonumber(local_port)
  415. } or nil,
  416. obfs = (server.flag_obfs == "1") and {
  417. type = server.obfs_type,
  418. salamander = { password = server.salamander }
  419. } or nil,
  420. quic = (server.flag_quicparam == "1" ) and {
  421. initStreamReceiveWindow = (server.initstreamreceivewindow and server.initstreamreceivewindow or nil),
  422. maxStreamReceiveWindow = (server.maxstreamseceivewindow and server.maxstreamseceivewindow or nil),
  423. initConnReceiveWindow = (server.initconnreceivewindow and server.initconnreceivewindow or nil),
  424. maxConnReceiveWindow = (server.maxconnreceivewindow and server.maxconnreceivewindow or nil),
  425. maxIdleTimeout = (tonumber(server.maxidletimeout) and tonumber(server.maxidletimeout) .. "s" or nil),
  426. keepAlivePeriod = (tonumber(server.keepaliveperiod) and tonumber(server.keepaliveperiod) .. "s" or nil),
  427. disable_mtu_discovery = (server.disablepathmtudiscovery == "1") and true or false
  428. } or nil,
  429. auth = server.hy2_auth,
  430. tls = (server.tls_host) and {
  431. sni = server.tls_host,
  432. alpn = server.tls_alpn or nil,
  433. insecure = (server.insecure == "1") and true or false,
  434. pinSHA256 = (server.insecure == "1") and server.pinsha256 or nil
  435. } or {
  436. sni = server.server,
  437. insecure = (server.insecure == "1") and true or false
  438. },
  439. fast_open = (server.fast_open == "1") and true or false,
  440. lazy = (server.lazy_mode == "1") and true or false
  441. }
  442. local shadowtls = {
  443. client = {
  444. server_addr = server.server_port and server.server .. ":" .. server.server_port or nil,
  445. listen = "127.0.0.1:" .. tonumber(local_port),
  446. tls_names = server.shadowtls_sni,
  447. password = server.password
  448. },
  449. v3 = (server.shadowtls_protocol == "v3") and true or false,
  450. disable_nodelay = (server.disable_nodelay == "1") and true or false,
  451. fastopen = (server.fastopen == "1") and true or false,
  452. strict = (server.strict == "1") and true or false
  453. }
  454. local chain_sslocal = {
  455. locals = local_port ~= "0" and {
  456. {
  457. local_address = "0.0.0.0",
  458. local_port = (chain_local_port == "0" and tonumber(server.local_port) or tonumber(chain_local_port)),
  459. mode = (proto:find("tcp,udp") and "tcp_and_udp") or proto .. "_only",
  460. protocol = "redir",
  461. tcp_redir = "redirect",
  462. --tcp_redir = "tproxy",
  463. udp_redir = "tproxy"
  464. },
  465. socks_port ~= "0" and {
  466. protocol = "socks",
  467. local_address = "0.0.0.0",
  468. local_port = tonumber(socks_port)
  469. } or nil
  470. } or {{
  471. protocol = "socks",
  472. local_address = "0.0.0.0",
  473. ocal_port = tonumber(socks_port)
  474. }},
  475. servers = {
  476. {
  477. server = "127.0.0.1",
  478. server_port = (tonumber(local_port) == 0 and tonumber(chain_local_port) or tonumber(local_port)),
  479. method = server.sslocal_method,
  480. password = server.sslocal_password
  481. }
  482. }
  483. }
  484. local chain_vmess = {
  485. inbounds = (local_port ~= "0") and {
  486. {
  487. port = (chain_local_port == "0" and tonumber(server.local_port) or tonumber(chain_local_port)),
  488. protocol = "dokodemo-door",
  489. settings = {
  490. network = proto,
  491. followRedirect = true
  492. },
  493. streamSettings = {
  494. sockopt = {tproxy = "redirect"}
  495. },
  496. sniffing = {
  497. enable = true,
  498. destOverride = {"http","tls"}
  499. }
  500. },
  501. (proto:find("tcp") and socks_port ~= "0") and {
  502. protocol = "socks",
  503. port = tonumber(socks_port)
  504. } or nil
  505. } or { protocol = "socks",port = tonumber(socks_port) },
  506. outbound = {
  507. protocol = "vmess",
  508. settings = {
  509. vnext = {{
  510. address = "127.0.0.1",
  511. port = (tonumber(local_port) == 0 and tonumber(chain_local_port) or tonumber(local_port)),
  512. users = {{
  513. id = (server.vmess_uuid),
  514. security = server.vmess_method,
  515. level = 0
  516. }}
  517. }}
  518. }
  519. }
  520. }
  521. local tuic = {
  522. relay = {
  523. server = server.server_port and server.server .. ":" .. server.server_port,
  524. ip = server.tuic_ip,
  525. uuid = server.tuic_uuid,
  526. password = server.tuic_passwd,
  527. certificates = server.certificate and { server.certpath } or nil,
  528. udp_relay_mode = server.udp_relay_mode,
  529. congestion_control = server.congestion_control,
  530. heartbeat = server.heartbeat and server.heartbeat .. "s" or nil,
  531. timeout = server.timeout and server.timeout .. "s" or nil,
  532. gc_interval = server.gc_interval and server.gc_interval .. "s" or nil,
  533. gc_lifetime = server.gc_lifetime and server.gc_lifetime .. "s" or nil,
  534. alpn = server.tls_alpn,
  535. disable_sni = (server.disable_sni == "1") and true or false,
  536. zero_rtt_handshake = (server.zero_rtt_handshake == "1") and true or false,
  537. send_window = tonumber(server.send_window),
  538. receive_window = tonumber(server.receive_window)
  539. },
  540. ["local"] = {
  541. server = tonumber(socks_port) and (server.tuic_dual_stack == "1" and "[::1]:" or "127.0.0.1:") .. (socks_port == "0" and local_port or tonumber(socks_port)),
  542. dual_stack = (server.tuic_dual_stack == "1") and true or false,
  543. max_packet_size = tonumber(server.tuic_max_package_size)
  544. }
  545. }
  546. local config = {}
  547. function config:new(o)
  548. o = o or {}
  549. setmetatable(o, self)
  550. self.__index = self
  551. return o
  552. end
  553. function config:handleIndex(index)
  554. local switch = {
  555. ss = function()
  556. ss.protocol = socks_port
  557. if server.plugin and server.plugin ~= "none" then
  558. ss.plugin = server.plugin
  559. ss.plugin_opts = server.plugin_opts or nil
  560. end
  561. print(json.stringify(ss, 1))
  562. end,
  563. ssr = function()
  564. ss.protocol = server.protocol
  565. ss.protocol_param = server.protocol_param
  566. ss.method = server.encrypt_method
  567. ss.obfs = server.obfs
  568. ss.obfs_param = server.obfs_param
  569. print(json.stringify(ss, 1))
  570. end,
  571. v2ray = function()
  572. print(json.stringify(Xray, 1))
  573. end,
  574. trojan = function()
  575. print(json.stringify(trojan, 1))
  576. end,
  577. naiveproxy = function()
  578. print(json.stringify(naiveproxy, 1))
  579. end,
  580. hysteria = function()
  581. print(json.stringify(hysteria, 1))
  582. end,
  583. shadowtls = function()
  584. local chain_switch = {
  585. sslocal = function()
  586. if (chain:find("chain")) then
  587. print(json.stringify(chain_sslocal, 1))
  588. else
  589. print(json.stringify(shadowtls, 1))
  590. end
  591. end,
  592. vmess = function()
  593. if (chain:find("chain")) then
  594. print(json.stringify(chain_vmess, 1))
  595. else
  596. print(json.stringify(shadowtls, 1))
  597. end
  598. end
  599. }
  600. local ChainType = server.chain_type
  601. if chain_switch[ChainType] then
  602. chain_switch[ChainType]()
  603. end
  604. end,
  605. tuic = function()
  606. print(json.stringify(tuic, 1))
  607. end
  608. }
  609. if switch[index] then
  610. switch[index]()
  611. end
  612. end
  613. local f = config:new()
  614. f:handleIndex(server.type)