From 7e2f36d41639b6367b36b15a8b816a0e085ff80d Mon Sep 17 00:00:00 2001 From: luwenpeng Date: Tue, 28 Jul 2020 18:54:00 +0800 Subject: [PATCH] =?UTF-8?q?TFE=20pangu=20=E5=A2=9E=E5=8A=A0=20enable=5Fplu?= =?UTF-8?q?gin=20=E9=85=8D=E7=BD=AE,=E5=8F=AF=E4=BB=A5=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=90=AF=E7=94=A8=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/pangu/pangu_pxy.conf | 1 + plugin/business/pangu-http/src/pangu_http.cpp | 22 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/conf/pangu/pangu_pxy.conf b/conf/pangu/pangu_pxy.conf index 73d2eec..94663df 100644 --- a/conf/pangu/pangu_pxy.conf +++ b/conf/pangu/pangu_pxy.conf @@ -1,5 +1,6 @@ [debug] log_level=10 +enable_plugin=1 [log] entrance_id=0 diff --git a/plugin/business/pangu-http/src/pangu_http.cpp b/plugin/business/pangu-http/src/pangu_http.cpp index c196d5f..bb65058 100644 --- a/plugin/business/pangu-http/src/pangu_http.cpp +++ b/plugin/business/pangu-http/src/pangu_http.cpp @@ -154,7 +154,7 @@ struct pangu_rt int ctrl_compile_idx; int ca_store_reseting; - + int enable_plugin; }; struct pangu_rt * g_pangu_rt; @@ -919,6 +919,11 @@ int pangu_http_init(struct tfe_proxy * proxy) int temp=0; g_pangu_rt = ALLOC(struct pangu_rt, 1); + MESA_load_profile_int_def(profile_path, "DEBUG", "enable_plugin", &(g_pangu_rt->enable_plugin), 1); + if (!g_pangu_rt->enable_plugin) + { + return 0; + } g_pangu_rt->thread_num = tfe_proxy_get_work_thread_count(); g_pangu_rt->gc_evbase=tfe_proxy_get_gc_evbase(); @@ -2548,6 +2553,11 @@ int http_ip_asn_scan(struct Maat_rule_t *result, struct ip_address* sip, struct void pangu_on_http_begin(const struct tfe_stream * stream, const struct tfe_http_session * session, unsigned int thread_id, void ** pme) { + if (!g_pangu_rt->enable_plugin) + { + return; + } + struct pangu_http_ctx * ctx = *(struct pangu_http_ctx **) pme; struct Maat_rule_t result[MAX_SCAN_RESULT]; struct ipaddr sapp_addr; @@ -2662,6 +2672,11 @@ static inline int ctx_actually_manipulate(struct pangu_http_ctx * ctx) void pangu_on_http_end(const struct tfe_stream * stream, const struct tfe_http_session * session, unsigned int thread_id, void ** pme) { + if (!g_pangu_rt->enable_plugin) + { + return; + } + struct pangu_http_ctx * ctx = *(struct pangu_http_ctx **) pme; size_t i=0, j=0; int ret=0; @@ -2723,6 +2738,11 @@ void pangu_on_http_end(const struct tfe_stream * stream, int pangu_on_http_data(const struct tfe_stream * stream, const struct tfe_http_session * session, enum tfe_http_event events, const unsigned char * body_frag, size_t frag_size, unsigned int thread_id, void ** pme) { + if (!g_pangu_rt->enable_plugin) + { + return CALL_NEXT_PLUGIN; + } + struct pangu_http_ctx * ctx = *(struct pangu_http_ctx **) pme; int ret=0; if(ctx->resumed_cb)