ObjFW
OFTCPSocketSOCKS5Connector.h
1 /*
2  * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This file is part of ObjFW. It may be distributed under the terms of the
7  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8  * the packaging of this file.
9  *
10  * Alternatively, it may be distributed under the terms of the GNU General
11  * Public License, either version 2 or 3, which can be found in the file
12  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13  * file.
14  */
15 
16 #import "OFTCPSocket.h"
17 
18 OF_ASSUME_NONNULL_BEGIN
19 
20 @class OFString;
21 
22 @interface OFTCPSocketSOCKS5Connector: OFObject <OFTCPSocketDelegate>
23 {
24  OFTCPSocket *_socket;
25  OFString *_host;
26  uint16_t _port;
27  id <OFTCPSocketDelegate> _Nullable _delegate;
28 #ifdef OF_HAVE_BLOCKS
29  of_tcp_socket_async_connect_block_t _Nullable _block;
30 #endif
31  id _Nullable _exception;
32  enum {
33  OF_SOCKS5_STATE_SEND_AUTHENTICATION = 1,
34  OF_SOCKS5_STATE_READ_VERSION,
35  OF_SOCKS5_STATE_SEND_REQUEST,
36  OF_SOCKS5_STATE_READ_RESPONSE,
37  OF_SOCKS5_STATE_READ_ADDRESS,
38  OF_SOCKS5_STATE_READ_ADDRESS_LENGTH,
39  } _SOCKS5State;
40  /* Longest read is domain name (max 255 bytes) + port */
41  unsigned char _buffer[257];
42  OFMutableData *_Nullable _request;
43 }
44 
45 - (instancetype)initWithSocket: (OFTCPSocket *)sock
46  host: (OFString *)host
47  port: (uint16_t)port
48  delegate: (nullable id <OFTCPSocketDelegate>)delegate
49 #ifdef OF_HAVE_BLOCKS
50  block: (nullable of_tcp_socket_async_connect_block_t)
51  block
52 #endif
53 ;
54 - (void)didConnect;
55 @end
56 
57 OF_ASSUME_NONNULL_END
void(^ of_tcp_socket_async_connect_block_t)(id _Nullable exception)
A block which is called when the socket connected.
Definition: OFTCPSocket.h:33
struct objc_object * id
A pointer to any object.
Definition: ObjFWRT.h:90
A class for storing and manipulating arbitrary data in an array.
Definition: OFMutableData.h:29
The root class for all other classes inside ObjFW.
Definition: OFObject.h:520
A class for handling strings.
Definition: OFString.h:132
A class which provides methods to create and use TCP sockets.
Definition: OFTCPSocket.h:67
Definition: OFTCPSocket.h:41