Avoid useless host automa lookup (#1724)

The host automa is used for two tasks:
* protocol sub-classification (obviously);
* DGA evaluation: the idea is that if a domain is present in this
automa, it can't be a DGA, regardless of its format/name.

In most dissectors both checks are executed, i.e. the code is something
like:

```
ndpi_match_host_subprotocol(..., flow->host_server_name, ...);
ndpi_check_dga_name(..., flow->host_server_name,...);

```

In that common case, we can perform only one automa lookup: if we check the
sub-classification before the DGA, we can avoid the second lookup in
the DGA function itself.
This commit is contained in:
Ivan Nardi
2022-09-05 13:59:51 +02:00
committed by GitHub
parent 01028ee779
commit 0a47f745cc
120 changed files with 127 additions and 124 deletions
+1 -1
View File
@@ -104,7 +104,7 @@ static void ndpi_int_netbios_add_connection(struct ndpi_detection_module_struct
(u_int)(packet->payload_packet_len - off), name, sizeof(name)-1) > 0) {
ndpi_hostname_sni_set(flow, (const u_int8_t *)name, strlen((char *)name));
ndpi_check_dga_name(ndpi_struct, flow, flow->host_server_name, 1);
ndpi_check_dga_name(ndpi_struct, flow, flow->host_server_name, 1, 1);
}
if(sub_protocol == NDPI_PROTOCOL_UNKNOWN)