From 92e78be63ac77606283397fef104f90304863afc Mon Sep 17 00:00:00 2001 From: Rafal Augustyniak Date: Thu, 1 Sep 2022 09:19:55 -0400 Subject: [PATCH 1/9] android: enable forceIPv6 by default Signed-off-by: Rafal Augustyniak --- .../envoymobile/engine/EnvoyConfiguration.java | 7 ++----- .../io/envoyproxy/envoymobile/EngineBuilder.kt | 15 --------------- .../envoymobile/engine/EnvoyConfigurationTest.kt | 8 +------- 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java b/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java index 92f8e03487..e0c2205d03 100644 --- a/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java +++ b/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java @@ -44,7 +44,6 @@ public enum TrustChainVerification { public final Boolean enableSocketTagging; public final Boolean enableHappyEyeballs; public final Boolean enableInterfaceBinding; - public final Boolean forceIPv6; public final Integer h2ConnectionKeepaliveIdleIntervalMilliseconds; public final Integer h2ConnectionKeepaliveTimeoutSeconds; public final Boolean h2ExtendKeepaliveTimeout; @@ -88,7 +87,6 @@ public enum TrustChainVerification { * @param enableSocketTagging whether to enable socket tagging. * @param enableHappyEyeballs whether to enable RFC 6555 handling for IPv4/IPv6. * @param enableInterfaceBinding whether to allow interface binding. - * @param forceIPv6 whether to force connections to use IPv6. * @param h2ConnectionKeepaliveIdleIntervalMilliseconds rate in milliseconds seconds to send h2 * pings on stream creation. * @param h2ConnectionKeepaliveTimeoutSeconds rate in seconds to timeout h2 pings. @@ -116,7 +114,7 @@ public EnvoyConfiguration( boolean dnsFilterUnroutableFamilies, boolean dnsUseSystemResolver, boolean enableDrainPostDnsRefresh, boolean enableHttp3, boolean enableGzip, boolean enableBrotli, boolean enableSocketTagging, boolean enableHappyEyeballs, - boolean enableInterfaceBinding, boolean forceIPv6, + boolean enableInterfaceBinding, int h2ConnectionKeepaliveIdleIntervalMilliseconds, int h2ConnectionKeepaliveTimeoutSeconds, boolean h2ExtendKeepaliveTimeout, List h2RawDomains, int maxConnectionsPerHost, int statsFlushSeconds, int streamIdleTimeoutSeconds, int perTryIdleTimeoutSeconds, @@ -145,7 +143,6 @@ public EnvoyConfiguration( this.enableSocketTagging = enableSocketTagging; this.enableHappyEyeballs = enableHappyEyeballs; this.enableInterfaceBinding = enableInterfaceBinding; - this.forceIPv6 = forceIPv6; this.h2ConnectionKeepaliveIdleIntervalMilliseconds = h2ConnectionKeepaliveIdleIntervalMilliseconds; this.h2ConnectionKeepaliveTimeoutSeconds = h2ConnectionKeepaliveTimeoutSeconds; @@ -274,7 +271,7 @@ String resolveTemplate(final String configTemplate, final String platformFilterT enableDrainPostDnsRefresh ? "true" : "false")) .append(String.format("- &enable_interface_binding %s\n", enableInterfaceBinding ? "true" : "false")) - .append(String.format("- &force_ipv6 %s\n", forceIPv6 ? "true" : "false")) + .append("- &force_ipv6 true\n") .append(String.format("- &h2_connection_keepalive_idle_interval %ss\n", h2ConnectionKeepaliveIdleIntervalMilliseconds / 1000.0)) .append(String.format("- &h2_connection_keepalive_timeout %ss\n", diff --git a/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt b/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt index 18a6f205cd..a2a9b72532 100644 --- a/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt +++ b/library/kotlin/io/envoyproxy/envoymobile/EngineBuilder.kt @@ -60,7 +60,6 @@ open class EngineBuilder( private var enableBrotli = false private var enableSocketTagging = false private var enableInterfaceBinding = false - private var forceIPv6 = false private var h2ConnectionKeepaliveIdleIntervalMilliseconds = 1 private var h2ConnectionKeepaliveTimeoutSeconds = 10 private var h2ExtendKeepaliveTimeout = false @@ -327,19 +326,6 @@ open class EngineBuilder( return this } - /** - * Specify whether to remap IPv4 addresses to the IPv6 space and always force connections - * to use IPv6. Note this is an experimental option and should be enabled with caution. - * - * @param forceIPv6 whether to force connections to use IPv6. - * - * @return This builder. - */ - fun forceIPv6(forceIPv6: Boolean): EngineBuilder { - this.forceIPv6 = forceIPv6 - return this - } - /** * Add a rate at which to ping h2 connections on new stream creation if the connection has * sat idle. Defaults to 1 millisecond which effectively enables h2 ping functionality @@ -629,7 +615,6 @@ open class EngineBuilder( enableSocketTagging, enableHappyEyeballs, enableInterfaceBinding, - forceIPv6, h2ConnectionKeepaliveIdleIntervalMilliseconds, h2ConnectionKeepaliveTimeoutSeconds, h2ExtendKeepaliveTimeout, diff --git a/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt b/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt index aefadef576..d5a05c8e84 100644 --- a/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt +++ b/test/java/io/envoyproxy/envoymobile/engine/EnvoyConfigurationTest.kt @@ -67,7 +67,6 @@ class EnvoyConfigurationTest { enableSocketTagging: Boolean = false, enableHappyEyeballs: Boolean = false, enableInterfaceBinding: Boolean = false, - forceIPv6: Boolean = false, h2ConnectionKeepaliveIdleIntervalMilliseconds: Int = 222, h2ConnectionKeepaliveTimeoutSeconds: Int = 333, h2ExtendKeepaliveTimeout: Boolean = false, @@ -102,7 +101,6 @@ class EnvoyConfigurationTest { enableSocketTagging, enableHappyEyeballs, enableInterfaceBinding, - forceIPv6, h2ConnectionKeepaliveIdleIntervalMilliseconds, h2ConnectionKeepaliveTimeoutSeconds, h2ExtendKeepaliveTimeout, @@ -150,7 +148,7 @@ class EnvoyConfigurationTest { assertThat(resolvedTemplate).contains("&enable_interface_binding false") // Forcing IPv6 - assertThat(resolvedTemplate).contains("&force_ipv6 false") + assertThat(resolvedTemplate).contains("&force_ipv6 true") // H2 Ping assertThat(resolvedTemplate).contains("&h2_connection_keepalive_idle_interval 0.222s") @@ -205,7 +203,6 @@ class EnvoyConfigurationTest { enableGzip = false, enableBrotli = true, enableInterfaceBinding = true, - forceIPv6 = true, h2ExtendKeepaliveTimeout = true ) @@ -233,9 +230,6 @@ class EnvoyConfigurationTest { // Interface Binding assertThat(resolvedTemplate).contains("&enable_interface_binding true") - - // Forcing IPv6 - assertThat(resolvedTemplate).contains("&force_ipv6 true") } @Test From fa6ce8b65e97031a0198ed18550bb8f308aa9c99 Mon Sep 17 00:00:00 2001 From: Rafal Augustyniak Date: Thu, 1 Sep 2022 09:25:10 -0400 Subject: [PATCH 2/9] updatae version history Signed-off-by: Rafal Augustyniak --- docs/root/intro/version_history.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/root/intro/version_history.rst b/docs/root/intro/version_history.rst index 5ba95369a8..f3ea896651 100644 --- a/docs/root/intro/version_history.rst +++ b/docs/root/intro/version_history.rst @@ -47,6 +47,7 @@ Features: - 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>`) - iOS: add ``KeyValueStore`` protocol conformance to ``UserDefaults`` (:issue: `#2452 <2452>`) +- android: enable forcing of IPv6 socket addresses by default and remove ``forceIPv6`` method from the engine builder. (:issue: `#2510 <2510>`) 0.4.6 (April 26, 2022) ======================== From 6bfbabe5e6065e4520964be95e32fb9678b8d2e0 Mon Sep 17 00:00:00 2001 From: Rafal Augustyniak Date: Thu, 1 Sep 2022 09:36:38 -0400 Subject: [PATCH 3/9] lint fix Signed-off-by: Rafal Augustyniak --- .../envoymobile/engine/EnvoyConfiguration.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java b/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java index e0c2205d03..3996f0a293 100644 --- a/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java +++ b/library/java/io/envoyproxy/envoymobile/engine/EnvoyConfiguration.java @@ -114,12 +114,12 @@ public EnvoyConfiguration( boolean dnsFilterUnroutableFamilies, boolean dnsUseSystemResolver, boolean enableDrainPostDnsRefresh, boolean enableHttp3, boolean enableGzip, boolean enableBrotli, boolean enableSocketTagging, boolean enableHappyEyeballs, - boolean enableInterfaceBinding, - 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 enableInterfaceBinding, 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) { From eb4da872201bf25d7d64a73880a17c04d527e84d Mon Sep 17 00:00:00 2001 From: Rafal Augustyniak Date: Thu, 1 Sep 2022 09:51:48 -0400 Subject: [PATCH 4/9] fix cronet Signed-off-by: Rafal Augustyniak --- .../org/chromium/net/impl/NativeCronetEngineBuilderImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/java/org/chromium/net/impl/NativeCronetEngineBuilderImpl.java b/library/java/org/chromium/net/impl/NativeCronetEngineBuilderImpl.java index f757f7f895..c9852f8408 100644 --- a/library/java/org/chromium/net/impl/NativeCronetEngineBuilderImpl.java +++ b/library/java/org/chromium/net/impl/NativeCronetEngineBuilderImpl.java @@ -49,7 +49,6 @@ public class NativeCronetEngineBuilderImpl extends CronetEngineBuilderImpl { private boolean mEnableSocketTag = true; private boolean mEnableHappyEyeballs = false; private boolean mEnableInterfaceBinding = false; - private boolean mForceIPv6 = false; private int mH2ConnectionKeepaliveIdleIntervalMilliseconds = 100000000; private int mH2ConnectionKeepaliveTimeoutSeconds = 10; private boolean mH2ExtendKeepaliveTimeout = false; @@ -110,7 +109,7 @@ private EnvoyConfiguration createEnvoyConfiguration() { mDnsQueryTimeoutSeconds, mDnsMinRefreshSeconds, mDnsPreresolveHostnames, mDnsFallbackNameservers, mEnableDnsFilterUnroutableFamilies, mDnsUseSystemResolver, mEnableDrainPostDnsRefresh, quicEnabled(), mEnableGzip, brotliEnabled(), mEnableSocketTag, - mEnableHappyEyeballs, mEnableInterfaceBinding, mForceIPv6, + mEnableHappyEyeballs, mEnableInterfaceBinding, mH2ConnectionKeepaliveIdleIntervalMilliseconds, mH2ConnectionKeepaliveTimeoutSeconds, mH2ExtendKeepaliveTimeout, mH2RawDomains, mMaxConnectionsPerHost, mStatsFlushSeconds, mStreamIdleTimeoutSeconds, mPerTryIdleTimeoutSeconds, mAppVersion, mAppId, From f829060e66d42eab46e7355f6ab49cadc6192893 Mon Sep 17 00:00:00 2001 From: Rafal Augustyniak Date: Thu, 1 Sep 2022 09:52:05 -0400 Subject: [PATCH 5/9] enable forceIPv6 when using c++ builder too Signed-off-by: Rafal Augustyniak --- library/cc/engine_builder.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/cc/engine_builder.cc b/library/cc/engine_builder.cc index 37ba6dd81a..fba092c58f 100644 --- a/library/cc/engine_builder.cc +++ b/library/cc/engine_builder.cc @@ -171,6 +171,10 @@ std::string EngineBuilder::generateConfigStr() { {"virtual_clusters", this->virtual_clusters_}, }; +// #if defined(ANDROID) + replacements.push_back({"force_ipv6", "true"}); +// #endif + // NOTE: this does not include support for custom filters // which are not yet supported in the C++ platform implementation std::ostringstream config_builder; From 238b0419b9318c50a3519c2f4fb7a45120d47496 Mon Sep 17 00:00:00 2001 From: Rafal Augustyniak Date: Thu, 1 Sep 2022 10:08:12 -0400 Subject: [PATCH 6/9] add force_ipv6 Signed-off-by: Rafal Augustyniak --- library/cc/engine_builder.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/library/cc/engine_builder.cc b/library/cc/engine_builder.cc index fba092c58f..7a02e2661a 100644 --- a/library/cc/engine_builder.cc +++ b/library/cc/engine_builder.cc @@ -169,12 +169,11 @@ std::string EngineBuilder::generateConfigStr() { {"stream_idle_timeout", fmt::format("{}s", this->stream_idle_timeout_seconds_)}, {"per_try_idle_timeout", fmt::format("{}s", this->per_try_idle_timeout_seconds_)}, {"virtual_clusters", this->virtual_clusters_}, +#if defined(__ANDROID_API__) + {"force_ipv6", "true"}, +#endif }; -// #if defined(ANDROID) - replacements.push_back({"force_ipv6", "true"}); -// #endif - // NOTE: this does not include support for custom filters // which are not yet supported in the C++ platform implementation std::ostringstream config_builder; From a019665723a5ac654f92b8c4f9cca950b8c11241 Mon Sep 17 00:00:00 2001 From: Rafal Augustyniak Date: Thu, 1 Sep 2022 10:14:28 -0400 Subject: [PATCH 7/9] force ipv6 in c++ builder Signed-off-by: Rafal Augustyniak --- library/cc/engine_builder.cc | 47 ++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/library/cc/engine_builder.cc b/library/cc/engine_builder.cc index 7a02e2661a..79a6b02d34 100644 --- a/library/cc/engine_builder.cc +++ b/library/cc/engine_builder.cc @@ -146,31 +146,30 @@ std::string EngineBuilder::generateConfigStr() { } #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_)}, - {"dns_fail_max_interval", fmt::format("{}s", this->dns_failure_refresh_seconds_max_)}, - {"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}, - {"h2_connection_keepalive_idle_interval", - fmt::format("{}s", this->h2_connection_keepalive_idle_interval_milliseconds_ / 1000.0)}, - {"h2_connection_keepalive_timeout", - fmt::format("{}s", this->h2_connection_keepalive_timeout_seconds_)}, - { - "metadata", - fmt::format("{{ device_os: {}, app_version: {}, app_id: {} }}", this->device_os_, - this->app_version_, this->app_id_), - }, - {"stats_domain", this->stats_domain_}, - {"stats_flush_interval", fmt::format("{}s", this->stats_flush_seconds_)}, - {"stream_idle_timeout", fmt::format("{}s", this->stream_idle_timeout_seconds_)}, - {"per_try_idle_timeout", fmt::format("{}s", this->per_try_idle_timeout_seconds_)}, - {"virtual_clusters", this->virtual_clusters_}, + 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_)}, + {"dns_fail_max_interval", fmt::format("{}s", this->dns_failure_refresh_seconds_max_)}, + {"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}, + {"h2_connection_keepalive_idle_interval", + fmt::format("{}s", this->h2_connection_keepalive_idle_interval_milliseconds_ / 1000.0)}, + {"h2_connection_keepalive_timeout", + fmt::format("{}s", this->h2_connection_keepalive_timeout_seconds_)}, + { + "metadata", + fmt::format("{{ device_os: {}, app_version: {}, app_id: {} }}", this->device_os_, + this->app_version_, this->app_id_), + }, + {"stats_domain", this->stats_domain_}, + {"stats_flush_interval", fmt::format("{}s", this->stats_flush_seconds_)}, + {"stream_idle_timeout", fmt::format("{}s", this->stream_idle_timeout_seconds_)}, + {"per_try_idle_timeout", fmt::format("{}s", this->per_try_idle_timeout_seconds_)}, + {"virtual_clusters", this->virtual_clusters_}, #if defined(__ANDROID_API__) - {"force_ipv6", "true"}, + {"force_ipv6", "true"}, #endif }; From dafc2f018e20e5a0ed0d945ed3dd858aca5af4ce Mon Sep 17 00:00:00 2001 From: Rafal Augustyniak Date: Thu, 1 Sep 2022 11:10:06 -0400 Subject: [PATCH 8/9] fix Signed-off-by: Rafal Augustyniak --- test/kotlin/apps/experimental/MainActivity.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/test/kotlin/apps/experimental/MainActivity.kt b/test/kotlin/apps/experimental/MainActivity.kt index 428dd7706f..c71ba06a32 100644 --- a/test/kotlin/apps/experimental/MainActivity.kt +++ b/test/kotlin/apps/experimental/MainActivity.kt @@ -58,7 +58,6 @@ class MainActivity : Activity() { .h2ExtendKeepaliveTimeout(true) .enableInterfaceBinding(true) .enableDNSUseSystemResolver(true) - .forceIPv6(true) .enableSocketTagging(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 8a7d094ef82e7fe288ca6fccae3273dc098816f6 Mon Sep 17 00:00:00 2001 From: Rafal Augustyniak Date: Thu, 1 Sep 2022 11:32:08 -0400 Subject: [PATCH 9/9] update version history Signed-off-by: Rafal Augustyniak --- docs/root/intro/version_history.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/root/intro/version_history.rst b/docs/root/intro/version_history.rst index f3ea896651..33419e0672 100644 --- a/docs/root/intro/version_history.rst +++ b/docs/root/intro/version_history.rst @@ -8,7 +8,6 @@ Breaking changes: - api: replace the ``drainConnections()`` method with a broader ``resetConnectivityState()``. (:issue:`#2225 <2225>`). - api: disallow setting 'host' header directly (:issue:`#2275 <2275>`) -- api: add experimental option to force all connections to use IPv6 (:issue: `#2379 <2379>`, :issue: `#2396 <2396>`) - android: respect Android's NetworkSecurityPolicy isCleartextTrafficPermitted APIs. - net: enable happy eyeballs by default (:issue:`#2272 <2272>`) - iOS: remove support for installing via CocoaPods, which had not worked since 2020 (:issue:`#2215 <2215>`) @@ -47,7 +46,8 @@ Features: - 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>`) - iOS: add ``KeyValueStore`` protocol conformance to ``UserDefaults`` (:issue: `#2452 <2452>`) -- android: enable forcing of IPv6 socket addresses by default and remove ``forceIPv6`` method from the engine builder. (:issue: `#2510 <2510>`) +- iOS: add experimental option to force all connections to use IPv6. (:issue: `#2396 <2396>`) +- android: force the use of IPv6 addresses for all connections. (:issue: `#2510 <2510>`) 0.4.6 (April 26, 2022) ========================