mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-29 23:47:27 +08:00
fix: resolve vmess http-opts headers null issue in subscription generation
This commit is contained in:
@@ -203,10 +203,12 @@ class Clash extends AbstractProtocol
|
|||||||
case 'tcp':
|
case 'tcp':
|
||||||
$array['network'] = data_get($protocol_settings, 'network_settings.header.type');
|
$array['network'] = data_get($protocol_settings, 'network_settings.header.type');
|
||||||
if (data_get($protocol_settings, 'network_settings.header.type', 'none') !== 'none') {
|
if (data_get($protocol_settings, 'network_settings.header.type', 'none') !== 'none') {
|
||||||
$array['http-opts'] = [
|
if ($httpOpts = array_filter([
|
||||||
'headers' => data_get($protocol_settings, 'network_settings.header.request.headers'),
|
'headers' => data_get($protocol_settings, 'network_settings.header.request.headers'),
|
||||||
'path' => data_get($protocol_settings, 'network_settings.header.request.path', ['/'])
|
'path' => data_get($protocol_settings, 'network_settings.header.request.path', ['/'])
|
||||||
];
|
])) {
|
||||||
|
$array['http-opts'] = $httpOpts;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'ws':
|
case 'ws':
|
||||||
|
|||||||
@@ -261,10 +261,12 @@ class ClashMeta extends AbstractProtocol
|
|||||||
case 'tcp':
|
case 'tcp':
|
||||||
$array['network'] = data_get($protocol_settings, 'network_settings.header.type', 'tcp');
|
$array['network'] = data_get($protocol_settings, 'network_settings.header.type', 'tcp');
|
||||||
if (data_get($protocol_settings, 'network_settings.header.type', 'none') !== 'none') {
|
if (data_get($protocol_settings, 'network_settings.header.type', 'none') !== 'none') {
|
||||||
$array['http-opts'] = [
|
if ($httpOpts = array_filter([
|
||||||
'headers' => data_get($protocol_settings, 'network_settings.header.request.headers'),
|
'headers' => data_get($protocol_settings, 'network_settings.header.request.headers'),
|
||||||
'path' => data_get($protocol_settings, 'network_settings.header.request.path', ['/'])
|
'path' => data_get($protocol_settings, 'network_settings.header.request.path', ['/'])
|
||||||
];
|
])) {
|
||||||
|
$array['http-opts'] = $httpOpts;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'ws':
|
case 'ws':
|
||||||
|
|||||||
@@ -209,13 +209,13 @@ class SingBox extends AbstractProtocol
|
|||||||
'path' => Arr::random(data_get($protocol_settings, 'network_settings.header.request.path', ['/'])),
|
'path' => Arr::random(data_get($protocol_settings, 'network_settings.header.request.path', ['/'])),
|
||||||
'host' => data_get($protocol_settings, 'network_settings.header.request.headers.Host', [])
|
'host' => data_get($protocol_settings, 'network_settings.header.request.headers.Host', [])
|
||||||
] : null,
|
] : null,
|
||||||
'ws' => [
|
'ws' => array_filter([
|
||||||
'type' => 'ws',
|
'type' => 'ws',
|
||||||
'path' => data_get($protocol_settings, 'network_settings.path'),
|
'path' => data_get($protocol_settings, 'network_settings.path'),
|
||||||
'headers' => ($host = data_get($protocol_settings, 'network_settings.headers.Host')) ? ['Host' => $host] : null,
|
'headers' => ($host = data_get($protocol_settings, 'network_settings.headers.Host')) ? ['Host' => $host] : null,
|
||||||
'max_early_data' => 2048,
|
'max_early_data' => 2048,
|
||||||
'early_data_header_name' => 'Sec-WebSocket-Protocol'
|
'early_data_header_name' => 'Sec-WebSocket-Protocol'
|
||||||
],
|
]),
|
||||||
'grpc' => [
|
'grpc' => [
|
||||||
'type' => 'grpc',
|
'type' => 'grpc',
|
||||||
'service_name' => data_get($protocol_settings, 'network_settings.serviceName')
|
'service_name' => data_get($protocol_settings, 'network_settings.serviceName')
|
||||||
@@ -330,13 +330,13 @@ class SingBox extends AbstractProtocol
|
|||||||
'type' => 'grpc',
|
'type' => 'grpc',
|
||||||
'service_name' => data_get($protocol_settings, 'network_settings.serviceName')
|
'service_name' => data_get($protocol_settings, 'network_settings.serviceName')
|
||||||
],
|
],
|
||||||
'ws' => [
|
'ws' => array_filter([
|
||||||
'type' => 'ws',
|
'type' => 'ws',
|
||||||
'path' => data_get($protocol_settings, 'network_settings.path'),
|
'path' => data_get($protocol_settings, 'network_settings.path'),
|
||||||
'headers' => data_get($protocol_settings, 'network_settings.headers.Host') ? ['Host' => [data_get($protocol_settings, 'network_settings.headers.Host')]] : null,
|
'headers' => data_get($protocol_settings, 'network_settings.headers.Host') ? ['Host' => [data_get($protocol_settings, 'network_settings.headers.Host')]] : null,
|
||||||
'max_early_data' => 2048,
|
'max_early_data' => 2048,
|
||||||
'early_data_header_name' => 'Sec-WebSocket-Protocol'
|
'early_data_header_name' => 'Sec-WebSocket-Protocol'
|
||||||
],
|
]),
|
||||||
default => null
|
default => null
|
||||||
};
|
};
|
||||||
$array['transport'] = $transport;
|
$array['transport'] = $transport;
|
||||||
|
|||||||
@@ -314,7 +314,12 @@ class Stash extends AbstractProtocol
|
|||||||
case 'tcp':
|
case 'tcp':
|
||||||
if ($headerType = data_get($protocol_settings, 'network_settings.header.type', 'tcp') != 'tcp') {
|
if ($headerType = data_get($protocol_settings, 'network_settings.header.type', 'tcp') != 'tcp') {
|
||||||
$array['network'] = $headerType;
|
$array['network'] = $headerType;
|
||||||
$array['http-opts']['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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'ws':
|
case 'ws':
|
||||||
@@ -356,7 +361,9 @@ class Stash extends AbstractProtocol
|
|||||||
case 'ws':
|
case 'ws':
|
||||||
$array['network'] = 'ws';
|
$array['network'] = 'ws';
|
||||||
$array['ws-opts']['path'] = data_get($protocol_settings, 'network_settings.path');
|
$array['ws-opts']['path'] = data_get($protocol_settings, 'network_settings.path');
|
||||||
$array['ws-opts']['headers'] = data_get($protocol_settings, 'network_settings.headers.Host') ? ['Host' => data_get($protocol_settings, 'network_settings.headers.Host')] : null;
|
if ($host = data_get($protocol_settings, 'network_settings.headers.Host')) {
|
||||||
|
$array['ws-opts']['headers'] = ['Host' => $host];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ($serverName = data_get($protocol_settings, 'server_name')) {
|
if ($serverName = data_get($protocol_settings, 'server_name')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user