feat: Allocate proper IP address for clients and expose getNextClientIP method
This commit is contained in:
@@ -1749,6 +1749,14 @@ class InstallProtocolManager
|
|||||||
|
|
||||||
$name = $nameById[$uuid] ?? ($email !== '' ? $email : 'xray-' . substr($uuid, 0, 8));
|
$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
|
// Generate VLESS config URL for the client
|
||||||
$host = $serverData['host'] ?? '';
|
$host = $serverData['host'] ?? '';
|
||||||
$realityPub = $details['reality_public_key'] ?? '';
|
$realityPub = $details['reality_public_key'] ?? '';
|
||||||
@@ -1773,7 +1781,7 @@ class InstallProtocolManager
|
|||||||
$serverId,
|
$serverId,
|
||||||
$serverData['user_id'] ?? null,
|
$serverData['user_id'] ?? null,
|
||||||
$name,
|
$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
|
$uuid, // Store UUID as public_key for X-Ray clients
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
|
|||||||
+1
-1
@@ -622,7 +622,7 @@ class VpnClient
|
|||||||
/**
|
/**
|
||||||
* Get next available client IP
|
* Get next available client IP
|
||||||
*/
|
*/
|
||||||
private static function getNextClientIP(array $serverData): string
|
public static function getNextClientIP(array $serverData): string
|
||||||
{
|
{
|
||||||
$pdo = DB::conn();
|
$pdo = DB::conn();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user