Merge remote-tracking branch 'origin/dev' into ios-wireguard
This commit is contained in:
commit
8591d4e96c
31 changed files with 287 additions and 2632 deletions
|
@ -78,14 +78,15 @@
|
|||
</activity>
|
||||
|
||||
<service android:name=".VPNService"
|
||||
android:process=":QtOnlyProcess"
|
||||
android:process=":QtOnlyProcess"
|
||||
android:permission="android.permission.BIND_VPN_SERVICE">
|
||||
<intent-filter>
|
||||
<action android:name="android.net.VpnService"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service android:name="org.mozilla.firefox.vpn.qt.VPNPermissionHelper"
|
||||
android:permission="android.permission.BIND_VPN_SERVICE">
|
||||
|
||||
<service android:name="org.amnezia.vpn.qt.VPNPermissionHelper"
|
||||
android:permission="android.permission.BIND_VPN_SERVICE">
|
||||
</service>
|
||||
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
|
||||
</application>
|
||||
|
|
|
@ -31,9 +31,7 @@ HEADERS += \
|
|||
containers/containers_defs.h \
|
||||
core/defs.h \
|
||||
core/errorstrings.h \
|
||||
core/ipcclient.h \
|
||||
configurators/openvpn_configurator.h \
|
||||
core/privileged_process.h \
|
||||
core/scripts_registry.h \
|
||||
core/server_defs.h \
|
||||
core/servercontroller.h \
|
||||
|
@ -88,9 +86,7 @@ SOURCES += \
|
|||
configurators/wireguard_configurator.cpp \
|
||||
containers/containers_defs.cpp \
|
||||
core/errorstrings.cpp \
|
||||
core/ipcclient.cpp \
|
||||
configurators/openvpn_configurator.cpp \
|
||||
core/privileged_process.cpp \
|
||||
core/scripts_registry.cpp \
|
||||
core/server_defs.cpp \
|
||||
core/servercontroller.cpp \
|
||||
|
@ -203,6 +199,8 @@ win32|macx|linux:!android {
|
|||
DEFINES += AMNEZIA_DESKTOP
|
||||
|
||||
HEADERS += \
|
||||
core/ipcclient.h \
|
||||
core/privileged_process.h \
|
||||
ui/systemtray_notificationhandler.h \
|
||||
protocols/openvpnprotocol.h \
|
||||
protocols/openvpnovercloakprotocol.h \
|
||||
|
@ -210,11 +208,16 @@ win32|macx|linux:!android {
|
|||
protocols/wireguardprotocol.h \
|
||||
|
||||
SOURCES += \
|
||||
core/ipcclient.cpp \
|
||||
core/privileged_process.cpp \
|
||||
ui/systemtray_notificationhandler.cpp \
|
||||
protocols/openvpnprotocol.cpp \
|
||||
protocols/openvpnovercloakprotocol.cpp \
|
||||
protocols/shadowsocksvpnprotocol.cpp \
|
||||
protocols/wireguardprotocol.cpp \
|
||||
|
||||
REPC_REPLICA += ../ipc/ipc_interface.rep
|
||||
REPC_REPLICA += ../ipc/ipc_process_interface.rep
|
||||
}
|
||||
|
||||
android {
|
||||
|
@ -360,6 +363,4 @@ ios {
|
|||
}
|
||||
|
||||
|
||||
REPC_REPLICA += ../ipc/ipc_interface.rep
|
||||
!ios: REPC_REPLICA += ../ipc/ipc_process_interface.rep
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ Proto ContainerProps::defaultProtocol(DockerContainer c)
|
|||
}
|
||||
}
|
||||
|
||||
bool ContainerProps::isWorkingOnPlatform(DockerContainer c)
|
||||
bool ContainerProps::isSupportedByCurrentPlatform(DockerContainer c)
|
||||
{
|
||||
#ifdef Q_OS_WINDOWS
|
||||
return true;
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
// it may be changed fot future containers :)
|
||||
Q_INVOKABLE static Proto defaultProtocol(DockerContainer c);
|
||||
|
||||
Q_INVOKABLE static bool isWorkingOnPlatform(DockerContainer c);
|
||||
Q_INVOKABLE static bool isSupportedByCurrentPlatform(DockerContainer c);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -65,7 +65,6 @@ bool IpcClient::init(IpcClient *instance)
|
|||
|
||||
QSharedPointer<PrivilegedProcess> IpcClient::CreatePrivilegedProcess()
|
||||
{
|
||||
#ifndef Q_OS_IOS
|
||||
if (! Instance()->m_ipcClient || ! Instance()->m_ipcClient->isReplicaValid()) {
|
||||
qWarning() << "IpcClient::createPrivilegedProcess : IpcClient IpcClient replica is not valid";
|
||||
return nullptr;
|
||||
|
@ -107,9 +106,6 @@ QSharedPointer<PrivilegedProcess> IpcClient::CreatePrivilegedProcess()
|
|||
|
||||
auto proccessReplica = QSharedPointer<PrivilegedProcess>(pd->ipcProcess);
|
||||
return proccessReplica;
|
||||
#else
|
||||
return QSharedPointer<PrivilegedProcess>();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "privileged_process.h"
|
||||
|
||||
#ifndef Q_OS_IOS
|
||||
PrivilegedProcess::PrivilegedProcess() :
|
||||
IpcProcessInterfaceReplica()
|
||||
{
|
||||
|
@ -26,4 +25,3 @@ void PrivilegedProcess::waitForFinished(int msecs)
|
|||
|
||||
loop->exec();
|
||||
}
|
||||
#endif // Q_OS_IOS
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
#ifndef Q_OS_IOS
|
||||
#include "rep_ipc_process_interface_replica.h"
|
||||
// This class is dangerous - instance of this class casted from base class,
|
||||
// so it support only functions
|
||||
|
@ -20,11 +19,6 @@ public:
|
|||
|
||||
};
|
||||
|
||||
#else // defined Q_OS_IOS
|
||||
class IpcProcessInterfaceReplica {};
|
||||
class PrivilegedProcess {};
|
||||
#endif // Q_OS_IOS
|
||||
|
||||
#endif // PRIVILEGED_PROCESS_H
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
|
@ -6,12 +7,14 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include <core/ipcclient.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "defines.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
#include <core/ipcclient.h>
|
||||
#endif
|
||||
|
||||
QFile Debug::m_file;
|
||||
QTextStream Debug::m_textStream;
|
||||
QString Debug::m_logFileName = QString("%1.log").arg(APPLICATION_NAME);
|
||||
|
@ -140,6 +143,7 @@ void Debug::clearLogs()
|
|||
|
||||
void Debug::clearServiceLogs()
|
||||
{
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
IpcClient *m_IpcClient = new IpcClient;
|
||||
|
||||
if (!m_IpcClient->isSocketConnected()) {
|
||||
|
@ -156,6 +160,7 @@ void Debug::clearServiceLogs()
|
|||
else {
|
||||
qWarning() << "Error occured cleaning up service logs";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Debug::cleanUp()
|
||||
|
|
|
@ -97,7 +97,7 @@ constexpr char ckBypassUidKeyPath[] = "/opt/amnezia/cloak/cloak_bypass_uid.key";
|
|||
constexpr char ckAdminKeyPath[] = "/opt/amnezia/cloak/cloak_admin_uid.key";
|
||||
constexpr char defaultPort[] = "443";
|
||||
constexpr char defaultRedirSite[] = "tile.openstreetmap.org";
|
||||
constexpr char defaultCipher[] = "chacha20-ietf-poly1305";
|
||||
constexpr char defaultCipher[] = "chacha20-poly1305";
|
||||
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,6 +3,7 @@
|
|||
#include "debug.h"
|
||||
#include "defines.h"
|
||||
#include "ui/qautostart.h"
|
||||
#include "ui/uilogic.h"
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
|
@ -65,22 +66,7 @@ void AppSettingsLogic::onPushButtonOpenLogsClicked()
|
|||
|
||||
void AppSettingsLogic::onPushButtonExportLogsClicked()
|
||||
{
|
||||
QString log = Debug::getLogFile();
|
||||
QString ext = ".log";
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Save log"),
|
||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*" + ext);
|
||||
|
||||
if (fileName.isEmpty()) return;
|
||||
if (!fileName.endsWith(ext)) fileName.append(ext);
|
||||
|
||||
QFile save(fileName);
|
||||
save.open(QIODevice::WriteOnly);
|
||||
save.write(log.toUtf8());
|
||||
save.close();
|
||||
|
||||
QFileInfo fi(fileName);
|
||||
QDesktopServices::openUrl(fi.absoluteDir().absolutePath());
|
||||
uiLogic()->saveTextFile(tr("Save log"), "AmneziaVPN.log", ".log", Debug::getLogFile());
|
||||
}
|
||||
|
||||
void AppSettingsLogic::onPushButtonClearLogsClicked()
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "core/errorstrings.h"
|
||||
#include <core/servercontroller.h>
|
||||
#include <QTimer>
|
||||
|
||||
ServerSettingsLogic::ServerSettingsLogic(UiLogic *logic, QObject *parent):
|
||||
PageLogicBase(logic, parent),
|
||||
|
|
|
@ -206,6 +206,6 @@ void SitesLogic::onPushButtonSitesExportClicked()
|
|||
for (auto s : sites.keys()) {
|
||||
data += s + "\t" + sites.value(s).toString() + "\n";
|
||||
}
|
||||
uiLogic()->saveTextFile("Sites", ".txt", data);
|
||||
uiLogic()->saveTextFile("Export Sites", "sites.txt", ".txt", data);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#include <QApplication>
|
||||
|
||||
#include "VpnLogic.h"
|
||||
|
||||
#include "core/errorstrings.h"
|
||||
#include "vpnconnection.h"
|
||||
#include <QTimer>
|
||||
#include <functional>
|
||||
#include "../uilogic.h"
|
||||
#include "defines.h"
|
||||
|
@ -19,6 +22,8 @@ VpnLogic::VpnLogic(UiLogic *logic, QObject *parent):
|
|||
m_labelSpeedReceivedText{tr("0 Mbps")},
|
||||
m_labelSpeedSentText{tr("0 Mbps")},
|
||||
m_labelStateText{},
|
||||
m_isContainerHaveAuthData{false},
|
||||
m_isContainerSupportedByCurrentPlatform{false},
|
||||
m_widgetVpnModeEnabled{false}
|
||||
{
|
||||
connect(uiLogic()->m_vpnConnection, &VpnConnection::bytesChanged, this, &VpnLogic::onBytesChanged);
|
||||
|
@ -49,6 +54,8 @@ void VpnLogic::onUpdatePage()
|
|||
selectedContainer == DockerContainer::ShadowSocks||
|
||||
selectedContainer == DockerContainer::Cloak);
|
||||
|
||||
set_isContainerHaveAuthData(m_settings.haveAuthData(m_settings.defaultServerIndex()));
|
||||
|
||||
set_radioButtonVpnModeAllSitesChecked(mode == Settings::VpnAllSites || !isCustomRoutesSupported());
|
||||
set_radioButtonVpnModeForwardSitesChecked(mode == Settings::VpnOnlyForwardSites && isCustomRoutesSupported());
|
||||
set_radioButtonVpnModeExceptSitesChecked(mode == Settings::VpnAllExceptSites && isCustomRoutesSupported());
|
||||
|
@ -72,8 +79,8 @@ void VpnLogic::onUpdatePage()
|
|||
}
|
||||
|
||||
|
||||
set_isContainerWorkingOnPlatform(ContainerProps::isWorkingOnPlatform(selectedContainer));
|
||||
if (!isContainerWorkingOnPlatform()) {
|
||||
set_isContainerSupportedByCurrentPlatform(ContainerProps::isSupportedByCurrentPlatform(selectedContainer));
|
||||
if (!isContainerSupportedByCurrentPlatform()) {
|
||||
set_labelErrorText(tr("AmneziaVPN not supporting selected protocol on this device. Select another protocol."));
|
||||
}
|
||||
else {
|
||||
|
@ -238,6 +245,6 @@ void VpnLogic::onConnectWorker(int serverIndex, const ServerCredentials &credent
|
|||
|
||||
void VpnLogic::onDisconnect()
|
||||
{
|
||||
set_pushButtonConnectChecked(false);
|
||||
onConnectionStateChanged(VpnProtocol::Disconnected);
|
||||
emit disconnectFromVpn();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,8 @@ class VpnLogic : public PageLogicBase
|
|||
AUTO_PROPERTY(bool, pushButtonConnectEnabled)
|
||||
AUTO_PROPERTY(bool, pushButtonConnectVisible)
|
||||
AUTO_PROPERTY(bool, widgetVpnModeEnabled)
|
||||
AUTO_PROPERTY(bool, isContainerWorkingOnPlatform)
|
||||
AUTO_PROPERTY(bool, isContainerSupportedByCurrentPlatform)
|
||||
AUTO_PROPERTY(bool, isContainerHaveAuthData)
|
||||
|
||||
AUTO_PROPERTY(QString, labelErrorText)
|
||||
AUTO_PROPERTY(QString, labelVersionText)
|
||||
|
|
|
@ -5,11 +5,13 @@ BasicButtonType {
|
|||
id: root
|
||||
property alias iconMargin: img.anchors.margins
|
||||
property alias img: img
|
||||
property int imgMargin: 4
|
||||
property int imgMarginHover: 3
|
||||
background: Item {}
|
||||
contentItem: Image {
|
||||
id: img
|
||||
source: root.icon.source
|
||||
anchors.fill: root
|
||||
anchors.margins: root.containsMouse ? 3 : 4
|
||||
anchors.margins: root.containsMouse ? imgMarginHover : imgMargin
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import QtQuick.Controls 2.12
|
|||
BasicButtonType {
|
||||
id: root
|
||||
property alias textItem: textItem
|
||||
height: 30
|
||||
|
||||
background: Item {}
|
||||
contentItem: Item {
|
||||
|
|
|
@ -42,6 +42,7 @@ PageBase {
|
|||
anchors.right: parent.right
|
||||
|
||||
CheckBoxType {
|
||||
visible: !GC.isMobile()
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("Auto connect")
|
||||
checked: AppSettingsLogic.checkBoxAutoConnectChecked
|
||||
|
@ -51,6 +52,7 @@ PageBase {
|
|||
}
|
||||
}
|
||||
CheckBoxType {
|
||||
visible: !GC.isMobile()
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("Auto start")
|
||||
checked: AppSettingsLogic.checkBoxAutostartChecked
|
||||
|
@ -60,6 +62,7 @@ PageBase {
|
|||
}
|
||||
}
|
||||
CheckBoxType {
|
||||
visible: !GC.isMobile()
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("Start minimized")
|
||||
checked: AppSettingsLogic.checkBoxStartMinimizedChecked
|
||||
|
@ -74,6 +77,7 @@ PageBase {
|
|||
text: AppSettingsLogic.labelVersionText
|
||||
}
|
||||
BlueButtonType {
|
||||
visible: !GC.isMobile()
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 41
|
||||
text: qsTr("Check for updates")
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import QtQuick.Layouts 1.15
|
||||
import QtGraphicalEffects 1.15
|
||||
import PageEnum 1.0
|
||||
import "./"
|
||||
|
@ -13,176 +14,155 @@ PageBase {
|
|||
|
||||
BackButton {
|
||||
id: back
|
||||
z: -1
|
||||
}
|
||||
|
||||
// ---------- App settings ------------
|
||||
Rectangle {
|
||||
id: l1
|
||||
visible: !GC.isMobile()
|
||||
Flickable {
|
||||
id: fl
|
||||
width: root.width
|
||||
anchors.top: back.bottom
|
||||
x: 20
|
||||
width: parent.width - 40
|
||||
height: GC.isMobile() ? 0: 1
|
||||
color: "#DDDDDD"
|
||||
}
|
||||
anchors.topMargin: 0
|
||||
anchors.bottom: root.bottom
|
||||
anchors.bottomMargin: 10
|
||||
anchors.left: root.left
|
||||
anchors.leftMargin: 30
|
||||
anchors.right: root.right
|
||||
anchors.rightMargin: 30
|
||||
|
||||
SettingButtonType {
|
||||
id: b1
|
||||
visible: !GC.isMobile()
|
||||
anchors.top: l1.bottom
|
||||
anchors.topMargin: GC.isMobile() ? 0: 15
|
||||
x: 30
|
||||
width: parent.width - 80
|
||||
height: GC.isMobile() ? 0: 30
|
||||
icon.source: "qrc:/images/svg/settings_black_24dp.svg"
|
||||
text: qsTr("App settings")
|
||||
onClicked: {
|
||||
UiLogic.goToPage(PageEnum.AppSettings)
|
||||
contentHeight: content.height
|
||||
clip: true
|
||||
|
||||
ColumnLayout {
|
||||
id: content
|
||||
enabled: logic.pageEnabled
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 10
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
spacing: 15
|
||||
|
||||
|
||||
// ---------- App settings ------------
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 1
|
||||
color: "#DDDDDD"
|
||||
}
|
||||
SettingButtonType {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 30
|
||||
icon.source: "qrc:/images/svg/settings_black_24dp.svg"
|
||||
text: qsTr("App settings")
|
||||
onClicked: {
|
||||
UiLogic.goToPage(PageEnum.AppSettings)
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- Network settings ------------
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 1
|
||||
color: "#DDDDDD"
|
||||
}
|
||||
SettingButtonType {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 30
|
||||
icon.source: "qrc:/images/svg/settings_suggest_black_24dp.svg"
|
||||
text: qsTr("Network settings")
|
||||
onClicked: {
|
||||
UiLogic.goToPage(PageEnum.NetworkSettings)
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- Server settings ------------
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 1
|
||||
color: "#DDDDDD"
|
||||
}
|
||||
SettingButtonType {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 30
|
||||
icon.source: "qrc:/images/svg/vpn_key_black_24dp.svg"
|
||||
text: qsTr("Server Settings")
|
||||
onClicked: {
|
||||
GeneralSettingsLogic.onPushButtonGeneralSettingsServerSettingsClicked()
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- Share connection ------------
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 1
|
||||
color: "#DDDDDD"
|
||||
}
|
||||
SettingButtonType {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 30
|
||||
icon.source: "qrc:/images/svg/share_black_24dp.svg"
|
||||
text: qsTr("Share connection")
|
||||
enabled: GeneralSettingsLogic.pushButtonGeneralSettingsShareConnectionEnable
|
||||
onClicked: {
|
||||
GeneralSettingsLogic.onPushButtonGeneralSettingsShareConnectionClicked()
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- Servers ------------
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 1
|
||||
color: "#DDDDDD"
|
||||
}
|
||||
SettingButtonType {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 30
|
||||
icon.source: "qrc:/images/svg/format_list_bulleted_black_24dp.svg"
|
||||
text: qsTr("Servers")
|
||||
onClicked: {
|
||||
UiLogic.goToPage(PageEnum.ServersList)
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- Add server ------------
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 1
|
||||
color: "#DDDDDD"
|
||||
}
|
||||
SettingButtonType {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 30
|
||||
icon.source: "qrc:/images/svg/control_point_black_24dp.svg"
|
||||
text: qsTr("Add server")
|
||||
onClicked: {
|
||||
UiLogic.goToPage(PageEnum.Start)
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 1
|
||||
color: "#DDDDDD"
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: fl.height > (75+1) * 6 ? fl.height - (75+1) * 6 : 0
|
||||
}
|
||||
|
||||
SettingButtonType {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 30
|
||||
Layout.bottomMargin: 20
|
||||
icon.source: "qrc:/images/svg/logout_black_24dp.svg"
|
||||
text: qsTr("Exit")
|
||||
onClicked: {
|
||||
Qt.quit()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- Network settings ------------
|
||||
Rectangle {
|
||||
id: l2
|
||||
anchors.top: b1.bottom
|
||||
anchors.topMargin: 15
|
||||
x: 20
|
||||
width: parent.width - 40
|
||||
height: 1
|
||||
color: "#DDDDDD"
|
||||
}
|
||||
SettingButtonType {
|
||||
id: b2
|
||||
x: 30
|
||||
anchors.top: l2.bottom
|
||||
anchors.topMargin: 15
|
||||
width: parent.width - 40
|
||||
height: 30
|
||||
icon.source: "qrc:/images/svg/settings_suggest_black_24dp.svg"
|
||||
text: qsTr("Network settings")
|
||||
onClicked: {
|
||||
UiLogic.goToPage(PageEnum.NetworkSettings)
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- Server settings ------------
|
||||
Rectangle {
|
||||
id: l3
|
||||
anchors.top: b2.bottom
|
||||
anchors.topMargin: 15
|
||||
x: 20
|
||||
width: parent.width - 40
|
||||
height: 1
|
||||
color: "#DDDDDD"
|
||||
}
|
||||
SettingButtonType {
|
||||
id: b3
|
||||
x: 30
|
||||
anchors.top: l3.bottom
|
||||
anchors.topMargin: 15
|
||||
width: 330
|
||||
height: 30
|
||||
icon.source: "qrc:/images/svg/vpn_key_black_24dp.svg"
|
||||
text: qsTr("Server Settings")
|
||||
onClicked: {
|
||||
GeneralSettingsLogic.onPushButtonGeneralSettingsServerSettingsClicked()
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- Share connection ------------
|
||||
Rectangle {
|
||||
id: l4
|
||||
anchors.top: b3.bottom
|
||||
anchors.topMargin: 15
|
||||
x: 20
|
||||
width: parent.width - 40
|
||||
height: 1
|
||||
color: "#DDDDDD"
|
||||
}
|
||||
SettingButtonType {
|
||||
id: b4
|
||||
x: 30
|
||||
anchors.top: l4.bottom
|
||||
anchors.topMargin: 15
|
||||
width: 330
|
||||
height: 30
|
||||
icon.source: "qrc:/images/svg/share_black_24dp.svg"
|
||||
text: qsTr("Share connection")
|
||||
enabled: GeneralSettingsLogic.pushButtonGeneralSettingsShareConnectionEnable
|
||||
onClicked: {
|
||||
GeneralSettingsLogic.onPushButtonGeneralSettingsShareConnectionClicked()
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- Servers ------------
|
||||
Rectangle {
|
||||
id: l5
|
||||
anchors.top: b4.bottom
|
||||
anchors.topMargin: 15
|
||||
x: 20
|
||||
width: parent.width - 40
|
||||
height: 1
|
||||
color: "#DDDDDD"
|
||||
}
|
||||
SettingButtonType {
|
||||
id: b5
|
||||
x: 30
|
||||
anchors.top: l5.bottom
|
||||
anchors.topMargin: 15
|
||||
width: 330
|
||||
height: 30
|
||||
icon.source: "qrc:/images/svg/format_list_bulleted_black_24dp.svg"
|
||||
text: qsTr("Servers")
|
||||
onClicked: {
|
||||
UiLogic.goToPage(PageEnum.ServersList)
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- Add server ------------
|
||||
Rectangle {
|
||||
id: l6
|
||||
anchors.top: b5.bottom
|
||||
anchors.topMargin: 15
|
||||
x: 20
|
||||
width: parent.width - 40
|
||||
height: 1
|
||||
color: "#DDDDDD"
|
||||
}
|
||||
SettingButtonType {
|
||||
id: b6
|
||||
x: 30
|
||||
anchors.top: l6.bottom
|
||||
anchors.topMargin: 15
|
||||
width: 330
|
||||
height: 30
|
||||
icon.source: "qrc:/images/svg/control_point_black_24dp.svg"
|
||||
text: qsTr("Add server")
|
||||
onClicked: {
|
||||
UiLogic.goToPage(PageEnum.Start)
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: l7
|
||||
anchors.top: b6.bottom
|
||||
anchors.topMargin: 15
|
||||
x: 20
|
||||
width: parent.width - 40
|
||||
height: 1
|
||||
color: "#DDDDDD"
|
||||
}
|
||||
|
||||
|
||||
SettingButtonType {
|
||||
x: 30
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: 20
|
||||
width: 330
|
||||
height: 30
|
||||
icon.source: "qrc:/images/svg/logout_black_24dp.svg"
|
||||
text: qsTr("Exit")
|
||||
onClicked: {
|
||||
Qt.quit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,16 +16,16 @@ PageBase {
|
|||
}
|
||||
Caption {
|
||||
id: caption
|
||||
text: qsTr("Servers list")
|
||||
text: qsTr("Servers")
|
||||
width: undefined
|
||||
}
|
||||
|
||||
SvgButtonType {
|
||||
anchors.bottom: caption.bottom
|
||||
anchors.verticalCenter: caption.verticalCenter
|
||||
anchors.leftMargin: 10
|
||||
anchors.left: caption.right
|
||||
width: 24
|
||||
height: 24
|
||||
width: 27
|
||||
height: 27
|
||||
|
||||
icon.source: "qrc:/images/svg/control_point_black_24dp.svg"
|
||||
onClicked: {
|
||||
|
|
|
@ -59,9 +59,11 @@ PageBase {
|
|||
|
||||
ImageButtonType {
|
||||
x: parent.width - 40
|
||||
y: 10
|
||||
width: 31
|
||||
height: 31
|
||||
y: 0
|
||||
width: 41
|
||||
height: 41
|
||||
imgMarginHover: 8
|
||||
imgMargin: 9
|
||||
icon.source: "qrc:/images/settings_grey.png"
|
||||
onClicked: {
|
||||
UiLogic.goToPage(PageEnum.GeneralSettings)
|
||||
|
@ -98,7 +100,7 @@ PageBase {
|
|||
}
|
||||
contentItem: Item {}
|
||||
antialiasing: true
|
||||
enabled: VpnLogic.pushButtonConnectEnabled && VpnLogic.isContainerWorkingOnPlatform
|
||||
enabled: VpnLogic.pushButtonConnectEnabled && VpnLogic.isContainerSupportedByCurrentPlatform
|
||||
opacity: VpnLogic.pushButtonConnectVisible ? 1 : 0
|
||||
|
||||
// transitions: Transition {
|
||||
|
@ -128,14 +130,14 @@ PageBase {
|
|||
LabelType {
|
||||
Layout.alignment: Qt.AlignRight
|
||||
height: 21
|
||||
text: qsTr("Server") + ": "
|
||||
text: ( VpnLogic.isContainerHaveAuthData ? qsTr("Server") : qsTr("Profile")) + ": "
|
||||
}
|
||||
|
||||
BasicButtonType {
|
||||
Layout.alignment: Qt.AlignLeft
|
||||
height: 21
|
||||
background: Item {}
|
||||
text: VpnLogic.labelCurrentServer + " →"
|
||||
text: VpnLogic.labelCurrentServer + (VpnLogic.isContainerHaveAuthData ? " →" : "")
|
||||
font.family: "Lato"
|
||||
font.styleName: "normal"
|
||||
font.pixelSize: 16
|
||||
|
@ -163,12 +165,12 @@ PageBase {
|
|||
Layout.alignment: Qt.AlignLeft
|
||||
height: 21
|
||||
background: Item {}
|
||||
text: VpnLogic.labelCurrentService + " →"
|
||||
text: VpnLogic.labelCurrentService + (VpnLogic.isContainerHaveAuthData ? " →" : "")
|
||||
font.family: "Lato"
|
||||
font.styleName: "normal"
|
||||
font.pixelSize: 16
|
||||
onClicked: {
|
||||
UiLogic.onGotoCurrentProtocolsPage()
|
||||
if (VpnLogic.isContainerHaveAuthData) UiLogic.onGotoCurrentProtocolsPage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -192,12 +194,12 @@ PageBase {
|
|||
height: 21
|
||||
implicitWidth: implicitContentWidth > root.width * 0.6 ? root.width * 0.6 : implicitContentWidth + leftPadding + rightPadding
|
||||
background: Item {}
|
||||
text: VpnLogic.labelCurrentDns + " →"
|
||||
text: VpnLogic.labelCurrentDns + (VpnLogic.isContainerHaveAuthData ? " →" : "")
|
||||
font.family: "Lato"
|
||||
font.styleName: "normal"
|
||||
font.pixelSize: 16
|
||||
onClicked: {
|
||||
UiLogic.goToPage(PageEnum.NetworkSettings)
|
||||
if (VpnLogic.isContainerHaveAuthData) UiLogic.goToPage(PageEnum.NetworkSettings)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ New encryption keys pair will be generated.")
|
|||
visible: tfShareCode.textArea.length > 0
|
||||
|
||||
onClicked: {
|
||||
UiLogic.saveTextFile(qsTr("Save AmneziaVPN config"), "*.vpn", tfShareCode.textArea.text)
|
||||
UiLogic.saveTextFile(qsTr("Save AmneziaVPN config"), "amnezia_config.vpn", "*.vpn", tfShareCode.textArea.text)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ PageShareProtocolBase {
|
|||
visible: tfShareCode.textArea.length > 0
|
||||
|
||||
onClicked: {
|
||||
UiLogic.saveTextFile(qsTr("Save AmneziaVPN config"), "*.json", tfShareCode.textArea.text)
|
||||
UiLogic.saveTextFile(qsTr("Save AmneziaVPN config"), "amnezia_config_cloak.json", "*.json", tfShareCode.textArea.text)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ PageShareProtocolBase {
|
|||
visible: tfCert.textArea.length > 0
|
||||
|
||||
onClicked: {
|
||||
UiLogic.saveTextFile(qsTr("Export p12 certificate"), "*.p12", tfCert.textArea.text)
|
||||
UiLogic.saveTextFile(qsTr("Export p12 certificate"), "amnezia_ikev2_cert_for_windows.p12", "*.p12", tfCert.textArea.text)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ PageShareProtocolBase {
|
|||
visible: tfMobileConfig.textArea.length > 0
|
||||
|
||||
onClicked: {
|
||||
UiLogic.saveTextFile(qsTr("Export config for Apple"), "*.plist", tfMobileConfig.textArea.text)
|
||||
UiLogic.saveTextFile(qsTr("Export config for Apple"), "amnezia_for_apple.plist", "*.plist", tfMobileConfig.textArea.text)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ PageShareProtocolBase {
|
|||
visible: tfStrongSwanConfig.textArea.length > 0
|
||||
|
||||
onClicked: {
|
||||
UiLogic.saveTextFile(qsTr("Export config for StrongSwan"), "*.profile", tfStrongSwanConfig.textArea.text)
|
||||
UiLogic.saveTextFile(qsTr("Export config for StrongSwan"), "amnezia_for_StrongSwan.profile", "*.profile", tfStrongSwanConfig.textArea.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ PageShareProtocolBase {
|
|||
visible: tfShareCode.textArea.length > 0
|
||||
|
||||
onClicked: {
|
||||
UiLogic.saveTextFile(qsTr("Save OpenVPN config"), "*.ovpn", tfShareCode.textArea.text)
|
||||
UiLogic.saveTextFile(qsTr("Save OpenVPN config"), "amnezia_for_openvpn.ovpn", "*.ovpn", tfShareCode.textArea.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ PageShareProtocolBase {
|
|||
visible: tfShareCode.textArea.length > 0
|
||||
|
||||
onClicked: {
|
||||
UiLogic.saveTextFile(qsTr("Save OpenVPN config"), "*.conf", tfShareCode.textArea.text)
|
||||
UiLogic.saveTextFile(qsTr("Save OpenVPN config"), "amnezia_for_wireguard.conf", "*.conf", tfShareCode.textArea.text)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ Window {
|
|||
height: GC.isDesktop() ? GC.screenHeight + titleBar.height : GC.screenHeight
|
||||
minimumWidth: 360
|
||||
minimumHeight: GC.isDesktop() ? 640 : 0
|
||||
Keys.enabled: true
|
||||
onClosing: {
|
||||
console.debug("QML onClosing signal")
|
||||
UiLogic.onCloseWindow()
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <QThread>
|
||||
#include <QTimer>
|
||||
#include <QRegularExpression>
|
||||
#include <QQmlFile>
|
||||
|
||||
#include "configurators/cloak_configurator.h"
|
||||
#include "configurators/vpn_configurator.h"
|
||||
|
@ -29,7 +30,6 @@
|
|||
#include "core/errorstrings.h"
|
||||
|
||||
#include "containers/containers_defs.h"
|
||||
#include "protocols/shadowsocksvpnprotocol.h"
|
||||
|
||||
#include "ui/qautostart.h"
|
||||
|
||||
|
@ -135,6 +135,11 @@ UiLogic::~UiLogic()
|
|||
void UiLogic::initalizeUiLogic()
|
||||
{
|
||||
#ifdef Q_OS_ANDROID
|
||||
connect(AndroidController::instance(), &AndroidController::initialized, [this](bool status, bool connected, const QDateTime& connectionDate) {
|
||||
if (connected) {
|
||||
vpnLogic()->onConnectionStateChanged(VpnProtocol::Connected);
|
||||
}
|
||||
});
|
||||
if (!AndroidController::instance()->initialize()) {
|
||||
qDebug() << QString("Init failed") ;
|
||||
emit VpnProtocol::Error;
|
||||
|
@ -605,21 +610,52 @@ PageEnumNS::Page UiLogic::currentPage()
|
|||
return static_cast<PageEnumNS::Page>(currentPageValue());
|
||||
}
|
||||
|
||||
void UiLogic::saveTextFile(const QString& desc, QString ext, const QString& data)
|
||||
void UiLogic::saveTextFile(const QString& desc, const QString& suggestedName, QString ext, const QString& data)
|
||||
{
|
||||
// ext.replace("*", "");
|
||||
// QString fileName = QFileDialog::getSaveFileName(nullptr, desc,
|
||||
// QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*" + ext);
|
||||
|
||||
// if (fileName.isEmpty()) return;
|
||||
// if (!fileName.endsWith(ext)) fileName.append(ext);
|
||||
|
||||
// QFile save(fileName);
|
||||
// save.open(QIODevice::WriteOnly);
|
||||
// save.write(data.toUtf8());
|
||||
// save.close();
|
||||
|
||||
// QFileInfo fi(fileName);
|
||||
// QDesktopServices::openUrl(fi.absoluteDir().absolutePath());
|
||||
|
||||
|
||||
ext.replace("*", "");
|
||||
QString fileName = QFileDialog::getSaveFileName(nullptr, desc,
|
||||
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "*" + ext);
|
||||
|
||||
QString docDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
|
||||
QUrl fileName;
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
fileName = QFileDialog::getSaveFileUrl(nullptr, desc,
|
||||
QUrl::fromLocalFile(docDir + "/" + suggestedName), "*" + ext);
|
||||
if (fileName.isEmpty()) return;
|
||||
if (!fileName.endsWith(ext)) fileName.append(ext);
|
||||
if (!fileName.toString().endsWith(ext)) fileName = QUrl(fileName.toString() + ext);
|
||||
#elif defined Q_OS_ANDROID
|
||||
fileName = QFileDialog::getSaveFileUrl(nullptr, suggestedName,
|
||||
QUrl::fromLocalFile(docDir), "*" + ext);
|
||||
#endif
|
||||
|
||||
qDebug() << "UiLogic::saveTextFile" << fileName;
|
||||
if (fileName.isEmpty()) return;
|
||||
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
QFile save(fileName.toLocalFile());
|
||||
#else
|
||||
qDebug() << "UiLogic::saveTextFile" << QQmlFile::urlToLocalFileOrQrc(fileName);
|
||||
QFile save(QQmlFile::urlToLocalFileOrQrc(fileName));
|
||||
#endif
|
||||
|
||||
QFile save(fileName);
|
||||
save.open(QIODevice::WriteOnly);
|
||||
save.write(data.toUtf8());
|
||||
save.close();
|
||||
|
||||
QFileInfo fi(fileName);
|
||||
QFileInfo fi(fileName.toLocalFile());
|
||||
QDesktopServices::openUrl(fi.absoluteDir().absolutePath());
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ public:
|
|||
|
||||
Q_INVOKABLE void keyPressEvent(Qt::Key key);
|
||||
|
||||
Q_INVOKABLE void saveTextFile(const QString& desc, QString ext, const QString& data);
|
||||
Q_INVOKABLE void saveTextFile(const QString& desc, const QString &suggestedName, QString ext, const QString& data);
|
||||
Q_INVOKABLE void saveBinaryFile(const QString& desc, QString ext, const QString& data);
|
||||
Q_INVOKABLE void copyToClipboard(const QString& text);
|
||||
|
||||
|
|
|
@ -10,7 +10,12 @@
|
|||
#include <configurators/wireguard_configurator.h>
|
||||
#include <configurators/vpn_configurator.h>
|
||||
#include <core/servercontroller.h>
|
||||
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
#include "ipc.h"
|
||||
#include "core/ipcclient.h"
|
||||
#include <protocols/wireguardprotocol.h>
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include "android_controller.h"
|
||||
|
@ -21,9 +26,6 @@
|
|||
#include <protocols/ios_vpnprotocol.h>
|
||||
#endif
|
||||
|
||||
#include "ipc.h"
|
||||
#include "core/ipcclient.h"
|
||||
|
||||
#include "utils.h"
|
||||
#include "vpnconnection.h"
|
||||
|
||||
|
@ -48,6 +50,7 @@ void VpnConnection::onBytesChanged(quint64 receivedBytes, quint64 sentBytes)
|
|||
|
||||
void VpnConnection::onConnectionStateChanged(VpnProtocol::VpnConnectionState state)
|
||||
{
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
if (IpcClient::Interface()) {
|
||||
if (state == VpnProtocol::Connected){
|
||||
IpcClient::Interface()->resetIpStack();
|
||||
|
@ -87,7 +90,7 @@ void VpnConnection::onConnectionStateChanged(VpnProtocol::VpnConnectionState sta
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
emit connectionStateChanged(state);
|
||||
}
|
||||
|
||||
|
@ -98,6 +101,7 @@ const QString &VpnConnection::remoteAddress() const
|
|||
|
||||
void VpnConnection::addSitesRoutes(const QString &gw, Settings::RouteMode mode)
|
||||
{
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
QStringList ips;
|
||||
QStringList sites;
|
||||
const QVariantMap &m = m_settings.vpnSites(mode);
|
||||
|
@ -137,6 +141,7 @@ void VpnConnection::addSitesRoutes(const QString &gw, Settings::RouteMode mode)
|
|||
};
|
||||
QHostInfo::lookupHost(site, this, cbResolv);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
QSharedPointer<VpnProtocol> VpnConnection::vpnProtocol() const
|
||||
|
@ -146,6 +151,7 @@ QSharedPointer<VpnProtocol> VpnConnection::vpnProtocol() const
|
|||
|
||||
void VpnConnection::addRoutes(const QStringList &ips)
|
||||
{
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
if (connectionState() == VpnProtocol::Connected && IpcClient::Interface()) {
|
||||
if (m_settings.routeMode() == Settings::VpnOnlyForwardSites) {
|
||||
IpcClient::Interface()->routeAddList(m_vpnProtocol->vpnGateway(), ips);
|
||||
|
@ -154,10 +160,12 @@ void VpnConnection::addRoutes(const QStringList &ips)
|
|||
IpcClient::Interface()->routeAddList(m_vpnProtocol->routeGateway(), ips);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void VpnConnection::deleteRoutes(const QStringList &ips)
|
||||
{
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
if (connectionState() == VpnProtocol::Connected && IpcClient::Interface()) {
|
||||
if (m_settings.routeMode() == Settings::VpnOnlyForwardSites) {
|
||||
IpcClient::Interface()->routeDeleteList(vpnProtocol()->vpnGateway(), ips);
|
||||
|
@ -166,11 +174,14 @@ void VpnConnection::deleteRoutes(const QStringList &ips)
|
|||
IpcClient::Interface()->routeDeleteList(m_vpnProtocol->routeGateway(), ips);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void VpnConnection::flushDns()
|
||||
{
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
if (IpcClient::Interface()) IpcClient::Interface()->flushDns();
|
||||
#endif
|
||||
}
|
||||
|
||||
ErrorCode VpnConnection::lastError() const
|
||||
|
@ -351,6 +362,7 @@ void VpnConnection::disconnectFromVpn()
|
|||
{
|
||||
// qDebug() << "Disconnect from VPN 1";
|
||||
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
if (IpcClient::Interface()) {
|
||||
IpcClient::Interface()->flushDns();
|
||||
|
||||
|
@ -358,8 +370,15 @@ void VpnConnection::disconnectFromVpn()
|
|||
QRemoteObjectPendingReply<bool> response = IpcClient::Interface()->clearSavedRoutes();
|
||||
response.waitForFinished(1000);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
if (!m_vpnProtocol.data()) {
|
||||
emit connectionStateChanged(VpnProtocol::Disconnected);
|
||||
#ifdef Q_OS_ANDROID
|
||||
AndroidController::instance()->stop();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
m_vpnProtocol.data()->stop();
|
||||
|
|
|
@ -8,9 +8,12 @@
|
|||
|
||||
#include "protocols/vpnprotocol.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/ipcclient.h"
|
||||
#include "settings.h"
|
||||
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
#include "core/ipcclient.h"
|
||||
#endif
|
||||
|
||||
using namespace amnezia;
|
||||
|
||||
class VpnConnection : public QObject
|
||||
|
@ -74,8 +77,10 @@ private:
|
|||
QJsonObject m_vpnConfiguration;
|
||||
QJsonObject m_routeMode;
|
||||
QString m_remoteAddress;
|
||||
IpcClient *m_IpcClient {nullptr};
|
||||
|
||||
#ifdef AMNEZIA_DESKTOP
|
||||
IpcClient *m_IpcClient {nullptr};
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // VPNCONNECTION_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue