|
| 1 | +From 98694642e85ae2dffba25ab4a94415e02d01db44 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Simon Lelievre <simon@lelievre.me> |
| 3 | +Date: Fri, 18 Sep 2015 15:07:31 +0200 |
| 4 | +Subject: [PATCH 1/2] filter aaaa |
| 5 | + |
| 6 | +--- |
| 7 | + src/dnsmasq.h | 3 ++- |
| 8 | + src/option.c | 6 +++++- |
| 9 | + src/rfc1035.c | 11 ++++++++++- |
| 10 | + 3 files changed, 17 insertions(+), 3 deletions(-) |
| 11 | + |
| 12 | +diff --git a/src/dnsmasq.h b/src/dnsmasq.h |
| 13 | +index cf1a782..8f92a02 100644 |
| 14 | +--- a/src/dnsmasq.h |
| 15 | ++++ b/src/dnsmasq.h |
| 16 | +@@ -242,7 +242,8 @@ struct event_desc { |
| 17 | + #define OPT_LOOP_DETECT 50 |
| 18 | + #define OPT_EXTRALOG 51 |
| 19 | + #define OPT_TFTP_NO_FAIL 52 |
| 20 | +-#define OPT_LAST 53 |
| 21 | ++#define OPT_FILTER_AAAA 53 |
| 22 | ++#define OPT_LAST 54 |
| 23 | + |
| 24 | + /* extra flags for my_syslog, we use a couple of facilities since they are known |
| 25 | + not to occupy the same bits as priorities, no matter how syslog.h is set up. */ |
| 26 | +diff --git a/src/option.c b/src/option.c |
| 27 | +index ecc2619..a575fa4 100644 |
| 28 | +--- a/src/option.c |
| 29 | ++++ b/src/option.c |
| 30 | +@@ -154,6 +154,8 @@ struct myoption { |
| 31 | + #define LOPT_HOST_INOTIFY 342 |
| 32 | + #define LOPT_DNSSEC_STAMP 343 |
| 33 | + #define LOPT_TFTP_NO_FAIL 344 |
| 34 | ++#define LOPT_FILTER_AAAA 345 |
| 35 | ++ |
| 36 | + |
| 37 | + #ifdef HAVE_GETOPT_LONG |
| 38 | + static const struct option opts[] = |
| 39 | +@@ -313,6 +315,7 @@ static const struct myoption opts[] = |
| 40 | + { "quiet-dhcp6", 0, 0, LOPT_QUIET_DHCP6 }, |
| 41 | + { "quiet-ra", 0, 0, LOPT_QUIET_RA }, |
| 42 | + { "dns-loop-detect", 0, 0, LOPT_LOOP_DETECT }, |
| 43 | ++ { "filter-aaaa", 0, 0, LOPT_FILTER_AAAA }, |
| 44 | + { NULL, 0, 0, 0 } |
| 45 | + }; |
| 46 | + |
| 47 | +@@ -478,7 +481,8 @@ static struct { |
| 48 | + { LOPT_QUIET_RA, OPT_QUIET_RA, NULL, gettext_noop("Do not log RA."), NULL }, |
| 49 | + { LOPT_LOCAL_SERVICE, OPT_LOCAL_SERVICE, NULL, gettext_noop("Accept queries only from directly-connected networks"), NULL }, |
| 50 | + { LOPT_LOOP_DETECT, OPT_LOOP_DETECT, NULL, gettext_noop("Detect and remove DNS forwarding loops"), NULL }, |
| 51 | +- { LOPT_IGNORE_ADDR, ARG_DUP, "<ipaddr>", gettext_noop("Ignore DNS responses containing ipaddr."), NULL }, |
| 52 | ++ { LOPT_IGNORE_ADDR, ARG_DUP, "<ipaddr>", gettext_noop("Ignore DNS responses containing ipaddr."), NULL }, |
| 53 | ++ { LOPT_FILTER_AAAA, OPT_FILTER_AAAA, NULL, gettext_noop("Filter all AAAA requests."), NULL }, |
| 54 | + { 0, 0, NULL, NULL, NULL } |
| 55 | + }; |
| 56 | + |
| 57 | +diff --git a/src/rfc1035.c b/src/rfc1035.c |
| 58 | +index 56647b0..7463fd2 100644 |
| 59 | +--- a/src/rfc1035.c |
| 60 | ++++ b/src/rfc1035.c |
| 61 | +@@ -1895,7 +1895,16 @@ size_t answer_request(struct dns_header *header, char *limit, size_t qlen, |
| 62 | + #else |
| 63 | + break; |
| 64 | + #endif |
| 65 | +- |
| 66 | ++ |
| 67 | ++ //patch to filter aaaa forwards |
| 68 | ++ if (qtype == T_AAAA && option_bool(OPT_FILTER_AAAA) ){ |
| 69 | ++ //return a null reply |
| 70 | ++ ans = 1; |
| 71 | ++ if (!dryrun) log_query(F_CONFIG | F_IPV6 | F_NEG, name, &addr, NULL); |
| 72 | ++ break; |
| 73 | ++ } |
| 74 | ++ //end of patch |
| 75 | ++ |
| 76 | + if (qtype != type && qtype != T_ANY) |
| 77 | + continue; |
| 78 | + |
| 79 | +-- |
| 80 | +2.1.4 |
| 81 | + |
| 82 | + |
| 83 | +From 3626e6a0e2bf9cdd085f58bb82b7567041a7de78 Mon Sep 17 00:00:00 2001 |
| 84 | +From: Simon Lelievre <simon@lelievre.me> |
| 85 | +Date: Fri, 18 Sep 2015 15:35:48 +0200 |
| 86 | +Subject: [PATCH 2/2] add source |
| 87 | + |
| 88 | +--- |
| 89 | + src/rfc1035.c | 1 + |
| 90 | + 1 file changed, 1 insertion(+) |
| 91 | + |
| 92 | +diff --git a/src/rfc1035.c b/src/rfc1035.c |
| 93 | +index 7463fd2..fa7b211 100644 |
| 94 | +--- a/src/rfc1035.c |
| 95 | ++++ b/src/rfc1035.c |
| 96 | +@@ -1897,6 +1897,7 @@ size_t answer_request(struct dns_header *header, char *limit, size_t qlen, |
| 97 | + #endif |
| 98 | + |
| 99 | + //patch to filter aaaa forwards |
| 100 | ++ //found : https://gist.github.com/bearice/7d3dc0e63e003d752622 |
| 101 | + if (qtype == T_AAAA && option_bool(OPT_FILTER_AAAA) ){ |
| 102 | + //return a null reply |
| 103 | + ans = 1; |
| 104 | +-- |
| 105 | +2.1.4 |
| 106 | + |
0 commit comments