subscription: add shadowsocks SIP008 subscription support

Signed-off-by: Beta Soft <betaxab@gmail.com>
This commit is contained in:
Beta Soft 2020-11-19 13:05:49 +08:00
parent a0dcf51c28
commit 7f12a79d07
No known key found for this signature in database
GPG Key ID: 180A31AB98D5C156
2 changed files with 34 additions and 0 deletions

View File

@ -50,6 +50,9 @@ class ClientController extends Controller
if (strpos($flag, 'shadowrocket') !== false) {
die($this->shadowrocket($user, $servers));
}
if (strpos($flag, 'shadowsocks') !== false) {
die($this->shaodowsocksSIP008($user, $servers));
}
}
die($this->origin($user, $servers));
}
@ -135,6 +138,25 @@ class ClientController extends Controller
return base64_encode($uri);
}
private function shaodowsocksSIP008($user, $servers = [])
{
$configs = [];
$subs = [];
$subs['servers'] = [];
foreach ($servers as $item) {
if ($item['type'] === 'shadowsocks') {
array_push($configs, URLSchemes::buildShadowsocksSIP008($item, $user));
}
}
$subs['version'] = 1;
$subs['remark'] = config('v2board.app_name', 'V2Board');
$subs['servers'] = array_merge($subs['servers'] ? $subs['servers'] : [], $configs);
return json_encode($subs, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
}
private function surge($user, $servers = [])
{
$proxies = '';

View File

@ -17,6 +17,18 @@ class URLSchemes
return "ss://{$str}@{$server['host']}:{$server['port']}#{$name}\r\n";
}
public static function buildShadowsocksSIP008($server, User $user)
{
$config = [
"id" => $server['id'],
"remark" => $server['name'],
"server" => $server['host'],
"server_port" => $server['port'],
"password" => $user['uuid'],
"method" => $server['cipher']
];
return $config;
}
public static function buildVmess($server, User $user)
{