feat: Enforce single IP per user for Xray servers and update protocol checks

This commit is contained in:
infosave2007
2026-01-30 21:45:05 +03:00
parent 1774fe598f
commit e200146dc0
2 changed files with 20 additions and 6 deletions
+6
View File
@@ -55,6 +55,12 @@ while (true) {
$monitoring = new ServerMonitoring($server['id']);
// Enforce single IP per user for Xray servers
$containerName = $server['container_name'] ?? '';
if (strpos($containerName, 'xray') !== false) {
$monitoring->enforceXraySingleIpPerUser();
}
// Collect server metrics
$serverMetrics = $monitoring->collectMetrics();
echo " Server: CPU={$serverMetrics['cpu_percent']}% RAM={$serverMetrics['ram_used_mb']}/{$serverMetrics['ram_total_mb']}MB ";
+14 -6
View File
@@ -275,9 +275,9 @@ class ServerMonitoring
$bytesReceived = 0;
$bytesSent = 0;
$slug = $this->serverData['slug']; // Assuming 'slug' is available in serverData
$protocol = $this->serverData['install_protocol'] ?? '';
if ($slug === 'xray' || $slug === 'vless') {
if (strpos($protocol, 'xray') !== false || strpos($protocol, 'vless') !== false) {
// Retrieve DELTA from cache
if ($this->xrayStatsFetched) {
// Try to find by UUID first (if we tracked it) or Email/Name
@@ -556,9 +556,9 @@ class ServerMonitoring
if (stripos($containerName, 'xray') !== false) {
return $containerName;
}
// Also check slug
$slug = $this->serverData['slug'] ?? '';
if (stripos($slug, 'xray') !== false || stripos($slug, 'vless') !== false) {
// Also check protocol
$protocol = $this->serverData['install_protocol'] ?? '';
if (stripos($protocol, 'xray') !== false || stripos($protocol, 'vless') !== false) {
return $containerName ?: 'amnezia-xray';
}
return null;
@@ -598,7 +598,15 @@ class ServerMonitoring
$ipsToBlock = [];
foreach ($data['users'] as $user) {
$email = $user['email'] ?? null;
// Format: "user>>>email>>>online"
if (!is_string($user)) {
continue;
}
$parts = explode('>>>', $user);
if (count($parts) < 2) {
continue;
}
$email = $parts[1];
if (!$email) {
continue;
}