Skip to content

Commit ffa459b

Browse files
committed
fix: 更新反代参数获取函数,修正正则表达式以支持更严格的IP和账号匹配
1 parent aa68476 commit ffa459b

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

_worker.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,7 +1688,7 @@ async function 反代参数获取(request) {
16881688
启用SOCKS5全局反代 = searchParams.has('globalproxy') || false;
16891689

16901690
// 统一处理反代IP参数 (优先级最高,使用正则一次匹配)
1691-
const proxyMatch = pathLower.match(/\/(proxyip[.=]|pyip=|ip=)(.+)/);
1691+
const proxyMatch = pathLower.match(/\/(proxyip[.=]|pyip=|ip=)([^/?]+)/);
16921692
if (searchParams.has('proxyip')) {
16931693
const 路参IP = searchParams.get('proxyip');
16941694
反代IP = 路参IP.includes(',') ? 路参IP.split(',')[Math.floor(Math.random() * 路参IP.split(',').length)] : 路参IP;
@@ -1703,10 +1703,10 @@ async function 反代参数获取(request) {
17031703

17041704
// 处理SOCKS5/HTTP代理参数
17051705
let socksMatch;
1706-
if ((socksMatch = pathname.match(/\/(socks5?|http):\/?\/?(.+)/i))) {
1706+
if ((socksMatch = pathname.match(/\/(socks5?|http):\/?\/?([^/?#]+)/i))) {
17071707
// 格式: /socks5://... 或 /http://...
17081708
启用SOCKS5反代 = socksMatch[1].toLowerCase() === 'http' ? 'http' : 'socks5';
1709-
我的SOCKS5账号 = socksMatch[2].split('#')[0];
1709+
我的SOCKS5账号 = socksMatch[2];
17101710
启用SOCKS5全局反代 = true;
17111711

17121712
// 处理Base64编码的用户名密码
@@ -1718,7 +1718,7 @@ async function 反代参数获取(request) {
17181718
}
17191719
我的SOCKS5账号 = `${userPassword}@${我的SOCKS5账号.substring(atIndex + 1)}`;
17201720
}
1721-
} else if ((socksMatch = pathname.match(/\/(g?s5|socks5|g?http)=(.+)/i))) {
1721+
} else if ((socksMatch = pathname.match(/\/(g?s5|socks5|g?http)=([^/?#]+)/i))) {
17221722
// 格式: /socks5=... 或 /s5=... 或 /gs5=... 或 /http=... 或 /ghttp=...
17231723
const type = socksMatch[1].toLowerCase();
17241724
我的SOCKS5账号 = socksMatch[2];

0 commit comments

Comments
 (0)