✨ Sync 2026-11-11 01:22:09

This commit is contained in:
github-actions[bot] committed 2026-11-11 01:22:09 +08:00
1 parent 9c5aa2e662
commit cc21462d8a
48 files changed
+9760 -59

No files matched your search

@@ -10,6 +10,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"
@@ -22,6 +23,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"
@@ -29,6 +31,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
@@ -100,7 +103,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
@@ -23,6 +23,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"
@@ -35,6 +36,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"
@@ -42,6 +44,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
@@ -222,7 +225,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"
@@ -706,6 +706,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部分(模拟) ]]--
@@ -507,6 +507,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
@@ -2438,7 +2439,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
}
},
@@ -436,7 +436,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
}
@@ -14,6 +14,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_hysteria2,"hysteria2"},{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)
-%>
@@ -27,6 +28,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);
@@ -191,6 +193,8 @@ local current_node = map:get(section)
dom_prefix = "xray_"
} else if (v_type === "sing-box") {
dom_prefix = "singbox_"
} else if (v_type === "Socks") {
dom_prefix = "socks_"
}
var _address = ""
if (dom_prefix && dom_prefix != null) {
@@ -741,6 +745,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 === "Socks" || ((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) {
@@ -1828,6 +1900,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(),