diff options
| author | lijia <[email protected]> | 2024-08-16 14:58:19 +0800 |
|---|---|---|
| committer | lijia <[email protected]> | 2024-08-16 16:05:57 +0800 |
| commit | 5ccd3bc23cf46a11ada14eab3e0b0a354733da59 (patch) | |
| tree | 140a676f27ca516916fdd78eb1a0f07d8c59dac8 /decoders/http/http_decoder_tunnel.cpp | |
| parent | a59eca7685e126226d5c2b4679a2a90711cc5875 (diff) | |
Adjust benchmark directory,enable HTTP test,rename variables,format codesdev-integration-http
Diffstat (limited to 'decoders/http/http_decoder_tunnel.cpp')
| -rw-r--r-- | decoders/http/http_decoder_tunnel.cpp | 67 |
1 files changed, 38 insertions, 29 deletions
diff --git a/decoders/http/http_decoder_tunnel.cpp b/decoders/http/http_decoder_tunnel.cpp index 42f100a..cf5a573 100644 --- a/decoders/http/http_decoder_tunnel.cpp +++ b/decoders/http/http_decoder_tunnel.cpp @@ -3,7 +3,7 @@ #include <string.h> #include <strings.h> #include <unistd.h> -#include "http_decoder_inc.h" +#include "http_decoder_private.h" #include "llhttp.h" struct http_tunnel_message @@ -12,28 +12,32 @@ struct http_tunnel_message hstring tunnel_payload; }; - int httpd_tunnel_identify(struct http_decoder_env *httpd_env, int curdir, struct http_decoder_half_data *hfdata) { - if(0 == httpd_env->hd_cfg.proxy_enable){ + if (0 == httpd_env->hd_cfg.proxy_enable) + { return 0; } - if(FLOW_DIRECTION_C2S == curdir){ + if (FLOW_DIRECTION_C2S == curdir) + { struct http_request_line reqline = {}; http_decoder_half_data_get_request_line(hfdata, &reqline); - if(0 == strncasecmp_safe("CONNECT", (char *)reqline.method.iov_base, - 7, reqline.method.iov_len)){ + if (0 == strncasecmp_safe("CONNECT", (char *)reqline.method.iov_base, + 7, reqline.method.iov_len)) + { return 1; } - }else{ + } + else + { struct http_response_line resline = {}; http_decoder_half_data_get_response_line(hfdata, &resline); - if(resline.status_code == HTTP_STATUS_OK - && 0 == strncasecmp_safe("Connection established", (char *)resline.status.iov_base, - strlen("Connection established"), resline.status.iov_len)){ + if (resline.status_code == HTTP_STATUS_OK && 0 == strncasecmp_safe("Connection established", (char *)resline.status.iov_base, + strlen("Connection established"), resline.status.iov_len)) + { return 1; - } + } } return 0; @@ -41,15 +45,17 @@ int httpd_tunnel_identify(struct http_decoder_env *httpd_env, int curdir, struct int httpd_is_tunnel_session(const struct http_decoder_env *httpd_env, const struct http_decoder_exdata *ex_data) { - if(0 == httpd_env->hd_cfg.proxy_enable){ + if (0 == httpd_env->hd_cfg.proxy_enable) + { return 0; - } + } return (ex_data && ex_data->tunnel_state != HTTP_TUN_NON); } int httpd_in_tunnel_transmitting(const struct http_decoder_env *httpd_env, struct http_decoder_exdata *ex_data) { - if(0 == httpd_env->hd_cfg.proxy_enable){ + if (0 == httpd_env->hd_cfg.proxy_enable) + { return 0; } return (ex_data && ex_data->tunnel_state >= HTTP_TUN_INNER_STARTING); @@ -57,10 +63,12 @@ int httpd_in_tunnel_transmitting(const struct http_decoder_env *httpd_env, struc enum http_tunnel_message_type httpd_tunnel_state_to_msg(const struct http_decoder_exdata *ex_data) { - if(ex_data->tunnel_state == HTTP_TUN_INNER_STARTING){ + if (ex_data->tunnel_state == HTTP_TUN_INNER_STARTING) + { return HTTP_TUNNEL_OPENING; } - if(ex_data->tunnel_state == HTTP_TUN_INNER_TRANS){ + if (ex_data->tunnel_state == HTTP_TUN_INNER_TRANS) + { return HTTP_TUNNEL_ACTIVE; } return HTTP_TUNNEL_MSG_MAX; @@ -68,7 +76,8 @@ enum http_tunnel_message_type httpd_tunnel_state_to_msg(const struct http_decode void httpd_tunnel_state_update(struct http_decoder_exdata *ex_data) { - if(ex_data->tunnel_state == HTTP_TUN_INNER_STARTING){ + if (ex_data->tunnel_state == HTTP_TUN_INNER_STARTING) + { ex_data->tunnel_state = HTTP_TUN_INNER_TRANS; } } @@ -86,21 +95,21 @@ void http_decoder_push_tunnel_data(struct session *sess, const struct http_decod extern "C" { #endif -void http_tunnel_message_get_payload(const struct http_tunnel_message *tmsg, - hstring *tunnel_payload) -{ - if (unlikely(NULL == tmsg || tunnel_payload == NULL)) + void http_tunnel_message_get_payload(const struct http_tunnel_message *tmsg, + hstring *tunnel_payload) { - return; + if (unlikely(NULL == tmsg || tunnel_payload == NULL)) + { + return; + } + tunnel_payload->iov_base = tmsg->tunnel_payload.iov_base; + tunnel_payload->iov_len = tmsg->tunnel_payload.iov_len; } - tunnel_payload->iov_base = tmsg->tunnel_payload.iov_base; - tunnel_payload->iov_len = tmsg->tunnel_payload.iov_len; -} -enum http_tunnel_message_type http_tunnel_message_type_get(const struct http_tunnel_message *tmsg) -{ - return tmsg->type; -} + enum http_tunnel_message_type http_tunnel_message_type_get(const struct http_tunnel_message *tmsg) + { + return tmsg->type; + } #ifdef __cplusplus } |
