feat: new xboard

This commit is contained in:
xboard
2025-01-21 14:57:54 +08:00
parent de18cfe596
commit 0f43fff242
373 changed files with 17923 additions and 20264 deletions
+30 -22
View File
@@ -2,10 +2,11 @@
namespace App\Protocols;
use App\Contracts\ProtocolInterface;
class QuantumultX
class QuantumultX implements ProtocolInterface
{
public $flag = 'quantumult%20x';
public $flags = ['quantumult%20x'];
private $servers;
private $user;
@@ -15,6 +16,11 @@ class QuantumultX
$this->servers = $servers;
}
public function getFlags(): array
{
return $this->flags;
}
public function handle()
{
$servers = $this->servers;
@@ -32,14 +38,16 @@ class QuantumultX
}
}
return response(base64_encode($uri), 200)
->header('subscription-userinfo', "upload={$user['u']}; download={$user['d']}; total={$user['transfer_enable']}; expire={$user['expired_at']}");
->header('subscription-userinfo', "upload={$user['u']}; download={$user['d']}; total={$user['transfer_enable']}; expire={$user['expired_at']}");
}
public static function buildShadowsocks($password, $server)
{
$protocol_settings = $server['protocol_settings'];
$password = data_get($server, 'password', $password);
$config = [
"shadowsocks={$server['host']}:{$server['port']}",
"method={$server['cipher']}",
"method={$protocol_settings['cipher']}",
"password={$password}",
'fast-open=true',
'udp-relay=true',
@@ -53,6 +61,7 @@ class QuantumultX
public static function buildVmess($uuid, $server)
{
$protocol_settings = $server['protocol_settings'];
$config = [
"vmess={$server['host']}:{$server['port']}",
'method=chacha20-poly1305',
@@ -62,28 +71,26 @@ class QuantumultX
"tag={$server['name']}"
];
if ($server['tls']) {
if ($server['network'] === 'tcp')
if (data_get($protocol_settings, 'tls')) {
if (data_get($protocol_settings, 'network') === 'tcp')
array_push($config, 'obfs=over-tls');
if ($server['tlsSettings']) {
$tlsSettings = $server['tlsSettings'];
if (isset($tlsSettings['allowInsecure']) && !empty($tlsSettings['allowInsecure']))
array_push($config, 'tls-verification=' . ($tlsSettings['allowInsecure'] ? 'false' : 'true'));
if (isset($tlsSettings['serverName']) && !empty($tlsSettings['serverName']))
$host = $tlsSettings['serverName'];
if (data_get($protocol_settings, 'tls_settings')) {
if (data_get($protocol_settings, 'tls_settings.allow_insecure'))
array_push($config, 'tls-verification=' . ($protocol_settings['tls_settings']['allow_insecure'] ? 'false' : 'true'));
if (data_get($protocol_settings, 'tls_settings.server_name'))
$host = data_get($protocol_settings, 'tls_settings.server_name');
}
}
if ($server['network'] === 'ws') {
if ($server['tls'])
if (data_get($protocol_settings, 'network') === 'ws') {
if (data_get($protocol_settings, 'tls'))
array_push($config, 'obfs=wss');
else
array_push($config, 'obfs=ws');
if ($server['networkSettings']) {
$wsSettings = $server['networkSettings'];
if (isset($wsSettings['path']) && !empty($wsSettings['path']))
array_push($config, "obfs-uri={$wsSettings['path']}");
if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host']) && !isset($host))
$host = $wsSettings['headers']['Host'];
if (data_get($protocol_settings, 'network_settings')) {
if (data_get($protocol_settings, 'network_settings.path'))
array_push($config, "obfs-uri={$protocol_settings['network_settings']['path']}");
if (data_get($protocol_settings, 'network_settings.headers.Host') && !isset($host))
$host = data_get($protocol_settings, 'network_settings.headers.Host');
}
}
if (isset($host)) {
@@ -97,13 +104,14 @@ class QuantumultX
public static function buildTrojan($password, $server)
{
$protocol_settings = $server['protocol_settings'];
$config = [
"trojan={$server['host']}:{$server['port']}",
"password={$password}",
'over-tls=true',
$server['server_name'] ? "tls-host={$server['server_name']}" : "",
$protocol_settings['server_name'] ? "tls-host={$protocol_settings['server_name']}" : "",
// Tips: allowInsecure=false = tls-verification=true
$server['allow_insecure'] ? 'tls-verification=false' : 'tls-verification=true',
$protocol_settings['allow_insecure'] ? 'tls-verification=false' : 'tls-verification=true',
'fast-open=true',
'udp-relay=true',
"tag={$server['name']}"