1#include <xrpld/app/misc/HashRouter.h>
2#include <xrpld/app/misc/NetworkOPs.h>
3#include <xrpld/app/misc/ValidatorList.h>
4#include <xrpld/app/misc/ValidatorSite.h>
5#include <xrpld/app/rdb/RelationalDatabase.h>
6#include <xrpld/app/rdb/Wallet.h>
7#include <xrpld/overlay/Cluster.h>
8#include <xrpld/overlay/detail/ConnectAttempt.h>
9#include <xrpld/overlay/detail/PeerImp.h>
10#include <xrpld/overlay/detail/TrafficCount.h>
11#include <xrpld/overlay/detail/Tuning.h>
12#include <xrpld/overlay/predicates.h>
13#include <xrpld/peerfinder/make_Manager.h>
14#include <xrpld/rpc/handlers/GetCounts.h>
15#include <xrpld/rpc/json_body.h>
17#include <xrpl/basics/base64.h>
18#include <xrpl/basics/make_SSLContext.h>
19#include <xrpl/basics/random.h>
20#include <xrpl/beast/core/LexicalCast.h>
21#include <xrpl/protocol/STTx.h>
22#include <xrpl/server/SimpleWriter.h>
24#include <boost/algorithm/string/predicate.hpp>
25#include <boost/asio/executor_work_guard.hpp>
29namespace CrawlOptions {
41 overlay_.remove(*
this);
63 timer_.async_wait(boost::asio::bind_executor(
72 if (ec && ec != boost::asio::error::operation_aborted)
74 JLOG(overlay_.journal_.error()) <<
"on_timer: " << ec.message();
79 overlay_.m_peerFinder->once_per_second();
80 overlay_.sendEndpoints();
81 overlay_.autoConnect();
82 if (overlay_.app_.config().TX_REDUCE_RELAY_ENABLE)
83 overlay_.sendTxQueue();
86 overlay_.deleteIdlePeers();
99 boost::asio::io_context& io_context,
114 ,
slots_(app.logs(), *this, app.config())
118 for (
auto const& pair : counts)
143 handoff.
moved =
true;
145 JLOG(journal.
debug()) <<
"Peer connection upgrade from " << remote_endpoint;
148 auto const local_endpoint(stream_ptr->next_layer().socket().local_endpoint(ec));
151 JLOG(journal.
debug()) << remote_endpoint <<
" failed: " << ec.message();
156 if (consumer.disconnect(journal))
159 auto const [slot, result] =
m_peerFinder->new_inbound_slot(
165 handoff.
moved =
false;
166 JLOG(journal.
debug()) <<
"Peer " << remote_endpoint <<
" refused, " <<
to_string(result);
174 if (
std::find_if(types.begin(), types.end(), [](
std::string const& s) { return boost::iequals(s,
"peer"); }) ==
177 handoff.
moved =
false;
185 if (!negotiatedVersion)
188 handoff.
moved =
false;
190 makeErrorResponse(slot, request, remote_endpoint.address(),
"Unable to agree on a protocol version");
199 handoff.
moved =
false;
210 consumer.setPublicKey(publicKey);
215 bool const reserved =
217 auto const result =
m_peerFinder->activate(slot, publicKey, reserved);
218 if (result != PeerFinder::Result::success)
221 JLOG(journal.
debug()) <<
"Peer " << remote_endpoint <<
" redirected, " <<
to_string(result);
222 handoff.
moved =
false;
230 app_,
id, slot, std::move(request), publicKey, *negotiatedVersion, consumer, std::move(stream_ptr), *
this);
237 auto const result =
m_peers.emplace(peer->slot(), peer);
238 XRPL_ASSERT(result.second,
"xrpl::OverlayImpl::onHandoff : peer is inserted");
241 list_.emplace(peer.get(), peer);
245 handoff.
moved =
true;
250 JLOG(journal.
debug()) <<
"Peer " << remote_endpoint <<
" fails handshake (" << e.
what() <<
")";
253 handoff.
moved =
false;
268 return !versions.empty();
285 boost::beast::http::response<json_body> msg;
286 msg.version(request.version());
287 msg.result(boost::beast::http::status::service_unavailable);
291 ostr << remote_address;
292 msg.insert(
"Remote-Address", ostr.
str());
294 msg.insert(
"Content-Type",
"application/json");
295 msg.insert(boost::beast::http::field::connection,
"close");
300 ips.
append(_.address.to_string());
302 msg.prepare_payload();
313 boost::beast::http::response<boost::beast::http::empty_body> msg;
314 msg.version(request.version());
315 msg.result(boost::beast::http::status::bad_request);
316 msg.reason(
"Bad Request (" + text +
")");
318 msg.insert(
"Remote-Address", remote_address.to_string());
319 msg.insert(boost::beast::http::field::connection,
"close");
320 msg.prepare_payload();
329 XRPL_ASSERT(
work_,
"xrpl::OverlayImpl::connect : work is set");
334 JLOG(
journal_.
info()) <<
"Over resource limit: " << remote_endpoint;
357 list_.emplace(p.get(), p);
373 auto const result =
m_peers.emplace(peer->slot(), peer);
374 XRPL_ASSERT(result.second,
"xrpl::OverlayImpl::add_active : peer is inserted");
380 XRPL_ASSERT(result.second,
"xrpl::OverlayImpl::add_active : peer ID is inserted");
386 JLOG(journal.debug()) <<
"activated";
398 auto const iter =
m_peers.find(slot);
399 XRPL_ASSERT(iter !=
m_peers.end(),
"xrpl::OverlayImpl::remove : valid input");
421 if (bootstrapIps.empty())
424 bootstrapIps.
push_back(
"r.ripple.com 51235");
427 bootstrapIps.
push_back(
"sahyadri.isrdc.in 51235");
430 bootstrapIps.push_back(
"hubs.xrpkuwait.com 51235");
433 bootstrapIps.push_back(
"hub.xrpl-commons.org 51235");
440 for (
auto const& addr : addresses)
442 if (addr.port() == 0)
462 for (
auto& addr : addresses)
464 if (addr.port() == 0)
476 list_.emplace(timer.get(), timer);
503 for (
auto const& pair : stats)
506 item[
"category"] = pair.second.name;
508 item[
"messages_in"] =
std::to_string(pair.second.messagesIn.load());
510 item[
"messages_out"] =
std::to_string(pair.second.messagesOut.load());
530 XRPL_ASSERT(result.second,
"xrpl::OverlayImpl::activate : peer ID is inserted");
534 JLOG(journal.debug()) <<
"activated";
537 XRPL_ASSERT(
size(),
"xrpl::OverlayImpl::activate : nonzero peers");
550 auto const n = m->list_size();
551 auto const& journal = from->pJournal();
553 protocol::TMManifests
relay;
557 auto& s = m->list().Get(i).stobject();
561 auto const serialized = mo->serialized;
567 relay.add_list()->set_stobject(s);
575 "xrpl::OverlayImpl::onManifests : manifest "
576 "deserialization succeeded");
589 JLOG(journal.debug()) <<
"Malformed manifest #" << i + 1 <<
": " <<
strHex(s);
594 if (!
relay.list().empty())
637 pv[jss::public_key] =
base64_encode(sp->getNodePublic().data(), sp->getNodePublic().size());
638 pv[jss::type] = sp->slot()->inbound() ?
"in" :
"out";
639 pv[jss::uptime] =
static_cast<std::uint32_t>(duration_cast<seconds>(sp->uptime()).count());
642 pv[jss::ip] = sp->getRemoteAddress().address().to_string();
643 if (sp->slot()->inbound())
645 if (
auto port = sp->slot()->listening_port())
646 pv[jss::port] = *port;
655 auto version{sp->getVersion()};
656 if (!version.empty())
662 sp->ledgerRange(minSeq, maxSeq);
663 if (minSeq != 0 || maxSeq != 0)
673 bool const humanReadable =
false;
674 bool const admin =
false;
675 bool const counters =
false;
681 server_info.
removeMember(jss::load_factor_fee_escalation);
685 if (server_info.
isMember(jss::validated_ledger))
687 Json::Value& validated_ledger = server_info[jss::validated_ledger];
708 if (validators.
isMember(jss::publisher_lists))
710 Json::Value& publisher_lists = validators[jss::publisher_lists];
712 for (
auto& publisher : publisher_lists)
724 if (validatorSites.
isMember(jss::validator_sites))
726 validators[jss::validator_sites] = std::move(validatorSites[jss::validator_sites]);
750 boost::beast::http::response<json_body> msg;
751 msg.version(req.version());
752 msg.result(boost::beast::http::status::ok);
754 msg.insert(
"Content-Type",
"application/json");
755 msg.insert(
"Connection",
"close");
775 msg.prepare_payload();
792 boost::beast::http::response<json_body> msg;
793 msg.version(req.version());
795 msg.insert(
"Content-Type",
"application/json");
796 msg.insert(
"Connection",
"close");
798 auto fail = [&msg, &handoff](
auto status) {
800 msg.insert(
"Content-Length",
"0");
804 msg.prepare_payload();
811 if (
auto slash = key.
find(
'/'); slash != std::string_view::npos)
813 auto verString = key.
substr(0, slash);
814 if (!boost::conversion::try_lexical_convert(verString, version))
815 return fail(boost::beast::http::status::bad_request);
816 key = key.
substr(slash + 1);
820 return fail(boost::beast::http::status::bad_request);
828 return fail(boost::beast::http::status::not_found);
832 return fail(boost::beast::http::status::bad_request);
836 msg.result(boost::beast::http::status::ok);
840 msg.prepare_payload();
849 if (req.target() !=
"/health")
851 boost::beast::http::response<json_body> msg;
852 msg.version(req.version());
854 msg.insert(
"Content-Type",
"application/json");
855 msg.insert(
"Connection",
"close");
859 int last_validated_ledger_age = -1;
860 if (info.isMember(jss::validated_ledger))
861 last_validated_ledger_age = info[jss::validated_ledger][jss::age].asInt();
862 bool amendment_blocked =
false;
863 if (info.isMember(jss::amendment_blocked))
864 amendment_blocked =
true;
865 int number_peers = info[jss::peers].asInt();
866 std::string server_state = info[jss::server_state].asString();
867 auto load_factor = info[jss::load_factor_server].asDouble() / info[jss::load_base].asDouble();
869 enum { healthy, warning, critical };
870 int health = healthy;
871 auto set_health = [&health](
int state) {
877 if (last_validated_ledger_age >= 7 || last_validated_ledger_age < 0)
879 msg.body()[jss::info][jss::validated_ledger] = last_validated_ledger_age;
880 if (last_validated_ledger_age < 20)
883 set_health(critical);
886 if (amendment_blocked)
888 msg.body()[jss::info][jss::amendment_blocked] =
true;
889 set_health(critical);
892 if (number_peers <= 7)
894 msg.body()[jss::info][jss::peers] = number_peers;
895 if (number_peers != 0)
898 set_health(critical);
901 if (!(server_state ==
"full" || server_state ==
"validating" || server_state ==
"proposing"))
903 msg.body()[jss::info][jss::server_state] = server_state;
904 if (server_state ==
"syncing" || server_state ==
"tracking" || server_state ==
"connected")
909 set_health(critical);
912 if (load_factor > 100)
914 msg.body()[jss::info][jss::load_factor] = load_factor;
915 if (load_factor < 1000)
918 set_health(critical);
924 msg.result(boost::beast::http::status::ok);
927 msg.result(boost::beast::http::status::service_unavailable);
930 msg.result(boost::beast::http::status::internal_server_error);
934 msg.prepare_payload();
967 active =
ids_.size();
968 disabled = enabledInSkip = 0;
973 for (
auto& [
id, w] :
ids_)
975 if (p = w.lock(); p !=
nullptr)
977 bool const reduceRelayEnabled = p->txReduceRelayEnabled();
979 if (!reduceRelayEnabled)
982 if (toSkip.
count(
id) == 0)
984 else if (reduceRelayEnabled)
1002 auto const iter =
ids_.find(
id);
1003 if (iter !=
ids_.end())
1004 return iter->second.lock();
1016 for (
auto const& e :
ids_)
1018 if (peer = e.second.lock(); peer !=
nullptr)
1020 if (peer->getNodePublic() == pubKey)
1041 if (toSkip->find(p->id()) == toSkip->end())
1063 if (toSkip->find(p->id()) == toSkip->end())
1078 protocol::TMManifests
tm;
1084 hr.addSuppression(
manifest.hash());
1089 if (
tm.list_size() != 0)
1104 bool relay = tx.has_value();
1107 auto& txn = tx->
get();
1133 for (
auto const& p : peers)
1134 p->addTxQueue(
hash);
1138 auto& txn = tx->get();
1145 for (
auto const& p : peers)
1155 auto const enabledTarget =
1160 if (enabledTarget > enabledInSkip)
1163 JLOG(
journal_.
trace()) <<
"relaying tx, total peers " << peers.
size() <<
" selected " << enabledTarget <<
" skip "
1164 << toSkip.
size() <<
" disabled " << disabled;
1168 for (
auto const& p : peers)
1171 if (!p->txReduceRelayEnabled())
1175 else if (enabledAndRelayed < enabledTarget)
1177 enabledAndRelayed++;
1182 p->addTxQueue(
hash);
1193 list_.erase(&child);
1217 for (
auto const& element :
list_)
1223 for (
auto const& child : children)
1225 if (child !=
nullptr)
1234 for (
auto addr : result)
1241 auto const result =
m_peerFinder->buildEndpointsForPeers();
1242 for (
auto const& e : result)
1247 auto const iter =
m_peers.find(e.first);
1249 peer = iter->second.lock();
1252 peer->sendEndpoints(e.second.begin(), e.second.end());
1260 if (p->txReduceRelayEnabled())
1268 protocol::TMSquelch m;
1270 m.set_validatorpubkey(validator.data(), validator.size());
1272 m.set_squelchduration(squelchDuration);
1301 protocol::MessageType type)
1303 if (!
slots_.baseSquelchReady())
1306 if (!
strand_.running_in_this_thread())
1310 [
this, key = key, validator = validator, peers = std::move(peers), type]()
mutable {
1314 for (
auto id : peers)
1315 slots_.updateSlotAndSquelch(
1324 protocol::MessageType type)
1326 if (!
slots_.baseSquelchReady())
1329 if (!
strand_.running_in_this_thread())
1333 [
this, key = key, validator = validator, peer, type]() {
1337 slots_.updateSlotAndSquelch(
1344 if (!
strand_.running_in_this_thread())
1347 slots_.deletePeer(
id,
true);
1353 if (!
strand_.running_in_this_thread())
1356 slots_.deleteIdlePeers();
1367 auto const& section = config.
section(
"overlay");
1372 Throw<std::runtime_error>(
"Configured IP limit is invalid");
1375 set(ip,
"public_ip", section);
1378 boost::system::error_code ec;
1379 setup.
public_ip = boost::asio::ip::make_address(ip, ec);
1381 Throw<std::runtime_error>(
"Configured public IP is invalid");
1386 auto const& section = config.
section(
"crawl");
1387 auto const& values = section.
values();
1389 if (values.size() > 1)
1391 Throw<std::runtime_error>(
"Configured [crawl] section is invalid, too many values");
1394 bool crawlEnabled =
true;
1397 if (values.size() == 1)
1401 crawlEnabled = boost::lexical_cast<bool>(values.front());
1403 catch (boost::bad_lexical_cast
const&)
1405 Throw<std::runtime_error>(
"Configured [crawl] section has invalid value: " + values.front());
1411 if (get<bool>(section,
"overlay",
true))
1415 if (get<bool>(section,
"server",
true))
1419 if (get<bool>(section,
"counts",
false))
1423 if (get<bool>(section,
"unl",
true))
1430 auto const& section = config.
section(
"vl");
1437 auto id = config.
legacy(
"network_id");
1444 if (
id ==
"testnet")
1450 setup.
networkID = beast::lexicalCastThrow<std::uint32_t>(
id);
1455 Throw<std::runtime_error>(
1456 "Configured [network_id] section is invalid: must be a number "
1457 "or one of the strings 'main', 'testnet' or 'devnet'.");
1470 boost::asio::io_context& io_context,
1475 app, setup, serverHandler, resourceManager, resolver, io_context, config, collector);
Value & append(Value const &value)
Append value to array at the end.
Value removeMember(char const *key)
Remove and return the named member.
bool isMember(char const *key) const
Return true if the object has a member named key.
A version-independent IP address and port combination.
A generic endpoint for log messages.
Sink & sink() const
Returns the Sink associated with this Journal.
Stream trace() const
Severity stream access functions.
std::string const & name() const
Returns the name of this source.
void add(Source &source)
Add a child source.
Wraps a Journal::Sink to prefix its output with a string.
virtual Config & config()=0
virtual beast::Journal journal(std::string const &name)=0
virtual DatabaseCon & getWalletDB()=0
Retrieve the "wallet database".
virtual std::optional< PublicKey const > getValidationPublicKey() const =0
Holds unparsed configuration information.
void legacy(std::string const §ion, std::string value)
Set a value that is not a key/value pair.
Section & section(std::string const &name)
Returns the section with the given name.
std::optional< std::string > member(PublicKey const &node) const
Determines whether a node belongs in the cluster.
bool TX_REDUCE_RELAY_ENABLE
std::vector< std::string > IPS
std::size_t TX_RELAY_PERCENTAGE
bool TX_REDUCE_RELAY_METRICS
std::vector< std::string > IPS_FIXED
std::size_t TX_REDUCE_RELAY_MIN_PEERS
LockedSociSession checkoutDb()
std::optional< std::set< PeerShortID > > shouldRelay(uint256 const &key)
Determines whether the hashed item should be relayed.
virtual void pubManifest(Manifest const &)=0
void for_each_manifest(Function &&f) const
Invokes the callback once for every populated manifest.
ManifestDisposition applyManifest(Manifest m)
Add manifest to cache.
std::uint32_t sequence() const
A monotonically increasing number used to detect new manifests.
virtual Json::Value getServerInfo(bool human, bool admin, bool counters)=0
Child(OverlayImpl &overlay)
void deletePeer(Peer::id_t id)
Called when the peer is deleted.
void remove(std::shared_ptr< PeerFinder::Slot > const &slot)
std::weak_ptr< Timer > timer_
boost::asio::io_context & io_context_
bool processRequest(http_request_type const &req, Handoff &handoff)
Handles non-peer protocol requests.
OverlayImpl(Application &app, Setup const &setup, ServerHandler &serverHandler, Resource::Manager &resourceManager, Resolver &resolver, boost::asio::io_context &io_context, BasicConfig const &config, beast::insight::Collector::ptr const &collector)
boost::asio::ip::address address_type
static bool isPeerUpgrade(http_request_type const &request)
Resource::Manager & m_resourceManager
boost::system::error_code error_code
bool processCrawl(http_request_type const &req, Handoff &handoff)
Handles crawl requests.
bool processHealth(http_request_type const &req, Handoff &handoff)
Handles health requests.
Json::Value getServerCounts()
Returns information about the local server's performance counters.
void activate(std::shared_ptr< PeerImp > const &peer)
Called when a peer has connected successfully This is called after the peer handshake has been comple...
Handoff onHandoff(std::unique_ptr< stream_type > &&bundle, http_request_type &&request, endpoint_type remote_endpoint) override
Conditionally accept an incoming HTTP request.
std::optional< boost::asio::executor_work_guard< boost::asio::io_context::executor_type > > work_
void reportOutboundTraffic(TrafficCount::category cat, int bytes)
void for_each(UnaryFunc &&f) const
void connect(beast::IP::Endpoint const &remote_endpoint) override
Establish a peer connection to the specified endpoint.
std::size_t size() const override
The number of active peers on the network Active peers are only those peers that have completed the h...
ServerHandler & serverHandler_
void onManifests(std::shared_ptr< protocol::TMManifests > const &m, std::shared_ptr< PeerImp > const &from)
void broadcast(protocol::TMProposeSet &m) override
Broadcast a proposal.
std::shared_ptr< Writer > makeErrorResponse(std::shared_ptr< PeerFinder::Slot > const &slot, http_request_type const &request, address_type remote_address, std::string msg)
reduce_relay::Slots< UptimeClock > slots_
hash_map< Peer::id_t, std::weak_ptr< PeerImp > > ids_
void deleteIdlePeers()
Check if peers stopped relaying messages and if slots stopped receiving messages from the validator.
void squelch(PublicKey const &validator, Peer::id_t const id, std::uint32_t squelchDuration) const override
Squelch handler.
void sendTxQueue()
Send once a second transactions' hashes aggregated by peers.
std::shared_ptr< Message > manifestMessage_
std::unique_ptr< PeerFinder::Manager > m_peerFinder
std::optional< std::uint32_t > manifestListSeq_
void onWrite(beast::PropertyStream::Map &stream) override
Subclass override.
void add_active(std::shared_ptr< PeerImp > const &peer)
PeerFinder::Manager & peerFinder()
std::recursive_mutex mutex_
Resource::Manager & resourceManager()
beast::Journal const journal_
boost::asio::ip::tcp::endpoint endpoint_type
void onPeerDeactivate(Peer::id_t id)
boost::asio::strand< boost::asio::io_context::executor_type > strand_
Json::Value json() override
Return diagnostics on the status of all peers.
static std::string makePrefix(std::uint32_t id)
Setup const & setup() const
std::set< Peer::id_t > relay(protocol::TMProposeSet &m, uint256 const &uid, PublicKey const &validator) override
Relay a proposal.
static bool is_upgrade(boost::beast::http::header< true, Fields > const &req)
metrics::TxMetrics txMetrics_
boost::container::flat_map< Child *, std::weak_ptr< Child > > list_
int limit() override
Returns the maximum number of peers we are configured to allow.
std::condition_variable_any cond_
hash_map< std::shared_ptr< PeerFinder::Slot >, std::weak_ptr< PeerImp > > m_peers
std::shared_ptr< Message > getManifestsMessage()
Json::Value getUnlInfo()
Returns information about the local server's UNL.
std::shared_ptr< Peer > findPeerByPublicKey(PublicKey const &pubKey) override
Returns the peer with the matching public key, or null.
std::shared_ptr< Writer > makeRedirectResponse(std::shared_ptr< PeerFinder::Slot > const &slot, http_request_type const &request, address_type remote_address)
std::atomic< Peer::id_t > next_id_
void reportInboundTraffic(TrafficCount::category cat, int bytes)
bool processValidatorList(http_request_type const &req, Handoff &handoff)
Handles validator list requests.
void checkTracking(std::uint32_t) override
Calls the checkTracking function on each peer.
Json::Value getServerInfo()
Returns information about the local server.
void updateSlotAndSquelch(uint256 const &key, PublicKey const &validator, std::set< Peer::id_t > &&peers, protocol::MessageType type)
Updates message count for validator/peer.
std::shared_ptr< Peer > findPeerByShortID(Peer::id_t const &id) const override
Returns the peer with the matching short id, or null.
PeerSequence getActivePeers() const override
Returns a sequence representing the current list of peers.
Json::Value getOverlayInfo()
Returns information about peers on the overlay network.
void unsquelch(PublicKey const &validator, Peer::id_t id) const override
Unsquelch handler.
Manages the set of connected peers.
virtual std::pair< std::shared_ptr< Slot >, Result > new_outbound_slot(beast::IP::Endpoint const &remote_endpoint)=0
Create a new outbound slot with the specified remote endpoint.
bool contains(PublicKey const &nodeId)
void resolve(std::vector< std::string > const &names, Handler handler)
resolve all hostnames on the list
Tracks load and resource consumption.
virtual Consumer newOutboundEndpoint(beast::IP::Endpoint const &address)=0
Create a new endpoint keyed by outbound IP address and port.
virtual Consumer newInboundEndpoint(beast::IP::Endpoint const &address)=0
Create a new endpoint keyed by inbound IP address or the forwarded IP if proxied.
std::vector< std::string > const & values() const
Returns all the values in the section.
void setup(Setup const &setup, beast::Journal journal)
virtual ValidatorList & validators()=0
virtual NetworkOPs & getOPs()=0
virtual PeerReservationTable & peerReservations()=0
virtual Cluster & cluster()=0
virtual HashRouter & getHashRouter()=0
virtual ValidatorSite & validatorSites()=0
virtual ManifestCache & validatorManifests()=0
void addCount(category cat, bool inbound, int bytes)
Account for traffic associated with the given category.
auto const & getCounts() const
An up-to-date copy of all the counters.
Json::Value getJson() const
Return a JSON representation of the state of the validator list.
std::optional< Json::Value > getAvailable(std::string_view pubKey, std::optional< std::uint32_t > forceVersion={})
Returns the current valid list for the given publisher key, if available, as a Json object.
bool listed(PublicKey const &identity) const
Returns true if public key is included on any lists.
Json::Value getJson() const
Return JSON representation of configured validator sites.
T emplace_back(T... args)
@ arrayValue
array value (ordered list)
@ objectValue
object value (collection of name/value pairs).
bool is_private(Address const &addr)
Returns true if the address is a private unroutable address.
Result split_commas(FwdIt first, FwdIt last)
bool is_keep_alive(boost::beast::http::message< isRequest, Body, Fields > const &m)
std::string const & getFullVersionString()
Full server version string.
@ checkIdlePeers
How often we check for idle peers (seconds)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::vector< ProtocolVersion > parseProtocolVersions(boost::beast::string_view const &value)
Parse a set of protocol versions.
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::optional< uint256 > makeSharedValue(stream_type &ssl, beast::Journal journal)
Computes a shared value based on the SSL connection state.
Stopwatch & stopwatch()
Returns an instance of a wall clock.
std::string to_string(base_uint< Bits, Tag > const &a)
std::string strHex(FwdIt begin, FwdIt end)
std::optional< ProtocolVersion > negotiateProtocolVersion(std::vector< ProtocolVersion > const &versions)
Given a list of supported protocol versions, choose the one we prefer.
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
std::shared_ptr< boost::asio::ssl::context > make_SSLContext(std::string const &cipherList)
Create a self-signed SSL context that allows anonymous Diffie Hellman.
void addValidatorManifest(soci::session &session, std::string const &serialized)
addValidatorManifest Saves the manifest of a validator to the database.
std::string base64_encode(std::uint8_t const *data, std::size_t len)
Json::Value getCountsJson(Application &app, int minObjectCount)
std::optional< Manifest > deserializeManifest(Slice s, beast::Journal journal)
Constructs Manifest from serialized string.
beast::xor_shift_engine & default_prng()
Return the default random engine.
constexpr Number squelch(Number const &x, Number const &limit) noexcept
std::shared_ptr< Message > makeSquelchMessage(PublicKey const &validator, bool squelch, uint32_t squelchDuration)
Overlay::Setup setup_Overlay(BasicConfig const &config)
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
PublicKey verifyHandshake(boost::beast::http::fields const &headers, xrpl::uint256 const &sharedValue, std::optional< std::uint32_t > networkID, beast::IP::Address public_ip, beast::IP::Address remote, Application &app)
Validate header fields necessary for upgrading the link to the peer protocol.
bool isPseudoTx(STObject const &tx)
Check whether a transaction is a pseudo-transaction.
std::unique_ptr< Overlay > make_Overlay(Application &app, Overlay::Setup const &setup, ServerHandler &serverHandler, Resource::Manager &resourceManager, Resolver &resolver, boost::asio::io_context &io_context, BasicConfig const &config, beast::insight::Collector::ptr const &collector)
Creates the implementation of Overlay.
@ accepted
Manifest is valid.
static boost::asio::ip::tcp::endpoint to_asio_endpoint(IP::Endpoint const &address)
static IP::Endpoint from_asio(boost::asio::ip::address const &address)
Used to indicate the result of a server connection handoff.
std::shared_ptr< Writer > response
void on_timer(error_code ec)
Timer(OverlayImpl &overlay)
std::uint32_t crawlOptions
std::optional< std::uint32_t > networkID
std::shared_ptr< boost::asio::ssl::context > context
beast::IP::Address public_ip
PeerFinder configuration settings.
static Config makeConfig(xrpl::Config const &config, std::uint16_t port, bool validationPublicKey, int ipLimit)
Make PeerFinder::Config from configuration parameters.
void addMetrics(protocol::MessageType type, std::uint32_t val)
Add protocol message metrics.