apply format to file
This commit is contained in:
parent
9398e0e695
commit
eb83086d5c
1 changed files with 12 additions and 17 deletions
|
@ -3,17 +3,16 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
|
||||||
IpcClient *IpcClient::m_instance = nullptr;
|
IpcClient *IpcClient::m_instance = nullptr;
|
||||||
|
|
||||||
IpcClient::IpcClient(QObject *parent) : QObject(parent)
|
IpcClient::IpcClient(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IpcClient::~IpcClient()
|
IpcClient::~IpcClient()
|
||||||
{
|
{
|
||||||
if (m_localSocket) m_localSocket->close();
|
if (m_localSocket)
|
||||||
|
m_localSocket->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IpcClient::isSocketConnected() const
|
bool IpcClient::isSocketConnected() const
|
||||||
|
@ -28,13 +27,15 @@ IpcClient *IpcClient::Instance()
|
||||||
|
|
||||||
QSharedPointer<IpcInterfaceReplica> IpcClient::Interface()
|
QSharedPointer<IpcInterfaceReplica> IpcClient::Interface()
|
||||||
{
|
{
|
||||||
if (!Instance()) return nullptr;
|
if (!Instance())
|
||||||
|
return nullptr;
|
||||||
return Instance()->m_ipcClient;
|
return Instance()->m_ipcClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<IpcProcessTun2SocksReplica> IpcClient::InterfaceTun2Socks()
|
QSharedPointer<IpcProcessTun2SocksReplica> IpcClient::InterfaceTun2Socks()
|
||||||
{
|
{
|
||||||
if (!Instance()) return nullptr;
|
if (!Instance())
|
||||||
|
return nullptr;
|
||||||
return Instance()->m_Tun2SocksClient;
|
return Instance()->m_Tun2SocksClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,9 +79,8 @@ bool IpcClient::init(IpcClient *instance)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(Instance()->m_localSocket, &QLocalSocket::disconnected, [instance](){
|
connect(Instance()->m_localSocket, &QLocalSocket::disconnected,
|
||||||
instance->m_isSocketConnected = false;
|
[instance]() { instance->m_isSocketConnected = false; });
|
||||||
});
|
|
||||||
|
|
||||||
Instance()->m_localSocket->connectToServer(amnezia::getIpcServiceUrl());
|
Instance()->m_localSocket->connectToServer(amnezia::getIpcServiceUrl());
|
||||||
Instance()->m_localSocket->waitForConnected();
|
Instance()->m_localSocket->waitForConnected();
|
||||||
|
@ -120,18 +120,15 @@ QSharedPointer<PrivilegedProcess> IpcClient::CreatePrivilegedProcess()
|
||||||
pd->ipcProcess.reset(priv);
|
pd->ipcProcess.reset(priv);
|
||||||
if (!pd->ipcProcess) {
|
if (!pd->ipcProcess) {
|
||||||
qWarning() << "Acquire PrivilegedProcess failed";
|
qWarning() << "Acquire PrivilegedProcess failed";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
pd->ipcProcess->waitForSource(1000);
|
pd->ipcProcess->waitForSource(1000);
|
||||||
if (!pd->ipcProcess->isReplicaValid()) {
|
if (!pd->ipcProcess->isReplicaValid()) {
|
||||||
qWarning() << "PrivilegedProcess replica is not connected!";
|
qWarning() << "PrivilegedProcess replica is not connected!";
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject::connect(pd->ipcProcess.data(), &PrivilegedProcess::destroyed, pd->ipcProcess.data(), [pd](){
|
QObject::connect(pd->ipcProcess.data(), &PrivilegedProcess::destroyed, pd->ipcProcess.data(),
|
||||||
pd->replicaNode->deleteLater();
|
[pd]() { pd->replicaNode->deleteLater(); });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
pd->localSocket->connectToServer(amnezia::getIpcProcessUrl(pid));
|
pd->localSocket->connectToServer(amnezia::getIpcProcessUrl(pid));
|
||||||
pd->localSocket->waitForConnected();
|
pd->localSocket->waitForConnected();
|
||||||
|
@ -139,5 +136,3 @@ QSharedPointer<PrivilegedProcess> IpcClient::CreatePrivilegedProcess()
|
||||||
auto processReplica = QSharedPointer<PrivilegedProcess>(pd->ipcProcess);
|
auto processReplica = QSharedPointer<PrivilegedProcess>(pd->ipcProcess);
|
||||||
return processReplica;
|
return processReplica;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue