Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
QiuSimons authored Jun 5, 2020
1 parent 1d34712 commit 63bb7e3
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 85 deletions.
59 changes: 59 additions & 0 deletions PATCH/900-add-filter-aaaa-option.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
diff -rNEZbwBdu3 a/src/dnsmasq.h b/src/dnsmasq.h
--- a/src/dnsmasq.h 2020-04-09 00:32:53.000000000 +0800
+++ b/src/dnsmasq.h 2020-06-05 23:03:45.941176855 +0800
@@ -269,7 +269,8 @@
#define OPT_IGNORE_CLID 59
#define OPT_SINGLE_PORT 60
#define OPT_LEASE_RENEW 61
-#define OPT_LAST 62
+#define OPT_FILTER_AAAA 62
+#define OPT_LAST 63

#define OPTION_BITS (sizeof(unsigned int)*8)
#define OPTION_SIZE ( (OPT_LAST/OPTION_BITS)+((OPT_LAST%OPTION_BITS)!=0) )
diff -rNEZbwBdu3 a/src/option.c b/src/option.c
--- a/src/option.c 2020-04-09 00:32:53.000000000 +0800
+++ b/src/option.c 2020-06-05 23:06:29.880350271 +0800
@@ -167,6 +167,7 @@
#define LOPT_IGNORE_CLID 358
#define LOPT_SINGLE_PORT 359
#define LOPT_SCRIPT_TIME 360
+#define LOPT_FILTER_AAAA 361

#ifdef HAVE_GETOPT_LONG
static const struct option opts[] =
@@ -339,6 +340,7 @@
{ "dumpfile", 1, 0, LOPT_DUMPFILE },
{ "dumpmask", 1, 0, LOPT_DUMPMASK },
{ "dhcp-ignore-clid", 0, 0, LOPT_IGNORE_CLID },
+ { "filter-aaaa", 0, 0, LOPT_FILTER_AAAA },
{ NULL, 0, 0, 0 }
};

@@ -518,6 +520,7 @@
{ LOPT_DUMPFILE, ARG_ONE, "<path>", gettext_noop("Path to debug packet dump file"), NULL },
{ LOPT_DUMPMASK, ARG_ONE, "<hex>", gettext_noop("Mask which packets to dump"), NULL },
{ LOPT_SCRIPT_TIME, OPT_LEASE_RENEW, NULL, gettext_noop("Call dhcp-script when lease expiry changes."), NULL },
+ { LOPT_FILTER_AAAA, OPT_FILTER_AAAA, NULL, gettext_noop("Filter all AAAA requests."), NULL },
{ 0, 0, NULL, NULL, NULL }
};

diff -rNEZbwBdu3 a/src/rfc1035.c b/src/rfc1035.c
--- a/src/rfc1035.c 2020-04-09 00:32:53.000000000 +0800
+++ b/src/rfc1035.c 2020-06-05 23:08:46.476106541 +0800
@@ -1955,6 +1955,15 @@
}
}

+ //patch to filter aaaa forwards
+ if (qtype == T_AAAA && option_bool(OPT_FILTER_AAAA) ){
+ //return a null reply
+ ans = 1;
+ if (!dryrun) log_query(F_CONFIG | F_IPV6 | F_NEG, name, &addr, NULL);
+ break;
+ }
+ //end of patch
+
if (!ans)
return 0; /* failed to answer a question */
}
86 changes: 1 addition & 85 deletions PATCH/dnsmasq-add-filter-aaaa-option.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ Signed-off-by: Chuck <[email protected]>
---
.../network/services/dnsmasq/files/dhcp.conf | 1 +
.../services/dnsmasq/files/dnsmasq.init | 1 +
.../patches/900-add-filter-aaaa-option.patch | 76 +++++++++++++++++++
3 files changed, 78 insertions(+)
create mode 100644 package/network/services/dnsmasq/patches/900-add-filter-aaaa-option.patch
2 files changed, 2 insertions(+)

diff --git a/package/network/services/dnsmasq/files/dhcp.conf b/package/network/services/dnsmasq/files/dhcp.conf
index 360c7d79eee..c9407f5e649 100644
Expand All @@ -35,85 +33,3 @@ index 06d83b06deb..08ff64d659f 100644
append_bool "$cfg" rapidcommit "--dhcp-rapid-commit"
append_bool "$cfg" scriptarp "--script-arp"

diff --git a/package/network/services/dnsmasq/patches/900-add-filter-aaaa-option.patch b/package/network/services/dnsmasq/patches/900-add-filter-aaaa-option.patch
new file mode 100644
index 00000000000..4f9e5393fe9
--- /dev/null
+++ b/package/network/services/dnsmasq/patches/900-add-filter-aaaa-option.patch
@@ -0,0 +1,76 @@
+From 966471712184cfb3b067f2ae8dad9d8e2a896cae Mon Sep 17 00:00:00 2001
+From: Bearice Ren <[email protected]>
+Date: Tue, 20 Sep 2016 11:52:08 +0800
+Subject: [PATCH] add filter-aaaa option
+
+---
+ src/dnsmasq.h | 3 ++-
+ src/option.c | 3 +++
+ src/rfc1035.c | 9 +++++++++
+ 3 files changed, 14 insertions(+), 1 deletion(-)
+
+diff --git a/src/dnsmasq.h b/src/dnsmasq.h
+index f53e9a5..e9617a6 100644
+--- a/src/dnsmasq.h
++++ b/src/dnsmasq.h
+@@ -262,7 +262,8 @@ struct event_desc {
+ #define OPT_TFTP_APREF_MAC 56
+ #define OPT_RAPID_COMMIT 57
+ #define OPT_UBUS 58
+-#define OPT_LAST 59
++#define OPT_FILTER_AAAA 59
++#define OPT_LAST 60
+
+ /* extra flags for my_syslog, we use a couple of facilities since they are known
+ not to occupy the same bits as priorities, no matter how syslog.h is set up. */
+diff --git a/src/option.c b/src/option.c
+index 44b1dc5..f954d7f 100644
+--- a/src/option.c
++++ b/src/option.c
+@@ -166,6 +166,7 @@ struct myoption {
+ #define LOPT_UBUS 354
+ #define LOPT_NAME_MATCH 355
+ #define LOPT_CAA 356
++#define LOPT_FILTER_AAAA 357
+
+ #ifdef HAVE_GETOPT_LONG
+ static const struct option opts[] =
+@@ -337,6 +338,7 @@ static const struct myoption opts[] =
+ { "dhcp-rapid-commit", 0, 0, LOPT_RAPID_COMMIT },
+ { "dumpfile", 1, 0, LOPT_DUMPFILE },
+ { "dumpmask", 1, 0, LOPT_DUMPMASK },
++ { "filter-aaaa", 0, 0, LOPT_FILTER_AAAA },
+ { NULL, 0, 0, 0 }
+ };
+
+@@ -515,6 +517,7 @@ static struct {
+ { LOPT_RAPID_COMMIT, OPT_RAPID_COMMIT, NULL, gettext_noop("Enables DHCPv4 Rapid Commit option."), NULL },
+ { LOPT_DUMPFILE, ARG_ONE, "<path>", gettext_noop("Path to debug packet dump file"), NULL },
+ { LOPT_DUMPMASK, ARG_ONE, "<hex>", gettext_noop("Mask which packets to dump"), NULL },
++ { LOPT_FILTER_AAAA, OPT_FILTER_AAAA, NULL, gettext_noop("Filter all AAAA requests."), NULL },
+ { 0, 0, NULL, NULL, NULL }
+ };
+
+diff --git a/src/rfc1035.c b/src/rfc1035.c
+index 6290f22..b67b169 100644
+--- a/src/rfc1035.c
++++ b/src/rfc1035.c
+@@ -1881,6 +1881,15 @@ size_t answer_request(struct dns_header *header, char *limit, size_t qlen,
+ }
+ }
+
++ //patch to filter aaaa forwards
++ if (qtype == T_AAAA && option_bool(OPT_FILTER_AAAA) ){
++ //return a null reply
++ ans = 1;
++ if (!dryrun) log_query(F_CONFIG | F_IPV6 | F_NEG, name, &addr, NULL);
++ break;
++ }
++ //end of patch
++
+ if (!ans)
+ return 0; /* failed to answer a question */
+ }
+--
+2.17.1
+

0 comments on commit 63bb7e3

Please sign in to comment.