Rabbit Remote Control 0.0.31
Loading...
Searching...
No Matches
SSHTunnelThread.cpp
1// Author: Kang Lin <kl222@126.com>
2
3#include <QLoggingCategory>
4#include <QThread>
5
6#include "ChannelSSHTunnelForward.h"
7#include "SSHTunnelThread.h"
8
9static Q_LOGGING_CATEGORY(log, "Channel.SSH.Tunnel.Thread")
10
12 : QThread(nullptr),
13 m_bExit(false),
14 m_Parameter(parameter)
15{
16 qDebug(log) << "CSSHTunnelThread::CSSHTunnelThread";
17 bool check = false;
18 check = connect(this, SIGNAL(finished()),
19 this, SLOT(deleteLater()));
20 Q_ASSERT(check);
21}
22
23CSSHTunnelThread::~CSSHTunnelThread()
24{
25 qDebug(log) << "CSSHTunnelThread::~CSSHTunnelThread";
26}
27
28void CSSHTunnelThread::Exit()
29{
30 m_bExit = true;
31}
32
33void CSSHTunnelThread::run()
34{
35 int nRet = 0;
36 qDebug(log) << "CSSHTunnelThread run";
38 if(!p)
39 return;
40
41 do{
42 bool check = connect(p, SIGNAL(sigServer(QString, quint16)),
43 this, SIGNAL(sigServer(QString, quint16)));
44 Q_ASSERT(check);
45 check = connect(p, SIGNAL(sigServer(QString)),
46 this, SIGNAL(sigServer(QString)));
47 Q_ASSERT(check);
48 if(!p->open(QIODevice::ReadWrite)) {
49 break;
50 }
51
52 while (!m_bExit && nRet >= 0) {
53 nRet = p->Process();
54 if(nRet) {
55 qCritical(log) << "Process fail" << p->errorString();
56 break;
57 }
58 }
59
60 p->close();
61 } while(0);
62
63 if(nRet)
64 emit sigError(nRet, p->errorString());
65
66 emit sigDisconnect();
67 p->deleteLater();
68 qDebug(log) << "CSSHTunnelThread end";
69}
Includes SSH tunneling and a local socket service for forwarding data.
virtual bool open(OpenMode mode) override
Data is forwarded over a local socket and SSH tunnel.
void sigServer(QString szHost, quint16 nPort)
It is triggered when the socket service establishes a listener and is used to notify other local sock...