mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
Added RESOLVEIPV6 config flag + extended comments in source
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -120,6 +120,7 @@ typedef struct {
|
||||
bool query_display;
|
||||
bool analyze_AAAA;
|
||||
int maxDBdays;
|
||||
bool resolveIPv6;
|
||||
} ConfigStruct;
|
||||
|
||||
// Dynamic structs
|
||||
|
||||
@@ -104,6 +104,7 @@ Possible settings (**the option shown first is the default**):
|
||||
- `QUERY_DISPLAY=yes|no` (Display all queries? Set to `no` to hide query display)
|
||||
- `AAAA_QUERY_ANALYSIS=yes|no` (Allow `FTL` to analyze AAAA queries from pihole.log?)
|
||||
- `MAXDBDAYS=365` (How long should queries be stored in the database? Setting this to `0` disables the database altogether)
|
||||
- `RESOLVEIPV6=yes|no` (Should `FTL` try to resolve IPv6 addresses to host names?)
|
||||
|
||||
### Implemented keywords (starting with `>`, subject to change):
|
||||
|
||||
|
||||
@@ -111,6 +111,20 @@ void read_FTLconf(void)
|
||||
else
|
||||
logg(" MAXDBDAYS: max age for stored queries is %i days", config.maxDBdays);
|
||||
|
||||
// RESOLVEIPV6
|
||||
// defaults to: Yes
|
||||
config.resolveIPv6 = true;
|
||||
buffer = parse_FTLconf(fp, "RESOLVEIPV6");
|
||||
if(buffer != NULL)
|
||||
{
|
||||
if(strcmp(buffer, "no") == 0)
|
||||
config.resolveIPv6 = false;
|
||||
}
|
||||
if(config.resolveIPv6)
|
||||
logg(" RESOLVEIPV6: Resolve IPv6 addresses");
|
||||
else
|
||||
logg(" RESOLVEIPV6: Don\'t resolve IPv6 addresses");
|
||||
|
||||
logg("Finished config file parsing");
|
||||
|
||||
if(conflinebuffer != NULL)
|
||||
|
||||
@@ -718,15 +718,23 @@ void process_pihole_log(int file)
|
||||
char *resolveHostname(const char *addr)
|
||||
{
|
||||
// Get host name
|
||||
struct hostent *he;
|
||||
struct hostent *he = NULL;
|
||||
char *hostname;
|
||||
bool IPv6 = false;
|
||||
|
||||
// Test if we want to resolve an IPv6 address
|
||||
if(strstr(addr,":") != NULL)
|
||||
{
|
||||
IPv6 = true;
|
||||
}
|
||||
|
||||
if(IPv6 && config.resolveIPv6) // Resolve IPv6 address only if requested
|
||||
{
|
||||
struct in6_addr ipaddr;
|
||||
inet_pton(AF_INET6, addr, &ipaddr);
|
||||
he = gethostbyaddr(&ipaddr, sizeof ipaddr, AF_INET6);
|
||||
}
|
||||
else
|
||||
else if(!IPv6) // Always resolve IPv4 addresses
|
||||
{
|
||||
struct in_addr ipaddr;
|
||||
inet_pton(AF_INET, addr, &ipaddr);
|
||||
@@ -735,11 +743,13 @@ char *resolveHostname(const char *addr)
|
||||
|
||||
if(he == NULL)
|
||||
{
|
||||
// No hostname found
|
||||
hostname = calloc(1,sizeof(char));
|
||||
hostname[0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Return hostname copied to new memory location
|
||||
hostname = strdup(he->h_name);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user