2020-05-09 23:31:44 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
#include "../acl_cpp_define.hpp"
|
2020-07-01 16:45:26 +08:00
|
|
|
|
#include "../stdlib/string.hpp"
|
2020-05-09 23:31:44 +08:00
|
|
|
|
#include "stream_hook.hpp"
|
|
|
|
|
|
|
|
|
|
struct ACL_VSTREAM;
|
|
|
|
|
|
|
|
|
|
namespace acl {
|
|
|
|
|
|
|
|
|
|
class sslbase_conf;
|
|
|
|
|
class atomic_long;
|
|
|
|
|
|
2022-08-19 10:28:04 +08:00
|
|
|
|
class ACL_CPP_API sslbase_io : public stream_hook {
|
2020-05-09 23:31:44 +08:00
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>캯<EFBFBD><EFBFBD>
|
|
|
|
|
* @param conf {sslbase_conf&} <EFBFBD><EFBFBD>ÿһ<EFBFBD><EFBFBD> SSL <EFBFBD><EFBFBD><EFBFBD>ӽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param server_side {bool} <EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* ģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param nblock {bool} <EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
|
|
|
|
*/
|
|
|
|
|
sslbase_io(sslbase_conf& conf, bool server_side, bool nblock = false);
|
|
|
|
|
virtual ~sslbase_io(void);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ssl <EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD>鷽<EFBFBD><EFBFBD>
|
|
|
|
|
* @return {bool}
|
|
|
|
|
*/
|
|
|
|
|
virtual bool handshake(void) = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
|
|
|
|
* @param yes {bool} <EFBFBD><EFBFBD>Ϊ false ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
|
|
|
|
*/
|
|
|
|
|
void set_non_blocking(bool yes);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>жϵ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD> SSL IO <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> true <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾΪ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
|
|
|
|
*/
|
|
|
|
|
bool is_non_blocking(void) const
|
|
|
|
|
{
|
|
|
|
|
return nblock_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>ж<EFBFBD> SSL <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
|
|
|
|
|
* @return {bool}
|
|
|
|
|
*/
|
|
|
|
|
bool handshake_ok(void)
|
|
|
|
|
{
|
|
|
|
|
return handshake_ok_;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-01 16:45:26 +08:00
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> SNI HOST <EFBFBD>ֶ<EFBFBD>
|
|
|
|
|
* @param host {const char*}
|
|
|
|
|
*/
|
|
|
|
|
void set_sni_host(const char* host);
|
|
|
|
|
|
2020-05-09 23:31:44 +08:00
|
|
|
|
protected:
|
|
|
|
|
sslbase_conf& base_conf_;
|
|
|
|
|
bool server_side_;
|
|
|
|
|
bool nblock_;
|
|
|
|
|
bool handshake_ok_;
|
|
|
|
|
atomic_long* refers_;
|
|
|
|
|
ACL_VSTREAM* stream_;
|
2020-07-01 16:45:26 +08:00
|
|
|
|
string sni_host_; // just for SNI
|
2020-05-09 23:31:44 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|