Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
ChannelSSHTunnel.h
1// Author: Kang Lin <kl222@126.com>
2
3#ifndef CCHANNELSSHTUNNEL_H
4#define CCHANNELSSHTUNNEL_H
5
6#pragma once
7
8#include <QSharedPointer>
9#include <QSocketNotifier>
10#include <QMutex>
11
12#include "libssh/libssh.h"
13#include "libssh/callbacks.h"
14
15#include "Channel.h"
16#include "ParameterChannelSSH.h"
17#include "Event.h"
18
29class CHANNEL_EXPORT CChannelSSHTunnel : public CChannel
30{
31 Q_OBJECT
32
33public:
34 explicit CChannelSSHTunnel(QSharedPointer<CParameterChannelSSH> parameter,
35 bool bWakeUp = true,
36 QObject *parent = nullptr);
37 virtual ~CChannelSSHTunnel();
38
39 // QIODevice interface
40public:
41 virtual bool open(OpenMode mode) override;
42 virtual void close() override;
43
44 virtual QString GetDetails() override;
45 int Process();
46 virtual int WakeUp();
47
48Q_SIGNALS:
65 void sigBlockShowMessageBox(const QString& szTitle,
66 const QString& szMessage,
67 QMessageBox::StandardButtons buttons,
68 QMessageBox::StandardButton& nRet,
69 bool &checkBox,
70 QString checkBoxContext = QString());
88 void sigBlockShowWidget(const QString& className, int &nRet, void* pContext);
89
90 // QIODevice interface
91protected:
92 virtual qint64 readData(char *data, qint64 maxlen) override;
93 virtual qint64 writeData(const char *data, qint64 len) override;
94
95private:
96 int verifyKnownhost(ssh_session session);
97 int authentication(
98 ssh_session session,
99 const QString szUser,
100 const QString szPassword,
101 const QString szPassphrase,
102 const int nMethod = SSH_AUTH_METHOD_PASSWORD);
103 int authenticationPublicKey(
104 ssh_session session,
105 const QString szUser,
106 const QString szPublicKeyFile,
107 const QString szPrivateKeyFile,
108 const QString szPassphrase);
109 int forward(ssh_session session);
110
111 static void cb_log(ssh_session session,
112 int priority,
113 const char *message,
114 void *userdata);
115
116protected:
117 ssh_session m_Session;
118 ssh_channel m_Channel;
119
120private:
121 ssh_pcap_file m_pcapFile;
122 QSharedPointer<CParameterChannelSSH> m_Parameter;
123
124 QSocketNotifier* m_pSocketRead;
125 QSocketNotifier* m_pSocketWrite;
126 QSocketNotifier* m_pSocketException;
127
128 Channel::CEvent* m_pEvent;
129};
130
131#endif // CCHANNELSSHTUNNEL_H
ssh tunnel class
void sigBlockShowMessageBox(const QString &szTitle, const QString &szMessage, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton &nRet, bool &checkBox, QString checkBoxContext=QString())
Block background threads and display message dialogs in foreground threads (QMessageBox)
void sigBlockShowWidget(const QString &className, int &nRet, void *pContext)
Blocks the background thread and displays the window in the foreground thread.
The channel interface class.
Definition Channel.h:25
virtual bool open(OpenMode mode) override
Definition Channel.cpp:78