fix: 处理SOCKS5账号中的Base64编码和用户密码解析

This commit is contained in:
cmliu
2025-11-07 02:29:58 +08:00
parent 163e0e994c
commit d3097e5dbb

View File

@@ -1035,6 +1035,13 @@ async function 反代参数获取(request) {
}
async function 获取SOCKS5账号(address) {
if (address.includes('@')) {
const lastAtIndex = address.lastIndexOf('@');
let userPassword = address.substring(0, lastAtIndex).replaceAll('%3D', '=');
const base64Regex = /^(?:[A-Z0-9+/]{4})*(?:[A-Z0-9+/]{2}==|[A-Z0-9+/]{3}=)?$/i;
if (base64Regex.test(userPassword) && !userPassword.includes(':')) userPassword = atob(userPassword);
address = `${userPassword}@${address.substring(lastAtIndex + 1)}`;
}
const atIndex = address.lastIndexOf("@");
const [hostPart, authPart] = atIndex === -1 ? [address, undefined] : [address.substring(atIndex + 1), address.substring(0, atIndex)];