mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-24 03:57:27 +08:00
feat: Refactor uTLS & Multiplex Support, Node Status Push Optimization
- Server/ServerSave/Server.php: Unified utls and multiplex schema, validation, and defaults for vmess/vless/trojan/mieru protocols, enabling more flexible protocol configuration. - Protocols (SingBox/ClashMeta/Shadowrocket/Stash/General): All protocol generators now support utls (client-fingerprint/fp) and multiplex options. Removed getRandFingerprint, replaced with getTlsFingerprint supporting random/custom fingerprints. - Helper.php: Refactored TLS fingerprint utility to support object/string/random input. - ServerService: Abstracted updateMetrics method to unify HTTP/WS node status caching logic. - NodeWebSocketServer: Improved node connection, status push, and full sync logic; adjusted log levels; clarified push logic. - ServerController: Reused ServerService for node metrics handling, reducing code duplication. - Docs: Improved aapanel installation docs, added fix for empty admin dashboard.
This commit is contained in:
+58
-14
@@ -227,7 +227,7 @@ class ClashMeta extends AbstractProtocol
|
||||
$array['plugin-opts'] = array_filter([
|
||||
'host' => $parsedOpts['host'] ?? null,
|
||||
'password' => $parsedOpts['password'] ?? null,
|
||||
'version' => isset($parsedOpts['version']) ? (int)$parsedOpts['version'] : 2
|
||||
'version' => isset($parsedOpts['version']) ? (int) $parsedOpts['version'] : 2
|
||||
], fn($v) => $v !== null);
|
||||
break;
|
||||
|
||||
@@ -266,14 +266,19 @@ class ClashMeta extends AbstractProtocol
|
||||
$array['servername'] = data_get($protocol_settings, 'tls_settings.server_name');
|
||||
}
|
||||
|
||||
self::appendUtls($array, $protocol_settings);
|
||||
self::appendMultiplex($array, $protocol_settings);
|
||||
|
||||
switch (data_get($protocol_settings, 'network')) {
|
||||
case 'tcp':
|
||||
$array['network'] = data_get($protocol_settings, 'network_settings.header.type', 'tcp');
|
||||
if (data_get($protocol_settings, 'network_settings.header.type', 'none') !== 'none') {
|
||||
if ($httpOpts = array_filter([
|
||||
'headers' => data_get($protocol_settings, 'network_settings.header.request.headers'),
|
||||
'path' => data_get($protocol_settings, 'network_settings.header.request.path', ['/'])
|
||||
])) {
|
||||
if (
|
||||
$httpOpts = array_filter([
|
||||
'headers' => data_get($protocol_settings, 'network_settings.header.request.headers'),
|
||||
'path' => data_get($protocol_settings, 'network_settings.header.request.path', ['/'])
|
||||
])
|
||||
) {
|
||||
$array['http-opts'] = $httpOpts;
|
||||
}
|
||||
}
|
||||
@@ -336,7 +341,7 @@ class ClashMeta extends AbstractProtocol
|
||||
if ($serverName = data_get($protocol_settings, 'tls_settings.server_name')) {
|
||||
$array['servername'] = $serverName;
|
||||
}
|
||||
$array['client-fingerprint'] = Helper::getRandFingerprint();
|
||||
self::appendUtls($array, $protocol_settings);
|
||||
break;
|
||||
case 2:
|
||||
$array['tls'] = true;
|
||||
@@ -346,7 +351,7 @@ class ClashMeta extends AbstractProtocol
|
||||
'public-key' => data_get($protocol_settings, 'reality_settings.public_key'),
|
||||
'short-id' => data_get($protocol_settings, 'reality_settings.short_id')
|
||||
];
|
||||
$array['client-fingerprint'] = Helper::getRandFingerprint();
|
||||
self::appendUtls($array, $protocol_settings);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -358,10 +363,12 @@ class ClashMeta extends AbstractProtocol
|
||||
$headerType = data_get($protocol_settings, 'network_settings.header.type', 'none');
|
||||
if ($headerType === 'http') {
|
||||
$array['network'] = 'http';
|
||||
if ($httpOpts = array_filter([
|
||||
'headers' => data_get($protocol_settings, 'network_settings.header.request.headers'),
|
||||
'path' => data_get($protocol_settings, 'network_settings.header.request.path', ['/'])
|
||||
])) {
|
||||
if (
|
||||
$httpOpts = array_filter([
|
||||
'headers' => data_get($protocol_settings, 'network_settings.header.request.headers'),
|
||||
'path' => data_get($protocol_settings, 'network_settings.header.request.path', ['/'])
|
||||
])
|
||||
) {
|
||||
$array['http-opts'] = $httpOpts;
|
||||
}
|
||||
}
|
||||
@@ -398,6 +405,8 @@ class ClashMeta extends AbstractProtocol
|
||||
break;
|
||||
}
|
||||
|
||||
self::appendMultiplex($array, $protocol_settings);
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
@@ -417,6 +426,9 @@ class ClashMeta extends AbstractProtocol
|
||||
$array['sni'] = $serverName;
|
||||
}
|
||||
|
||||
self::appendUtls($array, $protocol_settings);
|
||||
self::appendMultiplex($array, $protocol_settings);
|
||||
|
||||
switch (data_get($protocol_settings, 'network')) {
|
||||
case 'tcp':
|
||||
$array['network'] = 'tcp';
|
||||
@@ -565,8 +577,7 @@ class ClashMeta extends AbstractProtocol
|
||||
'port' => $server['port'],
|
||||
'username' => $password,
|
||||
'password' => $password,
|
||||
'transport' => strtoupper(data_get($protocol_settings, 'transport', 'TCP')),
|
||||
'multiplexing' => data_get($protocol_settings, 'multiplexing', 'MULTIPLEXING_LOW')
|
||||
'transport' => strtoupper(data_get($protocol_settings, 'transport', 'TCP'))
|
||||
];
|
||||
|
||||
// 如果配置了端口范围
|
||||
@@ -640,4 +651,37 @@ class ClashMeta extends AbstractProtocol
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static function appendMultiplex(&$array, $protocol_settings)
|
||||
{
|
||||
if ($multiplex = data_get($protocol_settings, 'multiplex')) {
|
||||
if (data_get($multiplex, 'enabled')) {
|
||||
$array['smux'] = array_filter([
|
||||
'enabled' => true,
|
||||
'protocol' => data_get($multiplex, 'protocol', 'yamux'),
|
||||
'max-connections' => data_get($multiplex, 'max_connections'),
|
||||
// 'min-streams' => data_get($multiplex, 'min_streams'),
|
||||
// 'max-streams' => data_get($multiplex, 'max_streams'),
|
||||
'padding' => data_get($multiplex, 'padding') ? true : null,
|
||||
]);
|
||||
|
||||
if (data_get($multiplex, 'brutal.enabled')) {
|
||||
$array['smux']['brutal'] = [
|
||||
'enabled' => true,
|
||||
'up' => data_get($multiplex, 'brutal.up_mbps'),
|
||||
'down' => data_get($multiplex, 'brutal.down_mbps'),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static function appendUtls(&$array, $protocol_settings)
|
||||
{
|
||||
if ($utls = data_get($protocol_settings, 'utls')) {
|
||||
if (data_get($utls, 'enabled')) {
|
||||
$array['client-fingerprint'] = Helper::getTlsFingerprint($utls);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user