TSG-13196 Decrypted Traffic Steering时照常统计intercept bytes

* STAT_STREAM_INCPT_DOWN_BYTES
    * STAT_STREAM_INCPT_UP_BYTES
    * STAT_STREAM_INCPT_BYTES
This commit is contained in:
luwenpeng
2022-12-29 14:28:49 +08:00
parent 0f542d376f
commit 2a2bead767

View File

@@ -597,21 +597,19 @@ static void __stream_bev_readcb(struct bufferevent * bev, void * arg)
struct tfe_conn_private * peer_conn = NULL;
struct evbuffer * inbuf = NULL;
struct evbuffer * outbuf = NULL;
int inbuff_len = 0;
if (steering_device_is_available() && (
(STREAM_PROTO_PLAIN == _stream->session_type && _stream->proxy_ref->traffic_steering_options.enable_steering_http) ||
(STREAM_PROTO_SSL == _stream->session_type &&_stream->proxy_ref->traffic_steering_options.enable_steering_ssl)))
{
enum TFE_STAT_FIELD stat_filed = TFE_STAT_MAX;
if (bev == _stream->conn_downstream->bev)
{
peer_conn = _stream->conn_fake_c;
stat_filed = STAT_STEERING_CLIENT_TX_B;
}
else if (bev == _stream->conn_upstream->bev)
{
peer_conn = _stream->conn_fake_s;
stat_filed = STAT_STEERING_SERVER_TX_B;
}
else
{
@@ -623,22 +621,39 @@ static void __stream_bev_readcb(struct bufferevent * bev, void * arg)
* This connection will be destoryed in __event_cb
*/
inbuf = bufferevent_get_input(bev);
inbuff_len = evbuffer_get_length(inbuf);
if (peer_conn == NULL)
{
evbuffer_drain(inbuf, evbuffer_get_length(inbuf));
evbuffer_drain(inbuf, inbuff_len);
return;
}
TFE_LOG_DEBUG(__STREAM_LOGGER(_stream), "decrypted traffic steering, %s send %d bytes from %s to %s",
_stream->str_stream_addr,
evbuffer_get_length(inbuf),
inbuff_len,
bev == _stream->conn_downstream->bev ? "conn_downstream" : "conn_upstream",
bev == _stream->conn_downstream->bev ? "conn_fake_c" : "conn_fake_s");
TFE_PROXY_STAT_INCREASE(stat_filed, evbuffer_get_length(inbuf));
outbuf = bufferevent_get_output(peer_conn->bev);
evbuffer_add_buffer(outbuf, inbuf);
if (bev == _stream->conn_downstream->bev)
{
TFE_PROXY_STAT_INCREASE(STAT_STEERING_CLIENT_TX_B, inbuff_len);
// TODO: Delete the following code when support calling the tfe-plugin
TFE_PROXY_STAT_INCREASE(STAT_STREAM_INCPT_DOWN_BYTES, inbuff_len);
_stream->downstream_rx_offset += inbuff_len;
}
else
{
TFE_PROXY_STAT_INCREASE(STAT_STEERING_SERVER_TX_B, inbuff_len);
// TODO: Delete the following code when support calling the tfe-plugin
TFE_PROXY_STAT_INCREASE(STAT_STREAM_INCPT_UP_BYTES, inbuff_len);
_stream->upstream_rx_offset += inbuff_len;
}
// TODO: Delete the following code when support calling the tfe-plugin
TFE_PROXY_STAT_INCREASE(STAT_STREAM_INCPT_BYTES, inbuff_len);
return;
}