From f6a854f5ab8c810dd15f878120d4c80080efc0d1 Mon Sep 17 00:00:00 2001 From: infosave2007 Date: Fri, 13 Feb 2026 20:40:04 +0300 Subject: [PATCH] feat: Allocate proper IP address for clients and expose getNextClientIP method --- inc/InstallProtocolManager.php | 10 +++++++++- inc/VpnClient.php | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/inc/InstallProtocolManager.php b/inc/InstallProtocolManager.php index b1fec08..a82210e 100644 --- a/inc/InstallProtocolManager.php +++ b/inc/InstallProtocolManager.php @@ -1749,6 +1749,14 @@ class InstallProtocolManager $name = $nameById[$uuid] ?? ($email !== '' ? $email : 'xray-' . substr($uuid, 0, 8)); + // Allocate a proper IP address for the client instead of using UUID + try { + $clientIp = VpnClient::getNextClientIP($serverData); + } catch (Throwable $e) { + // Fallback to UUID if IP allocation fails + $clientIp = $uuid; + } + // Generate VLESS config URL for the client $host = $serverData['host'] ?? ''; $realityPub = $details['reality_public_key'] ?? ''; @@ -1773,7 +1781,7 @@ class InstallProtocolManager $serverId, $serverData['user_id'] ?? null, $name, - $uuid, // Use UUID as client_ip (unique key requires non-empty value) + $clientIp, // Use allocated IP address $uuid, // Store UUID as public_key for X-Ray clients '', '', diff --git a/inc/VpnClient.php b/inc/VpnClient.php index 029c059..6573991 100644 --- a/inc/VpnClient.php +++ b/inc/VpnClient.php @@ -622,7 +622,7 @@ class VpnClient /** * Get next available client IP */ - private static function getNextClientIP(array $serverData): string + public static function getNextClientIP(array $serverData): string { $pdo = DB::conn();