mirror of
https://github.com/v2board/v2board.git
synced 2025-02-24 22:30:29 +08:00
update: server
This commit is contained in:
parent
b4212e7af4
commit
592b751e2c
@ -31,16 +31,16 @@ class AppController extends Controller
|
||||
|
||||
foreach ($servers as $item) {
|
||||
if ($item['type'] === 'shadowsocks') {
|
||||
array_push($proxy, Clash::buildShadowsocks($user->uuid, $item));
|
||||
array_push($proxies, $item->name);
|
||||
array_push($proxy, Clash::buildShadowsocks($user['uuid'], $item));
|
||||
array_push($proxies, $item['name']);
|
||||
}
|
||||
if ($item['type'] === 'v2ray') {
|
||||
array_push($proxy, Clash::buildVmess($user->uuid, $item));
|
||||
array_push($proxies, $item->name);
|
||||
array_push($proxy, Clash::buildVmess($user['uuid'], $item));
|
||||
array_push($proxies, $item['name']);
|
||||
}
|
||||
if ($item['type'] === 'trojan') {
|
||||
array_push($proxy, Clash::buildTrojan($user->uuid, $item));
|
||||
array_push($proxies, $item->name);
|
||||
array_push($proxy, Clash::buildTrojan($user['uuid'], $item));
|
||||
array_push($proxies, $item['name']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,13 +62,13 @@ class ClientController extends Controller
|
||||
foreach ($servers as $item) {
|
||||
if ($item['type'] === 'v2ray') {
|
||||
$str = '';
|
||||
$str .= $item->name . '= vmess, ' . $item->host . ', ' . $item->port . ', chacha20-ietf-poly1305, "' . $user->uuid . '", over-tls=' . ($item->tls ? "true" : "false") . ', certificate=0, group=' . config('v2board.app_name', 'V2Board');
|
||||
if ($item->network === 'ws') {
|
||||
$str .= $item['name'] . '= vmess, ' . $item['host'] . ', ' . $item['port'] . ', chacha20-ietf-poly1305, "' . $user['uuid'] . '", over-tls=' . ($item['tls'] ? "true" : "false") . ', certificate=0, group=' . config('v2board.app_name', 'V2Board');
|
||||
if ($item['network'] === 'ws') {
|
||||
$str .= ', obfs=ws';
|
||||
if ($item->networkSettings) {
|
||||
$wsSettings = json_decode($item->networkSettings);
|
||||
if (isset($wsSettings->path)) $str .= ', obfs-path="' . $wsSettings->path . '"';
|
||||
if (isset($wsSettings->headers->Host)) $str .= ', obfs-header="Host:' . $wsSettings->headers->Host . '"';
|
||||
if ($item['networkSettings']) {
|
||||
$wsSettings = json_decode($item['networkSettings']);
|
||||
if (isset($wsSettings['path'])) $str .= ', obfs-path="' . $wsSettings['path'] . '"';
|
||||
if (isset($wsSettings['headers']['Host'])) $str .= ', obfs-header="Host:' . $wsSettings['headers']['Host'] . '"';
|
||||
}
|
||||
}
|
||||
$uri .= "vmess://" . base64_encode($str) . "\r\n";
|
||||
@ -88,13 +88,13 @@ class ClientController extends Controller
|
||||
$uri .= "STATUS=🚀↑:{$upload}GB,↓:{$download}GB,TOT:{$totalTraffic}GB💡Expires:{$expiredDate}\r\n";
|
||||
foreach ($servers as $item) {
|
||||
if ($item['type'] === 'shadowsocks') {
|
||||
$uri .= Shadowrocket::buildShadowsocks($user->uuid, $item);
|
||||
$uri .= Shadowrocket::buildShadowsocks($user['uuid'], $item);
|
||||
}
|
||||
if ($item['type'] === 'v2ray') {
|
||||
$uri .= Shadowrocket::buildVmess($user->uuid, $item);
|
||||
$uri .= Shadowrocket::buildVmess($user['uuid'], $item);
|
||||
}
|
||||
if ($item['type'] === 'trojan') {
|
||||
$uri .= Shadowrocket::buildTrojan($user->uuid, $item);
|
||||
$uri .= Shadowrocket::buildTrojan($user['uuid'], $item);
|
||||
}
|
||||
}
|
||||
return base64_encode($uri);
|
||||
@ -106,13 +106,13 @@ class ClientController extends Controller
|
||||
header("subscription-userinfo: upload={$user->u}; download={$user->d}; total={$user->transfer_enable}; expire={$user->expired_at}");
|
||||
foreach ($servers as $item) {
|
||||
if ($item['type'] === 'shadowsocks') {
|
||||
$uri .= QuantumultX::buildShadowsocks($user->uuid, $item);
|
||||
$uri .= QuantumultX::buildShadowsocks($user['uuid'], $item);
|
||||
}
|
||||
if ($item['type'] === 'v2ray') {
|
||||
$uri .= QuantumultX::buildVmess($user->uuid, $item);
|
||||
$uri .= QuantumultX::buildVmess($user['uuid'], $item);
|
||||
}
|
||||
if ($item['type'] === 'trojan') {
|
||||
$uri .= QuantumultX::buildTrojan($user->uuid, $item);
|
||||
$uri .= QuantumultX::buildTrojan($user['uuid'], $item);
|
||||
}
|
||||
}
|
||||
return base64_encode($uri);
|
||||
@ -143,21 +143,21 @@ class ClientController extends Controller
|
||||
foreach ($servers as $item) {
|
||||
if ($item['type'] === 'shadowsocks') {
|
||||
// [Proxy]
|
||||
$proxies .= Surge::buildShadowsocks($user->uuid, $item);
|
||||
$proxies .= Surge::buildShadowsocks($user['uuid'], $item);
|
||||
// [Proxy Group]
|
||||
$proxyGroup .= $item->name . ', ';
|
||||
$proxyGroup .= $item['name'] . ', ';
|
||||
}
|
||||
if ($item['type'] === 'v2ray') {
|
||||
// [Proxy]
|
||||
$proxies .= Surge::buildVmess($user->uuid, $item);
|
||||
$proxies .= Surge::buildVmess($user['uuid'], $item);
|
||||
// [Proxy Group]
|
||||
$proxyGroup .= $item->name . ', ';
|
||||
$proxyGroup .= $item['name'] . ', ';
|
||||
}
|
||||
if ($item['type'] === 'trojan') {
|
||||
// [Proxy]
|
||||
$proxies .= Surge::buildTrojan($user->uuid, $item);
|
||||
$proxies .= Surge::buildTrojan($user['uuid'], $item);
|
||||
// [Proxy Group]
|
||||
$proxyGroup .= $item->name . ', ';
|
||||
$proxyGroup .= $item['name'] . ', ';
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,15 +186,15 @@ class ClientController extends Controller
|
||||
foreach ($servers as $item) {
|
||||
if ($item['type'] === 'shadowsocks') {
|
||||
// [Proxy]
|
||||
$proxies .= Surfboard::buildShadowsocks($user->uuid, $item);
|
||||
$proxies .= Surfboard::buildShadowsocks($user['uuid'], $item);
|
||||
// [Proxy Group]
|
||||
$proxyGroup .= $item->name . ', ';
|
||||
$proxyGroup .= $item['name'] . ', ';
|
||||
}
|
||||
if ($item['type'] === 'v2ray') {
|
||||
// [Proxy]
|
||||
$proxies .= Surfboard::buildVmess($user->uuid, $item);
|
||||
$proxies .= Surfboard::buildVmess($user['uuid'], $item);
|
||||
// [Proxy Group]
|
||||
$proxyGroup .= $item->name . ', ';
|
||||
$proxyGroup .= $item['name'] . ', ';
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,16 +229,16 @@ class ClientController extends Controller
|
||||
|
||||
foreach ($servers as $item) {
|
||||
if ($item['type'] === 'shadowsocks') {
|
||||
array_push($proxy, Clash::buildShadowsocks($user->uuid, $item));
|
||||
array_push($proxies, $item->name);
|
||||
array_push($proxy, Clash::buildShadowsocks($user['uuid'], $item));
|
||||
array_push($proxies, $item['name']);
|
||||
}
|
||||
if ($item['type'] === 'v2ray') {
|
||||
array_push($proxy, Clash::buildVmess($user->uuid, $item));
|
||||
array_push($proxies, $item->name);
|
||||
array_push($proxy, Clash::buildVmess($user['uuid'], $item));
|
||||
array_push($proxies, $item['name']);
|
||||
}
|
||||
if ($item['type'] === 'trojan') {
|
||||
array_push($proxy, Clash::buildTrojan($user->uuid, $item));
|
||||
array_push($proxies, $item->name);
|
||||
array_push($proxy, Clash::buildTrojan($user['uuid'], $item));
|
||||
array_push($proxies, $item['name']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,11 +8,11 @@ class Clash
|
||||
public static function buildShadowsocks($uuid, $server)
|
||||
{
|
||||
$array = [];
|
||||
$array['name'] = $server->name;
|
||||
$array['name'] = $server['name'];
|
||||
$array['type'] = 'ss';
|
||||
$array['server'] = $server->host;
|
||||
$array['port'] = $server->port;
|
||||
$array['cipher'] = $server->cipher;
|
||||
$array['server'] = $server['host'];
|
||||
$array['port'] = $server['port'];
|
||||
$array['cipher'] = $server['cipher'];
|
||||
$array['password'] = $uuid;
|
||||
$array['udp'] = true;
|
||||
return $array;
|
||||
@ -21,27 +21,27 @@ class Clash
|
||||
public static function buildVmess($uuid, $server)
|
||||
{
|
||||
$array = [];
|
||||
$array['name'] = $server->name;
|
||||
$array['name'] = $server['name'];
|
||||
$array['type'] = 'vmess';
|
||||
$array['server'] = $server->host;
|
||||
$array['port'] = $server->port;
|
||||
$array['server'] = $server['host'];
|
||||
$array['port'] = $server['port'];
|
||||
$array['uuid'] = $uuid;
|
||||
$array['alterId'] = 2;
|
||||
$array['cipher'] = 'auto';
|
||||
$array['udp'] = true;
|
||||
if ($server->tls) {
|
||||
$tlsSettings = json_decode($server->tlsSettings);
|
||||
if ($server['tls']) {
|
||||
$tlsSettings = json_decode($server['tlsSettings'], true);
|
||||
$array['tls'] = true;
|
||||
if (!empty($tlsSettings->allowInsecure)) $array['skip-cert-verify'] = ($tlsSettings->allowInsecure ? true : false );
|
||||
if (!empty($tlsSettings->serverName)) $array['servername'] = $tlsSettings->serverName;
|
||||
if (!empty($tlsSettings['allowInsecure'])) $array['skip-cert-verify'] = ($tlsSettings['allowInsecure'] ? true : false );
|
||||
if (!empty($tlsSettings['serverName'])) $array['servername'] = $tlsSettings['serverName'];
|
||||
}
|
||||
if ($server->network == 'ws') {
|
||||
$array['network'] = $server->network;
|
||||
if ($server->networkSettings) {
|
||||
$wsSettings = json_decode($server->networkSettings);
|
||||
if (isset($wsSettings->path)) $array['ws-path'] = $wsSettings->path;
|
||||
if (isset($wsSettings->headers->Host)) $array['ws-headers'] = [
|
||||
'Host' => $wsSettings->headers->Host
|
||||
if ($server['network'] == 'ws') {
|
||||
$array['network'] = $server['network'];
|
||||
if ($server['networkSettings']) {
|
||||
$wsSettings = json_decode($server['networkSettings'], true);
|
||||
if (isset($wsSettings['path'])) $array['ws-path'] = $wsSettings['path'];
|
||||
if (isset($wsSettings['headers']['Host'])) $array['ws-headers'] = [
|
||||
'Host' => $wsSettings['headers']['Host']
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -51,14 +51,14 @@ class Clash
|
||||
public static function buildTrojan($password, $server)
|
||||
{
|
||||
$array = [];
|
||||
$array['name'] = $server->name;
|
||||
$array['name'] = $server['name'];
|
||||
$array['type'] = 'trojan';
|
||||
$array['server'] = $server->host;
|
||||
$array['port'] = $server->port;
|
||||
$array['server'] = $server['host'];
|
||||
$array['port'] = $server['port'];
|
||||
$array['password'] = $password;
|
||||
$array['udp'] = true;
|
||||
if (!empty($server->server_name)) $array['sni'] = $server->server_name;
|
||||
if (!empty($server->allow_insecure)) $array['skip-cert-verify'] = ($server->allow_insecure ? true : false );
|
||||
if (!empty($server['server_name'])) $array['sni'] = $server['server_name'];
|
||||
if (!empty($server['allow_insecure'])) $array['skip-cert-verify'] = ($server['allow_insecure'] ? true : false );
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
|
@ -8,12 +8,12 @@ class QuantumultX
|
||||
public static function buildShadowsocks($password, $server)
|
||||
{
|
||||
$config = [
|
||||
"shadowsocks={$server->host}:{$server->port}",
|
||||
"method={$server->cipher}",
|
||||
"shadowsocks={$server['host']}:{$server['port']}",
|
||||
"method={$server['cipher']}",
|
||||
"password={$password}",
|
||||
'fast-open=true',
|
||||
'udp-relay=true',
|
||||
"tag={$server->name}"
|
||||
"tag={$server['name']}"
|
||||
];
|
||||
$config = array_filter($config);
|
||||
$uri = implode(',', $config);
|
||||
@ -24,41 +24,41 @@ class QuantumultX
|
||||
public static function buildVmess($uuid, $server)
|
||||
{
|
||||
$config = [
|
||||
"vmess={$server->host}:{$server->port}",
|
||||
"vmess={$server['host']}:{$server['port']}",
|
||||
'method=chacha20-poly1305',
|
||||
"password={$uuid}",
|
||||
'fast-open=true',
|
||||
'udp-relay=true',
|
||||
"tag={$server->name}"
|
||||
"tag={$server['name']}"
|
||||
];
|
||||
if ($server->network === 'tcp') {
|
||||
if ($server->tls) {
|
||||
$tlsSettings = json_decode($server->tlsSettings);
|
||||
if ($server['network'] === 'tcp') {
|
||||
if ($server['tls']) {
|
||||
$tlsSettings = json_decode($server['tlsSettings'], true);
|
||||
array_push($config, 'obfs=over-tls');
|
||||
if (isset($tlsSettings->allowInsecure)) {
|
||||
if (isset($tlsSettings['allowInsecure'])) {
|
||||
// Tips: allowInsecure=false = tls-verification=true
|
||||
array_push($config, $tlsSettings->allowInsecure ? 'tls-verification=false' : 'tls-verification=true');
|
||||
array_push($config, $tlsSettings['allowInsecure'] ? 'tls-verification=false' : 'tls-verification=true');
|
||||
}
|
||||
if (!empty($tlsSettings->serverName)) {
|
||||
array_push($config, "obfs-host={$tlsSettings->serverName}");
|
||||
if (!empty($tlsSettings['serverName'])) {
|
||||
array_push($config, "obfs-host={$tlsSettings['serverName']}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($server->network === 'ws') {
|
||||
if ($server->tls) {
|
||||
$tlsSettings = json_decode($server->tlsSettings);
|
||||
if ($server['network'] === 'ws') {
|
||||
if ($server['tls']) {
|
||||
$tlsSettings = json_decode($server['tlsSettings'], true);
|
||||
array_push($config, 'obfs=wss');
|
||||
if (isset($tlsSettings->allowInsecure)) {
|
||||
array_push($config, $tlsSettings->allowInsecure ? 'tls-verification=false' : 'tls-verification=true');
|
||||
if (isset($tlsSettings['allowInsecure'])) {
|
||||
array_push($config, $tlsSettings['allowInsecure'] ? 'tls-verification=false' : 'tls-verification=true');
|
||||
}
|
||||
} else {
|
||||
array_push($config, 'obfs=ws');
|
||||
}
|
||||
if ($server->networkSettings) {
|
||||
$wsSettings = json_decode($server->networkSettings);
|
||||
if (isset($wsSettings->path)) array_push($config, "obfs-uri={$wsSettings->path}");
|
||||
if (isset($wsSettings->headers->Host)) array_push($config, "obfs-host={$wsSettings->headers->Host}");
|
||||
if ($server['networkSettings']) {
|
||||
$wsSettings = json_decode($server['networkSettings'], true);
|
||||
if (isset($wsSettings['path'])) array_push($config, "obfs-uri={$wsSettings['path']}");
|
||||
if (isset($wsSettings['headers']['Host'])) array_push($config, "obfs-host={$wsSettings['headers']['Host']}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,15 +70,15 @@ class QuantumultX
|
||||
public static function buildTrojan($password, $server)
|
||||
{
|
||||
$config = [
|
||||
"trojan={$server->host}:{$server->port}",
|
||||
"trojan={$server['host']}:{$server['port']}",
|
||||
"password={$password}",
|
||||
'over-tls=true',
|
||||
$server->server_name ? "tls-host={$server->server_name}" : "",
|
||||
$server['server_name'] ? "tls-host={$server['server_name']}" : "",
|
||||
// Tips: allowInsecure=false = tls-verification=true
|
||||
$server->allow_insecure ? 'tls-verification=false' : 'tls-verification=true',
|
||||
$server['allow_insecure'] ? 'tls-verification=false' : 'tls-verification=true',
|
||||
'fast-open=true',
|
||||
'udp-relay=true',
|
||||
"tag={$server->name}"
|
||||
"tag={$server['name']}"
|
||||
];
|
||||
$config = array_filter($config);
|
||||
$uri = implode(',', $config);
|
||||
|
@ -7,32 +7,32 @@ class Shadowrocket
|
||||
{
|
||||
public static function buildShadowsocks($password, $server)
|
||||
{
|
||||
$name = rawurlencode($server->name);
|
||||
$name = rawurlencode($server['name']);
|
||||
$str = str_replace(
|
||||
['+', '/', '='],
|
||||
['-', '_', ''],
|
||||
base64_encode("{$server->cipher}:{$password}")
|
||||
base64_encode("{$server['cipher']}:{$password}")
|
||||
);
|
||||
return "ss://{$str}@{$server->host}:{$server->port}#{$name}\r\n";
|
||||
return "ss://{$str}@{$server['host']}:{$server['port']}#{$name}\r\n";
|
||||
}
|
||||
|
||||
public static function buildVmess($uuid, $server)
|
||||
{
|
||||
$userinfo = base64_encode('auto:' . $uuid . '@' . $server->host . ':' . $server->port);
|
||||
$userinfo = base64_encode('auto:' . $uuid . '@' . $server['host'] . ':' . $server['port']);
|
||||
$config = [
|
||||
'remark' => $server->name
|
||||
'remark' => $server['name']
|
||||
];
|
||||
if ($server->tls) {
|
||||
$tlsSettings = json_decode($server->tlsSettings);
|
||||
if ($server['tls']) {
|
||||
$tlsSettings = json_decode($server['tlsSettings'], true);
|
||||
$config['tls'] = 1;
|
||||
if (isset($tlsSettings->serverName)) $config['peer'] = $tlsSettings->serverName;
|
||||
if (isset($tlsSettings->allowInsecure)) $config['allowInsecure'] = 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);
|
||||
if ($server['network'] === 'ws') {
|
||||
$wsSettings = json_decode($server['networkSettings'], true);
|
||||
$config['obfs'] = "websocket";
|
||||
if (isset($wsSettings->path)) $config['path'] = $wsSettings->path;
|
||||
if (isset($wsSettings->headers->Host)) $config['obfsParam'] = $wsSettings->headers->Host;
|
||||
if (isset($wsSettings['path'])) $config['path'] = $wsSettings['path'];
|
||||
if (isset($wsSettings['headers']['Host'])) $config['obfsParam'] = $wsSettings['headers']['Host'];
|
||||
}
|
||||
$query = http_build_query($config, null, '&', PHP_QUERY_RFC3986);
|
||||
$uri = "vmess://{$userinfo}?{$query}&tfo=1";
|
||||
@ -42,12 +42,12 @@ class Shadowrocket
|
||||
|
||||
public static function buildTrojan($password, $server)
|
||||
{
|
||||
$name = rawurlencode($server->name);
|
||||
$name = rawurlencode($server['name']);
|
||||
$query = http_build_query([
|
||||
'allowInsecure' => $server->allow_insecure,
|
||||
'peer' => $server->server_name
|
||||
'allowInsecure' => $server['allow_insecure'],
|
||||
'peer' => $server['server_name']
|
||||
]);
|
||||
$uri = "trojan://{$password}@{$server->host}:{$server->port}?{$query}&tfo=1#{$name}";
|
||||
$uri = "trojan://{$password}@{$server['host']}:{$server['port']}?{$query}&tfo=1#{$name}";
|
||||
$uri .= "\r\n";
|
||||
return $uri;
|
||||
}
|
||||
|
@ -8,10 +8,10 @@ class Surfboard
|
||||
public static function buildShadowsocks($password, $server)
|
||||
{
|
||||
$config = [
|
||||
"{$server->name}=custom",
|
||||
"{$server->host}",
|
||||
"{$server->port}",
|
||||
"{$server->cipher}",
|
||||
"{$server['name']}=custom",
|
||||
"{$server['host']}",
|
||||
"{$server['port']}",
|
||||
"{$server['cipher']}",
|
||||
"{$password}",
|
||||
'https://raw.githubusercontent.com/Hackl0us/proxy-tool-backup/master/SSEncrypt.module',
|
||||
'tfo=true',
|
||||
@ -26,36 +26,36 @@ class Surfboard
|
||||
public static function buildVmess($uuid, $server)
|
||||
{
|
||||
$config = [
|
||||
"{$server->name}=vmess",
|
||||
"{$server->host}",
|
||||
"{$server->port}",
|
||||
"{$server['name']}=vmess",
|
||||
"{$server['host']}",
|
||||
"{$server['port']}",
|
||||
"username={$uuid}",
|
||||
'tfo=true',
|
||||
'udp-relay=true'
|
||||
];
|
||||
if ($server->network === 'tcp') {
|
||||
if ($server->tls) {
|
||||
$tlsSettings = json_decode($server->tlsSettings);
|
||||
array_push($config, $server->tls ? 'tls=true' : 'tls=false');
|
||||
if (!empty($tlsSettings->allowInsecure)) {
|
||||
array_push($config, $tlsSettings->allowInsecure ? 'skip-cert-verify=true' : 'skip-cert-verify=false');
|
||||
if ($server['network'] === 'tcp') {
|
||||
if ($server['tls']) {
|
||||
$tlsSettings = json_decode($server['tlsSettings'], true);
|
||||
array_push($config, $server['tls'] ? 'tls=true' : 'tls=false');
|
||||
if (!empty($tlsSettings['allowInsecure'])) {
|
||||
array_push($config, $tlsSettings['allowInsecure'] ? 'skip-cert-verify=true' : 'skip-cert-verify=false');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($server->network === 'ws') {
|
||||
if ($server['network'] === 'ws') {
|
||||
array_push($config, 'ws=true');
|
||||
if ($server->tls) {
|
||||
$tlsSettings = json_decode($server->tlsSettings);
|
||||
array_push($config, $server->tls ? 'tls=true' : 'tls=false');
|
||||
if (!empty($tlsSettings->allowInsecure)) {
|
||||
array_push($config, $tlsSettings->allowInsecure ? 'skip-cert-verify=true' : 'skip-cert-verify=false');
|
||||
if ($server['tls']) {
|
||||
$tlsSettings = json_decode($server['tlsSettings'], true);
|
||||
array_push($config, $server['tls'] ? 'tls=true' : 'tls=false');
|
||||
if (!empty($tlsSettings['allowInsecure'])) {
|
||||
array_push($config, $tlsSettings['allowInsecure'] ? 'skip-cert-verify=true' : 'skip-cert-verify=false');
|
||||
}
|
||||
}
|
||||
if ($server->networkSettings) {
|
||||
$wsSettings = json_decode($server->networkSettings);
|
||||
if (isset($wsSettings->path)) array_push($config, "ws-path={$wsSettings->path}");
|
||||
if (isset($wsSettings->headers->Host)) array_push($config, "ws-headers=host:{$wsSettings->headers->Host}");
|
||||
if ($server['networkSettings']) {
|
||||
$wsSettings = json_decode($server['networkSettings'], true);
|
||||
if (isset($wsSettings['path'])) array_push($config, "ws-path={$wsSettings['path']}");
|
||||
if (isset($wsSettings['headers']['Host'])) array_push($config, "ws-headers=host:{$wsSettings['headers']['Host']}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,10 +8,10 @@ class Surge
|
||||
public static function buildShadowsocks($password, $server)
|
||||
{
|
||||
$config = [
|
||||
"{$server->name}=ss",
|
||||
"{$server->host}",
|
||||
"{$server->port}",
|
||||
"encrypt-method={$server->cipher}",
|
||||
"{$server['name']}=ss",
|
||||
"{$server['host']}",
|
||||
"{$server['port']}",
|
||||
"encrypt-method={$server['cipher']}",
|
||||
"password={$password}",
|
||||
'tfo=true',
|
||||
'udp-relay=true'
|
||||
@ -25,39 +25,39 @@ class Surge
|
||||
public static function buildVmess($uuid, $server)
|
||||
{
|
||||
$config = [
|
||||
"{$server->name}=vmess",
|
||||
"{$server->host}",
|
||||
"{$server->port}",
|
||||
"{$server['name']}=vmess",
|
||||
"{$server['host']}",
|
||||
"{$server['port']}",
|
||||
"username={$uuid}",
|
||||
'tfo=true',
|
||||
'udp-relay=true'
|
||||
];
|
||||
if ($server->network === 'tcp') {
|
||||
if ($server->tls) {
|
||||
$tlsSettings = json_decode($server->tlsSettings);
|
||||
array_push($config, $server->tls ? 'tls=true' : 'tls=false');
|
||||
if (!empty($tlsSettings->allowInsecure)) {
|
||||
array_push($config, $tlsSettings->allowInsecure ? 'skip-cert-verify=true' : 'skip-cert-verify=false');
|
||||
if ($server['network'] === 'tcp') {
|
||||
if ($server['tls']) {
|
||||
$tlsSettings = json_decode($server['tlsSettings'], true);
|
||||
array_push($config, $server['tls'] ? 'tls=true' : 'tls=false');
|
||||
if (!empty($tlsSettings['allowInsecure'])) {
|
||||
array_push($config, $tlsSettings['allowInsecure'] ? 'skip-cert-verify=true' : 'skip-cert-verify=false');
|
||||
}
|
||||
if (!empty($tlsSettings->serverName)) {
|
||||
array_push($config, "sni={$tlsSettings->serverName}");
|
||||
if (!empty($tlsSettings['serverName'])) {
|
||||
array_push($config, "sni={$tlsSettings['serverName']}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($server->network === 'ws') {
|
||||
if ($server['network'] === 'ws') {
|
||||
array_push($config, 'ws=true');
|
||||
if ($server->tls) {
|
||||
$tlsSettings = json_decode($server->tlsSettings);
|
||||
array_push($config, $server->tls ? 'tls=true' : 'tls=false');
|
||||
if (!empty($tlsSettings->allowInsecure)) {
|
||||
array_push($config, $tlsSettings->allowInsecure ? 'skip-cert-verify=true' : 'skip-cert-verify=false');
|
||||
if ($server['tls']) {
|
||||
$tlsSettings = json_decode($server['tlsSettings'], true);
|
||||
array_push($config, $server['tls'] ? 'tls=true' : 'tls=false');
|
||||
if (!empty($tlsSettings['allowInsecure'])) {
|
||||
array_push($config, $tlsSettings['allowInsecure'] ? 'skip-cert-verify=true' : 'skip-cert-verify=false');
|
||||
}
|
||||
}
|
||||
if ($server->networkSettings) {
|
||||
$wsSettings = json_decode($server->networkSettings);
|
||||
if (isset($wsSettings->path)) array_push($config, "ws-path={$wsSettings->path}");
|
||||
if (isset($wsSettings->headers->Host)) array_push($config, "ws-headers=host:{$wsSettings->headers->Host}");
|
||||
if ($server['networkSettings']) {
|
||||
$wsSettings = json_decode($server['networkSettings'], true);
|
||||
if (isset($wsSettings['path'])) array_push($config, "ws-path={$wsSettings['path']}");
|
||||
if (isset($wsSettings['headers']['Host'])) array_push($config, "ws-headers=host:{$wsSettings['headers']['Host']}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,16 +69,16 @@ class Surge
|
||||
public static function buildTrojan($password, $server)
|
||||
{
|
||||
$config = [
|
||||
"{$server->name}=trojan",
|
||||
"{$server->host}",
|
||||
"{$server->port}",
|
||||
"{$server['name']}=trojan",
|
||||
"{$server['host']}",
|
||||
"{$server['port']}",
|
||||
"password={$password}",
|
||||
$server->server_name ? "sni={$server->server_name}" : "",
|
||||
$server['server_name'] ? "sni={$server['server_name']}" : "",
|
||||
'tfo=true',
|
||||
'udp-relay=true'
|
||||
];
|
||||
if (!empty($server->allow_insecure)) {
|
||||
array_push($config, $server->allow_insecure ? 'skip-cert-verify=true' : 'skip-cert-verify=false');
|
||||
if (!empty($server['allow_insecure'])) {
|
||||
array_push($config, $server['allow_insecure'] ? 'skip-cert-verify=true' : 'skip-cert-verify=false');
|
||||
}
|
||||
$config = array_filter($config);
|
||||
$uri = implode(',', $config);
|
||||
|
@ -2,56 +2,54 @@
|
||||
namespace App\Utils;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\ServerShadowsocks;
|
||||
use App\Models\ServerTrojan;
|
||||
use App\Models\User;
|
||||
|
||||
class URLSchemes
|
||||
{
|
||||
public static function buildShadowsocks(ServerShadowsocks $server, User $user)
|
||||
public static function buildShadowsocks($server, User $user)
|
||||
{
|
||||
$name = rawurlencode($server->name);
|
||||
$name = rawurlencode($server['name']);
|
||||
$str = str_replace(
|
||||
['+', '/', '='],
|
||||
['-', '_', ''],
|
||||
base64_encode("{$server->cipher}:{$user->uuid}")
|
||||
base64_encode("{$server['cipher']}:{$user['uuid']}")
|
||||
);
|
||||
return "ss://{$str}@{$server->host}:{$server->port}#{$name}\r\n";
|
||||
return "ss://{$str}@{$server['host']}:{$server['port']}#{$name}\r\n";
|
||||
}
|
||||
|
||||
|
||||
public static function buildVmess(Server $server, User $user)
|
||||
public static function buildVmess($server, User $user)
|
||||
{
|
||||
$config = [
|
||||
"v" => "2",
|
||||
"ps" => $server->name,
|
||||
"add" => $server->host,
|
||||
"port" => $server->port,
|
||||
"id" => $user->uuid,
|
||||
"ps" => $server['name'],
|
||||
"add" => $server['host'],
|
||||
"port" => $server['port'],
|
||||
"id" => $user['uuid'],
|
||||
"aid" => "2",
|
||||
"net" => $server->network,
|
||||
"net" => $server['network'],
|
||||
"type" => "none",
|
||||
"host" => "",
|
||||
"path" => "",
|
||||
"tls" => $server->tls ? "tls" : ""
|
||||
"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;
|
||||
if ((string)$server['network'] === 'ws') {
|
||||
$wsSettings = json_decode($server['networkSettings'], true);
|
||||
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 buildTrojan(ServerTrojan $server, User $user)
|
||||
public static function buildTrojan($server, User $user)
|
||||
{
|
||||
$name = rawurlencode($server->name);
|
||||
$name = rawurlencode($server['name']);
|
||||
$query = http_build_query([
|
||||
'allowInsecure' => $server->allow_insecure,
|
||||
'peer' => $server->server_name,
|
||||
'sni' => $server->server_name
|
||||
'allowInsecure' => $server['allow_insecure'],
|
||||
'peer' => $server['server_name'],
|
||||
'sni' => $server['server_name']
|
||||
]);
|
||||
$uri = "trojan://{$user->uuid}@{$server->host}:{$server->port}?{$query}#{$name}";
|
||||
$uri = "trojan://{$user['uuid']}@{$server['host']}:{$server['port']}?{$query}#{$name}";
|
||||
$uri .= "\r\n";
|
||||
return $uri;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user