3#include <xrpld/core/Config.h>
4#include <xrpld/peerfinder/Slot.h>
5#include <xrpld/peerfinder/detail/Tuning.h>
7#include <xrpl/beast/clock/abstract_clock.h>
8#include <xrpl/beast/utility/PropertyStream.h>
10#include <boost/asio/ip/tcp.hpp>
95 bool validationPublicKey,
149 case Result::InboundDisabled:
150 return "inbound disabled";
151 case Result::DuplicatePeer:
152 return "peer already connected";
153 case Result::IpLimitExceeded:
154 return "ip limit exceeded";
157 case Result::Success:
256 boost::asio::ip::tcp::endpoint
const& remoteAddress,
Abstract interface to a clock.
A version-independent IP address and port combination.
Subclasses can be called to write to a stream and have children.
std::string const & name() const
Returns the name of this source.
virtual void onEndpoints(std::shared_ptr< Slot > const &slot, Endpoints const &endpoints)=0
Called when mtENDPOINTS is received.
virtual void start()=0
Transition to the started state, synchronously.
virtual std::vector< beast::IP::Endpoint > autoconnect()=0
Return a set of addresses we should connect to.
virtual void addFallbackStrings(std::string const &name, std::vector< std::string > const &strings)=0
Add a set of strings as fallback IP::Endpoint sources.
~Manager() override=default
Destroy the object.
virtual void oncePerSecond()=0
Perform periodic activity.
virtual std::pair< std::shared_ptr< Slot >, Result > newInboundSlot(beast::IP::Endpoint const &localEndpoint, beast::IP::Endpoint const &remoteEndpoint)=0
Add a URL as a fallback location to obtain IP::Endpoint sources.
virtual std::vector< std::pair< std::shared_ptr< Slot >, std::vector< Endpoint > > > buildEndpointsForPeers()=0
virtual void onClosed(std::shared_ptr< Slot > const &slot)=0
Called when the slot is closed.
virtual void onFailure(std::shared_ptr< Slot > const &slot)=0
Called when an outbound connection is deemed to have failed.
virtual Result activate(std::shared_ptr< Slot > const &slot, PublicKey const &key, bool reserved)=0
Request an active slot type.
virtual bool onConnected(std::shared_ptr< Slot > const &slot, beast::IP::Endpoint const &localEndpoint)=0
Called when an outbound connection attempt succeeds.
virtual void stop()=0
Transition to the stopped state, synchronously.
virtual std::pair< std::shared_ptr< Slot >, Result > newOutboundSlot(beast::IP::Endpoint const &remoteEndpoint)=0
Create a new outbound slot with the specified remote endpoint.
virtual void onRedirects(boost::asio::ip::tcp::endpoint const &remoteAddress, std::vector< boost::asio::ip::tcp::endpoint > const &eps)=0
Called when we received redirect IPs from a busy peer.
virtual Config config()=0
Returns the configuration for the manager.
virtual void setConfig(Config const &config)=0
Set the configuration for the manager.
virtual void addFixedPeer(std::string_view name, std::vector< beast::IP::Endpoint > const &addresses)=0
Add a peer that should always be connected.
virtual std::vector< Endpoint > redirect(std::shared_ptr< Slot > const &slot)=0
Returns a set of endpoints suitable for redirection.
static constexpr auto kDefaultMaxPeers
The default value of Config::maxPeers.
std::vector< Endpoint > Endpoints
A set of Endpoint used for connecting.
std::string_view to_string(Result result) noexcept
Converts a Result enum value to its string representation.
std::vector< beast::IP::Endpoint > IPAddresses
Represents a set of addresses.
Result
Possible results from activating a slot.
bool operator<(Endpoint const &lhs, Endpoint const &rhs)
beast::AbstractClock< std::chrono::steady_clock > clock_type
PeerFinder configuration settings.
std::size_t maxPeers
The largest number of public peer slots to allow.
int ipLimit
Limit how many incoming connections we allow per IP.
std::size_t outPeers
The number of automatic outbound connections to maintain.
bool verifyEndpoints
true if we want to verify endpoints in TMEndpoints messages
Config()
Create a configuration with default values.
friend bool operator==(Config const &lhs, Config const &rhs)=default
void applyTuning()
Adjusts the values so they follow the business rules.
void onWrite(beast::PropertyStream::Map &map) const
Write the configuration into a property stream.
bool wantIncoming
true if we want to accept incoming connections.
bool autoConnect
true if we want to establish connections automatically
std::string features
The set of features we advertise.
std::size_t inPeers
The number of automatic inbound connections to maintain.
std::uint16_t listeningPort
The listening port number.
std::size_t calcOutPeers() const
Returns a suitable value for outPeers according to the rules.
static Config makeConfig(xrpl::Config const &config, std::uint16_t port, bool validationPublicKey, int ipLimit, bool verifyEndpoints)
Make PeerFinder::Config from configuration parameters.
bool peerPrivate
true if we want our IP address kept private.
Describes a connectable peer address along with some metadata.
beast::IP::Endpoint address