Переглянути джерело

ipset: fix ipset missing issue

Nick Peng 3 роки тому
батько
коміт
b70feb112a
1 змінених файлів з 5 додано та 4 видалено
  1. 5 4
      src/dns_server.c

+ 5 - 4
src/dns_server.c

@@ -1360,6 +1360,9 @@ static int _dns_request_post(struct dns_server_post_context *context)
 		tlog(TLOG_WARN, "cache packet for %s failed.", request->domain);
 		tlog(TLOG_WARN, "cache packet for %s failed.", request->domain);
 	}
 	}
 
 
+	/* setup ipset */
+	_dns_server_setup_ipset_packet(context);
+
 	if (context->do_reply == 0) {
 	if (context->do_reply == 0) {
 		return 0;
 		return 0;
 	}
 	}
@@ -1371,9 +1374,6 @@ static int _dns_request_post(struct dns_server_post_context *context)
 		}
 		}
 	}
 	}
 
 
-	/* setup ipset */
-	_dns_server_setup_ipset_packet(context);
-
 	/* log audit log */
 	/* log audit log */
 	_dns_server_audit_log(context);
 	_dns_server_audit_log(context);
 
 
@@ -3360,6 +3360,7 @@ errout:
 static int _dns_server_process_cache_packet(struct dns_request *request, struct dns_cache *dns_cache)
 static int _dns_server_process_cache_packet(struct dns_request *request, struct dns_cache *dns_cache)
 {
 {
 	struct dns_cache_packet *cache_packet = (struct dns_cache_packet *)dns_cache_get_data(dns_cache);
 	struct dns_cache_packet *cache_packet = (struct dns_cache_packet *)dns_cache_get_data(dns_cache);
+	int do_ipset = (dns_cache_get_ttl(dns_cache) == 0);
 
 
 	if (cache_packet->head.cache_type != CACHE_TYPE_PACKET) {
 	if (cache_packet->head.cache_type != CACHE_TYPE_PACKET) {
 		return -1;
 		return -1;
@@ -3380,7 +3381,7 @@ static int _dns_server_process_cache_packet(struct dns_request *request, struct
 
 
 	request->rcode = context.packet->head.rcode;
 	request->rcode = context.packet->head.rcode;
 	context.do_cache = 0;
 	context.do_cache = 0;
-	context.do_ipset = 0;
+	context.do_ipset = do_ipset;
 	context.do_audit = 1;
 	context.do_audit = 1;
 	context.do_reply = 1;
 	context.do_reply = 1;
 	context.reply_ttl = _dns_server_get_expired_ttl_reply(dns_cache);
 	context.reply_ttl = _dns_server_get_expired_ttl_reply(dns_cache);