mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-16 21:43:33 +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
@@ -6,8 +6,8 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-passwall2
|
||||
PKG_VERSION:=26.11.3
|
||||
PKG_RELEASE:=175
|
||||
PKG_VERSION:=26.11.11
|
||||
PKG_RELEASE:=176
|
||||
PKG_PO_VERSION:=$(PKG_VERSION)
|
||||
|
||||
PKG_CONFIG_DEPENDS:= \
|
||||
|
||||
@@ -9,6 +9,7 @@ local trojan_type = {}
|
||||
local vmess_type = {}
|
||||
local vless_type = {}
|
||||
local hysteria2_type = {}
|
||||
local other_type = {}
|
||||
local xray_version = api.get_app_version("xray")
|
||||
if has_ss_rust then
|
||||
local s = "shadowsocks-rust"
|
||||
@@ -21,6 +22,7 @@ if has_singbox then
|
||||
table.insert(vmess_type, s)
|
||||
table.insert(vless_type, s)
|
||||
table.insert(hysteria2_type, s)
|
||||
table.insert(other_type, s)
|
||||
end
|
||||
if has_xray then
|
||||
local s = "xray"
|
||||
@@ -28,6 +30,7 @@ if has_xray then
|
||||
table.insert(ss_type, s)
|
||||
table.insert(vmess_type, s)
|
||||
table.insert(vless_type, s)
|
||||
table.insert(other_type, s)
|
||||
if api.compare_versions(xray_version, ">=", "26.1.13") then
|
||||
table.insert(hysteria2_type, s)
|
||||
end
|
||||
@@ -95,7 +98,15 @@ if #hysteria2_type > 0 then
|
||||
end
|
||||
end
|
||||
|
||||
if #ss_type > 0 or #trojan_type > 0 or #vmess_type > 0 or #vless_type > 0 or #hysteria2_type > 0 then
|
||||
if #other_type > 0 then
|
||||
o = s:option(ListValue, "other_type", translatef("%s Node Use Type", translate("Other")))
|
||||
o:value("", translate("Auto"))
|
||||
for key, value in pairs(other_type) do
|
||||
o:value(value)
|
||||
end
|
||||
end
|
||||
|
||||
if #ss_type > 0 or #trojan_type > 0 or #vmess_type > 0 or #vless_type > 0 or #hysteria2_type > 0 or #other_type > 0 then
|
||||
o.description = string.format("<font color='red'>%s</font>",
|
||||
translate("The configured type also applies to the core specified when manually importing nodes."))
|
||||
end
|
||||
|
||||
@@ -22,6 +22,7 @@ local trojan_type = {}
|
||||
local vmess_type = {}
|
||||
local vless_type = {}
|
||||
local hysteria2_type = {}
|
||||
local other_type = {}
|
||||
local xray_version = api.get_app_version("xray")
|
||||
if has_ss_rust then
|
||||
local s = "shadowsocks-rust"
|
||||
@@ -34,6 +35,7 @@ if has_singbox then
|
||||
table.insert(vmess_type, s)
|
||||
table.insert(vless_type, s)
|
||||
table.insert(hysteria2_type, s)
|
||||
table.insert(other_type, s)
|
||||
end
|
||||
if has_xray then
|
||||
local s = "xray"
|
||||
@@ -41,6 +43,7 @@ if has_xray then
|
||||
table.insert(ss_type, s)
|
||||
table.insert(vmess_type, s)
|
||||
table.insert(vless_type, s)
|
||||
table.insert(other_type, s)
|
||||
if api.compare_versions(xray_version, ">=", "26.1.13") then
|
||||
table.insert(hysteria2_type, s)
|
||||
end
|
||||
@@ -215,7 +218,18 @@ if #hysteria2_type > 0 then
|
||||
for key, value in pairs(hysteria2_type) do
|
||||
o:value(value)
|
||||
end
|
||||
end
|
||||
|
||||
if #other_type > 0 then
|
||||
o = s:option(ListValue, "other_type", translatef("%s Node Use Type", translate("Other")))
|
||||
o.default = "global"
|
||||
o:value("global", translate("Use global config"))
|
||||
for key, value in pairs(other_type) do
|
||||
o:value(value)
|
||||
end
|
||||
end
|
||||
|
||||
if #hysteria2_type > 0 then
|
||||
o = s:option(Value, "hysteria_up_mbps", "Hy/Hy2 " .. translate("Max upload Mbps"))
|
||||
o.datatype = "uinteger"
|
||||
|
||||
|
||||
@@ -768,6 +768,10 @@ if singbox_tags:find("with_wireguard") then
|
||||
|
||||
o = s:option(Value, "wireguard_reserved", translate("Reserved"), translate("Decimal numbers separated by \",\" or Base64-encoded strings."))
|
||||
o:depends({ protocol = "wireguard" })
|
||||
|
||||
o = s:option(Value, "wireguard_keepAlive", translate("Keep Alive"))
|
||||
o.default = "0"
|
||||
o:depends({ protocol = "wireguard" })
|
||||
end
|
||||
|
||||
-- [[ TCP ]]--
|
||||
|
||||
@@ -523,6 +523,7 @@ function gen_outbound(flag, node, tag, proxy_table)
|
||||
pre_shared_key = node.wireguard_preSharedKey,
|
||||
reserved = node.wireguard_reserved,
|
||||
mtu = tonumber(node.wireguard_mtu),
|
||||
persistent_keepalive_interval = tonumber(node.wireguard_keepAlive),
|
||||
}
|
||||
end
|
||||
|
||||
@@ -2399,7 +2400,8 @@ function gen_config(var)
|
||||
port = value.server_port,
|
||||
public_key = value.peer_public_key,
|
||||
pre_shared_key = value.pre_shared_key,
|
||||
allowed_ips = {"0.0.0.0/0"},
|
||||
allowed_ips = {"0.0.0.0/0", "::/0"},
|
||||
persistent_keepalive_interval = value.persistent_keepalive_interval,
|
||||
reserved = value.reserved
|
||||
}
|
||||
},
|
||||
|
||||
@@ -445,7 +445,7 @@ function gen_outbound(flag, node, tag, proxy_table)
|
||||
peers = (node.protocol == "wireguard") and {
|
||||
{
|
||||
publicKey = node.wireguard_public_key,
|
||||
endpoint = node.address .. ":" .. node.port,
|
||||
endpoint = (api.is_ipv6(node.address) and ("[" .. node.address .. "]") or node.address) .. ":" .. node.port,
|
||||
preSharedKey = node.wireguard_preSharedKey,
|
||||
keepAlive = node.wireguard_keepAlive and tonumber(node.wireguard_keepAlive) or nil
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ local trojan_type = api.get_core("trojan_type", {{has_singbox,"sing-box"},{has_x
|
||||
local vmess_type = api.get_core("vmess_type", {{has_xray,"xray"},{has_singbox,"sing-box"}})
|
||||
local vless_type = api.get_core("vless_type", {{has_xray,"xray"},{has_singbox,"sing-box"}})
|
||||
local hysteria2_type = api.get_core("hysteria2_type", {{has_singbox,"sing-box"}, {has_xray,"xray"}})
|
||||
local other_type = api.get_core("other_type", {{has_singbox,"sing-box"},{has_xray,"xray"}})
|
||||
|
||||
local current_node = map:get(section)
|
||||
-%>
|
||||
@@ -25,6 +26,7 @@ local current_node = map:get(section)
|
||||
let vmess_type = "<%=vmess_type%>"
|
||||
let vless_type = "<%=vless_type%>"
|
||||
let hysteria2_type = "<%=hysteria2_type%>"
|
||||
let other_type = "<%=other_type%>"
|
||||
|
||||
function padright(str, cnt, pad) {
|
||||
return str + Array(cnt + 1).join(pad);
|
||||
@@ -713,6 +715,74 @@ local current_node = map:get(section)
|
||||
params = params.substring(1);
|
||||
}
|
||||
url += params;
|
||||
} else if ((v_type === "Xray" || v_type === "sing-box") && opt.get(dom_prefix + "protocol").value === "wireguard") {
|
||||
protocol = "wireguard";
|
||||
var v_password = opt.get(dom_prefix + "wireguard_secret_key");
|
||||
var v_port = opt.get(dom_prefix + "port");
|
||||
url = encodeURIComponent(v_password.value) +
|
||||
"@" + _address +
|
||||
":" + v_port.value + "?";
|
||||
|
||||
var params = "";
|
||||
params += opt.query("publickey", dom_prefix + "wireguard_public_key");
|
||||
params += opt.query("presharedkey", dom_prefix + "wireguard_preSharedKey");
|
||||
var addresses = opt.getlist(dom_prefix + "wireguard_local_address").map(value => value.trim()).filter(Boolean);
|
||||
params += "&address=" + encodeURIComponent(addresses.join(","));
|
||||
params += opt.query("reserved", dom_prefix + "wireguard_reserved");
|
||||
params += opt.query("mtu", dom_prefix + "wireguard_mtu");
|
||||
params += opt.query("persistent-keepalive", dom_prefix + "wireguard_keepAlive");
|
||||
if (v_type === "Xray" && opt.get(dom_prefix + "use_finalmask")?.checked) {
|
||||
params += opt.query("fm", dom_prefix + "finalmask");
|
||||
}
|
||||
params += "#" + encodeURIComponent(v_alias.value);
|
||||
if (params[0] == "&") {
|
||||
params = params.substring(1);
|
||||
}
|
||||
url += params;
|
||||
} else if ((v_type === "sing-box" || v_type === "Xray") && opt.get(dom_prefix + "protocol").value === "socks") {
|
||||
protocol = "socks";
|
||||
var v_username = opt.get(dom_prefix + "username");
|
||||
var v_password = opt.get(dom_prefix + "password");
|
||||
var v_port = opt.get(dom_prefix + "port");
|
||||
url = _address + ":" + v_port.value;
|
||||
if (v_username.value || v_password.value) {
|
||||
url = b64encutf8safe(v_username.value + ":" + v_password.value) + "@" + url;
|
||||
}
|
||||
var params = "";
|
||||
params += opt.query("uot", dom_prefix + "uot");
|
||||
params += opt.query("tfo", dom_prefix + "tcp_fast_open");
|
||||
if (params) {
|
||||
url += "?" + params.substring(1);
|
||||
}
|
||||
url += "#" + encodeURIComponent(v_alias.value);
|
||||
} else if ((v_type === "sing-box" || v_type === "Xray") && opt.get(dom_prefix + "protocol").value === "http") {
|
||||
protocol = opt.get(dom_prefix + "tls").checked ? "https" : "http";
|
||||
var v_username = opt.get(dom_prefix + "username");
|
||||
var v_password = opt.get(dom_prefix + "password");
|
||||
var v_port = opt.get(dom_prefix + "port");
|
||||
url = _address + ":" + v_port.value;
|
||||
if (v_username.value || v_password.value) {
|
||||
url = encodeURIComponent(v_username.value) + ":" + encodeURIComponent(v_password.value) + "@" + url;
|
||||
}
|
||||
var params = "";
|
||||
if (protocol === "https") {
|
||||
params += opt.query("sni", dom_prefix + "tls_serverName");
|
||||
params += opt.query("alpn", dom_prefix + "alpn");
|
||||
params += opt.query("insecure", dom_prefix + "tls_allowInsecure");
|
||||
params += opt.query("pcs", dom_prefix + "tls_pinSHA256");
|
||||
params += opt.query("vcn", dom_prefix + "tls_CertByName");
|
||||
if (opt.get(dom_prefix + "utls")?.checked) {
|
||||
params += opt.query("fp", dom_prefix + "fingerprint");
|
||||
}
|
||||
if (opt.get(dom_prefix + "ech")?.checked) {
|
||||
params += opt.query("ech", dom_prefix + "ech_config");
|
||||
}
|
||||
}
|
||||
params += opt.query("tfo", dom_prefix + "tcp_fast_open");
|
||||
if (params) {
|
||||
url += "?" + params.substring(1);
|
||||
}
|
||||
url += "#" + encodeURIComponent(v_alias.value);
|
||||
}
|
||||
|
||||
if (url) {
|
||||
@@ -1786,6 +1856,126 @@ local current_node = map:get(section)
|
||||
}
|
||||
}
|
||||
|
||||
if (link_type === "wireguard") {
|
||||
if (other_type == "sing-box" && has_singbox) {
|
||||
dom_prefix = "singbox_";
|
||||
opt.set('type', "sing-box");
|
||||
} else if (other_type == "xray" && has_xray) {
|
||||
dom_prefix = "xray_";
|
||||
opt.set('type', "Xray");
|
||||
}
|
||||
opt.set(dom_prefix + 'protocol', "wireguard");
|
||||
var info = link_split[1].split('@');
|
||||
var m = parseNodeUrl("wireguard://" + info[1]);
|
||||
var host_port = info[1].split(/[/?#]/)[0];
|
||||
opt.set(dom_prefix + 'address', unbracketIP(m.hostname));
|
||||
opt.set(dom_prefix + 'port', host_port.match(/:(\d+)$/)?.[1] || '51820');
|
||||
opt.set(dom_prefix + 'wireguard_secret_key', decodeURIComponent(info[0]));
|
||||
var queryParam = {};
|
||||
if (m.search.length > 1) {
|
||||
var queryArray = m.search.substr(1).split('&');
|
||||
for (var i = 0; i < queryArray.length; i++) {
|
||||
var index = queryArray[i].indexOf('=');
|
||||
if (index > 0) {
|
||||
queryParam[decodeURIComponent(queryArray[i].substr(0, index)).toLowerCase()] = decodeURIComponent(queryArray[i].substr(index + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
opt.set(dom_prefix + 'wireguard_public_key', queryParam.publickey);
|
||||
opt.set(dom_prefix + 'wireguard_preSharedKey', queryParam.presharedkey || '');
|
||||
var addresses = ((queryParam.address || queryParam.ip || '') + ',' + (queryParam.ipv6 || '')).split(/[,\s]+/).filter(Boolean);
|
||||
var fullName = opt.base + '.' + dom_prefix + 'wireguard_local_address';
|
||||
var lists = document.querySelectorAll('.cbi-dynlist');
|
||||
for (var i = 0; i < lists.length; i++) {
|
||||
var label = lists[i].closest('.cbi-value')?.querySelector('label.cbi-value-title');
|
||||
if (label?.getAttribute('for') === fullName) {
|
||||
L.dom.callClassMethod(lists[i], 'setValue', addresses);
|
||||
lists[i].dispatchEvent(new Event('change', { bubbles: true }));
|
||||
break;
|
||||
}
|
||||
}
|
||||
opt.set(dom_prefix + 'wireguard_reserved', queryParam.reserved || '');
|
||||
opt.set(dom_prefix + 'wireguard_mtu', queryParam.mtu || '1420');
|
||||
opt.set(dom_prefix + 'wireguard_keepAlive', queryParam['persistent-keepalive'] || queryParam.keepalive || '0');
|
||||
if (dom_prefix === "xray_") {
|
||||
opt.set(dom_prefix + 'use_finalmask', !!queryParam.fm);
|
||||
opt.set(dom_prefix + 'finalmask', queryParam.fm || '');
|
||||
}
|
||||
if (m.hash) {
|
||||
opt.set('remarks', decodeURIComponent(m.hash.substr(1)));
|
||||
}
|
||||
}
|
||||
|
||||
if (link_type === "socks" || link_type === "socks5" || link_type === "socks5h" || link_type === "http" || link_type === "https") {
|
||||
if (other_type == "sing-box" && has_singbox) {
|
||||
dom_prefix = "singbox_";
|
||||
opt.set('type', "sing-box");
|
||||
} else if (other_type == "xray" && has_xray) {
|
||||
dom_prefix = "xray_";
|
||||
opt.set('type', "Xray");
|
||||
}
|
||||
var protocol = (link_type === "http" || link_type === "https") ? "http" : "socks";
|
||||
opt.set(dom_prefix + 'protocol', protocol);
|
||||
var content = link_split[1];
|
||||
var index = content.search(/[?#]/);
|
||||
var suffix = index >= 0 ? content.substr(index) : '';
|
||||
content = index >= 0 ? content.substr(0, index) : content;
|
||||
var base64_auth = false;
|
||||
if (protocol === "socks" && content.indexOf('@') === -1 && content.indexOf(':') === -1) {
|
||||
content = b64decutf8safe(decodeURIComponent(content));
|
||||
base64_auth = true;
|
||||
}
|
||||
var auth = '';
|
||||
var index = content.lastIndexOf('@');
|
||||
if (index >= 0) {
|
||||
auth = content.substr(0, index);
|
||||
content = content.substr(index + 1);
|
||||
}
|
||||
if (protocol === "socks" && auth.indexOf(':') === -1) {
|
||||
auth = b64decutf8safe(decodeURIComponent(auth));
|
||||
base64_auth = true;
|
||||
}
|
||||
var index = auth.indexOf(':');
|
||||
var username = index >= 0 ? auth.substr(0, index) : auth;
|
||||
var password = index >= 0 ? auth.substr(index + 1) : '';
|
||||
if (!base64_auth) {
|
||||
username = decodeURIComponent(username);
|
||||
password = decodeURIComponent(password);
|
||||
}
|
||||
var m = new URL(link_type + "://" + content + suffix);
|
||||
opt.set(dom_prefix + 'address', unbracketIP(m.hostname));
|
||||
opt.set(dom_prefix + 'port', m.port || (protocol === "socks" ? "1080" : (link_type === "https" ? "443" : "80")));
|
||||
opt.set(dom_prefix + 'username', username);
|
||||
opt.set(dom_prefix + 'password', password);
|
||||
opt.set(dom_prefix + 'transport', dom_prefix === "xray_" ? "raw" : "tcp");
|
||||
var queryParam = {};
|
||||
if (m.search.length > 1) {
|
||||
var queryArray = m.search.substr(1).split('&');
|
||||
for (var i = 0; i < queryArray.length; i++) {
|
||||
var index = queryArray[i].indexOf('=');
|
||||
if (index > 0) {
|
||||
queryParam[decodeURIComponent(queryArray[i].substr(0, index)).toLowerCase()] = decodeURIComponent(queryArray[i].substr(index + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
opt.set(dom_prefix + 'uot', queryParam.uot === '1');
|
||||
opt.set(dom_prefix + 'tcp_fast_open', queryParam.tfo === '1');
|
||||
opt.set(dom_prefix + 'tls', link_type === "https");
|
||||
opt.set(dom_prefix + 'reality', false);
|
||||
opt.set(dom_prefix + 'tls_serverName', queryParam.sni || '');
|
||||
opt.set(dom_prefix + 'alpn', queryParam.alpn || 'default');
|
||||
opt.set(dom_prefix + 'tls_allowInsecure', (queryParam.allowinsecure || queryParam.insecure || queryParam.allow_insecure || '0') === '1');
|
||||
opt.set(dom_prefix + 'tls_pinSHA256', queryParam.pcs || '');
|
||||
opt.set(dom_prefix + 'tls_CertByName', queryParam.vcn || '');
|
||||
opt.set(dom_prefix + 'utls', !!queryParam.fp);
|
||||
opt.set(dom_prefix + 'fingerprint', queryParam.fp || 'chrome');
|
||||
opt.set(dom_prefix + 'ech', !!queryParam.ech);
|
||||
opt.set(dom_prefix + 'ech_config', queryParam.ech || '');
|
||||
if (m.hash) {
|
||||
opt.set('remarks', decodeURIComponent(m.hash.substr(1)));
|
||||
}
|
||||
}
|
||||
|
||||
if (switch_type) {
|
||||
sessionStorage.setItem("fromUrl", JSON.stringify({
|
||||
timestamp: Date.now(),
|
||||
|
||||
@@ -604,6 +604,9 @@ msgstr "پنجره دریافت اتصال QUIC"
|
||||
msgid "QUIC concurrent bidirectional streams"
|
||||
msgstr "جریانهای دوطرفه همزمان QUIC"
|
||||
|
||||
msgid "Keep Alive"
|
||||
msgstr "زنده نگه داشتن اتصال"
|
||||
|
||||
msgid "QUIC KeepAlive interval"
|
||||
msgstr "فاصله QUIC KeepAlive"
|
||||
|
||||
@@ -1369,6 +1372,9 @@ msgstr "زمانی استفاده میشود که لینک گره شامل ا
|
||||
msgid "%s Node Use Type"
|
||||
msgstr "نوع استفاده گره %s"
|
||||
|
||||
msgid "Other"
|
||||
msgstr "سایر"
|
||||
|
||||
msgid "UDP relay mode"
|
||||
msgstr "حالت بازپخش UDP"
|
||||
|
||||
|
||||
@@ -605,6 +605,9 @@ msgstr "Размер окна приёма соединения QUIC"
|
||||
msgid "QUIC concurrent bidirectional streams"
|
||||
msgstr "Макс. количество одновременных двунаправленных потоков QUIC"
|
||||
|
||||
msgid "Keep Alive"
|
||||
msgstr "Поддержание соединения"
|
||||
|
||||
msgid "QUIC KeepAlive interval"
|
||||
msgstr "Интервал QUIC KeepAlive"
|
||||
|
||||
@@ -1370,6 +1373,9 @@ msgstr "Используется, если в ссылке на узел это
|
||||
msgid "%s Node Use Type"
|
||||
msgstr "Тип использования сервера %s"
|
||||
|
||||
msgid "Other"
|
||||
msgstr "Другие"
|
||||
|
||||
msgid "UDP relay mode"
|
||||
msgstr "Режим ретрансляции UDP"
|
||||
|
||||
|
||||
@@ -596,6 +596,9 @@ msgstr "QUIC 连接接收窗口"
|
||||
msgid "QUIC concurrent bidirectional streams"
|
||||
msgstr "QUIC 并发双向流的最大数量"
|
||||
|
||||
msgid "Keep Alive"
|
||||
msgstr "保持连接"
|
||||
|
||||
msgid "QUIC KeepAlive interval"
|
||||
msgstr "QUIC KeepAlive 间隔"
|
||||
|
||||
@@ -1361,6 +1364,9 @@ msgstr "当节点链接未包含该参数时,将使用此设置。"
|
||||
msgid "%s Node Use Type"
|
||||
msgstr "%s 节点使用类型"
|
||||
|
||||
msgid "Other"
|
||||
msgstr "其他"
|
||||
|
||||
msgid "UDP relay mode"
|
||||
msgstr "UDP中继模式"
|
||||
|
||||
|
||||
@@ -596,6 +596,9 @@ msgstr "QUIC 連接接收窗口"
|
||||
msgid "QUIC concurrent bidirectional streams"
|
||||
msgstr "QUIC 並發双向流的最大數量"
|
||||
|
||||
msgid "Keep Alive"
|
||||
msgstr "保持連線"
|
||||
|
||||
msgid "QUIC KeepAlive interval"
|
||||
msgstr "QUIC KeepAlive 間隔"
|
||||
|
||||
@@ -1361,6 +1364,9 @@ msgstr "當節點連結未包含該參數時,將使用此設定。"
|
||||
msgid "%s Node Use Type"
|
||||
msgstr "%s 節點使用類型"
|
||||
|
||||
msgid "Other"
|
||||
msgstr "其他"
|
||||
|
||||
msgid "UDP relay mode"
|
||||
msgstr "UDP中继模式"
|
||||
|
||||
|
||||
@@ -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