serve-expired: support config reply ttl
This commit is contained in:
@@ -537,6 +537,7 @@ https://github.com/pymumu/smartdns/releases
|
|||||||
|prefetch-domain|域名预先获取功能|no|[yes\|no]|prefetch-domain yes
|
|prefetch-domain|域名预先获取功能|no|[yes\|no]|prefetch-domain yes
|
||||||
|serve-expired|过期缓存服务功能|no|[yes\|no],开启此功能后,如果有请求时尝试回应TTL为0的过期记录,并并发查询记录,以避免查询等待|serve-expired yes
|
|serve-expired|过期缓存服务功能|no|[yes\|no],开启此功能后,如果有请求时尝试回应TTL为0的过期记录,并并发查询记录,以避免查询等待|serve-expired yes
|
||||||
|serve-expired-ttl|过期缓存服务最长超时时间|0|秒,0:表示停用超时,> 0表示指定的超时的秒数|serve-expired-ttl 0
|
|serve-expired-ttl|过期缓存服务最长超时时间|0|秒,0:表示停用超时,> 0表示指定的超时的秒数|serve-expired-ttl 0
|
||||||
|
|serve-expired-reply-ttl|回应的过期缓存TTL|5|秒,0:表示停用超时,> 0表示指定的超时的秒数|serve-expired-reply-ttl 30
|
||||||
|dualstack-ip-selection|双栈IP优选|no|[yes\|no]|dualstack-ip-selection yes
|
|dualstack-ip-selection|双栈IP优选|no|[yes\|no]|dualstack-ip-selection yes
|
||||||
|dualstack-ip-selection-threshold|双栈IP优选阈值|30ms|毫秒|dualstack-ip-selection-threshold [0-1000]
|
|dualstack-ip-selection-threshold|双栈IP优选阈值|30ms|毫秒|dualstack-ip-selection-threshold [0-1000]
|
||||||
|ca-file|证书文件|/etc/ssl/certs/ca-certificates.crt|路径|ca-file /etc/ssl/certs/ca-certificates.crt
|
|ca-file|证书文件|/etc/ssl/certs/ca-certificates.crt|路径|ca-file /etc/ssl/certs/ca-certificates.crt
|
||||||
|
|||||||
@@ -531,6 +531,7 @@ Note: Merlin firmware is derived from ASUS firmware and can theoretically be use
|
|||||||
|prefetch-domain|domain prefetch feature|no|[yes\|no]|prefetch-domain yes
|
|prefetch-domain|domain prefetch feature|no|[yes\|no]|prefetch-domain yes
|
||||||
|serve-expired|Cache serve expired feature|no|[yes\|no], Attempts to serve old responses from cache with a TTL of 0 in the response without waiting for the actual resolution to finish.|serve-expired yes
|
|serve-expired|Cache serve expired feature|no|[yes\|no], Attempts to serve old responses from cache with a TTL of 0 in the response without waiting for the actual resolution to finish.|serve-expired yes
|
||||||
|serve-expired-ttl|Cache serve expired limite TTL|0|second,0:disable,> 0 seconds after expiration|serve-expired-ttl 0
|
|serve-expired-ttl|Cache serve expired limite TTL|0|second,0:disable,> 0 seconds after expiration|serve-expired-ttl 0
|
||||||
|
|serve-expired-reply-ttl|TTL value to use when replying with expired data|5|second,0:disable,> 0 seconds after expiration|serve-expired-reply-ttl 30
|
||||||
|dualstack-ip-selection|Dualstack ip selection|no|[yes\|no]|dualstack-ip-selection yes
|
|dualstack-ip-selection|Dualstack ip selection|no|[yes\|no]|dualstack-ip-selection yes
|
||||||
|dualstack-ip-selection-threshold|Dualstack ip select threadhold|30ms|millisecond|dualstack-ip-selection-threshold [0-1000]
|
|dualstack-ip-selection-threshold|Dualstack ip select threadhold|30ms|millisecond|dualstack-ip-selection-threshold [0-1000]
|
||||||
|ca-file|certificate file|/etc/ssl/certs/ca-certificates.crt|path|ca-file /etc/ssl/certs/ca-certificates.crt
|
|ca-file|certificate file|/etc/ssl/certs/ca-certificates.crt|path|ca-file /etc/ssl/certs/ca-certificates.crt
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ cache-size 4096
|
|||||||
# serve-expired-ttl [num]
|
# serve-expired-ttl [num]
|
||||||
# serve-expired-ttl 0
|
# serve-expired-ttl 0
|
||||||
|
|
||||||
|
# reply TTL value to use when replying with expired data
|
||||||
|
# serve-expired-reply-ttl [num]
|
||||||
|
# serve-expired-reply-ttl 30
|
||||||
|
|
||||||
# List of hosts that supply bogus NX domain results
|
# List of hosts that supply bogus NX domain results
|
||||||
# bogus-nxdomain [ip/subnet]
|
# bogus-nxdomain [ip/subnet]
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ int dns_conf_cachesize = DEFAULT_DNS_CACHE_SIZE;
|
|||||||
int dns_conf_prefetch = 0;
|
int dns_conf_prefetch = 0;
|
||||||
int dns_conf_serve_expired = 0;
|
int dns_conf_serve_expired = 0;
|
||||||
int dns_conf_serve_expired_ttl = 0;
|
int dns_conf_serve_expired_ttl = 0;
|
||||||
|
int dns_conf_serve_expired_reply_ttl = 5;
|
||||||
|
|
||||||
/* upstream servers */
|
/* upstream servers */
|
||||||
struct dns_servers dns_conf_servers[DNS_MAX_SERVERS];
|
struct dns_servers dns_conf_servers[DNS_MAX_SERVERS];
|
||||||
@@ -1366,6 +1367,7 @@ static struct config_item _config_item[] = {
|
|||||||
CONF_YESNO("prefetch-domain", &dns_conf_prefetch),
|
CONF_YESNO("prefetch-domain", &dns_conf_prefetch),
|
||||||
CONF_YESNO("serve-expired", &dns_conf_serve_expired),
|
CONF_YESNO("serve-expired", &dns_conf_serve_expired),
|
||||||
CONF_INT("serve-expired-ttl", &dns_conf_serve_expired_ttl, 0, CONF_INT_MAX),
|
CONF_INT("serve-expired-ttl", &dns_conf_serve_expired_ttl, 0, CONF_INT_MAX),
|
||||||
|
CONF_INT("serve-expired-reply-ttl", &dns_conf_serve_expired_reply_ttl, 0, CONF_INT_MAX),
|
||||||
CONF_YESNO("dualstack-ip-selection", &dns_conf_dualstack_ip_selection),
|
CONF_YESNO("dualstack-ip-selection", &dns_conf_dualstack_ip_selection),
|
||||||
CONF_INT("dualstack-ip-selection-threshold", &dns_conf_dualstack_ip_selection_threshold, 0, 1000),
|
CONF_INT("dualstack-ip-selection-threshold", &dns_conf_dualstack_ip_selection_threshold, 0, 1000),
|
||||||
CONF_CUSTOM("log-level", _config_log_level, NULL),
|
CONF_CUSTOM("log-level", _config_log_level, NULL),
|
||||||
|
|||||||
@@ -205,6 +205,7 @@ extern int dns_conf_cachesize;
|
|||||||
extern int dns_conf_prefetch;
|
extern int dns_conf_prefetch;
|
||||||
extern int dns_conf_serve_expired;
|
extern int dns_conf_serve_expired;
|
||||||
extern int dns_conf_serve_expired_ttl;
|
extern int dns_conf_serve_expired_ttl;
|
||||||
|
extern int dns_conf_serve_expired_reply_ttl;
|
||||||
extern struct dns_servers dns_conf_servers[DNS_MAX_SERVERS];
|
extern struct dns_servers dns_conf_servers[DNS_MAX_SERVERS];
|
||||||
extern int dns_conf_server_num;
|
extern int dns_conf_server_num;
|
||||||
|
|
||||||
|
|||||||
@@ -2264,6 +2264,16 @@ static void _dns_server_process_speed_check_rule(struct dns_request *request)
|
|||||||
request->check_order_list = check_order;
|
request->check_order_list = check_order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _dns_server_get_expired_ttl_reply(struct dns_cache *dns_cache)
|
||||||
|
{
|
||||||
|
int ttl = dns_cache_get_ttl(dns_cache);
|
||||||
|
if (ttl > 0) {
|
||||||
|
return ttl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dns_conf_serve_expired_reply_ttl;
|
||||||
|
}
|
||||||
|
|
||||||
static int _dns_server_process_cache_addr(struct dns_request *request, struct dns_cache *dns_cache)
|
static int _dns_server_process_cache_addr(struct dns_request *request, struct dns_cache *dns_cache)
|
||||||
{
|
{
|
||||||
struct dns_cache_addr *cache_addr = (struct dns_cache_addr *)dns_cache_get_data(dns_cache);
|
struct dns_cache_addr *cache_addr = (struct dns_cache_addr *)dns_cache_get_data(dns_cache);
|
||||||
@@ -2275,12 +2285,12 @@ static int _dns_server_process_cache_addr(struct dns_request *request, struct dn
|
|||||||
switch (request->qtype) {
|
switch (request->qtype) {
|
||||||
case DNS_T_A:
|
case DNS_T_A:
|
||||||
memcpy(request->ipv4_addr, cache_addr->addr_data.ipv4_addr, DNS_RR_A_LEN);
|
memcpy(request->ipv4_addr, cache_addr->addr_data.ipv4_addr, DNS_RR_A_LEN);
|
||||||
request->ttl_v4 = dns_cache_get_ttl(dns_cache);
|
request->ttl_v4 = _dns_server_get_expired_ttl_reply(dns_cache);
|
||||||
request->has_ipv4 = 1;
|
request->has_ipv4 = 1;
|
||||||
break;
|
break;
|
||||||
case DNS_T_AAAA:
|
case DNS_T_AAAA:
|
||||||
memcpy(request->ipv6_addr, cache_addr->addr_data.ipv6_addr, DNS_RR_AAAA_LEN);
|
memcpy(request->ipv6_addr, cache_addr->addr_data.ipv6_addr, DNS_RR_AAAA_LEN);
|
||||||
request->ttl_v6 = dns_cache_get_ttl(dns_cache);
|
request->ttl_v6 = _dns_server_get_expired_ttl_reply(dns_cache);
|
||||||
request->has_ipv6 = 1;
|
request->has_ipv6 = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user