Improved hyperscan support
This commit is contained in:
@@ -8162,11 +8162,11 @@ ndpi_protocol_match host_match[] = {
|
||||
{ ".sina.com.cn", NULL, NULL, "Sina", NDPI_PROTOCOL_SINA, NDPI_PROTOCOL_CATEGORY_SOCIAL_NETWORK, NDPI_PROTOCOL_FUN },
|
||||
|
||||
/* https://support.cipafilter.com/index.php?/Knowledgebase/Article/View/117/0/snapchat---how-to-block */
|
||||
{ "feelinsonice.appspot.com", NULL, NULL, "Snapchat", NDPI_PROTOCOL_SNAPCHAT, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN },
|
||||
{ "feelinsonice.appspot.com", NULL, "\\.appspot\\.com$", "Snapchat", NDPI_PROTOCOL_SNAPCHAT, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN },
|
||||
{ "feelinsonice-hrd.appspot.com", NULL, NULL, "Snapchat", NDPI_PROTOCOL_SNAPCHAT, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN },
|
||||
{ "feelinsonice.com", NULL, NULL, "Snapchat", NDPI_PROTOCOL_SNAPCHAT, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN },
|
||||
{ ".snapchat.", NULL, NULL, "Snapchat", NDPI_PROTOCOL_SNAPCHAT, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN },
|
||||
{ ".snapads.", NULL, NULL, "Snapchat", NDPI_PROTOCOL_SNAPCHAT, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN },
|
||||
{ "feelinsonice.com", NULL, "\\.feelsonice\\.com$", "Snapchat", NDPI_PROTOCOL_SNAPCHAT, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN },
|
||||
{ ".snapchat.", NULL, "\\.snapchat\\.com$", "Snapchat", NDPI_PROTOCOL_SNAPCHAT, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN },
|
||||
{ ".snapads.", NULL, "\\.snapads\\.com$", "Snapchat", NDPI_PROTOCOL_SNAPCHAT, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN },
|
||||
|
||||
/* Detected "instagram.c10r.facebook.com". Omitted "*amazonaws.com" and "*facebook.com" CDNs e.g. "ig-telegraph-shv-04-frc3.facebook.com" */
|
||||
{ ".cdninstagram.com", NULL, NULL, "Instagram", NDPI_PROTOCOL_INSTAGRAM, NDPI_PROTOCOL_CATEGORY_SOCIAL_NETWORK, NDPI_PROTOCOL_FUN },
|
||||
|
||||
+13
-4
@@ -750,20 +750,23 @@ static int init_hyperscan(struct ndpi_detection_module_struct *ndpi_mod) {
|
||||
const char **expressions;
|
||||
unsigned int *ids;
|
||||
hs_compile_error_t *compile_err;
|
||||
struct hs *hs = (struct hs*)ndpi_mod->hyperscan;
|
||||
struct hs *hs;
|
||||
|
||||
ndpi_mod->hyperscan = (void*)malloc(sizeof(struct hs));
|
||||
if(!ndpi_mod->hyperscan) return(-1);
|
||||
hs = (struct hs*)ndpi_mod->hyperscan;
|
||||
|
||||
for(i=0; host_match[i].string_to_match != NULL; i++) {
|
||||
if(host_match[i].pattern_to_match)
|
||||
if(host_match[i].pattern_to_match) {
|
||||
/* printf("[DEBUG] %s\n", host_match[i].pattern_to_match); */
|
||||
num_patterns++;
|
||||
}
|
||||
}
|
||||
|
||||
expressions = (const char**)malloc(sizeof(char*)*num_patterns);
|
||||
expressions = (const char**)calloc(sizeof(char*), num_patterns+1);
|
||||
if(!expressions) return(-1);
|
||||
|
||||
ids = (unsigned int*)malloc(sizeof(unsigned int)*num_patterns);
|
||||
ids = (unsigned int*)calloc(sizeof(unsigned int), num_patterns+1);
|
||||
if(!ids) {
|
||||
free(expressions);
|
||||
return(-1);
|
||||
@@ -794,6 +797,8 @@ static int init_hyperscan(struct ndpi_detection_module_struct *ndpi_mod) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ******************************************************************** */
|
||||
|
||||
static void destroy_hyperscan(struct ndpi_detection_module_struct *ndpi_mod) {
|
||||
if(ndpi_mod->hyperscan) {
|
||||
struct hs *hs = (struct hs*)ndpi_mod->hyperscan;
|
||||
@@ -805,6 +810,8 @@ static void destroy_hyperscan(struct ndpi_detection_module_struct *ndpi_mod) {
|
||||
|
||||
#endif
|
||||
|
||||
/* ******************************************************************** */
|
||||
|
||||
static void init_string_based_protocols(struct ndpi_detection_module_struct *ndpi_mod)
|
||||
{
|
||||
int i;
|
||||
@@ -5056,6 +5063,8 @@ static int ndpi_automa_match_string_subprotocol(struct ndpi_detection_module_str
|
||||
|
||||
#else
|
||||
|
||||
/* ******************************************************************** */
|
||||
|
||||
static int hyperscanEventHandler(unsigned int id, unsigned long long from,
|
||||
unsigned long long to, unsigned int flags, void *ctx) {
|
||||
*((int *)ctx) = (int)id;
|
||||
|
||||
Reference in New Issue
Block a user