#179 traffic_mirror 插件支持 enable/disable 配置项,但是当配置为 disable 时,traffic_mirror_init_cb() return -1,tfe 直接退出
This commit is contained in:
@@ -480,19 +480,17 @@ int traffic_mirror_init(struct tfe_proxy * proxy)
|
||||
{
|
||||
int result = 0;
|
||||
struct traffic_mirror_instance * instance = g_traffic_mirror_instance;
|
||||
instance->logger = tfe_proxy_get_error_logger();
|
||||
|
||||
/* Using PANGU-HTTP's profile */
|
||||
unsigned int is_enable = 1;
|
||||
MESA_load_profile_uint_def("./conf/tfe/tfe.conf", "traffic_mirror", "enable", &is_enable, 1);
|
||||
|
||||
if (!is_enable)
|
||||
MESA_load_profile_uint_def("./conf/tfe/tfe.conf", "traffic_mirror", "enable", &(instance->enable), 1);
|
||||
if (!instance->enable)
|
||||
{
|
||||
TFE_LOG_INFO(instance->logger, "traffic_mirror is disabled.");
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* INIT DECRYPT MIRROR INSTANCE */
|
||||
instance->logger = tfe_proxy_get_error_logger();
|
||||
instance->nr_threads = tfe_proxy_get_work_thread_count();
|
||||
|
||||
/* MAAT Feather, the configuration is same with pangu-http */
|
||||
@@ -559,6 +557,10 @@ int traffic_mirror_on_open_cb(const struct tfe_stream * stream, unsigned int thr
|
||||
/* Firstly, fetch destination address of traffic mirror */
|
||||
struct traffic_mirror_me * me = NULL;
|
||||
struct traffic_mirror_instance * instance = g_traffic_mirror_instance;
|
||||
if (!instance->enable)
|
||||
{
|
||||
return ACTION_FORWARD_DATA;
|
||||
}
|
||||
struct tfe_cmsg * cmsg = tfe_stream_get0_cmsg(stream);
|
||||
|
||||
unsigned int target_id;
|
||||
@@ -677,6 +679,11 @@ detach:
|
||||
enum tfe_stream_action traffic_mirror_on_data_cb(const struct tfe_stream * stream, unsigned int thread_id,
|
||||
enum tfe_conn_dir dir, const unsigned char * data, size_t len, void ** pme)
|
||||
{
|
||||
struct traffic_mirror_instance * instance = g_traffic_mirror_instance;
|
||||
if (!instance->enable)
|
||||
{
|
||||
return ACTION_FORWARD_DATA;
|
||||
}
|
||||
struct traffic_mirror_me * me = (struct traffic_mirror_me *)(*pme);
|
||||
|
||||
/* Rx offset of this callback */
|
||||
@@ -737,6 +744,12 @@ errout:
|
||||
void traffic_mirror_on_close_cb(const struct tfe_stream * stream, unsigned int thread_id,
|
||||
enum tfe_stream_close_reason reason, void ** pme)
|
||||
{
|
||||
struct traffic_mirror_instance * instance = g_traffic_mirror_instance;
|
||||
if (!instance->enable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
struct traffic_mirror_me * me = (struct traffic_mirror_me *)(*pme);
|
||||
traffic_mirror_rebuild_farewell(me->rebuild_ctx, thread_id);
|
||||
traffic_mirror_rebuild_destroy(me->rebuild_ctx);
|
||||
|
||||
Reference in New Issue
Block a user