IKEv2 class file renamed
This commit is contained in:
parent
bd9b9600c1
commit
f20134415e
5 changed files with 29 additions and 159 deletions
|
|
@ -11,7 +11,7 @@ win32 {
|
||||||
-lcrypt32 \
|
-lcrypt32 \
|
||||||
|
|
||||||
!contains(QMAKE_TARGET.arch, x86_64) {
|
!contains(QMAKE_TARGET.arch, x86_64) {
|
||||||
INCLUDEPATH += $$PWD/windows/x86_64
|
INCLUDEPATH += $$PWD/windows/x86
|
||||||
HEADERS += $$PWD/windows/x86/botan_all.h
|
HEADERS += $$PWD/windows/x86/botan_all.h
|
||||||
SOURCES += $$PWD/windows/x86/botan_all.cpp
|
SOURCES += $$PWD/windows/x86/botan_all.cpp
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -146,12 +146,14 @@ win32 {
|
||||||
RC_FILE = platform_win/vpnclient.rc
|
RC_FILE = platform_win/vpnclient.rc
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
ui/framelesswindow.h \
|
protocols/ikev2_vpn_protocol_windows.h \
|
||||||
|
ui/framelesswindow.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
protocols/ikev2_vpn_protocol_windows.cpp \
|
||||||
ui/framelesswindow.cpp
|
ui/framelesswindow.cpp
|
||||||
|
|
||||||
VERSION = 1.0.0.0
|
VERSION = 2.0.0.0
|
||||||
QMAKE_TARGET_COMPANY = "AmneziaVPN"
|
QMAKE_TARGET_COMPANY = "AmneziaVPN"
|
||||||
QMAKE_TARGET_PRODUCT = "AmneziaVPN"
|
QMAKE_TARGET_PRODUCT = "AmneziaVPN"
|
||||||
|
|
||||||
|
|
@ -202,7 +204,6 @@ win32|macx|linux:!android {
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
ui/systemtray_notificationhandler.h \
|
ui/systemtray_notificationhandler.h \
|
||||||
protocols/openvpnprotocol.h \
|
protocols/openvpnprotocol.h \
|
||||||
protocols/ikev2_vpn_protocol.h \
|
|
||||||
protocols/openvpnovercloakprotocol.h \
|
protocols/openvpnovercloakprotocol.h \
|
||||||
protocols/shadowsocksvpnprotocol.h \
|
protocols/shadowsocksvpnprotocol.h \
|
||||||
protocols/wireguardprotocol.h \
|
protocols/wireguardprotocol.h \
|
||||||
|
|
@ -210,7 +211,6 @@ win32|macx|linux:!android {
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
ui/systemtray_notificationhandler.cpp \
|
ui/systemtray_notificationhandler.cpp \
|
||||||
protocols/openvpnprotocol.cpp \
|
protocols/openvpnprotocol.cpp \
|
||||||
protocols/ikev2_vpn_protocol.cpp \
|
|
||||||
protocols/openvpnovercloakprotocol.cpp \
|
protocols/openvpnovercloakprotocol.cpp \
|
||||||
protocols/shadowsocksvpnprotocol.cpp \
|
protocols/shadowsocksvpnprotocol.cpp \
|
||||||
protocols/wireguardprotocol.cpp \
|
protocols/wireguardprotocol.cpp \
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
//#include <QRegularExpression>
|
|
||||||
//#include <QTcpSocket>
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "ikev2_vpn_protocol.h"
|
#include "ikev2_vpn_protocol_windows.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
static Ikev2Protocol* self = nullptr;
|
static Ikev2Protocol* self = nullptr;
|
||||||
|
|
@ -24,23 +23,19 @@ Ikev2Protocol::Ikev2Protocol(const QJsonObject &configuration, QObject* parent)
|
||||||
VpnProtocol(configuration, parent)
|
VpnProtocol(configuration, parent)
|
||||||
{
|
{
|
||||||
self = this;
|
self = this;
|
||||||
//m_configFile.setFileTemplate(QDir::tempPath() + QDir::separator() + serviceName() + ".conf");
|
|
||||||
readIkev2Configuration(configuration);
|
readIkev2Configuration(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ikev2Protocol::~Ikev2Protocol()
|
Ikev2Protocol::~Ikev2Protocol()
|
||||||
{
|
{
|
||||||
qDebug() << "IpsecProtocol::~IpsecProtocol()";
|
qDebug() << "IpsecProtocol::~IpsecProtocol()";
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
disconnect_vpn();
|
disconnect_vpn();
|
||||||
#endif
|
|
||||||
Ikev2Protocol::stop();
|
Ikev2Protocol::stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ikev2Protocol::stop()
|
void Ikev2Protocol::stop()
|
||||||
{
|
{
|
||||||
setConnectionState(VpnProtocol::Disconnecting);
|
setConnectionState(VpnProtocol::Disconnecting);
|
||||||
#ifdef Q_OS_WINDOWS
|
|
||||||
{
|
{
|
||||||
if (! disconnect_vpn() ){
|
if (! disconnect_vpn() ){
|
||||||
qDebug()<<"We don't disconnect";
|
qDebug()<<"We don't disconnect";
|
||||||
|
|
@ -50,7 +45,6 @@ void Ikev2Protocol::stop()
|
||||||
setConnectionState(VpnProtocol::Disconnected);
|
setConnectionState(VpnProtocol::Disconnected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ikev2Protocol::newConnectionStateEventReceived(UINT unMsg, tagRASCONNSTATE rasconnstate, DWORD dwError)
|
void Ikev2Protocol::newConnectionStateEventReceived(UINT unMsg, tagRASCONNSTATE rasconnstate, DWORD dwError)
|
||||||
|
|
@ -60,181 +54,117 @@ void Ikev2Protocol::newConnectionStateEventReceived(UINT unMsg, tagRASCONNSTATE
|
||||||
switch (rasconnstate)
|
switch (rasconnstate)
|
||||||
{
|
{
|
||||||
case RASCS_OpenPort:
|
case RASCS_OpenPort:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
setConnectionState(Preparing);
|
setConnectionState(Preparing);
|
||||||
//printf ("RASCS_OpenPort = %d\n", _connection_state);
|
|
||||||
//printf ("Opening port...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_PortOpened:
|
case RASCS_PortOpened:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
setConnectionState(Preparing);
|
setConnectionState(Preparing);
|
||||||
//printf ("RASCS_PortOpened = %d\n", _connection_state);
|
|
||||||
//printf ("Port opened.\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_ConnectDevice:
|
case RASCS_ConnectDevice:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
setConnectionState(Preparing);
|
setConnectionState(Preparing);
|
||||||
//printf ("RASCS_ConnectDevice = %d\n", _connection_state);
|
|
||||||
//printf ("Connecting device...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_DeviceConnected:
|
case RASCS_DeviceConnected:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
setConnectionState(Preparing);
|
setConnectionState(Preparing);
|
||||||
//printf ("RASCS_DeviceConnected = %d\n", _connection_state);
|
|
||||||
//printf ("Device connected.\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_AllDevicesConnected:
|
case RASCS_AllDevicesConnected:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
setConnectionState(Preparing);
|
setConnectionState(Preparing);
|
||||||
//printf ("RASCS_AllDevicesConnected = %d\n", _connection_state);
|
|
||||||
//printf ("All devices connected.\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_Authenticate:
|
case RASCS_Authenticate:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
setConnectionState(Preparing);
|
setConnectionState(Preparing);
|
||||||
//printf ("RASCS_Authenticate = %d\n", _connection_state);
|
|
||||||
// printf ("Authenticating...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_AuthNotify:
|
case RASCS_AuthNotify:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
if (dwError != 0) {
|
if (dwError != 0) {
|
||||||
qDebug() << "have error" << dwError;
|
//qDebug() << "have error" << dwError;
|
||||||
setConnectionState(Disconnected);
|
setConnectionState(Disconnected);
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "RASCS_AuthNotify but no error" << dwError;
|
//qDebug() << "RASCS_AuthNotify but no error" << dwError;
|
||||||
}
|
}
|
||||||
//printf ("RASCS_AuthNotify = %d\n", _connection_state);
|
|
||||||
// printf ("Authentication notify.\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_AuthRetry:
|
case RASCS_AuthRetry:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
setConnectionState(Preparing);
|
setConnectionState(Preparing);
|
||||||
//printf ("RASCS_AuthRetry = %d\n", _connection_state);
|
|
||||||
//printf ("Retrying authentication...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_AuthCallback:
|
case RASCS_AuthCallback:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_AuthCallback = %d\n", _connection_state);
|
|
||||||
//printf ("Authentication callback...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_AuthChangePassword:
|
case RASCS_AuthChangePassword:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
// printf ("RASCS_AuthChangePassword = %d\n", _connection_state);
|
|
||||||
//printf ("Change password...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_AuthProject:
|
case RASCS_AuthProject:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_AuthProject = %d\n", _connection_state);
|
|
||||||
//printf ("Projection phase started...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_AuthLinkSpeed:
|
case RASCS_AuthLinkSpeed:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_AuthLinkSpeed = %d\n", _connection_state);
|
|
||||||
//printf ("Negoting speed...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_AuthAck:
|
case RASCS_AuthAck:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_AuthAck = %d\n", _connection_state);
|
|
||||||
//printf ("Authentication acknowledge...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_ReAuthenticate:
|
case RASCS_ReAuthenticate:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_ReAuthenticate = %d\n", _connection_state);
|
|
||||||
//printf ("Retrying Authentication...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_Authenticated:
|
case RASCS_Authenticated:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_Authenticated = %d\n", _connection_state);
|
|
||||||
//printf ("Authentication complete.\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_PrepareForCallback:
|
case RASCS_PrepareForCallback:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_PrepareForCallback = %d\n", _connection_state);
|
|
||||||
//printf ("Preparing for callback...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_WaitForModemReset:
|
case RASCS_WaitForModemReset:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_WaitForModemReset = %d\n", _connection_state);
|
|
||||||
// printf ("Waiting for modem reset...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_WaitForCallback:
|
case RASCS_WaitForCallback:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_WaitForCallback = %d\n", _connection_state);
|
|
||||||
//printf ("Waiting for callback...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_Projected:
|
case RASCS_Projected:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_Projected = %d\n", _connection_state);
|
|
||||||
//printf ("Projection completed.\n");
|
|
||||||
break;
|
break;
|
||||||
#if (WINVER >= 0x400)
|
#if (WINVER >= 0x400)
|
||||||
case RASCS_StartAuthentication: // Windows 95 only
|
case RASCS_StartAuthentication: // Windows 95 only
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_StartAuthentication = %d\n", _connection_state);
|
|
||||||
//printf ("Starting authentication...\n");
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case RASCS_CallbackComplete: // Windows 95 only
|
case RASCS_CallbackComplete: // Windows 95 only
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_CallbackComplete = %d\n", rasconnstate);
|
|
||||||
//printf ("Callback complete.\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_LogonNetwork: // Windows 95 only
|
case RASCS_LogonNetwork: // Windows 95 only
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_LogonNetwork = %d\n", _connection_state);
|
|
||||||
//printf ("Login to the network.\n");
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case RASCS_SubEntryConnected:
|
case RASCS_SubEntryConnected:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_SubEntryConnected = %d\n", _connection_state);
|
|
||||||
//printf ("Subentry connected.\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_SubEntryDisconnected:
|
case RASCS_SubEntryDisconnected:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_SubEntryDisconnected = %d\n", _connection_state);
|
|
||||||
//printf ("Subentry disconnected.\n");
|
|
||||||
break;
|
break;
|
||||||
//PAUSED STATES:
|
//PAUSED STATES:
|
||||||
case RASCS_Interactive:
|
case RASCS_Interactive:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_Interactive = %d\n", _connection_state);
|
|
||||||
//printf ("In Paused state: Interactive mode.\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_RetryAuthentication:
|
case RASCS_RetryAuthentication:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_RetryAuthentication = %d\n", _connection_state);
|
|
||||||
//printf ("In Paused state: Retry Authentication...\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_CallbackSetByCaller:
|
case RASCS_CallbackSetByCaller:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_CallbackSetByCaller = %d\n", _connection_state);
|
|
||||||
//printf ("In Paused state: Callback set by Caller.\n");
|
|
||||||
break;
|
break;
|
||||||
case RASCS_PasswordExpired:
|
case RASCS_PasswordExpired:
|
||||||
setConnectionState(Error);
|
setConnectionState(Error);
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_PasswordExpired = %d\n", _connection_state);
|
|
||||||
//printf ("In Paused state: Password has expired...\n");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RASCS_Connected: // = RASCS_DONE:
|
case RASCS_Connected: // = RASCS_DONE:
|
||||||
setConnectionState(Connected);
|
setConnectionState(Connected);
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_Connected = %d\n", _connection_state);
|
|
||||||
//printf ("Connection completed.\n");
|
|
||||||
//SetEvent(gEvent_handle);
|
|
||||||
break;
|
break;
|
||||||
case RASCS_Disconnected:
|
case RASCS_Disconnected:
|
||||||
setConnectionState(Disconnected);
|
setConnectionState(Disconnected);
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("RASCS_Disconnected = %d\n", _connection_state);
|
|
||||||
//printf ("Disconnecting...\n");
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug()<<__FUNCTION__ << __LINE__;
|
//qDebug()<<__FUNCTION__ << __LINE__;
|
||||||
//printf ("Unknown Status = %d\n", _connection_state);
|
|
||||||
//printf ("What are you going to do about it?\n");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -246,7 +176,6 @@ void Ikev2Protocol::readIkev2Configuration(const QJsonObject &configuration)
|
||||||
|
|
||||||
ErrorCode Ikev2Protocol::start()
|
ErrorCode Ikev2Protocol::start()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINDOWS
|
|
||||||
QByteArray cert = QByteArray::fromBase64(m_config[config_key::cert].toString().toUtf8());
|
QByteArray cert = QByteArray::fromBase64(m_config[config_key::cert].toString().toUtf8());
|
||||||
setConnectionState(Connecting);
|
setConnectionState(Connecting);
|
||||||
|
|
||||||
|
|
@ -277,34 +206,10 @@ ErrorCode Ikev2Protocol::start()
|
||||||
});
|
});
|
||||||
certInstallProcess->setArguments(arguments);
|
certInstallProcess->setArguments(arguments);
|
||||||
|
|
||||||
// qDebug() << arguments.join(" ");
|
|
||||||
// connect(certInstallProcess.data(), &PrivilegedProcess::errorOccurred, [certInstallProcess](QProcess::ProcessError error) {
|
|
||||||
// qDebug() << "PrivilegedProcess errorOccurred" << error;
|
|
||||||
// });
|
|
||||||
|
|
||||||
// connect(certInstallProcess.data(), &PrivilegedProcess::stateChanged, [certInstallProcess](QProcess::ProcessState newState) {
|
|
||||||
// qDebug() << "PrivilegedProcess stateChanged" << newState;
|
|
||||||
// });
|
|
||||||
|
|
||||||
// connect(certInstallProcess.data(), &PrivilegedProcess::readyRead, [certInstallProcess]() {
|
|
||||||
// auto req = certInstallProcess->readAll();
|
|
||||||
// req.waitForFinished();
|
|
||||||
// qDebug() << "PrivilegedProcess readyRead" << req.returnValue();
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
certInstallProcess->start();
|
certInstallProcess->start();
|
||||||
}
|
}
|
||||||
// /*
|
// /*
|
||||||
{
|
{
|
||||||
// auto adapterRemoveProcess = new QProcess;
|
|
||||||
|
|
||||||
// adapterRemoveProcess->setProgram("powershell");
|
|
||||||
// QString arguments = QString("-command \"Remove-VpnConnection -Name '%1' -Force\"").arg(tunnelName());
|
|
||||||
// adapterRemoveProcess->setNativeArguments(arguments);
|
|
||||||
|
|
||||||
// adapterRemoveProcess->start();
|
|
||||||
// adapterRemoveProcess->waitForFinished(5000);
|
|
||||||
if ( disconnect_vpn()){
|
if ( disconnect_vpn()){
|
||||||
qDebug()<<"VPN was disconnected";
|
qDebug()<<"VPN was disconnected";
|
||||||
}
|
}
|
||||||
|
|
@ -319,21 +224,6 @@ ErrorCode Ikev2Protocol::start()
|
||||||
qDebug() <<"Can't create the VPN connect";
|
qDebug() <<"Can't create the VPN connect";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// auto adapterInstallProcess = new QProcess;
|
|
||||||
|
|
||||||
// adapterInstallProcess->setProgram("powershell");
|
|
||||||
// QString arguments = QString("-command \"Add-VpnConnection "
|
|
||||||
// "-ServerAddress '%1' "
|
|
||||||
// "-Name '%2' "
|
|
||||||
// "-TunnelType IKEv2 "
|
|
||||||
// "-AuthenticationMethod MachineCertificate "
|
|
||||||
// "-EncryptionLevel Required "
|
|
||||||
// "-PassThru\"")
|
|
||||||
// .arg(m_config[config_key::hostName].toString())
|
|
||||||
// .arg(tunnelName());
|
|
||||||
// adapterInstallProcess->setNativeArguments(arguments);
|
|
||||||
// adapterInstallProcess->start();
|
|
||||||
// adapterInstallProcess->waitForFinished(5000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -352,10 +242,6 @@ ErrorCode Ikev2Protocol::start()
|
||||||
.arg(tunnelName());
|
.arg(tunnelName());
|
||||||
adapterConfigProcess->setNativeArguments(arguments);
|
adapterConfigProcess->setNativeArguments(arguments);
|
||||||
|
|
||||||
// connect(adapterConfigProcess, &QProcess::readyRead, [adapterConfigProcess]() {
|
|
||||||
// qDebug().noquote() << "adapterConfigProcess readyRead" << adapterConfigProcess->readAll();
|
|
||||||
// });
|
|
||||||
|
|
||||||
adapterConfigProcess->start();
|
adapterConfigProcess->start();
|
||||||
adapterConfigProcess->waitForFinished(5000);
|
adapterConfigProcess->waitForFinished(5000);
|
||||||
}
|
}
|
||||||
|
|
@ -367,13 +253,8 @@ ErrorCode Ikev2Protocol::start()
|
||||||
}
|
}
|
||||||
//setConnectionState(Connecting);
|
//setConnectionState(Connecting);
|
||||||
return ErrorCode::NoError;
|
return ErrorCode::NoError;
|
||||||
#else
|
|
||||||
return ErrorCode::NoError;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
#ifdef Q_OS_WINDOWS
|
|
||||||
bool Ikev2Protocol::create_new_vpn(const QString & vpn_name,
|
bool Ikev2Protocol::create_new_vpn(const QString & vpn_name,
|
||||||
const QString & serv_addr){
|
const QString & serv_addr){
|
||||||
|
|
||||||
|
|
@ -442,5 +323,3 @@ void WINAPI RasDialFuncCallback(UINT unMsg,
|
||||||
self->newConnectionStateEventReceived(unMsg, rasconnstate, dwError);
|
self->newConnectionStateEventReceived(unMsg, rasconnstate, dwError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef IPSEC_PROTOCOL_H
|
#ifndef IKEV2_VPN_PROTOCOL_WINDOWS_H
|
||||||
#define IPSEC_PROTOCOL_H
|
#define IKEV2_VPN_PROTOCOL_WINDOWS_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
@ -10,7 +10,6 @@
|
||||||
#include "vpnprotocol.h"
|
#include "vpnprotocol.h"
|
||||||
#include "core/ipcclient.h"
|
#include "core/ipcclient.h"
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
@ -31,8 +30,6 @@
|
||||||
#pragma comment(lib, "rasapi32.lib")
|
#pragma comment(lib, "rasapi32.lib")
|
||||||
#pragma comment(lib, "Crypt32.lib")
|
#pragma comment(lib, "Crypt32.lib")
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class Ikev2Protocol : public VpnProtocol
|
class Ikev2Protocol : public VpnProtocol
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
@ -54,14 +51,9 @@ public:
|
||||||
private:
|
private:
|
||||||
void readIkev2Configuration(const QJsonObject &configuration);
|
void readIkev2Configuration(const QJsonObject &configuration);
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
//certificates variables
|
|
||||||
|
|
||||||
#endif
|
|
||||||
private:
|
private:
|
||||||
QJsonObject m_config;
|
QJsonObject m_config;
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
//RAS functions and parametrs
|
//RAS functions and parametrs
|
||||||
HRASCONN hRasConn{nullptr};
|
HRASCONN hRasConn{nullptr};
|
||||||
bool create_new_vpn(const QString & vpn_name,
|
bool create_new_vpn(const QString & vpn_name,
|
||||||
|
|
@ -70,12 +62,8 @@ private:
|
||||||
|
|
||||||
bool connect_to_vpn(const QString & vpn_name);
|
bool connect_to_vpn(const QString & vpn_name);
|
||||||
bool disconnect_vpn();
|
bool disconnect_vpn();
|
||||||
#endif
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
DWORD CALLBACK rasCallback(UINT msg, RASCONNSTATE rascs, DWORD err);
|
DWORD CALLBACK rasCallback(UINT msg, RASCONNSTATE rascs, DWORD err);
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // IPSEC_PROTOCOL_H
|
#endif // IKEV2_VPN_PROTOCOL_WINDOWS_H
|
||||||
|
|
@ -9,7 +9,10 @@
|
||||||
#include "shadowsocksvpnprotocol.h"
|
#include "shadowsocksvpnprotocol.h"
|
||||||
#include "openvpnovercloakprotocol.h"
|
#include "openvpnovercloakprotocol.h"
|
||||||
#include "wireguardprotocol.h"
|
#include "wireguardprotocol.h"
|
||||||
#include "ikev2_vpn_protocol.h"
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
#include "ikev2_vpn_protocol_windows.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue