grpc 1.83.1 → 1.84.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Makefile +21 -17
- data/include/grpc/credentials.h +10 -0
- data/include/grpc/grpc_security_constants.h +2 -0
- data/include/grpc/impl/channel_arg_names.h +9 -0
- data/src/core/call/call_filters.h +4 -2
- data/src/core/call/client_call.cc +20 -8
- data/src/core/call/client_call.h +4 -0
- data/src/core/call/interception_chain.cc +2 -0
- data/src/core/call/interception_chain.h +14 -1
- data/src/core/call/metadata.cc +1 -3
- data/src/core/call/metadata_batch.h +13 -5
- data/src/core/call/server_call.cc +31 -14
- data/src/core/call/server_call.h +4 -0
- data/src/core/channelz/text_encode.cc +9 -4
- data/src/core/channelz/v2tov1/convert.cc +2 -2
- data/src/core/client_channel/backup_poller.cc +1 -2
- data/src/core/client_channel/client_channel.cc +6 -33
- data/src/core/client_channel/client_channel_filter.cc +22 -55
- data/src/core/client_channel/client_channel_filter.h +2 -2
- data/src/core/client_channel/client_channel_service_config.cc +3 -19
- data/src/core/client_channel/direct_channel.cc +7 -1
- data/src/core/client_channel/direct_channel.h +2 -2
- data/src/core/client_channel/load_balanced_call_destination.cc +5 -3
- data/src/core/client_channel/retry_filter_legacy_call_data.cc +5 -12
- data/src/core/client_channel/subchannel.cc +310 -1058
- data/src/core/client_channel/subchannel.h +44 -329
- data/src/core/client_channel/subchannel_metrics.cc +48 -0
- data/src/core/client_channel/subchannel_metrics.h +60 -0
- data/src/core/credentials/call/external/file_external_account_credentials.cc +1 -1
- data/src/core/credentials/call/external/url_external_account_credentials.cc +2 -3
- data/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.cc +8 -24
- data/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.h +3 -6
- data/src/core/credentials/call/gdch_service_account/gdch_service_account_credentials.cc +525 -0
- data/src/core/credentials/call/gdch_service_account/gdch_service_account_credentials.h +138 -0
- data/src/core/credentials/call/json_util.h +1 -0
- data/src/core/credentials/call/jwt/json_token.cc +10 -2
- data/src/core/credentials/call/jwt/jwt_verifier.cc +15 -1
- data/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.cc +1 -1
- data/src/core/credentials/call/oauth2/oauth2_credentials.cc +42 -79
- data/src/core/credentials/call/oauth2/oauth2_credentials.h +2 -5
- data/src/core/credentials/call/token_fetcher/token_fetcher_credentials.cc +52 -31
- data/src/core/credentials/call/token_fetcher/token_fetcher_credentials.h +21 -8
- data/src/core/credentials/transport/google_default/google_default_credentials.cc +3 -4
- data/src/core/credentials/transport/ssl/ssl_credentials.cc +59 -72
- data/src/core/credentials/transport/ssl/ssl_credentials.h +9 -8
- data/src/core/credentials/transport/ssl/ssl_security_connector.cc +12 -6
- data/src/core/credentials/transport/ssl/ssl_security_connector.h +4 -4
- data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc +29 -18
- data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h +9 -6
- data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc +45 -56
- data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.h +5 -4
- data/src/core/credentials/transport/tls/grpc_tls_certificate_selector.h +26 -0
- data/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc +1 -1
- data/src/core/credentials/transport/tls/load_system_roots.h +2 -6
- data/src/core/credentials/transport/tls/load_system_roots_fallback.cc +2 -4
- data/src/core/credentials/transport/tls/load_system_roots_supported.cc +13 -15
- data/src/core/credentials/transport/tls/load_system_roots_supported.h +3 -2
- data/src/core/credentials/transport/tls/load_system_roots_windows.cc +5 -8
- data/src/core/credentials/transport/tls/spiffe_utils.cc +1 -1
- data/src/core/credentials/transport/tls/ssl_utils.cc +39 -28
- data/src/core/credentials/transport/tls/ssl_utils.h +12 -49
- data/src/core/credentials/transport/tls/tls_security_connector.cc +48 -33
- data/src/core/credentials/transport/tls/tls_security_connector.h +31 -10
- data/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc +15 -11
- data/src/core/ext/filters/http/http_filters_plugin.cc +20 -9
- data/src/core/ext/filters/rbac/rbac_filter.cc +43 -21
- data/src/core/ext/filters/rbac/rbac_filter.h +21 -3
- data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +2 -2
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +1 -1
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +6 -20
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +32 -67
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +2 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.h +78 -4
- data/src/core/ext/transport/chttp2/transport/frame.h +2 -0
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +3 -4
- data/src/core/ext/transport/chttp2/transport/goaway.h +7 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +5 -3
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +3 -1
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +141 -130
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +22 -22
- data/src/core/ext/transport/chttp2/transport/http2_server_transport.cc +402 -269
- data/src/core/ext/transport/chttp2/transport/http2_server_transport.h +80 -49
- data/src/core/ext/transport/chttp2/transport/http2_settings_promises.h +1 -2
- data/src/core/ext/transport/chttp2/transport/http2_status.h +38 -37
- data/src/core/ext/transport/chttp2/transport/http2_transport.cc +178 -5
- data/src/core/ext/transport/chttp2/transport/http2_transport.h +345 -5
- data/src/core/ext/transport/chttp2/transport/parsing.cc +5 -5
- data/src/core/ext/transport/chttp2/transport/ping_promise.cc +3 -2
- data/src/core/ext/transport/chttp2/transport/ping_promise.h +25 -5
- data/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc +3 -4
- data/src/core/ext/transport/chttp2/transport/read_context.h +30 -3
- data/src/core/ext/transport/chttp2/transport/stream.h +65 -23
- data/src/core/ext/transport/chttp2/transport/writing.cc +0 -3
- data/src/core/ext/transport/inproc/inproc_transport.cc +1 -5
- data/src/core/ext/transport/inproc/legacy_inproc_transport.cc +4 -17
- data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb.h +1912 -0
- data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb_minitable.c +300 -0
- data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb_minitable.h +37 -0
- data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upb.h +187 -0
- data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upb_minitable.c +64 -0
- data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upb_minitable.h +31 -0
- data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb.h +2362 -0
- data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb_minitable.c +556 -0
- data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb_minitable.h +47 -0
- data/src/core/ext/upb-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upb.h +5 -5
- data/src/core/ext/upb-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upb_minitable.c +3 -3
- data/src/core/ext/upb-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upb_minitable.h +5 -5
- data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upbdefs.c +453 -0
- data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upbdefs.h +67 -0
- data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upbdefs.c +142 -0
- data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upbdefs.h +37 -0
- data/src/core/ext/upbdefs-gen/grpc/channelz/v1/channelz.upbdefs.c +715 -0
- data/src/core/ext/upbdefs-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upbdefs.h +44 -44
- data/src/core/filter/auth/server_auth_filter.cc +2 -3
- data/src/core/filter/composite/composite_filter.cc +45 -33
- data/src/core/filter/composite/composite_filter.h +5 -4
- data/src/core/filter/ext_proc/ext_proc_filter.cc +224 -0
- data/src/core/filter/ext_proc/ext_proc_filter.h +155 -0
- data/src/core/filter/ext_proc/ext_proc_messages.cc +701 -0
- data/src/core/filter/ext_proc/ext_proc_messages.h +297 -0
- data/src/core/filter/filter_args.h +13 -2
- data/src/core/handshaker/http_connect/http_proxy_mapper.cc +30 -3
- data/src/core/handshaker/security/security_handshaker.cc +9 -6
- data/src/core/lib/channel/channel_stack.cc +3 -0
- data/src/core/lib/channel/channel_stack.h +2 -0
- data/src/core/lib/channel/channel_stack_builder_impl.cc +1 -2
- data/src/core/lib/channel/promise_based_filter.cc +132 -20
- data/src/core/lib/channel/promise_based_filter.h +42 -12
- data/src/core/lib/compression/compression_internal.cc +4 -5
- data/src/core/lib/debug/trace_flags.cc +8 -0
- data/src/core/lib/debug/trace_flags.h +3 -0
- data/src/core/lib/event_engine/ares_resolver.cc +54 -50
- data/src/core/lib/event_engine/ares_resolver.h +3 -2
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +3 -3
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +4 -10
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +74 -33
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +4 -4
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +6 -2
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +3 -0
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +3 -0
- data/src/core/lib/event_engine/windows/windows_endpoint.cc +1 -3
- data/src/core/lib/experiments/experiments.cc +60 -96
- data/src/core/lib/experiments/experiments.h +34 -50
- data/src/core/lib/iomgr/cfstream_handle.cc +2 -6
- data/src/core/lib/iomgr/endpoint_cfstream.cc +3 -10
- data/src/core/lib/iomgr/error.cc +2 -6
- data/src/core/lib/iomgr/error_cfstream.cc +1 -1
- data/src/core/lib/iomgr/ev_poll_posix.cc +5 -9
- data/src/core/lib/iomgr/event_engine_shims/closure.cc +1 -1
- data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +1 -2
- data/src/core/lib/iomgr/event_engine_shims/tcp_client.cc +1 -2
- data/src/core/lib/iomgr/iomgr_posix.cc +0 -4
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +0 -4
- data/src/core/lib/iomgr/iomgr_windows.cc +0 -4
- data/src/core/lib/iomgr/socket_factory_posix.h +1 -1
- data/src/core/lib/iomgr/socket_utils_posix.cc +3 -0
- data/src/core/lib/iomgr/socket_utils_posix.h +3 -0
- data/src/core/lib/iomgr/systemd_utils.cc +0 -1
- data/src/core/lib/iomgr/tcp_client.h +1 -1
- data/src/core/lib/iomgr/tcp_posix.cc +23 -15
- data/src/core/lib/iomgr/tcp_server.h +1 -1
- data/src/core/lib/iomgr/tcp_server_posix.cc +2 -3
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +0 -1
- data/src/core/lib/iomgr/tcp_server_windows.cc +0 -1
- data/src/core/lib/iomgr/tcp_windows.cc +5 -10
- data/src/core/lib/iomgr/unix_sockets_posix.cc +2 -4
- data/src/core/lib/iomgr/unix_sockets_posix.h +3 -1
- data/src/core/lib/iomgr/vsock.h +3 -1
- data/src/core/lib/resource_quota/memory_quota.cc +1 -1
- data/src/core/lib/security/authorization/rbac_policy.cc +139 -56
- data/src/core/lib/security/authorization/rbac_policy.h +21 -3
- data/src/core/lib/surface/call.cc +3 -9
- data/src/core/lib/surface/call_utils.h +113 -0
- data/src/core/lib/surface/channel_create.cc +1 -1
- data/src/core/lib/surface/channel_create.h +0 -2
- data/src/core/lib/surface/channel_init.cc +77 -38
- data/src/core/lib/surface/channel_init.h +30 -16
- data/src/core/lib/surface/filter_stack_call.cc +5 -10
- data/src/core/lib/surface/init.cc +13 -27
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/error_utils.cc +0 -27
- data/src/core/lib/transport/error_utils.h +0 -16
- data/src/core/lib/transport/transport.h +7 -5
- data/src/core/load_balancing/pick_first/pick_first.cc +2 -0
- data/src/core/load_balancing/rls/rls.cc +28 -11
- data/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc +33 -42
- data/src/core/load_balancing/weighted_round_robin/weighted_round_robin.h +0 -2
- data/src/core/load_balancing/xds/cds.cc +3 -1
- data/src/core/load_balancing/xds/xds_cluster_impl.cc +0 -1
- data/src/core/mitigation_engine/mitigation.h +14 -5
- data/src/core/mitigation_engine/mitigation_engine.h +7 -3
- data/src/core/mitigation_engine/mitigation_provider.h +2 -1
- data/src/core/plugin_registry/grpc_plugin_registry.cc +39 -8
- data/src/core/resolver/dns/{event_engine/event_engine_client_channel_resolver.cc → dns_resolver.cc} +42 -41
- data/src/core/resolver/dns/{event_engine/event_engine_client_channel_resolver.h → dns_resolver.h} +8 -5
- data/src/core/resolver/dns/{event_engine/service_config_helper.cc → service_config_helper.cc} +1 -1
- data/src/core/resolver/dns/{event_engine/service_config_helper.h → service_config_helper.h} +3 -3
- data/src/core/resolver/endpoint_addresses.h +3 -0
- data/src/core/resolver/google_c2p/google_c2p_resolver.cc +2 -1
- data/src/core/resolver/xds/xds_resolver.cc +35 -9
- data/src/core/server/server.cc +2 -6
- data/src/core/server/server_config_selector.h +18 -3
- data/src/core/server/server_config_selector_filter.cc +178 -91
- data/src/core/server/server_config_selector_filter.h +58 -3
- data/src/core/server/xds_server_config_fetcher.cc +196 -129
- data/src/core/server/xds_server_config_fetcher.h +49 -0
- data/src/core/server/xds_server_config_fetcher_legacy.cc +41 -37
- data/src/core/telemetry/histogram.h +94 -14
- data/src/core/telemetry/instrument.cc +179 -74
- data/src/core/telemetry/instrument.h +78 -30
- data/src/core/telemetry/metrics.h +5 -0
- data/src/core/{resolver/dns/dns_resolver_plugin.h → telemetry/telemetry_label.h} +12 -8
- data/src/core/tsi/alts/crypt/aes_gcm.cc +10 -13
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +2 -2
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +3 -1
- data/src/core/tsi/ssl_telemetry_utils.cc +216 -259
- data/src/core/tsi/ssl_telemetry_utils.h +12 -2
- data/src/core/tsi/ssl_transport_security.cc +238 -80
- data/src/core/tsi/ssl_transport_security.h +63 -33
- data/src/core/tsi/tls_telemetry.cc +31 -0
- data/src/core/tsi/tls_telemetry.h +47 -0
- data/src/core/tsi/transport_security.cc +2 -2
- data/src/core/tsi/transport_security.h +1 -1
- data/src/core/tsi/transport_security_interface.h +1 -1
- data/src/core/{resolver/dns/native/dns_resolver.h → util/address_sorting_init.cc} +21 -8
- data/src/core/{resolver/dns/c_ares/grpc_ares_wrapper_posix.cc → util/address_sorting_init.h} +7 -8
- data/src/core/util/http_client/httpcli.cc +16 -53
- data/src/core/util/http_client/httpcli.h +0 -7
- data/src/core/util/http_client/httpcli_security_connector.cc +13 -8
- data/src/core/util/linux/cpu.cc +1 -1
- data/src/core/util/load_file.cc +3 -9
- data/src/core/util/load_file.h +3 -4
- data/src/core/util/matchers.h +8 -0
- data/src/core/util/posix/cpu.cc +1 -1
- data/src/core/util/status_helper.cc +0 -20
- data/src/core/util/status_helper.h +3 -14
- data/src/core/xds/grpc/xds_audit_logger_registry.cc +51 -31
- data/src/core/xds/grpc/xds_audit_logger_registry.h +17 -3
- data/src/core/xds/grpc/xds_bootstrap_grpc.cc +2 -10
- data/src/core/xds/grpc/xds_bootstrap_grpc.h +8 -6
- data/src/core/xds/grpc/xds_bootstrap_grpc_builder.cc +488 -0
- data/src/core/xds/grpc/xds_bootstrap_grpc_builder.h +97 -0
- data/src/core/xds/grpc/xds_certificate_provider.cc +7 -7
- data/src/core/xds/grpc/xds_client_grpc.cc +4 -8
- data/src/core/xds/grpc/xds_client_grpc.h +0 -4
- data/src/core/xds/grpc/xds_cluster.h +1 -0
- data/src/core/xds/grpc/xds_cluster_parser.cc +1 -5
- data/src/core/xds/grpc/xds_cluster_parser.h +0 -2
- data/src/core/xds/grpc/xds_cluster_specifier_plugin.cc +0 -2
- data/src/core/xds/grpc/xds_cluster_specifier_plugin.h +0 -2
- data/src/core/xds/grpc/xds_common_types.cc +0 -91
- data/src/core/xds/grpc/xds_common_types.h +1 -47
- data/src/core/xds/grpc/xds_common_types_parser.cc +84 -378
- data/src/core/xds/grpc/xds_common_types_parser.h +9 -11
- data/src/core/xds/grpc/xds_endpoint_parser.cc +0 -2
- data/src/core/xds/grpc/xds_grpc_service_parser.cc +177 -0
- data/src/core/{resolver/dns/c_ares/dns_resolver_ares.h → xds/grpc/xds_grpc_service_parser.h} +14 -9
- data/src/core/xds/grpc/xds_http_composite_filter.cc +26 -21
- data/src/core/xds/grpc/xds_http_composite_filter.h +4 -3
- data/src/core/xds/grpc/xds_http_ext_proc_filter.cc +418 -0
- data/src/core/xds/grpc/xds_http_ext_proc_filter.h +89 -0
- data/src/core/xds/grpc/xds_http_fault_filter.cc +9 -12
- data/src/core/xds/grpc/xds_http_fault_filter.h +1 -4
- data/src/core/xds/grpc/xds_http_filter.cc +2 -1
- data/src/core/xds/grpc/xds_http_filter.h +6 -5
- data/src/core/xds/grpc/xds_http_filter_registry.cc +10 -127
- data/src/core/xds/grpc/xds_http_filter_registry.h +7 -59
- data/src/core/xds/grpc/xds_http_gcp_authn_filter.cc +13 -14
- data/src/core/xds/grpc/xds_http_gcp_authn_filter.h +3 -2
- data/src/core/xds/grpc/xds_http_rbac_filter.cc +403 -25
- data/src/core/xds/grpc/xds_http_rbac_filter.h +1 -3
- data/src/core/xds/grpc/xds_http_stateful_session_filter.cc +8 -13
- data/src/core/xds/grpc/xds_http_stateful_session_filter.h +1 -4
- data/src/core/xds/grpc/xds_lb_policy_registry.cc +0 -292
- data/src/core/xds/grpc/xds_lb_policy_registry.h +7 -3
- data/src/core/xds/grpc/xds_listener.cc +2 -0
- data/src/core/xds/grpc/xds_listener.h +5 -0
- data/src/core/xds/grpc/xds_listener_parser.cc +16 -11
- data/src/core/xds/grpc/xds_matcher_parse.h +3 -1
- data/src/core/xds/grpc/xds_metadata_parser.cc +6 -1
- data/src/core/xds/grpc/xds_metadata_parser.h +2 -0
- data/src/core/xds/grpc/xds_route_config.cc +2 -0
- data/src/core/xds/grpc/xds_route_config.h +3 -1
- data/src/core/xds/grpc/xds_route_config_parser.cc +13 -79
- data/src/core/xds/grpc/xds_route_config_parser.h +0 -3
- data/src/core/xds/grpc/xds_routing.cc +116 -69
- data/src/core/xds/grpc/xds_routing.h +19 -8
- data/src/core/xds/grpc/xds_tls_context.cc +117 -0
- data/src/core/xds/grpc/xds_tls_context.h +76 -0
- data/src/core/xds/grpc/xds_tls_context_parser.cc +275 -0
- data/src/core/xds/grpc/xds_tls_context_parser.h +35 -0
- data/src/core/xds/grpc/xds_transport_grpc.cc +41 -38
- data/src/core/xds/grpc/xds_transport_grpc.h +4 -2
- data/src/ruby/ext/grpc/rb_call.c +26 -15
- data/src/ruby/ext/grpc/rb_completion_queue.c +6 -5
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/test/client.rb +5 -4
- data/src/ruby/spec/call_spec.rb +14 -0
- data/src/ruby/spec/generic/server_interceptors_spec.rb +3 -6
- metadata +50 -35
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/channelz.upbdefs.c +0 -716
- data/src/core/lib/iomgr/resolve_address.cc +0 -59
- data/src/core/lib/iomgr/resolve_address.h +0 -125
- data/src/core/lib/iomgr/resolve_address_impl.h +0 -58
- data/src/core/lib/iomgr/resolve_address_posix.cc +0 -184
- data/src/core/lib/iomgr/resolve_address_posix.h +0 -78
- data/src/core/lib/iomgr/resolve_address_windows.cc +0 -169
- data/src/core/lib/iomgr/resolve_address_windows.h +0 -76
- data/src/core/resolver/dns/c_ares/dns_resolver_ares.cc +0 -781
- data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h +0 -93
- data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +0 -203
- data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +0 -838
- data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc +0 -1237
- data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h +0 -130
- data/src/core/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +0 -35
- data/src/core/resolver/dns/dns_resolver_plugin.cc +0 -64
- data/src/core/resolver/dns/native/dns_resolver.cc +0 -173
- data/src/core/util/json/json_util.cc +0 -101
- data/src/core/util/json/json_util.h +0 -163
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// Copyright 2016 gRPC authors.
|
|
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
|
-
//
|
|
18
|
-
|
|
19
|
-
#ifndef GRPC_SRC_CORE_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H
|
|
20
|
-
#define GRPC_SRC_CORE_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H
|
|
21
|
-
|
|
22
|
-
#include <grpc/support/port_platform.h>
|
|
23
|
-
#include <stddef.h>
|
|
24
|
-
|
|
25
|
-
#include <memory>
|
|
26
|
-
|
|
27
|
-
#include "src/core/lib/debug/trace.h"
|
|
28
|
-
#include "src/core/lib/iomgr/closure.h"
|
|
29
|
-
#include "src/core/lib/iomgr/error.h"
|
|
30
|
-
#include "src/core/lib/iomgr/iomgr_fwd.h"
|
|
31
|
-
#include "src/core/resolver/endpoint_addresses.h"
|
|
32
|
-
#include "src/core/util/sync.h"
|
|
33
|
-
#include "absl/base/thread_annotations.h"
|
|
34
|
-
#include "absl/log/log.h"
|
|
35
|
-
|
|
36
|
-
#if GRPC_ARES == 1
|
|
37
|
-
|
|
38
|
-
#include <ares.h>
|
|
39
|
-
|
|
40
|
-
#define GRPC_DNS_ARES_DEFAULT_QUERY_TIMEOUT_MS 120000
|
|
41
|
-
|
|
42
|
-
typedef struct grpc_ares_ev_driver grpc_ares_ev_driver;
|
|
43
|
-
|
|
44
|
-
struct grpc_ares_request {
|
|
45
|
-
/// synchronizes access to this request, and also to associated
|
|
46
|
-
/// ev_driver and fd_node objects
|
|
47
|
-
grpc_core::Mutex mu;
|
|
48
|
-
/// indicates the DNS server to use, if specified
|
|
49
|
-
struct ares_addr_port_node dns_server_addr ABSL_GUARDED_BY(mu);
|
|
50
|
-
/// following members are set in grpc_resolve_address_ares_impl
|
|
51
|
-
/// closure to call when the request completes
|
|
52
|
-
grpc_closure* on_done ABSL_GUARDED_BY(mu) = nullptr;
|
|
53
|
-
/// the pointer to receive the resolved addresses
|
|
54
|
-
std::unique_ptr<grpc_core::EndpointAddressesList>* addresses_out
|
|
55
|
-
ABSL_GUARDED_BY(mu);
|
|
56
|
-
/// the pointer to receive the resolved balancer addresses
|
|
57
|
-
std::unique_ptr<grpc_core::EndpointAddressesList>* balancer_addresses_out
|
|
58
|
-
ABSL_GUARDED_BY(mu);
|
|
59
|
-
/// the pointer to receive the service config in JSON
|
|
60
|
-
char** service_config_json_out ABSL_GUARDED_BY(mu) = nullptr;
|
|
61
|
-
/// the event driver used by this request
|
|
62
|
-
grpc_ares_ev_driver* ev_driver ABSL_GUARDED_BY(mu) = nullptr;
|
|
63
|
-
/// number of ongoing queries
|
|
64
|
-
size_t pending_queries ABSL_GUARDED_BY(mu) = 0;
|
|
65
|
-
/// the errors explaining query failures, appended to in query callbacks
|
|
66
|
-
grpc_error_handle error ABSL_GUARDED_BY(mu);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// Asynchronously resolve \a name (A/AAAA records only).
|
|
70
|
-
// It uses \a default_port if a port isn't designated in \a name, otherwise it
|
|
71
|
-
// uses the port in \a name. grpc_ares_init() must be called at least once
|
|
72
|
-
// before this function. The returned grpc_ares_request object is owned by the
|
|
73
|
-
// caller and it is safe to free after on_done is called back.
|
|
74
|
-
|
|
75
|
-
// Note on synchronization: \a as on_done might be called from another thread
|
|
76
|
-
//~immediately, access to the grpc_ares_request* return value must be
|
|
77
|
-
// synchronized by the caller. TODO(apolcyn): we should remove this requirement
|
|
78
|
-
// by changing this API to use two phase initialization - one API to create
|
|
79
|
-
// the grpc_ares_request* and another to start the async work.
|
|
80
|
-
extern grpc_ares_request* (*grpc_dns_lookup_hostname_ares)(
|
|
81
|
-
const char* dns_server, const char* name, const char* default_port,
|
|
82
|
-
grpc_pollset_set* interested_parties, grpc_closure* on_done,
|
|
83
|
-
std::unique_ptr<grpc_core::EndpointAddressesList>* addresses,
|
|
84
|
-
int query_timeout_ms);
|
|
85
|
-
|
|
86
|
-
// Asynchronously resolve a SRV record.
|
|
87
|
-
// See \a grpc_dns_lookup_hostname_ares for usage details and caveats.
|
|
88
|
-
extern grpc_ares_request* (*grpc_dns_lookup_srv_ares)(
|
|
89
|
-
const char* dns_server, const char* name,
|
|
90
|
-
grpc_pollset_set* interested_parties, grpc_closure* on_done,
|
|
91
|
-
std::unique_ptr<grpc_core::EndpointAddressesList>* balancer_addresses,
|
|
92
|
-
int query_timeout_ms);
|
|
93
|
-
|
|
94
|
-
// Asynchronously resolve a TXT record.
|
|
95
|
-
// See \a grpc_dns_lookup_hostname_ares for usage details and caveats.
|
|
96
|
-
extern grpc_ares_request* (*grpc_dns_lookup_txt_ares)(
|
|
97
|
-
const char* dns_server, const char* name,
|
|
98
|
-
grpc_pollset_set* interested_parties, grpc_closure* on_done,
|
|
99
|
-
char** service_config_json, int query_timeout_ms);
|
|
100
|
-
|
|
101
|
-
// Cancel the pending grpc_ares_request \a request
|
|
102
|
-
extern void (*grpc_cancel_ares_request)(grpc_ares_request* request);
|
|
103
|
-
|
|
104
|
-
// Initialize gRPC ares wrapper. Must be called at least once before
|
|
105
|
-
// grpc_resolve_address_ares().
|
|
106
|
-
grpc_error_handle grpc_ares_init(void);
|
|
107
|
-
|
|
108
|
-
// Uninitialized gRPC ares wrapper. If there was more than one previous call to
|
|
109
|
-
// grpc_ares_init(), this function uninitializes the gRPC ares wrapper only if
|
|
110
|
-
// it has been called the same number of times as grpc_ares_init().
|
|
111
|
-
void grpc_ares_cleanup(void);
|
|
112
|
-
|
|
113
|
-
// Indicates whether or not AAAA queries should be attempted.
|
|
114
|
-
// E.g., return false if ipv6 is known to not be available.
|
|
115
|
-
bool grpc_ares_query_ipv6();
|
|
116
|
-
|
|
117
|
-
// Sorts destinations in lb_addrs according to RFC 6724.
|
|
118
|
-
void grpc_cares_wrapper_address_sorting_sort(
|
|
119
|
-
const grpc_ares_request* request,
|
|
120
|
-
grpc_core::EndpointAddressesList* addresses);
|
|
121
|
-
|
|
122
|
-
// Exposed in this header for C-core tests only
|
|
123
|
-
extern void (*grpc_ares_test_only_inject_config)(ares_channel* channel);
|
|
124
|
-
|
|
125
|
-
// Exposed in this header for C-core tests only
|
|
126
|
-
extern bool g_grpc_ares_test_only_force_tcp;
|
|
127
|
-
|
|
128
|
-
#endif
|
|
129
|
-
|
|
130
|
-
#endif // GRPC_SRC_CORE_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// Copyright 2016 gRPC authors.
|
|
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
|
-
//
|
|
18
|
-
|
|
19
|
-
#include <grpc/support/port_platform.h>
|
|
20
|
-
|
|
21
|
-
#include "src/core/lib/iomgr/port.h" // IWYU pragma: keep
|
|
22
|
-
|
|
23
|
-
#if GRPC_ARES == 1 && defined(GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER)
|
|
24
|
-
|
|
25
|
-
#include <grpc/support/string_util.h>
|
|
26
|
-
|
|
27
|
-
#include "src/core/lib/address_utils/parse_address.h"
|
|
28
|
-
#include "src/core/lib/iomgr/socket_windows.h"
|
|
29
|
-
#include "src/core/resolver/dns/c_ares/grpc_ares_wrapper.h"
|
|
30
|
-
#include "src/core/resolver/endpoint_addresses.h"
|
|
31
|
-
#include "src/core/util/string.h"
|
|
32
|
-
|
|
33
|
-
bool grpc_ares_query_ipv6() { return grpc_ipv6_loopback_available(); }
|
|
34
|
-
|
|
35
|
-
#endif // GRPC_ARES == 1 && defined(GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER)
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// Copyright 2022 The gRPC Authors
|
|
2
|
-
//
|
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
// you may not use this file except in compliance with the License.
|
|
5
|
-
// You may obtain a copy of the License at
|
|
6
|
-
//
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
//
|
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
// See the License for the specific language governing permissions and
|
|
13
|
-
// limitations under the License.
|
|
14
|
-
#include "src/core/resolver/dns/dns_resolver_plugin.h"
|
|
15
|
-
|
|
16
|
-
#include <grpc/support/port_platform.h>
|
|
17
|
-
|
|
18
|
-
#include <memory>
|
|
19
|
-
|
|
20
|
-
#include "src/core/config/config_vars.h"
|
|
21
|
-
#include "src/core/lib/experiments/experiments.h"
|
|
22
|
-
#include "src/core/resolver/dns/c_ares/dns_resolver_ares.h"
|
|
23
|
-
#include "src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.h"
|
|
24
|
-
#include "src/core/resolver/dns/native/dns_resolver.h"
|
|
25
|
-
#include "src/core/resolver/resolver_factory.h"
|
|
26
|
-
#include "src/core/util/crash.h"
|
|
27
|
-
#include "absl/log/log.h"
|
|
28
|
-
#include "absl/strings/match.h"
|
|
29
|
-
|
|
30
|
-
namespace grpc_core {
|
|
31
|
-
|
|
32
|
-
void RegisterDnsResolver(CoreConfiguration::Builder* builder) {
|
|
33
|
-
#if GRPC_IOS_EVENT_ENGINE_CLIENT
|
|
34
|
-
VLOG(2) << "Using EventEngine dns resolver";
|
|
35
|
-
builder->resolver_registry()->RegisterResolverFactory(
|
|
36
|
-
std::make_unique<EventEngineClientChannelDNSResolverFactory>());
|
|
37
|
-
return;
|
|
38
|
-
#endif
|
|
39
|
-
if (IsEventEngineDnsEnabled()) {
|
|
40
|
-
VLOG(2) << "Using EventEngine dns resolver";
|
|
41
|
-
builder->resolver_registry()->RegisterResolverFactory(
|
|
42
|
-
std::make_unique<EventEngineClientChannelDNSResolverFactory>());
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
auto resolver = ConfigVars::Get().DnsResolver();
|
|
46
|
-
// ---- Ares resolver ----
|
|
47
|
-
if (ShouldUseAresDnsResolver(resolver)) {
|
|
48
|
-
VLOG(2) << "Using ares dns resolver";
|
|
49
|
-
RegisterAresDnsResolver(builder);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
// ---- Native resolver ----
|
|
53
|
-
if (absl::EqualsIgnoreCase(resolver, "native") ||
|
|
54
|
-
!builder->resolver_registry()->HasResolverFactory("dns")) {
|
|
55
|
-
VLOG(2) << "Using native dns resolver";
|
|
56
|
-
RegisterNativeDnsResolver(builder);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
Crash(
|
|
60
|
-
"Unable to set DNS resolver! Likely a logic error in gRPC-core, "
|
|
61
|
-
"please file a bug.");
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
} // namespace grpc_core
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2015 gRPC authors.
|
|
3
|
-
//
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// you may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
//
|
|
8
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
//
|
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
// See the License for the specific language governing permissions and
|
|
14
|
-
// limitations under the License.
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
#include <grpc/impl/channel_arg_names.h>
|
|
18
|
-
#include <grpc/support/port_platform.h>
|
|
19
|
-
|
|
20
|
-
#include <algorithm>
|
|
21
|
-
#include <memory>
|
|
22
|
-
#include <optional>
|
|
23
|
-
#include <utility>
|
|
24
|
-
#include <vector>
|
|
25
|
-
|
|
26
|
-
#include "src/core/config/core_configuration.h"
|
|
27
|
-
#include "src/core/lib/channel/channel_args.h"
|
|
28
|
-
#include "src/core/lib/debug/trace.h"
|
|
29
|
-
#include "src/core/lib/iomgr/resolve_address.h"
|
|
30
|
-
#include "src/core/lib/iomgr/resolved_address.h"
|
|
31
|
-
#include "src/core/resolver/endpoint_addresses.h"
|
|
32
|
-
#include "src/core/resolver/polling_resolver.h"
|
|
33
|
-
#include "src/core/resolver/resolver.h"
|
|
34
|
-
#include "src/core/resolver/resolver_factory.h"
|
|
35
|
-
#include "src/core/util/backoff.h"
|
|
36
|
-
#include "src/core/util/debug_location.h"
|
|
37
|
-
#include "src/core/util/orphanable.h"
|
|
38
|
-
#include "src/core/util/ref_counted_ptr.h"
|
|
39
|
-
#include "src/core/util/time.h"
|
|
40
|
-
#include "src/core/util/uri.h"
|
|
41
|
-
#include "absl/functional/bind_front.h"
|
|
42
|
-
#include "absl/log/log.h"
|
|
43
|
-
#include "absl/status/status.h"
|
|
44
|
-
#include "absl/status/statusor.h"
|
|
45
|
-
#include "absl/strings/str_cat.h"
|
|
46
|
-
#include "absl/strings/string_view.h"
|
|
47
|
-
#include "absl/strings/strip.h"
|
|
48
|
-
|
|
49
|
-
#define GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS 1
|
|
50
|
-
#define GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER 1.6
|
|
51
|
-
#define GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS 120
|
|
52
|
-
#define GRPC_DNS_RECONNECT_JITTER 0.2
|
|
53
|
-
|
|
54
|
-
namespace grpc_core {
|
|
55
|
-
|
|
56
|
-
namespace {
|
|
57
|
-
|
|
58
|
-
class NativeClientChannelDNSResolver final : public PollingResolver {
|
|
59
|
-
public:
|
|
60
|
-
NativeClientChannelDNSResolver(ResolverArgs args,
|
|
61
|
-
Duration min_time_between_resolutions);
|
|
62
|
-
~NativeClientChannelDNSResolver() override;
|
|
63
|
-
|
|
64
|
-
OrphanablePtr<Orphanable> StartRequest() override;
|
|
65
|
-
|
|
66
|
-
private:
|
|
67
|
-
// No-op request class, used so that the PollingResolver code knows
|
|
68
|
-
// when there is a request in flight, even if the request is not
|
|
69
|
-
// actually cancellable.
|
|
70
|
-
class Request final : public Orphanable {
|
|
71
|
-
public:
|
|
72
|
-
Request() = default;
|
|
73
|
-
|
|
74
|
-
void Orphan() override { delete this; }
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
void OnResolved(
|
|
78
|
-
absl::StatusOr<std::vector<grpc_resolved_address>> addresses_or);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
NativeClientChannelDNSResolver::NativeClientChannelDNSResolver(
|
|
82
|
-
ResolverArgs args, Duration min_time_between_resolutions)
|
|
83
|
-
: PollingResolver(std::move(args), min_time_between_resolutions,
|
|
84
|
-
BackOff::Options()
|
|
85
|
-
.set_initial_backoff(Duration::Milliseconds(
|
|
86
|
-
GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS * 1000))
|
|
87
|
-
.set_multiplier(GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER)
|
|
88
|
-
.set_jitter(GRPC_DNS_RECONNECT_JITTER)
|
|
89
|
-
.set_max_backoff(Duration::Milliseconds(
|
|
90
|
-
GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS * 1000)),
|
|
91
|
-
&dns_resolver_trace) {
|
|
92
|
-
GRPC_TRACE_VLOG(dns_resolver, 2) << "[dns_resolver=" << this << "] created";
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
NativeClientChannelDNSResolver::~NativeClientChannelDNSResolver() {
|
|
96
|
-
GRPC_TRACE_VLOG(dns_resolver, 2) << "[dns_resolver=" << this << "] destroyed";
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
OrphanablePtr<Orphanable> NativeClientChannelDNSResolver::StartRequest() {
|
|
100
|
-
Ref(DEBUG_LOCATION, "dns_request").release();
|
|
101
|
-
auto dns_request_handle = GetDNSResolver()->LookupHostname(
|
|
102
|
-
absl::bind_front(&NativeClientChannelDNSResolver::OnResolved, this),
|
|
103
|
-
name_to_resolve(), kDefaultSecurePort, kDefaultDNSRequestTimeout,
|
|
104
|
-
interested_parties(), /*name_server=*/"");
|
|
105
|
-
GRPC_TRACE_VLOG(dns_resolver, 2)
|
|
106
|
-
<< "[dns_resolver=" << this << "] starting request="
|
|
107
|
-
<< DNSResolver::HandleToString(dns_request_handle);
|
|
108
|
-
return MakeOrphanable<Request>();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
void NativeClientChannelDNSResolver::OnResolved(
|
|
112
|
-
absl::StatusOr<std::vector<grpc_resolved_address>> addresses_or) {
|
|
113
|
-
GRPC_TRACE_VLOG(dns_resolver, 2)
|
|
114
|
-
<< "[dns_resolver=" << this
|
|
115
|
-
<< "] request complete, status=" << addresses_or.status();
|
|
116
|
-
// Convert result from iomgr DNS API into Resolver::Result.
|
|
117
|
-
Result result;
|
|
118
|
-
if (addresses_or.ok()) {
|
|
119
|
-
EndpointAddressesList addresses;
|
|
120
|
-
for (auto& addr : *addresses_or) {
|
|
121
|
-
addresses.emplace_back(addr, ChannelArgs());
|
|
122
|
-
}
|
|
123
|
-
result.addresses = std::move(addresses);
|
|
124
|
-
} else {
|
|
125
|
-
result.addresses = absl::UnavailableError(
|
|
126
|
-
absl::StrCat("DNS resolution failed for ", name_to_resolve(), ": ",
|
|
127
|
-
addresses_or.status().ToString()));
|
|
128
|
-
}
|
|
129
|
-
result.args = channel_args();
|
|
130
|
-
OnRequestComplete(std::move(result));
|
|
131
|
-
Unref(DEBUG_LOCATION, "dns_request");
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
//
|
|
135
|
-
// Factory
|
|
136
|
-
//
|
|
137
|
-
|
|
138
|
-
class NativeClientChannelDNSResolverFactory final : public ResolverFactory {
|
|
139
|
-
public:
|
|
140
|
-
absl::string_view scheme() const override { return "dns"; }
|
|
141
|
-
|
|
142
|
-
bool IsValidUri(const URI& uri) const override {
|
|
143
|
-
if (GPR_UNLIKELY(!uri.authority().empty())) {
|
|
144
|
-
LOG(ERROR) << "authority based dns uri's not supported";
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
if (absl::StripPrefix(uri.path(), "/").empty()) {
|
|
148
|
-
LOG(ERROR) << "no server name supplied in dns URI";
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
return true;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
OrphanablePtr<Resolver> CreateResolver(ResolverArgs args) const override {
|
|
155
|
-
if (!IsValidUri(args.uri)) return nullptr;
|
|
156
|
-
Duration min_time_between_resolutions = std::max(
|
|
157
|
-
Duration::Zero(), args.args
|
|
158
|
-
.GetDurationFromIntMillis(
|
|
159
|
-
GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS)
|
|
160
|
-
.value_or(Duration::Seconds(30)));
|
|
161
|
-
return MakeOrphanable<NativeClientChannelDNSResolver>(
|
|
162
|
-
std::move(args), min_time_between_resolutions);
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
} // namespace
|
|
167
|
-
|
|
168
|
-
void RegisterNativeDnsResolver(CoreConfiguration::Builder* builder) {
|
|
169
|
-
builder->resolver_registry()->RegisterResolverFactory(
|
|
170
|
-
std::make_unique<NativeClientChannelDNSResolverFactory>());
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
} // namespace grpc_core
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// Copyright 2020 gRPC authors.
|
|
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
|
-
//
|
|
18
|
-
|
|
19
|
-
#include "src/core/util/json/json_util.h"
|
|
20
|
-
|
|
21
|
-
#include <grpc/support/port_platform.h>
|
|
22
|
-
|
|
23
|
-
#include "src/core/util/json/json_args.h"
|
|
24
|
-
#include "src/core/util/json/json_object_loader.h"
|
|
25
|
-
#include "src/core/util/no_destruct.h"
|
|
26
|
-
#include "src/core/util/validation_errors.h"
|
|
27
|
-
|
|
28
|
-
namespace grpc_core {
|
|
29
|
-
|
|
30
|
-
bool ParseDurationFromJson(const Json& field, Duration* duration) {
|
|
31
|
-
ValidationErrors errors;
|
|
32
|
-
static_cast<json_detail::LoaderInterface*>(
|
|
33
|
-
NoDestructSingleton<json_detail::AutoLoader<Duration>>::Get())
|
|
34
|
-
->LoadInto(field, JsonArgs(), duration, &errors);
|
|
35
|
-
return errors.ok();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
bool ExtractJsonBool(const Json& json, absl::string_view field_name,
|
|
39
|
-
bool* output, std::vector<grpc_error_handle>* error_list) {
|
|
40
|
-
if (json.type() != Json::Type::kBoolean) {
|
|
41
|
-
error_list->push_back(GRPC_ERROR_CREATE(
|
|
42
|
-
absl::StrCat("field:", field_name, " error:type should be BOOLEAN")));
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
*output = json.boolean();
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
bool ExtractJsonArray(const Json& json, absl::string_view field_name,
|
|
50
|
-
const Json::Array** output,
|
|
51
|
-
std::vector<grpc_error_handle>* error_list) {
|
|
52
|
-
if (json.type() != Json::Type::kArray) {
|
|
53
|
-
*output = nullptr;
|
|
54
|
-
error_list->push_back(GRPC_ERROR_CREATE(
|
|
55
|
-
absl::StrCat("field:", field_name, " error:type should be ARRAY")));
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
*output = &json.array();
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
bool ExtractJsonObject(const Json& json, absl::string_view field_name,
|
|
63
|
-
const Json::Object** output,
|
|
64
|
-
std::vector<grpc_error_handle>* error_list) {
|
|
65
|
-
if (json.type() != Json::Type::kObject) {
|
|
66
|
-
*output = nullptr;
|
|
67
|
-
error_list->push_back(GRPC_ERROR_CREATE(
|
|
68
|
-
absl::StrCat("field:", field_name, " error:type should be OBJECT")));
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
*output = &json.object();
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
bool ParseJsonObjectFieldAsDuration(const Json::Object& object,
|
|
76
|
-
absl::string_view field_name,
|
|
77
|
-
Duration* output,
|
|
78
|
-
std::vector<grpc_error_handle>* error_list,
|
|
79
|
-
bool required) {
|
|
80
|
-
// TODO(roth): Once we can use C++14 heterogenous lookups, stop
|
|
81
|
-
// creating a std::string here.
|
|
82
|
-
auto it = object.find(std::string(field_name));
|
|
83
|
-
if (it == object.end()) {
|
|
84
|
-
if (required) {
|
|
85
|
-
error_list->push_back(GRPC_ERROR_CREATE(
|
|
86
|
-
absl::StrCat("field:", field_name, " error:does not exist.")));
|
|
87
|
-
}
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
if (!ParseDurationFromJson(it->second, output)) {
|
|
91
|
-
*output = Duration::NegativeInfinity();
|
|
92
|
-
error_list->push_back(GRPC_ERROR_CREATE(
|
|
93
|
-
absl::StrCat("field:", field_name,
|
|
94
|
-
" error:type should be STRING of the form given by "
|
|
95
|
-
"google.proto.Duration.")));
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
} // namespace grpc_core
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// Copyright 2020 gRPC authors.
|
|
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
|
-
//
|
|
18
|
-
|
|
19
|
-
#ifndef GRPC_SRC_CORE_UTIL_JSON_JSON_UTIL_H
|
|
20
|
-
#define GRPC_SRC_CORE_UTIL_JSON_JSON_UTIL_H
|
|
21
|
-
|
|
22
|
-
#include <grpc/support/port_platform.h>
|
|
23
|
-
|
|
24
|
-
#include <algorithm>
|
|
25
|
-
#include <map>
|
|
26
|
-
#include <string>
|
|
27
|
-
#include <type_traits>
|
|
28
|
-
#include <utility>
|
|
29
|
-
#include <vector>
|
|
30
|
-
|
|
31
|
-
#include "src/core/lib/iomgr/error.h"
|
|
32
|
-
#include "src/core/util/json/json.h"
|
|
33
|
-
#include "src/core/util/time.h"
|
|
34
|
-
#include "absl/strings/numbers.h"
|
|
35
|
-
#include "absl/strings/str_cat.h"
|
|
36
|
-
#include "absl/strings/string_view.h"
|
|
37
|
-
|
|
38
|
-
namespace grpc_core {
|
|
39
|
-
|
|
40
|
-
// Parses a JSON field of the form generated for a google.proto.Duration
|
|
41
|
-
// proto message, as per:
|
|
42
|
-
// https://developers.google.com/protocol-buffers/docs/proto3#json
|
|
43
|
-
// Returns true on success, false otherwise.
|
|
44
|
-
bool ParseDurationFromJson(const Json& field, Duration* duration);
|
|
45
|
-
|
|
46
|
-
//
|
|
47
|
-
// Helper functions for extracting types from JSON.
|
|
48
|
-
// Return true on success, false otherwise. If an error is encountered during
|
|
49
|
-
// parsing, a descriptive error is appended to \a error_list.
|
|
50
|
-
//
|
|
51
|
-
template <typename NumericType>
|
|
52
|
-
bool ExtractJsonNumber(const Json& json, absl::string_view field_name,
|
|
53
|
-
NumericType* output,
|
|
54
|
-
std::vector<grpc_error_handle>* error_list) {
|
|
55
|
-
static_assert(std::is_integral<NumericType>::value, "Integral required");
|
|
56
|
-
if (json.type() != Json::Type::kNumber &&
|
|
57
|
-
json.type() != Json::Type::kString) {
|
|
58
|
-
error_list->push_back(GRPC_ERROR_CREATE(absl::StrCat(
|
|
59
|
-
"field:", field_name, " error:type should be NUMBER or STRING")));
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
if (!absl::SimpleAtoi(json.string(), output)) {
|
|
63
|
-
error_list->push_back(GRPC_ERROR_CREATE(
|
|
64
|
-
absl::StrCat("field:", field_name, " error:failed to parse.")));
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
bool ExtractJsonBool(const Json& json, absl::string_view field_name,
|
|
71
|
-
bool* output, std::vector<grpc_error_handle>* error_list);
|
|
72
|
-
|
|
73
|
-
// OutputType can be std::string or absl::string_view.
|
|
74
|
-
template <typename OutputType>
|
|
75
|
-
bool ExtractJsonString(const Json& json, absl::string_view field_name,
|
|
76
|
-
OutputType* output,
|
|
77
|
-
std::vector<grpc_error_handle>* error_list) {
|
|
78
|
-
if (json.type() != Json::Type::kString) {
|
|
79
|
-
*output = "";
|
|
80
|
-
error_list->push_back(GRPC_ERROR_CREATE(
|
|
81
|
-
absl::StrCat("field:", field_name, " error:type should be STRING")));
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
*output = json.string();
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
bool ExtractJsonArray(const Json& json, absl::string_view field_name,
|
|
89
|
-
const Json::Array** output,
|
|
90
|
-
std::vector<grpc_error_handle>* error_list);
|
|
91
|
-
|
|
92
|
-
bool ExtractJsonObject(const Json& json, absl::string_view field_name,
|
|
93
|
-
const Json::Object** output,
|
|
94
|
-
std::vector<grpc_error_handle>* error_list);
|
|
95
|
-
|
|
96
|
-
// Wrappers for automatically choosing one of the above functions based
|
|
97
|
-
// on output parameter type.
|
|
98
|
-
template <typename NumericType>
|
|
99
|
-
inline bool ExtractJsonType(const Json& json, absl::string_view field_name,
|
|
100
|
-
NumericType* output,
|
|
101
|
-
std::vector<grpc_error_handle>* error_list) {
|
|
102
|
-
return ExtractJsonNumber(json, field_name, output, error_list);
|
|
103
|
-
}
|
|
104
|
-
inline bool ExtractJsonType(const Json& json, absl::string_view field_name,
|
|
105
|
-
bool* output,
|
|
106
|
-
std::vector<grpc_error_handle>* error_list) {
|
|
107
|
-
return ExtractJsonBool(json, field_name, output, error_list);
|
|
108
|
-
}
|
|
109
|
-
inline bool ExtractJsonType(const Json& json, absl::string_view field_name,
|
|
110
|
-
std::string* output,
|
|
111
|
-
std::vector<grpc_error_handle>* error_list) {
|
|
112
|
-
return ExtractJsonString(json, field_name, output, error_list);
|
|
113
|
-
}
|
|
114
|
-
inline bool ExtractJsonType(const Json& json, absl::string_view field_name,
|
|
115
|
-
absl::string_view* output,
|
|
116
|
-
std::vector<grpc_error_handle>* error_list) {
|
|
117
|
-
return ExtractJsonString(json, field_name, output, error_list);
|
|
118
|
-
}
|
|
119
|
-
inline bool ExtractJsonType(const Json& json, absl::string_view field_name,
|
|
120
|
-
const Json::Array** output,
|
|
121
|
-
std::vector<grpc_error_handle>* error_list) {
|
|
122
|
-
return ExtractJsonArray(json, field_name, output, error_list);
|
|
123
|
-
}
|
|
124
|
-
inline bool ExtractJsonType(const Json& json, absl::string_view field_name,
|
|
125
|
-
const Json::Object** output,
|
|
126
|
-
std::vector<grpc_error_handle>* error_list) {
|
|
127
|
-
return ExtractJsonObject(json, field_name, output, error_list);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Extracts a field from a JSON object, automatically selecting the type
|
|
131
|
-
// of parsing based on the output parameter type.
|
|
132
|
-
// If the field is not present, returns false, and if required is true,
|
|
133
|
-
// adds an error to error_list.
|
|
134
|
-
// Upon any other error, adds an error to error_list and returns false.
|
|
135
|
-
template <typename T>
|
|
136
|
-
bool ParseJsonObjectField(const Json::Object& object,
|
|
137
|
-
absl::string_view field_name, T* output,
|
|
138
|
-
std::vector<grpc_error_handle>* error_list,
|
|
139
|
-
bool required = true) {
|
|
140
|
-
// TODO(roth): Once we can use C++14 heterogenous lookups, stop
|
|
141
|
-
// creating a std::string here.
|
|
142
|
-
auto it = object.find(std::string(field_name));
|
|
143
|
-
if (it == object.end()) {
|
|
144
|
-
if (required) {
|
|
145
|
-
error_list->push_back(GRPC_ERROR_CREATE(
|
|
146
|
-
absl::StrCat("field:", field_name, " error:does not exist.")));
|
|
147
|
-
}
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
auto& child_object_json = it->second;
|
|
151
|
-
return ExtractJsonType(child_object_json, field_name, output, error_list);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Alternative to ParseJsonObjectField() for duration-value fields.
|
|
155
|
-
bool ParseJsonObjectFieldAsDuration(const Json::Object& object,
|
|
156
|
-
absl::string_view field_name,
|
|
157
|
-
Duration* output,
|
|
158
|
-
std::vector<grpc_error_handle>* error_list,
|
|
159
|
-
bool required = true);
|
|
160
|
-
|
|
161
|
-
} // namespace grpc_core
|
|
162
|
-
|
|
163
|
-
#endif // GRPC_SRC_CORE_UTIL_JSON_JSON_UTIL_H
|