mirror of
https://github.com/v2board/v2board.git
synced 2025-06-12 12:37:54 +08:00
feature: shadowsocks and more
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
namespace App\Utils;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\ServerShadowsocks;
|
||||
use App\Models\ServerTrojan;
|
||||
use App\Models\User;
|
||||
|
||||
@ -57,42 +58,6 @@ class Helper
|
||||
return $str;
|
||||
}
|
||||
|
||||
public static function buildTrojanLink(ServerTrojan $server, User $user)
|
||||
{
|
||||
$server->name = rawurlencode($server->name);
|
||||
$query = http_build_query([
|
||||
'allowInsecure' => $server->allow_insecure,
|
||||
'peer' => $server->server_name,
|
||||
'sni' => $server->server_name
|
||||
]);
|
||||
$uri = "trojan://{$user->uuid}@{$server->host}:{$server->port}?{$query}#{$server->name}";
|
||||
$uri .= "\r\n";
|
||||
return $uri;
|
||||
}
|
||||
|
||||
public static function buildVmessLink(Server $server, User $user)
|
||||
{
|
||||
$config = [
|
||||
"v" => "2",
|
||||
"ps" => $server->name,
|
||||
"add" => $server->host,
|
||||
"port" => $server->port,
|
||||
"id" => $user->uuid,
|
||||
"aid" => "2",
|
||||
"net" => $server->network,
|
||||
"type" => "none",
|
||||
"host" => "",
|
||||
"path" => "",
|
||||
"tls" => $server->tls ? "tls" : ""
|
||||
];
|
||||
if ((string)$server->network === 'ws') {
|
||||
$wsSettings = json_decode($server->networkSettings);
|
||||
if (isset($wsSettings->path)) $config['path'] = $wsSettings->path;
|
||||
if (isset($wsSettings->headers->Host)) $config['host'] = $wsSettings->headers->Host;
|
||||
}
|
||||
return "vmess://" . base64_encode(json_encode($config)) . "\r\n";
|
||||
}
|
||||
|
||||
public static function multiPasswordVerify($algo, $password, $hash)
|
||||
{
|
||||
switch($algo) {
|
||||
|
Reference in New Issue
Block a user