mirror of
https://github.com/XRPLF/clio.git
synced 2026-08-22 21:20:52 +00:00
@@ -37,12 +37,16 @@ template <typename T>
|
||||
concept SomeResolver = requires(T t) {
|
||||
std::is_default_constructible_v<T>;
|
||||
{ t.resolve(std::string_view{}, std::string_view{}) } -> std::same_as<std::vector<std::string>>;
|
||||
{ t.resolve(std::string_view{}) } -> std::same_as<std::vector<std::string>>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Simple hostnames to IP addresses resolver.
|
||||
*/
|
||||
class Resolver {
|
||||
boost::asio::io_context ioContext_;
|
||||
boost::asio::ip::tcp::resolver resolver_{ioContext_};
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Resolve hostname to IP addresses.
|
||||
@@ -50,15 +54,26 @@ public:
|
||||
* @throw This method throws an exception when the hostname cannot be resolved.
|
||||
*
|
||||
* @param hostname Hostname to resolve
|
||||
* @param service Service to resolve (could be empty or port number or http)
|
||||
* @return IP addresses of the hostname
|
||||
*/
|
||||
std::vector<std::string>
|
||||
resolve(std::string_view hostname, std::string_view service = "");
|
||||
resolve(std::string_view hostname);
|
||||
|
||||
/**
|
||||
* @brief Resolve to IP addresses with port.
|
||||
*
|
||||
* @throw This method throws an exception when the hostname cannot be resolved.
|
||||
*
|
||||
* @param hostname Hostname to resolve
|
||||
* @param service Service to resolve
|
||||
* @return IP addresses of the hostname
|
||||
*/
|
||||
std::vector<std::string>
|
||||
resolve(std::string_view hostname, std::string_view service);
|
||||
|
||||
private:
|
||||
boost::asio::io_context ioContext_;
|
||||
boost::asio::ip::tcp::resolver resolver_{ioContext_};
|
||||
std::vector<boost::asio::ip::tcp::endpoint>
|
||||
doResolve(std::string_view hostname, std::string_view service);
|
||||
};
|
||||
|
||||
} // namespace web
|
||||
|
||||
Reference in New Issue
Block a user