mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-23 02:00:20 +07:00
add test macros AMNEZIA_QR_PAIRING_ALLOW_DUPLICATE_VPN_KEY & disable ApiConfigAlreadyAdded
This commit is contained in:
@@ -208,6 +208,10 @@ if(AMNEZIA_LOCAL_GATEWAY)
|
|||||||
target_compile_definitions(${PROJECT} PRIVATE AMNEZIA_LOCAL_GATEWAY)
|
target_compile_definitions(${PROJECT} PRIVATE AMNEZIA_LOCAL_GATEWAY)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(AMNEZIA_QR_PAIRING_ALLOW_DUPLICATE_VPN_KEY)
|
||||||
|
target_compile_definitions(${PROJECT} PRIVATE AMNEZIA_QR_PAIRING_ALLOW_DUPLICATE_VPN_KEY)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_sources(${PROJECT} PRIVATE ${SOURCES} ${HEADERS} ${RESOURCES} ${QRC} ${I18NQRC})
|
target_sources(${PROJECT} PRIVATE ${SOURCES} ${HEADERS} ${RESOURCES} ${QRC} ${I18NQRC})
|
||||||
|
|
||||||
# Finalize the executable so Qt can gather/deploy QML modules and plugins correctly (Android needs this).
|
# Finalize the executable so Qt can gather/deploy QML modules and plugins correctly (Android needs this).
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "subscriptionController.h"
|
#include "subscriptionController.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
@@ -338,7 +339,9 @@ ErrorCode SubscriptionController::importServerFromQrPairingResponse(const QStrin
|
|||||||
if (duplicateServerIndex) {
|
if (duplicateServerIndex) {
|
||||||
*duplicateServerIndex = i;
|
*duplicateServerIndex = i;
|
||||||
}
|
}
|
||||||
|
#ifndef AMNEZIA_QR_PAIRING_ALLOW_DUPLICATE_VPN_KEY
|
||||||
return ErrorCode::ApiConfigAlreadyAdded;
|
return ErrorCode::ApiConfigAlreadyAdded;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,6 +387,24 @@ ErrorCode SubscriptionController::importServerFromQrPairingResponse(const QStrin
|
|||||||
apiV2->apiConfig.vpnKey = fullKey;
|
apiV2->apiConfig.vpnKey = fullKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef AMNEZIA_QR_PAIRING_ALLOW_DUPLICATE_VPN_KEY
|
||||||
|
static int existingSameKeyCount = 0;
|
||||||
|
if (apiV2) {
|
||||||
|
++existingSameKeyCount;
|
||||||
|
const QString suffix = QCoreApplication::translate("SubscriptionController", " (paired copy %1)")
|
||||||
|
.arg(existingSameKeyCount);
|
||||||
|
|
||||||
|
if (!apiV2->name.isEmpty()) {
|
||||||
|
apiV2->name += suffix;
|
||||||
|
} else if (!apiV2->description.isEmpty()) {
|
||||||
|
apiV2->description += suffix;
|
||||||
|
} else {
|
||||||
|
apiV2->name = QCoreApplication::translate("SubscriptionController", "Paired subscription %1")
|
||||||
|
.arg(existingSameKeyCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
m_serversRepository->addServer(serverConfigModel);
|
m_serversRepository->addServer(serverConfigModel);
|
||||||
serverConfig = serverConfigModel;
|
serverConfig = serverConfigModel;
|
||||||
return ErrorCode::NoError;
|
return ErrorCode::NoError;
|
||||||
|
|||||||
Reference in New Issue
Block a user