Skip to content

Commit

Permalink
Merge branch 'release/v5.0' into new/all_clients_network_table
Browse files Browse the repository at this point in the history
  • Loading branch information
DL6ER committed Mar 28, 2020
2 parents 7759a76 + 603507c commit 149f656
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/FTL.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ enum { DNSSEC_UNSPECIFIED, DNSSEC_SECURE, DNSSEC_INSECURE, DNSSEC_BOGUS, DNSSEC_
enum { QUERY_UNKNOWN, QUERY_GRAVITY, QUERY_FORWARDED, QUERY_CACHE, QUERY_REGEX, QUERY_BLACKLIST, \
QUERY_EXTERNAL_BLOCKED_IP, QUERY_EXTERNAL_BLOCKED_NULL, QUERY_EXTERNAL_BLOCKED_NXRA, \
QUERY_GRAVITY_CNAME, QUERY_REGEX_CNAME, QUERY_BLACKLIST_CNAME, QUERY_STATUS_MAX };
enum { TYPE_A = 1, TYPE_AAAA, TYPE_ANY, TYPE_SRV, TYPE_SOA, TYPE_PTR, TYPE_TXT, TYPE_MAX };
enum { TYPE_A = 1, TYPE_AAAA, TYPE_ANY, TYPE_SRV, TYPE_SOA, TYPE_PTR, TYPE_TXT, TYPE_NAPTR, TYPE_MAX };
enum { REPLY_UNKNOWN, REPLY_NODATA, REPLY_NXDOMAIN, REPLY_CNAME, REPLY_IP, REPLY_DOMAIN, REPLY_RRNAME, REPLY_SERVFAIL, REPLY_REFUSED, REPLY_NOTIMP, REPLY_OTHER };
enum { PRIVACY_SHOW_ALL = 0, PRIVACY_HIDE_DOMAINS, PRIVACY_HIDE_DOMAINS_CLIENTS, PRIVACY_MAXIMUM, PRIVACY_NOSTATS };
enum { MODE_IP, MODE_NX, MODE_NULL, MODE_IP_NODATA_AAAA, MODE_NODATA };
Expand Down
9 changes: 6 additions & 3 deletions src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,10 @@ void getQueryTypes(const int *sock)
}

if(istelnet[*sock]) {
ssend(*sock, "A (IPv4): %.2f\nAAAA (IPv6): %.2f\nANY: %.2f\nSRV: %.2f\nSOA: %.2f\nPTR: %.2f\nTXT: %.2f\n",
ssend(*sock, "A (IPv4): %.2f\nAAAA (IPv6): %.2f\nANY: %.2f\nSRV: %.2f\n"
"SOA: %.2f\nPTR: %.2f\nTXT: %.2f\nNAPTR: %.2f\n",
percentage[0], percentage[1], percentage[2], percentage[3],
percentage[4], percentage[5], percentage[6]);
percentage[4], percentage[5], percentage[6], percentage[7]);
}
else {
pack_str32(*sock, "A (IPv4)");
Expand All @@ -606,10 +607,12 @@ void getQueryTypes(const int *sock)
pack_float(*sock, percentage[5]);
pack_str32(*sock, "TXT");
pack_float(*sock, percentage[6]);
pack_str32(*sock, "NAPTR");
pack_float(*sock, percentage[7]);
}
}

const char *querytypes[8] = {"A","AAAA","ANY","SRV","SOA","PTR","TXT","UNKN"};
const char *querytypes[TYPE_MAX] = {"A","AAAA","ANY","SRV","SOA","PTR","TXT","NAPTR","UNKN"};

void getAllQueries(const char *client_message, const int *sock)
{
Expand Down
2 changes: 2 additions & 0 deletions src/dnsmasq_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ bool _FTL_new_query(const unsigned int flags, const char *name,
querytype = TYPE_PTR;
else if(strcmp(types,"query[TXT]") == 0)
querytype = TYPE_TXT;
else if(strcmp(types,"query[NAPTR]") == 0)
querytype = TYPE_NAPTR;
else
{
// Return early to avoid accessing querytypedata out of bounds
Expand Down
13 changes: 7 additions & 6 deletions src/resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ static char *resolveHostname(const char *addr)
return hostname;
}

// Back up first ns record in _res and ...
struct in_addr nsbck;
nsbck = _res.nsaddr_list[0].sin_addr;
// Force last available (MAXNS-1) server used for lookups to 127.0.0.1 (FTL itself)
struct in_addr nsbck = { 0 };
// Back up corresponding ns record in _res and ...
nsbck = _res.nsaddr_list[MAXNS-1].sin_addr;
// ... force FTL resolver to 127.0.0.1
inet_pton(AF_INET, "127.0.0.1", &_res.nsaddr_list[0].sin_addr);
inet_pton(AF_INET, "127.0.0.1", &_res.nsaddr_list[MAXNS-1].sin_addr);

// Test if we want to resolve an IPv6 address
if(strstr(addr,":") != NULL)
Expand Down Expand Up @@ -123,8 +124,8 @@ static char *resolveHostname(const char *addr)
hostname = strdup("");
}

// Restore first ns record in _res
_res.nsaddr_list[0].sin_addr = nsbck;
// Restore ns record in _res
_res.nsaddr_list[MAXNS-1].sin_addr = nsbck;

// Return result
return hostname;
Expand Down
3 changes: 2 additions & 1 deletion test/test_suite.bats
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@
[[ ${lines[5]} == "SOA: 0.00" ]]
[[ ${lines[6]} == "PTR: 0.00" ]]
[[ ${lines[7]} == "TXT: 9.09" ]]
[[ ${lines[8]} == "" ]]
[[ ${lines[8]} == "NAPTR: 0.00" ]]
[[ ${lines[9]} == "" ]]
}

# Here and below: Acknowledge that there might be a host name after
Expand Down

0 comments on commit 149f656

Please sign in to comment.