|
@@ -238,38 +238,62 @@ local function processData(szType, content)
|
|
result.pinsha256 = params.pinSHA256
|
|
result.pinsha256 = params.pinSHA256
|
|
end
|
|
end
|
|
elseif szType == 'ssr' then
|
|
elseif szType == 'ssr' then
|
|
- local dat = split(content, "/%?")
|
|
|
|
- local hostInfo = split(dat[1], ':')
|
|
|
|
|
|
+ -- 去掉前后空白和#注释
|
|
|
|
+ local link = trim(content:gsub("#.*$", ""))
|
|
|
|
+ local dat = split(link, "/%?")
|
|
|
|
+ local hostInfo = split(dat[1] or '', ':')
|
|
|
|
+
|
|
result.type = 'ssr'
|
|
result.type = 'ssr'
|
|
- result.server = hostInfo[1]
|
|
|
|
- result.server_port = hostInfo[2]
|
|
|
|
- result.protocol = hostInfo[3]
|
|
|
|
- result.encrypt_method = hostInfo[4]
|
|
|
|
- result.obfs = hostInfo[5]
|
|
|
|
- result.password = base64Decode(hostInfo[6])
|
|
|
|
|
|
+ result.server = hostInfo[1] or ''
|
|
|
|
+ result.server_port = hostInfo[2] or ''
|
|
|
|
+ result.protocol = hostInfo[3] or ''
|
|
|
|
+ result.encrypt_method = hostInfo[4] or ''
|
|
|
|
+ result.obfs = hostInfo[5] or ''
|
|
|
|
+ result.password = base64Decode(hostInfo[6] or '')
|
|
|
|
+
|
|
local params = {}
|
|
local params = {}
|
|
- for _, v in pairs(split(dat[2], '&')) do
|
|
|
|
- local t = split(v, '=')
|
|
|
|
- params[t[1]] = t[2]
|
|
|
|
|
|
+ if dat[2] and dat[2] ~= '' then
|
|
|
|
+ for _, v in pairs(split(dat[2], '&')) do
|
|
|
|
+ local t = split(v, '=')
|
|
|
|
+ if t[1] and t[2] then
|
|
|
|
+ params[t[1]] = t[2]
|
|
|
|
+ end
|
|
|
|
+ end
|
|
end
|
|
end
|
|
- result.obfs_param = base64Decode(params.obfsparam)
|
|
|
|
- result.protocol_param = base64Decode(params.protoparam)
|
|
|
|
- local group = base64Decode(params.group)
|
|
|
|
- if group then
|
|
|
|
- result.alias = "[" .. group .. "] "
|
|
|
|
|
|
+
|
|
|
|
+ result.obfs_param = base64Decode(params.obfsparam or '')
|
|
|
|
+ result.protocol_param = base64Decode(params.protoparam or '')
|
|
|
|
+
|
|
|
|
+ local group = base64Decode(params.group or '')
|
|
|
|
+ local remarks = base64Decode(params.remarks or '')
|
|
|
|
+
|
|
|
|
+ -- 拼接 alias
|
|
|
|
+ local alias = ""
|
|
|
|
+ if group ~= "" then
|
|
|
|
+ alias = "[" .. group .. "] "
|
|
end
|
|
end
|
|
- result.alias = result.alias .. base64Decode(params.remarks)
|
|
|
|
|
|
+ alias = alias .. remarks
|
|
|
|
+ result.alias = alias
|
|
elseif szType == "vmess" then
|
|
elseif szType == "vmess" then
|
|
|
|
+ -- 去掉前后空白和#注释
|
|
|
|
+ local link = trim(content:gsub("#.*$", ""))
|
|
|
|
+
|
|
-- 解析正常节点
|
|
-- 解析正常节点
|
|
- local success, info = pcall(jsonParse, content)
|
|
|
|
|
|
+ local success, info = pcall(jsonParse, link)
|
|
if not success or type(info) ~= "table" then
|
|
if not success or type(info) ~= "table" then
|
|
return nil
|
|
return nil
|
|
end
|
|
end
|
|
- -- 处理有效数据
|
|
|
|
|
|
+
|
|
|
|
+ -- 基本信息
|
|
result.type = 'v2ray'
|
|
result.type = 'v2ray'
|
|
result.v2ray_protocol = 'vmess'
|
|
result.v2ray_protocol = 'vmess'
|
|
result.server = info.add
|
|
result.server = info.add
|
|
result.server_port = info.port
|
|
result.server_port = info.port
|
|
|
|
+ result.alter_id = info.aid
|
|
|
|
+ result.vmess_id = info.id
|
|
|
|
+ result.alias = info.ps
|
|
|
|
+
|
|
|
|
+ -- 调整传输协议
|
|
if info.net == "tcp" then
|
|
if info.net == "tcp" then
|
|
info.net = "raw"
|
|
info.net = "raw"
|
|
end
|
|
end
|
|
@@ -277,9 +301,7 @@ local function processData(szType, content)
|
|
info.net = "xhttp"
|
|
info.net = "xhttp"
|
|
end
|
|
end
|
|
result.transport = info.net
|
|
result.transport = info.net
|
|
- result.alter_id = info.aid
|
|
|
|
- result.vmess_id = info.id
|
|
|
|
- result.alias = info.ps
|
|
|
|
|
|
+
|
|
-- result.mux = 1
|
|
-- result.mux = 1
|
|
-- result.concurrency = 8
|
|
-- result.concurrency = 8
|
|
if info.net == 'ws' then
|
|
if info.net == 'ws' then
|
|
@@ -298,11 +320,11 @@ local function processData(szType, content)
|
|
result.enable_xhttp_extra = (info.extra and info.extra ~= "") and "1" or nil
|
|
result.enable_xhttp_extra = (info.extra and info.extra ~= "") and "1" or nil
|
|
result.xhttp_extra = (info.extra and info.extra ~= "") and info.extra or nil
|
|
result.xhttp_extra = (info.extra and info.extra ~= "") and info.extra or nil
|
|
-- 尝试解析 JSON 数据
|
|
-- 尝试解析 JSON 数据
|
|
- local success, Data = pcall(jsonParse, info.extra)
|
|
|
|
- if success and Data then
|
|
|
|
|
|
+ local success, Data = pcall(jsonParse, info.extra or "")
|
|
|
|
+ if success and type(Data) == "table" then
|
|
local address = (Data.extra and Data.extra.downloadSettings and Data.extra.downloadSettings.address)
|
|
local address = (Data.extra and Data.extra.downloadSettings and Data.extra.downloadSettings.address)
|
|
or (Data.downloadSettings and Data.downloadSettings.address)
|
|
or (Data.downloadSettings and Data.downloadSettings.address)
|
|
- result.download_address = address and address ~= "" and address or nil
|
|
|
|
|
|
+ result.download_address = (address and address ~= "") and address or nil
|
|
else
|
|
else
|
|
-- 如果解析失败,清空下载地址
|
|
-- 如果解析失败,清空下载地址
|
|
result.download_address = nil
|
|
result.download_address = nil
|
|
@@ -313,12 +335,11 @@ local function processData(szType, content)
|
|
result.h2_path = info.path
|
|
result.h2_path = info.path
|
|
end
|
|
end
|
|
if info.net == 'raw' or info.net == 'tcp' then
|
|
if info.net == 'raw' or info.net == 'tcp' then
|
|
- if info.type and info.type ~= "http" then
|
|
|
|
- info.type = "none"
|
|
|
|
|
|
+ result.tcp_guise = info.type or "none"
|
|
|
|
+ if result.tcp_guise == "http" then
|
|
|
|
+ result.http_host = info.host
|
|
|
|
+ result.http_path = info.path
|
|
end
|
|
end
|
|
- result.tcp_guise = info.type
|
|
|
|
- result.http_host = info.host
|
|
|
|
- result.http_path = info.path
|
|
|
|
end
|
|
end
|
|
if info.net == 'kcp' then
|
|
if info.net == 'kcp' then
|
|
result.kcp_guise = info.type
|
|
result.kcp_guise = info.type
|
|
@@ -356,19 +377,27 @@ local function processData(szType, content)
|
|
end
|
|
end
|
|
if info.sni and info.sni ~= "" then
|
|
if info.sni and info.sni ~= "" then
|
|
result.tls_host = info.sni
|
|
result.tls_host = info.sni
|
|
- elseif info.host then
|
|
|
|
|
|
+ elseif info.host and info.host ~= "" then
|
|
result.tls_host = info.host
|
|
result.tls_host = info.host
|
|
end
|
|
end
|
|
if info.ech and info.ech ~= "" then
|
|
if info.ech and info.ech ~= "" then
|
|
result.enable_ech = "1"
|
|
result.enable_ech = "1"
|
|
result.ech_config = info.ech
|
|
result.ech_config = info.ech
|
|
end
|
|
end
|
|
- if (info.allowInsecure or info.allowlnsecure) == "true" or (info.allowInsecure or info.allowlnsecure) == "1" then
|
|
|
|
- result.insecure = "1"
|
|
|
|
|
|
+ -- 兼容 allowInsecure / allowlnsecure / skip-cert-verify
|
|
|
|
+ if info.allowInsecure or info.allowlnsecure or info["skip-cert-verify"] then
|
|
|
|
+ local insecure = info.allowInsecure or info.allowlnsecure or info["skip-cert-verify"]
|
|
|
|
+ if insecure == true or insecure == "1" or insecure == "true" then
|
|
|
|
+ result.insecure = "1"
|
|
|
|
+ end
|
|
end
|
|
end
|
|
else
|
|
else
|
|
result.tls = "0"
|
|
result.tls = "0"
|
|
end
|
|
end
|
|
|
|
+ -- 其它可选安全字段
|
|
|
|
+ if info.security then
|
|
|
|
+ result.security = info.security
|
|
|
|
+ end
|
|
elseif szType == "ss" then
|
|
elseif szType == "ss" then
|
|
local idx_sp = content:find("#") or 0
|
|
local idx_sp = content:find("#") or 0
|
|
local alias = ""
|
|
local alias = ""
|
|
@@ -684,8 +713,8 @@ local function processData(szType, content)
|
|
result.enable_xhttp_extra = (params.extra and params.extra ~= "") and "1" or nil
|
|
result.enable_xhttp_extra = (params.extra and params.extra ~= "") and "1" or nil
|
|
result.xhttp_extra = (params.extra and params.extra ~= "") and params.extra or nil
|
|
result.xhttp_extra = (params.extra and params.extra ~= "") and params.extra or nil
|
|
-- 尝试解析 JSON 数据
|
|
-- 尝试解析 JSON 数据
|
|
- local success, Data = pcall(jsonParse, params.extra)
|
|
|
|
- if success and Data then
|
|
|
|
|
|
+ local success, Data = pcall(jsonParse, params.extra or "")
|
|
|
|
+ if success and type(Data) == "table" then
|
|
local address = (Data.extra and Data.extra.downloadSettings and Data.extra.downloadSettings.address)
|
|
local address = (Data.extra and Data.extra.downloadSettings and Data.extra.downloadSettings.address)
|
|
or (Data.downloadSettings and Data.downloadSettings.address)
|
|
or (Data.downloadSettings and Data.downloadSettings.address)
|
|
result.download_address = address and address ~= "" and address or nil
|
|
result.download_address = address and address ~= "" and address or nil
|
|
@@ -774,8 +803,8 @@ local function processData(szType, content)
|
|
result.enable_xhttp_extra = (params.extra and params.extra ~= "") and "1" or nil
|
|
result.enable_xhttp_extra = (params.extra and params.extra ~= "") and "1" or nil
|
|
result.xhttp_extra = (params.extra and params.extra ~= "") and params.extra or nil
|
|
result.xhttp_extra = (params.extra and params.extra ~= "") and params.extra or nil
|
|
-- 尝试解析 JSON 数据
|
|
-- 尝试解析 JSON 数据
|
|
- local success, Data = pcall(jsonParse, params.extra)
|
|
|
|
- if success and Data then
|
|
|
|
|
|
+ local success, Data = pcall(jsonParse, params.extra or "")
|
|
|
|
+ if success and type(Data) == "table" then
|
|
local address = (Data.extra and Data.extra.downloadSettings and Data.extra.downloadSettings.address)
|
|
local address = (Data.extra and Data.extra.downloadSettings and Data.extra.downloadSettings.address)
|
|
or (Data.downloadSettings and Data.downloadSettings.address)
|
|
or (Data.downloadSettings and Data.downloadSettings.address)
|
|
result.download_address = address and address ~= "" and address or nil
|
|
result.download_address = address and address ~= "" and address or nil
|