summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlijia <[email protected]>2024-06-21 14:32:39 +0800
committerlijia <[email protected]>2024-06-21 16:16:26 +0800
commit5d0168f5eb8c263b3e9b940b99b2c2097ee99282 (patch)
tree066127ce92dbae231bce2dc0133071dc1d123f46
parenta2e5617ed5f32078b9e2fc1f1a2649aaef6b0eec (diff)
add asymmetric test case.
-rw-r--r--src/http_content_decompress.cpp6
-rw-r--r--src/http_decoder.cpp55
-rw-r--r--src/http_decoder_half.cpp3
-rw-r--r--src/http_decoder_inc.h4
-rw-r--r--src/http_decoder_stat.cpp1
-rw-r--r--src/http_decoder_stat.h1
-rw-r--r--src/http_decoder_tunnel.h3
-rw-r--r--test/CMakeLists.txt3
-rw-r--r--test/http_decoder_perf_main.cpp35
-rw-r--r--test/http_pcap/http_fin.pcapbin0 -> 240 bytes
-rw-r--r--test/http_pcap/http_tunnel_for_http_C2S.pcapbin0 -> 823 bytes
-rw-r--r--test/http_pcap/http_tunnel_for_http_S2C.pcapbin0 -> 3434 bytes
-rw-r--r--test/http_pcap/http_tunnel_s2c_only_hdr.pcapbin0 -> 195 bytes
-rw-r--r--test/test_result_json/http_msg_type_state_tunnel_c2s.json15
-rw-r--r--test/test_result_json/http_msg_type_state_tunnel_s2c.json19
-rw-r--r--test/test_result_json/http_tunnel_for_http_c2s.json31
-rw-r--r--test/test_result_json/http_tunnel_for_http_s2c.json36
-rw-r--r--test/test_result_json/http_tunnel_s2c_only_hdr.json15
-rw-r--r--test_based_on_stellar/CMakeLists.txt22
19 files changed, 199 insertions, 50 deletions
diff --git a/src/http_content_decompress.cpp b/src/http_content_decompress.cpp
index 5c436d9..44fcdf3 100644
--- a/src/http_content_decompress.cpp
+++ b/src/http_content_decompress.cpp
@@ -136,9 +136,8 @@ http_content_decompress_write_zlib(struct http_content_decompress *decompress,
*outdata = NULL;
*outdata_len = 0;
- int ret = 0;
do {
- ret = inflate(z_stream_ptr, Z_NO_FLUSH);
+ int 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);
@@ -182,9 +181,8 @@ http_content_decompress_write_br(struct http_content_decompress *decompress,
*outdata = NULL;
*outdata_len = 0;
- int ret;
for (;;) {
- ret = BrotliDecoderDecompressStream(decompress->br_state, &available_in,
+ int 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) {
diff --git a/src/http_decoder.cpp b/src/http_decoder.cpp
index 3af4dad..551b0b0 100644
--- a/src/http_decoder.cpp
+++ b/src/http_decoder.cpp
@@ -86,6 +86,7 @@ static void http_event_handler(enum http_event event, struct http_decoder_half_d
session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
if(httpd_tunnel_identify(PACKET_DIRECTION_C2S, half_data)){
exdata->tunnel_state = HTTP_TUN_C2S_HDR_START;
+ http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_TUNNEL, 1);
}
http_decoder_get_url(half_data, mempool);
break;
@@ -112,17 +113,6 @@ static void http_event_handler(enum http_event event, struct http_decoder_half_d
hstring tmp_url = {};
http_half_data_get_url(half_data, &tmp_url);
http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_URL_BYTES, tmp_url.iov_len);
-
- if(httpd_is_tunnel_session(exdata)){
- session_is_symmetric(ev_ctx->ref_session, &flow_flag);
- if(SESSION_SEEN_C2S_FLOW == flow_flag){
- exdata->tunnel_state = HTTP_TUN_INNER_STARTING;
- http_half_pre_context_free(ev_ctx->ref_session, exdata);
- exdata->pub_topic_id = httpd_env->topic_exdata_compose[HTTPD_TOPIC_HTTP_TUNNEL_INDEX].sub_topic_id;
- }else{
- exdata->tunnel_state = HTTP_TUN_C2S_HDR_END;
- }
- }
}
break;
case HTTP_EVENT_REQ_BODY_BEGIN:
@@ -139,12 +129,21 @@ static void http_event_handler(enum http_event event, struct http_decoder_half_d
case HTTP_EVENT_REQ_END:
{
session_is_symmetric(ev_ctx->ref_session, &flow_flag);
+
if(SESSION_SEEN_C2S_FLOW == flow_flag){
msg = http_message_new(HTTP_TRANSACTION_FREE, queue, queue_idx, HTTP_REQUEST);
session_mq_publish_message(ev_ctx->ref_session, exdata->pub_topic_id, msg);
http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_TRANSACTION_FREE, 1);
http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_ASYMMETRY_TRANSACTION_C2S, 1);
}
+ if(httpd_is_tunnel_session(exdata)){
+ if(SESSION_SEEN_C2S_FLOW == flow_flag){
+ exdata->tunnel_state = HTTP_TUN_INNER_STARTING;
+ exdata->pub_topic_id = httpd_env->topic_exdata_compose[HTTPD_TOPIC_HTTP_TUNNEL_INDEX].sub_topic_id;
+ }else{
+ exdata->tunnel_state = HTTP_TUN_C2S_END;
+ }
+ }
http_half_update_state(half_data, event);
http_decoder_result_queue_inc_req_index(queue);
half_data = http_decoder_result_queue_pop_req(queue);
@@ -216,13 +215,12 @@ static void http_event_handler(enum http_event event, struct http_decoder_half_d
int tot_s2c_headers = http_half_data_get_total_parsed_header_count(half_data);
http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_HEADERS_S2C, tot_s2c_headers);
-
+
if(httpd_is_tunnel_session(exdata)){
exdata->tunnel_state = HTTP_TUN_INNER_STARTING;
http_half_pre_context_free(ev_ctx->ref_session, exdata);
exdata->pub_topic_id = httpd_env->topic_exdata_compose[HTTPD_TOPIC_HTTP_TUNNEL_INDEX].sub_topic_id;
- // http_decoder_push_tunnel_data(ev_ctx->ref_session, exdata, HTTP_TUNNEL_OPENING);
- }
+ }
}
break;
case HTTP_EVENT_RES_BODY_BEGIN:
@@ -243,6 +241,7 @@ static void http_event_handler(enum http_event event, struct http_decoder_half_d
if(SESSION_SEEN_S2C_FLOW == flow_flag){
http_decoder_stat_update(&httpd_env->hd_stat, thread_id, HTTPD_STAT_ASYMMETRY_TRANSACTION_S2C, 1);
}
+
http_half_update_state(half_data, event);
http_decoder_result_queue_inc_res_index(queue);
half_data = http_decoder_result_queue_pop_res(queue);
@@ -625,7 +624,7 @@ extern "C"
case HTTP_TUNNEL_OPENING:
{
if(NULL != exdata){
- //not support nested http tunnel
+ //not support nested http tunnel
session_mq_ignore_message(sess, topic_id, httpd_env->plugin_id);
return;
}
@@ -642,21 +641,26 @@ extern "C"
exdata->pub_topic_id = httpd_env->topic_exdata_compose[HTTPD_TOPIC_HTTP_MSG_INDEX].sub_topic_id;
exdata->in_tunnel_is_http = 1;
}else{
- exdata = CALLOC(struct http_decoder_exdata, 1);
- exdata->decoder = NULL;
- exdata->pub_topic_id = -1;
- exdata->in_tunnel_is_http = 0;
- session_exdata_set(sess, httpd_env->topic_exdata_compose[HTTPD_TOPIC_HTTP_TUNNEL_INDEX].exdata_id, exdata);
- //do nothing, but can't call stellar_session_plugin_dettach_current_session() !!!
+ //inner tunnel is not http, do nothing, do not push this message again !!!
+ session_mq_ignore_message(sess, topic_id, httpd_env->plugin_id);
return;
}
}
break;
case HTTP_TUNNEL_ACTIVE:
+ if(NULL == exdata){
+ session_mq_ignore_message(sess, topic_id, httpd_env->plugin_id);
+ http_decoder_stat_update(&httpd_env->hd_stat, session_get_current_thread_id(sess), HTTPD_STAT_PARSE_ERR, 1);
+ return;
+ }
break;
case HTTP_TUNNEL_CLOSING:
+ if(NULL == exdata){
+ http_decoder_stat_update(&httpd_env->hd_stat, session_get_current_thread_id(sess), HTTPD_STAT_PARSE_ERR, 1);
+ return;
+ }
if(exdata->in_tunnel_is_http){
http_half_pre_context_free(sess, exdata);
}
@@ -689,11 +693,20 @@ extern "C"
break;
case SESSION_STATE_ACTIVE:
+ if(NULL == exdata){
+ session_mq_ignore_message(sess, topic_id, httpd_env->plugin_id);
+ http_decoder_stat_update(&httpd_env->hd_stat, session_get_current_thread_id(sess), HTTPD_STAT_PARSE_ERR, 1);
+ return;
+ }
//go on
break;
case SESSION_STATE_CLOSING:
{
+ if(NULL == exdata){
+ http_decoder_stat_update(&httpd_env->hd_stat, session_get_current_thread_id(sess), HTTPD_STAT_PARSE_ERR, 1);
+ return;
+ }
if(httpd_in_tunnel_transmitting(exdata)){
http_decoder_push_tunnel_data(sess, exdata, HTTP_TUNNEL_CLOSING);
}else{
diff --git a/src/http_decoder_half.cpp b/src/http_decoder_half.cpp
index 6074307..b2d3f07 100644
--- a/src/http_decoder_half.cpp
+++ b/src/http_decoder_half.cpp
@@ -1048,12 +1048,11 @@ int http_half_data_get_total_parsed_header_count(struct http_decoder_half_data *
void http_half_pre_context_free(struct session *sess, struct http_decoder_exdata *exdata)
{
struct http_message *msg = NULL;
- struct http_decoder_half_data *req_data;
struct http_decoder_half_data *res_data;
struct http_decoder_result_queue *queue = exdata->queue;
for(int i = 0; i < queue->queue_size; i++){
- req_data = queue->array[i].req_data;
+ struct http_decoder_half_data *req_data = queue->array[i].req_data;
res_data = queue->array[i].res_data;
if ((req_data != NULL) && (NULL == res_data) && (req_data->state < HTTP_EVENT_REQ_END))
{
diff --git a/src/http_decoder_inc.h b/src/http_decoder_inc.h
index 0e0f0c5..9b64cad 100644
--- a/src/http_decoder_inc.h
+++ b/src/http_decoder_inc.h
@@ -46,8 +46,8 @@ extern "C"
#define MEMPOOL_REALLOC(pool)
#define MEMPOOL_FREE(pool, p) nmx_pfree(pool, p)
-#define ENABLE_MEMPOOL 1
-#ifdef ENABLE_MEMPOOL
+#define ENABLE_MEMPOOL 0
+#if ENABLE_MEMPOOL
#define HD_CALLOC(pool, type, number) MEMPOOL_CALLOC(pool, number, type)
#define HD_FREE(pool, p) MEMPOOL_FREE(pool, p)
#else
diff --git a/src/http_decoder_stat.cpp b/src/http_decoder_stat.cpp
index a2b6205..290af64 100644
--- a/src/http_decoder_stat.cpp
+++ b/src/http_decoder_stat.cpp
@@ -16,6 +16,7 @@ static const struct hd_stat_config_tuple g_httpd_stat_tuple[HTTPD_STAT_MAX] =
{HTTPD_STAT_SESSION_NEW, "session_new"},
{HTTPD_STAT_SESSION_FREE, "session_free"},
{HTTPD_STAT_SESSION_EXCEPTION, "sess_exception"},
+ {HTTPD_STAT_TUNNEL, "tunnel"},
{HTTPD_STAT_TRANSACTION_NEW, "trans_new"},
{HTTPD_STAT_TRANSACTION_FREE, "trans_free"},
{HTTPD_STAT_ASYMMETRY_SESSION_C2S, "asymmetry_sess_c2s"},
diff --git a/src/http_decoder_stat.h b/src/http_decoder_stat.h
index e8f18d8..f78f6b6 100644
--- a/src/http_decoder_stat.h
+++ b/src/http_decoder_stat.h
@@ -14,6 +14,7 @@ enum http_decoder_stat_type
HTTPD_STAT_SESSION_NEW,
HTTPD_STAT_SESSION_FREE,
HTTPD_STAT_SESSION_EXCEPTION, // rst, kickout, lost packet, etc.
+ HTTPD_STAT_TUNNEL,
HTTPD_STAT_TRANSACTION_NEW,
HTTPD_STAT_TRANSACTION_FREE,
HTTPD_STAT_ASYMMETRY_SESSION_C2S,
diff --git a/src/http_decoder_tunnel.h b/src/http_decoder_tunnel.h
index b1e74df..2b67649 100644
--- a/src/http_decoder_tunnel.h
+++ b/src/http_decoder_tunnel.h
@@ -6,9 +6,8 @@
enum http_tunnel_state{
HTTP_TUN_NON = 0, // init, or not tunnel session
HTTP_TUN_C2S_HDR_START, //CONNECT ...
- HTTP_TUN_C2S_HDR_END, //CONNECT request all heades end with \r\n
+ HTTP_TUN_C2S_END, //CONNECT request end
HTTP_TUN_S2C_START, // HTTP 200 connet established
- // HTTP_TUN_S2C_END, // http response all heades end with \r\n
HTTP_TUN_INNER_STARTING, // http inner tunnel protocol starting
HTTP_TUN_INNER_TRANS, // http inner tunnel protocol transmitting
};
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 2445ef2..07c1456 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -16,7 +16,6 @@ set(TEST_RUN_DIR /home/mesasoft/sapp_run)
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_SOURCE_DIR}/deps)
-# include_directories(/usr/local/include/cjson)
include_directories(/opt/tsg/framework/include/)
include_directories(/opt/MESA/include/MESA)
include_directories(${CMAKE_BINARY_DIR}/vendor/vbuild/include)
@@ -28,5 +27,3 @@ aux_source_directory(${PROJECT_SOURCE_DIR}/src PERF_TEST_DEP_SRC)
add_executable(httpd_perf_test ${PERF_TEST_DEP_SRC} http_decoder_perf_main.cpp http_decoder_perf_plug.cpp)
target_link_libraries(httpd_perf_test z brotlidec llhttp-static fieldstat4 pthread)
-
-#add_test(NAME INSTALL_PERF_TEST_MAIN COMMAND sh -c "cp ${CMAKE_CURRENT_BINARY_DIR}/httpd_perf_test ${TEST_RUN_DIR}/httpd_perf_test") \ No newline at end of file
diff --git a/test/http_decoder_perf_main.cpp b/test/http_decoder_perf_main.cpp
index 5d1b0f2..bd82b18 100644
--- a/test/http_decoder_perf_main.cpp
+++ b/test/http_decoder_perf_main.cpp
@@ -125,11 +125,15 @@ enum session_state session_get_current_state(struct session *sess)
int stellar_session_mq_get_topic_id(struct stellar *st, const char *topic_name)
{
- for(int i = 0; i < HTTPD_TOPIC_INDEX_MAX; i++){
- if(strcmp(topic_name, g_topic_exdata_set[i].topic_name) == 0){
- return st->consumer_topid_id;
- }
- }
+ // for(int i = 0; i < HTTPD_TOPIC_INDEX_MAX; i++){
+ // if(strcmp(topic_name, "TCP_STREAM") == 0){
+ // st->consumer_topid_id = g_topic_exdata_set[HTTPD_TOPIC_TCP_STREAM_INDEX].sub_topic_id;
+ // st->publish_topic_id = g_topic_exdata_set[HTTPD_TOPIC_HTTP_MSG_INDEX].sub_topic_id;
+ // }
+ // if(strcmp(topic_name, g_topic_exdata_set[i].topic_name) == 0){
+ // return st->consumer_topid_id;
+ // }
+ // }
return -1;
}
@@ -138,12 +142,13 @@ int stellar_session_mq_create_topic(struct stellar *st, const char *topic_name,
for(int i = 0; i < HTTPD_TOPIC_INDEX_MAX; i++){
if(strcmp(topic_name, g_topic_exdata_set[i].topic_name) == 0){
- st->consumer_topid_id = g_topic_exdata_set[i].sub_topic_id;
- st->publish_msg_free_cb = msg_free_cb;
+ if(strcmp(topic_name, HTTP_DECODER_TOPIC) == 0){
+ st->publish_msg_free_cb = msg_free_cb;
+ }
if(strcmp(topic_name, "TCP_STREAM") == 0){
st->publish_topic_id = g_topic_exdata_set[HTTPD_TOPIC_HTTP_MSG_INDEX].sub_topic_id;
}
- return st->consumer_topid_id;
+ return g_topic_exdata_set[i].sub_topic_id;
}
}
return -1;
@@ -177,7 +182,7 @@ int stellar_session_mq_subscribe(struct stellar *st, int topic_id, on_session_ms
}
int session_mq_publish_message(struct session *sess, int topic_id, void *msg)
{
- if(topic_id == sess->st->publish_topic_id){
+ if(topic_id == g_topic_exdata_set[HTTPD_TOPIC_HTTP_MSG_INDEX].sub_topic_id){
http_decoder_perf_entry(sess, topic_id, msg, NULL, NULL);
//maybe generate many messages for one packet, so free msg immediately
sess->st->publish_msg_free_cb(sess, msg, NULL);
@@ -206,17 +211,17 @@ static void perf_test_free_per_session(struct session *sess)
sess->st->free_func(sess, sess->st->exdata_id, sess->exdata, NULL);
}
-static void perf_test_loop(struct session *sess, struct packet *test_payload, int test_payload_index_max, const struct fieldstat_tag *tag, int fs4_metric_id)
+static void perf_test_loop(struct stellar *st, struct session *sess, struct packet *test_payload, int test_payload_index_max, const struct fieldstat_tag *tag, int fs4_metric_id)
{
- TIME_START();
sess->current_payload_st = &test_payload[0];
perf_test_init_per_session(sess);
sess->sess_state = SESSION_STATE_OPENING;
+ TIME_START();
for(int i = 0; i < test_payload_index_max; i++)
{
sess->current_payload_st = &test_payload[i];
- http_decoder_tcp_stream_msg_cb(sess, sess->st->consumer_topid_id, test_payload[i].payload, NULL, sess->st->plugin_env);
+ http_decoder_tcp_stream_msg_cb(sess, g_topic_exdata_set[HTTPD_TOPIC_TCP_STREAM_INDEX].sub_topic_id, test_payload[i].payload, NULL, sess->st->plugin_env);
TIME_DIFF();
fieldstat_easy_histogram_record(fs4_instance, 0, fs4_metric_id, tag, 1, time_diff_ns);
sess->sess_state = SESSION_STATE_ACTIVE;
@@ -380,9 +385,9 @@ int main(int argc, char const *argv[])
init_test_data_frag(test_payload_frag, &payload_index_frag);
while(1){
- perf_test_loop(&sess, test_payload_simple, payload_index_simple, &FS4_SIMPLE_HISGRAM_TAG, fs4_simple_id);
- perf_test_loop(&sess, test_payload_long_long_url, payload_index_long_long_url, &FS4_LONG_LONG_URL_HISGRAM_TAG, fs4_long_long_url_id);
- perf_test_loop(&sess, test_payload_frag, payload_index_frag, &FS4_FRAG_HISGRAM_TAG, fs4_frag_id);
+ perf_test_loop(&st, &sess, test_payload_simple, payload_index_simple, &FS4_SIMPLE_HISGRAM_TAG, fs4_simple_id);
+ perf_test_loop(&st, &sess, test_payload_long_long_url, payload_index_long_long_url, &FS4_LONG_LONG_URL_HISGRAM_TAG, fs4_long_long_url_id);
+ perf_test_loop(&st, &sess, test_payload_frag, payload_index_frag, &FS4_FRAG_HISGRAM_TAG, fs4_frag_id);
}
return 0;
}
diff --git a/test/http_pcap/http_fin.pcap b/test/http_pcap/http_fin.pcap
new file mode 100644
index 0000000..d23bcba
--- /dev/null
+++ b/test/http_pcap/http_fin.pcap
Binary files differ
diff --git a/test/http_pcap/http_tunnel_for_http_C2S.pcap b/test/http_pcap/http_tunnel_for_http_C2S.pcap
new file mode 100644
index 0000000..db336d9
--- /dev/null
+++ b/test/http_pcap/http_tunnel_for_http_C2S.pcap
Binary files differ
diff --git a/test/http_pcap/http_tunnel_for_http_S2C.pcap b/test/http_pcap/http_tunnel_for_http_S2C.pcap
new file mode 100644
index 0000000..f9bb2f5
--- /dev/null
+++ b/test/http_pcap/http_tunnel_for_http_S2C.pcap
Binary files differ
diff --git a/test/http_pcap/http_tunnel_s2c_only_hdr.pcap b/test/http_pcap/http_tunnel_s2c_only_hdr.pcap
new file mode 100644
index 0000000..6887fec
--- /dev/null
+++ b/test/http_pcap/http_tunnel_s2c_only_hdr.pcap
Binary files differ
diff --git a/test/test_result_json/http_msg_type_state_tunnel_c2s.json b/test/test_result_json/http_msg_type_state_tunnel_c2s.json
new file mode 100644
index 0000000..71e5cb5
--- /dev/null
+++ b/test/test_result_json/http_msg_type_state_tunnel_c2s.json
@@ -0,0 +1,15 @@
+[
+ {
+ "msg_0": "HTTP_TRANSACTION_NEW_transaction_0",
+ "msg_1": "HTTP_MESSAGE_REQ_LINE",
+ "msg_2": "HTTP_MESSAGE_REQ_HEADER",
+ "msg_3": "HTTP_MESSAGE_REQ_HEADER_END",
+ "msg_4": "HTTP_TRANSACTION_FREE_transaction_0",
+ "msg_5": "HTTP_TRANSACTION_NEW_transaction_1",
+ "msg_6": "HTTP_MESSAGE_REQ_LINE",
+ "msg_7": "HTTP_MESSAGE_REQ_HEADER",
+ "msg_8": "HTTP_MESSAGE_REQ_HEADER_END",
+ "msg_9": "HTTP_TRANSACTION_FREE_transaction_1"
+ },
+ {}
+] \ No newline at end of file
diff --git a/test/test_result_json/http_msg_type_state_tunnel_s2c.json b/test/test_result_json/http_msg_type_state_tunnel_s2c.json
new file mode 100644
index 0000000..b31260d
--- /dev/null
+++ b/test/test_result_json/http_msg_type_state_tunnel_s2c.json
@@ -0,0 +1,19 @@
+[
+ {},
+ {
+ "msg_0": "HTTP_TRANSACTION_NEW_transaction_0",
+ "msg_1": "HTTP_MESSAGE_RES_LINE",
+ "msg_2": "HTTP_MESSAGE_RES_HEADER",
+ "msg_3": "HTTP_MESSAGE_RES_HEADER_END",
+ "msg_4": "HTTP_TRANSACTION_FREE_transaction_0",
+ "msg_5": "HTTP_TRANSACTION_NEW_transaction_1",
+ "msg_6": "HTTP_MESSAGE_RES_LINE",
+ "msg_7": "HTTP_MESSAGE_RES_HEADER",
+ "msg_8": "HTTP_MESSAGE_RES_HEADER_END",
+ "msg_9": "HTTP_MESSAGE_RES_BODY",
+ "msg_10": "HTTP_MESSAGE_RES_BODY",
+ "msg_11": "HTTP_MESSAGE_RES_BODY",
+ "msg_12": "HTTP_MESSAGE_RES_BODY_END",
+ "msg_13": "HTTP_TRANSACTION_FREE_transaction_1"
+ }
+] \ No newline at end of file
diff --git a/test/test_result_json/http_tunnel_for_http_c2s.json b/test/test_result_json/http_tunnel_for_http_c2s.json
new file mode 100644
index 0000000..5e17067
--- /dev/null
+++ b/test/test_result_json/http_tunnel_for_http_c2s.json
@@ -0,0 +1,31 @@
+[
+ {
+ "__X_HTTP_TUPLE4": "192.168.40.139.59234>192.168.38.83.8080"
+ },
+ {
+ "__X_HTTP_TRANSACTION": "request",
+ "__X_HTTP_TRANSACTION_SEQ": 0,
+ "method": "CONNECT",
+ "uri": "www.baidu.com:80",
+ "req_version": "1.1",
+ "major_version": 1,
+ "minor_version": 1,
+ "Host": "www.baidu.com:80",
+ "User-Agent": "curl/7.29.0",
+ "Proxy-Connection": "Keep-Alive",
+ "__X_HTTP_URL": "www.baidu.com:80"
+ },
+ {
+ "__X_HTTP_TRANSACTION": "request",
+ "__X_HTTP_TRANSACTION_SEQ": 1,
+ "method": "GET",
+ "uri": "/",
+ "req_version": "1.1",
+ "major_version": 1,
+ "minor_version": 1,
+ "User-Agent": "curl/7.29.0",
+ "Host": "www.baidu.com",
+ "Accept": "*/*",
+ "__X_HTTP_URL": "www.baidu.com/"
+ }
+] \ No newline at end of file
diff --git a/test/test_result_json/http_tunnel_for_http_s2c.json b/test/test_result_json/http_tunnel_for_http_s2c.json
new file mode 100644
index 0000000..7bd4996
--- /dev/null
+++ b/test/test_result_json/http_tunnel_for_http_s2c.json
@@ -0,0 +1,36 @@
+[
+ {
+ "__X_HTTP_TUPLE4": "192.168.40.139.59234>192.168.38.83.8080"
+ },
+ {
+ "__X_HTTP_TRANSACTION": "response",
+ "__X_HTTP_TRANSACTION_SEQ": 0,
+ "res_version": "1.1",
+ "res_status": "Connection established",
+ "major_version": 1,
+ "minor_version": 1,
+ "status_code": 200,
+ "Proxy-agent": "CCProxy"
+ },
+ {
+ "__X_HTTP_TRANSACTION": "response",
+ "__X_HTTP_TRANSACTION_SEQ": 1,
+ "res_version": "1.1",
+ "res_status": "OK",
+ "major_version": 1,
+ "minor_version": 1,
+ "status_code": 200,
+ "Accept-Ranges": "bytes",
+ "Cache-Control": "private, no-cache, no-store, proxy-revalidate, no-transform",
+ "Connection": "keep-alive",
+ "Content-Length": "2381",
+ "Content-Type": "text/html",
+ "Date": "Mon, 08 Apr 2024 09:45:51 GMT",
+ "Etag": "\"588604c1-94d\"",
+ "Last-Modified": "Mon, 23 Jan 2017 13:27:29 GMT",
+ "Pragma": "no-cache",
+ "Server": "bfe/1.0.8.18",
+ "Set-Cookie": "BDORZ=27315; max-age=86400; domain=.baidu.com; path=/",
+ "__X_HTTP_PAYLOAD_MD5": "090fe607a5be1228362614ccaa088577"
+ }
+] \ No newline at end of file
diff --git a/test/test_result_json/http_tunnel_s2c_only_hdr.json b/test/test_result_json/http_tunnel_s2c_only_hdr.json
new file mode 100644
index 0000000..4f11604
--- /dev/null
+++ b/test/test_result_json/http_tunnel_s2c_only_hdr.json
@@ -0,0 +1,15 @@
+[
+ {
+ "__X_HTTP_TUPLE4": "36.255.45.61.29079>68.28.1.153.80"
+ },
+ {
+ "__X_HTTP_TRANSACTION": "response",
+ "__X_HTTP_TRANSACTION_SEQ": 0,
+ "res_version": "1.0",
+ "res_status": "Connection Established",
+ "major_version": 1,
+ "minor_version": 0,
+ "status_code": 200,
+ "Proxy-agent": "Apache/2.0.55 (Unix) proxy_html/2.5"
+ }
+] \ No newline at end of file
diff --git a/test_based_on_stellar/CMakeLists.txt b/test_based_on_stellar/CMakeLists.txt
index 64b0129..3559f10 100644
--- a/test_based_on_stellar/CMakeLists.txt
+++ b/test_based_on_stellar/CMakeLists.txt
@@ -85,6 +85,10 @@ add_test(NAME STELLAR_HTTP_TUNNEL_FOR_POP3_TEST COMMAND ./${TEST_MAIN} ${TEST_J
add_test(NAME STELLAR_HTTP_TUNNEL_FOR_HTTP_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_tunnel_for_http.json
-r ${TEST_PCAP_DIR}/http_tunnel_for_http.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_TUNNEL_FOR_HTTP_C2S_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_tunnel_for_http_c2s.json
+ -r ${TEST_PCAP_DIR}/http_tunnel_for_http_C2S.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_TUNNEL_FOR_HTTP_S2C_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_tunnel_for_http_s2c.json
+ -r ${TEST_PCAP_DIR}/http_tunnel_for_http_S2C.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME STELLAR_HTTP_OVER_PPPOE_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_over_pppoe.json
-r ${TEST_PCAP_DIR}/http_over_pppoe.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
@@ -137,6 +141,12 @@ add_test(NAME STELLAR_HTTP_HEADER_TRUNCATED_IN_KV_TEST COMMAND ./${TEST_MAIN} $
add_test(NAME STELLAR_HTTP_HEADER_TRUNCATED_AFTER_KV_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_hdr_truncated_after_kv.json
-r ${TEST_PCAP_DIR}/http_hdr_truncated_after_kv.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_FIN_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/non_http.json
+ -r ${TEST_PCAP_DIR}/http_fin.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
+
+add_test(NAME STELLAR_HTTP_TUNNEL_ONLY_HDR_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_tunnel_s2c_only_hdr.json
+ -r ${TEST_PCAP_DIR}/http_tunnel_s2c_only_hdr.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
+
set_tests_properties(STELLAR_HTTP_GET_SINGLE_TRANS_TEST
STELLAR_HTTP_GET_MULTI_TRANS_TEST
STELLAR_HTTP_GET_LONG_COOKIE_TEST
@@ -146,6 +156,8 @@ set_tests_properties(STELLAR_HTTP_GET_SINGLE_TRANS_TEST
STELLAR_HTTP_OVER_TCP_KEEPALIVE_TEST
STELLAR_HTTP_TUNNEL_FOR_POP3_TEST
STELLAR_HTTP_TUNNEL_FOR_HTTP_TEST
+ STELLAR_HTTP_TUNNEL_FOR_HTTP_C2S_TEST
+ STELLAR_HTTP_TUNNEL_FOR_HTTP_S2C_TEST
STELLAR_HTTP_OVER_PPPOE_TEST
STELLAR_HTTP_OVER_TLS_TEST
STELLAR_NON_HTTP_TEST
@@ -163,6 +175,8 @@ set_tests_properties(STELLAR_HTTP_GET_SINGLE_TRANS_TEST
STELLAR_HTTP_TRANS_PIPELINE_TEST
STELLAR_HTTP_HEADER_TRUNCATED_IN_KV_TEST
STELLAR_HTTP_HEADER_TRUNCATED_AFTER_KV_TEST
+ STELLAR_HTTP_FIN_TEST
+ STELLAR_HTTP_TUNNEL_ONLY_HDR_TEST
PROPERTIES FIXTURES_REQUIRED TestFixture)
add_test(NAME UPDATE_STATE_PLUG_ENTRY COMMAND bash -c "sed -i 's/name=.*/name=\\x22http_decoder_test_state_entry\\x22/' ${TEST_RUN_DIR}/etc/http/gtest_entry.toml")
@@ -184,7 +198,11 @@ add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_SES_EXCEPTION_C2S_TEST COMMAND ./${TE
add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_SES_EXCEPTION_S2C_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_msg_type_state_exception_s2c.json
-r ${TEST_PCAP_DIR}/http_session_exception_s2c.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_TUNNEL_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_msg_type_state_tunnel.json
- -r ${TEST_PCAP_DIR}/http_tunnel_for_http.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
+ -r ${TEST_PCAP_DIR}/http_tunnel_for_http.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_TUNNEL_C2S_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_msg_type_state_tunnel_c2s.json
+ -r ${TEST_PCAP_DIR}/http_tunnel_for_http_C2S.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
+add_test(NAME STELLAR_HTTP_MSG_TYPE_STATE_TUNNEL_S2C_TEST COMMAND ./${TEST_MAIN} ${TEST_JSON_DIR}/http_msg_type_state_tunnel_s2c.json
+ -r ${TEST_PCAP_DIR}/http_tunnel_for_http_S2C.pcap WORKING_DIRECTORY ${TEST_RUN_DIR})
set_tests_properties(STELLAR_HTTP_MSG_TYPE_STATE_TEST
STELLAR_HTTP_MSG_TYPE_STATE_C2S_TEST
STELLAR_HTTP_MSG_TYPE_STATE_S2C_TEST
@@ -192,6 +210,8 @@ set_tests_properties(STELLAR_HTTP_MSG_TYPE_STATE_TEST
STELLAR_HTTP_MSG_TYPE_STATE_SES_EXCEPTION_C2S_TEST
STELLAR_HTTP_MSG_TYPE_STATE_SES_EXCEPTION_S2C_TEST
STELLAR_HTTP_MSG_TYPE_STATE_TUNNEL_TEST
+ STELLAR_HTTP_MSG_TYPE_STATE_TUNNEL_C2S_TEST
+ STELLAR_HTTP_MSG_TYPE_STATE_TUNNEL_S2C_TEST
PROPERTIES FIXTURES_REQUIRED TestState)
add_test(NAME UPDATE_TUNNEL_PLUG_ENTRY COMMAND bash -c "sed -i 's/name=.*/name=\\x22http_decoder_tunnel_entry\\x22/' ${TEST_RUN_DIR}/etc/http/gtest_entry.toml")