Skip to content

Commit

Permalink
Merge pull request #1043 from pi-hole/release/v5.6
Browse files Browse the repository at this point in the history
Pi-hole FTL v5.6
  • Loading branch information
PromoFaux committed Jan 27, 2021
2 parents 3ecec15 + 88dc720 commit da89cc6
Show file tree
Hide file tree
Showing 52 changed files with 258 additions and 98 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
cmake_minimum_required(VERSION 2.8.12)
project(PIHOLE_FTL C)

set(DNSMASQ_VERSION pi-hole-2.83)
set(DNSMASQ_VERSION pi-hole-2.84)

add_subdirectory(src)
2 changes: 1 addition & 1 deletion src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ void getAllQueries(const char *client_message, const int *sock)
// If the domain of this query did not match, the CNAME
// domain may still match - we have to check it in
// addition if this query is of CNAME blocked type
else if(query->CNAME_domainID > -1)
else if(query->CNAME_domainID == domainid)
{
// Get this query
}
Expand Down
2 changes: 1 addition & 1 deletion src/dnsmasq/arp.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/dnsmasq/auth.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/dnsmasq/blockdata.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/dnsmasq/bpf.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/dnsmasq/cache.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
12 changes: 6 additions & 6 deletions src/dnsmasq/config.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -122,8 +122,8 @@ HAVE_AUTH
define this to include the facility to act as an authoritative DNS
server for one or more zones.
HAVE_NETTLEHASH
include just hash function from nettle, but no DNSSEC.
HAVE_CRYPTOHASH
include just hash function from crypto library, but no DNSSEC.
HAVE_DNSSEC
include DNSSEC validator.
Expand Down Expand Up @@ -192,7 +192,7 @@ RESOLVFILE
/* #define HAVE_IDN */
/* #define HAVE_LIBIDN2 */
/* #define HAVE_CONNTRACK */
/* #define HAVE_NETTLEHASH */
/* #define HAVE_CRYPTOHASH */
/* #define HAVE_DNSSEC */


Expand Down Expand Up @@ -426,10 +426,10 @@ static char *compile_opts =
"no-"
#endif
"auth "
#if !defined(HAVE_NETTLEHASH) && !defined(HAVE_DNSSEC)
#if !defined(HAVE_CRYPTOHASH) && !defined(HAVE_DNSSEC)
"no-"
#endif
"nettlehash "
"cryptohash "
#ifndef HAVE_DNSSEC
"no-"
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/dnsmasq/conntrack.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
4 changes: 2 additions & 2 deletions src/dnsmasq/crypto.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -27,7 +27,7 @@
#endif
#endif

#if defined(HAVE_DNSSEC) || defined(HAVE_NETTLEHASH)
#if defined(HAVE_DNSSEC) || defined(HAVE_CRYPTOHASH)
#include <nettle/nettle-meta.h>
#include <nettle/bignum.h>

Expand Down
2 changes: 1 addition & 1 deletion src/dnsmasq/dbus.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/dnsmasq/dhcp-common.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/dnsmasq/dhcp-protocol.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/dnsmasq/dhcp.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/dnsmasq/dhcp6-protocol.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/dnsmasq/dhcp6.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/dnsmasq/dns-protocol.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
4 changes: 2 additions & 2 deletions src/dnsmasq/dnsmasq.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -392,8 +392,8 @@ int main_dnsmasq (int argc, char **argv)
if (daemon->port != 0)
{
cache_init();

blockdata_init();
hash_questions_init();
}

#ifdef HAVE_INOTIFY
Expand Down
14 changes: 10 additions & 4 deletions src/dnsmasq/dnsmasq.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -14,7 +14,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#define COPYRIGHT "Copyright (c) 2000-2020 Simon Kelley"
#define COPYRIGHT "Copyright (c) 2000-2021 Simon Kelley"

/* We do defines that influence behavior of stdio.h, so complain
if included too early. */
Expand Down Expand Up @@ -157,7 +157,11 @@ extern int capget(cap_user_header_t header, cap_user_data_t data);
#include <priv.h>
#endif

#if defined(HAVE_DNSSEC) || defined(HAVE_NETTLEHASH)
/* Backwards compat with 2.83 */
#if defined(HAVE_NETTLEHASH)
# define HAVE_CRYPTOHASH
#endif
#if defined(HAVE_DNSSEC) || defined(HAVE_CRYPTOHASH)
# include <nettle/nettle-meta.h>
#endif

Expand Down Expand Up @@ -666,14 +670,15 @@ struct frec {
union mysockaddr source;
union all_addr dest;
unsigned int iface, log_id;
int fd;
unsigned short orig_id;
struct frec_src *next;
} frec_src;
struct server *sentto; /* NULL means free */
struct randfd *rfd4;
struct randfd *rfd6;
unsigned short new_id;
int fd, forwardall, flags;
int forwardall, flags;
time_t time;
unsigned char *hash[HASH_SIZE];
#ifdef HAVE_DNSSEC
Expand Down Expand Up @@ -1265,6 +1270,7 @@ size_t filter_rrsigs(struct dns_header *header, size_t plen);
int setup_timestamp(void);

/* hash_questions.c */
void hash_questions_init(void);
unsigned char *hash_questions(struct dns_header *header, size_t plen, char *name);

/* crypto.c */
Expand Down
69 changes: 48 additions & 21 deletions src/dnsmasq/dnssec.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,37 +334,64 @@ static int sort_rrset(struct dns_header *header, size_t plen, u16 *rr_desc, int
if (!CHECK_LEN(header, state2.ip, plen, rdlen2))
return rrsetidx; /* short packet */
state2.end = state2.ip + rdlen2;

while (1)

/* If the RR has no names in it then canonicalisation
is the identity function and we can compare
the RRs directly. If not we compare the
canonicalised RRs one byte at a time. */
if (*rr_desc == (u16)-1)
{
int ok1, ok2;
int rdmin = rdlen1 > rdlen2 ? rdlen2 : rdlen1;
int cmp = memcmp(state1.ip, state2.ip, rdmin);

ok1 = get_rdata(header, plen, &state1);
ok2 = get_rdata(header, plen, &state2);

if (!ok1 && !ok2)
if (cmp > 0 || (cmp == 0 && rdlen1 > rdmin))
{
unsigned char *tmp = rrset[i+1];
rrset[i+1] = rrset[i];
rrset[i] = tmp;
swap = 1;
}
else if (cmp == 0 && (rdlen1 == rdlen2))
{
/* Two RRs are equal, remove one copy. RFC 4034, para 6.3 */
for (j = i+1; j < rrsetidx-1; j++)
rrset[j] = rrset[j+1];
rrsetidx--;
i--;
break;
}
else if (ok1 && (!ok2 || *state1.op > *state2.op))
{
unsigned char *tmp = rrset[i+1];
rrset[i+1] = rrset[i];
rrset[i] = tmp;
swap = 1;
break;
}
else if (ok2 && (!ok1 || *state2.op > *state1.op))
break;

/* arrive here when bytes are equal, go round the loop again
and compare the next ones. */
}
else
/* Comparing canonicalised RRs, byte-at-a-time. */
while (1)
{
int ok1, ok2;

ok1 = get_rdata(header, plen, &state1);
ok2 = get_rdata(header, plen, &state2);

if (!ok1 && !ok2)
{
/* Two RRs are equal, remove one copy. RFC 4034, para 6.3 */
for (j = i+1; j < rrsetidx-1; j++)
rrset[j] = rrset[j+1];
rrsetidx--;
i--;
break;
}
else if (ok1 && (!ok2 || *state1.op > *state2.op))
{
unsigned char *tmp = rrset[i+1];
rrset[i+1] = rrset[i];
rrset[i] = tmp;
swap = 1;
break;
}
else if (ok2 && (!ok1 || *state2.op > *state1.op))
break;

/* arrive here when bytes are equal, go round the loop again
and compare the next ones. */
}
}
} while (swap);

Expand Down
2 changes: 1 addition & 1 deletion src/dnsmasq/domain.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/dnsmasq/dump.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/dnsmasq/edns0.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
15 changes: 12 additions & 3 deletions src/dnsmasq/forward.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2020 Simon Kelley
/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -391,8 +391,12 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
new->dest = *dst_addr;
new->log_id = daemon->log_id;
new->iface = dst_iface;
new->fd = udpfd;
}

// Pi-hole modification
FTL_query_in_progress(daemon->log_id);

return 1;
}

Expand All @@ -415,8 +419,8 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
forward->frec_src.dest = *dst_addr;
forward->frec_src.iface = dst_iface;
forward->frec_src.next = NULL;
forward->frec_src.fd = udpfd;
forward->new_id = get_id();
forward->fd = udpfd;
memcpy(forward->hash, hash, HASH_SIZE);
forward->forwardall = 0;
forward->flags = fwd_flags;
Expand Down Expand Up @@ -1329,6 +1333,9 @@ void reply_query(int fd, int family, time_t now)
}
#endif

// Pi-hole modification
int first_ID = -1;

for (src = &forward->frec_src; src; src = src->next)
{
header->id = htons(src->orig_id);
Expand All @@ -1337,7 +1344,7 @@ void reply_query(int fd, int family, time_t now)
dump_packet(DUMP_REPLY, daemon->packet, (size_t)nn, NULL, &src->source);
#endif

send_from(forward->fd, option_bool(OPT_NOWILD) || option_bool (OPT_CLEVERBIND), daemon->packet, nn,
send_from(src->fd, option_bool(OPT_NOWILD) || option_bool (OPT_CLEVERBIND), daemon->packet, nn,
&src->source, &src->dest, src->iface);

if (option_bool(OPT_EXTRALOG) && src != &forward->frec_src)
Expand All @@ -1346,6 +1353,8 @@ void reply_query(int fd, int family, time_t now)
daemon->log_source_addr = &src->source;
log_query(F_UPSTREAM, "query", NULL, "duplicate");
}
/* Pi-hole modification */
FTL_duplicate_reply(src->log_id, &first_ID);
}
}

Expand Down

0 comments on commit da89cc6

Please sign in to comment.