mainform.h
来自「著名的SecureBlackBox控件完整源码」· C头文件 代码 · 共 163 行
H
163 行
//---------------------------------------------------------------------------
#ifndef MainFormH
#define MainFormH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "SBSSHClient.hpp"
#include "SBSSHCommon.hpp"
#include <ComCtrls.hpp>
#include <ExtCtrls.hpp>
#include <ImgList.hpp>
#include <ScktComp.hpp>
#include "SBSSHClient.hpp"
#include "SBSSHKeyStorage.hpp"
#include "SBUtils.hpp"
#include "SBSSHConstants.hpp"
#include "SBSSHCommon.hpp"
//---------------------------------------------------------------------------
#define STATE_NOT_CONNECTED 0
#define STATE_ESTABLISHING_FORWARDING 1
#define STATE_ACTIVE 2
#define STATE_DISCONNECTED 3
//---------------------------------------------------------------------------
// This class stores information about links between logical and socket connections
// (Socket - Connection - State - amount of sent/received)
class TTunnelInfo : public TObject
{
public:
TCustomWinSocket* Socket; // Windows socket
TElSSHTunnelConnection* Tunnel; // SSH Tunnel connection
char SocketState; // Current socket state
int Sent; // Amount of data sent
int Received ; // Amount of data received
};
// This class stores information about active connections
class TTunnelInfoList : public TStringList
{
private:
TTunnelInfo* GetInfo(int Index);
void PutInfo(int Index, const TTunnelInfo* Value);
public:
__property TTunnelInfo* Info[int Index] = {read = GetInfo, write = PutInfo};
// Search methods
int IndexBySocket(TCustomWinSocket* Socket);
int IndexByTunnel(TElSSHTunnelConnection* Tunnel);
// Add methods
// Adds new instance of TTunnelInfo
void AddTunnel(TTunnelInfo* AObject);
// Adds new instance basing on socket connection
void AddBySocket(TCustomWinSocket* ASocket);
// Adds tunnel for existing socket connection
void AddTunnelForSocket(TCustomWinSocket* ASocket, TElSSHTunnelConnection* ATunnel);
};
class TfrmMain : public TForm
{
__published: // IDE-managed Components
TGroupBox *gbConnectOptions;
TLabel *lblSSHHost;
TLabel *lblSSHPort;
TLabel *lblSSHUserName;
TLabel *lblSSHPassword;
TLabel *lblLocalServerPort;
TLabel *lblRemoteHostPort;
TPanel *pnlSSHParameters;
TEdit *edtSSHHost;
TEdit *edtSSHPort;
TEdit *edtSSHUsername;
TEdit *edtSSHPassword;
TPanel *pnlForwardingParameters;
TEdit *edtLocalServerPort;
TEdit *edtRemoteHost;
TEdit *edtRemotePort;
TButton *btnStart;
TPanel *PanelClient;
TSplitter *Splitter;
TListView *lvEvents;
TPanel *PanelStatus;
TListView *lvConnections;
TServerSocket *ServerSocket;
TClientSocket *SSHClientSocket;
TElSSHClient *ElSSHClient;
TElLocalPortForwardSSHTunnel *ElLocalPortForwardSSHTunnel;
TElSSHTunnelList *SSHTunnelList;
TImageList *ilEvents;
TImageList *ilConnections;
void __fastcall FormCreate(TObject *Sender);
void __fastcall FormDestroy(TObject *Sender);
void __fastcall SSHClientSocketConnect(TObject *Sender,
TCustomWinSocket *Socket);
void __fastcall SSHClientSocketRead(TObject *Sender,
TCustomWinSocket *Socket);
void __fastcall SSHClientSocketDisconnect(TObject *Sender,
TCustomWinSocket *Socket);
void __fastcall ElSSHClientAuthenticationFailed(TObject *Sender,
int AuthenticationType);
void __fastcall ElSSHClientAuthenticationSuccess(TObject *Sender);
void __fastcall ElSSHClientCloseConnection(TObject *Sender);
void __fastcall ElSSHClientDebugData(TObject *Sender,
Pointer Buffer, int Size);
void __fastcall ElSSHClientError(TObject *Sender, int ErrorCode);
void __fastcall ElSSHClientKeyValidate(TObject *Sender,
TElSSHKey *ServerKey, bool &Validate);
void __fastcall ElSSHClientOpenConnection(TObject *Sender);
void __fastcall ElSSHClientReceive(TObject *Sender, Pointer Buffer,
int MaxSize, int Written);
void __fastcall ElSSHClientSend(TObject *Sender, Pointer Buffer,
int Size);
void __fastcall ElLocalPortForwardSSHTunnelClose(TObject *Sender,
TElSSHTunnelConnection *TunnelConnection);
void __fastcall ElLocalPortForwardSSHTunnelError(TObject *Sender,
int Error, Pointer Data);
void __fastcall ElLocalPortForwardSSHTunnelOpen(TObject *Sender,
TElSSHTunnelConnection *TunnelConnection);
void __fastcall ServerSocketClientConnect(TObject *Sender,
TCustomWinSocket *Socket);
void __fastcall ServerSocketClientDisconnect(TObject *Sender,
TCustomWinSocket *Socket);
void __fastcall ServerSocketClientRead(TObject *Sender,
TCustomWinSocket *Socket);
void __fastcall btnStartClick(TObject *Sender);
private: // User declarations
TTunnelInfoList* TunnelInfo;
void Log(const AnsiString S, bool AError = false);
void RemoveConnectionFromList(TElSSHTunnelConnection* Conn);// overload;
void SetBufferCount(int Value);
void RefreshListView(void);
void ClearConnections(void);
public: // User declarations
__fastcall TfrmMain(TComponent* Owner);
void __fastcall TunnelConnectionData(TObject* Sender, void* Buffer, int Size);
void __fastcall TunnelConnectionError(TObject* Sender, int ErrorCode);
void __fastcall TunnelConnectionClose(TObject* Sender, TSSHCloseType CloseType);
};
typedef struct
{
int Sent;
int Received;
char SocketState;
}TForwardStatus;
typedef TForwardStatus* PForwardStatus;
//---------------------------------------------------------------------------
TList* ConnList;
TList* SocketList;
TStringList* BufferList;
TList* StatusList;
bool ConnActive;
extern PACKAGE TfrmMain *frmMain;
//---------------------------------------------------------------------------
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?