├── .bazelproject ├── .bazelrc ├── .bazelversion ├── .circleci └── config.yml ├── .clang-format ├── .drstring.toml ├── .editorconfig ├── .gitattributes ├── .github ├── CODEOWNERS ├── actions │ └── pr_notifier │ │ ├── pr_notifier.py │ │ ├── requirements.in │ │ └── requirements.txt ├── lyft_maintainers.yml ├── stale.yml └── workflows │ ├── android_build.yml │ ├── android_tests.yml │ ├── asan.yml │ ├── bump_support_rotation.yml │ ├── cc_tests.yml │ ├── commands.yml │ ├── core.yml │ ├── coverage.yml │ ├── format.yml │ ├── ios_build.yml │ ├── ios_tests.yml │ ├── perf.yml │ ├── pr_notifier.yml │ ├── python_tests.yml │ ├── release.yml │ ├── release_validation.yml │ ├── submodule_update.yml │ ├── tsan.yml │ └── weekly_release.yml ├── .gitignore ├── .gitmodules ├── .kotlinlint.yml ├── .pre-commit-config.yaml ├── .swiftlint.yml ├── BUILD ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── DCO ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── NOTICE ├── OWNERS.md ├── PULL_REQUEST_TEMPLATE.md ├── README.md ├── RELEASE.md ├── STYLE.md ├── VERSION ├── WORKSPACE ├── bazel ├── BUILD ├── EnvoyMobileTestSuite.kt ├── abseil.patch ├── android_artifacts.bzl ├── android_configure.bzl ├── android_debug_info.bzl ├── apple_test.bzl ├── config.bzl ├── dokka.bzl ├── envoy_mobile_dependencies.bzl ├── envoy_mobile_repositories.bzl ├── envoy_mobile_test_extensions.bzl ├── envoy_mobile_toolchains.bzl ├── framework_imports_extractor.bzl ├── kotlin_lib.bzl ├── kotlin_test.bzl ├── pom_template.xml ├── protobuf.patch ├── python.bzl ├── swift_header_collector.bzl └── test_manifest.xml ├── bazelw ├── ci ├── BUILD ├── linux_ci_setup.sh ├── mac_ci_setup.sh ├── mac_start_emulator.sh ├── platform │ └── BUILD ├── sonatype_nexus_upload.py └── test_size_regression.sh ├── docs ├── README.md ├── Support.md ├── build.sh ├── conf.py ├── publish.sh ├── requirements.txt └── root │ ├── _static │ └── css │ │ └── envoy.css │ ├── api │ ├── api.rst │ ├── grpc.rst │ ├── http.rst │ ├── starting_envoy.rst │ └── stats.rst │ ├── development │ ├── debugging │ │ ├── android_local.rst │ │ ├── images │ │ │ ├── add-project.png │ │ │ ├── bazel-sync.png │ │ │ ├── environment.png │ │ │ ├── final-step-project.png │ │ │ ├── import-project.png │ │ │ ├── instruments.jpg │ │ │ ├── select-em.png │ │ │ └── xcode_breakpoint.jpg │ │ └── ios_local.rst │ ├── development.rst │ ├── performance │ │ ├── binary_size.rst │ │ ├── cpu_battery_impact.rst │ │ ├── device_connectivity.rst │ │ ├── performance.rst │ │ └── vpn_analysis.rst │ ├── releasing │ │ └── releasing.rst │ ├── testing │ │ ├── custom_envoy.rst │ │ ├── local_stats.rst │ │ └── testing.rst │ └── tools │ │ ├── intellij.rst │ │ └── tools.rst │ ├── favicon.ico │ ├── index.rst │ ├── intro │ ├── additional_resources.rst │ ├── comparison.rst │ ├── getting_help.rst │ ├── intro.rst │ ├── version_history.rst │ └── what_is_envoy_mobile.rst │ └── start │ ├── building │ └── building.rst │ ├── examples │ └── hello_world.rst │ └── start.rst ├── envoy_build_config ├── BUILD ├── WORKSPACE ├── extension_registry.cc ├── extension_registry.h ├── extension_registry_apple.cc ├── extension_registry_noop.cc ├── extension_registry_platform_additions.h └── extensions_build_config.bzl ├── examples ├── BUILD ├── java │ └── hello_world │ │ ├── .bazelproject │ │ ├── AndroidManifest.xml │ │ ├── BUILD │ │ ├── EmptyFile.kt │ │ ├── MainActivity.java │ │ ├── README.md │ │ ├── res │ │ └── layout │ │ │ └── activity_main.xml │ │ └── tools │ │ └── android-studio-run-configurations │ │ ├── run_configuration_example_debug_arm64.xml │ │ └── run_configuration_example_debug_x86.xml ├── kotlin │ ├── hello_world │ │ ├── .bazelproject │ │ ├── AndroidManifest.xml │ │ ├── AsyncDemoFilter.kt │ │ ├── BUILD │ │ ├── BufferDemoFilter.kt │ │ ├── DemoFilter.kt │ │ ├── MainActivity.kt │ │ ├── README.md │ │ ├── res │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ └── tools │ │ │ └── android-studio-run-configurations │ │ │ ├── run_configuration_example_debug_arm64.xml │ │ │ └── run_configuration_example_debug_x86.xml │ └── shared │ │ ├── AndroidManifest.xml │ │ ├── BUILD │ │ ├── Response.kt │ │ ├── ResponseRecyclerViewAdapter.kt │ │ ├── ResponseViewHolder.kt │ │ └── res │ │ ├── layout │ │ └── item.xml │ │ └── values │ │ ├── colors.xml │ │ └── strings.xml ├── objective-c │ └── hello_world │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── BUILD │ │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ │ ├── Info.plist │ │ ├── README.md │ │ ├── Result.h │ │ ├── Result.m │ │ ├── ViewController.h │ │ ├── ViewController.m │ │ └── main.m └── swift │ ├── async_await │ ├── AppDelegate.swift │ ├── BUILD │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ ├── ContentView.swift │ └── Info.plist │ ├── hello_world │ ├── AppDelegate.swift │ ├── AsyncDemoFilter.swift │ ├── BUILD │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ ├── BufferDemoFilter.swift │ ├── DemoFilter.swift │ ├── Info.plist │ ├── README.md │ ├── ResponseModels.swift │ └── ViewController.swift │ └── swiftpm │ ├── EnvoySwiftPMExample.xcodeproj │ └── project.pbxproj │ ├── EnvoySwiftPMExample │ ├── ContentView.swift │ └── EnvoySwiftPMExampleApp.swift │ └── Packages │ ├── Package.swift │ └── Sources │ └── NetworkClient │ └── NetworkClient.swift ├── experimental └── swift │ ├── BUILD │ └── QUICStreamTest.swift ├── library ├── BUILD ├── cc │ ├── BUILD │ ├── bridge_utility.cc │ ├── bridge_utility.h │ ├── engine.cc │ ├── engine.h │ ├── engine_builder.cc │ ├── engine_builder.h │ ├── engine_callbacks.cc │ ├── engine_callbacks.h │ ├── envoy_error.h │ ├── headers.cc │ ├── headers.h │ ├── headers_builder.cc │ ├── headers_builder.h │ ├── key_value_store.cc │ ├── key_value_store.h │ ├── log_level.cc │ ├── log_level.h │ ├── pulse_client.h │ ├── request_headers.cc │ ├── request_headers.h │ ├── request_headers_builder.cc │ ├── request_headers_builder.h │ ├── request_method.cc │ ├── request_method.h │ ├── request_trailers.cc │ ├── request_trailers.h │ ├── request_trailers_builder.cc │ ├── request_trailers_builder.h │ ├── response_headers.cc │ ├── response_headers.h │ ├── response_headers_builder.cc │ ├── response_headers_builder.h │ ├── response_trailers.cc │ ├── response_trailers.h │ ├── response_trailers_builder.cc │ ├── response_trailers_builder.h │ ├── retry_policy.cc │ ├── retry_policy.h │ ├── stream.cc │ ├── stream.h │ ├── stream_callbacks.cc │ ├── stream_callbacks.h │ ├── stream_client.cc │ ├── stream_client.h │ ├── stream_prototype.cc │ ├── stream_prototype.h │ ├── string_accessor.cc │ ├── string_accessor.h │ ├── trailers.h │ ├── upstream_http_protocol.cc │ └── upstream_http_protocol.h ├── common │ ├── BUILD │ ├── api │ │ ├── BUILD │ │ ├── c_types.h │ │ ├── external.cc │ │ └── external.h │ ├── bridge │ │ ├── BUILD │ │ ├── utility.cc │ │ └── utility.h │ ├── buffer │ │ ├── BUILD │ │ └── bridge_fragment.h │ ├── common │ │ ├── BUILD │ │ ├── lambda_logger_delegate.cc │ │ └── lambda_logger_delegate.h │ ├── config │ │ ├── BUILD │ │ ├── certificates.inc │ │ ├── config.cc │ │ ├── internal.h │ │ └── templates.h │ ├── data │ │ ├── BUILD │ │ ├── utility.cc │ │ └── utility.h │ ├── engine.cc │ ├── engine.h │ ├── engine_common.cc │ ├── engine_common.h │ ├── engine_handle.cc │ ├── engine_handle.h │ ├── event │ │ ├── BUILD │ │ ├── provisional_dispatcher.cc │ │ └── provisional_dispatcher.h │ ├── extensions │ │ ├── cert_validator │ │ │ └── platform_bridge │ │ │ │ ├── BUILD │ │ │ │ ├── c_types.h │ │ │ │ ├── config.cc │ │ │ │ ├── config.h │ │ │ │ ├── platform_bridge.proto │ │ │ │ ├── platform_bridge_cert_validator.cc │ │ │ │ └── platform_bridge_cert_validator.h │ │ ├── filters │ │ │ └── http │ │ │ │ ├── assertion │ │ │ │ ├── BUILD │ │ │ │ ├── config.cc │ │ │ │ ├── config.h │ │ │ │ ├── filter.cc │ │ │ │ ├── filter.h │ │ │ │ └── filter.proto │ │ │ │ ├── local_error │ │ │ │ ├── BUILD │ │ │ │ ├── config.cc │ │ │ │ ├── config.h │ │ │ │ ├── filter.cc │ │ │ │ ├── filter.h │ │ │ │ └── filter.proto │ │ │ │ ├── network_configuration │ │ │ │ ├── BUILD │ │ │ │ ├── config.cc │ │ │ │ ├── config.h │ │ │ │ ├── filter.cc │ │ │ │ ├── filter.h │ │ │ │ └── filter.proto │ │ │ │ ├── platform_bridge │ │ │ │ ├── BUILD │ │ │ │ ├── c_type_definitions.h │ │ │ │ ├── c_types.h │ │ │ │ ├── config.cc │ │ │ │ ├── config.h │ │ │ │ ├── filter.cc │ │ │ │ ├── filter.h │ │ │ │ └── filter.proto │ │ │ │ ├── route_cache_reset │ │ │ │ ├── BUILD │ │ │ │ ├── config.cc │ │ │ │ ├── config.h │ │ │ │ ├── filter.cc │ │ │ │ ├── filter.h │ │ │ │ └── filter.proto │ │ │ │ ├── socket_tag │ │ │ │ ├── BUILD │ │ │ │ ├── config.cc │ │ │ │ ├── config.h │ │ │ │ ├── filter.cc │ │ │ │ ├── filter.h │ │ │ │ └── filter.proto │ │ │ │ ├── test_accessor │ │ │ │ ├── BUILD │ │ │ │ ├── config.cc │ │ │ │ ├── config.h │ │ │ │ ├── filter.cc │ │ │ │ ├── filter.h │ │ │ │ └── filter.proto │ │ │ │ ├── test_event_tracker │ │ │ │ ├── BUILD │ │ │ │ ├── config.cc │ │ │ │ ├── config.h │ │ │ │ ├── filter.cc │ │ │ │ ├── filter.h │ │ │ │ └── filter.proto │ │ │ │ ├── test_kv_store │ │ │ │ ├── BUILD │ │ │ │ ├── config.cc │ │ │ │ ├── config.h │ │ │ │ ├── filter.cc │ │ │ │ ├── filter.h │ │ │ │ └── filter.proto │ │ │ │ └── test_logger │ │ │ │ ├── BUILD │ │ │ │ ├── config.cc │ │ │ │ ├── config.h │ │ │ │ ├── filter.h │ │ │ │ └── filter.proto │ │ ├── key_value │ │ │ └── platform │ │ │ │ ├── BUILD │ │ │ │ ├── c_types.h │ │ │ │ ├── config.cc │ │ │ │ ├── config.h │ │ │ │ └── platform.proto │ │ └── retry │ │ │ └── options │ │ │ └── network_configuration │ │ │ ├── BUILD │ │ │ ├── config.cc │ │ │ ├── config.h │ │ │ ├── predicate.cc │ │ │ ├── predicate.h │ │ │ └── predicate.proto │ ├── http │ │ ├── BUILD │ │ ├── client.cc │ │ ├── client.h │ │ ├── header_utility.cc │ │ ├── header_utility.h │ │ └── headers.h │ ├── jni │ │ ├── BUILD │ │ ├── android_jni_interface.cc │ │ ├── android_jni_utility.cc │ │ ├── android_jni_utility.h │ │ ├── android_network_utility.cc │ │ ├── android_network_utility.h │ │ ├── android_test_jni_interface.cc │ │ ├── import │ │ │ ├── BUILD │ │ │ └── jni_import.h │ │ ├── java_jni_support.cc │ │ ├── jni_interface.cc │ │ ├── jni_support.h │ │ ├── jni_utility.cc │ │ ├── jni_utility.h │ │ ├── jni_version.cc │ │ ├── jni_version.h │ │ └── ndk_jni_support.cc │ ├── main_interface.cc │ ├── main_interface.h │ ├── network │ │ ├── BUILD │ │ ├── android.cc │ │ ├── android.h │ │ ├── apple_platform_cert_verifier.cc │ │ ├── apple_platform_cert_verifier.h │ │ ├── connectivity_manager.cc │ │ ├── connectivity_manager.h │ │ ├── proxy_settings.h │ │ ├── socket_tag_socket_option_impl.cc │ │ ├── socket_tag_socket_option_impl.h │ │ ├── src_addr_socket_option_impl.cc │ │ ├── src_addr_socket_option_impl.h │ │ └── synthetic_address_impl.h │ ├── stats │ │ ├── BUILD │ │ ├── utility.cc │ │ └── utility.h │ ├── stream_info │ │ ├── BUILD │ │ ├── extra_stream_info.cc │ │ └── extra_stream_info.h │ ├── thread │ │ ├── BUILD │ │ └── lock_guard.h │ └── types │ │ ├── BUILD │ │ ├── c_types.cc │ │ └── c_types.h ├── java │ ├── io │ │ └── envoyproxy │ │ │ └── envoymobile │ │ │ └── engine │ │ │ ├── AndroidEngineImpl.java │ │ │ ├── AndroidEngineManifest.xml │ │ │ ├── AndroidJniLibrary.java │ │ │ ├── AndroidNetworkMonitor.java │ │ │ ├── AndroidProxyMonitor.java │ │ │ ├── BUILD │ │ │ ├── EnvoyConfiguration.java │ │ │ ├── EnvoyEngine.java │ │ │ ├── EnvoyEngineImpl.java │ │ │ ├── EnvoyFinalStreamIntelImpl.java │ │ │ ├── EnvoyHTTPFilterCallbacksImpl.java │ │ │ ├── EnvoyHTTPStream.java │ │ │ ├── EnvoyNativeFilterConfig.java │ │ │ ├── EnvoyNativeResourceRegistry.java │ │ │ ├── EnvoyNativeResourceReleaser.java │ │ │ ├── EnvoyNativeResourceWrapper.java │ │ │ ├── EnvoyStreamIntelImpl.java │ │ │ ├── JniBridgeUtility.java │ │ │ ├── JniLibrary.java │ │ │ ├── JvmBridgeUtility.java │ │ │ ├── JvmCallbackContext.java │ │ │ ├── JvmFilterContext.java │ │ │ ├── JvmFilterFactoryContext.java │ │ │ ├── JvmKeyValueStoreContext.java │ │ │ ├── JvmStringAccessorContext.java │ │ │ ├── UpstreamHttpProtocol.java │ │ │ └── types │ │ │ ├── BUILD │ │ │ ├── EnvoyEventTracker.java │ │ │ ├── EnvoyFinalStreamIntel.java │ │ │ ├── EnvoyHTTPCallbacks.java │ │ │ ├── EnvoyHTTPFilter.java │ │ │ ├── EnvoyHTTPFilterCallbacks.java │ │ │ ├── EnvoyHTTPFilterFactory.java │ │ │ ├── EnvoyKeyValueStore.java │ │ │ ├── EnvoyLogger.java │ │ │ ├── EnvoyNetworkType.java │ │ │ ├── EnvoyOnEngineRunning.java │ │ │ ├── EnvoyStatus.java │ │ │ ├── EnvoyStreamIntel.java │ │ │ └── EnvoyStringAccessor.java │ └── org │ │ └── chromium │ │ └── net │ │ ├── AndroidCertVerifyResult.java │ │ ├── AndroidNetworkLibrary.java │ │ ├── ApiVersion.java │ │ ├── BUILD │ │ ├── BidirectionalStream.java │ │ ├── CallbackException.java │ │ ├── CertVerifyStatusAndroid.java │ │ ├── ChromiumNetManifest.xml │ │ ├── ContextUtils.java │ │ ├── CronetEngine.java │ │ ├── CronetException.java │ │ ├── CronetProvider.java │ │ ├── ExperimentalBidirectionalStream.java │ │ ├── ExperimentalCronetEngine.java │ │ ├── ExperimentalUrlRequest.java │ │ ├── FakeX509Util.java │ │ ├── ICronetEngineBuilder.java │ │ ├── InlineExecutionProhibitedException.java │ │ ├── LICENSE │ │ ├── NetworkException.java │ │ ├── NetworkQualityRttListener.java │ │ ├── NetworkQualityThroughputListener.java │ │ ├── QuicException.java │ │ ├── RequestFinishedInfo.java │ │ ├── StrictModeContext.java │ │ ├── ThreadStatsUid.java │ │ ├── UploadDataProvider.java │ │ ├── UploadDataProviders.java │ │ ├── UploadDataSink.java │ │ ├── UrlRequest.java │ │ ├── UrlResponseInfo.java │ │ ├── X509Util.java │ │ ├── impl │ │ ├── Annotations.java │ │ ├── AtomicCombinatoryState.java │ │ ├── BUILD │ │ ├── BidirectionalStreamBuilderImpl.java │ │ ├── BidirectionalStreamNetworkException.java │ │ ├── CallbackExceptionImpl.java │ │ ├── CancelProofEnvoyStream.java │ │ ├── CronetBidirectionalState.java │ │ ├── CronetBidirectionalStream.java │ │ ├── CronetEngineBase.java │ │ ├── CronetEngineBuilderImpl.java │ │ ├── CronetExceptionImpl.java │ │ ├── CronetMetrics.java │ │ ├── CronetUploadDataStream.java │ │ ├── CronetUrlRequest.java │ │ ├── CronetUrlRequestContext.java │ │ ├── CronvoyManifest.xml │ │ ├── Errors.java │ │ ├── Executors.java │ │ ├── HttpReason.java │ │ ├── ImplVersion.java │ │ ├── InputStreamChannel.java │ │ ├── JavaCronetEngine.java │ │ ├── JavaCronetEngineBuilderImpl.java │ │ ├── JavaCronetProvider.java │ │ ├── JavaUploadDataSinkBase.java │ │ ├── JavaUrlRequest.java │ │ ├── NativeCronetEngineBuilderImpl.java │ │ ├── NativeCronetEngineBuilderWithLibraryLoaderImpl.java │ │ ├── NativeCronetProvider.java │ │ ├── NetworkExceptionImpl.java │ │ ├── Preconditions.java │ │ ├── QuicExceptionImpl.java │ │ ├── RequestFinishedInfoImpl.java │ │ ├── ThreadStatsUid.java │ │ ├── UrlRequestBase.java │ │ ├── UrlRequestBuilderImpl.java │ │ ├── UrlResponseInfoImpl.java │ │ ├── UserAgent.java │ │ └── VersionSafeCallbacks.java │ │ └── urlconnection │ │ ├── BUILD │ │ ├── CronetBufferedOutputStream.java │ │ ├── CronetChunkedOutputStream.java │ │ ├── CronetFixedModeOutputStream.java │ │ ├── CronetHttpURLConnection.java │ │ ├── CronetHttpURLStreamHandler.java │ │ ├── CronetInputStream.java │ │ ├── CronetOutputStream.java │ │ ├── CronetURLStreamHandlerFactory.java │ │ ├── MessageLoop.java │ │ └── URLConnectionManifest.xml ├── kotlin │ └── io │ │ └── envoyproxy │ │ └── envoymobile │ │ ├── AndroidEngineBuilder.kt │ │ ├── BUILD │ │ ├── Engine.kt │ │ ├── EngineBuilder.kt │ │ ├── EngineImpl.kt │ │ ├── EnvoyError.kt │ │ ├── EnvoyManifest.xml │ │ ├── FinalStreamIntel.kt │ │ ├── Headers.kt │ │ ├── HeadersBuilder.kt │ │ ├── HeadersContainer.kt │ │ ├── KeyValueStore.kt │ │ ├── LogLevel.kt │ │ ├── PulseClient.kt │ │ ├── PulseClientImpl.kt │ │ ├── RequestHeaders.kt │ │ ├── RequestHeadersBuilder.kt │ │ ├── RequestMethod.kt │ │ ├── RequestTrailers.kt │ │ ├── RequestTrailersBuilder.kt │ │ ├── ResponseHeaders.kt │ │ ├── ResponseHeadersBuilder.kt │ │ ├── ResponseTrailers.kt │ │ ├── ResponseTrailersBuilder.kt │ │ ├── RetryPolicy.kt │ │ ├── RetryPolicyMapper.kt │ │ ├── Stream.kt │ │ ├── StreamCallbacks.kt │ │ ├── StreamClient.kt │ │ ├── StreamClientImpl.kt │ │ ├── StreamIntel.kt │ │ ├── StreamPrototype.kt │ │ ├── StringAccessor.kt │ │ ├── Trailers.kt │ │ ├── UpstreamHttpProtocol.kt │ │ ├── android │ │ └── SharedPreferencesStore.kt │ │ ├── filters │ │ ├── AsyncRequestFilter.kt │ │ ├── AsyncResponseFilter.kt │ │ ├── Filter.kt │ │ ├── FilterDataStatus.kt │ │ ├── FilterHeadersStatus.kt │ │ ├── FilterResumeStatus.kt │ │ ├── FilterTrailersStatus.kt │ │ ├── RequestFilter.kt │ │ ├── RequestFilterCallbacks.kt │ │ ├── RequestFilterCallbacksImpl.kt │ │ ├── ResponseFilter.kt │ │ ├── ResponseFilterCallbacks.kt │ │ └── ResponseFilterCallbacksImpl.kt │ │ ├── grpc │ │ ├── GRPCClient.kt │ │ ├── GRPCRequestHeaders.kt │ │ ├── GRPCRequestHeadersBuilder.kt │ │ ├── GRPCStream.kt │ │ └── GRPCStreamPrototype.kt │ │ ├── mocks │ │ ├── MockEnvoyEngine.kt │ │ ├── MockEnvoyHTTPStream.kt │ │ ├── MockStream.kt │ │ ├── MockStreamClient.kt │ │ └── MockStreamPrototype.kt │ │ └── stats │ │ ├── Counter.kt │ │ ├── CounterImpl.kt │ │ ├── Distribution.kt │ │ ├── DistributionImpl.kt │ │ ├── Element.kt │ │ ├── Gauge.kt │ │ ├── GaugeImpl.kt │ │ ├── Tags.kt │ │ ├── TagsBuilder.kt │ │ ├── Timer.kt │ │ └── TimerImpl.kt ├── objective-c │ ├── BUILD │ ├── EnvoyBridgeUtility.h │ ├── EnvoyConfiguration.m │ ├── EnvoyEngine.h │ ├── EnvoyEngineImpl.m │ ├── EnvoyEventTracker.m │ ├── EnvoyHTTPCallbacks.m │ ├── EnvoyHTTPFilter.m │ ├── EnvoyHTTPFilterCallbacksImpl.h │ ├── EnvoyHTTPFilterCallbacksImpl.m │ ├── EnvoyHTTPFilterFactory.m │ ├── EnvoyHTTPStreamImpl.m │ ├── EnvoyLogger.m │ ├── EnvoyNativeFilterConfig.m │ ├── EnvoyNetworkMonitor.m │ └── EnvoyStringAccessor.m ├── proguard.txt ├── python │ ├── BUILD │ ├── README.rst │ ├── bytes_view.cc │ ├── bytes_view.h │ ├── engine_builder_shim.cc │ ├── engine_builder_shim.h │ ├── envoy_engine.pyi │ ├── envoy_requests │ │ ├── __init__.py │ │ ├── asyncio.py │ │ ├── common │ │ │ ├── __init__.py │ │ │ ├── core.py │ │ │ ├── engine.py │ │ │ └── executor.py │ │ ├── gevent.py │ │ ├── response.py │ │ └── threading.py │ ├── gevent_util │ │ ├── BUILD │ │ └── __init__.py │ ├── module_definition.cc │ ├── stream_prototype_shim.cc │ ├── stream_prototype_shim.h │ ├── stream_shim.cc │ └── stream_shim.h └── swift │ ├── BUILD │ ├── DirectResponse.swift │ ├── Engine.swift │ ├── EngineBuilder.swift │ ├── EngineImpl.swift │ ├── EnvoyError.swift │ ├── FinalStreamIntel.swift │ ├── Headers.swift │ ├── HeadersBuilder.swift │ ├── HeadersContainer.swift │ ├── KeyValueStore.swift │ ├── LogLevel.swift │ ├── NetworkMonitoringMode.swift │ ├── PulseClient.swift │ ├── PulseClientImpl.swift │ ├── RequestHeaders.swift │ ├── RequestHeadersBuilder.swift │ ├── RequestMethod.swift │ ├── RequestTrailers.swift │ ├── RequestTrailersBuilder.swift │ ├── ResponseHeaders.swift │ ├── ResponseHeadersBuilder.swift │ ├── ResponseTrailers.swift │ ├── ResponseTrailersBuilder.swift │ ├── RetryPolicy.swift │ ├── RetryPolicyMapper.swift │ ├── RouteMatcher.swift │ ├── Stream.swift │ ├── StreamCallbacks.swift │ ├── StreamClient.swift │ ├── StreamClientImpl.swift │ ├── StreamIntel.swift │ ├── StreamPrototype.swift │ ├── TestEngineBuilder.swift │ ├── Trailers.swift │ ├── UpstreamHttpProtocol.swift │ ├── extensions │ └── UserDefaults+KeyValueStore.swift │ ├── filters │ ├── AsyncRequestFilter.swift │ ├── AsyncResponseFilter.swift │ ├── Filter.swift │ ├── FilterDataStatus.swift │ ├── FilterHeadersStatus.swift │ ├── FilterResumeStatus.swift │ ├── FilterTrailersStatus.swift │ ├── RequestFilter.swift │ ├── RequestFilterCallbacks.swift │ ├── RequestFilterCallbacksImpl.swift │ ├── ResponseFilter.swift │ ├── ResponseFilterCallbacks.swift │ └── ResponseFilterCallbacksImpl.swift │ ├── grpc │ ├── Data+Extension.swift │ ├── GRPCClient.swift │ ├── GRPCRequestHeaders.swift │ ├── GRPCRequestHeadersBuilder.swift │ ├── GRPCStream.swift │ └── GRPCStreamPrototype.swift │ ├── mocks │ ├── MockEnvoyEngine.swift │ ├── MockEnvoyHTTPStream.swift │ ├── MockStream.swift │ ├── MockStreamClient.swift │ └── MockStreamPrototype.swift │ └── stats │ ├── Counter.swift │ ├── CounterImpl.swift │ ├── Distribution.swift │ ├── DistributionImpl.swift │ ├── Element.swift │ ├── Gauge.swift │ ├── GaugeImpl.swift │ ├── Tags.swift │ ├── TagsBuilder.swift │ ├── Timer.swift │ └── TimerImpl.swift ├── test ├── cc │ ├── integration │ │ ├── BUILD │ │ ├── lifetimes_test.cc │ │ └── send_headers_test.cc │ └── unit │ │ ├── BUILD │ │ └── envoy_config_test.cc ├── common │ ├── BUILD │ ├── bridge │ │ ├── BUILD │ │ └── utility_test.cc │ ├── buffer │ │ ├── BUILD │ │ └── bridge_fragment_test.cc │ ├── common │ │ ├── BUILD │ │ └── lambda_logger_delegate_test.cc │ ├── data │ │ ├── BUILD │ │ └── utility_test.cc │ ├── engine_common_test.cc │ ├── engine_test.cc │ ├── extensions │ │ ├── cert_validator │ │ │ └── platform_bridge │ │ │ │ ├── BUILD │ │ │ │ └── platform_bridge_cert_validator_test.cc │ │ ├── filters │ │ │ └── http │ │ │ │ ├── assertion │ │ │ │ ├── BUILD │ │ │ │ └── assertion_filter_test.cc │ │ │ │ ├── network_configuration │ │ │ │ ├── BUILD │ │ │ │ └── network_configuration_filter_test.cc │ │ │ │ └── platform_bridge │ │ │ │ ├── BUILD │ │ │ │ ├── platform_bridge_filter_integration_test.cc │ │ │ │ └── platform_bridge_filter_test.cc │ │ ├── key_value │ │ │ └── platform │ │ │ │ ├── BUILD │ │ │ │ └── platform_store_test.cc │ │ ├── retry │ │ │ └── options │ │ │ │ └── network_configuration │ │ │ │ ├── BUILD │ │ │ │ └── predicate_test.cc │ │ └── stat_sinks │ │ │ └── metrics_service │ │ │ ├── BUILD │ │ │ ├── mobile_grpc_streamer_integration_test.cc │ │ │ └── mobile_grpc_streamer_test.cc │ ├── http │ │ ├── BUILD │ │ ├── client_test.cc │ │ └── header_utility_test.cc │ ├── integration │ │ ├── BUILD │ │ ├── autonomous_upstream.cc │ │ ├── autonomous_upstream.h │ │ ├── base_client_integration_test.cc │ │ ├── base_client_integration_test.h │ │ ├── client_integration_test.cc │ │ ├── quic_test_server.cc │ │ ├── quic_test_server.h │ │ ├── quic_test_server_interface.cc │ │ ├── quic_test_server_interface.h │ │ ├── rtds_integration_test.cc │ │ ├── sds_integration_test.cc │ │ ├── xds_integration_test.cc │ │ └── xds_integration_test.h │ ├── jni │ │ ├── BUILD │ │ └── quic_test_server_jni_interface.cc │ ├── main_interface_test.cc │ ├── mocks │ │ └── event │ │ │ ├── BUILD │ │ │ ├── mocks.cc │ │ │ └── mocks.h │ ├── network │ │ ├── BUILD │ │ ├── connectivity_manager_test.cc │ │ ├── proxy_settings_test.cc │ │ ├── src_addr_socket_option_impl_test.cc │ │ └── synthetic_address_impl_test.cc │ ├── stats │ │ ├── BUILD │ │ └── utility_test.cc │ ├── stream_info │ │ ├── BUILD │ │ └── extra_stream_info_test.cc │ └── thread │ │ ├── BUILD │ │ └── lock_guard_test.cc ├── integration │ └── filters │ │ └── http │ │ └── test_read │ │ ├── BUILD │ │ ├── config.cc │ │ ├── config.h │ │ ├── filter.cc │ │ ├── filter.h │ │ └── filter.proto ├── java │ ├── integration │ │ ├── AndroidEngineSocketTagTest.java │ │ ├── AndroidEnvoyEngineStartUpTest.java │ │ ├── AndroidEnvoyExplicitFlowTest.java │ │ ├── AndroidEnvoyFlowTest.java │ │ └── BUILD │ ├── io │ │ └── envoyproxy │ │ │ └── envoymobile │ │ │ └── engine │ │ │ ├── AndroidNetworkMonitorTest.java │ │ │ ├── BUILD │ │ │ ├── EnvoyConfigurationTest.kt │ │ │ ├── EnvoyNativeResourceRegistryTest.kt │ │ │ ├── JvmBridgeUtilityTest.kt │ │ │ └── testing │ │ │ ├── BUILD │ │ │ ├── QuicTestServer.java │ │ │ ├── QuicTestServerTest.java │ │ │ ├── RequestScenario.java │ │ │ └── Response.java │ └── org │ │ └── chromium │ │ └── net │ │ ├── BUILD │ │ ├── BidirectionalStreamTest.java │ │ ├── BrotliTest.java │ │ ├── CertificateVerificationTest.java │ │ ├── CronetEngineBuilderTest.java │ │ ├── CronetStressTest.java │ │ ├── CronetUrlRequestContextTest.java │ │ ├── CronetUrlRequestTest.java │ │ ├── DiskStorageTest.java │ │ ├── GetStatusTest.java │ │ ├── RequestFinishedInfoTest.java │ │ ├── UploadDataProvidersTest.java │ │ ├── UrlResponseInfoTest.java │ │ ├── impl │ │ ├── AtomicCombinatoryStateTest.java │ │ ├── BUILD │ │ ├── CancelProofEnvoyStreamTest.java │ │ ├── CronetBidirectionalStateTest.java │ │ ├── CronvoyEngineTest.java │ │ └── UrlRequestCallbackTester.java │ │ ├── testing │ │ ├── AndroidEnvoyExplicitH2FlowTest.java │ │ ├── BUILD │ │ ├── CertTestUtil.java │ │ ├── ConditionVariable.java │ │ ├── ContextUtils.java │ │ ├── CronetTestRule.java │ │ ├── CronetTestRuleTest.java │ │ ├── CronetTestUtil.java │ │ ├── FailurePhase.java │ │ ├── Feature.java │ │ ├── FileUtils.java │ │ ├── Http2TestHandler.java │ │ ├── Http2TestServer.java │ │ ├── Http2TestServerTest.java │ │ ├── MetricsTestUtil.java │ │ ├── MockUrlRequestJobFactory.java │ │ ├── NativeTestServer.java │ │ ├── PathUtils.java │ │ ├── ReportingCollector.java │ │ ├── StrictModeContext.java │ │ ├── TestBidirectionalStreamCallback.java │ │ ├── TestDrivenDataProvider.java │ │ ├── TestFilesInstaller.java │ │ ├── TestUploadDataProvider.java │ │ ├── TestUrlRequestCallback.java │ │ ├── UrlUtils.java │ │ └── data │ │ │ ├── cacheable.txt │ │ │ ├── cacheable.txt.mock-http-headers │ │ │ ├── content_length_mismatch.html │ │ │ ├── content_length_mismatch.html.mock-http-headers │ │ │ ├── gzipped.html │ │ │ ├── gzipped.html.mock-http-headers │ │ │ ├── internalerror.txt │ │ │ ├── internalerror.txt.mock-http-headers │ │ │ ├── multiredirect.html │ │ │ ├── multiredirect.html.mock-http-headers │ │ │ ├── notfound.html │ │ │ ├── notfound.html.mock-http-headers │ │ │ ├── redirect.html │ │ │ ├── redirect.html.mock-http-headers │ │ │ ├── redirect_broken_header.html │ │ │ ├── redirect_broken_header.html.mock-http-headers │ │ │ ├── redirect_invalid_scheme.html │ │ │ ├── redirect_invalid_scheme.html.mock-http-headers │ │ │ ├── secureproxychecksuccess.txt │ │ │ ├── secureproxychecksuccess.txt.mock-http-headers │ │ │ ├── set_cookie.html │ │ │ ├── set_cookie.html.mock-http-headers │ │ │ ├── success.txt │ │ │ └── success.txt.mock-http-headers │ │ └── urlconnection │ │ ├── BUILD │ │ ├── CronetBufferedOutputStreamTest.java │ │ ├── CronetChunkedOutputStreamTest.java │ │ ├── CronetFixedModeOutputStreamTest.java │ │ ├── CronetHttpURLStreamHandlerTest.java │ │ ├── CronetInputStreamTest.java │ │ ├── CronetURLStreamHandlerFactoryTest.java │ │ ├── MessageLoopTest.java │ │ └── TestUtil.java ├── kotlin │ ├── apps │ │ ├── baseline │ │ │ ├── .bazelproject │ │ │ ├── AndroidManifest.xml │ │ │ ├── AsyncDemoFilter.kt │ │ │ ├── BUILD │ │ │ ├── BufferDemoFilter.kt │ │ │ ├── DemoFilter.kt │ │ │ ├── MainActivity.kt │ │ │ ├── README.md │ │ │ ├── res │ │ │ │ └── layout │ │ │ │ │ └── activity_main.xml │ │ │ └── tools │ │ │ │ └── android-studio-run-configurations │ │ │ │ ├── run_configuration_example_debug_arm64.xml │ │ │ │ └── run_configuration_example_debug_x86.xml │ │ └── experimental │ │ │ ├── .bazelproject │ │ │ ├── AndroidManifest.xml │ │ │ ├── AsyncDemoFilter.kt │ │ │ ├── BUILD │ │ │ ├── BufferDemoFilter.kt │ │ │ ├── DemoFilter.kt │ │ │ ├── MainActivity.kt │ │ │ ├── README.md │ │ │ ├── res │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ │ └── tools │ │ │ └── android-studio-run-configurations │ │ │ ├── run_configuration_example_debug_arm64.xml │ │ │ └── run_configuration_example_debug_x86.xml │ ├── integration │ │ ├── BUILD │ │ ├── CancelStreamTest.kt │ │ ├── EngineApiTest.kt │ │ ├── EnvoyEngineSimpleIntegrationTest.kt │ │ ├── GRPCReceiveErrorTest.kt │ │ ├── KeyValueStoreTest.kt │ │ ├── ReceiveDataTest.kt │ │ ├── ReceiveErrorTest.kt │ │ ├── ResetConnectivityStateTest.kt │ │ ├── SendDataTest.kt │ │ ├── SendHeadersTest.kt │ │ ├── SendTrailersTest.kt │ │ ├── SetEventTrackerTest.kt │ │ ├── SetLoggerTest.kt │ │ ├── StatFlushIntegrationTest.kt │ │ ├── StreamIdleTimeoutTest.kt │ │ ├── TestStatsdServer.kt │ │ └── proxying │ │ │ ├── BUILD │ │ │ ├── Proxy.kt │ │ │ ├── ProxyInfoIntentPerformHTTPRequestUsingProxyTest.kt │ │ │ ├── ProxyInfoIntentPerformHTTPSRequestBadHostnameTest.kt │ │ │ ├── ProxyInfoIntentPerformHTTPSRequestUsingAsyncProxyTest.kt │ │ │ ├── ProxyInfoIntentPerformHTTPSRequestUsingProxyTest.kt │ │ │ ├── ProxyPollPerformHTTPRequestUsingProxyTest.kt │ │ │ └── ProxyPollPerformHTTPRequestWithoutUsingPACProxyTest.kt │ └── io │ │ └── envoyproxy │ │ └── envoymobile │ │ ├── BUILD │ │ ├── EngineBuilderTest.kt │ │ ├── GRPCRequestHeadersBuilderTest.kt │ │ ├── GRPCStreamTest.kt │ │ ├── HeadersBuilderTest.kt │ │ ├── HeadersContainerTest.kt │ │ ├── PulseClientImplTest.kt │ │ ├── RequestHeadersBuilderTest.kt │ │ ├── ResponseHeadersTest.kt │ │ ├── RetryPolicyMapperTest.kt │ │ └── stats │ │ ├── BUILD │ │ ├── ElementTest.kt │ │ └── TagsBuilderTest.kt ├── objective-c │ ├── BUILD │ └── EnvoyBridgeUtilityTest.m ├── performance │ ├── BUILD │ └── test_binary_size.cc ├── python │ ├── BUILD │ ├── __init__.py │ ├── benchmark │ │ ├── __init__.py │ │ └── envoy_vs_requests.py │ ├── conftest.py │ ├── echo_server.py │ ├── integration │ │ ├── __init__.py │ │ └── test_send_headers.py │ ├── runner.py │ └── unit │ │ ├── __test__.py │ │ ├── test_basics.py │ │ ├── test_echo_server.py │ │ ├── test_methods.py │ │ └── test_pre_build_engine.py └── swift │ ├── BUILD │ ├── EngineBuilderTests.swift │ ├── GRPCRequestHeadersBuilderTests.swift │ ├── GRPCStreamTests.swift │ ├── HeadersBuilderTests.swift │ ├── HeadersContainerTests.swift │ ├── PulseClientImplTests.swift │ ├── RequestHeadersBuilderTests.swift │ ├── ResponseHeadersTests.swift │ ├── RetryPolicyMapperTests.swift │ ├── RetryPolicyTests.swift │ ├── apps │ ├── baseline │ │ ├── AppDelegate.swift │ │ ├── AsyncDemoFilter.swift │ │ ├── BUILD │ │ ├── Base.lproj │ │ │ └── LaunchScreen.storyboard │ │ ├── BufferDemoFilter.swift │ │ ├── DemoFilter.swift │ │ ├── Info.plist │ │ ├── README.md │ │ ├── ResponseModels.swift │ │ └── ViewController.swift │ └── experimental │ │ ├── AppDelegate.swift │ │ ├── AsyncDemoFilter.swift │ │ ├── BUILD │ │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ │ ├── BufferDemoFilter.swift │ │ ├── DemoFilter.swift │ │ ├── Info.plist │ │ ├── README.md │ │ ├── ResponseModels.swift │ │ └── ViewController.swift │ ├── integration │ ├── BUILD │ ├── CancelStreamTest.swift │ ├── DirectResponseContainsHeadersMatchIntegrationTest.swift │ ├── DirectResponseExactHeadersMatchIntegrationTest.swift │ ├── DirectResponseExactPathMatchIntegrationTest.swift │ ├── DirectResponseFilterMutationIntegrationTest.swift │ ├── DirectResponsePrefixHeadersMatchIntegrationTest.swift │ ├── DirectResponsePrefixPathMatchIntegrationTest.swift │ ├── DirectResponseSuffixHeadersMatchIntegrationTest.swift │ ├── EngineApiTest.swift │ ├── FilterResetIdleTest.swift │ ├── GRPCReceiveErrorTest.swift │ ├── IdleTimeoutTest.swift │ ├── KeyValueStoreTest.swift │ ├── README.md │ ├── ReceiveDataTest.swift │ ├── ReceiveErrorTest.swift │ ├── ResetConnectivityStateTest.swift │ ├── SendDataTest.swift │ ├── SendHeadersTest.swift │ ├── SendTrailersTest.swift │ ├── SetEventTrackerTest.swift │ ├── SetEventTrackerTestNoTracker.swift │ ├── SetLoggerTest.swift │ ├── StatFlushIntegrationTest.swift │ ├── TestExtensions.h │ ├── test_extensions.cc │ └── test_extensions.h │ └── stats │ ├── BUILD │ ├── CounterImplTests.swift │ ├── ElementTests.swift │ └── TagsBuilderTests.swift ├── third_party ├── BUILD ├── android │ ├── LocalArray.h │ ├── ScopedFd.h │ └── ifaddrs-android.h ├── python │ ├── BUILD │ ├── requirements.in │ └── requirements.txt └── rbe_configs │ ├── LICENSE │ ├── cc │ ├── BUILD │ ├── WORKSPACE │ ├── armeabi_cc_toolchain_config.bzl │ ├── builtin_include_directory_paths │ ├── cc_toolchain_config.bzl │ ├── cc_wrapper.sh │ ├── module.modulemap │ └── tools │ │ └── cpp │ │ └── empty.cc │ └── config │ └── BUILD └── tools ├── bump_lyft_support_rotation.sh ├── check_format.sh ├── docc.sh ├── post_to_slack.sh └── vscode_compdb.sh /.bazelproject: -------------------------------------------------------------------------------- 1 | # Uncomment the examples you'd like to use! 2 | import examples/kotlin/hello_world/.bazelproject 3 | import examples/java/hello_world/.bazelproject 4 | import test/kotlin/apps/baseline/.bazelproject 5 | import test/kotlin/apps/experimental/.bazelproject 6 | 7 | android_sdk_platform: android-31 8 | -------------------------------------------------------------------------------- /.bazelversion: -------------------------------------------------------------------------------- 1 | envoy/.bazelversion -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | executors: 4 | ubuntu-build: 5 | description: "A regular build executor based on ubuntu image" 6 | docker: 7 | - image: envoyproxy/envoy-build-ubuntu:0a02a76af5951bf7f4c7029c0ea6d29d96c0f682 8 | # TODO(mattklein123): Get xlarge class enabled 9 | resource_class: medium 10 | working_directory: /source 11 | 12 | jobs: 13 | docs: 14 | executor: ubuntu-build 15 | steps: 16 | - checkout 17 | - run: git submodule update --init 18 | - run: docs/build.sh 19 | - add_ssh_keys: 20 | fingerprints: 21 | - "a2:f7:59:f0:01:8b:91:31:ab:0c:3f:9f:25:4c:1e:e5" 22 | - run: docs/publish.sh 23 | - store_artifacts: 24 | path: generated/docs 25 | 26 | workflows: 27 | version: 2 28 | all: 29 | jobs: 30 | - docs: 31 | filters: 32 | tags: 33 | only: /^v.*/ 34 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | AccessModifierOffset: -2 4 | ColumnLimit: 100 5 | DerivePointerAlignment: false 6 | PointerAlignment: Left 7 | SortIncludes: false 8 | ... 9 | 10 | --- 11 | Language: Java 12 | AccessModifierOffset: -2 13 | ColumnLimit: 100 14 | DerivePointerAlignment: false 15 | IndentWidth: 2 16 | PointerAlignment: Left 17 | SortIncludes: false 18 | ... 19 | 20 | --- 21 | Language: ObjC 22 | AccessModifierOffset: -2 23 | ColumnLimit: 100 24 | DerivePointerAlignment: false 25 | IndentWidth: 2 26 | ObjCBlockIndentWidth: 2 27 | ObjCSpaceAfterProperty: true 28 | ObjCSpaceBeforeProtocolList: true 29 | PointerAlignment: Right 30 | SortIncludes: false 31 | ... 32 | 33 | --- 34 | Language: Proto 35 | ColumnLimit: 100 36 | SpacesInContainerLiterals: false 37 | AllowShortFunctionsOnASingleLine: false 38 | ... 39 | -------------------------------------------------------------------------------- /.drstring.toml: -------------------------------------------------------------------------------- 1 | include = [ 2 | "library/swift/**.swift", 3 | ] 4 | column-limit = 100 5 | ignore-throws = true 6 | first-letter = "lowercase" 7 | vertical-align = true 8 | empty-patterns = true 9 | needs-separation = [ 10 | "description", 11 | "parameters", 12 | ] 13 | parameter-style = "separate" 14 | align-after-colon = [ 15 | "throws", 16 | "returns", 17 | ] 18 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.{kt,kts}] 2 | # possible values: number (e.g. 2), "unset" (makes ktlint ignore indentation completely) 3 | indent_style = space 4 | indent_size = 2 5 | # true (recommended) / false 6 | insert_final_newline=true 7 | # possible values: number (e.g. 120) (package name, imports & comments are ignored), "off" 8 | # it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide) 9 | max_line_length=off 10 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | library/common/certificates.inc linguist-vendored 2 | docs/root/intro/version_history.rst merge=union 3 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @lyft/envoy-mobile-admin 2 | -------------------------------------------------------------------------------- /.github/actions/pr_notifier/requirements.in: -------------------------------------------------------------------------------- 1 | pygithub 2 | slack_sdk 3 | -------------------------------------------------------------------------------- /.github/lyft_maintainers.yml: -------------------------------------------------------------------------------- 1 | current: Augustyniak 2 | maintainers: 3 | - Augustyniak 4 | - jpsim 5 | -------------------------------------------------------------------------------- /.github/workflows/cc_tests.yml: -------------------------------------------------------------------------------- 1 | name: cc_tests 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | 9 | jobs: 10 | cctests: 11 | name: cc_tests 12 | runs-on: ubuntu-latest 13 | timeout-minutes: 120 14 | container: 15 | image: envoyproxy/envoy-build-ubuntu:0a02a76af5951bf7f4c7029c0ea6d29d96c0f682 16 | steps: 17 | - uses: actions/checkout@v1 18 | with: 19 | submodules: true 20 | - name: Add safe directory 21 | run: git config --global --add safe.directory /__w/envoy-mobile/envoy-mobile 22 | - env: 23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 24 | name: 'Run tests' 25 | run: | 26 | ./bazelw test \ 27 | --action_env=LD_LIBRARY_PATH \ 28 | --test_output=all \ 29 | $([ -z $GITHUB_TOKEN ] || echo "--config=remote-ci-linux") \ 30 | --remote_header="Authorization=Bearer $GITHUB_TOKEN" \ 31 | //test/cc/... 32 | -------------------------------------------------------------------------------- /.github/workflows/commands.yml: -------------------------------------------------------------------------------- 1 | name: commands 2 | on: 3 | issue_comment: 4 | types: [created] 5 | 6 | jobs: 7 | retest: 8 | name: Retest 9 | runs-on: ubuntu-latest 10 | steps: 11 | # jpsim/retest@v1 12 | - uses: jpsim/retest@c158dec0a7f67cb85f8367468dc8a9a75308bb7f 13 | with: 14 | token: ${{ secrets.GITHUB_TOKEN }} 15 | -------------------------------------------------------------------------------- /.github/workflows/core.yml: -------------------------------------------------------------------------------- 1 | name: core 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | 9 | jobs: 10 | unittests: 11 | name: unit_tests 12 | runs-on: macos-12 13 | timeout-minutes: 120 14 | steps: 15 | - uses: actions/checkout@v1 16 | with: 17 | submodules: true 18 | - name: 'Install dependencies' 19 | run: ./ci/mac_ci_setup.sh 20 | - name: 'Run tests' 21 | env: 22 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 23 | run: | 24 | ./bazelw test \ 25 | --test_output=all \ 26 | $([ -z $GITHUB_TOKEN ] || echo "--config=remote-ci-macos") \ 27 | --remote_header="Authorization=Bearer $GITHUB_TOKEN" \ 28 | //test/common/... 29 | -------------------------------------------------------------------------------- /.github/workflows/pr_notifier.yml: -------------------------------------------------------------------------------- 1 | on: 2 | workflow_dispatch: 3 | schedule: 4 | - cron: '0 5 * * 1,2,3,4,5' 5 | 6 | jobs: 7 | pr_notifier: 8 | name: PR Notifier 9 | runs-on: ubuntu-latest 10 | if: github.repository_owner == 'envoyproxy' 11 | 12 | steps: 13 | - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 14 | - name: Set up Python 3.8 15 | uses: actions/setup-python@v2 16 | with: 17 | python-version: '3.8' 18 | architecture: 'x64' 19 | - name: Install dependencies 20 | run: | 21 | python -m pip install --upgrade pip 22 | pip install -r ./.github/actions/pr_notifier/requirements.txt 23 | - name: Notify about PRs 24 | run: python ./.github/actions/pr_notifier/pr_notifier.py --cron_job 25 | env: 26 | SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .aswb 2 | .DS_Store 3 | .idea 4 | .ijwb 5 | .vscode 6 | /bazel-* 7 | /build_* 8 | /dist/ 9 | /generated 10 | /test/coverage/BUILD 11 | /tmp 12 | *.doccarchive 13 | *.pyc 14 | *.tulsiconf-user 15 | *.xcodeproj 16 | *.xcframework 17 | clang.bazelrc 18 | user.bazelrc 19 | tags 20 | tulsi-workspace 21 | compile_commands.json 22 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "envoy"] 2 | path = envoy 3 | url = https://github.com/envoyproxy/envoy.git 4 | -------------------------------------------------------------------------------- /.kotlinlint.yml: -------------------------------------------------------------------------------- 1 | # We build upon the default config provided by https://github.com/arturbosch/detekt/blob/master/detekt-cli/src/main/resources/default-detekt-config.yml 2 | build: 3 | maxIssues: 0 4 | 5 | complexity: 6 | ComplexCondition: 7 | active: false 8 | TooManyFunctions: 9 | active: false 10 | 11 | comments: 12 | OutdatedDocumentation: 13 | active: true 14 | matchTypeParameters: false 15 | matchDeclarationsOrder: false 16 | allowParamOnConstructorProperties: true 17 | UndocumentedPublicClass: 18 | active: true 19 | UndocumentedPublicFunction: 20 | active: true 21 | UndocumentedPublicProperty: 22 | active: true 23 | 24 | console-reports: 25 | active: true 26 | 27 | processors: 28 | active: true 29 | 30 | style: 31 | ForbiddenComment: 32 | active: false 33 | MagicNumber: 34 | active: false 35 | MaxLineLength: 36 | maxLineLength: 100 37 | ReturnCount: 38 | active: false 39 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | exclude: '(^third_party/rbe_configs/cc/module.modulemap$)|(/certificates.inc$)|(test/.*/testing/data/)' 2 | repos: 3 | - repo: https://github.com/pre-commit/pre-commit-hooks 4 | rev: v2.1.0 5 | hooks: 6 | - id: trailing-whitespace 7 | - id: end-of-file-fixer 8 | - id: check-docstring-first 9 | - id: check-executables-have-shebangs 10 | - id: check-merge-conflict 11 | - id: check-yaml 12 | exclude: '(.clang-format|test_envoy_config_template.yaml)' 13 | - id: detect-private-key 14 | exclude: 'experimental/swift/QUICStreamTest.swift' 15 | - id: mixed-line-ending 16 | - repo: https://github.com/codespell-project/codespell 17 | rev: v2.1.0 18 | hooks: 19 | - id: codespell 20 | args: ['-L=inout,keyserver,optin,uint'] 21 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # @envoyproxy/envoy-mobile-maintainers owns everything by default. 2 | 3 | # Cronet fork and Cronvoy sources + tests 4 | library/java/org/chromium/net @buildbreaker @goaway @DavidSchinazi @carloseltuerto 5 | test/java/org/chromium/net @buildbreaker @goaway @DavidSchinazi @carloseltuerto 6 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Community Code of Conduct 2 | 3 | Envoy Mobile follows the 4 | [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md). 5 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem "cocoapods" 4 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Envoy Mobile 2 | Copyright 2019-2021 Envoy Mobile Project Authors 3 | 4 | Licensed under Apache License 2.0. See LICENSE for terms. 5 | -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | For an explanation of how to fill out the fields, please see the relevant section 2 | in [PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/master/PULL_REQUESTS.md) 3 | 4 | Description: 5 | Risk Level: 6 | Testing: 7 | Docs Changes: 8 | Release Notes: 9 | [Optional Fixes #Issue] 10 | [Optional Deprecated:] 11 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 0.5.0 2 | -------------------------------------------------------------------------------- /bazel/abseil.patch: -------------------------------------------------------------------------------- 1 | --- absl/time/internal/cctz/BUILD.bazel 2 | +++ absl/time/internal/cctz/BUILD.bazel 3 | @@ -76,7 +76,7 @@ cc_library( 4 | ], 5 | linkopts = select({ 6 | ":osx": [ 7 | - "-framework Foundation", 8 | + # "-framework Foundation", 9 | ], 10 | ":ios": [ 11 | "-framework Foundation", 12 | -------------------------------------------------------------------------------- /bazel/config.bzl: -------------------------------------------------------------------------------- 1 | """Shared configuration for things we don't want to duplicate""" 2 | 3 | MINIMUM_IOS_VERSION = "12.0" 4 | -------------------------------------------------------------------------------- /bazel/envoy_mobile_test_extensions.bzl: -------------------------------------------------------------------------------- 1 | # List of modules to compile into the test files. For JVM we always compile these into the .so all 2 | # the time, while for iOS we have to force register the extensions, so test files must pull in 3 | # the TestExtensions module and call register_test_extensions(). 4 | TEST_EXTENSIONS = [ 5 | "//library/common/extensions/filters/http/test_logger:config", 6 | "//library/common/extensions/filters/http/test_accessor:config", 7 | "//library/common/extensions/filters/http/test_event_tracker:config", 8 | "//library/common/extensions/filters/http/test_kv_store:config", 9 | "//test/integration/filters/http/test_read:config", 10 | ] 11 | -------------------------------------------------------------------------------- /bazel/envoy_mobile_toolchains.bzl: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains") 2 | load("@rules_detekt//detekt:toolchains.bzl", "rules_detekt_toolchains") 3 | load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_toolchains") 4 | load("@rules_java//java:repositories.bzl", "rules_java_toolchains") 5 | 6 | def envoy_mobile_toolchains(): 7 | rules_java_toolchains() 8 | kt_register_toolchains() 9 | rules_detekt_toolchains(detekt_version = "1.20.0") 10 | rules_proto_grpc_toolchains() 11 | -------------------------------------------------------------------------------- /bazel/swift_header_collector.bzl: -------------------------------------------------------------------------------- 1 | """ 2 | Propagate the generated Swift header from a swift_library target 3 | This exists to work around https://github.com/bazelbuild/rules_swift/issues/291 4 | """ 5 | 6 | def _swift_header_collector(ctx): 7 | headers = [ 8 | DefaultInfo( 9 | files = ctx.attr.library[CcInfo].compilation_context.headers, 10 | ), 11 | ] 12 | 13 | if len(headers[0].files.to_list()) != 1: 14 | header_names = [header.basename for header in headers[0].files.to_list()] 15 | fail("Expected exactly 1 '-Swift.h' header, got {}".format(header_names)) 16 | 17 | return headers 18 | 19 | swift_header_collector = rule( 20 | attrs = dict( 21 | library = attr.label( 22 | mandatory = True, 23 | providers = [CcInfo], 24 | ), 25 | ), 26 | implementation = _swift_header_collector, 27 | ) 28 | -------------------------------------------------------------------------------- /bazel/test_manifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 7 | 8 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /ci/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) # Apache 2 2 | 3 | xcode_version( 4 | name = "xcode_14_1_0", 5 | default_ios_sdk_version = "16.1", 6 | default_macos_sdk_version = "13.0", 7 | default_tvos_sdk_version = "16.1", 8 | default_watchos_sdk_version = "9.1", 9 | version = "14.1", 10 | ) 11 | 12 | available_xcodes( 13 | name = "local_xcodes", 14 | default = ":xcode_14_1_0", 15 | versions = [ 16 | ":xcode_14_1_0", 17 | ], 18 | ) 19 | 20 | available_xcodes( 21 | name = "remote_xcodes", 22 | default = ":xcode_14_1_0", 23 | versions = [ 24 | ":xcode_14_1_0", 25 | ], 26 | ) 27 | 28 | xcode_config( 29 | name = "xcode_config", 30 | local_versions = ":local_xcodes", 31 | remote_versions = ":remote_xcodes", 32 | ) 33 | -------------------------------------------------------------------------------- /ci/mac_start_emulator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | echo "y" | "${ANDROID_HOME}/tools/bin/sdkmanager" --install 'system-images;android-29;google_apis;x86_64' --channel=3 6 | echo "no" | "${ANDROID_HOME}/tools/bin/avdmanager" create avd -n test_android_emulator -k 'system-images;android-29;google_apis;x86_64' --force 7 | ls "${ANDROID_HOME}/tools/bin/" 8 | 9 | nohup "${ANDROID_HOME}/emulator/emulator" -partition-size 1024 -avd test_android_emulator -no-snapshot > /dev/null 2>&1 & { 10 | # shellcheck disable=SC2016 11 | "${ANDROID_HOME}/platform-tools/adb" wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\''\r'\'') ]]; do sleep 1; done; input keyevent 82' 12 | } 13 | -------------------------------------------------------------------------------- /ci/platform/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) # Apache 2 2 | 3 | platform( 4 | name = "macos", 5 | constraint_values = [ 6 | "@platforms//cpu:x86_64", 7 | "@platforms//os:macos", 8 | ], 9 | exec_properties = { 10 | "Pool": "macos", 11 | }, 12 | ) 13 | -------------------------------------------------------------------------------- /ci/test_size_regression.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Checks the absolute size and the relative size increase of a file. 4 | 5 | MAX_SIZE=7300000 # 7.3MB 6 | MAX_PERC=2.0 7 | 8 | if [ "$(uname)" == "Darwin" ] 9 | then 10 | SIZE1=$(stat -f "%z" "$1") 11 | SIZE2=$(stat -f "%z" "$2") 12 | else 13 | SIZE1=$(stat -c "%s" "$1") 14 | SIZE2=$(stat -c "%s" "$2") 15 | fi 16 | PERC=$(bc <<< "scale=2; ($SIZE2 - $SIZE1)/$SIZE1 * 100") 17 | 18 | echo "The new binary is $PERC % different in size compared to main." 19 | echo "The new binary is $SIZE2 bytes." 20 | 21 | if [ "$SIZE2" -gt $MAX_SIZE ] 22 | then 23 | echo "The current size ($SIZE2) is larger than the maximum size ($MAX_SIZE)." 24 | exit 1 25 | fi 26 | 27 | if [ "$(bc <<< "scale=2; $PERC >= $MAX_PERC")" -eq 1 ] 28 | then 29 | echo "The percentage increase ($PERC) is larger then the maximum percentage increase ($MAX_PERC)." 30 | exit 1 31 | fi 32 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Envoy Mobile docs 2 | 3 | Envoy Mobile's docs are generated using [Sphinx](http://www.sphinx-doc.org), 4 | and are published 5 | [here](https://envoymobile.io/docs/envoy-mobile/latest/index.html). 6 | 7 | ## Generating docs locally 8 | 9 | To generate the docs locally, run: 10 | 11 | ```bash 12 | ./docs/build.sh 13 | ``` 14 | 15 | The output can be then be found in `generated/docs`. 16 | 17 | ## Updating the Envoy Mobile website and docs 18 | 19 | The docs website is automatically updated with the latest docs when a commit is 20 | merged to main. This is done via the [publish script](./publish.sh). 21 | -------------------------------------------------------------------------------- /docs/root/_static/css/envoy.css: -------------------------------------------------------------------------------- 1 | @import "theme.css"; 2 | 3 | /* Splits a long line descriptions in tables in to multiple lines */ 4 | .wy-table-responsive table td, .wy-table-responsive table th { 5 | white-space: normal !important; 6 | } 7 | 8 | /* align multi line csv table columns */ 9 | table.docutils div.line-block { 10 | margin-left: 0; 11 | } 12 | -------------------------------------------------------------------------------- /docs/root/api/api.rst: -------------------------------------------------------------------------------- 1 | API 2 | === 3 | 4 | Envoy Mobile's public API is outlined in this section. 5 | 6 | Consistency between platforms is an explicit goal of Envoy Mobile. As such, the documentation 7 | provided is grouped by feature and provides examples for both iOS and Android in each section. 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | 12 | starting_envoy 13 | http 14 | grpc 15 | stats 16 | -------------------------------------------------------------------------------- /docs/root/development/debugging/images/add-project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envoyproxy/envoy-mobile/a9ce5f854d789a9d95d53f8ed3a0f3e4013b7671/docs/root/development/debugging/images/add-project.png -------------------------------------------------------------------------------- /docs/root/development/debugging/images/bazel-sync.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envoyproxy/envoy-mobile/a9ce5f854d789a9d95d53f8ed3a0f3e4013b7671/docs/root/development/debugging/images/bazel-sync.png -------------------------------------------------------------------------------- /docs/root/development/debugging/images/environment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envoyproxy/envoy-mobile/a9ce5f854d789a9d95d53f8ed3a0f3e4013b7671/docs/root/development/debugging/images/environment.png -------------------------------------------------------------------------------- /docs/root/development/debugging/images/final-step-project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envoyproxy/envoy-mobile/a9ce5f854d789a9d95d53f8ed3a0f3e4013b7671/docs/root/development/debugging/images/final-step-project.png -------------------------------------------------------------------------------- /docs/root/development/debugging/images/import-project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envoyproxy/envoy-mobile/a9ce5f854d789a9d95d53f8ed3a0f3e4013b7671/docs/root/development/debugging/images/import-project.png -------------------------------------------------------------------------------- /docs/root/development/debugging/images/instruments.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envoyproxy/envoy-mobile/a9ce5f854d789a9d95d53f8ed3a0f3e4013b7671/docs/root/development/debugging/images/instruments.jpg -------------------------------------------------------------------------------- /docs/root/development/debugging/images/select-em.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envoyproxy/envoy-mobile/a9ce5f854d789a9d95d53f8ed3a0f3e4013b7671/docs/root/development/debugging/images/select-em.png -------------------------------------------------------------------------------- /docs/root/development/debugging/images/xcode_breakpoint.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envoyproxy/envoy-mobile/a9ce5f854d789a9d95d53f8ed3a0f3e4013b7671/docs/root/development/debugging/images/xcode_breakpoint.jpg -------------------------------------------------------------------------------- /docs/root/development/development.rst: -------------------------------------------------------------------------------- 1 | .. _dev: 2 | 3 | Development 4 | =========== 5 | 6 | This section of the docs describes information useful to engineers actively 7 | developing Envoy Mobile. 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | 12 | performance/performance 13 | releasing/releasing 14 | testing/testing 15 | tools/tools 16 | debugging/android_local 17 | debugging/ios_local 18 | -------------------------------------------------------------------------------- /docs/root/development/performance/performance.rst: -------------------------------------------------------------------------------- 1 | .. _dev_performance: 2 | 3 | Performance analysis 4 | ==================== 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | binary_size 10 | cpu_battery_impact 11 | device_connectivity 12 | vpn_analysis 13 | 14 | Performance analysis can take several shapes in mobile applications. These docs 15 | describe the process (tools, analysis, measurements) that the Envoy Mobile team 16 | uses in their performance investigations. These docs serve as a common ground 17 | so that any person running analyses can use the same platform in order to 18 | effectively advance their results. 19 | -------------------------------------------------------------------------------- /docs/root/development/testing/custom_envoy.rst: -------------------------------------------------------------------------------- 1 | .. _testing_custom_envoy: 2 | 3 | Custom Envoy 4 | ============ 5 | 6 | For some changes, it's helpful to test with changes to the envoy module, either to add additional 7 | information or verify that an upstream change will work well for Envoy Mobile. 8 | 9 | For local test runs, you can simply ``cd envoy`` and make changes. These changes will 10 | not be reflected when you create a draft pull request so can not be used to verify 11 | that the Envoy Mobile build bots will pass. 12 | 13 | To test Envoy changes against CI, make those changes in your Envoy repo, push that branch to GitHub 14 | and change the ``.gitmodules`` file in the Envoy Mobile repo to point to your Envoy branch like so:: 15 | 16 | 17 | [submodule "envoy"] 18 | path = envoy 19 | url = https://github.com/[githubid]/envoy.git 20 | branch = [branch name] 21 | 22 | You should then be able to test the changes locally with ``git submodule update --init`` 23 | as well as remotely. 24 | -------------------------------------------------------------------------------- /docs/root/development/tools/tools.rst: -------------------------------------------------------------------------------- 1 | .. _development_tools: 2 | 3 | Development Tools 4 | ================= 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | intellij 10 | 11 | This documentation outlines additional tools that may prove useful when 12 | developing Envoy Mobile. 13 | -------------------------------------------------------------------------------- /docs/root/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envoyproxy/envoy-mobile/a9ce5f854d789a9d95d53f8ed3a0f3e4013b7671/docs/root/favicon.ico -------------------------------------------------------------------------------- /docs/root/index.rst: -------------------------------------------------------------------------------- 1 | Envoy Mobile Documentation 2 | ========================== 3 | 4 | .. ifconfig:: release_level in ('pre-release') 5 | 6 | .. attention:: 7 | 8 | This is pre-release documentation. There is risk of it not being consistent with what is 9 | currently implemented in Envoy Mobile, though we try to make things consistent as quickly as 10 | possible. 11 | 12 | .. toctree:: 13 | :maxdepth: 2 14 | 15 | intro/intro 16 | start/start 17 | api/api 18 | development/development 19 | -------------------------------------------------------------------------------- /docs/root/intro/getting_help.rst: -------------------------------------------------------------------------------- 1 | .. _getting_help: 2 | 3 | Getting help 4 | ============ 5 | 6 | We are very interested in building a community around Envoy Mobile. Please reach out to us if you 7 | are interested in using it and need help or want to contribute. 8 | 9 | Please see `contact info `_. 10 | -------------------------------------------------------------------------------- /docs/root/intro/intro.rst: -------------------------------------------------------------------------------- 1 | .. _intro: 2 | 3 | Introduction 4 | ============ 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | what_is_envoy_mobile 10 | comparison 11 | getting_help 12 | version_history 13 | additional_resources 14 | -------------------------------------------------------------------------------- /docs/root/start/start.rst: -------------------------------------------------------------------------------- 1 | .. _start: 2 | 3 | Getting Started 4 | =============== 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | ../api/api 10 | building/building 11 | examples/hello_world 12 | -------------------------------------------------------------------------------- /envoy_build_config/WORKSPACE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envoyproxy/envoy-mobile/a9ce5f854d789a9d95d53f8ed3a0f3e4013b7671/envoy_build_config/WORKSPACE -------------------------------------------------------------------------------- /envoy_build_config/extension_registry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Envoy { 4 | class ExtensionRegistry { 5 | public: 6 | // As a server, Envoy's static factory registration happens when main is run. However, when 7 | // compiled as a library, there is no guarantee that such registration will happen before the 8 | // names are needed. The following calls ensure that registration happens before the entities are 9 | // needed. Note that as more registrations are needed, explicit initialization calls will need to 10 | // be added here. 11 | static void registerFactories(); 12 | }; 13 | } // namespace Envoy 14 | -------------------------------------------------------------------------------- /envoy_build_config/extension_registry_apple.cc: -------------------------------------------------------------------------------- 1 | #include "source/extensions/network/dns_resolver/apple/apple_dns_impl.h" 2 | 3 | #include "extension_registry_platform_additions.h" 4 | 5 | namespace Envoy { 6 | 7 | void ExtensionRegistryPlatformAdditions::registerFactories() { 8 | Envoy::Network::forceRegisterAppleDnsResolverFactory(); 9 | } 10 | 11 | } // namespace Envoy 12 | -------------------------------------------------------------------------------- /envoy_build_config/extension_registry_noop.cc: -------------------------------------------------------------------------------- 1 | #include "extension_registry_platform_additions.h" 2 | 3 | namespace Envoy { 4 | 5 | void ExtensionRegistryPlatformAdditions::registerFactories() {} 6 | 7 | } // namespace Envoy 8 | -------------------------------------------------------------------------------- /envoy_build_config/extension_registry_platform_additions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Envoy { 4 | class ExtensionRegistryPlatformAdditions { 5 | public: 6 | // As a server, Envoy's static factory registration happens when main is run. However, when 7 | // compiled as a library, there is no guarantee that such registration will happen before the 8 | // names are needed. The following calls ensure that registration happens before the entities are 9 | // needed. Note that as more registrations are needed, explicit initialization calls will need to 10 | // be added here. 11 | static void registerFactories(); 12 | }; 13 | } // namespace Envoy 14 | -------------------------------------------------------------------------------- /examples/java/hello_world/.bazelproject: -------------------------------------------------------------------------------- 1 | workspace_type: android 2 | 3 | bazel_binary: bazelw 4 | 5 | directories: 6 | -bazel-bin 7 | -bazel-instant-android 8 | -bazel-out 9 | -bazel-testlogs 10 | -buck-out 11 | -build 12 | examples/java/hello_world 13 | 14 | import_run_configurations: 15 | examples/java/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_x86.xml 16 | examples/java/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_arm64.xml 17 | 18 | targets: 19 | //examples/java/hello_world:hello_envoy 20 | 21 | additional_languages: 22 | kotlin 23 | java 24 | android 25 | c 26 | -------------------------------------------------------------------------------- /examples/java/hello_world/EmptyFile.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile.helloenvoy 2 | -------------------------------------------------------------------------------- /examples/java/hello_world/README.md: -------------------------------------------------------------------------------- 1 | For instructions on how to use this demo, please head over to our [docs](https://envoymobile.io/docs/envoy-mobile/latest/start/examples/hello_world.html). 2 | -------------------------------------------------------------------------------- /examples/java/hello_world/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /examples/kotlin/hello_world/.bazelproject: -------------------------------------------------------------------------------- 1 | workspace_type: android 2 | 3 | bazel_binary: bazelw 4 | 5 | directories: 6 | -bazel-bin 7 | -bazel-instant-android 8 | -bazel-out 9 | -bazel-testlogs 10 | -buck-out 11 | -build 12 | examples/kotlin/hello_world 13 | 14 | import_run_configurations: 15 | examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_x86.xml 16 | examples/kotlin/hello_world/tools/android-studio-run-configurations/run_configuration_example_debug_arm64.xml 17 | 18 | targets: 19 | //examples/kotlin/hello_world:hello_envoy_kt 20 | 21 | additional_languages: 22 | kotlin 23 | java 24 | android 25 | c 26 | -------------------------------------------------------------------------------- /examples/kotlin/hello_world/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 11 | 12 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /examples/kotlin/hello_world/README.md: -------------------------------------------------------------------------------- 1 | For instructions on how to use this demo, please head over to our [docs](https://envoymobile.io/docs/envoy-mobile/latest/start/examples/hello_world.html). 2 | -------------------------------------------------------------------------------- /examples/kotlin/hello_world/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /examples/kotlin/shared/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /examples/kotlin/shared/BUILD: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_kotlin//kotlin:android.bzl", "kt_android_library") 2 | load("@rules_jvm_external//:defs.bzl", "artifact") 3 | 4 | licenses(["notice"]) # Apache 2 5 | 6 | kt_android_library( 7 | name = "hello_envoy_shared_lib", 8 | srcs = [ 9 | "Response.kt", 10 | "ResponseRecyclerViewAdapter.kt", 11 | "ResponseViewHolder.kt", 12 | ], 13 | custom_package = "io.envoyproxy.envoymobile.shared", 14 | manifest = "AndroidManifest.xml", 15 | resource_files = glob([ 16 | "res/layout/item.xml", 17 | "res/values/colors.xml", 18 | "res/values/strings.xml", 19 | ]), 20 | visibility = ["//visibility:public"], 21 | deps = [ 22 | artifact("androidx.recyclerview:recyclerview"), 23 | ], 24 | ) 25 | -------------------------------------------------------------------------------- /examples/kotlin/shared/Response.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile.shared 2 | 3 | // Response is a class to handle HTTP responses. 4 | sealed class Response { 5 | fun fold(success: (Success) -> Unit, failure: (Failure) -> Unit) = when (this) { 6 | is Success -> success(this) 7 | is Failure -> failure(this) 8 | } 9 | } 10 | 11 | data class Success(val title: String, val header: String) : Response() 12 | 13 | data class Failure(val message: String) : Response() 14 | -------------------------------------------------------------------------------- /examples/kotlin/shared/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ffffff 4 | #ff3651 5 | 6 | -------------------------------------------------------------------------------- /examples/kotlin/shared/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Response: %s 4 | %s 5 | 6 | -------------------------------------------------------------------------------- /examples/objective-c/hello_world/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface AppDelegate : UIResponder 4 | 5 | @property (strong, nonatomic) UIWindow *window; 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /examples/objective-c/hello_world/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | #import 3 | #import "ViewController.h" 4 | 5 | @implementation AppDelegate 6 | 7 | - (BOOL)application:(UIApplication *)application 8 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 9 | UIViewController *controller = [ViewController new]; 10 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 11 | [self.window setRootViewController:controller]; 12 | [self.window makeKeyAndVisible]; 13 | 14 | NSLog(@"Finished launching!"); 15 | return YES; 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /examples/objective-c/hello_world/BUILD: -------------------------------------------------------------------------------- 1 | load("//bazel:config.bzl", "MINIMUM_IOS_VERSION") 2 | load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application") 3 | 4 | licenses(["notice"]) # Apache 2 5 | 6 | objc_library( 7 | name = "appmain", 8 | srcs = glob([ 9 | "*.h", 10 | "*.m", 11 | ]), 12 | deps = ["//:envoy_mobile_ios"], 13 | ) 14 | 15 | ios_application( 16 | name = "app", 17 | bundle_id = "io.envoyproxy.envoymobile.helloworld", 18 | families = ["iphone"], 19 | infoplists = ["Info.plist"], 20 | minimum_os_version = MINIMUM_IOS_VERSION, 21 | provisioning_profile = select({ 22 | "@envoy//bazel:ios_arm64": "//examples:ios_provisioning_profile", 23 | "//conditions:default": None, 24 | }), 25 | visibility = ["//visibility:public"], 26 | deps = ["appmain"], 27 | ) 28 | -------------------------------------------------------------------------------- /examples/objective-c/hello_world/README.md: -------------------------------------------------------------------------------- 1 | For instructions on how to use this demo, please head over to our [docs](https://envoymobile.io/docs/envoy-mobile/latest/start/examples/hello_world.html). 2 | -------------------------------------------------------------------------------- /examples/objective-c/hello_world/Result.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | /// Represents a response from the server or an error. 4 | @interface Result : NSObject 5 | @property (nonatomic, strong) NSString *message; 6 | @property (nonatomic, strong) NSString *headerMessage; 7 | @property (nonatomic, strong) NSString *error; 8 | @end 9 | -------------------------------------------------------------------------------- /examples/objective-c/hello_world/Result.m: -------------------------------------------------------------------------------- 1 | #import "Result.h" 2 | 3 | @implementation Result 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /examples/objective-c/hello_world/ViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface ViewController : UITableViewController 4 | @end 5 | -------------------------------------------------------------------------------- /examples/objective-c/hello_world/main.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | int main(int argc, char *argv[]) { 4 | @autoreleasepool { 5 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /examples/swift/async_await/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | import UIKit 3 | 4 | @UIApplicationMain 5 | final class AppDelegate: UIResponder, UIApplicationDelegate { 6 | var window: UIWindow? 7 | 8 | func application( 9 | _ application: UIApplication, 10 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool 11 | { 12 | let window = UIWindow(frame: UIScreen.main.bounds) 13 | window.rootViewController = UIHostingController(rootView: ContentView()) 14 | window.makeKeyAndVisible() 15 | self.window = window 16 | return true 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/swift/async_await/BUILD: -------------------------------------------------------------------------------- 1 | load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application") 2 | load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") 3 | 4 | licenses(["notice"]) # Apache 2 5 | 6 | swift_library( 7 | name = "appmain", 8 | srcs = glob(["*.swift"]), 9 | deps = ["//library/swift:ios_lib"], 10 | ) 11 | 12 | ios_application( 13 | name = "app", 14 | bundle_id = "io.envoyproxy.envoymobile.asyncawait", 15 | families = ["iphone"], 16 | infoplists = ["Info.plist"], 17 | minimum_os_version = "15.0", 18 | provisioning_profile = select({ 19 | "@envoy//bazel:ios_arm64": "//examples:ios_provisioning_profile", 20 | "//conditions:default": None, 21 | }), 22 | visibility = ["//visibility:public"], 23 | deps = ["appmain"], 24 | ) 25 | -------------------------------------------------------------------------------- /examples/swift/hello_world/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | @UIApplicationMain 4 | final class AppDelegate: UIResponder, UIApplicationDelegate { 5 | var window: UIWindow? 6 | 7 | func application( 8 | _ application: UIApplication, 9 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool 10 | { 11 | let window = UIWindow(frame: UIScreen.main.bounds) 12 | window.rootViewController = ViewController() 13 | window.makeKeyAndVisible() 14 | self.window = window 15 | 16 | NSLog("Finished launching!") 17 | return true 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/swift/hello_world/BUILD: -------------------------------------------------------------------------------- 1 | load("//bazel:config.bzl", "MINIMUM_IOS_VERSION") 2 | load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application") 3 | load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") 4 | 5 | licenses(["notice"]) # Apache 2 6 | 7 | swift_library( 8 | name = "appmain", 9 | srcs = glob(["*.swift"]), 10 | deps = ["//library/swift:ios_lib"], 11 | ) 12 | 13 | ios_application( 14 | name = "app", 15 | bundle_id = "io.envoyproxy.envoymobile.helloworld", 16 | families = ["iphone"], 17 | infoplists = ["Info.plist"], 18 | minimum_os_version = MINIMUM_IOS_VERSION, 19 | provisioning_profile = select({ 20 | "@envoy//bazel:ios_arm64": "//examples:ios_provisioning_profile", 21 | "//conditions:default": None, 22 | }), 23 | visibility = ["//visibility:public"], 24 | deps = ["appmain"], 25 | ) 26 | -------------------------------------------------------------------------------- /examples/swift/hello_world/README.md: -------------------------------------------------------------------------------- 1 | For instructions on how to use this demo, please head over to our [docs](https://envoymobile.io/docs/envoy-mobile/latest/start/examples/hello_world.html). 2 | -------------------------------------------------------------------------------- /examples/swift/hello_world/ResponseModels.swift: -------------------------------------------------------------------------------- 1 | /// Represents a response from the server. 2 | struct Response { 3 | let message: String 4 | let headerMessage: String 5 | } 6 | 7 | /// Error that was encountered when executing a request. 8 | struct RequestError: Error { 9 | let message: String 10 | } 11 | -------------------------------------------------------------------------------- /examples/swift/swiftpm/EnvoySwiftPMExample/EnvoySwiftPMExampleApp.swift: -------------------------------------------------------------------------------- 1 | import SwiftUI 2 | 3 | @main 4 | struct EnvoySwiftPMExampleApp: App { 5 | var body: some Scene { 6 | WindowGroup { 7 | ContentView() 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /experimental/swift/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy_mobile//bazel:apple_test.bzl", "envoy_mobile_swift_test") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_mobile_swift_test( 6 | name = "quic_stream_test", 7 | srcs = [ 8 | "QUICStreamTest.swift", 9 | ], 10 | data = [ 11 | "@envoy//test/config/integration/certs", 12 | ], 13 | visibility = ["//visibility:public"], 14 | deps = [ 15 | "//library/objective-c:envoy_engine_objc_lib", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /library/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) # Apache 2 2 | 3 | filegroup( 4 | name = "proguard_rules", 5 | srcs = ["proguard.txt"], 6 | visibility = ["//visibility:public"], 7 | ) 8 | -------------------------------------------------------------------------------- /library/cc/bridge_utility.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "headers.h" 7 | #include "library/common/types/c_types.h" 8 | 9 | namespace Envoy { 10 | namespace Platform { 11 | 12 | envoy_headers rawHeaderMapAsEnvoyHeaders(const RawHeaderMap& headers); 13 | RawHeaderMap envoyHeadersAsRawHeaderMap(envoy_headers raw_headers); 14 | 15 | } // namespace Platform 16 | } // namespace Envoy 17 | -------------------------------------------------------------------------------- /library/cc/engine_callbacks.cc: -------------------------------------------------------------------------------- 1 | #include "engine_callbacks.h" 2 | 3 | namespace Envoy { 4 | namespace Platform { 5 | 6 | namespace { 7 | 8 | void c_on_engine_running(void* context) { 9 | auto engine_callbacks = *static_cast(context); 10 | engine_callbacks->on_engine_running(); 11 | } 12 | 13 | void c_on_exit(void* context) { 14 | auto engine_callbacks_ptr = static_cast(context); 15 | delete engine_callbacks_ptr; 16 | } 17 | 18 | } // namespace 19 | 20 | envoy_engine_callbacks EngineCallbacks::asEnvoyEngineCallbacks() { 21 | return envoy_engine_callbacks{ 22 | &c_on_engine_running, 23 | &c_on_exit, 24 | new EngineCallbacksSharedPtr(shared_from_this()), 25 | }; 26 | } 27 | 28 | } // namespace Platform 29 | } // namespace Envoy 30 | -------------------------------------------------------------------------------- /library/cc/engine_callbacks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "engine.h" 7 | #include "library/common/types/c_types.h" 8 | 9 | namespace Envoy { 10 | namespace Platform { 11 | 12 | struct EngineCallbacks : public std::enable_shared_from_this { 13 | std::function on_engine_running; 14 | // unused: 15 | // std::function on_exit; 16 | 17 | envoy_engine_callbacks asEnvoyEngineCallbacks(); 18 | }; 19 | 20 | using EngineCallbacksSharedPtr = std::shared_ptr; 21 | 22 | } // namespace Platform 23 | } // namespace Envoy 24 | -------------------------------------------------------------------------------- /library/cc/envoy_error.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "absl/types/optional.h" 9 | #include "library/common/types/c_types.h" 10 | 11 | namespace Envoy { 12 | namespace Platform { 13 | 14 | struct EnvoyError { 15 | envoy_error_code_t error_code; 16 | std::string message; 17 | absl::optional attempt_count; 18 | absl::optional cause; 19 | }; 20 | 21 | using EnvoyErrorSharedPtr = std::shared_ptr; 22 | 23 | } // namespace Platform 24 | } // namespace Envoy 25 | -------------------------------------------------------------------------------- /library/cc/headers.cc: -------------------------------------------------------------------------------- 1 | #include "headers.h" 2 | 3 | namespace Envoy { 4 | namespace Platform { 5 | 6 | Headers::const_iterator Headers::begin() const { 7 | return Headers::const_iterator(this->allHeaders().begin()); 8 | } 9 | 10 | Headers::const_iterator Headers::end() const { 11 | return Headers::const_iterator(this->allHeaders().end()); 12 | } 13 | 14 | const std::vector& Headers::operator[](const std::string& key) const { 15 | return this->headers_.at(key); 16 | } 17 | 18 | const RawHeaderMap& Headers::allHeaders() const { return this->headers_; } 19 | 20 | bool Headers::contains(const std::string& key) const { return this->headers_.contains(key); } 21 | 22 | Headers::Headers(const RawHeaderMap& headers) : headers_(headers) {} 23 | 24 | } // namespace Platform 25 | } // namespace Envoy 26 | -------------------------------------------------------------------------------- /library/cc/headers_builder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "headers.h" 4 | 5 | namespace Envoy { 6 | namespace Platform { 7 | 8 | class HeadersBuilder { 9 | public: 10 | virtual ~HeadersBuilder() {} 11 | 12 | HeadersBuilder& add(std::string name, std::string value); 13 | HeadersBuilder& set(std::string name, std::vector values); 14 | HeadersBuilder& remove(const std::string& name); 15 | 16 | protected: 17 | HeadersBuilder(); 18 | HeadersBuilder& internalSet(std::string name, std::vector values); 19 | const RawHeaderMap& allHeaders() const; 20 | 21 | private: 22 | bool isRestrictedHeader(absl::string_view name) const; 23 | 24 | RawHeaderMap headers_; 25 | }; 26 | 27 | } // namespace Platform 28 | } // namespace Envoy 29 | -------------------------------------------------------------------------------- /library/cc/log_level.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "source/common/common/base_logger.h" 6 | 7 | namespace Envoy { 8 | namespace Platform { 9 | 10 | using LogLevel = Envoy::Logger::Logger::Levels; 11 | 12 | std::string logLevelToString(LogLevel method); 13 | LogLevel logLevelFromString(const std::string& str); 14 | 15 | } // namespace Platform 16 | } // namespace Envoy 17 | -------------------------------------------------------------------------------- /library/cc/pulse_client.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Envoy { 6 | namespace Platform { 7 | 8 | // TODO(crockeo): although this is stubbed out since it's in the main directory, it depends on 9 | // objects defined under stats. this will not be fully stubbed until stats is stubbed 10 | 11 | class PulseClient { 12 | public: 13 | // TODO: when these are commented out, you're going to have to 14 | // #include "envoy/common/pure.h" 15 | // 16 | // virtual Counter counter(Element element) PURE; 17 | // virtual Gauge gauge(Element element) PURE; 18 | }; 19 | 20 | using PulseClientSharedPtr = std::shared_ptr; 21 | 22 | } // namespace Platform 23 | } // namespace Envoy 24 | -------------------------------------------------------------------------------- /library/cc/request_headers_builder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "headers_builder.h" 6 | #include "request_headers.h" 7 | #include "request_method.h" 8 | #include "retry_policy.h" 9 | #include "upstream_http_protocol.h" 10 | 11 | namespace Envoy { 12 | namespace Platform { 13 | 14 | class RequestHeaders; 15 | struct RetryPolicy; 16 | 17 | class RequestHeadersBuilder : public HeadersBuilder { 18 | public: 19 | RequestHeadersBuilder(RequestMethod request_method, std::string scheme, std::string authority, 20 | std::string path); 21 | 22 | RequestHeadersBuilder& addRetryPolicy(const RetryPolicy& retry_policy); 23 | RequestHeadersBuilder& addUpstreamHttpProtocol(UpstreamHttpProtocol upstream_http_protocol); 24 | 25 | RequestHeaders build() const; 26 | }; 27 | 28 | using RequestHeadersBuilderSharedPtr = std::shared_ptr; 29 | 30 | } // namespace Platform 31 | } // namespace Envoy 32 | -------------------------------------------------------------------------------- /library/cc/request_method.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Envoy { 6 | namespace Platform { 7 | 8 | enum RequestMethod { 9 | DELETE, 10 | GET, 11 | HEAD, 12 | OPTIONS, 13 | PATCH, 14 | POST, 15 | PUT, 16 | TRACE, 17 | }; 18 | 19 | std::string requestMethodToString(RequestMethod method); 20 | RequestMethod requestMethodFromString(const std::string& str); 21 | 22 | } // namespace Platform 23 | } // namespace Envoy 24 | -------------------------------------------------------------------------------- /library/cc/request_trailers.cc: -------------------------------------------------------------------------------- 1 | #include "request_trailers.h" 2 | 3 | namespace Envoy { 4 | namespace Platform { 5 | 6 | RequestTrailersBuilder RequestTrailers::toRequestTrailersBuilder() const { 7 | RequestTrailersBuilder builder; 8 | for (const auto& pair : this->allHeaders()) { 9 | builder.set(pair.first, pair.second); 10 | } 11 | return builder; 12 | } 13 | 14 | } // namespace Platform 15 | } // namespace Envoy 16 | -------------------------------------------------------------------------------- /library/cc/request_trailers.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "request_trailers_builder.h" 4 | #include "trailers.h" 5 | 6 | namespace Envoy { 7 | namespace Platform { 8 | 9 | class RequestTrailersBuilder; 10 | 11 | class RequestTrailers : public Trailers { 12 | public: 13 | RequestTrailersBuilder toRequestTrailersBuilder() const; 14 | 15 | private: 16 | RequestTrailers(RawHeaderMap headers) : Trailers(std::move(headers)) {} 17 | 18 | friend class RequestTrailersBuilder; 19 | }; 20 | 21 | using RequestTrailersSharedPtr = std::shared_ptr; 22 | 23 | } // namespace Platform 24 | } // namespace Envoy 25 | -------------------------------------------------------------------------------- /library/cc/request_trailers_builder.cc: -------------------------------------------------------------------------------- 1 | #include "request_trailers_builder.h" 2 | 3 | namespace Envoy { 4 | namespace Platform { 5 | 6 | RequestTrailers RequestTrailersBuilder::build() const { 7 | return RequestTrailers(this->allHeaders()); 8 | } 9 | 10 | } // namespace Platform 11 | } // namespace Envoy 12 | -------------------------------------------------------------------------------- /library/cc/request_trailers_builder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "headers_builder.h" 4 | #include "request_trailers.h" 5 | 6 | namespace Envoy { 7 | namespace Platform { 8 | 9 | class RequestTrailers; 10 | 11 | class RequestTrailersBuilder : public HeadersBuilder { 12 | public: 13 | RequestTrailersBuilder() : HeadersBuilder() {} 14 | 15 | RequestTrailers build() const; 16 | }; 17 | 18 | using RequestTrailersBuilderSharedPtr = std::shared_ptr; 19 | 20 | } // namespace Platform 21 | } // namespace Envoy 22 | -------------------------------------------------------------------------------- /library/cc/response_headers.cc: -------------------------------------------------------------------------------- 1 | #include "response_headers.h" 2 | 3 | namespace Envoy { 4 | namespace Platform { 5 | 6 | int ResponseHeaders::httpStatus() const { 7 | if (!this->contains(":status")) { 8 | throw std::logic_error("ResponseHeaders does not contain :status"); 9 | } 10 | return stoi((*this)[":status"][0]); 11 | } 12 | 13 | ResponseHeadersBuilder ResponseHeaders::toResponseHeadersBuilder() { 14 | ResponseHeadersBuilder builder; 15 | if (this->contains(":status")) { 16 | builder.addHttpStatus(this->httpStatus()); 17 | } 18 | for (const auto& pair : this->allHeaders()) { 19 | builder.set(pair.first, pair.second); 20 | } 21 | return builder; 22 | } 23 | 24 | } // namespace Platform 25 | } // namespace Envoy 26 | -------------------------------------------------------------------------------- /library/cc/response_headers.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "headers.h" 4 | #include "response_headers_builder.h" 5 | 6 | namespace Envoy { 7 | namespace Platform { 8 | 9 | class ResponseHeadersBuilder; 10 | 11 | class ResponseHeaders : public Headers { 12 | public: 13 | int httpStatus() const; 14 | 15 | ResponseHeadersBuilder toResponseHeadersBuilder(); 16 | 17 | private: 18 | ResponseHeaders(RawHeaderMap headers) : Headers(std::move(headers)) {} 19 | 20 | friend class ResponseHeadersBuilder; 21 | }; 22 | 23 | using ResponseHeadersSharedPtr = std::shared_ptr; 24 | 25 | } // namespace Platform 26 | } // namespace Envoy 27 | -------------------------------------------------------------------------------- /library/cc/response_headers_builder.cc: -------------------------------------------------------------------------------- 1 | #include "response_headers_builder.h" 2 | 3 | namespace Envoy { 4 | namespace Platform { 5 | 6 | ResponseHeadersBuilder& ResponseHeadersBuilder::addHttpStatus(int status) { 7 | this->internalSet(":status", std::vector{std::to_string(status)}); 8 | return *this; 9 | } 10 | 11 | ResponseHeadersSharedPtr ResponseHeadersBuilder::build() const { 12 | ResponseHeaders* headers = new ResponseHeaders(this->allHeaders()); 13 | return ResponseHeadersSharedPtr(headers); 14 | } 15 | 16 | } // namespace Platform 17 | } // namespace Envoy 18 | -------------------------------------------------------------------------------- /library/cc/response_headers_builder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "headers_builder.h" 4 | #include "response_headers.h" 5 | 6 | namespace Envoy { 7 | namespace Platform { 8 | 9 | class ResponseHeaders; 10 | using ResponseHeadersSharedPtr = std::shared_ptr; 11 | 12 | class ResponseHeadersBuilder : public HeadersBuilder { 13 | public: 14 | ResponseHeadersBuilder() {} 15 | 16 | ResponseHeadersBuilder& addHttpStatus(int status); 17 | ResponseHeadersSharedPtr build() const; 18 | }; 19 | 20 | using ResponseHeadersBuilderSharedPtr = std::shared_ptr; 21 | 22 | } // namespace Platform 23 | } // namespace Envoy 24 | -------------------------------------------------------------------------------- /library/cc/response_trailers.cc: -------------------------------------------------------------------------------- 1 | #include "response_trailers.h" 2 | 3 | namespace Envoy { 4 | namespace Platform { 5 | 6 | ResponseTrailersBuilder ResponseTrailers::toResponseTrailersBuilder() { 7 | ResponseTrailersBuilder builder; 8 | for (const auto& pair : this->allHeaders()) { 9 | builder.set(pair.first, pair.second); 10 | } 11 | return builder; 12 | } 13 | 14 | } // namespace Platform 15 | } // namespace Envoy 16 | -------------------------------------------------------------------------------- /library/cc/response_trailers.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "response_trailers_builder.h" 4 | #include "trailers.h" 5 | 6 | namespace Envoy { 7 | namespace Platform { 8 | 9 | class ResponseTrailersBuilder; 10 | 11 | class ResponseTrailers : public Trailers { 12 | public: 13 | ResponseTrailersBuilder toResponseTrailersBuilder(); 14 | 15 | private: 16 | ResponseTrailers(RawHeaderMap trailers) : Trailers(std::move(trailers)) {} 17 | 18 | friend class ResponseTrailersBuilder; 19 | }; 20 | 21 | using ResponseTrailersSharedPtr = std::shared_ptr; 22 | 23 | } // namespace Platform 24 | } // namespace Envoy 25 | -------------------------------------------------------------------------------- /library/cc/response_trailers_builder.cc: -------------------------------------------------------------------------------- 1 | #include "response_trailers_builder.h" 2 | 3 | namespace Envoy { 4 | namespace Platform { 5 | 6 | ResponseTrailersSharedPtr ResponseTrailersBuilder::build() const { 7 | ResponseTrailers* trailers = new ResponseTrailers(this->allHeaders()); 8 | return ResponseTrailersSharedPtr(trailers); 9 | } 10 | 11 | } // namespace Platform 12 | } // namespace Envoy 13 | -------------------------------------------------------------------------------- /library/cc/response_trailers_builder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "headers_builder.h" 4 | #include "response_trailers.h" 5 | 6 | namespace Envoy { 7 | namespace Platform { 8 | 9 | class ResponseTrailers; 10 | using ResponseTrailersSharedPtr = std::shared_ptr; 11 | 12 | class ResponseTrailersBuilder : public HeadersBuilder { 13 | public: 14 | ResponseTrailersBuilder() {} 15 | 16 | ResponseTrailersSharedPtr build() const; 17 | }; 18 | 19 | using ResponseTrailersBuilderSharedPtr = std::shared_ptr; 20 | 21 | } // namespace Platform 22 | } // namespace Envoy 23 | -------------------------------------------------------------------------------- /library/cc/stream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "library/common/types/c_types.h" 6 | #include "request_headers.h" 7 | #include "request_trailers.h" 8 | #include "stream_callbacks.h" 9 | 10 | namespace Envoy { 11 | namespace Platform { 12 | 13 | class Engine; 14 | using EngineSharedPtr = std::shared_ptr; 15 | 16 | class Stream { 17 | public: 18 | Stream(envoy_engine_t engine_handle, envoy_stream_t handle); 19 | 20 | Stream& sendHeaders(RequestHeadersSharedPtr headers, bool end_stream); 21 | Stream& sendData(envoy_data data); 22 | void close(RequestTrailersSharedPtr trailers); 23 | void close(envoy_data data); 24 | void cancel(); 25 | 26 | private: 27 | envoy_engine_t engine_handle_; 28 | envoy_stream_t handle_; 29 | }; 30 | 31 | using StreamSharedPtr = std::shared_ptr; 32 | 33 | } // namespace Platform 34 | } // namespace Envoy 35 | -------------------------------------------------------------------------------- /library/cc/stream_client.cc: -------------------------------------------------------------------------------- 1 | #include "stream_client.h" 2 | 3 | namespace Envoy { 4 | namespace Platform { 5 | 6 | StreamClient::StreamClient(EngineSharedPtr engine) : engine_(engine) {} 7 | 8 | StreamPrototypeSharedPtr StreamClient::newStreamPrototype() { 9 | return std::make_shared(this->engine_); 10 | } 11 | 12 | } // namespace Platform 13 | } // namespace Envoy 14 | -------------------------------------------------------------------------------- /library/cc/stream_client.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "engine.h" 6 | #include "stream_prototype.h" 7 | 8 | namespace Envoy { 9 | namespace Platform { 10 | 11 | class Engine; 12 | using EngineSharedPtr = std::shared_ptr; 13 | 14 | class StreamPrototype; 15 | using StreamPrototypeSharedPtr = std::shared_ptr; 16 | 17 | class StreamClient { 18 | public: 19 | StreamClient(EngineSharedPtr engine); 20 | 21 | StreamPrototypeSharedPtr newStreamPrototype(); 22 | 23 | private: 24 | EngineSharedPtr engine_; 25 | }; 26 | 27 | using StreamClientSharedPtr = std::shared_ptr; 28 | 29 | } // namespace Platform 30 | } // namespace Envoy 31 | -------------------------------------------------------------------------------- /library/cc/string_accessor.cc: -------------------------------------------------------------------------------- 1 | #include "library/cc/string_accessor.h" 2 | 3 | #include "library/common/data/utility.h" 4 | 5 | namespace Envoy { 6 | namespace Platform { 7 | 8 | namespace { 9 | 10 | envoy_data c_string_accessor_read(const void* context) { 11 | auto accessor = *static_cast(context); 12 | return Data::Utility::copyToBridgeData(accessor->get()); 13 | } 14 | 15 | } // namespace 16 | 17 | envoy_string_accessor StringAccessor::asEnvoyStringAccessor(StringAccessorSharedPtr accessor) { 18 | return envoy_string_accessor{&c_string_accessor_read, new StringAccessorSharedPtr(accessor)}; 19 | } 20 | 21 | } // namespace Platform 22 | } // namespace Envoy 23 | -------------------------------------------------------------------------------- /library/cc/trailers.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "headers.h" 4 | 5 | namespace Envoy { 6 | namespace Platform { 7 | 8 | class Trailers : public Headers { 9 | public: 10 | Trailers(const RawHeaderMap& headers) : Headers(headers) {} 11 | }; 12 | 13 | } // namespace Platform 14 | } // namespace Envoy 15 | -------------------------------------------------------------------------------- /library/cc/upstream_http_protocol.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Envoy { 6 | namespace Platform { 7 | 8 | enum UpstreamHttpProtocol { 9 | HTTP1, 10 | HTTP2, 11 | }; 12 | 13 | std::string upstreamHttpProtocolToString(UpstreamHttpProtocol method); 14 | UpstreamHttpProtocol upstreamHttpProtocolFromString(const std::string& str); 15 | 16 | } // namespace Platform 17 | } // namespace Envoy 18 | -------------------------------------------------------------------------------- /library/common/api/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_library( 8 | name = "external_api_lib", 9 | srcs = [ 10 | "external.cc", 11 | ], 12 | hdrs = [ 13 | "external.h", 14 | ], 15 | repository = "@envoy", 16 | visibility = ["//visibility:public"], 17 | deps = [ 18 | "@envoy//source/common/common:assert_lib", 19 | ], 20 | ) 21 | 22 | envoy_cc_library( 23 | name = "c_types", 24 | hdrs = ["c_types.h"], 25 | repository = "@envoy", 26 | deps = [ 27 | "//library/common/types:c_types_lib", 28 | ], 29 | ) 30 | -------------------------------------------------------------------------------- /library/common/api/c_types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "library/common/types/c_types.h" 4 | 5 | // NOLINT(namespace-envoy) 6 | 7 | #ifdef __cplusplus 8 | extern "C" { // function pointers 9 | #endif 10 | 11 | typedef envoy_data (*envoy_get_string_f)(const void* context); 12 | 13 | #ifdef __cplusplus 14 | } // function pointers 15 | #endif 16 | 17 | /** 18 | * Datatype used to access strings from the platform layer. This accessor is read-only. 19 | */ 20 | // TODO: https://github.com/envoyproxy/envoy-mobile/issues/1192 generalize to access arbitrary 21 | // types. 22 | typedef struct { 23 | envoy_get_string_f get_string; 24 | const void* context; 25 | } envoy_string_accessor; 26 | -------------------------------------------------------------------------------- /library/common/api/external.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Envoy { 6 | namespace Api { 7 | namespace External { 8 | 9 | /** 10 | * Register an external runtime API for usage (e.g. in extensions). 11 | */ 12 | void registerApi(std::string name, void* api); 13 | 14 | /** 15 | * Retrieve an external runtime API for usage (e.g. in extensions). 16 | */ 17 | void* retrieveApi(std::string name); 18 | 19 | } // namespace External 20 | } // namespace Api 21 | } // namespace Envoy 22 | -------------------------------------------------------------------------------- /library/common/bridge/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_library( 8 | name = "utility_lib", 9 | srcs = ["utility.cc"], 10 | hdrs = ["utility.h"], 11 | repository = "@envoy", 12 | visibility = ["//visibility:public"], 13 | deps = [ 14 | "//library/common/data:utility_lib", 15 | "//library/common/types:c_types_lib", 16 | "@envoy//envoy/http:codes_interface", 17 | "@envoy//source/common/http:codes_lib", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /library/common/bridge/utility.cc: -------------------------------------------------------------------------------- 1 | #include "library/common/bridge/utility.h" 2 | 3 | #include 4 | 5 | namespace Envoy { 6 | namespace Bridge { 7 | namespace Utility { 8 | 9 | envoy_error_code_t errorCodeFromLocalStatus(Http::Code status) { 10 | switch (status) { 11 | case Http::Code::RequestTimeout: 12 | return ENVOY_REQUEST_TIMEOUT; 13 | case Http::Code::PayloadTooLarge: 14 | return ENVOY_BUFFER_LIMIT_EXCEEDED; 15 | case Http::Code::ServiceUnavailable: 16 | return ENVOY_CONNECTION_FAILURE; 17 | default: 18 | return ENVOY_UNDEFINED_ERROR; 19 | } 20 | } 21 | 22 | envoy_map makeEnvoyMap(std::initializer_list> map) { 23 | return makeEnvoyMap>>(map); 24 | } 25 | 26 | } // namespace Utility 27 | } // namespace Bridge 28 | } // namespace Envoy 29 | -------------------------------------------------------------------------------- /library/common/buffer/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_library( 8 | name = "bridge_fragment_lib", 9 | hdrs = ["bridge_fragment.h"], 10 | repository = "@envoy", 11 | deps = [ 12 | "//library/common/types:c_types_lib", 13 | "@envoy//envoy/buffer:buffer_interface", 14 | ], 15 | ) 16 | -------------------------------------------------------------------------------- /library/common/common/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_library( 8 | name = "lambda_logger_delegate_lib", 9 | srcs = ["lambda_logger_delegate.cc"], 10 | hdrs = ["lambda_logger_delegate.h"], 11 | repository = "@envoy", 12 | deps = [ 13 | "//library/common/api:external_api_lib", 14 | "//library/common/bridge:utility_lib", 15 | "//library/common/data:utility_lib", 16 | "//library/common/types:c_types_lib", 17 | "@envoy//source/common/common:macros", 18 | "@envoy//source/common/common:minimal_logger_lib", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /library/common/config/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_library( 8 | name = "config_lib", 9 | srcs = [ 10 | "certificates.inc", 11 | "config.cc", 12 | ], 13 | hdrs = [ 14 | "internal.h", 15 | "templates.h", 16 | ], 17 | repository = "@envoy", 18 | deps = [ 19 | "@envoy//source/extensions/http/header_formatters/preserve_case:config", 20 | "@envoy//source/extensions/http/header_formatters/preserve_case:preserve_case_formatter", 21 | ], 22 | ) 23 | -------------------------------------------------------------------------------- /library/common/config/internal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // NOLINT(namespace-envoy) 6 | 7 | /** 8 | * Fixed config header used in internal processing. 9 | */ 10 | extern const std::string config_header; 11 | -------------------------------------------------------------------------------- /library/common/data/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_library( 8 | name = "utility_lib", 9 | srcs = ["utility.cc"], 10 | hdrs = ["utility.h"], 11 | repository = "@envoy", 12 | deps = [ 13 | "//library/common/buffer:bridge_fragment_lib", 14 | "//library/common/types:c_types_lib", 15 | "@envoy//envoy/buffer:buffer_interface", 16 | "@envoy//source/common/buffer:buffer_lib", 17 | "@envoy//source/common/common:empty_string", 18 | ], 19 | ) 20 | -------------------------------------------------------------------------------- /library/common/event/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_library( 8 | name = "provisional_dispatcher_lib", 9 | srcs = ["provisional_dispatcher.cc"], 10 | hdrs = ["provisional_dispatcher.h"], 11 | external_deps = ["abseil_optional"], 12 | repository = "@envoy", 13 | deps = [ 14 | "//library/common/thread:lock_guard_lib", 15 | "//library/common/types:c_types_lib", 16 | "@envoy//envoy/event:deferred_deletable", 17 | "@envoy//envoy/event:dispatcher_interface", 18 | "@envoy//source/common/common:lock_guard_lib", 19 | "@envoy//source/common/common:thread_synchronizer_lib", 20 | ], 21 | ) 22 | -------------------------------------------------------------------------------- /library/common/extensions/cert_validator/platform_bridge/config.cc: -------------------------------------------------------------------------------- 1 | #include "library/common/extensions/cert_validator/platform_bridge/config.h" 2 | 3 | #include "library/common/api/external.h" 4 | 5 | namespace Envoy { 6 | namespace Extensions { 7 | namespace TransportSockets { 8 | namespace Tls { 9 | 10 | CertValidatorPtr PlatformBridgeCertValidatorFactory::createCertValidator( 11 | const Envoy::Ssl::CertificateValidationContextConfig* config, SslStats& stats, 12 | TimeSource& /*time_source*/) { 13 | if (platform_validator_ == nullptr) { 14 | platform_validator_ = 15 | static_cast(Api::External::retrieveApi("platform_cert_validator")); 16 | } 17 | return std::make_unique(config, stats, platform_validator_); 18 | } 19 | 20 | REGISTER_FACTORY(PlatformBridgeCertValidatorFactory, CertValidatorFactory); 21 | 22 | } // namespace Tls 23 | } // namespace TransportSockets 24 | } // namespace Extensions 25 | } // namespace Envoy 26 | -------------------------------------------------------------------------------- /library/common/extensions/cert_validator/platform_bridge/platform_bridge.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package envoy_mobile.extensions.cert_validator.platform_bridge; 4 | 5 | message PlatformBridgeCertValidator { 6 | } 7 | -------------------------------------------------------------------------------- /library/common/extensions/filters/http/assertion/filter.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package envoymobile.extensions.filters.http.assertion; 4 | 5 | import "envoy/config/common/matcher/v3/matcher.proto"; 6 | 7 | import "validate/validate.proto"; 8 | 9 | message Assertion { 10 | // The match configuration. If the configuration matches the request frames the filter will send 11 | // a local reply with Http::Code::OK on the last frame of the request stream (continuing on 12 | // intervening frames). Otherwise, it will send a local reply with Http::Code::BadRequest. 13 | // TODO: update upstream MatchPredicate proto to require at least one matcher. 14 | envoy.config.common.matcher.v3.MatchPredicate match_config = 1 15 | [(validate.rules).message = {required: true}]; 16 | } 17 | -------------------------------------------------------------------------------- /library/common/extensions/filters/http/local_error/filter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "envoy/http/filter.h" 4 | 5 | #include "source/common/common/logger.h" 6 | #include "source/extensions/filters/http/common/pass_through_filter.h" 7 | 8 | #include "library/common/extensions/filters/http/local_error/filter.pb.h" 9 | 10 | namespace Envoy { 11 | namespace Extensions { 12 | namespace HttpFilters { 13 | namespace LocalError { 14 | 15 | /** 16 | * Filter to assert expectations on HTTP requests. 17 | */ 18 | class LocalErrorFilter final : public Http::PassThroughFilter, 19 | public Logger::Loggable { 20 | public: 21 | // StreamFilterBase 22 | Http::LocalErrorStatus onLocalReply(const LocalReplyData&) override; 23 | }; 24 | 25 | } // namespace LocalError 26 | } // namespace HttpFilters 27 | } // namespace Extensions 28 | } // namespace Envoy 29 | -------------------------------------------------------------------------------- /library/common/extensions/filters/http/local_error/filter.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package envoymobile.extensions.filters.http.local_error; 4 | 5 | message LocalError { 6 | } 7 | -------------------------------------------------------------------------------- /library/common/extensions/filters/http/network_configuration/filter.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package envoymobile.extensions.filters.http.network_configuration; 4 | 5 | message NetworkConfiguration { 6 | // If set to true, the filter will permit the NetworkConnectivityManager to provide upstream 7 | // socket option that MAY bind a connection to a specific network interface. 8 | bool enable_interface_binding = 1; 9 | 10 | // If set to true, the filter will permit the NetworkConnectivityManager to drain connections 11 | // when a DNS refresh is externally triggered. 12 | bool enable_drain_post_dns_refresh = 2; 13 | } 14 | -------------------------------------------------------------------------------- /library/common/extensions/filters/http/platform_bridge/filter.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package envoymobile.extensions.filters.http.platform_bridge; 4 | 5 | import "validate/validate.proto"; 6 | 7 | message PlatformBridge { 8 | string platform_filter_name = 1 [(validate.rules).string.min_len = 1]; 9 | } 10 | -------------------------------------------------------------------------------- /library/common/extensions/filters/http/route_cache_reset/filter.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package envoymobile.extensions.filters.http.route_cache_reset; 4 | 5 | message RouteCacheReset { 6 | } 7 | -------------------------------------------------------------------------------- /library/common/extensions/filters/http/socket_tag/filter.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package envoymobile.extensions.filters.http.socket_tag; 4 | 5 | // Configuration for the socket tagging filer. This filter uses data from the 6 | // x-envoy-mobile-socket-tag request header to apply an Android Socket Tag to the upstream 7 | // socket. 8 | // See: https://source.android.com/devices/tech/datausage/tags-explained 9 | // See: https://developer.android.com/reference/android/net/TrafficStats#setThreadStatsTag(int) 10 | // See: https://developer.android.com/reference/android/net/TrafficStats#setThreadStatsUid(int) 11 | // See: https://developer.android.com/reference/android/net/TrafficStats#tagSocket(java.net.Socket) 12 | message SocketTag { 13 | } 14 | -------------------------------------------------------------------------------- /library/common/extensions/filters/http/test_accessor/filter.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package envoymobile.extensions.filters.http.test_accessor; 4 | 5 | import "validate/validate.proto"; 6 | 7 | message TestAccessor { 8 | string accessor_name = 1 [(validate.rules).string.min_len = 1]; 9 | string expected_string = 2 [(validate.rules).string.min_len = 1]; 10 | } 11 | -------------------------------------------------------------------------------- /library/common/extensions/filters/http/test_event_tracker/filter.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package envoymobile.extensions.filters.http.test_event_tracker; 4 | 5 | import "validate/validate.proto"; 6 | 7 | message TestEventTracker { 8 | // The attributes to report as part of envoy event emitted by `TestEventTrackerFilter` filter. 9 | map attributes = 1; 10 | } 11 | -------------------------------------------------------------------------------- /library/common/extensions/filters/http/test_kv_store/filter.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package envoymobile.extensions.filters.http.test_kv_store; 4 | 5 | import "validate/validate.proto"; 6 | 7 | message TestKeyValueStore { 8 | string kv_store_name = 1 [(validate.rules).string.min_len = 1]; 9 | string test_key = 2 [(validate.rules).string.min_len = 1]; 10 | string test_value = 3 [(validate.rules).string.min_len = 1]; 11 | } 12 | -------------------------------------------------------------------------------- /library/common/extensions/filters/http/test_logger/filter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "envoy/http/filter.h" 4 | 5 | #include "source/extensions/filters/http/common/pass_through_filter.h" 6 | 7 | #include "library/common/extensions/filters/http/test_logger/filter.pb.h" 8 | 9 | namespace Envoy { 10 | namespace Extensions { 11 | namespace HttpFilters { 12 | namespace TestLogger { 13 | 14 | // A filter that emits an ENVOY_EVENT log, used for testing event tracker integration. 15 | class Filter : public Envoy::Http::PassThroughFilter, public Logger::Loggable { 16 | public: 17 | Filter() { ENVOY_LOG_EVENT(debug, "event_name", "test log"); } 18 | }; 19 | 20 | } // namespace TestLogger 21 | } // namespace HttpFilters 22 | } // namespace Extensions 23 | } // namespace Envoy 24 | -------------------------------------------------------------------------------- /library/common/extensions/filters/http/test_logger/filter.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package envoymobile.extensions.filters.http.test_logger; 4 | 5 | import "validate/validate.proto"; 6 | 7 | message TestLogger { 8 | } 9 | -------------------------------------------------------------------------------- /library/common/extensions/key_value/platform/c_types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "library/common/types/c_types.h" 4 | 5 | // NOLINT(namespace-envoy) 6 | 7 | #ifdef __cplusplus 8 | extern "C" { // function pointers 9 | #endif 10 | 11 | /** 12 | * Function signature for reading value from implementation. 13 | */ 14 | typedef envoy_data (*envoy_kv_store_read_f)(envoy_data key, const void* context); 15 | 16 | /** 17 | * Function signature for saving value to implementation. 18 | */ 19 | typedef void (*envoy_kv_store_save_f)(envoy_data key, envoy_data value, const void* context); 20 | 21 | /** 22 | * Function signature for removing value from implementation. 23 | */ 24 | typedef void (*envoy_kv_store_remove_f)(envoy_data key, const void* context); 25 | 26 | #ifdef __cplusplus 27 | } // function pointers 28 | #endif 29 | 30 | typedef struct { 31 | envoy_kv_store_read_f read; 32 | envoy_kv_store_save_f save; 33 | envoy_kv_store_remove_f remove; 34 | const void* context; 35 | } envoy_kv_store; 36 | -------------------------------------------------------------------------------- /library/common/extensions/key_value/platform/platform.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package envoymobile.extensions.key_value.platform; 4 | 5 | import "google/protobuf/duration.proto"; 6 | 7 | import "validate/validate.proto"; 8 | 9 | message PlatformKeyValueStoreConfig { 10 | // The key to save the contents to. 11 | string key = 1 [(validate.rules).string = {min_len: 1}]; 12 | 13 | // The interval at which the key value store should be saved. 14 | google.protobuf.Duration save_interval = 2; 15 | 16 | // The maximum number of entries that can be stored in the cache. 17 | uint64 max_entries = 3; 18 | } 19 | -------------------------------------------------------------------------------- /library/common/extensions/retry/options/network_configuration/config.cc: -------------------------------------------------------------------------------- 1 | #include "library/common/extensions/retry/options/network_configuration/config.h" 2 | 3 | #include "envoy/registry/registry.h" 4 | 5 | namespace Envoy { 6 | namespace Extensions { 7 | namespace Retry { 8 | namespace Options { 9 | 10 | REGISTER_FACTORY(NetworkConfigurationRetryOptionsPredicateFactory, 11 | Upstream::RetryOptionsPredicateFactory); 12 | 13 | } 14 | } // namespace Retry 15 | } // namespace Extensions 16 | } // namespace Envoy 17 | -------------------------------------------------------------------------------- /library/common/extensions/retry/options/network_configuration/predicate.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package envoymobile.extensions.retry.options.network_configuration; 4 | 5 | import "validate/validate.proto"; 6 | 7 | message NetworkConfigurationOptionsPredicate { 8 | } 9 | -------------------------------------------------------------------------------- /library/common/http/headers.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "envoy/http/header_map.h" 4 | 5 | namespace Envoy { 6 | namespace Http { 7 | 8 | /** 9 | * Constant HTTP headers used internally for in-band signalling in the request/response path. 10 | */ 11 | class InternalHeaderValues { 12 | public: 13 | const LowerCaseString ErrorCode{"x-internal-error-code"}; 14 | const LowerCaseString ErrorMessage{"x-internal-error-message"}; 15 | }; 16 | 17 | using InternalHeaders = ConstSingleton; 18 | 19 | } // namespace Http 20 | } // namespace Envoy 21 | -------------------------------------------------------------------------------- /library/common/jni/android_jni_interface.cc: -------------------------------------------------------------------------------- 1 | #include "library/common/jni/android_network_utility.h" 2 | #include "library/common/jni/import/jni_import.h" 3 | #include "library/common/jni/jni_support.h" 4 | #include "library/common/jni/jni_utility.h" 5 | #include "library/common/main_interface.h" 6 | 7 | // NOLINT(namespace-envoy) 8 | 9 | // AndroidJniLibrary 10 | 11 | extern "C" JNIEXPORT jint JNICALL 12 | Java_io_envoyproxy_envoymobile_engine_AndroidJniLibrary_initialize(JNIEnv* env, 13 | jclass, // class 14 | jobject class_loader) { 15 | set_class_loader(env->NewGlobalRef(class_loader)); 16 | // At this point, we know Android APIs are available. Register cert chain validation JNI calls. 17 | return register_platform_api(cert_validator_name, get_android_cert_validator_api()); 18 | } 19 | -------------------------------------------------------------------------------- /library/common/jni/android_jni_utility.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "absl/strings/string_view.h" 4 | 5 | // NOLINT(namespace-envoy) 6 | 7 | /* For android, calls up through JNI to see if cleartext is permitted for this 8 | * host. 9 | * For other platforms simply returns true. 10 | */ 11 | bool is_cleartext_permitted(absl::string_view hostname); 12 | 13 | /* For android, calls up through JNI to apply 14 | * host. 15 | * For other platforms simply returns true. 16 | */ 17 | void tag_socket(int ifd, int uid, int tag); 18 | -------------------------------------------------------------------------------- /library/common/jni/android_network_utility.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "library/common/api/c_types.h" 7 | #include "library/common/extensions/cert_validator/platform_bridge/c_types.h" 8 | #include "library/common/jni/import/jni_import.h" 9 | 10 | // NOLINT(namespace-envoy) 11 | 12 | /* Calls up through JNI to validate given certificates. 13 | */ 14 | jobject call_jvm_verify_x509_cert_chain(JNIEnv* env, const std::vector& cert_chain, 15 | std::string auth_type, std::string host); 16 | 17 | /* Returns a group of C functions to do certificates validation using AndroidNetworkLibrary. 18 | */ 19 | envoy_cert_validator* get_android_cert_validator_api(); 20 | 21 | static constexpr const char* cert_validator_name = "platform_cert_validator"; 22 | -------------------------------------------------------------------------------- /library/common/jni/android_test_jni_interface.cc: -------------------------------------------------------------------------------- 1 | #include "library/common/jni/android_network_utility.h" 2 | #include "library/common/jni/import/jni_import.h" 3 | #include "library/common/jni/jni_support.h" 4 | #include "library/common/jni/jni_utility.h" 5 | #include "library/common/main_interface.h" 6 | 7 | // NOLINT(namespace-envoy) 8 | 9 | // AndroidJniLibrary 10 | 11 | extern "C" JNIEXPORT jint JNICALL 12 | Java_io_envoyproxy_envoymobile_engine_AndroidJniLibrary_initialize(JNIEnv* env, 13 | jclass, // class 14 | jobject class_loader) { 15 | set_class_loader(env->NewGlobalRef(class_loader)); 16 | // At this point, we know Android APIs are available. Register cert chain validation JNI calls. 17 | return register_platform_api(cert_validator_name, get_android_cert_validator_api()); 18 | } 19 | -------------------------------------------------------------------------------- /library/common/jni/import/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | cc_library( 8 | name = "jni_import_lib", 9 | srcs = [ 10 | "jni_import.h", 11 | ], 12 | deps = select({ 13 | "@envoy//bazel:linux": ["//bazel:jni"], 14 | "@envoy//bazel:apple": ["//bazel:jni"], 15 | "//conditions:default": [], 16 | }), 17 | ) 18 | -------------------------------------------------------------------------------- /library/common/jni/import/jni_import.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | // NOLINT(namespace-envoy) 6 | 7 | // This validates that the jni.h header that we include is *not* the jni.h provided by the JVM. This 8 | // helps ensure that the build is using a consistent jni.h header. 9 | #if defined(__ANDROID_API__) && defined(_JAVASOFT_JNI_H_) 10 | #error "JVM jni.h imported during android build" 11 | #endif 12 | -------------------------------------------------------------------------------- /library/common/jni/java_jni_support.cc: -------------------------------------------------------------------------------- 1 | #include "library/common/jni/jni_support.h" 2 | 3 | // NOLINT(namespace-envoy) 4 | 5 | int jni_log_fmt(const char* tag, const char* fmt, void* value) { return 0; } 6 | 7 | int jni_log(const char* tag, const char* str) { return 0; } 8 | 9 | jint attach_jvm(JavaVM* vm, JNIEnv** p_env, void* thr_args) { 10 | return vm->AttachCurrentThread(reinterpret_cast(p_env), thr_args); 11 | } 12 | -------------------------------------------------------------------------------- /library/common/jni/jni_support.h: -------------------------------------------------------------------------------- 1 | #include "library/common/jni/import/jni_import.h" 2 | 3 | // NOLINT(namespace-envoy) 4 | 5 | extern "C" int jni_log_fmt(const char* tag, const char* fmt, void* value); 6 | 7 | extern "C" int jni_log(const char* tag, const char* str); 8 | 9 | extern "C" jint attach_jvm(JavaVM* vm, JNIEnv** p_env, void* thr_args); 10 | -------------------------------------------------------------------------------- /library/common/jni/jni_version.cc: -------------------------------------------------------------------------------- 1 | #include "library/common/jni/jni_version.h" 2 | 3 | // NOLINT(namespace-envoy) 4 | 5 | const jint JNI_VERSION = JNI_VERSION_1_6; 6 | -------------------------------------------------------------------------------- /library/common/jni/jni_version.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "library/common/jni/import/jni_import.h" 4 | 5 | // NOLINT(namespace-envoy) 6 | 7 | extern const jint JNI_VERSION; 8 | -------------------------------------------------------------------------------- /library/common/jni/ndk_jni_support.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "library/common/jni/jni_support.h" 4 | 5 | // NOLINT(namespace-envoy) 6 | 7 | int jni_log_fmt(const char* tag, const char* fmt, void* value) { 8 | // For debug logging, use __android_log_print(ANDROID_LOG_VERBOSE, tag, fmt, value); 9 | return 0; 10 | } 11 | 12 | int jni_log(const char* tag, const char* str) { 13 | // For debug logging, use __android_log_write(ANDROID_LOG_VERBOSE, tag, str); 14 | return 0; 15 | } 16 | 17 | jint attach_jvm(JavaVM* vm, JNIEnv** p_env, void* thr_args) { 18 | return vm->AttachCurrentThread(p_env, thr_args); 19 | } 20 | -------------------------------------------------------------------------------- /library/common/network/android.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Envoy { 4 | namespace Network { 5 | namespace Android { 6 | namespace Utility { 7 | /** 8 | * Sets an alternate `getifaddrs` implementation than the one defined 9 | * in Envoy by default. 10 | */ 11 | void setAlternateGetifaddrs(); 12 | } // namespace Utility 13 | } // namespace Android 14 | } // namespace Network 15 | } // namespace Envoy 16 | -------------------------------------------------------------------------------- /library/common/network/apple_platform_cert_verifier.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // NOLINT(namespace-envoy) 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | /** 10 | * Registers the Apple platform cert verifier API. 11 | */ 12 | void register_apple_platform_cert_verifier(); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /library/common/stats/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_library( 8 | name = "utility_lib", 9 | srcs = [ 10 | "utility.cc", 11 | ], 12 | hdrs = ["utility.h"], 13 | repository = "@envoy", 14 | deps = [ 15 | "//library/common/data:utility_lib", 16 | "@envoy//source/common/stats:utility_lib", 17 | ], 18 | ) 19 | -------------------------------------------------------------------------------- /library/common/stats/utility.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // From upstream Envoy 4 | #include "source/common/stats/utility.h" 5 | 6 | #include "library/common/types/c_types.h" 7 | 8 | namespace Envoy { 9 | namespace Stats { 10 | namespace Utility { 11 | 12 | /** 13 | * Transforms from envoy_stats_tags to Stats::StatNameTagVector. 14 | * 15 | * @param envoy_stats_tags tags to be transformed. tags is free'd. Use after function return is 16 | * unsafe. 17 | * @param stat_name_set the Stats::StatNameSetPtr for the transformed Stats::StatNameTagVector to be 18 | * kept in. 19 | * @return Stats::StatNameTagVector within the given stat_name_set. 20 | */ 21 | Stats::StatNameTagVector transformToStatNameTagVector(envoy_stats_tags tags, 22 | Stats::StatNameSetPtr& stat_name_set); 23 | } // namespace Utility 24 | } // namespace Stats 25 | } // namespace Envoy 26 | -------------------------------------------------------------------------------- /library/common/stream_info/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_library( 8 | name = "extra_stream_info_lib", 9 | srcs = ["extra_stream_info.cc"], 10 | hdrs = ["extra_stream_info.h"], 11 | repository = "@envoy", 12 | deps = [ 13 | "//library/common/network:connectivity_manager_lib", 14 | "//library/common/types:c_types_lib", 15 | "@envoy//envoy/stream_info:stream_info_interface", 16 | "@envoy//source/common/stream_info:utility_lib", 17 | ], 18 | ) 19 | -------------------------------------------------------------------------------- /library/common/thread/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_library( 8 | name = "lock_guard_lib", 9 | hdrs = ["lock_guard.h"], 10 | repository = "@envoy", 11 | deps = [ 12 | "@envoy//envoy/thread:thread_interface", 13 | "@envoy//source/common/common:thread_annotations", 14 | ], 15 | ) 16 | -------------------------------------------------------------------------------- /library/common/types/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_library", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_library( 8 | name = "c_types_lib", 9 | srcs = [ 10 | "c_types.cc", 11 | ], 12 | hdrs = [ 13 | "c_types.h", 14 | ], 15 | repository = "@envoy", 16 | visibility = ["//visibility:public"], 17 | deps = [ 18 | "@envoy//source/common/common:assert_lib", 19 | ], 20 | ) 21 | -------------------------------------------------------------------------------- /library/java/io/envoyproxy/envoymobile/engine/AndroidEngineManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /library/java/io/envoyproxy/envoymobile/engine/EnvoyNativeFilterConfig.java: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile.engine; 2 | 3 | /* Datatype used by the EnvoyConfiguration to create a native http filter chain. */ 4 | public class EnvoyNativeFilterConfig { 5 | public final String name; 6 | public final String typedConfig; 7 | 8 | /** 9 | * Create a new instance of the configuration 10 | * 11 | * @param name the name of the filter. 12 | * @param typedConfig the filter configuration. 13 | */ 14 | public EnvoyNativeFilterConfig(String name, String typedConfig) { 15 | this.name = name; 16 | this.typedConfig = typedConfig; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /library/java/io/envoyproxy/envoymobile/engine/EnvoyNativeResourceReleaser.java: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile.engine; 2 | 3 | public interface EnvoyNativeResourceReleaser { 4 | 5 | /** 6 | * Release a native resource held by a Java object. 7 | * 8 | * @param @nativeHandle, JNI identifier for the native resource. 9 | */ 10 | public void release(long nativeHandle); 11 | } 12 | -------------------------------------------------------------------------------- /library/java/io/envoyproxy/envoymobile/engine/EnvoyNativeResourceWrapper.java: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile.engine; 2 | 3 | /** 4 | * This interface exists solely to scope the types accepted by EnvoyNativeResourceRegistry. 5 | * 6 | * Implemented by objects that require a native resource to be tied to their lifecycle. 7 | */ 8 | interface EnvoyNativeResourceWrapper {} 9 | -------------------------------------------------------------------------------- /library/java/io/envoyproxy/envoymobile/engine/JvmFilterFactoryContext.java: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile.engine; 2 | 3 | import io.envoyproxy.envoymobile.engine.JvmFilterContext; 4 | import io.envoyproxy.envoymobile.engine.types.EnvoyHTTPFilterFactory; 5 | 6 | /** 7 | * Wrapper class for EnvoyHTTPFilterFactory for receiving JNI calls. 8 | */ 9 | class JvmFilterFactoryContext { 10 | private final EnvoyHTTPFilterFactory filterFactory; 11 | 12 | public JvmFilterFactoryContext(EnvoyHTTPFilterFactory filterFactory) { 13 | this.filterFactory = filterFactory; 14 | } 15 | 16 | public JvmFilterContext create() { return new JvmFilterContext(filterFactory.create()); } 17 | } 18 | -------------------------------------------------------------------------------- /library/java/io/envoyproxy/envoymobile/engine/UpstreamHttpProtocol.java: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile.engine; 2 | 3 | import androidx.annotation.LongDef; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | 7 | /** 8 | * The upstream protocol, if an upstream connection was established. Field 9 | * entries are based off of Envoy's Http::Protocol 10 | * https://github.com/envoyproxy/envoy/blob/main/envoy/http/protocol.h 11 | */ 12 | @LongDef({UpstreamHttpProtocol.HTTP10, UpstreamHttpProtocol.HTTP11, UpstreamHttpProtocol.HTTP2, 13 | UpstreamHttpProtocol.HTTP3}) 14 | @Retention(RetentionPolicy.SOURCE) 15 | public @interface UpstreamHttpProtocol { 16 | long HTTP10 = 0; 17 | long HTTP11 = 1; 18 | long HTTP2 = 2; 19 | long HTTP3 = 3; 20 | } 21 | -------------------------------------------------------------------------------- /library/java/io/envoyproxy/envoymobile/engine/types/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_java//java:defs.bzl", "java_library") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | java_library( 6 | name = "envoy_c_types_lib", 7 | srcs = [ 8 | "EnvoyEventTracker.java", 9 | "EnvoyFinalStreamIntel.java", 10 | "EnvoyHTTPCallbacks.java", 11 | "EnvoyHTTPFilter.java", 12 | "EnvoyHTTPFilterCallbacks.java", 13 | "EnvoyHTTPFilterFactory.java", 14 | "EnvoyKeyValueStore.java", 15 | "EnvoyLogger.java", 16 | "EnvoyNetworkType.java", 17 | "EnvoyOnEngineRunning.java", 18 | "EnvoyStatus.java", 19 | "EnvoyStreamIntel.java", 20 | "EnvoyStringAccessor.java", 21 | ], 22 | visibility = ["//visibility:public"], 23 | ) 24 | -------------------------------------------------------------------------------- /library/java/io/envoyproxy/envoymobile/engine/types/EnvoyEventTracker.java: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile.engine.types; 2 | 3 | import java.util.Map; 4 | 5 | public interface EnvoyEventTracker { 6 | void track(Map events); 7 | } 8 | -------------------------------------------------------------------------------- /library/java/io/envoyproxy/envoymobile/engine/types/EnvoyHTTPFilterCallbacks.java: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile.engine.types; 2 | 3 | /** 4 | * Callbacks for asynchronous interaction with the filter. 5 | */ 6 | public interface EnvoyHTTPFilterCallbacks { 7 | /** 8 | * Resume filter iteration asynchronously. This will result in an on-resume invocation of the 9 | * filter. 10 | */ 11 | void resumeIteration(); 12 | 13 | /** 14 | * Reset the underlying stream idle timeout to its configured threshold. This may be useful if 15 | * a filter stops iteration for an extended period of time, since ordinarily timeouts will still 16 | * apply. This may be called periodically to continue to indicate "activity" on the stream. 17 | */ 18 | void resetIdleTimer(); 19 | } 20 | -------------------------------------------------------------------------------- /library/java/io/envoyproxy/envoymobile/engine/types/EnvoyHTTPFilterFactory.java: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile.engine.types; 2 | 3 | public interface EnvoyHTTPFilterFactory { 4 | 5 | String getFilterName(); 6 | 7 | EnvoyHTTPFilter create(); 8 | } 9 | -------------------------------------------------------------------------------- /library/java/io/envoyproxy/envoymobile/engine/types/EnvoyKeyValueStore.java: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile.engine.types; 2 | 3 | public interface EnvoyKeyValueStore { 4 | /** 5 | * Read a value from the key value store implementation. 6 | * 7 | * @param key, key identifying the value to be returned. 8 | * @return String, value mapped to the key, or null if not present. 9 | */ 10 | String read(String key); 11 | 12 | /** 13 | * Remove a value from the key value store implementation. 14 | * 15 | * @param key, key identifying the value to be removed. 16 | */ 17 | void remove(String key); 18 | 19 | /** 20 | * Save a value to the key value store implementation. 21 | * 22 | * @param key, key identifying the value to be saved. 23 | * @param value, the value to be saved. 24 | */ 25 | void save(String key, String value); 26 | } 27 | -------------------------------------------------------------------------------- /library/java/io/envoyproxy/envoymobile/engine/types/EnvoyLogger.java: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile.engine.types; 2 | 3 | public interface EnvoyLogger { 4 | void log(String str); 5 | } 6 | -------------------------------------------------------------------------------- /library/java/io/envoyproxy/envoymobile/engine/types/EnvoyNetworkType.java: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile.engine.types; 2 | 3 | // Network interface type 4 | public enum EnvoyNetworkType { 5 | // WWAN 6 | ENVOY_NETWORK_TYPE_WWAN, 7 | // WLAN 8 | ENVOY_NETWORK_TYPE_WLAN, 9 | // GENERIC 10 | ENVOY_NETWORK_TYPE_GENERIC; 11 | } 12 | -------------------------------------------------------------------------------- /library/java/io/envoyproxy/envoymobile/engine/types/EnvoyOnEngineRunning.java: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile.engine.types; 2 | 3 | /* Interface used to support lambdas being passed from Kotlin for engine setup completion. */ 4 | public interface EnvoyOnEngineRunning { 5 | Object invokeOnEngineRunning(); 6 | } 7 | -------------------------------------------------------------------------------- /library/java/io/envoyproxy/envoymobile/engine/types/EnvoyStatus.java: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile.engine.types; 2 | 3 | public enum EnvoyStatus { ENVOY_SUCCESS, ENVOY_FAILURE } 4 | -------------------------------------------------------------------------------- /library/java/io/envoyproxy/envoymobile/engine/types/EnvoyStringAccessor.java: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile.engine.types; 2 | 3 | public interface EnvoyStringAccessor { 4 | 5 | /** 6 | * Called to retrieve a string from the Application 7 | */ 8 | String getEnvoyString(); 9 | } 10 | -------------------------------------------------------------------------------- /library/java/org/chromium/net/CallbackException.java: -------------------------------------------------------------------------------- 1 | package org.chromium.net; 2 | 3 | /** 4 | * Exception passed to {@link UrlRequest.Callback#onFailed UrlRequest.Callback.onFailed()} when 5 | * {@link UrlRequest.Callback} or {@link UploadDataProvider} method throws an exception. In this 6 | * case {@link java.io.IOException#getCause getCause()} can be used to find the thrown exception. 7 | */ 8 | public abstract class CallbackException extends CronetException { 9 | /** 10 | * Constructs an exception that wraps {@code cause} thrown by a {@link UrlRequest.Callback}. 11 | * 12 | * @param message explanation of failure. 13 | * @param cause exception thrown by {@link UrlRequest.Callback} that's being wrapped. It is saved 14 | * for later retrieval by the {@link java.io.IOException#getCause getCause()}. 15 | */ 16 | protected CallbackException(String message, Throwable cause) { super(message, cause); } 17 | } 18 | -------------------------------------------------------------------------------- /library/java/org/chromium/net/ChromiumNetManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /library/java/org/chromium/net/CronetException.java: -------------------------------------------------------------------------------- 1 | package org.chromium.net; 2 | 3 | import java.io.IOException; 4 | 5 | /** Base exception passed to {@link UrlRequest.Callback#onFailed UrlRequest.Callback.onFailed()}. */ 6 | public abstract class CronetException extends IOException { 7 | /** 8 | * Constructs an exception that is caused by {@code cause}. 9 | * 10 | * @param message explanation of failure. 11 | * @param cause the cause (which is saved for later retrieval by the {@link 12 | * java.io.IOException#getCause getCause()} method). A null value is permitted, and indicates 13 | * that the cause is nonexistent or unknown. 14 | */ 15 | protected CronetException(String message, Throwable cause) { super(message, cause); } 16 | } 17 | -------------------------------------------------------------------------------- /library/java/org/chromium/net/InlineExecutionProhibitedException.java: -------------------------------------------------------------------------------- 1 | package org.chromium.net; 2 | 3 | import java.util.concurrent.RejectedExecutionException; 4 | 5 | /** 6 | * Thrown when an executor runs a submitted runnable inline in {@link 7 | * java.util.concurrent.Executor#execute(Runnable)} and {@link 8 | * UrlRequest.Builder#allowDirectExecutor} was not called. 9 | */ 10 | public final class InlineExecutionProhibitedException extends RejectedExecutionException { 11 | public InlineExecutionProhibitedException() { 12 | super("Inline execution is prohibited for this request"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /library/java/org/chromium/net/impl/BidirectionalStreamNetworkException.java: -------------------------------------------------------------------------------- 1 | package org.chromium.net.impl; 2 | 3 | import org.chromium.net.impl.Errors.NetError; 4 | 5 | /** 6 | * Used in {@link CronetBidirectionalStream}. Implements {@link NetworkExceptionImpl}. 7 | */ 8 | public final class BidirectionalStreamNetworkException extends NetworkExceptionImpl { 9 | public BidirectionalStreamNetworkException(String message, int errorCode, 10 | int cronetInternalErrorCode) { 11 | super(message, errorCode, cronetInternalErrorCode); 12 | } 13 | 14 | @Override 15 | public boolean immediatelyRetryable() { 16 | if (mCronetInternalErrorCode == NetError.ERR_HTTP2_PING_FAILED.getErrorCode() || 17 | mCronetInternalErrorCode == NetError.ERR_QUIC_HANDSHAKE_FAILED.getErrorCode()) { 18 | assert mErrorCode == ERROR_OTHER; 19 | return true; 20 | } 21 | return super.immediatelyRetryable(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /library/java/org/chromium/net/impl/CallbackExceptionImpl.java: -------------------------------------------------------------------------------- 1 | package org.chromium.net.impl; 2 | 3 | import org.chromium.net.CallbackException; 4 | 5 | /** An implementation of {@link CallbackException}. */ 6 | public final class CallbackExceptionImpl extends CallbackException { 7 | CallbackExceptionImpl(String message, Throwable cause) { super(message, cause); } 8 | } 9 | -------------------------------------------------------------------------------- /library/java/org/chromium/net/impl/CronetExceptionImpl.java: -------------------------------------------------------------------------------- 1 | package org.chromium.net.impl; 2 | 3 | import org.chromium.net.CronetException; 4 | 5 | /** Implements {@link CronetException}. */ 6 | final class CronetExceptionImpl extends CronetException { 7 | 8 | CronetExceptionImpl(String message, Throwable cause) { super(message, cause); } 9 | } 10 | -------------------------------------------------------------------------------- /library/java/org/chromium/net/impl/CronvoyManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /library/java/org/chromium/net/impl/JavaCronetEngineBuilderImpl.java: -------------------------------------------------------------------------------- 1 | package org.chromium.net.impl; 2 | 3 | import android.content.Context; 4 | import org.chromium.net.ExperimentalCronetEngine; 5 | import org.chromium.net.ICronetEngineBuilder; 6 | 7 | /** 8 | * Implementation of {@link ICronetEngineBuilder} that builds Java-based Cronet engine. 9 | */ 10 | final class JavaCronetEngineBuilderImpl extends CronetEngineBuilderImpl { 11 | /** 12 | * Builder for Platform Cronet Engine. 13 | * 14 | * @param context Android {@link Context} for engine to use. 15 | */ 16 | public JavaCronetEngineBuilderImpl(Context context) { super(context); } 17 | 18 | @Override 19 | public ExperimentalCronetEngine build() { 20 | if (getUserAgent() == null) { 21 | setUserAgent(getDefaultUserAgent()); 22 | } 23 | return new JavaCronetEngine(this); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /library/java/org/chromium/net/impl/Preconditions.java: -------------------------------------------------------------------------------- 1 | package org.chromium.net.impl; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | /** 6 | * Utility class to check preconditions. 7 | */ 8 | public final class Preconditions { 9 | 10 | public static void checkDirect(ByteBuffer buffer) { 11 | if (!buffer.isDirect()) { 12 | throw new IllegalArgumentException("byteBuffer must be a direct ByteBuffer."); 13 | } 14 | } 15 | 16 | public static void checkHasRemaining(ByteBuffer buffer) { 17 | if (!buffer.hasRemaining()) { 18 | throw new IllegalArgumentException("ByteBuffer is already full."); 19 | } 20 | } 21 | 22 | private Preconditions() {} 23 | } 24 | -------------------------------------------------------------------------------- /library/java/org/chromium/net/urlconnection/URLConnectionManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/AndroidEngineBuilder.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | import android.content.Context 4 | import io.envoyproxy.envoymobile.engine.AndroidEngineImpl 5 | 6 | 7 | /** 8 | * The engine builder to use to create Envoy engine on Android. 9 | */ 10 | class AndroidEngineBuilder @JvmOverloads constructor( 11 | context: Context, 12 | baseConfiguration: BaseConfiguration = Standard() 13 | ) : EngineBuilder(baseConfiguration) { 14 | init { 15 | addEngineType { 16 | AndroidEngineImpl(context, onEngineRunning, logger, eventTracker, enableProxying) 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/EnvoyError.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | /** 4 | * Error type containing information on failures reported by Envoy. 5 | * 6 | * @param errorCode internal error code associated with the exception that occurred. 7 | * @param message a description of what exception that occurred. 8 | * @param attemptCount an optional number of times an operation was attempted before firing 9 | * this error. 10 | * @param cause an optional cause for the exception. 11 | */ 12 | class EnvoyError constructor( 13 | val errorCode: Int, 14 | val message: String, 15 | val attemptCount: Int? = null, 16 | val cause: Throwable? = null 17 | ) 18 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/EnvoyManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/KeyValueStore.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | import io.envoyproxy.envoymobile.engine.types.EnvoyKeyValueStore 4 | 5 | /** 6 | * `KeyValueStore` is an interface that may be implemented to provide access to an arbitrary 7 | * key-value store implementation that may be made accessible to native Envoy Mobile code. 8 | */ 9 | interface KeyValueStore : EnvoyKeyValueStore 10 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/LogLevel.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | /** 4 | * Available logging levels for an Envoy instance. Note some levels may be compiled out. 5 | * 6 | * @param level string representation of a given log level. 7 | * @param levelInt integer representation of a given log level. 8 | */ 9 | enum class LogLevel(internal val level: String, val levelInt: Int) { 10 | TRACE("trace", 0), 11 | DEBUG("debug", 1), 12 | INFO("info", 2), 13 | WARN("warn", 3), 14 | ERROR("error", 4), 15 | CRITICAL("critical", 5), 16 | OFF("off", -1); 17 | } 18 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/RequestTrailers.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | /** 4 | * Trailers representing an outbound request. 5 | */ 6 | @Suppress("EmptyClassBlock") 7 | class RequestTrailers : Trailers { 8 | /** 9 | * Internal constructor used by builders. 10 | * 11 | * @param trailers: Trailers to set. 12 | */ 13 | internal constructor(trailers: Map>) : super(trailers) 14 | 15 | /** 16 | * Instantiate a new builder. 17 | * 18 | * @param container: The headers container to start with. 19 | */ 20 | internal constructor(container: HeadersContainer) : super(container) 21 | 22 | /** 23 | * Convert the trailers back to a builder for mutation. 24 | * 25 | * @return RequestTrailersBuilder, The new builder. 26 | */ 27 | fun toRequestTrailersBuilder() = RequestTrailersBuilder(container) 28 | } 29 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/ResponseHeaders.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | /** 4 | * Headers representing an inbound response. 5 | */ 6 | class ResponseHeaders : Headers { 7 | /** 8 | * Internal constructor used by builders. 9 | * 10 | * @param headers: Headers to set. 11 | */ 12 | internal constructor(headers: Map>) : super(HeadersContainer.create(headers)) 13 | 14 | internal constructor(container: HeadersContainer) : super(container) 15 | 16 | /** 17 | * HTTP status code received with the response. 18 | */ 19 | val httpStatus: Int? by lazy { 20 | value(":status")?.first()?.toIntOrNull()?.takeIf { it >= 0 } 21 | } 22 | 23 | /** 24 | * Convert the headers back to a builder for mutation. 25 | * 26 | * @return ResponseHeadersBuilder, The new builder. 27 | */ 28 | fun toResponseHeadersBuilder() = ResponseHeadersBuilder(container) 29 | } 30 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/ResponseTrailers.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | /** 4 | * Trailers representing an inbound response. 5 | */ 6 | @Suppress("EmptyClassBlock") 7 | class ResponseTrailers : Trailers { 8 | /** 9 | * Internal constructor used by builders. 10 | * 11 | * @param trailers: Trailers to set. 12 | */ 13 | internal constructor(trailers: Map>) : super(trailers) 14 | 15 | /** 16 | * Instantiate a new builder. 17 | * 18 | * @param container: The headers container to start with. 19 | */ 20 | internal constructor(container: HeadersContainer) : super(container) 21 | 22 | /** 23 | * Convert the trailers back to a builder for mutation. 24 | * 25 | * @return ResponseTrailersBuilder, The new builder. 26 | */ 27 | fun toResponseTrailersBuilder() = ResponseTrailersBuilder(container) 28 | } 29 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/StreamClient.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | /** 4 | * Client used to create HTTP streams. 5 | */ 6 | interface StreamClient { 7 | /** 8 | * Create a new stream prototype which can be used to start streams. 9 | * 10 | * @return The new stream prototype. 11 | */ 12 | fun newStreamPrototype(): StreamPrototype 13 | } 14 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/StreamClientImpl.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | import io.envoyproxy.envoymobile.engine.EnvoyEngine 4 | 5 | /** 6 | * Envoy implementation of `StreamClient`. 7 | */ 8 | internal class StreamClientImpl constructor( 9 | internal val engine: EnvoyEngine 10 | ) : StreamClient { 11 | 12 | override fun newStreamPrototype() = StreamPrototype(engine) 13 | } 14 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/StreamIntel.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | import io.envoyproxy.envoymobile.engine.types.EnvoyStreamIntel 4 | 5 | /** 6 | * Exposes internal HTTP stream metrics, context, and other details. 7 | * @param streamId An internal identifier for the stream. -1 if not set. 8 | * @param connectionId An internal identifier for the connection carrying the stream. -1 if not set. 9 | * @param attemptCount The number of internal attempts to carry out a request/operation. 0 if 10 | * not set. 11 | */ 12 | open class StreamIntel constructor( 13 | val streamId: Long, 14 | val connectionId: Long, 15 | val attemptCount: Long 16 | ) { 17 | constructor(base: EnvoyStreamIntel) : this(base.streamId, base.connectionId, base.attemptCount) 18 | } 19 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/StringAccessor.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | import io.envoyproxy.envoymobile.engine.types.EnvoyStringAccessor 4 | 5 | /** 6 | * `StringAccessor` is bridged through to `EnvoyStringAccessor` to communicate with the engine. 7 | */ 8 | class StringAccessor constructor ( 9 | /** 10 | * Accessor for a string exposed by a platform. 11 | */ 12 | val getEnvoyString: (() -> String) 13 | ) 14 | 15 | /** 16 | * Class responsible for bridging between the platform-level `StringAccessor` and the 17 | * engine's `EnvoyStringAccessor`. 18 | */ 19 | internal class EnvoyStringAccessorAdapter( 20 | private val callbacks: StringAccessor 21 | ) : EnvoyStringAccessor { 22 | override fun getEnvoyString(): String { 23 | return callbacks.getEnvoyString() 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/Trailers.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | /** 4 | * Base class representing trailers data structures. 5 | * To instantiate new instances see `{Request|Response}TrailersBuilder`. 6 | */ 7 | open class Trailers : Headers { 8 | /** 9 | * Internal constructor used by builders. 10 | * 11 | * @param trailers: Trailers to set. 12 | */ 13 | protected constructor(trailers: Map>) 14 | : super(HeadersContainer.create(trailers)) 15 | 16 | protected constructor(container: HeadersContainer) : super(container) 17 | } 18 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/UpstreamHttpProtocol.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | import java.lang.IllegalArgumentException 4 | 5 | /** 6 | * Available upstream HTTP protocols. 7 | */ 8 | enum class UpstreamHttpProtocol(internal val stringValue: String) { 9 | HTTP1("http1"), 10 | HTTP2("http2"); 11 | 12 | companion object { 13 | internal fun enumValue(stringRepresentation: String): UpstreamHttpProtocol { 14 | return when (stringRepresentation) { 15 | "http1" -> UpstreamHttpProtocol.HTTP1 16 | "http2" -> UpstreamHttpProtocol.HTTP2 17 | else -> throw IllegalArgumentException("invalid value $stringRepresentation") 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/android/SharedPreferencesStore.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile.android 2 | 3 | import android.content.SharedPreferences 4 | 5 | import io.envoyproxy.envoymobile.KeyValueStore 6 | 7 | /** 8 | * Simple implementation of a `KeyValueStore` leveraging `SharedPreferences` for persistence. 9 | */ 10 | class SharedPreferencesStore(sharedPreferences: SharedPreferences) : KeyValueStore { 11 | private val preferences = sharedPreferences 12 | private val editor = sharedPreferences.edit() 13 | 14 | override fun read(key: String): String? { 15 | return preferences.getString(key, null) 16 | } 17 | 18 | override fun remove(key: String) { 19 | editor.remove(key) 20 | editor.apply() 21 | } 22 | 23 | override fun save(key: String, value: String) { 24 | editor.putString(key, value) 25 | editor.apply() 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/filters/FilterHeadersStatus.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | /* 4 | * Status to be returned by filters when transmitting or receiving headers. 5 | */ 6 | sealed class FilterHeadersStatus( 7 | val status: Int 8 | ) { 9 | /** 10 | * Continue filter chain iteration, passing the provided headers through. 11 | * 12 | * @param headers: The (potentially-modified) headers to be forwarded along the filter chain. 13 | */ 14 | class Continue(val headers: T) : FilterHeadersStatus(0) 15 | 16 | /** 17 | * Do not iterate to any of the remaining filters in the chain with headers. 18 | * 19 | * Returning `ResumeIteration` from another filter invocation or calling 20 | * `resumeRequest()`/`resumeResponse()` MUST occur when continued filter iteration is 21 | * desired. 22 | */ 23 | class StopIteration : FilterHeadersStatus(1) 24 | } 25 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/filters/RequestFilterCallbacksImpl.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | import io.envoyproxy.envoymobile.engine.types.EnvoyHTTPFilterCallbacks 4 | 5 | /** 6 | * Envoy implementation of `RequestFilterCallbacks`. 7 | */ 8 | internal class RequestFilterCallbacksImpl constructor( 9 | internal val callbacks: EnvoyHTTPFilterCallbacks 10 | ) : RequestFilterCallbacks { 11 | 12 | override fun resumeRequest() { 13 | callbacks.resumeIteration() 14 | } 15 | 16 | override fun resetIdleTimer() { 17 | callbacks.resetIdleTimer() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/filters/ResponseFilterCallbacksImpl.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | import io.envoyproxy.envoymobile.engine.types.EnvoyHTTPFilterCallbacks 4 | 5 | /** 6 | * Envoy implementation of `ResponseFilterCallbacks`. 7 | */ 8 | internal class ResponseFilterCallbacksImpl constructor( 9 | internal val callbacks: EnvoyHTTPFilterCallbacks 10 | ) : ResponseFilterCallbacks { 11 | 12 | override fun resumeResponse() { 13 | callbacks.resumeIteration() 14 | } 15 | 16 | override fun resetIdleTimer() { 17 | callbacks.resetIdleTimer() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/grpc/GRPCClient.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | // 1 byte for the compression flag, 4 bytes for the message length (int) 4 | internal const val GRPC_PREFIX_LENGTH = 5 5 | 6 | /** 7 | * Client that supports sending and receiving gRPC traffic. 8 | * 9 | * @param streamClient The stream client to use for gRPC streams. 10 | */ 11 | class GRPCClient( 12 | private val streamClient: StreamClient 13 | ) { 14 | /** 15 | * Create a new gRPC stream prototype which can be used to start streams. 16 | * 17 | * @return The new gRPC stream prototype. 18 | */ 19 | fun newGRPCStreamPrototype() = GRPCStreamPrototype( 20 | streamClient.newStreamPrototype() 21 | ) 22 | } 23 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/grpc/GRPCRequestHeaders.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | /* 4 | * Headers representing an outbound gRPC request. 5 | */ 6 | class GRPCRequestHeaders : RequestHeaders { 7 | /** 8 | * Internal constructor used by builders. 9 | * 10 | * @param headers: Headers to set. 11 | */ 12 | internal constructor(headers: Map>) : super(HeadersContainer(headers)) 13 | 14 | internal constructor(container: HeadersContainer) : super(container) 15 | 16 | /** 17 | * Convert the headers back to a builder for mutation. 18 | * 19 | * @return GRPCRequestHeadersBuilder, The new builder. 20 | */ 21 | fun toGRPCRequestHeadersBuilder() = GRPCRequestHeadersBuilder(container) 22 | } 23 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/mocks/MockStreamClient.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | /** 4 | * Mock implementation of `StreamClient` which produces `MockStreamPrototype` values. 5 | * 6 | * @param onStartStream Closure that may be set to observe the creation of new streams. 7 | * It will be called each time `newStreamPrototype()` is executed. 8 | * Typically, this is used to capture streams on creation before sending values through them. 9 | */ 10 | class MockStreamClient(var onStartStream: ((MockStream) -> Unit)?) : StreamClient { 11 | override fun newStreamPrototype(): StreamPrototype { 12 | return MockStreamPrototype { onStartStream?.invoke(it) } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/mocks/MockStreamPrototype.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | import java.util.concurrent.Executor 4 | 5 | /** 6 | * Mock implementation of `StreamPrototype` which is used to produce `MockStream` instances. 7 | * 8 | * @param onStart Closure that will be called each time a new stream is started from the prototype. 9 | */ 10 | class MockStreamPrototype internal constructor(private val onStart: ((stream: MockStream) -> Unit)?) : StreamPrototype(MockEnvoyEngine()) { 11 | override fun start(executor: Executor): Stream { 12 | val callbacks = createCallbacks(executor) 13 | val stream = MockStream(MockEnvoyHTTPStream(callbacks, false)) 14 | onStart?.invoke(stream) 15 | return stream 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/stats/Counter.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | /** 4 | * A time series counter. 5 | */ 6 | interface Counter { 7 | 8 | /** 9 | * Increments the counter by the given count. 10 | */ 11 | fun increment(count: Int = 1) 12 | 13 | /** 14 | * Increments the counter by the given count and tags. 15 | */ 16 | fun increment(tags: Tags = TagsBuilder().build(), count: Int = 1) 17 | } 18 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/stats/Distribution.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | /** A time-series distribution that tracks quantile/sum/average stats. */ 4 | interface Distribution { 5 | 6 | /** Records a new value to add to the distribution. */ 7 | fun recordValue(value: Int) 8 | 9 | /** Records a new value to add to the distribution along with the tags. */ 10 | fun recordValue(tags: Tags = TagsBuilder().build(), value: Int) 11 | } 12 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/stats/Element.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | import java.util.regex.Pattern 4 | 5 | /** 6 | * Element represents one dot-delimited component of a time series name. 7 | * 8 | * Element values must conform to the [Element.ELEMENT_REGEX]. 9 | */ 10 | 11 | class Element(internal val value: String) { 12 | init { 13 | require(ELEMENT_PATTERN.matcher(value).matches()) { 14 | "Element values must conform to the regex $ELEMENT_REGEX" 15 | } 16 | } 17 | 18 | companion object { 19 | private const val ELEMENT_REGEX = "^[A-Za-z_]+$" 20 | private val ELEMENT_PATTERN = Pattern.compile(ELEMENT_REGEX) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/stats/Gauge.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | /** A time series gauge. */ 4 | interface Gauge { 5 | 6 | /** Sets the gauge by the given value. */ 7 | fun set(value: Int) 8 | 9 | /** Sets the gauge by the given value along with tags. */ 10 | fun set(tags: Tags = TagsBuilder().build(), value: Int) 11 | 12 | /** Adds the given amount to the gauge. */ 13 | fun add(amount: Int) 14 | 15 | /** Adds the given amount to the gauge along with tags. */ 16 | fun add(tags: Tags = TagsBuilder().build(), amount: Int) 17 | 18 | /** Subtracts the given amount from the gauge. */ 19 | fun sub(amount: Int) 20 | 21 | /** Subtracts the given amount from the gauge along with tags. */ 22 | fun sub(tags: Tags = TagsBuilder().build(), amount: Int) 23 | } 24 | -------------------------------------------------------------------------------- /library/kotlin/io/envoyproxy/envoymobile/stats/Timer.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | /** A time-series distribution of duration measurements. */ 4 | interface Timer { 5 | 6 | /** Records a new duration to add to the timer. */ 7 | fun recordDuration(durationMs: Int) 8 | 9 | /** Records a new duration to add to the timer along with tags. */ 10 | fun recordDuration(tags: Tags = TagsBuilder().build(), durationMs: Int) 11 | } 12 | -------------------------------------------------------------------------------- /library/objective-c/EnvoyEventTracker.m: -------------------------------------------------------------------------------- 1 | #import "library/objective-c/EnvoyEngine.h" 2 | 3 | @implementation EnvoyEventTracker 4 | 5 | - (instancetype)initWithEventTrackingClosure:(nonnull void (^)(EnvoyEvent *))track { 6 | self = [super init]; 7 | if (!self) { 8 | return nil; 9 | } 10 | 11 | self.track = track; 12 | return self; 13 | } 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /library/objective-c/EnvoyHTTPCallbacks.m: -------------------------------------------------------------------------------- 1 | #import "library/objective-c/EnvoyEngine.h" 2 | 3 | @implementation EnvoyHTTPCallbacks 4 | @end 5 | -------------------------------------------------------------------------------- /library/objective-c/EnvoyHTTPFilter.m: -------------------------------------------------------------------------------- 1 | #import "library/objective-c/EnvoyEngine.h" 2 | 3 | @implementation EnvoyHTTPFilter 4 | @end 5 | -------------------------------------------------------------------------------- /library/objective-c/EnvoyHTTPFilterCallbacksImpl.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "library/objective-c/EnvoyEngine.h" 4 | 5 | #import "library/common/extensions/filters/http/platform_bridge/c_types.h" 6 | 7 | // Concrete implementation of the `EnvoyHTTPFilterCallbacks` protocol. 8 | @interface EnvoyHTTPFilterCallbacksImpl : NSObject 9 | 10 | - (instancetype)initWithCallbacks:(envoy_http_filter_callbacks)callbacks; 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /library/objective-c/EnvoyHTTPFilterCallbacksImpl.m: -------------------------------------------------------------------------------- 1 | #import "library/objective-c/EnvoyHTTPFilterCallbacksImpl.h" 2 | 3 | #pragma mark - EnvoyHTTPFilterCallbacksImpl 4 | 5 | @implementation EnvoyHTTPFilterCallbacksImpl { 6 | envoy_http_filter_callbacks _callbacks; 7 | } 8 | 9 | - (instancetype)initWithCallbacks:(envoy_http_filter_callbacks)callbacks { 10 | self = [super init]; 11 | if (!self) { 12 | return nil; 13 | } 14 | 15 | _callbacks = callbacks; 16 | return self; 17 | } 18 | 19 | - (void)resumeIteration { 20 | _callbacks.resume_iteration(_callbacks.callback_context); 21 | } 22 | 23 | - (void)resetIdleTimer { 24 | _callbacks.reset_idle(_callbacks.callback_context); 25 | } 26 | 27 | - (void)dealloc { 28 | _callbacks.release_callbacks(_callbacks.callback_context); 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /library/objective-c/EnvoyHTTPFilterFactory.m: -------------------------------------------------------------------------------- 1 | #import "library/objective-c/EnvoyEngine.h" 2 | 3 | @implementation EnvoyHTTPFilterFactory 4 | @end 5 | -------------------------------------------------------------------------------- /library/objective-c/EnvoyLogger.m: -------------------------------------------------------------------------------- 1 | #import "library/objective-c/EnvoyEngine.h" 2 | 3 | @implementation EnvoyLogger 4 | 5 | - (instancetype)initWithLogClosure:(void (^)(NSString *))log { 6 | self = [super init]; 7 | if (!self) { 8 | return nil; 9 | } 10 | 11 | self.log = log; 12 | return self; 13 | } 14 | @end 15 | -------------------------------------------------------------------------------- /library/objective-c/EnvoyNativeFilterConfig.m: -------------------------------------------------------------------------------- 1 | #import "library/objective-c/EnvoyEngine.h" 2 | 3 | @implementation EnvoyNativeFilterConfig 4 | 5 | - (instancetype)initWithName:(NSString *)name typedConfig:(NSString *)typedConfig { 6 | self = [super init]; 7 | if (!self) { 8 | return nil; 9 | } 10 | 11 | self.name = name; 12 | self.typedConfig = typedConfig; 13 | return self; 14 | } 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /library/objective-c/EnvoyStringAccessor.m: -------------------------------------------------------------------------------- 1 | #import "library/objective-c/EnvoyEngine.h" 2 | 3 | @implementation EnvoyStringAccessor 4 | 5 | - (instancetype)initWithBlock:(NSString * (^)())block { 6 | self = [super init]; 7 | if (!self) { 8 | return nil; 9 | } 10 | 11 | self.getEnvoyString = block; 12 | return self; 13 | } 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /library/python/README.rst: -------------------------------------------------------------------------------- 1 | ============== 2 | envoy-requests 3 | ============== 4 | 5 | envoy-requests is pre-alpha software. 6 | It is NOT recommended to use in production applications. 7 | 8 | Overview 9 | ======== 10 | 11 | envoy-requests is a fast `requests`_-like library built on top of `envoy-mobile`_ 12 | to leverage the speed and flexibility of envoy with the intuitive interface of requests. 13 | 14 | .. _requests: https://pypi.org/project/requests/ 15 | .. _envoy-mobile: https://github.com/envoyproxy/envoy-mobile/ 16 | 17 | Copyright 18 | ========= 19 | 20 | Copyright Contributors to the envoy-mobile Project 21 | -------------------------------------------------------------------------------- /library/python/bytes_view.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "library/common/types/c_types.h" 4 | #include "pybind11/pybind11.h" 5 | 6 | namespace py = pybind11; 7 | 8 | namespace Envoy { 9 | namespace Python { 10 | 11 | envoy_data pyBytesAsEnvoyData(py::bytes bytes); 12 | py::bytes envoyDataAsPyBytes(envoy_data data); 13 | 14 | } // namespace Python 15 | } // namespace Envoy 16 | -------------------------------------------------------------------------------- /library/python/engine_builder_shim.cc: -------------------------------------------------------------------------------- 1 | #include "engine_builder_shim.h" 2 | 3 | namespace py = pybind11; 4 | 5 | namespace Envoy { 6 | namespace Python { 7 | namespace EngineBuilder { 8 | 9 | Platform::EngineBuilder& setOnEngineRunningShim(Platform::EngineBuilder& self, 10 | std::function closure) { 11 | return self.setOnEngineRunning([closure]() { 12 | py::gil_scoped_acquire acquire; 13 | closure(); 14 | }); 15 | } 16 | 17 | } // namespace EngineBuilder 18 | } // namespace Python 19 | } // namespace Envoy 20 | -------------------------------------------------------------------------------- /library/python/engine_builder_shim.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "library/cc/engine_builder.h" 6 | #include "pybind11/pybind11.h" 7 | 8 | namespace Envoy { 9 | namespace Python { 10 | namespace EngineBuilder { 11 | 12 | Platform::EngineBuilder& setOnEngineRunningShim(Platform::EngineBuilder& self, 13 | std::function closure); 14 | 15 | } // namespace EngineBuilder 16 | } // namespace Python 17 | } // namespace Envoy 18 | -------------------------------------------------------------------------------- /library/python/envoy_requests/__init__.py: -------------------------------------------------------------------------------- 1 | # explicit import-as re-export so that mypy sees these types 2 | # when implicit_reexport is disabled 3 | # 4 | # https://mypy.readthedocs.io/en/stable/config_file.html#confval-implicit_reexport 5 | from envoy_engine import ErrorCode as ErrorCode 6 | from envoy_engine import LogLevel as LogLevel 7 | 8 | from .response import Response as Response 9 | from .threading import pre_build_engine as pre_build_engine 10 | from .threading import request as request 11 | from .threading import delete as delete 12 | from .threading import get as get 13 | from .threading import head as head 14 | from .threading import options as options 15 | from .threading import patch as patch 16 | from .threading import post as post 17 | from .threading import put as put 18 | from .threading import trace as trace 19 | -------------------------------------------------------------------------------- /library/python/envoy_requests/common/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envoyproxy/envoy-mobile/a9ce5f854d789a9d95d53f8ed3a0f3e4013b7671/library/python/envoy_requests/common/__init__.py -------------------------------------------------------------------------------- /library/python/envoy_requests/common/executor.py: -------------------------------------------------------------------------------- 1 | from abc import ABC 2 | from abc import abstractmethod 3 | from typing import Any 4 | from typing import Callable 5 | from typing import TypeVar 6 | 7 | Func = TypeVar("Func", bound=Callable[..., Any]) 8 | 9 | 10 | class Executor(ABC): 11 | # TODO: verify that this preserves type signature 12 | @abstractmethod 13 | def wrap(self, fn: Func) -> Func: 14 | pass 15 | -------------------------------------------------------------------------------- /library/python/envoy_requests/response.py: -------------------------------------------------------------------------------- 1 | import json 2 | from typing import Any 3 | from typing import Dict 4 | from typing import List 5 | from typing import Optional 6 | from typing import Union 7 | 8 | import envoy_engine 9 | 10 | 11 | class Response: 12 | 13 | def __init__(self): 14 | self.body_raw = bytearray() 15 | self.status_code: Optional[int] = None 16 | self.headers: Dict[str, Union[str, List[str]]] = {} 17 | self.trailers: Dict[str, Union[str, List[str]]] = {} 18 | self.envoy_error: Optional[envoy_engine.EnvoyError] = None 19 | 20 | @property 21 | def body(self) -> bytes: 22 | return bytes(self.body_raw) 23 | 24 | @property 25 | def text(self) -> str: 26 | # TODO: use charset when provided 27 | return str(self.body, "utf8") 28 | 29 | def json(self) -> Dict[str, Any]: 30 | return json.loads(self.body) 31 | -------------------------------------------------------------------------------- /library/python/gevent_util/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_python//python:defs.bzl", "py_library") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | py_library( 6 | name = "gevent_util", 7 | srcs = [ 8 | "__init__.py", 9 | ], 10 | visibility = ["//visibility:public"], 11 | ) 12 | -------------------------------------------------------------------------------- /library/python/stream_shim.cc: -------------------------------------------------------------------------------- 1 | #include "stream_shim.h" 2 | 3 | #include "bytes_view.h" 4 | 5 | namespace Envoy { 6 | namespace Python { 7 | namespace Stream { 8 | 9 | Platform::Stream& sendDataShim(Platform::Stream& self, py::bytes data) { 10 | envoy_data raw_data = pyBytesAsEnvoyData(data); 11 | return self.sendData(raw_data); 12 | } 13 | 14 | void closeShim(Platform::Stream& self, py::bytes data) { 15 | envoy_data raw_data = pyBytesAsEnvoyData(data); 16 | self.close(raw_data); 17 | } 18 | 19 | } // namespace Stream 20 | } // namespace Python 21 | } // namespace Envoy 22 | -------------------------------------------------------------------------------- /library/python/stream_shim.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "library/cc/stream.h" 4 | #include "pybind11/pybind11.h" 5 | 6 | namespace py = pybind11; 7 | 8 | namespace Envoy { 9 | namespace Python { 10 | namespace Stream { 11 | 12 | Platform::Stream& sendDataShim(Platform::Stream& self, py::bytes data); 13 | void closeShim(Platform::Stream& self, py::bytes data); 14 | 15 | } // namespace Stream 16 | } // namespace Python 17 | } // namespace Envoy 18 | -------------------------------------------------------------------------------- /library/swift/Engine.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Engine represents a running instance of Envoy Mobile, and provides client interfaces that run on 4 | /// that instance. 5 | @objc 6 | public protocol Engine: AnyObject { 7 | /// - returns: A client for opening and managing HTTP streams. 8 | func streamClient() -> StreamClient 9 | 10 | /// - returns: A client for recording time series metrics. 11 | func pulseClient() -> PulseClient 12 | 13 | /// Flush the stats sinks outside of a flushing interval. 14 | /// Note: stat flushing is done asynchronously, this function will never block. 15 | /// This is a noop if called before the underlying EnvoyEngine has started. 16 | func flushStats() 17 | 18 | func dumpStats() -> String 19 | 20 | /// Terminates the running engine. 21 | func terminate() 22 | 23 | /// Refresh DNS, and drain connections owned by this Engine. 24 | func resetConnectivityState() 25 | } 26 | -------------------------------------------------------------------------------- /library/swift/EnvoyError.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Error type containing information on failures reported by Envoy. 4 | @objcMembers 5 | public final class EnvoyError: NSObject, Error { 6 | /// Error code associated with the exception that occurred. 7 | public let errorCode: UInt64 8 | /// A description of what exception that occurred. 9 | public let message: String 10 | /// Optional number of times an operation was attempted before firing this error. 11 | public let attemptCount: UInt32? 12 | /// Optional cause for the error. 13 | public let cause: Error? 14 | 15 | public init(errorCode: UInt64, message: String, attemptCount: UInt32?, cause: Error?) { 16 | self.errorCode = errorCode 17 | self.message = message 18 | self.attemptCount = attemptCount 19 | self.cause = cause 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /library/swift/LogLevel.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Available logging levels for an Envoy instance. 4 | /// Note that some levels may be compiled out. 5 | @objc 6 | public enum LogLevel: Int { 7 | case trace = 0 8 | case debug = 1 9 | case info = 2 10 | case warn = 3 11 | case error = 4 12 | case critical = 5 13 | case off = -1 14 | 15 | /// String representation of the log level. 16 | var stringValue: String { 17 | switch self { 18 | case .trace: 19 | return "trace" 20 | case .debug: 21 | return "debug" 22 | case .info: 23 | return "info" 24 | case .warn: 25 | return "warn" 26 | case .error: 27 | return "error" 28 | case .critical: 29 | return "critical" 30 | case .off: 31 | return "off" 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /library/swift/NetworkMonitoringMode.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// The different ways Envoy Mobile can monitor network reachability 4 | /// state. 5 | @objc 6 | public enum NetworkMonitoringMode: Int { 7 | /// Do not monitor changes to the network reachability state. 8 | case disabled = 0 9 | /// Monitor changes to the network reachability state using `SCNetworkReachability`. 10 | case reachability = 1 11 | /// Monitor changes to the network reachability state using `NWPathMonitor`. 12 | case pathMonitor = 2 13 | } 14 | -------------------------------------------------------------------------------- /library/swift/RequestTrailers.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Trailers representing an outbound request. 4 | @objcMembers 5 | public final class RequestTrailers: Trailers { 6 | /// Convert the trailers back to a builder for mutation. 7 | /// 8 | /// - returns: The new builder. 9 | public func toRequestTrailersBuilder() -> RequestTrailersBuilder { 10 | return RequestTrailersBuilder(container: self.container) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /library/swift/RequestTrailersBuilder.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Builder used for constructing instances of `RequestTrailers`. 4 | @objcMembers 5 | public final class RequestTrailersBuilder: HeadersBuilder { 6 | /// Initialize a new instance of the builder. 7 | public override convenience init() { 8 | self.init(container: HeadersContainer(headers: [:])) 9 | } 10 | 11 | /// Build the request trailers using the current builder. 12 | /// 13 | /// - returns: New instance of request trailers. 14 | public func build() -> RequestTrailers { 15 | return RequestTrailers(container: self.container) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /library/swift/ResponseHeaders.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Headers representing an inbound response. 4 | @objcMembers 5 | public final class ResponseHeaders: Headers { 6 | /// HTTP status code received with the response. 7 | public private(set) lazy var httpStatus: UInt? = 8 | self.value(forName: ":status")?.first.flatMap(UInt.init) 9 | 10 | /// Convert the headers back to a builder for mutation. 11 | /// 12 | /// - returns: The new builder. 13 | public func toResponseHeadersBuilder() -> ResponseHeadersBuilder { 14 | return ResponseHeadersBuilder(container: self.container) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /library/swift/ResponseHeadersBuilder.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Builder used for constructing instances of `ResponseHeaders`. 4 | @objcMembers 5 | public final class ResponseHeadersBuilder: HeadersBuilder { 6 | /// Initialize a new instance of the builder. 7 | public override convenience init() { 8 | self.init(container: HeadersContainer(headers: [:])) 9 | } 10 | 11 | /// Add an HTTP status to the response headers. 12 | /// 13 | /// - parameter status: The HTTP status to add. 14 | /// 15 | /// - returns: This builder. 16 | @discardableResult 17 | public func addHttpStatus(_ status: UInt) -> ResponseHeadersBuilder { 18 | self.internalSet(name: ":status", value: ["\(status)"]) 19 | return self 20 | } 21 | 22 | /// Build the response headers using the current builder. 23 | /// 24 | /// - returns: New instance of response headers. 25 | public func build() -> ResponseHeaders { 26 | return ResponseHeaders(container: self.container) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /library/swift/ResponseTrailers.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Trailers representing an inbound response. 4 | @objcMembers 5 | public final class ResponseTrailers: Trailers { 6 | /// Convert the trailers back to a builder for mutation. 7 | /// 8 | /// - returns: The new builder. 9 | public func toResponseTrailersBuilder() -> ResponseTrailersBuilder { 10 | return ResponseTrailersBuilder(container: self.container) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /library/swift/ResponseTrailersBuilder.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Builder used for constructing instances of `ResponseTrailers`. 4 | @objcMembers 5 | public final class ResponseTrailersBuilder: HeadersBuilder { 6 | /// Initialize a new instance of the builder. 7 | public override convenience init() { 8 | self.init(container: HeadersContainer()) 9 | } 10 | 11 | /// Build the response trailers using the current builder. 12 | /// 13 | /// - returns: New instance of response trailers. 14 | public func build() -> ResponseTrailers { 15 | return ResponseTrailers(container: self.container) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /library/swift/StreamClient.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Client used to create HTTP streams. 4 | @objc 5 | public protocol StreamClient: AnyObject { 6 | /// Create a new stream prototype which can be used to start streams. 7 | /// 8 | /// - returns: The new stream prototype. 9 | func newStreamPrototype() -> StreamPrototype 10 | } 11 | -------------------------------------------------------------------------------- /library/swift/StreamClientImpl.swift: -------------------------------------------------------------------------------- 1 | @_implementationOnly import EnvoyEngine 2 | import Foundation 3 | 4 | /// Envoy implementation of StreamClient. 5 | final class StreamClientImpl: NSObject { 6 | private let engine: EnvoyEngine 7 | 8 | init(engine: EnvoyEngine) { 9 | self.engine = engine 10 | super.init() 11 | } 12 | } 13 | 14 | extension StreamClientImpl: StreamClient { 15 | func newStreamPrototype() -> StreamPrototype { 16 | return StreamPrototype(engine: self.engine) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /library/swift/TestEngineBuilder.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Builder that can be used to construct instances of the Envoy engine 4 | /// which have the added functionality of returning "direct" responses to 5 | /// requests over a local connection. This can be particularly useful for mocking/testing. 6 | public final class TestEngineBuilder: EngineBuilder { 7 | /// Adds a direct response configuration which will be used when starting the engine. 8 | /// Doing so will cause Envoy to clear its route cache for each stream in order to allow 9 | /// filters to mutate headers (which can subsequently affect routing). 10 | /// 11 | /// - parameter response: The response configuration to add. 12 | /// 13 | /// - returns: This builder. 14 | @discardableResult 15 | public func addDirectResponse(_ response: DirectResponse) -> Self { 16 | self.addDirectResponseInternal(response) 17 | return self 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /library/swift/Trailers.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Base class used to represent trailer data structures. 4 | /// To instantiate a new instance, see `{Request|Response}TrailersBuilder`. 5 | @objcMembers 6 | public class Trailers: Headers { 7 | } 8 | -------------------------------------------------------------------------------- /library/swift/UpstreamHttpProtocol.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Available upstream HTTP protocols. 4 | @objc 5 | public enum UpstreamHttpProtocol: Int, CaseIterable { 6 | case http1 7 | case http2 8 | 9 | /// String representation of the protocol. 10 | var stringValue: String { 11 | switch self { 12 | case .http1: 13 | return "http1" 14 | case .http2: 15 | return "http2" 16 | } 17 | } 18 | 19 | /// Initialize the protocol using a string value. 20 | /// 21 | /// - parameter stringValue: Case-insensitive string value to use for initialization. 22 | init(stringValue: String) { 23 | switch stringValue.lowercased() { 24 | case "http1": 25 | self = .http1 26 | case "http2": 27 | self = .http2 28 | default: 29 | fatalError("invalid value '\(stringValue)'") 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /library/swift/extensions/UserDefaults+KeyValueStore.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension UserDefaults: KeyValueStore { 4 | public func readValue(forKey key: String) -> String? { 5 | self.string(forKey: key) 6 | } 7 | 8 | public func saveValue(_ value: String, toKey key: String) { 9 | self.set(value, forKey: key) 10 | } 11 | 12 | public func removeKey(_ key: String) { 13 | self.removeObject(forKey: key) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /library/swift/filters/FilterHeadersStatus.swift: -------------------------------------------------------------------------------- 1 | /// Status returned by filters when transmitting or receiving headers. 2 | @frozen 3 | public enum FilterHeadersStatus: Equatable { 4 | /// Continue filter chain iteration, passing the provided headers through. 5 | /// 6 | /// - params headers: The (potentially-modified) headers to be forwarded along the filter chain. 7 | case `continue`(headers: T) 8 | 9 | /// Do not iterate to any of the remaining filters in the chain with headers. 10 | /// 11 | /// Returning `resumeIteration` from another filter invocation or calling 12 | /// `resumeRequest()`/`resumeResponse()` MUST occur when continued filter iteration is 13 | /// desired. 14 | case stopIteration 15 | } 16 | -------------------------------------------------------------------------------- /library/swift/filters/RequestFilterCallbacks.swift: -------------------------------------------------------------------------------- 1 | public protocol RequestFilterCallbacks { 2 | /// Resume iterating through the filter chain with buffered headers and body data. 3 | /// 4 | /// This can only be called if the filter has previously returned `stopIteration{...}` from 5 | /// `onHeaders()`/`onData()`/`onTrailers()`. 6 | /// 7 | /// This will result in an `onResumeRequest()` callback on the RequestFilter. 8 | /// 9 | /// If the request is not complete, the filter may receive further `onData()`/`onTrailers()` 10 | /// calls. 11 | func resumeRequest() 12 | 13 | /// Reset the underlying stream idle timeout to its configured threshold. 14 | /// 15 | /// This may be useful if a filter stops iteration for an extended period of time, since stream 16 | /// timeouts will still apply. This may be called periodically to continue to indicate "activity" 17 | /// on the stream. 18 | func resetIdleTimer() 19 | } 20 | -------------------------------------------------------------------------------- /library/swift/filters/RequestFilterCallbacksImpl.swift: -------------------------------------------------------------------------------- 1 | @_implementationOnly import EnvoyEngine 2 | import Foundation 3 | 4 | /// Envoy implementation of RequestFilterCallbacks 5 | final class RequestFilterCallbacksImpl: NSObject { 6 | private let callbacks: EnvoyHTTPFilterCallbacks 7 | 8 | init(callbacks: EnvoyHTTPFilterCallbacks) { 9 | self.callbacks = callbacks 10 | super.init() 11 | } 12 | } 13 | 14 | extension RequestFilterCallbacksImpl: RequestFilterCallbacks { 15 | func resumeRequest() { 16 | self.callbacks.resumeIteration() 17 | } 18 | 19 | func resetIdleTimer() { 20 | self.callbacks.resetIdleTimer() 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /library/swift/filters/ResponseFilterCallbacks.swift: -------------------------------------------------------------------------------- 1 | public protocol ResponseFilterCallbacks { 2 | /// Resume iterating through the filter chain with buffered headers and body data. 3 | /// 4 | /// This can only be called if the filter has previously returned `stopIteration{...}` from 5 | /// `onHeaders()`/`onData()`/`onTrailers()`. 6 | /// 7 | /// This will result in an `onResumeResponse()` callback on the ResponseFilter. 8 | /// 9 | /// If the response is not complete, the filter may receive further `onData()`/`onTrailers()` 10 | /// calls. 11 | func resumeResponse() 12 | 13 | /// Reset the underlying stream idle timeout to its configured threshold. 14 | /// 15 | /// This may be useful if a filter stops iteration for an extended period of time, since stream 16 | /// timeouts will still apply. This may be called periodically to continue to indicate "activity" 17 | /// on the stream. 18 | func resetIdleTimer() 19 | } 20 | -------------------------------------------------------------------------------- /library/swift/filters/ResponseFilterCallbacksImpl.swift: -------------------------------------------------------------------------------- 1 | @_implementationOnly import EnvoyEngine 2 | import Foundation 3 | 4 | /// Envoy implementation of ResponseFilterCallbacks 5 | final class ResponseFilterCallbacksImpl: NSObject { 6 | private let callbacks: EnvoyHTTPFilterCallbacks 7 | 8 | init(callbacks: EnvoyHTTPFilterCallbacks) { 9 | self.callbacks = callbacks 10 | super.init() 11 | } 12 | } 13 | 14 | extension ResponseFilterCallbacksImpl: ResponseFilterCallbacks { 15 | func resumeResponse() { 16 | self.callbacks.resumeIteration() 17 | } 18 | 19 | func resetIdleTimer() { 20 | self.callbacks.resetIdleTimer() 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /library/swift/grpc/Data+Extension.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension Data { 4 | /// Gets the integer at the provided index using the size of `T`. 5 | /// Returns nil if the data is too small. 6 | /// 7 | /// - parameter index: The index at which to get the integer value. 8 | /// 9 | /// - returns: The next integer in the data, or nil. 10 | func integer(atIndex index: Int) -> T? { 11 | let size = MemoryLayout.size 12 | guard self.count >= index + size else { 13 | return nil 14 | } 15 | 16 | var value: T = 0 17 | _ = Swift.withUnsafeMutableBytes(of: &value) { valuePointer in 18 | self.copyBytes(to: valuePointer, from: index ..< index + size) 19 | } 20 | 21 | return value 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /library/swift/grpc/GRPCClient.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Client that supports sending and receiving gRPC traffic. 4 | @objcMembers 5 | public final class GRPCClient: NSObject { 6 | private let streamClient: StreamClient 7 | 8 | /// Create a new gRPC client instance. 9 | /// 10 | /// - parameter streamClient: The stream client to use for gRPC streams. 11 | public init(streamClient: StreamClient) { 12 | self.streamClient = streamClient 13 | } 14 | 15 | /// Create a new gRPC stream prototype which can be used to start streams. 16 | /// 17 | /// - returns: The new gRPC stream prototype. 18 | public func newGRPCStreamPrototype() -> GRPCStreamPrototype { 19 | let prototype = self.streamClient.newStreamPrototype() 20 | return GRPCStreamPrototype(underlyingStream: prototype) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /library/swift/grpc/GRPCRequestHeaders.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Headers representing an outbound gRPC request. 4 | @objcMembers 5 | public final class GRPCRequestHeaders: RequestHeaders { 6 | /// Convert the headers back to a builder for mutation. 7 | /// 8 | /// - returns: The new builder. 9 | public func toGRPCRequestHeadersBuilder() -> GRPCRequestHeadersBuilder { 10 | return GRPCRequestHeadersBuilder(container: self.container) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /library/swift/mocks/MockEnvoyHTTPStream.swift: -------------------------------------------------------------------------------- 1 | @_implementationOnly import EnvoyEngine 2 | import Foundation 3 | 4 | /// Internal no-op mock implementation of the engine's `EnvoyHTTPStream`. 5 | final class MockEnvoyHTTPStream: EnvoyHTTPStream { 6 | /// Callbacks associated with the stream. 7 | let callbacks: EnvoyHTTPCallbacks 8 | let explicitFlowControl: Bool 9 | 10 | init(handle: Int, engine: Int, callbacks: EnvoyHTTPCallbacks, explicitFlowControl: Bool) { 11 | self.callbacks = callbacks 12 | self.explicitFlowControl = explicitFlowControl 13 | } 14 | 15 | func sendHeaders(_ headers: [String: [String]], close: Bool) {} 16 | 17 | func readData(_ byteCount: size_t) {} 18 | 19 | func send(_ data: Data, close: Bool) {} 20 | 21 | func sendTrailers(_ trailers: [String: [String]]) {} 22 | 23 | func cancel() -> Int32 { return 0 } 24 | 25 | func cleanUp() {} 26 | } 27 | -------------------------------------------------------------------------------- /library/swift/stats/Counter.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A time series counter. 4 | @objc 5 | public protocol Counter: AnyObject { 6 | /// Increment the counter by the given count. 7 | /// 8 | /// - parameter count: The count to add to this counter. 9 | func increment(count: Int) 10 | 11 | /// Increment the counter by the given count and along with tags. 12 | /// 13 | /// - parameter tags: The tags to attach to this Counter. 14 | /// - parameter count: The count to add to this counter. 15 | func increment(tags: Tags, count: Int) 16 | } 17 | 18 | extension Counter { 19 | /// Increment the counter by 1. 20 | public func increment() { 21 | self.increment(count: 1) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /library/swift/stats/Distribution.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A time series distribution tracking quantile/sum/average stats. 4 | @objc 5 | public protocol Distribution: AnyObject { 6 | /// Record a new value to add to the integer distribution. 7 | /// 8 | /// - parameter value: The value to record. 9 | func recordValue(value: Int) 10 | 11 | /// Record a new value to add to the integer distribution with tags. 12 | /// 13 | /// - parameter tags: The tags to attach to this distribution. 14 | /// - parameter value: The value to record. 15 | func recordValue(tags: Tags, value: Int) 16 | } 17 | -------------------------------------------------------------------------------- /library/swift/stats/Element.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | private let kPattern = "^[A-Za-z_]+$" 4 | 5 | /// Element represents one dot-delimited component of a time series name. 6 | /// Element values must conform to the regex /^[A-Za-z_]+$/. 7 | @objcMembers 8 | public final class Element: NSObject, ExpressibleByStringLiteral { 9 | internal let value: String 10 | 11 | public init(stringLiteral value: String) { 12 | guard value.range(of: kPattern, options: .regularExpression) != nil else { 13 | preconditionFailure("Element values must conform to the regex '\(kPattern)'.") 14 | } 15 | self.value = value 16 | } 17 | 18 | public override func isEqual(_ object: Any?) -> Bool { 19 | return (object as? Element)?.value == self.value 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /library/swift/stats/Timer.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A time series distribution of duration measurements. 4 | @objc 5 | public protocol Timer: AnyObject { 6 | /// Record a new duration to add to the timer. 7 | /// 8 | /// - parameter durationMs: The duration to add in milliseconds. 9 | func recordDuration(durationMs: Int) 10 | 11 | /// Record a new duration to add to the timer along with tags. 12 | /// 13 | /// - parameter tags: The tags to attach to this Timer. 14 | /// - parameter durationMs: The duration to add in milliseconds. 15 | func recordDuration(tags: Tags, durationMs: Int) 16 | } 17 | -------------------------------------------------------------------------------- /test/cc/integration/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_test", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_test( 8 | name = "send_headers_test", 9 | srcs = ["send_headers_test.cc"], 10 | repository = "@envoy", 11 | deps = [ 12 | "//library/cc:engine_builder_lib", 13 | "//library/cc:envoy_engine_cc_lib_no_stamp", 14 | ], 15 | ) 16 | 17 | envoy_cc_test( 18 | name = "lifetimes_test", 19 | srcs = ["lifetimes_test.cc"], 20 | repository = "@envoy", 21 | deps = [ 22 | "//library/cc:engine_builder_lib", 23 | "//library/cc:envoy_engine_cc_lib_no_stamp", 24 | ], 25 | ) 26 | -------------------------------------------------------------------------------- /test/cc/unit/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_test", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_test( 8 | name = "envoy_config_test", 9 | srcs = ["envoy_config_test.cc"], 10 | repository = "@envoy", 11 | deps = [ 12 | "//library/cc:engine_builder_lib", 13 | "//library/cc:envoy_engine_cc_lib_no_stamp", 14 | "@envoy_build_config//:extension_registry", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /test/common/bridge/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_test", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_test( 8 | name = "utility_test", 9 | srcs = ["utility_test.cc"], 10 | repository = "@envoy", 11 | deps = [ 12 | "//library/common/bridge:utility_lib", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /test/common/bridge/utility_test.cc: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | #include "library/common/bridge/utility.h" 3 | #include "library/common/data/utility.h" 4 | #include "library/common/types/c_types.h" 5 | 6 | namespace Envoy { 7 | namespace Bridge { 8 | 9 | TEST(EnvoyMapConvenientInitializerTest, FromCppToCEmpty) { 10 | const auto map = Utility::makeEnvoyMap({}); 11 | 12 | EXPECT_EQ(map.length, 0); 13 | release_envoy_map(map); 14 | } 15 | 16 | TEST(EnvoyMapConvenientInitializerTest, FromCppToC) { 17 | const auto map = Utility::makeEnvoyMap({{"foo", "bar"}}); 18 | 19 | EXPECT_EQ(Data::Utility::copyToString(map.entries[0].key), "foo"); 20 | EXPECT_EQ(Data::Utility::copyToString(map.entries[0].value), "bar"); 21 | EXPECT_EQ(map.length, 1); 22 | release_envoy_map(map); 23 | } 24 | 25 | } // namespace Bridge 26 | } // namespace Envoy 27 | -------------------------------------------------------------------------------- /test/common/buffer/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_test", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_test( 8 | name = "bridge_fragment_test", 9 | srcs = ["bridge_fragment_test.cc"], 10 | repository = "@envoy", 11 | deps = [ 12 | "//library/common/buffer:bridge_fragment_lib", 13 | "//library/common/types:c_types_lib", 14 | "@envoy//source/common/buffer:buffer_lib", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /test/common/common/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_test", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_test( 8 | name = "lambda_logger_delegate_test", 9 | srcs = ["lambda_logger_delegate_test.cc"], 10 | repository = "@envoy", 11 | deps = [ 12 | "//library/common/api:external_api_lib", 13 | "//library/common/common:lambda_logger_delegate_lib", 14 | "//library/common/data:utility_lib", 15 | "//library/common/types:c_types_lib", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /test/common/data/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_test", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_test( 8 | name = "utility_test", 9 | srcs = ["utility_test.cc"], 10 | repository = "@envoy", 11 | deps = [ 12 | "//library/common/data:utility_lib", 13 | "//library/common/types:c_types_lib", 14 | "@envoy//source/common/buffer:buffer_lib", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /test/common/engine_common_test.cc: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | #include "library/common/engine_common.h" 3 | 4 | namespace Envoy { 5 | 6 | TEST(EngineCommonTest, SignalHandlingFalse) { 7 | std::vector envoy_argv{ 8 | "envoy", "--config-yaml", 9 | "{\"layered_runtime\":{\"layers\":[{\"name\":\"static_layer_0\",\"static_layer\":{" 10 | "\"overload\":{\"global_downstream_max_connections\":50000}}}]}}", 11 | nullptr}; 12 | EngineCommon main_common{3, &envoy_argv[0]}; 13 | ASSERT_FALSE(main_common.server()->options().signalHandlingEnabled()); 14 | } 15 | 16 | } // namespace Envoy 17 | -------------------------------------------------------------------------------- /test/common/extensions/filters/http/assertion/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_package") 2 | load( 3 | "@envoy//test/extensions:extensions_build_system.bzl", 4 | "envoy_extension_cc_test", 5 | ) 6 | 7 | licenses(["notice"]) # Apache 2 8 | 9 | envoy_package() 10 | 11 | envoy_extension_cc_test( 12 | name = "assertion_filter_test", 13 | srcs = ["assertion_filter_test.cc"], 14 | extension_names = ["envoy.filters.http.assertion"], 15 | repository = "@envoy", 16 | deps = [ 17 | "//library/common/extensions/filters/http/assertion:config", 18 | "//library/common/extensions/filters/http/assertion:filter_cc_proto", 19 | "@envoy//test/mocks/http:http_mocks", 20 | "@envoy//test/mocks/server:factory_context_mocks", 21 | "@envoy//test/test_common:utility_lib", 22 | ], 23 | ) 24 | -------------------------------------------------------------------------------- /test/common/extensions/key_value/platform/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_package") 2 | load( 3 | "@envoy//test/extensions:extensions_build_system.bzl", 4 | "envoy_extension_cc_test", 5 | ) 6 | 7 | licenses(["notice"]) # Apache 2 8 | 9 | envoy_package() 10 | 11 | envoy_extension_cc_test( 12 | name = "platform_store_test", 13 | srcs = ["platform_store_test.cc"], 14 | extension_names = ["envoy.key_value.platform"], 15 | repository = "@envoy", 16 | deps = [ 17 | "//library/common/extensions/key_value/platform:config", 18 | "@envoy//source/common/common:key_value_store_lib", 19 | "@envoy//test/mocks/event:event_mocks", 20 | "@envoy//test/test_common:file_system_for_test_lib", 21 | ], 22 | ) 23 | -------------------------------------------------------------------------------- /test/common/extensions/retry/options/network_configuration/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_package") 2 | load( 3 | "@envoy//test/extensions:extensions_build_system.bzl", 4 | "envoy_extension_cc_test", 5 | ) 6 | 7 | licenses(["notice"]) # Apache 2 8 | 9 | envoy_package() 10 | 11 | envoy_extension_cc_test( 12 | name = "network_configuration_retry_options_test", 13 | srcs = ["predicate_test.cc"], 14 | extension_names = ["envoy.retry.options.network_configuration"], 15 | repository = "@envoy", 16 | deps = [ 17 | "//library/common/extensions/retry/options/network_configuration:config", 18 | "//library/common/network:connectivity_manager_lib", 19 | "@envoy//source/common/upstream:retry_factory_lib", 20 | "@envoy//test/mocks/server:factory_context_mocks", 21 | "@envoy//test/mocks/stream_info:stream_info_mocks", 22 | ], 23 | ) 24 | -------------------------------------------------------------------------------- /test/common/integration/quic_test_server_interface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "test/common/integration/quic_test_server.h" 4 | 5 | // NOLINT(namespace-envoy) 6 | 7 | #ifdef __cplusplus 8 | extern "C" { // functions 9 | #endif 10 | 11 | /** 12 | * Starts the server. Can only have one server active per JVM. This is blocking until the port can 13 | * start accepting requests. 14 | */ 15 | void start_server(); 16 | 17 | /** 18 | * Shutdowns the server. Can be restarted later. This is blocking until the server has freed all 19 | * resources. 20 | */ 21 | void shutdown_server(); 22 | 23 | /** 24 | * Returns the port that got attributed. Can only be called once the server has been started. 25 | */ 26 | int get_server_port(); 27 | 28 | #ifdef __cplusplus 29 | } // functions 30 | #endif 31 | -------------------------------------------------------------------------------- /test/common/mocks/event/BUILD: -------------------------------------------------------------------------------- 1 | load( 2 | "@envoy//bazel:envoy_build_system.bzl", 3 | "envoy_cc_mock", 4 | "envoy_package", 5 | ) 6 | 7 | licenses(["notice"]) # Apache 2 8 | 9 | envoy_package() 10 | 11 | envoy_cc_mock( 12 | name = "event_mocks", 13 | srcs = ["mocks.cc"], 14 | hdrs = ["mocks.h"], 15 | repository = "@envoy", 16 | deps = [ 17 | "//library/common/event:provisional_dispatcher_lib", 18 | "@envoy//envoy/event:deferred_deletable", 19 | "@envoy//envoy/event:dispatcher_interface", 20 | "@envoy//test/test_common:test_time_lib", 21 | ], 22 | ) 23 | -------------------------------------------------------------------------------- /test/common/mocks/event/mocks.cc: -------------------------------------------------------------------------------- 1 | #include "mocks.h" 2 | 3 | #include "gmock/gmock.h" 4 | #include "gtest/gtest.h" 5 | 6 | using testing::_; 7 | using testing::Assign; 8 | using testing::DoAll; 9 | using testing::Invoke; 10 | using testing::NiceMock; 11 | using testing::Return; 12 | using testing::ReturnNew; 13 | using testing::ReturnPointee; 14 | using testing::SaveArg; 15 | 16 | namespace Envoy { 17 | namespace Event { 18 | 19 | MockProvisionalDispatcher::MockProvisionalDispatcher() { 20 | ON_CALL(*this, timeSource()).WillByDefault(testing::ReturnRef(time_system_)); 21 | } 22 | } // namespace Event 23 | } // namespace Envoy 24 | -------------------------------------------------------------------------------- /test/common/stats/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_test", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_test( 8 | name = "utility_test", 9 | srcs = ["utility_test.cc"], 10 | repository = "@envoy", 11 | deps = [ 12 | "//library/common:envoy_main_interface_lib_no_stamp", 13 | "//library/common/data:utility_lib", 14 | "//library/common/types:c_types_lib", 15 | "@envoy//test/common/stats:stat_test_utility_lib", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /test/common/stream_info/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_test", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_test( 8 | name = "extra_stream_info_test", 9 | srcs = ["extra_stream_info_test.cc"], 10 | repository = "@envoy", 11 | deps = [ 12 | "//library/common/stream_info:extra_stream_info_lib", 13 | "@envoy//source/common/stream_info:stream_info_lib", 14 | "@envoy//test/test_common:simulated_time_system_lib", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /test/common/thread/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_test", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_test( 8 | name = "lock_guard_test", 9 | srcs = ["lock_guard_test.cc"], 10 | repository = "@envoy", 11 | deps = [ 12 | "//library/common/thread:lock_guard_lib", 13 | "@envoy//source/common/common:thread_lib", 14 | ], 15 | ) 16 | -------------------------------------------------------------------------------- /test/common/thread/lock_guard_test.cc: -------------------------------------------------------------------------------- 1 | #include "source/common/common/thread.h" 2 | 3 | #include "gtest/gtest.h" 4 | #include "library/common/thread/lock_guard.h" 5 | 6 | namespace Envoy { 7 | namespace Thread { 8 | 9 | class ThreadTest : public testing::Test { 10 | protected: 11 | ThreadTest() = default; 12 | int a_ ABSL_GUARDED_BY(a_mutex_){0}; 13 | MutexBasicLockable a_mutex_; 14 | int b_{0}; 15 | }; 16 | 17 | TEST_F(ThreadTest, TestOptionalReleasableLockGuard) { 18 | OptionalReleasableLockGuard lock(nullptr); 19 | EXPECT_EQ(1, ++b_); 20 | 21 | OptionalReleasableLockGuard lock2(&a_mutex_); 22 | EXPECT_EQ(1, ++a_); 23 | lock2.release(); 24 | } 25 | 26 | } // namespace Thread 27 | } // namespace Envoy 28 | -------------------------------------------------------------------------------- /test/integration/filters/http/test_read/config.cc: -------------------------------------------------------------------------------- 1 | #include "test/integration/filters/http/test_read/config.h" 2 | 3 | #include "test/integration/filters/http/test_read/filter.h" 4 | 5 | namespace Envoy { 6 | namespace HttpFilters { 7 | namespace TestRead { 8 | 9 | Http::FilterFactoryCb TestReadFilterFactory::createFilterFactoryFromProtoTyped( 10 | const envoymobile::test::integration::filters::http::test_read::TestRead& /*config*/, 11 | const std::string&, Server::Configuration::FactoryContext& /*context*/) { 12 | return [](Http::FilterChainFactoryCallbacks& callbacks) -> void { 13 | callbacks.addStreamDecoderFilter(std::make_shared()); 14 | }; 15 | } 16 | 17 | /** 18 | * Static registration for the TestRead filter. @see NamedHttpFilterConfigFactory. 19 | */ 20 | REGISTER_FACTORY(TestReadFilterFactory, Server::Configuration::NamedHttpFilterConfigFactory); 21 | 22 | } // namespace TestRead 23 | } // namespace HttpFilters 24 | } // namespace Envoy 25 | -------------------------------------------------------------------------------- /test/integration/filters/http/test_read/filter.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package envoymobile.test.integration.filters.http.test_read; 4 | 5 | import "validate/validate.proto"; 6 | 7 | message TestRead { 8 | } 9 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/CronetTestUtil.java: -------------------------------------------------------------------------------- 1 | package org.chromium.net.testing; 2 | 3 | import org.chromium.net.ExperimentalCronetEngine; 4 | import org.chromium.net.impl.NativeCronetEngineBuilderImpl; 5 | 6 | /** 7 | * Utilities for Cronet testing 8 | */ 9 | public final class CronetTestUtil { 10 | 11 | public static void setMockCertVerifierForTesting(ExperimentalCronetEngine.Builder builder) { 12 | getCronetEngineBuilderImpl(builder).setMockCertVerifierForTesting(); 13 | } 14 | 15 | public static NativeCronetEngineBuilderImpl 16 | getCronetEngineBuilderImpl(ExperimentalCronetEngine.Builder builder) { 17 | return (NativeCronetEngineBuilderImpl)builder.getBuilderDelegate(); 18 | } 19 | 20 | public static boolean nativeCanGetTaggedBytes() { 21 | return false; // TODO(carloseltuerto) implement 22 | } 23 | 24 | public static long nativeGetTaggedBytes(int tag) { 25 | return 0; // TODO(carloseltuerto) implement 26 | } 27 | 28 | private CronetTestUtil() {} 29 | } 30 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/FailurePhase.java: -------------------------------------------------------------------------------- 1 | package org.chromium.net.testing; 2 | 3 | public enum FailurePhase { 4 | START, 5 | READ_SYNC, 6 | READ_ASYNC; 7 | 8 | @Override 9 | public String toString() { 10 | return name().toLowerCase(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/Feature.java: -------------------------------------------------------------------------------- 1 | package org.chromium.net.testing; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * The java instrumentation tests are normally fairly large (in terms of 10 | * dependencies), and the test suite ends up containing a large amount of 11 | * tests that are not trivial to filter / group just by their names. 12 | * Instead, we use this annotation: each test should be annotated as: 13 | * @Feature({"Foo", "Bar"}) 14 | * in order for the test runner scripts to be able to filter and group 15 | * them accordingly (for instance, this enable us to run all tests that exercise 16 | * feature Foo). 17 | */ 18 | @Target(ElementType.METHOD) 19 | @Retention(RetentionPolicy.RUNTIME) 20 | public @interface Feature { 21 | /** 22 | * @return A list of feature names. 23 | */ 24 | String[] value(); 25 | } 26 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/cacheable.txt: -------------------------------------------------------------------------------- 1 | this is a cacheable file 2 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/cacheable.txt.mock-http-headers: -------------------------------------------------------------------------------- 1 | HTTP/1.1 200 OK 2 | Content-Type: text/plain 3 | Cache-Control: max-age=300 4 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/content_length_mismatch.html: -------------------------------------------------------------------------------- 1 | Response that lies about content length. 2 | 3 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/content_length_mismatch.html.mock-http-headers: -------------------------------------------------------------------------------- 1 | HTTP/1.1 200 OK 2 | Content-Type: text/html 3 | Content-Length: 1000000 4 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/gzipped.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envoyproxy/envoy-mobile/a9ce5f854d789a9d95d53f8ed3a0f3e4013b7671/test/java/org/chromium/net/testing/data/gzipped.html -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/gzipped.html.mock-http-headers: -------------------------------------------------------------------------------- 1 | HTTP/1.1 200 OK 2 | Content-Encoding: gzip 3 | foo: bar 4 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/internalerror.txt: -------------------------------------------------------------------------------- 1 | Something went wrong 2 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/internalerror.txt.mock-http-headers: -------------------------------------------------------------------------------- 1 | HTTP/1.1 500 Internal Server Error 2 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/multiredirect.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Redirect 5 |

Redirecting...

6 | 7 | 8 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/multiredirect.html.mock-http-headers: -------------------------------------------------------------------------------- 1 | HTTP/1.1 302 Found 2 | Location: /redirect.html 3 | redirect-header0: header-value 4 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/notfound.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Not found 5 |

Test page loaded.

6 | 7 | 8 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/notfound.html.mock-http-headers: -------------------------------------------------------------------------------- 1 | HTTP/1.1 404 Not Found 2 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/redirect.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Redirect 5 |

Redirecting...

6 | 7 | 8 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/redirect.html.mock-http-headers: -------------------------------------------------------------------------------- 1 | HTTP/1.1 302 Found 2 | Location: /success.txt 3 | redirect-header: header-value 4 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/redirect_broken_header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Redirect 5 |

Redirecting...

6 | 7 | 8 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/redirect_broken_header.html.mock-http-headers: -------------------------------------------------------------------------------- 1 | HTTP/1.1 302 Found 2 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/redirect_invalid_scheme.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Redirect 5 |

Redirecting...

6 | 7 | 8 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/redirect_invalid_scheme.html.mock-http-headers: -------------------------------------------------------------------------------- 1 | HTTP/1.1 302 Found 2 | Location: https://127.0.0.1:8000/success.txt 3 | redirect-header: header-value 4 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/secureproxychecksuccess.txt: -------------------------------------------------------------------------------- 1 | OK 2 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/secureproxychecksuccess.txt.mock-http-headers: -------------------------------------------------------------------------------- 1 | HTTP/1.1 200 OK 2 | Content-Type: text/plain 3 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/set_cookie.html: -------------------------------------------------------------------------------- 1 | hello! 2 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/set_cookie.html.mock-http-headers: -------------------------------------------------------------------------------- 1 | HTTP/1.1 200 OK 2 | Set-Cookie: A=B 3 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/success.txt: -------------------------------------------------------------------------------- 1 | this is a text file 2 | -------------------------------------------------------------------------------- /test/java/org/chromium/net/testing/data/success.txt.mock-http-headers: -------------------------------------------------------------------------------- 1 | HTTP/1.1 200 OK 2 | Content-Type: text/plain 3 | Access-Control-Allow-Origin: * 4 | header-name: header-value 5 | multi-header-name: header-value1 6 | multi-header-name: header-value2 7 | -------------------------------------------------------------------------------- /test/kotlin/apps/baseline/.bazelproject: -------------------------------------------------------------------------------- 1 | workspace_type: android 2 | 3 | bazel_binary: bazelw 4 | 5 | directories: 6 | -bazel-bin 7 | -bazel-instant-android 8 | -bazel-out 9 | -bazel-testlogs 10 | -buck-out 11 | -build 12 | test/kotlin/apps/baseline/ 13 | 14 | import_run_configurations: 15 | test/kotlin/apps/baseline/tools/android-studio-run-configurations/run_configuration_example_debug_x86.xml 16 | test/kotlin/apps/baseline/tools/android-studio-run-configurations/run_configuration_example_debug_arm64.xml 17 | 18 | targets: 19 | //test/kotlin/apps/baseline:hello_envoy_kt 20 | 21 | additional_languages: 22 | kotlin 23 | java 24 | android 25 | c 26 | -------------------------------------------------------------------------------- /test/kotlin/apps/baseline/README.md: -------------------------------------------------------------------------------- 1 | For instructions on how to use this demo, please head over to our [docs](https://envoymobile.io/docs/envoy-mobile/latest/start/examples/hello_world.html). 2 | -------------------------------------------------------------------------------- /test/kotlin/apps/baseline/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/kotlin/apps/experimental/.bazelproject: -------------------------------------------------------------------------------- 1 | workspace_type: android 2 | 3 | directories: 4 | -bazel-bin 5 | -bazel-instant-android 6 | -bazel-out 7 | -bazel-testlogs 8 | -buck-out 9 | -build 10 | test/kotlin/apps/experimental 11 | 12 | import_run_configurations: 13 | test/kotlin/apps/experimental/tools/android-studio-run-configurations/run_configuration_example_debug_x86.xml 14 | test/kotlin/apps/experimental/tools/android-studio-run-configurations/run_configuration_example_debug_arm64.xml 15 | 16 | targets: 17 | //test/kotlin/apps/experimental:hello_envoy_kt 18 | 19 | additional_languages: 20 | kotlin 21 | java 22 | android 23 | c 24 | -------------------------------------------------------------------------------- /test/kotlin/apps/experimental/README.md: -------------------------------------------------------------------------------- 1 | For instructions on how to use this demo, please head over to our [docs](https://envoymobile.io/docs/envoy-mobile/latest/start/examples/hello_world.html). 2 | -------------------------------------------------------------------------------- /test/kotlin/apps/experimental/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/kotlin/integration/EnvoyEngineSimpleIntegrationTest.kt: -------------------------------------------------------------------------------- 1 | package test.kotlin.integration 2 | 3 | import io.envoyproxy.envoymobile.EngineBuilder 4 | import io.envoyproxy.envoymobile.engine.JniLibrary 5 | import org.assertj.core.api.Assertions.assertThat 6 | import org.junit.Test 7 | 8 | class EnvoyEngineSimpleIntegrationTest { 9 | 10 | init { 11 | JniLibrary.loadTestLibrary() 12 | } 13 | 14 | @Test 15 | fun `ensure engine build and termination succeeds with no errors`() { 16 | val engine = EngineBuilder().build() 17 | Thread.sleep(5000) 18 | engine.terminate() 19 | assertThat(true).isTrue() 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/kotlin/io/envoyproxy/envoymobile/stats/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy_mobile//bazel:kotlin_test.bzl", "envoy_mobile_kt_test") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_mobile_kt_test( 6 | name = "element_test", 7 | srcs = [ 8 | "ElementTest.kt", 9 | ], 10 | deps = [ 11 | "//library/kotlin/io/envoyproxy/envoymobile:envoy_interfaces_lib", 12 | ], 13 | ) 14 | 15 | envoy_mobile_kt_test( 16 | name = "tags_builder_test", 17 | srcs = [ 18 | "TagsBuilderTest.kt", 19 | ], 20 | deps = [ 21 | "//library/kotlin/io/envoyproxy/envoymobile:envoy_interfaces_lib", 22 | ], 23 | ) 24 | -------------------------------------------------------------------------------- /test/kotlin/io/envoyproxy/envoymobile/stats/ElementTest.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | import org.junit.Test 4 | 5 | class ElementTest { 6 | 7 | @Test 8 | fun `creates new element as expected`() { 9 | // Should just work 10 | Element("foo") 11 | } 12 | 13 | @Test(expected = IllegalArgumentException::class) 14 | fun `throw exception when element name is rejected`() { 15 | // Should throw exception 16 | Element("foo9") 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/kotlin/io/envoyproxy/envoymobile/stats/TagsBuilderTest.kt: -------------------------------------------------------------------------------- 1 | package io.envoyproxy.envoymobile 2 | 3 | import org.assertj.core.api.Assertions.assertThat 4 | import org.junit.Test 5 | 6 | class TagsBuilderTest { 7 | @Test 8 | fun `adds tags to tags`() { 9 | val tags = TagsBuilder().add("testKey", "testValue").build() 10 | assertThat(tags.allTags().size).isEqualTo(1) 11 | assertThat(tags.allTags().get("testKey")).isEqualTo("testValue") 12 | } 13 | 14 | @Test 15 | fun `puts a map of tags to tags`() { 16 | val tagsBuilder = TagsBuilder() 17 | val tagMap = mutableMapOf("testKey1" to "testValue1", "testKey2" to "testValue2") 18 | val tags = tagsBuilder.putAll(tagMap).build() 19 | assertThat(tags.allTags().size).isEqualTo(2) 20 | assertThat(tags.allTags().get("testKey1")).isEqualTo("testValue1") 21 | assertThat(tags.allTags().get("testKey2")).isEqualTo("testValue2") 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/objective-c/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy_mobile//bazel:apple_test.bzl", "envoy_mobile_objc_test") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_mobile_objc_test( 6 | name = "envoy_bridge_utility_test", 7 | srcs = [ 8 | "EnvoyBridgeUtilityTest.m", 9 | ], 10 | visibility = ["//visibility:public"], 11 | deps = [ 12 | "//library/objective-c:envoy_objc_bridge_lib", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /test/performance/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy//bazel:envoy_build_system.bzl", "envoy_cc_binary", "envoy_package") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_package() 6 | 7 | envoy_cc_binary( 8 | name = "test_binary_size", 9 | srcs = ["test_binary_size.cc"], 10 | repository = "@envoy", 11 | stamped = True, 12 | deps = ["//library/common:envoy_main_interface_lib"], 13 | ) 14 | -------------------------------------------------------------------------------- /test/performance/test_binary_size.cc: -------------------------------------------------------------------------------- 1 | #include "library/common/main_interface.h" 2 | 3 | // NOLINT(namespace-envoy) 4 | 5 | // This binary is used to perform stripped down binary size investigations of the Envoy codebase. 6 | // Please refer to the development docs for more information: 7 | // https://envoymobile.io/docs/envoy-mobile/latest/development/performance/binary_size.html 8 | int main() { return run_engine(0, nullptr, nullptr, nullptr); } 9 | -------------------------------------------------------------------------------- /test/python/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envoyproxy/envoy-mobile/a9ce5f854d789a9d95d53f8ed3a0f3e4013b7671/test/python/__init__.py -------------------------------------------------------------------------------- /test/python/benchmark/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envoyproxy/envoy-mobile/a9ce5f854d789a9d95d53f8ed3a0f3e4013b7671/test/python/benchmark/__init__.py -------------------------------------------------------------------------------- /test/python/integration/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envoyproxy/envoy-mobile/a9ce5f854d789a9d95d53f8ed3a0f3e4013b7671/test/python/integration/__init__.py -------------------------------------------------------------------------------- /test/python/runner.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | import pytest 4 | 5 | if __name__ == "__main__": 6 | exit(pytest.main(sys.argv[1:])) 7 | -------------------------------------------------------------------------------- /test/python/unit/__test__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/envoyproxy/envoy-mobile/a9ce5f854d789a9d95d53f8ed3a0f3e4013b7671/test/python/unit/__test__.py -------------------------------------------------------------------------------- /test/python/unit/test_echo_server.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | # since we already have requests installed for the benchmark 4 | # we reuse it to make sure that the echo server works as expected 5 | # requests provides a basis of correctness against which we can 6 | # measure our implementation 7 | 8 | 9 | def test_echo_server_get(http_server_url: str): 10 | response = requests.get(http_server_url).json() 11 | assert response["body"] == "" 12 | assert response["method"] == "GET" 13 | assert response["path"] == "/" 14 | 15 | 16 | def test_echo_server_body(http_server_url: str): 17 | response = requests.get(http_server_url, data="hello world").json() 18 | assert response["body"] == "hello world" 19 | assert response["method"] == "GET" 20 | assert response["path"] == "/" 21 | -------------------------------------------------------------------------------- /test/swift/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy_mobile//bazel:apple_test.bzl", "envoy_mobile_swift_test") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_mobile_swift_test( 6 | name = "test", 7 | srcs = [ 8 | "EngineBuilderTests.swift", 9 | "GRPCRequestHeadersBuilderTests.swift", 10 | "GRPCStreamTests.swift", 11 | "HeadersBuilderTests.swift", 12 | "HeadersContainerTests.swift", 13 | "PulseClientImplTests.swift", 14 | "RequestHeadersBuilderTests.swift", 15 | "ResponseHeadersTests.swift", 16 | "RetryPolicyMapperTests.swift", 17 | "RetryPolicyTests.swift", 18 | ], 19 | visibility = ["//visibility:public"], 20 | deps = [ 21 | "//library/objective-c:envoy_engine_objc_lib", 22 | ], 23 | ) 24 | -------------------------------------------------------------------------------- /test/swift/apps/baseline/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | @UIApplicationMain 4 | final class AppDelegate: UIResponder, UIApplicationDelegate { 5 | var window: UIWindow? 6 | 7 | func application( 8 | _ application: UIApplication, 9 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool 10 | { 11 | let window = UIWindow(frame: UIScreen.main.bounds) 12 | window.rootViewController = ViewController() 13 | window.makeKeyAndVisible() 14 | self.window = window 15 | 16 | NSLog("Finished launching!") 17 | return true 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/swift/apps/baseline/BUILD: -------------------------------------------------------------------------------- 1 | load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application") 2 | load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") 3 | load("//bazel:config.bzl", "MINIMUM_IOS_VERSION") 4 | 5 | licenses(["notice"]) # Apache 2 6 | 7 | swift_library( 8 | name = "appmain", 9 | srcs = glob(["*.swift"]), 10 | deps = ["//library/swift:ios_lib"], 11 | ) 12 | 13 | ios_application( 14 | name = "app", 15 | bundle_id = "io.envoyproxy.envoymobile.helloworld", 16 | families = ["iphone"], 17 | infoplists = ["Info.plist"], 18 | minimum_os_version = MINIMUM_IOS_VERSION, 19 | provisioning_profile = select({ 20 | "@envoy//bazel:ios_arm64": "//examples:ios_provisioning_profile", 21 | "//conditions:default": None, 22 | }), 23 | visibility = ["//visibility:public"], 24 | deps = ["appmain"], 25 | ) 26 | -------------------------------------------------------------------------------- /test/swift/apps/baseline/README.md: -------------------------------------------------------------------------------- 1 | For instructions on how to use this demo, please head over to our [docs](https://envoymobile.io/docs/envoy-mobile/latest/start/examples/hello_world.html). 2 | -------------------------------------------------------------------------------- /test/swift/apps/baseline/ResponseModels.swift: -------------------------------------------------------------------------------- 1 | /// Represents a response from the server. 2 | struct Response { 3 | let message: String 4 | let headerMessage: String 5 | } 6 | 7 | /// Error that was encountered when executing a request. 8 | struct RequestError: Error { 9 | let message: String 10 | } 11 | -------------------------------------------------------------------------------- /test/swift/apps/experimental/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | @UIApplicationMain 4 | final class AppDelegate: UIResponder, UIApplicationDelegate { 5 | var window: UIWindow? 6 | 7 | func application( 8 | _ application: UIApplication, 9 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool 10 | { 11 | let window = UIWindow(frame: UIScreen.main.bounds) 12 | window.rootViewController = ViewController() 13 | window.makeKeyAndVisible() 14 | self.window = window 15 | 16 | NSLog("Finished launching!") 17 | return true 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/swift/apps/experimental/BUILD: -------------------------------------------------------------------------------- 1 | load("//bazel:config.bzl", "MINIMUM_IOS_VERSION") 2 | load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application") 3 | load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") 4 | 5 | licenses(["notice"]) # Apache 2 6 | 7 | swift_library( 8 | name = "appmain", 9 | srcs = glob(["*.swift"]), 10 | deps = ["//library/swift:ios_lib"], 11 | ) 12 | 13 | ios_application( 14 | name = "app", 15 | bundle_id = "io.envoyproxy.envoymobile.helloworld", 16 | families = ["iphone"], 17 | infoplists = ["Info.plist"], 18 | minimum_os_version = MINIMUM_IOS_VERSION, 19 | provisioning_profile = select({ 20 | "@envoy//bazel:ios_arm64": "//examples:ios_provisioning_profile", 21 | "//conditions:default": None, 22 | }), 23 | visibility = ["//visibility:public"], 24 | deps = ["appmain"], 25 | ) 26 | -------------------------------------------------------------------------------- /test/swift/apps/experimental/README.md: -------------------------------------------------------------------------------- 1 | For instructions on how to use this demo, please head over to our [docs](https://envoymobile.io/docs/envoy-mobile/latest/start/examples/hello_world.html). 2 | -------------------------------------------------------------------------------- /test/swift/apps/experimental/ResponseModels.swift: -------------------------------------------------------------------------------- 1 | /// Represents a response from the server. 2 | struct Response { 3 | let message: String 4 | let headerMessage: String 5 | } 6 | 7 | /// Error that was encountered when executing a request. 8 | struct RequestError: Error { 9 | let message: String 10 | } 11 | -------------------------------------------------------------------------------- /test/swift/integration/EngineApiTest.swift: -------------------------------------------------------------------------------- 1 | import Envoy 2 | import Foundation 3 | import XCTest 4 | 5 | final class EngineApiTest: XCTestCase { 6 | func testEngineApis() throws { 7 | let engineExpectation = self.expectation(description: "Engine Running") 8 | 9 | let engine = EngineBuilder() 10 | .addLogLevel(.debug) 11 | .addStatsFlushSeconds(1) 12 | .setOnEngineRunning { 13 | engineExpectation.fulfill() 14 | } 15 | .build() 16 | 17 | XCTAssertEqual(XCTWaiter.wait(for: [engineExpectation], timeout: 10), .completed) 18 | 19 | let pulseClient = engine.pulseClient() 20 | pulseClient.gauge(elements: ["foo", "bar"]).set(value: 1) 21 | 22 | XCTAssertTrue(engine.dumpStats().contains("foo.bar: 1")) 23 | 24 | engine.terminate() 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/swift/integration/README.md: -------------------------------------------------------------------------------- 1 | This test suite tests end-to-end integration from the platform layer to the core layer's HTTP 2 | functionality. It tests both the request side `send{Headers|Data}`, `close`, `cancel`, as 3 | well as the response 4 | side via the ` setOnResponse{...}` functions. 5 | 6 | TODO: These tests are broken apart into different suites and bazel targets in order to tear down 7 | app state -- and thus static lifetime objects like the Envoy engine -- between tests. When 8 | multiple engine support (https://github.com/envoyproxy/envoy-mobile/issues/332) lands, all of these 9 | tests can be collapsed to the same suite/target. 10 | 11 | TODO: setOnTrailers is not tested as the neither the `direct_response` pathway, nor the router 12 | allow sending trailers programmatically. Add tests once possible. 13 | -------------------------------------------------------------------------------- /test/swift/integration/TestExtensions.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | #import "test/swift/integration/test_extensions.h" 5 | -------------------------------------------------------------------------------- /test/swift/integration/test_extensions.cc: -------------------------------------------------------------------------------- 1 | #include "test/swift/integration/test_extensions.h" 2 | 3 | #include "library/common/extensions/filters/http/test_accessor/config.h" 4 | #include "library/common/extensions/filters/http/test_event_tracker/config.h" 5 | #include "library/common/extensions/filters/http/test_logger/config.h" 6 | 7 | void register_test_extensions() { 8 | Envoy::Extensions::HttpFilters::TestLogger::forceRegisterFactory(); 9 | Envoy::Extensions::HttpFilters::TestAccessor::forceRegisterTestAccessorFilterFactory(); 10 | Envoy::Extensions::HttpFilters::TestEventTracker::forceRegisterTestEventTrackerFilterFactory(); 11 | } 12 | -------------------------------------------------------------------------------- /test/swift/integration/test_extensions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // NOLINT(namespace-envoy) 4 | 5 | #ifdef __cplusplus 6 | extern "C" { // functions 7 | #endif 8 | 9 | void register_test_extensions(); 10 | 11 | #ifdef __cplusplus 12 | } // functions 13 | #endif 14 | -------------------------------------------------------------------------------- /test/swift/stats/BUILD: -------------------------------------------------------------------------------- 1 | load("@envoy_mobile//bazel:apple_test.bzl", "envoy_mobile_swift_test") 2 | 3 | licenses(["notice"]) # Apache 2 4 | 5 | envoy_mobile_swift_test( 6 | name = "test", 7 | srcs = [ 8 | "CounterImplTests.swift", 9 | "ElementTests.swift", 10 | "TagsBuilderTests.swift", 11 | ], 12 | visibility = ["//visibility:public"], 13 | deps = [ 14 | "//library/objective-c:envoy_engine_objc_lib", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /test/swift/stats/ElementTests.swift: -------------------------------------------------------------------------------- 1 | import Envoy 2 | import XCTest 3 | 4 | final class ElementTests: XCTestCase { 5 | func testElementNotEqualToObjectOfUnrelatedType() { 6 | let element = Element("foo") 7 | XCTAssertFalse(element.isEqual("bar")) 8 | } 9 | 10 | func testElementsAreEqualIfStringValuesAreEqual() { 11 | XCTAssertTrue(Element("foo").isEqual(Element("foo"))) 12 | XCTAssertEqual(Element("foo"), Element("foo")) 13 | 14 | XCTAssertFalse(Element("foo").isEqual(Element("bar"))) 15 | XCTAssertNotEqual(Element("foo"), Element("bar")) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /third_party/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) # Apache 2 2 | 3 | exports_files([ 4 | "android/ifaddrs-android.h", 5 | "android/LocalArray.h", 6 | "android/ScopedFd.h", 7 | ]) 8 | -------------------------------------------------------------------------------- /third_party/python/BUILD: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) # Apache 2 2 | 3 | exports_files(glob(["**"])) 4 | -------------------------------------------------------------------------------- /third_party/python/requirements.in: -------------------------------------------------------------------------------- 1 | gevent 2 | mypy 3 | pytest 4 | pytest-asyncio 5 | pytest-benchmark 6 | requests 7 | -------------------------------------------------------------------------------- /third_party/rbe_configs/cc/WORKSPACE: -------------------------------------------------------------------------------- 1 | # DO NOT EDIT: automatically generated WORKSPACE file for cc_autoconf rule 2 | workspace(name = "local_config_cc") 3 | -------------------------------------------------------------------------------- /third_party/rbe_configs/cc/builtin_include_directory_paths: -------------------------------------------------------------------------------- 1 | This file is generated by cc_configure and contains builtin include directories 2 | that /opt/llvm/bin/clang-14 reported. This file is a dependency of every compilation action and 3 | changes to it will be reflected in the action cache key. When some of these 4 | paths change, Bazel will make sure to rerun the action, even though none of 5 | declared action inputs or the action commandline changes. 6 | 7 | /usr/local/include 8 | /opt/llvm/lib/clang/14.0.0/include 9 | /usr/include/x86_64-linux-gnu 10 | /usr/include 11 | /opt/llvm/lib/clang/14.0.0/share 12 | /usr/include/c++/9 13 | /usr/include/x86_64-linux-gnu/c++/9 14 | /usr/include/c++/9/backward 15 | /opt/llvm/include/c++/v1 16 | -------------------------------------------------------------------------------- /third_party/rbe_configs/cc/cc_wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2015 The Bazel Authors. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # Ship the environment to the C++ action 18 | # 19 | set -eu 20 | 21 | # Set-up the environment 22 | 23 | 24 | # Call the C++ compiler 25 | /opt/llvm/bin/clang-14 "$@" 26 | -------------------------------------------------------------------------------- /third_party/rbe_configs/cc/tools/cpp/empty.cc: -------------------------------------------------------------------------------- 1 | int main() {} 2 | -------------------------------------------------------------------------------- /tools/docc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | symbolgraph_dir="${1:-}" 6 | if [[ -z "$symbolgraph_dir" ]]; then 7 | ./bazelw build //library/swift:ios_lib --config=release-ios --output_groups=+swift_symbol_graph 8 | symbolgraph_dir="bazel-bin/library/swift/ios_lib.symbolgraph" 9 | fi 10 | 11 | "$(xcrun --find docc)" convert \ 12 | --index \ 13 | --fallback-display-name Envoy \ 14 | --fallback-bundle-identifier io.envoyproxy.EnvoyMobile \ 15 | --fallback-bundle-version "$(cat VERSION)" \ 16 | --output-dir Envoy.doccarchive \ 17 | --additional-symbol-graph-dir "$symbolgraph_dir" 18 | -------------------------------------------------------------------------------- /tools/post_to_slack.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | ################################################################## 6 | # post_to_slack.sh 7 | # 8 | # Posts a message to the #envoy-mobile-collaboration Slack channel 9 | # 10 | # Usage: `SLACK_BOT_TOKEN=x post_to_slack.sh "markdown message"` 11 | ################################################################## 12 | 13 | curl -H "Content-type: application/json; charset=utf-8" \ 14 | --data "{\"channel\":\"C02F93EEJCE\",\"blocks\":[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"$1\"}}]}" \ 15 | -H "Authorization: Bearer $SLACK_BOT_TOKEN" \ 16 | -X POST \ 17 | https://slack.com/api/chat.postMessage 18 | -------------------------------------------------------------------------------- /tools/vscode_compdb.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Generates a compile_commands.json file for use with the VS Code clangd plugin. 4 | # This is a modification of evnoy/tools/vscode/refresh_compdb.sh which hits 5 | # the correct envoy-mobile Bazel targets. 6 | 7 | # Setting TEST_TMPDIR here so the compdb headers won't be overwritten by another bazel run 8 | CC=clang TEST_TMPDIR=${BUILD_DIR:-/tmp}/envoy-mobile-compdb envoy/tools/gen_compilation_database.py --vscode --bazel ./bazelw //library/cc/... //library/common/... //test/cc/... //test/common/... 9 | 10 | # Kill clangd to reload the compilation database 11 | pkill clangd || : 12 | --------------------------------------------------------------------------------