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>
25 #include <boost/algorithm/string/predicate.hpp>
48 os <<
"'" << p.
name <<
"' (ip=" << p.
ip <<
":" << p.
port <<
", ";
54 os << ip.to_string() <<
", ";
59 os <<
"secure_gateway IPs:";
61 os << ip.to_string() <<
", ";
79 auto const result = section.
find(field);
92 log <<
"Invalid value '" << ip <<
"' for key '" << field
93 <<
"' in [" << section.
name() <<
"]";
94 Throw<std::exception>();
97 if (is_unspecified(*addr))
101 log << addr->address() <<
" not allowed'"
102 <<
"' for key '" << field <<
"' in [" << section.
name()
104 Throw<std::exception>();
112 if (has_any && !ips->empty())
114 log <<
"IP specified along with " << addr->address() <<
" '"
115 << ip <<
"' for key '" << field <<
"' in ["
116 << section.
name() <<
"]";
117 Throw<std::exception>();
120 auto const& address = addr->address();
126 }) != admin_ip.
end())
128 log <<
"IP specified for " << field <<
" is also for "
129 <<
"admin: " << ip <<
" in [" << section.
name() <<
"]";
130 Throw<std::exception>();
133 ips->emplace_back(addr->address());
142 auto result = section.
find(
"ip");
147 port.
ip = boost::asio::ip::address::from_string(result.first);
151 log <<
"Invalid value '" << result.first
152 <<
"' for key 'ip' in [" << section.
name() <<
"]";
159 auto const result = section.
find(
"port");
165 beast::lexicalCastThrow<std::uint16_t>(result.first);
169 Throw<std::exception>();
173 log <<
"Invalid value '" << result.first <<
"' for key "
174 <<
"'port' in [" << section.
name() <<
"]";
181 auto const result = section.
find(
"protocol");
185 result.first.begin(), result.first.end()))
191 auto const lim =
get(section,
"limit",
"unlimited");
193 if (!boost::iequals(lim,
"unlimited"))
198 safe_cast<int>(beast::lexicalCastThrow<std::uint16_t>(lim));
202 log <<
"Invalid value '" << lim <<
"' for key "
203 <<
"'limit' in [" << section.
name() <<
"]";
210 auto const result = section.
find(
"send_queue_limit");
216 beast::lexicalCastThrow<std::uint16_t>(result.first);
220 Throw<std::exception>();
224 log <<
"Invalid value '" << result.first <<
"' for key "
225 <<
"'send_queue_limit' in [" << section.
name() <<
"]";
245 set(port.
user,
"user", section);
255 section.
value_or(
"permessage_deflate",
true);
257 section.
value_or(
"client_max_window_bits", 15);
259 section.
value_or(
"server_max_window_bits", 15);
261 section.
value_or(
"client_no_context_takeover",
false);
263 section.
value_or(
"server_no_context_takeover",
false);
Holds a collection of configuration values.
std::vector< beast::IP::Address > admin_ip
std::string protocols() const
boost::asio::ip::address ip
boost::optional< 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::set< std::string, boost::beast::iless > protocol
std::string const & name() const
Returns the name of this section.
boost::asio::ip::address Address
void Rethrow()
Rethrow the exception currently being handled.
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< beast::IP::Address > secure_gateway_ip
boost::optional< std::vector< beast::IP::Address > > secure_gateway_ip
static void populate(Section const §ion, std::string const &field, std::ostream &log, boost::optional< std::vector< beast::IP::Address >> &ips, bool allowAllIps, std::vector< beast::IP::Address > const &admin_ip)
Configuration information for a Server listening port.
Result split_commas(FwdIt first, FwdIt last)
std::pair< std::string, bool > find(std::string const &name) const
Retrieve a key/value pair.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
boost::optional< std::uint16_t > port
boost::beast::websocket::permessage_deflate pmd_options
std::uint16_t ws_queue_limit
boost::optional< std::vector< beast::IP::Address > > admin_ip
static boost::optional< Endpoint > from_string_checked(std::string const &s)
Create an Endpoint from a string.
std::set< std::string, boost::beast::iless > protocol
std::string admin_password
T & get(EitherAmount &amt)