Skip to content

Commit f03e31b

Browse files
committed
Fixing issues after merge
1 parent f062d36 commit f03e31b

File tree

4 files changed

+69
-19
lines changed

4 files changed

+69
-19
lines changed

GCD/GCDAsyncSocket.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6324,13 +6324,13 @@ - (void)cf_startTLS
63246324
NSAssert([currentWrite isKindOfClass:[GCDAsyncSpecialPacket class]], @"Invalid write packet for startTLS");
63256325

63266326
GCDAsyncSpecialPacket *tlsPacket = (GCDAsyncSpecialPacket *)currentRead;
6327-
NSDictionary *tlsSettings = tlsPacket->tlsSettings;
6327+
CFDictionaryRef tlsSettings = (__bridge CFDictionaryRef)tlsPacket->tlsSettings;
63286328

63296329
// Getting an error concerning kCFStreamPropertySSLSettings ?
63306330
// You need to add the CFNetwork framework to your iOS application.
63316331

6332-
BOOL r1 = CFReadStreamSetProperty(readStream, kCFStreamPropertySSLSettings, (CFDictionaryRef)tlsSettings);
6333-
BOOL r2 = CFWriteStreamSetProperty(writeStream, kCFStreamPropertySSLSettings, (CFDictionaryRef)tlsSettings);
6332+
BOOL r1 = CFReadStreamSetProperty(readStream, kCFStreamPropertySSLSettings, tlsSettings);
6333+
BOOL r2 = CFWriteStreamSetProperty(writeStream, kCFStreamPropertySSLSettings, tlsSettings);
63346334

63356335
// For some reason, starting around the time of iOS 4.3,
63366336
// the first call to set the kCFStreamPropertySSLSettings will return true,

GCD/Xcode/SimpleHTTPClient/Desktop/SimpleHTTPClient/SimpleHTTPClientAppDelegate.m

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
#import "GCDAsyncSocket.h"
33
#import "DDLog.h"
44
#import "DDTTYLogger.h"
5+
#import "DispatchQueueLogFormatter.h"
56

67
// Log levels: off, error, warn, info, verbose
78
static const int ddLogLevel = LOG_LEVEL_VERBOSE;
89

910
#define HOST @"google.com"
1011

1112
#define USE_SECURE_CONNECTION 0
13+
#define VALIDATE_SSL_CERTIFICATE 1
14+
1215
#define READ_HEADER_LINE_BY_LINE 0
1316

1417

@@ -37,6 +40,24 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
3740

3841
[DDLog addLogger:[DDTTYLogger sharedInstance]];
3942

43+
// We're going to take advantage of some of Lumberjack's advanced features.
44+
//
45+
// Format log statements such that it outputs the queue/thread name.
46+
// As opposed to the not-so-helpful mach thread id.
47+
//
48+
// Old : 2011-12-05 19:54:08:161 [17894:f803] Connecting...
49+
// 2011-12-05 19:54:08:161 [17894:11f03] GCDAsyncSocket: Dispatching DNS lookup...
50+
// 2011-12-05 19:54:08:161 [17894:13303] GCDAsyncSocket: Creating IPv4 socket
51+
//
52+
// New : 2011-12-05 19:54:08:161 [main] Connecting...
53+
// 2011-12-05 19:54:08:161 [socket] GCDAsyncSocket: Dispatching DNS lookup...
54+
// 2011-12-05 19:54:08:161 [socket] GCDAsyncSocket: Creating IPv4 socket
55+
56+
DispatchQueueLogFormatter *formatter = [[DispatchQueueLogFormatter alloc] init];
57+
[formatter setReplacementString:@"socket" forQueueLabel:GCDAsyncSocketQueueName];
58+
[formatter setReplacementString:@"socket-cf" forQueueLabel:GCDAsyncSocketThreadName];
59+
60+
[[DDTTYLogger sharedInstance] setLogFormatter:formatter];
4061

4162
// Create our GCDAsyncSocket instance.
4263
//
@@ -106,17 +127,21 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
106127
// Some servers only have a development (self-signed) X.509 certificate.
107128
// In this case we could tell it not to attempt to validate the cert (cause if it did it would fail).
108129

109-
if (NO)
130+
#if VALIDATE_SSL_CERTIFICATE
110131
{
111-
NSDictionary *options =
112-
[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO]
113-
forKey:(NSString *)kCFStreamSSLValidatesCertificateChain];
114-
[asyncSocket startTLS:options];
132+
DDLogVerbose(@"Requesting StartTLS with options: (nil)");
133+
[asyncSocket startTLS:nil];
115134
}
116-
else
135+
#else
117136
{
118-
[asyncSocket startTLS:nil];
137+
NSDictionary *options =
138+
[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO]
139+
forKey:(NSString *)kCFStreamSSLValidatesCertificateChain];
140+
141+
DDLogVerbose(@"Requesting StartTLS with options:\n%@", options);
142+
[asyncSocket startTLS:options];
119143
}
144+
#endif
120145

121146
#endif
122147
}

GCD/Xcode/SimpleHTTPClient/Mobile/SimpleHTTPClient.xcodeproj/project.pbxproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
DC80CA5213C3B43F00D29D06 /* SimpleHTTPClientViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = DC80CA5013C3B43F00D29D06 /* SimpleHTTPClientViewController.xib */; };
2727
DC80CA6D13C3B4AA00D29D06 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC80CA6C13C3B4AA00D29D06 /* CFNetwork.framework */; };
2828
DC80CAA313C3B94B00D29D06 /* GCDAsyncSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = DC80CAA213C3B94B00D29D06 /* GCDAsyncSocket.m */; };
29+
DCFF8C051529676500448078 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCFF8C041529676500448078 /* Security.framework */; };
2930
/* End PBXBuildFile section */
3031

3132
/* Begin PBXFileReference section */
@@ -61,13 +62,15 @@
6162
DC80CA6C13C3B4AA00D29D06 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; };
6263
DC80CAA113C3B94B00D29D06 /* GCDAsyncSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GCDAsyncSocket.h; path = ../../../GCDAsyncSocket.h; sourceTree = "<group>"; };
6364
DC80CAA213C3B94B00D29D06 /* GCDAsyncSocket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GCDAsyncSocket.m; path = ../../../GCDAsyncSocket.m; sourceTree = "<group>"; };
65+
DCFF8C041529676500448078 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
6466
/* End PBXFileReference section */
6567

6668
/* Begin PBXFrameworksBuildPhase section */
6769
DC80CA3113C3B43F00D29D06 /* Frameworks */ = {
6870
isa = PBXFrameworksBuildPhase;
6971
buildActionMask = 2147483647;
7072
files = (
73+
DCFF8C051529676500448078 /* Security.framework in Frameworks */,
7174
DC80CA6D13C3B4AA00D29D06 /* CFNetwork.framework in Frameworks */,
7275
DC80CA3913C3B43F00D29D06 /* UIKit.framework in Frameworks */,
7376
DC80CA3B13C3B43F00D29D06 /* Foundation.framework in Frameworks */,
@@ -115,8 +118,9 @@
115118
children = (
116119
DC80CA3813C3B43F00D29D06 /* UIKit.framework */,
117120
DC80CA3A13C3B43F00D29D06 /* Foundation.framework */,
118-
DC80CA6C13C3B4AA00D29D06 /* CFNetwork.framework */,
119121
DC80CA3C13C3B43F00D29D06 /* CoreGraphics.framework */,
122+
DC80CA6C13C3B4AA00D29D06 /* CFNetwork.framework */,
123+
DCFF8C041529676500448078 /* Security.framework */,
120124
);
121125
name = Frameworks;
122126
sourceTree = "<group>";

GCD/Xcode/SimpleHTTPClient/Mobile/SimpleHTTPClient/SimpleHTTPClientAppDelegate.m

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
#import "GCDAsyncSocket.h"
44
#import "DDLog.h"
55
#import "DDTTYLogger.h"
6+
#import "DispatchQueueLogFormatter.h"
67

78
// Log levels: off, error, warn, info, verbose
89
static const int ddLogLevel = LOG_LEVEL_VERBOSE;
910

1011
#define HOST @"google.com"
1112

1213
#define USE_SECURE_CONNECTION 0
14+
#define VALIDATE_SSL_CERTIFICATE 1
15+
1316
#define READ_HEADER_LINE_BY_LINE 0
1417

1518

@@ -34,11 +37,28 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
3437
//
3538
// There is a massive amount of documentation on the Lumberjack project page:
3639
// http://code.google.com/p/cocoalumberjack/
37-
//
38-
// But this one line is all you need to instruct Lumberjack to spit out log statements to the Xcode console.
3940

4041
[DDLog addLogger:[DDTTYLogger sharedInstance]];
4142

43+
// We're going to take advantage of some of Lumberjack's advanced features.
44+
//
45+
// Format log statements such that it outputs the queue/thread name.
46+
// As opposed to the not-so-helpful mach thread id.
47+
//
48+
// Old : 2011-12-05 19:54:08:161 [17894:f803] Connecting...
49+
// 2011-12-05 19:54:08:161 [17894:11f03] GCDAsyncSocket: Dispatching DNS lookup...
50+
// 2011-12-05 19:54:08:161 [17894:13303] GCDAsyncSocket: Creating IPv4 socket
51+
//
52+
// New : 2011-12-05 19:54:08:161 [main] Connecting...
53+
// 2011-12-05 19:54:08:161 [socket] GCDAsyncSocket: Dispatching DNS lookup...
54+
// 2011-12-05 19:54:08:161 [socket] GCDAsyncSocket: Creating IPv4 socket
55+
56+
DispatchQueueLogFormatter *formatter = [[DispatchQueueLogFormatter alloc] init];
57+
[formatter setReplacementString:@"socket" forQueueLabel:GCDAsyncSocketQueueName];
58+
[formatter setReplacementString:@"socket-cf" forQueueLabel:GCDAsyncSocketThreadName];
59+
60+
[[DDTTYLogger sharedInstance] setLogFormatter:formatter];
61+
4262
// Create our GCDAsyncSocket instance.
4363
//
4464
// Notice that we give it the normal delegate AND a delegate queue.
@@ -106,7 +126,12 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
106126
// Some servers only have a development (self-signed) X.509 certificate.
107127
// In this case we would tell it not to attempt to validate the cert (cause if it did it would fail).
108128

109-
if (NO)
129+
#if VALIDATE_SSL_CERTIFICATE
130+
{
131+
DDLogVerbose(@"Requesting StartTLS with options: (nil)");
132+
[asyncSocket startTLS:nil];
133+
}
134+
#else
110135
{
111136
NSDictionary *options =
112137
[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO]
@@ -115,11 +140,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
115140
DDLogVerbose(@"Requesting StartTLS with options:\n%@", options);
116141
[asyncSocket startTLS:options];
117142
}
118-
else
119-
{
120-
DDLogVerbose(@"Requesting StartTLS with options: (nil)");
121-
[asyncSocket startTLS:nil];
122-
}
143+
#endif
123144

124145
#endif
125146

0 commit comments

Comments
 (0)