Fix: Case-sensitive AWG params and XRay Identifier logic

This commit is contained in:
infosave2007
2026-01-24 20:34:07 +03:00
parent a86e0cac9a
commit 9969014d3e
2 changed files with 18 additions and 16 deletions
+2 -1
View File
@@ -1200,7 +1200,8 @@ class InstallProtocolManager
} }
// Add client // Add client
$newClient = ['id' => $clientId, 'email' => $clientId]; $email = !empty($options['login']) ? $options['login'] : $clientId;
$newClient = ['id' => $clientId, 'email' => $email];
// Detect flow from other clients or default // Detect flow from other clients or default
$flow = 'xtls-rprx-vision'; // Default for Reality $flow = 'xtls-rprx-vision'; // Default for Reality
+16 -15
View File
@@ -117,11 +117,20 @@ class VpnClient
// Add AWG parameters (use UPPERCASE keys as extracted from container) // Add AWG parameters (use UPPERCASE keys as extracted from container)
// Normalize AWG params keys case-insensitively
$cleanAwgParams = [];
if (is_array($awgParams)) {
foreach ($awgParams as $k => $v) {
$cleanAwgParams[strtoupper($k)] = $v;
}
}
// Add AWG parameters (use UPPERCASE keys internal logic)
foreach (['JC', 'JMIN', 'JMAX', 'S1', 'S2', 'H1', 'H2', 'H3', 'H4'] as $key) { foreach (['JC', 'JMIN', 'JMAX', 'S1', 'S2', 'H1', 'H2', 'H3', 'H4'] as $key) {
if (isset($awgParams[$key])) { if (isset($cleanAwgParams[$key])) {
$vars[$key] = $awgParams[$key]; $vars[$key] = $cleanAwgParams[$key];
} else { } else {
// Default values for AWG params // Default values for AWG params (Fallback only)
$defaults = [ $defaults = [
'JC' => 5, 'JC' => 5,
'JMIN' => 100, 'JMIN' => 100,
@@ -1507,19 +1516,11 @@ class VpnClient
// Or better: try to detect protocol from config if container name is vague (but usually amnezia-xray) // Or better: try to detect protocol from config if container name is vague (but usually amnezia-xray)
if (strpos($containerName, 'xray') !== false) { if (strpos($containerName, 'xray') !== false) {
$uuid = null; // Use client Name (Login) as identifier strictly requested by user
// Try to find UUID in config $identifier = $this->data['name'] ?? null;
// 1. Check for JSON format (server.json style or subsets)
if (preg_match('/"id":\s*"([0-9a-fA-F-]{36})"/', $this->data['config'] ?? '', $m)) {
$uuid = $m[1];
}
// 2. Check for VLESS URI
elseif (preg_match('/vless:\/\/([0-9a-fA-F-]{36})@/', $this->data['config'] ?? '', $m)) {
$uuid = $m[1];
}
if ($uuid) { if ($identifier) {
$stats = self::getXrayStats($serverData, $uuid); $stats = self::getXrayStats($serverData, $identifier);
} }
} }