Added sub-domain classification fix
This commit is contained in:
@@ -32,7 +32,7 @@
|
|||||||
#define DEBUG_CONTAINS
|
#define DEBUG_CONTAINS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define USE_BINARY_BITMAP
|
//#define USE_BINARY_BITMAP
|
||||||
|
|
||||||
#ifdef USE_BINARY_BITMAP
|
#ifdef USE_BINARY_BITMAP
|
||||||
|
|
||||||
@@ -155,8 +155,7 @@ bool ndpi_domain_classify_contains(ndpi_domain_classify *c,
|
|||||||
u_int8_t *class_id /* out */,
|
u_int8_t *class_id /* out */,
|
||||||
char *domain) {
|
char *domain) {
|
||||||
u_int32_t len;
|
u_int32_t len;
|
||||||
char *dot;
|
char *dot, *elem, *last_dot;
|
||||||
u_int64_t hash;
|
|
||||||
|
|
||||||
if(!domain) return(false);
|
if(!domain) return(false);
|
||||||
if((len = strlen(domain)) == 0) return(false);
|
if((len = strlen(domain)) == 0) return(false);
|
||||||
@@ -180,17 +179,30 @@ bool ndpi_domain_classify_contains(ndpi_domain_classify *c,
|
|||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
hash = ndpi_quick_hash64(domain, strlen(domain));
|
elem = domain, last_dot = strrchr(domain, '.');
|
||||||
|
|
||||||
|
while(true) {
|
||||||
|
u_int64_t hash = ndpi_quick_hash64(elem, strlen(elem));
|
||||||
|
|
||||||
#ifdef DEBUG_CONTAINS
|
#ifdef DEBUG_CONTAINS
|
||||||
printf("[contains] Searching %s [hash: %llu]\n", domain, hash);
|
printf("[contains] Searching %s [hash: %llu]\n", elem, hash);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(ndpi_binary_bitmap_isset(c->bitmap, hash, class_id)) {
|
if(ndpi_binary_bitmap_isset(c->bitmap, hash, class_id)) {
|
||||||
#ifdef DEBUG_CONTAINS
|
#ifdef DEBUG_CONTAINS
|
||||||
printf("[contains] %s = %d\n", domain, *class_id);
|
printf("[contains] %s = %d\n", elem, *class_id);
|
||||||
#endif
|
#endif
|
||||||
return(true);
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if((elem = strchr(elem, '.')) == NULL)
|
||||||
|
break;
|
||||||
|
else {
|
||||||
|
if(elem == last_dot)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
elem = &elem[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_CONTAINS
|
#ifdef DEBUG_CONTAINS
|
||||||
|
|||||||
Reference in New Issue
Block a user