ObjFW  Check-in [eb2bfc674b]

Overview
Comment:Make SOCKS5 work with TLS sockets
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: eb2bfc674b9c9a9c62d5e06f83be1a25fb26f330da6a911c9f29fe3820d4d145
User & Date: js on 2021-11-07 20:02:32
Other Links: manifest | tags
Context
2021-11-13
13:04
Completely rework the TLS/SSL API check-in: d30efa8bbf user: js tags: trunk
2021-11-07
20:02
Make SOCKS5 work with TLS sockets check-in: eb2bfc674b user: js tags: trunk
19:44
Let -[OFStream flushWriteBuffer] return a bool check-in: 7faf776e26 user: js tags: trunk
Changes

Modified src/OFTCPSocketSOCKS5Connector.h from [a3decd0834] to [cfa41043ad].

18
19
20
21
22
23
24

25
26
27
28
29
30
31
OF_ASSUME_NONNULL_BEGIN

@class OFString;

@interface OFTCPSocketSOCKS5Connector: OFObject <OFTCPSocketDelegate>
{
	OFTCPSocket *_socket;

	OFString *_host;
	uint16_t _port;
	id <OFTCPSocketDelegate> _Nullable _delegate;
#ifdef OF_HAVE_BLOCKS
	OFTCPSocketAsyncConnectBlock _Nullable _block;
#endif
	id _Nullable _exception;







>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
OF_ASSUME_NONNULL_BEGIN

@class OFString;

@interface OFTCPSocketSOCKS5Connector: OFObject <OFTCPSocketDelegate>
{
	OFTCPSocket *_socket;
	Class _socketClass;
	OFString *_host;
	uint16_t _port;
	id <OFTCPSocketDelegate> _Nullable _delegate;
#ifdef OF_HAVE_BLOCKS
	OFTCPSocketAsyncConnectBlock _Nullable _block;
#endif
	id _Nullable _exception;

Modified src/OFTCPSocketSOCKS5Connector.m from [cef61681e6] to [a3d986247b].

50
51
52
53
54
55
56








57
58
59
60
61
62
63
64
65
66
67
68
69


70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85

86
87
88
89
90
91
92
		_host = [host copy];
		_port = port;
		_delegate = [delegate retain];
#ifdef OF_HAVE_BLOCKS
		_block = [block copy];
#endif









		_socket.delegate = self;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	if (_socket.delegate == self)
		_socket.delegate = _delegate;



	[_socket release];
	[_host release];
	[_delegate release];
#ifdef OF_HAVE_BLOCKS
	[_block release];
#endif
	[_exception release];
	[_request release];

	[super dealloc];
}

- (void)didConnect
{
	_socket.delegate = _delegate;


#ifdef OF_HAVE_BLOCKS
	if (_block != NULL)
		_block(_exception);
	else {
#endif
		if ([_delegate respondsToSelector:







>
>
>
>
>
>
>
>













>
>
















>







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
		_host = [host copy];
		_port = port;
		_delegate = [delegate retain];
#ifdef OF_HAVE_BLOCKS
		_block = [block copy];
#endif

		/*
		 * Temporarily swizzle it to a TCP socket, so that if it's a
		 * TLS socket, we still get to talk to the SOCKS5 proxy
		 * directly.
		 */
		_socketClass = object_getClass(_socket);
		object_setClass(_socket, [OFTCPSocket class]);

		_socket.delegate = self;
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	if (_socket.delegate == self)
		_socket.delegate = _delegate;

	object_setClass(_socket, _socketClass);

	[_socket release];
	[_host release];
	[_delegate release];
#ifdef OF_HAVE_BLOCKS
	[_block release];
#endif
	[_exception release];
	[_request release];

	[super dealloc];
}

- (void)didConnect
{
	_socket.delegate = _delegate;
	object_setClass(_socket, _socketClass);

#ifdef OF_HAVE_BLOCKS
	if (_block != NULL)
		_block(_exception);
	else {
#endif
		if ([_delegate respondsToSelector: