diff --git a/client/client.pro b/client/client.pro index c63c2c55..2c5202ea 100644 --- a/client/client.pro +++ b/client/client.pro @@ -21,6 +21,7 @@ HEADERS += \ localclient.h \ managementserver.h \ message.h \ + protocols/shadowsocksvpnprotocol.h \ runguard.h \ settings.h \ ui/Controls/SlidingStackedWidget.h \ @@ -40,6 +41,7 @@ SOURCES += \ main.cpp \ managementserver.cpp \ message.cpp \ + protocols/shadowsocksvpnprotocol.cpp \ runguard.cpp \ settings.cpp \ ui/Controls/SlidingStackedWidget.cpp \ diff --git a/client/core/servercontroller.cpp b/client/core/servercontroller.cpp index 8498ac7b..198aac79 100644 --- a/client/core/servercontroller.cpp +++ b/client/core/servercontroller.cpp @@ -52,19 +52,19 @@ ErrorCode ServerController::runScript(const SshConnectionParameters &sshParams, wait.quit(); }); -// QObject::connect(proc.data(), &SshRemoteProcess::readyReadStandardOutput, [proc](){ -// QString s = proc->readAllStandardOutput(); -// if (s != "." && !s.isEmpty()) { -// qDebug().noquote() << s; -// } -// }); + QObject::connect(proc.data(), &SshRemoteProcess::readyReadStandardOutput, [proc](){ + QString s = proc->readAllStandardOutput(); + if (s != "." && !s.isEmpty()) { + qDebug().noquote() << s; + } + }); -// QObject::connect(proc.data(), &SshRemoteProcess::readyReadStandardError, [proc](){ -// QString s = proc->readAllStandardError(); -// if (s != "." && !s.isEmpty()) { -// qDebug().noquote() << s; -// } -// }); + QObject::connect(proc.data(), &SshRemoteProcess::readyReadStandardError, [proc](){ + QString s = proc->readAllStandardError(); + if (s != "." && !s.isEmpty()) { + qDebug().noquote() << s; + } + }); proc->start(); @@ -284,13 +284,24 @@ ErrorCode ServerController::setupOpenVpnServer(const ServerCredentials &credenti ErrorCode e = runScript(sshParams(credentials), scriptData); if (e) return e; - //return ok; return checkOpenVpnServer(credentials); } ErrorCode ServerController::setupShadowSocksServer(const ServerCredentials &credentials) { - return ErrorCode::NotImplementedError; + QString scriptData; + QString scriptFileName = ":/server_scripts/setup_shadowsocks_server.sh"; + QFile file(scriptFileName); + if (! file.open(QIODevice::ReadOnly)) return ErrorCode::InternalError; + + scriptData = file.readAll(); + if (scriptData.isEmpty()) return ErrorCode::InternalError; + + ErrorCode e = runScript(sshParams(credentials), scriptData); + if (e) return e; + + return ErrorCode::NoError; + //return checkShadowSocksServer(credentials); } SshConnection *ServerController::connectToHost(const SshConnectionParameters &sshParams) diff --git a/client/protocols/shadowsocksvpnprotocol.cpp b/client/protocols/shadowsocksvpnprotocol.cpp new file mode 100644 index 00000000..5ab7fdb2 --- /dev/null +++ b/client/protocols/shadowsocksvpnprotocol.cpp @@ -0,0 +1,6 @@ +#include "shadowsocksvpnprotocol.h" + +ShadowSocksVpnProtocol::ShadowSocksVpnProtocol() +{ + +} diff --git a/client/protocols/shadowsocksvpnprotocol.h b/client/protocols/shadowsocksvpnprotocol.h new file mode 100644 index 00000000..37006f36 --- /dev/null +++ b/client/protocols/shadowsocksvpnprotocol.h @@ -0,0 +1,12 @@ +#ifndef SHADOWSOCKSVPNPROTOCOL_H +#define SHADOWSOCKSVPNPROTOCOL_H + +#include "openvpnprotocol.h" + +class ShadowSocksVpnProtocol : public OpenVpnProtocol +{ +public: + ShadowSocksVpnProtocol(); +}; + +#endif // SHADOWSOCKSVPNPROTOCOL_H diff --git a/client/ui/mainwindow.cpp b/client/ui/mainwindow.cpp index 595756f1..fe017705 100644 --- a/client/ui/mainwindow.cpp +++ b/client/ui/mainwindow.cpp @@ -243,7 +243,7 @@ bool MainWindow::installServer(ServerCredentials credentials, timer.start(1000); - ErrorCode e = ServerController::setupServer(credentials, Protocol::Any); + ErrorCode e = ServerController::setupServer(credentials, Protocol::ShadowSocks); if (e) { page->setEnabled(true); button->setVisible(true); @@ -251,8 +251,7 @@ bool MainWindow::installServer(ServerCredentials credentials, QMessageBox::warning(this, APPLICATION_NAME, tr("Error occurred while configuring server.") + "\n" + - errorString(e) + "\n" + - tr("See logs for details.")); + errorString(e)); return false; }