mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-05-08 14:33:23 +00:00
* Add network status check for AWG/WG protocol * Use service for PingSender * Cleanup unused code * Use networkchecker for all protocols * fix android build * add delay for ping checker stop * handle for interafe problems on windows * Restart IpcClient after OS suspend * Add DBus network checker for Linux * Use ping check for tun interfce * Windows suspend mode handler * MacOS suspend mode handler draft * Add delay for Linux wakeup reconnect * Add delay for Linux wakeup reconnect * Fix macOS wakeup/sleep prob Fix macOS not receiving wakeup/sleep events * fix done * Update deploy.yml fix CICD * Update vpnconnection.cpp update fix build CICD * Update vpnconnection.cpp update fix build cicd macos * Update deploy.yml fix CICD build macos * Update deploy.yml fix CICD macos * feat: implement SCP write buffer, improve network check and refactor macOS OpenGL support * feat: add tunnel addresses updated signal and handle network check based on gateway and local address availability * refactor: improve IpcClient connection handling and instance management * fix: scp revert. * fix: cmake reverted. * fix: submodules updated --------- Co-authored-by: Mykola Baibuz <mykola.baibuz@gmail.com> Co-authored-by: Yaroslav Yashin <yaroslav.yashin@gmail.com> Co-authored-by: vkamn <vk@amnezia.org>
80 lines
2.6 KiB
C++
80 lines
2.6 KiB
C++
#include <QCoreApplication>
|
|
#include <QFileInfo>
|
|
#include <QProcess>
|
|
#include <QTcpSocket>
|
|
#include <QThread>
|
|
|
|
#include "wireguardprotocol.h"
|
|
#include "core/networkUtilities.h"
|
|
|
|
#include "mozilla/localsocketcontroller.h"
|
|
|
|
WireguardProtocol::WireguardProtocol(const QJsonObject &configuration, QObject *parent)
|
|
: VpnProtocol(configuration, parent)
|
|
{
|
|
m_impl.reset(new LocalSocketController());
|
|
connect(m_impl.get(), &ControllerImpl::connected, this,
|
|
[this](const QString &pubkey, const QDateTime &connectionTimestamp) {
|
|
emit connectionStateChanged(Vpn::ConnectionState::Connected);
|
|
});
|
|
connect(m_impl.get(), &ControllerImpl::statusUpdated, this,
|
|
[this](const QString& serverIpv4Gateway,
|
|
const QString& deviceIpv4Address, uint64_t txBytes,
|
|
uint64_t rxBytes) {
|
|
const QString previousGateway = m_vpnGateway;
|
|
const QString previousLocal = m_vpnLocalAddress;
|
|
|
|
if (!serverIpv4Gateway.isEmpty()) {
|
|
m_vpnGateway = serverIpv4Gateway;
|
|
}
|
|
if (!deviceIpv4Address.isEmpty()) {
|
|
m_vpnLocalAddress = deviceIpv4Address;
|
|
}
|
|
|
|
if ((!m_vpnGateway.isEmpty() && m_vpnGateway != previousGateway) ||
|
|
(!m_vpnLocalAddress.isEmpty() && m_vpnLocalAddress != previousLocal)) {
|
|
emit tunnelAddressesUpdated(m_vpnGateway, m_vpnLocalAddress);
|
|
}
|
|
});
|
|
|
|
connect(m_impl.get(), &ControllerImpl::disconnected, this,
|
|
[this]() { emit connectionStateChanged(Vpn::ConnectionState::Disconnected); });
|
|
m_impl->initialize(nullptr, nullptr);
|
|
}
|
|
|
|
WireguardProtocol::~WireguardProtocol()
|
|
{
|
|
WireguardProtocol::stop();
|
|
QThread::msleep(200);
|
|
}
|
|
|
|
void WireguardProtocol::stop()
|
|
{
|
|
stopMzImpl();
|
|
return;
|
|
}
|
|
|
|
ErrorCode WireguardProtocol::startMzImpl()
|
|
{
|
|
QString protocolName = m_rawConfig.value("protocol").toString();
|
|
QJsonObject vpnConfigData = m_rawConfig.value(protocolName + "_config_data").toObject();
|
|
vpnConfigData[config_key::hostName] = NetworkUtilities::getIPAddress(vpnConfigData.value(config_key::hostName).toString());
|
|
m_rawConfig.insert(protocolName + "_config_data", vpnConfigData);
|
|
m_rawConfig[config_key::hostName] = NetworkUtilities::getIPAddress(m_rawConfig[config_key::hostName].toString());
|
|
|
|
m_impl->activate(m_rawConfig);
|
|
return ErrorCode::NoError;
|
|
}
|
|
|
|
ErrorCode WireguardProtocol::stopMzImpl()
|
|
{
|
|
m_impl->deactivate();
|
|
return ErrorCode::NoError;
|
|
}
|
|
|
|
|
|
ErrorCode WireguardProtocol::start()
|
|
{
|
|
return startMzImpl();
|
|
}
|