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/predicates.h>
32 #include <ripple/overlay/impl/ConnectAttempt.h>
33 #include <ripple/overlay/impl/PeerImp.h>
34 #include <ripple/peerfinder/make_Manager.h>
35 #include <ripple/rpc/json_body.h>
36 #include <ripple/rpc/handlers/GetCounts.h>
37 #include <ripple/server/SimpleWriter.h>
39 #include <boost/algorithm/string/predicate.hpp>
40 #include <boost/utility/in_place_factory.hpp>
64 namespace CrawlOptions
85 overlay_.remove(*
this);
107 timer_.async_wait(overlay_.strand_.wrap(
109 std::placeholders::_1)));
115 if (ec || overlay_.isStopping())
117 if (ec && ec != boost::asio::error::operation_aborted)
119 JLOG(overlay_.journal_.error()) <<
"on_timer: " << ec.message();
124 overlay_.m_peerFinder->once_per_second();
125 overlay_.sendEndpoints();
126 overlay_.autoConnect();
134 std::placeholders::_1)));
146 boost::asio::io_service& io_service,
158 ,
m_peerFinder (PeerFinder::make_Manager (*this, io_service,
166 [counts =
m_traffic.getCounts(), collector]()
171 for (
size_t i = 0; i < counts.size(); ++i)
210 handoff.
moved =
true;
212 JLOG(journal.
debug()) <<
"Peer connection upgrade from " << remote_endpoint;
215 auto const local_endpoint (stream_ptr->next_layer().socket().local_endpoint(ec));
218 JLOG(journal.
debug()) << remote_endpoint <<
" failed: " << ec.message();
224 if (consumer.disconnect())
234 handoff.
moved =
false;
242 request[
"Connect-As"]);
246 return boost::iequals(s,
"peer");
249 handoff.
moved =
false;
251 remote_endpoint.address());
258 if (!negotiatedVersion)
261 handoff.
moved =
false;
263 remote_endpoint.address(),
"Unable to agree on a protocol version");
272 handoff.
moved =
false;
274 remote_endpoint.address(),
"Incorrect security cookie");
287 bool const reserved =
290 auto const result =
m_peerFinder->activate(slot, publicKey, reserved);
294 JLOG(journal.
debug()) <<
"Peer " << remote_endpoint <<
" redirected, slots full";
295 handoff.
moved =
false;
297 remote_endpoint.address());
303 auto const peer = std::make_shared<PeerImp>(
app_,
id, slot,
304 std::move(request), publicKey, *negotiatedVersion, consumer,
305 std::move(stream_ptr), *
this);
312 auto const result =
m_peers.emplace (peer->slot(), peer);
313 assert (result.second);
314 (void) result.second;
316 list_.emplace(peer.get(), peer);
320 handoff.
moved =
true;
325 JLOG(journal.
debug()) <<
"Peer " << remote_endpoint <<
326 " fails handshake (" << e.
what() <<
")";
329 handoff.
moved =
false;
331 remote_endpoint.address(), e.
what());
345 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);
364 msg.insert(
"Remote-Address", remote_address);
365 msg.insert(
"Content-Type",
"application/json");
366 msg.insert(boost::beast::http::field::connection,
"close");
372 ips.
append(_.address.to_string());
374 msg.prepare_payload();
375 return std::make_shared<SimpleWriter>(msg);
384 boost::beast::http::response<boost::beast::http::empty_body> msg;
385 msg.version(request.version());
386 msg.result(boost::beast::http::status::bad_request);
387 msg.reason(
"Bad Request (" + text +
")");
389 msg.insert(
"Remote-Address", remote_address.to_string());
390 msg.insert(boost::beast::http::field::connection,
"close");
391 msg.prepare_payload();
392 return std::make_shared<SimpleWriter>(msg);
403 if (usage.disconnect())
405 JLOG(
journal_.
info()) <<
"Over resource limit: " << remote_endpoint;
412 JLOG(
journal_.
debug()) <<
"Connect: No slot for " << remote_endpoint;
416 auto const p = std::make_shared<ConnectAttempt>(
app_,
422 list_.emplace(p.get(), p);
436 m_peers.emplace (peer->slot(), peer);
437 assert (result.second);
438 (void) result.second;
442 auto const result =
ids_.emplace (
443 std::piecewise_construct,
446 assert(result.second);
447 (void) result.second;
453 "activated " << peer->getRemoteAddress() <<
454 " (" << peer->id() <<
":" <<
457 peer->getNodePublic()) <<
")";
469 auto const iter =
m_peers.find (slot);
470 assert(iter !=
m_peers.end ());
535 if (bootstrapIps.empty ())
538 bootstrapIps.
push_back(
"r.ripple.com 51235");
541 bootstrapIps.
push_back(
"zaphod.alloy.ee 51235");
544 bootstrapIps.push_back(
"sahyadri.isrdc.in 51235");
553 for (
auto const& addr : addresses)
555 if (addr.port () == 0)
557 Throw<std::runtime_error> (
"Port not specified for "
558 "address:" + addr.to_string ());
577 if (!addresses.
empty ())
586 auto const timer = std::make_shared<Timer>(*
this);
588 list_.emplace(timer.get(), timer);
617 for (
auto const& i : stats)
622 item[
"category"] = i.name;
643 auto const result (
ids_.emplace (
644 std::piecewise_construct,
647 assert(result.second);
648 (void) result.second;
652 "activated " << peer->getRemoteAddress() <<
653 " (" << peer->id() <<
656 peer->getNodePublic()) <<
")";
675 auto const n = m->list_size();
676 auto const& journal = from->pjournal();
678 JLOG(journal.debug()) <<
"TMManifest, " << n << (n == 1 ?
" item" :
" items");
682 auto& s = m->list ().Get (i).stobject ();
686 uint256 const hash = mo->hash ();
687 if (!hashRouter.addSuppressionPeer (hash, from->id ())) {
688 JLOG(journal.info()) <<
"Duplicate manifest #" << i + 1;
694 JLOG(journal.info()) <<
"Untrusted manifest #" << i + 1;
699 auto const serialized = mo->serialized;
713 soci::transaction tr(*db);
714 static const char*
const sql =
715 "INSERT INTO ValidatorManifests (RawData) VALUES (:rawData);";
716 soci::blob rawData(*db);
718 *db << sql, soci::use (rawData);
721 protocol::TMManifests o;
722 o.add_list ()->set_stobject (s);
724 auto const toSkip = hashRouter.shouldRelay (hash);
727 std::make_shared<Message>(o, protocol::mtMANIFESTS),
732 JLOG(journal.info()) <<
"Bad manifest #" << i + 1 <<
738 JLOG(journal.warn()) <<
"Malformed manifest #" << i + 1;
757 using namespace std::chrono_literals;
760 auto const numPeers {
size()};
771 auto const timeout(
seconds((hops * hops) * 10));
779 for (
auto&
id :
ids_)
784 protocol::TMGetPeerShardInfo tmGPS;
785 tmGPS.set_hops(hops);
787 tmGPS, protocol::mtGET_PEER_SHARD_INFO)));
794 csLast_ = duration_cast<seconds>(
806 if (
auto psi = peer->getPeerShardInfo())
808 for (auto const& e : *psi)
810 auto it {peerShardInfo.find(e.first)};
811 if (it != peerShardInfo.end())
813 it->second.shardIndexes += e.second.shardIndexes;
815 peerShardInfo.emplace(std::move(e));
822 for (
auto const& e : peerShardInfo)
828 auto const& address {e.second.endpoint.address()};
829 if (!address.is_unspecified())
830 pv[jss::ip] = address.to_string();
832 pv[jss::complete_shards] =
to_string(e.second.shardIndexes);
860 auto const s = e->getScore(score(e));
865 [](item
const& lhs, item
const&rhs)
867 return lhs.first > rhs.first;
871 for (
auto const& e : v)
907 sp->getNodePublic().data(),
908 sp->getNodePublic().size());
909 pv[jss::type] = sp->slot()->inbound() ?
913 sp->uptime()).count());
916 pv[jss::ip] = sp->getRemoteAddress().address().to_string();
917 if (sp->slot()->inbound())
919 if (
auto port = sp->slot()->listening_port())
920 pv[jss::port] = *port;
925 sp->getRemoteAddress().port());
930 auto version {sp->getVersion()};
931 if (!version.empty())
932 pv[jss::version] = std::move(version);
936 sp->ledgerRange(minSeq, maxSeq);
937 if (minSeq != 0 || maxSeq != 0)
938 pv[jss::complete_ledgers] =
942 if (
auto shardIndexes = sp->getShardIndexes())
943 pv[jss::complete_shards] =
to_string(*shardIndexes);
952 bool const humanReadable =
false;
953 bool const admin =
false;
954 bool const counters =
false;
960 server_info.
removeMember(jss::load_factor_fee_escalation);
964 if (server_info.
isMember(jss::validated_ledger))
966 Json::Value& validated_ledger = server_info[jss::validated_ledger];
987 if (validators.
isMember(jss::publisher_lists))
989 Json::Value& publisher_lists = validators[jss::publisher_lists];
991 for (
auto& publisher : publisher_lists)
1003 if (validatorSites.
isMember(jss::validator_sites))
1005 validators[jss::validator_sites] = std::move(validatorSites[jss::validator_sites]);
1025 boost::beast::http::response<json_body> msg;
1026 msg.version(req.version());
1027 msg.result(boost::beast::http::status::ok);
1029 msg.insert(
"Content-Type",
"application/json");
1030 msg.insert(
"Connection",
"close");
1050 msg.prepare_payload();
1051 handoff.
response = std::make_shared<SimpleWriter>(msg);
1061 if (!req.target().starts_with(
"/vl/") ||
1065 auto key = req.target();
1066 if (key.starts_with(
"/vl/"))
1067 key.remove_prefix(strlen(
"/vl/"));
1069 key.remove_prefix(strlen(
"/unl/"));
1076 boost::beast::http::response<json_body> msg;
1077 msg.version(req.version());
1079 msg.insert(
"Content-Type",
"application/json");
1080 msg.insert(
"Connection",
"close");
1085 msg.result(boost::beast::http::status::not_found);
1086 msg.insert(
"Content-Length",
"0");
1092 msg.result(boost::beast::http::status::ok);
1097 msg.prepare_payload();
1098 handoff.
response = std::make_shared<SimpleWriter>(msg);
1130 sp->checkSanity (index);
1147 auto const iter =
ids_.find (
id);
1148 if (iter !=
ids_.end ())
1149 return iter->second.lock();
1159 for (
auto const& e :
ids_)
1161 if (
auto peer = e.second.lock())
1163 if (peer->getNodePublic() == pubKey)
1175 auto const sm = std::make_shared<Message>(m, protocol::mtPROPOSE_LEDGER);
1186 auto const sm = std::make_shared<Message>(m, protocol::mtVALIDATION);
1192 SerialIter sit (m.validation().data(), m.validation().size());
1193 auto val = std::make_shared<STValidation>(
1205 if (m.has_hops() && m.hops() >=
maxTTL)
1209 auto const sm = std::make_shared<Message>(m, protocol::mtPROPOSE_LEDGER);
1212 if (toSkip->find(p->id()) == toSkip->end())
1221 if (m.has_hops() && m.hops() >=
maxTTL)
1225 auto const sm = std::make_shared<Message>(m, protocol::mtVALIDATION);
1228 if (toSkip->find(p->id()) == toSkip->end())
1240 list_.erase(&child);
1261 work_ = boost::none;
1264 for (
auto const& element :
list_)
1270 for (
auto const& child : children)
1272 if (child !=
nullptr)
1281 for (
auto addr : result)
1288 auto const result =
m_peerFinder->buildEndpointsForPeers();
1289 for (
auto const& e : result)
1294 auto const iter =
m_peers.find (e.first);
1296 peer = iter->second.lock();
1299 peer->sendEndpoints (e.second.begin(), e.second.end());
1307 auto const& p = std::dynamic_pointer_cast<PeerImp>(bp);
1308 return p->hasLedger (hash_, seq_);
1313 auto const& p = std::dynamic_pointer_cast<PeerImp>(bp);
1314 return p->hasTxSet (hash_);
1325 auto const& section = config.
section(
"overlay");
1327 setup.
expire = get<bool>(section,
"expire",
false);
1331 Throw<std::runtime_error>(
"Configured IP limit is invalid");
1334 set(ip,
"public_ip", section);
1337 boost::system::error_code ec;
1340 Throw<std::runtime_error>(
"Configured public IP is invalid");
1345 auto const& section = config.
section(
"crawl");
1346 auto const& values = section.
values();
1348 if (values.size() > 1)
1350 Throw<std::runtime_error>(
1351 "Configured [crawl] section is invalid, too many values");
1354 bool crawlEnabled =
true;
1357 if (values.size() == 1)
1361 crawlEnabled = boost::lexical_cast<bool>(values.front());
1363 catch (boost::bad_lexical_cast
const&)
1365 Throw<std::runtime_error>(
1366 "Configured [crawl] section has invalid value: " + values.front());
1372 if (get<bool>(section,
"overlay",
true))
1376 if (get<bool>(section,
"server",
true))
1380 if (get<bool>(section,
"counts",
false))
1384 if (get<bool>(section,
"unl",
true))
1391 auto const& section = config.
section(
"vl");
1398 auto id = config.
legacy(
"network_id");
1405 if (
id ==
"testnet")
1416 Throw<std::runtime_error>(
1417 "Configured [network_id] section is invalid: must be a number "
1418 "or one of the strings 'main', 'testnet' or 'devnet'.");
1432 boost::asio::io_service& io_service,
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.
std::shared_ptr< Peer > findPeerByShortID(Peer::id_t const &id) override
Returns the peer with the matching short id, or null.
void relay(protocol::TMProposeSet &m, uint256 const &uid) override
Relay a proposal.
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.
std::size_t selectPeers(PeerSet &set, std::size_t limit, std::function< bool(std::shared_ptr< Peer > const &)> score) override
Select from active peers.
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.
PublicKey getMasterKey(PublicKey const &pk) const
Returns ephemeral signing key's master public key.
boost::optional< boost::asio::io_service::work > work_
NodeID calcNodeID(PublicKey const &pk)
Calculate the 160-bit node ID from a node public key.
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)
constexpr std::uint32_t maxTTL
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
boost::optional< Json::Value > getAvailable(boost::beast::string_view const &pubKey)
Returns the current valid list for the given publisher key, if available, as a Json object.
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)
std::string features
The set of features we advertise.
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.
Stopwatch & stopwatch()
Returns an instance of a wall clock.
std::string to_string(ListDisposition disposition)
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 peerPrivate
true if we want our IP address kept private.
bool processValidatorList(http_request_type const &req, Handoff &handoff)
Handles validator list requests.
Select all peers that are in the specified set.
virtual NetworkOPs & getOPs()=0
virtual DatabaseCon & getWalletDB()=0
Retrieve the "wallet database".
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.
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.
void for_each(UnaryFunc &&f)
PublicKey verifyHandshake(boost::beast::http::fields const &headers, ripple::uint256 const &sharedValue, boost::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.
static IP::Endpoint from_asio(boost::asio::ip::address const &address)
boost::optional< std::string > member(PublicKey const &node) const
Determines whether a node belongs in the cluster.
PeerFinder::Manager & peerFinder()
void send(protocol::TMProposeSet &m) override
Broadcast a proposal.
bool is_keep_alive(boost::beast::http::message< isRequest, Body, Fields > const &m)
boost::container::flat_map< Child *, std::weak_ptr< Child > > list_
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
bool wantIncoming
true if we want to accept incoming connections.
virtual const PublicKey & getValidationPublicKey() const =0
LockedSociSession checkoutDb()
Resource::Manager & resourceManager()
PeerSequence getActivePeers() override
Returns a sequence representing the current list of peers.
@ 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
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.
boost::optional< uint256 > makeSharedValue(stream_type &ssl, beast::Journal journal)
Computes a shared value based on the SSL connection state.
double outPeers
The number of automatic outbound connections to maintain.
int maxPeers
The largest number of public peer slots to allow.
void legacy(std::string const §ion, std::string value)
Set a value that is not a key/value pair.
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)
boost::optional< std::set< PeerShortID > > shouldRelay(uint256 const &key)
Determines whether the hashed item should be relayed.
Result split_commas(FwdIt first, FwdIt last)
std::size_t size() override
The number of active peers on the network Active peers are only those peers that have completed the h...
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)
virtual ValidatorList & validators()=0
bool processRequest(http_request_type const &req, Handoff &handoff)
Handles non-peer protocol requests.
@ accepted
Manifest is valid.
Tracks load and resource consumption.
std::string const & getFullVersionString()
Full server version string.
void applyTuning()
Adjusts the values so they follow the business rules.
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.
boost::optional< Manifest > deserializeManifest(Slice s)
Constructs Manifest from serialized string.
void checkSanity(std::uint32_t) override
Calls the checkSanity function on each peer.
virtual beast::Journal journal(std::string const &name)=0
virtual ManifestCache & validatorManifests()=0
Value removeMember(const char *key)
Remove and return the named member.
std::uint16_t listeningPort
The listening port number.
send_if_not_pred< Predicate > send_if_not(std::shared_ptr< Message > const &m, Predicate const &f)
Helper function to aid in type deduction.
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...
double calcOutPeers() const
Returns a suitable value for outPeers according to the rules.
Supports data retrieval by managing a set of peers.
void onPeerDeactivate(Peer::id_t id)
boost::optional< std::uint32_t > networkID
void lastLink(std::uint32_t id)
Called when the last link from a peer chain is received.
void check() override
Calls the check function on each peer.
hash_map< std::shared_ptr< PeerFinder::Slot >, std::weak_ptr< PeerImp > > m_peers
Timer(OverlayImpl &overlay)
bool operator()(std::shared_ptr< Peer > const &) const
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)
A functor to visit all active peers and retrieve their JSON data.
bool operator()(std::shared_ptr< Peer > const &) const
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::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)
bool autoConnect
true if we want to establish connections automatically
PeerFinder configuration settings.
std::atomic< std::chrono::seconds > csLast_
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.
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)
@ checkSeconds
How often we check connections (seconds)
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
int ipLimit
Limit how many incoming connections we allow per IP.
void onWrite(beast::PropertyStream::Map &stream) override
Subclass override.
virtual HashRouter & getHashRouter()=0
Holds unparsed configuration information.
void onStop() override
Override called when the stop notification is issued.
Section & section(std::string const &name)
Returns the section with the given name.
virtual void pubValidation(STValidation::ref val)=0
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.