socks_connecter.hpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MPL-2.0 */
2 
3 #ifndef __SOCKS_CONNECTER_HPP_INCLUDED__
4 #define __SOCKS_CONNECTER_HPP_INCLUDED__
5 
6 #include "fd.hpp"
8 #include "stdint.hpp"
9 #include "socks.hpp"
10 
11 namespace zmq
12 {
13 class io_thread_t;
14 class session_base_t;
15 struct address_t;
16 
17 class socks_connecter_t ZMQ_FINAL : public stream_connecter_base_t
18 {
19  public:
20  // If 'delayed_start' is true connecter first waits for a while,
21  // then starts connection process.
22  socks_connecter_t (zmq::io_thread_t *io_thread_,
23  zmq::session_base_t *session_,
24  const options_t &options_,
25  address_t *addr_,
26  address_t *proxy_addr_,
27  bool delayed_start_);
28  ~socks_connecter_t ();
29 
30  void set_auth_method_basic (const std::string &username,
31  const std::string &password);
32  void set_auth_method_none ();
33 
34 
35  private:
36  enum
37  {
46  waiting_for_response
47  };
48 
49  // Method ID
50  enum
51  {
52  socks_no_auth_required = 0x00,
53  socks_basic_auth = 0x02,
54  socks_no_acceptable_method = 0xff
55  };
56 
57  // Handlers for I/O events.
58  void in_event ();
59  void out_event ();
60 
61  // Internal function to start the actual connection establishment.
62  void start_connecting ();
63 
64  static int process_server_response (const socks_choice_t &response_);
65  static int process_server_response (const socks_response_t &response_);
66  static int process_server_response (const socks_auth_response_t &response_);
67 
68  static int parse_address (const std::string &address_,
69  std::string &hostname_,
70  uint16_t &port_);
71 
72  int connect_to_proxy ();
73 
74  void error ();
75 
76  // Open TCP connecting socket. Returns -1 in case of error,
77  // 0 if connect was successful immediately. Returns -1 with
78  // EAGAIN errno if async connect was launched.
79  int open ();
80 
81  // Get the file descriptor of newly created connection. Returns
82  // retired_fd if the connection was unsuccessful.
83  zmq::fd_t check_proxy_connection () const;
84 
91 
92  // SOCKS address; owned by this connecter.
94 
95  // User defined authentication method
97 
98  // Credentials for basic authentication
101 
102  int _status;
103 
104  ZMQ_NON_COPYABLE_NOR_MOVABLE (socks_connecter_t)
105 };
106 }
107 
108 #endif
zmq::ZMQ_FINAL::_auth_password
std::string _auth_password
Definition: socks_connecter.hpp:100
zmq::session_base_t
Definition: session_base.hpp:21
zmq::ZMQ_FINAL::_request_encoder
socks_request_encoder_t _request_encoder
Definition: socks_connecter.hpp:89
zmq::socks_response_decoder_t
Definition: socks.hpp:136
string
GLsizei const GLchar *const * string
Definition: glcorearb.h:3083
zmq::ZMQ_FINAL::unplugged
@ unplugged
Definition: socks_connecter.hpp:38
zmq::ZMQ_FINAL::_basic_auth_request_encoder
socks_basic_auth_request_encoder_t _basic_auth_request_encoder
Definition: socks_connecter.hpp:87
error
Definition: cJSON.c:88
zmq::ZMQ_FINAL::_proxy_addr
address_t * _proxy_addr
Definition: socks_connecter.hpp:93
zmq::ZMQ_FINAL::waiting_for_proxy_connection
@ waiting_for_proxy_connection
Definition: socks_connecter.hpp:40
zmq::fd_t
int fd_t
Definition: zmq.hpp:287
socks.hpp
zmq::socks_auth_response_t
Definition: socks.hpp:82
zmq
Definition: zmq.hpp:229
stdint.hpp
zmq::ZMQ_FINAL::_response_decoder
socks_response_decoder_t _response_decoder
Definition: socks_connecter.hpp:90
zmq::ZMQ_FINAL::_status
int _status
Definition: socks_connecter.hpp:102
ZMQ_NON_COPYABLE_NOR_MOVABLE
#define ZMQ_NON_COPYABLE_NOR_MOVABLE(classname)
Definition: macros.hpp:58
zmq::ZMQ_FINAL::sending_request
@ sending_request
Definition: socks_connecter.hpp:45
fd.hpp
zmq::ZMQ_FINAL::waiting_for_choice
@ waiting_for_choice
Definition: socks_connecter.hpp:42
zmq::ZMQ_FINAL::_auth_method
int _auth_method
Definition: socks_connecter.hpp:96
zmq::ZMQ_FINAL::_auth_username
std::string _auth_username
Definition: socks_connecter.hpp:99
zmq::ZMQ_FINAL::waiting_for_auth_response
@ waiting_for_auth_response
Definition: socks_connecter.hpp:44
zmq::ZMQ_FINAL::sending_basic_auth_request
@ sending_basic_auth_request
Definition: socks_connecter.hpp:43
zmq::address_t
Definition: address.hpp:64
zmq::ZMQ_FINAL::sending_greeting
@ sending_greeting
Definition: socks_connecter.hpp:41
zmq::ZMQ_FINAL::waiting_for_reconnect_time
@ waiting_for_reconnect_time
Definition: socks_connecter.hpp:39
zmq::ZMQ_FINAL::_auth_response_decoder
socks_auth_response_decoder_t _auth_response_decoder
Definition: socks_connecter.hpp:88
zmq::ZMQ_FINAL::_greeting_encoder
socks_greeting_encoder_t _greeting_encoder
Definition: socks_connecter.hpp:85
zmq::socks_auth_response_decoder_t
Definition: socks.hpp:88
zmq::socks_request_encoder_t
Definition: socks.hpp:111
zmq::socks_greeting_encoder_t
Definition: socks.hpp:21
zmq::ZMQ_FINAL::_choice_decoder
socks_choice_decoder_t _choice_decoder
Definition: socks_connecter.hpp:86
zmq::socks_choice_decoder_t
Definition: socks.hpp:43
stream_connecter_base.hpp
ZMQ_FINAL
Definition: unittest_ip_resolver.cpp:26
zmq::socks_basic_auth_request_encoder_t
Definition: socks.hpp:67
zmq::socks_choice_t
Definition: socks.hpp:36
zmq::socks_response_t
Definition: socks.hpp:126
options_
DebugStringOptions options_
Definition: src/google/protobuf/descriptor.cc:2410


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:58