diff options
| author | yangwei <[email protected]> | 2024-05-28 02:07:20 +0800 |
|---|---|---|
| committer | yangwei <[email protected]> | 2024-05-28 04:40:31 +0800 |
| commit | ba8450caed9876a463fbfefc7a521cc62bce432e (patch) | |
| tree | 552986583d706751572d39b180422811d5bb3e03 | |
| parent | 0737ab92295eca2690e875db240f1b0af495d7dc (diff) | |
🧪 test(remove http decoder): rm related source code
82 files changed, 133 insertions, 5797 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 20cc211..52f279c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,9 +80,6 @@ add_subdirectory(deps/bitmap) add_subdirectory(src/plugin_manager) add_subdirectory(src/stellar_on_sapp) -#add_subdirectory(src/http_decoder) - -#add_subdirectory(examples/sapp_plugin) add_subdirectory(examples/stellar_plugin) enable_testing() diff --git a/src/http_decoder/CMakeLists.txt b/src/http_decoder/CMakeLists.txt deleted file mode 100644 index a17fcd8..0000000 --- a/src/http_decoder/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -add_definitions(-fPIC) - -include_directories(/opt/MESA/include/) - -set(HTTP_SRC http_decoder.c http_decoder_utils.c http_decoder_half.c - http_decoder_table.c http_decoder_string.c http_content_decompress.c - http_decoder_result_queue.c) - -add_library(http_decoder SHARED ${HTTP_SRC}) -#set_target_properties(http_decoder_shared PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_LIST_DIR}/version.map") -target_link_libraries(http_decoder z brotlidec llhttp-static fieldstat4) -set_target_properties(http_decoder PROPERTIES PREFIX "")
\ No newline at end of file diff --git a/src/http_decoder/http_content_decompress.c b/src/http_decoder/http_content_decompress.c deleted file mode 100644 index b887487..0000000 --- a/src/http_decoder/http_content_decompress.c +++ /dev/null @@ -1,268 +0,0 @@ -/* -********************************************************************************************** -* File: http_content_decompress.c -* Description: -* Authors: LuWenPeng <[email protected]> -* Date: 2022-10-31 -* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved. -*********************************************************************************************** -*/ - - -#include <zlib.h> -#include <string.h> -#include <assert.h> -#include <brotli/decode.h> - -#include "stellar/utils.h" -#include "http_decoder_utils.h" -#include "http_content_decompress.h" - -#define BUFFER_SIZE (1024 * 1024 * 4) - -struct http_content_decompress { - enum http_content_encoding encoding; - - z_stream *z_stream_ptr; - BrotliDecoderState *br_state; - - char *buffer; - size_t buffer_size; -}; - -enum http_content_encoding -http_content_encoding_str2int(const char *content_encoding) -{ - if (strcasestr(content_encoding, "gzip") != NULL) { - return HTTP_CONTENT_ENCODING_GZIP; - } - - if (strcasestr(content_encoding, "deflate") != NULL) { - return HTTP_CONTENT_ENCODING_DEFLATE; - } - - if (strcasestr(content_encoding, "br") != NULL) { - return HTTP_CONTENT_ENCODING_BR; - } - - return HTTP_CONTENT_ENCODING_NONE; -} - -const char * -http_content_encoding_int2str(enum http_content_encoding content_encoding) -{ - if (content_encoding == HTTP_CONTENT_ENCODING_GZIP) { - return "gzip"; - } - - if (content_encoding == HTTP_CONTENT_ENCODING_DEFLATE) { - return "deflate"; - } - - if (content_encoding == HTTP_CONTENT_ENCODING_BR) { - return "br"; - } - - return "unknown"; -} - -struct http_content_decompress * -http_content_decompress_create(enum http_content_encoding encoding) -{ - struct http_content_decompress *decompress = - CALLOC(struct http_content_decompress, 1); - assert(decompress); - - decompress->encoding = encoding; - decompress->z_stream_ptr = NULL; - decompress->br_state = NULL; - - decompress->buffer = CALLOC(char, BUFFER_SIZE); - assert(decompress->buffer); - decompress->buffer_size = BUFFER_SIZE; - - if (encoding == HTTP_CONTENT_ENCODING_GZIP - || encoding == HTTP_CONTENT_ENCODING_DEFLATE) { - decompress->z_stream_ptr = CALLOC(z_stream, 1); - assert(decompress->z_stream_ptr); - - decompress->z_stream_ptr->zalloc = NULL; - decompress->z_stream_ptr->zfree = NULL; - decompress->z_stream_ptr->opaque = NULL; - decompress->z_stream_ptr->avail_in = 0; - decompress->z_stream_ptr->next_in = Z_NULL; - - if (encoding == HTTP_CONTENT_ENCODING_GZIP) { - if (inflateInit2(decompress->z_stream_ptr, MAX_WBITS + 16) - != Z_OK) { - goto error; - } - } - - if (encoding == HTTP_CONTENT_ENCODING_DEFLATE) { - if (inflateInit2(decompress->z_stream_ptr, -MAX_WBITS) != Z_OK) { - goto error; - } - } - } - - if (encoding == HTTP_CONTENT_ENCODING_BR) { - decompress->br_state = BrotliDecoderCreateInstance(NULL, NULL, NULL); - if (decompress->br_state == NULL) { - goto error; - } - } - - return decompress; - -error: - http_content_decompress_destroy(decompress); - return NULL; -} - -void http_content_decompress_destroy(struct http_content_decompress *decompress) -{ - if (NULL == decompress) { - return; - } - - if (decompress->z_stream_ptr != NULL) { - inflateEnd(decompress->z_stream_ptr); - FREE(decompress->z_stream_ptr); - } - - if (decompress->br_state) { - BrotliDecoderDestroyInstance(decompress->br_state); - decompress->br_state = NULL; - } - - FREE(decompress->buffer); - FREE(decompress); -} - -static int -http_content_decompress_write_zlib(struct http_content_decompress *decompress, - const char *indata, size_t indata_len, - char **outdata, size_t *outdata_len) -{ - z_stream *z_stream_ptr = decompress->z_stream_ptr; - z_stream_ptr->avail_in = (unsigned int)indata_len; - z_stream_ptr->next_in = (unsigned char *)indata; - z_stream_ptr->avail_out = (unsigned int)decompress->buffer_size; - z_stream_ptr->next_out = (unsigned char *)decompress->buffer; - - *outdata = NULL; - *outdata_len = 0; - - int ret = 0; - do { - ret = inflate(z_stream_ptr, Z_NO_FLUSH); - if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT - || ret == Z_DATA_ERROR || ret == Z_MEM_ERROR) { - (void)inflateEnd(z_stream_ptr); - return -1; - } - - size_t have = decompress->buffer_size - z_stream_ptr->avail_out; - if (have > 0) { - if (0 == z_stream_ptr->avail_out) { - decompress->buffer_size += have; - decompress->buffer = REALLOC(char, decompress->buffer, - decompress->buffer_size); - *outdata = decompress->buffer; - *outdata_len = *outdata_len + have; - http_decoder_log(DEBUG, "%s realloc outbuffer %zu bytes", - http_content_encoding_int2str(decompress->encoding), - decompress->buffer_size); - z_stream_ptr->avail_out = have; - z_stream_ptr->next_out = (unsigned char *)decompress->buffer + - (decompress->buffer_size - have); - } else { - *outdata = decompress->buffer; - *outdata_len = have; - } - } - } while (z_stream_ptr->avail_in != 0); - - return 0; -} - -static int -http_content_decompress_write_br(struct http_content_decompress *decompress, - const char *indata, size_t indata_len, - char **outdata, size_t *outdata_len) -{ - size_t available_in = indata_len; - const unsigned char *next_in = (const unsigned char *)indata; - size_t available_out = decompress->buffer_size; - unsigned char *next_out = (unsigned char *)decompress->buffer; - - *outdata = NULL; - *outdata_len = 0; - - int ret; - for (;;) { - ret = BrotliDecoderDecompressStream(decompress->br_state, &available_in, - &next_in, &available_out, &next_out, 0); - size_t have = decompress->buffer_size - available_out; - if (have > 0) { - if (0 == available_out) { - decompress->buffer_size += have; - decompress->buffer = REALLOC(char, decompress->buffer, - decompress->buffer_size); - *outdata = decompress->buffer; - *outdata_len = *outdata_len + have; - available_out = have; - next_out = (unsigned char *)decompress->buffer + - (decompress->buffer_size - have); - } else { - *outdata = decompress->buffer; - *outdata_len = have; - } - } - - if (ret == BROTLI_DECODER_RESULT_SUCCESS - || ret == BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT) { - return 0; - } - - if (ret == BROTLI_DECODER_RESULT_ERROR) { - BrotliDecoderErrorCode errcode = - BrotliDecoderGetErrorCode(decompress->br_state); - http_decoder_log(ERROR, - "BrotliDecoderDecompressStream() failed: errno = %d, %s", - errcode, BrotliDecoderErrorString(errcode)); - return -1; - } - - assert(ret == BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT); - } -} - -int http_content_decompress_write(struct http_content_decompress *decompress, - const char *indata, size_t indata_len, - char **outdata, size_t *outdata_len) -{ - assert(decompress); - assert(indata); - assert(indata_len > 0); - assert(outdata); - assert(outdata_len); - - *outdata = NULL; - *outdata_len = 0; - - if (decompress->encoding == HTTP_CONTENT_ENCODING_GZIP || - decompress->encoding == HTTP_CONTENT_ENCODING_DEFLATE) { - return http_content_decompress_write_zlib(decompress, indata, indata_len, - outdata, outdata_len); - } - - if (decompress->encoding == HTTP_CONTENT_ENCODING_BR) { - return http_content_decompress_write_br(decompress, indata, indata_len, - outdata, outdata_len); - } - - assert(0); - return -1; -}
\ No newline at end of file diff --git a/src/http_decoder/http_content_decompress.h b/src/http_decoder/http_content_decompress.h deleted file mode 100644 index 3c2ba48..0000000 --- a/src/http_decoder/http_content_decompress.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -********************************************************************************************** -* File: http_content_decompress.h -* Description: -* Authors: LuWenPeng <[email protected]> -* Date: 2022-10-31 -* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved. -*********************************************************************************************** -*/ - - -#ifndef _HTTP_CONTENT_DECOMPRESS_H_ -#define _HTTP_CONTENT_DECOMPRESS_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include <stddef.h> - -enum http_content_encoding { - HTTP_CONTENT_ENCODING_NONE = 0, - HTTP_CONTENT_ENCODING_GZIP = 1 << 1, - HTTP_CONTENT_ENCODING_DEFLATE = 1 << 2, - HTTP_CONTENT_ENCODING_BR = 1 << 3, -}; - -struct http_content_decompress; - -enum http_content_encoding -http_content_encoding_str2int(const char *content_encoding); - -const char * -http_content_encoding_int2str(enum http_content_encoding content_encoding); - -struct http_content_decompress * -http_content_decompress_create(enum http_content_encoding encoding); - -void http_content_decompress_destroy(struct http_content_decompress *decompress); - -// return 0 : success -// return -1 : error -int http_content_decompress_write(struct http_content_decompress *decompress, - const char *indata, size_t indata_len, - char **outdata, size_t *outdata_len); - -#ifdef __cplusplus -} -#endif - -#endif
\ No newline at end of file diff --git a/src/http_decoder/http_decoder.c b/src/http_decoder/http_decoder.c deleted file mode 100644 index 523253b..0000000 --- a/src/http_decoder/http_decoder.c +++ /dev/null @@ -1,592 +0,0 @@ -/* -********************************************************************************************** -* File: http_decoder.c -* Description: -* Authors: Liu WenTan <[email protected]> -* Date: 2024-01-10 -* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved. -*********************************************************************************************** -*/ - -#include <assert.h> -#include <stdio.h> -#include <unistd.h> - -#include "stellar/utils.h" -#include "stellar/session.h" -#include "stellar/session_mq.h" -#include "stellar/session_exdata.h" -#include "http_decoder.h" -#include "http_decoder_half.h" -#include "http_decoder_table.h" -#include "http_decoder_result_queue.h" -#include "llhttp.h" -#include "fieldstat/fieldstat_easy.h" - -#define HTTP_IDENTIFY_LEN 16 -#define HD_RESULT_QUEUE_SIZE 16 -#define HD_IS_CACHE_BODY 1 - -const char *http_decoder_topic = "HTTP_DECODER_MESSAGE"; -const char *fs_file_name = "http_decoder.fs"; - -/** - * NOTE: http_message don't have the ownership of data -*/ -struct http_message { - enum http_message_type type; - struct http_decoder_half_data *data; -}; - -struct http_decoder { - struct http_decoder_half *c2s_half; - struct http_decoder_half *s2c_half; -}; - -struct http_decoder_exdata { - struct http_decoder_result_queue *queue; - struct http_decoder *decoder; -}; - -struct http_decoder_context { - int plugin_id; - int topic_id; - int ex_data_idx; - int fs_incoming_bytes_id; - int fs_incoming_pkts_id; - int fs_incoming_trans_id; - struct fieldstat_easy *fse; - struct stellar *st; -}; - -static void http_event_handler(enum http_event event, - struct http_decoder_half_data **data, - struct http_event_context *ev_ctx) -{ - assert(ev_ctx); - - struct http_decoder_result_queue *queue = ev_ctx->ref_queue; - struct http_message *msg = NULL; - struct http_decoder_half_data *half_data = NULL; - int ret = 0; - - switch (event) { - case HTTP_EVENT_REQ_INIT: - half_data = http_decoder_result_queue_peek_req(queue); - if (half_data != NULL) { - http_decoder_result_queue_inc_req_index(queue); - } - - half_data = http_decoder_result_queue_peek_req(queue); - if (half_data != NULL) { - half_data = http_decoder_result_queue_pop_req(queue); - http_decoder_half_data_free(half_data); - half_data = NULL; - } - - half_data = http_decoder_half_data_new(); - ret = http_decoder_result_queue_push_req(queue, half_data); - if (ret < 0) { - fprintf(stderr, "http_decoder_result_queue_push req failed."); - http_decoder_half_data_free(half_data); - half_data = NULL; - } - *data = half_data; - break; - case HTTP_EVENT_REQ_LINE: - msg = CALLOC(struct http_message, 1); - msg->type = HTTP_MESSAGE_REQ_LINE; - msg->data = *data; - session_mq_publish_message(ev_ctx->ref_session, ev_ctx->topic_id, msg); - break; - case HTTP_EVENT_REQ_HDR_END: - msg = CALLOC(struct http_message, 1); - msg->type = HTTP_MESSAGE_REQ_HEADER; - msg->data = *data; - session_mq_publish_message(ev_ctx->ref_session, ev_ctx->topic_id, msg); - break; - case HTTP_EVENT_REQ_BODY_BEGIN: - break; - case HTTP_EVENT_REQ_BODY_DATA: - msg = CALLOC(struct http_message, 1); - msg->type = HTTP_MESSAGE_REQ_BODY; - msg->data = *data; - session_mq_publish_message(ev_ctx->ref_session, ev_ctx->topic_id, msg); - break; - case HTTP_EVENT_REQ_BODY_END: - break; - case HTTP_EVENT_REQ_END: - http_decoder_result_queue_inc_req_index(queue); - half_data = http_decoder_result_queue_pop_req(queue); - if (half_data != NULL) { - http_decoder_half_data_free(half_data); - half_data = NULL; - } - break; - case HTTP_EVENT_RES_INIT: - half_data = http_decoder_result_queue_peek_res(queue); - if (half_data != NULL) { - http_decoder_result_queue_inc_res_index(queue); - } - - half_data = http_decoder_result_queue_peek_res(queue); - if (half_data != NULL) { - half_data = http_decoder_result_queue_pop_res(queue); - http_decoder_half_data_free(half_data); - half_data = NULL; - } - - half_data = http_decoder_half_data_new(); - ret = http_decoder_result_queue_push_res(queue, half_data); - if (ret < 0) { - fprintf(stderr, "http_decoder_result_queue_push res failed."); - http_decoder_half_data_free(half_data); - half_data = NULL; - } - *data = half_data; - break; - case HTTP_EVENT_RES_LINE: - msg = CALLOC(struct http_message, 1); - msg->type = HTTP_MESSAGE_RES_LINE; - msg->data = *data; - session_mq_publish_message(ev_ctx->ref_session, ev_ctx->topic_id, msg); - break; - case HTTP_EVENT_RES_HDR: - break; - case HTTP_EVENT_RES_HDR_END: - msg = CALLOC(struct http_message, 1); - msg->type = HTTP_MESSAGE_RES_HEADER; - msg->data = *data; - session_mq_publish_message(ev_ctx->ref_session, ev_ctx->topic_id, msg); - break; - case HTTP_EVENT_RES_BODY_BEGIN: - break; - case HTTP_EVENT_RES_BODY_DATA: - msg = CALLOC(struct http_message, 1); - msg->type = HTTP_MESSAGE_RES_BODY; - msg->data = *data; - session_mq_publish_message(ev_ctx->ref_session, ev_ctx->topic_id, msg); - break; - case HTTP_EVENT_RES_BODY_END: - break; - case HTTP_EVENT_RES_END: - http_decoder_result_queue_inc_res_index(queue); - half_data = http_decoder_result_queue_pop_res(queue); - if (half_data != NULL) { - http_decoder_half_data_free(half_data); - half_data = NULL; - } - break; - default: - assert(0); - break; - } -} - -static struct http_decoder * -http_decoder_new(http_event_cb *ev_cb, int is_cache_body) -{ - struct http_decoder *decoder = CALLOC(struct http_decoder, 1); - assert(decoder); - - decoder->c2s_half = http_decoder_half_new(ev_cb, is_cache_body, HTTP_REQUEST); - decoder->s2c_half = http_decoder_half_new(ev_cb, is_cache_body, HTTP_RESPONSE); - - return decoder; -} - -static void http_decoder_free(struct http_decoder *decoder) -{ - if (NULL == decoder) { - return; - } - - if (decoder->c2s_half != NULL) { - http_decoder_half_free(decoder->c2s_half); - decoder->c2s_half = NULL; - } - - if (decoder->s2c_half != NULL) { - http_decoder_half_free(decoder->s2c_half); - decoder->s2c_half = NULL; - } - - FREE(decoder); -} - -static struct http_decoder_exdata *http_decoder_exdata_new(size_t queue_size) -{ - struct http_decoder_exdata *ex_data = CALLOC(struct http_decoder_exdata, 1); - - ex_data->decoder = http_decoder_new(http_event_handler, 0); - ex_data->queue = http_decoder_result_queue_new(HD_RESULT_QUEUE_SIZE); - - return ex_data; -} - -static void http_decoder_exdata_free(struct http_decoder_exdata *ex_data) -{ - if (NULL == ex_data) { - return; - } - - if (ex_data->decoder != NULL) { - http_decoder_free(ex_data->decoder); - ex_data->decoder = NULL; - } - - if (ex_data->queue != NULL) { - http_decoder_result_queue_free(ex_data->queue); - ex_data->queue = NULL; - } - - FREE(ex_data); -} - -static int http_protocol_identify(const char *data, size_t data_len) -{ - llhttp_t parser; - llhttp_settings_t settings; - enum llhttp_errno error; - - llhttp_settings_init(&settings); - llhttp_init(&parser, HTTP_BOTH, &settings); - - error = llhttp_execute(&parser, data, data_len); - if (error != HPE_OK) { - return -1; - } - - return 0; -} - -int http_decoder_entry(struct session *sess, int events, - const struct packet *pkt, void *cb_arg) -{ - struct http_decoder_context *decoder_ctx = (struct http_decoder_context *)cb_arg; - size_t payload_len = 0; - uint64_t inner_flag = 0; - - int ret = session_is_inner_most(sess, &inner_flag); - if (0 == ret) { - return 0; - } - - struct http_decoder_exdata *ex_data = - session_get_ex_data(sess, decoder_ctx->ex_data_idx); - - if (events & SESS_EV_CLOSING) { - if (ex_data != NULL) { - http_decoder_exdata_free(ex_data); - session_set_ex_data(sess, decoder_ctx->ex_data_idx, NULL); - } - - return 0; - } - - const char *payload = session_get0_current_payload(sess, &payload_len); - - if (events & SESS_EV_OPENING) { - assert(ex_data == NULL); - - //If not http, ignore this session - if (payload_len > 0) { - size_t http_identify_len = payload_len > HTTP_IDENTIFY_LEN - ? HTTP_IDENTIFY_LEN - : payload_len; - - ret = http_protocol_identify(payload, http_identify_len); - if (ret < 0) { - // ignore this session's event - struct session_event *s_event = - session_get_intrinsic_event(sess, decoder_ctx->plugin_id); - - session_event_assign(s_event, decoder_ctx->st, sess, 0, - http_decoder_entry, decoder_ctx); - return 0; - } - } - - ex_data = http_decoder_exdata_new(HD_RESULT_QUEUE_SIZE); - session_set_ex_data(sess, decoder_ctx->ex_data_idx, ex_data); - } - - if (0 == payload_len || NULL == ex_data) { - return 0; - } - - int dir = packet_get_direction(pkt); - if (dir < 0) { - return -1; - } - - struct http_decoder_half *cur_half = NULL; - if (dir == PACKET_DIRECTION_C2S) { - cur_half = ex_data->decoder->c2s_half; - } else { - cur_half = ex_data->decoder->s2c_half; - } - - http_decoder_half_reinit(cur_half, decoder_ctx->topic_id, ex_data->queue, sess); - http_decoder_half_parse(cur_half, payload, payload_len); - - int thread_id = session_get_current_thread_id(sess); - - fieldstat_easy_counter_incrby(decoder_ctx->fse, thread_id, - decoder_ctx->fs_incoming_bytes_id, - NULL, 0, payload_len); - - fieldstat_easy_counter_incrby(decoder_ctx->fse, thread_id, - decoder_ctx->fs_incoming_pkts_id, - NULL, 0, 1); - - long long trans_cnt = http_decoder_half_trans_count(cur_half); - fieldstat_easy_counter_incrby(decoder_ctx->fse, thread_id, - decoder_ctx->fs_incoming_trans_id, - NULL, 0, trans_cnt); - - return 0; -} - -static void http_message_free(void *msg, void *cb_arg) -{ - if (NULL == msg) { - return; - } - - struct http_message *message = (struct http_message *)msg; - message->data = NULL; //don't have memory's ownership - - FREE(message); -} - -static void _http_decoder_context_free(struct http_decoder_context *ctx) -{ - if (NULL == ctx) { - return; - } - - if (ctx->fse != NULL) { - fieldstat_easy_free(ctx->fse); - ctx->fse = NULL; - } - - if (ctx->topic_id >= 0) { - session_mq_destroy_topic(ctx->st, ctx->topic_id); - ctx->topic_id = -1; - } - - FREE(ctx); -} - -static void http_decoder_ex_data_free(struct session *s, int idx, - void *ex_data, void *arg) -{ - if (NULL == ex_data) { - return; - } - - struct http_decoder_exdata *exdata = (struct http_decoder_exdata *)ex_data; - http_decoder_exdata_free(exdata); -} - -#define FS_OUTPUT_INTERVAL_S 1 -void *http_decoder_init(struct stellar *st) -{ - struct http_decoder_context *ctx = CALLOC(struct http_decoder_context, 1); - - ctx->st = st; - ctx->ex_data_idx = stellar_session_get_ex_new_index(st, "HTTP_DECODER", - http_decoder_ex_data_free, - NULL); - - int plugin_id = stellar_plugin_register(st, SESS_EV_TCP|SESS_EV_CLOSING, - http_decoder_entry, ctx); - if (plugin_id >= 0) { - ctx->plugin_id = plugin_id; - } - - int topic_id = session_mq_get_topic_id(st, http_decoder_topic); - if (topic_id < 0) { - topic_id = session_mq_create_topic(st, http_decoder_topic, - http_message_free, NULL); - } - ctx->topic_id = topic_id; - - int thread_num = stellar_get_worker_thread_num(st); - - ctx->fse = fieldstat_easy_new(thread_num, "http_decoder_statistics", NULL, 0); - if (NULL == ctx->fse) { - fprintf(stderr, "fieldstat_easy_new failed."); - goto failed; - } - - ctx->fs_incoming_bytes_id = - fieldstat_easy_register_counter(ctx->fse, "incoming_bytes"); - if (ctx->fs_incoming_bytes_id < 0) { - fprintf(stderr, "fieldstat_easy_register_counter incoming_bytes failed."); - goto failed; - } - - ctx->fs_incoming_trans_id = - fieldstat_easy_register_counter(ctx->fse, "incoming_trans"); - if (ctx->fs_incoming_trans_id < 0) { - fprintf(stderr, "fieldstat_easy_register_counter incoming_trans failed."); - goto failed; - } - - ctx->fs_incoming_pkts_id = - fieldstat_easy_register_counter(ctx->fse, "incoming_pkts"); - if (ctx->fs_incoming_pkts_id < 0) { - fprintf(stderr, "fieldstat_easy_register_counter incoming_pkts failed."); - goto failed; - } - - int ret = fieldstat_easy_enable_auto_output(ctx->fse, fs_file_name, - FS_OUTPUT_INTERVAL_S); - if (ret < 0) { - fprintf(stderr, "fieldstat_easy_enable_auto_output failed."); - goto failed; - } - sleep(1); - - printf("http_decoder_init: ex_data_idx:%d, plugin_id:%d, topic_id:%d\n", - ctx->ex_data_idx, ctx->plugin_id, ctx->topic_id); - - return ctx; - -failed: - _http_decoder_context_free(ctx); - return NULL; -} - -void http_decoder_exit(void *decoder_ctx) -{ - if (NULL == decoder_ctx) { - return; - } - - struct http_decoder_context *ctx = - (struct http_decoder_context *)decoder_ctx; - - _http_decoder_context_free(ctx); -} - -enum http_message_type http_message_type(struct http_message *msg) -{ - if (NULL == msg) { - return HTTP_MESSAGE_MAX; - } - - return msg->type; -} - -int http_message_get_request_line(struct http_message *msg, - struct http_request_line *line) -{ - if (NULL == msg || msg->type != HTTP_MESSAGE_REQ_LINE || - NULL == line) { - return -1; - } - - return http_decoder_half_data_get_request_line(msg->data, line); -} - -int http_message_get_response_line(struct http_message *msg, - struct http_response_line *line) -{ - if (NULL == msg || msg->type != HTTP_MESSAGE_RES_LINE || - NULL == line) { - return -1; - } - - return http_decoder_half_data_get_response_line(msg->data, line); -} - -int http_message_get_request_header(struct http_message *msg, struct hstring *key, - struct http_header *hdr_array, size_t array_size) -{ - if (NULL == msg || msg->type != HTTP_MESSAGE_REQ_HEADER || - NULL == key || NULL == hdr_array || 0 == array_size) { - return -1; - } - - return http_decoder_half_data_get_header(msg->data, key, hdr_array, array_size); -} - -int http_message_get_response_header(struct http_message *msg, struct hstring *key, - struct http_header *hdr_array, size_t array_size) -{ - if (NULL == msg || msg->type != HTTP_MESSAGE_RES_HEADER || NULL == key || - NULL == hdr_array || 0 == array_size) { - return -1; - } - - return http_decoder_half_data_get_header(msg->data, key, hdr_array, array_size); -} - -int http_message_request_header_next(struct http_message *msg, - struct http_header *hdr) -{ - if (NULL == msg || msg->type != HTTP_MESSAGE_REQ_HEADER - || NULL == hdr) { - return -1; - } - - return http_decoder_half_data_iter_header(msg->data, hdr); -} - -int http_message_response_header_next(struct http_message *msg, - struct http_header *hdr) -{ - if (NULL == msg || msg->type != HTTP_MESSAGE_RES_HEADER || - NULL == hdr) { - return -1; - } - - return http_decoder_half_data_iter_header(msg->data, hdr); -} - -int http_message_get_request_raw_body(struct http_message *msg, - struct hstring *body) -{ - if (NULL == msg || (msg->type != HTTP_MESSAGE_REQ_BODY) || - NULL == body) { - return -1; - } - - return http_decoder_half_data_get_raw_body(msg->data, body); -} - -int http_message_get_response_raw_body(struct http_message *msg, - struct hstring *body) -{ - if (NULL == msg || (msg->type != HTTP_MESSAGE_RES_BODY) || - NULL == body) { - return -1; - } - - return http_decoder_half_data_get_raw_body(msg->data, body); -} - -int http_message_get_request_decompress_body(struct http_message *msg, - struct hstring *body) -{ - if (NULL == msg || (msg->type != HTTP_MESSAGE_REQ_BODY) || - NULL == body) { - return -1; - } - - return http_decoder_half_data_get_decompress_body(msg->data, body); -} - -int http_message_get_response_decompress_body(struct http_message *msg, - struct hstring *body) -{ - if (NULL == msg || (msg->type != HTTP_MESSAGE_RES_BODY) || - NULL == body) { - return -1; - } - - return http_decoder_half_data_get_decompress_body(msg->data, body); -}
\ No newline at end of file diff --git a/src/http_decoder/http_decoder.h b/src/http_decoder/http_decoder.h deleted file mode 100644 index 24b96c6..0000000 --- a/src/http_decoder/http_decoder.h +++ /dev/null @@ -1,115 +0,0 @@ -/* -********************************************************************************************** -* File: http_decoder.h -* Description: -* Authors: Liu WenTan <[email protected]> -* Date: 2024-01-10 -* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved. -*********************************************************************************************** -*/ - -#ifndef _HTTP_DECODER_H_ -#define _HTTP_DECODER_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include <stddef.h> - -enum http_message_type { - HTTP_MESSAGE_REQ_LINE, - HTTP_MESSAGE_REQ_HEADER, - HTTP_MESSAGE_REQ_BODY, - HTTP_MESSAGE_RES_LINE, - HTTP_MESSAGE_RES_HEADER, - HTTP_MESSAGE_RES_BODY, - HTTP_MESSAGE_MAX -}; - -//http string -struct hstring { - char *str; - size_t str_len; -}; - -struct http_header { - struct hstring key; - struct hstring val; -}; - -struct http_request_line { - struct hstring method; - struct hstring uri; - struct hstring version; - - int major_version; - int minor_version; -}; - -struct http_response_line { - struct hstring version; - struct hstring status; - - int major_version; - int minor_version; - int status_code; -}; - -struct http_message; - -enum http_message_type http_message_type(struct http_message *msg); - -/** - * @retval succeed(0) failed(-1) -*/ -int http_message_get_request_line(struct http_message *msg, - struct http_request_line *line); - -int http_message_get_response_line(struct http_message *msg, - struct http_response_line *line); - -/* same key may has multiple kv */ -int http_message_get_request_header(struct http_message *msg, struct hstring *key, - struct http_header *hdr_array, size_t array_size); - -int http_message_get_response_header(struct http_message *msg, struct hstring *key, - struct http_header *hdr_array, size_t array_size); - -/** - * @brief loop reading all headers - * - * @retval succeed(1) failed(<= 0) -*/ -int http_message_request_header_next(struct http_message *msg, - struct http_header *header); - -int http_message_response_header_next(struct http_message *msg, - struct http_header *header); - -/** - * @retval succeed(0) failed(-1) -*/ -int http_message_get_request_raw_body(struct http_message *msg, - struct hstring *body); - -int http_message_get_response_raw_body(struct http_message *msg, - struct hstring *body); - -/** - * @brief If the body hasn't been compressed, return raw body - * - * @retval succeed(0) failed(-1) -*/ -int http_message_get_request_decompress_body(struct http_message *msg, - struct hstring *body); - -int http_message_get_response_decompress_body(struct http_message *msg, - struct hstring *body); - -#ifdef __cplusplus -} -#endif - -#endif
\ No newline at end of file diff --git a/src/http_decoder/http_decoder.toml b/src/http_decoder/http_decoder.toml deleted file mode 100644 index f7717a7..0000000 --- a/src/http_decoder/http_decoder.toml +++ /dev/null @@ -1,4 +0,0 @@ -[[plugin]] -path = "./src/http_decoder/http_decoder.so" -init = "http_decoder_init" -exit = "http_decoder_exit"
\ No newline at end of file diff --git a/src/http_decoder/http_decoder_half.c b/src/http_decoder/http_decoder_half.c deleted file mode 100644 index d97cd25..0000000 --- a/src/http_decoder/http_decoder_half.c +++ /dev/null @@ -1,803 +0,0 @@ -/* -********************************************************************************************** -* File: http_decoder_half.c -* Description: -* Authors: Liu WenTan <[email protected]> -* Date: 2024-01-10 -* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved. -*********************************************************************************************** -*/ - -#include <assert.h> -#include <stdio.h> - -#include "stellar/utils.h" -#include "llhttp.h" -#include "http_decoder_utils.h" -#include "http_decoder_half.h" -#include "http_decoder_table.h" -#include "http_content_decompress.h" - -struct http_decoder_half_data { - struct http_decoder_table *table; - - int major_version; - int minor_version; - int status_code; - - enum http_content_encoding content_encoding; - struct http_content_decompress *decompress; - char *ref_decompress_body; - size_t decompress_body_len; -}; - -struct http_decoder_half { - llhttp_t parser; - llhttp_settings_t settings; - enum llhttp_errno error; - - int is_cache_body; - - struct http_decoder_half_data *ref_data; - enum http_event event; - http_event_cb *http_ev_cb; - struct http_event_context *http_ev_ctx; - long long trans_counter; -}; - -// #define HTTP_DECODER_DEBUG -#ifdef HTTP_DECODER_DEBUG -static void printf_debug_info(const char *desc, const char *at, size_t length) -{ - if (at) - { - char *temp = safe_dup(at, length); - printf("HTTP PARSER STAGE: %s: %s\n", desc, temp); - FREE(temp); - } - else - { - printf("HTTP PARSER STAGE: %s\n", desc); - } -} -#else -#define printf_debug_info(desc, at, length) -#endif - -static void -http_decoder_half_data_decompress(struct http_decoder_half_data *data) -{ - assert(data); - - if (data->content_encoding == HTTP_CONTENT_ENCODING_NONE) { - return; - } - - struct hstring raw_body = {0}; - http_decoder_table_get_body(data->table, &raw_body); - if (raw_body.str == NULL || raw_body.str_len == 0) { - return; - } - - if (NULL == data->decompress) { - data->decompress = http_content_decompress_create(data->content_encoding); - } - - assert(data->decompress); - if (http_content_decompress_write(data->decompress, raw_body.str, - raw_body.str_len, - &data->ref_decompress_body, - &data->decompress_body_len) == -1) { - // log error - http_content_decompress_destroy(data->decompress); - data->decompress = NULL; - } -} - -/* Possible return values 0, -1, `HPE_PAUSED` */ -static int on_message_begin(llhttp_t *http) -{ - printf_debug_info("on_message_begin", NULL, 0); - - struct http_decoder_half *half = - container_of(http, struct http_decoder_half, parser); - assert(half); - - if (half->parser.type == HTTP_REQUEST) { - half->event = HTTP_EVENT_REQ_INIT; - } else { - half->event = HTTP_EVENT_RES_INIT; - } - - half->ref_data = NULL; - - assert(half->http_ev_cb != NULL); - half->http_ev_cb(half->event, &half->ref_data, half->http_ev_ctx); - - half->trans_counter++; - - return 0; -} - -static int on_message_complete(llhttp_t *http) -{ - printf_debug_info("on_message_complete", NULL, 0); - - struct http_decoder_half *half = - container_of(http, struct http_decoder_half, parser); - assert(half); - - if (half->parser.type == HTTP_REQUEST) { - if (half->event == HTTP_EVENT_REQ_BODY_DATA) { - half->event = HTTP_EVENT_REQ_BODY_END; - if (half->http_ev_cb != NULL) { - half->http_ev_cb(half->event, &half->ref_data, - half->http_ev_ctx); - } - } - } else { - if (half->event == HTTP_EVENT_RES_BODY_DATA) { - half->event = HTTP_EVENT_RES_BODY_END; - if (half->http_ev_cb != NULL) { - half->http_ev_cb(half->event, &half->ref_data, - half->http_ev_ctx); - } - } - } - - //trigger req_end/res_end - if (half->parser.type == HTTP_REQUEST) { - half->event = HTTP_EVENT_REQ_END; - if (half->http_ev_cb != NULL) { - half->http_ev_cb(half->event, &half->ref_data, half->http_ev_ctx); - } - } else { - half->event = HTTP_EVENT_RES_END; - if (half->http_ev_cb != NULL) { - half->http_ev_cb(half->event, &half->ref_data, half->http_ev_ctx); - } - } - - return 0; -} - -static int on_reset(llhttp_t *http) -{ - printf_debug_info("on_reset", NULL, 0); - - return 0; -} - -static int on_method(llhttp_t *http, const char *at, size_t length) -{ - printf_debug_info("on_method", at, length); - - struct http_decoder_half *half = - container_of(http, struct http_decoder_half, parser); - assert(half); - - http_decoder_table_refer(half->ref_data->table, HTTP_ITEM_METHOD, - at, length); - return 0; -} - -/* Information-only callbacks, return value is ignored */ -static int on_method_complete(llhttp_t *http) -{ - printf_debug_info("on_method_complete", NULL, 0); - - struct http_decoder_half *half = - container_of(http, struct http_decoder_half, parser); - assert(half); - - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_METHOD) == - STRING_STATE_REFER) { - http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_METHOD); - } - http_decoder_table_commit(half->ref_data->table, HTTP_ITEM_METHOD); - - return 0; -} - -/* Possible return values 0, -1, HPE_USER */ -static int on_uri(llhttp_t *http, const char *at, size_t length) -{ - printf_debug_info("on_uri", at, length); - - struct http_decoder_half *half = - container_of(http, struct http_decoder_half, parser); - assert(half); - - http_decoder_table_refer(half->ref_data->table, HTTP_ITEM_URI, - at, length); - return 0; -} - -/* Information-only callbacks, return value is ignored */ -static int on_uri_complete(llhttp_t *http) -{ - printf_debug_info("on_uri_complete", NULL, 0); - - struct http_decoder_half *half = - container_of(http, struct http_decoder_half, parser); - assert(half); - - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_URI) == - STRING_STATE_REFER) { - http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_URI); - } - http_decoder_table_commit(half->ref_data->table, HTTP_ITEM_URI); - - return 0; -} - -/* Possible return values 0, -1, HPE_USER */ -static int on_version(llhttp_t *http, const char *at, size_t length) -{ - printf_debug_info("on_version", at, length); - - struct http_decoder_half *half = - container_of(http, struct http_decoder_half, parser); - assert(half); - - http_decoder_table_refer(half->ref_data->table, HTTP_ITEM_VERSION, - at, length); - return 0; -} - -/* Information-only callbacks, return value is ignored */ -static int on_version_complete(llhttp_t *http) -{ - printf_debug_info("on_version_complete", NULL, 0); - - struct http_decoder_half *half = - container_of(http, struct http_decoder_half, parser); - assert(half); - - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_VERSION) == - STRING_STATE_REFER) { - http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_VERSION); - } - http_decoder_table_commit(half->ref_data->table, HTTP_ITEM_VERSION); - - half->ref_data->major_version = llhttp_get_http_major(&half->parser); - half->ref_data->minor_version = llhttp_get_http_minor(&half->parser); - - if (half->parser.type == HTTP_REQUEST) { - half->event = HTTP_EVENT_REQ_LINE; - if (half->http_ev_cb) { - half->http_ev_cb(half->event, &half->ref_data, half->http_ev_ctx); - } - } - - return 0; -} - -/* Possible return values 0, -1, HPE_USER */ -static int on_status(llhttp_t *http, const char *at, size_t length) -{ - printf_debug_info("on_status", at, length); - - struct http_decoder_half *half = - container_of(http, struct http_decoder_half, parser); - assert(half); - - http_decoder_table_refer(half->ref_data->table, HTTP_ITEM_STATUS, - at, length); - return 0; -} - -/* Information-only callbacks, return value is ignored */ -static int on_status_complete(llhttp_t *http) -{ - printf_debug_info("on_status_complete", NULL, 0); - - struct http_decoder_half *half = - container_of(http, struct http_decoder_half, parser); - assert(half); - - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_STATUS) == - STRING_STATE_REFER) { - http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_STATUS); - } - http_decoder_table_commit(half->ref_data->table, HTTP_ITEM_STATUS); - - half->ref_data->status_code = llhttp_get_status_code(&half->parser); - - half->event = HTTP_EVENT_RES_LINE; - if (half->http_ev_cb != NULL) { - half->http_ev_cb(half->event, &half->ref_data, half->http_ev_ctx); - } - - return 0; -} - -/* Possible return values 0, -1, HPE_USER */ -static int on_header_field(llhttp_t *http, const char *at, size_t length) -{ - printf_debug_info("on_header_field", at, length); - - struct http_decoder_half *half = - container_of(http, struct http_decoder_half, parser); - assert(half); - - http_decoder_table_refer(half->ref_data->table, HTTP_ITEM_HDRKEY, - at, length); - return 0; -} - -/* Information-only callbacks, return value is ignored */ -static int on_header_field_complete(llhttp_t *http) -{ - printf_debug_info("on_header_field_complete", NULL, 0); - - struct http_decoder_half *half = - container_of(http, struct http_decoder_half, parser); - assert(half); - - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_HDRKEY) == - STRING_STATE_REFER) { - http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_HDRKEY); - } - http_decoder_table_commit(half->ref_data->table, HTTP_ITEM_HDRKEY); - - return 0; -} - -/* Possible return values 0, -1, HPE_USER */ -static int on_header_value(llhttp_t *http, const char *at, size_t length) -{ - printf_debug_info("on_header_value", at, length); - - struct http_decoder_half *half = - container_of(http, struct http_decoder_half, parser); - assert(half); - - http_decoder_table_refer(half->ref_data->table, HTTP_ITEM_HDRVAL, - at, length); - return 0; -} - -/* Information-only callbacks, return value is ignored */ -static int on_header_value_complete(llhttp_t *http) -{ - printf_debug_info("on_header_value_complete", NULL, 0); - - struct http_decoder_half *half = - container_of(http, struct http_decoder_half, parser); - assert(half); - - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_HDRVAL) == - STRING_STATE_REFER) { - http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_HDRVAL); - } - http_decoder_table_commit(half->ref_data->table, HTTP_ITEM_HDRVAL); - - if (half->ref_data->content_encoding == HTTP_CONTENT_ENCODING_NONE) { - struct http_header http_hdr = {0}; - struct hstring key = {.str = (char *)"Content-Encoding", .str_len = 16}; - - if (http_decoder_table_get_header(half->ref_data->table, &key, - &http_hdr, 1) == 1) { - char *str = safe_dup(http_hdr.val.str, http_hdr.val.str_len); - half->ref_data->content_encoding = - http_content_encoding_str2int(str); - FREE(str); - } - } - - return 0; -} - -/* When on_chunk_header is called, the current chunk length is stored - * in parser->content_length. - * Possible return values 0, -1, `HPE_PAUSED` - */ -static int on_chunk_header(llhttp_t *http) -{ - printf_debug_info("on_chunk_header", NULL, 0); - - return 0; -} - -/* When on_chunk_header is called, the current chunk length is stored - * in parser->content_length. - * Possible return values 0, -1, `HPE_PAUSED` - */ -static int on_chunk_header_complete(llhttp_t *http) -{ - printf_debug_info("on_chunk_header_complete", NULL, 0); - - return 0; -} - -/* Possible return values: - * 0 - Proceed normally - * 1 - Assume that request/response has no body, and proceed to parsing the next message - * 2 - Assume absence of body (as above) and make `llhttp_execute()` return `HPE_PAUSED_UPGRADE` - * -1 - Error `HPE_PAUSED` - */ -static int on_headers_complete(llhttp_t *http) -{ - printf_debug_info("on_headers_complete", NULL, 0); - - struct http_decoder_half *half = - container_of(http, struct http_decoder_half, parser); - assert(half); - - if (half->parser.type == HTTP_REQUEST) { - half->event = HTTP_EVENT_REQ_HDR_END; - if (half->http_ev_cb) { - half->http_ev_cb(half->event, &half->ref_data, half->http_ev_ctx); - } - } - - if (half->parser.type == HTTP_RESPONSE) { - half->event = HTTP_EVENT_RES_HDR_END; - if (half->http_ev_cb) { - half->http_ev_cb(half->event, &half->ref_data, half->http_ev_ctx); - } - } - - return 0; -} - -/* Possible return values 0, -1, HPE_USER */ -static int on_body(llhttp_t *http, const char *at, size_t length) -{ - printf_debug_info("on_body", at, length); - - struct http_decoder_half *half = - container_of(http, struct http_decoder_half, parser); - assert(half); - - // trigger body_begin event - if (half->parser.type == HTTP_REQUEST) { - if (half->event == HTTP_EVENT_REQ_HDR_END) { - half->event = HTTP_EVENT_REQ_BODY_BEGIN; - if (half->http_ev_cb) { - half->http_ev_cb(half->event, &half->ref_data, - half->http_ev_ctx); - } - } - } else { - if (half->event == HTTP_EVENT_RES_HDR_END) { - half->event = HTTP_EVENT_RES_BODY_BEGIN; - if (half->http_ev_cb) { - half->http_ev_cb(half->event, &half->ref_data, - half->http_ev_ctx); - } - } - } - - if (half->ref_data != NULL) { - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_BODY) == - STRING_STATE_COMMIT) { - http_decoder_table_reset(half->ref_data->table, HTTP_ITEM_BODY); - } - - http_decoder_table_refer(half->ref_data->table, HTTP_ITEM_BODY, at, - length); - http_decoder_table_commit(half->ref_data->table, HTTP_ITEM_BODY); - } - - if (half->ref_data->content_encoding != HTTP_CONTENT_ENCODING_NONE) { - http_decoder_half_data_decompress(half->ref_data); - } - - if (half->parser.type == HTTP_REQUEST) { - half->event = HTTP_EVENT_REQ_BODY_DATA; - if (half->http_ev_cb) { - half->http_ev_cb(half->event, &half->ref_data, half->http_ev_ctx); - } - } else { - half->event = HTTP_EVENT_RES_BODY_DATA; - if (half->http_ev_cb) { - half->http_ev_cb(half->event, &half->ref_data, half->http_ev_ctx); - } - } - - return 0; -} - -static void http_decoder_half_init(struct http_decoder_half *half, - http_event_cb *http_ev_cb, - int is_cache_body, int type) -{ - if (NULL == half) { - return; - } - - llhttp_settings_init(&half->settings); - llhttp_init(&half->parser, type, &half->settings); - - half->settings.on_message_begin = on_message_begin; - half->settings.on_message_complete = on_message_complete; - half->settings.on_reset = on_reset; - - half->settings.on_url = on_uri; - half->settings.on_url_complete = on_uri_complete; - - half->settings.on_status = on_status; - half->settings.on_status_complete = on_status_complete; - - half->settings.on_method = on_method; - half->settings.on_method_complete = on_method_complete; - - half->settings.on_version = on_version; - half->settings.on_version_complete = on_version_complete; - - half->settings.on_header_field = on_header_field; - half->settings.on_header_field_complete = on_header_field_complete; - - half->settings.on_header_value = on_header_value; - half->settings.on_header_value_complete = on_header_value_complete; - - half->settings.on_chunk_header = on_chunk_header; - half->settings.on_chunk_complete = on_chunk_header_complete; - - half->settings.on_headers_complete = on_headers_complete; - half->settings.on_body = on_body; - - half->error = HPE_OK; - - half->http_ev_cb = http_ev_cb; - half->is_cache_body = is_cache_body; - - half->ref_data = NULL; -} - -struct http_decoder_half * -http_decoder_half_new(http_event_cb *ev_cb, int is_cache_body, int type) -{ - struct http_decoder_half *half = CALLOC(struct http_decoder_half, 1); - assert(half); - - half->http_ev_ctx = CALLOC(struct http_event_context, 1); - http_decoder_half_init(half, ev_cb, is_cache_body, type); - - return half; -} - -void http_decoder_half_free(struct http_decoder_half *half) -{ - if (NULL == half) { - return; - } - - if (half->http_ev_ctx != NULL) { - FREE(half->http_ev_ctx); - } - - FREE(half); -} - -void http_decoder_half_reinit(struct http_decoder_half *half, int topic_id, - struct http_decoder_result_queue *queue, - struct session *sess) -{ - assert(half != NULL); - - half->http_ev_ctx->topic_id = topic_id; - half->http_ev_ctx->ref_session = sess; - half->http_ev_ctx->ref_queue = queue; -} - -int http_decoder_half_parse(struct http_decoder_half *half, - const char *data, size_t data_len) -{ - if (NULL == half || NULL == data || 0 == data_len) { - return -1; - } - - half->error = llhttp_execute(&half->parser, data, data_len); - - int ret = 0; - uint8_t type = 0; - struct http_decoder_half_data *half_data = NULL; - - switch (half->error) { - case HPE_OK: - break; - case HPE_PAUSED: - llhttp_resume(&half->parser); - break; - case HPE_PAUSED_UPGRADE: - llhttp_resume_after_upgrade(&half->parser); - ret = 0; - break; - default: - type = half->parser.type; - llhttp_init(&half->parser, type, &half->settings); - ret = -1; - break; - } - - if (ret < 0) { - // fprintf(stdout, - // "llhttp_execute parse error: %s err_reason:%s\n", - // llhttp_errno_name(half->error), half->parser.reason); - return half->error; - } - - if (half->ref_data != NULL) { - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_URI) - == STRING_STATE_REFER) { - http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_URI); - } - - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_STATUS) - == STRING_STATE_REFER) { - http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_STATUS); - } - - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_METHOD) - == STRING_STATE_REFER) { - http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_METHOD); - } - - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_VERSION) - == STRING_STATE_REFER) { - http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_VERSION); - } - - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_HDRKEY) - == STRING_STATE_REFER) { - http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_HDRKEY); - } - - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_HDRVAL) - == STRING_STATE_REFER) { - http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_HDRVAL); - } - - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_BODY) - == STRING_STATE_REFER) { - http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_BODY); - } - } - - return 0; -} - -long long http_decoder_half_trans_count(struct http_decoder_half *half) -{ - if (NULL == half) { - return 0; - } - - long long trans_cnt = half->trans_counter; - half->trans_counter = 0; - - return trans_cnt; -} - -struct http_decoder_half_data *http_decoder_half_data_new() -{ - struct http_decoder_half_data *data = - CALLOC(struct http_decoder_half_data, 1); - assert(data); - - data->table = http_decoder_table_new(); - assert(data->table); - - data->major_version = -1; - data->minor_version = -1; - data->status_code = -1; - - data->content_encoding = HTTP_CONTENT_ENCODING_NONE; - data->ref_decompress_body = NULL; - data->decompress_body_len = 0; - - return data; -} - -void http_decoder_half_data_free(struct http_decoder_half_data *data) -{ - if (NULL == data) { - return; - } - - if (data->table != NULL) { - http_decoder_table_free(data->table); - data->table = NULL; - } - - if (data->decompress != NULL) { - http_content_decompress_destroy(data->decompress); - data->decompress = NULL; - } - - FREE(data); -} - -int http_decoder_half_data_get_request_line(struct http_decoder_half_data *data, - struct http_request_line *line) -{ - if (NULL == data || NULL == line) { - return -1; - } - - http_decoder_table_get_method(data->table, &line->method); - http_decoder_table_get_uri(data->table, &line->uri); - http_decoder_table_get_version(data->table, &line->version); - - line->major_version = data->major_version; - line->minor_version = data->minor_version; - - return 0; -} - -int http_decoder_half_data_get_response_line(struct http_decoder_half_data *data, - struct http_response_line *line) -{ - if (NULL == data || NULL == line) { - return -1; - } - - http_decoder_table_get_version(data->table, &line->version); - http_decoder_table_get_status(data->table, &line->status); - - line->major_version = data->major_version; - line->minor_version = data->minor_version; - line->status_code = data->status_code; - - return 0; -} - -int http_decoder_half_data_get_header(struct http_decoder_half_data *data, - struct hstring *key, struct http_header *hdr_array, - size_t array_size) -{ - if (NULL == data) { - return -1; - } - - return http_decoder_table_get_header(data->table, key, hdr_array, array_size); -} - -int http_decoder_half_data_iter_header(struct http_decoder_half_data *data, - struct http_header *header) -{ - if (NULL == data || NULL == header) { - return -1; - } - - return http_decoder_table_iter_header(data->table, header); -} - -int http_decoder_half_data_get_raw_body(struct http_decoder_half_data *data, - struct hstring *body) -{ - if (NULL == data || NULL == body) { - return -1; - } - - return http_decoder_table_get_body(data->table, body); -} - -int http_decoder_half_data_get_decompress_body(struct http_decoder_half_data *data, - struct hstring *body) -{ - if (NULL == data || NULL == body) { - return -1; - } - - if (HTTP_CONTENT_ENCODING_NONE == data->content_encoding) { - return http_decoder_table_get_body(data->table, body); - } - - - body->str = data->ref_decompress_body; - body->str_len = data->decompress_body_len; - return 0; -} - -void http_decoder_half_data_dump(struct http_decoder_half *half) -{ - if (NULL == half || NULL == half->ref_data) { - return; - } - - http_decoder_table_dump(half->ref_data->table); -}
\ No newline at end of file diff --git a/src/http_decoder/http_decoder_half.h b/src/http_decoder/http_decoder_half.h deleted file mode 100644 index 99cc260..0000000 --- a/src/http_decoder/http_decoder_half.h +++ /dev/null @@ -1,104 +0,0 @@ -/* -********************************************************************************************** -* File: http_decoder_half.h -* Description: -* Authors: Liu WenTan <[email protected]> -* Date: 2024-01-10 -* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved. -*********************************************************************************************** -*/ - - -#ifndef _HTTP_DECODER_HALF_H_ -#define _HTTP_DECODER_HALF_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include <stddef.h> - -#include "stellar/session.h" -#include "http_decoder.h" -#include "http_content_decompress.h" -#include "http_decoder_result_queue.h" - -// only one http event is fired at a time -enum http_event { - HTTP_EVENT_REQ_INIT = 1 << 1, - HTTP_EVENT_REQ_LINE = 1 << 2, - HTTP_EVENT_REQ_HDR = 1 << 3, - HTTP_EVENT_REQ_HDR_END = 1 << 4, - HTTP_EVENT_REQ_BODY_BEGIN = 1 << 5, - HTTP_EVENT_REQ_BODY_DATA = 1 << 6, - HTTP_EVENT_REQ_BODY_END = 1 << 7, - HTTP_EVENT_REQ_END = 1 << 8, - - HTTP_EVENT_RES_INIT = 1 << 9, - HTTP_EVENT_RES_LINE = 1 << 10, - HTTP_EVENT_RES_HDR = 1 << 11, - HTTP_EVENT_RES_HDR_END = 1 << 12, - HTTP_EVENT_RES_BODY_BEGIN = 1 << 13, - HTTP_EVENT_RES_BODY_DATA = 1 << 14, - HTTP_EVENT_RES_BODY_END = 1 << 15, - HTTP_EVENT_RES_END = 1 << 16, -}; - -struct http_event_context { - int topic_id; - struct session *ref_session; - struct http_decoder_result_queue *ref_queue; -}; - -struct http_decoder_half; -struct http_decoder_half_data; - -typedef void http_event_cb(enum http_event event, struct http_decoder_half_data **data, - struct http_event_context *ev_ctx); - -struct http_decoder_half * -http_decoder_half_new(http_event_cb *event_cb, int is_cache_body, int type); - -void http_decoder_half_free(struct http_decoder_half *half); - -void http_decoder_half_reinit(struct http_decoder_half *half, int topic_id, - struct http_decoder_result_queue *queue, - struct session *sess); - -int http_decoder_half_parse(struct http_decoder_half *half, - const char *data, size_t len); - -long long http_decoder_half_trans_count(struct http_decoder_half *half); - -//http decoder half data API -struct http_decoder_half_data *http_decoder_half_data_new(); - -void http_decoder_half_data_free(struct http_decoder_half_data *data); - -int http_decoder_half_data_get_request_line(struct http_decoder_half_data *data, - struct http_request_line *line); - -int http_decoder_half_data_get_response_line(struct http_decoder_half_data *data, - struct http_response_line *line); - -int http_decoder_half_data_get_header(struct http_decoder_half_data *data, - struct hstring *key, struct http_header *hdr_array, - size_t array_size); - -int http_decoder_half_data_iter_header(struct http_decoder_half_data *data, - struct http_header *header); - -int http_decoder_half_data_get_raw_body(struct http_decoder_half_data *data, - struct hstring *body); - -int http_decoder_half_data_get_decompress_body(struct http_decoder_half_data *data, - struct hstring *body); - -void http_decoder_half_data_dump(struct http_decoder_half *half); - -#ifdef __cplusplus -} -#endif - -#endif
\ No newline at end of file diff --git a/src/http_decoder/http_decoder_result_queue.c b/src/http_decoder/http_decoder_result_queue.c deleted file mode 100644 index eb7b2d1..0000000 --- a/src/http_decoder/http_decoder_result_queue.c +++ /dev/null @@ -1,155 +0,0 @@ -/* -********************************************************************************************** -* File: http_decoder_result_queue.c -* Description: -* Authors: Liuwentan <[email protected]> -* Date: 2024-01-15 -* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved. -*********************************************************************************************** -*/ - -#include <assert.h> - -#include "stellar/utils.h" -#include "http_decoder_half.h" -#include "http_decoder_result_queue.h" - -struct http_decoder_result_queue * -http_decoder_result_queue_new(size_t queue_size) -{ - struct http_decoder_result_queue *queue = - CALLOC(struct http_decoder_result_queue, 1); - assert(queue); - - queue->req_index = 0; - queue->res_index = 0; - queue->queue_size = queue_size; - - queue->array = CALLOC(struct http_decoder_result, queue->queue_size); - assert(queue->array); - - return queue; -} - -void http_decoder_result_queue_free(struct http_decoder_result_queue *queue) -{ - if (NULL == queue) { - return; - } - - if (queue->array != NULL) { - for (size_t i = 0; i < queue->queue_size; i++) { - if (queue->array[i].req_data != NULL) { - http_decoder_half_data_free(queue->array[i].req_data); - queue->array[i].req_data = NULL; - } - - if (queue->array[i].res_data != NULL) { - http_decoder_half_data_free(queue->array[i].res_data); - queue->array[i].res_data = NULL; - } - } - - FREE(queue->array); - } - - FREE(queue); -} - -void http_decoder_result_queue_inc_req_index(struct http_decoder_result_queue *queue) -{ - assert(queue); - - queue->req_index++; - queue->req_index = queue->req_index % queue->queue_size; -} - -void http_decoder_result_queue_inc_res_index(struct http_decoder_result_queue *queue) -{ - assert(queue); - - queue->res_index++; - queue->res_index = queue->res_index % queue->queue_size; -} - -int http_decoder_result_queue_push_req(struct http_decoder_result_queue *queue, - struct http_decoder_half_data *req_data) -{ - if (NULL == queue || NULL == req_data) { - return -1; - } - - assert(queue->array[queue->req_index].req_data == NULL); - if (queue->array[queue->req_index].req_data != NULL) { - return -1; - } - - queue->array[queue->req_index].req_data = req_data; - return 0; -} - -int http_decoder_result_queue_push_res(struct http_decoder_result_queue *queue, - struct http_decoder_half_data *res_data) -{ - if (NULL == queue || NULL == res_data) { - return -1; - } - - assert(queue->array[queue->res_index].res_data == NULL); - if (queue->array[queue->res_index].res_data != NULL) { - return -1; - } - - queue->array[queue->res_index].res_data = res_data; - return 0; -} - -struct http_decoder_half_data * -http_decoder_result_queue_pop_req(struct http_decoder_result_queue *queue) -{ - if (NULL == queue) { - return NULL; - } - - struct http_decoder_half_data *req_data = - queue->array[queue->req_index].req_data; - queue->array[queue->req_index].req_data = NULL; - - return req_data; -} - -struct http_decoder_half_data * -http_decoder_result_queue_pop_res(struct http_decoder_result_queue *queue) -{ - if (NULL == queue) { - return NULL; - } - - struct http_decoder_half_data *res_data = - queue->array[queue->res_index].res_data; - queue->array[queue->res_index].res_data = NULL; - - return res_data; -} - -struct http_decoder_half_data * -http_decoder_result_queue_peek_req(struct http_decoder_result_queue *queue) -{ - if (NULL == queue) { - return NULL; - } - - assert(queue->req_index < queue->queue_size); - return queue->array[queue->req_index].req_data; -} - -struct http_decoder_half_data * -http_decoder_result_queue_peek_res(struct http_decoder_result_queue *queue) -{ - if (NULL == queue) { - return NULL; - } - - assert(queue->res_index < queue->queue_size); - return queue->array[queue->res_index].res_data; -}
\ No newline at end of file diff --git a/src/http_decoder/http_decoder_result_queue.h b/src/http_decoder/http_decoder_result_queue.h deleted file mode 100644 index eef68ba..0000000 --- a/src/http_decoder/http_decoder_result_queue.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -********************************************************************************************** -* File: http_decoder_result_queue.h -* Description: -* Authors: Liuwentan <[email protected]> -* Date: 2024-01-15 -* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved. -*********************************************************************************************** -*/ - - -#ifndef _HTTP_DECODER_RESULT_QUEUE_H_ -#define _HTTP_DECODER_RESULT_QUEUE_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include <stddef.h> - -#include "http_decoder_half.h" - -struct http_decoder_result { - struct http_decoder_half_data *req_data; - struct http_decoder_half_data *res_data; -}; - -struct http_decoder_result_queue { - size_t req_index; - size_t res_index; - size_t queue_size; - struct http_decoder_result *array; -}; - -struct http_decoder_result_queue * -http_decoder_result_queue_new(size_t queue_size); - -void http_decoder_result_queue_free(struct http_decoder_result_queue *queue); - -void http_decoder_result_queue_inc_req_index(struct http_decoder_result_queue *queue); - -void http_decoder_result_queue_inc_res_index(struct http_decoder_result_queue *queue); - -struct http_decoder_half_data * -http_decoder_result_queue_pop_req(struct http_decoder_result_queue *queue); - -struct http_decoder_half_data * -http_decoder_result_queue_pop_res(struct http_decoder_result_queue *queue); - -int http_decoder_result_queue_push_req(struct http_decoder_result_queue *queue, - struct http_decoder_half_data *req_data); - -int http_decoder_result_queue_push_res(struct http_decoder_result_queue *queue, - struct http_decoder_half_data *res_data); - -struct http_decoder_half_data * -http_decoder_result_queue_peek_req(struct http_decoder_result_queue *queue); - -struct http_decoder_half_data * -http_decoder_result_queue_peek_res(struct http_decoder_result_queue *queue); - -#ifdef __cplusplus -} -#endif - -#endif
\ No newline at end of file diff --git a/src/http_decoder/http_decoder_string.c b/src/http_decoder/http_decoder_string.c deleted file mode 100644 index cfaeb4c..0000000 --- a/src/http_decoder/http_decoder_string.c +++ /dev/null @@ -1,193 +0,0 @@ -/* -********************************************************************************************** -* File: http_decoder_string.h -* Description: -* Authors: LuWenPeng <[email protected]> -* Date: 2022-10-31 -* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved. -*********************************************************************************************** -*/ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <assert.h> - -#include "stellar/utils.h" -#include "http_decoder_utils.h" -#include "http_decoder_string.h" - -static const char *string_state_to_desc(enum string_state state) -{ - switch (state) { - case STRING_STATE_INIT: - return "init"; - break; - case STRING_STATE_REFER: - return "refer"; - break; - case STRING_STATE_CACHE: - return "cache"; - break; - case STRING_STATE_COMMIT: - return "commit"; - break; - default: - return "unknown"; - break; - } -} - -void http_decoder_string_refer(struct http_decoder_string *rstr, - const char *at, size_t length) -{ - if (NULL == rstr) { - return; - } - - switch (rstr->state) { - case STRING_STATE_INIT: - case STRING_STATE_CACHE: - rstr->refer.str = (char *)at; - rstr->refer.str_len = length; - break; - default: - abort(); - break; - } - - rstr->state = STRING_STATE_REFER; -} - -void http_decoder_string_cache(struct http_decoder_string *rstr) -{ - if (NULL == rstr) { - return; - } - - size_t length = 0; - - switch (rstr->state) { - case STRING_STATE_REFER: - if (rstr->refer.str_len > 0) { - if (NULL == rstr->cache.str) { - length = rstr->refer.str_len + 1; - rstr->cache.str = CALLOC(char, length); - } else { - length = rstr->cache.str_len + rstr->refer.str_len + 2; - rstr->cache.str = REALLOC(char, rstr->cache.str, length); - } - - memcpy(rstr->cache.str + rstr->cache.str_len, rstr->refer.str, - rstr->refer.str_len); - rstr->cache.str_len += rstr->refer.str_len; - - rstr->refer.str = NULL; - rstr->refer.str_len = 0; - } - break; - default: - abort(); - break; - } - - rstr->state = STRING_STATE_CACHE; -} - -void http_decoder_string_commit(struct http_decoder_string *rstr) -{ - if (NULL == rstr) { - return; - } - - switch (rstr->state) { - case STRING_STATE_REFER: - if (rstr->cache.str_len) { - http_decoder_string_cache(rstr); - - rstr->commit.str = rstr->cache.str; - rstr->commit.str_len = rstr->cache.str_len; - // not overwrite rstr->cache.str - } else { - rstr->commit.str = rstr->refer.str; - rstr->commit.str_len = rstr->refer.str_len; - - rstr->refer.str = NULL; - rstr->refer.str_len = 0; - } - break; - case STRING_STATE_CACHE: - rstr->commit.str = rstr->cache.str; - rstr->commit.str_len = rstr->cache.str_len; - // not overwrite rstr->cache.str - break; - default: - //abort(); - break; - } - - rstr->state = STRING_STATE_COMMIT; -} - -void http_decoder_string_reset(struct http_decoder_string *rstr) -{ - assert(rstr); - - switch (rstr->state) { - case STRING_STATE_INIT: - case STRING_STATE_REFER: - case STRING_STATE_CACHE: - case STRING_STATE_COMMIT: - FREE(rstr->cache.str); - memset(rstr, 0, sizeof(struct http_decoder_string)); - break; - default: - abort(); - break; - } - - rstr->state = STRING_STATE_INIT; -} - -enum string_state http_decoder_string_state(struct http_decoder_string *rstr) -{ - return rstr->state; -} - -int http_decoder_string_get(struct http_decoder_string *rstr, struct hstring *out) -{ - if (NULL == rstr || NULL == out) { - return -1; - } - - if (http_decoder_string_state(rstr) == STRING_STATE_COMMIT) { - out->str = rstr->commit.str; - out->str_len = rstr->commit.str_len; - } else { - out->str = NULL; - out->str_len = 0; - } - - return 0; -} - -void http_decoder_string_dump(struct http_decoder_string *rstr, const char *desc) -{ - if (NULL == rstr) { - return; - } - - char *refer_str = safe_dup(rstr->refer.str, rstr->refer.str_len); - char *cache_str = safe_dup(rstr->cache.str, rstr->cache.str_len); - char *commit_str = safe_dup(rstr->commit.str, rstr->commit.str_len); - - printf("%s: state: %s, refer: {len: %02zu, str: %s}, cache: {len: %02zu, str: %s}, commit: {len: %02zu, str: %s}\n", - desc, string_state_to_desc(rstr->state), - rstr->refer.str_len, refer_str, - rstr->cache.str_len, cache_str, - rstr->commit.str_len, commit_str); - - FREE(refer_str); - FREE(cache_str); - FREE(commit_str); -}
\ No newline at end of file diff --git a/src/http_decoder/http_decoder_string.h b/src/http_decoder/http_decoder_string.h deleted file mode 100644 index 804a7ff..0000000 --- a/src/http_decoder/http_decoder_string.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -********************************************************************************************** -* File: http_decoder_string.h -* Description: -* Authors: LuWenPeng <[email protected]> -* Date: 2022-10-31 -* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved. -*********************************************************************************************** -*/ - -#ifndef _HTTP_DECODER_STRING_H_ -#define _HTTP_DECODER_STRING_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include "http_decoder.h" - - -enum string_state { - STRING_STATE_INIT, - STRING_STATE_REFER, - STRING_STATE_CACHE, - STRING_STATE_COMMIT, -}; - -/* state transition diagram - * +----------+ - * | | - * \|/ | - * +------+ | - * | init | | - * +------+ | - * | | - * +---->| | - * | \|/ | - * | +-------+ | - * | | refer |--+ | - * | +-------+ | | - * | | | | - * | \|/ | | - * | +-------+ | | - * +--| cache | | | - * +-------+ | | - * | | | - * |<------+ | - * \|/ | - * +--------+ | - * | commit | | - * +--------+ | - * | | - * \|/ | - * +--------+ | - * | reset |----+ - * +--------+ - */ - - -//http decoder string -struct http_decoder_string { - struct hstring refer; // shallow copy - struct hstring cache; // deep copy - struct hstring commit; - - enum string_state state; -}; - -void http_decoder_string_refer(struct http_decoder_string *rstr, - const char *at, size_t length); - -void http_decoder_string_cache(struct http_decoder_string *rstr); - -void http_decoder_string_commit(struct http_decoder_string *rstr); - -void http_decoder_string_reset(struct http_decoder_string *rstr); - -enum string_state http_decoder_string_state(struct http_decoder_string *rstr); - -int http_decoder_string_get(struct http_decoder_string *rstr, struct hstring *out); - -void http_decoder_string_dump(struct http_decoder_string *rstr, const char *desc); - -#ifdef __cplusplus -} -#endif - -#endif
\ No newline at end of file diff --git a/src/http_decoder/http_decoder_table.c b/src/http_decoder/http_decoder_table.c deleted file mode 100644 index 300994d..0000000 --- a/src/http_decoder/http_decoder_table.c +++ /dev/null @@ -1,443 +0,0 @@ -/* -********************************************************************************************** -* File: http_decoder_table.c -* Description: -* Authors: LuWenPeng <[email protected]> -* Date: 2022-10-31 -* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved. -*********************************************************************************************** -*/ - - -#include <assert.h> -#include <stdlib.h> -#include <string.h> - -#include "http_decoder_table.h" -#include "http_decoder.h" -#include "http_decoder_string.h" -#include "stellar/utils.h" - -#define MAX_HEADER_SIZE 16 - - -struct http_decoder_header { - struct http_decoder_string key; - struct http_decoder_string val; -}; - -struct http_decoder_table { - struct http_decoder_string uri; - struct http_decoder_string status; - struct http_decoder_string method; - struct http_decoder_string version; - struct http_decoder_string body; - - size_t header_size; - size_t header_index; - size_t header_iter; - struct http_decoder_header *headers; -}; - -struct http_decoder_table *http_decoder_table_new() -{ - struct http_decoder_table *table = CALLOC(struct http_decoder_table, 1); - assert(table); - - table->header_index = 0; - table->header_size = MAX_HEADER_SIZE; - table->headers = CALLOC(struct http_decoder_header, table->header_size); - - return table; -} - -void http_decoder_table_free(struct http_decoder_table *table) -{ - if (NULL == table) { - return; - } - - if (table->uri.cache.str != NULL) { - FREE(table->uri.cache.str); - } - - if (table->status.cache.str != NULL) { - FREE(table->status.cache.str); - } - - if (table->method.cache.str != NULL) { - FREE(table->method.cache.str); - } - - if (table->version.cache.str != NULL) { - FREE(table->version.cache.str); - } - - if (table->body.cache.str != NULL) { - FREE(table->body.cache.str); - } - - if (table->headers != NULL) { - for (size_t i = 0; i < table->header_size; i++) { - if (table->headers[i].key.cache.str != NULL) { - FREE(table->headers[i].key.cache.str); - } - - if (table->headers[i].val.cache.str != NULL) { - FREE(table->headers[i].val.cache.str); - } - } - - FREE(table->headers); - } - - FREE(table); -} - -enum string_state -http_decoder_table_state(struct http_decoder_table *table, enum http_item type) -{ - if (NULL == table) { - return STRING_STATE_INIT; - } - - struct http_decoder_header *header = NULL; - enum string_state state = STRING_STATE_INIT; - assert(table); - - switch (type) { - case HTTP_ITEM_URI: - state = http_decoder_string_state(&table->uri); - break; - case HTTP_ITEM_STATUS: - state = http_decoder_string_state(&table->status); - break; - case HTTP_ITEM_METHOD: - state = http_decoder_string_state(&table->method); - break; - case HTTP_ITEM_VERSION: - state = http_decoder_string_state(&table->version); - break; - case HTTP_ITEM_HDRKEY: - assert(table->header_index < table->header_size); - header = &table->headers[table->header_index]; - state = http_decoder_string_state(&header->key); - break; - case HTTP_ITEM_HDRVAL: - assert(table->header_index < table->header_size); - header = &table->headers[table->header_index]; - state = http_decoder_string_state(&header->val); - break; - case HTTP_ITEM_BODY: - state = http_decoder_string_state(&table->body); - break; - default: - abort(); - break; - } - - return state; -} - -void http_decoder_table_refer(struct http_decoder_table *table, enum http_item type, - const char *at, size_t len) -{ - if (NULL == table) { - return; - } - - struct http_decoder_header *header = NULL; - assert(table); - - switch (type) { - case HTTP_ITEM_URI: - http_decoder_string_refer(&table->uri, at, len); - break; - case HTTP_ITEM_STATUS: - http_decoder_string_refer(&table->status, at, len); - break; - case HTTP_ITEM_METHOD: - http_decoder_string_refer(&table->method, at, len); - break; - case HTTP_ITEM_VERSION: - http_decoder_string_refer(&table->version, at, len); - break; - case HTTP_ITEM_HDRKEY: - assert(table->header_index < table->header_size); - header = &table->headers[table->header_index]; - http_decoder_string_refer(&header->key, at, len); - break; - case HTTP_ITEM_HDRVAL: - assert(table->header_index < table->header_size); - header = &table->headers[table->header_index]; - http_decoder_string_refer(&header->val, at, len); - break; - case HTTP_ITEM_BODY: - http_decoder_string_refer(&table->body, at, len); - break; - default: - abort(); - break; - } -} - -void http_decoder_table_cache(struct http_decoder_table *table, enum http_item type) -{ - if (NULL == table) { - return; - } - - struct http_decoder_header *header = NULL; - assert(table); - - switch (type) { - case HTTP_ITEM_URI: - http_decoder_string_cache(&table->uri); - break; - case HTTP_ITEM_STATUS: - http_decoder_string_cache(&table->status); - break; - case HTTP_ITEM_METHOD: - http_decoder_string_cache(&table->method); - break; - case HTTP_ITEM_VERSION: - http_decoder_string_cache(&table->version); - break; - case HTTP_ITEM_HDRKEY: - assert(table->header_index < table->header_size); - header = &table->headers[table->header_index]; - http_decoder_string_cache(&header->key); - break; - case HTTP_ITEM_HDRVAL: - assert(table->header_index < table->header_size); - header = &table->headers[table->header_index]; - http_decoder_string_cache(&header->val); - break; - case HTTP_ITEM_BODY: - http_decoder_string_cache(&table->body); - break; - default: - abort(); - break; - } -} - -void http_decoder_table_commit(struct http_decoder_table *table, enum http_item type) -{ - if (NULL == table) { - return; - } - - struct http_decoder_header *header = NULL; - assert(table); - - switch (type) { - case HTTP_ITEM_URI: - http_decoder_string_commit(&table->uri); - break; - case HTTP_ITEM_STATUS: - http_decoder_string_commit(&table->status); - break; - case HTTP_ITEM_METHOD: - http_decoder_string_commit(&table->method); - break; - case HTTP_ITEM_VERSION: - http_decoder_string_commit(&table->version); - break; - case HTTP_ITEM_HDRKEY: - assert(table->header_index < table->header_size); - header = &table->headers[table->header_index]; - http_decoder_string_commit(&header->key); - break; - case HTTP_ITEM_HDRVAL: - header = &table->headers[table->header_index]; - http_decoder_string_commit(&header->val); - // inc index - if ((table->header_index + 1) >= table->header_size) { - table->headers = REALLOC(struct http_decoder_header, table->headers, - table->header_size * 2); - table->header_size *= 2; - for (size_t i = table->header_index + 1; i < table->header_size; i++) { - header = &table->headers[i]; - memset(header, 0, sizeof(struct http_decoder_header)); - } - } - table->header_index++; - break; - case HTTP_ITEM_BODY: - http_decoder_string_commit(&table->body); - break; - default: - abort(); - break; - } -} - -void http_decoder_table_reset(struct http_decoder_table *table, enum http_item type) -{ - if (NULL == table) { - return; - } - - struct http_decoder_header *header = NULL; - assert(table); - - switch (type) { - case HTTP_ITEM_URI: - http_decoder_string_reset(&table->uri); - break; - case HTTP_ITEM_STATUS: - http_decoder_string_reset(&table->status); - break; - case HTTP_ITEM_METHOD: - http_decoder_string_reset(&table->method); - break; - case HTTP_ITEM_VERSION: - http_decoder_string_reset(&table->version); - break; - case HTTP_ITEM_HDRKEY: - header = &table->headers[table->header_index]; - http_decoder_string_reset(&header->key); - break; - case HTTP_ITEM_HDRVAL: - header = &table->headers[table->header_index]; - http_decoder_string_reset(&header->val); - break; - case HTTP_ITEM_BODY: - http_decoder_string_reset(&table->body); - break; - default: - abort(); - break; - } -} - -void http_decoder_table_dump(struct http_decoder_table *table) -{ - if (NULL == table) { - return; - } - - http_decoder_string_dump(&table->uri, "uri"); - http_decoder_string_dump(&table->status, "status"); - http_decoder_string_dump(&table->method, "method"); - http_decoder_string_dump(&table->version, "version"); - http_decoder_string_dump(&table->body, "body"); - - for (size_t i = 0; i < table->header_size; i++) { - struct http_decoder_header *header = &table->headers[i]; - if (NULL == header) { - continue; - } - - http_decoder_string_dump(&header->key, "key"); - http_decoder_string_dump(&header->val, "val"); - } -} - -int http_decoder_table_get_uri(struct http_decoder_table *table, struct hstring *out) -{ - if (NULL == table || NULL == out) { - return -1; - } - - return http_decoder_string_get(&table->uri, out); -} - -int http_decoder_table_get_method(struct http_decoder_table *table, struct hstring *out) -{ - if (NULL == table || NULL == out) { - return -1; - } - - return http_decoder_string_get(&table->method, out); -} - -int http_decoder_table_get_status(struct http_decoder_table *table, struct hstring *out) -{ - if (NULL == table || NULL == out) { - return -1; - } - - return http_decoder_string_get(&table->status, out); -} - -int http_decoder_table_get_version(struct http_decoder_table *table, struct hstring *out) -{ - if (NULL == table || NULL == out) { - return -1; - } - - return http_decoder_string_get(&table->version, out); -} - -int http_decoder_table_get_body(struct http_decoder_table *table, struct hstring *out) -{ - if (NULL == table || NULL == out) { - return -1; - } - - return http_decoder_string_get(&table->body, out); -} - -int http_decoder_table_get_header(struct http_decoder_table *table, struct hstring *key, - struct http_header *hdr_array, size_t array_size) -{ - if (NULL == table || NULL == key->str || 0 == key->str_len) { - return 0; - } - - int header_cnt = 0; - for (int i = 0; i < table->header_size && header_cnt < array_size; i++) { - struct http_decoder_header *tmp_header = &table->headers[i]; - if (NULL == tmp_header) { - continue; - } - - if (http_decoder_string_state(&tmp_header->key) == STRING_STATE_COMMIT - && http_decoder_string_state(&tmp_header->val) == STRING_STATE_COMMIT) { - struct hstring tmp_key; - http_decoder_string_get(&tmp_header->key, &tmp_key); - - if (tmp_key.str_len == key->str_len - && (0 == strncasecmp(tmp_key.str, key->str, key->str_len))) { - http_decoder_string_get(&tmp_header->key, &hdr_array[header_cnt].key); - http_decoder_string_get(&tmp_header->val, &hdr_array[header_cnt].val); - header_cnt++; - } - } - } - - return header_cnt; -} - -int http_decoder_table_iter_header(struct http_decoder_table *table, - struct http_header *hdr) -{ - if (NULL == table || NULL == hdr) { - return -1; - } - - if (table->header_iter >= table->header_size) { - return 0; - } - - struct http_decoder_header *tmp_header = &table->headers[table->header_iter++]; - if (tmp_header != NULL) { - if (http_decoder_string_state(&tmp_header->key) == STRING_STATE_COMMIT && - http_decoder_string_state(&tmp_header->val) == STRING_STATE_COMMIT) { - - http_decoder_string_get(&tmp_header->key, &hdr->key); - http_decoder_string_get(&tmp_header->val, &hdr->val); - return 1; - } - } - - hdr->key.str = NULL; - hdr->key.str_len = 0; - - hdr->val.str = NULL; - hdr->val.str_len = 0; - - return 0; -}
\ No newline at end of file diff --git a/src/http_decoder/http_decoder_table.h b/src/http_decoder/http_decoder_table.h deleted file mode 100644 index 19a4811..0000000 --- a/src/http_decoder/http_decoder_table.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -********************************************************************************************** -* File: http_decoder_table.h -* Description: -* Authors: LuWenPeng <[email protected]> -* Date: 2022-10-31 -* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved. -*********************************************************************************************** -*/ - - -#ifndef _HTTP_DECODER_TABLE_H_ -#define _HTTP_DECODER_TABLE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stddef.h> - -#include "http_decoder.h" -#include "http_decoder_string.h" - - -enum http_item { - HTTP_ITEM_URI = 0x01, - HTTP_ITEM_STATUS = 0x02, - HTTP_ITEM_METHOD = 0x03, - HTTP_ITEM_VERSION = 0x04, - HTTP_ITEM_HDRKEY = 0x05, - HTTP_ITEM_HDRVAL = 0x06, - HTTP_ITEM_BODY = 0x07, -}; - -struct http_decoder_table; - -struct http_decoder_table *http_decoder_table_new(); - -void http_decoder_table_free(struct http_decoder_table *table); - -enum string_state -http_decoder_table_state(struct http_decoder_table *table, enum http_item type); - -void http_decoder_table_refer(struct http_decoder_table *table, enum http_item type, - const char *at, size_t len); - -void http_decoder_table_cache(struct http_decoder_table *table, enum http_item type); - -void http_decoder_table_commit(struct http_decoder_table *table, enum http_item type); - -void http_decoder_table_reset(struct http_decoder_table *table, enum http_item type); - -void http_decoder_table_dump(struct http_decoder_table *table); - -int http_decoder_table_get_uri(struct http_decoder_table *table, struct hstring *out); - -int http_decoder_table_get_method(struct http_decoder_table *table, struct hstring *out); - -int http_decoder_table_get_status(struct http_decoder_table *table, struct hstring *out); - -int http_decoder_table_get_version(struct http_decoder_table *table, struct hstring *out); - -int http_decoder_table_get_body(struct http_decoder_table *table, struct hstring *out); - -int http_decoder_table_get_header(struct http_decoder_table *table, struct hstring *key, - struct http_header *hdr_array, size_t array_size); - -int http_decoder_table_iter_header(struct http_decoder_table *table, struct http_header *hdr); - -#ifdef __cplusplus -} -#endif - -#endif
\ No newline at end of file diff --git a/src/http_decoder/http_decoder_utils.c b/src/http_decoder/http_decoder_utils.c deleted file mode 100644 index a5dfbe1..0000000 --- a/src/http_decoder/http_decoder_utils.c +++ /dev/null @@ -1,25 +0,0 @@ -/* -********************************************************************************************** -* File: http_decoder_utils.c -* Description: -* Authors: LuWenPeng <[email protected]> -* Date: 2022-10-31 -* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved. -*********************************************************************************************** -*/ - -#include <string.h> - -#include "stellar/utils.h" - -char *safe_dup(const char *str, size_t len) -{ - if (str == NULL || len == 0) { - return NULL; - } - - char *dup = CALLOC(char, len + 1); - memcpy(dup, str, len); - - return dup; -}
\ No newline at end of file diff --git a/src/http_decoder/http_decoder_utils.h b/src/http_decoder/http_decoder_utils.h deleted file mode 100644 index 9c031a3..0000000 --- a/src/http_decoder/http_decoder_utils.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -********************************************************************************************** -* File: http_decoder_utils.h -* Description: -* Authors: LuWenPeng <[email protected]> -* Date: 2022-10-31 -* Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved. -*********************************************************************************************** -*/ - - -#ifndef _HTTP_DECODER_UTILS_H_ -#define _HTTP_DECODER_UTILS_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include <stdlib.h> -#include <stdio.h> - - -char *safe_dup(const char *str, size_t len); - -/****************************************************************************** - * Logger - ******************************************************************************/ - -enum http_decoder_log_level { - DEBUG = 0x11, - WARN = 0x12, - INFO = 0x13, - ERROR = 0x14, -}; - -#ifndef http_decoder_log -#define http_decoder_log(level, format, ...) \ - { \ - switch (level) \ - { \ - case DEBUG: \ - fprintf(stdout, "HTTP_DECODER [DEBUG] " format "\n", ##__VA_ARGS__); \ - fflush(stdout); \ - break; \ - case WARN: \ - fprintf(stdout, "HTTP_DECODER [WARN] " format "\n", ##__VA_ARGS__); \ - fflush(stdout); \ - break; \ - case INFO: \ - fprintf(stdout, "HTTP_DECODER [INFO] " format "\n", ##__VA_ARGS__); \ - fflush(stdout); \ - break; \ - case ERROR: \ - fprintf(stderr, "HTTP_DECODER [ERROR] " format "\n", ##__VA_ARGS__); \ - fflush(stderr); \ - break; \ - } \ - } -#endif - -#ifdef __cplusplus -} -#endif - -#endif
\ No newline at end of file diff --git a/src/http_decoder/version.map b/src/http_decoder/version.map deleted file mode 100644 index a0ba8a4..0000000 --- a/src/http_decoder/version.map +++ /dev/null @@ -1,7 +0,0 @@ -VERS_3.0{ -global: - extern "C" { - http_message_*; - }; -local: *; -};
\ No newline at end of file diff --git a/src/plugin_manager/CMakeLists.txt b/src/plugin_manager/CMakeLists.txt index cc17074..ed3aff9 100644 --- a/src/plugin_manager/CMakeLists.txt +++ b/src/plugin_manager/CMakeLists.txt @@ -4,4 +4,4 @@ include_directories(${CMAKE_SOURCE_DIR}/deps) include_directories(${CMAKE_SOURCE_DIR}/src/stellar_on_sapp) add_library(plugin_manager STATIC plugin_manager.c) -target_link_libraries(plugin_manager toml bitmap) +target_link_libraries(plugin_manager toml bitmap)
\ No newline at end of file diff --git a/src/plugin_manager/plugin_manager.c b/src/plugin_manager/plugin_manager.c index 744b160..09cee97 100644 --- a/src/plugin_manager/plugin_manager.c +++ b/src/plugin_manager/plugin_manager.c @@ -16,13 +16,22 @@ #include <threads.h> -struct per_thread_exdata_array; -struct per_thread_mq_array; + +struct per_thread_exdata_array +{ + struct stellar_exdata *exdata_array; +}; + +struct stellar_message; +struct per_thread_mq_array +{ + struct stellar_message *mq; +}; struct plugin_manger_per_thread_data { - struct per_thread_exdata_array *per_thread_pkt_exdata_array; - struct per_thread_mq_array *per_thread_pkt_mq_array; + struct per_thread_exdata_array per_thread_pkt_exdata_array; + struct per_thread_mq_array per_thread_pkt_mq_array; }; struct plugin_manager_schema @@ -48,11 +57,7 @@ struct plugin_manager_schema struct plugin_manger_per_thread_data *per_thread_data; }; -struct stellar_message; -struct per_thread_mq_array -{ - struct stellar_message *mq; -}; + struct stellar_exdata @@ -60,10 +65,6 @@ struct stellar_exdata void *exdata; }; -struct per_thread_exdata_array -{ - struct stellar_exdata *exdata_array; -}; struct stellar_exdata_schema @@ -248,18 +249,32 @@ PLUGIN_SPEC_LOAD_ERROR: return NULL; } -static struct per_thread_exdata_array *per_thread_packet_exdata_arrary_new(struct stellar *st, struct plugin_manager_schema *plug_mgr); -static struct per_thread_mq_array *per_thread_mq_arrary_new(struct stellar *st); -static struct plugin_manger_per_thread_data *plugin_manager_per_thread_data_new(struct stellar *st, struct plugin_manager_schema *plug_mgr) +static struct plugin_manger_per_thread_data *plugin_manager_per_thread_data_new(struct stellar *st) { - if(st == NULL || plug_mgr == NULL)return NULL; - struct plugin_manger_per_thread_data *per_thread_data = CALLOC(struct plugin_manger_per_thread_data, 1); - per_thread_data->per_thread_pkt_exdata_array = per_thread_packet_exdata_arrary_new(st, plug_mgr); - per_thread_data->per_thread_pkt_mq_array = per_thread_mq_arrary_new(st); + if(st == NULL)return NULL; + int thread_num=stellar_get_worker_thread_num(st); + struct plugin_manger_per_thread_data *per_thread_data = CALLOC(struct plugin_manger_per_thread_data, thread_num); return per_thread_data; } + +static void plugin_manager_per_thread_data_free(struct plugin_manger_per_thread_data *per_thread_data, struct stellar *st) +{ + if(per_thread_data == NULL || st == NULL)return; + int thread_num=stellar_get_worker_thread_num(st); + struct plugin_manger_per_thread_data *p_data; + for (int i = 0; i < thread_num; i++) + { + p_data=per_thread_data+i; + if(p_data->per_thread_pkt_exdata_array.exdata_array)FREE(p_data->per_thread_pkt_exdata_array.exdata_array); + if(p_data->per_thread_pkt_mq_array.mq)FREE(p_data->per_thread_pkt_mq_array.mq); + } + FREE(per_thread_data); + return; +} + + struct plugin_manager_schema *plugin_manager_init(struct stellar *st, const char *plugin_spec_file_path) { int spec_num; @@ -294,21 +309,10 @@ struct plugin_manager_schema *plugin_manager_init(struct stellar *st, const char } } FREE(specs); - plug_mgr->per_thread_data = plugin_manager_per_thread_data_new(st, plug_mgr); + plug_mgr->per_thread_data = plugin_manager_per_thread_data_new(st); return plug_mgr; } -static void per_thread_packet_exdata_arrary_free(struct stellar *st, struct per_thread_exdata_array *exdata_array); -static void per_thread_mq_arrary_free(struct per_thread_mq_array *mq_array); - -static void plugin_manager_per_thread_data_free(struct plugin_manger_per_thread_data *per_thread_data, struct stellar *st) -{ - if(per_thread_data == NULL || st == NULL)return; - per_thread_packet_exdata_arrary_free(st, per_thread_data->per_thread_pkt_exdata_array); - per_thread_mq_arrary_free(per_thread_data->per_thread_pkt_mq_array); - FREE(per_thread_data); - return; -} void plugin_manager_exit(struct plugin_manager_schema *plug_mgr) { @@ -436,43 +440,25 @@ void *stellar_exdata_get(UT_array *exdata_schema, struct stellar_exdata *exdata_ * PACKET EXDATA * *******************************/ -static struct per_thread_exdata_array *per_thread_packet_exdata_arrary_new(struct stellar *st, struct plugin_manager_schema *plug_mgr) -{ - if(st == NULL || plug_mgr == NULL || plug_mgr->packet_exdata_schema_array == NULL )return NULL; - int thread_num=stellar_get_worker_thread_num(st); - struct per_thread_exdata_array *per_thread_pkt_exdata_array = CALLOC(struct per_thread_exdata_array, thread_num); - unsigned int len=utarray_len(plug_mgr->packet_exdata_schema_array); - for (int i = 0; i < thread_num; i++) - { - (per_thread_pkt_exdata_array+i)->exdata_array = CALLOC(struct stellar_exdata, len); - } - return per_thread_pkt_exdata_array; -} - -static void per_thread_packet_exdata_arrary_free(struct stellar *st, struct per_thread_exdata_array *exdata_array) -{ - if(st == NULL || exdata_array == NULL)return; - int thread_num=stellar_get_worker_thread_num(st); - for (int i = 0; i < thread_num; i++) - { - FREE((exdata_array+i)->exdata_array); - } - FREE(exdata_array); - return; -} static struct stellar_exdata *per_thread_packet_exdata_arrary_get(struct plugin_manager_schema *plug_mgr) { if(plug_mgr==NULL || plug_mgr->packet_exdata_schema_array == NULL)return NULL; int tid=stellar_get_current_thread_id(plug_mgr->st); - return (plug_mgr->per_thread_data->per_thread_pkt_exdata_array+tid)->exdata_array; + if((plug_mgr->per_thread_data+tid)->per_thread_pkt_exdata_array.exdata_array == NULL) + { + unsigned int len = utarray_len(plug_mgr->packet_exdata_schema_array); + (plug_mgr->per_thread_data+tid)->per_thread_pkt_exdata_array.exdata_array = CALLOC(struct stellar_exdata, len); + } + return (plug_mgr->per_thread_data+tid)->per_thread_pkt_exdata_array.exdata_array; } static void per_thread_packet_exdata_arrary_clean(struct plugin_manager_schema *plug_mgr, struct packet *pkt) { - if(plug_mgr==NULL || plug_mgr->packet_exdata_schema_array == NULL || plug_mgr->per_thread_data->per_thread_pkt_exdata_array == NULL)return; + if(plug_mgr==NULL || plug_mgr->packet_exdata_schema_array == NULL)return; unsigned int len=utarray_len(plug_mgr->packet_exdata_schema_array); struct stellar_exdata *per_thread_pkt_exdata_arrary = per_thread_packet_exdata_arrary_get(plug_mgr); + if(per_thread_pkt_exdata_arrary == NULL)return; for (unsigned int i = 0; i < len; i++) { void *exdata = (per_thread_pkt_exdata_arrary + i)->exdata; @@ -656,20 +642,6 @@ UT_icd stellar_mq_subscriber_info_icd = {sizeof(struct stellar_mq_subscriber_inf * PACKET MQ * *******************************/ -static struct per_thread_mq_array *per_thread_mq_arrary_new(struct stellar *st) -{ - if(st == NULL)return NULL; - int thread_num=stellar_get_worker_thread_num(st); - struct per_thread_mq_array *per_thread_pkt_mq_array = CALLOC(struct per_thread_mq_array, thread_num); - return per_thread_pkt_mq_array; -} - -static void per_thread_mq_arrary_free(struct per_thread_mq_array *mq_array) -{ - if(mq_array == NULL)return; - FREE(mq_array); - return; -} int stellar_packet_mq_create_topic(struct stellar *st, const char *topic_name, packet_msg_free_cb_func *msg_free_cb, void *msg_free_arg) { @@ -753,7 +725,7 @@ int packet_mq_publish_message(struct packet *pkt, int topic_id, void *msg) struct plugin_manager_schema *plug_mgr = stellar_plugin_manager_schema_get(st); assert(plug_mgr); int tid = stellar_get_current_thread_id(st); - return stellar_mq_publish_message(topic_id, msg, plug_mgr->packet_mq_schema_array, &(plug_mgr->per_thread_data->per_thread_pkt_mq_array+tid)->mq); + return stellar_mq_publish_message(topic_id, msg, plug_mgr->packet_mq_schema_array, &((plug_mgr->per_thread_data+tid)->per_thread_pkt_mq_array.mq)); } static void plugin_manager_packet_message_dispatch(struct packet *pkt) @@ -768,7 +740,7 @@ static void plugin_manager_packet_message_dispatch(struct packet *pkt) int tid = stellar_get_current_thread_id(st); - struct stellar_message **mq= &(plug_mgr->per_thread_data->per_thread_pkt_mq_array+tid)->mq; + struct stellar_message **mq= &((plug_mgr->per_thread_data+tid)->per_thread_pkt_mq_array.mq); struct stellar_message *mq_elt=NULL, *mq_tmp=NULL; struct stellar_mq_subscriber *sub_elt, *sub_tmp; diff --git a/src/stellar_on_sapp/stellar_on_sapp_api.c b/src/stellar_on_sapp/stellar_on_sapp_api.c index b40a246..ed10683 100644 --- a/src/stellar_on_sapp/stellar_on_sapp_api.c +++ b/src/stellar_on_sapp/stellar_on_sapp_api.c @@ -49,7 +49,6 @@ inline struct plugin_manager_schema * stellar_plugin_manager_schema_get(struct s inline int stellar_plugin_manager_schema_set(struct stellar *st, struct plugin_manager_schema *pm) { - if(st->plug_mgr)return -1; st->plug_mgr=pm; return 0; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7d3c6b9..a6e54d7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,2 +1 @@ add_subdirectory(plugin_manager) -#add_subdirectory(http_decoder) diff --git a/test/http_decoder/CMakeLists.txt b/test/http_decoder/CMakeLists.txt deleted file mode 100644 index 9bfc7ee..0000000 --- a/test/http_decoder/CMakeLists.txt +++ /dev/null @@ -1,134 +0,0 @@ -set(DECODER_NAME http_decoder) - -add_library(${DECODER_NAME}_test SHARED http_decoder_gtest.cpp) -add_dependencies(${DECODER_NAME}_test ${DECODER_NAME}) -target_link_libraries(${DECODER_NAME}_test MESA_prof_load cjson) -set_target_properties(${DECODER_NAME}_test PROPERTIES PREFIX "") - -set(TEST_RUN_DIR ${CMAKE_CURRENT_BINARY_DIR}/sapp) -set(TEST_MAIN ${TEST_RUN_DIR}/plugin_test_main) - -# assemble test env -add_test(NAME INSTALL_TEST_MAIN COMMAND sh -c "rpm -i ${CMAKE_CURRENT_SOURCE_DIR}/test_env/sapp4.el8.x86_64.rpm --prefix=${CMAKE_CURRENT_BINARY_DIR}/sapp --force --nodeps") - -add_test(NAME COPY_TEST_MAIN COMMAND sh -c "cp ${TEST_RUN_DIR}/tools/plugin_test_main ${TEST_RUN_DIR}/plugin_test_main") -add_test(NAME COPY_CONF COMMAND sh -c "mkdir -p ${TEST_RUN_DIR}/tsgconf/ && cp ${CMAKE_CURRENT_SOURCE_DIR}/test_env/tsg_l7_protocol.conf ${TEST_RUN_DIR}/tsgconf/tsg_l7_protocol.conf") -add_test(NAME COPY_SPEC COMMAND sh -c "mkdir -p ${TEST_RUN_DIR}/stellar_plugin/ && cp ${CMAKE_CURRENT_SOURCE_DIR}/test_env/spec.toml ${TEST_RUN_DIR}/stellar_plugin/spec.toml") -add_test(NAME COPY_CONFLIST COMMAND sh -c "mkdir -p ${TEST_RUN_DIR}/plug/ && cp ${CMAKE_CURRENT_SOURCE_DIR}/test_env/conflist.inf ${TEST_RUN_DIR}/plug/conflist.inf") -add_test(NAME COPY_INF COMMAND sh -c "mkdir -p ${TEST_RUN_DIR}/plug/stellar_on_sapp && cp ${CMAKE_CURRENT_SOURCE_DIR}/test_env/start_loader.inf ${TEST_RUN_DIR}/plug/stellar_on_sapp/start_loader.inf") - -# update config files -add_test(NAME UPDATE_SAPP_LOG COMMAND bash -c "sed -i 's/sapp_log.fatal/sapp_log.info/' ${TEST_RUN_DIR}/etc/sapp_log.conf") -add_test(NAME UPDATE_SAPP_SYN_MODE COMMAND bash -c "sed -i 's/syn_mandatory=1/syn_mandatory=0/' ${TEST_RUN_DIR}/etc/sapp.toml") -add_test(NAME UPDATE_SAPP_REORDER COMMAND bash -c "sed -i 's/reorder_pkt_max=32/reorder_pkt_max=5/' ${TEST_RUN_DIR}/etc/sapp.toml") - - -# update plugin to be tested -add_test(NAME UPDATE_STELLAR_ON_SAPP_SO COMMAND sh -c "cp ${CMAKE_BINARY_DIR}/src/stellar_on_sapp/stellar_on_sapp.so ${TEST_RUN_DIR}/plug/stellar_on_sapp/stellar_on_sapp.so") -add_test(NAME UPDATE_PLUG_SO COMMAND sh -c "cp ${CMAKE_BINARY_DIR}/src/${DECODER_NAME}/${DECODER_NAME}.so ${TEST_RUN_DIR}/stellar_plugin/${DECODER_NAME}.so") -add_test(NAME UPDATE_TEST_SO COMMAND sh -c "cp ${CMAKE_CURRENT_BINARY_DIR}/${DECODER_NAME}_test.so ${TEST_RUN_DIR}/stellar_plugin/${DECODER_NAME}_test.so") - -set_tests_properties(INSTALL_TEST_MAIN COPY_TEST_MAIN COPY_CONF COPY_SPEC COPY_CONFLIST COPY_INF - UPDATE_SAPP_LOG UPDATE_SAPP_SYN_MODE UPDATE_SAPP_REORDER - UPDATE_STELLAR_ON_SAPP_SO UPDATE_PLUG_SO UPDATE_TEST_SO - PROPERTIES FIXTURES_SETUP TestFixture) - -# run tests -add_test(NAME HTTP_GET_SINGLE_TRANS_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_get_single_trans.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_get_single_trans.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_GET_MULTI_TRANS_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_get_multi_trans.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_get_multi_trans.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_GET_LONG_COOKIE_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_get_long_cookie.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_get_long_cookie.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_GET_ENCODED_URI_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_get_encoded_uri.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_get_encoded_uri.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_RES_GZIP_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_res_gzip.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_res_gzip.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_CHUNKED_RES_GZIP_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_chunked_res_gzip.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_chunked_res_gzip.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_OVER_TCP_KEEPALIVE_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_over_tcp_keepalive.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_over_tcp_keepalive.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_TUNNEL_FOR_POP3_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_tunnel_for_pop3.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_tunnel_for_pop3.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_OVER_PPPOE_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_over_pppoe.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_over_pppoe.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_OVER_TLS_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_over_tls.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_over_tls.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME NON_HTTP_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/non_http.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name non_http.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_REQ_1BYTE_SLIDING_WINDOW_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_req_1byte_sliding_window.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_req_1byte_sliding_window.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_RES_1BYTE_SLIDING_WINDOW_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_res_1byte_sliding_window.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_res_1byte_sliding_window.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_NO_CONTENT_LENGTH_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_no_content_length.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_no_content_length.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_POST_MULTIPART_FORM_DATA_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_post_multipart_form_data.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_post_multipart_form_data.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_HEADERS_EXCEED_MAXIMUM_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_headers_exceed_maximum.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_headers_exceed_maximum.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_CONNECT_FLOOD_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_connect_flood.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_connect_flood.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_GET_MALFORMED_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_get_malformed.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_get_malformed.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_HEADER_VALUE_EMPTY_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_header_value_empty.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_header_value_empty.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_UPGRADE_WEBSOCKET_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_upgrade_websocket.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_upgrade_websocket.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_UPGRADE_HTTP2_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_upgrade_http2.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_upgrade_http2.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_MULTI_PARSE_ERROR_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_multi_parse_error.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_multi_parse_error.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_GET_REQ_PIPELINE_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_get_req_pipeline.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_get_req_pipeline.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - -add_test(NAME HTTP_TRANS_PIPELINE_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_trans_pipeline.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_trans_pipeline.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - - -set_tests_properties(HTTP_GET_SINGLE_TRANS_TEST - HTTP_GET_MULTI_TRANS_TEST - HTTP_GET_LONG_COOKIE_TEST - HTTP_GET_ENCODED_URI_TEST - HTTP_RES_GZIP_TEST - HTTP_CHUNKED_RES_GZIP_TEST - HTTP_OVER_TCP_KEEPALIVE_TEST - HTTP_TUNNEL_FOR_POP3_TEST - HTTP_OVER_PPPOE_TEST - HTTP_OVER_TLS_TEST - NON_HTTP_TEST - HTTP_REQ_1BYTE_SLIDING_WINDOW_TEST - HTTP_RES_1BYTE_SLIDING_WINDOW_TEST - HTTP_NO_CONTENT_LENGTH_TEST - HTTP_POST_MULTIPART_FORM_DATA_TEST - HTTP_HEADERS_EXCEED_MAXIMUM_TEST - HTTP_CONNECT_FLOOD_TEST - HTTP_GET_MALFORMED_TEST - HTTP_HEADER_VALUE_EMPTY_TEST - HTTP_MULTI_PARSE_ERROR_TEST - HTTP_UPGRADE_WEBSOCKET_TEST - HTTP_UPGRADE_HTTP2_TEST - HTTP_GET_REQ_PIPELINE_TEST - HTTP_TRANS_PIPELINE_TEST - PROPERTIES FIXTURES_REQUIRED TestFixture)
\ No newline at end of file diff --git a/test/http_decoder/http_decoder_gtest.cpp b/test/http_decoder/http_decoder_gtest.cpp deleted file mode 100644 index 852844e..0000000 --- a/test/http_decoder/http_decoder_gtest.cpp +++ /dev/null @@ -1,303 +0,0 @@ -/* -********************************************************************************************** -* File: http_decoder_gtest.cpp -* Description: -* Authors: Liu WenTan <[email protected]> -* Date: 2023-12-15 -* Copyright: (c) Since 2023 Geedge Networks, Ltd. All rights reserved. -*********************************************************************************************** -*/ - -#include <stdio.h> -#include <time.h> -#include <unistd.h> -#include <assert.h> -#include <string.h> - -#include "../../src/http_decoder/http_decoder.h" - -#ifdef __cplusplus -extern "C" -{ - -#include "cJSON.h" - -#include "stellar/utils.h" -#include "stellar/stellar.h" -#include "stellar/session_exdata.h" -#include "stellar/session_mq.h" - -int commit_test_result_json(cJSON *node, const char *name); -} -#endif - -#define MAX_KEY_STR_LEN 2048 - -static int g_result_count = 1; -int g_header_count = 1; -int g_req_exdata_idx = 0; -int g_res_exdata_idx = 0; -int g_topic_id = 0; - - -#if 1 -void output_http_req_line(struct http_request_line *req_line) -{ - char tmp_str[MAX_KEY_STR_LEN] = {0}; - snprintf(tmp_str, req_line->method.str_len + 1, "%s", req_line->method.str); - printf("req_method:%s\n", tmp_str); - - memset(tmp_str, 0, sizeof(tmp_str)); - snprintf(tmp_str, req_line->uri.str_len + 1, "%s", req_line->uri.str); - printf("req_uri:%s\n", tmp_str); - - memset(tmp_str, 0, sizeof(tmp_str)); - snprintf(tmp_str, req_line->version.str_len + 1, "%s", req_line->version.str); - printf("req_version:%s\n", tmp_str); -} - -void output_http_res_line(struct http_response_line *res_line) -{ - char tmp_str[MAX_KEY_STR_LEN] = {0}; - snprintf(tmp_str, res_line->version.str_len + 1, "%s", res_line->version.str); - printf("res_version:%s\n", tmp_str); - - memset(tmp_str, 0, sizeof(tmp_str)); - snprintf(tmp_str, res_line->status.str_len + 1, "%s", res_line->status.str); - printf("res_status:%s\n", tmp_str); -} - -void output_http_header(struct http_header *header) -{ - printf("<%s:%s>\n", header->key.str, header->val.str); -} -#endif - -void -output_http_body(struct hstring *body, int decompress_flag) -{ - int counter = 0; - - if (1 == decompress_flag) { - printf("\n\n----------------decompress body len:%zu---------------\n", - body->str_len); - } else { - printf("\n\n----------------raw body len:%zu---------------\n", - body->str_len); - } - - for (size_t i = 0; i < body->str_len; i++) { - if (counter % 16 == 0) { - printf("\n"); - } - printf("%02x ", (unsigned char)body->str[i]); - counter++; - } - printf("\n"); -} - -int -http_field_to_json(cJSON *object, const char *key, char *val, size_t val_len) -{ - if (NULL == object || NULL == key || NULL == val || 0 == val_len) { - return -1; - } - - char *tmp = CALLOC(char, val_len + 1); - memcpy(tmp, val, val_len); - cJSON_AddStringToObject(object, key, tmp); - FREE(tmp); - - return 0; -} - -void -req_line_to_json(cJSON *ctx, struct http_request_line *req_line) -{ - http_field_to_json(ctx, "method", req_line->method.str, - req_line->method.str_len); - http_field_to_json(ctx, "uri", req_line->uri.str, req_line->uri.str_len); - http_field_to_json(ctx, "req_version", req_line->version.str, - req_line->version.str_len); - - cJSON_AddNumberToObject(ctx, "major_version", req_line->major_version); - cJSON_AddNumberToObject(ctx, "minor_version", req_line->minor_version); -} - -void -res_line_to_json(cJSON *ctx, struct http_response_line *res_line) -{ - http_field_to_json(ctx, "res_version", res_line->version.str, - res_line->version.str_len); - http_field_to_json(ctx, "res_status", res_line->status.str, - res_line->status.str_len); - - cJSON_AddNumberToObject(ctx, "major_version", res_line->major_version); - cJSON_AddNumberToObject(ctx, "minor_version", res_line->minor_version); - cJSON_AddNumberToObject(ctx, "status_code", res_line->status_code); -} - -void -http_header_to_json(cJSON *ctx, struct http_header *header) -{ - char key[MAX_KEY_STR_LEN] = {0}; - - memcpy(key, header->key.str, header->key.str_len); - - if (cJSON_HasObjectItem(ctx, key) == FALSE) { - http_field_to_json(ctx, key, header->val.str, header->val.str_len); - } else { - //ctx already has the key, so rename key by key%d - char new_key[MAX_KEY_STR_LEN] = {0}; - sprintf(new_key, "%s%d", key, g_header_count++); - http_field_to_json(ctx, new_key, header->val.str, header->val.str_len); - } -} - -static int -http_decoder_test_entry(struct session *sess, int topic_id, const void *data, - void *cb_arg) -{ - int exdata_idx = 0; - struct http_request_line req_line = {0}; - struct http_response_line res_line = {0}; - struct http_header header = {0}; - struct hstring body = {0}; - struct http_message *msg = (struct http_message *)data; - enum http_message_type msg_type = http_message_type(msg); - - if (msg_type == HTTP_MESSAGE_REQ_LINE || - msg_type == HTTP_MESSAGE_REQ_HEADER) { - exdata_idx = g_req_exdata_idx; - } else { - exdata_idx = g_res_exdata_idx; - } - - cJSON *json = (cJSON *)session_get_ex_data(sess, exdata_idx); - - if (msg_type == HTTP_MESSAGE_REQ_BODY || - msg_type == HTTP_MESSAGE_RES_BODY) { - goto next; - } - - if (NULL == json) { - json = cJSON_CreateObject(); - cJSON_AddStringToObject(json, "Tuple4", session_get0_readable_addr(sess)); - session_set_ex_data(sess, exdata_idx, json); - } - -next: - switch (msg_type) { - case HTTP_MESSAGE_REQ_LINE: - http_message_get_request_line(msg, &req_line); - req_line_to_json(json, &req_line); - break; - case HTTP_MESSAGE_REQ_HEADER: - while (http_message_request_header_next(msg, &header) > 0) { - http_header_to_json(json, &header); - // output_http_header(&header); - } - g_header_count = 1; - break; - case HTTP_MESSAGE_REQ_BODY: - http_message_get_request_raw_body(msg, &body); - // output_http_body(&body, 0); - - http_message_get_request_decompress_body(msg, &body); - // output_http_body(&body, 1); - break; - case HTTP_MESSAGE_RES_LINE: - http_message_get_response_line(msg, &res_line); - res_line_to_json(json, &res_line); - break; - case HTTP_MESSAGE_RES_HEADER: - while (http_message_response_header_next(msg, &header) > 0) { - http_header_to_json(json, &header); - // output_http_header(&header); - } - g_header_count = 1; - break; - case HTTP_MESSAGE_RES_BODY: - http_message_get_response_raw_body(msg, &body); - // output_http_body(&body, 0); - - http_message_get_response_decompress_body(msg, &body); - // output_http_body(&body, 1); - break; - default: - break; - } - - char result_name[MAX_KEY_STR_LEN] = {0}; - if (msg_type == HTTP_MESSAGE_REQ_HEADER) { - sprintf(result_name, "HTTP_DECODER_RESULT_%d", g_result_count); - commit_test_result_json(json, result_name); - // printf("req json:%s\n", cJSON_Print(ctx)); - session_set_ex_data(sess, exdata_idx, NULL); - g_result_count++; - } - - if (msg_type == HTTP_MESSAGE_RES_HEADER) { - sprintf(result_name, "HTTP_DECODER_RESULT_%d", g_result_count); - commit_test_result_json(json, result_name); - // printf("res json:%s\n", cJSON_Print(ctx)); - session_set_ex_data(sess, exdata_idx, NULL); - g_result_count++; - } - - return 0; -} - -void -http_decoder_test_exdata_free(struct session *sess, int idx, void *ex_ptr, - void *arg) -{ - if (ex_ptr != NULL) { - cJSON_Delete((cJSON *)ex_ptr); - } -} - -extern "C" void *http_decoder_test_init(struct stellar *st) -{ - g_req_exdata_idx = - stellar_session_get_ex_new_index(st, "HTTP_DECODER_REQ_TEST", - http_decoder_test_exdata_free, - NULL); - if (g_req_exdata_idx < 0) { - printf("[%s:%d]: can't get http_decoder req exdata index !!!\n", - __FUNCTION__, __LINE__); - exit(-1); - } - - g_res_exdata_idx = - stellar_session_get_ex_new_index(st, "HTTP_DECODER_RES_TEST", - http_decoder_test_exdata_free, - NULL); - if (g_res_exdata_idx < 0) { - printf("[%s:%d]: can't get http_decoder res exdata index !!!\n", - __FUNCTION__, __LINE__); - exit(-1); - } - - g_topic_id = session_mq_get_topic_id(st, "HTTP_DECODER_MESSAGE"); - if (g_topic_id < 0) { - printf("[%s:%d]: can't get http_decoder topic id !!!\n", - __FUNCTION__, __LINE__); - exit(-1); - } - - session_mq_subscribe_topic(st, g_topic_id, http_decoder_test_entry, NULL); - printf("http_decoder_test_init OK!\n"); - - return NULL; - -} - -extern "C" void http_decoder_test_exit(void *test_ctx) -{ - if (test_ctx != NULL) { - FREE(test_ctx); - } - - printf("http_decoder_test_exit OK!\n"); -}
\ No newline at end of file diff --git a/test/http_decoder/http_pcap/http_chunked_res_gzip.pcap b/test/http_decoder/http_pcap/http_chunked_res_gzip.pcap Binary files differdeleted file mode 100644 index fa237fb..0000000 --- a/test/http_decoder/http_pcap/http_chunked_res_gzip.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_connect_flood.pcap b/test/http_decoder/http_pcap/http_connect_flood.pcap Binary files differdeleted file mode 100644 index 11b7e14..0000000 --- a/test/http_decoder/http_pcap/http_connect_flood.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_get_encoded_uri.pcap b/test/http_decoder/http_pcap/http_get_encoded_uri.pcap Binary files differdeleted file mode 100644 index 633b50b..0000000 --- a/test/http_decoder/http_pcap/http_get_encoded_uri.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_get_long_cookie.pcap b/test/http_decoder/http_pcap/http_get_long_cookie.pcap Binary files differdeleted file mode 100644 index 8857615..0000000 --- a/test/http_decoder/http_pcap/http_get_long_cookie.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_get_malformed.pcap b/test/http_decoder/http_pcap/http_get_malformed.pcap Binary files differdeleted file mode 100644 index cfe16d9..0000000 --- a/test/http_decoder/http_pcap/http_get_malformed.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_get_multi_trans.pcap b/test/http_decoder/http_pcap/http_get_multi_trans.pcap Binary files differdeleted file mode 100644 index 9c0d2e7..0000000 --- a/test/http_decoder/http_pcap/http_get_multi_trans.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_get_req_pipeline.pcap b/test/http_decoder/http_pcap/http_get_req_pipeline.pcap Binary files differdeleted file mode 100644 index f805493..0000000 --- a/test/http_decoder/http_pcap/http_get_req_pipeline.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_get_single_trans.pcap b/test/http_decoder/http_pcap/http_get_single_trans.pcap Binary files differdeleted file mode 100644 index a4b6bea..0000000 --- a/test/http_decoder/http_pcap/http_get_single_trans.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_header_value_empty.pcap b/test/http_decoder/http_pcap/http_header_value_empty.pcap Binary files differdeleted file mode 100644 index 138f905..0000000 --- a/test/http_decoder/http_pcap/http_header_value_empty.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_headers_exceed_maximum.pcap b/test/http_decoder/http_pcap/http_headers_exceed_maximum.pcap Binary files differdeleted file mode 100644 index 537bffa..0000000 --- a/test/http_decoder/http_pcap/http_headers_exceed_maximum.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_multi_parse_error.pcap b/test/http_decoder/http_pcap/http_multi_parse_error.pcap Binary files differdeleted file mode 100644 index 0dca059..0000000 --- a/test/http_decoder/http_pcap/http_multi_parse_error.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_no_content_length.pcap b/test/http_decoder/http_pcap/http_no_content_length.pcap Binary files differdeleted file mode 100644 index 28e6881..0000000 --- a/test/http_decoder/http_pcap/http_no_content_length.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_over_pppoe.pcap b/test/http_decoder/http_pcap/http_over_pppoe.pcap Binary files differdeleted file mode 100644 index a6587cb..0000000 --- a/test/http_decoder/http_pcap/http_over_pppoe.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_over_tcp_keepalive.pcap b/test/http_decoder/http_pcap/http_over_tcp_keepalive.pcap Binary files differdeleted file mode 100644 index 5b2db18..0000000 --- a/test/http_decoder/http_pcap/http_over_tcp_keepalive.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_over_tls.pcap b/test/http_decoder/http_pcap/http_over_tls.pcap Binary files differdeleted file mode 100644 index 71c557e..0000000 --- a/test/http_decoder/http_pcap/http_over_tls.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_post_multipart_form_data.pcap b/test/http_decoder/http_pcap/http_post_multipart_form_data.pcap Binary files differdeleted file mode 100644 index 0136e05..0000000 --- a/test/http_decoder/http_pcap/http_post_multipart_form_data.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_req_1byte_sliding_window.pcap b/test/http_decoder/http_pcap/http_req_1byte_sliding_window.pcap Binary files differdeleted file mode 100644 index 632c676..0000000 --- a/test/http_decoder/http_pcap/http_req_1byte_sliding_window.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_res_1byte_sliding_window.pcap b/test/http_decoder/http_pcap/http_res_1byte_sliding_window.pcap Binary files differdeleted file mode 100644 index 6d1d6a4..0000000 --- a/test/http_decoder/http_pcap/http_res_1byte_sliding_window.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_res_gzip.pcap b/test/http_decoder/http_pcap/http_res_gzip.pcap Binary files differdeleted file mode 100644 index 04b9998..0000000 --- a/test/http_decoder/http_pcap/http_res_gzip.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_trans_pipeline.pcap b/test/http_decoder/http_pcap/http_trans_pipeline.pcap Binary files differdeleted file mode 100644 index 9d4aa1a..0000000 --- a/test/http_decoder/http_pcap/http_trans_pipeline.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_tunnel_for_pop3.pcap b/test/http_decoder/http_pcap/http_tunnel_for_pop3.pcap Binary files differdeleted file mode 100644 index 6df9669..0000000 --- a/test/http_decoder/http_pcap/http_tunnel_for_pop3.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_upgrade_http2.pcap b/test/http_decoder/http_pcap/http_upgrade_http2.pcap Binary files differdeleted file mode 100644 index a77847a..0000000 --- a/test/http_decoder/http_pcap/http_upgrade_http2.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/http_upgrade_websocket.pcap b/test/http_decoder/http_pcap/http_upgrade_websocket.pcap Binary files differdeleted file mode 100644 index e1ac4d0..0000000 --- a/test/http_decoder/http_pcap/http_upgrade_websocket.pcap +++ /dev/null diff --git a/test/http_decoder/http_pcap/non_http.pcap b/test/http_decoder/http_pcap/non_http.pcap Binary files differdeleted file mode 100644 index 931b43b..0000000 --- a/test/http_decoder/http_pcap/non_http.pcap +++ /dev/null diff --git a/test/http_decoder/test_env/conflist.inf b/test/http_decoder/test_env/conflist.inf deleted file mode 100644 index 2e8144d..0000000 --- a/test/http_decoder/test_env/conflist.inf +++ /dev/null @@ -1,9 +0,0 @@ -[platform] -./plug/stellar_on_sapp/start_loader.inf - - -[protocol] - - -[business] -#./plug/stellar_on_sapp/defer_loader.inf diff --git a/test/http_decoder/test_env/sapp4.el8.x86_64.rpm b/test/http_decoder/test_env/sapp4.el8.x86_64.rpm Binary files differdeleted file mode 100644 index e43fe2f..0000000 --- a/test/http_decoder/test_env/sapp4.el8.x86_64.rpm +++ /dev/null diff --git a/test/http_decoder/test_env/spec.toml b/test/http_decoder/test_env/spec.toml deleted file mode 100644 index 626f85b..0000000 --- a/test/http_decoder/test_env/spec.toml +++ /dev/null @@ -1,11 +0,0 @@ -# stellar_plugin.toml -# -[[plugin]] -path = "./stellar_plugin/http_decoder.so" -init = "http_decoder_init" -exit = "http_decoder_exit" - -[[plugin]] -path = "./stellar_plugin/http_decoder_test.so" -init = "http_decoder_test_init" -exit = "http_decoder_test_exit" diff --git a/test/http_decoder/test_env/start_loader.inf b/test/http_decoder/test_env/start_loader.inf deleted file mode 100644 index 89b2f94..0000000 --- a/test/http_decoder/test_env/start_loader.inf +++ /dev/null @@ -1,17 +0,0 @@ -[PLUGINFO] -PLUGNAME=stellar_start_loader -SO_PATH=./plug/stellar_on_sapp/stellar_on_sapp.so -INIT_FUNC=STELLAR_START_LOADER_INIT -DESTROY_FUNC=STELLAR_START_LOADER_EXIT - -#[TCP_ALL] -#FUNC_FLAG=ALL -#FUNC_NAME=stellar_on_sapp_tcpall_entry - -[TCP] -FUNC_FLAG=ALL -FUNC_NAME=stellar_on_sapp_tcp_entry - -[UDP] -FUNC_FLAG=ALL -FUNC_NAME=stellar_on_sapp_udp_entry
\ No newline at end of file diff --git a/test/http_decoder/test_env/tsg_l7_protocol.conf b/test/http_decoder/test_env/tsg_l7_protocol.conf deleted file mode 100644 index 1075a8f..0000000 --- a/test/http_decoder/test_env/tsg_l7_protocol.conf +++ /dev/null @@ -1,57 +0,0 @@ -#TYPE:1:UCHAR,2:USHORT,3:USTRING,4:ULOG,5:USTRING,6:FILE,7:UBASE64,8:PACKET -#TYPE FIELD VALUE -STRING UNCATEGORIZED 8000 -#STRING UNCATEGORIZED 8001 -#STRING UNKNOWN_OTHER 8002 -STRING DNS 32 -STRING FTP 45 -STRING FTPS 751 -STRING HTTP 67 -STRING HTTPS 68 -STRING ICMP 70 -STRING IKE 8003 -STRING MAIL 8004 -STRING IMAP 75 -STRING IMAPS 76 -STRING IPSEC 85 -STRING XMPP 94 -STRING L2TP 98 -STRING NTP 137 -STRING POP3 147 -STRING POP3S 148 -STRING PPTP 153 -STRING QUIC 2521 -STRING SIP 182 -STRING SMB 185 -STRING SMTP 186 -STRING SMTPS 187 -STRING SPDY 1469 -STRING SSH 198 -STRING SSL 199 -STRING SOCKS 8005 -STRING TELNET 209 -STRING DHCP 29 -STRING RADIUS 158 -STRING OPENVPN 336 -STRING STUN 201 -STRING TEREDO 555 -STRING DTLS 1291 -STRING DoH 8006 -STRING ISAKMP 92 -STRING MDNS 3835 -STRING NETBIOS 129 -STRING NETFLOW 130 -STRING RDP 150 -STRING RTCP 174 -STRING RTP 175 -STRING SLP 8007 -STRING SNMP 190 -STRING SSDP 197 -STRING TFTP 211 -STRING BJNP 2481 -STRING LDAP 100 -STRING RTMP 337 -STRING RTSP 176 -STRING ESNI 8008 -STRING QQ 156 -STRING WeChat 1296 diff --git a/test/http_decoder/test_result_json/http_chunked_res_gzip.json b/test/http_decoder/test_result_json/http_chunked_res_gzip.json deleted file mode 100644 index 3fe64ca..0000000 --- a/test/http_decoder/test_result_json/http_chunked_res_gzip.json +++ /dev/null @@ -1,40 +0,0 @@ -[ - { - "Tuple4": "127.0.0.1.33412>127.0.0.1.8080", - "method": "GET", - "uri": "/", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "www.wireshark.org:8080", - "User-Agent": "curl/7.46.0", - "Accept": "*/*", - "Connection": "close", - "Accept-Encoding": "chunked, gzip", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "127.0.0.1.33412>127.0.0.1.8080", - "res_version": "1.1", - "res_status": "OK", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Server": "cloudflare-nginx", - "Date": "Wed, 06 Jan 2016 20:42:10 GMT", - "Content-Type": "text/html", - "Transfer-Encoding": "chunked", - "Connection": "close", - "Set-Cookie": "__cfduid=d8d37b52eaa3137bdfd7fd67a4ffc8a7a1452112929; expires=Thu, 05-Jan-17 20:42:09 GMT; path=/; domain=.wireshark.org; HttpOnly", - "X-Frame-Options": "SAMEORIGIN", - "Strict-Transport-Security": "max-age=31536000;", - "X-Slogan": "It's a great product with a great story to tell. I'm pumped!", - "X-Mod-Pagespeed": "1.9.32.11-7550", - "Vary": "Accept-Encoding", - "Cache-control": "max-age=0, no-cache, no-store", - "X-Slogan1": "Go deep.", - "CF-RAY": "260a3f709d7b0761-AMS", - "Content-Encoding": "gzip", - "name": "HTTP_DECODER_RESULT_2" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_connect_flood.json b/test/http_decoder/test_result_json/http_connect_flood.json deleted file mode 100644 index 199c038..0000000 --- a/test/http_decoder/test_result_json/http_connect_flood.json +++ /dev/null @@ -1,686 +0,0 @@ -[ - { - "Tuple4": "10.128.0.2.18762>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20110929 Iceweasel/3.5.16", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "10.128.0.2.18746>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:38 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_2" - }, - { - "Tuple4": "10.128.0.2.18744>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:38 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_3" - }, - { - "Tuple4": "10.128.0.2.18748>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:38 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_4" - }, - { - "Tuple4": "10.128.0.2.18750>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:38 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_5" - }, - { - "Tuple4": "10.128.0.2.18752>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:38 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_6" - }, - { - "Tuple4": "10.128.0.2.18754>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:38 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_7" - }, - { - "Tuple4": "10.128.0.2.18756>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:38 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_8" - }, - { - "Tuple4": "10.128.0.2.18758>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:38 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_9" - }, - { - "Tuple4": "10.128.0.2.18760>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:38 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_10" - }, - { - "Tuple4": "10.128.0.2.18762>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:38 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_11" - }, - { - "Tuple4": "10.128.0.2.18768>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "Safari/5.00 (Macintosh; U; en)", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_12" - }, - { - "Tuple4": "10.128.0.2.18766>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_13" - }, - { - "Tuple4": "10.128.0.2.18770>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "Opera/9.00 (Windows NT 5.1; U; en)", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_14" - }, - { - "Tuple4": "10.128.0.2.18772>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "Opera/9.00 (Windows NT 5.1; U; en)", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_15" - }, - { - "Tuple4": "10.128.0.2.18776>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "GooglePocket/2.1 ( http://www.googlePocket.com/Pocket.html)", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_16" - }, - { - "Tuple4": "10.128.0.2.18774>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.4.0", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_17" - }, - { - "Tuple4": "10.128.0.2.18780>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20030505 Mozilla Firebird/0.6", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_18" - }, - { - "Tuple4": "10.128.0.2.18778>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "DoCoMo/2.0 SH902i (compatible; Y!J-SRD/1.0; http://help.yahoo.co.jp/help/jp/search/indexing/indexing-27.html)", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_19" - }, - { - "Tuple4": "10.128.0.2.18782>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "IE/5.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322;)", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_20" - }, - { - "Tuple4": "10.128.0.2.18784>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20110929 Iceweasel/3.5.16", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_21" - }, - { - "Tuple4": "10.128.0.2.18768>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:39 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_22" - }, - { - "Tuple4": "10.128.0.2.18766>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:39 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_23" - }, - { - "Tuple4": "10.128.0.2.18770>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:39 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_24" - }, - { - "Tuple4": "10.128.0.2.18772>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:39 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_25" - }, - { - "Tuple4": "10.128.0.2.18776>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:39 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_26" - }, - { - "Tuple4": "10.128.0.2.18780>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:39 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_27" - }, - { - "Tuple4": "10.128.0.2.18774>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:39 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_28" - }, - { - "Tuple4": "10.128.0.2.18778>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:39 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_29" - }, - { - "Tuple4": "10.128.0.2.18782>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:39 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_30" - }, - { - "Tuple4": "10.128.0.2.18784>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:39 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_31" - }, - { - "Tuple4": "10.128.0.2.18790>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "Safari/5.00 (Macintosh; U; en)", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_32" - }, - { - "Tuple4": "10.128.0.2.18792>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_33" - }, - { - "Tuple4": "10.128.0.2.18796>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "Opera/9.00 (Windows NT 5.1; U; en)", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_34" - }, - { - "Tuple4": "10.128.0.2.18794>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "Opera/9.00 (Windows NT 5.1; U; en)", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_35" - }, - { - "Tuple4": "10.128.0.2.18798>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "GooglePocket/2.1 ( http://www.googlePocket.com/Pocket.html)", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_36" - }, - { - "Tuple4": "10.128.0.2.18800>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20030505 Mozilla Firebird/0.6", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_37" - }, - { - "Tuple4": "10.128.0.2.18804>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "DoCoMo/2.0 SH902i (compatible; Y!J-SRD/1.0; http://help.yahoo.co.jp/help/jp/search/indexing/indexing-27.html)", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_38" - }, - { - "Tuple4": "10.128.0.2.18802>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.4.0", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_39" - }, - { - "Tuple4": "10.128.0.2.18806>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "IE/5.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322;)", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_40" - }, - { - "Tuple4": "10.128.0.2.18808>10.0.0.2.80", - "method": "CONNECT", - "uri": "test.mazebolt.com:80", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.mazebolt.com", - "User-Agent": "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20110929 Iceweasel/3.5.16", - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate", - "Content-Length": "0", - "name": "HTTP_DECODER_RESULT_41" - }, - { - "Tuple4": "10.128.0.2.18790>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:41 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_42" - }, - { - "Tuple4": "10.128.0.2.18792>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:41 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_43" - }, - { - "Tuple4": "10.128.0.2.18796>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:41 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_44" - }, - { - "Tuple4": "10.128.0.2.18798>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:41 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_45" - }, - { - "Tuple4": "10.128.0.2.18794>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:41 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_46" - }, - { - "Tuple4": "10.128.0.2.18800>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:41 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_47" - }, - { - "Tuple4": "10.128.0.2.18804>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:41 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_48" - }, - { - "Tuple4": "10.128.0.2.18802>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:41 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_49" - }, - { - "Tuple4": "10.128.0.2.18806>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:41 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_50" - }, - { - "Tuple4": "10.128.0.2.18808>10.0.0.2.80", - "res_version": "1.1", - "res_status": "Forbidden", - "major_version": 1, - "minor_version": 1, - "status_code": 403, - "Date": "Thu, 03 Sep 2020 10:26:41 GMT", - "Server": "Apache", - "Content-Length": "199", - "Content-Type": "text/html; charset=iso-8859-1", - "name": "HTTP_DECODER_RESULT_51" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_get_encoded_uri.json b/test/http_decoder/test_result_json/http_get_encoded_uri.json deleted file mode 100644 index 25a6362..0000000 --- a/test/http_decoder/test_result_json/http_get_encoded_uri.json +++ /dev/null @@ -1,71 +0,0 @@ -[ - { - "Tuple4": "192.168.117.60.39655>58.16.70.122.80", - "method": "POST", - "uri": "/disAll/tcCertType.html", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "User-Agent": "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36", - "Accept": "*/*", - "Accept-Language": "en-US,en;q=0.8,en-us,en;q=0.5", - "Origin": "http://58.16.70.122", - "X-Requested-With": "XMLHttpRequest", - "Referer": "http://58.16.70.122/register.jsp?redirect:http://58.16.70.122.r87.com/?", - "Cache-Control": "no-cache", - "X-Scanner": "Netsparker", - "Cookie": "JSESSIONID=385C79E211D561C0CA13D90F150F603D", - "Host": "58.16.70.122", - "Content-Length": "0", - "Accept-Encoding": "gzip, deflate", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "192.168.117.60.39655>58.16.70.122.80", - "res_version": "1.1", - "res_status": "OK", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Server": "Apache-Coyote/1.1", - "Pragma": "No-cache", - "Expires": "Thu, 01 Jan 1970 00:00:00 GMT", - "Content-Type": "text/html;charset=UTF-8", - "Transfer-Encoding": "chunked", - "Date": "Sat, 18 May 2019 01:36:57 GMT", - "name": "HTTP_DECODER_RESULT_2" - }, - { - "Tuple4": "192.168.117.60.39655>58.16.70.122.80", - "method": "GET", - "uri": "/upload/%E6%B3%95%E5%BE%8B%E6%B3%95%E8%A7%84/%E5%B8%82%E4%BA%BA%E6%B0%91%E6%94%BF%E5%BA%9C%E5%8A%9E%E5%85%AC%E5%8E%85%E5%8D%B0%E5%8F%91%E8%B4%B5%E9%98%B3%E5%B8%82%E5%85%B3%E4%BA%8E%E6%8E%A8%E8%BF%9B%E5%B7%A5%E5%95%86%E8%90%A5%E4%B8%9A%E6%89%A7%E7%85%A7%E3%80%81%E7%BB%84%E7%BB%87%E6%9C%BA%E6%9E%84%E4%BB%A3%E7%A0%81%E8%AF%81%E5%92%8C%E7%A8%8E%E5%8A%A1%E7%99%BB%E8%AE%B0%E8%AF%81%E2%80%9C%E4%B8%89%E8%AF%81%E5%90%88%E4%B8%80%E2%80%9D%E7%99%BB%E8%AE%B0%E5%88%B6%E5%BA%A6%E6%94%B9%E9%9D%A9%E5%AE%9E%E6%96%BD%E6%96%B9%E6%A1%88%E7%9A%84%E9%80%9A%E7%9F%A5%EF%BC%88%E7%AD%91%E5%BA%9C%E5%8A%9E%E5%87%BD%E3%80%902015%E3%80%91162%E5%8F%B7%EF%BC%89.docx?nsextt=N3TSP4RKE2", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", - "User-Agent": "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36", - "Cache-Control": "no-cache", - "Accept-Language": "en-us,en;q=0.5", - "X-Scanner": "Netsparker", - "Cookie": "JSESSIONID=385C79E211D561C0CA13D90F150F603D", - "Host": "58.16.70.122", - "Accept-Encoding": "gzip, deflate", - "name": "HTTP_DECODER_RESULT_3" - }, - { - "Tuple4": "192.168.117.60.39655>58.16.70.122.80", - "res_version": "1.1", - "res_status": "OK", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Server": "Apache-Coyote/1.1", - "Accept-Ranges": "bytes", - "ETag": "W/\"1703517-1546572172000\"", - "Last-Modified": "Fri, 04 Jan 2019 03:22:52 GMT", - "Content-Type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document;charset=UTF-8", - "Content-Length": "1703517", - "Date": "Sat, 18 May 2019 01:37:00 GMT", - "name": "HTTP_DECODER_RESULT_4" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_get_long_cookie.json b/test/http_decoder/test_result_json/http_get_long_cookie.json deleted file mode 100644 index de07582..0000000 --- a/test/http_decoder/test_result_json/http_get_long_cookie.json +++ /dev/null @@ -1,19 +0,0 @@ -[ - { - "Tuple4": "202.127.156.91.27282>14.17.32.203.80", - "method": "GET", - "uri": "/livemsg?imagemd5=02f5efd8a349c50280f8540b2735bd54&tailroll=1&plugin=1.3.8&pf=out&si=3766845706&url=http%3A%2F%2Fsports.qq.com%2Fa%2F20160106%2F008987.htm&soid=CA7F9C5B0120568CDC2F68726300&chid=0&ping_data=dXNlcl9pbmZvPXVCWDluVDg5SFJhOUFQK0JQVGdKRUxVYi9Kdz0&t=0&iptype=0&vptag=&pid=7F993E38C0E676ACC07DE764D1F3DEF56AA8F90A&adtype=LD&oadid=6012&ev=3236&l=4020&ufc_filter=0&imagelog=1&pid2=7F993E38C0E676ACC07DE764D1F3DEF56AA8F90A&mt=15000&coverid=&reqtime=1452071981&requestl=4020&isthirdip=0&cid=0&isfloatindex=0&o=100654557&lcount=2&refluence=4020&from=0&vid=m01794rm5ej&cip=202.127.156.91&aver=0&ip_filter=0&adlength=30000&tagid=&v=TencentPlayerOutV3.2.19.346&live=0&dura=105", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "livep.l.qq.com", - "Connection": "keep-alive", - "User-Agent": "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36", - "Accept": "*/*", - "Referer": "http://imgcache.qq.com/tencentvideo_v1/player/TPout.swf?max_age=86400&v=20140714", - "Accept-Encoding": "gzip,deflate,sdch", - "Accept-Language": "zh-CN,zh;q=0.8", - "Cookie": "flashuser=95621BA8CB862E09; piao_city=179; lv_irt_id=3628e1bbe25a6c941da9fac02ec2df8b; cm_cookie=V1,10017&-EP5mRruXhQarsCl5LD-2YzgjVTvyr2K&AQEBh7uoLMUB9lnaB5Tz9XdYnGIWflXmsDrU&150723&150723,10035&7t-tEmfJ076VAsM9&AQEBh7uoLMUB9lnc4tpW7vbazqdrRdBYOUCi&150724&150807,110054&ucO0Z0gctNn3&AQEBh7uoLMUB9llxMNl45F3RAIsKK0iMOJAG&150716&151008,10040&ACZ1r0A70NaEFcGT&AQEBh7uoLMUB9lmVgSoTwuuXZi896zSVsXIF&150818&151014,110015&1&AQEBh7uoLMUB9lkt2LUHO6ARwODHLI_Y51rj&150928&151103,10037&1433388364186289251984&AQEBh7uoLMUB9llIBencOqTAEh2aQ2SURSSQ&150909&151110,10011&jL40Z03uUFI0&AQEBh7uoLMUB9lkfw2sJVNx9g12Fzs12rPSN&150717&151125,10016&F64E6LFZs0W&AQEBh7uoLMUB9llE4yoPFNUykSj7WKaRK5lH&150805&151127,10019&WQAO-C1K9qI5OP8W_t2pSw&AQEBh7uoLMUB9llhpZE87GmOk3XGo_MJgV6K&150826&151130,10015&820490997316506147&AQEBh7uoLMUB9llXiynsGYRhMO3XuPnkuHUt&150715&151201,10012&x3X1yY6b&AQEBh7uoLMUB9ll9mraU_LJCDBYsE0Sbk_V9&151202&151202,110065&ucO0Z0gctNn3&AQEBh7uoLMUB9lkJcK3KDBQTKF0YfZ5wB7r5&150716&151203,110066&jL40Z03uUFI0&AQEBh7uoLMUB9lnyvKSYhcJD1X_rSs_DLVWx&150916&151221,10013&ePyYB2MSKa0TCbebpxKjmU&AQEBh7uoLMUB9ln6_6nGNidqml4nFKXhtE58&151221&151221,110061&d9cfa518d82abee&AQEBh7uoLMUB9llj2NYzmCjxaLWXALTcAGIH&150818&151224,10038&CAESEPZbUhToZJ39CS9MlgXGUSQ&AQEBh7uoLMUB9lmhnrDM5lIGtl6vc1NxMD6F&151110&151224,10077&820490997316506147&AQEBh7uoLMUB9lmkUdUe2xSHGkvM0IRu9Jt9&151214&151228,10008&0yPSvk92ie1nhB8wTUlTq&AQEBh7uoLMUB9lnL5ZCYvXJNvlv53G0CKEkj&150817&151228,10045&0&AQEBh7uoLMUB9llW3v1Vh7W72lv14RlAjUXn&151023&151228,110064&jL40Z03uUFI0&AQEBh7uoLMUB9lkBYuCUDLDrOcGURJcilogv&151016&160104,110069&26d49ecc&AQEBh7uoLMUB9lmlBLTxQY9BkCmimkMFqTo5&151204&160105,10079&B8hGto5y1e3uDXwCMsIun3rjk--dVCof&AQEBh7uoLMUB9llxnFrhDtdNMjZ1hs1il5J4&151214&160105; LHTturn=24; ptisp=ctc; RK=hRWyd82Gd8; pgv_pvi=7567882240; image_md5=bd21d5fb2f401b37cf3a02724dc06545; LTPturn=27; pt2gguin=o0583115900; uin=o0583115900; skey=@Mp9aCinaO; ptcz=10d4b1b7bde835d64663338a8008fd4f81e2c6b5f0ba81a90da3627ee617c7ee; pgv_info=ssid=s4768939310; pgv_pvid=6872592818; o_cookie=583115900; lv_play_index_textAd=47; lv_play_indexl.=32; dc_vplaying=1; LKBturn=29; Lturn=29; adid=583115900; appuser=95621BA8CB862E09; o_minduid=phhdxyNLkxBWMa74VTm5zU4y5EbUv5vR; appuser_95621BA8CB862E09_0=2b7gwp=1453219199_6&2btemv=1455551999_1&2c8311=1453305599_3&2cfx4j=1453651199_3&2cfx9l=1453651199_1&2d49y9=1453823999_2&2d67kl=1454255999_2&2d69mf=1454255999_3&2dxv8l=1455465599_6&2dzhfl=1452614399_1&f_pogvwp=1452095999_1&f_pogvwv=1452095999_2&f_pogw0m=1452095999_1&fd_15bm2t7=1452095999_1&fd_1h2pbsd=1452095999_2&fd_1k6so62=1452095999_1&fd_rhmjmq=1452095999_2&m_roiw0t=1452095999_3&m_xty8wl=1452095999_1&pogree=1452095999_2; TX.boid=100655474=1452072582_1&701041365=1452072585_1; appuser_95621BA8CB862E09_effect_0=fd_1ez2rcc=1452095999_1&fd_qdh7zw=1452095999_1&fd_ul215j=1452095999_1; psessionid=ca7f9c5b_1452071982_583115900_30754; psessiontime=1452071990", - "name": "HTTP_DECODER_RESULT_1" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_get_malformed.json b/test/http_decoder/test_result_json/http_get_malformed.json deleted file mode 100644 index 2cae230..0000000 --- a/test/http_decoder/test_result_json/http_get_malformed.json +++ /dev/null @@ -1,38 +0,0 @@ -[ - { - "Tuple4": "192.168.140.10.49160>5.8.88.25.80", - "Host": "5.8.88.25", - "Connection": "keep-alive", - "Upgrade-Insecure-Requests": "1", - "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36", - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", - "Accept-Language": "en-US;q=0.6,en;q=0.4", - "Accept-Encoding": "gzip, deflate", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "192.168.4.2.37788>104.197.3.80.80", - "method": "GET", - "uri": "/", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "connectivity-check.ubuntu.com", - "Accept": "*/*", - "Connection": "close", - "name": "HTTP_DECODER_RESULT_2" - }, - { - "Tuple4": "192.168.4.2.37788>104.197.3.80.80", - "res_version": "1.1", - "res_status": "No Content", - "major_version": 1, - "minor_version": 1, - "status_code": 204, - "Date": "Wed, 12 Sep 2018 19:49:21 GMT", - "Server": "Apache/2.4.18 (Ubuntu)", - "X-NetworkManager-Status": "online", - "Connection": "close", - "name": "HTTP_DECODER_RESULT_3" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_get_multi_trans.json b/test/http_decoder/test_result_json/http_get_multi_trans.json deleted file mode 100644 index 3a499d7..0000000 --- a/test/http_decoder/test_result_json/http_get_multi_trans.json +++ /dev/null @@ -1,140 +0,0 @@ -[ - { - "Tuple4": "192.168.50.18.60400>192.168.42.1.80", - "method": "GET", - "uri": "/account/login.htm", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.pro.testin.cn", - "Connection": "keep-alive", - "Upgrade-Insecure-Requests": "1", - "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.0.0 Safari/537.36", - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", - "Accept-Encoding": "gzip, deflate", - "Accept-Language": "zh-CN,zh;q=0.9", - "Cookie": "Hm_lvt_1b8c1194303ef64e02f003f0cb8a1906=1653898514; _gcl_au=1.1.1010551181.1653898515; _ga=GA1.2.1419569885.1653898515; _gid=GA1.2.2007113907.1653898515; authtoken_pro=tea83b3beef07488bb8571811385db42; userId_pro=1160; pid_pro=1; eid_pro=1; pname_pro=name; Hm_lpvt_1b8c1194303ef64e02f003f0cb8a1906=1653961741; JSESSIONID=531AACA879469EDAB825E28113490E10", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "192.168.50.18.60400>192.168.42.1.80", - "res_version": "1.1", - "major_version": 1, - "minor_version": 1, - "status_code": 302, - "Server": "nginx/1.16.1", - "Date": "Tue, 31 May 2022 06:41:23 GMT", - "Content-Length": "0", - "Connection": "keep-alive", - "Set-Cookie": "JSESSIONID=CFAB9C0C3F4D9D6C2837E3BA9425AFCA; Path=/; HttpOnly", - "Set-Cookie1": "authtoken_pro=tea83b3beef07488bb8571811385db42; Max-Age=28800; Expires=Tue, 31-May-2022 14:41:23 GMT; Domain=testin.cn; Path=/; HttpOnly", - "Set-Cookie2": "userId_pro=1160; Max-Age=28800; Expires=Tue, 31-May-2022 14:41:23 GMT; Domain=testin.cn; Path=/; HttpOnly", - "Location": "http://test.pro.testin.cn/enterprise/index.htm", - "Content-Language": "zh-CN", - "name": "HTTP_DECODER_RESULT_2" - }, - { - "Tuple4": "192.168.50.18.60400>192.168.42.1.80", - "method": "GET", - "uri": "/enterprise/index.htm", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.pro.testin.cn", - "Connection": "keep-alive", - "Upgrade-Insecure-Requests": "1", - "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.0.0 Safari/537.36", - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", - "Accept-Encoding": "gzip, deflate", - "Accept-Language": "zh-CN,zh;q=0.9", - "Cookie": "Hm_lvt_1b8c1194303ef64e02f003f0cb8a1906=1653898514; _gcl_au=1.1.1010551181.1653898515; _ga=GA1.2.1419569885.1653898515; _gid=GA1.2.2007113907.1653898515; authtoken_pro=tea83b3beef07488bb8571811385db42; userId_pro=1160; pid_pro=1; eid_pro=1; pname_pro=name; Hm_lpvt_1b8c1194303ef64e02f003f0cb8a1906=1653961741; JSESSIONID=CFAB9C0C3F4D9D6C2837E3BA9425AFCA", - "name": "HTTP_DECODER_RESULT_3" - }, - { - "Tuple4": "192.168.50.18.60400>192.168.42.1.80", - "res_version": "1.1", - "major_version": 1, - "minor_version": 1, - "status_code": 302, - "Server": "nginx/1.16.1", - "Date": "Tue, 31 May 2022 06:41:23 GMT", - "Content-Length": "0", - "Connection": "keep-alive", - "Set-Cookie": "authtoken_pro=tea83b3beef07488bb8571811385db42; Max-Age=28800; Expires=Tue, 31-May-2022 14:41:23 GMT; Domain=testin.cn; Path=/; HttpOnly", - "Set-Cookie1": "userId_pro=1160; Max-Age=28800; Expires=Tue, 31-May-2022 14:41:23 GMT; Domain=testin.cn; Path=/; HttpOnly", - "Location": "http://test.pro.testin.cn/enterprise/into.htm?eid=1", - "Content-Language": "zh-CN", - "name": "HTTP_DECODER_RESULT_4" - }, - { - "Tuple4": "192.168.50.18.60400>192.168.42.1.80", - "method": "GET", - "uri": "/enterprise/into.htm?eid=1", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.pro.testin.cn", - "Connection": "keep-alive", - "Upgrade-Insecure-Requests": "1", - "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.0.0 Safari/537.36", - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", - "Accept-Encoding": "gzip, deflate", - "Accept-Language": "zh-CN,zh;q=0.9", - "Cookie": "Hm_lvt_1b8c1194303ef64e02f003f0cb8a1906=1653898514; _gcl_au=1.1.1010551181.1653898515; _ga=GA1.2.1419569885.1653898515; _gid=GA1.2.2007113907.1653898515; authtoken_pro=tea83b3beef07488bb8571811385db42; userId_pro=1160; pid_pro=1; eid_pro=1; pname_pro=name; Hm_lpvt_1b8c1194303ef64e02f003f0cb8a1906=1653961741; JSESSIONID=CFAB9C0C3F4D9D6C2837E3BA9425AFCA", - "name": "HTTP_DECODER_RESULT_5" - }, - { - "Tuple4": "192.168.50.18.60400>192.168.42.1.80", - "res_version": "1.1", - "major_version": 1, - "minor_version": 1, - "status_code": 302, - "Server": "nginx/1.16.1", - "Date": "Tue, 31 May 2022 06:41:23 GMT", - "Content-Length": "0", - "Connection": "keep-alive", - "Set-Cookie": "authtoken_pro=tea83b3beef07488bb8571811385db42; Max-Age=28800; Expires=Tue, 31-May-2022 14:41:23 GMT; Domain=testin.cn; Path=/; HttpOnly", - "Set-Cookie1": "userId_pro=1160; Max-Age=28800; Expires=Tue, 31-May-2022 14:41:23 GMT; Domain=testin.cn; Path=/; HttpOnly", - "Location": "http://test.pro.testin.cn/realmachine/index.htm", - "Content-Language": "zh-CN", - "name": "HTTP_DECODER_RESULT_6" - }, - { - "Tuple4": "192.168.50.18.60400>192.168.42.1.80", - "method": "GET", - "uri": "/realmachine/index.htm", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "test.pro.testin.cn", - "Connection": "keep-alive", - "Upgrade-Insecure-Requests": "1", - "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.0.0 Safari/537.36", - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", - "Accept-Encoding": "gzip, deflate", - "Accept-Language": "zh-CN,zh;q=0.9", - "Cookie": "Hm_lvt_1b8c1194303ef64e02f003f0cb8a1906=1653898514; _gcl_au=1.1.1010551181.1653898515; _ga=GA1.2.1419569885.1653898515; _gid=GA1.2.2007113907.1653898515; authtoken_pro=tea83b3beef07488bb8571811385db42; userId_pro=1160; pid_pro=1; eid_pro=1; pname_pro=name; Hm_lpvt_1b8c1194303ef64e02f003f0cb8a1906=1653961741; JSESSIONID=CFAB9C0C3F4D9D6C2837E3BA9425AFCA", - "name": "HTTP_DECODER_RESULT_7" - }, - { - "Tuple4": "192.168.50.18.60400>192.168.42.1.80", - "res_version": "1.1", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Server": "nginx/1.16.1", - "Date": "Tue, 31 May 2022 06:41:23 GMT", - "Content-Type": "text/html;charset=UTF-8", - "Transfer-Encoding": "chunked", - "Connection": "keep-alive", - "Vary": "Accept-Encoding", - "Set-Cookie": "authtoken_pro=tea83b3beef07488bb8571811385db42; Max-Age=28800; Expires=Tue, 31-May-2022 14:41:23 GMT; Domain=testin.cn; Path=/; HttpOnly", - "Set-Cookie1": "userId_pro=1160; Max-Age=28800; Expires=Tue, 31-May-2022 14:41:23 GMT; Domain=testin.cn; Path=/; HttpOnly", - "Set-Cookie2": "pid_pro=1; Max-Age=28800; Expires=Tue, 31-May-2022 14:41:23 GMT; Domain=testin.cn; Path=/; HttpOnly", - "Set-Cookie3": "eid_pro=1; Max-Age=28800; Expires=Tue, 31-May-2022 14:41:23 GMT; Domain=testin.cn; Path=/; HttpOnly", - "Set-Cookie4": "pname_pro=name; Max-Age=28800; Expires=Tue, 31-May-2022 14:41:23 GMT; Domain=testin.cn; Path=/; HttpOnly", - "Content-Language": "zh-CN", - "Content-Encoding": "gzip", - "name": "HTTP_DECODER_RESULT_8" - } -] diff --git a/test/http_decoder/test_result_json/http_get_req_pipeline.json b/test/http_decoder/test_result_json/http_get_req_pipeline.json deleted file mode 100644 index fca5f91..0000000 --- a/test/http_decoder/test_result_json/http_get_req_pipeline.json +++ /dev/null @@ -1,60 +0,0 @@ -[ - { - "Tuple4": "192.168.40.81.52802>192.168.40.137.80", - "method": "GET", - "uri": "/aa.mp4?asf=sdaf", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "113.31.27.226", - "Connection": "keep-alive", - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", - "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1636.2 Safari/537.36", - "Accept-Encoding": "gzip,deflate,sdch", - "Accept-Language": "zh-CN,zh;q=0.8", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "192.168.40.81.52802>192.168.40.137.80", - "method": "GET", - "uri": "/fetch_ldns.png", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "ns.pb.cachecn.net", - "Connection": "keep-alive", - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", - "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1636.2 Safari/537.36", - "Accept-Encoding": "gzip,deflate,sdch", - "Accept-Language": "zh-CN,zh;q=0.8", - "name": "HTTP_DECODER_RESULT_2" - }, - { - "Tuple4": "192.168.40.81.52802>192.168.40.137.80", - "method": "GET", - "uri": "/40x.jpg", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "ns.pb.cachecn.net", - "Connection": "keep-alive", - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", - "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1636.2 Safari/537.36", - "Accept-Encoding": "gzip,deflate,sdch", - "Accept-Language": "zh-CN,zh;q=0.8", - "name": "HTTP_DECODER_RESULT_3" - }, - { - "Tuple4": "192.168.40.81.52802>192.168.40.137.80", - "res_version": "1.0", - "res_status": "File not found", - "major_version": 1, - "minor_version": 0, - "status_code": 404, - "Server": "SimpleHTTP/0.6 Python/2.7.5", - "Date": "Wed, 25 Oct 2023 06:43:35 GMT", - "Content-Type": "text/html", - "Connection": "close", - "name": "HTTP_DECODER_RESULT_4" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_get_single_trans.json b/test/http_decoder/test_result_json/http_get_single_trans.json deleted file mode 100644 index 988f0b7..0000000 --- a/test/http_decoder/test_result_json/http_get_single_trans.json +++ /dev/null @@ -1,28 +0,0 @@ -[ - { - "Tuple4": "192.168.38.73.50806>192.168.40.137.80", - "method": "GET", - "uri": "/index.html", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "192.168.40.137", - "User-Agent": "curl/7.79.1", - "Accept": "*/*", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "192.168.38.73.50806>192.168.40.137.80", - "res_version": "1.0", - "res_status": "OK", - "major_version": 1, - "minor_version": 0, - "status_code": 200, - "Server": "SimpleHTTP/0.6 Python/2.7.5", - "Date": "Thu, 30 Nov 2023 08:42:24 GMT", - "Content-type": "text/html", - "Content-Length": "144", - "Last-Modified": "Thu, 30 Nov 2023 08:38:54 GMT", - "name": "HTTP_DECODER_RESULT_2" - } -] diff --git a/test/http_decoder/test_result_json/http_header_value_empty.json b/test/http_decoder/test_result_json/http_header_value_empty.json deleted file mode 100644 index 3310002..0000000 --- a/test/http_decoder/test_result_json/http_header_value_empty.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "Tuple4": "192.168.131.33.47164>192.168.204.67.4445", - "method": "POST", - "uri": "http://:4445/RPC2", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "User-Agent": "ulxmlrpcpp/1.7.5", - "Connection": "Close", - "Content-Type": "text/xml", - "Date": "Sat Sep 7 10:04:57 2019", - "Content-Length": "468", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "192.168.131.33.47164>192.168.204.67.4445", - "res_version": "1.1", - "res_status": "OK", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Connection": "Close", - "Content-Type": "text/xml", - "Transfer-Encoding": "chunked", - "X-Powered-By": "ulxmlrpcpp/1.7.4", - "Date": "Sat Sep 7 01:09:08 2019", - "name": "HTTP_DECODER_RESULT_2" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_headers_exceed_maximum.json b/test/http_decoder/test_result_json/http_headers_exceed_maximum.json deleted file mode 100644 index fac220b..0000000 --- a/test/http_decoder/test_result_json/http_headers_exceed_maximum.json +++ /dev/null @@ -1,45 +0,0 @@ -[ - { - "Tuple4": "10.0.0.1.61462>10.0.0.2.80", - "method": "GET", - "uri": "/x/xx/xxxxxxxxxxxxxxxxxxx/x/xxxxxx/xxxxxxxxxxxxxxx?xxx=1&xxx=1&x=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&vmf=xxxxxxxxxx.xxx.xxx.xxx&ce=UTF-8&ns=xxxxxxxxxx&pageName=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&g=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.jsp&r=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&events=xxxxxxxxxxxxxxxxxxxxxxxxxxx&products=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&v1=xxxxxxxxxxxxxxx&v2=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&v17=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&c49=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&AQE=1", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "xxxxx.xxxxxxxx.xxxxxxxxxx.xxx", - "Connection": "keep-alive", - "Accept": "image/webp,*/*;q=0.8", - "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36", - "Referer": "http://www.xxxxxxxxxx.xxx/xx/xxxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx.jsp", - "Accept-Encoding": "gzip,deflate,sdch", - "Accept-Language": "en-US,en;q=0.8,en-GB;q=0.6", - "Cookie": "xxxxxxxxxxxxxxxxxxx=ie; xxxxxxxxxxxxxxxxxxxxxx=true; lp=xxxxxx; rememberUn=false; xxx.xxxxxxxxxx.xxxxxxxxxx=xx; xxxxx=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; autocomplete=1; xxxx=xxxx; xxxx=xxxxv1|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; xxxxxx=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx2xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "10.0.0.1.61462>10.0.0.2.80", - "res_version": "1.1", - "res_status": "OK", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Date": "Mon, 30 Jun 2014 13:35:21 GMT", - "Server": "xxxxxxxxxxxxxxxxx", - "Access-Control-Allow-Origin": "*", - "Set-Cookie": "xxxx=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; Expires=Wed, 29 Jun 2016 13:35:21 GMT; Domain=.xxxxxxxxxx.xxx; Path=/", - "X-C": "ms-4.9", - "Expires": "Sun, 29 Jun 2014 13:35:21 GMT", - "Last-Modified": "Tue, 01 Jul 2014 13:35:21 GMT", - "Cache-Control": "no-cache, no-store, max-age=0, no-transform, private", - "Pragma": "no-cache", - "ETag": "\"xxxxxxxxxxxxxxxxxxxxxx\"", - "Vary": "*", - "P3P": "policyref=\"/w3c/p3p.xml\", CP=\"NOI DSP COR NID PSA OUR IND COM NAV STA\"", - "xserver": "xxxxxx", - "Content-Length": "43", - "Keep-Alive": "timeout=15", - "Connection": "Keep-Alive", - "Content-Type": "image/gif", - "name": "HTTP_DECODER_RESULT_2" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_multi_parse_error.json b/test/http_decoder/test_result_json/http_multi_parse_error.json deleted file mode 100644 index c61f70a..0000000 --- a/test/http_decoder/test_result_json/http_multi_parse_error.json +++ /dev/null @@ -1,197 +0,0 @@ -[ - { - "Tuple4": "192.168.131.33.47164>192.168.204.67.4445", - "method": "POST", - "uri": "http://:4445/RPC2", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "User-Agent": "ulxmlrpcpp/1.7.5", - "Connection": "Close", - "Content-Type": "text/xml", - "Date": "Sat Sep 7 10:04:57 2019", - "Content-Length": "468", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "192.168.131.33.47164>192.168.204.67.4445", - "res_version": "1.1", - "res_status": "OK", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Connection": "Close", - "Content-Type": "text/xml", - "Transfer-Encoding": "chunked", - "X-Powered-By": "ulxmlrpcpp/1.7.4", - "Date": "Sat Sep 7 01:09:08 2019", - "name": "HTTP_DECODER_RESULT_2" - }, - { - "Tuple4": "192.168.131.33.47166>192.168.204.67.4445", - "method": "POST", - "uri": "http://:4445/RPC2", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "User-Agent": "ulxmlrpcpp/1.7.5", - "Connection": "Close", - "Content-Type": "text/xml", - "Date": "Sat Sep 7 10:05:05 2019", - "Content-Length": "468", - "name": "HTTP_DECODER_RESULT_3" - }, - { - "Tuple4": "192.168.131.33.47166>192.168.204.67.4445", - "res_version": "1.1", - "res_status": "OK", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Connection": "Close", - "Content-Type": "text/xml", - "Transfer-Encoding": "chunked", - "X-Powered-By": "ulxmlrpcpp/1.7.4", - "Date": "Sat Sep 7 01:09:16 2019", - "name": "HTTP_DECODER_RESULT_4" - }, - { - "Tuple4": "192.168.131.33.47172>192.168.204.67.4445", - "method": "POST", - "uri": "http://:4445/RPC2", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "User-Agent": "ulxmlrpcpp/1.7.5", - "Connection": "Close", - "Content-Type": "text/xml", - "Date": "Sat Sep 7 10:05:13 2019", - "Content-Length": "468", - "name": "HTTP_DECODER_RESULT_5" - }, - { - "Tuple4": "192.168.131.33.47172>192.168.204.67.4445", - "res_version": "1.1", - "res_status": "OK", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Connection": "Close", - "Content-Type": "text/xml", - "Transfer-Encoding": "chunked", - "X-Powered-By": "ulxmlrpcpp/1.7.4", - "Date": "Sat Sep 7 01:09:24 2019", - "name": "HTTP_DECODER_RESULT_6" - }, - { - "Tuple4": "192.168.131.33.47194>192.168.204.67.4445", - "method": "POST", - "uri": "http://:4445/RPC2", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "User-Agent": "ulxmlrpcpp/1.7.5", - "Connection": "Close", - "Content-Type": "text/xml", - "Date": "Sat Sep 7 10:05:22 2019", - "Content-Length": "306", - "name": "HTTP_DECODER_RESULT_7" - }, - { - "Tuple4": "192.168.131.33.47194>192.168.204.67.4445", - "res_version": "1.1", - "res_status": "OK", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Connection": "Close", - "Transfer-Encoding": "chunked", - "X-Powered-By": "ulxmlrpcpp/1.7.4", - "Date": "Sat Sep 7 01:09:32 2019", - "name": "HTTP_DECODER_RESULT_8" - }, - { - "Tuple4": "192.168.131.33.47196>192.168.204.67.4445", - "method": "POST", - "uri": "http://:4445/RPC2", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "User-Agent": "ulxmlrpcpp/1.7.5", - "Connection": "Close", - "Content-Type": "text/xml", - "Date": "Sat Sep 7 10:05:30 2019", - "Content-Length": "225", - "name": "HTTP_DECODER_RESULT_9" - }, - { - "Tuple4": "192.168.131.33.47196>192.168.204.67.4445", - "res_version": "1.1", - "res_status": "OK", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Connection": "Close", - "Content-Type": "text/xml", - "Transfer-Encoding": "chunked", - "X-Powered-By": "ulxmlrpcpp/1.7.4", - "Date": "Sat Sep 7 01:09:42 2019", - "name": "HTTP_DECODER_RESULT_10" - }, - { - "Tuple4": "192.168.131.33.47200>192.168.204.67.4445", - "method": "POST", - "uri": "http://:4445/RPC2", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "User-Agent": "ulxmlrpcpp/1.7.5", - "Connection": "Close", - "Content-Type": "text/xml", - "Date": "Sat Sep 7 10:05:39 2019", - "Content-Length": "461", - "name": "HTTP_DECODER_RESULT_11" - }, - { - "Tuple4": "192.168.131.33.47200>192.168.204.67.4445", - "res_version": "1.1", - "res_status": "OK", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Connection": "Close", - "Content-Type": "text/xml", - "Transfer-Encoding": "chunked", - "X-Powered-By": "ulxmlrpcpp/1.7.4", - "Date": "Sat Sep 7 01:09:50 2019", - "name": "HTTP_DECODER_RESULT_12" - }, - { - "Tuple4": "192.168.131.33.47214>192.168.204.67.4445", - "method": "POST", - "uri": "http://:4445/RPC2", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "User-Agent": "ulxmlrpcpp/1.7.5", - "Connection": "Close", - "Content-Type": "text/xml", - "Date": "Sat Sep 7 10:05:47 2019", - "Content-Length": "461", - "name": "HTTP_DECODER_RESULT_13" - }, - { - "Tuple4": "192.168.131.33.47214>192.168.204.67.4445", - "res_version": "1.1", - "res_status": "OK", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Connection": "Close", - "Content-Type": "text/xml", - "Transfer-Encoding": "chunked", - "X-Powered-By": "ulxmlrpcpp/1.7.4", - "Date": "Sat Sep 7 01:09:58 2019", - "name": "HTTP_DECODER_RESULT_14" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_no_content_length.json b/test/http_decoder/test_result_json/http_no_content_length.json deleted file mode 100644 index 61613ea..0000000 --- a/test/http_decoder/test_result_json/http_no_content_length.json +++ /dev/null @@ -1,40 +0,0 @@ -[ - { - "Tuple4": "10.0.0.1.50384>10.0.0.2.80", - "method": "GET", - "uri": "/js/xxxxxx.js", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "xxxxxxx.xxxxxx.xx", - "User-Agent": "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3", - "Accept": "*/*", - "Accept-Language": "en-us,en;q=0.5", - "Accept-Encoding": "gzip,deflate", - "Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7", - "Keep-Alive": "115", - "Connection": "keep-alive", - "Referer": "http://www.xxxxxxxx.com/xxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxx.html", - "Cookie": "trafic_ranking=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "10.0.0.1.50384>10.0.0.2.80", - "res_version": "1.0", - "res_status": "OK", - "major_version": 1, - "minor_version": 0, - "status_code": 200, - "Date": "Mon, 10 May 2010 08:31:02 GMT", - "Server": "Apache", - "Content-type": "application/x-javascript", - "Expires": "Thu, 11 Jan 1973 16:00:00 GMT", - "Last-Modified": "Mon, 10 May 2010 08:31:02 GMT", - "Cache-Control": "no-store, no-cache, must-revalidate, post-check=0, pre-check=0", - "Pragma": "no-cache", - "P3P": "policyref=\"/w3c/p3p.xml\", CP=\"ALL IND DSP COR ADM CONo CUR IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI\"", - "Set-Cookie": "trafic_ranking=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; expires=Sun, 11-Jan-2037 14:00:00 GMT; path=/; domain=.xxxxxx.xx", - "connection": "close", - "name": "HTTP_DECODER_RESULT_2" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_over_pppoe.json b/test/http_decoder/test_result_json/http_over_pppoe.json deleted file mode 100644 index e2e459d..0000000 --- a/test/http_decoder/test_result_json/http_over_pppoe.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "Tuple4": "2a00:5e80:101:212d:504:7b1:2572:db22.37034>2606:f200:0:7:bad:f00d:d00d:1.80", - "method": "GET", - "uri": "/", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "User-Agent": "curl/7.34.0", - "Host": "ipv6.icanhazip.com", - "Accept": "*/*", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "2a00:5e80:101:212d:504:7b1:2572:db22.37034>2606:f200:0:7:bad:f00d:d00d:1.80", - "res_version": "1.1", - "res_status": "OK", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Date": "Thu, 02 Jan 2014 08:38:06 GMT", - "Server": "Apache", - "Content-Length": "38", - "Content-Type": "text/plain; charset=UTF-8", - "X-RTFM": "Learn about this site at http://bit.ly/14DAh2o and don't abuse the service", - "X-YOU-SHOULD-APPLY-FOR-A-JOB": "If you're reading this, apply here: http://rackertalent.com/", - "X-ICANHAZNODE": "icanhazip1.nugget", - "name": "HTTP_DECODER_RESULT_2" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_over_tcp_keepalive.json b/test/http_decoder/test_result_json/http_over_tcp_keepalive.json deleted file mode 100644 index dd428ae..0000000 --- a/test/http_decoder/test_result_json/http_over_tcp_keepalive.json +++ /dev/null @@ -1,39 +0,0 @@ -[ - { - "Tuple4": "192.168.56.66.55356>60.190.243.167.80", - "method": "GET", - "uri": "/", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "www.yumi.com", - "Connection": "keep-alive", - "Cache-Control": "max-age=0", - "Upgrade-Insecure-Requests": "1", - "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36", - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", - "Accept-Encoding": "gzip, deflate", - "Accept-Language": "zh-CN,zh;q=0.9", - "Cookie": "UM_distinctid=17d37645f9c1a1-0281befa480414-b7a1a38-144000-17d37645f9d336; CNZZDATA1258295942=1778021578-1637307701-%7C1637307701; Hm_lvt_a6dc86f6e27435039966e994bd7f0792=1637311872; yumi_sid=JaMlFyTA07ikpZjTHZsRTWyGdMqFyFy%2B4hXGj%2FSoQRJYbrfBUQuOTIMZ8jUGmugDC594AYcbeRhg75xidhRxCW4zq9Y0gPwTmkhq4LQuprp4DrtDMLI3L5wLMqkG%2FuAX1aVFPfud5GRNxNFTSp%2Bos%2FKhfCFKhfN5%2BuT2xyVYSAjy2ftiSOGDi7FN13icuuyPhFCoWqOxWVu1CZ3AiYPJssv6kXqiR6paf75icdeROZY2bkFCDKkcIQcPy7o9EKpkL1Mbimeb40JMg9hUsWdmyhDkzVjSHJmC4z2ujpzSDTsjRIQOnxTy1PHZi%2FMwg3uyGLCusDwqbagpO4pcgEJ5ONDy%2BGwO7FmHXU3mFfR56c9HxxiiuLPnBt9ErpqqWKsxH6lUrlHaUp6AzyrgX7PFdksiMfPSk6%2F3%2FWOYr%2FkYuI4fopw7z8%2FLhxC9AiLr9Czz3MngFUGzkmaMVvAhZOSPzg%3D%3D; Hm_lpvt_a6dc86f6e27435039966e994bd7f0792=1637313847", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "192.168.56.66.55356>60.190.243.167.80", - "res_version": "1.1", - "res_status": "OK", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Server": "Tengine", - "Date": "Fri, 19 Nov 2021 09:57:40 GMT", - "Content-Type": "text/html", - "Transfer-Encoding": "chunked", - "Connection": "keep-alive", - "Vary": "Accept-Encoding", - "Set-Cookie": "yumi_sid=V6EhlyovLp46BBzQWLVOBg%2F73RUD5E%2FfaRlkR8RLa8aKhGrPVdVHvHfFWRKKd9wZ%2BfFF4Tb2wnVOOn%2F9iXbBpyHsbxjmUqnbFSoAX7QIJjt%2BEEjAL3M7O7VSpAyMnrFKt7qu46oXV%2B6teyyTUY7Ucy285v6otvZcu8bN%2B5YxKZ1gYh56iJ0bHxnrnQ0vvAx3l%2BLwfw2y0c5IaF2tjrL%2Fn83nrHsPoYYRWAR2zLIXD%2FEMKRtyerwsM5LKhZZteFGWD2w%2B15alKF5T65i0lPvPcAdaqpceL5xz23twQULhs1tIJsOfJZ8JudLlRy6x3DvxQYqRe2xTCex5c77zJqfq%2FdryNbBycIq9gf6C2hXDRwDqRqVgXDMadwGnooKFkv%2ByCbohjHyBCZJypBcYFmglYhin23UC9i%2B%2BOA%2FxhlxcnU8kT8udpTNCktSmF950SQLOmvdvYuXGydKs8v05cxe5fg%3D%3D; expires=Fri, 19-Nov-2021 11:57:38 GMT; Max-Age=7200; path=/; domain=.yumi.com", - "Pragma": "no-cache", - "Cache-Control": "no-store", - "Content-Encoding": "gzip", - "name": "HTTP_DECODER_RESULT_2" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_over_tls.json b/test/http_decoder/test_result_json/http_over_tls.json deleted file mode 100644 index 32960f8..0000000 --- a/test/http_decoder/test_result_json/http_over_tls.json +++ /dev/null @@ -1,2 +0,0 @@ -[ -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_post_multipart_form_data.json b/test/http_decoder/test_result_json/http_post_multipart_form_data.json deleted file mode 100644 index c728970..0000000 --- a/test/http_decoder/test_result_json/http_post_multipart_form_data.json +++ /dev/null @@ -1,94 +0,0 @@ -[ - { - "Tuple4": "192.168.8.97.11371>192.168.57.14.8080", - "method": "GET", - "uri": "/fileupload/", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "192.168.57.14:8080", - "Connection": "keep-alive", - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", - "User-Agent": "Mozilla/5.0 (Windows NT 5.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36", - "Accept-Encoding": "gzip,deflate,sdch", - "Accept-Language": "zh-CN,zh;q=0.8", - "Cookie": "JSESSIONID=969AC5FBD069EE6218EB10513726B244; JSESSIONID=400CC78DF5784F303702CC7F02C6122C", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "192.168.8.97.11371>192.168.57.14.8080", - "res_version": "1.1", - "res_status": "OK", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Server": "Apache-Coyote/1.1", - "Content-Type": "text/html;charset=UTF-8", - "Content-Length": "468", - "Date": "Thu, 28 Mar 2019 08:13:33 GMT", - "name": "HTTP_DECODER_RESULT_2" - }, - { - "Tuple4": "192.168.8.97.11371>192.168.57.14.8080", - "method": "GET", - "uri": "/fileupload/", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "192.168.57.14:8080", - "Connection": "keep-alive", - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", - "User-Agent": "Mozilla/5.0 (Windows NT 5.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36", - "Accept-Encoding": "gzip,deflate,sdch", - "Accept-Language": "zh-CN,zh;q=0.8", - "Cookie": "JSESSIONID=969AC5FBD069EE6218EB10513726B244; JSESSIONID=400CC78DF5784F303702CC7F02C6122C", - "name": "HTTP_DECODER_RESULT_3" - }, - { - "Tuple4": "192.168.8.97.11371>192.168.57.14.8080", - "res_version": "1.1", - "res_status": "OK", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Server": "Apache-Coyote/1.1", - "Content-Type": "text/html;charset=UTF-8", - "Content-Length": "468", - "Date": "Thu, 28 Mar 2019 08:13:33 GMT", - "name": "HTTP_DECODER_RESULT_4" - }, - { - "Tuple4": "192.168.8.97.11371>192.168.57.14.8080", - "method": "POST", - "uri": "/fileupload/servlet/UploadHandleServlet", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "192.168.57.14:8080", - "Connection": "keep-alive", - "Content-Length": "449", - "Cache-Control": "max-age=0", - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", - "Origin": "http://192.168.57.14:8080", - "User-Agent": "Mozilla/5.0 (Windows NT 5.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36", - "Content-Type": "multipart/form-data; boundary=----WebKitFormBoundaryAe47vGj7ybAe6RwO", - "Referer": "http://192.168.57.14:8080/fileupload/", - "Accept-Encoding": "gzip,deflate,sdch", - "Accept-Language": "zh-CN,zh;q=0.8", - "Cookie": "JSESSIONID=969AC5FBD069EE6218EB10513726B244; JSESSIONID=400CC78DF5784F303702CC7F02C6122C", - "name": "HTTP_DECODER_RESULT_5" - }, - { - "Tuple4": "192.168.8.97.11371>192.168.57.14.8080", - "res_version": "1.1", - "res_status": "OK", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Server": "Apache-Coyote/1.1", - "Content-Type": "text/html;charset=UTF-8", - "Content-Length": "144", - "Date": "Thu, 28 Mar 2019 08:13:37 GMT", - "name": "HTTP_DECODER_RESULT_6" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_req_1byte_sliding_window.json b/test/http_decoder/test_result_json/http_req_1byte_sliding_window.json deleted file mode 100644 index 1612574..0000000 --- a/test/http_decoder/test_result_json/http_req_1byte_sliding_window.json +++ /dev/null @@ -1,29 +0,0 @@ -[ - { - "Tuple4": "192.168.40.137.46180>192.168.42.40.80", - "method": "GET", - "uri": "/index.html", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "User-Agent": "Wget/1.14 (linux-gnu)", - "Accept": "*/*", - "Host": "192.168.42.40", - "Connection": "Keep-Alive", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "192.168.40.137.46180>192.168.42.40.80", - "res_version": "1.0", - "res_status": "OK", - "major_version": 1, - "minor_version": 0, - "status_code": 200, - "Server": "SimpleHTTP/0.6 Python/2.7.5", - "Date": "Fri, 29 Dec 2023 09:11:12 GMT", - "Content-type": "text/html", - "Content-Length": "144", - "Last-Modified": "Fri, 29 Dec 2023 08:50:53 GMT", - "name": "HTTP_DECODER_RESULT_2" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_res_1byte_sliding_window.json b/test/http_decoder/test_result_json/http_res_1byte_sliding_window.json deleted file mode 100644 index 845e1b2..0000000 --- a/test/http_decoder/test_result_json/http_res_1byte_sliding_window.json +++ /dev/null @@ -1,29 +0,0 @@ -[ - { - "Tuple4": "192.168.42.40.36338>192.168.40.137.80", - "method": "GET", - "uri": "/index.html", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "User-Agent": "Wget/1.14 (linux-gnu)", - "Accept": "*/*", - "Host": "192.168.40.137", - "Connection": "Keep-Alive", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "192.168.42.40.36338>192.168.40.137.80", - "res_version": "1.0", - "res_status": "OK", - "major_version": 1, - "minor_version": 0, - "status_code": 200, - "Server": "SimpleHTTP/0.6 Python/2.7.5", - "Date": "Fri, 29 Dec 2023 09:32:21 GMT", - "Content-type": "text/html", - "Content-Length": "144", - "Last-Modified": "Fri, 29 Dec 2023 08:50:53 GMT", - "name": "HTTP_DECODER_RESULT_2" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_res_gzip.json b/test/http_decoder/test_result_json/http_res_gzip.json deleted file mode 100644 index 403a559..0000000 --- a/test/http_decoder/test_result_json/http_res_gzip.json +++ /dev/null @@ -1,39 +0,0 @@ -[ - { - "Tuple4": "192.168.69.2.34059>192.168.69.1.80", - "method": "GET", - "uri": "/test/ethereal.html", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "cerberus", - "User-Agent": "Mozilla/5.0 (X11; U; Linux ppc; rv:1.7.3) Gecko/20041004 Firefox/0.10.1", - "Accept": "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5", - "Accept-Language": "en-us,en;q=0.5", - "Accept-Encoding": "gzip,deflate", - "Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7", - "Keep-Alive": "300", - "Connection": "keep-alive", - "Cookie": "FGNCLIID=05c04axp1yaqynldtcdiwis0ag1", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "192.168.69.2.34059>192.168.69.1.80", - "res_version": "1.1", - "res_status": "OK", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Date": "Fri, 29 Oct 2004 05:21:00 GMT", - "Server": "Apache/2.0.50 (Fedora)", - "Last-Modified": "Fri, 29 Oct 2004 05:20:21 GMT", - "ETag": "\"126e1f-6d-371b2f40\"", - "Accept-Ranges": "bytes", - "Vary": "Accept-Encoding", - "Content-Encoding": "gzip", - "Content-Length": "92", - "Connection": "close", - "Content-Type": "text/html; charset=UTF-8", - "name": "HTTP_DECODER_RESULT_2" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_trans_pipeline.json b/test/http_decoder/test_result_json/http_trans_pipeline.json deleted file mode 100644 index e2d18c7..0000000 --- a/test/http_decoder/test_result_json/http_trans_pipeline.json +++ /dev/null @@ -1,348 +0,0 @@ -[ - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "method": "GET", - "uri": "/postinfo.html", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "116.181.2.152", - "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "method": "GET", - "uri": "/_vti_bin/_vti_aut/author.dll", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "116.181.2.152", - "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_2" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "method": "GET", - "uri": "/_vti_bin/_vti_aut/author.exe", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "116.181.2.152", - "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_3" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "method": "GET", - "uri": "/_vti_bin/_vti_aut/dvwssr.dll", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "116.181.2.152", - "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_4" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "method": "GET", - "uri": "/_vti_bin/_vti_adm/admin.dll", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "116.181.2.152", - "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_5" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "method": "GET", - "uri": "/_vti_bin/_vti_adm/admin.exe", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "116.181.2.152", - "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_6" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "method": "GET", - "uri": "/_vti_bin/fpcount.exe?Page=default.asp|Image=3", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "116.181.2.152", - "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_7" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "res_version": "1.1", - "res_status": "Not Found", - "major_version": 1, - "minor_version": 1, - "status_code": 404, - "Server": "nginx", - "Date": "Thu, 29 Oct 2020 09:59:02 GMT", - "Content-Type": "text/html", - "Content-Length": "146", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_8" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "res_version": "1.1", - "res_status": "Not Found", - "major_version": 1, - "minor_version": 1, - "status_code": 404, - "Server": "nginx", - "Date": "Thu, 29 Oct 2020 09:59:02 GMT", - "Content-Type": "text/html", - "Content-Length": "146", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_9" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "res_version": "1.1", - "res_status": "Not Found", - "major_version": 1, - "minor_version": 1, - "status_code": 404, - "Server": "nginx", - "Date": "Thu, 29 Oct 2020 09:59:02 GMT", - "Content-Type": "text/html", - "Content-Length": "146", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_10" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "res_version": "1.1", - "res_status": "Not Found", - "major_version": 1, - "minor_version": 1, - "status_code": 404, - "Server": "nginx", - "Date": "Thu, 29 Oct 2020 09:59:02 GMT", - "Content-Type": "text/html", - "Content-Length": "146", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_11" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "res_version": "1.1", - "res_status": "Not Found", - "major_version": 1, - "minor_version": 1, - "status_code": 404, - "Server": "nginx", - "Date": "Thu, 29 Oct 2020 09:59:02 GMT", - "Content-Type": "text/html", - "Content-Length": "146", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_12" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "res_version": "1.1", - "res_status": "Not Found", - "major_version": 1, - "minor_version": 1, - "status_code": 404, - "Server": "nginx", - "Date": "Thu, 29 Oct 2020 09:59:02 GMT", - "Content-Type": "text/html", - "Content-Length": "146", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_13" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "method": "GET", - "uri": "/_vti_bin/shtml.dll", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "116.181.2.152", - "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_14" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "method": "GET", - "uri": "/_vti_bin/shtml.exe", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "116.181.2.152", - "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_15" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "method": "GET", - "uri": "/_vti_pvt/_x_todo.htm", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "116.181.2.152", - "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_16" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "method": "GET", - "uri": "/_vti_pvt/_x_todoh.htm", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "116.181.2.152", - "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_17" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "method": "GET", - "uri": "/_vti_pvt/access.cnf", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "116.181.2.152", - "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_18" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "method": "GET", - "uri": "/_vti_pvt/administrator.pwd", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "116.181.2.152", - "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_19" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "method": "GET", - "uri": "/_vti_pvt/administrators.pwd", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "116.181.2.152", - "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_20" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "method": "GET", - "uri": "/_vti_pvt/authors.pwd", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "116.181.2.152", - "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_21" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "method": "GET", - "uri": "/_vti_pvt/bots.cnf", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "116.181.2.152", - "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_22" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "res_version": "1.1", - "res_status": "Not Found", - "major_version": 1, - "minor_version": 1, - "status_code": 404, - "Server": "nginx", - "Date": "Thu, 29 Oct 2020 09:59:02 GMT", - "Content-Type": "text/html", - "Content-Length": "146", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_23" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "res_version": "1.1", - "res_status": "Not Found", - "major_version": 1, - "minor_version": 1, - "status_code": 404, - "Server": "nginx", - "Date": "Thu, 29 Oct 2020 09:59:02 GMT", - "Content-Type": "text/html", - "Content-Length": "146", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_24" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "res_version": "1.1", - "res_status": "Not Found", - "major_version": 1, - "minor_version": 1, - "status_code": 404, - "Server": "nginx", - "Date": "Thu, 29 Oct 2020 09:59:02 GMT", - "Content-Type": "text/html", - "Content-Length": "146", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_25" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "res_version": "1.1", - "res_status": "Not Found", - "major_version": 1, - "minor_version": 1, - "status_code": 404, - "Server": "nginx", - "Date": "Thu, 29 Oct 2020 09:59:02 GMT", - "Content-Type": "text/html", - "Content-Length": "146", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_26" - }, - { - "Tuple4": "223.72.39.14.2545>192.168.182.147.80", - "res_version": "1.1", - "res_status": "Not Found", - "major_version": 1, - "minor_version": 1, - "status_code": 404, - "Server": "nginx", - "Date": "Thu, 29 Oct 2020 09:59:02 GMT", - "Content-Type": "text/html", - "Content-Length": "146", - "Connection": "keep-alive", - "name": "HTTP_DECODER_RESULT_27" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_tunnel_for_pop3.json b/test/http_decoder/test_result_json/http_tunnel_for_pop3.json deleted file mode 100644 index 6d24715..0000000 --- a/test/http_decoder/test_result_json/http_tunnel_for_pop3.json +++ /dev/null @@ -1,28 +0,0 @@ -[ - { - "Tuple4": "192.168.10.58.51798>192.168.10.144.808", - "method": "CONNECT", - "uri": "pop.163.com:110", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Content-Length": "0", - "Accept": "*/*", - "User-Agent": "Foxmail 7, 1, 3, 48[cn]", - "Accept-Encoding": "gzip, deflate", - "Proxy-Connection": "Keep-Alive", - "Connection": "Keep-Alive", - "Host": "192.168.10.144", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "192.168.10.58.51798>192.168.10.144.808", - "res_version": "1.1", - "res_status": "Connection established", - "major_version": 1, - "minor_version": 1, - "status_code": 200, - "Proxy-agent": "CCProxy", - "name": "HTTP_DECODER_RESULT_2" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_upgrade_http2.json b/test/http_decoder/test_result_json/http_upgrade_http2.json deleted file mode 100644 index 54d7638..0000000 --- a/test/http_decoder/test_result_json/http_upgrade_http2.json +++ /dev/null @@ -1,28 +0,0 @@ -[ - { - "Tuple4": "10.9.0.2.58038>139.162.123.134.80", - "method": "GET", - "uri": "/robots.txt", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "nghttp2.org", - "User-Agent": "curl/7.61.0", - "Accept": "*/*", - "Connection": "Upgrade, HTTP2-Settings", - "Upgrade": "h2c", - "HTTP2-Settings": "AAMAAABkAARAAAAAAAIAAAAA", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "10.9.0.2.58038>139.162.123.134.80", - "res_version": "1.1", - "res_status": "Switching Protocols", - "major_version": 1, - "minor_version": 1, - "status_code": 101, - "Connection": "Upgrade", - "Upgrade": "h2c", - "name": "HTTP_DECODER_RESULT_2" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/http_upgrade_websocket.json b/test/http_decoder/test_result_json/http_upgrade_websocket.json deleted file mode 100644 index 7921ff3..0000000 --- a/test/http_decoder/test_result_json/http_upgrade_websocket.json +++ /dev/null @@ -1,37 +0,0 @@ -[ - { - "Tuple4": "131.179.196.220.59631>131.179.196.46.9696", - "method": "GET", - "uri": "/", - "req_version": "1.1", - "major_version": 1, - "minor_version": 1, - "Host": "spurs.cs.ucla.edu:9696", - "Connection": "Upgrade", - "Pragma": "no-cache", - "Cache-Control": "no-cache", - "Upgrade": "websocket", - "Origin": "null", - "Sec-WebSocket-Version": "13", - "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36", - "Accept-Encoding": "gzip, deflate, sdch", - "Accept-Language": "en-US,en;q=0.8,lv;q=0.6,ru;q=0.4", - "Cookie": "s_cc=true; s_sq=%5B%5BB%5D%5D; iwe_user_noticecount_urn%3amace%3aucla.edu%3appid%3aperson%3a1223EF7211FC4EC1965579D0B8D85FBA=2; __utma=125574670.1759122974.1407127284.1407127284.1415755402.2; __utmc=125574670; __utma=126236063.2139843507.1390525421.1433785187.1435706244.46; __utmc=126236063; __utmz=126236063.1427934389.33.5.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); _ucla_sso=2015-07-02T11%3A34%3A30-07%3A00; _ga=GA1.2.1759122974.1407127284", - "Sec-WebSocket-Key": "sgD1adxQ3mk6BbBqab7owA==", - "Sec-WebSocket-Extensions": "permessage-deflate; client_max_window_bits", - "name": "HTTP_DECODER_RESULT_1" - }, - { - "Tuple4": "131.179.196.220.59631>131.179.196.46.9696", - "res_version": "1.1", - "res_status": "Switching Protocols", - "major_version": 1, - "minor_version": 1, - "status_code": 101, - "Connection": "upgrade", - "Sec-WebSocket-Accept": "FRh9fmH0UaoLdY5BSFO4hP2Pcjw=", - "Server": "WebSocket++/0.5.1", - "Upgrade": "websocket", - "name": "HTTP_DECODER_RESULT_2" - } -]
\ No newline at end of file diff --git a/test/http_decoder/test_result_json/non_http.json b/test/http_decoder/test_result_json/non_http.json deleted file mode 100644 index 0637a08..0000000 --- a/test/http_decoder/test_result_json/non_http.json +++ /dev/null @@ -1 +0,0 @@ -[]
\ No newline at end of file diff --git a/test/plugin_manager/CMakeLists.txt b/test/plugin_manager/CMakeLists.txt index b096bec..e29fb43 100644 --- a/test/plugin_manager/CMakeLists.txt +++ b/test/plugin_manager/CMakeLists.txt @@ -1,12 +1,14 @@ - -# 开启测试 - add_executable(gtest_plugin_manager plugin_manager_gtest_main.cpp ) +include_directories(${CMAKE_SOURCE_DIR}/src/) + target_link_libraries( gtest_plugin_manager + plugin_manager + dl + "-rdynamic" gtest ) diff --git a/test/plugin_manager/plugin_manager_gtest_main.cpp b/test/plugin_manager/plugin_manager_gtest_main.cpp index 8fb5f51..4ef516c 100644 --- a/test/plugin_manager/plugin_manager_gtest_main.cpp +++ b/test/plugin_manager/plugin_manager_gtest_main.cpp @@ -1,10 +1,16 @@ #include <gtest/gtest.h> +#include "plugin_manager_mock.h" -TEST(EQ_Test, Always_True) { - EXPECT_EQ(1, 1); +TEST(plugin_manager_init, init_none_toml) { + + struct stellar st={0}; + struct plugin_manager_schema *pm = plugin_manager_init(&st, NULL); + ASSERT_TRUE(pm!=NULL); + plugin_manager_exit(pm); } + int main(int argc, char ** argv) { int ret=0; diff --git a/test/plugin_manager/plugin_manager_mock.h b/test/plugin_manager/plugin_manager_mock.h new file mode 100644 index 0000000..e02e686 --- /dev/null +++ b/test/plugin_manager/plugin_manager_mock.h @@ -0,0 +1,72 @@ +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "plugin_manager/plugin_manager.h" +#include "stellar_on_sapp/stellar_internal.h" + +//mock stellar +struct stellar +{ + struct plugin_manager_schema *plug_mgr; +}; + +struct packet +{ + struct stellar *st; + enum packet_type type; + unsigned char ip_proto; +}; + +struct session +{ + struct plugin_manager_runtime *plug_mgr_rt; +}; + +struct plugin_manager_schema * stellar_plugin_manager_schema_get(struct stellar *st) +{ + return st->plug_mgr; +} + +int stellar_plugin_manager_schema_set(struct stellar *st, struct plugin_manager_schema *pm) +{ + st->plug_mgr=pm; + return 0; +} + +int stellar_get_worker_thread_num(struct stellar *st) +{ + return 1; +} + +int stellar_get_current_thread_id(struct stellar *st) +{ + return 0; +} + +struct stellar * packet_stellar_get(struct packet *pkt) +{ + return pkt->st; +} + +struct plugin_manager_runtime * session_plugin_manager_runtime_get(struct session *sess) +{ + return sess->plug_mgr_rt; +} + +unsigned char packet_get_ip_protocol(struct packet *pkt) +{ + if(pkt == NULL)return 0; + return pkt->ip_proto; +} + + +enum packet_type packet_get_type(const struct packet *pkt) +{ + return pkt->type; +} + +#ifdef __cplusplus +} +#endif diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index 045e36f..8b38241 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -20,17 +20,4 @@ set_property(TARGET gtest PROPERTY INTERFACE_LINK_LIBRARIES pthread) add_library(gmock STATIC IMPORTED GLOBAL) add_dependencies(gmock googletest) set_property(TARGET gmock PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libgmock.a) -set_property(TARGET gmock PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include) - -#llhttp-9.1.2 -ExternalProject_Add(llhttp PREFIX llhttp - URL ${CMAKE_CURRENT_SOURCE_DIR}/llhttp-release-v9.1.3.tar.gz - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${VENDOR_BUILD} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_C_FLAGS="-fPIC") - -file(MAKE_DIRECTORY ${VENDOR_BUILD}/include) - -add_library(llhttp-static STATIC IMPORTED GLOBAL) -add_dependencies(llhttp-static llhttp) - -set_property(TARGET llhttp-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${VENDOR_BUILD}/include) -set_property(TARGET llhttp-static PROPERTY IMPORTED_LOCATION ${VENDOR_BUILD}/lib64/libllhttp.a)
\ No newline at end of file +set_property(TARGET gmock PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
\ No newline at end of file diff --git a/vendor/llhttp-release-v9.1.3.tar.gz b/vendor/llhttp-release-v9.1.3.tar.gz Binary files differdeleted file mode 100644 index c83dbd0..0000000 --- a/vendor/llhttp-release-v9.1.3.tar.gz +++ /dev/null |
