TSG-5003 无条件发送Metric,与Log Session开关无关

请求体正则替换修复
This commit is contained in:
fengweihao
2021-01-12 16:17:18 +08:00
parent f99cfe9c1c
commit fee4b2daaa
2 changed files with 15 additions and 26 deletions

View File

@@ -1434,8 +1434,8 @@ void http_replace(const struct tfe_stream * stream, const struct tfe_http_sessio
rewrite_buff = NULL;
rewrite_sz = 0;
if (tfe_http_in_response(events) && in_resp_spec->content_type != NULL
&& strcasestr(in_resp_spec->content_type, "utf-8"))
if ((tfe_http_in_response(events) && in_resp_spec->content_type != NULL
&& strcasestr(in_resp_spec->content_type, "utf-8")) || tfe_http_in_request(events))
{
options = 1;
}
@@ -1555,10 +1555,8 @@ static void http_redirect(const struct tfe_http_session * session, enum tfe_http
{
assert(0);
}
if(ctx->enforce_rules[0].do_log > 0)
{
ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_REDIRECT]));
}
ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_REDIRECT]));
response = tfe_http_session_response_create(to_write, resp_code);
tfe_http_std_field_write(response, TFE_HTTP_LOCATION, rd_url);
@@ -1610,10 +1608,7 @@ static void http_block(const struct tfe_http_session * session, enum tfe_http_ev
snprintf(cont_len_str, sizeof(cont_len_str), "%lu", page_size);
tfe_http_std_field_write(response, TFE_HTTP_CONT_LENGTH, cont_len_str);
if(ctx->enforce_rules[0].do_log > 0)
{
ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_REJECT]));
}
ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_REJECT]));
tfe_http_half_append_body(response, page_buff, page_size, 0);
tfe_http_half_append_body(response, NULL, 0, 0);
tfe_http_session_response_set(to_write_sess, response);
@@ -1622,10 +1617,7 @@ static void http_block(const struct tfe_http_session * session, enum tfe_http_ev
}
else
{
if(ctx->enforce_rules[0].do_log > 0)
{
ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_REJECT]));
}
ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_REJECT]));
to_write_sess = tfe_http_session_allow_write(session);
tfe_http_session_kill(to_write_sess);
}
@@ -1685,13 +1677,10 @@ static void http_hijack(const struct tfe_http_session * session, enum tfe_http_e
return;
}
ctx->inject_sz = hijack_size;
if(ctx->enforce_rules[0].do_log > 0)
{
ATOMIC_ADD(&(g_pangu_rt->stat_val[STAT_ACTION_HIJACK_SZ]), hijack_size);
ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_HIJACK]));
}
char cont_len_str[16];
ATOMIC_ADD(&(g_pangu_rt->stat_val[STAT_ACTION_HIJACK_SZ]), hijack_size);
ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_HIJACK]));
char cont_len_str[16];
to_write_sess = tfe_http_session_allow_write(session);
response = tfe_http_session_response_create(to_write_sess, 200);
@@ -1865,11 +1854,8 @@ static void http_insert(const struct tfe_stream * stream, const struct tfe_http_
if (rewrite_sz >0)
{
tfe_http_half_append_body(ins_ctx->replacing, rewrite_buff, rewrite_sz, 0);
if(ctx->enforce_rules[0].do_log > 0)
{
ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_INSERT]));
ATOMIC_ADD(&(g_pangu_rt->stat_val[STAT_ACTION_INSERT_SZ]), ctx->inject_sz);
}
ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_INSERT]));
ATOMIC_ADD(&(g_pangu_rt->stat_val[STAT_ACTION_INSERT_SZ]), ctx->inject_sz);
ins_ctx->actually_inserted=1;
}
else
@@ -2524,7 +2510,7 @@ void pangu_on_http_end(const struct tfe_stream * stream,
}
}
if(ctx->rep_ctx && ctx->rep_ctx->actually_replaced==1 && ctx->enforce_rules[0].do_log ==1)
if(ctx->rep_ctx && ctx->rep_ctx->actually_replaced==1)
{
ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_REPLACE]));
}