Skip to content

Commit

Permalink
Improve XRay protocol process close
Browse files Browse the repository at this point in the history
  • Loading branch information
outspace committed Dec 26, 2024
1 parent b88ab8e commit 9ced043
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
13 changes: 5 additions & 8 deletions client/protocols/xrayprotocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,10 @@ ErrorCode XrayProtocol::start()
connect(&m_xrayProcess, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, [this](int exitCode, QProcess::ExitStatus exitStatus) {
qDebug().noquote() << "XrayProtocol finished, exitCode, exitStatus" << exitCode << exitStatus;
setConnectionState(Vpn::ConnectionState::Disconnected);
if (exitStatus != QProcess::NormalExit) {
emit protocolError(amnezia::ErrorCode::XrayExecutableCrashed);
stop();
}
if (exitCode != 0) {
emit protocolError(amnezia::ErrorCode::InternalError);
stop();
if ((exitStatus != QProcess::NormalExit) || (exitCode != 0)){
if (exitCode != 62097 ){
stop();
}
}
});

Expand Down Expand Up @@ -177,7 +174,7 @@ void XrayProtocol::stop()
IpcClient::Interface()->StartRoutingIpv6();
#endif
qDebug() << "XrayProtocol::stop()";
m_xrayProcess.terminate();
m_xrayProcess.kill();
if (m_t2sProcess) {
m_t2sProcess->stop();
}
Expand Down
13 changes: 7 additions & 6 deletions ipc/ipctun2socksprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ void IpcProcessTun2Socks::start()
connect(m_t2sProcess.data(), QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, [this](int exitCode, QProcess::ExitStatus exitStatus) {
qDebug().noquote() << "tun2socks finished, exitCode, exiStatus" << exitCode << exitStatus;
emit setConnectionState(Vpn::ConnectionState::Disconnected);
if (exitStatus != QProcess::NormalExit){
stop();
}
if (exitCode !=0 ){
stop();
if ((exitStatus != QProcess::NormalExit) || (exitCode != 0)){
if (exitCode != 62097 ){
stop();
}
}

});

m_t2sProcess->start();
Expand All @@ -69,6 +69,7 @@ void IpcProcessTun2Socks::start()
void IpcProcessTun2Socks::stop()
{
qDebug() << "IpcProcessTun2Socks::stop()";
m_t2sProcess->close();
m_t2sProcess->kill();
m_t2sProcess->waitForFinished(3000);
}
#endif

0 comments on commit 9ced043

Please sign in to comment.