dns_server: suppress error log

This commit is contained in:
Nick Peng
2023-04-12 23:14:10 +08:00
parent 0947a8dcab
commit 0e6eeefe5e
3 changed files with 24 additions and 3 deletions

View File

@@ -3562,7 +3562,13 @@ static int _dns_client_send_packet(struct dns_query_struct *query, void *packet,
}
if (send_count <= 0) {
tlog(TLOG_WARN, "Send query to upstream server failed, total server number %d", total_server);
static time_t lastlog = 0;
time_t now = 0;
time(&now);
if (now - lastlog > 120) {
lastlog = now;
tlog(TLOG_WARN, "Send query %s to upstream server failed, total server number %d", query->domain, total_server);
}
return -1;
}

View File

@@ -3393,6 +3393,19 @@ void dns_server_load_exit(void)
_config_proxy_table_destroy();
dns_conf_server_num = 0;
dns_conf_bind_ip_num = 0;
}
static int _config_add_default_server_if_needed(void)
{
if (dns_conf_bind_ip_num > 0) {
return 0;
}
/* add default server */
char *argv[] = {"bind", "[::]:53", 0};
int argc = sizeof(argv) / sizeof(char *) - 1;
return _config_bind_ip(argc, argv, DNS_BIND_TYPE_UDP);
}
static int _dns_conf_speed_check_mode_verify(void)
@@ -3513,6 +3526,8 @@ static int _dns_conf_load_post(void)
_config_update_bootstrap_dns_rule();
_config_add_default_server_if_needed();
return 0;
}

View File

@@ -5293,7 +5293,7 @@ static int _dns_server_recv(struct dns_server_conn_head *conn, unsigned char *in
ret = _dns_server_do_query(request, 1);
if (ret != 0) {
tlog(TLOG_WARN, "do query %s failed.\n", request->domain);
tlog(TLOG_DEBUG, "do query %s failed.\n", request->domain);
goto errout;
}
_dns_server_request_release_complete(request, 0);
@@ -6168,7 +6168,7 @@ static void _dns_server_prefetch_expired_domain(struct dns_cache *dns_cache)
server_query_option.ecs_enable_flag = 0;
if (_dns_server_prefetch_request(dns_cache->info.domain, dns_cache->info.qtype, 1, &server_query_option) != 0) {
tlog(TLOG_WARN, "prefetch domain %s, qtype %d, failed.", dns_cache->info.domain, dns_cache->info.qtype);
tlog(TLOG_DEBUG, "prefetch domain %s, qtype %d, failed.", dns_cache->info.domain, dns_cache->info.qtype);
}
}