修改http reject的模板,可以显示预配置的字符串。修改key keeper初始化MESA_htable的默认大小和超时。
This commit is contained in:
@@ -364,10 +364,11 @@ static enum pangu_action decide_ctrl_action(const struct Maat_rule_t * hit_rules
|
||||
return prior_action;
|
||||
}
|
||||
//HTML template is downloaded from https://github.com/AndiDittrich/HttpErrorPages
|
||||
static void html_generate(int cfg_id, int status_code, char ** page_buff, size_t * page_size)
|
||||
static void html_generate(int status_code, int cfg_id, const char* msg, char ** page_buff, size_t * page_size)
|
||||
{
|
||||
ctemplate::TemplateDictionary dict("pg_page_dict"); //dict is automatically finalized after function returned.
|
||||
dict.SetIntValue("cfg_id", cfg_id);
|
||||
dict.SetValue("msg", msg);
|
||||
std::string output;
|
||||
ctemplate::Template * tpl = NULL;
|
||||
|
||||
@@ -559,20 +560,23 @@ static void http_reject(const struct tfe_http_session * session, enum tfe_http_e
|
||||
char * page_buff = NULL;
|
||||
size_t page_size = 0;
|
||||
|
||||
char cont_len_str[TFE_STRING_MAX];
|
||||
char cont_len_str[16];
|
||||
char msg[TFE_STRING_MAX];
|
||||
struct tfe_http_session * to_write_sess = NULL;
|
||||
|
||||
ret = sscanf(ctx->enforce_para, "code=%d;", &resp_code);
|
||||
if (ret != 1)
|
||||
ret = sscanf(ctx->enforce_para, "code=%d;content=%s", &resp_code, msg);
|
||||
if (ret != 2)
|
||||
{
|
||||
TFE_LOG_ERROR(g_pangu_rt->local_logger, "Invalid reject rule %d paramter %s",
|
||||
ctx->enforce_rules[0].config_id, ctx->enforce_para); goto error_out;
|
||||
ctx->enforce_rules[0].config_id, ctx->enforce_para);
|
||||
ctx->action==PG_ACTION_NONE;
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
to_write_sess = tfe_http_session_allow_write(session);
|
||||
response = tfe_http_session_response_create(to_write_sess, resp_code);
|
||||
|
||||
html_generate(ctx->enforce_rules[0].config_id, resp_code, &page_buff, &page_size);
|
||||
html_generate(resp_code, ctx->enforce_rules[0].config_id, msg, &page_buff, &page_size);
|
||||
_wrap_std_field_write(response, TFE_HTTP_CONT_TYPE, "text/html; charset=utf-8");
|
||||
snprintf(cont_len_str, sizeof(cont_len_str), "%lu", page_size);
|
||||
_wrap_std_field_write(response, TFE_HTTP_CONT_LENGTH, cont_len_str);
|
||||
|
||||
Reference in New Issue
Block a user