20#include <xrpld/app/misc/HashRouter.h>
21#include <xrpld/app/misc/NetworkOPs.h>
22#include <xrpld/app/misc/ValidatorList.h>
23#include <xrpld/app/misc/ValidatorSite.h>
24#include <xrpld/app/rdb/RelationalDatabase.h>
25#include <xrpld/app/rdb/Wallet.h>
26#include <xrpld/overlay/Cluster.h>
27#include <xrpld/overlay/detail/ConnectAttempt.h>
28#include <xrpld/overlay/detail/PeerImp.h>
29#include <xrpld/overlay/detail/Tuning.h>
30#include <xrpld/overlay/predicates.h>
31#include <xrpld/peerfinder/make_Manager.h>
32#include <xrpld/rpc/handlers/GetCounts.h>
33#include <xrpld/rpc/json_body.h>
35#include <xrpl/basics/base64.h>
36#include <xrpl/basics/make_SSLContext.h>
37#include <xrpl/basics/random.h>
38#include <xrpl/beast/core/LexicalCast.h>
39#include <xrpl/protocol/STTx.h>
40#include <xrpl/server/SimpleWriter.h>
42#include <boost/algorithm/string/predicate.hpp>
44#include "xrpld/overlay/detail/TrafficCount.h"
48namespace CrawlOptions {
66 overlay_.remove(*
this);
98 if (ec && ec != boost::asio::error::operation_aborted)
100 JLOG(overlay_.journal_.error()) <<
"on_timer: " << ec.message();
105 overlay_.m_peerFinder->once_per_second();
106 overlay_.sendEndpoints();
107 overlay_.autoConnect();
108 if (overlay_.app_.config().TX_REDUCE_RELAY_ENABLE)
109 overlay_.sendTxQueue();
112 overlay_.deleteIdlePeers();
125 boost::asio::io_service& io_service,
139 app_.journal(
"PeerFinder"),
145 ,
slots_(app.logs(), *this, app.config())
149 [counts =
m_traffic.getCounts(), collector]() {
152 for (
auto const& pair : counts)
178 handoff.
moved =
true;
180 JLOG(journal.
debug()) <<
"Peer connection upgrade from " << remote_endpoint;
183 auto const local_endpoint(
184 stream_ptr->next_layer().socket().local_endpoint(ec));
187 JLOG(journal.
debug()) << remote_endpoint <<
" failed: " << ec.message();
193 if (consumer.disconnect(journal))
203 handoff.
moved =
false;
212 return boost::iequals(s,
"peer");
215 handoff.
moved =
false;
224 if (!negotiatedVersion)
227 handoff.
moved =
false;
231 remote_endpoint.address(),
232 "Unable to agree on a protocol version");
241 handoff.
moved =
false;
245 remote_endpoint.address(),
246 "Incorrect security cookie");
258 remote_endpoint.address(),
264 bool const reserved =
269 if (result != PeerFinder::Result::success)
272 JLOG(journal.
debug())
273 <<
"Peer " << remote_endpoint <<
" redirected, slots full";
274 handoff.
moved =
false;
276 slot, request, remote_endpoint.address());
282 auto const peer = std::make_shared<PeerImp>(
290 std::move(stream_ptr),
298 auto const result =
m_peers.emplace(peer->slot(), peer);
301 "ripple::OverlayImpl::onHandoff : peer is inserted");
304 list_.emplace(peer.get(), peer);
308 handoff.
moved =
true;
313 JLOG(journal.
debug()) <<
"Peer " << remote_endpoint
314 <<
" fails handshake (" << e.
what() <<
")";
317 handoff.
moved =
false;
319 slot, request, remote_endpoint.address(), e.
what());
333 return !versions.empty();
350 boost::beast::http::response<json_body> msg;
351 msg.version(request.version());
352 msg.result(boost::beast::http::status::service_unavailable);
356 ostr << remote_address;
357 msg.insert(
"Remote-Address", ostr.
str());
359 msg.insert(
"Content-Type",
"application/json");
360 msg.insert(boost::beast::http::field::connection,
"close");
365 ips.
append(_.address.to_string());
367 msg.prepare_payload();
368 return std::make_shared<SimpleWriter>(msg);
378 boost::beast::http::response<boost::beast::http::empty_body> msg;
379 msg.version(request.version());
380 msg.result(boost::beast::http::status::bad_request);
381 msg.reason(
"Bad Request (" + text +
")");
383 msg.insert(
"Remote-Address", remote_address.to_string());
384 msg.insert(boost::beast::http::field::connection,
"close");
385 msg.prepare_payload();
386 return std::make_shared<SimpleWriter>(msg);
394 XRPL_ASSERT(
work_,
"ripple::OverlayImpl::connect : work is set");
399 JLOG(
journal_.
info()) <<
"Over resource limit: " << remote_endpoint;
406 JLOG(
journal_.
debug()) <<
"Connect: No slot for " << remote_endpoint;
410 auto const p = std::make_shared<ConnectAttempt>(
422 list_.emplace(p.get(), p);
435 auto const result =
m_peers.emplace(peer->slot(), peer);
438 "ripple::OverlayImpl::add_active : peer is inserted");
443 auto const result =
ids_.emplace(
449 "ripple::OverlayImpl::add_active : peer ID is inserted");
455 JLOG(
journal_.
debug()) <<
"activated " << peer->getRemoteAddress() <<
" ("
471 auto const iter =
m_peers.find(slot);
473 iter !=
m_peers.end(),
"ripple::OverlayImpl::remove : valid input");
496 if (bootstrapIps.empty())
499 bootstrapIps.
push_back(
"r.ripple.com 51235");
502 bootstrapIps.
push_back(
"sahyadri.isrdc.in 51235");
505 bootstrapIps.push_back(
"hubs.xrpkuwait.com 51235");
508 bootstrapIps.push_back(
"hub.xrpl-commons.org 51235");
518 for (
auto const& addr : addresses)
520 if (addr.port() == 0)
542 for (
auto& addr : addresses)
544 if (addr.port() == 0)
554 auto const timer = std::make_shared<Timer>(*
this);
556 list_.emplace(timer.get(), timer);
583 for (
auto const& pair : stats)
586 item[
"category"] = pair.second.name;
588 item[
"messages_in"] =
std::to_string(pair.second.messagesIn.load());
590 item[
"messages_out"] =
std::to_string(pair.second.messagesOut.load());
606 auto const result(
ids_.emplace(
612 "ripple::OverlayImpl::activate : peer ID is inserted");
616 JLOG(
journal_.
debug()) <<
"activated " << peer->getRemoteAddress() <<
" ("
623 XRPL_ASSERT(
size(),
"ripple::OverlayImpl::activate : nonzero peers");
638 auto const n = m->list_size();
639 auto const& journal = from->pjournal();
641 protocol::TMManifests
relay;
645 auto& s = m->list().Get(i).stobject();
649 auto const serialized = mo->serialized;
656 relay.add_list()->set_stobject(s);
664 "ripple::OverlayImpl::onManifests : manifest "
665 "deserialization succeeded");
678 JLOG(journal.debug())
679 <<
"Malformed manifest #" << i + 1 <<
": " <<
strHex(s);
684 if (!
relay.list().empty())
685 for_each([m2 = std::make_shared<Message>(
relay, protocol::mtMANIFESTS)](
727 sp->getNodePublic().data(), sp->getNodePublic().size());
728 pv[jss::type] = sp->slot()->inbound() ?
"in" :
"out";
730 duration_cast<seconds>(sp->uptime()).count());
733 pv[jss::ip] = sp->getRemoteAddress().address().to_string();
734 if (sp->slot()->inbound())
736 if (
auto port = sp->slot()->listening_port())
737 pv[jss::port] = *port;
746 auto version{sp->getVersion()};
747 if (!version.empty())
753 sp->ledgerRange(minSeq, maxSeq);
754 if (minSeq != 0 || maxSeq != 0)
755 pv[jss::complete_ledgers] =
765 bool const humanReadable =
false;
766 bool const admin =
false;
767 bool const counters =
false;
774 server_info.
removeMember(jss::load_factor_fee_escalation);
778 if (server_info.
isMember(jss::validated_ledger))
780 Json::Value& validated_ledger = server_info[jss::validated_ledger];
801 if (validators.
isMember(jss::publisher_lists))
803 Json::Value& publisher_lists = validators[jss::publisher_lists];
805 for (
auto& publisher : publisher_lists)
817 if (validatorSites.
isMember(jss::validator_sites))
819 validators[jss::validator_sites] =
820 std::move(validatorSites[jss::validator_sites]);
841 if (req.target() !=
"/crawl" ||
845 boost::beast::http::response<json_body> msg;
846 msg.version(req.version());
847 msg.result(boost::beast::http::status::ok);
849 msg.insert(
"Content-Type",
"application/json");
850 msg.insert(
"Connection",
"close");
870 msg.prepare_payload();
871 handoff.
response = std::make_shared<SimpleWriter>(msg);
889 boost::beast::http::response<json_body> msg;
890 msg.version(req.version());
892 msg.insert(
"Content-Type",
"application/json");
893 msg.insert(
"Connection",
"close");
895 auto fail = [&msg, &handoff](
auto status) {
897 msg.insert(
"Content-Length",
"0");
901 msg.prepare_payload();
902 handoff.
response = std::make_shared<SimpleWriter>(msg);
908 if (
auto slash = key.
find(
'/'); slash != std::string_view::npos)
910 auto verString = key.
substr(0, slash);
911 if (!boost::conversion::try_lexical_convert(verString, version))
912 return fail(boost::beast::http::status::bad_request);
913 key = key.
substr(slash + 1);
917 return fail(boost::beast::http::status::bad_request);
925 return fail(boost::beast::http::status::not_found);
929 return fail(boost::beast::http::status::bad_request);
933 msg.result(boost::beast::http::status::ok);
937 msg.prepare_payload();
938 handoff.
response = std::make_shared<SimpleWriter>(msg);
946 if (req.target() !=
"/health")
948 boost::beast::http::response<json_body> msg;
949 msg.version(req.version());
951 msg.insert(
"Content-Type",
"application/json");
952 msg.insert(
"Connection",
"close");
956 int last_validated_ledger_age = -1;
957 if (info.isMember(jss::validated_ledger))
958 last_validated_ledger_age =
959 info[jss::validated_ledger][jss::age].asInt();
960 bool amendment_blocked =
false;
961 if (info.isMember(jss::amendment_blocked))
962 amendment_blocked =
true;
963 int number_peers = info[jss::peers].asInt();
964 std::string server_state = info[jss::server_state].asString();
965 auto load_factor = info[jss::load_factor_server].asDouble() /
966 info[jss::load_base].asDouble();
968 enum { healthy, warning, critical };
969 int health = healthy;
970 auto set_health = [&health](
int state) {
976 if (last_validated_ledger_age >= 7 || last_validated_ledger_age < 0)
978 msg.body()[jss::info][jss::validated_ledger] =
979 last_validated_ledger_age;
980 if (last_validated_ledger_age < 20)
983 set_health(critical);
986 if (amendment_blocked)
988 msg.body()[jss::info][jss::amendment_blocked] =
true;
989 set_health(critical);
992 if (number_peers <= 7)
994 msg.body()[jss::info][jss::peers] = number_peers;
995 if (number_peers != 0)
998 set_health(critical);
1001 if (!(server_state ==
"full" || server_state ==
"validating" ||
1002 server_state ==
"proposing"))
1004 msg.body()[jss::info][jss::server_state] = server_state;
1005 if (server_state ==
"syncing" || server_state ==
"tracking" ||
1006 server_state ==
"connected")
1008 set_health(warning);
1011 set_health(critical);
1014 if (load_factor > 100)
1016 msg.body()[jss::info][jss::load_factor] = load_factor;
1017 if (load_factor < 1000)
1018 set_health(warning);
1020 set_health(critical);
1026 msg.result(boost::beast::http::status::ok);
1029 msg.result(boost::beast::http::status::service_unavailable);
1032 msg.result(boost::beast::http::status::internal_server_error);
1036 msg.prepare_payload();
1037 handoff.
response = std::make_shared<SimpleWriter>(msg);
1072 active =
ids_.size();
1073 disabled = enabledInSkip = 0;
1078 for (
auto& [
id, w] :
ids_)
1080 if (p = w.lock(); p !=
nullptr)
1082 bool const reduceRelayEnabled = p->txReduceRelayEnabled();
1084 if (!reduceRelayEnabled)
1087 if (toSkip.
count(
id) == 0)
1089 else if (reduceRelayEnabled)
1108 auto const iter =
ids_.find(
id);
1109 if (iter !=
ids_.end())
1110 return iter->second.lock();
1122 for (
auto const& e :
ids_)
1124 if (peer = e.second.lock(); peer !=
nullptr)
1126 if (peer->getNodePublic() == pubKey)
1136 auto const sm = std::make_shared<Message>(m, protocol::mtPROPOSE_LEDGER);
1142 protocol::TMProposeSet& m,
1149 std::make_shared<Message>(m, protocol::mtPROPOSE_LEDGER, validator);
1151 if (toSkip->find(p->id()) == toSkip->end())
1162 auto const sm = std::make_shared<Message>(m, protocol::mtVALIDATION);
1168 protocol::TMValidation& m,
1175 std::make_shared<Message>(m, protocol::mtVALIDATION, validator);
1177 if (toSkip->find(p->id()) == toSkip->end())
1193 protocol::TMManifests
tm;
1198 tm.add_list()->set_stobject(
1200 hr.addSuppression(
manifest.hash());
1205 if (
tm.list_size() != 0)
1207 std::make_shared<Message>(
tm, protocol::mtMANIFESTS);
1221 bool relay = tx.has_value();
1224 auto& txn = tx->get();
1241 <<
"not relaying tx, total peers " << peers.
size();
1242 for (
auto const& p : peers)
1243 p->addTxQueue(
hash);
1247 auto& txn = tx->get();
1248 auto const sm = std::make_shared<Message>(txn, protocol::mtTRANSACTION);
1254 for (
auto const& p : peers)
1270 if (enabledTarget > enabledInSkip)
1274 <<
" selected " << enabledTarget <<
" skip "
1275 << toSkip.
size() <<
" disabled " << disabled;
1279 for (
auto const& p : peers)
1282 if (!p->txReduceRelayEnabled())
1286 else if (enabledAndRelayed < enabledTarget)
1288 enabledAndRelayed++;
1293 p->addTxQueue(
hash);
1304 list_.erase(&child);
1325 work_ = std::nullopt;
1328 for (
auto const& element :
list_)
1334 for (
auto const& child : children)
1336 if (child !=
nullptr)
1345 for (
auto addr : result)
1352 auto const result =
m_peerFinder->buildEndpointsForPeers();
1353 for (
auto const& e : result)
1358 auto const iter =
m_peers.find(e.first);
1360 peer = iter->second.lock();
1363 peer->sendEndpoints(e.second.begin(), e.second.end());
1371 if (p->txReduceRelayEnabled())
1382 protocol::TMSquelch m;
1384 m.set_validatorpubkey(validator.data(), validator.size());
1386 m.set_squelchduration(squelchDuration);
1387 return std::make_shared<Message>(m, protocol::mtSQUELCH);
1418 protocol::MessageType type)
1420 if (!
slots_.baseSquelchReady())
1423 if (!
strand_.running_in_this_thread())
1426 [
this, key, validator, peers = std::move(peers), type]()
mutable {
1430 for (
auto id : peers)
1431 slots_.updateSlotAndSquelch(key, validator,
id, type, [&]() {
1441 protocol::MessageType type)
1443 if (!
slots_.baseSquelchReady())
1446 if (!
strand_.running_in_this_thread())
1447 return post(
strand_, [
this, key, validator, peer, type]() {
1451 slots_.updateSlotAndSquelch(key, validator, peer, type, [&]() {
1459 if (!
strand_.running_in_this_thread())
1462 slots_.deletePeer(
id,
true);
1468 if (!
strand_.running_in_this_thread())
1471 slots_.deleteIdlePeers();
1482 auto const& section = config.
section(
"overlay");
1487 Throw<std::runtime_error>(
"Configured IP limit is invalid");
1490 set(ip,
"public_ip", section);
1493 boost::system::error_code ec;
1494 setup.
public_ip = beast::IP::Address::from_string(ip, ec);
1496 Throw<std::runtime_error>(
"Configured public IP is invalid");
1501 auto const& section = config.
section(
"crawl");
1502 auto const& values = section.
values();
1504 if (values.size() > 1)
1506 Throw<std::runtime_error>(
1507 "Configured [crawl] section is invalid, too many values");
1510 bool crawlEnabled =
true;
1513 if (values.size() == 1)
1517 crawlEnabled = boost::lexical_cast<bool>(values.front());
1519 catch (boost::bad_lexical_cast
const&)
1521 Throw<std::runtime_error>(
1522 "Configured [crawl] section has invalid value: " +
1529 if (get<bool>(section,
"overlay",
true))
1533 if (get<bool>(section,
"server",
true))
1537 if (get<bool>(section,
"counts",
false))
1541 if (get<bool>(section,
"unl",
true))
1548 auto const& section = config.
section(
"vl");
1555 auto id = config.
legacy(
"network_id");
1562 if (
id ==
"testnet")
1568 setup.
networkID = beast::lexicalCastThrow<std::uint32_t>(
id);
1573 Throw<std::runtime_error>(
1574 "Configured [network_id] section is invalid: must be a number "
1575 "or one of the strings 'main', 'testnet' or 'devnet'.");
1588 boost::asio::io_service& io_service,
1592 return std::make_unique<OverlayImpl>(
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.
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 ValidatorSite & validatorSites()=0
virtual DatabaseCon & getWalletDB()=0
Retrieve the "wallet database".
virtual NetworkOPs & getOPs()=0
virtual ValidatorList & validators()=0
virtual std::optional< PublicKey const > getValidationPublicKey() const =0
virtual ManifestCache & validatorManifests()=0
virtual PeerReservationTable & peerReservations()=0
virtual Cluster & cluster()=0
virtual HashRouter & getHashRouter()=0
Holds unparsed configuration information.
Section & section(std::string const &name)
Returns the section with the given name.
void legacy(std::string const §ion, std::string value)
Set a value that is not a key/value pair.
std::optional< std::string > member(PublicKey const &node) const
Determines whether a node belongs in the cluster.
std::vector< std::string > IPS_FIXED
std::vector< std::string > IPS
std::size_t TX_REDUCE_RELAY_MIN_PEERS
bool TX_REDUCE_RELAY_ENABLE
bool TX_REDUCE_RELAY_METRICS
std::size_t TX_RELAY_PERCENTAGE
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
std::uint32_t sequence() const
A monotonically increasing number used to detect new manifests.
void for_each_manifest(Function &&f) const
Invokes the callback once for every populated manifest.
ManifestDisposition applyManifest(Manifest m)
Add manifest to cache.
virtual Json::Value getServerInfo(bool human, bool admin, bool counters)=0
Child(OverlayImpl &overlay)
boost::system::error_code error_code
Json::Value getUnlInfo()
Returns information about the local server's UNL.
static std::string makePrefix(std::uint32_t id)
PeerFinder::Manager & peerFinder()
boost::asio::ip::tcp::endpoint endpoint_type
bool processHealth(http_request_type const &req, Handoff &handoff)
Handles health requests.
boost::asio::ip::address address_type
static bool is_upgrade(boost::beast::http::header< true, Fields > const &req)
std::condition_variable_any cond_
void onWrite(beast::PropertyStream::Map &stream) override
Subclass override.
void deleteIdlePeers()
Check if peers stopped relaying messages and if slots stopped receiving messages from the validator.
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...
PeerSequence getActivePeers() const override
Returns a sequence representing the current list of peers.
hash_map< std::shared_ptr< PeerFinder::Slot >, std::weak_ptr< PeerImp > > m_peers
void add_active(std::shared_ptr< PeerImp > const &peer)
std::shared_ptr< Peer > findPeerByPublicKey(PublicKey const &pubKey) override
Returns the peer with the matching public key, or null.
Resource::Manager & m_resourceManager
std::shared_ptr< Message > manifestMessage_
std::optional< std::uint32_t > manifestListSeq_
void squelch(PublicKey const &validator, Peer::id_t const id, std::uint32_t squelchDuration) const override
Squelch handler.
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_
void deletePeer(Peer::id_t id)
Called when the peer is deleted.
std::shared_ptr< Peer > findPeerByShortID(Peer::id_t const &id) const override
Returns the peer with the matching short id, or null.
std::atomic< Peer::id_t > next_id_
boost::asio::io_service & io_service_
std::weak_ptr< Timer > timer_
metrics::TxMetrics txMetrics_
void broadcast(protocol::TMProposeSet &m) override
Broadcast a proposal.
void onPeerDeactivate(Peer::id_t id)
bool processRequest(http_request_type const &req, Handoff &handoff)
Handles non-peer protocol requests.
std::recursive_mutex mutex_
void remove(std::shared_ptr< PeerFinder::Slot > const &slot)
void sendTxQueue()
Send once a second transactions' hashes aggregated by peers.
void reportOutboundTraffic(TrafficCount::category cat, int bytes)
std::set< Peer::id_t > relay(protocol::TMProposeSet &m, uint256 const &uid, PublicKey const &validator) override
Relay a proposal.
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...
void unsquelch(PublicKey const &validator, Peer::id_t id) const override
Unsquelch handler.
std::shared_ptr< Writer > makeRedirectResponse(std::shared_ptr< PeerFinder::Slot > const &slot, http_request_type const &request, address_type remote_address)
void for_each(UnaryFunc &&f) const
std::optional< boost::asio::io_service::work > work_
Json::Value getOverlayInfo()
Returns information about peers on the overlay network.
Resource::Manager & resourceManager()
static bool isPeerUpgrade(http_request_type const &request)
Json::Value getServerCounts()
Returns information about the local server's performance counters.
void reportInboundTraffic(TrafficCount::category cat, int bytes)
boost::asio::io_service::strand strand_
void onManifests(std::shared_ptr< protocol::TMManifests > const &m, std::shared_ptr< PeerImp > const &from)
std::unique_ptr< PeerFinder::Manager > m_peerFinder
void connect(beast::IP::Endpoint const &remote_endpoint) override
Establish a peer connection to the specified endpoint.
Handoff onHandoff(std::unique_ptr< stream_type > &&bundle, http_request_type &&request, endpoint_type remote_endpoint) override
Conditionally accept an incoming HTTP request.
Setup const & setup() const
std::shared_ptr< Message > getManifestsMessage()
hash_map< Peer::id_t, std::weak_ptr< PeerImp > > ids_
Json::Value getServerInfo()
Returns information about the local server.
bool processValidatorList(http_request_type const &req, Handoff &handoff)
Handles validator list requests.
Json::Value json() override
Return diagnostics on the status of all peers.
void checkTracking(std::uint32_t) override
Calls the checkTracking function on each peer.
ServerHandler & serverHandler_
bool processCrawl(http_request_type const &req, Handoff &handoff)
Handles crawl requests.
int limit() override
Returns the maximum number of peers we are configured to allow.
void updateSlotAndSquelch(uint256 const &key, PublicKey const &validator, std::set< Peer::id_t > &&peers, protocol::MessageType type)
Updates message count for validator/peer.
OverlayImpl(Application &app, Setup const &setup, ServerHandler &serverHandler, Resource::Manager &resourceManager, Resolver &resolver, boost::asio::io_service &io_service, BasicConfig const &config, beast::insight::Collector::ptr const &collector)
beast::Journal const journal_
boost::container::flat_map< Child *, std::weak_ptr< Child > > list_
Manages the set of connected peers.
virtual std::shared_ptr< Slot > 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 newInboundEndpoint(beast::IP::Endpoint const &address)=0
Create a new endpoint keyed by inbound IP address or the forwarded IP if proxied.
virtual Consumer newOutboundEndpoint(beast::IP::Endpoint const &address)=0
Create a new endpoint keyed by outbound IP address and port.
std::vector< std::string > const & values() const
Returns all the values in the section.
void setup(Setup const &setup, beast::Journal journal)
auto const & getCounts() const
An up-to-date copy of all the counters.
void addCount(category cat, bool inbound, int bytes)
Account for traffic associated with the given category.
bool listed(PublicKey const &identity) const
Returns true if public key is included on any lists.
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.
Json::Value getJson() const
Return a JSON representation of the state of the validator list.
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::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
std::optional< ProtocolVersion > negotiateProtocolVersion(std::vector< ProtocolVersion > const &versions)
Given a list of supported protocol versions, choose the one we prefer.
std::optional< Manifest > deserializeManifest(Slice s, beast::Journal journal)
Constructs Manifest from serialized string.
std::vector< ProtocolVersion > parseProtocolVersions(boost::beast::string_view const &value)
Parse a set of protocol versions.
bool isPseudoTx(STObject const &tx)
Check whether a transaction is a pseudo-transaction.
void addValidatorManifest(soci::session &session, std::string const &serialized)
addValidatorManifest Saves the manifest of a validator to the database.
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.
std::shared_ptr< boost::asio::ssl::context > make_SSLContext(std::string const &cipherList)
Create a self-signed SSL context that allows anonymous Diffie Hellman.
std::shared_ptr< Message > makeSquelchMessage(PublicKey const &validator, bool squelch, uint32_t squelchDuration)
std::string strHex(FwdIt begin, FwdIt end)
@ accepted
Manifest is valid.
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)
std::string base64_encode(std::uint8_t const *data, std::size_t len)
Stopwatch & stopwatch()
Returns an instance of a wall clock.
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
Json::Value getCountsJson(Application &app, int minObjectCount)
std::string to_string(base_uint< Bits, Tag > const &a)
PublicKey verifyHandshake(boost::beast::http::fields const &headers, ripple::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.
Overlay::Setup setup_Overlay(BasicConfig const &config)
constexpr Number squelch(Number const &x, Number const &limit) noexcept
std::unique_ptr< Overlay > make_Overlay(Application &app, Overlay::Setup const &setup, ServerHandler &serverHandler, Resource::Manager &resourceManager, Resolver &resolver, boost::asio::io_service &io_service, BasicConfig const &config, beast::insight::Collector::ptr const &collector)
Creates the implementation of Overlay.
beast::xor_shift_engine & default_prng()
Return the default random engine.
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)
beast::IP::Address public_ip
std::uint32_t crawlOptions
std::shared_ptr< boost::asio::ssl::context > context
std::optional< std::uint32_t > networkID
PeerFinder configuration settings.
static Config makeConfig(ripple::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.