From 50d0d7ead1ea6d9d6055767823c97dcb1102bc42 Mon Sep 17 00:00:00 2001 From: zhengchao Date: Tue, 18 Sep 2018 12:01:56 +0800 Subject: [PATCH] =?UTF-8?q?http=E4=B8=9A=E5=8A=A1=E5=B1=82=E4=B8=8E?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E5=B1=82=E9=9B=86=E6=88=90=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/business/pangu-http/pangu_http.cpp | 41 ++++++++++++++++------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/plugin/business/pangu-http/pangu_http.cpp b/plugin/business/pangu-http/pangu_http.cpp index 313d89f..b6e6d64 100644 --- a/plugin/business/pangu-http/pangu_http.cpp +++ b/plugin/business/pangu-http/pangu_http.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -114,7 +115,7 @@ static Maat_feather_t create_maat_feather(const char* profile, const char* secti } return target; } -void pangu_http_init(struct tfe_proxy * proxy) +int pangu_http_init(struct tfe_proxy * proxy) { const char* profile="./pangu/pangu_pxy.conf"; const char* logfile="./log/pangu_pxy.log"; @@ -158,11 +159,11 @@ void pangu_http_init(struct tfe_proxy * proxy) g_pangu_rt->tpl_451 = ctemplate::Template::GetTemplate(page_path,ctemplate::DO_NOT_STRIP); TFE_LOG_INFO(NULL, "Pangu HTTP init success."); - return; + return 0; error_out: TFE_LOG_ERROR(NULL, "Pangu HTTP init failed."); - return; + return -1; } static void _wrap_std_field_write(struct tfe_http_half * half, enum tfe_http_std_field field_id, const char * value) { @@ -344,7 +345,7 @@ static void html_free(char** page_buff) FREE(page_buff); return; } -static int is_http_request(uint64_t events) +static int is_http_request(enum tfe_http_event events) { if((events&EV_HTTP_REQ_HDR)|(events&EV_HTTP_REQ_BODY_BEGIN)|(events&EV_HTTP_REQ_BODY_END)|(events&EV_HTTP_REQ_BODY_CONT)) { @@ -365,7 +366,7 @@ enum replace_zone zone_name_to_id(const char* name) "http_resp_body", "http_resp_body"}; size_t i=0; - for(i=0;i< sizeof(std_name)/sizeof(const char*);i++) + for(i=0; isp),CHARSET_UTF8, body_frag, (int)frag_size + scan_ret=Maat_stream_scan_string(&(ctx->sp),CHARSET_UTF8, (const char*)body_frag, (int)frag_size ,result+hit_cnt, NULL, MAX_SCAN_RESULT-hit_cnt, &(ctx->mid)); if(scan_ret>0) { @@ -853,6 +854,7 @@ void pangu_on_http_begin(const struct tfe_stream * stream, { tfe_http_session_detach(session); } + return; } @@ -871,8 +873,8 @@ void pangu_on_http_end(const struct tfe_stream * stream, return; } -void pangu_on_http_data(const struct tfe_stream * stream, const struct tfe_http_session * session, - uint64_t events, const char* body_frag, size_t frag_size, unsigned int thread_id, void ** pme) +void 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) { struct pangu_http_ctx* ctx=*(struct pangu_http_ctx**)pme; enum pangu_action hit_action=PG_ACTION_NONE; @@ -909,4 +911,17 @@ Re_Enter: return; } +struct tfe_plugin pangu_http_spec={ + .symbol=NULL, + .type = TFE_PLUGIN_TYPE_BUSINESS, + .on_init = pangu_http_init, + .on_deinit = NULL, + .on_open = NULL, + .on_data = NULL, + .on_close = NULL, + .on_session_begin=pangu_on_http_begin, + .on_session_data=pangu_on_http_data, + .on_session_end=pangu_on_http_end + }; +TFE_PLUGIN_REGISTER(pangu_http, pangu_http_spec)