fix: 修复ss2022订阅下发密码错误的问题

This commit is contained in:
xboard 2024-05-24 22:45:27 +08:00
parent 2b0bf6cbb7
commit fd52795f49
16 changed files with 37 additions and 65 deletions

View File

@ -47,7 +47,7 @@ class Clash
'chacha20-ietf-poly1305' 'chacha20-ietf-poly1305'
]) ])
) { ) {
array_push($proxy, self::buildShadowsocks($user['uuid'], $item)); array_push($proxy, self::buildShadowsocks($item['password'], $item));
array_push($proxies, $item['name']); array_push($proxies, $item['name']);
} }
if ($item['type'] === 'vmess') { if ($item['type'] === 'vmess') {

View File

@ -38,7 +38,7 @@ class ClashMeta
foreach ($servers as $item) { foreach ($servers as $item) {
if ($item['type'] === 'shadowsocks') { if ($item['type'] === 'shadowsocks') {
array_push($proxy, self::buildShadowsocks($user['uuid'], $item)); array_push($proxy, self::buildShadowsocks($item['password'], $item));
array_push($proxies, $item['name']); array_push($proxies, $item['name']);
} }
if ($item['type'] === 'vmess') { if ($item['type'] === 'vmess') {
@ -97,16 +97,6 @@ class ClashMeta
public static function buildShadowsocks($password, $server) public static function buildShadowsocks($password, $server)
{ {
if ($server['cipher'] === '2022-blake3-aes-128-gcm') {
$serverKey = Helper::getServerKey($server['created_at'], 16);
$userKey = Helper::uuidToBase64($password, 16);
$password = "{$serverKey}:{$userKey}";
}
if ($server['cipher'] === '2022-blake3-aes-256-gcm') {
$serverKey = Helper::getServerKey($server['created_at'], 32);
$userKey = Helper::uuidToBase64($password, 32);
$password = "{$serverKey}:{$userKey}";
}
$array = []; $array = [];
$array['name'] = $server['name']; $array['name'] = $server['name'];
$array['type'] = 'ss'; $array['type'] = 'ss';

View File

@ -31,7 +31,7 @@ class General
$uri .= self::buildVless($user['uuid'], $item); $uri .= self::buildVless($user['uuid'], $item);
} }
if ($item['type'] === 'shadowsocks') { if ($item['type'] === 'shadowsocks') {
$uri .= self::buildShadowsocks($user['uuid'], $item); $uri .= self::buildShadowsocks($item['password'], $item);
} }
if ($item['type'] === 'trojan') { if ($item['type'] === 'trojan') {
$uri .= self::buildTrojan($user['uuid'], $item); $uri .= self::buildTrojan($user['uuid'], $item);
@ -42,16 +42,6 @@ class General
public static function buildShadowsocks($password, $server) public static function buildShadowsocks($password, $server)
{ {
if ($server['cipher'] === '2022-blake3-aes-128-gcm') {
$serverKey = Helper::getServerKey($server['created_at'], 16);
$userKey = Helper::uuidToBase64($password, 16);
$password = "{$serverKey}:{$userKey}";
}
if ($server['cipher'] === '2022-blake3-aes-256-gcm') {
$serverKey = Helper::getServerKey($server['created_at'], 32);
$userKey = Helper::uuidToBase64($password, 32);
$password = "{$serverKey}:{$userKey}";
}
$name = rawurlencode($server['name']); $name = rawurlencode($server['name']);
$str = str_replace( $str = str_replace(
['+', '/', '='], ['+', '/', '='],

View File

@ -30,7 +30,7 @@ class Loon
'chacha20-ietf-poly1305' 'chacha20-ietf-poly1305'
]) ])
) { ) {
$uri .= self::buildShadowsocks($user['uuid'], $item); $uri .= self::buildShadowsocks($item['password'], $item);
} }
if ($item['type'] === 'vmess') { if ($item['type'] === 'vmess') {
$uri .= self::buildVmess($user['uuid'], $item); $uri .= self::buildVmess($user['uuid'], $item);

View File

@ -29,7 +29,7 @@ class Passwall
$uri .= self::buildVless($user['uuid'], $item); $uri .= self::buildVless($user['uuid'], $item);
} }
if ($item['type'] === 'shadowsocks') { if ($item['type'] === 'shadowsocks') {
$uri .= self::buildShadowsocks($user['uuid'], $item); $uri .= self::buildShadowsocks($item['password'], $item);
} }
if ($item['type'] === 'trojan') { if ($item['type'] === 'trojan') {
$uri .= self::buildTrojan($user['uuid'], $item); $uri .= self::buildTrojan($user['uuid'], $item);

View File

@ -22,7 +22,7 @@ class QuantumultX
$uri = ''; $uri = '';
foreach ($servers as $item) { foreach ($servers as $item) {
if ($item['type'] === 'shadowsocks') { if ($item['type'] === 'shadowsocks') {
$uri .= self::buildShadowsocks($user['uuid'], $item); $uri .= self::buildShadowsocks($item['password'], $item);
} }
if ($item['type'] === 'vmess') { if ($item['type'] === 'vmess') {
$uri .= self::buildVmess($user['uuid'], $item); $uri .= self::buildVmess($user['uuid'], $item);

View File

@ -29,7 +29,7 @@ class SSRPlus
$uri .= self::buildVless($user['uuid'], $item); $uri .= self::buildVless($user['uuid'], $item);
} }
if ($item['type'] === 'shadowsocks') { if ($item['type'] === 'shadowsocks') {
$uri .= self::buildShadowsocks($user['uuid'], $item); $uri .= self::buildShadowsocks($item['password'], $item);
} }
if ($item['type'] === 'trojan') { if ($item['type'] === 'trojan') {
$uri .= self::buildTrojan($user['uuid'], $item); $uri .= self::buildTrojan($user['uuid'], $item);

View File

@ -25,7 +25,7 @@ class SagerNet
$uri .= self::buildVmess($user['uuid'], $item); $uri .= self::buildVmess($user['uuid'], $item);
} }
if ($item['type'] === 'shadowsocks') { if ($item['type'] === 'shadowsocks') {
$uri .= self::buildShadowsocks($user['uuid'], $item); $uri .= self::buildShadowsocks($item['password'], $item);
} }
if ($item['type'] === 'trojan') { if ($item['type'] === 'trojan') {
$uri .= self::buildTrojan($user['uuid'], $item); $uri .= self::buildTrojan($user['uuid'], $item);

View File

@ -31,7 +31,7 @@ class Shadowrocket
$uri .= "STATUS=🚀↑:{$upload}GB,↓:{$download}GB,TOT:{$totalTraffic}GB💡Expires:{$expiredDate}\r\n"; $uri .= "STATUS=🚀↑:{$upload}GB,↓:{$download}GB,TOT:{$totalTraffic}GB💡Expires:{$expiredDate}\r\n";
foreach ($servers as $item) { foreach ($servers as $item) {
if ($item['type'] === 'shadowsocks') { if ($item['type'] === 'shadowsocks') {
$uri .= self::buildShadowsocks($user['uuid'], $item); $uri .= self::buildShadowsocks($item['password'], $item);
} }
if ($item['type'] === 'vmess') { if ($item['type'] === 'vmess') {
$uri .= self::buildVmess($user['uuid'], $item); $uri .= self::buildVmess($user['uuid'], $item);
@ -52,16 +52,6 @@ class Shadowrocket
public static function buildShadowsocks($password, $server) public static function buildShadowsocks($password, $server)
{ {
if ($server['cipher'] === '2022-blake3-aes-128-gcm') {
$serverKey = Helper::getServerKey($server['created_at'], 16);
$userKey = Helper::uuidToBase64($password, 16);
$password = "{$serverKey}:{$userKey}";
}
if ($server['cipher'] === '2022-blake3-aes-256-gcm') {
$serverKey = Helper::getServerKey($server['created_at'], 32);
$userKey = Helper::uuidToBase64($password, 32);
$password = "{$serverKey}:{$userKey}";
}
$name = rawurlencode($server['name']); $name = rawurlencode($server['name']);
$str = str_replace( $str = str_replace(
['+', '/', '='], ['+', '/', '='],

View File

@ -44,7 +44,7 @@ class SingBox
$proxies = []; $proxies = [];
foreach ($this->servers as $item) { foreach ($this->servers as $item) {
if ($item['type'] === 'shadowsocks') { if ($item['type'] === 'shadowsocks') {
$ssConfig = $this->buildShadowsocks($this->user['uuid'], $item); $ssConfig = $this->buildShadowsocks($item['password'], $item);
$proxies[] = $ssConfig; $proxies[] = $ssConfig;
} }
if ($item['type'] === 'trojan') { if ($item['type'] === 'trojan') {
@ -77,16 +77,6 @@ class SingBox
protected function buildShadowsocks($password, $server) protected function buildShadowsocks($password, $server)
{ {
if ($server['cipher'] === '2022-blake3-aes-128-gcm') {
$serverKey = Helper::getServerKey($server['created_at'], 16);
$userKey = Helper::uuidToBase64($password, 16);
$password = "{$serverKey}:{$userKey}";
}
if ($server['cipher'] === '2022-blake3-aes-256-gcm') {
$serverKey = Helper::getServerKey($server['created_at'], 32);
$userKey = Helper::uuidToBase64($password, 32);
$password = "{$serverKey}:{$userKey}";
}
$array = []; $array = [];
$array['tag'] = $server['name']; $array['tag'] = $server['name'];
$array['type'] = 'shadowsocks'; $array['type'] = 'shadowsocks';

View File

@ -45,7 +45,7 @@ class Stash
'chacha20-ietf-poly1305' 'chacha20-ietf-poly1305'
]) ])
) { ) {
array_push($proxy, self::buildShadowsocks($user['uuid'], $item)); array_push($proxy, self::buildShadowsocks($item['password'], $item));
array_push($proxies, $item['name']); array_push($proxies, $item['name']);
} }
if ($item['type'] === 'vmess') { if ($item['type'] === 'vmess') {

View File

@ -36,7 +36,7 @@ class Surfboard
]) ])
) { ) {
// [Proxy] // [Proxy]
$proxies .= self::buildShadowsocks($user['uuid'], $item); $proxies .= self::buildShadowsocks($item['password'], $item);
// [Proxy Group] // [Proxy Group]
$proxyGroup .= $item['name'] . ', '; $proxyGroup .= $item['name'] . ', ';
} }

View File

@ -36,7 +36,7 @@ class Surge
]) ])
) { ) {
// [Proxy] // [Proxy]
$proxies .= self::buildShadowsocks($user['uuid'], $item); $proxies .= self::buildShadowsocks($item['password'], $item);
// [Proxy Group] // [Proxy Group]
$proxyGroup .= $item['name'] . ', '; $proxyGroup .= $item['name'] . ', ';
} }

View File

@ -31,7 +31,7 @@ class V2rayN
$uri .= self::buildVless($user['uuid'], $item); $uri .= self::buildVless($user['uuid'], $item);
} }
if ($item['type'] === 'shadowsocks') { if ($item['type'] === 'shadowsocks') {
$uri .= self::buildShadowsocks($user['uuid'], $item); $uri .= self::buildShadowsocks($item['password'], $item);
} }
if ($item['type'] === 'trojan') { if ($item['type'] === 'trojan') {
$uri .= self::buildTrojan($user['uuid'], $item); $uri .= self::buildTrojan($user['uuid'], $item);
@ -46,16 +46,6 @@ class V2rayN
public static function buildShadowsocks($password, $server) public static function buildShadowsocks($password, $server)
{ {
if ($server['cipher'] === '2022-blake3-aes-128-gcm') {
$serverKey = Helper::getServerKey($server['created_at'], 16);
$userKey = Helper::uuidToBase64($password, 16);
$password = "{$serverKey}:{$userKey}";
}
if ($server['cipher'] === '2022-blake3-aes-256-gcm') {
$serverKey = Helper::getServerKey($server['created_at'], 32);
$userKey = Helper::uuidToBase64($password, 32);
$password = "{$serverKey}:{$userKey}";
}
$name = rawurlencode($server['name']); $name = rawurlencode($server['name']);
$str = str_replace( $str = str_replace(
['+', '/', '='], ['+', '/', '='],

View File

@ -26,7 +26,7 @@ class V2rayNG
$uri .= self::buildVmess($user['uuid'], $item); $uri .= self::buildVmess($user['uuid'], $item);
} }
if ($item['type'] === 'shadowsocks') { if ($item['type'] === 'shadowsocks') {
$uri .= self::buildShadowsocks($user['uuid'], $item); $uri .= self::buildShadowsocks($item['password'], $item);
} }
if ($item['type'] === 'trojan') { if ($item['type'] === 'trojan') {
$uri .= self::buildTrojan($user['uuid'], $item); $uri .= self::buildTrojan($user['uuid'], $item);

View File

@ -139,6 +139,28 @@ class ServerService
$shadowsocks[$key]['last_check_at'] = Cache::get(CacheKey::get('SERVER_SHADOWSOCKS_LAST_CHECK_AT', $v['parent_id'])); $shadowsocks[$key]['last_check_at'] = Cache::get(CacheKey::get('SERVER_SHADOWSOCKS_LAST_CHECK_AT', $v['parent_id']));
$shadowsocks[$key]['created_at'] = $shadowsocks[$v['parent_id']]['created_at']; $shadowsocks[$key]['created_at'] = $shadowsocks[$v['parent_id']]['created_at'];
} }
// 处理ss2022密码
$cipherConfiguration = [
'2022-blake3-aes-128-gcm' => [
'serverKeySize' => 16,
'userKeySize' => 16,
],
'2022-blake3-aes-256-gcm' => [
'serverKeySize' => 32,
'userKeySize' => 32,
],
'2022-blake3-chacha20-poly1305' => [
'serverKeySize' => 32,
'userKeySize' => 32,
]
];
$shadowsocks[$key]['password'] = $user['uuid'];
if (array_key_exists($cipher = $v['cipher'], $cipherConfiguration)) {
$config = $cipherConfiguration[$cipher];
$serverKey = Helper::getServerKey($v['created_at'], $config['serverKeySize']);
$userKey = Helper::uuidToBase64($user['uuid'], $config['userKeySize']);
$shadowsocks[$key]['password'] = "{$serverKey}:{$userKey}";
}
$servers[] = $shadowsocks[$key]->toArray(); $servers[] = $shadowsocks[$key]->toArray();
} }
return $servers; return $servers;