added local port field to v2ray settings page

- some code style refactoring
This commit is contained in:
vladimir.kuznetsov 2023-02-14 08:35:03 +03:00
parent 2b0ba2aff9
commit 36fae9152f
10 changed files with 88 additions and 65 deletions

View file

@ -9,7 +9,7 @@
#include <QJsonObject>
ShadowSocksVpnProtocol::ShadowSocksVpnProtocol(const QJsonObject &configuration, QObject *parent):
OpenVpnProtocol(configuration, parent)
OpenVpnProtocol(configuration, parent)
{
readShadowSocksConfiguration(configuration);
}
@ -32,7 +32,6 @@ ErrorCode ShadowSocksVpnProtocol::start()
return lastError();
}
#ifndef Q_OS_IOS
if (Utils::processIsRunning(Utils::executable("ss-local", false))) {
Utils::killProcessByName(Utils::executable("ss-local", false));
@ -48,30 +47,28 @@ ErrorCode ShadowSocksVpnProtocol::start()
#ifdef Q_OS_LINUX
QStringList args = QStringList() << "-c" << m_shadowSocksCfgFile.fileName();
#else
QStringList args = QStringList() << "-c" << m_shadowSocksCfgFile.fileName()
<< "--no-delay";
QStringList args = QStringList() << "-c" << m_shadowSocksCfgFile.fileName() << "--no-delay";
#endif
qDebug().noquote() << "ShadowSocksVpnProtocol::start()"
<< shadowSocksExecPath() << args.join(" ");
qDebug().noquote() << "ShadowSocksVpnProtocol::start()" << shadowSocksExecPath() << args.join(" ");
m_ssProcess.setProcessChannelMode(QProcess::MergedChannels);
m_ssProcess.setProgram(shadowSocksExecPath());
m_ssProcess.setArguments(args);
connect(&m_ssProcess, &QProcess::readyReadStandardOutput, this, [this](){
connect(&m_ssProcess, &QProcess::readyReadStandardOutput, this, [this]() {
qDebug().noquote() << "ss-local:" << m_ssProcess.readAllStandardOutput();
});
connect(&m_ssProcess, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, [this](int exitCode, QProcess::ExitStatus exitStatus){
connect(&m_ssProcess, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, [this](int exitCode, QProcess::ExitStatus exitStatus) {
qDebug().noquote() << "ShadowSocksVpnProtocol finished, exitCode, exiStatus" << exitCode << exitStatus;
setConnectionState(VpnProtocol::Disconnected);
if (exitStatus != QProcess::NormalExit){
if (exitStatus != QProcess::NormalExit) {
emit protocolError(amnezia::ErrorCode::ShadowSocksExecutableCrashed);
stop();
}
if (exitCode !=0 ){
if (exitCode !=0 ) {
emit protocolError(amnezia::ErrorCode::InternalError);
stop();
}
@ -84,8 +81,9 @@ ErrorCode ShadowSocksVpnProtocol::start()
setConnectionState(VpnConnectionState::Connecting);
return OpenVpnProtocol::start();
} else {
return ErrorCode::ShadowSocksExecutableMissing;
}
else return ErrorCode::ShadowSocksExecutableMissing;
#else
return ErrorCode::NotImplementedError;
#endif