Fix connection to server from old versions by credentials

This commit is contained in:
aiamnezia 2024-11-27 15:52:10 +04:00
parent 7a63ef79f4
commit 46a7f97e32
3 changed files with 10 additions and 1 deletions

View file

@ -148,6 +148,7 @@ namespace amnezia
namespace xray namespace xray
{ {
constexpr char serverConfigPath[] = "/opt/amnezia/xray/server.json"; constexpr char serverConfigPath[] = "/opt/amnezia/xray/server.json";
constexpr char uuidPath[] = "/opt/amnezia/xray/xray_uuid.key";
constexpr char PublicKeyPath[] = "/opt/amnezia/xray/xray_public.key"; constexpr char PublicKeyPath[] = "/opt/amnezia/xray/xray_public.key";
constexpr char PrivateKeyPath[] = "/opt/amnezia/xray/xray_private.key"; constexpr char PrivateKeyPath[] = "/opt/amnezia/xray/xray_private.key";
constexpr char shortidPath[] = "/opt/amnezia/xray/xray_short_id.key"; constexpr char shortidPath[] = "/opt/amnezia/xray/xray_short_id.key";

View file

@ -1,4 +1,5 @@
cd /opt/amnezia/xray cd /opt/amnezia/xray
XRAY_CLIENT_ID=$(xray uuid) && echo $XRAY_CLIENT_ID > /opt/amnezia/xray/xray_uuid.key
XRAY_SHORT_ID=$(openssl rand -hex 8) && echo $XRAY_SHORT_ID > /opt/amnezia/xray/xray_short_id.key XRAY_SHORT_ID=$(openssl rand -hex 8) && echo $XRAY_SHORT_ID > /opt/amnezia/xray/xray_short_id.key
KEYPAIR=$(xray x25519) KEYPAIR=$(xray x25519)
@ -32,6 +33,10 @@ cat > /opt/amnezia/xray/server.json <<EOF
"protocol": "vless", "protocol": "vless",
"settings": { "settings": {
"clients": [ "clients": [
{
"id": "$XRAY_CLIENT_ID",
"flow": "xtls-rprx-vision"
}
], ],
"decryption": "none" "decryption": "none"
}, },

View file

@ -285,7 +285,10 @@ ErrorCode ClientManagementModel::getXrayClients(const DockerContainer container,
} }
QString clientId = clientObj["id"].toString(); QString clientId = clientObj["id"].toString();
if (!isClientExists(clientId)) { QString xrayDefUuid = serverController->getTextFileFromContainer(container, credentials, amnezia::protocols::xray::uuidPath, error);
xrayDefUuid.replace("\n", "");
if (!isClientExists(clientId) && clientId != xrayDefUuid) {
QJsonObject client; QJsonObject client;
client[configKey::clientId] = clientId; client[configKey::clientId] = clientId;