mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-05-08 14:33:23 +00:00
* fix: xray heap corruption * fix: use proper configuration for split-tunneled apps * chore: enable killswitch * chore: xray windows split-tunneling cleanup * chore: proper xray killswitch log * feat: add wait for the tun device * chore: update amnezia_xray deps for macos * fix: add nullptr check for split-tunnel on win * fix: modernize vpnAdapter grabbing function * fix: remove network watcher due to its fragileness * chore: xrayprotocol cleanup * fix: correct wrong iface index on win * chore: move tun2socks implementation to the client from the service * chore: xrayprotocol cleanup * chore: more xrayprotocol cleanup * fix: consistent tun device with GUID specified * chore: tun2socks logs * chore: PrivilegedProcess cleanup * better error handling in establishment phase * terminate&kill ops for remote process * fix: straighforward killing the process on windows * fix: finally remove GUID setting from tun2socks due to instability * fix: add sanitizer to ipc process * chore: do not collect sensitive info from tun2socks
122 lines
3.2 KiB
C++
122 lines
3.2 KiB
C++
#include "ipcserverprocess.h"
|
|
#include "ipc.h"
|
|
#include <QProcess>
|
|
|
|
#ifndef Q_OS_IOS
|
|
|
|
IpcServerProcess::IpcServerProcess(QObject *parent) :
|
|
IpcProcessInterfaceSource(parent),
|
|
m_process(QSharedPointer<QProcess>(new QProcess()))
|
|
{
|
|
connect(m_process.data(), &QProcess::errorOccurred, this, &IpcServerProcess::errorOccurred);
|
|
connect(m_process.data(), QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, &IpcServerProcess::finished);
|
|
connect(m_process.data(), &QProcess::readyRead, this, &IpcServerProcess::readyRead);
|
|
connect(m_process.data(), &QProcess::readyReadStandardError, this, &IpcServerProcess::readyReadStandardError);
|
|
connect(m_process.data(), &QProcess::readyReadStandardOutput, this, &IpcServerProcess::readyReadStandardOutput);
|
|
connect(m_process.data(), &QProcess::started, this, &IpcServerProcess::started);
|
|
connect(m_process.data(), &QProcess::stateChanged, this, &IpcServerProcess::stateChanged);
|
|
|
|
connect(m_process.data(), &QProcess::errorOccurred, [&](QProcess::ProcessError error){
|
|
qDebug() << "IpcServerProcess errorOccurred " << error;
|
|
});
|
|
|
|
}
|
|
|
|
IpcServerProcess::~IpcServerProcess()
|
|
{
|
|
qDebug() << "IpcServerProcess::~IpcServerProcess";
|
|
}
|
|
|
|
void IpcServerProcess::start()
|
|
{
|
|
if (m_process->program().isEmpty()) {
|
|
qDebug() << "IpcServerProcess failed to start, program is empty";
|
|
}
|
|
|
|
Utils::killProcessByName(m_process->program());
|
|
m_process->start();
|
|
qDebug() << "IpcServerProcess started, " << m_process->program() << m_process->arguments();
|
|
|
|
m_process->waitForStarted();
|
|
}
|
|
|
|
void IpcServerProcess::terminate() {
|
|
m_process->terminate();
|
|
}
|
|
|
|
void IpcServerProcess::kill() {
|
|
m_process->kill();
|
|
}
|
|
|
|
void IpcServerProcess::close()
|
|
{
|
|
m_process->close();
|
|
}
|
|
|
|
void IpcServerProcess::setArguments(const QStringList &arguments)
|
|
{
|
|
m_process->setArguments(amnezia::sanitizeArguments(m_program, arguments));
|
|
}
|
|
|
|
void IpcServerProcess::setInputChannelMode(QProcess::InputChannelMode mode)
|
|
{
|
|
m_process->setInputChannelMode(mode);
|
|
}
|
|
|
|
void IpcServerProcess::setNativeArguments(const QString &arguments)
|
|
{
|
|
#ifdef Q_OS_WIN
|
|
m_process->setNativeArguments(arguments);
|
|
#endif
|
|
}
|
|
|
|
void IpcServerProcess::setProcessChannelMode(QProcess::ProcessChannelMode mode)
|
|
{
|
|
m_process->setProcessChannelMode(mode);
|
|
}
|
|
|
|
void IpcServerProcess::setProgram(int programId)
|
|
{
|
|
m_program = static_cast<amnezia::PermittedProcess>(programId);
|
|
m_process->setProgram(amnezia::permittedProcessPath(m_program));
|
|
m_process->setArguments({});
|
|
}
|
|
|
|
void IpcServerProcess::setWorkingDirectory(const QString &dir)
|
|
{
|
|
m_process->setWorkingDirectory(dir);
|
|
}
|
|
|
|
QByteArray IpcServerProcess::readAll()
|
|
{
|
|
return m_process->readAll();
|
|
}
|
|
|
|
QByteArray IpcServerProcess::readAllStandardError()
|
|
{
|
|
return m_process->readAllStandardError();
|
|
}
|
|
|
|
QByteArray IpcServerProcess::readAllStandardOutput()
|
|
{
|
|
return m_process->readAllStandardOutput();
|
|
}
|
|
|
|
bool IpcServerProcess::waitForStarted() {
|
|
return m_process->waitForStarted();
|
|
}
|
|
|
|
bool IpcServerProcess::waitForStarted(int msecs) {
|
|
return m_process->waitForStarted(msecs);
|
|
}
|
|
|
|
bool IpcServerProcess::waitForFinished() {
|
|
return m_process->waitForFinished();
|
|
}
|
|
|
|
bool IpcServerProcess::waitForFinished(int msecs) {
|
|
return m_process->waitForFinished(msecs);
|
|
}
|
|
|
|
#endif
|