xrpld
Loading...
Searching...
No Matches
ServerHandler.cpp
1#include <xrpld/rpc/ServerHandler.h>
2
3#include <xrpld/app/main/Application.h>
4#include <xrpld/overlay/Overlay.h>
5#include <xrpld/rpc/RPCHandler.h>
6#include <xrpld/rpc/Role.h>
7#include <xrpld/rpc/detail/Tuning.h>
8#include <xrpld/rpc/detail/WSInfoSub.h>
9
10#include <xrpl/basics/Log.h>
11#include <xrpl/basics/StringUtilities.h>
12#include <xrpl/basics/base64.h>
13#include <xrpl/basics/contract.h>
14#include <xrpl/basics/make_SSLContext.h>
15#include <xrpl/beast/net/IPAddress.h>
16#include <xrpl/beast/net/IPAddressConversion.h>
17#include <xrpl/beast/rfc2616.h>
18#include <xrpl/beast/utility/Journal.h>
19#include <xrpl/config/Constants.h>
20#include <xrpl/core/Job.h>
21#include <xrpl/core/JobQueue.h>
22#include <xrpl/json/Output.h>
23#include <xrpl/json/json_forwards.h>
24#include <xrpl/json/json_reader.h>
25#include <xrpl/json/json_value.h>
26#include <xrpl/json/json_writer.h>
27#include <xrpl/json/to_string.h>
28#include <xrpl/protocol/ApiVersion.h>
29#include <xrpl/protocol/BuildInfo.h>
30#include <xrpl/protocol/ErrorCodes.h>
31#include <xrpl/protocol/RPCErr.h>
32#include <xrpl/protocol/SystemParameters.h>
33#include <xrpl/protocol/jss.h>
34#include <xrpl/resource/Charge.h>
35#include <xrpl/resource/Consumer.h>
36#include <xrpl/resource/Fees.h>
37#include <xrpl/resource/ResourceManager.h>
38#include <xrpl/server/Handoff.h>
39#include <xrpl/server/InfoSub.h>
40#include <xrpl/server/NetworkOPs.h>
41#include <xrpl/server/Port.h>
42#include <xrpl/server/Server.h>
43#include <xrpl/server/Session.h>
44#include <xrpl/server/SimpleWriter.h>
45#include <xrpl/server/WSSession.h>
46#include <xrpl/server/detail/JSONRPCUtil.h>
47
48#include <boost/asio/buffer.hpp>
49#include <boost/asio/io_context.hpp>
50#include <boost/asio/ip/tcp.hpp>
51#include <boost/beast/core/multi_buffer.hpp>
52#include <boost/beast/http/fields.hpp>
53#include <boost/beast/http/status.hpp>
54#include <boost/beast/http/string_body.hpp>
55#include <boost/beast/http/verb.hpp>
56#include <boost/beast/websocket/impl/rfc6455.hpp>
57#include <boost/beast/websocket/rfc6455.hpp>
58#include <boost/system/detail/error_code.hpp>
59
60#include <algorithm>
61#include <cctype>
62#include <chrono>
63#include <exception>
64#include <map>
65#include <memory>
66#include <mutex>
67#include <ostream>
68#include <string>
69#include <string_view>
70#include <utility>
71#include <vector>
72
73namespace xrpl {
74
75class Peer;
76class LedgerMaster;
77class Transaction;
78class ValidatorKeys;
79class CanonicalTXSet;
80
81static bool
83{
84 return request.version() >= 11 && request.target() == "/" && request.body().size() == 0 &&
85 request.method() == boost::beast::http::verb::get;
86}
87
88static Handoff
89statusRequestResponse(HttpRequestType const& request, boost::beast::http::status status)
90{
91 using namespace boost::beast::http;
92 Handoff handoff;
93 response<string_body> msg;
94 msg.version(request.version());
95 msg.result(status);
96 msg.insert("Server", build_info::getFullVersionString());
97 msg.insert("Content-Type", "text/html");
98 msg.insert("Connection", "close");
99 msg.body() = "Invalid protocol.";
100 msg.prepare_payload();
102 return handoff;
103}
104
105// VFALCO TODO Rewrite to use boost::beast::http::fields
106static bool
108{
109 if (port.user.empty() || port.password.empty())
110 return true;
111
112 auto const it = h.find("authorization");
113 if ((it == h.end()) || (!it->second.starts_with("Basic ")))
114 return false;
115 std::string strUserPass64 = it->second.substr(6);
116 strUserPass64 = trimWhitespace(strUserPass64);
117 std::string const strUserPass = base64Decode(strUserPass64);
118 std::string::size_type const nColon = strUserPass.find(':');
119 if (nColon == std::string::npos)
120 return false;
121 std::string const strUser = strUserPass.substr(0, nColon);
122 std::string const strPassword = strUserPass.substr(nColon + 1);
123 return strUser == port.user && strPassword == port.password;
124}
125
128 Application& app,
129 boost::asio::io_context& ioContext,
130 JobQueue& jobQueue,
131 NetworkOPs& networkOPs,
132 resource::Manager& resourceManager,
134 : app_(app)
135 , resourceManager_(resourceManager)
136 , journal_(app_.getJournal("Server"))
137 , networkOPs_(networkOPs)
138 , server_(makeServer(*this, ioContext, app_.getJournal("Server")))
139 , jobQueue_(jobQueue)
140{
141 auto const& group(cm.group("rpc"));
142 rpcRequests_ = group->makeCounter("requests");
143 rpcSize_ = group->makeEvent("size");
144 rpcTime_ = group->makeEvent("time");
145}
146
148{
149 server_ = nullptr;
150}
151
152void
154{
155 setup_ = setup;
156 endpoints_ = server_->ports(setup.ports);
157
158 // fix auto ports
159 for (auto& port : setup_.ports)
160 {
161 if (auto const it = endpoints_.find(port.name); it != endpoints_.end())
162 {
163 auto const endpointPort = it->second.port();
164 if (port.port == 0u)
165 port.port = endpointPort;
166
167 if ((setup_.client.port == 0u) &&
168 (port.protocol.contains("http") || port.protocol.contains("https")))
169 setup_.client.port = endpointPort;
170
171 if ((setup_.overlay.port() == 0u) && port.protocol.contains("peer"))
172 setup_.overlay.port(endpointPort);
173 }
174 }
175}
176
177//------------------------------------------------------------------------------
178
179void
181{
182 server_->close();
183 {
185 condition_.wait(lock, [this] { return stopped_; });
186 }
187}
188
189//------------------------------------------------------------------------------
190
191bool
192ServerHandler::onAccept(Session& session, boost::asio::ip::tcp::endpoint endpoint)
193{
194 auto const& port = session.port();
195
196 auto const c = [this, &port] {
197 std::scoped_lock const lock(mutex_);
198 return ++count_[port];
199 }();
200
201 if ((port.limit != 0) && c >= port.limit)
202 {
203 JLOG(journal_.trace()) << port.name << " is full; dropping " << endpoint;
204 return false;
205 }
206
207 return true;
208}
209
212 Session& session,
214 HttpRequestType&& request,
215 boost::asio::ip::tcp::endpoint const& remoteAddress)
216{
217 using namespace boost::beast;
218 auto const& p{session.port().protocol};
219 bool const isWs{
220 p.contains("ws") || p.contains("ws2") || p.contains("wss") || p.contains("wss2"),
221 };
222
223 if (websocket::is_upgrade(request))
224 {
225 if (!isWs)
226 return statusRequestResponse(request, http::status::unauthorized);
227
229 try
230 {
231 ws = session.websocketUpgrade();
232 }
233 catch (std::exception const& e)
234 {
235 JLOG(journal_.error()) << "Exception upgrading websocket: " << e.what() << "\n";
236 return statusRequestResponse(request, http::status::internal_server_error);
237 }
238
240 auto const beastRemoteAddress = beast::IPAddressConversion::fromAsio(remoteAddress);
241 is->getConsumer() = requestInboundEndpoint(
243 beastRemoteAddress,
244 requestRole(Role::GUEST, session.port(), json::Value(), beastRemoteAddress, is->user()),
245 is->user(),
246 is->forwardedFor());
247 ws->appDefined = std::move(is);
248 ws->run();
249
250 Handoff handoff;
251 handoff.moved = true;
252 return handoff;
253 }
254
255 if (bundle && p.contains("peer"))
256 return app_.getOverlay().onHandoff(std::move(bundle), std::move(request), remoteAddress);
257
258 if (isWs && isStatusRequest(request))
259 return statusResponse(request);
260
261 // Otherwise pass to legacy onRequest or websocket
262 return {};
263}
264
265static inline json::Output
267{
268 return [&](std::string_view b) { session.write(b.data(), b.size()); };
269}
270
272buildMap(boost::beast::http::fields const& h)
273{
275 for (auto const& e : h)
276 {
277 // key cannot be a std::string_view because it needs to be used in
278 // map and along with iterators
279 std::string key(e.name_string());
281 key, key.begin(), [](auto kc) { return std::tolower(static_cast<unsigned char>(kc)); });
282 c[key] = e.value();
283 }
284 return c;
285}
286
287template <class ConstBufferSequence>
288static std::string
289buffersToString(ConstBufferSequence const& bs)
290{
291 using boost::asio::buffer_size;
292 std::string s;
293 s.reserve(buffer_size(bs));
294 // Use auto&& so the right thing happens whether bs returns a copy or
295 // a reference
296 for (auto&& b : bs)
297 s.append(static_cast<char const*>(b.data()), buffer_size(b));
298 return s;
299}
300
301void
303{
304 // Make sure RPC is enabled on the port
305 if (!session.port().protocol.contains("http") && !session.port().protocol.contains("https"))
306 {
307 httpReply(403, "Forbidden", makeOutput(session), app_.getJournal("RPC"));
308 session.close(true);
309 return;
310 }
311
312 // Check user/password authorization
313 if (!authorized(session.port(), buildMap(session.request())))
314 {
315 httpReply(403, "Forbidden", makeOutput(session), app_.getJournal("RPC"));
316 session.close(true);
317 return;
318 }
319
320 std::shared_ptr<Session> const detachedSession = session.detach();
321 auto const postResult = jobQueue_.postCoro(
322 JtClientRpc, "RPC-Client", [this, detachedSession](std::shared_ptr<JobQueue::Coro> coro) {
323 processSession(detachedSession, coro);
324 });
325 if (postResult == nullptr)
326 {
327 // The coroutine was rejected, probably because we're shutting down.
328 httpReply(503, "Service Unavailable", makeOutput(*detachedSession), app_.getJournal("RPC"));
329 detachedSession->close(true);
330 return;
331 }
332}
333
334void
338{
339 json::Value jv;
340 auto const size = boost::asio::buffer_size(buffers);
341 if (size > rpc::tuning::kMaxRequestSize || !json::Reader{}.parse(jv, buffers) || !jv.isObject())
342 {
344 jvResult[jss::type] = jss::error;
345 jvResult[jss::error] = "jsonInvalid";
346 jvResult[jss::value] = buffersToString(buffers);
347 boost::beast::multi_buffer sb;
348 json::stream(jvResult, [&sb](auto const p, auto const n) {
349 sb.commit(boost::asio::buffer_copy(sb.prepare(n), boost::asio::buffer(p, n)));
350 });
351 JLOG(journal_.trace()) << "Websocket sending '" << jvResult << "'";
352 session->send(std::make_shared<StreambufWSMsg<decltype(sb)>>(std::move(sb)));
353 session->complete();
354 return;
355 }
356
357 JLOG(journal_.trace()) << "Websocket received '" << jv << "'";
358
359 auto const postResult = jobQueue_.postCoro(
361 "WS-Client",
362 [this, session, jv = std::move(jv)](std::shared_ptr<JobQueue::Coro> const& coro) {
363 auto const jr = this->processSession(session, coro, jv);
364 auto const s = to_string(jr);
365 auto const n = s.length();
366 boost::beast::multi_buffer sb(n);
367 sb.commit(boost::asio::buffer_copy(sb.prepare(n), boost::asio::buffer(s.c_str(), n)));
368 session->send(std::make_shared<StreambufWSMsg<decltype(sb)>>(std::move(sb)));
369 session->complete();
370 });
371 if (postResult == nullptr)
372 {
373 // The coroutine was rejected, probably because we're shutting down.
374 session->close({boost::beast::websocket::going_away, "Shutting Down"});
375 }
376}
377
378void
379ServerHandler::onClose(Session& session, boost::system::error_code const&)
380{
381 std::scoped_lock const lock(mutex_);
382 --count_[session.port()];
383}
384
385void
387{
388 std::scoped_lock const lock(mutex_);
389 stopped_ = true;
390 condition_.notify_one();
391}
392
393//------------------------------------------------------------------------------
394
395template <class T>
396void
397logDuration(json::Value const& request, T const& duration, beast::Journal& journal)
398{
399 using namespace std::chrono_literals;
400 auto const level = [&] {
401 if (duration >= 10s)
402 return journal.error();
403 if (duration >= 1s)
404 return journal.warn();
405 return journal.debug();
406 }();
407
408 JLOG(level) << "RPC request processing duration = "
410 << " microseconds. request = " << request;
411}
412
415 std::shared_ptr<WSSession> const& session,
417 json::Value const& jv)
418{
419 auto const is = std::static_pointer_cast<WSInfoSub>(session->appDefined);
420 if (is->getConsumer().disconnect(journal_))
421 {
422 session->close({boost::beast::websocket::policy_error, "threshold exceeded"});
423 // FIX: This rpcError is not delivered since the session
424 // was just closed.
425 return rpcError(RpcSlowDown);
426 }
427
428 // Requests without "command" are invalid.
431 try
432 {
433 auto const apiVersion = rpc::getAPIVersionNumber(jv, app_.config().betaRpcApi);
434 if (apiVersion == rpc::kApiInvalidVersion ||
435 (!jv.isMember(jss::command) && !jv.isMember(jss::method)) ||
436 (jv.isMember(jss::command) && !jv[jss::command].isString()) ||
437 (jv.isMember(jss::method) && !jv[jss::method].isString()) ||
438 (jv.isMember(jss::command) && jv.isMember(jss::method) &&
439 jv[jss::command].asString() != jv[jss::method].asString()))
440 {
441 jr[jss::type] = jss::response;
442 jr[jss::status] = jss::error;
443 jr[jss::error] = apiVersion == rpc::kApiInvalidVersion ? jss::invalid_API_version
444 : jss::missingCommand;
445 jr[jss::request] = jv;
446 if (jv.isMember(jss::id))
447 jr[jss::id] = jv[jss::id];
448 if (jv.isMember(jss::jsonrpc))
449 jr[jss::jsonrpc] = jv[jss::jsonrpc];
450 if (jv.isMember(jss::ripplerpc))
451 jr[jss::ripplerpc] = jv[jss::ripplerpc];
452 if (jv.isMember(jss::api_version))
453 jr[jss::api_version] = jv[jss::api_version];
454
455 is->getConsumer().charge(resource::kFeeMalformedRpc);
456 return jr;
457 }
458
459 auto const required = rpc::roleRequired(
460 apiVersion,
461 app_.config().betaRpcApi,
462 jv.isMember(jss::command) ? jv[jss::command].asString() : jv[jss::method].asString());
463 auto const role = requestRole(
464 required,
465 session->port(),
466 jv,
467 beast::ip::fromAsio(session->remoteEndpoint().address()),
468 is->user());
469 if (Role::FORBID == role)
470 {
472 jr[jss::result] = rpcError(RpcForbidden);
473 }
474 else
475 {
476 rpc::JsonContext context{
477 {
478 .j = app_.getJournal("RPCHandler"),
479 .app = app_,
480 .loadType = loadType,
481 .netOps = app_.getOPs(),
482 .ledgerMaster = app_.getLedgerMaster(),
483 .consumer = is->getConsumer(),
484 .role = role,
485 .coro = coro,
486 .infoSub = is,
487 .apiVersion = apiVersion,
488 },
489 jv,
490 {.user = is->user(), .forwardedFor = is->forwardedFor()},
491 };
492
493 auto const start = std::chrono::system_clock::now();
494 rpc::doCommand(context, jr[jss::result]);
495 auto const end = std::chrono::system_clock::now();
496 logDuration(jv, end - start, journal_);
497 }
498 }
499 catch (std::exception const& ex)
500 {
501 // LCOV_EXCL_START
502 jr[jss::result] = rpc::makeError(RpcInternal);
503 JLOG(journal_.error()) << "Exception while processing WS: " << ex.what() << "\n"
504 << "Input JSON: " << json::Compact{json::Value{jv}};
505 // LCOV_EXCL_STOP
506 }
507
508 is->getConsumer().charge(loadType);
509 if (is->getConsumer().warn())
510 jr[jss::warning] = jss::load;
511
512 // Currently we will simply unwrap errors returned by the RPC
513 // API, in the future maybe we can make the responses
514 // consistent.
515 //
516 // Regularize result. This is duplicate code.
517 if (jr[jss::result].isMember(jss::error))
518 {
519 jr = jr[jss::result];
520 jr[jss::status] = jss::error;
521
522 auto rq = jv;
523
524 if (rq.isObject())
525 {
526 if (rq.isMember(jss::passphrase.cStr()))
527 rq[jss::passphrase.cStr()] = "<masked>";
528 if (rq.isMember(jss::secret.cStr()))
529 rq[jss::secret.cStr()] = "<masked>";
530 if (rq.isMember(jss::seed.cStr()))
531 rq[jss::seed.cStr()] = "<masked>";
532 if (rq.isMember(jss::seed_hex.cStr()))
533 rq[jss::seed_hex.cStr()] = "<masked>";
534 }
535
536 jr[jss::request] = rq;
537 }
538 else
539 {
540 jr[jss::status] = jss::success;
541 }
542
543 if (jv.isMember(jss::id))
544 jr[jss::id] = jv[jss::id];
545 if (jv.isMember(jss::jsonrpc))
546 jr[jss::jsonrpc] = jv[jss::jsonrpc];
547 if (jv.isMember(jss::ripplerpc))
548 jr[jss::ripplerpc] = jv[jss::ripplerpc];
549 if (jv.isMember(jss::api_version))
550 jr[jss::api_version] = jv[jss::api_version];
551
552 jr[jss::type] = jss::response;
553 return jr;
554}
555
556// Run as a coroutine.
557void
559 std::shared_ptr<Session> const& session,
561{
563 session->port(),
564 buffersToString(session->request().body().data()),
565 session->remoteAddress().atPort(0),
566 makeOutput(*session),
567 coro,
568 forwardedFor(session->request()),
569 [&] -> std::string_view {
570 auto const iter = session->request().find("X-User");
571 if (iter != session->request().end())
572 return iter->value();
573 return {};
574 }());
575
576 if (beast::rfc2616::isKeepAlive(session->request()))
577 {
578 session->complete();
579 }
580 else
581 {
582 session->close(true);
583 }
584}
585
586static json::Value
588{
590 sub["code"] = code;
591 sub["message"] = std::move(message);
593 r["error"] = sub;
594 return r;
595}
596
597constexpr json::Int kMethodNotFound = -32601;
598constexpr json::Int kServerOverloaded = -32604;
599constexpr json::Int kForbidden = -32605;
600constexpr json::Int kWrongVersion = -32606;
601
602void
604 Port const& port,
605 std::string const& request,
606 beast::ip::Endpoint const& remoteIPAddress,
607 Output const& output,
610 std::string_view user)
611{
612 auto const rpcJ = app_.getJournal("RPC");
613
614 json::Value jsonOrig;
615 {
616 json::Reader reader;
617 if ((request.size() > rpc::tuning::kMaxRequestSize) || !reader.parse(request, jsonOrig) ||
618 !jsonOrig || !jsonOrig.isObject())
619 {
620 httpReply(
621 400,
622 "Unable to parse request: " + reader.getFormattedErrorMessages(),
623 output,
624 rpcJ);
625 return;
626 }
627 }
628
629 bool batch = false;
630 unsigned size = 1;
631 if (jsonOrig.isMember(jss::method) && jsonOrig[jss::method] == "batch")
632 {
633 batch = true;
634 if (!jsonOrig.isMember(jss::params) || !jsonOrig[jss::params].isArray())
635 {
636 httpReply(400, "Malformed batch request", output, rpcJ);
637 return;
638 }
639 size = jsonOrig[jss::params].size();
640 }
641
643 auto const start(std::chrono::high_resolution_clock::now());
644 for (unsigned i = 0; i < size; ++i)
645 {
646 json::Value const& jsonRPC = batch ? jsonOrig[jss::params][i] : jsonOrig;
647
648 if (!jsonRPC.isObject())
649 {
651 r[jss::request] = jsonRPC;
652 r[jss::error] = makeJsonError(kMethodNotFound, "Method not found");
653 reply.append(r);
654 continue;
655 }
656
657 unsigned apiVersion = rpc::kApiVersionIfUnspecified;
658 if (jsonRPC.isMember(jss::params) && jsonRPC[jss::params].isArray() &&
659 jsonRPC[jss::params].size() > 0 && jsonRPC[jss::params][0u].isObject())
660 {
661 apiVersion = rpc::getAPIVersionNumber(
662 jsonRPC[jss::params][json::UInt(0)], app_.config().betaRpcApi);
663 }
664
665 if (apiVersion == rpc::kApiVersionIfUnspecified && batch)
666 {
667 // for batch request, api_version may be at a different level
668 apiVersion = rpc::getAPIVersionNumber(jsonRPC, app_.config().betaRpcApi);
669 }
670
671 if (apiVersion == rpc::kApiInvalidVersion)
672 {
673 if (!batch)
674 {
675 httpReply(400, jss::invalid_API_version.cStr(), output, rpcJ);
676 return;
677 }
679 r[jss::request] = jsonRPC;
680 r[jss::error] = makeJsonError(kWrongVersion, jss::invalid_API_version.cStr());
681 reply.append(r);
682 continue;
683 }
684
685 /* ------------------------------------------------------------------ */
686 auto role = Role::FORBID;
687 auto required = Role::FORBID;
688 if (jsonRPC.isMember(jss::method) && jsonRPC[jss::method].isString())
689 {
690 required = rpc::roleRequired(
691 apiVersion, app_.config().betaRpcApi, jsonRPC[jss::method].asString());
692 }
693
694 if (jsonRPC.isMember(jss::params) && jsonRPC[jss::params].isArray() &&
695 jsonRPC[jss::params].size() > 0 && jsonRPC[jss::params][json::UInt(0)].isObjectOrNull())
696 {
697 role = requestRole(
698 required, port, jsonRPC[jss::params][json::UInt(0)], remoteIPAddress, user);
699 }
700 else
701 {
702 role = requestRole(required, port, json::ValueType::Object, remoteIPAddress, user);
703 }
704
705 resource::Consumer usage;
706 if (isUnlimited(role))
707 {
708 usage = resourceManager_.newUnlimitedEndpoint(remoteIPAddress);
709 }
710 else
711 {
712 usage = resourceManager_.newInboundEndpoint(
713 remoteIPAddress, role == Role::PROXY, forwardedFor);
714 if (usage.disconnect(journal_))
715 {
716 if (!batch)
717 {
718 httpReply(503, "Server is overloaded", output, rpcJ);
719 return;
720 }
721 json::Value r = jsonRPC;
722 r[jss::error] = makeJsonError(kServerOverloaded, "Server is overloaded");
723 reply.append(r);
724 continue;
725 }
726 }
727
728 if (role == Role::FORBID)
729 {
731 if (!batch)
732 {
733 httpReply(403, "Forbidden", output, rpcJ);
734 return;
735 }
736 json::Value r = jsonRPC;
737 r[jss::error] = makeJsonError(kForbidden, "Forbidden");
738 reply.append(r);
739 continue;
740 }
741
742 if (!jsonRPC.isMember(jss::method) || jsonRPC[jss::method].isNull())
743 {
745 if (!batch)
746 {
747 httpReply(400, "Null method", output, rpcJ);
748 return;
749 }
750 json::Value r = jsonRPC;
751 r[jss::error] = makeJsonError(kMethodNotFound, "Null method");
752 reply.append(r);
753 continue;
754 }
755
756 json::Value const& method = jsonRPC[jss::method];
757 if (!method.isString())
758 {
760 if (!batch)
761 {
762 httpReply(400, "method is not string", output, rpcJ);
763 return;
764 }
765 json::Value r = jsonRPC;
766 r[jss::error] = makeJsonError(kMethodNotFound, "method is not string");
767 reply.append(r);
768 continue;
769 }
770
771 std::string const strMethod = method.asString();
772 if (strMethod.empty())
773 {
775 if (!batch)
776 {
777 httpReply(400, "method is empty", output, rpcJ);
778 return;
779 }
780 json::Value r = jsonRPC;
781 r[jss::error] = makeJsonError(kMethodNotFound, "method is empty");
782 reply.append(r);
783 continue;
784 }
785
786 // Extract request parameters from the request Json as `params`.
787 //
788 // If the field "params" is empty, `params` is an empty object.
789 //
790 // Otherwise, that field must be an array of length 1 (why?)
791 // and we take that first entry and validate that it's an object.
792 json::Value params;
793 if (!batch)
794 {
795 params = jsonRPC[jss::params];
796 if (!params)
797 {
799 }
800 else if (!params.isArray() || params.size() != 1)
801 {
803 httpReply(400, "params unparsable", output, rpcJ);
804 return;
805 }
806 else
807 {
808 params = std::move(params[0u]);
809 if (!params.isObjectOrNull())
810 {
812 httpReply(400, "params unparsable", output, rpcJ);
813 return;
814 }
815 }
816 }
817 else // batch
818 {
819 params = jsonRPC;
820 }
821
823 if (params.isMember(jss::ripplerpc))
824 {
825 if (!params[jss::ripplerpc].isString())
826 {
828 if (!batch)
829 {
830 httpReply(400, "ripplerpc is not a string", output, rpcJ);
831 return;
832 }
833
834 json::Value r = jsonRPC;
835 r[jss::error] = makeJsonError(kMethodNotFound, "ripplerpc is not a string");
836 reply.append(r);
837 continue;
838 }
839 ripplerpc = params[jss::ripplerpc].asString();
840 }
841
846 if (role != Role::IDENTIFIED && role != Role::PROXY)
847 {
848 forwardedFor.remove_suffix(forwardedFor.size());
849 user.remove_suffix(user.size());
850 }
851
852 JLOG(journal_.debug()) << "Query: " << strMethod << params;
853
854 // Provide the JSON-RPC method as the field "command" in the request.
855 params[jss::command] = strMethod;
856 JLOG(journal_.trace()) << "doRpcCommand:" << strMethod << ":" << params;
857
859
860 rpc::JsonContext context{
861 {
862 .j = journal_,
863 .app = app_,
864 .loadType = loadType,
865 .netOps = networkOPs_,
866 .ledgerMaster = app_.getLedgerMaster(),
867 .consumer = usage,
868 .role = role,
869 .coro = coro,
870 .infoSub = InfoSub::pointer(),
871 .apiVersion = apiVersion,
872 },
873 params,
874 {.user = user, .forwardedFor = forwardedFor},
875 };
876 json::Value result;
877
878 auto const start = std::chrono::system_clock::now();
879
880 try
881 {
882 rpc::doCommand(context, result);
883 }
884 catch (std::exception const& ex)
885 {
886 // LCOV_EXCL_START
887 result = rpc::makeError(RpcInternal);
888 JLOG(journal_.error())
889 << "Internal error : " << ex.what()
890 << " when processing request: " << json::Compact{json::Value{params}};
891 // LCOV_EXCL_STOP
892 }
893
894 auto const end = std::chrono::system_clock::now();
895
896 logDuration(params, end - start, journal_);
897
898 usage.charge(loadType);
899 if (usage.warn())
900 result[jss::warning] = jss::load;
901
903 if (ripplerpc >= rpc::kRippleRpcVersion2)
904 {
905 if (result.isMember(jss::error))
906 {
907 result[jss::status] = jss::error;
908 result["code"] = result[jss::error_code];
909 result["message"] = result[jss::error_message];
910 result.removeMember(jss::error_message);
911 JLOG(journal_.debug())
912 << "rpcError: " << result[jss::error] << ": " << result[jss::error_message];
913 r[jss::error] = std::move(result);
914 }
915 else
916 {
917 result[jss::status] = jss::success;
918 r[jss::result] = std::move(result);
919 }
920 }
921 else
922 {
923 // Always report "status". On an error report the request as
924 // received.
925 if (result.isMember(jss::error))
926 {
927 auto rq = params;
928
929 if (rq.isObject())
930 { // But mask potentially sensitive information.
931 if (rq.isMember(jss::passphrase.cStr()))
932 rq[jss::passphrase.cStr()] = "<masked>";
933 if (rq.isMember(jss::secret.cStr()))
934 rq[jss::secret.cStr()] = "<masked>";
935 if (rq.isMember(jss::seed.cStr()))
936 rq[jss::seed.cStr()] = "<masked>";
937 if (rq.isMember(jss::seed_hex.cStr()))
938 rq[jss::seed_hex.cStr()] = "<masked>";
939 }
940
941 result[jss::status] = jss::error;
942 result[jss::request] = rq;
943
944 JLOG(journal_.debug())
945 << "rpcError: " << result[jss::error] << ": " << result[jss::error_message];
946 }
947 else
948 {
949 result[jss::status] = jss::success;
950 }
951 r[jss::result] = std::move(result);
952 }
953
954 if (params.isMember(jss::jsonrpc))
955 r[jss::jsonrpc] = params[jss::jsonrpc];
956 if (params.isMember(jss::ripplerpc))
957 r[jss::ripplerpc] = params[jss::ripplerpc];
958 if (params.isMember(jss::id))
959 r[jss::id] = params[jss::id];
960 if (batch)
961 {
962 reply.append(std::move(r));
963 }
964 else
965 {
966 reply = std::move(r);
967 }
968
969 if (reply.isMember(jss::result) && reply[jss::result].isMember(jss::result))
970 {
971 reply = reply[jss::result];
972 if (reply.isMember(jss::status))
973 {
974 reply[jss::result][jss::status] = reply[jss::status];
975 reply.removeMember(jss::status);
976 }
977 }
978 }
979
980 // If we're returning an error_code, use that to determine the HTTP status.
981 int const httpStatus = [&reply] {
982 // This feature is enabled with ripplerpc version 3.0 and above.
983 // Before ripplerpc version 3.0 always return 200.
984 if (reply.isMember(jss::ripplerpc) && reply[jss::ripplerpc].isString() &&
985 reply[jss::ripplerpc].asString() >= rpc::kRippleRpcVersion3)
986 {
987 // If there's an error_code, use that to determine the HTTP Status.
988 if (reply.isMember(jss::error) && reply[jss::error].isMember(jss::error_code) &&
989 reply[jss::error][jss::error_code].isInt())
990 {
991 int const errCode = reply[jss::error][jss::error_code].asInt();
992 return rpc::errorCodeHttpStatus(static_cast<ErrorCodeI>(errCode));
993 }
994 }
995 // Return OK.
996 return 200;
997 }();
998
999 auto response = to_string(reply);
1000
1001 rpcTime_.notify(
1004 ++rpcRequests_;
1005 rpcSize_.notify(beast::insight::Event::value_type{response.size()});
1006
1007 response += '\n';
1008
1009 if (auto const stream = journal_.debug())
1010 {
1011 static int const kMaxSize = 10000;
1012 if (response.size() <= kMaxSize)
1013 {
1014 stream << "Reply: " << response;
1015 }
1016 else
1017 {
1018 stream << "Reply: " << response.substr(0, kMaxSize);
1019 }
1020 }
1021
1022 httpReply(httpStatus, response, output, rpcJ);
1023}
1024
1025//------------------------------------------------------------------------------
1026
1027/* This response is used with load balancing.
1028 If the server is overloaded, status 500 is reported. Otherwise status 200
1029 is reported, meaning the server can accept more connections.
1030*/
1031Handoff
1033{
1034 using namespace boost::beast::http;
1035 Handoff handoff;
1036 response<string_body> msg;
1037 std::string reason;
1038 if (app_.serverOkay(reason))
1039 {
1040 msg.result(boost::beast::http::status::ok);
1041 msg.body() = "<!DOCTYPE html><html><head><title>Test page for " + systemName() +
1042 "</title></head><body><h1>Test</h1><p>This page shows " + systemName() +
1043 " http(s) connectivity is working.</p></body></html>";
1044 }
1045 else
1046 {
1047 msg.result(boost::beast::http::status::internal_server_error);
1048 msg.body() = "<HTML><BODY>Server cannot accept clients: " + reason + "</BODY></HTML>";
1049 }
1050 msg.version(request.version());
1052 msg.insert("Content-Type", "text/html");
1053 msg.insert("Connection", "close");
1054 msg.prepare_payload();
1056 return handoff;
1057}
1058
1059//------------------------------------------------------------------------------
1060
1061void
1063{
1064 for (auto& p : ports)
1065 {
1066 if (p.secure())
1067 {
1068 if (p.sslKey.empty() && p.sslCert.empty() && p.sslChain.empty())
1069 {
1070 p.context = makeSslContext(p.sslCiphers);
1071 }
1072 else
1073 {
1074 p.context = makeSslContextAuthed(p.sslKey, p.sslCert, p.sslChain, p.sslCiphers);
1075 }
1076 }
1077 else
1078 {
1079 p.context =
1080 std::make_shared<boost::asio::ssl::context>(boost::asio::ssl::context::sslv23);
1081 }
1082 }
1083}
1084
1085static Port
1086toPort(ParsedPort const& parsed, std::ostream& log)
1087{
1088 Port p;
1089 p.name = parsed.name;
1090
1091 if (!parsed.ip)
1092 {
1093 log << "Missing 'ip' in [" << p.name << "]";
1095 }
1096 p.ip = *parsed.ip;
1097
1098 if (!parsed.port)
1099 {
1100 log << "Missing 'port' in [" << p.name << "]";
1102 }
1103 p.port = *parsed.port;
1104
1105 if (parsed.protocol.empty())
1106 {
1107 log << "Missing 'protocol' in [" << p.name << "]";
1109 }
1110 p.protocol = parsed.protocol;
1111
1112 p.user = parsed.user;
1113 p.password = parsed.password;
1114 p.adminUser = parsed.adminUser;
1115 p.adminPassword = parsed.adminPassword;
1116 p.sslKey = parsed.sslKey;
1117 p.sslCert = parsed.sslCert;
1118 p.sslChain = parsed.sslChain;
1119 p.sslCiphers = parsed.sslCiphers;
1120 p.pmdOptions = parsed.pmdOptions;
1121 p.wsQueueLimit = parsed.wsQueueLimit;
1122 p.limit = parsed.limit;
1123 p.adminNetsV4 = parsed.adminNetsV4;
1124 p.adminNetsV6 = parsed.adminNetsV6;
1127
1128 return p;
1129}
1130
1131static std::vector<Port>
1132parsePorts(Config const& config, std::ostream& log)
1133{
1134 std::vector<Port> result;
1135
1136 if (!config.exists(Sections::kServer))
1137 {
1138 log << "Required section [server] is missing";
1140 }
1141
1142 ParsedPort common;
1143 parsePort(common, config[Sections::kServer], log);
1144
1145 auto const& names = config.section(Sections::kServer).values();
1146 result.reserve(names.size());
1147 for (auto const& name : names)
1148 {
1149 if (!config.exists(name))
1150 {
1151 log << "Missing section: [" << name << "]";
1153 }
1154
1155 // grpc ports are parsed by GRPCServer class. Do not validate
1156 // grpc port information in this file.
1157 if (name == Sections::kPortGrpc)
1158 continue;
1159
1160 ParsedPort parsed = common;
1161 parsePort(parsed, config[name], log);
1162 result.push_back(toPort(parsed, log));
1163 }
1164
1165 if (config.standalone())
1166 {
1167 auto it = result.begin();
1168
1169 while (it != result.end())
1170 {
1171 auto& p = it->protocol;
1172
1173 // Remove the peer protocol, and if that would
1174 // leave the port empty, remove the port as well
1175 if ((p.erase("peer") != 0u) && p.empty())
1176 {
1177 it = result.erase(it);
1178 }
1179 else
1180 {
1181 ++it;
1182 }
1183 }
1184 }
1185 else
1186 {
1187 auto const count = std::ranges::count_if(
1188 result, [](Port const& p) { return p.protocol.contains("peer"); });
1189
1190 if (count > 1)
1191 {
1192 log << "Error: More than one peer protocol configured in [server]";
1194 }
1195
1196 if (count == 0)
1197 log << "Warning: No peer protocol configured";
1198 }
1199
1200 return result;
1201}
1202
1203// Fill out the client portion of the Setup
1204static void
1206{
1207 decltype(setup.ports)::const_iterator iter;
1208 for (iter = setup.ports.cbegin(); iter != setup.ports.cend(); ++iter)
1209 {
1210 if (iter->protocol.contains("http") || iter->protocol.contains("https"))
1211 break;
1212 }
1213 if (iter == setup.ports.cend())
1214 return;
1215 setup.client.secure = iter->protocol.contains("https");
1216 if (beast::ip::isUnspecified(iter->ip))
1217 {
1218 // VFALCO HACK! to make localhost work
1219 setup.client.ip = iter->ip.is_v6() ? "::1" : "127.0.0.1";
1220 }
1221 else
1222 {
1223 setup.client.ip = iter->ip.to_string();
1224 }
1225 setup.client.port = iter->port;
1226 setup.client.user = iter->user;
1227 setup.client.password = iter->password;
1228 setup.client.adminUser = iter->adminUser;
1229 setup.client.adminPassword = iter->adminPassword;
1230}
1231
1232// Fill out the overlay portion of the Setup
1233static void
1235{
1236 auto const iter = std::ranges::find_if(
1237 setup.ports, [](Port const& port) { return port.protocol.contains("peer"); });
1238 if (iter == setup.ports.cend())
1239 {
1240 setup.overlay = {};
1241 return;
1242 }
1243 setup.overlay = {iter->ip, iter->port};
1244}
1245
1246ServerHandler::Setup
1248{
1250 setup.ports = parsePorts(config, log);
1251
1252 setupClient(setup);
1253 setupOverlay(setup);
1254
1255 return setup;
1256}
1257
1260 Application& app,
1261 boost::asio::io_context& ioContext,
1262 JobQueue& jobQueue,
1263 NetworkOPs& networkOPs,
1264 resource::Manager& resourceManager,
1265 CollectorManager& cm)
1266{
1269 app,
1270 ioContext,
1271 jobQueue,
1272 networkOPs,
1273 resourceManager,
1274 cm);
1275}
1276
1277} // namespace xrpl
T append(T... args)
T begin(T... args)
A generic endpoint for log messages.
Definition Journal.h:44
Stream error() const
Definition Journal.h:362
Stream debug() const
Definition Journal.h:344
Stream warn() const
Definition Journal.h:356
EventImpl::value_type value_type
Definition Event.h:24
A version-independent IP address and port combination.
Definition IPEndpoint.h:24
Decorator for streaming out compact json.
Unserialize a JSON document into a Value.
Definition json_reader.h:20
bool parse(std::string const &document, Value &root)
Read a Value from a JSON document.
std::string getFormattedErrorMessages() const
Returns a user friendly string that list errors in the parsed document.
Represents a JSON value.
Definition json_value.h:121
Value removeMember(char const *key)
Remove and return the named member.
bool isNull() const
isNull() tests to see if this field is null.
bool isObject() const
bool isArray() const
bool isString() const
Value & append(Value const &value)
Append value to array at the end.
UInt size() const
Number of values in array or object.
bool isInt() const
std::string asString() const
Returns the unquoted string value.
bool isObjectOrNull() const
bool isMember(char const *key) const
Return true if the object has a member named key.
Int asInt() const
bool exists(std::string const &name) const
Returns true if a section with the given name exists.
Section & section(std::string const &name)
Returns the section with the given name.
Holds transactions which were deferred to the next pass of consensus.
Provides the beast::insight::Collector service.
virtual beast::insight::Group::Ptr const & group(std::string const &name)=0
bool standalone() const
std::shared_ptr< InfoSub > pointer
Definition InfoSub.h:92
A pool of threads to perform work.
Definition JobQueue.h:60
Tracks the current ledger and any ledgers in the process of closing.
Provides server functionality for clients.
Definition NetworkOPs.h:82
Represents a peer connection in the overlay.
std::vector< std::string > const & values() const
Returns all the values in the section.
Definition BasicConfig.h:68
std::condition_variable condition_
ServerHandler(ServerHandlerCreator const &, Application &app, boost::asio::io_context &ioContext, JobQueue &jobQueue, NetworkOPs &networkOPs, resource::Manager &resourceManager, CollectorManager &cm)
Handoff onHandoff(Session &session, std::unique_ptr< StreamType > &&bundle, HttpRequestType &&request, boost::asio::ip::tcp::endpoint const &remoteAddress)
beast::insight::Event rpcTime_
beast::insight::Event rpcSize_
Application & app_
json::Value processSession(std::shared_ptr< WSSession > const &session, std::shared_ptr< JobQueue::Coro > const &coro, json::Value const &jv)
void processRequest(Port const &port, std::string const &request, beast::ip::Endpoint const &remoteIPAddress, Output const &, std::shared_ptr< JobQueue::Coro > coro, std::string_view forwardedFor, std::string_view user)
void onClose(Session &session, boost::system::error_code const &)
Setup const & setup() const
NetworkOPs & networkOPs_
bool onAccept(Session &session, boost::asio::ip::tcp::endpoint endpoint)
friend std::unique_ptr< ServerHandler > makeServerHandler(Application &app, boost::asio::io_context &, JobQueue &, NetworkOPs &, resource::Manager &, CollectorManager &cm)
void onStopped(Server &)
void setup(Setup const &setup, beast::Journal journal)
resource::Manager & resourceManager_
Handoff statusResponse(HttpRequestType const &request) const
std::map< std::reference_wrapper< Port const >, int > count_
void onRequest(Session &session)
void onWSMessage(std::shared_ptr< WSSession > session, std::vector< boost::asio::const_buffer > const &buffers)
beast::Journal journal_
std::unique_ptr< Server > server_
beast::insight::Counter rpcRequests_
A multi-protocol server.
Definition ServerImpl.h:37
Persistent state information for a connection session.
Definition Session.h:25
virtual Port const & port()=0
Returns the Port settings for this connection.
virtual void close(bool graceful)=0
Close the session.
virtual std::shared_ptr< Session > detach()=0
Detach the session.
void write(std::string_view s)
Send a copy of data asynchronously.
Definition Session.h:69
virtual HttpRequestType & request()=0
Returns the current HTTP request.
virtual std::shared_ptr< WSSession > websocketUpgrade()=0
Convert the connection to WebSocket.
Validator keys and manifest as set in configuration file.
A consumption charge.
Definition Charge.h:13
An endpoint that consumes resources.
Definition Consumer.h:20
bool disconnect(beast::Journal const &j)
Returns true if the consumer should be disconnected.
Definition Consumer.cpp:107
Disposition charge(Charge const &fee, std::string const &context={})
Apply a load charge to the consumer.
Definition Consumer.cpp:89
bool warn()
Returns true if the consumer should be warned.
Definition Consumer.cpp:100
Tracks load and resource consumption.
T contains(T... args)
T count_if(T... args)
T duration_cast(T... args)
T empty(T... args)
T end(T... args)
T erase(T... args)
T find(T... args)
T insert(T... args)
T make_shared(T... args)
T make_unique(T... args)
bool isUnspecified(Address const &addr)
Returns true if the address is unspecified.
Definition IPAddress.h:44
Endpoint fromAsio(boost::asio::ip::address const &address)
Convert to Endpoint.
bool isKeepAlive(boost::beast::http::message< IsRequest, Body, Fields > const &m)
Definition rfc2616.h:367
int Int
std::function< void(std::string_view)> Output
Definition Output.h:9
void stream(json::Value const &jv, Write const &write)
Stream compact JSON to the specified function.
unsigned int UInt
@ Array
array value (ordered list)
Definition json_value.h:32
@ Object
object value (collection of name/value pairs).
Definition json_value.h:33
std::string const & getFullVersionString()
Full server version string.
Definition BuildInfo.cpp:77
Charge const kFeeMalformedRpc
Charge const kFeeReferenceRpc
static constexpr int kMaxRequestSize
constexpr std::string_view kRippleRpcVersion1
Values accepted in the ripplerpc request field, which selects the shape of the JSON-RPC reply envelop...
Definition ApiVersion.h:56
Role roleRequired(unsigned int version, bool betaEnabled, std::string_view method)
static constexpr auto kApiVersionIfUnspecified
Definition ApiVersion.h:34
constexpr std::string_view kRippleRpcVersion3
Definition ApiVersion.h:58
unsigned int getAPIVersionNumber(json::Value const &jv, bool betaEnabled)
Retrieve the api version number from the json value.
Definition ApiVersion.h:100
int errorCodeHttpStatus(ErrorCodeI code)
Returns http status that corresponds to the error code.
static constexpr auto kApiInvalidVersion
Definition ApiVersion.h:31
constexpr std::string_view kRippleRpcVersion2
Definition ApiVersion.h:57
json::Value makeError(ErrorCodeI code)
Returns a new json object that reflects the error code.
::rpc::Status doCommand(rpc::JsonContext &context, json::Value &result)
Execute an RPC command and store the results in a json::Value.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
static void setupClient(ServerHandler::Setup &setup)
std::string base64Decode(std::string_view data)
static json::Value makeJsonError(json::Int code, json::Value &&message)
ErrorCodeI
Definition ErrorCodes.h:23
@ RpcInternal
Definition ErrorCodes.h:113
@ RpcSlowDown
Definition ErrorCodes.h:40
@ RpcForbidden
Definition ErrorCodes.h:31
ServerHandler::Setup setupServerHandler(Config const &config, std::ostream &log)
constexpr json::Int kWrongVersion
void parsePort(ParsedPort &port, Section const &section, std::ostream &log)
Definition Port.cpp:195
static Port toPort(ParsedPort const &parsed, std::ostream &log)
std::unique_ptr< Server > makeServer(Handler &handler, boost::asio::io_context &ioContext, beast::Journal journal)
Create the HTTP server using the specified handler.
Definition Server.h:17
static std::map< std::string, std::string > buildMap(boost::beast::http::fields const &h)
static bool authorized(Port const &port, std::map< std::string, std::string > const &h)
constexpr json::Int kMethodNotFound
std::string trimWhitespace(std::string str)
Remove leading and trailing ASCII whitespace.
static std::vector< Port > parsePorts(Config const &config, std::ostream &log)
std::string to_string(BaseUInt< Bits, Tag > const &a)
Definition base_uint.h:658
void logDuration(json::Value const &request, T const &duration, beast::Journal &journal)
static json::Output makeOutput(Session &session)
json::Value rpcError(ErrorCodeI iError)
Definition RPCErr.cpp:13
@ IDENTIFIED
Definition Role.h:27
@ GUEST
Definition Role.h:27
@ FORBID
Definition Role.h:27
@ PROXY
Definition Role.h:27
void httpReply(int nStatus, std::string const &strMsg, json::Output const &, beast::Journal j)
@ JtClientWebsocket
Definition Job.h:37
@ JtClientRpc
Definition Job.h:36
Role requestRole(Role const &required, Port const &port, json::Value const &params, beast::ip::Endpoint const &remoteIp, std::string_view user)
Return the allowed privilege role.
Definition Role.cpp:88
std::shared_ptr< boost::asio::ssl::context > makeSslContextAuthed(std::string const &keyFile, std::string const &certFile, std::string const &chainFile, std::string const &cipherList)
Create an authenticated SSL context using the specified files.
constexpr json::Int kForbidden
static std::string const & systemName()
boost::beast::http::request< boost::beast::http::dynamic_body > HttpRequestType
Definition Handoff.h:12
std::shared_ptr< boost::asio::ssl::context > makeSslContext(std::string const &cipherList)
Create a self-signed SSL context that allows anonymous Diffie Hellman.
static std::string buffersToString(ConstBufferSequence const &bs)
std::string_view forwardedFor(HttpRequestType const &request)
Definition Role.cpp:251
static bool isStatusRequest(HttpRequestType const &request)
static Handoff statusRequestResponse(HttpRequestType const &request, boost::beast::http::status status)
bool isUnlimited(Role const &role)
ADMIN and IDENTIFIED roles shall have unlimited resources.
Definition Role.cpp:115
constexpr json::Int kServerOverloaded
Overlay::Setup setupOverlay(BasicConfig const &config, beast::Journal j)
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
Definition contract.h:52
resource::Consumer requestInboundEndpoint(resource::Manager &manager, beast::ip::Endpoint const &remoteAddress, Role const &role, std::string_view user, std::string_view forwardedFor)
Definition Role.cpp:132
T static_pointer_cast(T... args)
T push_back(T... args)
T remove_suffix(T... args)
T reserve(T... args)
T size(T... args)
static ip::Endpoint fromAsio(boost::asio::ip::address const &address)
Used to indicate the result of a server connection handoff.
Definition Handoff.h:20
std::shared_ptr< Writer > response
Definition Handoff.h:29
std::set< std::string, boost::beast::iless > protocol
Definition Port.h:81
std::vector< boost::asio::ip::network_v4 > adminNetsV4
Definition Port.h:96
std::optional< boost::asio::ip::address > ip
Definition Port.h:94
std::vector< boost::asio::ip::network_v6 > adminNetsV6
Definition Port.h:97
std::string sslKey
Definition Port.h:86
std::vector< boost::asio::ip::network_v6 > secureGatewayNetsV6
Definition Port.h:99
std::string name
Definition Port.h:80
std::string sslCiphers
Definition Port.h:89
std::string adminUser
Definition Port.h:84
std::string user
Definition Port.h:82
std::optional< std::uint16_t > port
Definition Port.h:95
std::vector< boost::asio::ip::network_v4 > secureGatewayNetsV4
Definition Port.h:98
std::string sslCert
Definition Port.h:87
std::string password
Definition Port.h:83
std::uint16_t wsQueueLimit
Definition Port.h:92
boost::beast::websocket::permessage_deflate pmdOptions
Definition Port.h:90
std::string adminPassword
Definition Port.h:85
std::string sslChain
Definition Port.h:88
Configuration information for a Server listening port.
Definition Port.h:29
std::string sslCiphers
Definition Port.h:47
int limit
Definition Port.h:53
std::string sslCert
Definition Port.h:45
std::string password
Definition Port.h:41
std::vector< boost::asio::ip::network_v6 > adminNetsV6
Definition Port.h:37
std::set< std::string, boost::beast::iless > protocol
Definition Port.h:35
boost::beast::websocket::permessage_deflate pmdOptions
Definition Port.h:48
std::vector< boost::asio::ip::network_v4 > secureGatewayNetsV4
Definition Port.h:38
std::vector< boost::asio::ip::network_v4 > adminNetsV4
Definition Port.h:36
std::string adminUser
Definition Port.h:42
std::uint16_t wsQueueLimit
Definition Port.h:56
std::vector< boost::asio::ip::network_v6 > secureGatewayNetsV6
Definition Port.h:39
std::string sslKey
Definition Port.h:44
std::string adminPassword
Definition Port.h:43
boost::asio::ip::address ip
Definition Port.h:33
std::string sslChain
Definition Port.h:46
std::string name
Definition Port.h:32
std::string user
Definition Port.h:40
std::uint16_t port
Definition Port.h:34
static constexpr auto kServer
Definition Constants.h:56
static constexpr auto kPortGrpc
Definition Constants.h:45
boost::asio::ip::tcp::endpoint overlay
std::vector< Port > ports
T substr(T... args)
T transform(T... args)
T what(T... args)