Skip to content

Commit

Permalink
apply format to file
Browse files Browse the repository at this point in the history
  • Loading branch information
CyAn84 committed Feb 13, 2025
1 parent 9398e0e commit eb83086
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions client/core/ipcclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
#include <chrono>
#include <thread>


IpcClient *IpcClient::m_instance = nullptr;

IpcClient::IpcClient(QObject *parent) : QObject(parent)
{

}

IpcClient::~IpcClient()
{
if (m_localSocket) m_localSocket->close();
if (m_localSocket)
m_localSocket->close();
}

bool IpcClient::isSocketConnected() const
Expand All @@ -28,13 +27,15 @@ IpcClient *IpcClient::Instance()

QSharedPointer<IpcInterfaceReplica> IpcClient::Interface()
{
if (!Instance()) return nullptr;
if (!Instance())
return nullptr;
return Instance()->m_ipcClient;
}

QSharedPointer<IpcProcessTun2SocksReplica> IpcClient::InterfaceTun2Socks()
{
if (!Instance()) return nullptr;
if (!Instance())
return nullptr;
return Instance()->m_Tun2SocksClient;
}

Expand Down Expand Up @@ -78,9 +79,8 @@ bool IpcClient::init(IpcClient *instance)
}
});

connect(Instance()->m_localSocket, &QLocalSocket::disconnected, [instance](){
instance->m_isSocketConnected = false;
});
connect(Instance()->m_localSocket, &QLocalSocket::disconnected,
[instance]() { instance->m_isSocketConnected = false; });

Instance()->m_localSocket->connectToServer(amnezia::getIpcServiceUrl());
Instance()->m_localSocket->waitForConnected();
Expand All @@ -97,7 +97,7 @@ bool IpcClient::init(IpcClient *instance)

QSharedPointer<PrivilegedProcess> IpcClient::CreatePrivilegedProcess()
{
if (! Instance()->m_ipcClient || ! Instance()->m_ipcClient->isReplicaValid()) {
if (!Instance()->m_ipcClient || !Instance()->m_ipcClient->isReplicaValid()) {
qWarning() << "IpcClient::createPrivilegedProcess : IpcClient IpcClient replica is not valid";
return nullptr;
}
Expand All @@ -120,24 +120,19 @@ QSharedPointer<PrivilegedProcess> IpcClient::CreatePrivilegedProcess()
pd->ipcProcess.reset(priv);
if (!pd->ipcProcess) {
qWarning() << "Acquire PrivilegedProcess failed";
}
else {
} else {
pd->ipcProcess->waitForSource(1000);
if (!pd->ipcProcess->isReplicaValid()) {
qWarning() << "PrivilegedProcess replica is not connected!";
}

QObject::connect(pd->ipcProcess.data(), &PrivilegedProcess::destroyed, pd->ipcProcess.data(), [pd](){
pd->replicaNode->deleteLater();
});
QObject::connect(pd->ipcProcess.data(), &PrivilegedProcess::destroyed, pd->ipcProcess.data(),
[pd]() { pd->replicaNode->deleteLater(); });
}

});
pd->localSocket->connectToServer(amnezia::getIpcProcessUrl(pid));
pd->localSocket->waitForConnected();

auto processReplica = QSharedPointer<PrivilegedProcess>(pd->ipcProcess);
return processReplica;
}


0 comments on commit eb83086

Please sign in to comment.