ObjFW  Diff

Differences From Artifact [34fdf0c261]:

To Artifact [bfc7e59ebf]:


62
63
64
65
66
67
68
69

70
71
72
73
74
75
76
62
63
64
65
66
67
68

69
70
71
72
73
74
75
76







-
+







    @"of_tcp_socket_connect_mode";

Class of_tls_socket_class = Nil;

static OFString *defaultSOCKS5Host = nil;
static uint16_t defaultSOCKS5Port = 1080;

@interface OFTCPSocket_AsyncConnectDelegate: OFObject <OFTCPSocketDelegate,
@interface OFTCPSocketAsyncConnectDelegate: OFObject <OFTCPSocketDelegate,
    OFTCPSocketDelegate_Private, OFDNSResolverDelegate>
{
	OFTCPSocket *_socket;
	OFString *_host;
	uint16_t _port;
	OFString *_SOCKS5Host;
	uint16_t _SOCKS5Port;
110
111
112
113
114
115
116
117

118
119
120
121
122
123
124
125

126
127
128
129
130
131
132
110
111
112
113
114
115
116

117
118
119
120
121
122
123
124

125
126
127
128
129
130
131
132







-
+







-
+







#endif
- (void)didConnect;
- (void)tryNextAddressWithRunLoopMode: (of_run_loop_mode_t)runLoopMode;
- (void)startWithRunLoopMode: (of_run_loop_mode_t)runLoopMode;
- (void)sendSOCKS5Request;
@end

@interface OFTCPSocket_ConnectDelegate: OFObject <OFTCPSocketDelegate>
@interface OFTCPSocketConnectDelegate: OFObject <OFTCPSocketDelegate>
{
@public
	bool _done;
	id _exception;
}
@end

@implementation OFTCPSocket_AsyncConnectDelegate
@implementation OFTCPSocketAsyncConnectDelegate
- (instancetype)initWithSocket: (OFTCPSocket *)sock
			  host: (OFString *)host
			  port: (uint16_t)port
		    SOCKS5Host: (OFString *)SOCKS5Host
		    SOCKS5Port: (uint16_t)SOCKS5Port
		      delegate: (id <OFTCPSocketDelegate>)delegate
{
576
577
578
579
580
581
582
583

584
585
586
587
588
589
590
576
577
578
579
580
581
582

583
584
585
586
587
588
589
590







-
+







	default:
		assert(0);
		return nil;
	}
}
@end

@implementation OFTCPSocket_ConnectDelegate
@implementation OFTCPSocketConnectDelegate
- (void)dealloc
{
	[_exception release];

	[super dealloc];
}

707
708
709
710
711
712
713
714
715


716
717
718
719
720
721
722
707
708
709
710
711
712
713


714
715
716
717
718
719
720
721
722







-
-
+
+







#endif

- (void)connectToHost: (OFString *)host
		 port: (uint16_t)port
{
	void *pool = objc_autoreleasePoolPush();
	id <OFTCPSocketDelegate> delegate = [_delegate retain];
	OFTCPSocket_ConnectDelegate *connectDelegate =
	    [[[OFTCPSocket_ConnectDelegate alloc] init] autorelease];
	OFTCPSocketConnectDelegate *connectDelegate =
	    [[[OFTCPSocketConnectDelegate alloc] init] autorelease];
	OFRunLoop *runLoop = [OFRunLoop currentRunLoop];

	self.delegate = connectDelegate;
	[self asyncConnectToHost: host
			    port: port
		     runLoopMode: connectRunLoopMode];

746
747
748
749
750
751
752
753

754
755
756
757
758
759
760
746
747
748
749
750
751
752

753
754
755
756
757
758
759
760







-
+








- (void)asyncConnectToHost: (OFString *)host
		      port: (uint16_t)port
	       runLoopMode: (of_run_loop_mode_t)runLoopMode
{
	void *pool = objc_autoreleasePoolPush();

	[[[[OFTCPSocket_AsyncConnectDelegate alloc]
	[[[[OFTCPSocketAsyncConnectDelegate alloc]
		  initWithSocket: self
			    host: host
			    port: port
		      SOCKS5Host: _SOCKS5Host
		      SOCKS5Port: _SOCKS5Port
			delegate: _delegate] autorelease]
	    startWithRunLoopMode: runLoopMode];
776
777
778
779
780
781
782
783

784
785
786
787
788
789
790
776
777
778
779
780
781
782

783
784
785
786
787
788
789
790







-
+







- (void)asyncConnectToHost: (OFString *)host
		      port: (uint16_t)port
	       runLoopMode: (of_run_loop_mode_t)runLoopMode
		     block: (of_tcp_socket_async_connect_block_t)block
{
	void *pool = objc_autoreleasePoolPush();

	[[[[OFTCPSocket_AsyncConnectDelegate alloc]
	[[[[OFTCPSocketAsyncConnectDelegate alloc]
		  initWithSocket: self
			    host: host
			    port: port
		      SOCKS5Host: _SOCKS5Host
		      SOCKS5Port: _SOCKS5Port
			   block: block] autorelease]
	    startWithRunLoopMode: runLoopMode];