20 #include <ripple/overlay/Cluster.h>
21 #include <ripple/overlay/impl/InboundHandoff.h>
22 #include <ripple/overlay/impl/PeerImp.h>
24 #include <boost/beast/core/ostream.hpp>
49 , stream_ptr_(std::move(stream_ptr))
50 , strand_(stream_ptr_->next_layer().socket().get_executor())
51 , remote_address_(slot->remote_endpoint())
53 , publicKey_(publicKey)
56 , request_(std::move(request))
63 if (!
strand_.running_in_this_thread())
72 if (!
strand_.running_in_this_thread())
89 return fail(
"makeSharedValue: Unexpected failure");
95 auto write_buffer = std::make_shared<boost::beast::multi_buffer>();
108 boost::asio::async_write(
110 write_buffer->data(),
111 boost::asio::transfer_all(),
118 if (ec == boost::asio::error::operation_aborted)
121 return fail(
"onWriteResponse", ec);
122 if (write_buffer->size() == bytes_transferred)
124 return fail(
"Failed to write header");
165 auto peer = std::make_shared<PeerImp>(
const std::shared_ptr< PeerFinder::Slot > slot_
virtual Cluster & cluster()=0
std::string to_string() const
Returns a string representing the endpoint.
void close()
Close connection.
void createPeer()
Instantiate and run the overlay peer.
Resource::Consumer usage_
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Address const & address() const
Returns the address portion of this endpoint.
boost::asio::strand< boost::asio::executor > strand_
std::optional< uint256 > makeSharedValue(stream_type &ssl, beast::Journal journal)
Computes a shared value based on the SSL connection state.
std::optional< std::string > member(PublicKey const &node) const
Determines whether a node belongs in the cluster.
std::unique_ptr< stream_type > stream_ptr_
Setup const & setup() const
bool peerPrivate
true if we want our IP address kept private.
InboundHandoff(Application &app, id_t id, std::shared_ptr< PeerFinder::Slot > const &slot, http_request_type &&request, PublicKey const &publicKey, ProtocolVersion protocol, Resource::Consumer consumer, std::unique_ptr< stream_type > &&stream_ptr, OverlayImpl &overlay)
PeerFinder::Manager & peerFinder()
T shared_from_this(T... args)
void stop() override
Stop the child.
bool active(Severity level) const
Returns true if any message would be logged at this severity level.
void sendResponse()
Send upgrade response to the client.
ProtocolVersion protocol_
http_request_type request_
void fail(std::string const &name, error_code const &ec)
Log and close.
boost::asio::ip::tcp::socket socket_type
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
const beast::Journal journal_
virtual Config config()=0
Returns the configuration for the manager.
An endpoint that consumes resources.
boost::system::error_code error_code
const beast::IP::Endpoint remote_address_
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
void run()
Start the handshake.
socket_type & socket() const
Get underlying socket.
http_response_type makeResponse(bool crawlPublic, http_request_type const &req, beast::IP::Address public_ip, beast::IP::Address remote_ip, uint256 const &sharedValue, std::optional< std::uint32_t > networkID, ProtocolVersion protocol, Application &app)
Make http response.
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
void add_active(std::shared_ptr< PeerImp > const &peer)
const PublicKey publicKey_