玉兔远程控制
0.1.0-bate11
Toggle main menu visibility
载入中...
搜索中...
未找到
Plugins
SftpServer
BackendSftpServer.h
1
// Author: Kang Lin <kl222@126.com>
2
3
#pragma once
4
5
#include <QSocketNotifier>
6
7
#include <libssh/server.h>
8
#include <libssh/sftpserver.h>
9
#include <libssh/callbacks.h>
10
11
#include "BackendServer.h"
12
#include "OperateSftpServer.h"
13
#include "ParameterSftpServer.h"
14
18
class
CBackendSftpServer :
public
CBackendServer
19
{
20
Q_OBJECT
21
22
public
:
23
explicit
CBackendSftpServer(
COperateSftpServer
*pOperate =
nullptr
,
24
bool
bStopSignal =
true
);
25
virtual
~CBackendSftpServer();
26
27
public
Q_SLOTS:
28
virtual
void
slotDisconnect(
const
QString& szIp,
const
quint16 port)
override
;
29
30
protected
:
31
virtual
OnInitReturnValue
OnInit
()
override
;
32
virtual
int
OnClean
()
override
;
33
virtual
int
OnProcess
()
override
;
34
virtual
int
WakeUp
()
override
;
35
36
private
Q_SLOTS:
37
void
slotNewConnection();
38
39
private
:
40
CParameterSftpServer
* m_pPara;
41
ssh_event m_event;
42
43
struct
sBindData
{
44
ssh_bind sshBind;
45
QSocketNotifier* pListenNotifier;
46
};
47
QList<sBindData*> m_lstListen;
48
struct
sClientData
49
{
50
QString ip;
51
quint16 port;
52
ssh_session session;
53
ssh_channel channel;
54
sftp_session sftp;
55
QTime m_Time;
56
int
m_nAuthAttempts;
57
struct
ssh_channel_callbacks_struct channel_cb;
58
struct
ssh_server_callbacks_struct server_cb;
59
CParameterSftpServer
* pPara;
60
};
61
QList<sClientData*> m_lstClients;
62
63
static
int
cbAuthPassword(ssh_session session,
const
char
*user,
64
const
char
*pass,
void
*userdata);
65
static
int
cbAuthPublickey(ssh_session session,
66
const
char
*user,
67
struct
ssh_key_struct *pubkey,
68
char
signature_state,
69
void
*userdata);
70
static
ssh_channel cbChannelOpen(ssh_session session,
void
*userdata);
71
72
int
Listen(
const
QString &szIp, qint16 nPort);
73
ssh_bind GetSshBind(QSocketNotifier* notifier);
74
bool
InitHostKey(ssh_bind ssdBind);
75
int
DeleteClient(
sClientData
* pClient);
76
static
void
SendBanner(
sClientData
* pClient,
const
QString& user);
77
};
CBackendSftpServer::OnClean
virtual int OnClean() override
清理
定义
BackendSftpServer.cpp:139
CBackendSftpServer::OnInit
virtual OnInitReturnValue OnInit() override
初始化
定义
BackendSftpServer.cpp:99
CBackendSftpServer::OnProcess
virtual int OnProcess() override
具体操作处理
定义
BackendSftpServer.cpp:184
CBackendSftpServer::WakeUp
virtual int WakeUp() override
唤醒后台线程。
定义
BackendSftpServer.cpp:163
COperateSftpServer
定义
OperateSftpServer.h:10
CParameterSftpServer
定义
ParameterSftpServer.h:8
CBackendSftpServer::sBindData
定义
BackendSftpServer.h:43
CBackendSftpServer::sClientData
定义
BackendSftpServer.h:49
作者:康林 (kl222@126.com)
版权所有(c) 康林工作室 保留所有权力