TSG-10595 Proxy-Deny中Subscriber ID替换修复,TSG-10601 上传文件窗口限制问题修复
This commit is contained in:
@@ -1585,54 +1585,63 @@ static void http_get_subscriber_id(const struct tfe_stream * stream, char *repla
|
||||
TFE_LOG_ERROR(g_pangu_rt->local_logger, "fetch src sub id from cmsg failed, ret: %d addr: %s", ret, stream->str_stream_info);
|
||||
}
|
||||
}
|
||||
snprintf(replace_regex, TFE_SYMBOL_MAX, "%s", source_subscribe_id);
|
||||
if(strlen(source_subscribe_id) > 0)
|
||||
{
|
||||
snprintf(replace_regex, TFE_SYMBOL_MAX, "%s", source_subscribe_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(replace_regex, TFE_SYMBOL_MAX, "%s", " ");
|
||||
}
|
||||
}
|
||||
|
||||
static int http_regex_replace_message(const struct tfe_stream * stream, char *message, int profile_id, char **rewrite_message)
|
||||
static int http_regex_replace(const struct tfe_stream * stream, char *message, int profile_id, char **rewrite_message)
|
||||
{
|
||||
int i=0, n_rule=0;
|
||||
char replace_with[TFE_SYMBOL_MAX]={0};
|
||||
struct replace_rule *rule;
|
||||
|
||||
struct replace_rule rule[3];
|
||||
memset(rule, 0, sizeof(struct replace_rule));
|
||||
|
||||
if(message == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(strstr(message, "tsg_policy_id")==NULL && strstr(message, "tsg_subscriber_id")==NULL && strstr(message, "tsg_client_ip")==NULL)
|
||||
if(strcasestr(message,"{{tsg_policy_id}}") != NULL)
|
||||
{
|
||||
return 0;
|
||||
rule[n_rule].zone = kZoneRequestUri;
|
||||
rule[n_rule].find = tfe_strdup("{{tsg_policy_id}}");
|
||||
snprintf(replace_with, TFE_SYMBOL_MAX, "%d", profile_id);
|
||||
rule[n_rule].replace_with = tfe_strdup(replace_with);
|
||||
n_rule++;
|
||||
}
|
||||
if(strcasestr(message,"tsg_subscriber_id") != NULL)
|
||||
{
|
||||
memset(replace_with, TFE_SYMBOL_MAX, 0);
|
||||
rule[n_rule].zone = kZoneRequestUri;
|
||||
rule[n_rule].find = tfe_strdup("{{tsg_subscriber_id}}");
|
||||
http_get_subscriber_id(stream, replace_with);
|
||||
rule[n_rule].replace_with = tfe_strdup(replace_with);
|
||||
n_rule++;
|
||||
}
|
||||
if(strcasestr(message,"tsg_client_ip") != NULL)
|
||||
{
|
||||
memset(replace_with, TFE_SYMBOL_MAX, 0);
|
||||
rule[n_rule].zone = kZoneRequestUri;
|
||||
rule[n_rule].find = tfe_strdup("{{tsg_client_ip}}");
|
||||
http_get_client_id(stream, replace_with);
|
||||
rule[n_rule].replace_with = tfe_strdup(replace_with);
|
||||
n_rule++;
|
||||
}
|
||||
|
||||
rule = ALLOC(struct replace_rule, 3);
|
||||
n_rule=0;
|
||||
rule[n_rule].zone = kZoneRequestUri;
|
||||
rule[n_rule].find = tfe_strdup("{{tsg_policy_id}}");
|
||||
snprintf(replace_with, TFE_SYMBOL_MAX, "%d", profile_id);
|
||||
rule[n_rule].replace_with = tfe_strdup(replace_with);
|
||||
size_t rewrite_uri_sz = execute_replace_rule(message, strlen(message), kZoneRequestUri, rule, n_rule, rewrite_message, 1);
|
||||
|
||||
n_rule=1;
|
||||
memset(replace_with, TFE_SYMBOL_MAX, 0);
|
||||
rule[n_rule].zone = kZoneRequestUri;
|
||||
rule[n_rule].find = tfe_strdup("{{tsg_subscriber_id}}");
|
||||
http_get_subscriber_id(stream, replace_with);
|
||||
rule[n_rule].replace_with = tfe_strdup(replace_with);
|
||||
|
||||
n_rule=2;
|
||||
memset(replace_with, TFE_SYMBOL_MAX, 0);
|
||||
rule[n_rule].zone = kZoneRequestUri;
|
||||
rule[n_rule].find = tfe_strdup("{{tsg_client_ip}}");
|
||||
http_get_client_id(stream, replace_with);
|
||||
rule[n_rule].replace_with = tfe_strdup(replace_with);
|
||||
|
||||
size_t rewrite_uri_sz = execute_replace_rule(message, strlen(message), kZoneRequestUri, rule, n_rule+1, rewrite_message, 1);
|
||||
|
||||
for(i=0; i<n_rule+1; i++)
|
||||
for(i=0; i<n_rule; i++)
|
||||
{
|
||||
FREE(&(rule[i].find));
|
||||
FREE(&(rule[i].replace_with));
|
||||
}
|
||||
FREE(&rule);
|
||||
|
||||
return rewrite_uri_sz;
|
||||
}
|
||||
@@ -1680,7 +1689,7 @@ static void http_redirect(const struct tfe_stream * stream, const struct tfe_htt
|
||||
|
||||
response = tfe_http_session_response_create(to_write, resp_code);
|
||||
|
||||
rewrite_uri_sz = http_regex_replace_message(stream, rd_url, ctx->enforce_rules[0].config_id, &rewrite_uri);
|
||||
rewrite_uri_sz = http_regex_replace(stream, rd_url, ctx->enforce_rules[0].config_id, &rewrite_uri);
|
||||
if(rewrite_uri_sz>0 && rewrite_uri!= NULL)
|
||||
{
|
||||
tfe_http_std_field_write(response, TFE_HTTP_LOCATION, rewrite_uri);
|
||||
@@ -1732,11 +1741,12 @@ static void http_block(const struct tfe_stream * stream, const struct tfe_http_s
|
||||
ret = html_generate(profile_id, message, &page_buff, &page_size);
|
||||
if (ret != 0)
|
||||
{
|
||||
rewrite_message_sz = http_regex_replace_message(stream, message, ctx->enforce_rules[0].config_id, &rewrite_message);
|
||||
rewrite_message_sz = http_regex_replace(stream, message, ctx->enforce_rules[0].config_id, &rewrite_message);
|
||||
if(rewrite_message_sz>0 && rewrite_message!= NULL)
|
||||
{
|
||||
message = rewrite_message;
|
||||
}
|
||||
|
||||
/*read local configuration**/
|
||||
template_generate(resp_code, message, &page_buff, &page_size);
|
||||
if(rewrite_message_sz>0 && rewrite_message!= NULL)
|
||||
|
||||
Reference in New Issue
Block a user