TSG-1818 insert和hijack增加注入流量控制

This commit is contained in:
fengweihao
2020-06-05 19:27:32 +08:00
parent 611b6645b2
commit ed19fc177e
4 changed files with 19 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
add_library(pangu-http src/pangu_logger.cpp src/pangu_http.cpp src/pattern_replace.cpp src/pangu_web_cache.cpp)
target_link_libraries(pangu-http PUBLIC common http tango-cache-client)
target_link_libraries(pangu-http PUBLIC librdkafka ctemplate-static cjson pcre2-static libdablooms pthread)
target_link_libraries(pangu-http PUBLIC librdkafka ctemplate-static cjson pcre2-static ratelimiter-static libdablooms pthread)
target_link_libraries(pangu-http PUBLIC maatframe)
add_executable(test_pattern_replace src/test_pattern_replace.cpp src/pattern_replace.cpp)

View File

@@ -987,7 +987,7 @@ error_out:
Ratelimiter_handle_t ratelimit_handle_create(const char* profile_path, const char* static_section)
{
int ret=0;
int ret=0, field_stat=0;
int redis_port = 0, interval_sec = 0;
char redis_server[TFE_STRING_MAX] = {0};
char token_name[TFE_STRING_MAX] = {0};
@@ -1000,13 +1000,27 @@ Ratelimiter_handle_t ratelimit_handle_create(const char* profile_path, const cha
MESA_load_profile_string_def(profile_path, static_section, "token_name", token_name, sizeof(token_name), "");
MESA_load_profile_int_def(profile_path, static_section, "interval_sec", &(interval_sec), 1);
if (g_pangu_rt->enable_rate != 1)
{
return NULL;
}
ratelimit=Ratelimiter_create(token_name, g_pangu_rt->local_logger);
Ratelimiter_set_opt(ratelimit, RATELIMITER_OPT_INTERVAL_SEC, &interval_sec, sizeof(interval_sec));
Ratelimiter_set_opt(ratelimit, RATELIMITER_OPT_REDIS_IP, redis_server, strlen(redis_server) + 1);
Ratelimiter_set_opt(ratelimit, RATELIMITER_OPT_REDIS_PORT, &redis_port, sizeof(redis_port));
/*field stata for debug test**/
MESA_load_profile_int_def(profile_path, static_section, "field_stat", &(field_stat), 0);
if (field_stat == 1)
{
MESA_load_profile_int_def(profile_path, static_section, "stat_port", &(redis_port), 6379);
MESA_load_profile_string_def(profile_path, static_section, "stat_server", redis_server, sizeof(redis_server), "");
Ratelimiter_set_opt(ratelimit, RATELIMITER_OPT_FIELD_STAT, &field_stat, sizeof(field_stat));
Ratelimiter_set_opt(ratelimit, RATELIMITER_OPT_STAT_IP, redis_server, strlen(redis_server));
Ratelimiter_set_opt(ratelimit, RATELIMITER_OPT_STAT_PORT, &redis_port, sizeof(redis_port));
Ratelimiter_set_opt(ratelimit, RATELIMITER_OPT_STAT_PATH, token_name, sizeof(token_name));
Ratelimiter_stat_init(ratelimit);
}
ret = Ratelimiter_start(ratelimit);
if (ret < 0)
{

View File

@@ -97,7 +97,7 @@ set_property(TARGET nghttp2-static APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES
### ratelimiter
ExternalProject_Add(ratelimiter PREFIX ratelimiter
URL ${CMAKE_CURRENT_SOURCE_DIR}/ratelimiter-1.1.0-x86_64.tar.gz
URL_MD5 54cc36713c2aaa8ff378ca342778e57d
URL_MD5 4e5d01586fef4165c4dfd1f1a3595e61
CONFIGURE_COMMAND ""
BUILD_COMMAND make
BUILD_IN_SOURCE 1)

Binary file not shown.