mirror of
https://github.com/v2board/v2board.git
synced 2025-06-12 12:37:54 +08:00
Shadowrocket specified url generator
shadowrocket ClientController enable tfo on vmess for shadowrocket enable tfo on trojan for shadowrocket fix typo
This commit is contained in:
43
app/Utils/Shadowrocket.php
Normal file
43
app/Utils/Shadowrocket.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utils;
|
||||
|
||||
|
||||
class Shadowrocket
|
||||
{
|
||||
public static function buildVmess($uuid, $server)
|
||||
{
|
||||
$userinfo = base64_encode('auto:' . $uuid . '@' . $server->host . ':' . $server->port);
|
||||
$config = [
|
||||
'remark' => $server->name
|
||||
];
|
||||
if ($server->tls) {
|
||||
$tlsSettings = json_decode($server->tlsSettings);
|
||||
$config['tls'] = 1;
|
||||
if (isset($tlsSettings->serverName)) $config['peer'] = $tlsSettings->serverName;
|
||||
if (isset($tlsSettings->allowInsecure)) $config['allowInsecure'] = 1;
|
||||
}
|
||||
if ($server->network === 'ws') {
|
||||
$wsSettings = json_decode($server->networkSettings);
|
||||
$config['obfs'] = "websocket";
|
||||
if (isset($wsSettings->path)) $config['path'] = $wsSettings->path;
|
||||
if (isset($wsSettings->headers->Host)) $config['obfsParam'] = $wsSettings->headers->Host;
|
||||
}
|
||||
$query = http_build_query($config);
|
||||
$uri = "vmess://{$userinfo}?{$query}&tfo=1";
|
||||
$uri .= "\r\n";
|
||||
return $uri;
|
||||
}
|
||||
|
||||
public static function buildTrojan($password, $server)
|
||||
{
|
||||
$server->name = rawurlencode($server->name);
|
||||
$query = http_build_query([
|
||||
'allowInsecure' => $server->allow_insecure,
|
||||
'peer' => $server->server_name
|
||||
]);
|
||||
$uri = "trojan://{$password}@{$server->host}:{$server->port}?{$query}&tfo=1#{$server->name}";
|
||||
$uri .= "\r\n";
|
||||
return $uri;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user