mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-22 02:01:08 +07:00
Merge branch 'dev' of github.com:amnezia-vpn/amnezia-client into feature/api-awg
This commit is contained in:
@@ -327,7 +327,8 @@ void ExportController::updateClientManagementModel(const DockerContainer contain
|
||||
|
||||
void ExportController::revokeConfig(const int row, const DockerContainer container, ServerCredentials credentials)
|
||||
{
|
||||
ErrorCode errorCode = m_clientManagementModel->revokeClient(row, container, credentials);
|
||||
ErrorCode errorCode = m_clientManagementModel->revokeClient(row, container, credentials,
|
||||
m_serversModel->getCurrentlyProcessedServerIndex());
|
||||
if (errorCode != ErrorCode::NoError) {
|
||||
emit exportErrorOccurred(errorString(errorCode));
|
||||
}
|
||||
|
||||
@@ -296,30 +296,36 @@ ErrorCode ClientManagementModel::renameClient(const int row, const QString &clie
|
||||
}
|
||||
|
||||
ErrorCode ClientManagementModel::revokeClient(const int row, const DockerContainer container,
|
||||
ServerCredentials credentials)
|
||||
ServerCredentials credentials, const int serverIndex)
|
||||
{
|
||||
ErrorCode errorCode = ErrorCode::NoError;
|
||||
auto client = m_clientsTable.at(row).toObject();
|
||||
QString clientId = client.value(configKey::clientId).toString();
|
||||
|
||||
if (container == DockerContainer::OpenVpn || container == DockerContainer::ShadowSocks
|
||||
|| container == DockerContainer::Cloak) {
|
||||
errorCode = revokeOpenVpn(row, container, credentials);
|
||||
errorCode = revokeOpenVpn(row, container, credentials, serverIndex);
|
||||
} else if (container == DockerContainer::WireGuard || container == DockerContainer::Awg) {
|
||||
errorCode = revokeWireGuard(row, container, credentials);
|
||||
}
|
||||
|
||||
if (errorCode == ErrorCode::NoError) {
|
||||
auto client = m_clientsTable.at(row).toObject();
|
||||
QString clientId = client.value(configKey::clientId).toString();
|
||||
|
||||
const auto server = m_settings->defaultServer();
|
||||
const auto server = m_settings->server(serverIndex);
|
||||
QJsonArray containers = server.value(config_key::containers).toArray();
|
||||
for (auto i = 0; i < containers.size(); i++) {
|
||||
auto containerConfig = containers.at(i).toObject();
|
||||
auto containerType = ContainerProps::containerFromString(containerConfig.value(config_key::container).toString());
|
||||
auto protocolConfig = containerConfig.value(ContainerProps::containerTypeToString(containerType)).toObject();
|
||||
if (containerType == container) {
|
||||
QJsonObject protocolConfig;
|
||||
if (container == DockerContainer::ShadowSocks || container == DockerContainer::Cloak) {
|
||||
protocolConfig = containerConfig.value(ContainerProps::containerTypeToString(DockerContainer::OpenVpn)).toObject();
|
||||
} else {
|
||||
protocolConfig = containerConfig.value(ContainerProps::containerTypeToString(containerType)).toObject();
|
||||
}
|
||||
|
||||
if (protocolConfig.value(config_key::last_config).toString().contains(clientId)) {
|
||||
emit adminConfigRevoked(container);
|
||||
if (protocolConfig.value(config_key::last_config).toString().contains(clientId)) {
|
||||
emit adminConfigRevoked(container);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -328,7 +334,7 @@ ErrorCode ClientManagementModel::revokeClient(const int row, const DockerContain
|
||||
}
|
||||
|
||||
ErrorCode ClientManagementModel::revokeOpenVpn(const int row, const DockerContainer container,
|
||||
ServerCredentials credentials)
|
||||
ServerCredentials credentials, const int serverIndex)
|
||||
{
|
||||
auto client = m_clientsTable.at(row).toObject();
|
||||
QString clientId = client.value(configKey::clientId).toString();
|
||||
@@ -337,6 +343,7 @@ ErrorCode ClientManagementModel::revokeOpenVpn(const int row, const DockerContai
|
||||
"cd /opt/amnezia/openvpn ;\\"
|
||||
"easyrsa revoke %1 ;\\"
|
||||
"easyrsa gen-crl ;\\"
|
||||
"chmod 666 pki/crl.pem ;\\"
|
||||
"cp pki/crl.pem .'")
|
||||
.arg(clientId);
|
||||
|
||||
@@ -356,12 +363,7 @@ ErrorCode ClientManagementModel::revokeOpenVpn(const int row, const DockerContai
|
||||
const QByteArray clientsTableString = QJsonDocument(m_clientsTable).toJson();
|
||||
|
||||
QString clientsTableFile = QString("/opt/amnezia/%1/clientsTable");
|
||||
if (container == DockerContainer::OpenVpn || container == DockerContainer::ShadowSocks
|
||||
|| container == DockerContainer::Cloak) {
|
||||
clientsTableFile = clientsTableFile.arg(ContainerProps::containerTypeToString(DockerContainer::OpenVpn));
|
||||
} else {
|
||||
clientsTableFile = clientsTableFile.arg(ContainerProps::containerTypeToString(container));
|
||||
}
|
||||
clientsTableFile = clientsTableFile.arg(ContainerProps::containerTypeToString(DockerContainer::OpenVpn));
|
||||
error = serverController.uploadTextFileToContainer(container, credentials, clientsTableString, clientsTableFile);
|
||||
if (error != ErrorCode::NoError) {
|
||||
logger.error() << "Failed to upload the clientsTable file to the server";
|
||||
|
||||
@@ -28,7 +28,7 @@ public slots:
|
||||
ServerCredentials credentials);
|
||||
ErrorCode renameClient(const int row, const QString &userName, const DockerContainer container,
|
||||
ServerCredentials credentials, bool addTimeStamp = false);
|
||||
ErrorCode revokeClient(const int index, const DockerContainer container, ServerCredentials credentials);
|
||||
ErrorCode revokeClient(const int index, const DockerContainer container, ServerCredentials credentials, const int serverIndex);
|
||||
|
||||
protected:
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
@@ -41,7 +41,7 @@ private:
|
||||
|
||||
void migration(const QByteArray &clientsTableString);
|
||||
|
||||
ErrorCode revokeOpenVpn(const int row, const DockerContainer container, ServerCredentials credentials);
|
||||
ErrorCode revokeOpenVpn(const int row, const DockerContainer container, ServerCredentials credentials, const int serverIndex);
|
||||
ErrorCode revokeWireGuard(const int row, const DockerContainer container, ServerCredentials credentials);
|
||||
|
||||
ErrorCode getOpenVpnClients(ServerController &serverController, DockerContainer container, ServerCredentials credentials, int &count);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "ikev2ConfigModel.h".h "
|
||||
#include "ikev2ConfigModel.h"
|
||||
|
||||
#include "protocols/protocols_defs.h"
|
||||
|
||||
|
||||
@@ -251,10 +251,9 @@ void ServersModel::addServer(const QJsonObject &server)
|
||||
|
||||
void ServersModel::editServer(const QJsonObject &server)
|
||||
{
|
||||
beginResetModel();
|
||||
m_settings->editServer(m_currentlyProcessedServerIndex, server);
|
||||
m_servers = m_settings->serversArray();
|
||||
endResetModel();
|
||||
m_servers.replace(m_currentlyProcessedServerIndex, m_settings->serversArray().at(m_currentlyProcessedServerIndex));
|
||||
emit dataChanged(index(m_currentlyProcessedServerIndex, 0), index(m_currentlyProcessedServerIndex, 0));
|
||||
updateContainersModel();
|
||||
}
|
||||
|
||||
|
||||
@@ -124,8 +124,13 @@ void Autostart::setAutostart(bool autostart) {
|
||||
if (file.open(QIODevice::ReadWrite)) {
|
||||
QTextStream stream(&file);
|
||||
stream << "[Desktop Entry]" << Qt::endl;
|
||||
stream << "Exec=" << appPath() << Qt::endl;
|
||||
stream << "Exec=AmneziaVPN" << Qt::endl;
|
||||
stream << "Type=Application" << Qt::endl;
|
||||
stream << "Name=AmneziaVPN" << Qt::endl;
|
||||
stream << "Comment=Client of your self-hosted VPN" << Qt::endl;
|
||||
stream << "Icon=/usr/share/pixmaps/AmneziaVPN.png" << Qt::endl;
|
||||
stream << "Categories=Network;Qt;Security;" << Qt::endl;
|
||||
stream << "Terminal=false" << Qt::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,9 @@ ListView {
|
||||
target: ServersModel
|
||||
|
||||
function onCurrentlyProcessedServerIndexChanged() {
|
||||
menuContent.checkCurrentItem()
|
||||
if (ContainersModel.getDefaultContainer()) {
|
||||
menuContent.checkCurrentItem()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,9 +78,8 @@ ListView {
|
||||
}
|
||||
|
||||
if (checked) {
|
||||
ServersModel.setDefaultContainer(proxyContainersModel.mapToSource(index))
|
||||
|
||||
containersDropDown.menuVisible = false
|
||||
ServersModel.setDefaultContainer(proxyContainersModel.mapToSource(index))
|
||||
} else {
|
||||
if (!isSupported && isInstalled) {
|
||||
PageController.showErrorMessage(qsTr("The selected protocol is not supported on the current platform"))
|
||||
|
||||
@@ -25,7 +25,7 @@ DrawerType {
|
||||
|
||||
property string configExtension: ".vpn"
|
||||
property string configCaption: qsTr("Save AmneziaVPN config")
|
||||
property string configFileName: "amnezia_config.vpn"
|
||||
property string configFileName: "amnezia_config"
|
||||
|
||||
width: parent.width
|
||||
height: parent.height * 0.9
|
||||
|
||||
@@ -81,7 +81,7 @@ PageType {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 32
|
||||
|
||||
headerText: qsTr("VPN Addresses Subnet")
|
||||
headerText: qsTr("VPN address subnet")
|
||||
textFieldText: subnetAddress
|
||||
|
||||
textField.onEditingFinished: {
|
||||
|
||||
@@ -91,7 +91,7 @@ PageType {
|
||||
|
||||
onLinkActivated: Qt.openUrlExternally(link)
|
||||
textFormat: Text.RichText
|
||||
text: qsTr("Use <a href=\"https://www.torproject.org/download/\" style=\"color: #FBB26A;\">Tor Browser</a> to open this url.")
|
||||
text: qsTr("Use <a href=\"https://www.torproject.org/download/\" style=\"color: #FBB26A;\">Tor Browser</a> to open this URL.")
|
||||
}
|
||||
|
||||
ParagraphTextType {
|
||||
@@ -100,7 +100,7 @@ PageType {
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
|
||||
text: qsTr("After installation it takes several minutes while your onion site will become available in the Tor Network.")
|
||||
text: qsTr("After creating your onion site, it takes a few minutes for the Tor network to make it available for use.")
|
||||
}
|
||||
|
||||
ParagraphTextType {
|
||||
|
||||
@@ -53,7 +53,7 @@ PageType {
|
||||
Layout.leftMargin: 16
|
||||
Layout.rightMargin: 16
|
||||
|
||||
text: qsTr("Support the project with a donation")
|
||||
text: qsTr("Support Amnezia")
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ PageType {
|
||||
Layout.fillWidth: true
|
||||
|
||||
text: qsTr("DNS servers")
|
||||
descriptionText: qsTr("If AmneziaDNS is not used or installed")
|
||||
descriptionText: qsTr("When AmneziaDNS is not used or installed")
|
||||
rightImageSource: "qrc:/images/controls/chevron-right.svg"
|
||||
|
||||
clickedFunction: function() {
|
||||
@@ -117,7 +117,7 @@ PageType {
|
||||
Layout.fillWidth: true
|
||||
|
||||
text: qsTr("App-based split tunneling")
|
||||
descriptionText: qsTr("Allows you to use the VPN only for certain applications")
|
||||
descriptionText: qsTr("Allows you to use the VPN only for certain Apps")
|
||||
rightImageSource: "qrc:/images/controls/chevron-right.svg"
|
||||
|
||||
clickedFunction: function() {
|
||||
|
||||
@@ -66,8 +66,8 @@ PageType {
|
||||
|
||||
ColumnLayout {
|
||||
Layout.alignment: Qt.AlignBaseline
|
||||
Layout.preferredWidth: Qt.platform.os === "ios"? 0 : root.width / 3
|
||||
visible: Qt.platform.os !== "ios"
|
||||
Layout.preferredWidth: GC.isMobile() ? 0 : root.width / 3
|
||||
visible: !GC.isMobile()
|
||||
|
||||
ImageButtonType {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
@@ -91,7 +91,7 @@ PageType {
|
||||
|
||||
ColumnLayout {
|
||||
Layout.alignment: Qt.AlignBaseline
|
||||
Layout.preferredWidth: root.width / ( Qt.platform.os === "ios" ? 2 : 3 )
|
||||
Layout.preferredWidth: root.width / ( GC.isMobile() ? 2 : 3 )
|
||||
|
||||
ImageButtonType {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
@@ -132,7 +132,7 @@ PageType {
|
||||
|
||||
ColumnLayout {
|
||||
Layout.alignment: Qt.AlignBaseline
|
||||
Layout.preferredWidth: root.width / ( Qt.platform.os === "ios" ? 2 : 3 )
|
||||
Layout.preferredWidth: root.width / ( GC.isMobile() ? 2 : 3 )
|
||||
|
||||
ImageButtonType {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
@@ -56,7 +56,7 @@ PageType {
|
||||
|
||||
QtObject {
|
||||
id: onlyForwardSites
|
||||
property string name: qsTr("Addresses from the list should be accessed via VPN")
|
||||
property string name: qsTr("Only the sites listed here will be accessed through the VPN")
|
||||
property int type: routeMode.onlyForwardSites
|
||||
}
|
||||
QtObject {
|
||||
@@ -251,7 +251,7 @@ PageType {
|
||||
TextFieldWithHeaderType {
|
||||
Layout.fillWidth: true
|
||||
|
||||
textFieldPlaceholderText: qsTr("Site or IP")
|
||||
textFieldPlaceholderText: qsTr("website or IP")
|
||||
buttonImageSource: "qrc:/images/controls/plus.svg"
|
||||
|
||||
clickedFunc: function() {
|
||||
@@ -295,7 +295,7 @@ PageType {
|
||||
Layout.fillWidth: true
|
||||
Layout.margins: 16
|
||||
|
||||
headerText: qsTr("Import/Export Sites")
|
||||
headerText: qsTr("Import / Export Sites")
|
||||
}
|
||||
|
||||
LabelWithButtonType {
|
||||
|
||||
@@ -73,7 +73,7 @@ PageType {
|
||||
property bool hidePassword: true
|
||||
|
||||
Layout.fillWidth: true
|
||||
headerText: qsTr("Password / SSH private key")
|
||||
headerText: qsTr("Password or SSH private key")
|
||||
textField.echoMode: hidePassword ? TextInput.Password : TextInput.Normal
|
||||
buttonImageSource: textFieldText !== "" ? (hidePassword ? "qrc:/images/controls/eye.svg" : "qrc:/images/controls/eye-off.svg")
|
||||
: ""
|
||||
|
||||
@@ -112,7 +112,7 @@ PageType {
|
||||
var defaultContainerProto = ContainerProps.defaultProtocol(dockerContainer)
|
||||
|
||||
containers.dockerContainer = dockerContainer
|
||||
containers.containerDefaultPort = ProtocolProps.defaultPort(defaultContainerProto)
|
||||
containers.containerDefaultPort = ProtocolProps.getPortForInstall(defaultContainerProto)
|
||||
containers.containerDefaultTransportProto = ProtocolProps.defaultTransportProto(defaultContainerProto)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user