Skip to content

Commit

Permalink
Merge pull request #74 from YangSen-qn/master
Browse files Browse the repository at this point in the history
support SPM
  • Loading branch information
xwen-winnie authored Jan 17, 2022
2 parents 754985f + ca49ddf commit 45f2d81
Show file tree
Hide file tree
Showing 39 changed files with 127 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ DerivedData
#
Pods/
Podfile.lock
.swiftpm
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#Changelog
## 1.0.1 (2021-11-25)
* 支持 Swift Package Manager
* Dnspod 默认 server ip 切至 119.29.29.98

## 1.0.0 (2021-09-02)

* 新增 dns udp 解析 api
Expand Down
4 changes: 2 additions & 2 deletions HappyDNS.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'HappyDNS'
s.version = '1.0.0'
s.version = '1.0.1'
s.summary = 'DNS library for iOS and Mac'
s.homepage = 'https://github.com/qiniu/happy-dns-objc'
s.social_media_url = 'http://weibo.com/qiniutek'
Expand All @@ -10,7 +10,7 @@ Pod::Spec.new do |s|
s.ios.deployment_target = '6.0'
s.osx.deployment_target = '10.8'
s.libraries = 'resolv'
s.source_files = 'HappyDNS/**/*.{h,m}'
s.source_files = 'HappyDNS/Common/*.{h,m}','HappyDNS/Dns/*.{h,m}','HappyDNS/Http/*.{h,m}','HappyDNS/Local/*.{h,m}','HappyDNS/Util/*.{h,m}','HappyDNS/HappyDNS.h'
s.requires_arc = true
s.license = { :type => 'MIT', :text => <<-LICENSE
The MIT License (MIT)
Expand Down
50 changes: 34 additions & 16 deletions HappyDNS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions HappyDNS/HappyDNS.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import <Foundation/Foundation.h>

#import "QNDnsError.h"
#import "QNDnsManager.h"
#import "QNDnspodEnterprise.h"
#import "QNDomain.h"
Expand Down
4 changes: 2 additions & 2 deletions HappyDNS/Http/QNDnspodEnterprise.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ @implementation QNDnspodEnterprise

- (instancetype)initWithId:(NSString *)userId
key:(NSString *)key {
return [self initWithId:userId key:key server:@"119.29.29.29"];
return [self initWithId:userId key:key server:@"119.29.29.98"];
}

- (instancetype)initWithId:(NSString *)userId
key:(NSString *)key
server:(NSString *)server {
return [self initWithId:userId key:key server:@"119.29.29.29" timeout:QN_DNS_DEFAULT_TIMEOUT];
return [self initWithId:userId key:key server:@"119.29.29.98" timeout:QN_DNS_DEFAULT_TIMEOUT];
}

- (instancetype)initWithId:(NSString *)userId
Expand Down
5 changes: 3 additions & 2 deletions HappyDNS/Local/QNHosts.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ @implementation QNHosts
[x addObject:first];
}
}

NSArray <QNHostsValue *> *values = filter([x copy], netInfo.provider);
return [self toRecords:values];
}
Expand All @@ -74,7 +74,7 @@ @implementation QNHosts
if (values == nil) {
return nil;
}

NSMutableArray<QNRecord *> *records = [NSMutableArray array];
for (QNHostsValue *value in values) {
if (value.record != nil && value.record.value != nil) {
Expand All @@ -84,6 +84,7 @@ @implementation QNHosts
return [records copy];
}


- (void)put:(NSString *)domain record:(QNRecord *)record {
[self put:domain record:record provider:kQNISP_GENERAL];
}
Expand Down
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/HappyDNS.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/NSData+QNRW.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNAsyncUdpSocket.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNDes.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNDnsDefine.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNDnsError.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNDnsManager.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNDnsMessage.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNDnsRequest.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNDnsResolver.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNDnsResponse.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNDnsUdpResolver.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNDnspodEnterprise.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNDohResolver.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNDomain.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNGetAddrInfo.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNHex.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNHijackingDetectWrapper.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNHosts.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNIP.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNLruCache.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNMD5.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNNetworkInfo.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNRecord.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNResolvUtil.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNResolver.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNResolverDelegate.h
1 change: 1 addition & 0 deletions HappyDNS/include/HappyDNS/QNTxtResolver.h
35 changes: 35 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "HappyDNS",
platforms: [
.macOS(.v10_10),
.iOS(.v8)
],
products: [
.library(
name: "HappyDNS",
targets: ["HappyDNS"]),
],
dependencies: [
],
targets: [
.target(
name: "HappyDNS",
path: "HappyDNS",
sources: ["Common", "Dns", "Http", "Local", "Util"],
cSettings: [
.headerSearchPath("Common"),
.headerSearchPath("Dns"),
.headerSearchPath("Http"),
.headerSearchPath("Local"),
.headerSearchPath("Util"),
],
linkerSettings:[
.linkedLibrary("resolv", nil)
]),
]
)
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,26 @@
## 安装

通过CocoaPods

```ruby
pod "HappyDNS"
```

通过 Swift Package Manager (Xcode 11+)
```
App 对接:
File -> Swift Packages -> Add Package Dependency,输入 HappyDNS 库链接,选择相应版本即可
库链接: https://github.com/qiniu/happy-dns-objc
库对接:
let package = Package(
dependencies: [
.package(url: "https://github.com/qiniu/happy-dns-objc", from: "1.0.1")
],
// ...
)
```

## 运行环境


Expand All @@ -30,7 +45,7 @@ pod "HappyDNS"
[array addObject:[[QNResolver alloc] initWithAddress:@"119.29.29.29"]];
[array addObject:[QNDohResolver resolverWithServer:@"https://dns.alidns.com/dns-query"]];
QNDnsManager *dns = [[QNDnsManager alloc] init:array networkInfo:[QNNetworkInfo normal]];
NSArray <QNRecord *> *records = [dns queryRecords:@"www.qiniu.com"];;
NSArray <QNRecord *> *records = [dns queryRecords:@"www.qiniu.com"];
```
* url 请求,返回一个IP 替换URL 里的domain
```
Expand Down

0 comments on commit 45f2d81

Please sign in to comment.