Skip to content

Commit

Permalink
Merge pull request #175 from longbai/ipv6
Browse files Browse the repository at this point in the history
ipv6 support for ios8
  • Loading branch information
longbai committed May 31, 2016
2 parents b9fd1e3 + f6ef8bf commit 7df8239
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 36 deletions.
36 changes: 18 additions & 18 deletions QiniuDemo/QiniuDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@
isa = PBXNativeTarget;
buildConfigurationList = 93D2304C1C86D7F800434F6D /* Build configuration list for PBXNativeTarget "QiniuDemo" */;
buildPhases = (
D0F6ADCA764EF90D58C53A3C /* Check Pods Manifest.lock */,
D0F6ADCA764EF90D58C53A3C /* 📦 Check Pods Manifest.lock */,
93D2301B1C86D7F700434F6D /* Sources */,
93D2301C1C86D7F700434F6D /* Frameworks */,
93D2301D1C86D7F700434F6D /* Resources */,
E7747219847A629D5312382A /* Embed Pods Frameworks */,
200D9CECB60715C9746F9444 /* Copy Pods Resources */,
E7747219847A629D5312382A /* 📦 Embed Pods Frameworks */,
200D9CECB60715C9746F9444 /* 📦 Copy Pods Resources */,
);
buildRules = (
);
Expand All @@ -199,12 +199,12 @@
isa = PBXNativeTarget;
buildConfigurationList = 93D2304F1C86D7F800434F6D /* Build configuration list for PBXNativeTarget "QiniuDemoTests" */;
buildPhases = (
7BC7BFB54A15F4E854C3D84E /* Check Pods Manifest.lock */,
7BC7BFB54A15F4E854C3D84E /* 📦 Check Pods Manifest.lock */,
93D230341C86D7F700434F6D /* Sources */,
93D230351C86D7F700434F6D /* Frameworks */,
93D230361C86D7F700434F6D /* Resources */,
29A428BC542135B14A72E77B /* Embed Pods Frameworks */,
ABE36606520E0BC28F0FB079 /* Copy Pods Resources */,
29A428BC542135B14A72E77B /* 📦 Embed Pods Frameworks */,
ABE36606520E0BC28F0FB079 /* 📦 Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -304,89 +304,89 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
200D9CECB60715C9746F9444 /* Copy Pods Resources */ = {
200D9CECB60715C9746F9444 /* 📦 Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy Pods Resources";
name = "📦 Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-QiniuDemo/Pods-QiniuDemo-resources.sh\"\n";
showEnvVarsInLog = 0;
};
29A428BC542135B14A72E77B /* Embed Pods Frameworks */ = {
29A428BC542135B14A72E77B /* 📦 Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Embed Pods Frameworks";
name = "📦 Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-QiniuDemoTests/Pods-QiniuDemoTests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
7BC7BFB54A15F4E854C3D84E /* Check Pods Manifest.lock */ = {
7BC7BFB54A15F4E854C3D84E /* 📦 Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check Pods Manifest.lock";
name = "📦 Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
ABE36606520E0BC28F0FB079 /* Copy Pods Resources */ = {
ABE36606520E0BC28F0FB079 /* 📦 Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy Pods Resources";
name = "📦 Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-QiniuDemoTests/Pods-QiniuDemoTests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
D0F6ADCA764EF90D58C53A3C /* Check Pods Manifest.lock */ = {
D0F6ADCA764EF90D58C53A3C /* 📦 Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check Pods Manifest.lock";
name = "📦 Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
E7747219847A629D5312382A /* Embed Pods Frameworks */ = {
E7747219847A629D5312382A /* 📦 Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Embed Pods Frameworks";
name = "📦 Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
20 changes: 11 additions & 9 deletions QiniuSDK/Http/QNHttpManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,17 @@ - (void)sendRequest:(NSMutableURLRequest *)request
url = [[NSURL alloc] initWithString:_converter(u)];
request.URL = url;
domain = url.host;
} else if (_dns != nil && [url.scheme isEqual:@"http"] && !(isIpV6FullySupported() && [QNIP isV6])) {
ips = [_dns queryWithDomain:[[QNDomain alloc] init:domain hostsFirst:NO hasCname:YES maxTtl:1000]];
double duration = [[NSDate date] timeIntervalSinceDate:startTime];
if (ips == nil || ips.count == 0) {
NSError *error = [[NSError alloc] initWithDomain:domain code:-1003 userInfo:@{ @"error" : @"unkonwn host" }];
QNResponseInfo *info = [QNResponseInfo responseInfoWithNetError:error host:domain duration:duration];
NSLog(@"failure %@", info);
completeBlock(info, nil);
return;
} else if (_dns != nil && [url.scheme isEqual:@"http"]) {
if (isIpV6FullySupported() || ![QNIP isV6]) {
ips = [_dns queryWithDomain:[[QNDomain alloc] init:domain hostsFirst:NO hasCname:YES maxTtl:1000]];
double duration = [[NSDate date] timeIntervalSinceDate:startTime];
if (ips == nil || ips.count == 0) {
NSError *error = [[NSError alloc] initWithDomain:domain code:-1003 userInfo:@{ @"error" : @"unkonwn host" }];
QNResponseInfo *info = [QNResponseInfo responseInfoWithNetError:error host:domain duration:duration];
NSLog(@"failure %@", info);
completeBlock(info, nil);
return;
}
}
}
[self sendRequest2:request withCompleteBlock:completeBlock withProgressBlock:progressBlock withCancelBlock:cancelBlock withIpArray:ips withIndex:0 withDomain:domain withRetryTimes:kQNRetryConnectTimes withStartTime:startTime];
Expand Down
20 changes: 11 additions & 9 deletions QiniuSDK/Http/QNSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,20 @@ - (void)sendRequest:(NSMutableURLRequest *)request
url = [[NSURL alloc] initWithString:_converter(u)];
request.URL = url;
domain = url.host;
} else if (_noProxy && _dns != nil && [url.scheme isEqualToString:@"http"] && !(isIpV6FullySupported() && [QNIP isV6])) {
ips = [_dns queryWithDomain:[[QNDomain alloc] init:domain hostsFirst:NO hasCname:YES maxTtl:1000]];
double duration = [[NSDate date] timeIntervalSinceDate:startTime];
} else if (_noProxy && _dns != nil && [url.scheme isEqualToString:@"http"]) {
if (isIpV6FullySupported() || ![QNIP isV6]) {
ips = [_dns queryWithDomain:[[QNDomain alloc] init:domain hostsFirst:NO hasCname:YES maxTtl:1000]];
double duration = [[NSDate date] timeIntervalSinceDate:startTime];

if (ips == nil || ips.count == 0) {
NSError *error = [[NSError alloc] initWithDomain:domain code:-1003 userInfo:@{ @"error" : @"unkonwn host" }];
if (ips == nil || ips.count == 0) {
NSError *error = [[NSError alloc] initWithDomain:domain code:-1003 userInfo:@{ @"error" : @"unkonwn host" }];

QNResponseInfo *info = [QNResponseInfo responseInfoWithNetError:error host:domain duration:duration];
NSLog(@"failure %@", info);
QNResponseInfo *info = [QNResponseInfo responseInfoWithNetError:error host:domain duration:duration];
NSLog(@"failure %@", info);

completeBlock(info, nil);
return;
completeBlock(info, nil);
return;
}
}
}
[self sendRequest2:request withCompleteBlock:completeBlock withProgressBlock:progressBlock withCancelBlock:cancelBlock withIpArray:ips withIndex:0 withDomain:domain withRetryTimes:3 withStartTime:startTime];
Expand Down

0 comments on commit 7df8239

Please sign in to comment.