20#include <xrpld/rpc/Role.h> 
   22#include <boost/beast/http/field.hpp> 
   23#include <boost/utility/string_view.hpp> 
   34        "ripple::passwordUnrequiredOrSentCorrect : non-empty admin nets");
 
   35    bool const passwordRequired =
 
   38    return !passwordRequired ||
 
   39        ((params[
"admin_password"].
isString() &&
 
   41         (params[
"admin_user"].isString() &&
 
 
   63        auto ipNet = boost::asio::ip::make_network_v4(addrString);
 
   64        for (
auto const& net : nets4)
 
   66            if (ipNet.is_subnet_of(net) || ipNet == net)
 
   73        auto ipNet = boost::asio::ip::make_network_v6(addrString);
 
   74        for (
auto const& net : nets6)
 
   76            if (ipNet.is_subnet_of(net) || ipNet == net)
 
 
  132    Role const& required,
 
 
  167            if (firstNonSpace == std::string_view::npos)
 
  172            ret = ret.
substr(firstNonSpace);
 
  178            if (
unsigned char const c = ret.
back();
 
  179                c == 
' ' || c == 
'\r' || c == 
'\n')
 
  182                if (lastNonSpace == std::string_view::npos)
 
  187                ret = ret.
substr(0, lastNonSpace + 1);
 
  198    if (ret.
front() == 
'"')
 
  214    if (ret.
front() == 
'[')
 
  221        auto const closeBracket =
 
  223                return std::isxdigit(c) || c == 
':' || c == 
'.' || c == 
' ';
 
  228        if (closeBracket == ret.
end() || (*closeBracket) != 
']')
 
  244                return std::isxdigit(c) || c == 
' ';
 
  249        if (colon == ret.
end() || (*colon) == 
':')
 
  255    if (
std::size_t colon = ret.
find(
':'); colon != std::string_view::npos)
 
  256        ret = ret.
substr(0, colon);
 
 
  265    if (
auto it = request.find(boost::beast::http::field::forwarded);
 
  268        auto ascii_tolower = [](
char c) -> 
char {
 
  269            return ((
static_cast<unsigned>(c) - 65U) < 26) ? c + 
'a' - 
'A' : c;
 
  279            [&ascii_tolower](
char c1, 
char c2) {
 
  280                return ascii_tolower(c1) == ascii_tolower(c2);
 
  283        if (found == it->value().end())
 
  286        found += forStr.size();
 
  292            if (pos != std::string_view::npos)
 
  295            return it->value().size() - forStr.size();
 
  302    if (
auto it = request.find(
"X-Forwarded-For"); it != request.end())
 
  306        if (found == boost::string_view::npos)
 
  307            found = it->value().length();
 
 
std::string asString() const
Returns the unquoted string value.
 
A version-independent IP address and port combination.
 
Address const & address() const
Returns the address portion of this endpoint.
 
Tracks load and resource consumption.
 
virtual Consumer newInboundEndpoint(beast::IP::Endpoint const &address)=0
Create a new endpoint keyed by inbound IP address or the forwarded IP if proxied.
 
virtual Consumer newUnlimitedEndpoint(beast::IP::Endpoint const &address)=0
Create a new unlimited endpoint keyed by forwarded IP.
 
T find_first_not_of(T... args)
 
T find_first_of(T... args)
 
T find_last_not_of(T... args)
 
boost::asio::ip::address Address
 
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
 
Resource::Consumer requestInboundEndpoint(Resource::Manager &manager, beast::IP::Endpoint const &remoteAddress, Role const &role, std::string_view user, std::string_view forwardedFor)
 
static std::string_view extractIpAddrFromField(std::string_view field)
 
bool isAdmin(Port const &port, Json::Value const ¶ms, beast::IP::Address const &remoteIp)
 
bool isUnlimited(Role const &role)
ADMIN and IDENTIFIED roles shall have unlimited resources.
 
std::string_view forwardedFor(http_request_type const &request)
 
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
 
bool passwordUnrequiredOrSentCorrect(Port const &port, Json::Value const ¶ms)
 
Role
Indicates the level of administrative permission to grant.
 
Role requestRole(Role const &required, Port const &port, Json::Value const ¶ms, beast::IP::Endpoint const &remoteIp, std::string_view user)
Return the allowed privilege role.
 
bool ipAllowed(beast::IP::Address const &remoteIp, std::vector< boost::asio::ip::network_v4 > const &nets4, std::vector< boost::asio::ip::network_v6 > const &nets6)
True if remoteIp is in any of adminIp.
 
T remove_prefix(T... args)
 
T remove_suffix(T... args)
 
Configuration information for a Server listening port.
 
std::vector< boost::asio::ip::network_v6 > admin_nets_v6
 
std::vector< boost::asio::ip::network_v6 > secure_gateway_nets_v6
 
std::vector< boost::asio::ip::network_v4 > secure_gateway_nets_v4
 
std::string admin_password
 
std::vector< boost::asio::ip::network_v4 > admin_nets_v4