conf: Supports setting the maximum number of IPs returned to the client
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#define DEFAULT_DNS_CACHE_SIZE 512
|
||||
#define DNS_MAX_REPLY_IP_NUM 8
|
||||
|
||||
/* ipset */
|
||||
struct dns_ipset_table {
|
||||
@@ -56,6 +57,8 @@ struct dns_bind_ip dns_conf_bind_ip[DNS_MAX_BIND_IP];
|
||||
int dns_conf_bind_ip_num = 0;
|
||||
int dns_conf_tcp_idle_time = 120;
|
||||
|
||||
int dns_conf_max_reply_ip_num = DNS_MAX_REPLY_IP_NUM;
|
||||
|
||||
/* cache */
|
||||
int dns_conf_cachesize = DEFAULT_DNS_CACHE_SIZE;
|
||||
int dns_conf_prefetch = 0;
|
||||
@@ -1867,6 +1870,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("max-reply-ip-num", &dns_conf_max_reply_ip_num, 1, CONF_INT_MAX),
|
||||
CONF_YESNO("force-AAAA-SOA", &dns_conf_force_AAAA_SOA),
|
||||
CONF_CUSTOM("force-qtype-SOA", _config_qtype_soa, NULL),
|
||||
CONF_CUSTOM("blacklist-ip", _config_blacklist_ip, NULL),
|
||||
|
||||
@@ -290,6 +290,8 @@ extern struct dns_conf_address_rule dns_conf_address_rule;
|
||||
extern int dns_conf_dualstack_ip_selection;
|
||||
extern int dns_conf_dualstack_ip_selection_threshold;
|
||||
|
||||
extern int dns_conf_max_reply_ip_num;
|
||||
|
||||
extern int dns_conf_rr_ttl;
|
||||
extern int dns_conf_rr_ttl_reply_max;
|
||||
extern int dns_conf_rr_ttl_min;
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#define DNS_MAX_EVENTS 256
|
||||
#define DNS_SERVER_MAX_REPONSE_IPNUM 10
|
||||
#define IPV6_READY_CHECK_TIME 180
|
||||
#define DNS_SERVER_TMOUT_TTL (5 * 60)
|
||||
#define DNS_CONN_BUFF_SIZE 4096
|
||||
@@ -532,7 +531,7 @@ static int _dns_rrs_add_all_best_ip(struct dns_server_post_context *context)
|
||||
int ignore_speed = 0;
|
||||
int maxhit = 0;
|
||||
|
||||
if (context->select_all_best_ip == 0) {
|
||||
if (context->select_all_best_ip == 0 || dns_conf_max_reply_ip_num - 1 <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -555,7 +554,7 @@ static int _dns_rrs_add_all_best_ip(struct dns_server_post_context *context)
|
||||
pthread_mutex_lock(&request->ip_map_lock);
|
||||
hash_for_each_safe(request->ip_map, bucket, tmp, addr_map, node)
|
||||
{
|
||||
if (context->ip_num >= DNS_SERVER_MAX_REPONSE_IPNUM) {
|
||||
if (context->ip_num >= dns_conf_max_reply_ip_num) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1497,6 +1496,8 @@ static void _dns_server_complete_with_multi_ipaddress(struct dns_request *reques
|
||||
int do_reply = 0;
|
||||
if (atomic_inc_return(&request->notified) == 1) {
|
||||
do_reply = 1;
|
||||
} else if (dns_conf_max_reply_ip_num == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
_dns_server_post_context_init(&context, request);
|
||||
|
||||
Reference in New Issue
Block a user