Setup routing for Linux IPSec

This commit is contained in:
Mykola Baibuz 2024-08-25 00:26:32 +03:00
parent 30df4c6800
commit 63c569c3d2
3 changed files with 50 additions and 1 deletions

View file

@ -310,6 +310,25 @@ bool IpcServer::disableKillSwitch()
bool IpcServer::startIPsec(QString tunnelName)
{
#ifdef Q_OS_LINUX
/* QProcess processSystemd;
QStringList commandsSystemd;
commandsSystemd << "systemctl" << "restart" << "ipsec";
processSystemd.start("sudo", commandsSystemd);
if (!processSystemd.waitForStarted(1000))
{
qDebug().noquote() << "Could not start ipsec tunnel!\n";
return false;
}
else if (!processSystemd.waitForFinished(2000))
{
qDebug().noquote() << "Could not start ipsec tunnel\n";
return false;
}
commandsSystemd.clear();
QThread::msleep(2000);
*/
QProcess process;
QStringList commands;
commands << "ipsec" << "up" << QString("%1").arg(tunnelName);
@ -325,10 +344,13 @@ bool IpcServer::startIPsec(QString tunnelName)
return false;
}
commands.clear();
#endif
return true;
}
bool IpcServer::stopIPsec(QString tunnelName)
{
#ifdef Q_OS_LINUX
QProcess process;
QStringList commands;
commands << "ipsec" << "down" << QString("%1").arg(tunnelName);
@ -344,6 +366,8 @@ bool IpcServer::stopIPsec(QString tunnelName)
return false;
}
commands.clear();
#endif
return true;
}
bool IpcServer::writeIPsecConfig(QString config)