update: new cipher

This commit is contained in:
tokumeikoi 2022-11-18 03:25:02 +08:00
parent 964376fa3c
commit 5c4e863560
3 changed files with 26 additions and 1 deletions

View File

@ -2,6 +2,8 @@
namespace App\Http\Controllers\Client\Protocols; namespace App\Http\Controllers\Client\Protocols;
use App\Utils\Helper;
class Shadowrocket class Shadowrocket
{ {
public $flag = 'shadowrocket'; public $flag = 'shadowrocket';
@ -43,6 +45,16 @@ class Shadowrocket
public static function buildShadowsocks($password, $server) public static function buildShadowsocks($password, $server)
{ {
if ($server['cipher'] === '2022-blake3-aes-128-gcm') {
$serverKey = Helper::getShadowsocksServerKey($server['created_at'], 16);
$userKey = Helper::uuidToBase64($password, 16);
$password = "{$serverKey}:{$userKey}";
}
if ($server['cipher'] === '2022-blake3-aes-256-gcm') {
$serverKey = Helper::getShadowsocksServerKey($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

@ -99,6 +99,13 @@ class UniProxyController extends Controller
'obfs' => $this->nodeInfo->obfs, 'obfs' => $this->nodeInfo->obfs,
'obfs_settings' => $this->nodeInfo->obfs_settings 'obfs_settings' => $this->nodeInfo->obfs_settings
]; ];
if ($this->nodeInfo->cipher === '2022-blake3-aes-128-gcm') {
$response['server_key'] = Helper::getShadowsocksServerKey($this->nodeInfo->created_at, 16);
}
if ($this->nodeInfo->cipher === '2022-blake3-aes-256-gcm') {
$response['server_key'] = Helper::getShadowsocksServerKey($this->nodeInfo->created_at, 32);
}
break; break;
case 'v2ray': case 'v2ray':
$response = [ $response = [

View File

@ -6,8 +6,14 @@ class Helper
{ {
public static function uuidToBase64($uuid, $length) public static function uuidToBase64($uuid, $length)
{ {
return base64_encode(substr(str_replace('-', '', $uuid), 0, $length - 6)); return base64_encode(substr($uuid, 0, $length));
} }
public static function getShadowsocksServerKey($timestamp, $length)
{
return base64_encode(substr(md5($timestamp), 0, $length));
}
public static function guid($format = false) public static function guid($format = false)
{ {
if (function_exists('com_create_guid') === true) { if (function_exists('com_create_guid') === true) {