Commit a57b7b84 authored by Lefebvre, Jordan's avatar Lefebvre, Jordan
Browse files

Adding support for ProxyCommand integration with libssh.

parent aead89d0
Pipeline #88920 passed with stages
in 1 minute and 20 seconds
......@@ -88,6 +88,8 @@ SessionController::SessionController(QObject* parent)
// connect
QObject::connect(this, &SessionController::setHostRequested, p->worker,
&SessionWorker::setHost);
QObject::connect(this, &SessionController::setProxyCommandRequested,
p->worker, &SessionWorker::setProxyCommand);
QObject::connect(this, &SessionController::setLogVerbosityRequested,
p->worker, &SessionWorker::setLogVerbosity);
QObject::connect(this, &SessionController::setPortRequested, p->worker,
......@@ -137,6 +139,11 @@ void SessionController::setPort(int port) { emit setPortRequested(port); }
void SessionController::setUser(QString name) { emit setUserRequested(name); }
void SessionController::setProxyCommand(QString command)
{
emit setProxyCommandRequested(command);
}
void SessionController::connect() { emit connectRequested(); }
void SessionController::disconnect() { emit disconnectRequested(); }
......
......@@ -41,6 +41,11 @@ class RSM_PUBLIC SessionController : public QObject
* Defaults to system user
*/
void setUser(QString name);
/**
* Set the proxy command
* @param command
*/
void setProxyCommand(QString command);
/**
* Perform hand-shake to connect to host.
*/
......@@ -181,6 +186,10 @@ class RSM_PUBLIC SessionController : public QObject
* Set the remote host to connect to
*/
void setHostRequested(QString host);
/**
* Set the proxy command
*/
void setProxyCommandRequested(QString command);
/**
* Set the Log verbosity
*/
......
......@@ -101,6 +101,14 @@ void SessionWorker::setUser(QString name)
assert_ssh_session(p->session, "setName() -- Session is not allocated.");
ssh_options_set(p->session, SSH_OPTIONS_USER, name.toStdString().c_str());
}
void SessionWorker::setProxyCommand(QString command)
{
assert_ssh_session(p->session,
"setProxyCommand() -- Session is not allocated.");
ssh_options_set(p->session, SSH_OPTIONS_PROXYCOMMAND,
command.toStdString().c_str());
}
void SessionWorker::connect()
{
assert_ssh_session(p->session, "connect() -- Session is not allocated.");
......
......@@ -50,6 +50,12 @@ class RSM_PUBLIC SessionWorker : public QObject
* Defaults to system user
*/
void setUser(QString name);
/**
* Set the proxy command
* @param command
*/
void setProxyCommand(QString command);
/**
* Perform hand-shake to connect to host.
*/
......
......@@ -19,13 +19,15 @@ using namespace rsm;
ExamplePortalWidget::ExamplePortalWidget(QWidget *parent)
: QWidget(parent)
{
QGridLayout *layout = new QGridLayout(this);
QLabel *hostLabel = new QLabel("Host:", this);
QLabel *portLabel = new QLabel("Port:", this);
QLabel *userNameLabel = new QLabel("Username:", this);
QGridLayout *layout = new QGridLayout(this);
QLabel *proxyHostLabel = new QLabel("Proxy:", this);
QLabel *hostLabel = new QLabel("Host:", this);
QLabel *portLabel = new QLabel("Port:", this);
QLabel *userNameLabel = new QLabel("Username:", this);
mProxyEdit = new QLineEdit(this);
mHostEdit = new QLineEdit(this);
mPortEdit = new QLineEdit("22", this);
mPortEdit = new QLineEdit(this);
mUserNameEdit = new QLineEdit(this);
mConnectButton = new QPushButton("Connect", this);
mCommandEdit = new QLineEdit(this);
......@@ -33,17 +35,19 @@ ExamplePortalWidget::ExamplePortalWidget(QWidget *parent)
mTextEdit = new QTextEdit(this);
layout->addWidget(hostLabel, 0, 0);
layout->addWidget(mHostEdit, 0, 1);
layout->addWidget(portLabel, 1, 0);
layout->addWidget(mPortEdit, 1, 1);
layout->addWidget(userNameLabel, 2, 0);
layout->addWidget(mUserNameEdit, 2, 1);
layout->addWidget(mConnectButton, 3, 1);
layout->addWidget(mCommandEdit, 4, 0, 1, 2);
layout->addWidget(mCommandSubmitButton, 5, 1);
layout->addWidget(proxyHostLabel, 0, 0);
layout->addWidget(mProxyEdit, 0, 1);
layout->addWidget(hostLabel, 1, 0);
layout->addWidget(mHostEdit, 1, 1);
layout->addWidget(portLabel, 2, 0);
layout->addWidget(mPortEdit, 2, 1);
layout->addWidget(userNameLabel, 3, 0);
layout->addWidget(mUserNameEdit, 3, 1);
layout->addWidget(mConnectButton, 4, 1);
layout->addWidget(mCommandEdit, 5, 0, 1, 2);
layout->addWidget(mCommandSubmitButton, 6, 1);
layout->addWidget(mTextEdit, 6, 0, 2, 2);
layout->addWidget(mTextEdit, 7, 0, 2, 2);
connect(mConnectButton, &QPushButton::pressed, this,
&ExamplePortalWidget::connectToHost);
......@@ -96,6 +100,7 @@ void ExamplePortalWidget::connectToHost()
}
else
{
mSession->setProxyCommand(mProxyEdit->text());
mSession->setHost(mHostEdit->text());
mSession->setPort(mPortEdit->text().toInt());
mSession->setUser(mUserNameEdit->text());
......
......@@ -20,6 +20,7 @@ class ExamplePortalWidget : public QWidget
Q_OBJECT
private:
QPushButton *mConnectButton;
QLineEdit *mProxyEdit;
QLineEdit *mHostEdit;
QLineEdit *mPortEdit;
QLineEdit *mUserNameEdit;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment