feat: add support for awg2, mtproxy, and aivpn protocols, and implement user role-based access control.
This commit is contained in:
@@ -295,6 +295,8 @@ class InstallProtocolManager
|
||||
'server_public_key' => $result['server_public_key'] ?? null,
|
||||
'preshared_key' => $result['preshared_key'] ?? null,
|
||||
'awg_params' => $result['awg_params'] ?? null,
|
||||
'secret' => $result['secret'] ?? null,
|
||||
'server_host' => $result['server_host'] ?? null,
|
||||
];
|
||||
if (($protocol['slug'] ?? '') === 'xray-vless') {
|
||||
foreach (['client_id', 'container_name', 'server_port', 'xray_port', 'reality_public_key', 'reality_private_key', 'reality_short_id', 'reality_server_name'] as $k) {
|
||||
@@ -653,6 +655,9 @@ class InstallProtocolManager
|
||||
'privatekey' => 'reality_private_key',
|
||||
'shortid' => 'reality_short_id',
|
||||
'servername' => 'reality_server_name',
|
||||
'secret' => 'secret',
|
||||
'serverhost' => 'server_host',
|
||||
'server_host' => 'server_host',
|
||||
];
|
||||
|
||||
$finalKey = $keyMap[$normalizedKey] ?? $normalizedKey;
|
||||
@@ -899,7 +904,7 @@ class InstallProtocolManager
|
||||
*/
|
||||
private static function isAwgProtocol(string $slug, array $protocol): bool
|
||||
{
|
||||
if (in_array($slug, ['amnezia-wg', 'amnezia-wg-advanced'], true)) {
|
||||
if (in_array($slug, ['amnezia-wg', 'amnezia-wg-advanced', 'awg2'], true)) {
|
||||
return true;
|
||||
}
|
||||
$installScript = (string) ($protocol['install_script'] ?? '');
|
||||
|
||||
+7
-6
@@ -67,7 +67,7 @@ class VpnClient
|
||||
$protoRow = $stmtProto2->fetch();
|
||||
}
|
||||
$slug = $protoRow['slug'] ?? ($serverData['install_protocol'] ?? 'amnezia-wg');
|
||||
$isWireguard = in_array($slug, ['amnezia-wg-advanced', 'wireguard-standard', 'amnezia-wg'], true);
|
||||
$isWireguard = in_array($slug, ['amnezia-wg-advanced', 'wireguard-standard', 'amnezia-wg', 'awg2'], true);
|
||||
|
||||
// Auto-sync server keys from container EVERY TIME for WireGuard protocols
|
||||
// This ensures we always use current container configuration even if it was recreated
|
||||
@@ -1121,7 +1121,7 @@ class VpnClient
|
||||
$stmt = $pdo->prepare('SELECT slug FROM protocols WHERE id = ?');
|
||||
$stmt->execute([$protocolId]);
|
||||
$slug = (string) $stmt->fetchColumn();
|
||||
return in_array($slug, ['amnezia-wg-advanced', 'wireguard-standard', 'amnezia-wg'], true);
|
||||
return in_array($slug, ['amnezia-wg-advanced', 'wireguard-standard', 'amnezia-wg', 'awg2'], true);
|
||||
} catch (Exception $e) {
|
||||
return true;
|
||||
}
|
||||
@@ -1309,7 +1309,7 @@ class VpnClient
|
||||
$protoRow = $stmt->fetch();
|
||||
}
|
||||
$slug = $protoRow['slug'] ?? '';
|
||||
$isWireguard = in_array($slug, ['amnezia-wg-advanced', 'wireguard-standard', 'amnezia-wg'], true);
|
||||
$isWireguard = in_array($slug, ['amnezia-wg-advanced', 'wireguard-standard', 'amnezia-wg', 'awg2'], true);
|
||||
|
||||
if (!$isWireguard) {
|
||||
return ['success' => false, 'error' => 'not_wireguard_protocol', 'protocol_slug' => $slug];
|
||||
@@ -1335,7 +1335,7 @@ class VpnClient
|
||||
|
||||
// If AWG params are missing (common after reinstall), fetch them directly from wg0.conf
|
||||
// to avoid falling back to template defaults that will not match the server.
|
||||
if ($slug === 'amnezia-wg-advanced') {
|
||||
if (in_array($slug, ['amnezia-wg-advanced', 'awg2'], true)) {
|
||||
$needKeys = ['JC', 'JMIN', 'JMAX', 'S1', 'S2', 'H1', 'H2', 'H3', 'H4'];
|
||||
$missing = false;
|
||||
foreach ($needKeys as $k) {
|
||||
@@ -1346,8 +1346,9 @@ class VpnClient
|
||||
}
|
||||
|
||||
if ($missing) {
|
||||
$containerName = $serverData['container_name'] ?? 'amnezia-awg';
|
||||
$direct = self::extractAwgParamsFromWg0Conf($server, $containerName, '/opt/amnezia/awg/wg0.conf');
|
||||
$containerName = $serverData['container_name'] ?? ($slug === 'awg2' ? 'amnezia-awg2' : 'amnezia-awg');
|
||||
$configDir = $slug === 'awg2' ? '/opt/amnezia/awg2' : '/opt/amnezia/awg';
|
||||
$direct = self::extractAwgParamsFromWg0Conf($server, $containerName, $configDir . '/wg0.conf');
|
||||
if (empty($direct)) {
|
||||
$direct = self::extractAwgParamsFromWg0Conf($server, $containerName, '/etc/wireguard/wg0.conf');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user