WebSocket++  0.8.0-dev
C++ websocket client/server library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
debug.hpp
1 /*
2  * Copyright (c) 2014, Peter Thorson. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution.
11  * * Neither the name of the WebSocket++ Project nor the
12  * names of its contributors may be used to endorse or promote products
13  * derived from this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL PETER THORSON BE LIABLE FOR ANY
19  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  */
27 
28 #ifndef WEBSOCKETPP_CONFIG_DEBUG_HPP
29 #define WEBSOCKETPP_CONFIG_DEBUG_HPP
30 
31 
32 
33 // Non-Policy common stuff
34 #include <websocketpp/common/cpp11.hpp>
35 #include <websocketpp/common/stdint.hpp>
36 
37 // Concurrency
38 #include <websocketpp/concurrency/basic.hpp>
39 
40 // Transport
41 #include <websocketpp/transport/iostream/endpoint.hpp>
42 
43 // HTTP
44 #include <websocketpp/http/request.hpp>
45 #include <websocketpp/http/response.hpp>
46 
47 // Messages
48 #include <websocketpp/message_buffer/message.hpp>
49 #include <websocketpp/message_buffer/alloc.hpp>
50 
51 // Loggers
52 #include <websocketpp/logger/basic.hpp>
53 
54 // RNG
55 #include <websocketpp/random/none.hpp>
56 
57 // User stub base classes
58 #include <websocketpp/endpoint_base.hpp>
59 #include <websocketpp/connection_base.hpp>
60 
61 // Extensions
62 #include <websocketpp/extensions/permessage_deflate/disabled.hpp>
63 
64 namespace websocketpp {
65 namespace config {
66 
67 /// Client/Server debug config with iostream transport
68 struct debug_core {
69  typedef debug_core type;
70 
71  // Concurrency policy
72  typedef websocketpp::concurrency::basic concurrency_type;
73 
74  // HTTP Parser Policies
75  typedef http::parser::request request_type;
76  typedef http::parser::response response_type;
77 
78  // Message Policies
79  typedef message_buffer::message<message_buffer::alloc::con_msg_manager>
80  message_type;
81  typedef message_buffer::alloc::con_msg_manager<message_type>
82  con_msg_manager_type;
83  typedef message_buffer::alloc::endpoint_msg_manager<con_msg_manager_type>
84  endpoint_msg_manager_type;
85 
86  /// Logging policies
87  typedef websocketpp::log::basic<concurrency_type,
88  websocketpp::log::elevel> elog_type;
89  typedef websocketpp::log::basic<concurrency_type,
90  websocketpp::log::alevel> alog_type;
91 
92  /// RNG policies
93  typedef websocketpp::random::none::int_generator<uint32_t> rng_type;
94 
95  /// Controls compile time enabling/disabling of thread syncronization
96  /// code Disabling can provide a minor performance improvement to single
97  /// threaded applications
98  static bool const enable_multithreading = true;
99 
101  typedef type::concurrency_type concurrency_type;
102  typedef type::elog_type elog_type;
103  typedef type::alog_type alog_type;
104  typedef type::request_type request_type;
105  typedef type::response_type response_type;
106 
107  /// Controls compile time enabling/disabling of thread syncronization
108  /// code Disabling can provide a minor performance improvement to single
109  /// threaded applications
110  static bool const enable_multithreading = true;
111 
112  /// Default timer values (in ms)
113 
114  /// Length of time to wait for socket pre-initialization
115  /**
116  * Exactly what this includes depends on the socket policy in use
117  */
118  static const long timeout_socket_pre_init = 5000;
119 
120  /// Length of time to wait before a proxy handshake is aborted
121  static const long timeout_proxy = 5000;
122 
123  /// Length of time to wait for socket post-initialization
124  /**
125  * Exactly what this includes depends on the socket policy in use.
126  * Often this means the TLS handshake
127  */
128  static const long timeout_socket_post_init = 5000;
129 
130  /// Length of time to wait for dns resolution
131  static const long timeout_dns_resolve = 5000;
132 
133  /// Length of time to wait for TCP connect
134  static const long timeout_connect = 5000;
135 
136  /// Length of time to wait for socket shutdown
137  static const long timeout_socket_shutdown = 5000;
138  };
139 
140  /// Transport Endpoint Component
141  typedef websocketpp::transport::iostream::endpoint<transport_config>
142  transport_type;
143 
144  /// User overridable Endpoint base class
146  /// User overridable Connection base class
148 
149  /// Default timer values (in ms)
150 
151  /// Length of time before an opening handshake is aborted
152  static const long timeout_open_handshake = 5000;
153  /// Length of time before a closing handshake is aborted
154  static const long timeout_close_handshake = 5000;
155  /// Length of time to wait for a pong after a ping
156  static const long timeout_pong = 5000;
157 
158  /// WebSocket Protocol version to use as a client
159  /**
160  * What version of the WebSocket Protocol to use for outgoing client
161  * connections. Setting this to a value other than 13 (RFC6455) is not
162  * recommended.
163  */
164  static const int client_version = 13; // RFC6455
165 
166  /// Default static error logging channels
167  /**
168  * Which error logging channels to enable at compile time. Channels not
169  * enabled here will be unable to be selected by programs using the library.
170  * This option gives an optimizing compiler the ability to remove entirely
171  * code to test whether or not to print out log messages on a certain
172  * channel
173  *
174  * Default is all except for development/debug level errors
175  */
176  static const websocketpp::log::level elog_level =
177  websocketpp::log::elevel::all;
178 
179  /// Default static access logging channels
180  /**
181  * Which access logging channels to enable at compile time. Channels not
182  * enabled here will be unable to be selected by programs using the library.
183  * This option gives an optimizing compiler the ability to remove entirely
184  * code to test whether or not to print out log messages on a certain
185  * channel
186  *
187  * Default is all except for development/debug level access messages
188  */
189  static const websocketpp::log::level alog_level =
190  websocketpp::log::alevel::all;
191 
192  ///
193  static const size_t connection_read_buffer_size = 16384;
194 
195  /// Drop connections immediately on protocol error.
196  /**
197  * Drop connections on protocol error rather than sending a close frame.
198  * Off by default. This may result in legit messages near the error being
199  * dropped as well. It may free up resources otherwise spent dealing with
200  * misbehaving clients.
201  */
202  static const bool drop_on_protocol_error = false;
203 
204  /// Suppresses the return of detailed connection close information
205  /**
206  * Silence close suppresses the return of detailed connection close
207  * information during the closing handshake. This information is useful
208  * for debugging and presenting useful errors to end users but may be
209  * undesirable for security reasons in some production environments.
210  * Close reasons could be used by an attacker to confirm that the endpoint
211  * is out of resources or be used to identify the WebSocket implementation
212  * in use.
213  *
214  * Note: this will suppress *all* close codes, including those explicitly
215  * sent by local applications.
216  */
217  static const bool silent_close = false;
218 
219  /// Default maximum message size
220  /**
221  * Default value for the processor's maximum message size. Maximum message size
222  * determines the point at which the library will fail a connection with the
223  * message_too_big protocol error.
224  *
225  * The default is 32MB
226  *
227  * @since 0.3.0
228  */
229  static const size_t max_message_size = 32000000;
230 
231  /// Default maximum http body size
232  /**
233  * Default value for the http parser's maximum body size. Maximum body size
234  * determines the point at which the library will abort reading an HTTP
235  * connection with the 413/request entity too large error.
236  *
237  * The default is 32MB
238  *
239  * @since 0.5.0
240  */
241  static const size_t max_http_body_size = 32000000;
242 
243  /// Global flag for enabling/disabling extensions
244  static const bool enable_extensions = true;
245 
246  /// Extension specific settings:
247 
248  /// permessage_compress extension
250  typedef type::request_type request_type;
251 
252  /// If the remote endpoint requests that we reset the compression
253  /// context after each message should we honor the request?
254  static const bool allow_disabling_context_takeover = true;
255 
256  /// If the remote endpoint requests that we reduce the size of the
257  /// LZ77 sliding window size this is the lowest value that will be
258  /// allowed. Values range from 8 to 15. A value of 8 means we will
259  /// allow any possible window size. A value of 15 means do not allow
260  /// negotiation of the window size (ie require the default).
262  };
263 
264  typedef websocketpp::extensions::permessage_deflate::disabled
265  <permessage_deflate_config> permessage_deflate_type;
266 
267  /// Autonegotiate permessage-deflate
268  /**
269  * Automatically enables the permessage-deflate extension.
270  *
271  * For clients this results in a permessage-deflate extension request being
272  * sent with every request rather than requiring it to be requested manually
273  *
274  * For servers this results in accepting the first set of extension settings
275  * requested by the client that we understand being used. The alternative is
276  * requiring the extension to be manually negotiated in `validate`. With
277  * auto-negotiate on, you may still override the auto-negotiate manually if
278  * needed.
279  */
280  //static const bool autonegotiate_compression = false;
281 };
282 
283 } // namespace config
284 } // namespace websocketpp
285 
286 #endif // WEBSOCKETPP_CONFIG_CORE_HPP
static const long timeout_dns_resolve
Length of time to wait for dns resolution.
Definition: debug.hpp:131
websocketpp::endpoint_base endpoint_base
User overridable Endpoint base class.
Definition: debug.hpp:145
static const bool drop_on_protocol_error
Drop connections immediately on protocol error.
Definition: debug.hpp:202
static const int client_version
WebSocket Protocol version to use as a client.
Definition: debug.hpp:164
static const long timeout_socket_post_init
Length of time to wait for socket post-initialization.
Definition: debug.hpp:128
static const long timeout_open_handshake
Default timer values (in ms)
Definition: debug.hpp:152
static const long timeout_pong
Length of time to wait for a pong after a ping.
Definition: debug.hpp:156
static const long timeout_socket_shutdown
Length of time to wait for socket shutdown.
Definition: debug.hpp:137
static const bool enable_extensions
Global flag for enabling/disabling extensions.
Definition: debug.hpp:244
static const size_t max_message_size
Default maximum message size.
Definition: debug.hpp:229
websocketpp::connection_base connection_base
User overridable Connection base class.
Definition: debug.hpp:147
static const long timeout_connect
Length of time to wait for TCP connect.
Definition: debug.hpp:134
static const websocketpp::log::level elog_level
Default static error logging channels.
Definition: debug.hpp:176
static const websocketpp::log::level alog_level
Default static access logging channels.
Definition: debug.hpp:189
void handle_accept(connection_ptr con, lib::error_code const &ec)
Handler callback for start_accept.
static const long timeout_socket_pre_init
Default timer values (in ms)
Definition: debug.hpp:118
static const long timeout_proxy
Length of time to wait before a proxy handshake is aborted.
Definition: debug.hpp:121
static bool const enable_multithreading
Definition: debug.hpp:98
static const bool silent_close
Suppresses the return of detailed connection close information.
Definition: debug.hpp:217
static const size_t max_http_body_size
Default maximum http body size.
Definition: debug.hpp:241
static const long timeout_close_handshake
Length of time before a closing handshake is aborted.
Definition: debug.hpp:154