added page to display raw config
This commit is contained in:
parent
c13b9754eb
commit
3aaa7b62ef
16 changed files with 266 additions and 30 deletions
|
@ -86,6 +86,21 @@ void AmneziaApplication::init()
|
|||
initModels();
|
||||
initControllers();
|
||||
|
||||
m_notificationHandler.reset(NotificationHandler::create(nullptr));
|
||||
|
||||
connect(m_vpnConnection.get(), &VpnConnection::connectionStateChanged, m_notificationHandler.get(),
|
||||
&NotificationHandler::setConnectionState);
|
||||
|
||||
void openConnection();
|
||||
void closeConnection();
|
||||
|
||||
connect(m_notificationHandler.get(), &NotificationHandler::raiseRequested, m_pageController.get(),
|
||||
&PageController::raise);
|
||||
connect(m_notificationHandler.get(), &NotificationHandler::connectRequested, m_connectionController.get(),
|
||||
&ConnectionController::openConnection);
|
||||
connect(m_notificationHandler.get(), &NotificationHandler::disconnectRequested, m_connectionController.get(),
|
||||
&ConnectionController::closeConnection);
|
||||
|
||||
//
|
||||
|
||||
m_engine->load(url);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "ui/models/containers_model.h"
|
||||
#include "ui/models/languageModel.h"
|
||||
#include "ui/models/protocols/cloakConfigModel.h"
|
||||
#include "ui/notificationhandler.h"
|
||||
#ifdef Q_OS_WINDOWS
|
||||
#include "ui/models/protocols/ikev2ConfigModel.h"
|
||||
#endif
|
||||
|
@ -91,6 +92,7 @@ private:
|
|||
#endif
|
||||
|
||||
QSharedPointer<VpnConnection> m_vpnConnection;
|
||||
QScopedPointer<NotificationHandler> m_notificationHandler;
|
||||
|
||||
QScopedPointer<ConnectionController> m_connectionController;
|
||||
QScopedPointer<PageController> m_pageController;
|
||||
|
|
|
@ -273,5 +273,6 @@
|
|||
<file>ui/qml/Pages2/PageProtocolOpenVpnSettings.qml</file>
|
||||
<file>ui/qml/Pages2/PageProtocolShadowSocksSettings.qml</file>
|
||||
<file>ui/qml/Pages2/PageProtocolCloakSettings.qml</file>
|
||||
<file>ui/qml/Pages2/PageProtocolRaw.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -36,10 +36,9 @@ void ExportController::generateFullAccessConfig()
|
|||
|
||||
QByteArray compressedConfig = QJsonDocument(config).toJson();
|
||||
compressedConfig = qCompress(compressedConfig, 8);
|
||||
m_rawConfig = QString("vpn://%1")
|
||||
.arg(QString(compressedConfig.toBase64(QByteArray::Base64UrlEncoding
|
||||
| QByteArray::OmitTrailingEquals)));
|
||||
m_formattedConfig = m_rawConfig;
|
||||
m_config = QString("vpn://%1")
|
||||
.arg(QString(compressedConfig.toBase64(QByteArray::Base64UrlEncoding
|
||||
| QByteArray::OmitTrailingEquals)));
|
||||
|
||||
m_qrCodes = generateQrCodeImageSeries(compressedConfig);
|
||||
emit exportConfigChanged();
|
||||
|
@ -88,10 +87,9 @@ void ExportController::generateConnectionConfig()
|
|||
|
||||
QByteArray compressedConfig = QJsonDocument(config).toJson();
|
||||
compressedConfig = qCompress(compressedConfig, 8);
|
||||
m_rawConfig = QString("vpn://%1")
|
||||
.arg(QString(compressedConfig.toBase64(QByteArray::Base64UrlEncoding
|
||||
| QByteArray::OmitTrailingEquals)));
|
||||
m_formattedConfig = m_rawConfig;
|
||||
m_config = QString("vpn://%1")
|
||||
.arg(QString(compressedConfig.toBase64(QByteArray::Base64UrlEncoding
|
||||
| QByteArray::OmitTrailingEquals)));
|
||||
|
||||
m_qrCodes = generateQrCodeImageSeries(compressedConfig);
|
||||
emit exportConfigChanged();
|
||||
|
@ -120,12 +118,10 @@ void ExportController::generateOpenVpnConfig()
|
|||
}
|
||||
config = m_configurator->processConfigWithExportSettings(serverIndex, container, Proto::OpenVpn, config);
|
||||
|
||||
m_rawConfig = config;
|
||||
|
||||
auto configJson = QJsonDocument::fromJson(config.toUtf8()).object();
|
||||
QStringList lines = configJson.value(config_key::config).toString().replace("\r", "").split("\n");
|
||||
for (const QString &line : lines) {
|
||||
m_formattedConfig.append(line + "\n");
|
||||
m_config.append(line + "\n");
|
||||
}
|
||||
|
||||
emit exportConfigChanged();
|
||||
|
@ -154,20 +150,18 @@ void ExportController::generateWireGuardConfig()
|
|||
}
|
||||
config = m_configurator->processConfigWithExportSettings(serverIndex, container, Proto::WireGuard, config);
|
||||
|
||||
m_rawConfig = config;
|
||||
|
||||
auto configJson = QJsonDocument::fromJson(config.toUtf8()).object();
|
||||
QStringList lines = configJson.value(config_key::config).toString().replace("\r", "").split("\n");
|
||||
for (const QString &line : lines) {
|
||||
m_formattedConfig.append(line + "\n");
|
||||
m_config.append(line + "\n");
|
||||
}
|
||||
|
||||
emit exportConfigChanged();
|
||||
}
|
||||
|
||||
QString ExportController::getFormattedConfig()
|
||||
QString ExportController::getConfig()
|
||||
{
|
||||
return m_formattedConfig;
|
||||
return m_config;
|
||||
}
|
||||
|
||||
QList<QString> ExportController::getQrCodes()
|
||||
|
@ -193,7 +187,7 @@ void ExportController::saveFile()
|
|||
QFile save(fileName.toLocalFile());
|
||||
|
||||
save.open(QIODevice::WriteOnly);
|
||||
save.write(m_rawConfig.toUtf8());
|
||||
save.write(m_config.toUtf8());
|
||||
save.close();
|
||||
|
||||
QFileInfo fi(fileName.toLocalFile());
|
||||
|
@ -233,7 +227,6 @@ int ExportController::getQrCodesCount()
|
|||
|
||||
void ExportController::clearPreviousConfig()
|
||||
{
|
||||
m_rawConfig.clear();
|
||||
m_formattedConfig.clear();
|
||||
m_config.clear();
|
||||
m_qrCodes.clear();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public:
|
|||
|
||||
Q_PROPERTY(QList<QString> qrCodes READ getQrCodes NOTIFY exportConfigChanged)
|
||||
Q_PROPERTY(int qrCodesCount READ getQrCodesCount NOTIFY exportConfigChanged)
|
||||
Q_PROPERTY(QString formattedConfig READ getFormattedConfig NOTIFY exportConfigChanged)
|
||||
Q_PROPERTY(QString config READ getConfig NOTIFY exportConfigChanged)
|
||||
|
||||
public slots:
|
||||
void generateFullAccessConfig();
|
||||
|
@ -26,7 +26,7 @@ public slots:
|
|||
void generateOpenVpnConfig();
|
||||
void generateWireGuardConfig();
|
||||
|
||||
QString getFormattedConfig();
|
||||
QString getConfig();
|
||||
QList<QString> getQrCodes();
|
||||
|
||||
void saveFile();
|
||||
|
@ -50,8 +50,7 @@ private:
|
|||
std::shared_ptr<Settings> m_settings;
|
||||
std::shared_ptr<VpnConfigurator> m_configurator;
|
||||
|
||||
QString m_rawConfig;
|
||||
QString m_formattedConfig;
|
||||
QString m_config;
|
||||
QList<QString> m_qrCodes;
|
||||
};
|
||||
|
||||
|
|
|
@ -42,7 +42,8 @@ namespace PageLoader
|
|||
PageProtocolShadowSocksSettings,
|
||||
PageProtocolCloakSettings,
|
||||
PageProtocolWireGuardSettings,
|
||||
PageProtocolIKev2Settings
|
||||
PageProtocolIKev2Settings,
|
||||
PageProtocolRaw
|
||||
};
|
||||
Q_ENUM_NS(PageEnum)
|
||||
|
||||
|
@ -70,6 +71,7 @@ signals:
|
|||
void showErrorMessage(QString errorMessage);
|
||||
void showInfoMessage(QString message);
|
||||
void showBusyIndicator(bool visible);
|
||||
void raise();
|
||||
|
||||
private:
|
||||
QSharedPointer<ServersModel> m_serversModel;
|
||||
|
|
|
@ -17,6 +17,7 @@ QHash<int, QByteArray> ProtocolsModel::roleNames() const
|
|||
|
||||
roles[ProtocolNameRole] = "protocolName";
|
||||
roles[ProtocolPageRole] = "protocolPage";
|
||||
roles[RawConfigRole] = "rawConfig";
|
||||
|
||||
return roles;
|
||||
}
|
||||
|
@ -34,6 +35,19 @@ QVariant ProtocolsModel::data(const QModelIndex &index, int role) const
|
|||
}
|
||||
case ProtocolPageRole:
|
||||
return static_cast<int>(protocolPage(ProtocolProps::protoFromString(m_content.keys().at(index.row()))));
|
||||
case RawConfigRole: {
|
||||
auto protocolConfig = m_content.value(ContainerProps::containerTypeToString(m_container)).toObject();
|
||||
auto lastConfigJsonDoc =
|
||||
QJsonDocument::fromJson(protocolConfig.value(config_key::last_config).toString().toUtf8());
|
||||
auto lastConfigJson = lastConfigJsonDoc.object();
|
||||
|
||||
QString rawConfig;
|
||||
QStringList lines = lastConfigJson.value(config_key::config).toString().replace("\r", "").split("\n");
|
||||
for (const QString &l : lines) {
|
||||
rawConfig.append(l + "\n");
|
||||
}
|
||||
return rawConfig;
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
|
|
|
@ -13,7 +13,8 @@ class ProtocolsModel : public QAbstractListModel
|
|||
public:
|
||||
enum Roles {
|
||||
ProtocolNameRole = Qt::UserRole + 1,
|
||||
ProtocolPageRole
|
||||
ProtocolPageRole,
|
||||
RawConfigRole
|
||||
};
|
||||
|
||||
ProtocolsModel(std::shared_ptr<Settings> settings, QObject *parent = nullptr);
|
||||
|
|
|
@ -7,6 +7,7 @@ import SortFilterProxyModel 0.2
|
|||
import PageEnum 1.0
|
||||
import ProtocolEnum 1.0
|
||||
import ContainerEnum 1.0
|
||||
import ContainerProps 1.0
|
||||
|
||||
import "../Controls2"
|
||||
import "../Controls2/TextTypes"
|
||||
|
@ -91,19 +92,25 @@ ListView {
|
|||
if (isInstalled) {
|
||||
var containerIndex = root.model.mapToSource(index)
|
||||
ContainersModel.setCurrentlyProcessedContainerIndex(containerIndex)
|
||||
if (config[ContainerProps.containerTypeToString(containerIndex)]["isThirdPartyConfig"]) {
|
||||
ProtocolsModel.updateModel(config)
|
||||
goToPage(PageEnum.PageProtocolRaw)
|
||||
return
|
||||
}
|
||||
|
||||
switch (containerIndex) {
|
||||
case ContainerEnum.OpenVpn: {
|
||||
OpenVpnConfigModel.updateModel(ProtocolsModel.getConfig())
|
||||
OpenVpnConfigModel.updateModel(config)
|
||||
goToPage(PageEnum.PageProtocolOpenVpnSettings)
|
||||
break
|
||||
}
|
||||
case ContainerEnum.WireGuard: {
|
||||
WireGuardConfigModel.updateModel(ProtocolsModel.getConfig())
|
||||
WireGuardConfigModel.updateModel(config)
|
||||
goToPage(PageEnum.PageProtocolWireGuardSettings)
|
||||
break
|
||||
}
|
||||
case ContainerEnum.Ipsec: {
|
||||
Ikev2ConfigModel.updateModel(ProtocolsModel.getConfig())
|
||||
Ikev2ConfigModel.updateModel(config)
|
||||
goToPage(PageEnum.PageProtocolIKev2Settings)
|
||||
break
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ DrawerType {
|
|||
font.weight: Font.Medium
|
||||
font.family: "PT Root UI VF"
|
||||
|
||||
text: ExportController.formattedConfig
|
||||
text: ExportController.config
|
||||
|
||||
wrapMode: Text.Wrap
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ PageType {
|
|||
description += "Amnezia DNS | "
|
||||
}
|
||||
} else {
|
||||
if (ServersModel.isDefaultServerConfigContainsAmneziaDns) {
|
||||
if (ServersModel.isDefaultServerConfigContainsAmneziaDns()) {
|
||||
description += "Amnezia DNS | "
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,8 @@ PageType {
|
|||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
enabled: ServersModel.isCurrentlyProcessedServerHasWriteAccess()
|
||||
|
||||
ListView {
|
||||
id: listview
|
||||
|
||||
|
|
|
@ -54,6 +54,8 @@ PageType {
|
|||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
enabled: ServersModel.isCurrentlyProcessedServerHasWriteAccess()
|
||||
|
||||
ListView {
|
||||
id: listview
|
||||
|
||||
|
|
190
client/ui/qml/Pages2/PageProtocolRaw.qml
Normal file
190
client/ui/qml/Pages2/PageProtocolRaw.qml
Normal file
|
@ -0,0 +1,190 @@
|
|||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
import PageEnum 1.0
|
||||
import ProtocolEnum 1.0
|
||||
import ContainerEnum 1.0
|
||||
import ContainerProps 1.0
|
||||
|
||||
import "./"
|
||||
import "../Controls2"
|
||||
import "../Controls2/TextTypes"
|
||||
import "../Config"
|
||||
import "../Components"
|
||||
|
||||
PageType {
|
||||
id: root
|
||||
|
||||
ColumnLayout {
|
||||
id: header
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
anchors.topMargin: 20
|
||||
|
||||
BackButtonType {
|
||||
}
|
||||
|
||||
HeaderType {
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
|
||||
headerText: ContainersModel.getCurrentlyProcessedContainerName() + qsTr(" settings")
|
||||
}
|
||||
}
|
||||
|
||||
FlickableType {
|
||||
id: fl
|
||||
anchors.top: header.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
contentHeight: content.height
|
||||
|
||||
Column {
|
||||
id: content
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.topMargin: 32
|
||||
|
||||
ListView {
|
||||
width: parent.width
|
||||
height: contentItem.height
|
||||
clip: true
|
||||
interactive: false
|
||||
model: ProtocolsModel
|
||||
|
||||
delegate: Item {
|
||||
implicitWidth: parent.width
|
||||
implicitHeight: delegateContent.implicitHeight
|
||||
|
||||
ColumnLayout {
|
||||
id: delegateContent
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
LabelWithButtonType {
|
||||
id: button
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
text: qsTr("Show connection options")
|
||||
|
||||
clickedFunction: function() {
|
||||
configContentDrawer.open()
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: button
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
|
||||
DividerType {}
|
||||
|
||||
DrawerType {
|
||||
id: configContentDrawer
|
||||
|
||||
width: parent.width
|
||||
height: parent.height * 0.9
|
||||
|
||||
BackButtonType {
|
||||
id: backButton
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.topMargin: 16
|
||||
|
||||
backButtonFunction: function() {
|
||||
configContentDrawer.visible = false
|
||||
}
|
||||
}
|
||||
|
||||
FlickableType {
|
||||
anchors.top: backButton.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
contentHeight: configContent.implicitHeight + configContent.anchors.topMargin + configContent.anchors.bottomMargin
|
||||
|
||||
ColumnLayout {
|
||||
id: configContent
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.rightMargin: 16
|
||||
anchors.leftMargin: 16
|
||||
|
||||
Header2Type {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 16
|
||||
|
||||
headerText: qsTr("Connection options ") + protocolName
|
||||
}
|
||||
|
||||
TextArea {
|
||||
id: configText
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 16
|
||||
Layout.bottomMargin: 16
|
||||
|
||||
padding: 0
|
||||
leftPadding: 0
|
||||
height: 24
|
||||
|
||||
color: "#D7D8DB"
|
||||
selectionColor: "#412102"
|
||||
selectedTextColor: "#D7D8DB"
|
||||
|
||||
font.pixelSize: 16
|
||||
font.weight: Font.Medium
|
||||
font.family: "PT Root UI VF"
|
||||
|
||||
text: rawConfig
|
||||
|
||||
wrapMode: Text.Wrap
|
||||
|
||||
background: Rectangle {
|
||||
color: "transparent"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LabelWithButtonType {
|
||||
id: removeButton
|
||||
|
||||
width: parent.width
|
||||
|
||||
text: qsTr("Remove ") + ContainersModel.getCurrentlyProcessedContainerName()
|
||||
textColor: "#EB5757"
|
||||
|
||||
clickedFunction: function() {
|
||||
ContainersModel.removeCurrentlyProcessedContainer()
|
||||
closePage()
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: removeButton
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
|
||||
DividerType {}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -53,6 +53,8 @@ PageType {
|
|||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
enabled: ServersModel.isCurrentlyProcessedServerHasWriteAccess()
|
||||
|
||||
ListView {
|
||||
id: listview
|
||||
|
||||
|
|
|
@ -48,5 +48,11 @@ Window {
|
|||
}
|
||||
rootStackView.replace(pagePath, { "objectName" : pagePath })
|
||||
}
|
||||
|
||||
function onRaise() {
|
||||
root.show()
|
||||
root.raise()
|
||||
root.requestActivate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue