Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/bitcoin/network/net/proxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class BCT_API proxy
/// The proxy (socket) is stopped.
bool stopped() const NOEXCEPT;

/// Connection is currently secured (TLS or comparable for socket type).
bool secure() const NOEXCEPT;

/// The number of bytes in the write backlog.
uint64_t backlog() const NOEXCEPT;

Expand Down
7 changes: 3 additions & 4 deletions include/bitcoin/network/net/socket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ class BCT_API socket
/// The socket was accepted (vs. connected).
virtual bool inbound() const NOEXCEPT;

/// The socket upgrades to its secure configuration upon connect.
virtual bool secure() const NOEXCEPT;

/// Stop has been signaled, work is stopping.
virtual bool stopped() const NOEXCEPT;

Expand All @@ -182,7 +185,6 @@ class BCT_API socket
virtual asio::context& service() const NOEXCEPT;

protected:
// TODO: p2p::socket, zmq::socket.
using ws_t = std::variant<ref<ws::socket>, ref<ws::ssl::socket>>;
using tcp_t = std::variant<ref<asio::socket>, ref<asio::ssl::socket>>;
using socket_t = std::variant<
Expand All @@ -198,9 +200,6 @@ class BCT_API socket
/// Context.
/// -----------------------------------------------------------------------

/// Upgrade the socket to its secure configuration.
bool secure() const NOEXCEPT;

/// The socket was upgraded to ssl (requires strand).
bool is_secure() const NOEXCEPT;

Expand Down
10 changes: 6 additions & 4 deletions src/channels/channel_http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,11 @@ void channel_http::assign_json_buffer(response& response) NOEXCEPT
void channel_http::log_message(const request& LOG_ONLY(request),
size_t LOG_ONLY(bytes)) const NOEXCEPT
{
LOG_ONLY(const auto scheme = secure() ? "https" : "http";)
LOG_ONLY(const auto version = "http/" + serialize(request.version() / 10) +
"." + serialize(request.version() % 10);)
LOGA("Http [" << request.method_string()

LOGA(scheme << " [" << request.method_string()
<< "] " << version
<< " (" << (request.chunked() ? "c" : serialize(bytes))
<< ") " << (request.keep_alive() ? "keep" : "drop")
Expand All @@ -206,10 +207,11 @@ void channel_http::log_message(const request& LOG_ONLY(request),
void channel_http::log_message(const response& LOG_ONLY(response),
size_t LOG_ONLY(bytes)) const NOEXCEPT
{
LOG_ONLY(const auto scheme = secure() ? "https" : "http";)
LOG_ONLY(const auto version = "http/" + serialize(response.version() / 10)
+ "." + serialize(response.version() % 10);)
LOGA("Http [" << status_string(response.result())

LOGA(scheme << " [" << status_string(response.result())
<< "] " << version
<< " (" << (response.chunked() ? "c" : serialize(bytes))
<< ") " << (response.keep_alive() ? "keep" : "drop")
Expand Down
5 changes: 5 additions & 0 deletions src/net/proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ bool proxy::stranded() const NOEXCEPT
return socket_->stranded();
}

bool proxy::secure() const NOEXCEPT
{
return socket_->secure();
}

uint64_t proxy::backlog() const NOEXCEPT
{
return backlog_.load(std::memory_order_relaxed);
Expand Down
Loading