From 3f7e7f260113b65db04b7d595be921212041bec2 Mon Sep 17 00:00:00 2001 From: "vladimir.kuznetsov" Date: Fri, 25 Aug 2023 09:20:42 +0500 Subject: [PATCH] fixed native wireguard config import if there is no port in the Endpoint field --- client/ui/controllers/importController.cpp | 9 +++++++-- client/ui/controllers/pageController.cpp | 2 ++ client/ui/controllers/sitesController.cpp | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/client/ui/controllers/importController.cpp b/client/ui/controllers/importController.cpp index b5d10abf..81ab313b 100644 --- a/client/ui/controllers/importController.cpp +++ b/client/ui/controllers/importController.cpp @@ -225,12 +225,17 @@ QJsonObject ImportController::extractWireGuardConfig(const QString &data) QJsonObject lastConfig; lastConfig[config_key::config] = data; - const static QRegularExpression hostNameAndPortRegExp("Endpoint = (.*):([0-9]*)"); + const static QRegularExpression hostNameAndPortRegExp("Endpoint = (.*)(?::([0-9]*))?"); QRegularExpressionMatch hostNameAndPortMatch = hostNameAndPortRegExp.match(data); QString hostName; QString port; - if (hostNameAndPortMatch.hasMatch()) { + if (hostNameAndPortMatch.hasCaptured(1)) { hostName = hostNameAndPortMatch.captured(1); + } /*else { + qDebug() << "send error?" + }*/ + + if (hostNameAndPortMatch.hasCaptured(2)) { port = hostNameAndPortMatch.captured(2); } diff --git a/client/ui/controllers/pageController.cpp b/client/ui/controllers/pageController.cpp index d0c219c1..84d2ebf2 100644 --- a/client/ui/controllers/pageController.cpp +++ b/client/ui/controllers/pageController.cpp @@ -28,8 +28,10 @@ PageController::PageController(const QSharedPointer &serversModel, }); #endif +#if defined Q_OS_MACX connect(this, &PageController::raiseMainWindow, []() { setDockIconVisible(true); }); connect(this, &PageController::hideMainWindow, []() { setDockIconVisible(false); }); +#endif } QString PageController::getInitialPage() diff --git a/client/ui/controllers/sitesController.cpp b/client/ui/controllers/sitesController.cpp index d19f5758..80cac698 100644 --- a/client/ui/controllers/sitesController.cpp +++ b/client/ui/controllers/sitesController.cpp @@ -4,6 +4,7 @@ #include #include "fileUtilites.h" +#include "utilities.h" SitesController::SitesController(const std::shared_ptr &settings, const QSharedPointer &vpnConnection,