mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-15 18:03:30 +00:00
103 lines
4.2 KiB
Diff
103 lines
4.2 KiB
Diff
--- a/src/dnsmasq.h
|
|
+++ b/src/dnsmasq.h
|
|
@@ -1116,7 +1116,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;
|
|
u32 umbrella_org;
|
|
u32 umbrella_asset;
|
|
--- a/src/option.c
|
|
+++ b/src/option.c
|
|
@@ -181,6 +181,7 @@
|
|
#define LOPT_STRIP_MAC 372
|
|
#define LOPT_CONF_OPT 373
|
|
#define LOPT_CONF_SCRIPT 374
|
|
+#define LOPT_MINTTL 375
|
|
|
|
#ifdef HAVE_GETOPT_LONG
|
|
static const struct option opts[] =
|
|
@@ -292,6 +293,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 },
|
|
@@ -425,6 +427,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 },
|
|
@@ -3047,6 +3050,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 */
|
|
@@ -3058,6 +3062,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
|
|
@@ -607,6 +607,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 */
|
|
|
|
@@ -615,6 +616,14 @@ int extract_addresses(struct dns_header *header, size_t qlen, char *name, time_t
|
|
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);
|
|
@@ -722,6 +731,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 */
|
|
@@ -730,6 +740,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);
|