Skip to content

Commit

Permalink
upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
longbai committed Apr 3, 2018
1 parent ed5fb21 commit 0063d3b
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 45 deletions.
2 changes: 2 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore:
- "Pods"
14 changes: 4 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
language: objective-c
rvm: 2.2.2
before_install:
- brew update
- brew upgrade xctool
- gem install cocoapods
before_script:
- export QINIU_TEST_ENV="travis"
script:
- xctool -workspace HappyDNS.xcworkspace -scheme HappyDNS_iOS -sdk iphonesimulator -configuration Release test -test-sdk iphonesimulator7.0 -freshInstall -freshSimulator
- xctool -workspace HappyDNS.xcworkspace -scheme HappyDNS_Mac -sdk macosx -configuration Debug test -test-sdk macosx -only "HappyDNS_MacTests"
osx_image: xcode9

after_success:
- bash <(curl -s https://codecov.io/bash)
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#Changelog

## 0.3.13 (2018-04-03)

### 增加
* qiniu http dns 支持

## 0.3.12 (2017-08-31)

### 修正
Expand Down
2 changes: 1 addition & 1 deletion 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 = '0.3.12'
s.version = '0.3.13'
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 Down
20 changes: 10 additions & 10 deletions HappyDNS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
/* Begin PBXBuildFile section */
6B6090D36D2ECCD34FCE6DAE /* libPods-HappyDNS_iOSTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B7A5E527D9CF80E564A69D85 /* libPods-HappyDNS_iOSTests.a */; };
71FB87ACF7AF0163E3F8AF2F /* libPods-HappyDNS_MacTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 04A4DFEA159C0945AFABEA3A /* libPods-HappyDNS_MacTests.a */; };
93AB4B5520513F6E00FF2AB3 /* QNNiuDns.h in Headers */ = {isa = PBXBuildFile; fileRef = 93AB4B5320513F6E00FF2AB3 /* QNNiuDns.h */; };
93AB4B5620513F6E00FF2AB3 /* QNNiuDns.m in Sources */ = {isa = PBXBuildFile; fileRef = 93AB4B5420513F6E00FF2AB3 /* QNNiuDns.m */; };
93AB4B5720513F6E00FF2AB3 /* QNNiuDns.m in Sources */ = {isa = PBXBuildFile; fileRef = 93AB4B5420513F6E00FF2AB3 /* QNNiuDns.m */; };
93AB4B5920513FF200FF2AB3 /* NiuDnsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 93AB4B5820513FF200FF2AB3 /* NiuDnsTest.m */; };
93AB4B5A20513FF200FF2AB3 /* NiuDnsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 93AB4B5820513FF200FF2AB3 /* NiuDnsTest.m */; };
DF0A03181B3B999D00E3778C /* libHappyDNS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DF801F951B3A4F4D00866FDE /* libHappyDNS.a */; };
Expand Down Expand Up @@ -102,6 +99,9 @@
DFFC8AB51B6C4DD200EC938D /* DesTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DFFC8AB31B6C4DD200EC938D /* DesTest.m */; };
DFFC8AB71B6C62E800EC938D /* HexTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DFFC8AB61B6C62E800EC938D /* HexTest.m */; };
DFFC8AB81B6C62E800EC938D /* HexTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DFFC8AB61B6C62E800EC938D /* HexTest.m */; };
FDD09F63207361780047AE7B /* QNNiuDns.m in Sources */ = {isa = PBXBuildFile; fileRef = FDD09F61207361780047AE7B /* QNNiuDns.m */; };
FDD09F64207361780047AE7B /* QNNiuDns.m in Sources */ = {isa = PBXBuildFile; fileRef = FDD09F61207361780047AE7B /* QNNiuDns.m */; };
FDD09F65207361780047AE7B /* QNNiuDns.h in Headers */ = {isa = PBXBuildFile; fileRef = FDD09F62207361780047AE7B /* QNNiuDns.h */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -140,8 +140,6 @@
2A93CF6550EE709B01A78948 /* Pods-HappyDNS_iOSTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HappyDNS_iOSTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-HappyDNS_iOSTests/Pods-HappyDNS_iOSTests.release.xcconfig"; sourceTree = "<group>"; };
9387D718204EA24300B91879 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
9387D71B204EA28700B91879 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Platforms/MacOSX.platform/Developer/Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
93AB4B5320513F6E00FF2AB3 /* QNNiuDns.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QNNiuDns.h; sourceTree = "<group>"; };
93AB4B5420513F6E00FF2AB3 /* QNNiuDns.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QNNiuDns.m; sourceTree = "<group>"; };
93AB4B5820513FF200FF2AB3 /* NiuDnsTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NiuDnsTest.m; sourceTree = "<group>"; };
A7C629E8C4C0F06862464808 /* Pods-HappyDNS_iOSTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HappyDNS_iOSTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-HappyDNS_iOSTests/Pods-HappyDNS_iOSTests.debug.xcconfig"; sourceTree = "<group>"; };
B7A5E527D9CF80E564A69D85 /* libPods-HappyDNS_iOSTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-HappyDNS_iOSTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -207,6 +205,8 @@
DFFC8AAF1B6BD77000EC938D /* QNDnspodEnterprise.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = QNDnspodEnterprise.m; path = Http/QNDnspodEnterprise.m; sourceTree = "<group>"; };
DFFC8AB31B6C4DD200EC938D /* DesTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DesTest.m; sourceTree = "<group>"; };
DFFC8AB61B6C62E800EC938D /* HexTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HexTest.m; sourceTree = "<group>"; };
FDD09F61207361780047AE7B /* QNNiuDns.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = QNNiuDns.m; path = Http/QNNiuDns.m; sourceTree = "<group>"; };
FDD09F62207361780047AE7B /* QNNiuDns.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = QNNiuDns.h; path = Http/QNNiuDns.h; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -343,12 +343,12 @@
DF801F591B39449C00866FDE /* Http */ = {
isa = PBXGroup;
children = (
FDD09F62207361780047AE7B /* QNNiuDns.h */,
FDD09F61207361780047AE7B /* QNNiuDns.m */,
DFFC8AAE1B6BD77000EC938D /* QNDnspodEnterprise.h */,
DFFC8AAF1B6BD77000EC938D /* QNDnspodEnterprise.m */,
DF801F7B1B396E7600866FDE /* QNDnspodFree.h */,
DF801F7C1B396E7600866FDE /* QNDnspodFree.m */,
93AB4B5320513F6E00FF2AB3 /* QNNiuDns.h */,
93AB4B5420513F6E00FF2AB3 /* QNNiuDns.m */,
);
name = Http;
sourceTree = "<group>";
Expand Down Expand Up @@ -431,8 +431,8 @@
buildActionMask = 2147483647;
files = (
DF0A03201B3BABBD00E3778C /* QNNetworkInfo.h in Headers */,
93AB4B5520513F6E00FF2AB3 /* QNNiuDns.h in Headers */,
DF801F691B396DA000866FDE /* QNDnsManager.h in Headers */,
FDD09F65207361780047AE7B /* QNNiuDns.h in Headers */,
DF801F641B396D5100866FDE /* QNRecord.h in Headers */,
DF8152691D3D4097007C44DA /* QNGetAddrInfo.h in Headers */,
DF5AC8E11B575E2800728D30 /* QNHijackingDetectWrapper.h in Headers */,
Expand Down Expand Up @@ -699,14 +699,14 @@
buildActionMask = 2147483647;
files = (
DFE09E561D3F0D8700235B71 /* QNRefresher.m in Sources */,
FDD09F63207361780047AE7B /* QNNiuDns.m in Sources */,
DF801F741B396E3C00866FDE /* QNResolver.m in Sources */,
DFDD2A761CF58887006ECFCE /* QNIP.m in Sources */,
DFFC8AB11B6BD77000EC938D /* QNDnspodEnterprise.m in Sources */,
DF801F6A1B396DA000866FDE /* QNDnsManager.m in Sources */,
DFE09E5E1D3F0DF200235B71 /* QNIpModel.m in Sources */,
DF2B76F61C3C1D5300643678 /* QNTxtResolver.m in Sources */,
DF5B33811D2BB28500CD608F /* QNLruCache.m in Sources */,
93AB4B5620513F6E00FF2AB3 /* QNNiuDns.m in Sources */,
DF8152671D3D4097007C44DA /* QNGetAddrInfo.m in Sources */,
DF801F7E1B396E7600866FDE /* QNDnspodFree.m in Sources */,
DFFC8AAC1B6BD73900EC938D /* QNDes.m in Sources */,
Expand Down Expand Up @@ -746,14 +746,14 @@
buildActionMask = 2147483647;
files = (
DFE09E571D3F0D8700235B71 /* QNRefresher.m in Sources */,
FDD09F64207361780047AE7B /* QNNiuDns.m in Sources */,
DF90509C1CFD88AA008B98C2 /* QNResolvUtil.m in Sources */,
DF1552541B3B9316008D3E7C /* QNDnsManager.m in Sources */,
DFDD2A771CF58887006ECFCE /* QNIP.m in Sources */,
DFFC8AB21B6BD77000EC938D /* QNDnspodEnterprise.m in Sources */,
DFE09E5F1D3F0DF200235B71 /* QNIpModel.m in Sources */,
DF1552561B3B9316008D3E7C /* QNRecord.m in Sources */,
DF5B33821D2BB28500CD608F /* QNLruCache.m in Sources */,
93AB4B5720513F6E00FF2AB3 /* QNNiuDns.m in Sources */,
DF8152681D3D4097007C44DA /* QNGetAddrInfo.m in Sources */,
DF2B76F71C3C1D5300643678 /* QNTxtResolver.m in Sources */,
DF1552591B3B9316008D3E7C /* QNDomain.m in Sources */,
Expand Down
8 changes: 8 additions & 0 deletions HappyDNS.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
6 changes: 3 additions & 3 deletions HappyDNS/QNNiuDns.h → HappyDNS/Http/QNNiuDns.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
// Copyright © 2018年 Qiniu Cloud Storage. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "QNResolverDelegate.h"
#import <Foundation/Foundation.h>

@interface QNNiuDns : NSObject<QNResolverDelegate>
@interface QNNiuDns : NSObject <QNResolverDelegate>
- (NSArray *)query:(QNDomain *)domain networkInfo:(QNNetworkInfo *)netInfo error:(NSError *__autoreleasing *)error;

@property (nonatomic, strong, readonly) NSString *accountId;
Expand All @@ -31,6 +31,6 @@
*/
- (instancetype)initWithAccountId:(NSString *)accountId
encryptKey:(NSString *)encryptKey
expireTime:(long) expireTime;
expireTime:(long)expireTime;

@end
33 changes: 16 additions & 17 deletions HappyDNS/QNNiuDns.m → HappyDNS/Http/QNNiuDns.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
//

#import "QNNiuDns.h"
#import "QNDomain.h"
#import "QNRecord.h"
#import "QNNetworkInfo.h"
#import "QNDes.h"
#import "QNDomain.h"
#import "QNHex.h"
#import "QNNetworkInfo.h"
#import "QNRecord.h"

#define ENDPOINT @"https://httpdns.qnydns.net:18443/"

@interface QNNiuDns()
@interface QNNiuDns ()

@property (nonatomic, strong) QNDes *des;

Expand All @@ -29,11 +29,11 @@ - (instancetype)initWithAccountId:(NSString *)accountId {

- (instancetype)initWithAccountId:(NSString *)accountId
encryptKey:(NSString *)encryptKey
expireTime:(long) expireTime {
expireTime:(long)expireTime {
if (self = [super init]) {
_accountId = accountId;
_expireTime = expireTime;
if(encryptKey) {
if (encryptKey) {
_encryptKey = encryptKey;
_des = [[QNDes alloc] init:[encryptKey dataUsingEncoding:NSUTF8StringEncoding]];
}
Expand Down Expand Up @@ -63,25 +63,25 @@ - (NSArray *)decrypt:(NSString *)raw {
}

- (NSArray *)query:(QNDomain *)domain networkInfo:(QNNetworkInfo *)netInfo error:(NSError *__autoreleasing *)error {
NSString * realDomain = domain.domain;

NSString *realDomain = domain.domain;
if (self.encryptKey) {
realDomain = [self encrypt:[NSString stringWithFormat:@"%@?e=%ld",domain.domain,(long)[[NSDate date] timeIntervalSince1970] + self.expireTime]];
realDomain = [self encrypt:[NSString stringWithFormat:@"%@?e=%ld", domain.domain, (long)[[NSDate date] timeIntervalSince1970] + self.expireTime]];
if (realDomain == nil) {
if (error != nil) {
*error = [[NSError alloc] initWithDomain:domain.domain code:kQN_ENCRYPT_FAILED userInfo:nil];
}
return nil;
}
}
NSString *url = [NSString stringWithFormat:@"%@%@/d?dn=%@&ttl=1", ENDPOINT,self.accountId,realDomain];
NSString *url = [NSString stringWithFormat:@"%@%@/d?dn=%@&ttl=1", ENDPOINT, self.accountId, realDomain];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:QN_DNS_DEFAULT_TIMEOUT];
NSHTTPURLResponse *response = nil;
NSError *httpError = nil;
NSData* data = [NSURLConnection sendSynchronousRequest:urlRequest
NSData *data = [NSURLConnection sendSynchronousRequest:urlRequest
returningResponse:&response
error:&httpError];

if (httpError != nil) {
if (error != nil) {
*error = httpError;
Expand All @@ -91,19 +91,18 @@ - (NSArray *)query:(QNDomain *)domain networkInfo:(QNNetworkInfo *)netInfo error
if (response.statusCode != 200) {
return nil;
}


NSDictionary * raw = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];

NSDictionary *raw = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
if (raw == nil) {
if (error != nil) {
*error = [[NSError alloc] initWithDomain:domain.domain code:kQN_DECRYPT_FAILED userInfo:nil];
}
return nil;
}
NSArray * rawArray;
NSArray *rawArray;
if (self.encryptKey) {
rawArray = [self decrypt:raw[@"data"]][0];
}else {
} else {
rawArray = raw[@"data"][0];
}
if (rawArray.count <= 0) {
Expand Down
8 changes: 4 additions & 4 deletions HappyDNSTests/NiuDnsTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
// Copyright © 2018年 Qiniu Cloud Storage. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "QNDomain.h"
#import "QNNiuDns.h"
#import "QNRecord.h"
#import "QNResolverDelegate.h"
#import "QNNiuDns.h"
#import <XCTest/XCTest.h>

@interface NiuDnsTest : XCTestCase

Expand All @@ -36,7 +36,7 @@ - (void)testHttpDNSWithEncryptKey {
XCTAssert(records.count >= 1, @"Pass");
QNRecord *record = [records objectAtIndex:0];
XCTAssert(record.ttl >= 0, @"Pass");

records = [resolver query:[[QNDomain alloc] init:@"www.qiniu.com"] networkInfo:nil error:nil];
XCTAssert(records != nil, @"Pass");
XCTAssert(records.count >= 1, @"Pass");
Expand All @@ -52,7 +52,7 @@ - (void)testHttpDNS {
XCTAssert(records.count >= 1, @"Pass");
QNRecord *record = [records objectAtIndex:0];
XCTAssert(record.ttl >= 0, @"Pass");

records = [resolver query:[[QNDomain alloc] init:@"www.qiniu.com"] networkInfo:nil error:nil];
XCTAssert(records != nil, @"Pass");
XCTAssert(records.count >= 1, @"Pass");
Expand Down
Empty file modified format.sh
100644 → 100755
Empty file.

0 comments on commit 0063d3b

Please sign in to comment.