20#include <xrpl/basics/BasicConfig.h> 
   21#include <xrpl/basics/contract.h> 
   22#include <xrpl/basics/safe_cast.h> 
   23#include <xrpl/beast/core/LexicalCast.h> 
   24#include <xrpl/beast/net/IPEndpoint.h> 
   25#include <xrpl/beast/rfc2616.h> 
   26#include <xrpl/server/Port.h> 
   28#include <boost/algorithm/string/predicate.hpp> 
   29#include <boost/algorithm/string/trim.hpp> 
   30#include <boost/asio/ip/address.hpp> 
   31#include <boost/asio/ip/impl/network_v4.ipp> 
   32#include <boost/asio/ip/impl/network_v6.ipp> 
   33#include <boost/system/system_error.hpp> 
   57        s += (iter != 
protocol.cbegin() ? 
"," : 
"") + *iter;
 
 
   64    os << 
"'" << p.
name << 
"' (ip=" << p.
ip << 
":" << p.
port << 
", ";
 
   71            os << net.to_string();
 
   76            os << net.to_string();
 
   83        os << 
"secure_gateway nets:";
 
   86            os << net.to_string();
 
   91            os << net.to_string();
 
 
  110    auto const optResult = section.
get(field);
 
  119        boost::algorithm::trim(ip);
 
  121        boost::asio::ip::network_v4 v4Net;
 
  122        boost::asio::ip::network_v6 v6Net;
 
  131                if (is_unspecified(*addr))
 
  134                        boost::asio::ip::make_network_v4(
"0.0.0.0/0"));
 
  135                    nets6.
push_back(boost::asio::ip::make_network_v6(
"::/0"));
 
  148                    addressString += 
"/32";
 
  149                    v4Net = boost::asio::ip::make_network_v4(addressString);
 
  153                    addressString += 
"/128";
 
  154                    v6Net = boost::asio::ip::make_network_v6(addressString);
 
  167                    v4Net = boost::asio::ip::make_network_v4(ip);
 
  170                catch (boost::system::system_error 
const&)
 
  172                    v6Net = boost::asio::ip::make_network_v6(ip);
 
  183                if (v4Net != v4Net.canonical())
 
  185                    log << 
"The configured subnet " << v4Net.to_string()
 
  186                        << 
" is not the same as the network address, which is " 
  187                        << v4Net.canonical().to_string();
 
  188                    Throw<std::exception>();
 
  194                if (v6Net != v6Net.canonical())
 
  196                    log << 
"The configured subnet " << v6Net.to_string()
 
  197                        << 
" is not the same as the network address, which is " 
  198                        << v6Net.canonical().to_string();
 
  199                    Throw<std::exception>();
 
  204        catch (boost::system::system_error 
const& e)
 
  206            log << 
"Invalid value '" << ip << 
"' for key '" << field << 
"' in [" 
  207                << section.
name() << 
"]: " << e.what();
 
  208            Throw<std::exception>();
 
 
  218        auto const optResult = section.
get(
"ip");
 
  223                port.
ip = boost::asio::ip::make_address(*optResult);
 
  227                log << 
"Invalid value '" << *optResult << 
"' for key 'ip' in [" 
  228                    << section.
name() << 
"]";
 
  235        auto const optResult = section.
get(
"port");
 
  240                port.
port = beast::lexicalCastThrow<std::uint16_t>(*optResult);
 
  243                if ((*port.
port == 0) && (port.
name == 
"server"))
 
  244                    Throw<std::exception>();
 
  248                log << 
"Invalid value '" << *optResult << 
"' for key " 
  249                    << 
"'port' in [" << section.
name() << 
"]";
 
  256        auto const optResult = section.
get(
"protocol");
 
  260                     optResult->begin(), optResult->end()))
 
  266        auto const lim = 
get(section, 
"limit", 
"unlimited");
 
  268        if (!boost::iequals(lim, 
"unlimited"))
 
  273                    safe_cast<int>(beast::lexicalCastThrow<std::uint16_t>(lim));
 
  277                log << 
"Invalid value '" << lim << 
"' for key " 
  278                    << 
"'limit' in [" << section.
name() << 
"]";
 
  285        auto const optResult = section.
get(
"send_queue_limit");
 
  291                    beast::lexicalCastThrow<std::uint16_t>(*optResult);
 
  295                    Throw<std::exception>();
 
  299                log << 
"Invalid value '" << *optResult << 
"' for key " 
  300                    << 
"'send_queue_limit' in [" << section.
name() << 
"]";
 
  319    set(port.
user, 
"user", section);
 
  329        section.
value_or(
"permessage_deflate", 
true);
 
  331        section.
value_or(
"client_max_window_bits", 15);
 
  333        section.
value_or(
"server_max_window_bits", 15);
 
  335        section.
value_or(
"client_no_context_takeover", 
false);
 
  337        section.
value_or(
"server_no_context_takeover", 
false);
 
 
static std::optional< Endpoint > from_string_checked(std::string const &s)
Create an Endpoint from a string.
 
Holds a collection of configuration values.
 
std::string const & name() const
Returns the name of this section.
 
T value_or(std::string const &name, T const &other) const
Returns a value if present, else another value.
 
std::optional< T > get(std::string const &name) const
 
Result split_commas(FwdIt first, FwdIt last)
 
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
 
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)
 
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,...
 
void parse_Port(ParsedPort &port, Section const §ion, std::ostream &log)
 
std::ostream & operator<<(std::ostream &out, base_uint< Bits, Tag > const &u)
 
T get(Section const §ion, std::string const &name, T const &defaultValue=T{})
Retrieve a key/value pair from a section.
 
void Rethrow()
Rethrow the exception currently being handled.
 
boost::beast::websocket::permessage_deflate pmd_options
 
std::optional< std::uint16_t > port
 
std::vector< boost::asio::ip::network_v4 > admin_nets_v4
 
std::uint16_t ws_queue_limit
 
std::vector< boost::asio::ip::network_v6 > secure_gateway_nets_v6
 
std::set< std::string, boost::beast::iless > protocol
 
std::string admin_password
 
std::vector< boost::asio::ip::network_v6 > admin_nets_v6
 
std::optional< boost::asio::ip::address > ip
 
std::vector< boost::asio::ip::network_v4 > secure_gateway_nets_v4
 
Configuration information for a Server listening port.
 
std::vector< boost::asio::ip::network_v6 > admin_nets_v6
 
std::string protocols() const
 
std::vector< boost::asio::ip::network_v6 > secure_gateway_nets_v6
 
std::vector< boost::asio::ip::network_v4 > secure_gateway_nets_v4
 
boost::asio::ip::address ip
 
std::vector< boost::asio::ip::network_v4 > admin_nets_v4