diff options
| author | fengweihao <[email protected]> | 2021-07-23 15:55:42 +0800 |
|---|---|---|
| committer | fengweihao <[email protected]> | 2021-07-23 15:55:42 +0800 |
| commit | 9745251b2aff9fac176e0443acd95a9bf33d592c (patch) | |
| tree | f4ee06c4a9d364099761af7a0aea90bbd94bb3ad /plugin | |
| parent | d18b647ec5203e8f7497a6b96523be7f832d6f8b (diff) | |
TSG-7141 修复非格式日志部分下载失败问题v4.5.4-202107
修复重定向指定用户自定义域无法替换问题
Diffstat (limited to 'plugin')
| -rw-r--r-- | plugin/business/pangu-http/src/pangu_http.cpp | 14 | ||||
| -rw-r--r-- | plugin/business/pangu-http/src/pangu_logger.cpp | 3 | ||||
| -rw-r--r-- | plugin/business/pangu-http/src/test_pattern_replace.cpp | 14 |
3 files changed, 17 insertions, 14 deletions
diff --git a/plugin/business/pangu-http/src/pangu_http.cpp b/plugin/business/pangu-http/src/pangu_http.cpp index 86a07ba..f55c170 100644 --- a/plugin/business/pangu-http/src/pangu_http.cpp +++ b/plugin/business/pangu-http/src/pangu_http.cpp @@ -1532,7 +1532,7 @@ static void http_get_client_id(const struct tfe_stream * stream, char *replace_r tfe_stream_addr_str_split((char *)stream->str_stream_info, &sip, &sport, &dip, &dport); - snprintf(replace_regex, TFE_SYMBOL_MAX, "%s=%s", "source_ip", sip); + snprintf(replace_regex, TFE_SYMBOL_MAX, "%s", sip); } static void http_get_subscriber_id(const struct tfe_stream * stream, char *replace_regex) @@ -1549,7 +1549,7 @@ 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=%s", "user_id", source_subscribe_id); + snprintf(replace_regex, TFE_SYMBOL_MAX, "%s", source_subscribe_id); } static int http_decoder_url(const struct tfe_stream * stream, char *rd_url, int profile_id, char **rewrite_uri) @@ -1558,7 +1558,7 @@ static int http_decoder_url(const struct tfe_stream * stream, char *rd_url, int char replace_with[TFE_SYMBOL_MAX]={0}; struct replace_rule *rule; - if(strstr(rd_url, "policy_id")==NULL && strstr(rd_url, "user_id")==NULL && strstr(rd_url, "source_ip")==NULL) + if(strstr(rd_url, "tsg_policy_id")==NULL && strstr(rd_url, "tsg_subscriber_id")==NULL && strstr(rd_url, "tsg_client_ip")==NULL) { return 0; } @@ -1566,21 +1566,21 @@ static int http_decoder_url(const struct tfe_stream * stream, char *rd_url, int rule = ALLOC(struct replace_rule, 3); n_rule=0; rule[n_rule].zone = kZoneRequestUri; - rule[n_rule].find = tfe_strdup("policy_id={{tsg_policy_id}}"); - snprintf(replace_with, TFE_SYMBOL_MAX, "policy_id=%d", profile_id); + 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=1; memset(replace_with, TFE_SYMBOL_MAX, 0); rule[n_rule].zone = kZoneRequestUri; - rule[n_rule].find = tfe_strdup("user_id={{tsg_subscriber_id}}"); + 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("source_ip={{tsg_client_ip}}"); + 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); diff --git a/plugin/business/pangu-http/src/pangu_logger.cpp b/plugin/business/pangu-http/src/pangu_logger.cpp index 46185d0..e02493a 100644 --- a/plugin/business/pangu-http/src/pangu_logger.cpp +++ b/plugin/business/pangu-http/src/pangu_logger.cpp @@ -284,6 +284,9 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg) } if(log_msg->resp_body!=NULL) { + memset(log_file_upload_path, 0, sizeof(log_file_upload_path)); + memset(cont_type_whole, 0, sizeof(cont_type_whole)); + memset(&meta, 0, sizeof(meta)); asprintf(&log_file_key, "%s.respbody", http->req->req_spec.url); meta.url=log_file_key; diff --git a/plugin/business/pangu-http/src/test_pattern_replace.cpp b/plugin/business/pangu-http/src/test_pattern_replace.cpp index c993b06..6885661 100644 --- a/plugin/business/pangu-http/src/test_pattern_replace.cpp +++ b/plugin/business/pangu-http/src/test_pattern_replace.cpp @@ -186,7 +186,7 @@ TEST(PatternReplace, UrlReplace) const char *rd_url = "http://www.example.com/query?pageid=12345&policy_id={{tsg_policy_id}}&user_id={{tsg_subscriber_id}}&source_ip={{tsg_client_ip}}"; - if(strstr(rd_url, "policy_id")==NULL && strstr(rd_url, "user_id")==NULL && strstr(rd_url, "source_ip")==NULL) + if(strstr(rd_url, "tsg_policy_id")==NULL && strstr(rd_url, "tsg_subscriber_id")==NULL && strstr(rd_url, "tsg_client_ip")==NULL) { return; } @@ -194,21 +194,21 @@ TEST(PatternReplace, UrlReplace) rule = ALLOC(struct replace_rule, 3); n_rule=0; rule[n_rule].zone = kZoneRequestUri; - rule[n_rule].find = tfe_strdup("policy_id={{tsg_policy_id}}"); - snprintf(replace_with, TFE_SYMBOL_MAX, "policy_id=%d", 23); + rule[n_rule].find = tfe_strdup("{{tsg_policy_id}}"); + snprintf(replace_with, TFE_SYMBOL_MAX, "%d", 23); rule[n_rule].replace_with = tfe_strdup(replace_with); n_rule=1; memset(replace_with, TFE_SYMBOL_MAX, 0); rule[n_rule].zone = kZoneRequestUri; - rule[n_rule].find = tfe_strdup("user_id={{tsg_subscriber_id}}"); - rule[n_rule].replace_with = tfe_strdup("user_id=te&st01"); + rule[n_rule].find = tfe_strdup("{{tsg_subscriber_id}}"); + rule[n_rule].replace_with = tfe_strdup("te&st01"); n_rule=2; memset(replace_with, TFE_SYMBOL_MAX, 0); rule[n_rule].zone = kZoneRequestUri; - rule[n_rule].find = tfe_strdup("source_ip={{tsg_client_ip}}"); - rule[n_rule].replace_with = tfe_strdup("source_ip=192.168.50.71"); + rule[n_rule].find = tfe_strdup("{{tsg_client_ip}}"); + rule[n_rule].replace_with = tfe_strdup("192.168.50.71"); size_t rewrite_uri_sz = execute_replace_rule(rd_url, strlen(rd_url), kZoneRequestUri, rule, n_rule+1, &rewrite_uri, 1); |
