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/asio/ip/network_v4.hpp>
27 #include <boost/asio/ip/network_v6.hpp>
28 #include <boost/beast/core/string.hpp>
29 #include <boost/beast/websocket/option.hpp>
30 #include <cstdint>
31 #include <memory>
32 #include <optional>
33 #include <set>
34 #include <string>
35 #include <variant>
36 
37 namespace boost {
38 namespace asio {
39 namespace ssl {
40 class context;
41 }
42 } // namespace asio
43 } // namespace boost
44 
45 namespace ripple {
46 
48 struct Port
49 {
50  explicit Port() = default;
51 
53  boost::asio::ip::address ip;
68  boost::beast::websocket::permessage_deflate pmd_options;
70 
71  // How many incoming connections are allowed on this
72  // port in the range [0, 65535] where 0 means unlimited.
73  int limit = 0;
74 
75  // Websocket disconnects if send queue exceeds this limit
77 
78  // Returns `true` if any websocket protocols are specified
79  bool
80  websockets() const;
81 
82  // Returns `true` if any secure protocols are specified
83  bool
84  secure() const;
85 
86  // Returns a string containing the list of protocols
88  protocols() const;
89 };
90 
92 operator<<(std::ostream& os, Port const& p);
93 
94 //------------------------------------------------------------------------------
95 
96 struct ParsedPort
97 {
98  explicit ParsedPort() = default;
99 
110  boost::beast::websocket::permessage_deflate pmd_options;
111  int limit = 0;
113 
120 };
121 
122 void
123 parse_Port(ParsedPort& port, Section const& section, std::ostream& log);
124 
125 } // namespace ripple
126 
127 #endif
ripple::Section
Holds a collection of configuration values.
Definition: BasicConfig.h:42
ripple::Port::ws_queue_limit
std::uint16_t ws_queue_limit
Definition: Port.h:76
std::string
STL class.
std::shared_ptr< boost::asio::ssl::context >
ripple::Port::protocols
std::string protocols() const
Definition: Port.cpp:38
ripple::ParsedPort::admin_nets_v6
std::vector< boost::asio::ip::network_v6 > admin_nets_v6
Definition: Port.h:117
ripple::ParsedPort::ssl_ciphers
std::string ssl_ciphers
Definition: Port.h:109
std::vector< boost::asio::ip::network_v4 >
ripple::Port::ssl_key
std::string ssl_key
Definition: Port.h:64
ripple::Port::context
std::shared_ptr< boost::asio::ssl::context > context
Definition: Port.h:69
ripple::Port::secure_gateway_nets_v6
std::vector< boost::asio::ip::network_v6 > secure_gateway_nets_v6
Definition: Port.h:59
ripple::Port::ip
boost::asio::ip::address ip
Definition: Port.h:53
ripple::Port::secure
bool secure() const
Definition: Port.cpp:31
ripple::ParsedPort::limit
int limit
Definition: Port.h:111
boost
Definition: IPAddress.h:103
ripple::Port::admin_user
std::string admin_user
Definition: Port.h:62
ripple::parse_Port
void parse_Port(ParsedPort &port, Section const &section, std::ostream &log)
Definition: Port.cpp:199
ripple::Port::name
std::string name
Definition: Port.h:52
ripple::Port::port
std::uint16_t port
Definition: Port.h:54
ripple::ParsedPort
Definition: Port.h:96
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:55
ripple::Port::user
std::string user
Definition: Port.h:60
ripple::Port::ssl_cert
std::string ssl_cert
Definition: Port.h:65
ripple::ParsedPort::secure_gateway_nets_v6
std::vector< boost::asio::ip::network_v6 > secure_gateway_nets_v6
Definition: Port.h:119
ripple::Port::admin_nets_v6
std::vector< boost::asio::ip::network_v6 > admin_nets_v6
Definition: Port.h:57
ripple::Port::ssl_chain
std::string ssl_chain
Definition: Port.h:66
ripple::ParsedPort::password
std::string password
Definition: Port.h:103
std::ostream
STL class.
ripple::Port::secure_gateway_nets_v4
std::vector< boost::asio::ip::network_v4 > secure_gateway_nets_v4
Definition: Port.h:58
ripple::Port::admin_nets_v4
std::vector< boost::asio::ip::network_v4 > admin_nets_v4
Definition: Port.h:56
ripple::ParsedPort::admin_user
std::string admin_user
Definition: Port.h:104
cstdint
std::uint16_t
ripple::Port::ssl_ciphers
std::string ssl_ciphers
Definition: Port.h:67
ripple::Port
Configuration information for a Server listening port.
Definition: Port.h:48
memory
ripple::Port::pmd_options
boost::beast::websocket::permessage_deflate pmd_options
Definition: Port.h:68
ripple::ParsedPort::ssl_chain
std::string ssl_chain
Definition: Port.h:108
ripple::Port::admin_password
std::string admin_password
Definition: Port.h:63
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::ParsedPort::ip
std::optional< boost::asio::ip::address > ip
Definition: Port.h:114
ripple::ParsedPort::pmd_options
boost::beast::websocket::permessage_deflate pmd_options
Definition: Port.h:110
ripple::ParsedPort::ssl_key
std::string ssl_key
Definition: Port.h:106
ripple::ParsedPort::port
std::optional< std::uint16_t > port
Definition: Port.h:115
ripple::ParsedPort::user
std::string user
Definition: Port.h:102
ripple::ParsedPort::ParsedPort
ParsedPort()=default
ripple::Port::limit
int limit
Definition: Port.h:73
ripple::ParsedPort::ws_queue_limit
std::uint16_t ws_queue_limit
Definition: Port.h:112
ripple::Port::password
std::string password
Definition: Port.h:61
optional
ripple::Port::websockets
bool websockets() const
ripple::Port::Port
Port()=default
ripple::ParsedPort::protocol
std::set< std::string, boost::beast::iless > protocol
Definition: Port.h:101
ripple::ParsedPort::name
std::string name
Definition: Port.h:100
ripple::ParsedPort::admin_password
std::string admin_password
Definition: Port.h:105
ripple::ParsedPort::ssl_cert
std::string ssl_cert
Definition: Port.h:107
set
ripple::ParsedPort::secure_gateway_nets_v4
std::vector< boost::asio::ip::network_v4 > secure_gateway_nets_v4
Definition: Port.h:118
variant
ripple::ParsedPort::admin_nets_v4
std::vector< boost::asio::ip::network_v4 > admin_nets_v4
Definition: Port.h:116
string