20 #include <ripple/basics/safe_cast.h>
21 #include <ripple/beast/core/LexicalCast.h>
22 #include <ripple/beast/rfc2616.h>
23 #include <ripple/server/Port.h>
24 #include <boost/algorithm/string/predicate.hpp>
25 #include <boost/algorithm/string/trim.hpp>
42 s += (iter !=
protocol.cbegin() ?
"," :
"") + *iter;
49 os <<
"'" << p.
name <<
"' (ip=" << p.
ip <<
":" << p.
port <<
", ";
56 os << net.to_string();
61 os << net.to_string();
68 os <<
"secure_gateway nets:";
71 os << net.to_string();
76 os << net.to_string();
95 auto const optResult = section.
get(field);
104 boost::algorithm::trim(ip);
106 boost::asio::ip::network_v4 v4Net;
107 boost::asio::ip::network_v6 v6Net;
116 if (is_unspecified(*addr))
119 boost::asio::ip::make_network_v4(
"0.0.0.0/0"));
120 nets6.
push_back(boost::asio::ip::make_network_v6(
"::/0"));
133 addressString +=
"/32";
134 v4Net = boost::asio::ip::make_network_v4(addressString);
138 addressString +=
"/128";
139 v6Net = boost::asio::ip::make_network_v6(addressString);
152 v4Net = boost::asio::ip::make_network_v4(ip);
155 catch (boost::system::system_error
const&)
157 v6Net = boost::asio::ip::make_network_v6(ip);
168 if (v4Net != v4Net.canonical())
170 log <<
"The configured subnet " << v4Net.to_string()
171 <<
" is not the same as the network address, which is "
172 << v4Net.canonical().to_string();
173 Throw<std::exception>();
179 if (v6Net != v6Net.canonical())
181 log <<
"The configured subnet " << v6Net.to_string()
182 <<
" is not the same as the network address, which is "
183 << v6Net.canonical().to_string();
184 Throw<std::exception>();
189 catch (boost::system::system_error
const& e)
191 log <<
"Invalid value '" << ip <<
"' for key '" << field <<
"' in ["
192 << section.
name() <<
"]: " << e.what();
193 Throw<std::exception>();
202 auto const optResult = section.
get(
"ip");
207 port.
ip = boost::asio::ip::address::from_string(*optResult);
211 log <<
"Invalid value '" << *optResult <<
"' for key 'ip' in ["
212 << section.
name() <<
"]";
219 auto const optResult = section.
get(
"port");
224 port.
port = beast::lexicalCastThrow<std::uint16_t>(*optResult);
228 Throw<std::exception>();
232 log <<
"Invalid value '" << *optResult <<
"' for key "
233 <<
"'port' in [" << section.
name() <<
"]";
240 auto const optResult = section.
get(
"protocol");
244 optResult->begin(), optResult->end()))
250 auto const lim =
get(section,
"limit",
"unlimited");
252 if (!boost::iequals(lim,
"unlimited"))
257 safe_cast<int>(beast::lexicalCastThrow<std::uint16_t>(lim));
261 log <<
"Invalid value '" << lim <<
"' for key "
262 <<
"'limit' in [" << section.
name() <<
"]";
269 auto const optResult = section.
get(
"send_queue_limit");
275 beast::lexicalCastThrow<std::uint16_t>(*optResult);
279 Throw<std::exception>();
283 log <<
"Invalid value '" << *optResult <<
"' for key "
284 <<
"'send_queue_limit' in [" << section.
name() <<
"]";
303 set(port.
user,
"user", section);
313 section.
value_or(
"permessage_deflate",
true);
315 section.
value_or(
"client_max_window_bits", 15);
317 section.
value_or(
"server_max_window_bits", 15);
319 section.
value_or(
"client_no_context_takeover",
false);
321 section.
value_or(
"server_no_context_takeover",
false);
Holds a collection of configuration values.
std::string protocols() const
static void populate(Section const §ion, std::string const &field, std::ostream &log, std::vector< boost::asio::ip::network_v4 > &nets4, std::vector< boost::asio::ip::network_v6 > &nets6)
std::vector< boost::asio::ip::network_v6 > admin_nets_v6
std::vector< boost::asio::ip::network_v6 > secure_gateway_nets_v6
boost::asio::ip::address ip
T value_or(std::string const &name, T const &other) const
Returns a value if present, else another value.
void parse_Port(ParsedPort &port, Section const §ion, std::ostream &log)
std::ostream & operator<<(std::ostream &os, TOffer< TIn, TOut > const &offer)
std::string const & name() const
Returns the name of this section.
std::vector< boost::asio::ip::network_v6 > secure_gateway_nets_v6
std::vector< boost::asio::ip::network_v6 > admin_nets_v6
void Rethrow()
Rethrow the exception currently being handled.
std::vector< boost::asio::ip::network_v4 > secure_gateway_nets_v4
bool set(T &target, std::string const &name, Section const §ion)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
std::vector< boost::asio::ip::network_v4 > admin_nets_v4
Configuration information for a Server listening port.
Result split_commas(FwdIt first, FwdIt last)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::optional< boost::asio::ip::address > ip
boost::beast::websocket::permessage_deflate pmd_options
std::optional< std::uint16_t > port
std::uint16_t ws_queue_limit
std::optional< T > get(std::string const &name) const
std::set< std::string, boost::beast::iless > protocol
std::string admin_password
static std::optional< Endpoint > from_string_checked(std::string const &s)
Create an Endpoint from a string.
std::vector< boost::asio::ip::network_v4 > secure_gateway_nets_v4
T & get(EitherAmount &amt)
std::vector< boost::asio::ip::network_v4 > admin_nets_v4