From 2093ac5bf6444db290cdf1c7d64cf4b80f415d2f Mon Sep 17 00:00:00 2001 From: Luca Deri Date: Mon, 20 May 2024 12:17:04 +0200 Subject: Minor dissector optimizations --- src/lib/protocols/socks45.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src/lib/protocols/socks45.c') diff --git a/src/lib/protocols/socks45.c b/src/lib/protocols/socks45.c index 742e0a6e6..78a744087 100644 --- a/src/lib/protocols/socks45.c +++ b/src/lib/protocols/socks45.c @@ -40,12 +40,6 @@ static void ndpi_check_socks4(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_packet_struct *packet = &ndpi_struct->packet; u_int32_t payload_len = packet->payload_packet_len; - /* Break after 10 packets. */ - if(flow->packet_counter > 10) { - NDPI_EXCLUDE_PROTO(ndpi_struct, flow); - return; - } - /* Check if we so far detected the protocol in the request or not. */ if(flow->socks4_stage == 0) { NDPI_LOG_DBG2(ndpi_struct, "SOCKS4 stage 0: \n"); @@ -81,12 +75,6 @@ static void ndpi_check_socks5(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_packet_struct *packet = &ndpi_struct->packet; u_int32_t payload_len = packet->payload_packet_len; - /* Break after 10 packets. */ - if(flow->packet_counter > 10) { - NDPI_EXCLUDE_PROTO(ndpi_struct, flow); - return; - } - /* Check if we so far detected the protocol in the request or not. */ if(flow->socks5_stage == 0) { NDPI_LOG_DBG2(ndpi_struct, "SOCKS5 stage 0: \n"); @@ -123,6 +111,11 @@ static void ndpi_search_socks(struct ndpi_detection_module_struct *ndpi_struct, { NDPI_LOG_DBG(ndpi_struct, "search SOCKS\n"); + if(flow->packet_counter >= 10) { + NDPI_EXCLUDE_PROTO(ndpi_struct, flow); + return; + } + ndpi_check_socks4(ndpi_struct, flow); if(flow->detected_protocol_stack[0] != NDPI_PROTOCOL_SOCKS) -- cgit v1.2.3