From 6b5b085b78dc84f6d97e13ef76057f6a9108b20a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Augustyniak?= Date: Thu, 7 Jul 2022 18:52:22 +0200 Subject: [PATCH 01/16] api: make RequestTrailersBuilder and ResponseHeadersBuilder constructors public (#2410) Description: Revert constructors' visibility to the state from before https://github.com/envoyproxy/envoy-mobile/pull/2400. These constructors were supposed to be public. Risk Level: None Testing: None Docs Changes: N/A Release Notes: N/A Signed-off-by: Rafal Augustyniak --- .../kotlin/io/envoyproxy/envoymobile/RequestTrailersBuilder.kt | 2 +- .../kotlin/io/envoyproxy/envoymobile/ResponseHeadersBuilder.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/kotlin/io/envoyproxy/envoymobile/RequestTrailersBuilder.kt b/library/kotlin/io/envoyproxy/envoymobile/RequestTrailersBuilder.kt index 26b57e56eb..085a1bc775 100644 --- a/library/kotlin/io/envoyproxy/envoymobile/RequestTrailersBuilder.kt +++ b/library/kotlin/io/envoyproxy/envoymobile/RequestTrailersBuilder.kt @@ -7,7 +7,7 @@ class RequestTrailersBuilder : HeadersBuilder { /* * Instantiate a new builder. */ - internal constructor() : super(HeadersContainer(mapOf())) + constructor() : super(HeadersContainer(mapOf())) /* * Instantiate a new instance of the builder. diff --git a/library/kotlin/io/envoyproxy/envoymobile/ResponseHeadersBuilder.kt b/library/kotlin/io/envoyproxy/envoymobile/ResponseHeadersBuilder.kt index 4c57f9526f..93254aaac8 100644 --- a/library/kotlin/io/envoyproxy/envoymobile/ResponseHeadersBuilder.kt +++ b/library/kotlin/io/envoyproxy/envoymobile/ResponseHeadersBuilder.kt @@ -8,7 +8,7 @@ class ResponseHeadersBuilder : HeadersBuilder { /* * Instantiate a new builder. */ - internal constructor() : super(HeadersContainer(mapOf())) + constructor() : super(HeadersContainer(mapOf())) /* * Instantiate a new builder. Used only by ResponseHeaders to convert back to From 0b88af49eeab703e69c85de096301afba9683339 Mon Sep 17 00:00:00 2001 From: JP Simard Date: Fri, 8 Jul 2022 17:16:59 -0400 Subject: [PATCH 02/16] engine: remove outdated comment about `registerFactories()` (#2412) `ExtensionRegistry::registerFactories()` doesn't do any work at runtime, its purpose is to guarantee that the linker won't strip away these factories as dead code because they're discovered at runtime as opposed to being referenced statically. So it's safe to call on engine creation because it's a no-op at runtime. Signed-off-by: JP Simard --- library/common/engine.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/library/common/engine.cc b/library/common/engine.cc index aca974474f..d8abe2521e 100644 --- a/library/common/engine.cc +++ b/library/common/engine.cc @@ -16,9 +16,6 @@ Engine::Engine(envoy_engine_callbacks callbacks, envoy_logger logger, envoy_event_tracker event_tracker) : callbacks_(callbacks), logger_(logger), event_tracker_(event_tracker), dispatcher_(std::make_unique()) { - // Ensure static factory registration occurs on time. - // TODO: ensure this is only called one time once multiple Engine objects can be allocated. - // https://github.com/envoyproxy/envoy-mobile/issues/332 ExtensionRegistry::registerFactories(); // TODO(Augustyniak): Capturing an address of event_tracker_ and registering it in the API From 3d0bd00c860eda37b61ea905f892216da3c96ffe Mon Sep 17 00:00:00 2001 From: envoy-bot <37382446+envoy-bot@users.noreply.github.com> Date: Mon, 11 Jul 2022 12:27:24 -0600 Subject: [PATCH 03/16] Update Envoy (#2413) Signed-off-by: GitHub Action Co-authored-by: jpsim --- envoy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/envoy b/envoy index e5ef611dd9..f2c832b965 160000 --- a/envoy +++ b/envoy @@ -1 +1 @@ -Subproject commit e5ef611dd9a0e840681cd6e99c6cffc97ecb47b5 +Subproject commit f2c832b9656da1494b16aeffc8e7f399633faabb From f3ef916ac219ef147e0b7bb4e265bb71592c72df Mon Sep 17 00:00:00 2001 From: JP Simard Date: Wed, 13 Jul 2022 11:53:44 -0400 Subject: [PATCH 04/16] iOS: fix retain cycles in `EnvoyNetworkMonitor` (#2415) And properly clean up reachability ref. Signed-off-by: JP Simard --- library/objective-c/EnvoyNetworkMonitor.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/objective-c/EnvoyNetworkMonitor.m b/library/objective-c/EnvoyNetworkMonitor.m index 5f6a435917..6ee2e6a3de 100644 --- a/library/objective-c/EnvoyNetworkMonitor.m +++ b/library/objective-c/EnvoyNetworkMonitor.m @@ -26,6 +26,11 @@ - (void)dealloc { if (_path_monitor) { nw_path_monitor_cancel(_path_monitor); } + if (_reachability_ref) { + SCNetworkReachabilitySetCallback(_reachability_ref, nil, nil); + SCNetworkReachabilitySetDispatchQueue(_reachability_ref, nil); + CFRelease(_reachability_ref); + } } - (void)startPathMonitor { @@ -38,6 +43,7 @@ - (void)startPathMonitor { nw_path_monitor_set_queue(_path_monitor, queue); __block envoy_network_t previousNetworkType = -1; + envoy_engine_t engineHandle = _engineHandle; nw_path_monitor_set_update_handler(_path_monitor, ^(nw_path_t _Nonnull path) { BOOL isSatisfied = nw_path_get_status(path) == nw_path_status_satisfied; if (!isSatisfied) { @@ -60,7 +66,7 @@ - (void)startPathMonitor { if (network != previousNetworkType) { NSLog(@"[Envoy] setting preferred network to %d", network); - set_preferred_network(_engineHandle, network); + set_preferred_network(engineHandle, network); previousNetworkType = network; } From 41369cc036956ee2814af63563665c1c389884b0 Mon Sep 17 00:00:00 2001 From: envoy-bot <37382446+envoy-bot@users.noreply.github.com> Date: Wed, 13 Jul 2022 10:41:18 -0600 Subject: [PATCH 05/16] Bump Lyft Support Rotation (#2414) Signed-off-by: GitHub Action Co-authored-by: jpsim --- .github/lyft_maintainers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/lyft_maintainers.yml b/.github/lyft_maintainers.yml index 93fa6d0be6..f23021193a 100644 --- a/.github/lyft_maintainers.yml +++ b/.github/lyft_maintainers.yml @@ -1,4 +1,4 @@ -current: Augustyniak +current: snowp maintainers: - Augustyniak - snowp From e5500ce700717eb93ec3c04e97ab428df43528dd Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Wed, 13 Jul 2022 10:09:27 -0700 Subject: [PATCH 06/16] Remove rules_cc uses Signed-off-by: Keith Smiley --- bazel/android_artifacts.bzl | 3 +-- bazel/apple_test.bzl | 3 +-- examples/objective-c/hello_world/BUILD | 1 - library/common/jni/BUILD | 1 - library/common/jni/import/BUILD | 1 - library/objective-c/BUILD | 2 -- test/common/jni/BUILD | 1 - test/swift/integration/BUILD | 1 - third_party/rbe_configs/cc/BUILD | 1 - 9 files changed, 2 insertions(+), 12 deletions(-) diff --git a/bazel/android_artifacts.bzl b/bazel/android_artifacts.bzl index e577b4d2a5..e3a7ad73c0 100644 --- a/bazel/android_artifacts.bzl +++ b/bazel/android_artifacts.bzl @@ -1,7 +1,6 @@ load("@build_bazel_rules_android//android:rules.bzl", "android_binary") load("@envoy_mobile//bazel:dokka.bzl", "sources_javadocs") load("@rules_java//java:defs.bzl", "java_binary") -load("@rules_cc//cc:defs.bzl", "cc_library") load("@google_bazel_common//tools/maven:pom_file.bzl", "pom_file") # This file is based on https://github.com/aj-michael/aar_with_jni which is @@ -203,7 +202,7 @@ def _create_jni_library(name, native_deps = []): # We wrap our native so dependencies in a cc_library because android_binaries # require a library target as dependencies in order to generate the appropriate # architectures in the directory `lib/` - cc_library( + native.cc_library( name = cc_lib_name, srcs = native_deps, ) diff --git a/bazel/apple_test.bzl b/bazel/apple_test.bzl index 4e2a8a38c5..37510959b3 100644 --- a/bazel/apple_test.bzl +++ b/bazel/apple_test.bzl @@ -1,6 +1,5 @@ load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test") load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") -load("@rules_cc//cc:defs.bzl", "objc_library") load("//bazel:config.bzl", "MINIMUM_IOS_VERSION") # Macro providing a way to easily/consistently define Swift unit test targets. @@ -44,7 +43,7 @@ def envoy_mobile_swift_test(name, srcs, data = [], deps = [], tags = [], reposit def envoy_mobile_objc_test(name, srcs, data = [], deps = [], tags = [], visibility = []): test_lib_name = name + "_lib" - objc_library( + native.objc_library( name = test_lib_name, srcs = srcs, data = data, diff --git a/examples/objective-c/hello_world/BUILD b/examples/objective-c/hello_world/BUILD index 4c85dbc97c..c027462fc7 100644 --- a/examples/objective-c/hello_world/BUILD +++ b/examples/objective-c/hello_world/BUILD @@ -1,5 +1,4 @@ load("//bazel:config.bzl", "MINIMUM_IOS_VERSION") -load("@rules_cc//cc:defs.bzl", "objc_library") load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application") licenses(["notice"]) # Apache 2 diff --git a/library/common/jni/BUILD b/library/common/jni/BUILD index dcf22d6136..0c7dd182cf 100644 --- a/library/common/jni/BUILD +++ b/library/common/jni/BUILD @@ -1,6 +1,5 @@ load("//bazel:kotlin_lib.bzl", "envoy_mobile_so_to_jni_lib") load("//bazel:android_debug_info.bzl", "android_debug_info") -load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") load("@envoy//bazel:envoy_build_system.bzl", "envoy_package") load("//bazel:envoy_mobile_test_extensions.bzl", "TEST_EXTENSIONS") diff --git a/library/common/jni/import/BUILD b/library/common/jni/import/BUILD index a15794127d..16fb814475 100644 --- a/library/common/jni/import/BUILD +++ b/library/common/jni/import/BUILD @@ -1,4 +1,3 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") load("@envoy//bazel:envoy_build_system.bzl", "envoy_package") licenses(["notice"]) # Apache 2 diff --git a/library/objective-c/BUILD b/library/objective-c/BUILD index af8f13a3ff..60eec3bb16 100644 --- a/library/objective-c/BUILD +++ b/library/objective-c/BUILD @@ -1,5 +1,3 @@ -load("@rules_cc//cc:defs.bzl", "objc_library") - licenses(["notice"]) # Apache 2 exports_files([ diff --git a/test/common/jni/BUILD b/test/common/jni/BUILD index 3a167db040..8de058294d 100644 --- a/test/common/jni/BUILD +++ b/test/common/jni/BUILD @@ -1,5 +1,4 @@ load("@envoy//bazel:envoy_build_system.bzl", "envoy_package") -load("@rules_cc//cc:defs.bzl", "cc_binary") load("//bazel:kotlin_lib.bzl", "envoy_mobile_so_to_jni_lib") licenses(["notice"]) # Apache 2 diff --git a/test/swift/integration/BUILD b/test/swift/integration/BUILD index 973152b032..a22b10d16b 100644 --- a/test/swift/integration/BUILD +++ b/test/swift/integration/BUILD @@ -1,4 +1,3 @@ -load("@rules_cc//cc:defs.bzl", "objc_library") load("@envoy_mobile//bazel:apple_test.bzl", "envoy_mobile_swift_test") load("@envoy_mobile//bazel:envoy_mobile_test_extensions.bzl", "TEST_EXTENSIONS") load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library") diff --git a/third_party/rbe_configs/cc/BUILD b/third_party/rbe_configs/cc/BUILD index 3ae2389a9a..ef5c08e321 100644 --- a/third_party/rbe_configs/cc/BUILD +++ b/third_party/rbe_configs/cc/BUILD @@ -16,7 +16,6 @@ load(":cc_toolchain_config.bzl", "cc_toolchain_config") load(":armeabi_cc_toolchain_config.bzl", "armeabi_cc_toolchain_config") -load("@rules_cc//cc:defs.bzl", "cc_toolchain", "cc_toolchain_suite") package(default_visibility = ["//visibility:public"]) From a327a04ea104c89341b71b36d45c0e245ed65085 Mon Sep 17 00:00:00 2001 From: envoy-bot <37382446+envoy-bot@users.noreply.github.com> Date: Thu, 14 Jul 2022 06:50:04 -0600 Subject: [PATCH 07/16] Update Envoy (#2417) Signed-off-by: GitHub Action Co-authored-by: jpsim --- envoy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/envoy b/envoy index f2c832b965..afdc9bd288 160000 --- a/envoy +++ b/envoy @@ -1 +1 @@ -Subproject commit f2c832b9656da1494b16aeffc8e7f399633faabb +Subproject commit afdc9bd2882666a67c829ecc909d6096988e27ad From 529cbe572440557465c50e14535d8cf74496151d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Augustyniak?= Date: Thu, 14 Jul 2022 15:40:58 +0200 Subject: [PATCH 08/16] docs: use sphinx githubpages extension (#2418) Description: This change is an attempt to fix images in the generated documentation. As it is now they do not work - [example](https://envoy-mobile.github.io/docs/envoy-mobile/latest/development/debugging/android_local.html). The issues seems to be caused by the fact that Sphinx puts all of the images in `_images` directory and Github Pages, backed by `jekyll`, ignores all directories whose names start with `_`. The idea is to use `sphinx.ext.githubpages` extension that puts `.nojekyll` file in the root of the generated sphinx artifacts which is supposed to fix the issue as reported in https://stackoverflow.com/a/64544659. Not a great way to test this e2e locally so may need to revert the change if it turns out that the issue persists. Risk Level: Low, documentation changes Testing: Generated sphinx's artifacts locally with and without the change. Confirmed that with the change I can see `.nojekyll` file being added to `generated/docs` directory. Docs Changes: Release Notes: Signed-off-by: Rafal Augustyniak --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 3e7e11cccd..610c534f5f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -67,7 +67,7 @@ def setup(app): # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ['sphinxcontrib.httpdomain', 'sphinx.ext.extlinks', 'sphinx.ext.ifconfig'] +extensions = ['sphinxcontrib.httpdomain', 'sphinx.ext.extlinks', 'sphinx.ext.ifconfig', 'sphinx.ext.githubpages'] extlinks = { 'issue': ('https://github.com/envoyproxy/envoy-mobile/issues/%s', ''), 'repo': ('https://github.com/envoyproxy/envoy-mobile/blob/{}/%s'.format(blob_sha), ''), From a12287c681f15765779b1f35e4b37a63f4062a55 Mon Sep 17 00:00:00 2001 From: JP Simard Date: Thu, 14 Jul 2022 16:40:31 -0400 Subject: [PATCH 09/16] dns: allow using the `getaddrinfo`-based system DNS resolver (#2419) For non-Apple platforms like Linux and Android. Updated the Kotlin, Java & C++ builders. Added here: https://github.com/envoyproxy/envoy/pull/22080 Risk Level: Low to moderate, off by default but I had to refactor some stuff. Testing: Added. Docs Changes: Documentation comments. Release Notes: Added. Signed-off-by: JP Simard --- docs/root/intro/version_history.rst | 1 + .../extensions_build_config.bzl | 1 + library/cc/engine_builder.cc | 42 +++++++++++++------ library/cc/engine_builder.h | 4 +- .../engine/EnvoyConfiguration.java | 42 ++++++++++++------- .../impl/NativeCronetEngineBuilderImpl.java | 16 +++---- .../envoyproxy/envoymobile/EngineBuilder.kt | 18 ++++++++ test/cc/unit/envoy_config_test.cc | 13 ++++++ .../engine/EnvoyConfigurationTest.kt | 16 +++++++ test/kotlin/apps/experimental/MainActivity.kt | 1 + 10 files changed, 118 insertions(+), 36 deletions(-) diff --git a/docs/root/intro/version_history.rst b/docs/root/intro/version_history.rst index f1a1907f27..67df745861 100644 --- a/docs/root/intro/version_history.rst +++ b/docs/root/intro/version_history.rst @@ -44,6 +44,7 @@ Features: - android: create simple persistent SharedPreferencesStore (:issue: `#2319 <2319>`) - iOS: A documentation archive is now included in the GitHub release artifact (:issue: `#2335 <2335>`) - api: improved C++ APIs compatibility with Java / Kotlin / Swift (:issue `#2362 <2362>`) +- api: add option to use the a ``getaddrinfo``-based system DNS resolver instead of c-ares (:issue: `#2419 <2419>`) 0.4.6 (April 26, 2022) ======================== diff --git a/envoy_build_config/extensions_build_config.bzl b/envoy_build_config/extensions_build_config.bzl index 47a84e0648..248158ab49 100644 --- a/envoy_build_config/extensions_build_config.bzl +++ b/envoy_build_config/extensions_build_config.bzl @@ -18,6 +18,7 @@ EXTENSIONS = { "envoy.http.original_ip_detection.xff": "//source/extensions/http/original_ip_detection/xff:config", "envoy.key_value.platform": "@envoy_mobile//library/common/extensions/key_value/platform:config", "envoy.network.dns_resolver.apple": "//source/extensions/network/dns_resolver/apple:config", + "envoy.network.dns_resolver.getaddrinfo": "//source/extensions/network/dns_resolver/getaddrinfo:config", "envoy.retry.options.network_configuration": "@envoy_mobile//library/common/extensions/retry/options/network_configuration:config", "envoy.stat_sinks.metrics_service": "//source/extensions/stat_sinks/metrics_service:config", "envoy.transport_sockets.raw_buffer": "//source/extensions/transport_sockets/raw_buffer:config", diff --git a/library/cc/engine_builder.cc b/library/cc/engine_builder.cc index 4a4a230fa3..78ca403661 100644 --- a/library/cc/engine_builder.cc +++ b/library/cc/engine_builder.cc @@ -11,17 +11,7 @@ namespace Platform { EngineBuilder::EngineBuilder(std::string config_template) : callbacks_(std::make_shared()), config_template_(config_template) {} -EngineBuilder::EngineBuilder() : EngineBuilder(std::string(config_template)) { -#if defined(__APPLE__) - dns_resolver_name_ = "envoy.network.dns_resolver.apple"; - dns_resolver_config_ = "{\"@type\":\"type.googleapis.com/" - "envoy.extensions.network.dns_resolver.apple.v3.AppleDnsResolverConfig\"}"; -#else - dns_resolver_name_ = "envoy.network.dns_resolver.cares"; - dns_resolver_config_ = "{\"@type\":\"type.googleapis.com/" - "envoy.extensions.network.dns_resolver.cares.v3.CaresDnsResolverConfig\"}"; -#endif -} +EngineBuilder::EngineBuilder() : EngineBuilder(std::string(config_template)) {} EngineBuilder& EngineBuilder::addLogLevel(LogLevel log_level) { this->log_level_ = log_level; @@ -65,6 +55,11 @@ EngineBuilder::addDnsPreresolveHostnames(const std::string& dns_preresolve_hostn return *this; } +EngineBuilder& EngineBuilder::useDnsSystemResolver(bool use_system_resolver) { + this->use_system_resolver_ = use_system_resolver; + return *this; +} + EngineBuilder& EngineBuilder::addH2ConnectionKeepaliveIdleIntervalMilliseconds( int h2_connection_keepalive_idle_interval_milliseconds) { this->h2_connection_keepalive_idle_interval_milliseconds_ = @@ -119,6 +114,27 @@ EngineBuilder& EngineBuilder::enableBrotli(bool brotli_on) { } std::string EngineBuilder::generateConfigStr() { +#if defined(__APPLE__) + std::string dns_resolver_name = "envoy.network.dns_resolver.apple"; + std::string dns_resolver_config = + "{\"@type\":\"type.googleapis.com/" + "envoy.extensions.network.dns_resolver.apple.v3.AppleDnsResolverConfig\"}"; +#else + std::string dns_resolver_name = ""; + std::string dns_resolver_config = ""; + if (this->use_system_resolver_) { + dns_resolver_name = "envoy.network.dns_resolver.getaddrinfo"; + dns_resolver_config = + "{\"@type\":\"type.googleapis.com/" + "envoy.extensions.network.dns_resolver.getaddrinfo.v3.GetAddrInfoDnsResolverConfig\"}"; + } else { + dns_resolver_name = "envoy.network.dns_resolver.cares"; + dns_resolver_config = + "{\"@type\":\"type.googleapis.com/" + "envoy.extensions.network.dns_resolver.cares.v3.CaresDnsResolverConfig\"}"; + } +#endif + std::vector> replacements{ {"connect_timeout", fmt::format("{}s", this->connect_timeout_seconds_)}, {"dns_fail_base_interval", fmt::format("{}s", this->dns_failure_refresh_seconds_base_)}, @@ -126,8 +142,8 @@ std::string EngineBuilder::generateConfigStr() { {"dns_preresolve_hostnames", this->dns_preresolve_hostnames_}, {"dns_refresh_rate", fmt::format("{}s", this->dns_refresh_seconds_)}, {"dns_query_timeout", fmt::format("{}s", this->dns_query_timeout_seconds_)}, - {"dns_resolver_name", dns_resolver_name_}, - {"dns_resolver_config", dns_resolver_config_}, + {"dns_resolver_name", dns_resolver_name}, + {"dns_resolver_config", dns_resolver_config}, {"h2_connection_keepalive_idle_interval", fmt::format("{}s", this->h2_connection_keepalive_idle_interval_milliseconds_ / 1000.0)}, {"h2_connection_keepalive_timeout", diff --git a/library/cc/engine_builder.h b/library/cc/engine_builder.h index fd0db97535..e9da0a5aba 100644 --- a/library/cc/engine_builder.h +++ b/library/cc/engine_builder.h @@ -24,6 +24,7 @@ class EngineBuilder { EngineBuilder& addDnsFailureRefreshSeconds(int base, int max); EngineBuilder& addDnsQueryTimeoutSeconds(int dns_query_timeout_seconds); EngineBuilder& addDnsPreresolveHostnames(const std::string& dns_preresolve_hostnames); + EngineBuilder& useDnsSystemResolver(bool use_system_resolver); EngineBuilder& addH2ConnectionKeepaliveIdleIntervalMilliseconds( int h2_connection_keepalive_idle_interval_milliseconds); EngineBuilder& @@ -63,6 +64,7 @@ class EngineBuilder { int dns_failure_refresh_seconds_max_ = 10; int dns_query_timeout_seconds_ = 25; std::string dns_preresolve_hostnames_ = "[]"; + bool use_system_resolver_ = false; int h2_connection_keepalive_idle_interval_milliseconds_ = 100000000; int h2_connection_keepalive_timeout_seconds_ = 10; int stats_flush_seconds_ = 60; @@ -72,8 +74,6 @@ class EngineBuilder { std::string virtual_clusters_ = "[]"; std::string config_override_for_tests_ = ""; std::string admin_address_path_for_tests_ = ""; - std::string dns_resolver_name_ = ""; - std::string dns_resolver_config_ = ""; int stream_idle_timeout_seconds_ = 15; int per_try_idle_timeout_seconds_ = 15; bool gzip_filter_ = true; diff --git a/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java b/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java index f0612e79bf..b8ec294b08 100644 --- a/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java +++ b/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java @@ -36,6 +36,7 @@ public enum TrustChainVerification { public final String dnsPreresolveHostnames; public final List dnsFallbackNameservers; public final Boolean dnsFilterUnroutableFamilies; + public final Boolean dnsUseSystemResolver; public final Boolean enableDrainPostDnsRefresh; public final Boolean enableHttp3; public final Boolean enableGzip; @@ -77,6 +78,8 @@ public enum TrustChainVerification { * @param dnsPreresolveHostnames hostnames to preresolve on Envoy Client construction. * @param dnsFallbackNameservers addresses to use as DNS name server fallback. * @param dnsFilterUnroutableFamilies whether to filter unroutable IP families or not. + * @param dnsUseSystemResolver whether to use the getaddrinfo-based system resolver or + * c-ares. * @param enableDrainPostDnsRefresh whether to drain connections after soft DNS refresh. * @param enableHttp3 whether to enable experimental support for HTTP/3 (QUIC). * @param enableGzip whether to enable response gzip decompression. @@ -104,18 +107,19 @@ public enum TrustChainVerification { * @param keyValueStores platform key-value store implementations. */ public EnvoyConfiguration( - Boolean adminInterfaceEnabled, String grpcStatsDomain, @Nullable Integer statsdPort, + boolean adminInterfaceEnabled, String grpcStatsDomain, @Nullable Integer statsdPort, int connectTimeoutSeconds, int dnsRefreshSeconds, int dnsFailureRefreshSecondsBase, int dnsFailureRefreshSecondsMax, int dnsQueryTimeoutSeconds, int dnsMinRefreshSeconds, String dnsPreresolveHostnames, List dnsFallbackNameservers, - Boolean dnsFilterUnroutableFamilies, boolean enableDrainPostDnsRefresh, boolean enableHttp3, - boolean enableGzip, boolean enableBrotli, boolean enableHappyEyeballs, - boolean enableInterfaceBinding, boolean forceIPv6, - int h2ConnectionKeepaliveIdleIntervalMilliseconds, int h2ConnectionKeepaliveTimeoutSeconds, - boolean h2ExtendKeepaliveTimeout, List h2RawDomains, int maxConnectionsPerHost, - int statsFlushSeconds, int streamIdleTimeoutSeconds, int perTryIdleTimeoutSeconds, - String appVersion, String appId, TrustChainVerification trustChainVerification, - String virtualClusters, List nativeFilterChain, + boolean dnsFilterUnroutableFamilies, boolean dnsUseSystemResolver, + boolean enableDrainPostDnsRefresh, boolean enableHttp3, boolean enableGzip, + boolean enableBrotli, boolean enableHappyEyeballs, boolean enableInterfaceBinding, + boolean forceIPv6, int h2ConnectionKeepaliveIdleIntervalMilliseconds, + int h2ConnectionKeepaliveTimeoutSeconds, boolean h2ExtendKeepaliveTimeout, + List h2RawDomains, int maxConnectionsPerHost, int statsFlushSeconds, + int streamIdleTimeoutSeconds, int perTryIdleTimeoutSeconds, String appVersion, String appId, + TrustChainVerification trustChainVerification, String virtualClusters, + List nativeFilterChain, List httpPlatformFilterFactories, Map stringAccessors, Map keyValueStores) { @@ -131,6 +135,7 @@ public EnvoyConfiguration( this.dnsPreresolveHostnames = dnsPreresolveHostnames; this.dnsFallbackNameservers = dnsFallbackNameservers; this.dnsFilterUnroutableFamilies = dnsFilterUnroutableFamilies; + this.dnsUseSystemResolver = dnsUseSystemResolver; this.enableDrainPostDnsRefresh = enableDrainPostDnsRefresh; this.enableHttp3 = enableHttp3; this.enableGzip = enableGzip; @@ -228,10 +233,19 @@ String resolveTemplate(final String configTemplate, final String platformFilterT h2RawDomainsAsString = sb.toString(); } - String dnsResolverConfig = String.format( - "{\"@type\":\"type.googleapis.com/envoy.extensions.network.dns_resolver.cares.v3.CaresDnsResolverConfig\",\"resolvers\":%s,\"use_resolvers_as_fallback\": %s, \"filter_unroutable_families\": %s}", - dnsFallbackNameserversAsString, !dnsFallbackNameservers.isEmpty() ? "true" : "false", - dnsFilterUnroutableFamilies ? "true" : "false"); + String dnsResolverName = ""; + String dnsResolverConfig = ""; + if (dnsUseSystemResolver) { + dnsResolverName = "envoy.network.dns_resolver.getaddrinfo"; + dnsResolverConfig = + "{\"@type\":\"type.googleapis.com/envoy.extensions.network.dns_resolver.getaddrinfo.v3.GetAddrInfoDnsResolverConfig\"}"; + } else { + dnsResolverName = "envoy.network.dns_resolver.cares"; + dnsResolverConfig = String.format( + "{\"@type\":\"type.googleapis.com/envoy.extensions.network.dns_resolver.cares.v3.CaresDnsResolverConfig\",\"resolvers\":%s,\"use_resolvers_as_fallback\": %s, \"filter_unroutable_families\": %s}", + dnsFallbackNameserversAsString, !dnsFallbackNameservers.isEmpty() ? "true" : "false", + dnsFilterUnroutableFamilies ? "true" : "false"); + } StringBuilder configBuilder = new StringBuilder("!ignore platform_defs:\n"); configBuilder.append(String.format("- &connect_timeout %ss\n", connectTimeoutSeconds)) @@ -246,7 +260,7 @@ String resolveTemplate(final String configTemplate, final String platformFilterT String.format("- &dns_multiple_addresses %s\n", enableHappyEyeballs ? "true" : "false")) .append(String.format("- &h2_delay_keepalive_timeout %s\n", h2ExtendKeepaliveTimeout ? "true" : "false")) - .append("- &dns_resolver_name envoy.network.dns_resolver.cares\n") + .append(String.format("- &dns_resolver_name %s\n", dnsResolverName)) .append(String.format("- &dns_refresh_rate %ss\n", dnsRefreshSeconds)) .append(String.format("- &dns_resolver_config %s\n", dnsResolverConfig)) .append(String.format("- &enable_drain_post_dns_refresh %s\n", diff --git a/library/java/org/chromium/net/impl/NativeCronetEngineBuilderImpl.java b/library/java/org/chromium/net/impl/NativeCronetEngineBuilderImpl.java index cb2c985360..fc9d1e06db 100644 --- a/library/java/org/chromium/net/impl/NativeCronetEngineBuilderImpl.java +++ b/library/java/org/chromium/net/impl/NativeCronetEngineBuilderImpl.java @@ -43,6 +43,7 @@ public class NativeCronetEngineBuilderImpl extends CronetEngineBuilderImpl { private String mDnsPreresolveHostnames = "[]"; private List mDnsFallbackNameservers = Collections.emptyList(); private boolean mEnableDnsFilterUnroutableFamilies = false; + private boolean mDnsUseSystemResolver = false; private boolean mEnableDrainPostDnsRefresh = false; private boolean mEnableHttp3 = false; private boolean mEnableGzip = true; @@ -107,12 +108,13 @@ private EnvoyConfiguration createEnvoyConfiguration() { mAdminInterfaceEnabled, mGrpcStatsDomain, mStatsDPort, mConnectTimeoutSeconds, mDnsRefreshSeconds, mDnsFailureRefreshSecondsBase, mDnsFailureRefreshSecondsMax, mDnsQueryTimeoutSeconds, mDnsMinRefreshSeconds, mDnsPreresolveHostnames, - mDnsFallbackNameservers, mEnableDnsFilterUnroutableFamilies, mEnableDrainPostDnsRefresh, - mEnableHttp3, mEnableGzip, brotliEnabled(), mEnableHappyEyeballs, mEnableInterfaceBinding, - mForceIPv6, mH2ConnectionKeepaliveIdleIntervalMilliseconds, - mH2ConnectionKeepaliveTimeoutSeconds, mH2ExtendKeepaliveTimeout, mH2RawDomains, - mMaxConnectionsPerHost, mStatsFlushSeconds, mStreamIdleTimeoutSeconds, - mPerTryIdleTimeoutSeconds, mAppVersion, mAppId, mTrustChainVerification, mVirtualClusters, - nativeFilterChain, platformFilterChain, stringAccessors, keyValueStores); + mDnsFallbackNameservers, mEnableDnsFilterUnroutableFamilies, mDnsUseSystemResolver, + mEnableDrainPostDnsRefresh, mEnableHttp3, mEnableGzip, brotliEnabled(), + mEnableHappyEyeballs, mEnableInterfaceBinding, mForceIPv6, + mH2ConnectionKeepaliveIdleIntervalMilliseconds, mH2ConnectionKeepaliveTimeoutSeconds, + mH2ExtendKeepaliveTimeout, mH2RawDomains, mMaxConnectionsPerHost, mStatsFlushSeconds, + mStreamIdleTimeoutSeconds, mPerTryIdleTimeoutSeconds, mAppVersion, mAppId, + mTrustChainVerification, mVirtualClusters, nativeFilterChain, platformFilterChain, + stringAccessors, keyValueStores); } } diff --git a/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt b/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt index 61f5a08c48..920948dafd 100644 --- a/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt +++ b/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt @@ -49,6 +49,7 @@ open class EngineBuilder( private var dnsFailureRefreshSecondsMax = 10 private var dnsFallbackNameservers = listOf() private var dnsFilterUnroutableFamilies = true + private var dnsUseSystemResolver = false private var dnsQueryTimeoutSeconds = 25 private var dnsMinRefreshSeconds = 60 private var dnsPreresolveHostnames = "[]" @@ -218,6 +219,22 @@ open class EngineBuilder( return this } + /** + * Specify whether to use the getaddrinfo-based system DNS resolver or the c-ares resolver. + * Defaults to false. + * + * Note that if this is set, the values of `dnsFallbackNameservers` and + * `dnsFilterUnroutableFamilies` will be ignored. + * + * @param dnsUseSystemResolver whether to use the system DNS resolver. + * + * @return this builder. + */ + fun enableDNSUseSystemResolver(dnsUseSystemResolver: Boolean): EngineBuilder { + this.dnsUseSystemResolver = dnsUseSystemResolver + return this + } + /** * Specify whether to drain connections after the resolution of a soft DNS refresh. A refresh may * be triggered directly via the Engine API, or as a result of a network status update provided by @@ -591,6 +608,7 @@ open class EngineBuilder( dnsPreresolveHostnames, dnsFallbackNameservers, dnsFilterUnroutableFamilies, + dnsUseSystemResolver, enableDrainPostDnsRefresh, enableHttp3, enableGzip, diff --git a/test/cc/unit/envoy_config_test.cc b/test/cc/unit/envoy_config_test.cc index 92cb98d6dc..4d180c4b39 100644 --- a/test/cc/unit/envoy_config_test.cc +++ b/test/cc/unit/envoy_config_test.cc @@ -76,6 +76,19 @@ TEST(TestConfig, ConfigIsValid) { #endif } +#if !defined(__APPLE__) +TEST(TestConfig, SetUseDnsSystemResolver) { + auto engine_builder = EngineBuilder(); + engine_builder.useDnsSystemResolver(true); + auto config_str = engine_builder.generateConfigStr(); + envoy::config::bootstrap::v3::Bootstrap bootstrap; + TestUtility::loadFromYaml(absl::StrCat(config_header, config_str), bootstrap); + + ASSERT_THAT(bootstrap.DebugString(), HasSubstr("envoy.network.dns_resolver.getaddrinfo")); + ASSERT_THAT(bootstrap.DebugString(), Not(HasSubstr("envoy.network.dns_resolver.cares"))); +} +#endif + TEST(TestConfig, SetGzip) { auto engine_builder = EngineBuilder(); diff --git a/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt b/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt index 27968982e4..41740ec430 100644 --- a/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt +++ b/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt @@ -54,6 +54,7 @@ class EnvoyConfigurationTest { dnsPreresolveHostnames: String = "[hostname]", dnsFallbackNameservers: List = emptyList(), enableDnsFilterUnroutableFamilies: Boolean = true, + dnsUseSystemResolver: Boolean = false, enableDrainPostDnsRefresh: Boolean = false, enableHttp3: Boolean = false, enableGzip: Boolean = true, @@ -87,6 +88,7 @@ class EnvoyConfigurationTest { dnsPreresolveHostnames, dnsFallbackNameservers, enableDnsFilterUnroutableFamilies, + dnsUseSystemResolver, enableDrainPostDnsRefresh, enableHttp3, enableGzip, @@ -230,6 +232,20 @@ class EnvoyConfigurationTest { assertThat(resolvedTemplate).contains("&force_ipv6 true") } + @Test + fun `configuration resolves with system DNS resolver`() { + val envoyConfiguration = buildTestEnvoyConfiguration( + dnsUseSystemResolver = true + ) + + val resolvedTemplate = envoyConfiguration.resolveTemplate( + TEST_CONFIG, PLATFORM_FILTER_CONFIG, NATIVE_FILTER_CONFIG, APCF_INSERT, GZIP_INSERT, BROTLI_INSERT + ) + + assertThat(resolvedTemplate).contains("&dns_resolver_config {\"@type\":\"type.googleapis.com/envoy.extensions.network.dns_resolver.getaddrinfo.v3.GetAddrInfoDnsResolverConfig\"}") + assertThat(resolvedTemplate).contains("&dns_resolver_name envoy.network.dns_resolver.getaddrinfo") + } + @Test fun `resolve templates with invalid templates will throw on build`() { val envoyConfiguration = buildTestEnvoyConfiguration() diff --git a/test/kotlin/apps/experimental/MainActivity.kt b/test/kotlin/apps/experimental/MainActivity.kt index 704d4b34b6..11eead710a 100644 --- a/test/kotlin/apps/experimental/MainActivity.kt +++ b/test/kotlin/apps/experimental/MainActivity.kt @@ -57,6 +57,7 @@ class MainActivity : Activity() { .addPlatformFilter(::AsyncDemoFilter) .h2ExtendKeepaliveTimeout(true) .enableInterfaceBinding(true) + .enableDNSUseSystemResolver(true) .forceIPv6(true) .addNativeFilter("envoy.filters.http.buffer", "{\"@type\":\"type.googleapis.com/envoy.extensions.filters.http.buffer.v3.Buffer\",\"max_request_bytes\":5242880}") .addStringAccessor("demo-accessor", { "PlatformString" }) From 36e0edaf6f321532a0ba9c7ad85b78ba7b5caf1f Mon Sep 17 00:00:00 2001 From: Ryan Hamilton Date: Fri, 15 Jul 2022 11:14:41 -0700 Subject: [PATCH 10/16] Squelch two JNI build warnings (#2426) Signed-off-by: Ryan Hamilton --- library/common/jni/jni_interface.cc | 3 +++ library/common/jni/jni_utility.cc | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/library/common/jni/jni_interface.cc b/library/common/jni/jni_interface.cc index 74b1d72e57..52423561ea 100644 --- a/library/common/jni/jni_interface.cc +++ b/library/common/jni/jni_interface.cc @@ -1191,6 +1191,8 @@ static jobject call_jvm_verify_x509_cert_chain(JNIEnv* env, return result; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-function" // `auth_type` and `host` are expected to be UTF-8 encoded. static void jvm_verify_x509_cert_chain(const std::vector& cert_chain, std::string auth_type, std::string host, @@ -1202,6 +1204,7 @@ static void jvm_verify_x509_cert_chain(const std::vector& cert_chai ExtractCertVerifyResult(get_env(), result, status, is_issued_by_known_root, verified_chain); env->DeleteLocalRef(result); } +#pragma clang diagnostic pop static void jvm_add_test_root_certificate(const uint8_t* cert, size_t len) { jni_log("[Envoy]", "jvm_add_test_root_certificate"); diff --git a/library/common/jni/jni_utility.cc b/library/common/jni/jni_utility.cc index 164b0bae25..0d9dbe427b 100644 --- a/library/common/jni/jni_utility.cc +++ b/library/common/jni/jni_utility.cc @@ -25,8 +25,8 @@ JNIEnv* get_env() { jint result = static_jvm->GetEnv(reinterpret_cast(&local_env), JNI_VERSION); if (result == JNI_EDETACHED) { // Note: the only thread that should need to be attached is Envoy's engine std::thread. - static char* thread_name = "EnvoyMain"; - JavaVMAttachArgs args = {JNI_VERSION, thread_name, nullptr}; + static const char* thread_name = "EnvoyMain"; + JavaVMAttachArgs args = {JNI_VERSION, const_cast(thread_name), nullptr}; result = attach_jvm(static_jvm, &local_env, &args); } RELEASE_ASSERT(result == JNI_OK, "Unable to get a JVM env for the current thread"); From e80978a12df7c42d6bf6760f76ecded372951571 Mon Sep 17 00:00:00 2001 From: Ryan Hamilton Date: Mon, 18 Jul 2022 06:41:00 -0700 Subject: [PATCH 11/16] Fix isCleartextTrafficPermitted (#2420) Fix isCleartextTrafficPermitted by finding a static method (instead of an object method) and calling the static method of the AndroidNetworkLibrary class instead of calling the instance method on a string. Signed-off-by: Ryan Hamilton --- library/common/jni/android_jni_utility.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/library/common/jni/android_jni_utility.cc b/library/common/jni/android_jni_utility.cc index 733cc3b929..ba66ba20df 100644 --- a/library/common/jni/android_jni_utility.cc +++ b/library/common/jni/android_jni_utility.cc @@ -20,10 +20,11 @@ bool is_cleartext_permitted(absl::string_view hostname) { envoy_data host = Envoy::Data::Utility::copyToBridgeData(hostname); JNIEnv* env = get_env(); jstring java_host = native_data_to_string(env, host); - jclass jcls_Boolean = env->FindClass("org/chromium/net/AndroidNetworkLibrary"); - jmethodID jmid_isCleartextTrafficPermitted = - env->GetMethodID(jcls_Boolean, "isCleartextTrafficPermitted", "(Ljava/lang/String;)Z"); - jboolean result = env->CallBooleanMethod(java_host, jmid_isCleartextTrafficPermitted); + jclass jcls_AndroidNetworkLibrary = env->FindClass("org/chromium/net/AndroidNetworkLibrary"); + jmethodID jmid_isCleartextTrafficPermitted = env->GetStaticMethodID( + jcls_AndroidNetworkLibrary, "isCleartextTrafficPermitted", "(Ljava/lang/String;)Z"); + jboolean result = env->CallStaticBooleanMethod(jcls_AndroidNetworkLibrary, + jmid_isCleartextTrafficPermitted, java_host); env->DeleteLocalRef(java_host); release_envoy_data(host); return result == JNI_TRUE; From f6a23f37965d8db41dea428688f31f8b85cb2dd3 Mon Sep 17 00:00:00 2001 From: JP Simard Date: Mon, 18 Jul 2022 10:32:52 -0400 Subject: [PATCH 12/16] Remove Tulsi configuration & docs (#2421) Now that we've integrated with rules_xcodeproj and that's working well. Signed-off-by: JP Simard --- docs/root/development/tools/tools.rst | 1 - docs/root/development/tools/tulsi.rst | 31 ------ envoy-mobile.tulsiproj/Configs/all.tulsigen | 115 -------------------- envoy-mobile.tulsiproj/project.tulsiconf | 27 ----- 4 files changed, 174 deletions(-) delete mode 100644 docs/root/development/tools/tulsi.rst delete mode 100644 envoy-mobile.tulsiproj/Configs/all.tulsigen delete mode 100644 envoy-mobile.tulsiproj/project.tulsiconf diff --git a/docs/root/development/tools/tools.rst b/docs/root/development/tools/tools.rst index 3a3492b5c5..2861ac5488 100644 --- a/docs/root/development/tools/tools.rst +++ b/docs/root/development/tools/tools.rst @@ -6,7 +6,6 @@ Development Tools .. toctree:: :maxdepth: 2 - tulsi intellij This documentation outlines additional tools that may prove useful when diff --git a/docs/root/development/tools/tulsi.rst b/docs/root/development/tools/tulsi.rst deleted file mode 100644 index b90b045e35..0000000000 --- a/docs/root/development/tools/tulsi.rst +++ /dev/null @@ -1,31 +0,0 @@ -.. _tulsi_development: - -Tulsi Development -================= - -`Tulsi `_ is a tool that aims to integrate -Bazel with Xcode in order to generate, build, and run Bazel-based projects with -the Xcode IDE which is commonly used for Apple/iOS development. - -Configuration files for Tulsi are checked into the Envoy Mobile repository in order to: - -- Provide a way to generate Xcode projects to build the Envoy Mobile library -- Reduce barrier to entry for iOS engineers hoping to contribute - -Using Tulsi with Envoy Mobile ------------------------------ - -To get started using Tulsi with Envoy Mobile: - -1. Download and `install Tulsi `_ -2. Open the :repo:`envoy-mobile.tulsiproj ` file -3. From the ``Packages`` tab, click ``Bazel..`` and select the ``bazelw`` binary from at the root of the Envoy Mobile directory (to ensure you're building with the correct version of Bazel) -4. Click on the ``Configs`` tab in Tulsi, and click ``Generate`` -5. Open up the Xcode project, and build - -Known issues ------------- - -Code completion for Swift for Tulsi-based project is currently broken. -It's being tracked in -`Tulsi issue #96 `_. diff --git a/envoy-mobile.tulsiproj/Configs/all.tulsigen b/envoy-mobile.tulsiproj/Configs/all.tulsigen deleted file mode 100644 index 164ebe87b6..0000000000 --- a/envoy-mobile.tulsiproj/Configs/all.tulsigen +++ /dev/null @@ -1,115 +0,0 @@ -{ - "additionalFilePaths" : [ - "library/swift/BUILD", - "test/swift/BUILD" - ], - "buildTargets" : [ - "//examples/objective-c/hello_world:app", - "//examples/objective-c/hello_world:appmain", - "//examples/swift/hello_world:app", - "//examples/swift/hello_world:appmain", - "//library/swift:ios_lib", - "//test/swift/integration:cancel_stream_test", - "//test/swift/integration:cancel_stream_test_lib", - "//test/swift/integration:direct_response_contains_headers_integration_test", - "//test/swift/integration:direct_response_contains_headers_integration_test_lib", - "//test/swift/integration:direct_response_exact_headers_match_integration_test", - "//test/swift/integration:direct_response_exact_headers_match_integration_test_lib", - "//test/swift/integration:direct_response_exact_path_match_integration_test", - "//test/swift/integration:direct_response_exact_path_match_integration_test_lib", - "//test/swift/integration:direct_response_filter_mutation_integration_test", - "//test/swift/integration:direct_response_filter_mutation_integration_test_lib", - "//test/swift/integration:direct_response_prefix_headers_match_integration_test", - "//test/swift/integration:direct_response_prefix_headers_match_integration_test_lib", - "//test/swift/integration:direct_response_prefix_path_match_integration_test", - "//test/swift/integration:direct_response_prefix_path_match_integration_test_lib", - "//test/swift/integration:direct_response_suffix_path_match_integration_test", - "//test/swift/integration:direct_response_suffix_path_match_integration_test_lib", - "//test/swift/integration:grpc_receive_error_test", - "//test/swift/integration:grpc_receive_error_test_lib", - "//test/swift/integration:receive_data_test", - "//test/swift/integration:receive_data_test_lib", - "//test/swift/integration:receive_error_test", - "//test/swift/integration:receive_error_test_lib", - "//test/swift/integration:send_data_test", - "//test/swift/integration:send_data_test_lib", - "//test/swift/integration:send_headers_test", - "//test/swift/integration:send_headers_test_lib", - "//test/swift/integration:send_trailers_test", - "//test/swift/integration:send_trailers_test_lib", - "//test/swift:counter_tests", - "//test/swift:counter_tests_lib", - "//test/swift:element_tests", - "//test/swift:element_tests_lib", - "//test/swift:engine_builder_tests", - "//test/swift:engine_builder_tests_lib", - "//test/swift:grpc_request_headers_builder_tests", - "//test/swift:grpc_request_headers_builder_tests_lib", - "//test/swift:grpc_stream_tests", - "//test/swift:grpc_stream_tests_lib", - "//test/swift:headers_builder_tests", - "//test/swift:headers_builder_tests_lib", - "//test/swift:pulse_client_impl_tests", - "//test/swift:pulse_client_impl_tests_lib", - "//test/swift:request_headers_builder_tests", - "//test/swift:request_headers_builder_tests_lib", - "//test/swift:response_headers_tests", - "//test/swift:response_headers_tests_lib", - "//test/swift:retry_policy_mapper_tests", - "//test/swift:retry_policy_mapper_tests_lib", - "//test/swift:retry_policy_tests", - "//test/swift:retry_policy_tests_lib" - ], - "optionSet" : { - "BazelBuildOptionsDebug" : { - "p" : "$(inherited)" - }, - "BazelBuildOptionsRelease" : { - "p" : "$(inherited)" - }, - "BazelBuildStartupOptionsDebug" : { - "p" : "$(inherited)" - }, - "BazelBuildStartupOptionsRelease" : { - "p" : "$(inherited)" - }, - "BuildActionPostActionScript" : { - "p" : "$(inherited)" - }, - "BuildActionPreActionScript" : { - "p" : "$(inherited)" - }, - "CommandlineArguments" : { - "p" : "$(inherited)" - }, - "EnvironmentVariables" : { - "p" : "$(inherited)" - }, - "IncludeBuildSources" : { - "p" : "YES" - }, - "LaunchActionPostActionScript" : { - "p" : "$(inherited)" - }, - "LaunchActionPreActionScript" : { - "p" : "$(inherited)" - }, - "ProjectPrioritizesSwift" : { - "p" : "YES" - }, - "TestActionPostActionScript" : { - "p" : "$(inherited)" - }, - "TestActionPreActionScript" : { - "p" : "$(inherited)" - } - }, - "projectName" : "envoy-mobile", - "sourceFilters" : [ - "examples/...", - "library", - "library/objective-c/...", - "library/swift", - "library/swift/..." - ] -} diff --git a/envoy-mobile.tulsiproj/project.tulsiconf b/envoy-mobile.tulsiproj/project.tulsiconf deleted file mode 100644 index e20a5bc134..0000000000 --- a/envoy-mobile.tulsiproj/project.tulsiconf +++ /dev/null @@ -1,27 +0,0 @@ -{ - "configDefaults" : { - "optionSet" : { - "BazelBuildOptionsDebug" : { - "p" : "--config=ios" - }, - "BazelBuildOptionsRelease" : { - "p" : "--config=release-ios --ios_multi_cpus=i386,x86_64,armv7,arm64" - }, - "IncludeBuildSources" : { - "p" : "YES" - }, - "ProjectPrioritizesSwift" : { - "p" : "YES" - } - } - }, - "packages" : [ - "library/swift", - "test/swift", - "examples/objective-c/hello_world", - "examples/swift/hello_world", - "test/swift/integration" - ], - "projectName" : "envoy-mobile", - "workspaceRoot" : ".." -} From abfdfdb00f00129f310eee188c34fef6fcb6e33a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Augustyniak?= Date: Mon, 18 Jul 2022 17:50:52 +0200 Subject: [PATCH 13/16] Revert "docs: use sphinx githubpages extension (#2418)" (#2425) Description: Revert https://github.com/envoyproxy/envoy-mobile/pull/2418 as the change did not fix the issues with images not appearing in documentation. https://github.com/envoy-mobile/envoy-mobile.github.io/pull/24 fixed the issues instead. Risk Level: None. Testing: N/A Docs Changes: N/A Release Notes: N/A Signed-off-by: Rafal Augustyniak --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 610c534f5f..3e7e11cccd 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -67,7 +67,7 @@ def setup(app): # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ['sphinxcontrib.httpdomain', 'sphinx.ext.extlinks', 'sphinx.ext.ifconfig', 'sphinx.ext.githubpages'] +extensions = ['sphinxcontrib.httpdomain', 'sphinx.ext.extlinks', 'sphinx.ext.ifconfig'] extlinks = { 'issue': ('https://github.com/envoyproxy/envoy-mobile/issues/%s', ''), 'repo': ('https://github.com/envoyproxy/envoy-mobile/blob/{}/%s'.format(blob_sha), ''), From 4239fe019864e5c8abbb345aa12ba90ff6e0a1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Augustyniak?= Date: Mon, 18 Jul 2022 18:33:51 +0200 Subject: [PATCH 14/16] tools: add arm64 debug run configuration (#2424) Description: Add an arm64 run configuration for Envoy example app so that it's possible to run and debug Envoy Mobile example app on ARM machines (i.e., M1 Macbooks). Following steps from https://envoy-mobile.github.io/docs/envoy-mobile/latest/development/debugging/android_local.html#adding-envoy-mobile-project-into-android-studio it's possible to set up an Android project that makes it possible to run and debug Envoy Mobile example app (put symbolic breakpoints in Envoy code). As it is now, the configured/added run configuration supports running of x86 builds only which do not work on ARM machines. Risk Level: None Testing: Run new configuration locally on M1 Macbook. Docs Changes: N/A Release Notes: N/A Signed-off-by: Rafal Augustyniak --- .../development/debugging/android_local.rst | 14 ++----- examples/kotlin/hello_world/.bazelproject | 1 + .../run_configuration_example_debug_arm64.xml | 38 +++++++++++++++++++ .../run_configuration_example_debug_x86.xml | 2 +- 4 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_arm64.xml diff --git a/docs/root/development/debugging/android_local.rst b/docs/root/development/debugging/android_local.rst index 061e2b593f..0527302d43 100644 --- a/docs/root/development/debugging/android_local.rst +++ b/docs/root/development/debugging/android_local.rst @@ -17,7 +17,7 @@ Setting up the environment Before we start, you'll need to download Android Studio and the `Bazel plugin `_, you can find it in Preferences -> Plugins . -1. Go `here `_ and install Android Studio. +1. Go `here `_ and install Android Studio 2. Install the bazel plugin Adding Envoy-Mobile Project into Android Studio @@ -51,16 +51,8 @@ Entering a debugging session With the project ready, you can now start debugging with Android Studio. -1. Compile your envoy-mobile with debug symbols to the architecture of the device or emulator you are about to run. - -For example: -:: - - $ ./bazelw build android_dist --config=android --fat_apk_cpu=x86 -c dbg - -Android supported archs are `arm64_v8a`, `armeabi-v7a`, `x86`, `x86_64`. - -2. From Android Studio select the `Example App x86 (Debug)` configuration and hit the debug icon. Note: if you don't see this option go to "Add configuration" and it'll be there on the Bazel category, just select it and hit Ok. +1. From Android Studio select either `Example App (Debug) [x86]` or `Example App (Debug) [arm64]` configuration. Note: the `x86` configuration doesn't work on ARM machines (i.e., M1 Macbooks). +2. Hit the debug icon. Note: if you don't see this option go to "Add configuration" and it'll be there on the Bazel category, just select it and hit Ok. 3. Optionally you could create symbolic breakpoints before running by going to the Debugger tab. Your environment should look like this at this point: diff --git a/examples/kotlin/hello_world/.bazelproject b/examples/kotlin/hello_world/.bazelproject index a71dcf6cbd..41db7a62ea 100644 --- a/examples/kotlin/hello_world/.bazelproject +++ b/examples/kotlin/hello_world/.bazelproject @@ -13,6 +13,7 @@ directories: import_run_configurations: examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_x86.xml + examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_arm64.xml targets: //examples/kotlin/hello_world:hello_envoy_kt diff --git a/examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_arm64.xml b/examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_arm64.xml new file mode 100644 index 0000000000..9a06114cea --- /dev/null +++ b/examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_arm64.xml @@ -0,0 +1,38 @@ + + + --fat_apk_cpu=arm64-v8a + //examples/kotlin/hello_world:hello_envoy_kt + + + + + + diff --git a/examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_x86.xml b/examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_x86.xml index ab975a532c..230b570721 100644 --- a/examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_x86.xml +++ b/examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_x86.xml @@ -1,4 +1,4 @@ - From 3465cb6fae967845410ce95dd1868a43e1b6b026 Mon Sep 17 00:00:00 2001 From: envoy-bot <37382446+envoy-bot@users.noreply.github.com> Date: Mon, 18 Jul 2022 11:13:59 -0600 Subject: [PATCH 15/16] Update Envoy (#2427) Signed-off-by: GitHub Action Co-authored-by: jpsim --- envoy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/envoy b/envoy index afdc9bd288..4212e541d8 160000 --- a/envoy +++ b/envoy @@ -1 +1 @@ -Subproject commit afdc9bd2882666a67c829ecc909d6096988e27ad +Subproject commit 4212e541d8ed646012c5fe6777311bfe398f0b02 From 6eb67e6cd004665a01a35981b5728450ba6a179c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Augustyniak?= Date: Mon, 18 Jul 2022 23:54:36 +0200 Subject: [PATCH 16/16] tools: fix source mapping (#2429) Description: Per our documentation, the following should be true "While breaking on a C++ function, Android Studio should present the source file and highlight the line where the breakpoint hit with all scope information". That feature did not work - I didn't confirm this but it's possible that the functionality was broken when https://github.com/envoyproxy/envoy-mobile/pull/2184 was merged. Anyway, the issue was that https://github.com/envoyproxy/envoy-mobile/blob/581ba40f2f8597243efccb2bdccade8193ff4559/.bazelrc#L44 config setting was not applied when Envoy Mobile was built for the runs of example apps. This has been fixed by making run configurations that are used by Envoy Mobile example apps specify `--config=dbg` setting explicitly. Risk Level: None Testing: Confirmed that Android Studio opens the right file (and highlights the right line) when EnvoyMobile breakpoint is hit. Docs Changes: N/A Release Notes: N/A Signed-off-by: Rafal Augustyniak --- .bazelrc | 1 + .../run_configuration_example_debug_arm64.xml | 1 + .../run_configuration_example_debug_x86.xml | 1 + 3 files changed, 3 insertions(+) diff --git a/.bazelrc b/.bazelrc index 72cd76d75f..fed4929cb5 100644 --- a/.bazelrc +++ b/.bazelrc @@ -40,6 +40,7 @@ build --java_language_version=8 # Override PGV validation with NOP functions build --@com_envoyproxy_protoc_gen_validate//bazel:template-flavor=nop +build:dbg --compilation_mode=dbg # Enable source map for debugging in IDEs build:dbg --copt="-fdebug-compilation-dir" --copt="/proc/self/cwd" diff --git a/examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_arm64.xml b/examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_arm64.xml index 9a06114cea..0b65d06926 100644 --- a/examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_arm64.xml +++ b/examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_arm64.xml @@ -14,6 +14,7 @@ use-work-profile-if-present="false" show-logcat-automatically="false" AM_START_OPTIONS=""> + --config=dbg --fat_apk_cpu=arm64-v8a //examples/kotlin/hello_world:hello_envoy_kt diff --git a/examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_x86.xml b/examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_x86.xml index 230b570721..68241c4b7e 100644 --- a/examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_x86.xml +++ b/examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_x86.xml @@ -14,6 +14,7 @@ use-work-profile-if-present="false" show-logcat-automatically="false" AM_START_OPTIONS=""> + --config=dbg --fat_apk_cpu=x86 //examples/kotlin/hello_world:hello_envoy_kt