Improved domain search tet unit
This commit is contained in:
+18
-7
@@ -5421,19 +5421,30 @@ void sketchUnitTest() {
|
|||||||
|
|
||||||
void domainSearchUnitTest() {
|
void domainSearchUnitTest() {
|
||||||
ndpi_domain_classify *sc = ndpi_domain_classify_alloc();
|
ndpi_domain_classify *sc = ndpi_domain_classify_alloc();
|
||||||
|
const char *fname = NDPI_BASE_DIR "/lists/gambling.list";
|
||||||
char *domain = "ntop.org";
|
char *domain = "ntop.org";
|
||||||
|
u_int32_t num_domains;
|
||||||
|
|
||||||
assert(sc);
|
assert(sc);
|
||||||
|
|
||||||
ndpi_domain_classify_add(sc, CUSTOM_CATEGORY_MALWARE, domain);
|
ndpi_domain_classify_add(sc, NDPI_PROTOCOL_NTOP, domain);
|
||||||
|
|
||||||
assert(ndpi_domain_classify_contains(sc, domain));
|
assert(ndpi_domain_classify_contains(sc, domain));
|
||||||
|
|
||||||
#if 0
|
num_domains = ndpi_domain_classify_add_domains(sc, NDPI_PROTOCOL_GAMBLING, (char*)fname);
|
||||||
printf("Added %u domains\n",
|
assert(num_domains == 35370);
|
||||||
ndpi_domain_classify_add_domains(sc, NDPI_PROTOCOL_GAMBLING,
|
/* Subdomain check */
|
||||||
NDPI_BASE_DIR "/lists/gambling.list"));
|
assert(ndpi_domain_classify_contains(sc, "blog.ntop.org") == NDPI_PROTOCOL_NTOP);
|
||||||
printf("Size: %u\n", ndpi_domain_classify_size(sc));
|
assert(ndpi_domain_classify_contains(sc, "0grand-casino.com") == NDPI_PROTOCOL_GAMBLING);
|
||||||
|
|
||||||
|
#ifdef DEBUG_TRACE
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
|
if(stat(fname, &st) == 0) {
|
||||||
|
u_int32_t s = ndpi_domain_classify_size(sc);
|
||||||
|
|
||||||
|
printf("Size: %u [%.1f %% of the original filename size]\n",
|
||||||
|
s, (float)(s * 100) / (float)st.st_size);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ndpi_domain_classify_free(sc);
|
ndpi_domain_classify_free(sc);
|
||||||
|
|||||||
Reference in New Issue
Block a user