mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-23 02:00:20 +07:00
update: separate XRaySubscriptionConfig from NativeServerConfig and fixed some bugs
This commit is contained in:
@@ -176,71 +176,62 @@ void SecureServersRepository::clearLastConnectionConfig(int serverIndex, DockerC
|
||||
setContainerConfig(serverIndex, container, containerCfg);
|
||||
}
|
||||
|
||||
void SecureServersRepository::setCurrentConfigIndex(const int index)
|
||||
void SecureServersRepository::setCurrentConfigIndex(const int serverIndex, const int index)
|
||||
{
|
||||
ServerConfig serverConfig = server(m_defaultServerIndex);
|
||||
NativeServerConfig *xrayConfig = serverConfig.as<NativeServerConfig>();
|
||||
ServerConfig serverConfig = server(serverIndex);
|
||||
|
||||
xrayConfig->currentConfig = index;
|
||||
editServer(m_defaultServerIndex, serverConfig);
|
||||
if (serverConfig.isXRayConfig()) {
|
||||
XRaySubscriptionConfig* xrayConfig = serverConfig.as<XRaySubscriptionConfig>();
|
||||
if (xrayConfig && xrayConfig->currentConfig != index) {
|
||||
xrayConfig->currentConfig = index;
|
||||
editServer(serverIndex, serverConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int SecureServersRepository::getCurrentConfigIndex() const
|
||||
int SecureServersRepository::getCurrentConfigIndex(const int serverIndex) const
|
||||
{
|
||||
const ServerConfig serverConfig = server(m_defaultServerIndex);
|
||||
ServerConfig serverConfig = server(serverIndex);
|
||||
if (!serverConfig.isXRayConfig())
|
||||
return int();
|
||||
|
||||
const NativeServerConfig *xrayConfig = serverConfig.as<NativeServerConfig>();
|
||||
if (!xrayConfig->currentConfig.has_value())
|
||||
const XRaySubscriptionConfig* xrayConfig = serverConfig.as<XRaySubscriptionConfig>();
|
||||
if (xrayConfig->currentConfig < 0)
|
||||
return int();
|
||||
|
||||
return xrayConfig->currentConfig.value();
|
||||
return xrayConfig->currentConfig;
|
||||
}
|
||||
|
||||
QString SecureServersRepository::getConfigString(const int index) const
|
||||
QString SecureServersRepository::getConfigString(const int serverIndex, const int index) const
|
||||
{
|
||||
const ServerConfig serverConfig = server(m_defaultServerIndex);
|
||||
ServerConfig serverConfig = server(serverIndex);
|
||||
if (!serverConfig.isXRayConfig())
|
||||
return QString();
|
||||
|
||||
const NativeServerConfig *xrayConfig = serverConfig.as<NativeServerConfig>();
|
||||
if (!xrayConfig->configString.has_value())
|
||||
const XRaySubscriptionConfig* xrayConfig = serverConfig.as<XRaySubscriptionConfig>();
|
||||
if (xrayConfig->configString.isEmpty())
|
||||
return QString();
|
||||
|
||||
if (index < 0 || index >= xrayConfig->configString.value().size())
|
||||
return QString();
|
||||
|
||||
return xrayConfig->configString.value().at(index).toString();
|
||||
return xrayConfig->configString.at(index).toString();
|
||||
}
|
||||
|
||||
QString SecureServersRepository::getConfigName(const int index) const
|
||||
QString SecureServersRepository::getConfigName(const int serverIndex, const int index) const
|
||||
{
|
||||
const ServerConfig serverConfig = server(m_defaultServerIndex);
|
||||
if (!serverConfig.isXRayConfig())
|
||||
return QString();
|
||||
|
||||
const NativeServerConfig *xrayConfig = serverConfig.as<NativeServerConfig>();
|
||||
if (!xrayConfig->configName.has_value())
|
||||
return QString();
|
||||
|
||||
if (index < 0 || index >= xrayConfig->configName.value().size())
|
||||
return QString();
|
||||
|
||||
return xrayConfig->configName.value().at(index).toString();
|
||||
QJsonArray names = getConfigNames(serverIndex);
|
||||
return names.at(index).toString();
|
||||
}
|
||||
|
||||
QJsonArray SecureServersRepository::getConfigNames() const
|
||||
QJsonArray SecureServersRepository::getConfigNames(const int serverIndex) const
|
||||
{
|
||||
const ServerConfig serverConfig = server(m_defaultServerIndex);
|
||||
ServerConfig serverConfig = server(serverIndex);
|
||||
if (!serverConfig.isXRayConfig())
|
||||
return QJsonArray();
|
||||
|
||||
const NativeServerConfig *xrayConfig = serverConfig.as<NativeServerConfig>();
|
||||
if (!xrayConfig->configName.has_value())
|
||||
const XRaySubscriptionConfig* xrayConfig = serverConfig.as<XRaySubscriptionConfig>();
|
||||
if (xrayConfig->configName.isEmpty())
|
||||
return QJsonArray();
|
||||
|
||||
return xrayConfig->configName.value();
|
||||
return xrayConfig->configName;
|
||||
}
|
||||
|
||||
ServerCredentials SecureServersRepository::serverCredentials(int index) const
|
||||
|
||||
@@ -35,11 +35,11 @@ public:
|
||||
void setContainerConfig(int serverIndex, DockerContainer container, const ContainerConfig &config);
|
||||
void clearLastConnectionConfig(int serverIndex, DockerContainer container);
|
||||
|
||||
void setCurrentConfigIndex(int index);
|
||||
int getCurrentConfigIndex() const;
|
||||
QString getConfigString(const int index) const;
|
||||
QString getConfigName(const int index) const;
|
||||
QJsonArray getConfigNames() const;
|
||||
void setCurrentConfigIndex(const int serverIndex, int index);
|
||||
int getCurrentConfigIndex(const int serverIndex) const;
|
||||
QString getConfigString(const int serverIndex, const int index) const;
|
||||
QString getConfigName(const int serverIndex, const int index) const;
|
||||
QJsonArray getConfigNames(const int serverIndex) const;
|
||||
|
||||
ServerCredentials serverCredentials(int index) const;
|
||||
bool hasServerWithVpnKey(const QString &vpnKey) const;
|
||||
|
||||
Reference in New Issue
Block a user