#167 增加已拦截连接数、字节数、PASSTHROUGH连接数统计并调整FieldStat状态文件的输出位置。
This commit is contained in:
@@ -422,7 +422,7 @@ static void __conn_private_destory(struct tfe_conn_private * conn)
|
||||
|
||||
free(conn);
|
||||
(void)ret;
|
||||
TFE_PROXY_STAT_INCREASE(STAT_FD_INSTANT_CLOSE, 1);
|
||||
TFE_PROXY_STAT_INCREASE(STAT_FD_CLOSE, 1);
|
||||
}
|
||||
|
||||
static void __conn_private_destory_with_ssl(struct event_base * ev_base,
|
||||
@@ -445,6 +445,12 @@ static void __stream_bev_passthrough_readcb(struct bufferevent * bev, void * arg
|
||||
return;
|
||||
}
|
||||
|
||||
if (_stream->is_first_call_rxcb == 0)
|
||||
{
|
||||
TFE_PROXY_STAT_INCREASE(STAT_STREAM_BYPASS, 1);
|
||||
_stream->is_first_call_rxcb = 1;
|
||||
}
|
||||
|
||||
struct evbuffer * __output_buffer = bufferevent_get_output(peer_conn->bev);
|
||||
evbuffer_add_buffer(__output_buffer, __input_buffer);
|
||||
}
|
||||
@@ -589,6 +595,12 @@ static void __stream_bev_readcb(struct bufferevent * bev, void * arg)
|
||||
return;
|
||||
}
|
||||
|
||||
if (_stream->is_first_call_rxcb == 0)
|
||||
{
|
||||
TFE_PROXY_STAT_INCREASE(STAT_STREAM_INTERCEPT, 1);
|
||||
_stream->is_first_call_rxcb = 1;
|
||||
}
|
||||
|
||||
struct evbuffer * outbuf = bufferevent_get_output(peer_conn->bev);
|
||||
assert(inbuf != NULL && outbuf != NULL);
|
||||
|
||||
@@ -673,15 +685,18 @@ static void __stream_bev_readcb(struct bufferevent * bev, void * arg)
|
||||
|
||||
if (dir == CONN_DIR_DOWNSTREAM)
|
||||
{
|
||||
TFE_PROXY_STAT_INCREASE(STAT_STREAM_DOWN_RX_BYTES, rx_offset_increase);
|
||||
TFE_PROXY_STAT_INCREASE(STAT_STREAM_INCPT_DOWN_BYTES, rx_offset_increase);
|
||||
_stream->downstream_rx_offset += rx_offset_increase;
|
||||
}
|
||||
else
|
||||
{
|
||||
TFE_PROXY_STAT_INCREASE(STAT_STREAM_UP_RX_BYTES, rx_offset_increase);
|
||||
TFE_PROXY_STAT_INCREASE(STAT_STREAM_INCPT_UP_BYTES, rx_offset_increase);
|
||||
_stream->upstream_rx_offset += rx_offset_increase;
|
||||
}
|
||||
|
||||
/* Total Bytes */
|
||||
TFE_PROXY_STAT_INCREASE(STAT_STREAM_INCPT_BYTES, rx_offset_increase);
|
||||
|
||||
if(_stream->need_to_be_kill)
|
||||
{
|
||||
const static struct linger sl{.l_onoff = 1, .l_linger = 0};
|
||||
@@ -997,18 +1012,18 @@ void ssl_upstream_create_on_success(future_result_t * result, void * user)
|
||||
enum ssl_stream_action ssl_action = ssl_upstream_create_result_release_action(result);
|
||||
if (SSL_ACTION_PASSTHROUGH == ssl_action)
|
||||
{
|
||||
_stream->tcp_passthough = true;
|
||||
_stream->conn_upstream = __conn_private_create_by_fd(_stream, _stream->defer_fd_upstream);
|
||||
_stream->conn_downstream = __conn_private_create_by_fd(_stream, _stream->defer_fd_downstream);
|
||||
__conn_private_enable(_stream->conn_downstream);
|
||||
__conn_private_enable(_stream->conn_upstream);
|
||||
|
||||
_stream->tcp_passthough = 1;
|
||||
_stream->defer_fd_downstream = 0;
|
||||
_stream->defer_fd_upstream = 0;
|
||||
}
|
||||
else if (SSL_ACTION_SHUTDOWN == ssl_action)
|
||||
{
|
||||
tfe_stream_destory(_stream);
|
||||
return tfe_stream_destory(_stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1232,7 +1247,8 @@ void __stream_fd_option_setup(struct tfe_stream_private * _stream, evutil_socket
|
||||
struct tfe_proxy_tcp_options * tcp_options = &_stream->proxy_ref->tcp_options;
|
||||
|
||||
/* Make it non-blocking */
|
||||
evutil_make_socket_nonblocking(fd);
|
||||
int ret = evutil_make_socket_nonblocking(fd);
|
||||
assert(ret >= 0);
|
||||
|
||||
/* Recv Buffer */
|
||||
if (tcp_options->sz_rcv_buffer >= 0)
|
||||
@@ -1307,6 +1323,8 @@ void __stream_fd_option_setup(struct tfe_stream_private * _stream, evutil_socket
|
||||
TFE_LOG_ERROR(g_default_logger, "%s: Failed at setup FD's ttl option, ttl = %d, fd = %d",
|
||||
stream->str_stream_info, __ttl, fd);
|
||||
}
|
||||
|
||||
(void)ret;
|
||||
}
|
||||
|
||||
int tfe_stream_init_by_fds(struct tfe_stream * stream, evutil_socket_t fd_downstream, evutil_socket_t fd_upstream)
|
||||
@@ -1325,8 +1343,7 @@ int tfe_stream_init_by_fds(struct tfe_stream * stream, evutil_socket_t fd_downst
|
||||
if (unlikely(_stream->head.addr == NULL))
|
||||
{
|
||||
TFE_LOG_ERROR(_stream->stream_logger, "Failed to create address from fd %d, %d, terminate fds.",
|
||||
fd_downstream, fd_upstream);
|
||||
goto __errout;
|
||||
fd_downstream, fd_upstream); goto __errout;
|
||||
}
|
||||
|
||||
_stream->str_stream_addr = tfe_stream_addr_to_str(_stream->head.addr);
|
||||
|
||||
Reference in New Issue
Block a user