mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-20 02:00:55 +07:00
fixed increment name server N
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
@@ -205,14 +206,16 @@ QString SecureServersRepository::nextAvailableServerName() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
static const QRegularExpression serverNameRe(QStringLiteral("^Server (\\d+)$"));
|
||||||
QString candidate;
|
int maxN = 0;
|
||||||
do {
|
for (const QString &name : std::as_const(usedNames)) {
|
||||||
i++;
|
const QRegularExpressionMatch match = serverNameRe.match(name);
|
||||||
candidate = QStringLiteral("Server %1").arg(i);
|
if (match.hasMatch()) {
|
||||||
} while (usedNames.contains(candidate));
|
maxN = std::max(maxN, match.captured(1).toInt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return candidate;
|
return QStringLiteral("Server %1").arg(maxN + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SecureServersRepository::addServer(const QString &serverId, const QJsonObject &serverJson, serverConfigUtils::ConfigType kind)
|
QString SecureServersRepository::addServer(const QString &serverId, const QJsonObject &serverJson, serverConfigUtils::ConfigType kind)
|
||||||
|
|||||||
Reference in New Issue
Block a user