Merge branch 'dev' into qt_migration

This commit is contained in:
pokamest 2023-01-08 23:00:13 +00:00
commit 167d3caa5d
47 changed files with 1061 additions and 876 deletions

View file

@ -76,6 +76,7 @@ HEADERS += \
ui/pages_logic/protocols/OtherProtocolsLogic.h \ ui/pages_logic/protocols/OtherProtocolsLogic.h \
ui/pages_logic/protocols/PageProtocolLogicBase.h \ ui/pages_logic/protocols/PageProtocolLogicBase.h \
ui/pages_logic/protocols/ShadowSocksLogic.h \ ui/pages_logic/protocols/ShadowSocksLogic.h \
ui/pages_logic/protocols/WireGuardLogic.h \
ui/property_helper.h \ ui/property_helper.h \
ui/models/servers_model.h \ ui/models/servers_model.h \
ui/uilogic.h \ ui/uilogic.h \
@ -138,6 +139,7 @@ SOURCES += \
ui/pages_logic/protocols/PageProtocolLogicBase.cpp \ ui/pages_logic/protocols/PageProtocolLogicBase.cpp \
ui/pages_logic/protocols/ShadowSocksLogic.cpp \ ui/pages_logic/protocols/ShadowSocksLogic.cpp \
ui/models/servers_model.cpp \ ui/models/servers_model.cpp \
ui/pages_logic/protocols/WireGuardLogic.cpp \
ui/uilogic.cpp \ ui/uilogic.cpp \
ui/qautostart.cpp \ ui/qautostart.cpp \
ui/models/sites_model.cpp \ ui/models/sites_model.cpp \

View file

@ -58,6 +58,12 @@ constexpr char additional_server_config[] = "additional_server_config";
// proto config keys // proto config keys
constexpr char last_config[] = "last_config"; constexpr char last_config[] = "last_config";
constexpr char isThirdPartyConfig[] = "isThirdPartyConfig";
constexpr char openvpn[] = "openvpn";
constexpr char wireguard[] = "wireguard";
} }
namespace protocols { namespace protocols {

View file

@ -63,6 +63,7 @@
<file>server_scripts/website_tor/run_container.sh</file> <file>server_scripts/website_tor/run_container.sh</file>
<file>ui/qml/main.qml</file> <file>ui/qml/main.qml</file>
<file>ui/qml/TitleBar.qml</file> <file>ui/qml/TitleBar.qml</file>
<file>ui/qml/Pages/PageBase.qml</file>
<file>ui/qml/Pages/PageAppSetting.qml</file> <file>ui/qml/Pages/PageAppSetting.qml</file>
<file>ui/qml/Pages/PageGeneralSettings.qml</file> <file>ui/qml/Pages/PageGeneralSettings.qml</file>
<file>ui/qml/Pages/PageNetworkSetting.qml</file> <file>ui/qml/Pages/PageNetworkSetting.qml</file>
@ -81,6 +82,28 @@
<file>ui/qml/Pages/PageSites.qml</file> <file>ui/qml/Pages/PageSites.qml</file>
<file>ui/qml/Pages/PageStart.qml</file> <file>ui/qml/Pages/PageStart.qml</file>
<file>ui/qml/Pages/PageVPN.qml</file> <file>ui/qml/Pages/PageVPN.qml</file>
<file>ui/qml/Pages/PageQrDecoder.qml</file>
<file>ui/qml/Pages/PageAbout.qml</file>
<file>ui/qml/Pages/PageQrDecoderIos.qml</file>
<file>ui/qml/Pages/PageViewConfig.qml</file>
<file>ui/qml/Pages/Protocols/PageProtoCloak.qml</file>
<file>ui/qml/Pages/Protocols/PageProtoOpenVPN.qml</file>
<file>ui/qml/Pages/Protocols/PageProtoShadowSocks.qml</file>
<file>ui/qml/Pages/Protocols/PageProtoSftp.qml</file>
<file>ui/qml/Pages/Protocols/PageProtoTorWebSite.qml</file>
<file>ui/qml/Pages/Protocols/PageProtocolBase.qml</file>
<file>ui/qml/Pages/Protocols/PageProtoWireGuard.qml</file>
<file>ui/qml/Pages/InstallSettings/InstallSettingsBase.qml</file>
<file>ui/qml/Pages/InstallSettings/SelectContainer.qml</file>
<file>ui/qml/Pages/Share/PageShareProtoCloak.qml</file>
<file>ui/qml/Pages/Share/PageShareProtocolBase.qml</file>
<file>ui/qml/Pages/Share/PageShareProtoOpenVPN.qml</file>
<file>ui/qml/Pages/Share/PageShareProtoSftp.qml</file>
<file>ui/qml/Pages/Share/PageShareProtoShadowSocks.qml</file>
<file>ui/qml/Pages/Share/PageShareProtoTorWebSite.qml</file>
<file>ui/qml/Pages/Share/PageShareProtoAmnezia.qml</file>
<file>ui/qml/Pages/Share/PageShareProtoWireGuard.qml</file>
<file>ui/qml/Pages/Share/PageShareProtoIkev2.qml</file>
<file>ui/qml/Controls/BasicButtonType.qml</file> <file>ui/qml/Controls/BasicButtonType.qml</file>
<file>ui/qml/Controls/BlueButtonType.qml</file> <file>ui/qml/Controls/BlueButtonType.qml</file>
<file>ui/qml/Controls/CheckBoxType.qml</file> <file>ui/qml/Controls/CheckBoxType.qml</file>
@ -92,57 +115,40 @@
<file>ui/qml/Controls/ShareConnectionButtonType.qml</file> <file>ui/qml/Controls/ShareConnectionButtonType.qml</file>
<file>ui/qml/Controls/ShareConnectionContent.qml</file> <file>ui/qml/Controls/ShareConnectionContent.qml</file>
<file>ui/qml/Controls/TextFieldType.qml</file> <file>ui/qml/Controls/TextFieldType.qml</file>
<file>ui/qml/Pages/PageBase.qml</file> <file>ui/qml/Controls/RichLabelType.qml</file>
<file>ui/qml/Config/GlobalConfig.qml</file> <file>ui/qml/Controls/SvgImageType.qml</file>
<file>ui/qml/Config/qmldir</file> <file>ui/qml/Controls/FlickableType.qml</file>
<file>images/background_connected.png</file> <file>ui/qml/Controls/UrlButtonType.qml</file>
<file>images/background_connected@2x.png</file> <file>ui/qml/Controls/TextAreaType.qml</file>
<file>ui/qml/Pages/Protocols/PageProtoCloak.qml</file> <file>ui/qml/Controls/ContextMenu.qml</file>
<file>ui/qml/Pages/Protocols/PageProtoOpenVPN.qml</file>
<file>ui/qml/Pages/Protocols/PageProtoShadowSocks.qml</file>
<file>ui/qml/Controls/BackButton.qml</file>
<file>ui/qml/Pages/InstallSettings/InstallSettingsBase.qml</file>
<file>ui/qml/Controls/Caption.qml</file>
<file>ui/qml/Controls/Logo.qml</file>
<file>ui/qml/Pages/InstallSettings/SelectContainer.qml</file>
<file>ui/qml/Pages/Protocols/PageProtocolBase.qml</file>
<file>images/delete.png</file>
<file>ui/qml/Controls/FadeBehavior.qml</file> <file>ui/qml/Controls/FadeBehavior.qml</file>
<file>ui/qml/Controls/VisibleBehavior.qml</file> <file>ui/qml/Controls/VisibleBehavior.qml</file>
<file>ui/qml/Controls/Caption.qml</file>
<file>ui/qml/Controls/Logo.qml</file>
<file>ui/qml/Controls/BackButton.qml</file>
<file>ui/qml/Controls/ShareConnectionButtonCopyType.qml</file>
<file>ui/qml/Controls/SvgButtonType.qml</file>
<file>ui/qml/Config/GlobalConfig.qml</file>
<file>ui/qml/Config/qmldir</file>
<file>server_scripts/dns/configure_container.sh</file> <file>server_scripts/dns/configure_container.sh</file>
<file>server_scripts/dns/Dockerfile</file> <file>server_scripts/dns/Dockerfile</file>
<file>server_scripts/dns/run_container.sh</file> <file>server_scripts/dns/run_container.sh</file>
<file>server_scripts/sftp/configure_container.sh</file> <file>server_scripts/sftp/configure_container.sh</file>
<file>server_scripts/sftp/Dockerfile</file> <file>server_scripts/sftp/Dockerfile</file>
<file>server_scripts/sftp/run_container.sh</file> <file>server_scripts/sftp/run_container.sh</file>
<file>ui/qml/Pages/Protocols/PageProtoSftp.qml</file>
<file>ui/qml/Pages/Protocols/PageProtoTorWebSite.qml</file>
<file>server_scripts/ipsec/configure_container.sh</file> <file>server_scripts/ipsec/configure_container.sh</file>
<file>server_scripts/ipsec/Dockerfile</file> <file>server_scripts/ipsec/Dockerfile</file>
<file>server_scripts/ipsec/run_container.sh</file> <file>server_scripts/ipsec/run_container.sh</file>
<file>server_scripts/ipsec/start.sh</file> <file>server_scripts/ipsec/start.sh</file>
<file>ui/qml/Pages/Share/PageShareProtoCloak.qml</file>
<file>ui/qml/Pages/Share/PageShareProtocolBase.qml</file>
<file>ui/qml/Pages/Share/PageShareProtoOpenVPN.qml</file>
<file>ui/qml/Pages/Share/PageShareProtoSftp.qml</file>
<file>ui/qml/Pages/Share/PageShareProtoShadowSocks.qml</file>
<file>ui/qml/Pages/Share/PageShareProtoTorWebSite.qml</file>
<file>ui/qml/Controls/TextAreaType.qml</file>
<file>ui/qml/Controls/ContextMenu.qml</file>
<file>ui/qml/Pages/Share/PageShareProtoAmnezia.qml</file>
<file>ui/qml/Controls/ShareConnectionButtonCopyType.qml</file>
<file>ui/qml/Pages/Share/PageShareProtoWireGuard.qml</file>
<file>server_scripts/ipsec/mobileconfig.plist</file> <file>server_scripts/ipsec/mobileconfig.plist</file>
<file>ui/qml/Pages/Share/PageShareProtoIkev2.qml</file>
<file>server_scripts/ipsec/strongswan.profile</file> <file>server_scripts/ipsec/strongswan.profile</file>
<file>images/background_connected.png</file>
<file>images/background_connected@2x.png</file>
<file>images/delete.png</file>
<file>images/animation.gif</file> <file>images/animation.gif</file>
<file>images/connected.png</file> <file>images/connected.png</file>
<file>images/disconnected.png</file> <file>images/disconnected.png</file>
<file>ui/qml/Pages/PageQrDecoder.qml</file>
<file>ui/qml/Pages/PageAbout.qml</file>
<file>ui/qml/Controls/RichLabelType.qml</file>
<file>images/svg/gpp_good_black_24dp.svg</file> <file>images/svg/gpp_good_black_24dp.svg</file>
<file>ui/qml/Controls/SvgImageType.qml</file>
<file>images/svg/gpp_maybe_black_24dp.svg</file> <file>images/svg/gpp_maybe_black_24dp.svg</file>
<file>images/svg/close_black_24dp.svg</file> <file>images/svg/close_black_24dp.svg</file>
<file>images/svg/delete_black_24dp.svg</file> <file>images/svg/delete_black_24dp.svg</file>
@ -156,9 +162,6 @@
<file>images/svg/vpn_key_black_24dp.svg</file> <file>images/svg/vpn_key_black_24dp.svg</file>
<file>images/svg/control_point_black_24dp.svg</file> <file>images/svg/control_point_black_24dp.svg</file>
<file>images/svg/settings_suggest_black_24dp.svg</file> <file>images/svg/settings_suggest_black_24dp.svg</file>
<file>ui/qml/Controls/SvgButtonType.qml</file>
<file>ui/qml/Pages/PageQrDecoderIos.qml</file>
<file>server_scripts/website_tor/Dockerfile</file> <file>server_scripts/website_tor/Dockerfile</file>
<file>ui/qml/Pages/PageViewConfig.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -29,6 +29,7 @@ void ServerContainersLogic::onUpdatePage()
ProtocolsModel *p_model = qobject_cast<ProtocolsModel *>(uiLogic()->protocolsModel()); ProtocolsModel *p_model = qobject_cast<ProtocolsModel *>(uiLogic()->protocolsModel());
p_model->setSelectedServerIndex(uiLogic()->selectedServerIndex); p_model->setSelectedServerIndex(uiLogic()->selectedServerIndex);
set_isManagedServer(m_settings->haveAuthData(uiLogic()->selectedServerIndex));
emit updatePage(); emit updatePage();
} }

View file

@ -19,6 +19,8 @@ public:
Q_INVOKABLE void onPushButtonRemoveClicked(DockerContainer c); Q_INVOKABLE void onPushButtonRemoveClicked(DockerContainer c);
Q_INVOKABLE void onPushButtonContinueClicked(DockerContainer c, int port, TransportProto tp); Q_INVOKABLE void onPushButtonContinueClicked(DockerContainer c, int port, TransportProto tp);
AUTO_PROPERTY(bool, isManagedServer)
public: public:
explicit ServerContainersLogic(UiLogic *uiLogic, QObject *parent = nullptr); explicit ServerContainersLogic(UiLogic *uiLogic, QObject *parent = nullptr);
~ServerContainersLogic() = default; ~ServerContainersLogic() = default;

View file

@ -37,11 +37,17 @@ void ServerSettingsLogic::onUpdatePage()
set_pushButtonShareFullVisible(m_settings->haveAuthData(uiLogic()->selectedServerIndex)); set_pushButtonShareFullVisible(m_settings->haveAuthData(uiLogic()->selectedServerIndex));
const QJsonObject &server = m_settings->server(uiLogic()->selectedServerIndex); const QJsonObject &server = m_settings->server(uiLogic()->selectedServerIndex);
const QString &port = server.value(config_key::port).toString(); const QString &port = server.value(config_key::port).toString();
set_labelServerText(QString("%1@%2%3%4")
.arg(server.value(config_key::userName).toString()) const QString &userName = server.value(config_key::userName).toString();
.arg(server.value(config_key::hostName).toString()) const QString &hostName = server.value(config_key::hostName).toString();
.arg(port.isEmpty() ? "" : ":") QString name = QString("%1%2%3%4%5")
.arg(port)); .arg(userName)
.arg(userName.isEmpty() ? "" : "@")
.arg(hostName)
.arg(port.isEmpty() ? "" : ":")
.arg(port);
set_labelServerText(name);
set_lineEditDescriptionText(server.value(config_key::description).toString()); set_lineEditDescriptionText(server.value(config_key::description).toString());
DockerContainer selectedContainer = m_settings->defaultContainer(uiLogic()->selectedServerIndex); DockerContainer selectedContainer = m_settings->defaultContainer(uiLogic()->selectedServerIndex);

View file

@ -15,6 +15,36 @@
#include "platforms/android/android_controller.h" #include "platforms/android/android_controller.h"
#endif #endif
namespace {
enum class ConfigTypes {
Amnezia,
OpenVpn,
WireGuard
};
ConfigTypes checkConfigFormat(const QString &config)
{
const QString openVpnConfigPatternCli = "client";
const QString openVpnConfigPatternProto1 = "proto tcp";
const QString openVpnConfigPatternProto2 = "proto udp";
const QString openVpnConfigPatternDriver1 = "dev tun";
const QString openVpnConfigPatternDriver2 = "dev tap";
const QString wireguardConfigPatternSectionInterface = "[Interface]";
const QString wireguardConfigPatternSectionPeer = "[Peer]";
if (config.contains(openVpnConfigPatternCli) &&
(config.contains(openVpnConfigPatternProto1) || config.contains(openVpnConfigPatternProto2)) &&
(config.contains(openVpnConfigPatternDriver1) || config.contains(openVpnConfigPatternDriver2))) {
return ConfigTypes::OpenVpn;
} else if (config.contains(wireguardConfigPatternSectionInterface) &&
config.contains(wireguardConfigPatternSectionPeer))
return ConfigTypes::WireGuard;
return ConfigTypes::Amnezia;
}
}
StartPageLogic::StartPageLogic(UiLogic *logic, QObject *parent): StartPageLogic::StartPageLogic(UiLogic *logic, QObject *parent):
PageLogicBase(logic, parent), PageLogicBase(logic, parent),
m_pushButtonConnectEnabled{true}, m_pushButtonConnectEnabled{true},
@ -135,15 +165,22 @@ void StartPageLogic::onPushButtonImport()
void StartPageLogic::onPushButtonImportOpenFile() void StartPageLogic::onPushButtonImportOpenFile()
{ {
QString fileName = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Open profile"), QString fileName = QFileDialog::getOpenFileName(Q_NULLPTR, tr("Open config file"),
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), tr("*.vpn")); QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*.vpn *.ovpn *.conf");
if (fileName.isEmpty()) return; if (fileName.isEmpty()) return;
QFile file(fileName); QFile file(fileName);
file.open(QIODevice::ReadOnly); file.open(QIODevice::ReadOnly);
QByteArray data = file.readAll(); QByteArray data = file.readAll();
importConnectionFromCode(QString(data)); auto configFormat = checkConfigFormat(QString(data));
if (configFormat == ConfigTypes::OpenVpn) {
importConnectionFromOpenVpnConfig(QString(data));
} else if (configFormat == ConfigTypes::WireGuard) {
importConnectionFromWireguardConfig(QString(data));
} else {
importConnectionFromCode(QString(data));
}
} }
bool StartPageLogic::importConnection(const QJsonObject &profile) bool StartPageLogic::importConnection(const QJsonObject &profile)
@ -201,3 +238,90 @@ bool StartPageLogic::importConnectionFromQr(const QByteArray &data)
return false; return false;
} }
bool StartPageLogic::importConnectionFromOpenVpnConfig(const QString &config)
{
QJsonObject openVpnConfig;
openVpnConfig[config_key::config] = config;
QJsonObject lastConfig;
lastConfig[config_key::last_config] = QString(QJsonDocument(openVpnConfig).toJson());
lastConfig[config_key::isThirdPartyConfig] = true;
QJsonObject containers;
containers.insert(config_key::container, QJsonValue("amnezia-openvpn"));
containers.insert(config_key::openvpn, QJsonValue(lastConfig));
QJsonArray arr;
arr.push_back(containers);
QString hostName;
const static QRegularExpression hostNameRegExp("remote (.*) [0-9]*");
QRegularExpressionMatch hostNameMatch = hostNameRegExp.match(config);
if (hostNameMatch.hasMatch()) {
hostName = hostNameMatch.captured(1);
}
QJsonObject o;
o[config_key::containers] = arr;
o[config_key::defaultContainer] = "amnezia-openvpn";
o[config_key::description] = m_settings->nextAvailableServerName();
const static QRegularExpression dnsRegExp("dhcp-option DNS (\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b)");
QRegularExpressionMatchIterator dnsMatch = dnsRegExp.globalMatch(config);
if (dnsMatch.hasNext()) {
o[config_key::dns1] = dnsMatch.next().captured(1);
}
if (dnsMatch.hasNext()) {
o[config_key::dns2] = dnsMatch.next().captured(1);
}
o[config_key::hostName] = hostName;
return importConnection(o);
}
bool StartPageLogic::importConnectionFromWireguardConfig(const QString &config)
{
QJsonObject lastConfig;
lastConfig[config_key::config] = config;
const static QRegularExpression hostNameAndPortRegExp("Endpoint = (.*):([0-9]*)");
QRegularExpressionMatch hostNameAndPortMatch = hostNameAndPortRegExp.match(config);
QString hostName;
QString port;
if (hostNameAndPortMatch.hasMatch()) {
hostName = hostNameAndPortMatch.captured(1);
port = hostNameAndPortMatch.captured(2);
}
QJsonObject wireguardConfig;
wireguardConfig[config_key::last_config] = QString(QJsonDocument(lastConfig).toJson());
wireguardConfig[config_key::isThirdPartyConfig] = true;
wireguardConfig[config_key::port] = port;
wireguardConfig[config_key::transport_proto] = "udp";
QJsonObject containers;
containers.insert(config_key::container, QJsonValue("amnezia-wireguard"));
containers.insert(config_key::wireguard, QJsonValue(wireguardConfig));
QJsonArray arr;
arr.push_back(containers);
QJsonObject o;
o[config_key::containers] = arr;
o[config_key::defaultContainer] = "amnezia-wireguard";
o[config_key::description] = m_settings->nextAvailableServerName();
const static QRegularExpression dnsRegExp("DNS = (\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b).*(\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b)");
QRegularExpressionMatch dnsMatch = dnsRegExp.match(config);
if (dnsMatch.hasMatch()) {
o[config_key::dns1] = dnsMatch.captured(1);
o[config_key::dns2] = dnsMatch.captured(2);
}
o[config_key::hostName] = hostName;
return importConnection(o);
}

View file

@ -34,6 +34,8 @@ public:
bool importConnection(const QJsonObject &profile); bool importConnection(const QJsonObject &profile);
bool importConnectionFromCode(QString code); bool importConnectionFromCode(QString code);
bool importConnectionFromQr(const QByteArray &data); bool importConnectionFromQr(const QByteArray &data);
bool importConnectionFromOpenVpnConfig(const QString &config);
bool importConnectionFromWireguardConfig(const QString &config);
public: public:
explicit StartPageLogic(UiLogic *uiLogic, QObject *parent = nullptr); explicit StartPageLogic(UiLogic *uiLogic, QObject *parent = nullptr);

View file

@ -13,6 +13,8 @@ void ViewConfigLogic::onUpdatePage()
{ {
set_configText(QJsonDocument(configJson()).toJson()); set_configText(QJsonDocument(configJson()).toJson());
auto s = configJson()[config_key::isThirdPartyConfig].toBool();
m_openVpnLastConfigs = m_openVpnMalStrings = m_openVpnLastConfigs = m_openVpnMalStrings =
"<style> \ "<style> \
div { line-height: 0.5; } \ div { line-height: 0.5; } \
@ -24,28 +26,42 @@ void ViewConfigLogic::onUpdatePage()
const QJsonArray &containers = configJson()[config_key::containers].toArray(); const QJsonArray &containers = configJson()[config_key::containers].toArray();
int i = 0; int i = 0;
for (const QJsonValue &v: containers) { for (const QJsonValue &v: containers) {
QString cfg_json = v.toObject()[ProtocolProps::protoToString(Proto::OpenVpn)] auto containerName = v.toObject()[config_key::container].toString();
.toObject()[config_key::last_config].toString(); QJsonObject containerConfig = v.toObject()[containerName.replace("amnezia-", "")].toObject();
if (containerConfig[config_key::isThirdPartyConfig].toBool()) {
QString openvpn_cfg = QJsonDocument::fromJson(cfg_json.toUtf8()).object()[config_key::config] auto lastConfig = containerConfig.value(config_key::last_config).toString();
.toString(); auto lastConfigJson = QJsonDocument::fromJson(lastConfig.toUtf8()).object();
QStringList lines = lastConfigJson.value(config_key::config).toString().replace("\r", "").split("\n");
openvpn_cfg.replace("\r", ""); QString lastConfigText;
for (const QString &l: lines) {
QStringList lines = openvpn_cfg.split("\n"); lastConfigText.append(l + "\n");
for (const QString &l: lines) {
i++;
QRegularExpressionMatch match = m_re.match(l);
if (dangerousTags.contains(match.captured(0))) {
QString t = QString("<p><font color=\"red\">%1</font>").arg(l);
m_openVpnLastConfigs.append(t + "\n");
m_openVpnMalStrings.append(t);
if (m_warningStringNumber == 3) m_warningStringNumber = i - 3;
m_warningActive = true;
qDebug() << "ViewConfigLogic : malicious scripts warning:" << l;
} }
else { set_configText(lastConfigText);
m_openVpnLastConfigs.append("<p>" + l + "&nbsp;\n"); }
if (v.toObject()[config_key::container].toString() == "amnezia-openvpn") {
QString lastConfig = v.toObject()[ProtocolProps::protoToString(Proto::OpenVpn)]
.toObject()[config_key::last_config].toString();
QString lastConfigJson = QJsonDocument::fromJson(lastConfig.toUtf8()).object()[config_key::config]
.toString();
QStringList lines = lastConfigJson.replace("\r", "").split("\n");
for (const QString &l: lines) {
i++;
QRegularExpressionMatch match = m_re.match(l);
if (dangerousTags.contains(match.captured(0))) {
QString t = QString("<p><font color=\"red\">%1</font>").arg(l);
m_openVpnLastConfigs.append(t + "\n");
m_openVpnMalStrings.append(t);
if (m_warningStringNumber == 3) m_warningStringNumber = i - 3;
m_warningActive = true;
qDebug() << "ViewConfigLogic : malicious scripts warning:" << l;
}
else {
m_openVpnLastConfigs.append("<p>" + l + "&nbsp;\n");
}
} }
} }
} }

View file

@ -28,7 +28,7 @@ public:
explicit CloakLogic(UiLogic *uiLogic, QObject *parent = nullptr); explicit CloakLogic(UiLogic *uiLogic, QObject *parent = nullptr);
~CloakLogic() = default; ~CloakLogic() = default;
void updateProtocolPage (const QJsonObject &ckConfig, DockerContainer container, bool haveAuthData) override; void updateProtocolPage(const QJsonObject &ckConfig, DockerContainer container, bool haveAuthData) override;
QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) override; QJsonObject getProtocolConfigFromPage(QJsonObject oldConfig) override;
private: private:

View file

@ -87,6 +87,17 @@ void OpenVpnLogic::updateProtocolPage(const QJsonObject &openvpnConfig, DockerCo
toString(protocols::openvpn::defaultPort)); toString(protocols::openvpn::defaultPort));
set_lineEditPortEnabled(container == DockerContainer::OpenVpn); set_lineEditPortEnabled(container == DockerContainer::OpenVpn);
auto lastConfig = openvpnConfig.value(config_key::last_config).toString();
auto lastConfigJson = QJsonDocument::fromJson(lastConfig.toUtf8()).object();
QStringList lines = lastConfigJson.value(config_key::config).toString().replace("\r", "").split("\n");
QString openVpnLastConfigText;
for (const QString &l: lines) {
openVpnLastConfigText.append(l + "\n");
}
set_openVpnLastConfigText(openVpnLastConfigText);
set_isThirdPartyConfig(openvpnConfig.value(config_key::isThirdPartyConfig).isBool());
} }
void OpenVpnLogic::onPushButtonProtoOpenVpnSaveClicked() void OpenVpnLogic::onPushButtonProtoOpenVpnSaveClicked()

View file

@ -35,6 +35,9 @@ class OpenVpnLogic : public PageProtocolLogicBase
AUTO_PROPERTY(int, progressBarResetValue) AUTO_PROPERTY(int, progressBarResetValue)
AUTO_PROPERTY(int, progressBarResetMaximium) AUTO_PROPERTY(int, progressBarResetMaximium)
AUTO_PROPERTY(QString, openVpnLastConfigText)
AUTO_PROPERTY(bool, isThirdPartyConfig)
public: public:
Q_INVOKABLE void onPushButtonProtoOpenVpnSaveClicked(); Q_INVOKABLE void onPushButtonProtoOpenVpnSaveClicked();

View file

@ -0,0 +1,30 @@
#include "WireGuardLogic.h"
#include "core/servercontroller.h"
#include <functional>
#include "../../uilogic.h"
using namespace amnezia;
using namespace PageEnumNS;
WireGuardLogic::WireGuardLogic(UiLogic *logic, QObject *parent):
PageProtocolLogicBase(logic, parent)
{
}
void WireGuardLogic::updateProtocolPage(const QJsonObject &wireGuardConfig, DockerContainer container, bool haveAuthData)
{
qDebug() << "WireGuardLogic::updateProtocolPage";
auto lastConfigJsonDoc = QJsonDocument::fromJson(wireGuardConfig.value(config_key::last_config).toString().toUtf8());
auto lastConfigJson = lastConfigJsonDoc.object();
QString wireGuardLastConfigText;
QStringList lines = lastConfigJson.value(config_key::config).toString().replace("\r", "").split("\n");
for (const QString &l: lines) {
wireGuardLastConfigText.append(l + "\n");
}
set_wireGuardLastConfigText(wireGuardLastConfigText);
set_isThirdPartyConfig(wireGuardConfig.value(config_key::isThirdPartyConfig).toBool());
}

View file

@ -0,0 +1,26 @@
#ifndef WIREGUARDLOGIC_H
#define WIREGUARDLOGIC_H
#include "PageProtocolLogicBase.h"
class UiLogic;
class WireGuardLogic : public PageProtocolLogicBase
{
Q_OBJECT
AUTO_PROPERTY(QString, wireGuardLastConfigText)
AUTO_PROPERTY(bool, isThirdPartyConfig)
public:
explicit WireGuardLogic(UiLogic *uiLogic, QObject *parent = nullptr);
~WireGuardLogic() = default;
void updateProtocolPage(const QJsonObject &wireGuardConfig, DockerContainer container, bool haveAuthData) override;
private:
UiLogic *m_uiLogic;
};
#endif // WIREGUARDLOGIC_H

View file

@ -8,6 +8,8 @@ Item {
readonly property int screenWidth: 380 readonly property int screenWidth: 380
readonly property int screenHeight: 640 readonly property int screenHeight: 640
readonly property int defaultMargin: 20
function isMobile() { function isMobile() {
if (Qt.platform.os == "android" || if (Qt.platform.os == "android" ||
Qt.platform.os == "ios") { Qt.platform.os == "ios") {

View file

@ -1,11 +1,12 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import "../Config"
BasicButtonType { BasicButtonType {
id: root id: root
width: parent.width - 80 width: parent.width - 2 * GC.defaultMargin
height: 40 implicitHeight: 40
background: Rectangle { background: Rectangle {
anchors.fill: parent anchors.fill: parent

View file

@ -0,0 +1,26 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import "../Config"
Flickable {
id: fl
clip: true
width: parent.width
anchors.topMargin: GC.defaultMargin
anchors.bottom: parent.bottom
anchors.bottomMargin: GC.defaultMargin
anchors.left: root.left
anchors.leftMargin: GC.defaultMargin
anchors.right: root.right
anchors.rightMargin: 1
Keys.onUpPressed: scrollBar.decrease()
Keys.onDownPressed: scrollBar.increase()
ScrollBar.vertical: ScrollBar {
id: scrollBar
policy: fl.height >= fl.contentHeight ? ScrollBar.AlwaysOff : ScrollBar.AlwaysOn
}
}

View file

@ -1,9 +1,9 @@
import QtQuick import QtQuick
import "../Config"
Text { Text {
id: root id: root
x: 40 width: parent.width - 2 * GC.defaultMargin
width: parent.width
anchors.topMargin: 10 anchors.topMargin: 10
font.family: "Lato" font.family: "Lato"

View file

@ -1,19 +1,20 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import Qt.labs.platform import Qt.labs.platform
import "../Config"
TextField { TextField {
id: root id: root
property bool error: false property bool error: false
width: parent.width - 80 width: parent.width - 2 * GC.defaultMargin
height: 40 height: 40
anchors.topMargin: 5 anchors.topMargin: 5
selectByMouse: true selectByMouse: true
selectionColor: "darkgray" selectionColor: "darkgray"
font.pixelSize: 16 font.pixelSize: 16
color: "#333333" color: "#333333"
background: Rectangle { background: Rectangle {
implicitWidth: 200 implicitWidth: 200
implicitHeight: 40 implicitHeight: 40

View file

@ -0,0 +1,25 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
BasicButtonType {
property alias label: lbl
id: root
antialiasing: true
height: 21
background: Item {}
contentItem: Text {
id: lbl
anchors.fill: parent
font.family: "Lato"
font.styleName: "normal"
font.pixelSize: 18
font.underline: true
text: root.text
color: "#3045ee"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
}

View file

@ -48,8 +48,7 @@ Drawer {
} }
Flickable { FlickableType {
clip: true
anchors.fill: parent anchors.fill: parent
contentHeight: col.height contentHeight: col.height

View file

@ -19,20 +19,11 @@ PageBase {
text: qsTr("Application Settings") text: qsTr("Application Settings")
} }
Flickable { FlickableType {
id: fl id: fl
width: root.width
anchors.top: caption.bottom anchors.top: caption.bottom
anchors.topMargin: 20
anchors.bottom: logo.top anchors.bottom: logo.top
anchors.bottomMargin: 20
anchors.left: root.left
anchors.leftMargin: 30
anchors.right: root.right
anchors.rightMargin: 30
contentHeight: content.height contentHeight: content.height
clip: true
ColumnLayout { ColumnLayout {
id: content id: content
@ -40,6 +31,7 @@ PageBase {
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 15
CheckBoxType { CheckBoxType {
visible: !GC.isMobile() visible: !GC.isMobile()
@ -79,7 +71,6 @@ PageBase {
BlueButtonType { BlueButtonType {
visible: !GC.isMobile() visible: !GC.isMobile()
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 41
text: qsTr("Check for updates") text: qsTr("Check for updates")
onClicked: { onClicked: {
Qt.openUrlExternally("https://github.com/amnezia-vpn/desktop-client/releases/latest") Qt.openUrlExternally("https://github.com/amnezia-vpn/desktop-client/releases/latest")
@ -98,7 +89,6 @@ PageBase {
} }
BlueButtonType { BlueButtonType {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 41
text: qsTr("Open logs folder") text: qsTr("Open logs folder")
onClicked: { onClicked: {
AppSettingsLogic.onPushButtonOpenLogsClicked() AppSettingsLogic.onPushButtonOpenLogsClicked()
@ -108,7 +98,6 @@ PageBase {
BlueButtonType { BlueButtonType {
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 10 Layout.topMargin: 10
Layout.preferredHeight: 41
text: qsTr("Export logs") text: qsTr("Export logs")
onClicked: { onClicked: {
AppSettingsLogic.onPushButtonExportLogsClicked() AppSettingsLogic.onPushButtonExportLogsClicked()
@ -118,7 +107,6 @@ PageBase {
BlueButtonType { BlueButtonType {
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 10 Layout.topMargin: 10
Layout.preferredHeight: 41
property string start_text: qsTr("Clear logs") property string start_text: qsTr("Clear logs")
property string end_text: qsTr("Cleared") property string end_text: qsTr("Cleared")

View file

@ -17,8 +17,4 @@ Item {
onActivated: pageActive = true onActivated: pageActive = true
onDeactivated: pageActive = false onDeactivated: pageActive = false
// width: GC.screenWidth
// height: GC.screenHeight
} }

View file

@ -16,20 +16,12 @@ PageBase {
z: -1 z: -1
} }
Flickable { FlickableType {
id: fl id: fl
width: root.width
anchors.top: back.bottom anchors.top: back.bottom
anchors.topMargin: 0 anchors.topMargin: 0
anchors.bottom: root.bottom
anchors.bottomMargin: 10 anchors.bottomMargin: 10
anchors.left: root.left
anchors.leftMargin: 30
anchors.right: root.right
anchors.rightMargin: 30
contentHeight: content.height contentHeight: content.height
clip: true
ColumnLayout { ColumnLayout {
id: content id: content
@ -38,6 +30,7 @@ PageBase {
anchors.topMargin: 10 anchors.topMargin: 10
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: GC.defaultMargin
spacing: 15 spacing: 15

View file

@ -1,5 +1,6 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts
import PageEnum 1.0 import PageEnum 1.0
import "./" import "./"
import "../Controls" import "../Controls"
@ -18,108 +19,95 @@ PageBase {
text: qsTr("DNS Servers") text: qsTr("DNS Servers")
} }
CheckBoxType { FlickableType {
id: cb_amnezia_dns id: fl
anchors.top: caption.bottom anchors.top: caption.bottom
x: 30 contentHeight: content.height
width: parent.width - 60
text: qsTr("Use AmneziaDNS service (recommended)")
checked: NetworkSettingsLogic.checkBoxUseAmneziaDnsChecked
onCheckedChanged: {
NetworkSettingsLogic.checkBoxUseAmneziaDnsChecked = checked
NetworkSettingsLogic.onCheckBoxUseAmneziaDnsToggled(checked)
UiLogic.onUpdateAllPages()
}
}
LabelType { ColumnLayout {
id: lb_amnezia_dns id: content
x: 30 enabled: logic.pageEnabled
anchors.top: cb_amnezia_dns.bottom anchors.top: parent.top
width: parent.width - 60 anchors.left: parent.left
text: qsTr("Use AmneziaDNS container on your server, when it installed.\n anchors.right: parent.right
anchors.rightMargin: 15
CheckBoxType {
Layout.preferredWidth: parent.width
text: qsTr("Use AmneziaDNS service (recommended)")
checked: NetworkSettingsLogic.checkBoxUseAmneziaDnsChecked
onCheckedChanged: {
NetworkSettingsLogic.checkBoxUseAmneziaDnsChecked = checked
NetworkSettingsLogic.onCheckBoxUseAmneziaDnsToggled(checked)
UiLogic.onUpdateAllPages()
}
}
LabelType {
Layout.preferredWidth: parent.width
text: qsTr("Use AmneziaDNS container on your server, when it installed.\n
Your AmneziaDNS server available only when it installed and VPN connected, it has internal IP address 172.29.172.254\n Your AmneziaDNS server available only when it installed and VPN connected, it has internal IP address 172.29.172.254\n
If AmneziaDNS service is not installed on the same server, or this option is unchecked, the following DNS servers will be used:") If AmneziaDNS service is not installed on the same server, or this option is unchecked, the following DNS servers will be used:")
} }
LabelType { LabelType {
id: l1 Layout.topMargin: 15
x: 30 text: qsTr("Primary DNS server")
anchors.top: lb_amnezia_dns.bottom }
width: parent.width - 30 TextFieldType {
height: 21 height: 40
text: qsTr("Primary DNS server") implicitWidth: parent.width
} text: NetworkSettingsLogic.lineEditDns1Text
TextFieldType { onEditingFinished: {
id: dns1 NetworkSettingsLogic.lineEditDns1Text = text
x: 30 NetworkSettingsLogic.onLineEditDns1EditFinished(text)
anchors.top: l1.bottom UiLogic.onUpdateAllPages()
width: parent.width - 90 }
height: 40 validator: RegularExpressionValidator {
text: NetworkSettingsLogic.lineEditDns1Text regularExpression: NetworkSettingsLogic.ipAddressRegex
onEditingFinished: { }
NetworkSettingsLogic.lineEditDns1Text = text }
NetworkSettingsLogic.onLineEditDns1EditFinished(text)
UiLogic.onUpdateAllPages()
}
validator: RegularExpressionValidator {
regularExpression: NetworkSettingsLogic.ipAddressRegex
}
}
SvgButtonType {
id: resetDNS1
anchors. left: dns1.right
anchors.leftMargin: 10
anchors.verticalCenter: dns1.verticalCenter
width: 24
height: 24
icon.source: "qrc:/images/svg/refresh_black_24dp.svg"
onClicked: {
NetworkSettingsLogic.onPushButtonResetDns1Clicked()
UiLogic.onUpdateAllPages()
}
}
LabelType { UrlButtonType {
id: l2 text: qsTr("Reset to default")
x: 30 label.horizontalAlignment: Text.AlignLeft
anchors.top: dns1.bottom label.verticalAlignment: Text.AlignTop
anchors.topMargin: 20 label.font.pixelSize: 14
width: parent.width - 60 icon.source: "qrc:/images/svg/refresh_black_24dp.svg"
height: 21 onClicked: {
text: qsTr("Secondary DNS server") NetworkSettingsLogic.onPushButtonResetDns1Clicked()
} UiLogic.onUpdateAllPages()
TextFieldType { }
id: dns2 }
x: 30
anchors.top: l2.bottom
width: parent.width - 90
height: 40
text: NetworkSettingsLogic.lineEditDns2Text
onEditingFinished: {
NetworkSettingsLogic.lineEditDns2Text = text
NetworkSettingsLogic.onLineEditDns2EditFinished(text)
UiLogic.onUpdateAllPages()
}
validator: RegularExpressionValidator {
regularExpression: NetworkSettingsLogic.ipAddressRegex
}
}
SvgButtonType {
id: resetDNS2
anchors. left: dns2.right
anchors.leftMargin: 10
anchors.verticalCenter: dns2.verticalCenter
width: 24
height: 24
icon.source: "qrc:/images/svg/refresh_black_24dp.svg"
onClicked: {
NetworkSettingsLogic.onPushButtonResetDns2Clicked()
UiLogic.onUpdateAllPages()
}
}
Logo { LabelType {
anchors.bottom: parent.bottom text: qsTr("Secondary DNS server")
}
TextFieldType {
height: 40
implicitWidth: parent.width
text: NetworkSettingsLogic.lineEditDns2Text
onEditingFinished: {
NetworkSettingsLogic.lineEditDns2Text = text
NetworkSettingsLogic.onLineEditDns2EditFinished(text)
UiLogic.onUpdateAllPages()
}
validator: RegularExpressionValidator {
regularExpression: NetworkSettingsLogic.ipAddressRegex
}
}
UrlButtonType {
text: qsTr("Reset to default")
label.horizontalAlignment: Text.AlignLeft
label.verticalAlignment: Text.AlignTop
label.font.pixelSize: 14
icon.source: "qrc:/images/svg/refresh_black_24dp.svg"
onClicked: {
NetworkSettingsLogic.onPushButtonResetDns2Clicked()
UiLogic.onUpdateAllPages()
}
}
}
} }
} }

View file

@ -8,7 +8,6 @@ import "../Config"
PageBase { PageBase {
id: root id: root
page: PageEnum.NewServer page: PageEnum.NewServer
//logic: {}
BackButton { BackButton {
id: back_from_new_server id: back_from_new_server
@ -22,15 +21,15 @@ PageBase {
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
text: qsTr("If you want easily configure your server just run Wizard") text: qsTr("If you want easily configure your server just run Wizard")
width: parent.width - 80 anchors.horizontalCenter: parent.horizontalCenter
anchors.top: caption.bottom anchors.top: caption.bottom
anchors.topMargin: 30 anchors.topMargin: 30
} }
BlueButtonType { BlueButtonType {
id: pushButtonWizard id: pushButtonWizard
text: qsTr("Run Setup Wizard") text: qsTr("Run Setup Wizard")
anchors.top: labelWizard.bottom
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.top: labelWizard.bottom
anchors.topMargin: 10 anchors.topMargin: 10
onClicked: { onClicked: {
UiLogic.goToPage(PageEnum.Wizard); UiLogic.goToPage(PageEnum.Wizard);
@ -41,14 +40,13 @@ PageBase {
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
text: qsTr("Press configure manually to choose VPN protocols you want to install") text: qsTr("Press configure manually to choose VPN protocols you want to install")
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width - 80
anchors.top: pushButtonWizard.bottom anchors.top: pushButtonWizard.bottom
anchors.topMargin: 40 anchors.topMargin: 40
} }
BlueButtonType { BlueButtonType {
text: qsTr("Configure VPN protocols manually") text: qsTr("Configure")
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.top: labelManual.bottom anchors.top: labelManual.bottom
anchors.topMargin: 10 anchors.topMargin: 10

View file

@ -32,6 +32,7 @@ PageBase {
BackButton { BackButton {
id: back id: back
onClicked: tb_c.currentIndex = -1
} }
Caption { Caption {
id: caption id: caption
@ -174,11 +175,7 @@ PageBase {
} }
} }
FlickableType {
Flickable {
visible: container_selector.selectedIndex <= 0 visible: container_selector.selectedIndex <= 0
clip: true clip: true
width: parent.width width: parent.width
@ -224,7 +221,6 @@ PageBase {
ListView { ListView {
id: tb_c id: tb_c
x: 10
width: parent.width - 10 width: parent.width - 10
height: tb_c.contentItem.height height: tb_c.contentItem.height
currentIndex: -1 currentIndex: -1
@ -293,7 +289,7 @@ PageBase {
ImageButtonType { ImageButtonType {
id: button_remove id: button_remove
visible: index === tb_c.currentIndex visible: (index === tb_c.currentIndex) && ServerContainersLogic.isManagedServer
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
checkable: true checkable: true
icon.source: "qrc:/images/delete.png" icon.source: "qrc:/images/delete.png"
@ -320,7 +316,7 @@ PageBase {
ImageButtonType { ImageButtonType {
id: button_share id: button_share
visible: index === tb_c.currentIndex visible: (index === tb_c.currentIndex) && ServerContainersLogic.isManagedServer
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
icon.source: "qrc:/images/share.png" icon.source: "qrc:/images/share.png"
implicitWidth: 30 implicitWidth: 30
@ -431,7 +427,7 @@ PageBase {
width: parent.width - 40 width: parent.width - 40
height: 40 height: 40
text: qsTr("Install new protocols container") text: qsTr("Install new service")
font.pixelSize: 16 font.pixelSize: 16
onClicked: container_selector.visible ? container_selector.close() : container_selector.open() onClicked: container_selector.visible ? container_selector.close() : container_selector.open()

View file

@ -35,10 +35,10 @@ PageBase {
ListView { ListView {
id: listWidget_servers id: listWidget_servers
x: 20 x: GC.defaultMargin
anchors.top: caption.bottom anchors.top: caption.bottom
anchors.topMargin: 15 anchors.topMargin: 15
width: parent.width width: parent.width - GC.defaultMargin - 1
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.bottomMargin: 20 anchors.bottomMargin: 20
model: ServerListLogic.serverListModel model: ServerListLogic.serverListModel
@ -49,7 +49,7 @@ PageBase {
clip: true clip: true
delegate: Item { delegate: Item {
height: 60 height: 60
width: root.width - 40 width: listWidget_servers.width - 15
MouseArea { MouseArea {
id: ms id: ms
anchors.fill: parent anchors.fill: parent
@ -96,14 +96,14 @@ PageBase {
id: label_address id: label_address
x: 20 x: 20
y: 40 y: 40
width: 141 width: listWidget_servers.width - 100
height: 16 height: 16
text: address text: address
} }
Text { Text {
x: 10 x: 10
y: 10 y: 10
width: 181 width: listWidget_servers.width - 100
height: 21 height: 21
font.family: "Lato" font.family: "Lato"
font.styleName: "normal" font.styleName: "normal"
@ -177,5 +177,9 @@ PageBase {
} }
} }
} }
ScrollBar.vertical: ScrollBar {
policy: ScrollBar.AsNeeded
}
} }
} }

View file

@ -1,5 +1,6 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts
import PageEnum 1.0 import PageEnum 1.0
import "./" import "./"
import "../Controls" import "../Controls"
@ -16,113 +17,106 @@ PageBase {
id: back id: back
} }
Caption { Caption {
id: caption
text: qsTr("Server settings") text: qsTr("Server settings")
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
} }
LabelType {
anchors.horizontalCenter: parent.horizontalCenter FlickableType {
y: 150 id: fl
width: 341 anchors.top: caption.bottom
height: 31 anchors.bottom: logo.top
font.pixelSize: 20 contentHeight: content.height
horizontalAlignment: Text.AlignHCenter
text: ServerSettingsLogic.labelCurrentVpnProtocolText ColumnLayout {
} id: content
// LabelType { enabled: logic.pageEnabled
// anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top
// y: 120 anchors.left: parent.left
// width: 341 anchors.right: parent.right
// height: 31 anchors.rightMargin: 15
// font.pixelSize: 20
// horizontalAlignment: Text.AlignHCenter LabelType {
// text: ServerSettingsLogic.labelServerText Layout.fillWidth: true
// } font.pixelSize: 20
TextFieldType { horizontalAlignment: Text.AlignHCenter
anchors.horizontalCenter: parent.horizontalCenter text: ServerSettingsLogic.labelCurrentVpnProtocolText
y: 120 }
width: 341
height: 31 TextFieldType {
font.pixelSize: 20 Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter font.pixelSize: 20
text: ServerSettingsLogic.labelServerText horizontalAlignment: Text.AlignHCenter
readOnly: true text: ServerSettingsLogic.labelServerText
background: Item {} readOnly: true
background: Item {}
}
LabelType {
Layout.fillWidth: true
text: ServerSettingsLogic.labelWaitInfoText
visible: ServerSettingsLogic.labelWaitInfoVisible
}
TextFieldType {
Layout.fillWidth: true
text: ServerSettingsLogic.lineEditDescriptionText
onEditingFinished: {
ServerSettingsLogic.lineEditDescriptionText = text
ServerSettingsLogic.onLineEditDescriptionEditingFinished()
}
}
BlueButtonType {
text: qsTr("Protocols and Services")
Layout.topMargin: 20
Layout.fillWidth: true
onClicked: {
UiLogic.goToPage(PageEnum.ServerContainers)
}
}
BlueButtonType {
Layout.fillWidth: true
Layout.topMargin: 10
text: qsTr("Share Server (FULL ACCESS)")
visible: ServerSettingsLogic.pushButtonShareFullVisible
onClicked: {
ServerSettingsLogic.onPushButtonShareFullClicked()
}
}
BlueButtonType {
Layout.fillWidth: true
Layout.topMargin: 60
text: ServerSettingsLogic.pushButtonClearText
visible: ServerSettingsLogic.pushButtonClearVisible
onClicked: {
ServerSettingsLogic.onPushButtonClearServer()
}
}
BlueButtonType {
Layout.fillWidth: true
Layout.topMargin: 10
text: ServerSettingsLogic.pushButtonClearClientCacheText
visible: ServerSettingsLogic.pushButtonClearClientCacheVisible
onClicked: {
ServerSettingsLogic.onPushButtonClearClientCacheClicked()
}
}
BlueButtonType {
Layout.fillWidth: true
Layout.topMargin: 10
text: qsTr("Forget this server")
onClicked: {
ServerSettingsLogic.onPushButtonForgetServer()
}
}
}
} }
LabelType {
anchors.horizontalCenter: parent.horizontalCenter
y: 530
width: 301
height: 41
text: ServerSettingsLogic.labelWaitInfoText
visible: ServerSettingsLogic.labelWaitInfoVisible
}
TextFieldType {
anchors.horizontalCenter: parent.horizontalCenter
y: 80
width: 251
height: 31
text: ServerSettingsLogic.lineEditDescriptionText
onEditingFinished: {
ServerSettingsLogic.lineEditDescriptionText = text
ServerSettingsLogic.onLineEditDescriptionEditingFinished()
}
}
BlueButtonType {
anchors.horizontalCenter: parent.horizontalCenter
y: 410
width: parent.width - 40
height: 40
text: ServerSettingsLogic.pushButtonClearText
visible: ServerSettingsLogic.pushButtonClearVisible
onClicked: {
ServerSettingsLogic.onPushButtonClearServer()
}
}
BlueButtonType {
anchors.horizontalCenter: parent.horizontalCenter
y: 350
width: parent.width - 40
height: 40
text: ServerSettingsLogic.pushButtonClearClientCacheText
visible: ServerSettingsLogic.pushButtonClearClientCacheVisible
onClicked: {
ServerSettingsLogic.onPushButtonClearClientCacheClicked()
}
}
BlueButtonType {
anchors.horizontalCenter: parent.horizontalCenter
y: 470
width: parent.width - 40
height: 40
text: qsTr("Forget this server")
onClicked: {
ServerSettingsLogic.onPushButtonForgetServer()
}
}
BlueButtonType {
anchors.horizontalCenter: parent.horizontalCenter
y: 210
width: parent.width - 40
height: 40
text: qsTr("Protocols and Services")
onClicked: {
UiLogic.goToPage(PageEnum.ServerContainers)
}
}
BlueButtonType {
anchors.horizontalCenter: parent.horizontalCenter
y: 260
width: parent.width - 40
height: 40
text: qsTr("Share Server (FULL ACCESS)")
visible: ServerSettingsLogic.pushButtonShareFullVisible
onClicked: {
ServerSettingsLogic.onPushButtonShareFullClicked()
}
}
Logo { Logo {
id : logo
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
} }
} }

View file

@ -19,20 +19,11 @@ PageBase {
text: qsTr("Setup your server to use VPN") text: qsTr("Setup your server to use VPN")
} }
Flickable { FlickableType {
id: fl id: fl
width: root.width
anchors.top: caption.bottom anchors.top: caption.bottom
anchors.topMargin: 20 anchors.bottom: next_button.top
anchors.bottom: root.bottom
anchors.bottomMargin: 20
anchors.left: root.left
anchors.leftMargin: 30
anchors.right: root.right
anchors.rightMargin: 30
contentHeight: content.height contentHeight: content.height
clip: true
ColumnLayout { ColumnLayout {
id: content id: content
@ -40,6 +31,7 @@ PageBase {
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 15
RadioButtonType { RadioButtonType {
id: radioButton_setup_wizard_high id: radioButton_setup_wizard_high
@ -93,21 +85,23 @@ OpenVPN over ShadowSocks profile will be installed.\n")
text: qsTr("I want to improve my privacy on the internet. text: qsTr("I want to improve my privacy on the internet.
OpenVPN profile will be installed.\n") OpenVPN profile will be installed.\n")
} }
}
}
BlueButtonType {
BlueButtonType { id: next_button
Layout.fillWidth: true anchors.bottom: parent.bottom
Layout.preferredHeight: 41 anchors.bottomMargin: GC.defaultMargin
text: qsTr("Next") x: GC.defaultMargin
onClicked: { width: parent.width - 2 * GC.defaultMargin
if (radioButton_setup_wizard_high.checked) { text: qsTr("Next")
UiLogic.goToPage(PageEnum.WizardHigh, false); onClicked: {
} else if (radioButton_setup_wizard_medium.checked) { if (radioButton_setup_wizard_high.checked) {
UiLogic.goToPage(PageEnum.WizardMedium, false); UiLogic.goToPage(PageEnum.WizardHigh, false);
} else if (radioButton_setup_wizard_low.checked) { } else if (radioButton_setup_wizard_medium.checked) {
UiLogic.goToPage(PageEnum.WizardLow, false); UiLogic.goToPage(PageEnum.WizardMedium, false);
} } else if (radioButton_setup_wizard_low.checked) {
} UiLogic.goToPage(PageEnum.WizardLow, false);
} }
} }
} }

View file

@ -19,20 +19,11 @@ PageBase {
text: qsTr("Setup Wizard") text: qsTr("Setup Wizard")
} }
Flickable { FlickableType {
id: fl id: fl
width: root.width
anchors.top: caption.bottom anchors.top: caption.bottom
anchors.topMargin: 20 anchors.bottom: next_button.top
anchors.bottom: root.bottom
anchors.bottomMargin: 20
anchors.left: root.left
anchors.leftMargin: 30
anchors.right: root.right
anchors.rightMargin: 30
contentHeight: content.height contentHeight: content.height
clip: true
ColumnLayout { ColumnLayout {
id: content id: content
@ -40,6 +31,7 @@ PageBase {
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 15
LabelType { LabelType {
Layout.fillWidth: true Layout.fillWidth: true
@ -83,22 +75,22 @@ You SHOULD set this website address to some foreign website which is not blocked
This protocol support exporting connection profiles to mobile devices by exporting ShadowSocks and Cloak configs (you should launch the 3rd party open source VPN client - ShadowSocks VPN and install Cloak plugin).") This protocol support exporting connection profiles to mobile devices by exporting ShadowSocks and Cloak configs (you should launch the 3rd party open source VPN client - ShadowSocks VPN and install Cloak plugin).")
} }
BlueButtonType {
id: next_button
Layout.fillWidth: true
Layout.topMargin: 15
Layout.preferredHeight: 41
text: qsTr("Next")
onClicked: {
let domain = website_masking.text;
if (!domain || !domain.includes(".")) {
return
}
UiLogic.goToPage(PageEnum.WizardVpnMode, false)
}
}
} }
}
BlueButtonType {
id: next_button
anchors.bottom: parent.bottom
anchors.bottomMargin: GC.defaultMargin
x: GC.defaultMargin
width: parent.width - 2 * GC.defaultMargin
text: qsTr("Next")
onClicked: {
let domain = website_masking.text;
if (!domain || !domain.includes(".")) {
return
}
UiLogic.goToPage(PageEnum.WizardVpnMode, false)
}
} }
} }

View file

@ -19,20 +19,11 @@ PageBase {
text: qsTr("Setup Wizard") text: qsTr("Setup Wizard")
} }
Flickable { FlickableType {
id: fl id: fl
width: root.width
anchors.top: caption.bottom anchors.top: caption.bottom
anchors.topMargin: 20 anchors.bottom: next_button.top
anchors.bottom: root.bottom
anchors.bottomMargin: 20
anchors.left: root.left
anchors.leftMargin: 30
anchors.right: root.right
anchors.rightMargin: 30
contentHeight: content.height contentHeight: content.height
clip: true
ColumnLayout { ColumnLayout {
id: content id: content
@ -40,6 +31,7 @@ PageBase {
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 15
LabelType { LabelType {
Layout.fillWidth: true Layout.fillWidth: true
@ -56,16 +48,18 @@ We recommend not to use messaging applications for sending the connection profil
text: qsTr('OpenVPN profile will be installed') text: qsTr('OpenVPN profile will be installed')
verticalAlignment: Text.AlignBottom verticalAlignment: Text.AlignBottom
} }
BlueButtonType { }
id: next_button }
Layout.fillWidth: true
Layout.topMargin: 15 BlueButtonType {
Layout.preferredHeight: 41 id: next_button
text: qsTr("Start configuring") anchors.bottom: parent.bottom
onClicked: { anchors.bottomMargin: GC.defaultMargin
WizardLogic.onPushButtonLowFinishClicked() x: GC.defaultMargin
} width: parent.width - 2 * GC.defaultMargin
} text: qsTr("Start configuring")
onClicked: {
WizardLogic.onPushButtonLowFinishClicked()
} }
} }
} }

View file

@ -19,20 +19,11 @@ PageBase {
text: qsTr("Setup Wizard") text: qsTr("Setup Wizard")
} }
Flickable { FlickableType {
id: fl id: fl
width: root.width
anchors.top: caption.bottom anchors.top: caption.bottom
anchors.topMargin: 20 anchors.bottom: next_button.top
anchors.bottom: root.bottom
anchors.bottomMargin: 20
anchors.left: root.left
anchors.leftMargin: 30
anchors.right: root.right
anchors.rightMargin: 30
contentHeight: content.height contentHeight: content.height
clip: true
ColumnLayout { ColumnLayout {
id: content id: content
@ -40,6 +31,7 @@ PageBase {
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 15
LabelType { LabelType {
Layout.fillWidth: true Layout.fillWidth: true
@ -51,16 +43,18 @@ PageBase {
Layout.topMargin: 15 Layout.topMargin: 15
text: qsTr('OpenVPN over ShadowSocks profile will be installed') text: qsTr('OpenVPN over ShadowSocks profile will be installed')
} }
BlueButtonType { }
id: next_button }
Layout.fillWidth: true
Layout.topMargin: 15 BlueButtonType {
Layout.preferredHeight: 41 id: next_button
text: qsTr("Next") anchors.bottom: parent.bottom
onClicked: { anchors.bottomMargin: GC.defaultMargin
UiLogic.goToPage(PageEnum.WizardVpnMode, false) x: GC.defaultMargin
} width: parent.width - 2 * GC.defaultMargin
} text: qsTr("Next")
onClicked: {
UiLogic.goToPage(PageEnum.WizardVpnMode, false)
} }
} }
} }

View file

@ -19,20 +19,11 @@ PageBase {
text: qsTr("Setup Wizard") text: qsTr("Setup Wizard")
} }
Flickable { FlickableType {
id: fl id: fl
width: root.width
anchors.top: caption.bottom anchors.top: caption.bottom
anchors.topMargin: 20 anchors.bottom: vpn_mode_finish.top
anchors.bottom: root.bottom
anchors.bottomMargin: 20
anchors.left: root.left
anchors.leftMargin: 30
anchors.right: root.right
anchors.rightMargin: 30
contentHeight: content.height contentHeight: content.height
clip: true
ColumnLayout { ColumnLayout {
id: content id: content
@ -40,6 +31,7 @@ PageBase {
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 15
LabelType { LabelType {
Layout.fillWidth: true Layout.fillWidth: true
@ -56,17 +48,18 @@ You can enable VPN mode "For selected sites" and add blocked sites you need to v
WizardLogic.checkBoxVpnModeChecked = checked WizardLogic.checkBoxVpnModeChecked = checked
} }
} }
}
}
BlueButtonType { BlueButtonType {
id: vpn_mode_finish id: vpn_mode_finish
Layout.fillWidth: true anchors.bottom: parent.bottom
Layout.topMargin: 15 anchors.bottomMargin: GC.defaultMargin
Layout.preferredHeight: 41 x: GC.defaultMargin
text: qsTr("Start configuring") width: parent.width - 2 * GC.defaultMargin
onClicked: { text: qsTr("Start configuring")
WizardLogic.onPushButtonVpnModeFinishClicked() onClicked: {
} WizardLogic.onPushButtonVpnModeFinishClicked()
}
} }
} }
} }

View file

@ -27,12 +27,11 @@ PageBase {
} }
Flickable { FlickableType {
clip: true clip: true
width: parent.width
anchors.top: caption.bottom anchors.top: caption.bottom
anchors.bottom: root.bottom
contentHeight: col.height contentHeight: col.height
boundsBehavior: Flickable.StopAtBounds
Column { Column {
id: col id: col
@ -54,7 +53,6 @@ PageBase {
ShareConnectionContent { ShareConnectionContent {
x: 10
text: qsTr("Share for Amnezia") text: qsTr("Share for Amnezia")
height: 40 height: 40
width: tb_c.width - 10 width: tb_c.width - 10
@ -63,7 +61,6 @@ PageBase {
ListView { ListView {
id: tb_c id: tb_c
x: 10
width: parent.width - 10 width: parent.width - 10
height: tb_c.contentItem.height height: tb_c.contentItem.height
currentIndex: -1 currentIndex: -1

View file

@ -46,12 +46,12 @@ PageBase {
BasicButtonType { BasicButtonType {
id: start_switch_page id: start_switch_page
width: parent.width - 2 * GC.defaultMargin
implicitHeight: 40
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: logo.top anchors.bottom: logo.top
anchors.bottomMargin: 10 anchors.bottomMargin: 10
width: parent.width - 80
height: 40
anchors.topMargin: 20 anchors.topMargin: 20
text: qsTr("Set up your own server") text: qsTr("Set up your own server")
@ -88,7 +88,6 @@ PageBase {
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
antialiasing: true antialiasing: true
} }
Item { Item {
@ -104,6 +103,7 @@ PageBase {
id: label_connection_code id: label_connection_code
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: 20 anchors.topMargin: 20
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Connection code") text: qsTr("Connection code")
} }
TextFieldType { TextFieldType {
@ -303,7 +303,8 @@ PageBase {
} }
enabled: StartPageLogic.pushButtonConnectEnabled enabled: StartPageLogic.pushButtonConnectEnabled
} }
BasicButtonType {
UrlButtonType {
id: new_sever_connect_key id: new_sever_connect_key
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.top: new_sever_connect.bottom anchors.top: new_sever_connect.bottom
@ -311,21 +312,8 @@ PageBase {
width: 281 width: 281
height: 21 height: 21
text: qsTr("Connect using SSH key") text: qsTr("Connect using SSH key")
background: Item {
anchors.fill: parent
}
contentItem: Text { label.font.pixelSize: 16
anchors.fill: parent
font.family: "Lato"
font.styleName: "normal"
font.pixelSize: 16
color: "#15CDCB";
text: new_sever_connect_key.text
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
antialiasing: true
checkable: true checkable: true
checked: StartPageLogic.pushButtonConnectKeyChecked checked: StartPageLogic.pushButtonConnectKeyChecked
onCheckedChanged: { onCheckedChanged: {

View file

@ -30,27 +30,12 @@ PageBase {
font.pixelSize: 12 font.pixelSize: 12
} }
BasicButtonType { UrlButtonType {
y: 10 y: 10
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
height: 21 height: 21
background: Item {} label.color: "#D4D4D4"
label.text: qsTr("Donate")
contentItem: Text {
anchors.fill: parent
font.family: "Lato"
font.styleName: "normal"
font.pixelSize: 18
font.underline: true
text: qsTr("Donate")
color: "#D4D4D4"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
onClicked: { onClicked: {
UiLogic.goToPage(PageEnum.About) UiLogic.goToPage(PageEnum.About)

View file

@ -20,20 +20,10 @@ PageBase {
text: qsTr("Check config") text: qsTr("Check config")
} }
Flickable { FlickableType {
id: fl id: fl
width: root.width
anchors.top: caption.bottom anchors.top: caption.bottom
anchors.topMargin: 20
anchors.bottom: root.bottom
anchors.bottomMargin: 20
anchors.left: root.left
anchors.leftMargin: 30
anchors.right: root.right
anchors.rightMargin: 30
contentHeight: content.height contentHeight: content.height
clip: true
ColumnLayout { ColumnLayout {
id: content id: content
@ -41,6 +31,7 @@ PageBase {
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 15
TextAreaType { TextAreaType {
id: ta_config id: ta_config
@ -124,7 +115,7 @@ AmneziaVPN detected this profile may contain malicious scripts. Please, carefull
BasicButtonType { BasicButtonType {
Layout.preferredWidth: (content.width - parent.spacing) /2 Layout.preferredWidth: (content.width - parent.spacing) /2
Layout.preferredHeight: 41 Layout.preferredHeight: 40
font.pixelSize: btn_import.font.pixelSize font.pixelSize: btn_import.font.pixelSize
text: qsTr("Cancel") text: qsTr("Cancel")
onClicked: { onClicked: {
@ -135,7 +126,6 @@ AmneziaVPN detected this profile may contain malicious scripts. Please, carefull
BlueButtonType { BlueButtonType {
id: btn_import id: btn_import
Layout.preferredWidth: (content.width - parent.spacing) /2 Layout.preferredWidth: (content.width - parent.spacing) /2
Layout.preferredHeight: 41
text: qsTr("Import config") text: qsTr("Import config")
onClicked: { onClicked: {
logic.importConfig() logic.importConfig()

View file

@ -19,387 +19,398 @@ PageProtocolBase {
text: qsTr("OpenVPN Settings") text: qsTr("OpenVPN Settings")
} }
Flickable { FlickableType {
id: fl id: fl
width: root.width
anchors.top: caption.bottom anchors.top: caption.bottom
anchors.topMargin: 20
anchors.bottom: parent.bottom
anchors.bottomMargin: 20
anchors.left: root.left
anchors.leftMargin: 30
anchors.right: root.right
anchors.rightMargin: 30
contentHeight: content.height contentHeight: content.height
clip: true
ColumnLayout { ColumnLayout {
id: content id: content
enabled: logic.pageEnabled
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: GC.defaultMargin - 1
ColumnLayout {
visible: !logic.isThirdPartyConfig
enabled: logic.pageEnabled
LabelType {
id: lb_subnet
height: 21
text: qsTr("VPN Addresses Subnet")
}
TextFieldType {
id: tf_subnet
implicitWidth: parent.width
height: 31
text: logic.lineEditSubnetText
onEditingFinished: {
logic.lineEditSubnetText = text
}
}
//
LabelType {
id: lb_proto
Layout.topMargin: 20
height: 21
text: qsTr("Network protocol")
}
Rectangle {
id: rect_proto
implicitWidth: root.width - 60
height: 71
border.width: 1
border.color: "lightgray"
radius: 2
RadioButtonType {
x: 10
y: 40
width: 171
height: 19
text: qsTr("TCP")
enabled: logic.radioButtonTcpEnabled
checked: logic.radioButtonTcpChecked
onCheckedChanged: {
UiLogic.radioButtonTcpChecked = checked
}
}
RadioButtonType {
x: 10
y: 10
width: 171
height: 19
text: qsTr("UDP")
checked: logic.radioButtonUdpChecked
onCheckedChanged: {
logic.radioButtonUdpChecked = checked
}
enabled: logic.radioButtonUdpEnabled
}
}
//
RowLayout {
Layout.topMargin: 10
Layout.fillWidth: true
LabelType { LabelType {
id: lb_port id: lb_subnet
height: 31 height: 21
text: qsTr("Port") text: qsTr("VPN Addresses Subnet")
Layout.preferredWidth: root.width / 2 - 10
} }
TextFieldType { TextFieldType {
id: tf_port id: tf_subnet
implicitWidth: parent.width
height: 31
text: logic.lineEditSubnetText
onEditingFinished: {
logic.lineEditSubnetText = text
}
}
//
LabelType {
id: lb_proto
Layout.topMargin: 20
height: 21
text: qsTr("Network protocol")
}
Rectangle {
id: rect_proto
implicitWidth: parent.width
height: 71
border.width: 1
border.color: "lightgray"
radius: 2
RadioButtonType {
x: 10
y: 40
width: 171
height: 19
text: qsTr("TCP")
enabled: logic.radioButtonTcpEnabled
checked: logic.radioButtonTcpChecked
onCheckedChanged: {
logic.radioButtonTcpChecked = checked
}
}
RadioButtonType {
x: 10
y: 10
width: 171
height: 19
text: qsTr("UDP")
checked: logic.radioButtonUdpChecked
onCheckedChanged: {
logic.radioButtonUdpChecked = checked
}
enabled: logic.radioButtonUdpEnabled
}
}
//
RowLayout {
Layout.topMargin: 10
Layout.fillWidth: true Layout.fillWidth: true
LabelType {
id: lb_port
height: 31
text: qsTr("Port")
Layout.preferredWidth: root.width / 2 - 10
}
TextFieldType {
id: tf_port
Layout.fillWidth: true
height: 31
text: logic.lineEditPortText
onEditingFinished: {
logic.lineEditPortText = text
}
enabled: logic.lineEditPortEnabled
}
}
//
CheckBoxType {
id: check_auto_enc
implicitWidth: parent.width
height: 21
text: qsTr("Auto-negotiate encryption")
checked: logic.checkBoxAutoEncryptionChecked
onCheckedChanged: {
logic.checkBoxAutoEncryptionChecked = checked
}
onClicked: {
logic.checkBoxAutoEncryptionClicked()
}
}
//
LabelType {
id: lb_cipher
height: 21
text: qsTr("Cipher")
}
ComboBoxType {
id: cb_cipher
implicitWidth: parent.width
height: 31 height: 31
text: logic.lineEditPortText model: [
onEditingFinished: { qsTr("AES-256-GCM"),
logic.lineEditPortText = text qsTr("AES-192-GCM"),
} qsTr("AES-128-GCM"),
enabled: logic.lineEditPortEnabled qsTr("AES-256-CBC"),
} qsTr("AES-192-CBC"),
} qsTr("AES-128-CBC"),
qsTr("ChaCha20-Poly1305"),
qsTr("ARIA-256-CBC"),
qsTr("CAMELLIA-256-CBC"),
// qsTr("none")
CheckBoxType { ]
id: check_auto_enc currentIndex: {
for (let i = 0; i < model.length; ++i) {
implicitWidth: parent.width if (logic.comboBoxVpnCipherText === model[i]) {
height: 21 return i
text: qsTr("Auto-negotiate encryption") }
checked: logic.checkBoxAutoEncryptionChecked
onCheckedChanged: {
logic.checkBoxAutoEncryptionChecked = checked
}
onClicked: {
logic.checkBoxAutoEncryptionClicked()
}
}
//
LabelType {
id: lb_cipher
height: 21
text: qsTr("Cipher")
}
ComboBoxType {
id: cb_cipher
implicitWidth: parent.width
height: 31
model: [
qsTr("AES-256-GCM"),
qsTr("AES-192-GCM"),
qsTr("AES-128-GCM"),
qsTr("AES-256-CBC"),
qsTr("AES-192-CBC"),
qsTr("AES-128-CBC"),
qsTr("ChaCha20-Poly1305"),
qsTr("ARIA-256-CBC"),
qsTr("CAMELLIA-256-CBC"),
qsTr("none")
]
currentIndex: {
for (let i = 0; i < model.length; ++i) {
if (logic.comboBoxVpnCipherText === model[i]) {
return i
} }
return -1
} }
return -1 onCurrentTextChanged: {
logic.comboBoxVpnCipherText = currentText
}
enabled: !check_auto_enc.checked
} }
onCurrentTextChanged: {
logic.comboBoxVpnCipherText = currentText
}
enabled: !check_auto_enc.checked
}
// //
LabelType { LabelType {
id: lb_hash id: lb_hash
height: 21 height: 21
Layout.topMargin: 20 Layout.topMargin: 20
text: qsTr("Hash") text: qsTr("Hash")
} }
ComboBoxType { ComboBoxType {
id: cb_hash id: cb_hash
height: 31 height: 31
implicitWidth: parent.width implicitWidth: parent.width
model: [ model: [
qsTr("SHA512"), qsTr("SHA512"),
qsTr("SHA384"), qsTr("SHA384"),
qsTr("SHA256"), qsTr("SHA256"),
qsTr("SHA3-512"), qsTr("SHA3-512"),
qsTr("SHA3-384"), qsTr("SHA3-384"),
qsTr("SHA3-256"), qsTr("SHA3-256"),
qsTr("whirlpool"), qsTr("whirlpool"),
qsTr("BLAKE2b512"), qsTr("BLAKE2b512"),
qsTr("BLAKE2s256"), qsTr("BLAKE2s256"),
qsTr("SHA1") qsTr("SHA1")
] ]
currentIndex: { currentIndex: {
for (let i = 0; i < model.length; ++i) { for (let i = 0; i < model.length; ++i) {
if (logic.comboBoxVpnHashText === model[i]) { if (logic.comboBoxVpnHashText === model[i]) {
return i return i
}
} }
return -1
} }
return -1 onCurrentTextChanged: {
} logic.comboBoxVpnHashText = currentText
onCurrentTextChanged: { }
logic.comboBoxVpnHashText = currentText enabled: !check_auto_enc.checked
}
enabled: !check_auto_enc.checked
}
CheckBoxType {
id: check_tls
implicitWidth: parent.width
Layout.topMargin: 20
height: 21
text: qsTr("Enable TLS auth")
checked: logic.checkBoxTlsAuthChecked
onCheckedChanged: {
logic.checkBoxTlsAuthChecked = checked
} }
} CheckBoxType {
id: check_tls
implicitWidth: parent.width
Layout.topMargin: 20
height: 21
text: qsTr("Enable TLS auth")
checked: logic.checkBoxTlsAuthChecked
onCheckedChanged: {
logic.checkBoxTlsAuthChecked = checked
}
CheckBoxType {
id: check_block_dns
implicitWidth: parent.width
height: 21
text: qsTr("Block DNS requests outside of VPN")
checked: logic.checkBoxBlockDnsChecked
onCheckedChanged: {
logic.checkBoxBlockDnsChecked = checked
}
}
BasicButtonType {
id: pb_client_config
implicitWidth: parent.width
height: 21
text: qsTr("Additional client config commands →")
background: Item {
anchors.fill: parent
} }
contentItem: Text { CheckBoxType {
anchors.fill: parent id: check_block_dns
font.family: "Lato" implicitWidth: parent.width
font.styleName: "normal" height: 21
font.pixelSize: 16 text: qsTr("Block DNS requests outside of VPN")
color: "#15CDCB"; checked: logic.checkBoxBlockDnsChecked
text: pb_client_config.text onCheckedChanged: {
horizontalAlignment: Text.AlignLeft logic.checkBoxBlockDnsChecked = checked
verticalAlignment: Text.AlignVCenter }
} }
antialiasing: true
checkable: true
checked: StartPageLogic.pushButtonConnectKeyChecked
}
Rectangle {
id: rect_client_conf
implicitWidth: root.width - 60
height: 101
border.width: 1
border.color: "lightgray"
radius: 2
visible: pb_client_config.checked
ScrollView { BasicButtonType {
anchors.fill: parent id: pb_client_config
TextArea {
id: te_client_config implicitWidth: parent.width
height: 21
text: qsTr("Additional client config commands →")
background: Item {
anchors.fill: parent
}
contentItem: Text {
anchors.fill: parent
font.family: "Lato" font.family: "Lato"
font.styleName: "normal" font.styleName: "normal"
font.pixelSize: 16 font.pixelSize: 16
color: "#181922" color: "#15CDCB";
text: logic.textAreaAdditionalClientConfig text: pb_client_config.text
onEditingFinished: { horizontalAlignment: Text.AlignLeft
logic.textAreaAdditionalClientConfig = text verticalAlignment: Text.AlignVCenter
}
antialiasing: true
checkable: true
checked: StartPageLogic.pushButtonConnectKeyChecked
}
Rectangle {
id: rect_client_conf
implicitWidth: root.width - 60
height: 101
border.width: 1
border.color: "lightgray"
radius: 2
visible: pb_client_config.checked
ScrollView {
anchors.fill: parent
TextArea {
id: te_client_config
font.family: "Lato"
font.styleName: "normal"
font.pixelSize: 16
color: "#181922"
text: logic.textAreaAdditionalClientConfig
onEditingFinished: {
logic.textAreaAdditionalClientConfig = text
}
} }
} }
} }
} BasicButtonType {
id: pb_server_config
implicitWidth: parent.width
height: 21
text: qsTr("Additional server config commands →")
background: Item {
anchors.fill: parent
}
BasicButtonType { contentItem: Text {
id: pb_server_config anchors.fill: parent
implicitWidth: parent.width
height: 21
text: qsTr("Additional server config commands →")
background: Item {
anchors.fill: parent
}
contentItem: Text {
anchors.fill: parent
font.family: "Lato"
font.styleName: "normal"
font.pixelSize: 16
color: "#15CDCB";
text: pb_server_config.text
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
antialiasing: true
checkable: true
checked: StartPageLogic.pushButtonConnectKeyChecked
}
Rectangle {
id: rect_server_conf
implicitWidth: root.width - 60
height: 101
border.width: 1
border.color: "lightgray"
radius: 2
visible: pb_server_config.checked
ScrollView {
anchors.fill: parent
TextArea {
id: te_server_config
font.family: "Lato" font.family: "Lato"
font.styleName: "normal" font.styleName: "normal"
font.pixelSize: 16 font.pixelSize: 16
color: "#181922" color: "#15CDCB";
text: logic.textAreaAdditionalServerConfig text: pb_server_config.text
onEditingFinished: { horizontalAlignment: Text.AlignLeft
logic.textAreaAdditionalServerConfig = text verticalAlignment: Text.AlignVCenter
}
} }
antialiasing: true
checkable: true
checked: StartPageLogic.pushButtonConnectKeyChecked
} }
Rectangle {
id: rect_server_conf
implicitWidth: root.width - 60
height: 101
border.width: 1
border.color: "lightgray"
radius: 2
visible: pb_server_config.checked
} ScrollView {
anchors.fill: parent
TextArea {
id: te_server_config
font.family: "Lato"
font.styleName: "normal"
font.pixelSize: 16
color: "#181922"
text: logic.textAreaAdditionalServerConfig
onEditingFinished: {
logic.textAreaAdditionalServerConfig = text
}
}
}
LabelType {
id: label_proto_openvpn_info
height: 41 }
visible: logic.labelProtoOpenVpnInfoVisible
text: logic.labelProtoOpenVpnInfoText
}
Rectangle { LabelType {
id: it_save id: label_proto_openvpn_info
implicitWidth: parent.width
Layout.topMargin: 20
height: 40
BlueButtonType { height: 41
id: pb_save visible: logic.labelProtoOpenVpnInfoVisible
z: 1 text: logic.labelProtoOpenVpnInfoText
}
Rectangle {
id: it_save
implicitWidth: parent.width
Layout.topMargin: 20
height: 40 height: 40
text: qsTr("Save and restart VPN")
width: parent.width
visible: logic.pushButtonSaveVisible
onClicked: {
logic.onPushButtonProtoOpenVpnSaveClicked()
}
}
ProgressBar { BlueButtonType {
id: progress_save id: pb_save
anchors.fill: pb_save z: 1
from: 0 height: 40
to: logic.progressBarResetMaximium text: qsTr("Save and restart VPN")
value: logic.progressBarResetValue width: parent.width
visible: logic.progressBarResetVisible visible: logic.pushButtonSaveVisible
background: Rectangle { onClicked: {
implicitWidth: parent.width logic.onPushButtonProtoOpenVpnSaveClicked()
implicitHeight: parent.height
color: "#100A44"
radius: 4
}
contentItem: Item {
implicitWidth: parent.width
implicitHeight: parent.height
Rectangle {
width: progress_save.visualPosition * parent.width
height: parent.height
radius: 4
color: Qt.rgba(255, 255, 255, 0.15);
} }
} }
ProgressBar {
id: progress_save
anchors.fill: pb_save
from: 0
to: logic.progressBarResetMaximium
value: logic.progressBarResetValue
visible: logic.progressBarResetVisible
background: Rectangle {
implicitWidth: parent.width
implicitHeight: parent.height
color: "#100A44"
radius: 4
}
contentItem: Item {
implicitWidth: parent.width
implicitHeight: parent.height
Rectangle {
width: progress_save.visualPosition * parent.width
height: parent.height
radius: 4
color: Qt.rgba(255, 255, 255, 0.15);
}
}
}
} }
} }
} ColumnLayout {
visible: logic.isThirdPartyConfig
TextAreaType {
id: ta_config
Layout.topMargin: 5
Layout.bottomMargin: 20
Layout.fillWidth: true
Layout.leftMargin: 1
Layout.rightMargin: 1
Layout.preferredHeight: fl.height - 70
flickableDirection: Flickable.AutoFlickIfNeeded
textArea.readOnly: true
textArea.text: logic.openVpnLastConfigText
}
}
}
} }
} }

View file

@ -0,0 +1,60 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.15
import ProtocolEnum 1.0
import "../"
import "../../Controls"
import "../../Config"
PageProtocolBase {
id: root
protocol: ProtocolEnum.WireGuard
logic: UiLogic.protocolLogic(protocol)
BackButton {
id: back
}
Caption {
id: caption
text: qsTr("WireGuard Settings")
}
Flickable {
id: fl
width: root.width
anchors.top: caption.bottom
anchors.topMargin: 20
anchors.bottom: parent.bottom
anchors.bottomMargin: 20
anchors.left: root.left
anchors.leftMargin: 30
anchors.right: root.right
anchors.rightMargin: 30
contentHeight: content.height
clip: true
ColumnLayout {
id: content
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
TextAreaType {
id: ta_config
Layout.topMargin: 5
Layout.bottomMargin: 20
Layout.fillWidth: true
Layout.leftMargin: 1
Layout.rightMargin: 1
Layout.preferredHeight: fl.height - 70
flickableDirection: Flickable.AutoFlickIfNeeded
textArea.readOnly: true
textArea.text: logic.wireGuardLastConfigText
}
}
}
}

View file

@ -18,20 +18,10 @@ PageShareProtocolBase {
text: qsTr("Share for Amnezia") text: qsTr("Share for Amnezia")
} }
Flickable { FlickableType {
id: fl id: fl
width: root.width
anchors.top: caption.bottom anchors.top: caption.bottom
anchors.topMargin: 20
anchors.bottom: root.bottom
anchors.bottomMargin: 20
anchors.left: root.left
anchors.leftMargin: 30
anchors.right: root.right
anchors.rightMargin: 30
contentHeight: content.height + 20 contentHeight: content.height + 20
clip: true
Behavior on contentY{ Behavior on contentY{
NumberAnimation { NumberAnimation {
@ -46,6 +36,7 @@ PageShareProtocolBase {
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 15
Text { Text {
id: lb_desc id: lb_desc

View file

@ -18,20 +18,10 @@ PageShareProtocolBase {
text: qsTr("Share Cloak Settings") text: qsTr("Share Cloak Settings")
} }
Flickable { FlickableType {
id: fl id: fl
width: root.width
anchors.top: caption.bottom anchors.top: caption.bottom
anchors.topMargin: 20
anchors.bottom: root.bottom
anchors.bottomMargin: 20
anchors.left: root.left
anchors.leftMargin: 30
anchors.right: root.right
anchors.rightMargin: 30
contentHeight: content.height contentHeight: content.height
clip: true
ColumnLayout { ColumnLayout {
id: content id: content
@ -39,7 +29,7 @@ PageShareProtocolBase {
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 15
LabelType { LabelType {
id: lb_desc id: lb_desc

View file

@ -42,20 +42,10 @@ PageShareProtocolBase {
visible: false visible: false
} }
Flickable { FlickableType {
id: fl id: fl
width: root.width
anchors.top: caption.bottom anchors.top: caption.bottom
anchors.topMargin: 20
anchors.bottom: root.bottom
anchors.bottomMargin: 20
anchors.left: root.left
anchors.leftMargin: 30
anchors.right: root.right
anchors.rightMargin: 30
contentHeight: content.height contentHeight: content.height
clip: true
ColumnLayout { ColumnLayout {
id: content id: content
@ -63,6 +53,7 @@ PageShareProtocolBase {
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 15
// LabelType { // LabelType {
// id: lb_desc // id: lb_desc

View file

@ -18,20 +18,10 @@ PageShareProtocolBase {
text: qsTr("Share OpenVPN Settings") text: qsTr("Share OpenVPN Settings")
} }
Flickable { FlickableType {
id: fl id: fl
width: root.width
anchors.top: caption.bottom anchors.top: caption.bottom
anchors.topMargin: 20
anchors.bottom: root.bottom
anchors.bottomMargin: 20
anchors.left: root.left
anchors.leftMargin: 30
anchors.right: root.right
anchors.rightMargin: 30
contentHeight: content.height contentHeight: content.height
clip: true
ColumnLayout { ColumnLayout {
id: content id: content
@ -39,7 +29,7 @@ PageShareProtocolBase {
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 15
LabelType { LabelType {
id: lb_desc id: lb_desc

View file

@ -18,20 +18,10 @@ PageShareProtocolBase {
text: qsTr("Share ShadowSocks Settings") text: qsTr("Share ShadowSocks Settings")
} }
Flickable { FlickableType {
id: fl id: fl
width: root.width
anchors.top: caption.bottom anchors.top: caption.bottom
anchors.topMargin: 20
anchors.bottom: root.bottom
anchors.bottomMargin: 20
anchors.left: root.left
anchors.leftMargin: 30
anchors.right: root.right
anchors.rightMargin: 30
contentHeight: content.height contentHeight: content.height
clip: true
ColumnLayout { ColumnLayout {
id: content id: content
@ -39,6 +29,7 @@ PageShareProtocolBase {
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 15
LabelType { LabelType {
id: lb_desc id: lb_desc

View file

@ -18,20 +18,10 @@ PageShareProtocolBase {
text: qsTr("Share WireGuard Settings") text: qsTr("Share WireGuard Settings")
} }
Flickable { FlickableType {
id: fl id: fl
width: root.width
anchors.top: caption.bottom anchors.top: caption.bottom
anchors.topMargin: 20
anchors.bottom: root.bottom
anchors.bottomMargin: 20
anchors.left: root.left
anchors.leftMargin: 30
anchors.right: root.right
anchors.rightMargin: 30
contentHeight: content.height contentHeight: content.height
clip: true
ColumnLayout { ColumnLayout {
id: content id: content
@ -39,6 +29,7 @@ PageShareProtocolBase {
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 15
LabelType { LabelType {
id: lb_desc id: lb_desc

View file

@ -72,7 +72,7 @@
#include "pages_logic/protocols/OpenVpnLogic.h" #include "pages_logic/protocols/OpenVpnLogic.h"
#include "pages_logic/protocols/ShadowSocksLogic.h" #include "pages_logic/protocols/ShadowSocksLogic.h"
#include "pages_logic/protocols/OtherProtocolsLogic.h" #include "pages_logic/protocols/OtherProtocolsLogic.h"
#include "pages_logic/protocols/WireGuardLogic.h"
using namespace amnezia; using namespace amnezia;
using namespace PageEnumNS; using namespace PageEnumNS;
@ -95,7 +95,7 @@ UiLogic::UiLogic(std::shared_ptr<Settings> settings, std::shared_ptr<VpnConfigur
m_protocolLogicMap.insert(Proto::OpenVpn, new OpenVpnLogic(this)); m_protocolLogicMap.insert(Proto::OpenVpn, new OpenVpnLogic(this));
m_protocolLogicMap.insert(Proto::ShadowSocks, new ShadowSocksLogic(this)); m_protocolLogicMap.insert(Proto::ShadowSocks, new ShadowSocksLogic(this));
m_protocolLogicMap.insert(Proto::Cloak, new CloakLogic(this)); m_protocolLogicMap.insert(Proto::Cloak, new CloakLogic(this));
//m_protocolLogicMap->insert(Proto::WireGuard, new WireguardLogic(this)); m_protocolLogicMap.insert(Proto::WireGuard, new WireGuardLogic(this));
m_protocolLogicMap.insert(Proto::Dns, new OtherProtocolsLogic(this)); m_protocolLogicMap.insert(Proto::Dns, new OtherProtocolsLogic(this));
m_protocolLogicMap.insert(Proto::Sftp, new OtherProtocolsLogic(this)); m_protocolLogicMap.insert(Proto::Sftp, new OtherProtocolsLogic(this));