20 #include <ripple/app/ledger/LedgerMaster.h>
21 #include <ripple/app/misc/HashRouter.h>
22 #include <ripple/app/misc/NetworkOPs.h>
23 #include <ripple/app/misc/ValidatorList.h>
24 #include <ripple/app/misc/ValidatorSite.h>
25 #include <ripple/basics/base64.h>
26 #include <ripple/basics/make_SSLContext.h>
27 #include <ripple/beast/core/LexicalCast.h>
28 #include <ripple/core/DatabaseCon.h>
29 #include <ripple/nodestore/DatabaseShard.h>
30 #include <ripple/overlay/Cluster.h>
31 #include <ripple/overlay/impl/ConnectAttempt.h>
32 #include <ripple/overlay/impl/PeerImp.h>
33 #include <ripple/overlay/predicates.h>
34 #include <ripple/peerfinder/make_Manager.h>
35 #include <ripple/rpc/handlers/GetCounts.h>
36 #include <ripple/rpc/json_body.h>
37 #include <ripple/server/SimpleWriter.h>
39 #include <boost/algorithm/string/predicate.hpp>
40 #include <boost/utility/in_place_factory.hpp>
44 namespace CrawlOptions {
62 overlay_.remove(*
this);
90 if (ec || overlay_.isStopping())
92 if (ec && ec != boost::asio::error::operation_aborted)
94 JLOG(overlay_.journal_.error()) <<
"on_timer: " << ec.message();
99 overlay_.m_peerFinder->once_per_second();
100 overlay_.sendEndpoints();
101 overlay_.autoConnect();
104 overlay_.deleteIdlePeers();
120 boost::asio::io_service& io_service,
136 app_.journal(
"PeerFinder"),
146 [counts =
m_traffic.getCounts(), collector]() {
150 for (
size_t i = 0; i < counts.size(); ++i)
190 handoff.
moved =
true;
192 JLOG(journal.
debug()) <<
"Peer connection upgrade from " << remote_endpoint;
195 auto const local_endpoint(
196 stream_ptr->next_layer().socket().local_endpoint(ec));
199 JLOG(journal.
debug()) << remote_endpoint <<
" failed: " << ec.message();
205 if (consumer.disconnect())
215 handoff.
moved =
false;
224 return boost::iequals(s,
"peer");
227 handoff.
moved =
false;
236 if (!negotiatedVersion)
239 handoff.
moved =
false;
243 remote_endpoint.address(),
244 "Unable to agree on a protocol version");
253 handoff.
moved =
false;
257 remote_endpoint.address(),
258 "Incorrect security cookie");
270 remote_endpoint.address(),
276 bool const reserved =
284 JLOG(journal.
debug())
285 <<
"Peer " << remote_endpoint <<
" redirected, slots full";
286 handoff.
moved =
false;
288 slot, request, remote_endpoint.address());
294 auto const peer = std::make_shared<PeerImp>(
302 std::move(stream_ptr),
310 auto const result =
m_peers.emplace(peer->slot(), peer);
311 assert(result.second);
314 list_.emplace(peer.get(), peer);
318 handoff.
moved =
true;
323 JLOG(journal.
debug()) <<
"Peer " << remote_endpoint
324 <<
" fails handshake (" << e.
what() <<
")";
327 handoff.
moved =
false;
329 slot, request, remote_endpoint.address(), e.
what());
343 return !versions.empty();
360 boost::beast::http::response<json_body> msg;
361 msg.version(request.version());
362 msg.result(boost::beast::http::status::service_unavailable);
366 ostr << remote_address;
367 msg.insert(
"Remote-Address", ostr.
str());
369 msg.insert(
"Content-Type",
"application/json");
370 msg.insert(boost::beast::http::field::connection,
"close");
375 ips.
append(_.address.to_string());
377 msg.prepare_payload();
378 return std::make_shared<SimpleWriter>(msg);
388 boost::beast::http::response<boost::beast::http::empty_body> msg;
389 msg.version(request.version());
390 msg.result(boost::beast::http::status::bad_request);
391 msg.reason(
"Bad Request (" + text +
")");
393 msg.insert(
"Remote-Address", remote_address.to_string());
394 msg.insert(boost::beast::http::field::connection,
"close");
395 msg.prepare_payload();
396 return std::make_shared<SimpleWriter>(msg);
407 if (usage.disconnect())
409 JLOG(
journal_.
info()) <<
"Over resource limit: " << remote_endpoint;
416 JLOG(
journal_.
debug()) <<
"Connect: No slot for " << remote_endpoint;
420 auto const p = std::make_shared<ConnectAttempt>(
432 list_.emplace(p.get(), p);
445 auto const result =
m_peers.emplace(peer->slot(), peer);
446 assert(result.second);
451 auto const result =
ids_.emplace(
452 std::piecewise_construct,
455 assert(result.second);
461 JLOG(
journal_.
debug()) <<
"activated " << peer->getRemoteAddress() <<
" ("
477 auto const iter =
m_peers.find(slot);
514 if (bootstrapIps.empty())
517 bootstrapIps.
push_back(
"r.ripple.com 51235");
520 bootstrapIps.
push_back(
"zaphod.alloy.ee 51235");
523 bootstrapIps.push_back(
"sahyadri.isrdc.in 51235");
533 for (
auto const& addr : addresses)
535 if (addr.port() == 0)
557 for (
auto& addr : addresses)
559 if (addr.port() == 0)
574 auto const timer = std::make_shared<Timer>(*
this);
576 list_.emplace(timer.get(), timer);
605 for (
auto const& i : stats)
610 item[
"category"] = i.name;
631 auto const result(
ids_.emplace(
632 std::piecewise_construct,
635 assert(result.second);
639 JLOG(
journal_.
debug()) <<
"activated " << peer->getRemoteAddress() <<
" ("
661 auto const n = m->list_size();
662 auto const& journal = from->pjournal();
664 protocol::TMManifests
relay;
668 auto& s = m->list().Get(i).stobject();
672 auto const serialized = mo->serialized;
679 relay.add_list()->set_stobject(s);
693 soci::transaction tr(*db);
694 static const char*
const sql =
695 "INSERT INTO ValidatorManifests (RawData) VALUES "
697 soci::blob rawData(*db);
699 *db << sql, soci::use(rawData);
706 JLOG(journal.debug())
707 <<
"Malformed manifest #" << i + 1 <<
": " <<
strHex(s);
712 if (!
relay.list().empty())
713 for_each([m2 = std::make_shared<Message>(
relay, protocol::mtMANIFESTS)](
730 using namespace std::chrono_literals;
733 auto const numPeers{
size()};
744 auto const timeout(
seconds((hops * hops) * 10));
752 for (
auto&
id :
ids_)
757 protocol::TMGetPeerShardInfo tmGPS;
758 tmGPS.set_hops(hops);
760 tmGPS, protocol::mtGET_PEER_SHARD_INFO)));
767 csLast_ = duration_cast<seconds>(
778 if (
auto psi = peer->getPeerShardInfo())
783 auto it{peerShardInfo.find(e.first)};
784 if (it != peerShardInfo.end())
786 it->second.shardIndexes += e.second.shardIndexes;
788 peerShardInfo.emplace(std::move(e));
795 for (
auto const& e : peerShardInfo)
801 auto const& address{e.second.endpoint.address()};
802 if (!address.is_unspecified())
803 pv[jss::ip] = address.to_string();
805 pv[jss::complete_shards] =
to_string(e.second.shardIndexes);
849 sp->getNodePublic().data(), sp->getNodePublic().size());
850 pv[jss::type] = sp->slot()->inbound() ?
"in" :
"out";
852 duration_cast<seconds>(sp->uptime()).count());
855 pv[jss::ip] = sp->getRemoteAddress().address().to_string();
856 if (sp->slot()->inbound())
858 if (
auto port = sp->slot()->listening_port())
859 pv[jss::port] = *port;
868 auto version{sp->getVersion()};
869 if (!version.empty())
871 pv[jss::version] = version;
875 sp->ledgerRange(minSeq, maxSeq);
876 if (minSeq != 0 || maxSeq != 0)
877 pv[jss::complete_ledgers] =
880 if (
auto shardIndexes = sp->getShardIndexes())
881 pv[jss::complete_shards] =
to_string(*shardIndexes);
890 bool const humanReadable =
false;
891 bool const admin =
false;
892 bool const counters =
false;
899 server_info.
removeMember(jss::load_factor_fee_escalation);
903 if (server_info.
isMember(jss::validated_ledger))
905 Json::Value& validated_ledger = server_info[jss::validated_ledger];
926 if (validators.
isMember(jss::publisher_lists))
928 Json::Value& publisher_lists = validators[jss::publisher_lists];
930 for (
auto& publisher : publisher_lists)
942 if (validatorSites.
isMember(jss::validator_sites))
944 validators[jss::validator_sites] =
945 std::move(validatorSites[jss::validator_sites]);
966 if (req.target() !=
"/crawl" ||
970 boost::beast::http::response<json_body> msg;
971 msg.version(req.version());
972 msg.result(boost::beast::http::status::ok);
974 msg.insert(
"Content-Type",
"application/json");
975 msg.insert(
"Connection",
"close");
995 msg.prepare_payload();
996 handoff.
response = std::make_shared<SimpleWriter>(msg);
1014 boost::beast::http::response<json_body> msg;
1015 msg.version(req.version());
1017 msg.insert(
"Content-Type",
"application/json");
1018 msg.insert(
"Connection",
"close");
1020 auto fail = [&msg, &handoff](
auto status) {
1022 msg.insert(
"Content-Length",
"0");
1026 msg.prepare_payload();
1027 handoff.
response = std::make_shared<SimpleWriter>(msg);
1031 auto key = req.target().substr(prefix.size());
1033 if (
auto slash = key.find(
'/'); slash != boost::string_view::npos)
1035 auto verString = key.substr(0, slash);
1036 if (!boost::conversion::try_lexical_convert(verString, version))
1037 return fail(boost::beast::http::status::bad_request);
1038 key = key.substr(slash + 1);
1042 return fail(boost::beast::http::status::bad_request);
1050 return fail(boost::beast::http::status::not_found);
1054 return fail(boost::beast::http::status::bad_request);
1058 msg.result(boost::beast::http::status::ok);
1062 msg.prepare_payload();
1063 handoff.
response = std::make_shared<SimpleWriter>(msg);
1071 if (req.target() !=
"/health")
1073 boost::beast::http::response<json_body> msg;
1074 msg.version(req.version());
1076 msg.insert(
"Content-Type",
"application/json");
1077 msg.insert(
"Connection",
"close");
1081 int last_validated_ledger_age = -1;
1082 if (info.isMember(
"validated_ledger"))
1083 last_validated_ledger_age = info[
"validated_ledger"][
"age"].asInt();
1084 bool amendment_blocked =
false;
1085 if (info.isMember(
"amendment_blocked"))
1086 amendment_blocked =
true;
1087 int number_peers = info[
"peers"].asInt();
1088 std::string server_state = info[
"server_state"].asString();
1090 info[
"load_factor"].asDouble() / info[
"load_base"].asDouble();
1092 enum { healthy, warning, critical };
1093 int health = healthy;
1094 auto set_health = [&health](
int state) {
1100 if (last_validated_ledger_age >= 7 || last_validated_ledger_age < 0)
1102 msg.body()[jss::info][
"validated_ledger"] = last_validated_ledger_age;
1103 if (last_validated_ledger_age < 20)
1104 set_health(warning);
1106 set_health(critical);
1109 if (amendment_blocked)
1111 msg.body()[jss::info][
"amendment_blocked"] =
true;
1112 set_health(critical);
1115 if (number_peers <= 7)
1117 msg.body()[jss::info][
"peers"] = number_peers;
1118 if (number_peers != 0)
1119 set_health(warning);
1121 set_health(critical);
1124 if (!(server_state ==
"full" || server_state ==
"validating" ||
1125 server_state ==
"proposing"))
1127 msg.body()[jss::info][
"server_state"] = server_state;
1128 if (server_state ==
"syncing" || server_state ==
"tracking" ||
1129 server_state ==
"connected")
1131 set_health(warning);
1134 set_health(critical);
1137 if (load_factor > 100)
1139 msg.body()[jss::info][
"load_factor"] = load_factor;
1140 if (load_factor < 1000)
1141 set_health(warning);
1143 set_health(critical);
1149 msg.result(boost::beast::http::status::ok);
1152 msg.result(boost::beast::http::status::service_unavailable);
1155 msg.result(boost::beast::http::status::internal_server_error);
1159 msg.prepare_payload();
1160 handoff.
response = std::make_shared<SimpleWriter>(msg);
1196 auto const iter =
ids_.find(
id);
1197 if (iter !=
ids_.end())
1198 return iter->second.lock();
1208 for (
auto const& e :
ids_)
1210 if (
auto peer = e.second.lock())
1212 if (peer->getNodePublic() == pubKey)
1222 auto const sm = std::make_shared<Message>(m, protocol::mtPROPOSE_LEDGER);
1228 protocol::TMProposeSet& m,
1235 std::make_shared<Message>(m, protocol::mtPROPOSE_LEDGER, validator);
1237 if (toSkip->find(p->id()) == toSkip->end())
1248 auto const sm = std::make_shared<Message>(m, protocol::mtVALIDATION);
1254 protocol::TMValidation& m,
1261 std::make_shared<Message>(m, protocol::mtVALIDATION, validator);
1263 if (toSkip->find(p->id()) == toSkip->end())
1279 protocol::TMManifests tm;
1282 [&tm](
std::size_t s) { tm.mutable_list()->Reserve(s); },
1284 tm.add_list()->set_stobject(
1286 hr.addSuppression(
manifest.hash());
1291 if (tm.list_size() != 0)
1293 std::make_shared<Message>(tm, protocol::mtMANIFESTS);
1307 list_.erase(&child);
1328 work_ = boost::none;
1331 for (
auto const& element :
list_)
1337 for (
auto const& child : children)
1339 if (child !=
nullptr)
1348 for (
auto addr : result)
1355 auto const result =
m_peerFinder->buildEndpointsForPeers();
1356 for (
auto const& e : result)
1361 auto const iter =
m_peers.find(e.first);
1363 peer = iter->second.lock();
1366 peer->sendEndpoints(e.second.begin(), e.second.end());
1374 uint32_t squelchDuration)
1376 protocol::TMSquelch m;
1378 m.set_validatorpubkey(validator.data(), validator.size());
1380 m.set_squelchduration(squelchDuration);
1381 return std::make_shared<Message>(m, protocol::mtSQUELCH);
1388 peer &&
app_.
config().VP_REDUCE_RELAY_SQUELCH)
1400 uint32_t squelchDuration)
const
1403 peer &&
app_.
config().VP_REDUCE_RELAY_SQUELCH)
1414 protocol::MessageType type)
1416 if (!
strand_.running_in_this_thread())
1419 [
this, key, validator, peers = std::move(peers), type]()
mutable {
1423 for (
auto id : peers)
1424 slots_.updateSlotAndSquelch(key, validator,
id, type);
1432 protocol::MessageType type)
1434 if (!
strand_.running_in_this_thread())
1435 return post(
strand_, [
this, key, validator, peer, type]() {
1439 slots_.updateSlotAndSquelch(key, validator, peer, type);
1445 if (!
strand_.running_in_this_thread())
1448 slots_.deletePeer(
id,
true);
1454 if (!
strand_.running_in_this_thread())
1457 slots_.deleteIdlePeers();
1468 auto const& section = config.
section(
"overlay");
1473 Throw<std::runtime_error>(
"Configured IP limit is invalid");
1476 set(ip,
"public_ip", section);
1479 boost::system::error_code ec;
1482 Throw<std::runtime_error>(
"Configured public IP is invalid");
1487 auto const& section = config.
section(
"crawl");
1488 auto const& values = section.
values();
1490 if (values.size() > 1)
1492 Throw<std::runtime_error>(
1493 "Configured [crawl] section is invalid, too many values");
1496 bool crawlEnabled =
true;
1499 if (values.size() == 1)
1503 crawlEnabled = boost::lexical_cast<bool>(values.front());
1505 catch (boost::bad_lexical_cast
const&)
1507 Throw<std::runtime_error>(
1508 "Configured [crawl] section has invalid value: " +
1515 if (get<bool>(section,
"overlay",
true))
1519 if (get<bool>(section,
"server",
true))
1523 if (get<bool>(section,
"counts",
false))
1527 if (get<bool>(section,
"unl",
true))
1534 auto const& section = config.
section(
"vl");
1541 auto id = config.
legacy(
"network_id");
1548 if (
id ==
"testnet")
1559 Throw<std::runtime_error>(
1560 "Configured [network_id] section is invalid: must be a number "
1561 "or one of the strings 'main', 'testnet' or 'devnet'.");
1575 boost::asio::io_service& io_service,
1579 return std::make_unique<OverlayImpl>(
std::string const & name() const
Returns the name of this source.
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.
Json::Value getServerCounts()
Returns information about the local server's performance counters.
const beast::Journal journal_
boost::asio::ip::address address_type
virtual Cluster & cluster()=0
virtual Json::Value getServerInfo(bool human, bool admin, bool counters)=0
auto const & getCounts() const
An up-to-date copy of all the counters.
boost::optional< boost::asio::io_service::work > work_
std::shared_ptr< Message > makeSquelchMessage(PublicKey const &validator, bool squelch, uint32_t squelchDuration)
std::optional< std::uint32_t > networkID
void stopped()
Called by derived classes to indicate that the stoppable has stopped.
virtual void pubManifest(Manifest const &)=0
static bool is_upgrade(boost::beast::http::header< true, Fields > const &req)
hash_map< Peer::id_t, std::weak_ptr< PeerImp > > ids_
@ arrayValue
array value (ordered list)
void updateSlotAndSquelch(uint256 const &key, PublicKey const &validator, std::set< Peer::id_t > &&peers, protocol::MessageType type)
Updates message count for validator/peer.
virtual ValidatorSite & validatorSites()=0
std::uint32_t crawlOptions
void convert(soci::blob &from, std::vector< std::uint8_t > &to)
std::set< std::uint32_t > csIDs_
std::recursive_mutex mutex_
void on_timer(error_code ec)
virtual PeerReservationTable & peerReservations()=0
std::atomic< Peer::id_t > next_id_
std::string base64_encode(std::uint8_t const *data, std::size_t len)
bool empty() const noexcept
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::unique_ptr< Overlay > make_Overlay(Application &app, Overlay::Setup const &setup, Stoppable &parent, 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.
static std::string makePrefix(std::uint32_t id)
Handoff onHandoff(std::unique_ptr< stream_type > &&bundle, http_request_type &&request, endpoint_type remote_endpoint) override
Conditionally accept an incoming HTTP request.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
std::condition_variable csCV_
void setup(Setup const &setup, beast::Journal journal)
boost::asio::io_service::strand strand_
Json::Value getServerInfo()
Returns information about the local server.
void onStart() override
Override called during start.
std::vector< ProtocolVersion > parseProtocolVersions(boost::beast::string_view const &value)
Parse a set of protocol versions.
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(ListDisposition disposition)
void broadcast(protocol::TMProposeSet &m) override
Broadcast a proposal.
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.
void connect(beast::IP::Endpoint const &remote_endpoint) override
Establish a peer connection to the specified endpoint.
Json::Value json() override
Return diagnostics on the status of all peers.
Setup const & setup() const
bool processValidatorList(http_request_type const &req, Handoff &handoff)
Handles validator list requests.
virtual NetworkOPs & getOPs()=0
virtual DatabaseCon & getWalletDB()=0
Retrieve the "wallet database".
bool processHealth(http_request_type const &req, Handoff &handoff)
Handles health requests.
std::vector< std::string > const & values() const
Returns all the values in the section.
bool is_private(AddressV4 const &addr)
Returns true if the address is a private unroutable address.
Sends a message to all peers.
void onChildrenStopped() override
Override called when all children have stopped.
static Config makeConfig(ripple::Config const &config, std::uint16_t port, bool validationPublicKey, int ipLimit)
Make PeerFinder::Config from configuration parameters.
std::condition_variable_any cond_
boost::optional< ProtocolVersion > negotiateProtocolVersion(std::vector< ProtocolVersion > const &versions)
Given a list of supported protocol versions, choose the one we prefer.
static IP::Endpoint from_asio(boost::asio::ip::address const &address)
@ checkIdlePeers
How often we check for idle peers (seconds)
boost::optional< std::string > member(PublicKey const &node) const
Determines whether a node belongs in the cluster.
PeerFinder::Manager & peerFinder()
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 checkTracking(std::uint32_t) override
Calls the checkTracking function on each peer.
bool is_keep_alive(boost::beast::http::message< isRequest, Body, Fields > const &m)
boost::optional< Json::Value > getAvailable(boost::beast::string_view const &pubKey, boost::optional< std::uint32_t > forceVersion={})
Returns the current valid list for the given publisher key, if available, as a Json object.
Overlay::Setup setup_Overlay(BasicConfig const &config)
Value & append(const Value &value)
Append value to array at the end.
void onManifests(std::shared_ptr< protocol::TMManifests > const &m, std::shared_ptr< PeerImp > const &from)
Provides an interface for starting and stopping.
beast::IP::Address public_ip
std::shared_ptr< Message > manifestMessage_
LockedSociSession checkoutDb()
Resource::Manager & resourceManager()
@ objectValue
object value (collection of name/value pairs).
void add(Source &source)
Add a child source.
Json::Value getOverlayInfo()
Returns information about peers on the overlay network.
boost::asio::io_service & io_service_
virtual Config & config()=0
Json::Value getJson() const
Return JSON representation of configured validator sites.
std::vector< std::string > IPS_FIXED
reduce_relay::Slots< UptimeClock > slots_
bool areChildrenStopped() const
Returns true if all children have stopped.
ServerHandler & serverHandler()
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,...
Json::Value getUnlInfo()
Returns information about the local server's UNL.
bool listed(PublicKey const &identity) const
Returns true if public key is included on any lists.
void legacy(std::string const §ion, std::string value)
Set a value that is not a key/value pair.
void for_each_manifest(Function &&f) const
Invokes the callback once for every populated manifest.
std::unique_ptr< PeerFinder::Manager > m_peerFinder
bool isMember(const char *key) const
Return true if the object has a member named key.
A generic endpoint for log messages.
ServerHandler & serverHandler_
void onPrepare() override
Override called during preparation.
Child(OverlayImpl &overlay)
std::optional< std::set< PeerShortID > > shouldRelay(uint256 const &key)
Determines whether the hashed item should be relayed.
PeerSequence getActivePeers() const override
Returns a sequence representing the current list of peers.
Result split_commas(FwdIt first, FwdIt last)
virtual PublicKey const & getValidationPublicKey() const =0
OverlayImpl(Application &app, Setup const &setup, Stoppable &parent, ServerHandler &serverHandler, Resource::Manager &resourceManager, Resolver &resolver, boost::asio::io_service &io_service, BasicConfig const &config, beast::insight::Collector::ptr const &collector)
void deleteIdlePeers()
Check if peers stopped relaying messages and if slots stopped receiving messages from the validator.
virtual ValidatorList & validators()=0
bool processRequest(http_request_type const &req, Handoff &handoff)
Handles non-peer protocol requests.
std::optional< std::uint32_t > manifestListSeq_
@ accepted
Manifest is valid.
Tracks load and resource consumption.
std::string const & getFullVersionString()
Full server version string.
void deletePeer(Peer::id_t id)
Called when the peer is deleted.
Json::Value getCountsJson(Application &app, int minObjectCount)
Resource::Manager & m_resourceManager
T emplace_back(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::set< Peer::id_t > relay(protocol::TMProposeSet &m, uint256 const &uid, PublicKey const &validator) override
Relay a proposal.
boost::optional< Manifest > deserializeManifest(Slice s)
Constructs Manifest from serialized string.
virtual beast::Journal journal(std::string const &name)=0
virtual ManifestCache & validatorManifests()=0
std::shared_ptr< Message > getManifestsMessage()
Value removeMember(const char *key)
Remove and return the named member.
void remove(std::shared_ptr< PeerFinder::Slot > const &slot)
Manages the set of connected peers.
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...
void onPeerDeactivate(Peer::id_t id)
boost::container::flat_map< Child *, std::weak_ptr< Child > > list_
void lastLink(std::uint32_t id)
Called when the last link from a peer chain is received.
Timer(OverlayImpl &overlay)
void squelch(PublicKey const &validator, Peer::id_t const id, std::uint32_t squelchDuration) const override
Squelch handler.
Wraps a Journal::Sink to prefix its output with a string.
Used to indicate the result of a server connection handoff.
std::shared_ptr< Peer > findPeerByPublicKey(PublicKey const &pubKey) override
Returns the peer with the matching public key, or null.
Json::Value getJson() const
Return a JSON representation of the state of the validator list.
bool contains(PublicKey const &nodeId)
std::vector< std::string > IPS
std::shared_ptr< Writer > makeRedirectResponse(std::shared_ptr< PeerFinder::Slot > const &slot, http_request_type const &request, address_type remote_address)
A version-independent IP address and port combination.
std::string strHex(FwdIt begin, FwdIt end)
std::weak_ptr< Timer > timer_
std::shared_ptr< boost::asio::ssl::context > context
std::shared_ptr< Writer > response
static boost::asio::ip::tcp::endpoint to_asio_endpoint(IP::Endpoint const &address)
PeerFinder configuration settings.
std::atomic< std::chrono::seconds > csLast_
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.
std::shared_ptr< Peer > findPeerByShortID(Peer::id_t const &id) const override
Returns the peer with the matching short id, or null.
void reportTraffic(TrafficCount::category cat, bool isInbound, int bytes)
Json::Value crawlShards(bool pubKey, std::uint32_t hops) override
Returns information reported to the crawl shard RPC command.
void addCount(category cat, bool inbound, int bytes)
Account for traffic associated with the given category.
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
ManifestDisposition applyManifest(Manifest m)
Add manifest to cache.
std::shared_ptr< Writer > makeErrorResponse(std::shared_ptr< PeerFinder::Slot > const &slot, http_request_type const &request, address_type remote_address, std::string msg)
hash_map< std::shared_ptr< PeerFinder::Slot >, std::weak_ptr< PeerImp > > m_peers
void resolve(std::vector< std::string > const &names, Handler handler)
resolve all hostnames on the list
static bool isPeerUpgrade(http_request_type const &request)
void add_active(std::shared_ptr< PeerImp > const &peer)
boost::system::error_code error_code
void onWrite(beast::PropertyStream::Map &stream) override
Subclass override.
virtual HashRouter & getHashRouter()=0
Holds unparsed configuration information.
void for_each(UnaryFunc &&f) const
void onStop() override
Override called when the stop notification is issued.
void unsquelch(PublicKey const &validator, Peer::id_t id) const override
Unsquelch handler.
Section & section(std::string const &name)
Returns the section with the given name.
int limit() override
Returns the maximum number of peers we are configured to allow.
bool processCrawl(http_request_type const &req, Handoff &handoff)
Handles crawl requests.
boost::asio::ip::tcp::endpoint endpoint_type
bool isStopping() const
Returns true if the stoppable should stop.
std::uint32_t sequence() const
A monotonically increasing number used to detect new manifests.