From 8e82428740c0d6b9126480f816178fc404bfd4ec Mon Sep 17 00:00:00 2001 From: Michael Maroszek Date: Tue, 28 Jul 2020 11:36:54 +0200 Subject: [PATCH] expose local endpoint --- server_http.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server_http.hpp b/server_http.hpp index e5f6952..4506313 100644 --- a/server_http.hpp +++ b/server_http.hpp @@ -241,6 +241,16 @@ namespace SimpleWeb { return asio::ip::tcp::endpoint(); } + asio::ip::tcp::endpoint local_endpoint() const noexcept { + try { + if(auto connection = this->connection.lock()) + return connection->socket->lowest_layer().local_endpoint(); + } + catch(...) { + } + return asio::ip::tcp::endpoint(); + } + /// Deprecated, please use remote_endpoint().address().to_string() instead. DEPRECATED std::string remote_endpoint_address() const noexcept { try {