Parcourir la source

dns_server: no retry when upstream server return no results with RCODE=NOERROR

Nick Peng il y a 1 an
Parent
commit
d00f012fe3
2 fichiers modifiés avec 7 ajouts et 4 suppressions
  1. 6 2
      src/dns_server.c
  2. 1 2
      src/tlog.c

+ 6 - 2
src/dns_server.c

@@ -3746,9 +3746,13 @@ static int _dns_server_process_answer(struct dns_request *request, const char *d
 	}
 
 	if (has_result == 0 && request->rcode == DNS_RC_NOERROR) {
-		tlog(TLOG_DEBUG, "no result, %s qtype: %d, rcode: %d, id: %d, retry", domain, request->qtype,
+		/* When queries A and AAAA from CloudFlare DNS at the same time and there is a retry, 
+		 * CloudFlare DNS may return the sent request packet. I don’t know the reason. 
+		 * Maybe retry should be considered?
+		 */
+		tlog(TLOG_DEBUG, "no result, %s qtype: %d, rcode: %d, id: %d", domain, request->qtype,
 			 packet->head.rcode, packet->head.id);
-		return -1;
+		return 0;
 	}
 
 	return 0;

+ 1 - 2
src/tlog.c

@@ -666,7 +666,7 @@ int tlog_stdout_with_color(tlog_level level, const char *buff, int bufflen)
     }
 
     if (color != NULL) {
-        fprintf(stdout, "%s%.*s\033[0m\n", color, bufflen - 2, buff);
+        fprintf(stdout, "%s%.*s\033[0m\n", color, bufflen - 1, buff);
     } else {
         fprintf(stdout, "%s", buff);
     }
@@ -1227,7 +1227,6 @@ static int _tlog_write_screen(struct tlog_log *log, struct tlog_loginfo *info, c
     }
 
     if (info == NULL) {
-        
         return write(STDOUT_FILENO, buff, bufflen);;
     }