mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
subs: add Quantumult X & Surge Shadowsocks support
Signed-off-by: Beta Soft <betaxab@gmail.com>
This commit is contained in:
parent
87a9f6727b
commit
1acf64db44
@ -29,7 +29,7 @@ class ClientController extends Controller
|
||||
if (isset($_SERVER['HTTP_USER_AGENT'])) {
|
||||
$_SERVER['HTTP_USER_AGENT'] = strtolower($_SERVER['HTTP_USER_AGENT']);
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'quantumult%20x') !== false) {
|
||||
die($this->quantumultX($user, $servers['vmess'], $servers['trojan']));
|
||||
die($this->quantumultX($user, $servers['shadowsocks'], $servers['vmess'], $servers['trojan']));
|
||||
}
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'quantumult') !== false) {
|
||||
die($this->quantumult($user, $servers['vmess']));
|
||||
@ -41,7 +41,7 @@ class ClientController extends Controller
|
||||
die($this->surfboard($user, $servers['vmess']));
|
||||
}
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'surge') !== false) {
|
||||
die($this->surge($user, $servers['vmess'], $servers['trojan']));
|
||||
die($this->surge($user, $servers['shadowsocks'], $servers['vmess'], $servers['trojan']));
|
||||
}
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'shadowrocket') !== false) {
|
||||
die($this->shadowrocket($user, $servers['shadowsocks'], $servers['vmess'], $servers['trojan']));
|
||||
@ -92,10 +92,13 @@ class ClientController extends Controller
|
||||
return base64_encode($uri);
|
||||
}
|
||||
|
||||
private function quantumultX($user, $vmess = [], $trojan = [])
|
||||
private function quantumultX($user, $shadowsocks = [], $vmess = [], $trojan = [])
|
||||
{
|
||||
$uri = '';
|
||||
header("subscription-userinfo: upload={$user->u}; download={$user->d}; total={$user->transfer_enable}; expire={$user->expired_at}");
|
||||
foreach ($shadowsocks as $item) {
|
||||
$uri .= QuantumultX::buildShadowsocks($user->uuid, $item);
|
||||
}
|
||||
foreach ($vmess as $item) {
|
||||
$uri .= QuantumultX::buildVmess($user->uuid, $item);
|
||||
}
|
||||
@ -120,10 +123,18 @@ class ClientController extends Controller
|
||||
return base64_encode($uri);
|
||||
}
|
||||
|
||||
private function surge($user, $vmess = [], $trojan = [])
|
||||
private function surge($user, $shadowsocks = [], $vmess = [], $trojan = [])
|
||||
{
|
||||
$proxies = '';
|
||||
$proxyGroup = '';
|
||||
|
||||
foreach ($shadowsocks as $item) {
|
||||
// [Proxy]
|
||||
$proxies .= Surge::buildShadowsocks($user->uuid, $item);
|
||||
// [Proxy Group]
|
||||
$proxyGroup .= $item->name . ', ';
|
||||
}
|
||||
|
||||
foreach ($vmess as $item) {
|
||||
// [Proxy]
|
||||
$proxies .= Surge::buildVmess($user->uuid, $item);
|
||||
@ -221,7 +232,6 @@ class ClientController extends Controller
|
||||
array_push($proxies, $item->name);
|
||||
}
|
||||
|
||||
|
||||
foreach ($trojan as $item) {
|
||||
array_push($proxy, Clash::buildTrojan($user->uuid, $item));
|
||||
array_push($proxies, $item->name);
|
||||
|
@ -5,6 +5,22 @@ namespace App\Utils;
|
||||
|
||||
class QuantumultX
|
||||
{
|
||||
public static function buildShadowsocks($password, $server)
|
||||
{
|
||||
$config = [
|
||||
"shadowsocks={$server->host}:{$server->port}",
|
||||
"method={$server->cipher}",
|
||||
"password={$password}",
|
||||
"fast-open=true",
|
||||
"udp-relay=true",
|
||||
"tag={$server->name}"
|
||||
];
|
||||
$config = array_filter($config);
|
||||
$uri = implode(',', $config);
|
||||
$uri .= "\r\n";
|
||||
return $uri;
|
||||
}
|
||||
|
||||
public static function buildVmess($uuid, $server)
|
||||
{
|
||||
$config = [
|
||||
|
@ -5,6 +5,23 @@ namespace App\Utils;
|
||||
|
||||
class Surge
|
||||
{
|
||||
public static function buildShadowsocks($password, $server)
|
||||
{
|
||||
$config = [
|
||||
"{$server->name}=ss",
|
||||
"{$server->host}",
|
||||
"{$server->port}",
|
||||
"encrypt-method={$server->cipher}",
|
||||
"password={$password}",
|
||||
"tfo=true",
|
||||
"udp-relay=true"
|
||||
];
|
||||
$config = array_filter($config);
|
||||
$uri = implode(',', $config);
|
||||
$uri .= "\r\n";
|
||||
return $uri;
|
||||
}
|
||||
|
||||
public static function buildVmess($uuid, $server)
|
||||
{
|
||||
$proxies = $server->name . ' = vmess, ' . $server->host . ', ' . $server->port . ', username=' . $uuid . ', tfo=true';
|
||||
|
Loading…
Reference in New Issue
Block a user