mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-23 02:00:20 +07:00
feat: add xray subscription link support
This commit is contained in:
@@ -176,6 +176,73 @@ void SecureServersRepository::clearLastConnectionConfig(int serverIndex, DockerC
|
||||
setContainerConfig(serverIndex, container, containerCfg);
|
||||
}
|
||||
|
||||
void SecureServersRepository::setCurrentConfigIndex(const int index)
|
||||
{
|
||||
ServerConfig serverConfig = server(m_defaultServerIndex);
|
||||
NativeServerConfig *xrayConfig = serverConfig.as<NativeServerConfig>();
|
||||
|
||||
xrayConfig->currentConfig = index;
|
||||
editServer(m_defaultServerIndex, serverConfig);
|
||||
}
|
||||
|
||||
int SecureServersRepository::getCurrentConfigIndex() const
|
||||
{
|
||||
const ServerConfig serverConfig = server(m_defaultServerIndex);
|
||||
if (!serverConfig.isXRayConfig())
|
||||
return int();
|
||||
|
||||
const NativeServerConfig *xrayConfig = serverConfig.as<NativeServerConfig>();
|
||||
if (!xrayConfig->currentConfig.has_value())
|
||||
return int();
|
||||
|
||||
return xrayConfig->currentConfig.value();
|
||||
}
|
||||
|
||||
QString SecureServersRepository::getConfigString(const int index) const
|
||||
{
|
||||
const ServerConfig serverConfig = server(m_defaultServerIndex);
|
||||
if (!serverConfig.isXRayConfig())
|
||||
return QString();
|
||||
|
||||
const NativeServerConfig *xrayConfig = serverConfig.as<NativeServerConfig>();
|
||||
if (!xrayConfig->configString.has_value())
|
||||
return QString();
|
||||
|
||||
if (index < 0 || index >= xrayConfig->configString.value().size())
|
||||
return QString();
|
||||
|
||||
return xrayConfig->configString.value().at(index).toString();
|
||||
}
|
||||
|
||||
QString SecureServersRepository::getConfigName(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 SecureServersRepository::getConfigNames() const
|
||||
{
|
||||
const ServerConfig serverConfig = server(m_defaultServerIndex);
|
||||
if (!serverConfig.isXRayConfig())
|
||||
return QJsonArray();
|
||||
|
||||
const NativeServerConfig *xrayConfig = serverConfig.as<NativeServerConfig>();
|
||||
if (!xrayConfig->configName.has_value())
|
||||
return QJsonArray();
|
||||
|
||||
return xrayConfig->configName.value();
|
||||
}
|
||||
|
||||
ServerCredentials SecureServersRepository::serverCredentials(int index) const
|
||||
{
|
||||
ServerConfig config = server(index);
|
||||
|
||||
@@ -35,6 +35,12 @@ 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;
|
||||
|
||||
ServerCredentials serverCredentials(int index) const;
|
||||
bool hasServerWithVpnKey(const QString &vpnKey) const;
|
||||
bool hasServerWithCrc(quint16 crc) const;
|
||||
|
||||
Reference in New Issue
Block a user