mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
Print FTL regex extension details in regex-test mode
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -588,3 +588,41 @@ void _query_set_status(queriesData *query, const enum query_status new_status, c
|
||||
// Update status
|
||||
query->status = new_status;
|
||||
}
|
||||
|
||||
const char * __attribute__ ((const)) get_query_reply_str(const enum reply_type reply)
|
||||
{
|
||||
switch(reply)
|
||||
{
|
||||
case REPLY_UNKNOWN:
|
||||
return "UNKNOWN";
|
||||
case REPLY_NODATA:
|
||||
return "NODATA";
|
||||
case REPLY_NXDOMAIN:
|
||||
return "NXDOMAIN";
|
||||
case REPLY_CNAME:
|
||||
return "CNAME";
|
||||
case REPLY_IP:
|
||||
return "IP";
|
||||
case REPLY_DOMAIN:
|
||||
return "DOMAIN";
|
||||
case REPLY_RRNAME:
|
||||
return "RRNAME";
|
||||
case REPLY_SERVFAIL:
|
||||
return "SERVFAIL";
|
||||
case REPLY_REFUSED:
|
||||
return "REFUSED";
|
||||
case REPLY_NOTIMP:
|
||||
return "NOTIMP";
|
||||
case REPLY_OTHER:
|
||||
return "OTHER";
|
||||
case REPLY_DNSSEC:
|
||||
return "DNSSEC";
|
||||
case REPLY_NONE:
|
||||
return "NONE";
|
||||
case REPLY_BLOB:
|
||||
return "BLOB";
|
||||
default:
|
||||
case QUERY_REPLY_MAX:
|
||||
return "INVALID";
|
||||
}
|
||||
}
|
||||
|
||||
+43
-18
@@ -410,25 +410,50 @@ int match_regex(const char *input, DNSCacheData* dns_cache, const int clientID,
|
||||
input, regex[index].string);
|
||||
}
|
||||
|
||||
if(regextest && regexid == REGEX_CLI)
|
||||
if(regextest)
|
||||
{
|
||||
// CLI provided regular expression
|
||||
logg(" %s%s%s matches",
|
||||
cli_bold(), regex[index].string, cli_normal());
|
||||
}
|
||||
else if(regextest && regexid == REGEX_BLACKLIST)
|
||||
{
|
||||
// Database-sourced regular expression
|
||||
logg(" %s%s%s matches (regex blacklist, DB ID %i)",
|
||||
cli_bold(), regex[index].string, cli_normal(),
|
||||
regex[index].database_id);
|
||||
}
|
||||
else if(regextest && regexid == REGEX_WHITELIST)
|
||||
{
|
||||
// Database-sourced regular expression
|
||||
logg(" %s%s%s matches (regex whitelist, DB ID %i)",
|
||||
cli_bold(), regex[index].string, cli_normal(),
|
||||
regex[index].database_id);
|
||||
if(regexid == REGEX_CLI)
|
||||
{
|
||||
// CLI provided regular expression
|
||||
logg(" %s%s%s matches",
|
||||
cli_bold(), regex[index].string, cli_normal());
|
||||
}
|
||||
else if(regextest && regexid == REGEX_BLACKLIST)
|
||||
{
|
||||
// Database-sourced regular expression
|
||||
logg(" %s%s%s matches (regex blacklist, DB ID %i)",
|
||||
cli_bold(), regex[index].string, cli_normal(),
|
||||
regex[index].database_id);
|
||||
}
|
||||
else if(regextest && regexid == REGEX_WHITELIST)
|
||||
{
|
||||
// Database-sourced regular expression
|
||||
logg(" %s%s%s matches (regex whitelist, DB ID %i)",
|
||||
cli_bold(), regex[index].string, cli_normal(),
|
||||
regex[index].database_id);
|
||||
}
|
||||
|
||||
// Check query type filtering
|
||||
if(regex[index].ext.query_type != 0)
|
||||
{
|
||||
logg(" Hint: This regex %s type %s queries",
|
||||
regex[index].ext.query_type_inverted ? "does not match" : "matches only",
|
||||
querytypes[regex[index].ext.query_type]);
|
||||
}
|
||||
|
||||
// Check inversion
|
||||
if(regex[index].ext.inverted)
|
||||
{
|
||||
logg(" Hint: This regex is inverted");
|
||||
}
|
||||
|
||||
// Check special reply type
|
||||
if(regex[index].ext.reply != REPLY_UNKNOWN)
|
||||
{
|
||||
logg(" Hint: This regex forces reply type %s",
|
||||
get_query_reply_str(regex[index].ext.reply));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user