Added NDPI_PROTOCOL_NTOP assert and removed percentage comparison (#2460)

Close #2413
This commit is contained in:
Mark Jeffery
2024-06-10 19:45:19 +02:00
committed by GitHub
parent aee2c81f76
commit 312dc424bd
+5 -10
View File
@@ -5950,6 +5950,7 @@ void domainSearchUnitTest() {
char *domain = "ntop.org"; char *domain = "ntop.org";
u_int16_t class_id; u_int16_t class_id;
struct ndpi_detection_module_struct *ndpi_str = ndpi_init_detection_module(NULL); struct ndpi_detection_module_struct *ndpi_str = ndpi_init_detection_module(NULL);
u_int8_t trace = 0;
assert(ndpi_str); assert(ndpi_str);
assert(sc); assert(sc);
@@ -5957,6 +5958,7 @@ void domainSearchUnitTest() {
ndpi_domain_classify_add(ndpi_str, sc, NDPI_PROTOCOL_NTOP, ".ntop.org"); ndpi_domain_classify_add(ndpi_str, sc, NDPI_PROTOCOL_NTOP, ".ntop.org");
ndpi_domain_classify_add(ndpi_str, sc, NDPI_PROTOCOL_NTOP, domain); ndpi_domain_classify_add(ndpi_str, sc, NDPI_PROTOCOL_NTOP, domain);
assert(ndpi_domain_classify_hostname(ndpi_str, sc, &class_id, domain)); assert(ndpi_domain_classify_hostname(ndpi_str, sc, &class_id, domain));
assert(class_id == NDPI_PROTOCOL_NTOP);
ndpi_domain_classify_add(ndpi_str, sc, NDPI_PROTOCOL_CATEGORY_GAMBLING, "123vc.club"); ndpi_domain_classify_add(ndpi_str, sc, NDPI_PROTOCOL_CATEGORY_GAMBLING, "123vc.club");
assert(ndpi_domain_classify_hostname(ndpi_str, sc, &class_id, "123vc.club")); assert(ndpi_domain_classify_hostname(ndpi_str, sc, &class_id, "123vc.club"));
@@ -5966,16 +5968,9 @@ void domainSearchUnitTest() {
assert(ndpi_domain_classify_hostname(ndpi_str, sc, &class_id, "blog.ntop.org")); assert(ndpi_domain_classify_hostname(ndpi_str, sc, &class_id, "blog.ntop.org"));
assert(class_id == NDPI_PROTOCOL_NTOP); assert(class_id == NDPI_PROTOCOL_NTOP);
#ifdef DEBUG_TRACE u_int32_t s = ndpi_domain_classify_size(sc);
struct stat st; if(trace) printf("ndpi_domain_classify size: %u \n",s);
if(stat(fname, &st) == 0) {
u_int32_t s = ndpi_domain_classify_size(ndpi_str, sc);
printf("Size: %u [%.1f %% of the original filename size]\n",
s, (float)(s * 100) / (float)st.st_size);
}
#endif
ndpi_domain_classify_free(sc); ndpi_domain_classify_free(sc);
ndpi_exit_detection_module(ndpi_str); ndpi_exit_detection_module(ndpi_str);