conf: add local-ttl option
This commit is contained in:
@@ -563,6 +563,7 @@ rtt min/avg/max/mdev = 5.954/6.133/6.313/0.195 ms
|
||||
| rr-ttl-min | 允许的最小 TTL 值 | 远程查询结果 | 大于 0 的数字 | rr-ttl-min 60 |
|
||||
| rr-ttl-max | 允许的最大 TTL 值 | 远程查询结果 | 大于 0 的数字 | rr-ttl-max 600 |
|
||||
| rr-ttl-reply-max | 允许返回给客户端的最大 TTL 值 | 远程查询结果 | 大于 0 的数字 | rr-ttl-reply-max 60 |
|
||||
| local-ttl | 本地HOST,address的TTL值 | rr-ttl-min | 大于 0 的数字 | local-ttl 60 |
|
||||
| max-reply-ip-num | 允许返回给客户的最大IP数量 | IP数量 | 大于 0 的数字 | max-reply-ip-num 1 |
|
||||
| log-level | 设置日志级别 | error | fatal、error、warn、notice、info 或 debug | log-level error |
|
||||
| log-file | 日志文件路径 | /var/log/smartdns/smartdns.log | 合法路径字符串 | log-file /var/log/smartdns/smartdns.log |
|
||||
|
||||
@@ -497,6 +497,7 @@ Note: Merlin firmware is derived from ASUS firmware and can theoretically be use
|
||||
|tcp-idle-time|TCP connection idle timeout|120|integer|tcp-idle-time 120
|
||||
|rr-ttl|Domain name TTL|Remote query result|number greater than 0|rr-ttl 600
|
||||
|rr-ttl-min|Domain name Minimum TTL|Remote query result|number greater than 0|rr-ttl-min 60
|
||||
|local-ttl|ttl for address and host|rr-ttl-min|number greater than 0|local-ttl 600
|
||||
|rr-ttl-reply-max|Domain name Minimum Reply TTL|Remote query result|number greater than 0|rr-ttl-reply-max 60
|
||||
|rr-ttl-max|Domain name Maximum TTL|Remote query result|number greater than 0|rr-ttl-max 600
|
||||
|max-reply-ip-num|Maximum number of IPs returned to the client|8|number of IPs, 1~16 |max-reply-ip-num 1
|
||||
|
||||
@@ -124,6 +124,7 @@ int dns_conf_rr_ttl;
|
||||
int dns_conf_rr_ttl_reply_max;
|
||||
int dns_conf_rr_ttl_min = 600;
|
||||
int dns_conf_rr_ttl_max;
|
||||
int dns_conf_local_ttl;
|
||||
int dns_conf_force_AAAA_SOA;
|
||||
int dns_conf_force_no_cname;
|
||||
int dns_conf_ipset_timeout_enable;
|
||||
@@ -1907,6 +1908,7 @@ static struct config_item _config_item[] = {
|
||||
CONF_INT("rr-ttl-min", &dns_conf_rr_ttl_min, 0, CONF_INT_MAX),
|
||||
CONF_INT("rr-ttl-max", &dns_conf_rr_ttl_max, 0, CONF_INT_MAX),
|
||||
CONF_INT("rr-ttl-reply-max", &dns_conf_rr_ttl_reply_max, 0, CONF_INT_MAX),
|
||||
CONF_INT("local-ttl", &dns_conf_local_ttl, 0, CONF_INT_MAX),
|
||||
CONF_INT("max-reply-ip-num", &dns_conf_max_reply_ip_num, 1, CONF_INT_MAX),
|
||||
CONF_ENUM("response-mode", &dns_conf_response_mode, &dns_conf_response_mode_enum),
|
||||
CONF_YESNO("force-AAAA-SOA", &dns_conf_force_AAAA_SOA),
|
||||
@@ -2091,6 +2093,10 @@ static int _dns_conf_load_post(void)
|
||||
dns_conf_response_mode_enum[dns_conf_response_mode].name);
|
||||
}
|
||||
|
||||
if (dns_conf_local_ttl == 0) {
|
||||
dns_conf_local_ttl = dns_conf_rr_ttl_min;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -312,6 +312,7 @@ extern int dns_conf_rr_ttl_min;
|
||||
extern int dns_conf_rr_ttl_max;
|
||||
extern int dns_conf_force_AAAA_SOA;
|
||||
extern int dns_conf_ipset_timeout_enable;
|
||||
extern int dns_conf_local_ttl;
|
||||
|
||||
extern int dns_conf_force_no_cname;
|
||||
|
||||
|
||||
@@ -3413,7 +3413,7 @@ static int _dns_server_process_address(struct dns_request *request)
|
||||
}
|
||||
|
||||
request->rcode = DNS_RC_NOERROR;
|
||||
request->ip_ttl = 600;
|
||||
request->ip_ttl = dns_conf_local_ttl;
|
||||
request->has_ip = 1;
|
||||
|
||||
struct dns_server_post_context context;
|
||||
@@ -3934,7 +3934,7 @@ static int _dns_server_process_host(struct dns_request *request)
|
||||
}
|
||||
|
||||
request->rcode = DNS_RC_NOERROR;
|
||||
request->ip_ttl = 600;
|
||||
request->ip_ttl = dns_conf_local_ttl;
|
||||
request->has_ip = 1;
|
||||
|
||||
struct dns_server_post_context context;
|
||||
@@ -4040,9 +4040,6 @@ static int _dns_server_do_query(struct dns_request *request)
|
||||
safe_strncpy(request->dns_group_name, group_name, DNS_GROUP_NAME_LEN);
|
||||
}
|
||||
|
||||
if (_dns_server_process_host(request) == 0) {
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
_dns_server_set_dualstack_selection(request);
|
||||
|
||||
@@ -4060,6 +4057,10 @@ static int _dns_server_do_query(struct dns_request *request)
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
if (_dns_server_process_host(request) == 0) {
|
||||
goto clean_exit;
|
||||
}
|
||||
|
||||
/* process qtype soa */
|
||||
if (_dns_server_qtype_soa(request) == 0) {
|
||||
goto clean_exit;
|
||||
|
||||
Reference in New Issue
Block a user