You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

280 lines
11 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. #ifndef WEBSOCKETPP_CONFIG_DEBUG_HPP
  28. #define WEBSOCKETPP_CONFIG_DEBUG_HPP
  29. // Non-Policy common stuff
  30. #include <websocketpp/common/cpp11.hpp>
  31. #include <websocketpp/common/stdint.hpp>
  32. // Concurrency
  33. #include <websocketpp/concurrency/basic.hpp>
  34. // Transport
  35. #include <websocketpp/transport/iostream/endpoint.hpp>
  36. // HTTP
  37. #include <websocketpp/http/request.hpp>
  38. #include <websocketpp/http/response.hpp>
  39. // Messages
  40. #include <websocketpp/message_buffer/alloc.hpp>
  41. #include <websocketpp/message_buffer/message.hpp>
  42. // Loggers
  43. #include <websocketpp/logger/basic.hpp>
  44. // RNG
  45. #include <websocketpp/random/none.hpp>
  46. // User stub base classes
  47. #include <websocketpp/connection_base.hpp>
  48. #include <websocketpp/endpoint_base.hpp>
  49. // Extensions
  50. #include <websocketpp/extensions/permessage_deflate/disabled.hpp>
  51. namespace websocketpp
  52. {
  53. namespace config
  54. {
  55. /// Client/Server debug config with iostream transport
  56. struct debug_core
  57. {
  58. typedef debug_core type;
  59. // Concurrency policy
  60. typedef websocketpp::concurrency::basic concurrency_type;
  61. // HTTP Parser Policies
  62. typedef http::parser::request request_type;
  63. typedef http::parser::response response_type;
  64. // Message Policies
  65. typedef message_buffer::message<message_buffer::alloc::con_msg_manager> message_type;
  66. typedef message_buffer::alloc::con_msg_manager<message_type> con_msg_manager_type;
  67. typedef message_buffer::alloc::endpoint_msg_manager<con_msg_manager_type> endpoint_msg_manager_type;
  68. /// Logging policies
  69. typedef websocketpp::log::basic<concurrency_type, websocketpp::log::elevel> elog_type;
  70. typedef websocketpp::log::basic<concurrency_type, websocketpp::log::alevel> alog_type;
  71. /// RNG policies
  72. typedef websocketpp::random::none::int_generator<uint32_t> rng_type;
  73. /// Controls compile time enabling/disabling of thread syncronization
  74. /// code Disabling can provide a minor performance improvement to single
  75. /// threaded applications
  76. static const bool enable_multithreading = true;
  77. struct transport_config
  78. {
  79. typedef type::concurrency_type concurrency_type;
  80. typedef type::elog_type elog_type;
  81. typedef type::alog_type alog_type;
  82. typedef type::request_type request_type;
  83. typedef type::response_type response_type;
  84. /// Controls compile time enabling/disabling of thread syncronization
  85. /// code Disabling can provide a minor performance improvement to single
  86. /// threaded applications
  87. static const bool enable_multithreading = true;
  88. /// Default timer values (in ms)
  89. /// Length of time to wait for socket pre-initialization
  90. /**
  91. * Exactly what this includes depends on the socket policy in use
  92. */
  93. static const long timeout_socket_pre_init = 5000;
  94. /// Length of time to wait before a proxy handshake is aborted
  95. static const long timeout_proxy = 5000;
  96. /// Length of time to wait for socket post-initialization
  97. /**
  98. * Exactly what this includes depends on the socket policy in use.
  99. * Often this means the TLS handshake
  100. */
  101. static const long timeout_socket_post_init = 5000;
  102. /// Length of time to wait for dns resolution
  103. static const long timeout_dns_resolve = 5000;
  104. /// Length of time to wait for TCP connect
  105. static const long timeout_connect = 5000;
  106. /// Length of time to wait for socket shutdown
  107. static const long timeout_socket_shutdown = 5000;
  108. };
  109. /// Transport Endpoint Component
  110. typedef websocketpp::transport::iostream::endpoint<transport_config> transport_type;
  111. /// User overridable Endpoint base class
  112. typedef websocketpp::endpoint_base endpoint_base;
  113. /// User overridable Connection base class
  114. typedef websocketpp::connection_base connection_base;
  115. /// Default timer values (in ms)
  116. /// Length of time before an opening handshake is aborted
  117. static const long timeout_open_handshake = 5000;
  118. /// Length of time before a closing handshake is aborted
  119. static const long timeout_close_handshake = 5000;
  120. /// Length of time to wait for a pong after a ping
  121. static const long timeout_pong = 5000;
  122. /// WebSocket Protocol version to use as a client
  123. /**
  124. * What version of the WebSocket Protocol to use for outgoing client
  125. * connections. Setting this to a value other than 13 (RFC6455) is not
  126. * recommended.
  127. */
  128. static const int client_version = 13; // RFC6455
  129. /// Default static error logging channels
  130. /**
  131. * Which error logging channels to enable at compile time. Channels not
  132. * enabled here will be unable to be selected by programs using the library.
  133. * This option gives an optimizing compiler the ability to remove entirely
  134. * code to test whether or not to print out log messages on a certain
  135. * channel
  136. *
  137. * Default is all except for development/debug level errors
  138. */
  139. static const websocketpp::log::level elog_level = websocketpp::log::elevel::all;
  140. /// Default static access logging channels
  141. /**
  142. * Which access logging channels to enable at compile time. Channels not
  143. * enabled here will be unable to be selected by programs using the library.
  144. * This option gives an optimizing compiler the ability to remove entirely
  145. * code to test whether or not to print out log messages on a certain
  146. * channel
  147. *
  148. * Default is all except for development/debug level access messages
  149. */
  150. static const websocketpp::log::level alog_level = websocketpp::log::alevel::all;
  151. ///
  152. static const size_t connection_read_buffer_size = 16384;
  153. /// Drop connections immediately on protocol error.
  154. /**
  155. * Drop connections on protocol error rather than sending a close frame.
  156. * Off by default. This may result in legit messages near the error being
  157. * dropped as well. It may free up resources otherwise spent dealing with
  158. * misbehaving clients.
  159. */
  160. static const bool drop_on_protocol_error = false;
  161. /// Suppresses the return of detailed connection close information
  162. /**
  163. * Silence close suppresses the return of detailed connection close
  164. * information during the closing handshake. This information is useful
  165. * for debugging and presenting useful errors to end users but may be
  166. * undesirable for security reasons in some production environments.
  167. * Close reasons could be used by an attacker to confirm that the endpoint
  168. * is out of resources or be used to identify the WebSocket implementation
  169. * in use.
  170. *
  171. * Note: this will suppress *all* close codes, including those explicitly
  172. * sent by local applications.
  173. */
  174. static const bool silent_close = false;
  175. /// Default maximum message size
  176. /**
  177. * Default value for the processor's maximum message size. Maximum message size
  178. * determines the point at which the library will fail a connection with the
  179. * message_too_big protocol error.
  180. *
  181. * The default is 32MB
  182. *
  183. * @since 0.3.0
  184. */
  185. static const size_t max_message_size = 32000000;
  186. /// Default maximum http body size
  187. /**
  188. * Default value for the http parser's maximum body size. Maximum body size
  189. * determines the point at which the library will abort reading an HTTP
  190. * connection with the 413/request entity too large error.
  191. *
  192. * The default is 32MB
  193. *
  194. * @since 0.5.0
  195. */
  196. static const size_t max_http_body_size = 32000000;
  197. /// Global flag for enabling/disabling extensions
  198. static const bool enable_extensions = true;
  199. /// Extension specific settings:
  200. /// permessage_compress extension
  201. struct permessage_deflate_config
  202. {
  203. typedef type::request_type request_type;
  204. /// If the remote endpoint requests that we reset the compression
  205. /// context after each message should we honor the request?
  206. static const bool allow_disabling_context_takeover = true;
  207. /// If the remote endpoint requests that we reduce the size of the
  208. /// LZ77 sliding window size this is the lowest value that will be
  209. /// allowed. Values range from 8 to 15. A value of 8 means we will
  210. /// allow any possible window size. A value of 15 means do not allow
  211. /// negotiation of the window size (ie require the default).
  212. static const uint8_t minimum_outgoing_window_bits = 8;
  213. };
  214. typedef websocketpp::extensions::permessage_deflate::disabled<permessage_deflate_config> permessage_deflate_type;
  215. /// Autonegotiate permessage-deflate
  216. /**
  217. * Automatically enables the permessage-deflate extension.
  218. *
  219. * For clients this results in a permessage-deflate extension request being
  220. * sent with every request rather than requiring it to be requested manually
  221. *
  222. * For servers this results in accepting the first set of extension settings
  223. * requested by the client that we understand being used. The alternative is
  224. * requiring the extension to be manually negotiated in `validate`. With
  225. * auto-negotiate on, you may still override the auto-negotiate manually if
  226. * needed.
  227. */
  228. // static const bool autonegotiate_compression = false;
  229. };
  230. } // namespace config
  231. } // namespace websocketpp
  232. #endif // WEBSOCKETPP_CONFIG_CORE_HPP