mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-30 16:07:24 +08:00
fix(singbox): resolve port type casting and add port hopping support
This commit is contained in:
@@ -3,6 +3,7 @@ namespace App\Protocols;
|
|||||||
|
|
||||||
use App\Utils\Helper;
|
use App\Utils\Helper;
|
||||||
use App\Contracts\ProtocolInterface;
|
use App\Contracts\ProtocolInterface;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
class SingBox implements ProtocolInterface
|
class SingBox implements ProtocolInterface
|
||||||
{
|
{
|
||||||
@@ -70,8 +71,9 @@ class SingBox implements ProtocolInterface
|
|||||||
$vmessConfig = $this->buildVmess($this->user['uuid'], $item);
|
$vmessConfig = $this->buildVmess($this->user['uuid'], $item);
|
||||||
$proxies[] = $vmessConfig;
|
$proxies[] = $vmessConfig;
|
||||||
}
|
}
|
||||||
if ($item['type'] === 'vless'
|
if (
|
||||||
&& in_array(data_get($protocol_settings, 'network'), ['tcp', 'ws', 'grpc', 'http', 'quic', 'httpupgrade'])
|
$item['type'] === 'vless'
|
||||||
|
&& in_array(data_get($protocol_settings, 'network'), ['tcp', 'ws', 'grpc', 'http', 'quic', 'httpupgrade'])
|
||||||
) {
|
) {
|
||||||
$vlessConfig = $this->buildVless($this->user['uuid'], $item);
|
$vlessConfig = $this->buildVless($this->user['uuid'], $item);
|
||||||
$proxies[] = $vlessConfig;
|
$proxies[] = $vlessConfig;
|
||||||
@@ -158,7 +160,7 @@ class SingBox implements ProtocolInterface
|
|||||||
$transport = match ($protocol_settings['network']) {
|
$transport = match ($protocol_settings['network']) {
|
||||||
'tcp' => [
|
'tcp' => [
|
||||||
'type' => 'http',
|
'type' => 'http',
|
||||||
'path' => \Arr::random(data_get($protocol_settings, 'network_settings.header.request.path', ['/']))
|
'path' => Arr::random(data_get($protocol_settings, 'network_settings.header.request.path', ['/']))
|
||||||
],
|
],
|
||||||
'ws' => [
|
'ws' => [
|
||||||
'type' => 'ws',
|
'type' => 'ws',
|
||||||
@@ -306,6 +308,9 @@ class SingBox implements ProtocolInterface
|
|||||||
'insecure' => (bool) $protocol_settings['tls']['allow_insecure'],
|
'insecure' => (bool) $protocol_settings['tls']['allow_insecure'],
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
if (isset($server['ports'])) {
|
||||||
|
$baseConfig['server_ports'][] = str_replace('-', ':', $server['ports']);
|
||||||
|
}
|
||||||
if ($serverName = data_get($protocol_settings, 'tls_settings.server_name')) {
|
if ($serverName = data_get($protocol_settings, 'tls_settings.server_name')) {
|
||||||
$baseConfig['tls']['server_name'] = $serverName;
|
$baseConfig['tls']['server_name'] = $serverName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,8 +45,9 @@ class ServerService
|
|||||||
$servers = collect($servers)->map(function ($server) use ($user) {
|
$servers = collect($servers)->map(function ($server) use ($user) {
|
||||||
// 判断动态端口
|
// 判断动态端口
|
||||||
if (str_contains($server->port, '-')) {
|
if (str_contains($server->port, '-')) {
|
||||||
$server->port = (string) Helper::randomPort($server->port);
|
$port = $server->port;
|
||||||
$server->ports = $server->port;
|
$server->port = (int) Helper::randomPort($port);
|
||||||
|
$server->ports = $port;
|
||||||
} else {
|
} else {
|
||||||
$server->port = (int) $server->port;
|
$server->port = (int) $server->port;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user