rippled
Port.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #ifndef RIPPLE_SERVER_PORT_H_INCLUDED
21 #define RIPPLE_SERVER_PORT_H_INCLUDED
22 
23 #include <ripple/basics/BasicConfig.h>
24 #include <ripple/beast/net/IPEndpoint.h>
25 #include <boost/asio/ip/address.hpp>
26 #include <boost/beast/core/string.hpp>
27 #include <boost/beast/websocket/option.hpp>
28 #include <cstdint>
29 #include <memory>
30 #include <set>
31 #include <string>
32 
33 namespace boost {
34 namespace asio {
35 namespace ssl {
36 class context;
37 }
38 } // namespace asio
39 } // namespace boost
40 
41 namespace ripple {
42 
44 struct Port
45 {
46  explicit Port() = default;
47 
49  boost::asio::ip::address ip;
62  boost::beast::websocket::permessage_deflate pmd_options;
64 
65  // How many incoming connections are allowed on this
66  // port in the range [0, 65535] where 0 means unlimited.
67  int limit = 0;
68 
69  // Websocket disconnects if send queue exceeds this limit
71 
72  // Returns `true` if any websocket protocols are specified
73  bool
74  websockets() const;
75 
76  // Returns `true` if any secure protocols are specified
77  bool
78  secure() const;
79 
80  // Returns a string containing the list of protocols
82  protocols() const;
83 };
84 
86 operator<<(std::ostream& os, Port const& p);
87 
88 //------------------------------------------------------------------------------
89 
90 struct ParsedPort
91 {
92  explicit ParsedPort() = default;
93 
104  boost::beast::websocket::permessage_deflate pmd_options;
105  int limit = 0;
107 
108  boost::optional<boost::asio::ip::address> ip;
109  boost::optional<std::uint16_t> port;
110  boost::optional<std::vector<beast::IP::Address>> admin_ip;
111  boost::optional<std::vector<beast::IP::Address>> secure_gateway_ip;
112 };
113 
114 void
115 parse_Port(ParsedPort& port, Section const& section, std::ostream& log);
116 
117 } // namespace ripple
118 
119 #endif
ripple::Section
Holds a collection of configuration values.
Definition: BasicConfig.h:43
ripple::Port::ws_queue_limit
std::uint16_t ws_queue_limit
Definition: Port.h:70
ripple::Port::admin_ip
std::vector< beast::IP::Address > admin_ip
Definition: Port.h:52
std::string
STL class.
std::shared_ptr< boost::asio::ssl::context >
ripple::Port::protocols
std::string protocols() const
Definition: Port.cpp:37
ripple::ParsedPort::ssl_ciphers
std::string ssl_ciphers
Definition: Port.h:103
std::vector< beast::IP::Address >
ripple::Port::ssl_key
std::string ssl_key
Definition: Port.h:58
ripple::Port::context
std::shared_ptr< boost::asio::ssl::context > context
Definition: Port.h:63
ripple::Port::ip
boost::asio::ip::address ip
Definition: Port.h:49
ripple::Port::secure
bool secure() const
Definition: Port.cpp:30
ripple::ParsedPort::ip
boost::optional< boost::asio::ip::address > ip
Definition: Port.h:108
ripple::ParsedPort::limit
int limit
Definition: Port.h:105
boost
Definition: IPAddress.h:117
ripple::Port::admin_user
std::string admin_user
Definition: Port.h:56
ripple::parse_Port
void parse_Port(ParsedPort &port, Section const &section, std::ostream &log)
Definition: Port.cpp:139
ripple::Port::name
std::string name
Definition: Port.h:48
ripple::Port::port
std::uint16_t port
Definition: Port.h:50
ripple::ParsedPort
Definition: Port.h:90
ripple::operator<<
std::ostream & operator<<(std::ostream &os, TOffer< TIn, TOut > const &offer)
Definition: Offer.h:242
ripple::Port::protocol
std::set< std::string, boost::beast::iless > protocol
Definition: Port.h:51
ripple::Port::user
std::string user
Definition: Port.h:54
ripple::Port::ssl_cert
std::string ssl_cert
Definition: Port.h:59
ripple::Port::ssl_chain
std::string ssl_chain
Definition: Port.h:60
ripple::ParsedPort::password
std::string password
Definition: Port.h:97
std::ostream
STL class.
ripple::ParsedPort::admin_user
std::string admin_user
Definition: Port.h:98
ripple::Port::secure_gateway_ip
std::vector< beast::IP::Address > secure_gateway_ip
Definition: Port.h:53
cstdint
ripple::ParsedPort::secure_gateway_ip
boost::optional< std::vector< beast::IP::Address > > secure_gateway_ip
Definition: Port.h:111
std::uint16_t
ripple::Port::ssl_ciphers
std::string ssl_ciphers
Definition: Port.h:61
ripple::Port
Configuration information for a Server listening port.
Definition: Port.h:44
memory
ripple::Port::pmd_options
boost::beast::websocket::permessage_deflate pmd_options
Definition: Port.h:62
ripple::ParsedPort::ssl_chain
std::string ssl_chain
Definition: Port.h:102
ripple::Port::admin_password
std::string admin_password
Definition: Port.h:57
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::ParsedPort::port
boost::optional< std::uint16_t > port
Definition: Port.h:109
ripple::ParsedPort::pmd_options
boost::beast::websocket::permessage_deflate pmd_options
Definition: Port.h:104
ripple::ParsedPort::ssl_key
std::string ssl_key
Definition: Port.h:100
ripple::ParsedPort::user
std::string user
Definition: Port.h:96
ripple::ParsedPort::ParsedPort
ParsedPort()=default
ripple::Port::limit
int limit
Definition: Port.h:67
ripple::ParsedPort::ws_queue_limit
std::uint16_t ws_queue_limit
Definition: Port.h:106
ripple::Port::password
std::string password
Definition: Port.h:55
ripple::Port::websockets
bool websockets() const
ripple::ParsedPort::admin_ip
boost::optional< std::vector< beast::IP::Address > > admin_ip
Definition: Port.h:110
ripple::Port::Port
Port()=default
ripple::ParsedPort::protocol
std::set< std::string, boost::beast::iless > protocol
Definition: Port.h:95
ripple::ParsedPort::name
std::string name
Definition: Port.h:94
ripple::ParsedPort::admin_password
std::string admin_password
Definition: Port.h:99
ripple::ParsedPort::ssl_cert
std::string ssl_cert
Definition: Port.h:101
set
string