1#include <xrpld/peerfinder/PeerfinderManager.h>
2#include <xrpld/peerfinder/detail/Checker.h>
3#include <xrpld/peerfinder/detail/Logic.h>
4#include <xrpld/peerfinder/detail/SourceStrings.h>
5#include <xrpld/peerfinder/detail/StoreSqdb.h>
7#include <boost/asio/executor_work_guard.hpp>
8#include <boost/asio/io_context.hpp>
21 boost::asio::io_context::executor_type>>
33 boost::asio::io_context& io_context,
147 boost::asio::ip::tcp::endpoint
const& remote_address,
168 bool reserved)
override
221 template <
class Handler>
223 Handler
const& handler,
225 :
hook(collector->make_hook(handler))
227 collector->make_gauge(
"Peer_Finder",
"Active_Inbound_Peers"))
229 collector->make_gauge(
"Peer_Finder",
"Active_Outbound_Peers"))
258 boost::asio::io_context& io_context,
265 io_context, clock, journal, config, collector);
A version-independent IP address and port combination.
A generic endpoint for log messages.
std::string const & name() const
Returns the name of this source.
A metric for measuring an integral value.
A reference to a handler for performing polled collection.
Holds unparsed configuration information.
Tests remote listening sockets to make sure they are connectable.
void stop()
Stop the service.
int inboundActive() const
Returns the number of inbound peers assigned an open slot.
int out_active() const
Returns the number of outbound peers assigned an open slot.
The Logic for maintaining the list of Slot addresses.
void on_closed(SlotImp::ptr const &slot)
std::vector< Endpoint > redirect(SlotImp::ptr const &slot)
Return a list of addresses suitable for redirection.
std::vector< std::pair< std::shared_ptr< Slot >, std::vector< Endpoint > > > buildEndpointsForPeers()
void onRedirects(FwdIter first, FwdIter last, boost::asio::ip::tcp::endpoint const &remote_address)
void addFixedPeer(std::string const &name, beast::IP::Endpoint const &ep)
void config(Config const &c)
std::pair< SlotImp::ptr, Result > new_inbound_slot(beast::IP::Endpoint const &local_endpoint, beast::IP::Endpoint const &remote_endpoint)
Result activate(SlotImp::ptr const &slot, PublicKey const &key, bool reserved)
void on_endpoints(SlotImp::ptr const &slot, Endpoints list)
bool onConnected(SlotImp::ptr const &slot, beast::IP::Endpoint const &local_endpoint)
void stop()
Stop the logic.
std::vector< beast::IP::Endpoint > autoconnect()
Create new outbound connection attempts as needed.
void addStaticSource(std::shared_ptr< Source > const &source)
std::pair< SlotImp::ptr, Result > new_outbound_slot(beast::IP::Endpoint const &remote_endpoint)
void on_failure(SlotImp::ptr const &slot)
void onWrite(beast::PropertyStream::Map &map)
ManagerImp(boost::asio::io_context &io_context, clock_type &clock, beast::Journal journal, BasicConfig const &config, beast::insight::Collector::ptr const &collector)
std::optional< boost::asio::executor_work_guard< boost::asio::io_context::executor_type > > work_
void setConfig(Config const &config) override
Set the configuration for the manager.
void on_closed(std::shared_ptr< Slot > const &slot) override
Called when the slot is closed.
void start() override
Transition to the started state, synchronously.
Config config() override
Returns the configuration for the manager.
void once_per_second() override
Perform periodic activity.
void on_failure(std::shared_ptr< Slot > const &slot) override
Called when an outbound connection is deemed to have failed.
std::vector< Endpoint > redirect(std::shared_ptr< Slot > const &slot) override
Returns a set of endpoints suitable for redirection.
std::pair< std::shared_ptr< Slot >, Result > new_outbound_slot(beast::IP::Endpoint const &remote_endpoint) override
Create a new outbound slot with the specified remote endpoint.
BasicConfig const & m_config
void on_endpoints(std::shared_ptr< Slot > const &slot, Endpoints const &endpoints) override
Called when mtENDPOINTS is received.
Logic< decltype(checker_)> m_logic
void addFallbackURL(std::string const &name, std::string const &url)
void onWrite(beast::PropertyStream::Map &map) override
Subclass override.
Checker< boost::asio::ip::tcp > checker_
void stop() override
Transition to the stopped state, synchronously.
std::pair< std::shared_ptr< Slot >, Result > new_inbound_slot(beast::IP::Endpoint const &local_endpoint, beast::IP::Endpoint const &remote_endpoint) override
Add a URL as a fallback location to obtain IP::Endpoint sources.
void addFallbackStrings(std::string const &name, std::vector< std::string > const &strings) override
Add a set of strings as fallback IP::Endpoint sources.
std::vector< beast::IP::Endpoint > autoconnect() override
Return a set of addresses we should connect to.
Result activate(std::shared_ptr< Slot > const &slot, PublicKey const &key, bool reserved) override
Request an active slot type.
bool onConnected(std::shared_ptr< Slot > const &slot, beast::IP::Endpoint const &local_endpoint) override
Called when an outbound connection attempt succeeds.
std::vector< std::pair< std::shared_ptr< Slot >, std::vector< Endpoint > > > buildEndpointsForPeers() override
void addFixedPeer(std::string const &name, std::vector< beast::IP::Endpoint > const &addresses) override
Add a peer that should always be connected.
void onRedirects(boost::asio::ip::tcp::endpoint const &remote_address, std::vector< boost::asio::ip::tcp::endpoint > const &eps) override
Called when we received redirect IPs from a busy peer.
boost::asio::io_context & io_context_
Maintains a set of IP addresses used for getting into the network.
static std::shared_ptr< Source > New(std::string const &name, Strings const &strings)
A static or dynamic source of peer addresses.
Database persistence for PeerFinder using SQLite.
void open(BasicConfig const &config)
Result
Possible results from activating a slot.
std::unique_ptr< Manager > make_Manager(boost::asio::io_context &io_context, clock_type &clock, beast::Journal journal, BasicConfig const &config, beast::insight::Collector::ptr const &collector)
Create a new Manager.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
PeerFinder configuration settings.
beast::insight::Gauge activeOutboundPeers
beast::insight::Hook hook
Stats(Handler const &handler, beast::insight::Collector::ptr const &collector)
beast::insight::Gauge activeInboundPeers