TSG-5003 无条件发送Metric,与Log Session开关无关
请求体正则替换修复
This commit is contained in:
@@ -1434,8 +1434,8 @@ void http_replace(const struct tfe_stream * stream, const struct tfe_http_sessio
|
|||||||
rewrite_buff = NULL;
|
rewrite_buff = NULL;
|
||||||
rewrite_sz = 0;
|
rewrite_sz = 0;
|
||||||
|
|
||||||
if (tfe_http_in_response(events) && in_resp_spec->content_type != NULL
|
if ((tfe_http_in_response(events) && in_resp_spec->content_type != NULL
|
||||||
&& strcasestr(in_resp_spec->content_type, "utf-8"))
|
&& strcasestr(in_resp_spec->content_type, "utf-8")) || tfe_http_in_request(events))
|
||||||
{
|
{
|
||||||
options = 1;
|
options = 1;
|
||||||
}
|
}
|
||||||
@@ -1555,10 +1555,8 @@ static void http_redirect(const struct tfe_http_session * session, enum tfe_http
|
|||||||
{
|
{
|
||||||
assert(0);
|
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);
|
response = tfe_http_session_response_create(to_write, resp_code);
|
||||||
tfe_http_std_field_write(response, TFE_HTTP_LOCATION, rd_url);
|
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);
|
snprintf(cont_len_str, sizeof(cont_len_str), "%lu", page_size);
|
||||||
tfe_http_std_field_write(response, TFE_HTTP_CONT_LENGTH, cont_len_str);
|
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, page_buff, page_size, 0);
|
||||||
tfe_http_half_append_body(response, NULL, 0, 0);
|
tfe_http_half_append_body(response, NULL, 0, 0);
|
||||||
tfe_http_session_response_set(to_write_sess, response);
|
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
|
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);
|
to_write_sess = tfe_http_session_allow_write(session);
|
||||||
tfe_http_session_kill(to_write_sess);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
ctx->inject_sz = hijack_size;
|
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]));
|
||||||
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];
|
|
||||||
|
|
||||||
|
char cont_len_str[16];
|
||||||
to_write_sess = tfe_http_session_allow_write(session);
|
to_write_sess = tfe_http_session_allow_write(session);
|
||||||
response = tfe_http_session_response_create(to_write_sess, 200);
|
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)
|
if (rewrite_sz >0)
|
||||||
{
|
{
|
||||||
tfe_http_half_append_body(ins_ctx->replacing, rewrite_buff, 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;
|
ins_ctx->actually_inserted=1;
|
||||||
}
|
}
|
||||||
else
|
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]));
|
ATOMIC_INC(&(g_pangu_rt->stat_val[STAT_ACTION_REPLACE]));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1959,6 +1959,9 @@ finish:
|
|||||||
h2_stream_info->thread_id);
|
h2_stream_info->thread_id);
|
||||||
h2_session->frame_ctx = NULL;
|
h2_session->frame_ctx = NULL;
|
||||||
delete_http2_stream_data(h2_session, h2_stream_info->tf_stream, 1);
|
delete_http2_stream_data(h2_session, h2_stream_info->tf_stream, 1);
|
||||||
|
/*The stream connection is closed, Force clear context**/
|
||||||
|
nghttp2_session_set_stream_user_data(h2_stream_info->as_client, stream_id, NULL);
|
||||||
|
nghttp2_session_set_stream_user_data(h2_stream_info->as_server, stream_id, NULL);
|
||||||
free(h2_session);
|
free(h2_session);
|
||||||
h2_session = NULL;
|
h2_session = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user