mirror of
https://github.com/v2board/v2board.git
synced 2024-11-14 07:29:13 +08:00
update: support shadowsocks app subscribe
This commit is contained in:
parent
63adb9c4a8
commit
6fd577d2c8
@ -44,7 +44,7 @@ class ClientController extends Controller
|
|||||||
die($this->surge($user, $servers['vmess'], $servers['trojan']));
|
die($this->surge($user, $servers['vmess'], $servers['trojan']));
|
||||||
}
|
}
|
||||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'shadowrocket') !== false) {
|
if (strpos($_SERVER['HTTP_USER_AGENT'], 'shadowrocket') !== false) {
|
||||||
die($this->shadowrocket($user, $servers['vmess'], $servers['trojan']));
|
die($this->shadowrocket($user, $servers['shadowsocks'], $servers['vmess'], $servers['trojan']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
die($this->origin($user, $servers['shadowsocks'], $servers['vmess'], $servers['trojan']));
|
die($this->origin($user, $servers['shadowsocks'], $servers['vmess'], $servers['trojan']));
|
||||||
@ -71,7 +71,7 @@ class ClientController extends Controller
|
|||||||
return base64_encode($uri);
|
return base64_encode($uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function shadowrocket($user, $vmess = [], $trojan = [])
|
private function shadowrocket($user, $shadowsocks = [], $vmess = [], $trojan = [])
|
||||||
{
|
{
|
||||||
$uri = '';
|
$uri = '';
|
||||||
//display remaining traffic and expire date
|
//display remaining traffic and expire date
|
||||||
@ -80,6 +80,9 @@ class ClientController extends Controller
|
|||||||
$totalTraffic = round($user->transfer_enable / (1024*1024*1024), 2);
|
$totalTraffic = round($user->transfer_enable / (1024*1024*1024), 2);
|
||||||
$expiredDate = date('Y-m-d', $user->expired_at);
|
$expiredDate = date('Y-m-d', $user->expired_at);
|
||||||
$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 ($shadowsocks as $item) {
|
||||||
|
$uri .= Shadowrocket::buildShadowsocks($user->uuid, $item);
|
||||||
|
}
|
||||||
foreach ($vmess as $item) {
|
foreach ($vmess as $item) {
|
||||||
$uri .= Shadowrocket::buildVmess($user->uuid, $item);
|
$uri .= Shadowrocket::buildVmess($user->uuid, $item);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,17 @@ namespace App\Utils;
|
|||||||
|
|
||||||
class Shadowrocket
|
class Shadowrocket
|
||||||
{
|
{
|
||||||
|
public static function buildShadowsocks($password, $server)
|
||||||
|
{
|
||||||
|
$name = rawurlencode($server->name);
|
||||||
|
$str = str_replace(
|
||||||
|
['+', '/', '='],
|
||||||
|
['-', '_', ''],
|
||||||
|
base64_encode("{$server->cipher}:{$password}")
|
||||||
|
);
|
||||||
|
return "ss://{$str}@{$server->host}:{$server->port}#{$name}\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
public static function buildVmess($uuid, $server)
|
public static function buildVmess($uuid, $server)
|
||||||
{
|
{
|
||||||
$userinfo = base64_encode('auto:' . $uuid . '@' . $server->host . ':' . $server->port);
|
$userinfo = base64_encode('auto:' . $uuid . '@' . $server->host . ':' . $server->port);
|
||||||
@ -31,12 +42,12 @@ class Shadowrocket
|
|||||||
|
|
||||||
public static function buildTrojan($password, $server)
|
public static function buildTrojan($password, $server)
|
||||||
{
|
{
|
||||||
$server->name = rawurlencode($server->name);
|
$name = rawurlencode($server->name);
|
||||||
$query = http_build_query([
|
$query = http_build_query([
|
||||||
'allowInsecure' => $server->allow_insecure,
|
'allowInsecure' => $server->allow_insecure,
|
||||||
'peer' => $server->server_name
|
'peer' => $server->server_name
|
||||||
]);
|
]);
|
||||||
$uri = "trojan://{$password}@{$server->host}:{$server->port}?{$query}&tfo=1#{$server->name}";
|
$uri = "trojan://{$password}@{$server->host}:{$server->port}?{$query}&tfo=1#{$name}";
|
||||||
$uri .= "\r\n";
|
$uri .= "\r\n";
|
||||||
return $uri;
|
return $uri;
|
||||||
}
|
}
|
||||||
|
@ -10,12 +10,13 @@ class URLSchemes
|
|||||||
{
|
{
|
||||||
public static function buildShadowsocks(ServerShadowsocks $server, User $user)
|
public static function buildShadowsocks(ServerShadowsocks $server, User $user)
|
||||||
{
|
{
|
||||||
|
$name = rawurlencode($server->name);
|
||||||
$str = str_replace(
|
$str = str_replace(
|
||||||
['+', '/', '='],
|
['+', '/', '='],
|
||||||
['-', '_', ''],
|
['-', '_', ''],
|
||||||
base64_encode("{$server->cipher}:{$user->uuid}")
|
base64_encode("{$server->cipher}:{$user->uuid}")
|
||||||
);
|
);
|
||||||
return "ss://{$str}@{$server->host}:{$server->port}#{$server->name}\r\n";
|
return "ss://{$str}@{$server->host}:{$server->port}#{$name}\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -44,12 +45,13 @@ class URLSchemes
|
|||||||
|
|
||||||
public static function buildTrojan(ServerTrojan $server, User $user)
|
public static function buildTrojan(ServerTrojan $server, User $user)
|
||||||
{
|
{
|
||||||
|
$name = rawurlencode($server->name);
|
||||||
$query = http_build_query([
|
$query = http_build_query([
|
||||||
'allowInsecure' => $server->allow_insecure,
|
'allowInsecure' => $server->allow_insecure,
|
||||||
'peer' => $server->server_name,
|
'peer' => $server->server_name,
|
||||||
'sni' => $server->server_name
|
'sni' => $server->server_name
|
||||||
]);
|
]);
|
||||||
$uri = "trojan://{$user->uuid}@{$server->host}:{$server->port}?{$query}#{$server->name}";
|
$uri = "trojan://{$user->uuid}@{$server->host}:{$server->port}?{$query}#{$name}";
|
||||||
$uri .= "\r\n";
|
$uri .= "\r\n";
|
||||||
return $uri;
|
return $uri;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user