-
Notifications
You must be signed in to change notification settings - Fork 5.5k
dynamic_forward_proxy: adding dns_resolvers to dns_cache used by the proxy filter #16294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 42 commits
c152c7e
9fa85a7
3988eb0
026ca82
6260b09
9d95c7b
5501231
d3aaa31
a673969
c03697b
7d41f09
0677cf9
2feca06
54af3ba
9390e7a
5c1ae91
04cc847
a9a03bc
be652e9
6be5d06
6d4aa65
6e99c81
b67d82e
2d7e299
e689756
25e4ae0
9d2d403
e9c44c7
7c44cc6
0602d8d
6af2490
4e2a6e8
3b41679
f9a8326
6234826
364258f
e91e5e0
8060ed8
58c0500
94c5bd3
19201c5
8a7d214
6a3f7e5
e0f0df2
5eef9b3
80b95ea
0412e3a
69345fe
e83289a
004177f
aaaea99
ecd3229
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| syntax = "proto3"; | ||
|
|
||
| package envoy.config.core.v3; | ||
|
|
||
| import "envoy/config/core/v3/address.proto"; | ||
|
|
||
| import "udpa/annotations/status.proto"; | ||
|
|
||
| option java_package = "io.envoyproxy.envoy.config.core.v3"; | ||
| option java_outer_classname = "ResolverProto"; | ||
| option java_multiple_files = true; | ||
| option (udpa.annotations.file_status).package_version_status = ACTIVE; | ||
|
|
||
| // [#protodoc-title: Resolver] | ||
|
|
||
| // DNS resolver configuration which includes the underlying dns resolver addresses and options | ||
| message DnsResolver { | ||
| // A list of dns resolver addresses | ||
| // Setting this value causes failure if the | ||
| // ``envoy.restart_features.use_apple_api_for_dns_lookups`` runtime value is true during | ||
| // server startup. Apple's API only allows overriding DNS resolvers via system settings. | ||
| repeated Address resolvers = 1; | ||
|
ntgsx92 marked this conversation as resolved.
Outdated
|
||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
|
|
||
| #include "common/config/utility.h" | ||
| #include "common/http/utility.h" | ||
| #include "common/network/resolver_impl.h" | ||
| #include "common/network/utility.h" | ||
|
|
||
| // TODO(mattklein123): Move DNS family helpers to a smaller include. | ||
|
|
@@ -20,8 +21,8 @@ DnsCacheImpl::DnsCacheImpl( | |
| const envoy::extensions::common::dynamic_forward_proxy::v3::DnsCacheConfig& config) | ||
| : main_thread_dispatcher_(main_thread_dispatcher), | ||
| dns_lookup_family_(Upstream::getDnsLookupFamilyFromEnum(config.dns_lookup_family())), | ||
| resolver_(main_thread_dispatcher.createDnsResolver({}, config.use_tcp_for_dns_lookups())), | ||
| tls_slot_(tls), scope_(root_scope.createScope(fmt::format("dns_cache.{}.", config.name()))), | ||
| resolver_(selectDnsResolver(config, main_thread_dispatcher)), tls_slot_(tls), | ||
| scope_(root_scope.createScope(fmt::format("dns_cache.{}.", config.name()))), | ||
| stats_(generateDnsCacheStats(*scope_)), | ||
| resource_manager_(*scope_, loader, config.name(), config.dns_cache_circuit_breaker()), | ||
| refresh_interval_(PROTOBUF_GET_MS_OR_DEFAULT(config, dns_refresh_rate, 60000)), | ||
|
|
@@ -46,6 +47,23 @@ DnsCacheImpl::~DnsCacheImpl() { | |
| } | ||
| } | ||
|
|
||
| Network::DnsResolverSharedPtr DnsCacheImpl::selectDnsResolver( | ||
| const envoy::extensions::common::dynamic_forward_proxy::v3::DnsCacheConfig& config, | ||
| Event::Dispatcher& main_thread_dispatcher) { | ||
| if (config.has_dns_resolver() && !config.dns_resolver().resolvers().empty()) { | ||
| const auto& resolver_addrs = config.dns_resolver().resolvers(); | ||
| std::vector<Network::Address::InstanceConstSharedPtr> resolvers; | ||
| resolvers.reserve(resolver_addrs.size()); | ||
| for (const auto& resolver_addr : resolver_addrs) { | ||
| resolvers.push_back(Network::Address::resolveProtoAddress(resolver_addr)); | ||
| } | ||
| const bool use_tcp_for_dns_lookups = config.use_tcp_for_dns_lookups(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can pass directly to the parameter.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @adisuissa, since the PR #16237 will follow this PR(16294) shortly, this line will be replaced by using |
||
| return main_thread_dispatcher.createDnsResolver(resolvers, use_tcp_for_dns_lookups); | ||
| } | ||
|
|
||
| return main_thread_dispatcher.createDnsResolver({}, config.use_tcp_for_dns_lookups()); | ||
| } | ||
|
|
||
| DnsCacheStats DnsCacheImpl::generateDnsCacheStats(Stats::Scope& scope) { | ||
| return {ALL_DNS_CACHE_STATS(POOL_COUNTER(scope), POOL_GAUGE(scope))}; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.