feat: Allocate proper IP address for clients and expose getNextClientIP method

This commit is contained in:
infosave2007
2026-02-13 20:40:04 +03:00
parent 86eeb765e7
commit e7af048a9e
2 changed files with 10 additions and 2 deletions
+9 -1
View File
@@ -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
'',
'',
+1 -1
View File
@@ -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();