MySQL
9.7.0
Source Code Documentation
resolver_net_ts.h
Go to the documentation of this file.
1
/*
2
Copyright (c) 2026, Oracle and/or its affiliates.
3
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License, version 2.0,
6
as published by the Free Software Foundation.
7
8
This program is designed to work with certain software (including
9
but not limited to OpenSSL) that is licensed under separate terms,
10
as designated in a particular file or component or in included license
11
documentation. The authors of MySQL hereby grant you an additional
12
permission to link the program and your derivative works with the
13
separately licensed software that they have either included with
14
the program or referenced in the documentation.
15
16
This program is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
GNU General Public License for more details.
20
21
You should have received a copy of the GNU General Public License
22
along with this program; if not, write to the Free Software
23
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
*/
25
#ifndef ROUTER_SRC_HARNESS_SRC_RESOLVER_RESOLVER_NET_TS_H_
26
#define ROUTER_SRC_HARNESS_SRC_RESOLVER_RESOLVER_NET_TS_H_
27
28
#include <string>
29
#include <utility>
30
31
#include "
mysql/harness/net_ts/internet.h
"
32
#include "
mysql/harness/resolver/error_code.h
"
33
#include "
mysql/harness/resolver/interface.h
"
34
35
namespace
mysql_harness
{
36
namespace
resolver {
37
38
class
ResolverNetTs
:
public
ResolverInterface
{
39
public
:
40
ResolveHostResult
resolve_host
(
const
std::string &hostname,
41
CachePolicy
/*cache_policy*/
)
override
{
42
// Create io_context only for resolution. Net-ts just gets
43
// the correct impl of 'getaddrinfo'. The context is not used
44
// to do any async name-resolution.
45
static
net::io_context
s_context;
46
net::ip::tcp::resolver
resolver(s_context);
47
48
auto
resolve_result = resolver.
resolve
(hostname, {});
49
50
if
(!resolve_result) {
51
if
(resolve_result.error().category() ==
net::ip::resolver_category
() &&
52
resolve_result.error().value() == EAI_NONAME) {
53
return
stdx::unexpected
(
make_error_code
(
ErrcResolveResult::NotFound
));
54
}
55
56
return
stdx::unexpected
(resolve_result.error());
57
}
58
59
ResolvedAddresses
result
;
60
result
.addresses.reserve(resolve_result.value().size());
61
for
(
const
auto
&
entry
: *resolve_result) {
62
auto
address =
entry
.endpoint().address();
63
if
(address.is_v4() || address.is_v6()) {
64
result
.addresses.emplace_back(std::move(address));
65
}
66
}
67
68
return
result
;
69
}
70
};
71
72
}
// namespace resolver
73
}
// namespace mysql_harness
74
75
#endif
/* ROUTER_SRC_HARNESS_SRC_RESOLVER_RESOLVER_NET_TS_H_ */
mysql_harness::resolver::ResolverInterface
Definition:
interface.h:37
mysql_harness::resolver::ResolverNetTs
Definition:
resolver_net_ts.h:38
mysql_harness::resolver::ResolverNetTs::resolve_host
ResolveHostResult resolve_host(const std::string &hostname, CachePolicy) override
Definition:
resolver_net_ts.h:40
net::io_context
Definition:
io_context.h:61
net::ip::basic_resolver
Definition:
internet.h:608
net::ip::basic_resolver::resolve
stdx::expected< results_type, error_type > resolve(const std::string &host_name, const std::string &service_name, flags f)
Definition:
internet.h:618
stdx::expected
Definition:
expected.h:286
error_code.h
interface.h
internet.h
mysql_harness::resolver::ErrcResolveResult::NotFound
@ NotFound
Deterministic negative outcome (NXDOMAIN, NODATA).
mysql_harness::resolver::CachePolicy
CachePolicy
Definition:
common.h:40
mysql_harness::resolver::make_error_code
HARNESS_EXPORT std::error_code make_error_code(ErrcResolveResult) noexcept
Definition:
error_code.cc:56
mysql_harness
Definition:
common.h:44
net::ip::resolver_category
const std::error_category & resolver_category() noexcept
Definition:
resolver.h:113
stdx::unexpected
unexpected(E) -> unexpected< E >
result
struct result result
Definition:
result.h:34
_entry
Definition:
completion_hash.h:35
mysql_harness::resolver::ResolvedAddresses
Definition:
common.h:47
result
Definition:
result.h:30
router
src
harness
src
resolver
resolver_net_ts.h
Generated by
1.9.2