mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-24 12:07:28 +08:00
feat: Trojan Reality support and protocol distribution optimizations
This commit is contained in:
@@ -271,8 +271,9 @@ class ClashMeta extends AbstractProtocol
|
||||
|
||||
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') {
|
||||
$headerType = data_get($protocol_settings, 'network_settings.header.type', 'none');
|
||||
$array['network'] = ($headerType === 'http') ? 'http' : 'tcp';
|
||||
if ($headerType === 'http') {
|
||||
if (
|
||||
$httpOpts = array_filter([
|
||||
'headers' => data_get($protocol_settings, 'network_settings.header.request.headers'),
|
||||
@@ -420,10 +421,26 @@ class ClashMeta extends AbstractProtocol
|
||||
'port' => $server['port'],
|
||||
'password' => $password,
|
||||
'udp' => true,
|
||||
'skip-cert-verify' => (bool) data_get($protocol_settings, 'allow_insecure', false)
|
||||
];
|
||||
if ($serverName = data_get($protocol_settings, 'server_name')) {
|
||||
$array['sni'] = $serverName;
|
||||
|
||||
$tlsMode = (int) data_get($protocol_settings, 'tls', 1);
|
||||
switch ($tlsMode) {
|
||||
case 2: // Reality
|
||||
$array['skip-cert-verify'] = (bool) data_get($protocol_settings, 'reality_settings.allow_insecure', false);
|
||||
if ($serverName = data_get($protocol_settings, 'reality_settings.server_name')) {
|
||||
$array['sni'] = $serverName;
|
||||
}
|
||||
$array['reality-opts'] = [
|
||||
'public-key' => data_get($protocol_settings, 'reality_settings.public_key'),
|
||||
'short-id' => data_get($protocol_settings, 'reality_settings.short_id'),
|
||||
];
|
||||
break;
|
||||
default: // Standard TLS
|
||||
$array['skip-cert-verify'] = (bool) data_get($protocol_settings, 'allow_insecure', false);
|
||||
if ($serverName = data_get($protocol_settings, 'server_name')) {
|
||||
$array['sni'] = $serverName;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
self::appendUtls($array, $protocol_settings);
|
||||
|
||||
Reference in New Issue
Block a user