mirror of
https://github.com/lush2020/edgetunnel.git
synced 2026-03-21 17:12:33 +08:00
fix: 处理SOCKS5账号中的Base64编码和用户密码解析
This commit is contained in:
@@ -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)];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user