为了识别第二种pinning:在tcp_stream的event callback中,若接收字节数为0,调用ssl_stream_process_zero_eof。

This commit is contained in:
zhengchao
2019-06-14 22:49:41 +08:00
parent b2eb88a7ad
commit b579c718b3
4 changed files with 30 additions and 9 deletions

View File

@@ -526,11 +526,14 @@ static void __stream_bev_readcb(struct bufferevent * bev, void * arg)
{
struct tfe_stream_private * _stream = (struct tfe_stream_private *) arg;
enum tfe_conn_dir dir = __bev_dir(_stream, bev);
struct tfe_conn_private * this_conn = __this_conn(_stream, dir);
struct tfe_conn_private * peer_conn = __peer_conn(_stream, dir);
/* Peer connection is terminated, drain all data.
* This connection will be destoryed in __event_cb */
struct evbuffer * inbuf = bufferevent_get_input(bev);
size_t contigous_len = evbuffer_get_length(inbuf);
this_conn->total_rx_bytes+=contigous_len;
if (peer_conn == NULL)
{
evbuffer_drain(inbuf, evbuffer_get_length(inbuf));
@@ -544,7 +547,6 @@ static void __stream_bev_readcb(struct bufferevent * bev, void * arg)
enum tfe_stream_action action_final = ACTION_FORWARD_DATA;
size_t drain_size = 0;
size_t contigous_len = evbuffer_get_length(inbuf);
unsigned char * contiguous_data = evbuffer_pullup(inbuf, contigous_len);
_stream->defer_bytes = 0;
@@ -585,10 +587,12 @@ static void __stream_bev_readcb(struct bufferevent * bev, void * arg)
if (_stream->forward_bytes > 0)
{
evbuffer_remove_buffer(inbuf, outbuf, _stream->forward_bytes);
peer_conn->total_tx_bytes+=_stream->forward_bytes;
}
else
{
evbuffer_add_buffer(outbuf, inbuf);
peer_conn->total_tx_bytes+=contigous_len;
}
break;
@@ -743,7 +747,10 @@ static void __stream_bev_eventcb(struct bufferevent * bev, short events, void *
_stream->str_stream_addr, str_conn_dir, errno, strerror(errno));
}
}
else if(events & BEV_EVENT_EOF && (*ref_this_conn)->total_rx_bytes==0 && _stream->session_type==STREAM_PROTO_SSL)
{
ssl_stream_process_zero_eof(*ref_this_ssl_stream, g_default_proxy->ssl_mgr_handler);
}
if(events & BEV_EVENT_ERROR) __stream_log_event(_stream, EVENT_LOG_CLOSE_BY_FD_ERROR, conn_dir, 0, NULL);
if(events & BEV_EVENT_EOF) __stream_log_event(_stream, EVENT_LOG_CLOSE_BY_FD_EOF, conn_dir, 0, NULL);
goto __close_connection;