Close #151 解密流量转发使用独立的tableinfo。

This commit is contained in:
luqiuwen
2019-09-20 15:13:47 +08:00
parent ff66f91446
commit a5cfc17de5
4 changed files with 37 additions and 48 deletions

View File

@@ -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

View File

@@ -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,

View File

@@ -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}

View File

@@ -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}