Integração Pangolin Proxy
This commit is contained in:
@@ -30,8 +30,13 @@ class ApiMiddleware
|
||||
try {
|
||||
$conn = \App\Config\Database::getInstance()->getConnection();
|
||||
|
||||
// Find server by Serial Key
|
||||
$stmt = $conn->prepare("SELECT id, machine_id, status, ip_v4 FROM servers WHERE serial_key = :serial");
|
||||
// Find server by Serial Key and join with client to check both statuses
|
||||
$stmt = $conn->prepare("
|
||||
SELECT s.id, s.machine_id, s.status, s.ip_v4, s.client_id, c.status as client_status
|
||||
FROM servers s
|
||||
JOIN clients c ON s.client_id = c.id
|
||||
WHERE s.serial_key = :serial
|
||||
");
|
||||
$stmt->execute(['serial' => $serialKey]);
|
||||
$server = $stmt->fetch();
|
||||
|
||||
@@ -61,6 +66,13 @@ class ApiMiddleware
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if client is active
|
||||
if ($server['client_status'] !== 'active') {
|
||||
$this->log($server['id'], 'auth_blocked', 'Client is inactive');
|
||||
View::json(['error' => 'Client is inactive'], 403);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bind Machine ID if first use
|
||||
if (empty($server['machine_id'])) {
|
||||
$update = $conn->prepare("UPDATE servers SET machine_id = :mid WHERE id = :id");
|
||||
|
||||
Reference in New Issue
Block a user