diff options
author | Toni <matzeton@googlemail.com> | 2025-02-23 13:13:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-23 13:13:38 +0100 |
commit | 5858e1debffe7e12c0144f9af5e0d40a4c68ca45 (patch) | |
tree | a8f97864a2ac33c4c4d877f3997fbf8d6301d2ab /src/lib | |
parent | 2d3f08362e66fd5ac4d7889f92061f5be6884487 (diff) |
Add LagoFast protocol dissector. (#2743)
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/ndpi_content_match.c.inc | 4 | ||||
-rw-r--r-- | src/lib/ndpi_main.c | 7 | ||||
-rw-r--r-- | src/lib/protocols/lagofast.c | 77 |
3 files changed, 88 insertions, 0 deletions
diff --git a/src/lib/ndpi_content_match.c.inc b/src/lib/ndpi_content_match.c.inc index 245af396a..9cdd12385 100644 --- a/src/lib/ndpi_content_match.c.inc +++ b/src/lib/ndpi_content_match.c.inc @@ -1650,6 +1650,10 @@ static ndpi_protocol_match host_match[] = { "rutube.ru", "RUTUBE", NDPI_PROTOCOL_RUTUBE, NDPI_PROTOCOL_CATEGORY_MEDIA, NDPI_PROTOCOL_FUN, NDPI_PROTOCOL_DEFAULT_LEVEL }, + /* LagoFast */ + { "6fast.com", "LagoFast", NDPI_PROTOCOL_LAGOFAST, NDPI_PROTOCOL_CATEGORY_VPN, NDPI_PROTOCOL_FUN, NDPI_PROTOCOL_DEFAULT_LEVEL }, + { "lagofast.com", "LagoFast", NDPI_PROTOCOL_LAGOFAST, NDPI_PROTOCOL_CATEGORY_VPN, NDPI_PROTOCOL_FUN, NDPI_PROTOCOL_DEFAULT_LEVEL }, + #ifdef CUSTOM_NDPI_PROTOCOLS #include "../../../nDPI-custom/custom_ndpi_content_match_host_match.c.inc" #endif diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index 11d9d44d1..fe8004178 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -2465,6 +2465,10 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp "MS_OneDrive", NDPI_PROTOCOL_CATEGORY_COLLABORATIVE, NDPI_PROTOCOL_QOE_CATEGORY_UNSPECIFIED, ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */, ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */); + ndpi_set_proto_defaults(ndpi_str, 0 /* encrypted */, 0 /* nw proto */, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_LAGOFAST, + "LagoFast", NDPI_PROTOCOL_CATEGORY_VPN, NDPI_PROTOCOL_QOE_CATEGORY_ONLINE_GAMING, + ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */, + ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */); #ifdef CUSTOM_NDPI_PROTOCOLS #include "../../../nDPI-custom/custom_ndpi_main.c" @@ -6431,6 +6435,9 @@ static int ndpi_callback_init(struct ndpi_detection_module_struct *ndpi_str) { /* Paltalk */ init_paltalk_dissector(ndpi_str, &a); + /* LagoFast */ + init_lagofast_dissector(ndpi_str, &a); + #ifdef CUSTOM_NDPI_PROTOCOLS #include "../../../nDPI-custom/custom_ndpi_main_init.c" #endif diff --git a/src/lib/protocols/lagofast.c b/src/lib/protocols/lagofast.c new file mode 100644 index 000000000..624c528a0 --- /dev/null +++ b/src/lib/protocols/lagofast.c @@ -0,0 +1,77 @@ +/* + * lagofast.c + * + * Copyright (C) 2011-25 - ntop.org + * + * nDPI is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * nDPI is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with nDPI. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include "ndpi_protocol_ids.h" + +#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_LAGOFAST + +#include "ndpi_api.h" +#include "ndpi_private.h" + +static void ndpi_int_lagofast_add_connection(struct ndpi_detection_module_struct * const ndpi_struct, + struct ndpi_flow_struct * const flow) +{ + NDPI_LOG_INFO(ndpi_struct, "found LagoFast\n"); + ndpi_set_detected_protocol(ndpi_struct, flow, + NDPI_PROTOCOL_LAGOFAST, + NDPI_PROTOCOL_UNKNOWN, + NDPI_CONFIDENCE_DPI); +} + +static void ndpi_search_lagofast(struct ndpi_detection_module_struct *ndpi_struct, + struct ndpi_flow_struct *flow) +{ + struct ndpi_packet_struct const * const packet = &ndpi_struct->packet; + + NDPI_LOG_DBG(ndpi_struct, "search LagoFast\n"); + if (packet->payload_packet_len < 6) { + NDPI_EXCLUDE_PROTO(ndpi_struct, flow); + return; + } + + // LagoFast identifier + if (get_u_int32_t(packet->payload, 0) != htonl(0x006e5d03)) { + NDPI_EXCLUDE_PROTO(ndpi_struct, flow); + return; + } + + // Check encoded length + const uint16_t encoded_length = ntohs(get_u_int16_t(packet->payload, 4)); + if (packet->payload_packet_len != encoded_length + 6 /* identifier + length */) { + NDPI_EXCLUDE_PROTO(ndpi_struct, flow); + return; + } + + ndpi_int_lagofast_add_connection(ndpi_struct, flow); +} + +void init_lagofast_dissector(struct ndpi_detection_module_struct *ndpi_struct, + u_int32_t *id) +{ + ndpi_set_bitmask_protocol_detection("LagoFast", ndpi_struct, *id, + NDPI_PROTOCOL_LAGOFAST, + ndpi_search_lagofast, + NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD, + SAVE_DETECTION_BITMASK_AS_UNKNOWN, + ADD_TO_DETECTION_BITMASK); + + *id += 1; +} + |