1.修改HTTP2命中block规则后,页面无法显示问题
2.上次漏提代码对ex_data释放接口
This commit is contained in:
@@ -92,6 +92,7 @@ enum manipulate_profile_table
|
|||||||
struct manipulate_profile
|
struct manipulate_profile
|
||||||
{
|
{
|
||||||
int profile_id;
|
int profile_id;
|
||||||
|
int ref_cnt;
|
||||||
size_t msg_len;
|
size_t msg_len;
|
||||||
char *profile_name;
|
char *profile_name;
|
||||||
char *profile_msg;
|
char *profile_msg;
|
||||||
@@ -629,8 +630,10 @@ void ma_profile_table_new_cb(int table_id, const char* key, const char* table_li
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct manipulate_profile* ply_profile=ALLOC(struct manipulate_profile, 1);
|
struct manipulate_profile* ply_profile=ALLOC(struct manipulate_profile, 1);
|
||||||
|
memset(ply_profile, 0, sizeof(struct manipulate_profile));
|
||||||
|
|
||||||
ply_profile->profile_id=profile_id;
|
ply_profile->profile_id=profile_id;
|
||||||
|
ply_profile->ref_cnt=1;
|
||||||
if(strcasecmp(formate, "template") == 0)
|
if(strcasecmp(formate, "template") == 0)
|
||||||
{
|
{
|
||||||
ply_profile->tpl = ctemplate::Template::GetTemplate(profile_path, ctemplate::DO_NOT_STRIP);
|
ply_profile->tpl = ctemplate::Template::GetTemplate(profile_path, ctemplate::DO_NOT_STRIP);
|
||||||
@@ -652,16 +655,27 @@ void ma_profile_table_new_cb(int table_id, const char* key, const char* table_li
|
|||||||
void ma_profile_table_free_cb(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void *argp)
|
void ma_profile_table_free_cb(int table_id, MAAT_PLUGIN_EX_DATA* ad, long argl, void *argp)
|
||||||
{
|
{
|
||||||
struct manipulate_profile* ply_obj=(struct manipulate_profile*)(*ad);
|
struct manipulate_profile* ply_obj=(struct manipulate_profile*)(*ad);
|
||||||
|
ply_obj->ref_cnt--;
|
||||||
|
|
||||||
|
if (ply_obj->ref_cnt==0)
|
||||||
|
{
|
||||||
FREE(&ply_obj->profile_type);
|
FREE(&ply_obj->profile_type);
|
||||||
FREE(&ply_obj->profile_msg);
|
FREE(&ply_obj->profile_msg);
|
||||||
FREE(&ply_obj->profile_name);
|
FREE(&ply_obj->profile_name);
|
||||||
FREE(&ply_obj);
|
FREE(&ply_obj);
|
||||||
*ad=NULL;
|
*ad=NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ma_profile_table_free(struct manipulate_profile* ply_obj)
|
||||||
|
{
|
||||||
|
ma_profile_table_free_cb(0, (void **)&ply_obj, 0, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void ma_profile_table_dup_cb(int table_id, MAAT_PLUGIN_EX_DATA *to, MAAT_PLUGIN_EX_DATA *from, long argl, void *argp)
|
void ma_profile_table_dup_cb(int table_id, MAAT_PLUGIN_EX_DATA *to, MAAT_PLUGIN_EX_DATA *from, long argl, void *argp)
|
||||||
{
|
{
|
||||||
struct manipulate_profile* ply_obj=(struct manipulate_profile*)(*from);
|
struct manipulate_profile* ply_obj=(struct manipulate_profile*)(*from);
|
||||||
|
ply_obj->ref_cnt++;
|
||||||
*to=ply_obj;
|
*to=ply_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -892,7 +906,6 @@ struct pangu_http_ctx
|
|||||||
struct cache_mid* cmid;
|
struct cache_mid* cmid;
|
||||||
struct Maat_rule_t * enforce_rules;
|
struct Maat_rule_t * enforce_rules;
|
||||||
size_t n_enforce;
|
size_t n_enforce;
|
||||||
char * enforce_para;
|
|
||||||
struct policy_action_param *param;
|
struct policy_action_param *param;
|
||||||
struct evbuffer* log_req_body, *log_resp_body;
|
struct evbuffer* log_req_body, *log_resp_body;
|
||||||
|
|
||||||
@@ -968,7 +981,8 @@ static void pangu_http_ctx_free(struct pangu_http_ctx * ctx)
|
|||||||
ctx->ins_ctx = NULL;
|
ctx->ins_ctx = NULL;
|
||||||
}
|
}
|
||||||
FREE(&ctx->enforce_rules);
|
FREE(&ctx->enforce_rules);
|
||||||
FREE(&ctx->enforce_para);
|
policy_action_param_free(ctx->param);
|
||||||
|
ctx->param=NULL;
|
||||||
Maat_clean_status(&(ctx->scan_mid));
|
Maat_clean_status(&(ctx->scan_mid));
|
||||||
ctx->scan_mid = NULL;
|
ctx->scan_mid = NULL;
|
||||||
|
|
||||||
@@ -1191,7 +1205,9 @@ static int html_generate(int profile_id, const char* msg, char ** page_buff, siz
|
|||||||
*page_size = block_profile->msg_len;
|
*page_size = block_profile->msg_len;
|
||||||
*page_buff = tfe_strdup(block_profile->profile_msg);
|
*page_buff = tfe_strdup(block_profile->profile_msg);
|
||||||
}
|
}
|
||||||
|
ma_profile_table_free(block_profile);
|
||||||
block_profile=NULL;
|
block_profile=NULL;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1523,6 +1539,7 @@ static void http_hijack(const struct tfe_http_session * session, enum tfe_http_e
|
|||||||
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);
|
||||||
tfe_http_session_detach(session);
|
tfe_http_session_detach(session);
|
||||||
|
ma_profile_table_free(hijack_profile);
|
||||||
hijack_profile = NULL;
|
hijack_profile = NULL;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -1543,6 +1560,7 @@ static int format_insert_rule(int profile_id, const char* insert_position, struc
|
|||||||
|
|
||||||
if (insert_position)
|
if (insert_position)
|
||||||
rule->position=tfe_strdup(insert_position);
|
rule->position=tfe_strdup(insert_position);
|
||||||
|
ma_profile_table_free(insert_profile);
|
||||||
insert_profile = NULL;
|
insert_profile = NULL;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -863,8 +863,11 @@ nghttp2_submit_frame_priority(struct tfe_session_info_t *session_info,const nght
|
|||||||
dir, nghttp2_strerror(xret));
|
dir, nghttp2_strerror(xret));
|
||||||
}
|
}
|
||||||
finish:
|
finish:
|
||||||
|
|
||||||
|
#ifdef TFE_LOG_HTTP2
|
||||||
TFE_LOG_DEBUG(logger()->handle, "%s, %d, submit priority, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
TFE_LOG_DEBUG(logger()->handle, "%s, %d, submit priority, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
||||||
dir, frame->hd.stream_id, session_info->stream_action);
|
dir, frame->hd.stream_id, session_info->stream_action);
|
||||||
|
#endif
|
||||||
session_info->stream_action = stream_action;
|
session_info->stream_action = stream_action;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -895,8 +898,11 @@ nghttp2_submit_frame_rst_stream(struct tfe_session_info_t *session_info,const ng
|
|||||||
}
|
}
|
||||||
finish:
|
finish:
|
||||||
session_info->stream_action = stream_action;
|
session_info->stream_action = stream_action;
|
||||||
|
|
||||||
|
#ifdef TFE_LOG_HTTP2
|
||||||
TFE_LOG_DEBUG(logger()->handle, "%s, %d, submit rst stream, stream_id:%d, action:%d, error_code = %d", session_info->tf_stream->str_stream_info,
|
TFE_LOG_DEBUG(logger()->handle, "%s, %d, submit rst stream, stream_id:%d, action:%d, error_code = %d", session_info->tf_stream->str_stream_info,
|
||||||
dir, frame->hd.stream_id, session_info->stream_action, rst_stream->error_code);
|
dir, frame->hd.stream_id, session_info->stream_action, rst_stream->error_code);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -937,8 +943,11 @@ nghttp2_submit_frame_settings(struct tfe_session_info_t *session_info,const nght
|
|||||||
}
|
}
|
||||||
finish:
|
finish:
|
||||||
session_info->stream_action = stream_action;
|
session_info->stream_action = stream_action;
|
||||||
|
|
||||||
|
#ifdef TFE_LOG_HTTP2
|
||||||
TFE_LOG_DEBUG(logger()->handle, "%s, %d, submit setting, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
TFE_LOG_DEBUG(logger()->handle, "%s, %d, submit setting, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
||||||
dir, frame->hd.stream_id, session_info->stream_action);
|
dir, frame->hd.stream_id, session_info->stream_action);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -968,8 +977,11 @@ nghttp2_submit_frame_ping(struct tfe_session_info_t *session_info,const nghttp2_
|
|||||||
}
|
}
|
||||||
finish:
|
finish:
|
||||||
session_info->stream_action = stream_action;
|
session_info->stream_action = stream_action;
|
||||||
|
|
||||||
|
#ifdef TFE_LOG_HTTP2
|
||||||
TFE_LOG_DEBUG(logger()->handle, "%s, %d, submit ping, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
TFE_LOG_DEBUG(logger()->handle, "%s, %d, submit ping, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
||||||
dir, frame->hd.stream_id, session_info->stream_action);
|
dir, frame->hd.stream_id, session_info->stream_action);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1107,8 +1119,11 @@ nghttp2_submit_frame_window_update(struct tfe_session_info_t *session_info,const
|
|||||||
}
|
}
|
||||||
finish:
|
finish:
|
||||||
session_info->stream_action = stream_action;
|
session_info->stream_action = stream_action;
|
||||||
|
|
||||||
|
#ifdef TFE_LOG_HTTP2
|
||||||
TFE_LOG_DEBUG(logger()->handle, "%s, %d, submit window update, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
TFE_LOG_DEBUG(logger()->handle, "%s, %d, submit window update, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
||||||
dir, frame->hd.stream_id, session_info->stream_action);
|
dir, frame->hd.stream_id, session_info->stream_action);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1161,10 +1176,6 @@ nghttp2_submit_end_data(struct tfe_session_info_t *session_info,
|
|||||||
|
|
||||||
struct http2_half_private *resp = h2_stream->resp;
|
struct http2_half_private *resp = h2_stream->resp;
|
||||||
|
|
||||||
if (resp->body_state == MANAGE_STAGE_INIT){
|
|
||||||
nghttp2_submit_end_header(session_info, h2_stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (resp->body_state != MANAGE_STAGE_INIT){
|
if (resp->body_state != MANAGE_STAGE_INIT){
|
||||||
if (resp->event_cb) {
|
if (resp->event_cb) {
|
||||||
resp->event_cb(resp, EV_HTTP_RESP_BODY_END, NULL, 0,
|
resp->event_cb(resp, EV_HTTP_RESP_BODY_END, NULL, 0,
|
||||||
@@ -1188,9 +1199,11 @@ nghttp2_submit_end_data(struct tfe_session_info_t *session_info,
|
|||||||
TFE_LOG_ERROR(logger()->handle, "Fatal upstream send error: %s\n",nghttp2_strerror(xret));
|
TFE_LOG_ERROR(logger()->handle, "Fatal upstream send error: %s\n",nghttp2_strerror(xret));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TFE_LOG_HTTP2
|
||||||
TFE_LOG_DEBUG(logger()->handle, "%s, 1, End of stream submit, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
TFE_LOG_DEBUG(logger()->handle, "%s, 1, End of stream submit, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
||||||
h2_stream->stream_id, session_info->stream_action);
|
h2_stream->stream_id, session_info->stream_action);
|
||||||
|
#endif
|
||||||
if (stream_action == ACTION_USER_DATA)
|
if (stream_action == ACTION_USER_DATA)
|
||||||
stream_action = ACTION_DROP_DATA;
|
stream_action = ACTION_DROP_DATA;
|
||||||
session_info->stream_action = stream_action;
|
session_info->stream_action = stream_action;
|
||||||
@@ -1354,8 +1367,11 @@ nghttp2_submit_frame_push_promise(struct tfe_session_info_t *session_info,const
|
|||||||
}
|
}
|
||||||
session_info->stream_action = stream_action;
|
session_info->stream_action = stream_action;
|
||||||
finish:
|
finish:
|
||||||
|
|
||||||
|
#ifdef TFE_LOG_HTTP2
|
||||||
TFE_LOG_DEBUG(logger()->handle, "%s, %d, submit push promise, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
TFE_LOG_DEBUG(logger()->handle, "%s, %d, submit push promise, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
||||||
dir, frame->hd.stream_id, session_info->stream_action);
|
dir, frame->hd.stream_id, session_info->stream_action);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1682,7 +1698,7 @@ tfe_submit_response(struct tfe_session_info_t *session_info,
|
|||||||
|
|
||||||
stream_action = nghttp2_server_frame_submit_response(session_info, h2_stream);
|
stream_action = nghttp2_server_frame_submit_response(session_info, h2_stream);
|
||||||
if (stream_action == ACTION_DROP_DATA){
|
if (stream_action == ACTION_DROP_DATA){
|
||||||
xret = nghttp2_session_send(session_info->as_client);
|
xret = nghttp2_session_send(session_info->as_server);
|
||||||
if (xret != 0) {
|
if (xret != 0) {
|
||||||
stream_action = ACTION_FORWARD_DATA;
|
stream_action = ACTION_FORWARD_DATA;
|
||||||
TFE_LOG_ERROR(logger()->handle, "Fatal downstream send error: %s\n",
|
TFE_LOG_ERROR(logger()->handle, "Fatal downstream send error: %s\n",
|
||||||
@@ -1837,13 +1853,17 @@ nghttp2_submit_frame_header(struct tfe_session_info_t *session_info,const nghttp
|
|||||||
if (frame->hd.flags & NGHTTP2_FLAG_END_HEADERS){
|
if (frame->hd.flags & NGHTTP2_FLAG_END_HEADERS){
|
||||||
if (dir == CONN_DIR_UPSTREAM){
|
if (dir == CONN_DIR_UPSTREAM){
|
||||||
xret = nghttp2_server_submit_header(session_info, frame->hd.stream_id);
|
xret = nghttp2_server_submit_header(session_info, frame->hd.stream_id);
|
||||||
|
#ifdef TFE_LOG_HTTP2
|
||||||
TFE_LOG_DEBUG(logger()->handle, "%s, %d, submit response header, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
TFE_LOG_DEBUG(logger()->handle, "%s, %d, submit response header, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
||||||
dir, frame->hd.stream_id, session_info->stream_action);
|
dir, frame->hd.stream_id, session_info->stream_action);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (dir == CONN_DIR_DOWNSTREAM){
|
if (dir == CONN_DIR_DOWNSTREAM){
|
||||||
xret = nghttp2_client_submit_header(session_info, frame->hd.stream_id);
|
xret = nghttp2_client_submit_header(session_info, frame->hd.stream_id);
|
||||||
|
#ifdef TFE_LOG_HTTP2
|
||||||
TFE_LOG_DEBUG(logger()->handle, "%s, %d, submit request header, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
TFE_LOG_DEBUG(logger()->handle, "%s, %d, submit request header, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
||||||
dir, frame->hd.stream_id, session_info->stream_action);
|
dir, frame->hd.stream_id, session_info->stream_action);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return xret;
|
return xret;
|
||||||
@@ -2111,11 +2131,14 @@ nghttp2_client_on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
|
|||||||
xret = nghttp2_session_send(session_info->as_server);
|
xret = nghttp2_session_send(session_info->as_server);
|
||||||
if (xret != 0) {
|
if (xret != 0) {
|
||||||
stream_action = ACTION_FORWARD_DATA;
|
stream_action = ACTION_FORWARD_DATA;
|
||||||
TFE_LOG_ERROR(logger()->handle, "Fatal upstream send error: %s\n",nghttp2_strerror(xret));
|
TFE_LOG_ERROR(logger()->handle, "Fatal upstream(%d) send error: %s\n",stream_id, nghttp2_strerror(xret));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TFE_LOG_HTTP2
|
||||||
TFE_LOG_DEBUG(logger()->handle, "%s, 1, submit data %d, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
TFE_LOG_DEBUG(logger()->handle, "%s, 1, submit data %d, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
||||||
(int)input_len, stream_id, stream_action);
|
(int)input_len, stream_id, stream_action);
|
||||||
|
#endif
|
||||||
if (stream_action == ACTION_USER_DATA)
|
if (stream_action == ACTION_USER_DATA)
|
||||||
stream_action = ACTION_DROP_DATA;
|
stream_action = ACTION_DROP_DATA;
|
||||||
session_info->stream_action = stream_action;
|
session_info->stream_action = stream_action;
|
||||||
@@ -2402,8 +2425,11 @@ nghttp2_server_on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
|
|||||||
TFE_LOG_ERROR(logger()->handle, "Fatal upstream send error: %s\n",nghttp2_strerror(xret));
|
TFE_LOG_ERROR(logger()->handle, "Fatal upstream send error: %s\n",nghttp2_strerror(xret));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TFE_LOG_HTTP2
|
||||||
TFE_LOG_INFO(logger()->handle, "%s, %d, submit data %d, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
TFE_LOG_INFO(logger()->handle, "%s, %d, submit data %d, stream_id:%d, action:%d", session_info->tf_stream->str_stream_info,
|
||||||
0, (int)input_len, stream_id, session_info->stream_action);
|
0, (int)input_len, stream_id, session_info->stream_action);
|
||||||
|
#endif
|
||||||
if (stream_action == ACTION_USER_DATA)
|
if (stream_action == ACTION_USER_DATA)
|
||||||
stream_action = ACTION_DROP_DATA;
|
stream_action = ACTION_DROP_DATA;
|
||||||
session_info->stream_action = stream_action;
|
session_info->stream_action = stream_action;
|
||||||
|
|||||||
Reference in New Issue
Block a user