mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-15 04:53:00 +08:00
✨ Sync 2026-11-11 01:22:09
This commit is contained in:
1 parent
9c5aa2e662
commit
cc21462d8a
48 files changed
+9760
-59
No files matched your search
@@ -100,6 +100,7 @@ local DEFAULT_TROJAN_TYPE = api.get_core("trojan_type", {{has_singbox,"sing-box"
|
||||
local DEFAULT_VMESS_TYPE = api.get_core("vmess_type", {{has_xray,"xray"},{has_singbox,"sing-box"}})
|
||||
local DEFAULT_VLESS_TYPE = api.get_core("vless_type", {{has_xray,"xray"},{has_singbox,"sing-box"}})
|
||||
local DEFAULT_HYSTERIA2_TYPE = api.get_core("hysteria2_type", {{has_singbox,"sing-box"},{has_xray,"xray"}})
|
||||
local DEFAULT_OTHER_TYPE = api.get_core("other_type", {{has_singbox,"sing-box"},{has_xray,"xray"}})
|
||||
local core_has = {
|
||||
["xray"] = has_xray,
|
||||
["sing-box"] = has_singbox,
|
||||
@@ -536,6 +537,7 @@ local function processData(szType, content, add_mode, group, sub_cfg)
|
||||
local sub_vmess_type = DEFAULT_VMESS_TYPE
|
||||
local sub_vless_type = DEFAULT_VLESS_TYPE
|
||||
local sub_hysteria2_type = DEFAULT_HYSTERIA2_TYPE
|
||||
local sub_other_type = DEFAULT_OTHER_TYPE
|
||||
local sub_hy_up_mbps, sub_hy_down_mbps
|
||||
if sub_cfg then
|
||||
if sub_cfg.allowInsecure and sub_cfg.allowInsecure ~= "1" then
|
||||
@@ -561,6 +563,10 @@ local function processData(szType, content, add_mode, group, sub_cfg)
|
||||
if hysteria2_type ~= "global" and core_has[hysteria2_type] then
|
||||
sub_hysteria2_type = hysteria2_type
|
||||
end
|
||||
local other_type = sub_cfg.other_type or "global"
|
||||
if other_type ~= "global" and core_has[other_type] then
|
||||
sub_other_type = other_type
|
||||
end
|
||||
sub_hy_up_mbps = sub_cfg.hysteria_up_mbps
|
||||
sub_hy_down_mbps = sub_cfg.hysteria_down_mbps
|
||||
end
|
||||
@@ -1622,6 +1628,115 @@ local function processData(szType, content, add_mode, group, sub_cfg)
|
||||
result.snell_mode = params.mode or "default"
|
||||
end
|
||||
result.snell_reuse = (params.reuse == "1") and "1" or "0"
|
||||
elseif szType == "wireguard" then
|
||||
if sub_other_type == "sing-box" and has_singbox then
|
||||
result.type = "sing-box"
|
||||
elseif sub_other_type == "xray" and has_xray then
|
||||
result.type = "Xray"
|
||||
else
|
||||
log(2, i18n.translatef("Skipping the %s node is due to incompatibility with the %s core program or incorrect node usage type settings.", "WireGuard", "Xray / sing-box"))
|
||||
return nil
|
||||
end
|
||||
result.protocol = "wireguard"
|
||||
|
||||
local alias = ""
|
||||
if content:find("#") then
|
||||
local idx_sp = content:find("#")
|
||||
alias = content:sub(idx_sp + 1, -1)
|
||||
content = content:sub(0, idx_sp - 1)
|
||||
end
|
||||
result.remarks = UrlDecode(alias)
|
||||
local contents = split(content, "@")
|
||||
result.wireguard_secret_key = UrlDecode(contents[1]:gsub("%+", "%%2B"))
|
||||
local query = split(contents[2], "%?")
|
||||
local host_port = query[1]
|
||||
local params = {}
|
||||
for _, v in pairs(split(query[2], '&')) do
|
||||
local s = v:find("=", 1, true)
|
||||
if s and s > 1 then
|
||||
params[UrlDecode(v:sub(1, s - 1)):lower()] = UrlDecode(v:sub(s + 1):gsub("%+", "%%2B"))
|
||||
end
|
||||
end
|
||||
result.address, result.port = parse_host_port(host_port, "51820")
|
||||
result.wireguard_public_key = params.publickey
|
||||
result.wireguard_preSharedKey = params.presharedkey
|
||||
result.wireguard_local_address = {}
|
||||
for value in ((params.address or params.ip or "") .. "," .. (params.ipv6 or "")):gmatch("[^,%s]+") do
|
||||
result.wireguard_local_address[#result.wireguard_local_address + 1] = value
|
||||
end
|
||||
result.wireguard_reserved = params.reserved
|
||||
result.wireguard_mtu = params.mtu or "1420"
|
||||
result.wireguard_keepAlive = params["persistent-keepalive"] or params.keepalive or "0"
|
||||
result.use_finalmask = (params.fm and params.fm ~= "") and "1" or nil
|
||||
result.finalmask = (params.fm and params.fm ~= "") and api.base64Encode(params.fm) or nil
|
||||
elseif szType == "socks" or szType == "socks5" or szType == "socks5h" or szType == "http" or szType == "https" then
|
||||
if sub_other_type == "sing-box" and has_singbox then
|
||||
result.type = "sing-box"
|
||||
elseif sub_other_type == "xray" and has_xray then
|
||||
result.type = "Xray"
|
||||
else
|
||||
log(2, i18n.translatef("Skipping the %s node is due to incompatibility with the %s core program or incorrect node usage type settings.", szType, "Xray / sing-box"))
|
||||
return nil
|
||||
end
|
||||
result.protocol = (szType == "http" or szType == "https") and "http" or "socks"
|
||||
|
||||
local alias = ""
|
||||
if content:find("#") then
|
||||
local idx_sp = content:find("#")
|
||||
alias = content:sub(idx_sp + 1, -1)
|
||||
content = content:sub(0, idx_sp - 1)
|
||||
end
|
||||
result.remarks = UrlDecode(alias)
|
||||
local query = split(content, "%?")
|
||||
local Info = query[1]
|
||||
local base64_auth = false
|
||||
if result.protocol == "socks" and not Info:find("@", 1, true) and not Info:find(":", 1, true) then
|
||||
Info = base64Decode(UrlDecode(Info:gsub("%+", "%%2B")))
|
||||
base64_auth = true
|
||||
end
|
||||
local auth, host_port = Info:match("^(.*)@(.*)$")
|
||||
host_port = host_port or Info
|
||||
auth = auth or ""
|
||||
if result.protocol == "socks" and not auth:find(":", 1, true) then
|
||||
auth = base64Decode(UrlDecode(auth:gsub("%+", "%%2B")))
|
||||
base64_auth = true
|
||||
end
|
||||
local idx = auth:find(":", 1, true)
|
||||
result.username = idx and auth:sub(1, idx - 1) or auth
|
||||
result.password = idx and auth:sub(idx + 1) or ""
|
||||
if not base64_auth then
|
||||
result.username = UrlDecode(result.username:gsub("%+", "%%2B"))
|
||||
result.password = UrlDecode(result.password:gsub("%+", "%%2B"))
|
||||
end
|
||||
local params = {}
|
||||
for _, v in pairs(split(query[2], '&')) do
|
||||
local s = v:find("=", 1, true)
|
||||
if s and s > 1 then
|
||||
params[UrlDecode(v:sub(1, s - 1)):lower()] = UrlDecode(v:sub(s + 1):gsub("%+", "%%2B"))
|
||||
end
|
||||
end
|
||||
local port = result.protocol == "socks" and "1080" or (szType == "https" and "443" or "80")
|
||||
result.address, result.port = parse_host_port(host_port, port)
|
||||
result.transport = result.type == "Xray" and "raw" or "tcp"
|
||||
result.uot = params.uot
|
||||
result.tcp_fast_open = params.tfo
|
||||
result.tls = szType == "https" and "1" or "0"
|
||||
if result.tls == "1" then
|
||||
result.tls_serverName = params.sni
|
||||
result.alpn = params.alpn
|
||||
local insecure = params.allowinsecure or params.insecure or params.allow_insecure
|
||||
result.tls_allowInsecure = (insecure == "1" or insecure == "0") and insecure or (sub_allowinsecure and "1" or "0")
|
||||
result.tls_pinSHA256 = params.pcs
|
||||
result.tls_CertByName = params.vcn
|
||||
if params.fp and params.fp ~= "" then
|
||||
result.utls = "1"
|
||||
result.fingerprint = params.fp
|
||||
end
|
||||
if params.ech and params.ech ~= "" then
|
||||
result.ech = "1"
|
||||
result.ech_config = params.ech
|
||||
end
|
||||
end
|
||||
else
|
||||
log(2, i18n.translatef("%s type node subscriptions are not currently supported, skip this node.", szType))
|
||||
return nil
|
||||
|
||||
Reference in new issue
Block a user