Files
2026-05-20 03:08:08 +09:00

73 lines
1.5 KiB
C++

#ifndef MULTIPLEX_SSL_SOCKET__H_
#define MULTIPLEX_SSL_SOCKET__H_
#ifdef _WIN32
#pragma once
#endif
typedef struct ssl_ctx_st SSL_CTX;
typedef struct ssl_st SSL;
typedef struct bio_st BIO;
class HMultiplexSslSocket : public HMultiplexTcpSocket
{
public:
static SSL_CTX * m_sslCtxClient;
static SSL_CTX * m_sslCtxServer;
static void SslInit(const char * pszCertPath, const char * pszKeyPath, const char * pszCaPath);
static void SslDestroy();
//
HMultiplexSslSocket();
HMultiplexSslSocket(SOCKET sock, struct sockaddr_in * psaiRemote, HMpsDispatcher * pDispatcher);
~HMultiplexSslSocket();
bool Close();
int Send(const char * pData, int nSize);
int SendBufferedData();
//int Receive(char * pBuffer, int nSize);
int Receive();
bool SetRemoteAddressHostByName(const char * pszHostName, u_short nPort);
bool IsRemain();
inline bool IsEncryptRetry() { return m_bEncryptRetry; }
virtual bool IsSslSocket() { return true; }
protected:
enum {
TIMER_CHANNEL_CLOSE = 100,
TIMER_CHECK_RECEIVE = 101
};
void OnConnect(bool bIsSuccess);
virtual void OnConnectChild(bool bIsSuccess) {}
void OnAccepted();
//virtual void OnAcceptedChild() {}
bool ProcHandShake();
protected:
SSL_CTX * m_ssl_ctx;
SSL * m_ssl;
BIO * m_rbio;
HStreamBuffer * m_pStreamBufferForDecrypt;
BIO * m_wbio;
HStreamBuffer * m_pStreamBufferForSend;
char * m_pBufferForRecv;
char m_szDstServerName[512];
bool m_bIsSslConnecting; //...
bool m_bEncryptRetry;
};
#endif // MULTIPLEX_SSL_SOCKET__H_