Skip to content

Commit 85e3066

Browse files
authored
Merge pull request #80 from YangSen-qn/master
use 114.114.114.114 instead 8.8.8.8
2 parents 6e5eef6 + a147089 commit 85e3066

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#Changelog
2+
## 1.0.3 (2023-06-16)
3+
* 调整 内部使用 114.114.114.114 替换 8.8.8.8
4+
15
#Changelog
26
## 1.0.2 (2022-06-02)
37
* 优化 udp dns reslover 的线程队列使用

HappyDNS.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'HappyDNS'
3-
s.version = '1.0.2'
3+
s.version = '1.0.3'
44
s.summary = 'DNS library for iOS and Mac'
55
s.homepage = 'https://github.com/qiniu/happy-dns-objc'
66
s.social_media_url = 'http://weibo.com/qiniutek'

HappyDNS/Dns/QNDnsUdpResolver.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ NS_ASSUME_NONNULL_BEGIN
1313

1414

1515
/// 构造函数
16-
/// @param serverIP 指定 dns local server1. eg:8.8.8.8
16+
/// @param serverIP 指定 dns local server1. eg:114.114.114.114
1717
+ (instancetype)resolverWithServerIP:(NSString *)serverIP;
1818

1919
/// 构造函数
20-
/// @param serverIP 指定 dns local server1. eg:8.8.8.8
20+
/// @param serverIP 指定 dns local server1. eg:114.114.114.114
2121
/// @param recordType 记录类型 eg:kQNTypeA
2222
/// @param timeout 超时时间
2323
+ (instancetype)resolverWithServerIP:(NSString *)serverIP

HappyDNS/Util/QNIP.m

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
#import <UIKit/UIKit.h>
2323
#endif
2424

25+
#ifndef kQNDnsDefaultIPv4IP
26+
#define kQNDnsDefaultIPv4IP "114.114.114.114"
27+
#endif
28+
29+
#ifndef kQNDnsDefaultIPv6IP
30+
#define kQNDnsDefaultIPv6IP "2400:3200::1"
31+
#endif
32+
2533
void qn_nat64(char *buf, int buf_size, uint32_t ipv4addr) {
2634
bzero(buf, buf_size);
2735
//nat 4 to ipv6
@@ -99,11 +107,11 @@ int qn_local_ip_internal(char *buf, int buf_size, const char *t_ip) {
99107
}
100108

101109
int qn_localIp(char *buf, int buf_size) {
102-
int ret = qn_local_ip_internal(buf, buf_size, "8.8.8.8");
110+
int ret = qn_local_ip_internal(buf, buf_size, kQNDnsDefaultIPv4IP);
103111
if (ret != 0) {
104112
#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
105113
if (![QNIP isIpV6FullySupported]) {
106-
ret = qn_local_ip_internal(buf, buf_size, "64:ff9b::808:808");
114+
ret = qn_local_ip_internal(buf, buf_size, kQNDnsDefaultIPv6IP);
107115
}
108116
#endif
109117
}
@@ -116,7 +124,8 @@ + (BOOL)isV6 {
116124
struct addrinfo hints = {0}, *ai;
117125
hints.ai_family = AF_UNSPEC;
118126
hints.ai_socktype = SOCK_STREAM;
119-
int ret = getaddrinfo("8.8.8.8", "http", &hints, &ai);
127+
hints.ai_flags = AI_NUMERICHOST;
128+
int ret = getaddrinfo(kQNDnsDefaultIPv4IP, "http", &hints, &ai);
120129
if (ret != 0) {
121130
return NO;
122131
}
@@ -126,7 +135,7 @@ + (BOOL)isV6 {
126135
#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
127136
if (![QNIP isIpV6FullySupported] && !ret) {
128137
char buf[64] = {0};
129-
ret = qn_local_ip_internal(buf, sizeof(buf), "64:ff9b::808:808");
138+
ret = qn_local_ip_internal(buf, sizeof(buf), kQNDnsDefaultIPv6IP);
130139
if (strchr(buf, ':') != NULL) {
131140
result = YES;
132141
}
@@ -156,7 +165,7 @@ + (NSString *)adaptiveIp:(NSString *)ipv4 {
156165
#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
157166
if (![QNIP isIpV6FullySupported] && family == AF_INET) {
158167
char buf2[64] = {0};
159-
ret = qn_local_ip_internal(buf2, sizeof(buf2), "64:ff9b::808:808");
168+
ret = qn_local_ip_internal(buf2, sizeof(buf2), kQNDnsDefaultIPv6IP);
160169
if (strchr(buf2, ':') != NULL) {
161170
bzero(buf, sizeof(buf));
162171
qn_nat64(buf, sizeof(buf), *((uint32_t *)addr));

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ if([QNDnsManager needHttpDns]){
9696
}else{
9797
NSMutableArray *array = [[NSMutableArray alloc] init];
9898
[array addObject:[QNResolver systemResolver]];
99-
[array addObject:[[QNResolver alloc] initWithAddress:@"8.8.8.8"]];
99+
[array addObject:[[QNResolver alloc] initWithAddress:@"114.114.114.114"]];
100100
dns = [[QNDnsManager alloc] init:array networkInfo:[QNNetworkInfo normal]];
101101
}
102102
```

0 commit comments

Comments
 (0)