📄 tunnel.h
字号:
/************************************
REVISION LOG ENTRY
Revision By: Alex Turc
Revised on 6/15/00 1:55:32 PM
Comments: Tunnel related clases
************************************/
#ifndef __tunnel_h__
#define __tunnel_h__
#include <string>
#include <vector>
using namespace std;
#include "mylib/_socket.h"
#include "mylib/_manage.h"
#include "mylib/_process.h"
#include "mylib/_exception.h"
using namespace extension;
#include "cfg.h"
// Forward declaration of the manager class.
// Is needed because tunnels requires a reference to the instance of this class
class manager;
/*
Tunnel exception class
*/
//##ModelId=3B79EDE4023D
class tunnel_exception :
public extended_exception
{
public:
// Function name : configuration_stream_exception
// Description : Exception raised when a tunneled connection failed
// Return type :
// Argument : long nCode - exception code
// Argument : const char* pDescription = "Tunnel exception" - description
// Argument : const char* pFile = "" - the file name where the exception has occured
// Argument : long nLine = -1 - the line number where the exception has occured
//##ModelId=3B79EDE40283
tunnel_exception( long nCode, const char* pDescription = "Tunnel exception", const char* pFile = "", long nLine = -1 ) :
extended_exception( nCode, pDescription, pFile, nLine )
{
}
};
/*
Tunnel class
*/
//##ModelId=3B79EDE40322
class tunnel
{
public:
// Source stream
//##ModelId=3B79EDE40391
a_ptr< sockstream > m_pskSource;
// Destination stream
//##ModelId=3B79EDE403E1
a_ptr< sockstream > m_pskDestination;
// Id of the tunnel
//##ModelId=3B79EDE5000C
long m_lID;
//##ModelId=3B79EDE500E9
tunnel( a_ptr< sockstream > pskSource, a_ptr< sockstream > pskDestination, int iBufferSize = 2 * 1024 );
//##ModelId=3B79EDE500FD
virtual ~tunnel();
//##ModelId=3B79EDE50108
void close();
//##ModelId=3B79EDE50111
bool is_active();
//##ModelId=3B79EDE5011B
void tunnel::do_data_transfer();
private:
// Buffer
int m_iContentSize_1, m_iContentSize_2;
vector< char > m_vctBuffer_1, m_vctBuffer_2;
};
/*
Tunnel constructor
*/
//##ModelId=3B79EDE50175
class tunnel_constructor :
public thread
{
public:
//##ModelId=3B79EDE50180
tunnel_constructor( manager* pManager, a_ptr< sockstream > pskSource, const char* szDestinationAddress, int iDestinationPort );
//##ModelId=3B79EDE50193
virtual ~tunnel_constructor();
//##ModelId=3B79EDE5019D
void close();
//##ModelId=3B79EDE501A7
virtual void stop();
protected:
// Source stream
//##ModelId=3B79EDE501BC
a_ptr< sockstream > m_pskSource;
// Destination stream
//##ModelId=3B79EDE501DA
a_ptr< sockstream > m_pskDestination;
// Destination addres
//##ModelId=3B79EDE501F8
string m_strDestinationAddress;
// Destination port
//##ModelId=3B79EDE50201
int m_iDestinationPort;
// Reference to the manager object
//##ModelId=3B79EDE50220
manager* m_pManager;
};
/*
Direct tunnel constructor
*/
//##ModelId=3B79EDE50251
class direct_tunnel_constructor :
public tunnel_constructor
{
public:
//##ModelId=3B79EDE5025C
direct_tunnel_constructor( manager* pManager, a_ptr< sockstream > pskSource, const char* szDestinationAddress, int iDestinationPort );
//##ModelId=3B79EDE5026F
virtual unsigned long run();
};
/*
Proxy tunnel constructor
*/
//##ModelId=3B79EDE502A1
class proxy_tunnel_constructor :
public tunnel_constructor
{
public:
//##ModelId=3B79EDE502AC
proxy_tunnel_constructor( manager* pManager, a_ptr< sockstream > pskSource, const char* szProxyAddress, int iProxyPort, const char* szDestinationAddress, int iDestinationPort );
//##ModelId=3B79EDE502C0
virtual unsigned long run();
protected:
// Proxy address
//##ModelId=3B79EDE502CA
string m_strProxyAddress;
// Proxy port
//##ModelId=3B79EDE502DD
int m_iProxyPort;
};
/*
Instances of this class listen on a port for new tunnel requests
*/
//##ModelId=3B79EDE50337
class tunnel_request_listener :
public tunnel_cfg,
public thread
{
public:
//##ModelId=3B79EDE50343
tunnel_request_listener( manager* pManager, const tunnel_cfg& c );
//##ModelId=3B79EDE5034D
virtual ~tunnel_request_listener();
//##ModelId=3B79EDE50356
virtual unsigned long run();
//##ModelId=3B79EDE50361
virtual void stop();
private:
// Reference to manager object
//##ModelId=3B79EDE5036B
manager* m_pManager;
// Server socket
//##ModelId=3B79EDE5037F
a_ptr< server_socket< char > > m_pskServerSocket;
//##ModelId=3B79EDE50392
bool use_proxy();
};
#endif // __tunnel_h__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -