feat: machine mode, ECH subscriptions, batch ops & security hardening

This commit is contained in:
xboard
2026-04-17 02:27:47 +08:00
parent edbd8de356
commit e297b5fe9f
25 changed files with 1564 additions and 343 deletions
+48 -37
View File
@@ -124,6 +124,7 @@ class Server extends Model
'last_check_at' => 'integer',
'last_push_at' => 'integer',
'show' => 'boolean',
'enabled' => 'boolean',
'created_at' => 'timestamp',
'updated_at' => 'timestamp',
'rate_time_ranges' => 'array',
@@ -131,6 +132,7 @@ class Server extends Model
'transfer_enable' => 'integer',
'u' => 'integer',
'd' => 'integer',
'machine_id' => 'integer',
];
private const MULTIPLEX_CONFIGURATION = [
@@ -179,6 +181,38 @@ class Server extends Model
]
];
private const ECH_CONFIGURATION = [
'ech' => [
'type' => 'object',
'fields' => [
'enabled' => ['type' => 'boolean', 'default' => false],
'config' => ['type' => 'string', 'default' => null],
'query_server_name' => ['type' => 'string', 'default' => null],
'key' => ['type' => 'string', 'default' => null],
'key_path' => ['type' => 'string', 'default' => null],
'config_path' => ['type' => 'string', 'default' => null],
]
]
];
private const TLS_SETTINGS_CONFIGURATION = [
'type' => 'object',
'fields' => [
'server_name' => ['type' => 'string', 'default' => null],
'allow_insecure' => ['type' => 'boolean', 'default' => false],
...self::ECH_CONFIGURATION,
]
];
private const TLS_CONFIGURATION = [
'type' => 'object',
'fields' => [
'server_name' => ['type' => 'string', 'default' => null],
'allow_insecure' => ['type' => 'boolean', 'default' => false],
...self::ECH_CONFIGURATION,
]
];
private const PROTOCOL_CONFIGURATIONS = [
self::TYPE_TROJAN => [
'tls' => ['type' => 'integer', 'default' => 1],
@@ -186,6 +220,7 @@ class Server extends Model
'network_settings' => ['type' => 'array', 'default' => null],
'server_name' => ['type' => 'string', 'default' => null],
'allow_insecure' => ['type' => 'boolean', 'default' => false],
'tls_settings' => self::TLS_SETTINGS_CONFIGURATION,
...self::REALITY_CONFIGURATION,
...self::MULTIPLEX_CONFIGURATION,
...self::UTLS_CONFIGURATION
@@ -195,13 +230,13 @@ class Server extends Model
'network' => ['type' => 'string', 'default' => null],
'rules' => ['type' => 'array', 'default' => null],
'network_settings' => ['type' => 'array', 'default' => null],
'tls_settings' => ['type' => 'array', 'default' => null],
'tls_settings' => self::TLS_SETTINGS_CONFIGURATION,
...self::MULTIPLEX_CONFIGURATION,
...self::UTLS_CONFIGURATION
],
self::TYPE_VLESS => [
'tls' => ['type' => 'integer', 'default' => 0],
'tls_settings' => ['type' => 'array', 'default' => null],
'tls_settings' => self::TLS_SETTINGS_CONFIGURATION,
'flow' => ['type' => 'string', 'default' => null],
'encryption' => [
'type' => 'object',
@@ -242,13 +277,7 @@ class Server extends Model
'password' => ['type' => 'string', 'default' => null]
]
],
'tls' => [
'type' => 'object',
'fields' => [
'server_name' => ['type' => 'string', 'default' => null],
'allow_insecure' => ['type' => 'boolean', 'default' => false]
]
],
'tls' => self::TLS_CONFIGURATION,
'hop_interval' => ['type' => 'integer', 'default' => null]
],
self::TYPE_TUIC => [
@@ -256,13 +285,7 @@ class Server extends Model
'congestion_control' => ['type' => 'string', 'default' => 'cubic'],
'alpn' => ['type' => 'array', 'default' => ['h3']],
'udp_relay_mode' => ['type' => 'string', 'default' => 'native'],
'tls' => [
'type' => 'object',
'fields' => [
'server_name' => ['type' => 'string', 'default' => null],
'allow_insecure' => ['type' => 'boolean', 'default' => false]
]
]
'tls' => self::TLS_CONFIGURATION
],
self::TYPE_ANYTLS => [
'padding_scheme' => [
@@ -279,36 +302,19 @@ class Server extends Model
"7=500-1000"
]
],
'tls' => [
'type' => 'object',
'fields' => [
'server_name' => ['type' => 'string', 'default' => null],
'allow_insecure' => ['type' => 'boolean', 'default' => false]
]
]
'tls' => self::TLS_CONFIGURATION
],
self::TYPE_SOCKS => [
'tls' => ['type' => 'integer', 'default' => 0],
'tls_settings' => [
'type' => 'object',
'fields' => [
'allow_insecure' => ['type' => 'boolean', 'default' => false]
]
]
'tls_settings' => self::TLS_SETTINGS_CONFIGURATION
],
self::TYPE_NAIVE => [
'tls' => ['type' => 'integer', 'default' => 0],
'tls_settings' => ['type' => 'array', 'default' => null]
'tls_settings' => self::TLS_SETTINGS_CONFIGURATION
],
self::TYPE_HTTP => [
'tls' => ['type' => 'integer', 'default' => 0],
'tls_settings' => [
'type' => 'object',
'fields' => [
'allow_insecure' => ['type' => 'boolean', 'default' => false],
'server_name' => ['type' => 'string', 'default' => null]
]
]
'tls_settings' => self::TLS_SETTINGS_CONFIGURATION
],
self::TYPE_MIERU => [
'transport' => ['type' => 'string', 'default' => 'TCP'],
@@ -416,6 +422,11 @@ class Server extends Model
return $this->hasMany(StatServer::class, 'server_id', 'id');
}
public function machine(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(ServerMachine::class, 'machine_id');
}
public function groups()
{
return ServerGroup::whereIn('id', $this->group_ids)->get();