MacOS WG/AWG killswitch
This commit is contained in:
parent
1a17f2956a
commit
3d2174d84e
23 changed files with 397 additions and 51 deletions
|
@ -66,7 +66,7 @@ ErrorCode OpenVpnOverCloakProtocol::start()
|
|||
emit protocolError(amnezia::ErrorCode::CloakExecutableCrashed);
|
||||
stop();
|
||||
}
|
||||
if (exitCode !=0 ){
|
||||
if (exitCode !=0 ) {
|
||||
emit protocolError(amnezia::ErrorCode::InternalError);
|
||||
stop();
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ void OpenVpnProtocol::stop()
|
|||
m_managementServer.stop();
|
||||
}
|
||||
|
||||
#if defined(Q_OS_WIN) || defined(Q_OS_LINUX)
|
||||
#if defined(Q_OS_WIN) || defined(Q_OS_LINUX) || defined(Q_OS_MACOS)
|
||||
IpcClient::Interface()->disableKillSwitch();
|
||||
#endif
|
||||
|
||||
|
@ -345,7 +345,7 @@ void OpenVpnProtocol::updateVpnGateway(const QString &line)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef Q_OS_LINUX
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_MACOS)
|
||||
IpcClient::Interface()->enableKillSwitch(m_configData, 0);
|
||||
#endif
|
||||
qDebug() << QString("Set vpn local address %1, gw %2").arg(m_vpnLocalAddress).arg(vpnGateway());
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
WireguardProtocol::WireguardProtocol(const QJsonObject &configuration, QObject *parent)
|
||||
: VpnProtocol(configuration, parent)
|
||||
{
|
||||
m_configFile.setFileName(QDir::tempPath() + QDir::separator() + serviceName() + ".conf");
|
||||
writeWireguardConfiguration(configuration);
|
||||
|
||||
m_impl.reset(new LocalSocketController());
|
||||
connect(m_impl.get(), &ControllerImpl::connected, this,
|
||||
[this](const QString &pubkey, const QDateTime &connectionTimestamp) {
|
||||
|
@ -50,45 +47,9 @@ ErrorCode WireguardProtocol::stopMzImpl()
|
|||
return ErrorCode::NoError;
|
||||
}
|
||||
|
||||
void WireguardProtocol::writeWireguardConfiguration(const QJsonObject &configuration)
|
||||
{
|
||||
QJsonObject jConfig = configuration.value(ProtocolProps::key_proto_config_data(Proto::WireGuard)).toObject();
|
||||
|
||||
if (!m_configFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||
qCritical() << "Failed to save wireguard config to" << m_configFile.fileName();
|
||||
return;
|
||||
}
|
||||
|
||||
m_configFile.write(jConfig.value(config_key::config).toString().toUtf8());
|
||||
m_configFile.close();
|
||||
|
||||
|
||||
m_configFileName = m_configFile.fileName();
|
||||
|
||||
m_isConfigLoaded = true;
|
||||
|
||||
qDebug().noquote() << QString("Set config data") << configPath();
|
||||
qDebug().noquote() << QString("Set config data")
|
||||
<< configuration.value(ProtocolProps::key_proto_config_data(Proto::WireGuard)).toString().toUtf8();
|
||||
}
|
||||
|
||||
QString WireguardProtocol::configPath() const
|
||||
{
|
||||
return m_configFileName;
|
||||
}
|
||||
|
||||
QString WireguardProtocol::serviceName() const
|
||||
{
|
||||
return "AmneziaVPN.WireGuard0";
|
||||
}
|
||||
|
||||
ErrorCode WireguardProtocol::start()
|
||||
{
|
||||
if (!m_isConfigLoaded) {
|
||||
setLastError(ErrorCode::ConfigMissing);
|
||||
return lastError();
|
||||
}
|
||||
|
||||
return startMzImpl();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,15 +26,6 @@ public:
|
|||
ErrorCode stopMzImpl();
|
||||
|
||||
private:
|
||||
QString configPath() const;
|
||||
void writeWireguardConfiguration(const QJsonObject &configuration);
|
||||
QString serviceName() const;
|
||||
|
||||
private:
|
||||
QString m_configFileName;
|
||||
QFile m_configFile;
|
||||
|
||||
bool m_isConfigLoaded = false;
|
||||
|
||||
QScopedPointer<ControllerImpl> m_impl;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue