20 #ifndef RIPPLE_OVERLAY_HANDSHAKE_H_INCLUDED
21 #define RIPPLE_OVERLAY_HANDSHAKE_H_INCLUDED
23 #include <ripple/app/main/Application.h>
24 #include <ripple/beast/utility/Journal.h>
25 #include <ripple/overlay/impl/ProtocolVersion.h>
26 #include <ripple/protocol/BuildInfo.h>
27 #include <boost/asio/ip/tcp.hpp>
28 #include <boost/asio/ssl/context.hpp>
29 #include <boost/asio/ssl/stream.hpp>
30 #include <boost/beast/core/tcp_stream.hpp>
31 #include <boost/beast/ssl/ssl_stream.hpp>
33 #include <boost/asio/ssl.hpp>
34 #include <boost/beast/http/dynamic_body.hpp>
35 #include <boost/beast/http/empty_body.hpp>
36 #include <boost/beast/http/fields.hpp>
45 boost::beast::http::request<boost::beast::http::empty_body>;
47 boost::beast::http::request<boost::beast::http::dynamic_body>;
49 boost::beast::http::response<boost::beast::http::dynamic_body>;
67 boost::beast::http::fields& h,
87 boost::beast::http::fields
const& headers,
109 bool ledgerReplayEnabled,
110 bool txReduceRelayEnabled,
111 bool vpReduceRelayEnabled);
160 boost::beast::http::fields
const& headers,
173 boost::beast::http::fields
const& headers,
184 boost::beast::http::fields
const& headers,
197 template <
typename headers>
200 headers
const& request,
209 template <
typename headers>
212 headers
const& request,
231 bool ledgerReplayEnabled,
232 bool txReduceRelayEnabled,
233 bool vpReduceRelayEnabled);
253 bool ledgerReplayEnabled,
254 bool txReduceRelayEnabled,
255 bool vpReduceRelayEnabled);
static constexpr char DELIM_FEATURE[]
std::string makeFeaturesRequestHeader(bool comprEnabled, bool ledgerReplayEnabled, bool txReduceRelayEnabled, bool vpReduceRelayEnabled)
Make request header X-Protocol-Ctl value with supported features.
static constexpr char FEATURE_LEDGER_REPLAY[]
std::optional< uint256 > makeSharedValue(stream_type &ssl, beast::Journal journal)
Computes a shared value based on the SSL connection state.
static constexpr char FEATURE_VPRR[]
bool isFeatureValue(boost::beast::http::fields const &headers, std::string const &feature, std::string const &value)
Check if a feature's value is equal to the specified value.
static constexpr char FEATURE_TXRR[]
bool featureEnabled(boost::beast::http::fields const &headers, std::string const &feature)
Check if a feature is enabled.
boost::asio::ip::address Address
static constexpr char FEATURE_COMPR[]
static constexpr char DELIM_VALUE[]
A generic endpoint for log messages.
bool peerFeatureEnabled(headers const &request, std::string const &feature, std::string value, bool config)
Check if a feature should be enabled for a peer.
std::optional< std::string > getFeatureValue(boost::beast::http::fields const &headers, std::string const &feature)
Get feature's header value.
boost::beast::ssl_stream< socket_type > stream_type
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
boost::beast::tcp_stream socket_type
boost::beast::http::request< boost::beast::http::empty_body > request_type
PublicKey verifyHandshake(boost::beast::http::fields const &headers, ripple::uint256 const &sharedValue, std::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.
std::string makeFeaturesResponseHeader(http_request_type const &headers, bool comprEnabled, bool ledgerReplayEnabled, bool txReduceRelayEnabled, bool vpReduceRelayEnabled)
Make response header X-Protocol-Ctl value with supported features.
auto makeRequest(bool crawlPublic, bool comprEnabled, bool ledgerReplayEnabled, bool txReduceRelayEnabled, bool vpReduceRelayEnabled) -> request_type
Make outbound http request.
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
boost::beast::http::response< boost::beast::http::dynamic_body > http_response_type
void buildHandshake(boost::beast::http::fields &h, ripple::uint256 const &sharedValue, std::optional< std::uint32_t > networkID, beast::IP::Address public_ip, beast::IP::Address remote_ip, Application &app)
Insert fields headers necessary for upgrading the link to the peer protocol.