20 #ifndef RIPPLE_PEERFINDER_MANAGER_H_INCLUDED
21 #define RIPPLE_PEERFINDER_MANAGER_H_INCLUDED
23 #include <ripple/beast/clock/abstract_clock.h>
24 #include <ripple/beast/utility/PropertyStream.h>
25 #include <ripple/core/Config.h>
26 #include <ripple/peerfinder/Slot.h>
27 #include <boost/asio/ip/tcp.hpp>
30 namespace PeerFinder {
106 bool validationPublicKey,
235 boost::asio::ip::tcp::endpoint
const& remote_address,
std::string const & name() const
Returns the name of this source.
virtual void once_per_second()=0
Perform periodic activity.
virtual void addFallbackStrings(std::string const &name, std::vector< std::string > const &strings)=0
Add a set of strings as fallback IP::Endpoint sources.
virtual std::vector< std::pair< std::shared_ptr< Slot >, std::vector< Endpoint > > > buildEndpointsForPeers()=0
Subclasses can be called to write to a stream and have children.
std::string features
The set of features we advertise.
bool operator<(Endpoint const &lhs, Endpoint const &rhs)
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.
virtual std::shared_ptr< Slot > new_inbound_slot(beast::IP::Endpoint const &local_endpoint, beast::IP::Endpoint const &remote_endpoint)=0
Add a URL as a fallback location to obtain IP::Endpoint sources.
bool peerPrivate
true if we want our IP address kept private.
virtual std::vector< beast::IP::Endpoint > autoconnect()=0
Return a set of addresses we should connect to.
virtual void on_endpoints(std::shared_ptr< Slot > const &slot, Endpoints const &endpoints)=0
Called when mtENDPOINTS is received.
static Config makeConfig(ripple::Config const &config, std::uint16_t port, bool validationPublicKey, int ipLimit)
Make PeerFinder::Config from configuration parameters.
virtual Result activate(std::shared_ptr< Slot > const &slot, PublicKey const &key, bool reserved)=0
Request an active slot type.
virtual std::vector< Endpoint > redirect(std::shared_ptr< Slot > const &slot)=0
Returns a set of endpoints suitable for redirection.
virtual void on_closed(std::shared_ptr< Slot > const &slot)=0
Called when the slot is closed.
virtual void stop()=0
Transition to the stopped state, synchronously.
bool wantIncoming
true if we want to accept incoming connections.
virtual void setConfig(Config const &config)=0
Set the configuration for the manager.
virtual void start()=0
Transition to the started state, synchronously.
std::size_t outPeers
The number of automatic outbound connections to maintain.
Abstract interface to a clock.
std::size_t maxPeers
The largest number of public peer slots to allow.
void applyTuning()
Adjusts the values so they follow the business rules.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
virtual bool onConnected(std::shared_ptr< Slot > const &slot, beast::IP::Endpoint const &local_endpoint)=0
Called when an outbound connection attempt succeeds.
virtual ~Manager()=default
Destroy the object.
virtual void onRedirects(boost::asio::ip::tcp::endpoint const &remote_address, std::vector< boost::asio::ip::tcp::endpoint > const &eps)=0
Called when we received redirect IPs from a busy peer.
virtual void addFixedPeer(std::string const &name, std::vector< beast::IP::Endpoint > const &addresses)=0
Add a peer that should always be connected.
std::uint16_t listeningPort
The listening port number.
std::size_t calcOutPeers() const
Returns a suitable value for outPeers according to the rules.
virtual Config config()=0
Returns the configuration for the manager.
A version-independent IP address and port combination.
virtual void on_failure(std::shared_ptr< Slot > const &slot)=0
Called when an outbound connection is deemed to have failed.
bool autoConnect
true if we want to establish connections automatically
PeerFinder configuration settings.
Describes a connectible peer address along with some metadata.
Config()
Create a configuration with default values.
void onWrite(beast::PropertyStream::Map &map)
Write the configuration into a property stream.
beast::IP::Endpoint address
int ipLimit
Limit how many incoming connections we allow per IP.
Maintains a set of IP addresses used for getting into the network.
std::size_t inPeers
The number of automatic inbound connections to maintain.
Result
Possible results from activating a slot.