provide access to servers local acceptor endpoints

This commit is contained in:
Peter Eisenlohr 2021-10-13 19:09:53 +00:00
parent fa7a916ef3
commit 55fce39cbe
6 changed files with 19 additions and 0 deletions

View File

@ -209,6 +209,15 @@ const std::vector<int> server::ports() const {
return ports; return ports;
} }
const std::vector<boost::asio::ip::tcp::endpoint> server::endpoints() const {
std::vector<boost::asio::ip::tcp::endpoint> ports;
ports.reserve(acceptors_.size());
for (const auto &acceptor : acceptors_) {
ports.emplace_back(acceptor.local_endpoint());
}
return ports;
}
} // namespace server } // namespace server
} // namespace asio_http2 } // namespace asio_http2
} // namespace nghttp2 } // namespace nghttp2

View File

@ -81,6 +81,8 @@ public:
/// Returns a vector with all the acceptors ports in use. /// Returns a vector with all the acceptors ports in use.
const std::vector<int> ports() const; const std::vector<int> ports() const;
/// Returns a vector with all the acceptors endpoints.
const std::vector<boost::asio::ip::tcp::endpoint> endpoints() const;
private: private:
/// Initiate an asynchronous accept operation. /// Initiate an asynchronous accept operation.

View File

@ -92,6 +92,8 @@ http2::io_services() const {
std::vector<int> http2::ports() const { return impl_->ports(); } std::vector<int> http2::ports() const { return impl_->ports(); }
std::vector<boost::asio::ip::tcp::endpoint> http2::endpoints() const { return impl_->endpoints(); }
} // namespace server } // namespace server
} // namespace asio_http2 } // namespace asio_http2

View File

@ -80,6 +80,8 @@ http2_impl::io_services() const {
std::vector<int> http2_impl::ports() const { return server_->ports(); } std::vector<int> http2_impl::ports() const { return server_->ports(); }
std::vector<boost::asio::ip::tcp::endpoint> http2_impl::endpoints() const { return server_->endpoints(); }
} // namespace server } // namespace server
} // namespace asio_http2 } // namespace asio_http2

View File

@ -55,6 +55,7 @@ public:
const std::vector<std::shared_ptr<boost::asio::io_service>> & const std::vector<std::shared_ptr<boost::asio::io_service>> &
io_services() const; io_services() const;
std::vector<int> ports() const; std::vector<int> ports() const;
std::vector<boost::asio::ip::tcp::endpoint> endpoints() const;
private: private:
std::unique_ptr<server> server_; std::unique_ptr<server> server_;

View File

@ -217,6 +217,9 @@ public:
// Returns a vector with the ports in use // Returns a vector with the ports in use
std::vector<int> ports() const; std::vector<int> ports() const;
// Returns a vector of the endpoints in use
std::vector<boost::asio::ip::tcp::endpoint> endpoints() const;
private: private:
std::unique_ptr<http2_impl> impl_; std::unique_ptr<http2_impl> impl_;
}; };