|
|
@@ -1,102 +0,0 @@
|
|
|
---- a/src/dnsmasq.h
|
|
|
-+++ b/src/dnsmasq.h
|
|
|
-@@ -1042,7 +1042,7 @@ extern struct daemon {
|
|
|
- int max_logs; /* queue limit */
|
|
|
- int cachesize, ftabsize;
|
|
|
- int port, query_port, min_port, max_port;
|
|
|
-- unsigned long local_ttl, neg_ttl, max_ttl, min_cache_ttl, max_cache_ttl, auth_ttl, dhcp_ttl, use_dhcp_ttl;
|
|
|
-+ unsigned long local_ttl, neg_ttl, min_ttl, max_ttl, min_cache_ttl, max_cache_ttl, auth_ttl, dhcp_ttl, use_dhcp_ttl;
|
|
|
- char *dns_client_id;
|
|
|
- struct hostsfile *addn_hosts;
|
|
|
- struct dhcp_context *dhcp, *dhcp6;
|
|
|
---- a/src/option.c
|
|
|
-+++ b/src/option.c
|
|
|
-@@ -168,6 +168,7 @@ struct myoption {
|
|
|
- #define LOPT_SINGLE_PORT 359
|
|
|
- #define LOPT_SCRIPT_TIME 360
|
|
|
- #define LOPT_PXE_VENDOR 361
|
|
|
-+#define LOPT_MINTTL 362
|
|
|
-
|
|
|
- #ifdef HAVE_GETOPT_LONG
|
|
|
- static const struct option opts[] =
|
|
|
-@@ -286,6 +287,7 @@ static const struct myoption opts[] =
|
|
|
- { "dhcp-name-match", 1, 0, LOPT_NAME_MATCH },
|
|
|
- { "dhcp-broadcast", 2, 0, LOPT_BROADCAST },
|
|
|
- { "neg-ttl", 1, 0, LOPT_NEGTTL },
|
|
|
-+ { "min-ttl", 1, 0, LOPT_MINTTL },
|
|
|
- { "max-ttl", 1, 0, LOPT_MAXTTL },
|
|
|
- { "min-cache-ttl", 1, 0, LOPT_MINCTTL },
|
|
|
- { "max-cache-ttl", 1, 0, LOPT_MAXCTTL },
|
|
|
-@@ -413,6 +415,7 @@ static struct {
|
|
|
- { 't', ARG_ONE, "<host_name>", gettext_noop("Specify default target in an MX record."), NULL },
|
|
|
- { 'T', ARG_ONE, "<integer>", gettext_noop("Specify time-to-live in seconds for replies from /etc/hosts."), NULL },
|
|
|
- { LOPT_NEGTTL, ARG_ONE, "<integer>", gettext_noop("Specify time-to-live in seconds for negative caching."), NULL },
|
|
|
-+ { LOPT_MINTTL, ARG_ONE, "<integer>", gettext_noop("Specify time-to-live in seconds for minimum TTL to send to clients."), NULL },
|
|
|
- { LOPT_MAXTTL, ARG_ONE, "<integer>", gettext_noop("Specify time-to-live in seconds for maximum TTL to send to clients."), NULL },
|
|
|
- { LOPT_MAXCTTL, ARG_ONE, "<integer>", gettext_noop("Specify time-to-live ceiling for cache."), NULL },
|
|
|
- { LOPT_MINCTTL, ARG_ONE, "<integer>", gettext_noop("Specify time-to-live floor for cache."), NULL },
|
|
|
-@@ -2823,6 +2826,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|
|
-
|
|
|
- case 'T': /* --local-ttl */
|
|
|
- case LOPT_NEGTTL: /* --neg-ttl */
|
|
|
-+ case LOPT_MINTTL: /* --min-ttl */
|
|
|
- case LOPT_MAXTTL: /* --max-ttl */
|
|
|
- case LOPT_MINCTTL: /* --min-cache-ttl */
|
|
|
- case LOPT_MAXCTTL: /* --max-cache-ttl */
|
|
|
-@@ -2834,6 +2838,8 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|
|
- ret_err(gen_err);
|
|
|
- else if (option == LOPT_NEGTTL)
|
|
|
- daemon->neg_ttl = (unsigned long)ttl;
|
|
|
-+ else if (option == LOPT_MINTTL)
|
|
|
-+ daemon->min_ttl = (unsigned long)ttl;
|
|
|
- else if (option == LOPT_MAXTTL)
|
|
|
- daemon->max_ttl = (unsigned long)ttl;
|
|
|
- else if (option == LOPT_MINCTTL)
|
|
|
---- a/src/rfc1035.c
|
|
|
-+++ b/src/rfc1035.c
|
|
|
-@@ -606,6 +606,7 @@ int extract_addresses(struct dns_header *header, size_t qlen, char *name, time_t
|
|
|
- for (j = 0; j < ntohs(header->ancount); j++)
|
|
|
- {
|
|
|
- int secflag = 0;
|
|
|
-+ unsigned long mttl = 0;
|
|
|
- unsigned char *tmp = namep;
|
|
|
- /* the loop body overwrites the original name, so get it back here. */
|
|
|
- if (!extract_name(header, qlen, &tmp, name, 1, 0) ||
|
|
|
-@@ -616,6 +617,14 @@ int extract_addresses(struct dns_header *header, size_t qlen, char *name, time_t
|
|
|
- GETSHORT(aqclass, p1);
|
|
|
- GETLONG(attl, p1);
|
|
|
- if ((daemon->max_ttl != 0) && (attl > daemon->max_ttl) && !is_sign)
|
|
|
-+ {
|
|
|
-+ mttl = daemon->max_ttl;
|
|
|
-+ }
|
|
|
-+ if ((daemon->min_ttl != 0) && (attl < daemon->min_ttl) && !is_sign)
|
|
|
-+ {
|
|
|
-+ mttl = daemon->min_ttl;
|
|
|
-+ }
|
|
|
-+ if (mttl != 0)
|
|
|
- {
|
|
|
- (p1) -= 4;
|
|
|
- PUTLONG(daemon->max_ttl, p1);
|
|
|
-@@ -704,6 +713,7 @@ int extract_addresses(struct dns_header *header, size_t qlen, char *name, time_t
|
|
|
- for (j = 0; j < ntohs(header->ancount); j++)
|
|
|
- {
|
|
|
- int secflag = 0;
|
|
|
-+ unsigned long mttl = 0;
|
|
|
-
|
|
|
- if (!(res = extract_name(header, qlen, &p1, name, 0, 10)))
|
|
|
- return 0; /* bad packet */
|
|
|
-@@ -712,6 +722,14 @@ int extract_addresses(struct dns_header *header, size_t qlen, char *name, time_t
|
|
|
- GETSHORT(aqclass, p1);
|
|
|
- GETLONG(attl, p1);
|
|
|
- if ((daemon->max_ttl != 0) && (attl > daemon->max_ttl) && !is_sign)
|
|
|
-+ {
|
|
|
-+ mttl = daemon->max_ttl;
|
|
|
-+ }
|
|
|
-+ if ((daemon->min_ttl != 0) && (attl < daemon->min_ttl) && !is_sign)
|
|
|
-+ {
|
|
|
-+ mttl = daemon->min_ttl;
|
|
|
-+ }
|
|
|
-+ if (mttl != 0)
|
|
|
- {
|
|
|
- (p1) -= 4;
|
|
|
- PUTLONG(daemon->max_ttl, p1);
|