Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ndpi_domain_classify_finalize() function #2084

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/include/ndpi_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -2104,6 +2104,7 @@ extern "C" {
u_int32_t ndpi_domain_classify_add_domains(ndpi_domain_classify *s,
u_int8_t class_id,
char *file_path);
bool ndpi_domain_classify_finalize(ndpi_domain_classify *s);
bool ndpi_domain_classify_contains(ndpi_domain_classify *s,
u_int8_t *class_id /* out */,
const char *domain);
Expand Down
16 changes: 16 additions & 0 deletions src/lib/ndpi_domain_classify.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,22 @@ u_int32_t ndpi_domain_classify_add_domains(ndpi_domain_classify *s,

/* ********************************************************** */

bool ndpi_domain_classify_finalize(ndpi_domain_classify *s) {
u_int32_t i;

if(!s)
return(false);

for(i=0; i<MAX_NUM_NDPI_DOMAIN_CLASSIFICATIONS; i++) {
if(s->classes[i].class_id != 0) {
ndpi_bitmap64_compress(s->classes[i].domains);
}
}
return(true);
}

/* ********************************************************** */

static bool is_valid_domain_char(u_char c) {
if(((c >= 'A')&& (c <= 'Z'))
|| ((c >= 'a')&& (c <= 'z'))
Expand Down
1 change: 1 addition & 0 deletions src/lib/ndpi_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6959,6 +6959,7 @@ int ndpi_enable_loaded_categories(struct ndpi_detection_module_struct *ndpi_str)
}
#else
ndpi_domain_classify_free(ndpi_str->custom_categories.sc_hostnames);
ndpi_domain_classify_finalize(ndpi_str->custom_categories.sc_hostnames_shadow);
ndpi_str->custom_categories.sc_hostnames = ndpi_str->custom_categories.sc_hostnames_shadow;
ndpi_str->custom_categories.sc_hostnames_shadow = ndpi_domain_classify_alloc();
#endif
Expand Down
Loading