Browse Source

Update code

Nick Peng 7 năm trước cách đây
mục cha
commit
d92a67bf2a
4 tập tin đã thay đổi với 11 bổ sung3 xóa
  1. 1 1
      dns_client.c
  2. 10 0
      dns_server.c
  3. 0 1
      include/bitmap.h
  4. 0 1
      include/bitops.h

+ 1 - 1
dns_client.c

@@ -416,7 +416,7 @@ static int _dns_client_process(struct dns_query_struct *dns_query, unsigned long
 		return -1;
 	}
 
-	tlog(TLOG_INFO, "recv from %s", gethost_by_addr(from_host, (struct sockaddr *)&from, from_len));
+	tlog(TLOG_DEBUG, "recv from %s", gethost_by_addr(from_host, (struct sockaddr *)&from, from_len));
 
 	if (_dns_client_recv(inpacket, len, &from, from_len) != 0) {
 		int fd = open("dns.bin", O_CREAT | O_TRUNC | O_RDWR);

+ 10 - 0
dns_server.c

@@ -426,6 +426,10 @@ static int _dns_client_process_answer(struct dns_request *request, char *domain,
 				unsigned char addr[4];
 				_dns_server_request_get(request);
 				dns_get_A(rrs, name, DNS_MAX_CNAME_LEN, &ttl, addr);
+				if (request->has_ipv4 == 0) {
+					memcpy(request->ipv4_addr, addr, DNS_RR_A_LEN);
+					request->has_ipv4 = 1;
+				}
 				if (_dns_ip_address_check_add(request, addr, DNS_T_A) != 0) {
 					_dns_server_request_release(request);
 					break;
@@ -443,6 +447,12 @@ static int _dns_client_process_answer(struct dns_request *request, char *domain,
 				unsigned char addr[16];
 				_dns_server_request_get(request);
 				dns_get_AAAA(rrs, name, DNS_MAX_CNAME_LEN, &ttl, addr);
+
+				if (request->has_ipv6 == 0) {
+					memcpy(request->ipv6_addr, addr, DNS_RR_AAAA_LEN);
+					request->has_ipv6 = 1;
+				}
+
 				if (_dns_ip_address_check_add(request, addr, DNS_T_AAAA) != 0) {
 					_dns_server_request_release(request);
 					break;

+ 0 - 1
include/bitmap.h

@@ -1,4 +1,3 @@
-/* SPDX-License-Identifier: GPL-2.0 */
 #ifndef _PERF_BITOPS_H
 #define _PERF_BITOPS_H
 

+ 0 - 1
include/bitops.h

@@ -1,4 +1,3 @@
-/* SPDX-License-Identifier: GPL-2.0 */
 #ifndef _GENERIC_BITOPS_H_
 #define _GENERIC_BITOPS_H_