ObjFW
OFTCPSocketSOCKS5Connector.h
1 /*
2  * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License version 3.0 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13  * version 3.0 for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * version 3.0 along with this program. If not, see
17  * <https://www.gnu.org/licenses/>.
18  */
19 
20 #import "OFTCPSocket.h"
21 
22 OF_ASSUME_NONNULL_BEGIN
23 
24 @class OFString;
25 
26 @interface OFTCPSocketSOCKS5Connector: OFObject <OFTCPSocketDelegate>
27 {
28  OFTCPSocket *_socket;
29  OFString *_host;
30  uint16_t _port;
31  id <OFTCPSocketDelegate> _Nullable _delegate;
32 #ifdef OF_HAVE_BLOCKS
33  OFTCPSocketConnectedHandler _Nullable _handler;
34 #endif
35  id _Nullable _exception;
36  uint_least8_t _SOCKS5State;
37  /* Longest read is domain name (max 255 bytes) + port */
38  unsigned char _buffer[257];
39  OFMutableData *_Nullable _request;
40 }
41 
42 - (instancetype)initWithSocket: (OFTCPSocket *)sock
43  host: (OFString *)host
44  port: (uint16_t)port
45  delegate: (nullable id <OFTCPSocketDelegate>)delegate
46 #ifdef OF_HAVE_BLOCKS
47  handler: (nullable OFTCPSocketConnectedHandler)handler
48 #endif
49 ;
50 - (void)didConnect;
51 @end
52 
53 OF_ASSUME_NONNULL_END
The root class for all other classes inside ObjFW.
Definition: OFObject.h:690
void(^ OFTCPSocketConnectedHandler)(OFTCPSocket *socket, OFString *host, uint16_t port, id exception)
A handler which is called when the socket connected.
Definition: OFTCPSocket.h:51
A class for handling strings.
Definition: OFString.h:142
A class which provides methods to create and use TCP sockets.
Definition: OFTCPSocket.h:85
A class for storing and manipulating arbitrary data in an array.
Definition: OFMutableData.h:29