rippled
OverlayImpl.cpp
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
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/app/rdb/RelationalDatabase.h>
26 #include <ripple/app/rdb/Wallet.h>
27 #include <ripple/basics/base64.h>
28 #include <ripple/basics/make_SSLContext.h>
29 #include <ripple/basics/random.h>
30 #include <ripple/beast/core/LexicalCast.h>
31 #include <ripple/nodestore/DatabaseShard.h>
32 #include <ripple/overlay/Cluster.h>
33 #include <ripple/overlay/impl/ConnectAttempt.h>
34 #include <ripple/overlay/impl/PeerImp.h>
35 #include <ripple/overlay/predicates.h>
36 #include <ripple/peerfinder/make_Manager.h>
37 #include <ripple/rpc/handlers/GetCounts.h>
38 #include <ripple/rpc/json_body.h>
39 #include <ripple/server/SimpleWriter.h>
40 
41 #include <boost/algorithm/string/predicate.hpp>
42 #include <boost/utility/in_place_factory.hpp>
43 
44 namespace ripple {
45 
46 namespace CrawlOptions {
47 enum {
48  Disabled = 0,
49  Overlay = (1 << 0),
50  ServerInfo = (1 << 1),
51  ServerCounts = (1 << 2),
52  Unl = (1 << 3)
53 };
54 }
55 
56 //------------------------------------------------------------------------------
57 
58 OverlayImpl::Child::Child(OverlayImpl& overlay) : overlay_(overlay)
59 {
60 }
61 
63 {
64  overlay_.remove(*this);
65 }
66 
67 //------------------------------------------------------------------------------
68 
70  : Child(overlay), timer_(overlay_.io_service_)
71 {
72 }
73 
74 void
76 {
77  // This method is only ever called from the same strand that calls
78  // Timer::on_timer, ensuring they never execute concurrently.
79  stopping_ = true;
80  timer_.cancel();
81 }
82 
83 void
85 {
86  timer_.expires_after(std::chrono::seconds(1));
87  timer_.async_wait(overlay_.strand_.wrap(std::bind(
88  &Timer::on_timer, shared_from_this(), std::placeholders::_1)));
89 }
90 
91 void
93 {
94  if (ec || stopping_)
95  {
96  if (ec && ec != boost::asio::error::operation_aborted)
97  {
98  JLOG(overlay_.journal_.error()) << "on_timer: " << ec.message();
99  }
100  return;
101  }
102 
103  overlay_.m_peerFinder->once_per_second();
104  overlay_.sendEndpoints();
105  overlay_.autoConnect();
106  if (overlay_.app_.config().TX_REDUCE_RELAY_ENABLE)
107  overlay_.sendTxQueue();
108 
109  if ((++overlay_.timer_count_ % Tuning::checkIdlePeers) == 0)
110  overlay_.deleteIdlePeers();
111 
112  async_wait();
113 }
114 
115 //------------------------------------------------------------------------------
116 
118  Application& app,
119  Setup const& setup,
120  ServerHandler& serverHandler,
122  Resolver& resolver,
123  boost::asio::io_service& io_service,
124  BasicConfig const& config,
125  beast::insight::Collector::ptr const& collector)
126  : app_(app)
127  , io_service_(io_service)
128  , work_(std::in_place, std::ref(io_service_))
130  , setup_(setup)
131  , journal_(app_.journal("Overlay"))
132  , serverHandler_(serverHandler)
134  , m_peerFinder(PeerFinder::make_Manager(
135  io_service,
136  stopwatch(),
137  app_.journal("PeerFinder"),
138  config,
139  collector))
140  , m_resolver(resolver)
141  , next_id_(1)
142  , timer_count_(0)
143  , slots_(app.logs(), *this)
144  , m_stats(
145  std::bind(&OverlayImpl::collect_metrics, this),
146  collector,
147  [counts = m_traffic.getCounts(), collector]() {
149  ret.reserve(counts.size());
150 
151  for (size_t i = 0; i < counts.size(); ++i)
152  {
153  ret.push_back(TrafficGauges(counts[i].name, collector));
154  }
155 
156  return ret;
157  }())
158 {
160 }
161 
162 Handoff
164  std::unique_ptr<stream_type>&& stream_ptr,
165  http_request_type&& request,
166  endpoint_type remote_endpoint)
167 {
168  auto const id = next_id_++;
169  beast::WrappedSink sink(app_.logs()["Peer"], makePrefix(id));
170  beast::Journal journal(sink);
171 
172  Handoff handoff;
173  if (processRequest(request, handoff))
174  return handoff;
175  if (!isPeerUpgrade(request))
176  return handoff;
177 
178  handoff.moved = true;
179 
180  JLOG(journal.debug()) << "Peer connection upgrade from " << remote_endpoint;
181 
182  error_code ec;
183  auto const local_endpoint(
184  stream_ptr->next_layer().socket().local_endpoint(ec));
185  if (ec)
186  {
187  JLOG(journal.debug()) << remote_endpoint << " failed: " << ec.message();
188  return handoff;
189  }
190 
191  auto consumer = m_resourceManager.newInboundEndpoint(
192  beast::IPAddressConversion::from_asio(remote_endpoint));
193  if (consumer.disconnect(journal))
194  return handoff;
195 
196  auto const slot = m_peerFinder->new_inbound_slot(
198  beast::IPAddressConversion::from_asio(remote_endpoint));
199 
200  if (slot == nullptr)
201  {
202  // self-connect, close
203  handoff.moved = false;
204  return handoff;
205  }
206 
207  // Validate HTTP request
208 
209  {
210  auto const types = beast::rfc2616::split_commas(request["Connect-As"]);
211  if (std::find_if(types.begin(), types.end(), [](std::string const& s) {
212  return boost::iequals(s, "peer");
213  }) == types.end())
214  {
215  handoff.moved = false;
216  handoff.response =
217  makeRedirectResponse(slot, request, remote_endpoint.address());
218  handoff.keep_alive = beast::rfc2616::is_keep_alive(request);
219  return handoff;
220  }
221  }
222 
223  auto const negotiatedVersion = negotiateProtocolVersion(request["Upgrade"]);
224  if (!negotiatedVersion)
225  {
226  m_peerFinder->on_closed(slot);
227  handoff.moved = false;
228  handoff.response = makeErrorResponse(
229  slot,
230  request,
231  remote_endpoint.address(),
232  "Unable to agree on a protocol version");
233  handoff.keep_alive = false;
234  return handoff;
235  }
236 
237  auto const sharedValue = makeSharedValue(*stream_ptr, journal);
238  if (!sharedValue)
239  {
240  m_peerFinder->on_closed(slot);
241  handoff.moved = false;
242  handoff.response = makeErrorResponse(
243  slot,
244  request,
245  remote_endpoint.address(),
246  "Incorrect security cookie");
247  handoff.keep_alive = false;
248  return handoff;
249  }
250 
251  try
252  {
253  auto publicKey = verifyHandshake(
254  request,
255  *sharedValue,
258  remote_endpoint.address(),
259  app_);
260 
261  {
262  // The node gets a reserved slot if it is in our cluster
263  // or if it has a reservation.
264  bool const reserved =
265  static_cast<bool>(app_.cluster().member(publicKey)) ||
266  app_.peerReservations().contains(publicKey);
267  auto const result =
268  m_peerFinder->activate(slot, publicKey, reserved);
269  if (result != PeerFinder::Result::success)
270  {
271  m_peerFinder->on_closed(slot);
272  JLOG(journal.debug())
273  << "Peer " << remote_endpoint << " redirected, slots full";
274  handoff.moved = false;
275  handoff.response = makeRedirectResponse(
276  slot, request, remote_endpoint.address());
277  handoff.keep_alive = false;
278  return handoff;
279  }
280  }
281 
282  auto const peer = std::make_shared<PeerImp>(
283  app_,
284  id,
285  slot,
286  std::move(request),
287  publicKey,
288  *negotiatedVersion,
289  consumer,
290  std::move(stream_ptr),
291  *this);
292  {
293  // As we are not on the strand, run() must be called
294  // while holding the lock, otherwise new I/O can be
295  // queued after a call to stop().
296  std::lock_guard<decltype(mutex_)> lock(mutex_);
297  {
298  auto const result = m_peers.emplace(peer->slot(), peer);
299  assert(result.second);
300  (void)result.second;
301  }
302  list_.emplace(peer.get(), peer);
303 
304  peer->run();
305  }
306  handoff.moved = true;
307  return handoff;
308  }
309  catch (std::exception const& e)
310  {
311  JLOG(journal.debug()) << "Peer " << remote_endpoint
312  << " fails handshake (" << e.what() << ")";
313 
314  m_peerFinder->on_closed(slot);
315  handoff.moved = false;
316  handoff.response = makeErrorResponse(
317  slot, request, remote_endpoint.address(), e.what());
318  handoff.keep_alive = false;
319  return handoff;
320  }
321 }
322 
323 //------------------------------------------------------------------------------
324 
325 bool
327 {
328  if (!is_upgrade(request))
329  return false;
330  auto const versions = parseProtocolVersions(request["Upgrade"]);
331  return !versions.empty();
332 }
333 
336 {
338  ss << "[" << std::setfill('0') << std::setw(3) << id << "] ";
339  return ss.str();
340 }
341 
345  http_request_type const& request,
346  address_type remote_address)
347 {
348  boost::beast::http::response<json_body> msg;
349  msg.version(request.version());
350  msg.result(boost::beast::http::status::service_unavailable);
351  msg.insert("Server", BuildInfo::getFullVersionString());
352  {
353  std::ostringstream ostr;
354  ostr << remote_address;
355  msg.insert("Remote-Address", ostr.str());
356  }
357  msg.insert("Content-Type", "application/json");
358  msg.insert(boost::beast::http::field::connection, "close");
359  msg.body() = Json::objectValue;
360  {
361  Json::Value& ips = (msg.body()["peer-ips"] = Json::arrayValue);
362  for (auto const& _ : m_peerFinder->redirect(slot))
363  ips.append(_.address.to_string());
364  }
365  msg.prepare_payload();
366  return std::make_shared<SimpleWriter>(msg);
367 }
368 
372  http_request_type const& request,
373  address_type remote_address,
374  std::string text)
375 {
376  boost::beast::http::response<boost::beast::http::empty_body> msg;
377  msg.version(request.version());
378  msg.result(boost::beast::http::status::bad_request);
379  msg.reason("Bad Request (" + text + ")");
380  msg.insert("Server", BuildInfo::getFullVersionString());
381  msg.insert("Remote-Address", remote_address.to_string());
382  msg.insert(boost::beast::http::field::connection, "close");
383  msg.prepare_payload();
384  return std::make_shared<SimpleWriter>(msg);
385 }
386 
387 //------------------------------------------------------------------------------
388 
389 void
391 {
392  assert(work_);
393 
394  auto usage = resourceManager().newOutboundEndpoint(remote_endpoint);
395  if (usage.disconnect(journal_))
396  {
397  JLOG(journal_.info()) << "Over resource limit: " << remote_endpoint;
398  return;
399  }
400 
401  auto const slot = peerFinder().new_outbound_slot(remote_endpoint);
402  if (slot == nullptr)
403  {
404  JLOG(journal_.debug()) << "Connect: No slot for " << remote_endpoint;
405  return;
406  }
407 
408  auto const p = std::make_shared<ConnectAttempt>(
409  app_,
410  io_service_,
412  usage,
413  setup_.context,
414  next_id_++,
415  slot,
416  app_.journal("Peer"),
417  *this);
418 
419  std::lock_guard lock(mutex_);
420  list_.emplace(p.get(), p);
421  p->run();
422 }
423 
424 //------------------------------------------------------------------------------
425 
426 // Adds a peer that is already handshaked and active
427 void
429 {
430  std::lock_guard lock(mutex_);
431 
432  {
433  auto const result = m_peers.emplace(peer->slot(), peer);
434  assert(result.second);
435  (void)result.second;
436  }
437 
438  {
439  auto const result = ids_.emplace(
440  std::piecewise_construct,
441  std::make_tuple(peer->id()),
442  std::make_tuple(peer));
443  assert(result.second);
444  (void)result.second;
445  }
446 
447  list_.emplace(peer.get(), peer);
448 
449  JLOG(journal_.debug()) << "activated " << peer->getRemoteAddress() << " ("
450  << peer->id() << ":"
451  << toBase58(
452  TokenType::NodePublic, peer->getNodePublic())
453  << ")";
454 
455  // As we are not on the strand, run() must be called
456  // while holding the lock, otherwise new I/O can be
457  // queued after a call to stop().
458  peer->run();
459 }
460 
461 void
463 {
464  std::lock_guard lock(mutex_);
465  auto const iter = m_peers.find(slot);
466  assert(iter != m_peers.end());
467  m_peers.erase(iter);
468 }
469 
470 void
472 {
474  app_.config(),
475  serverHandler_.setup().overlay.port,
477  setup_.ipLimit);
478 
479  m_peerFinder->setConfig(config);
480  m_peerFinder->start();
481 
482  // Populate our boot cache: if there are no entries in [ips] then we use
483  // the entries in [ips_fixed].
484  auto bootstrapIps =
486 
487  // If nothing is specified, default to several well-known high-capacity
488  // servers to serve as bootstrap:
489  if (bootstrapIps.empty())
490  {
491  // Pool of servers operated by Ripple Labs Inc. - https://ripple.com
492  bootstrapIps.push_back("r.ripple.com 51235");
493 
494  // Pool of servers operated by Alloy Networks - https://www.alloy.ee
495  bootstrapIps.push_back("zaphod.alloy.ee 51235");
496 
497  // Pool of servers operated by ISRDC - https://isrdc.in
498  bootstrapIps.push_back("sahyadri.isrdc.in 51235");
499  }
500 
502  bootstrapIps,
503  [this](
504  std::string const& name,
505  std::vector<beast::IP::Endpoint> const& addresses) {
507  ips.reserve(addresses.size());
508  for (auto const& addr : addresses)
509  {
510  if (addr.port() == 0)
511  ips.push_back(to_string(addr.at_port(DEFAULT_PEER_PORT)));
512  else
513  ips.push_back(to_string(addr));
514  }
515 
516  std::string const base("config: ");
517  if (!ips.empty())
518  m_peerFinder->addFallbackStrings(base + name, ips);
519  });
520 
521  // Add the ips_fixed from the rippled.cfg file
522  if (!app_.config().standalone() && !app_.config().IPS_FIXED.empty())
523  {
526  [this](
527  std::string const& name,
528  std::vector<beast::IP::Endpoint> const& addresses) {
530  ips.reserve(addresses.size());
531 
532  for (auto& addr : addresses)
533  {
534  if (addr.port() == 0)
535  ips.emplace_back(addr.address(), DEFAULT_PEER_PORT);
536  else
537  ips.emplace_back(addr);
538  }
539 
540  if (!ips.empty())
541  m_peerFinder->addFixedPeer(name, ips);
542  });
543  }
544  auto const timer = std::make_shared<Timer>(*this);
545  std::lock_guard lock(mutex_);
546  list_.emplace(timer.get(), timer);
547  timer_ = timer;
548  timer->async_wait();
549 }
550 
551 void
553 {
554  strand_.dispatch(std::bind(&OverlayImpl::stopChildren, this));
555  {
556  std::unique_lock<decltype(mutex_)> lock(mutex_);
557  cond_.wait(lock, [this] { return list_.empty(); });
558  }
559  m_peerFinder->stop();
560 }
561 
562 //------------------------------------------------------------------------------
563 //
564 // PropertyStream
565 //
566 //------------------------------------------------------------------------------
567 
568 void
570 {
571  beast::PropertyStream::Set set("traffic", stream);
572  auto const stats = m_traffic.getCounts();
573  for (auto const& i : stats)
574  {
575  if (i)
576  {
578  item["category"] = i.name;
579  item["bytes_in"] = std::to_string(i.bytesIn.load());
580  item["messages_in"] = std::to_string(i.messagesIn.load());
581  item["bytes_out"] = std::to_string(i.bytesOut.load());
582  item["messages_out"] = std::to_string(i.messagesOut.load());
583  }
584  }
585 }
586 
587 //------------------------------------------------------------------------------
593 void
595 {
596  // Now track this peer
597  {
598  std::lock_guard lock(mutex_);
599  auto const result(ids_.emplace(
600  std::piecewise_construct,
601  std::make_tuple(peer->id()),
602  std::make_tuple(peer)));
603  assert(result.second);
604  (void)result.second;
605  }
606 
607  JLOG(journal_.debug()) << "activated " << peer->getRemoteAddress() << " ("
608  << peer->id() << ":"
609  << toBase58(
610  TokenType::NodePublic, peer->getNodePublic())
611  << ")";
612 
613  // We just accepted this peer so we have non-zero active peers
614  assert(size() != 0);
615 }
616 
617 void
619 {
620  std::lock_guard lock(mutex_);
621  ids_.erase(id);
622 }
623 
624 void
627  std::shared_ptr<PeerImp> const& from)
628 {
629  auto const n = m->list_size();
630  auto const& journal = from->pjournal();
631 
632  protocol::TMManifests relay;
633 
634  for (std::size_t i = 0; i < n; ++i)
635  {
636  auto& s = m->list().Get(i).stobject();
637 
638  if (auto mo = deserializeManifest(s))
639  {
640  auto const serialized = mo->serialized;
641 
642  auto const result =
643  app_.validatorManifests().applyManifest(std::move(*mo));
644 
645  if (result == ManifestDisposition::accepted)
646  {
647  relay.add_list()->set_stobject(s);
648 
649  // N.B.: this is important; the applyManifest call above moves
650  // the loaded Manifest out of the optional so we need to
651  // reload it here.
652  mo = deserializeManifest(serialized);
653  assert(mo);
654 
655  app_.getOPs().pubManifest(*mo);
656 
657  if (app_.validators().listed(mo->masterKey))
658  {
659  auto db = app_.getWalletDB().checkoutDb();
660  addValidatorManifest(*db, serialized);
661  }
662  }
663  }
664  else
665  {
666  JLOG(journal.debug())
667  << "Malformed manifest #" << i + 1 << ": " << strHex(s);
668  continue;
669  }
670  }
671 
672  if (!relay.list().empty())
673  for_each([m2 = std::make_shared<Message>(relay, protocol::mtMANIFESTS)](
674  std::shared_ptr<PeerImp>&& p) { p->send(m2); });
675 }
676 
677 void
680  bool isInbound,
681  int number)
682 {
683  m_traffic.addCount(cat, isInbound, number);
684 }
685 
687 OverlayImpl::crawlShards(bool includePublicKey, std::uint32_t relays)
688 {
689  using namespace std::chrono;
690 
692 
693  // Add shard info from this server to json result
694  if (auto shardStore = app_.getShardStore())
695  {
696  if (includePublicKey)
697  jv[jss::public_key] =
699 
700  auto const shardInfo{shardStore->getShardInfo()};
701  if (!shardInfo->finalized().empty())
702  jv[jss::complete_shards] = shardInfo->finalizedToString();
703  if (!shardInfo->incomplete().empty())
704  jv[jss::incomplete_shards] = shardInfo->incompleteToString();
705  }
706 
707  if (relays == 0 || size() == 0)
708  return jv;
709 
710  {
711  protocol::TMGetPeerShardInfoV2 tmGPS;
712  tmGPS.set_relays(relays);
713 
714  // Wait if a request is in progress
716  if (!csIDs_.empty())
717  csCV_.wait(csLock);
718 
719  {
720  std::lock_guard lock{mutex_};
721  for (auto const& id : ids_)
722  csIDs_.emplace(id.first);
723  }
724 
725  // Request peer shard info
726  foreach(send_always(std::make_shared<Message>(
727  tmGPS, protocol::mtGET_PEER_SHARD_INFO_V2)));
728 
729  if (csCV_.wait_for(csLock, seconds(60)) == std::cv_status::timeout)
730  {
731  csIDs_.clear();
732  csCV_.notify_all();
733  }
734  }
735 
736  // Combine shard info from peers
738  for_each([&](std::shared_ptr<PeerImp>&& peer) {
739  auto const psi{peer->getPeerShardInfos()};
740  for (auto const& [publicKey, shardInfo] : psi)
741  {
742  auto const it{peerShardInfo.find(publicKey)};
743  if (it == peerShardInfo.end())
744  peerShardInfo.emplace(publicKey, shardInfo);
745  else if (shardInfo.msgTimestamp() > it->second.msgTimestamp())
746  it->second = shardInfo;
747  }
748  });
749 
750  // Add shard info to json result
751  if (!peerShardInfo.empty())
752  {
753  auto& av = jv[jss::peers] = Json::Value(Json::arrayValue);
754  for (auto const& [publicKey, shardInfo] : peerShardInfo)
755  {
756  auto& pv{av.append(Json::Value(Json::objectValue))};
757  if (includePublicKey)
758  {
759  pv[jss::public_key] =
760  toBase58(TokenType::NodePublic, publicKey);
761  }
762 
763  if (!shardInfo.finalized().empty())
764  pv[jss::complete_shards] = shardInfo.finalizedToString();
765  if (!shardInfo.incomplete().empty())
766  pv[jss::incomplete_shards] = shardInfo.incompleteToString();
767  }
768  }
769 
770  return jv;
771 }
772 
773 void
775 {
776  // Notify threads if all peers have received a reply from all peer chains
777  std::lock_guard csLock{csMutex_};
778  csIDs_.erase(id);
779  if (csIDs_.empty())
780  csCV_.notify_all();
781 }
782 
789 {
790  std::lock_guard lock(mutex_);
791  return ids_.size();
792 }
793 
794 int
796 {
797  return m_peerFinder->config().maxPeers;
798 }
799 
802 {
803  using namespace std::chrono;
804  Json::Value jv;
805  auto& av = jv["active"] = Json::Value(Json::arrayValue);
806 
808  auto& pv = av.append(Json::Value(Json::objectValue));
809  pv[jss::public_key] = base64_encode(
810  sp->getNodePublic().data(), sp->getNodePublic().size());
811  pv[jss::type] = sp->slot()->inbound() ? "in" : "out";
812  pv[jss::uptime] = static_cast<std::uint32_t>(
813  duration_cast<seconds>(sp->uptime()).count());
814  if (sp->crawl())
815  {
816  pv[jss::ip] = sp->getRemoteAddress().address().to_string();
817  if (sp->slot()->inbound())
818  {
819  if (auto port = sp->slot()->listening_port())
820  pv[jss::port] = *port;
821  }
822  else
823  {
824  pv[jss::port] = std::to_string(sp->getRemoteAddress().port());
825  }
826  }
827 
828  {
829  auto version{sp->getVersion()};
830  if (!version.empty())
831  // Could move here if Json::value supported moving from strings
832  pv[jss::version] = version;
833  }
834 
835  std::uint32_t minSeq, maxSeq;
836  sp->ledgerRange(minSeq, maxSeq);
837  if (minSeq != 0 || maxSeq != 0)
838  pv[jss::complete_ledgers] =
839  std::to_string(minSeq) + "-" + std::to_string(maxSeq);
840 
841  auto const peerShardInfos{sp->getPeerShardInfos()};
842  auto const it{peerShardInfos.find(sp->getNodePublic())};
843  if (it != peerShardInfos.end())
844  {
845  auto const& shardInfo{it->second};
846  if (!shardInfo.finalized().empty())
847  pv[jss::complete_shards] = shardInfo.finalizedToString();
848  if (!shardInfo.incomplete().empty())
849  pv[jss::incomplete_shards] = shardInfo.incompleteToString();
850  }
851  });
852 
853  return jv;
854 }
855 
858 {
859  bool const humanReadable = false;
860  bool const admin = false;
861  bool const counters = false;
862 
863  Json::Value server_info =
864  app_.getOPs().getServerInfo(humanReadable, admin, counters);
865 
866  // Filter out some information
867  server_info.removeMember(jss::hostid);
868  server_info.removeMember(jss::load_factor_fee_escalation);
869  server_info.removeMember(jss::load_factor_fee_queue);
870  server_info.removeMember(jss::validation_quorum);
871 
872  if (server_info.isMember(jss::validated_ledger))
873  {
874  Json::Value& validated_ledger = server_info[jss::validated_ledger];
875 
876  validated_ledger.removeMember(jss::base_fee);
877  validated_ledger.removeMember(jss::reserve_base_xrp);
878  validated_ledger.removeMember(jss::reserve_inc_xrp);
879  }
880 
881  return server_info;
882 }
883 
886 {
887  return getCountsJson(app_, 10);
888 }
889 
892 {
893  Json::Value validators = app_.validators().getJson();
894 
895  if (validators.isMember(jss::publisher_lists))
896  {
897  Json::Value& publisher_lists = validators[jss::publisher_lists];
898 
899  for (auto& publisher : publisher_lists)
900  {
901  publisher.removeMember(jss::list);
902  }
903  }
904 
905  validators.removeMember(jss::signing_keys);
906  validators.removeMember(jss::trusted_validator_keys);
907  validators.removeMember(jss::validation_quorum);
908 
909  Json::Value validatorSites = app_.validatorSites().getJson();
910 
911  if (validatorSites.isMember(jss::validator_sites))
912  {
913  validators[jss::validator_sites] =
914  std::move(validatorSites[jss::validator_sites]);
915  }
916 
917  return validators;
918 }
919 
920 // Returns information on verified peers.
923 {
925  for (auto const& peer : getActivePeers())
926  {
927  json.append(peer->json());
928  }
929  return json;
930 }
931 
932 bool
934 {
935  if (req.target() != "/crawl" ||
937  return false;
938 
939  boost::beast::http::response<json_body> msg;
940  msg.version(req.version());
941  msg.result(boost::beast::http::status::ok);
942  msg.insert("Server", BuildInfo::getFullVersionString());
943  msg.insert("Content-Type", "application/json");
944  msg.insert("Connection", "close");
945  msg.body()["version"] = Json::Value(2u);
946 
948  {
949  msg.body()["overlay"] = getOverlayInfo();
950  }
952  {
953  msg.body()["server"] = getServerInfo();
954  }
956  {
957  msg.body()["counts"] = getServerCounts();
958  }
960  {
961  msg.body()["unl"] = getUnlInfo();
962  }
963 
964  msg.prepare_payload();
965  handoff.response = std::make_shared<SimpleWriter>(msg);
966  return true;
967 }
968 
969 bool
971  http_request_type const& req,
972  Handoff& handoff)
973 {
974  // If the target is in the form "/vl/<validator_list_public_key>",
975  // return the most recent validator list for that key.
976  constexpr std::string_view prefix("/vl/");
977 
978  if (!req.target().starts_with(prefix.data()) || !setup_.vlEnabled)
979  return false;
980 
981  std::uint32_t version = 1;
982 
983  boost::beast::http::response<json_body> msg;
984  msg.version(req.version());
985  msg.insert("Server", BuildInfo::getFullVersionString());
986  msg.insert("Content-Type", "application/json");
987  msg.insert("Connection", "close");
988 
989  auto fail = [&msg, &handoff](auto status) {
990  msg.result(status);
991  msg.insert("Content-Length", "0");
992 
993  msg.body() = Json::nullValue;
994 
995  msg.prepare_payload();
996  handoff.response = std::make_shared<SimpleWriter>(msg);
997  return true;
998  };
999 
1000  auto key = req.target().substr(prefix.size());
1001 
1002  if (auto slash = key.find('/'); slash != boost::string_view::npos)
1003  {
1004  auto verString = key.substr(0, slash);
1005  if (!boost::conversion::try_lexical_convert(verString, version))
1006  return fail(boost::beast::http::status::bad_request);
1007  key = key.substr(slash + 1);
1008  }
1009 
1010  if (key.empty())
1011  return fail(boost::beast::http::status::bad_request);
1012 
1013  // find the list
1014  auto vl = app_.validators().getAvailable(key, version);
1015 
1016  if (!vl)
1017  {
1018  // 404 not found
1019  return fail(boost::beast::http::status::not_found);
1020  }
1021  else if (!*vl)
1022  {
1023  return fail(boost::beast::http::status::bad_request);
1024  }
1025  else
1026  {
1027  msg.result(boost::beast::http::status::ok);
1028 
1029  msg.body() = *vl;
1030 
1031  msg.prepare_payload();
1032  handoff.response = std::make_shared<SimpleWriter>(msg);
1033  return true;
1034  }
1035 }
1036 
1037 bool
1039 {
1040  if (req.target() != "/health")
1041  return false;
1042  boost::beast::http::response<json_body> msg;
1043  msg.version(req.version());
1044  msg.insert("Server", BuildInfo::getFullVersionString());
1045  msg.insert("Content-Type", "application/json");
1046  msg.insert("Connection", "close");
1047 
1048  auto info = getServerInfo();
1049 
1050  int last_validated_ledger_age = -1;
1051  if (info.isMember(jss::validated_ledger))
1052  last_validated_ledger_age =
1053  info[jss::validated_ledger][jss::age].asInt();
1054  bool amendment_blocked = false;
1055  if (info.isMember(jss::amendment_blocked))
1056  amendment_blocked = true;
1057  int number_peers = info[jss::peers].asInt();
1058  std::string server_state = info[jss::server_state].asString();
1059  auto load_factor = info[jss::load_factor_server].asDouble() /
1060  info[jss::load_base].asDouble();
1061 
1062  enum { healthy, warning, critical };
1063  int health = healthy;
1064  auto set_health = [&health](int state) {
1065  if (health < state)
1066  health = state;
1067  };
1068 
1069  msg.body()[jss::info] = Json::objectValue;
1070  if (last_validated_ledger_age >= 7 || last_validated_ledger_age < 0)
1071  {
1072  msg.body()[jss::info][jss::validated_ledger] =
1073  last_validated_ledger_age;
1074  if (last_validated_ledger_age < 20)
1075  set_health(warning);
1076  else
1077  set_health(critical);
1078  }
1079 
1080  if (amendment_blocked)
1081  {
1082  msg.body()[jss::info][jss::amendment_blocked] = true;
1083  set_health(critical);
1084  }
1085 
1086  if (number_peers <= 7)
1087  {
1088  msg.body()[jss::info][jss::peers] = number_peers;
1089  if (number_peers != 0)
1090  set_health(warning);
1091  else
1092  set_health(critical);
1093  }
1094 
1095  if (!(server_state == "full" || server_state == "validating" ||
1096  server_state == "proposing"))
1097  {
1098  msg.body()[jss::info][jss::server_state] = server_state;
1099  if (server_state == "syncing" || server_state == "tracking" ||
1100  server_state == "connected")
1101  {
1102  set_health(warning);
1103  }
1104  else
1105  set_health(critical);
1106  }
1107 
1108  if (load_factor > 100)
1109  {
1110  msg.body()[jss::info][jss::load_factor] = load_factor;
1111  if (load_factor < 1000)
1112  set_health(warning);
1113  else
1114  set_health(critical);
1115  }
1116 
1117  switch (health)
1118  {
1119  case healthy:
1120  msg.result(boost::beast::http::status::ok);
1121  break;
1122  case warning:
1123  msg.result(boost::beast::http::status::service_unavailable);
1124  break;
1125  case critical:
1126  msg.result(boost::beast::http::status::internal_server_error);
1127  break;
1128  }
1129 
1130  msg.prepare_payload();
1131  handoff.response = std::make_shared<SimpleWriter>(msg);
1132  return true;
1133 }
1134 
1135 bool
1137 {
1138  // Take advantage of || short-circuiting
1139  return processCrawl(req, handoff) || processValidatorList(req, handoff) ||
1140  processHealth(req, handoff);
1141 }
1142 
1145 {
1147  ret.reserve(size());
1148 
1149  for_each([&ret](std::shared_ptr<PeerImp>&& sp) {
1150  ret.emplace_back(std::move(sp));
1151  });
1152 
1153  return ret;
1154 }
1155 
1158  std::set<Peer::id_t> const& toSkip,
1159  std::size_t& active,
1160  std::size_t& disabled,
1161  std::size_t& enabledInSkip) const
1162 {
1164  std::lock_guard lock(mutex_);
1165 
1166  active = ids_.size();
1167  disabled = enabledInSkip = 0;
1168  ret.reserve(ids_.size());
1169 
1170  for (auto& [id, w] : ids_)
1171  {
1172  if (auto p = w.lock())
1173  {
1174  bool const reduceRelayEnabled = p->txReduceRelayEnabled();
1175  // tx reduced relay feature disabled
1176  if (!reduceRelayEnabled)
1177  ++disabled;
1178 
1179  if (toSkip.count(id) == 0)
1180  ret.emplace_back(std::move(p));
1181  else if (reduceRelayEnabled)
1182  ++enabledInSkip;
1183  }
1184  }
1185 
1186  return ret;
1187 }
1188 
1189 void
1191 {
1192  for_each(
1193  [index](std::shared_ptr<PeerImp>&& sp) { sp->checkTracking(index); });
1194 }
1195 
1198 {
1199  std::lock_guard lock(mutex_);
1200  auto const iter = ids_.find(id);
1201  if (iter != ids_.end())
1202  return iter->second.lock();
1203  return {};
1204 }
1205 
1206 // A public key hash map was not used due to the peer connect/disconnect
1207 // update overhead outweighing the performance of a small set linear search.
1210 {
1211  std::lock_guard lock(mutex_);
1212  for (auto const& e : ids_)
1213  {
1214  if (auto peer = e.second.lock())
1215  {
1216  if (peer->getNodePublic() == pubKey)
1217  return peer;
1218  }
1219  }
1220  return {};
1221 }
1222 
1223 void
1224 OverlayImpl::broadcast(protocol::TMProposeSet& m)
1225 {
1226  auto const sm = std::make_shared<Message>(m, protocol::mtPROPOSE_LEDGER);
1227  for_each([&](std::shared_ptr<PeerImp>&& p) { p->send(sm); });
1228 }
1229 
1232  protocol::TMProposeSet& m,
1233  uint256 const& uid,
1234  PublicKey const& validator)
1235 {
1236  if (auto const toSkip = app_.getHashRouter().shouldRelay(uid))
1237  {
1238  auto const sm =
1239  std::make_shared<Message>(m, protocol::mtPROPOSE_LEDGER, validator);
1241  if (toSkip->find(p->id()) == toSkip->end())
1242  p->send(sm);
1243  });
1244  return *toSkip;
1245  }
1246  return {};
1247 }
1248 
1249 void
1250 OverlayImpl::broadcast(protocol::TMValidation& m)
1251 {
1252  auto const sm = std::make_shared<Message>(m, protocol::mtVALIDATION);
1253  for_each([sm](std::shared_ptr<PeerImp>&& p) { p->send(sm); });
1254 }
1255 
1258  protocol::TMValidation& m,
1259  uint256 const& uid,
1260  PublicKey const& validator)
1261 {
1262  if (auto const toSkip = app_.getHashRouter().shouldRelay(uid))
1263  {
1264  auto const sm =
1265  std::make_shared<Message>(m, protocol::mtVALIDATION, validator);
1267  if (toSkip->find(p->id()) == toSkip->end())
1268  p->send(sm);
1269  });
1270  return *toSkip;
1271  }
1272  return {};
1273 }
1274 
1277 {
1279 
1280  if (auto seq = app_.validatorManifests().sequence();
1281  seq != manifestListSeq_)
1282  {
1283  protocol::TMManifests tm;
1284 
1286  [&tm](std::size_t s) { tm.mutable_list()->Reserve(s); },
1287  [&tm, &hr = app_.getHashRouter()](Manifest const& manifest) {
1288  tm.add_list()->set_stobject(
1289  manifest.serialized.data(), manifest.serialized.size());
1290  hr.addSuppression(manifest.hash());
1291  });
1292 
1294 
1295  if (tm.list_size() != 0)
1297  std::make_shared<Message>(tm, protocol::mtMANIFESTS);
1298 
1299  manifestListSeq_ = seq;
1300  }
1301 
1302  return manifestMessage_;
1303 }
1304 
1305 void
1307  uint256 const& hash,
1308  protocol::TMTransaction& m,
1309  std::set<Peer::id_t> const& toSkip)
1310 {
1311  auto const sm = std::make_shared<Message>(m, protocol::mtTRANSACTION);
1312  std::size_t total = 0;
1313  std::size_t disabled = 0;
1314  std::size_t enabledInSkip = 0;
1315 
1316  // total peers excluding peers in toSkip
1317  auto peers = getActivePeers(toSkip, total, disabled, enabledInSkip);
1318  auto minRelay = app_.config().TX_REDUCE_RELAY_MIN_PEERS + disabled;
1319 
1320  if (!app_.config().TX_REDUCE_RELAY_ENABLE || total <= minRelay)
1321  {
1322  for (auto const& p : peers)
1323  p->send(sm);
1326  txMetrics_.addMetrics(total, toSkip.size(), 0);
1327  return;
1328  }
1329 
1330  // We have more peers than the minimum (disabled + minimum enabled),
1331  // relay to all disabled and some randomly selected enabled that
1332  // do not have the transaction.
1333  auto enabledTarget = app_.config().TX_REDUCE_RELAY_MIN_PEERS +
1334  (total - minRelay) * app_.config().TX_RELAY_PERCENTAGE / 100;
1335 
1336  txMetrics_.addMetrics(enabledTarget, toSkip.size(), disabled);
1337 
1338  if (enabledTarget > enabledInSkip)
1339  std::shuffle(peers.begin(), peers.end(), default_prng());
1340 
1341  JLOG(journal_.trace()) << "relaying tx, total peers " << peers.size()
1342  << " selected " << enabledTarget << " skip "
1343  << toSkip.size() << " disabled " << disabled;
1344 
1345  // count skipped peers with the enabled feature towards the quota
1346  std::uint16_t enabledAndRelayed = enabledInSkip;
1347  for (auto const& p : peers)
1348  {
1349  // always relay to a peer with the disabled feature
1350  if (!p->txReduceRelayEnabled())
1351  {
1352  p->send(sm);
1353  }
1354  else if (enabledAndRelayed < enabledTarget)
1355  {
1356  enabledAndRelayed++;
1357  p->send(sm);
1358  }
1359  else
1360  {
1361  p->addTxQueue(hash);
1362  }
1363  }
1364 }
1365 
1366 //------------------------------------------------------------------------------
1367 
1368 void
1370 {
1371  std::lock_guard lock(mutex_);
1372  list_.erase(&child);
1373  if (list_.empty())
1374  cond_.notify_all();
1375 }
1376 
1377 void
1379 {
1380  // Calling list_[].second->stop() may cause list_ to be modified
1381  // (OverlayImpl::remove() may be called on this same thread). So
1382  // iterating directly over list_ to call child->stop() could lead to
1383  // undefined behavior.
1384  //
1385  // Therefore we copy all of the weak/shared ptrs out of list_ before we
1386  // start calling stop() on them. That guarantees OverlayImpl::remove()
1387  // won't be called until vector<> children leaves scope.
1389  {
1390  std::lock_guard lock(mutex_);
1391  if (!work_)
1392  return;
1393  work_ = std::nullopt;
1394 
1395  children.reserve(list_.size());
1396  for (auto const& element : list_)
1397  {
1398  children.emplace_back(element.second.lock());
1399  }
1400  } // lock released
1401 
1402  for (auto const& child : children)
1403  {
1404  if (child != nullptr)
1405  child->stop();
1406  }
1407 }
1408 
1409 void
1411 {
1412  auto const result = m_peerFinder->autoconnect();
1413  for (auto addr : result)
1414  connect(addr);
1415 }
1416 
1417 void
1419 {
1420  auto const result = m_peerFinder->buildEndpointsForPeers();
1421  for (auto const& e : result)
1422  {
1424  {
1425  std::lock_guard lock(mutex_);
1426  auto const iter = m_peers.find(e.first);
1427  if (iter != m_peers.end())
1428  peer = iter->second.lock();
1429  }
1430  if (peer)
1431  peer->sendEndpoints(e.second.begin(), e.second.end());
1432  }
1433 }
1434 
1435 void
1437 {
1438  for_each([](auto const& p) {
1439  if (p->txReduceRelayEnabled())
1440  p->sendTxQueue();
1441  });
1442 }
1443 
1446  PublicKey const& validator,
1447  bool squelch,
1448  uint32_t squelchDuration)
1449 {
1450  protocol::TMSquelch m;
1451  m.set_squelch(squelch);
1452  m.set_validatorpubkey(validator.data(), validator.size());
1453  if (squelch)
1454  m.set_squelchduration(squelchDuration);
1455  return std::make_shared<Message>(m, protocol::mtSQUELCH);
1456 }
1457 
1458 void
1459 OverlayImpl::unsquelch(PublicKey const& validator, Peer::id_t id) const
1460 {
1461  if (auto peer = findPeerByShortID(id);
1462  peer && app_.config().VP_REDUCE_RELAY_SQUELCH)
1463  {
1464  // optimize - multiple message with different
1465  // validator might be sent to the same peer
1466  peer->send(makeSquelchMessage(validator, false, 0));
1467  }
1468 }
1469 
1470 void
1472  PublicKey const& validator,
1473  Peer::id_t id,
1474  uint32_t squelchDuration) const
1475 {
1476  if (auto peer = findPeerByShortID(id);
1477  peer && app_.config().VP_REDUCE_RELAY_SQUELCH)
1478  {
1479  peer->send(makeSquelchMessage(validator, true, squelchDuration));
1480  }
1481 }
1482 
1483 void
1485  uint256 const& key,
1486  PublicKey const& validator,
1487  std::set<Peer::id_t>&& peers,
1488  protocol::MessageType type)
1489 {
1490  if (!strand_.running_in_this_thread())
1491  return post(
1492  strand_,
1493  [this, key, validator, peers = std::move(peers), type]() mutable {
1494  updateSlotAndSquelch(key, validator, std::move(peers), type);
1495  });
1496 
1497  for (auto id : peers)
1498  slots_.updateSlotAndSquelch(key, validator, id, type);
1499 }
1500 
1501 void
1503  uint256 const& key,
1504  PublicKey const& validator,
1505  Peer::id_t peer,
1506  protocol::MessageType type)
1507 {
1508  if (!strand_.running_in_this_thread())
1509  return post(strand_, [this, key, validator, peer, type]() {
1510  updateSlotAndSquelch(key, validator, peer, type);
1511  });
1512 
1513  slots_.updateSlotAndSquelch(key, validator, peer, type);
1514 }
1515 
1516 void
1518 {
1519  if (!strand_.running_in_this_thread())
1520  return post(strand_, std::bind(&OverlayImpl::deletePeer, this, id));
1521 
1522  slots_.deletePeer(id, true);
1523 }
1524 
1525 void
1527 {
1528  if (!strand_.running_in_this_thread())
1529  return post(strand_, std::bind(&OverlayImpl::deleteIdlePeers, this));
1530 
1531  slots_.deleteIdlePeers();
1532 }
1533 
1534 //------------------------------------------------------------------------------
1535 
1538 {
1540 
1541  {
1542  auto const& section = config.section("overlay");
1544 
1545  set(setup.ipLimit, "ip_limit", section);
1546  if (setup.ipLimit < 0)
1547  Throw<std::runtime_error>("Configured IP limit is invalid");
1548 
1549  std::string ip;
1550  set(ip, "public_ip", section);
1551  if (!ip.empty())
1552  {
1553  boost::system::error_code ec;
1554  setup.public_ip = beast::IP::Address::from_string(ip, ec);
1556  Throw<std::runtime_error>("Configured public IP is invalid");
1557  }
1558  }
1559 
1560  {
1561  auto const& section = config.section("crawl");
1562  auto const& values = section.values();
1563 
1564  if (values.size() > 1)
1565  {
1566  Throw<std::runtime_error>(
1567  "Configured [crawl] section is invalid, too many values");
1568  }
1569 
1570  bool crawlEnabled = true;
1571 
1572  // Only allow "0|1" as a value
1573  if (values.size() == 1)
1574  {
1575  try
1576  {
1577  crawlEnabled = boost::lexical_cast<bool>(values.front());
1578  }
1579  catch (boost::bad_lexical_cast const&)
1580  {
1581  Throw<std::runtime_error>(
1582  "Configured [crawl] section has invalid value: " +
1583  values.front());
1584  }
1585  }
1586 
1587  if (crawlEnabled)
1588  {
1589  if (get<bool>(section, "overlay", true))
1590  {
1592  }
1593  if (get<bool>(section, "server", true))
1594  {
1596  }
1597  if (get<bool>(section, "counts", false))
1598  {
1600  }
1601  if (get<bool>(section, "unl", true))
1602  {
1604  }
1605  }
1606  }
1607  {
1608  auto const& section = config.section("vl");
1609 
1610  set(setup.vlEnabled, "enabled", section);
1611  }
1612 
1613  try
1614  {
1615  auto id = config.legacy("network_id");
1616 
1617  if (!id.empty())
1618  {
1619  if (id == "main")
1620  id = "0";
1621 
1622  if (id == "testnet")
1623  id = "1";
1624 
1625  if (id == "devnet")
1626  id = "2";
1627 
1628  setup.networkID = beast::lexicalCastThrow<std::uint32_t>(id);
1629  }
1630  }
1631  catch (...)
1632  {
1633  Throw<std::runtime_error>(
1634  "Configured [network_id] section is invalid: must be a number "
1635  "or one of the strings 'main', 'testnet' or 'devnet'.");
1636  }
1637 
1638  return setup;
1639 }
1640 
1643  Application& app,
1644  Overlay::Setup const& setup,
1645  ServerHandler& serverHandler,
1647  Resolver& resolver,
1648  boost::asio::io_service& io_service,
1649  BasicConfig const& config,
1650  beast::insight::Collector::ptr const& collector)
1651 {
1652  return std::make_unique<OverlayImpl>(
1653  app,
1654  setup,
1655  serverHandler,
1657  resolver,
1658  io_service,
1659  config,
1660  collector);
1661 }
1662 
1663 } // namespace ripple
ripple::OverlayImpl::OverlayImpl
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)
Definition: OverlayImpl.cpp:117
beast::PropertyStream::Source::name
std::string const & name() const
Returns the name of this source.
Definition: beast_PropertyStream.cpp:190
ripple::Resource::Manager::newInboundEndpoint
virtual Consumer newInboundEndpoint(beast::IP::Endpoint const &address)=0
Create a new endpoint keyed by inbound IP address or the forwarded IP if proxied.
ripple::Resource::Manager::newOutboundEndpoint
virtual Consumer newOutboundEndpoint(beast::IP::Endpoint const &address)=0
Create a new endpoint keyed by outbound IP address and port.
ripple::Application
Definition: Application.h:115
ripple::OverlayImpl::getServerCounts
Json::Value getServerCounts()
Returns information about the local server's performance counters.
Definition: OverlayImpl.cpp:885
ripple::OverlayImpl::journal_
const beast::Journal journal_
Definition: OverlayImpl.h:108
std::make_tuple
T make_tuple(T... args)
ripple::OverlayImpl::address_type
boost::asio::ip::address address_type
Definition: OverlayImpl.h:78
ripple::Application::cluster
virtual Cluster & cluster()=0
ripple::NetworkOPs::getServerInfo
virtual Json::Value getServerInfo(bool human, bool admin, bool counters)=0
ripple::TrafficCount::getCounts
auto const & getCounts() const
An up-to-date copy of all the counters.
Definition: TrafficCount.h:196
std::bind
T bind(T... args)
std::string
STL class.
std::shared_ptr< Collector >
ripple::makeSquelchMessage
std::shared_ptr< Message > makeSquelchMessage(PublicKey const &validator, bool squelch, uint32_t squelchDuration)
Definition: OverlayImpl.cpp:1445
ripple::Overlay::Setup::networkID
std::optional< std::uint32_t > networkID
Definition: Overlay.h:75
std::exception
STL class.
ripple::make_Overlay
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.
Definition: OverlayImpl.cpp:1642
ripple::CrawlOptions::Disabled
@ Disabled
Definition: OverlayImpl.cpp:48
beast::Journal::trace
Stream trace() const
Severity stream access functions.
Definition: Journal.h:309
beast::PropertyStream::Map
Definition: PropertyStream.h:224
ripple::OverlayImpl::collect_metrics
void collect_metrics()
Definition: OverlayImpl.h:615
std::string_view
STL class.
ripple::InfoSub::Source::pubManifest
virtual void pubManifest(Manifest const &)=0
ripple::OverlayImpl::is_upgrade
static bool is_upgrade(boost::beast::http::header< true, Fields > const &req)
Definition: OverlayImpl.h:323
ripple::OverlayImpl::ids_
hash_map< Peer::id_t, std::weak_ptr< PeerImp > > ids_
Definition: OverlayImpl.h:114
ripple::Manifest
Definition: Manifest.h:80
Json::arrayValue
@ arrayValue
array value (ordered list)
Definition: json_value.h:42
std::vector::reserve
T reserve(T... args)
ripple::OverlayImpl::updateSlotAndSquelch
void updateSlotAndSquelch(uint256 const &key, PublicKey const &validator, std::set< Peer::id_t > &&peers, protocol::MessageType type)
Updates message count for validator/peer.
Definition: OverlayImpl.cpp:1484
ripple::OverlayImpl::autoConnect
void autoConnect()
Definition: OverlayImpl.cpp:1410
ripple::Application::validatorSites
virtual ValidatorSite & validatorSites()=0
ripple::HashPrefix::manifest
@ manifest
Manifest.
ripple::Overlay::Setup::crawlOptions
std::uint32_t crawlOptions
Definition: Overlay.h:74
ripple::OverlayImpl::endOfPeerChain
void endOfPeerChain(std::uint32_t id)
Called when the reply from the last peer in a peer chain is received.
Definition: OverlayImpl.cpp:774
ripple::OverlayImpl::stop
void stop() override
Definition: OverlayImpl.cpp:552
ripple::OverlayImpl::csIDs_
std::set< std::uint32_t > csIDs_
Definition: OverlayImpl.h:126
ripple::OverlayImpl::m_resolver
Resolver & m_resolver
Definition: OverlayImpl.h:115
ripple::OverlayImpl::mutex_
std::recursive_mutex mutex_
Definition: OverlayImpl.h:103
ripple::OverlayImpl::Timer::on_timer
void on_timer(error_code ec)
Definition: OverlayImpl.cpp:92
std::vector
STL class.
std::find_if
T find_if(T... args)
std::vector::size
T size(T... args)
ripple::Application::peerReservations
virtual PeerReservationTable & peerReservations()=0
ripple::OverlayImpl::next_id_
std::atomic< Peer::id_t > next_id_
Definition: OverlayImpl.h:116
ripple::base64_encode
std::string base64_encode(std::uint8_t const *data, std::size_t len)
Definition: base64.cpp:236
ripple::PublicKey::empty
bool empty() const noexcept
Definition: PublicKey.h:117
ripple::make_SSLContext
std::shared_ptr< boost::asio::ssl::context > make_SSLContext(std::string const &cipherList)
Create a self-signed SSL context that allows anonymous Diffie Hellman.
Definition: make_SSLContext.cpp:364
ripple::OverlayImpl::makePrefix
static std::string makePrefix(std::uint32_t id)
Definition: OverlayImpl.cpp:335
ripple::OverlayImpl::onHandoff
Handoff onHandoff(std::unique_ptr< stream_type > &&bundle, http_request_type &&request, endpoint_type remote_endpoint) override
Conditionally accept an incoming HTTP request.
Definition: OverlayImpl.cpp:163
std::chrono::seconds
ripple::toBase58
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Definition: AccountID.cpp:104
std::set::emplace
T emplace(T... args)
ripple::OverlayImpl::csCV_
std::condition_variable csCV_
Definition: OverlayImpl.h:124
std::stringstream
STL class.
ripple::ServerHandlerImp::setup
void setup(Setup const &setup, beast::Journal journal)
Definition: ServerHandlerImp.cpp:130
ripple::addValidatorManifest
void addValidatorManifest(soci::session &session, std::string const &serialized)
addValidatorManifest Saves the manifest of a validator to the database.
Definition: Wallet.cpp:115
ripple::OverlayImpl::strand_
boost::asio::io_service::strand strand_
Definition: OverlayImpl.h:102
std::shared_ptr::get
T get(T... args)
ripple::OverlayImpl::getServerInfo
Json::Value getServerInfo()
Returns information about the local server.
Definition: OverlayImpl.cpp:857
std::lock_guard
STL class.
ripple::Application::getShardStore
virtual NodeStore::DatabaseShard * getShardStore()=0
ripple::parseProtocolVersions
std::vector< ProtocolVersion > parseProtocolVersions(boost::beast::string_view const &value)
Parse a set of protocol versions.
Definition: ProtocolVersion.cpp:78
ripple::OverlayImpl::stopChildren
void stopChildren()
Definition: OverlayImpl.cpp:1378
ripple::makeSharedValue
std::optional< uint256 > makeSharedValue(stream_type &ssl, beast::Journal journal)
Computes a shared value based on the SSL connection state.
Definition: Handshake.cpp:145
ripple::Cluster::member
std::optional< std::string > member(PublicKey const &node) const
Determines whether a node belongs in the cluster.
Definition: Cluster.cpp:39
ripple::stopwatch
Stopwatch & stopwatch()
Returns an instance of a wall clock.
Definition: chrono.h:88
std::setfill
T setfill(T... args)
ripple::OverlayImpl::broadcast
void broadcast(protocol::TMProposeSet &m) override
Broadcast a proposal.
Definition: OverlayImpl.cpp:1224
ripple::PeerFinder::Manager::new_outbound_slot
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.
ripple::OverlayImpl::connect
void connect(beast::IP::Endpoint const &remote_endpoint) override
Establish a peer connection to the specified endpoint.
Definition: OverlayImpl.cpp:390
ripple::OverlayImpl::json
Json::Value json() override
Return diagnostics on the status of all peers.
Definition: OverlayImpl.cpp:922
ripple::OverlayImpl::setup
Setup const & setup() const
Definition: OverlayImpl.h:176
ripple::OverlayImpl::timer_count_
int timer_count_
Definition: OverlayImpl.h:117
ripple::OverlayImpl::processValidatorList
bool processValidatorList(http_request_type const &req, Handoff &handoff)
Handles validator list requests.
Definition: OverlayImpl.cpp:970
beast::PropertyStream::Set
Definition: PropertyStream.h:296
std::shared_ptr::reset
T reset(T... args)
ripple::Application::getOPs
virtual NetworkOPs & getOPs()=0
ripple::Application::getWalletDB
virtual DatabaseCon & getWalletDB()=0
Retrieve the "wallet database".
ripple::OverlayImpl::m_traffic
TrafficCount m_traffic
Definition: OverlayImpl.h:112
ripple::OverlayImpl::processHealth
bool processHealth(http_request_type const &req, Handoff &handoff)
Handles health requests.
Definition: OverlayImpl.cpp:1038
ripple::OverlayImpl::setup_
Setup setup_
Definition: OverlayImpl.h:107
ripple::Section::values
std::vector< std::string > const & values() const
Returns all the values in the section.
Definition: BasicConfig.h:77
std::set::clear
T clear(T... args)
beast::IP::is_private
bool is_private(AddressV4 const &addr)
Returns true if the address is a private unroutable address.
Definition: IPAddressV4.cpp:29
ripple::send_always
Sends a message to all peers.
Definition: predicates.h:31
ripple::OverlayImpl::start
void start() override
Definition: OverlayImpl.cpp:471
ripple::PeerFinder::Config::makeConfig
static Config makeConfig(ripple::Config const &config, std::uint16_t port, bool validationPublicKey, int ipLimit)
Make PeerFinder::Config from configuration parameters.
Definition: PeerfinderConfig.cpp:78
ripple::OverlayImpl::cond_
std::condition_variable_any cond_
Definition: OverlayImpl.h:104
ripple::OverlayImpl::sendTxQueue
void sendTxQueue()
Send once a second transactions' hashes aggregated by peers.
Definition: OverlayImpl.cpp:1436
ripple::TrafficCount::category
category
Definition: TrafficCount.h:67
std::vector::push_back
T push_back(T... args)
beast::IPAddressConversion::from_asio
static IP::Endpoint from_asio(boost::asio::ip::address const &address)
Definition: IPAddressConversion.h:63
ripple::Tuning::checkIdlePeers
@ checkIdlePeers
How often we check for idle peers (seconds)
Definition: overlay/impl/Tuning.h:58
ripple::PeerFinder::Result::success
@ success
ripple::OverlayImpl::peerFinder
PeerFinder::Manager & peerFinder()
Definition: OverlayImpl.h:164
ripple::base_uint< 256 >
ripple::OverlayImpl::size
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...
Definition: OverlayImpl.cpp:788
ripple::OverlayImpl::checkTracking
void checkTracking(std::uint32_t) override
Calls the checkTracking function on each peer.
Definition: OverlayImpl.cpp:1190
beast::rfc2616::is_keep_alive
bool is_keep_alive(boost::beast::http::message< isRequest, Body, Fields > const &m)
Definition: rfc2616.h:386
ripple::setup_Overlay
Overlay::Setup setup_Overlay(BasicConfig const &config)
Definition: OverlayImpl.cpp:1537
ripple::OverlayImpl::csMutex_
std::mutex csMutex_
Definition: OverlayImpl.h:123
Json::Value::append
Value & append(const Value &value)
Append value to array at the end.
Definition: json_value.cpp:882
ripple::OverlayImpl::onManifests
void onManifests(std::shared_ptr< protocol::TMManifests > const &m, std::shared_ptr< PeerImp > const &from)
Definition: OverlayImpl.cpp:625
ripple::Overlay::Setup::public_ip
beast::IP::Address public_ip
Definition: Overlay.h:72
ripple::OverlayImpl::manifestMessage_
std::shared_ptr< Message > manifestMessage_
Definition: OverlayImpl.h:134
ripple::DatabaseCon::checkoutDb
LockedSociSession checkoutDb()
Definition: DatabaseCon.h:178
ripple::OverlayImpl::resourceManager
Resource::Manager & resourceManager()
Definition: OverlayImpl.h:170
Json::objectValue
@ objectValue
object value (collection of name/value pairs).
Definition: json_value.h:43
beast::PropertyStream::Source::add
void add(Source &source)
Add a child source.
Definition: beast_PropertyStream.cpp:196
ripple::PublicKey
A public key.
Definition: PublicKey.h:59
ripple::OverlayImpl::getOverlayInfo
Json::Value getOverlayInfo()
Returns information about peers on the overlay network.
Definition: OverlayImpl.cpp:801
ripple::OverlayImpl::io_service_
boost::asio::io_service & io_service_
Definition: OverlayImpl.h:100
ripple::Application::config
virtual Config & config()=0
ripple::ValidatorSite::getJson
Json::Value getJson() const
Return JSON representation of configured validator sites.
Definition: ValidatorSite.cpp:667
ripple::Config::IPS_FIXED
std::vector< std::string > IPS_FIXED
Definition: Config.h:150
ripple::ServerHandlerImp
Definition: ServerHandlerImp.h:47
ripple::Config::standalone
bool standalone() const
Definition: Config.h:332
std::unique_lock
STL class.
ripple::Resolver
Definition: Resolver.h:30
ripple::OverlayImpl::slots_
reduce_relay::Slots< UptimeClock > slots_
Definition: OverlayImpl.h:128
ripple::Application::nodeIdentity
virtual std::pair< PublicKey, SecretKey > const & nodeIdentity()=0
ripple::OverlayImpl::m_stats
Stats m_stats
Definition: OverlayImpl.h:610
std::to_string
T to_string(T... args)
ripple::set
bool set(T &target, std::string const &name, Section const &section)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
Definition: BasicConfig.h:313
ripple::OverlayImpl::getUnlInfo
Json::Value getUnlInfo()
Returns information about the local server's UNL.
Definition: OverlayImpl.cpp:891
ripple::ValidatorList::listed
bool listed(PublicKey const &identity) const
Returns true if public key is included on any lists.
Definition: ValidatorList.cpp:1349
ripple::default_prng
beast::xor_shift_engine & default_prng()
Return the default random engine.
Definition: ripple/basics/random.h:65
beast::Journal::info
Stream info() const
Definition: Journal.h:321
std::set::erase
T erase(T... args)
ripple::ValidatorList::getAvailable
std::optional< Json::Value > getAvailable(boost::beast::string_view const &pubKey, std::optional< std::uint32_t > forceVersion={})
Returns the current valid list for the given publisher key, if available, as a Json object.
Definition: ValidatorList.cpp:1678
ripple::BasicConfig::legacy
void legacy(std::string const &section, std::string value)
Set a value that is not a key/value pair.
Definition: BasicConfig.cpp:164
ripple::Application::logs
virtual Logs & logs()=0
ripple::ManifestCache::for_each_manifest
void for_each_manifest(Function &&f) const
Invokes the callback once for every populated manifest.
Definition: Manifest.h:401
ripple::OverlayImpl::app_
Application & app_
Definition: OverlayImpl.h:99
ripple::CrawlOptions::ServerCounts
@ ServerCounts
Definition: OverlayImpl.cpp:51
ripple::OverlayImpl::m_peerFinder
std::unique_ptr< PeerFinder::Manager > m_peerFinder
Definition: OverlayImpl.h:111
Json::Value::isMember
bool isMember(const char *key) const
Return true if the object has a member named key.
Definition: json_value.cpp:932
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::OverlayImpl::serverHandler_
ServerHandler & serverHandler_
Definition: OverlayImpl.h:109
std::uint32_t
std::condition_variable_any::wait
T wait(T... args)
ripple::OverlayImpl::TrafficGauges
Definition: OverlayImpl.h:574
ripple::OverlayImpl::Child::Child
Child(OverlayImpl &overlay)
Definition: OverlayImpl.cpp:58
ripple::HashRouter::shouldRelay
std::optional< std::set< PeerShortID > > shouldRelay(uint256 const &key)
Determines whether the hashed item should be relayed.
Definition: HashRouter.cpp:118
ripple::OverlayImpl::getActivePeers
PeerSequence getActivePeers() const override
Returns a sequence representing the current list of peers.
Definition: OverlayImpl.cpp:1144
ripple::CrawlOptions::Unl
@ Unl
Definition: OverlayImpl.cpp:52
beast::rfc2616::split_commas
Result split_commas(FwdIt first, FwdIt last)
Definition: rfc2616.h:199
ripple::Application::getValidationPublicKey
virtual PublicKey const & getValidationPublicKey() const =0
ripple::OverlayImpl::Timer::async_wait
void async_wait()
Definition: OverlayImpl.cpp:84
ripple::Handoff::moved
bool moved
Definition: Handoff.h:41
std::condition_variable::wait_for
T wait_for(T... args)
ripple::CrawlOptions::Overlay
@ Overlay
Definition: OverlayImpl.cpp:49
ripple::OverlayImpl::deleteIdlePeers
void deleteIdlePeers()
Check if peers stopped relaying messages and if slots stopped receiving messages from the validator.
Definition: OverlayImpl.cpp:1526
ripple::Application::validators
virtual ValidatorList & validators()=0
ripple::OverlayImpl::processRequest
bool processRequest(http_request_type const &req, Handoff &handoff)
Handles non-peer protocol requests.
Definition: OverlayImpl.cpp:1136
ripple::OverlayImpl::manifestListSeq_
std::optional< std::uint32_t > manifestListSeq_
Definition: OverlayImpl.h:136
ripple::ManifestDisposition::accepted
@ accepted
Manifest is valid.
ripple::Resource::Manager
Tracks load and resource consumption.
Definition: ResourceManager.h:36
std::ostringstream
STL class.
ripple::BuildInfo::getFullVersionString
std::string const & getFullVersionString()
Full server version string.
Definition: BuildInfo.cpp:78
ripple::OverlayImpl::deletePeer
void deletePeer(Peer::id_t id)
Called when the peer is deleted.
Definition: OverlayImpl.cpp:1517
ripple::getCountsJson
Json::Value getCountsJson(Application &app, int minObjectCount)
Definition: GetCounts.cpp:65
ripple::OverlayImpl::Child::~Child
virtual ~Child()
Definition: OverlayImpl.cpp:62
ripple::OverlayImpl::m_resourceManager
Resource::Manager & m_resourceManager
Definition: OverlayImpl.h:110
std::vector::emplace_back
T emplace_back(T... args)
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::OverlayImpl::relay
std::set< Peer::id_t > relay(protocol::TMProposeSet &m, uint256 const &uid, PublicKey const &validator) override
Relay a proposal.
Definition: OverlayImpl.cpp:1231
ripple::metrics::TxMetrics::addMetrics
void addMetrics(protocol::MessageType type, std::uint32_t val)
Add protocol message metrics.
Definition: TxMetrics.cpp:30
ripple::Overlay::Setup::ipLimit
int ipLimit
Definition: Overlay.h:73
ripple::Application::journal
virtual beast::Journal journal(std::string const &name)=0
ripple::Application::validatorManifests
virtual ManifestCache & validatorManifests()=0
ripple::OverlayImpl::getManifestsMessage
std::shared_ptr< Message > getManifestsMessage()
Definition: OverlayImpl.cpp:1276
Json::Value::removeMember
Value removeMember(const char *key)
Remove and return the named member.
Definition: json_value.cpp:907
ripple::OverlayImpl::crawlShards
Json::Value crawlShards(bool includePublicKey, std::uint32_t relays) override
Returns information reported to the crawl shard RPC command.
Definition: OverlayImpl.cpp:687
ripple::Overlay::Setup::vlEnabled
bool vlEnabled
Definition: Overlay.h:76
ripple::Config::TX_REDUCE_RELAY_MIN_PEERS
std::size_t TX_REDUCE_RELAY_MIN_PEERS
Definition: Config.h:274
ripple::OverlayImpl::remove
void remove(std::shared_ptr< PeerFinder::Slot > const &slot)
Definition: OverlayImpl.cpp:462
ripple::Overlay
Manages the set of connected peers.
Definition: Overlay.h:51
ripple::Config::TX_REDUCE_RELAY_METRICS
bool TX_REDUCE_RELAY_METRICS
Definition: Config.h:271
std
STL namespace.
ripple::OverlayImpl::activate
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...
Definition: OverlayImpl.cpp:594
ripple::OverlayImpl::onPeerDeactivate
void onPeerDeactivate(Peer::id_t id)
Definition: OverlayImpl.cpp:618
Json::nullValue
@ nullValue
'null' value
Definition: json_value.h:36
ripple::OverlayImpl::list_
boost::container::flat_map< Child *, std::weak_ptr< Child > > list_
Definition: OverlayImpl.h:106
ripple::OverlayImpl::work_
std::optional< boost::asio::io_service::work > work_
Definition: OverlayImpl.h:101
ripple::OverlayImpl::Timer::Timer
Timer(OverlayImpl &overlay)
Definition: OverlayImpl.cpp:69
std::set::count
T count(T... args)
ripple::OverlayImpl::squelch
void squelch(PublicKey const &validator, Peer::id_t const id, std::uint32_t squelchDuration) const override
Squelch handler.
Definition: OverlayImpl.cpp:1471
beast::WrappedSink
Wraps a Journal::Sink to prefix its output with a string.
Definition: WrappedSink.h:33
std::vector::empty
T empty(T... args)
ripple::Handoff
Used to indicate the result of a server connection handoff.
Definition: Handoff.h:37
ripple::TokenType::NodePublic
@ NodePublic
ripple::Overlay::Setup
Definition: Overlay.h:67
ripple::OverlayImpl::Timer::stop
void stop() override
Definition: OverlayImpl.cpp:75
ripple::OverlayImpl::findPeerByPublicKey
std::shared_ptr< Peer > findPeerByPublicKey(PublicKey const &pubKey) override
Returns the peer with the matching public key, or null.
Definition: OverlayImpl.cpp:1209
ripple::ValidatorList::getJson
Json::Value getJson() const
Return a JSON representation of the state of the validator list.
Definition: ValidatorList.cpp:1507
ripple::PeerReservationTable::contains
bool contains(PublicKey const &nodeId)
Definition: PeerReservationTable.h:92
std::stringstream::str
T str(T... args)
beast::Journal::debug
Stream debug() const
Definition: Journal.h:315
ripple::Config::IPS
std::vector< std::string > IPS
Definition: Config.h:149
ripple::OverlayImpl::txMetrics_
metrics::TxMetrics txMetrics_
Definition: OverlayImpl.h:131
std::size_t
ripple::to_string
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
Definition: app/misc/impl/Manifest.cpp:41
ripple::OverlayImpl::makeRedirectResponse
std::shared_ptr< Writer > makeRedirectResponse(std::shared_ptr< PeerFinder::Slot > const &slot, http_request_type const &request, address_type remote_address)
Definition: OverlayImpl.cpp:343
ripple::Config::TX_RELAY_PERCENTAGE
std::size_t TX_RELAY_PERCENTAGE
Definition: Config.h:277
beast::IP::Endpoint
A version-independent IP address and port combination.
Definition: IPEndpoint.h:38
ripple::strHex
std::string strHex(FwdIt begin, FwdIt end)
Definition: strHex.h:30
ripple::OverlayImpl::timer_
std::weak_ptr< Timer > timer_
Definition: OverlayImpl.h:105
ripple::Overlay::Setup::context
std::shared_ptr< boost::asio::ssl::context > context
Definition: Overlay.h:71
std::unordered_map::end
T end(T... args)
ripple::Handoff::response
std::shared_ptr< Writer > response
Definition: Handoff.h:47
beast::IPAddressConversion::to_asio_endpoint
static boost::asio::ip::tcp::endpoint to_asio_endpoint(IP::Endpoint const &address)
Definition: IPAddressConversion.h:78
ripple::deserializeManifest
std::optional< Manifest > deserializeManifest(Slice s, beast::Journal journal)
Constructs Manifest from serialized string.
Definition: app/misc/impl/Manifest.cpp:53
ripple::Config::TX_REDUCE_RELAY_ENABLE
bool TX_REDUCE_RELAY_ENABLE
Definition: Config.h:264
ripple::PeerFinder::Config
PeerFinder configuration settings.
Definition: PeerfinderManager.h:40
std::setw
T setw(T... args)
ripple::verifyHandshake
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.
Definition: Handshake.cpp:226
ripple::OverlayImpl
Definition: OverlayImpl.h:58
ripple::CrawlOptions::ServerInfo
@ ServerInfo
Definition: OverlayImpl.cpp:50
ripple::OverlayImpl::findPeerByShortID
std::shared_ptr< Peer > findPeerByShortID(Peer::id_t const &id) const override
Returns the peer with the matching short id, or null.
Definition: OverlayImpl.cpp:1197
ripple::OverlayImpl::reportTraffic
void reportTraffic(TrafficCount::category cat, bool isInbound, int bytes)
Definition: OverlayImpl.cpp:678
ripple::TrafficCount::addCount
void addCount(category cat, bool inbound, int bytes)
Account for traffic associated with the given category.
Definition: TrafficCount.h:173
ripple::OverlayImpl::Child
Definition: OverlayImpl.h:61
ripple::http_request_type
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
Definition: Handshake.h:47
std::unique_ptr< stream_type >
std::shuffle
T shuffle(T... args)
ripple::ManifestCache::applyManifest
ManifestDisposition applyManifest(Manifest m)
Add manifest to cache.
Definition: app/misc/impl/Manifest.cpp:363
ripple::OverlayImpl::makeErrorResponse
std::shared_ptr< Writer > makeErrorResponse(std::shared_ptr< PeerFinder::Slot > const &slot, http_request_type const &request, address_type remote_address, std::string msg)
Definition: OverlayImpl.cpp:370
ripple::OverlayImpl::m_peers
hash_map< std::shared_ptr< PeerFinder::Slot >, std::weak_ptr< PeerImp > > m_peers
Definition: OverlayImpl.h:113
ripple::Resolver::resolve
void resolve(std::vector< std::string > const &names, Handler handler)
resolve all hostnames on the list
Definition: Resolver.h:57
std::unordered_map
STL class.
ripple::OverlayImpl::isPeerUpgrade
static bool isPeerUpgrade(http_request_type const &request)
Definition: OverlayImpl.cpp:326
ripple::OverlayImpl::add_active
void add_active(std::shared_ptr< PeerImp > const &peer)
Definition: OverlayImpl.cpp:428
ripple::negotiateProtocolVersion
std::optional< ProtocolVersion > negotiateProtocolVersion(std::vector< ProtocolVersion > const &versions)
Given a list of supported protocol versions, choose the one we prefer.
Definition: ProtocolVersion.cpp:125
ripple::OverlayImpl::error_code
boost::system::error_code error_code
Definition: OverlayImpl.h:80
std::condition_variable::notify_all
T notify_all(T... args)
ripple::OverlayImpl::onWrite
void onWrite(beast::PropertyStream::Map &stream) override
Subclass override.
Definition: OverlayImpl.cpp:569
std::set
STL class.
ripple::Application::getHashRouter
virtual HashRouter & getHashRouter()=0
ripple::BasicConfig
Holds unparsed configuration information.
Definition: BasicConfig.h:215
ripple::OverlayImpl::manifestLock_
std::mutex manifestLock_
Definition: OverlayImpl.h:138
ripple::OverlayImpl::sendEndpoints
void sendEndpoints()
Definition: OverlayImpl.cpp:1418
ripple::OverlayImpl::for_each
void for_each(UnaryFunc &&f) const
Definition: OverlayImpl.h:281
std::exception::what
T what(T... args)
ripple::OverlayImpl::unsquelch
void unsquelch(PublicKey const &validator, Peer::id_t id) const override
Unsquelch handler.
Definition: OverlayImpl.cpp:1459
ripple::HashPrefix::shardInfo
@ shardInfo
shard info for signing
Json::Value
Represents a JSON value.
Definition: json_value.h:145
ripple::BasicConfig::section
Section & section(std::string const &name)
Returns the section with the given name.
Definition: BasicConfig.cpp:127
ripple::OverlayImpl::limit
int limit() override
Returns the maximum number of peers we are configured to allow.
Definition: OverlayImpl.cpp:795
ripple::OverlayImpl::processCrawl
bool processCrawl(http_request_type const &req, Handoff &handoff)
Handles crawl requests.
Definition: OverlayImpl.cpp:933
ripple::OverlayImpl::endpoint_type
boost::asio::ip::tcp::endpoint endpoint_type
Definition: OverlayImpl.h:79
ripple::Handoff::keep_alive
bool keep_alive
Definition: Handoff.h:44
ripple::ManifestCache::sequence
std::uint32_t sequence() const
A monotonically increasing number used to detect new manifests.
Definition: Manifest.h:254
std::chrono