From a5cfc17de56e27a54e33f61ee80ab2bfbde8916f Mon Sep 17 00:00:00 2001 From: luqiuwen Date: Fri, 20 Sep 2019 15:13:47 +0800 Subject: [PATCH] =?UTF-8?q?Close=20#151=20=E8=A7=A3=E5=AF=86=E6=B5=81?= =?UTF-8?q?=E9=87=8F=E8=BD=AC=E5=8F=91=E4=BD=BF=E7=94=A8=E7=8B=AC=E7=AB=8B?= =?UTF-8?q?=E7=9A=84tableinfo=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/pangu/pangu_pxy.conf | 4 ++ plugin/business/traffic-mirror/src/entry.cpp | 24 +++++++----- resource/pangu/table_info.conf_yiqi | 38 ------------------- resource/pangu/table_info_traffic_mirror.conf | 19 ++++++++++ 4 files changed, 37 insertions(+), 48 deletions(-) delete mode 100644 resource/pangu/table_info.conf_yiqi create mode 100644 resource/pangu/table_info_traffic_mirror.conf diff --git a/conf/pangu/pangu_pxy.conf b/conf/pangu/pangu_pxy.conf index 9ec6482..ddb592d 100644 --- a/conf/pangu/pangu_pxy.conf +++ b/conf/pangu/pangu_pxy.conf @@ -105,3 +105,7 @@ query_undefined_obj=0 statsd_server=10.4.20.201 statsd_port=8125 histogram_bins=0.20,0.40,0.6,0.8 + +[traffic_mirror] +table_info=resource/pangu/table_info_traffic_mirror.conf +stat_file=log/traffic_mirror.status diff --git a/plugin/business/traffic-mirror/src/entry.cpp b/plugin/business/traffic-mirror/src/entry.cpp index 3acb11f..f55f2bb 100644 --- a/plugin/business/traffic-mirror/src/entry.cpp +++ b/plugin/business/traffic-mirror/src/entry.cpp @@ -315,8 +315,9 @@ out: #define MAAT_INPUT_REDIS 1 #define MAAT_INPUT_FILE 2 -static Maat_feather_t maat_feather_create(const char * instance_name, - const char * profile, const char * section, unsigned int max_thread, void * logger) +static Maat_feather_t maat_feather_create_with_override(const char * instance_name, + const char * profile, const char * section, const char * override_section, + unsigned int max_thread, void * logger) { Maat_feather_t target; int input_mode = 0, maat_stat_on = 0, maat_perf_on = 0; @@ -365,6 +366,10 @@ static Maat_feather_t maat_feather_create(const char * instance_name, MESA_load_profile_string_def(profile, section, "stat_file", maat_stat_file, sizeof(maat_stat_file), ""); MESA_load_profile_int_def(profile, section, "effect_interval_s", &(effect_interval), 60); + /* Only override the table info */ + MESA_load_profile_string_def(profile, override_section, "table_info", table_info, sizeof(table_info), table_info); + MESA_load_profile_string_def(profile, override_section, "stat_file", maat_stat_file, sizeof(maat_stat_file), maat_stat_file); + effect_interval *= 1000;//convert s to ms assert(strlen(inc_cfg_dir) != 0 || strlen(ful_cfg_dir) != 0 || strlen(redis_server) != 0 || strlen(json_cfg_file) != 0); @@ -388,7 +393,6 @@ static Maat_feather_t maat_feather_create(const char * instance_name, break; } - Maat_set_feather_opt(target, MAAT_OPT_FOREIGN_CONT_DIR, "./pangu_files", strlen("./pangu_files") + 1); if (maat_stat_on) { Maat_set_feather_opt(target, MAAT_OPT_STAT_FILE_PATH, maat_stat_file, strlen(maat_stat_file) + 1); @@ -467,11 +471,8 @@ int traffic_mirror_init(struct tfe_proxy * proxy) struct traffic_mirror_instance * instance = g_traffic_mirror_instance; /* Using PANGU-HTTP's profile */ - const char * profile = "./conf/pangu/pangu_pxy.conf"; - const char * section = "maat"; - unsigned int is_enable = 1; - MESA_load_profile_uint_def(profile, "traffic_mirror", "enable", &is_enable, 1); + MESA_load_profile_uint_def("./conf/tfe/tfe.conf", "traffic_mirror", "enable", &is_enable, 1); if (!is_enable) { @@ -484,8 +485,9 @@ int traffic_mirror_init(struct tfe_proxy * proxy) instance->nr_threads = tfe_proxy_get_work_thread_count(); /* MAAT Feather, the configuration is same with pangu-http */ - instance->maat_feather = maat_feather_create("traffic-mirror", profile, section, - instance->nr_threads, instance->logger); + instance->maat_feather = maat_feather_create_with_override( + "traffic-mirror", "./conf/pangu/pangu_pxy.conf", + "maat", "traffic_mirror", instance->nr_threads, instance->logger); if (unlikely(!instance->maat_feather)) { @@ -534,8 +536,10 @@ int traffic_mirror_init(struct tfe_proxy * proxy) goto errout; } -errout: return 0; + +errout: + return -1; } int traffic_mirror_on_open_cb(const struct tfe_stream * stream, unsigned int thread_id, diff --git a/resource/pangu/table_info.conf_yiqi b/resource/pangu/table_info.conf_yiqi deleted file mode 100644 index 34c3301..0000000 --- a/resource/pangu/table_info.conf_yiqi +++ /dev/null @@ -1,38 +0,0 @@ -#each collumn seperate with '\t' -#id (0~65535) -#name string -#type one of ip,expr,expr_plus,digest,intval,compile or plugin -#src_charset one of GBK,BIG5,UNICODE,UTF8 -#dst_charset combined by GBK,BIG5,UNICODE,UTF8,seperate with '/' -#do_merege [yes/no] -#cross cache [number] -#quick mode [quickon/quickoff], default [quickoff] -#For ip/intval/digest/compile/group -#id name type -# -#For plugin table -#id name type json_descr -# -#For expr/expr_plus Table -#id name type src_charset dst_charset do_merge cross_cache quick_mode -0 PXY_CTRL_COMPILE compile escape -- -1 PXY_CTRL_GROUP group -- -2 PXY_CTRL_IP ip --- -3 PXY_CTRL_HTTP_URL expr UTF8 GBK/UNICODE/UTF8/url_encode_gb2312/url_encode_utf8 yes 0 quickoff -4 PXY_CTRL_HTTP_REQ_HDR expr_plus UTF8 UTF8 yes 0 quickoff -5 PXY_CTRL_HTTP_REQ_BODY expr UTF8 GBK/UNICODE/UTF8 yes 128 quickoff -6 PXY_CTRL_HTTP_RES_HDR expr_plus UTF8 UTF8 UTF8 yes 0 quickoff -7 PXY_CTRL_HTTP_RES_BODY expr UTF8 GBK/UNICODE/UTF8 yes 128 quickoff -7 TSG_OBJ_CONTENT expr UTF8 GBK/UNICODE/UTF8 yes 128 quickoff -8 PXY_CTRL_SUBSCRIBE_ID expr UTF8 UTF8 yes 0 quickon -9 PXY_CACHE_COMPILE compile escape -- -10 PXY_CACHE_GROUP group -- -11 PXY_CACHE_HTTP_URL expr UTF8 UTF8 yes 0 quickoff -12 PXY_CACHE_HTTP_COOKIE expr UTF8 UTF8 yes 0 quickoff -13 PXY_PROFILE_TRUSTED_CA_CERT plugin {"key":1,"valid":4,"foreign":"3"} -14 PXY_OBJ_TRUSTED_CA_CRL plugin {"valid":4,"foreign":"3"} -15 PXY_PROFILE_RESPONSE_PAGES plugin {"key":1,"foreign":"4","valid":5} -16 PXY_PROFILE_HIJACK_FILES plugin {"key":1,"foreign":"5","valid":6} -17 PXY_PROFILE_INSERT_SCRIPTS plugin {"key":1,"foreign":"4","valid":5} -18 PXY_INTERCEPT_COMPILE plugin {"key":1,"valid":8} -19 PXY_PROFILE_TRAFFIC_MIRROR plugin {"key":1,"valid":4} diff --git a/resource/pangu/table_info_traffic_mirror.conf b/resource/pangu/table_info_traffic_mirror.conf new file mode 100644 index 0000000..c1a2529 --- /dev/null +++ b/resource/pangu/table_info_traffic_mirror.conf @@ -0,0 +1,19 @@ +#each collumn seperate with '\t' +#id (0~65535) +#name string +#type one of ip,expr,expr_plus,digest,intval,compile or plugin +#src_charset one of GBK,BIG5,UNICODE,UTF8 +#dst_charset combined by GBK,BIG5,UNICODE,UTF8,seperate with '/' +#do_merege [yes/no] +#cross cache [number] +#quick mode [quickon/quickoff], default [quickoff] +#For ip/intval/digest/compile/group +#id name type +# +#For plugin table +#id name type json_descr +# +#For expr/expr_plus Table +#id name type src_charset dst_charset do_merge cross_cache quick_mode +0 PXY_INTERCEPT_COMPILE plugin {"key":1,"valid":8} +1 PXY_PROFILE_TRAFFIC_MIRROR plugin {"key":1,"valid":4}