TSG-16126 修复Proxy Events日志中存在c2s和s2c有字节数为0的问题

This commit is contained in:
fengweihao
2023-08-02 16:55:56 +08:00
parent 2451bd795c
commit e43b4954b5
9 changed files with 34 additions and 17 deletions

View File

@@ -1272,6 +1272,8 @@ struct proxy_http_ctx
struct cache_write_context* cache_write_ctx;
int cache_wirte_result;
size_t c2s_byte_num;
size_t s2c_byte_num;
int thread_id;
};
@@ -2027,7 +2029,7 @@ static void http_get_subscriber_id(const struct tfe_stream * stream, char *repla
{
int ret = 0;
uint16_t opt_out_size;
char source_subscribe_id[TFE_STRING_MAX] = {0};
char source_subscribe_id[TFE_SYMBOL_MAX] = {0};
struct tfe_cmsg *cmsg = tfe_stream_get0_cmsg(stream);
if (cmsg != NULL)
{
@@ -2070,7 +2072,7 @@ static int http_regex_replace(const struct tfe_stream * stream, char *message, i
}
if(strcasestr(message,"tsg_subscriber_id") != NULL)
{
memset(replace_with, TFE_SYMBOL_MAX, 0);
memset(replace_with, 0, TFE_SYMBOL_MAX);
rule[n_rule].zone = kZoneRequestUri;
rule[n_rule].find = tfe_strdup("{{tsg_subscriber_id}}");
http_get_subscriber_id(stream, replace_with);
@@ -2079,7 +2081,7 @@ static int http_regex_replace(const struct tfe_stream * stream, char *message, i
}
if(strcasestr(message,"tsg_client_ip") != NULL)
{
memset(replace_with, TFE_SYMBOL_MAX, 0);
memset(replace_with, 0, TFE_SYMBOL_MAX);
rule[n_rule].zone = kZoneRequestUri;
rule[n_rule].find = tfe_strdup("{{tsg_client_ip}}");
http_get_client_id(stream, replace_with);
@@ -2840,6 +2842,9 @@ void enforce_control_policy(const struct tfe_stream * stream, const struct tfe_h
evbuffer_add(ctx->log_resp_body, body_frag, frag_size);
}
tfe_stream_info_get(stream, INFO_FROM_DOWNSTREAM_RX_OFFSET, &(ctx->c2s_byte_num), sizeof(ctx->c2s_byte_num));
tfe_stream_info_get(stream, INFO_FROM_UPSTREAM_RX_OFFSET, &(ctx->s2c_byte_num), sizeof(ctx->s2c_byte_num));
return;
}
#define RESUMED_CB_NO_MORE_CALLS 0
@@ -3341,7 +3346,7 @@ void proxy_on_http_end(const struct tfe_stream * stream,
struct proxy_log log_msg = {.stream=stream, .http=session, .result=(struct log_rule_t *)ctx->enforce_rules, .result_num=ctx->n_enforce,
.req_body=ctx->log_req_body, .resp_body=ctx->log_resp_body, .action=0, .inject_sz=ctx->inject_sz,
.asn_client=ctx->ip_ctx.asn_client, .asn_server=ctx->ip_ctx.asn_server, .location_client=ctx->ip_ctx.location_client,
.location_server=ctx->ip_ctx.location_server};
.location_server=ctx->ip_ctx.location_server, .c2s_byte_num=ctx->c2s_byte_num, .s2c_byte_num=ctx->s2c_byte_num};
if(ctx->action == PX_ACTION_MANIPULATE)
{
log_msg.action = ctx->param->action;