feat: Enforce single IP per user for Xray servers and update protocol checks
This commit is contained in:
@@ -55,6 +55,12 @@ while (true) {
|
|||||||
|
|
||||||
$monitoring = new ServerMonitoring($server['id']);
|
$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
|
// Collect server metrics
|
||||||
$serverMetrics = $monitoring->collectMetrics();
|
$serverMetrics = $monitoring->collectMetrics();
|
||||||
echo " Server: CPU={$serverMetrics['cpu_percent']}% RAM={$serverMetrics['ram_used_mb']}/{$serverMetrics['ram_total_mb']}MB ";
|
echo " Server: CPU={$serverMetrics['cpu_percent']}% RAM={$serverMetrics['ram_used_mb']}/{$serverMetrics['ram_total_mb']}MB ";
|
||||||
|
|||||||
@@ -275,9 +275,9 @@ class ServerMonitoring
|
|||||||
$bytesReceived = 0;
|
$bytesReceived = 0;
|
||||||
$bytesSent = 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
|
// Retrieve DELTA from cache
|
||||||
if ($this->xrayStatsFetched) {
|
if ($this->xrayStatsFetched) {
|
||||||
// Try to find by UUID first (if we tracked it) or Email/Name
|
// Try to find by UUID first (if we tracked it) or Email/Name
|
||||||
@@ -556,9 +556,9 @@ class ServerMonitoring
|
|||||||
if (stripos($containerName, 'xray') !== false) {
|
if (stripos($containerName, 'xray') !== false) {
|
||||||
return $containerName;
|
return $containerName;
|
||||||
}
|
}
|
||||||
// Also check slug
|
// Also check protocol
|
||||||
$slug = $this->serverData['slug'] ?? '';
|
$protocol = $this->serverData['install_protocol'] ?? '';
|
||||||
if (stripos($slug, 'xray') !== false || stripos($slug, 'vless') !== false) {
|
if (stripos($protocol, 'xray') !== false || stripos($protocol, 'vless') !== false) {
|
||||||
return $containerName ?: 'amnezia-xray';
|
return $containerName ?: 'amnezia-xray';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -598,7 +598,15 @@ class ServerMonitoring
|
|||||||
$ipsToBlock = [];
|
$ipsToBlock = [];
|
||||||
|
|
||||||
foreach ($data['users'] as $user) {
|
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) {
|
if (!$email) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user