diff options
| author | Shauren <shauren.trinity@gmail.com> | 2024-11-12 13:54:43 +0100 |
|---|---|---|
| committer | Ovahlord <dreadkiller@gmx.de> | 2024-11-12 20:56:47 +0100 |
| commit | 893f2d4cef5b0ee619a04ef6208ef0c1b974c8a3 (patch) | |
| tree | a9fb77a877e0319edb96ddd0b72ec72441f8bb46 /src/common | |
| parent | 1a32ac5ab0cd6887e3904147bda0bc65af6cb992 (diff) | |
Core/Networking: Support IPv6
(cherry picked from commit af4dcc93ed04c4f2219c14821b25cb9efeb7e781)
# Conflicts:
# sql/base/auth_database.sql
# sql/updates/auth/cata_classic/2024_11_12_00_auth.sql
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/Asio/Resolver.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/common/Asio/Resolver.h b/src/common/Asio/Resolver.h index 01399e435e5..01fd3127abe 100644 --- a/src/common/Asio/Resolver.h +++ b/src/common/Asio/Resolver.h @@ -21,7 +21,8 @@ #include "IoContext.h" #include "Optional.h" #include <boost/asio/ip/tcp.hpp> -#include <string> +#include <string_view> +#include <vector> namespace Trinity { @@ -35,7 +36,7 @@ namespace Trinity public: explicit Resolver(IoContext& ioContext) : _impl(ioContext) { } - Optional<boost::asio::ip::tcp::endpoint> Resolve(boost::asio::ip::tcp const& protocol, std::string const& host, std::string const& service) + Optional<boost::asio::ip::tcp::endpoint> Resolve(boost::asio::ip::tcp const& protocol, std::string_view host, std::string_view service) { boost::system::error_code ec; boost::asio::ip::resolver_base::flags flagsResolver = boost::asio::ip::resolver_base::all_matching; @@ -46,6 +47,18 @@ namespace Trinity return results.begin()->endpoint(); } + std::vector<boost::asio::ip::tcp::endpoint> ResolveAll(std::string_view host, std::string_view service) + { + boost::system::error_code ec; + boost::asio::ip::resolver_base::flags flagsResolver = boost::asio::ip::resolver_base::all_matching; + boost::asio::ip::tcp::resolver::results_type results = _impl.resolve(host, service, flagsResolver, ec); + std::vector<boost::asio::ip::tcp::endpoint> result; + if (!ec) + std::ranges::transform(results, std::back_inserter(result), [](boost::asio::ip::tcp::resolver::results_type::value_type const& entry) { return entry.endpoint(); }); + + return result; + } + private: boost::asio::ip::tcp::resolver _impl; }; |
