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
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
#include "src/core/util/string.h"
|
|
71
71
|
#include "src/core/util/sync.h"
|
|
72
72
|
#include "src/core/util/time.h"
|
|
73
|
+
#include "src/core/util/useful.h"
|
|
73
74
|
#include "absl/base/thread_annotations.h"
|
|
74
75
|
#include "absl/log/log.h"
|
|
75
76
|
#include "absl/status/status.h"
|
|
@@ -478,6 +479,7 @@ struct grpc_tcp {
|
|
|
478
479
|
explicit grpc_tcp(const grpc_core::PosixTcpOptions& tcp_options)
|
|
479
480
|
: min_read_chunk_size(tcp_options.tcp_min_read_chunk_size),
|
|
480
481
|
max_read_chunk_size(tcp_options.tcp_max_read_chunk_size),
|
|
482
|
+
max_read_buffer_size(tcp_options.tcp_max_read_buffer_size),
|
|
481
483
|
tcp_zerocopy_send_ctx(
|
|
482
484
|
tcp_options.tcp_tx_zerocopy_max_simultaneous_sends,
|
|
483
485
|
tcp_options.tcp_tx_zerocopy_send_bytes_threshold) {}
|
|
@@ -492,6 +494,7 @@ struct grpc_tcp {
|
|
|
492
494
|
|
|
493
495
|
int min_read_chunk_size;
|
|
494
496
|
int max_read_chunk_size;
|
|
497
|
+
int max_read_buffer_size;
|
|
495
498
|
|
|
496
499
|
// garbage after the last read
|
|
497
500
|
grpc_slice_buffer last_read_buffer;
|
|
@@ -736,17 +739,17 @@ static void finish_estimate(grpc_tcp* tcp) {
|
|
|
736
739
|
tcp->target_length =
|
|
737
740
|
0.99 * tcp->target_length + 0.01 * tcp->bytes_read_this_round;
|
|
738
741
|
}
|
|
742
|
+
// Opt-in: if a maximum read buffer size has been configured, clamp the
|
|
743
|
+
// adaptive target so that occasional large reads do not leave a permanently
|
|
744
|
+
// high read-buffer high-watermark. When unset (max_read_buffer_size < 0) the
|
|
745
|
+
// behavior is unchanged.
|
|
746
|
+
if (tcp->max_read_buffer_size >= 0 &&
|
|
747
|
+
tcp->target_length > static_cast<double>(tcp->max_read_buffer_size)) {
|
|
748
|
+
tcp->target_length = static_cast<double>(tcp->max_read_buffer_size);
|
|
749
|
+
}
|
|
739
750
|
tcp->bytes_read_this_round = 0;
|
|
740
751
|
}
|
|
741
752
|
|
|
742
|
-
static grpc_error_handle tcp_annotate_error(grpc_error_handle src_error) {
|
|
743
|
-
return grpc_error_set_int(src_error,
|
|
744
|
-
// All tcp errors are marked with UNAVAILABLE so
|
|
745
|
-
// that application may choose to retry.
|
|
746
|
-
grpc_core::StatusIntProperty::kRpcStatus,
|
|
747
|
-
GRPC_STATUS_UNAVAILABLE);
|
|
748
|
-
}
|
|
749
|
-
|
|
750
753
|
static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error_handle error);
|
|
751
754
|
static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error_handle error);
|
|
752
755
|
|
|
@@ -975,10 +978,10 @@ static bool tcp_do_read(grpc_tcp* tcp, grpc_error_handle* error)
|
|
|
975
978
|
// 0 read size ==> end of stream
|
|
976
979
|
grpc_slice_buffer_reset_and_unref(tcp->incoming_buffer);
|
|
977
980
|
if (read_bytes == 0) {
|
|
978
|
-
*error =
|
|
981
|
+
*error = absl::UnavailableError("Socket closed");
|
|
979
982
|
} else {
|
|
980
|
-
*error =
|
|
981
|
-
absl::StrCat("recvmsg:", grpc_core::StrError(saved_errno)))
|
|
983
|
+
*error = absl::UnavailableError(
|
|
984
|
+
absl::StrCat("recvmsg:", grpc_core::StrError(saved_errno)));
|
|
982
985
|
}
|
|
983
986
|
return true;
|
|
984
987
|
}
|
|
@@ -1126,7 +1129,7 @@ static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error_handle error) {
|
|
|
1126
1129
|
tcp_trace_read(tcp, tcp_read_error);
|
|
1127
1130
|
} else {
|
|
1128
1131
|
if (!tcp->memory_owner.is_valid() && error.ok()) {
|
|
1129
|
-
tcp_read_error =
|
|
1132
|
+
tcp_read_error = absl::UnavailableError("Socket closed");
|
|
1130
1133
|
} else {
|
|
1131
1134
|
tcp_read_error = error;
|
|
1132
1135
|
}
|
|
@@ -1563,6 +1566,11 @@ void TcpZerocopySendRecord::UpdateOffsetForBytesSent(size_t sending_length,
|
|
|
1563
1566
|
}
|
|
1564
1567
|
}
|
|
1565
1568
|
|
|
1569
|
+
static absl::Status OSError(int err, absl::string_view call_name) {
|
|
1570
|
+
return absl::UnavailableError(
|
|
1571
|
+
absl::StrCat(call_name, ": ", grpc_core::StrError(err), " (", err, ")"));
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1566
1574
|
// returns true if done, false if pending; if returning true, *error is set
|
|
1567
1575
|
static bool do_tcp_flush_zerocopy(grpc_tcp* tcp, TcpZerocopySendRecord* record,
|
|
1568
1576
|
grpc_error_handle* error) {
|
|
@@ -1625,7 +1633,7 @@ static bool do_tcp_flush_zerocopy(grpc_tcp* tcp, TcpZerocopySendRecord* record,
|
|
|
1625
1633
|
record->UnwindIfThrottled(unwind_slice_idx, unwind_byte_idx);
|
|
1626
1634
|
return false;
|
|
1627
1635
|
} else {
|
|
1628
|
-
*error =
|
|
1636
|
+
*error = OSError(saved_errno, "sendmsg");
|
|
1629
1637
|
tcp_shutdown_buffer_list(tcp);
|
|
1630
1638
|
return true;
|
|
1631
1639
|
}
|
|
@@ -1735,7 +1743,7 @@ static bool tcp_flush(grpc_tcp* tcp, grpc_error_handle* error) {
|
|
|
1735
1743
|
}
|
|
1736
1744
|
return false;
|
|
1737
1745
|
} else {
|
|
1738
|
-
*error =
|
|
1746
|
+
*error = OSError(saved_errno, "sendmsg");
|
|
1739
1747
|
grpc_slice_buffer_reset_and_unref(tcp->outgoing_buffer);
|
|
1740
1748
|
tcp_shutdown_buffer_list(tcp);
|
|
1741
1749
|
return true;
|
|
@@ -1833,7 +1841,7 @@ static void tcp_write(
|
|
|
1833
1841
|
if (buf->length == 0) {
|
|
1834
1842
|
grpc_core::Closure::Run(DEBUG_LOCATION, cb,
|
|
1835
1843
|
grpc_fd_is_shutdown(tcp->em_fd)
|
|
1836
|
-
?
|
|
1844
|
+
? absl::UnavailableError("EOF")
|
|
1837
1845
|
: absl::OkStatus());
|
|
1838
1846
|
tcp_shutdown_buffer_list(tcp);
|
|
1839
1847
|
return;
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
#include "src/core/lib/iomgr/closure.h"
|
|
30
30
|
#include "src/core/lib/iomgr/endpoint.h"
|
|
31
|
-
#include "src/core/lib/iomgr/
|
|
31
|
+
#include "src/core/lib/iomgr/resolved_address.h"
|
|
32
32
|
|
|
33
33
|
// Forward decl of grpc_tcp_server
|
|
34
34
|
typedef struct grpc_tcp_server grpc_tcp_server;
|
|
@@ -61,7 +61,6 @@
|
|
|
61
61
|
#include "src/core/lib/iomgr/event_engine_shims/closure.h"
|
|
62
62
|
#include "src/core/lib/iomgr/event_engine_shims/endpoint.h"
|
|
63
63
|
#include "src/core/lib/iomgr/exec_ctx.h"
|
|
64
|
-
#include "src/core/lib/iomgr/resolve_address.h"
|
|
65
64
|
#include "src/core/lib/iomgr/sockaddr.h"
|
|
66
65
|
#include "src/core/lib/iomgr/socket_utils_posix.h"
|
|
67
66
|
#include "src/core/lib/iomgr/systemd_utils.h"
|
|
@@ -212,7 +211,7 @@ static grpc_error_handle CreateEventEngineListener(
|
|
|
212
211
|
std::move(accept_cb),
|
|
213
212
|
[s, shutdown_complete](absl::Status status) {
|
|
214
213
|
grpc_event_engine::experimental::RunEventEngineClosure(
|
|
215
|
-
shutdown_complete,
|
|
214
|
+
shutdown_complete, status);
|
|
216
215
|
finish_shutdown(s);
|
|
217
216
|
},
|
|
218
217
|
config,
|
|
@@ -240,7 +239,7 @@ static grpc_error_handle CreateEventEngineListener(
|
|
|
240
239
|
[s, ee = keeper, shutdown_complete](absl::Status status) {
|
|
241
240
|
GRPC_CHECK_EQ(gpr_atm_no_barrier_load(&s->refs.count), 0);
|
|
242
241
|
grpc_event_engine::experimental::RunEventEngineClosure(
|
|
243
|
-
shutdown_complete,
|
|
242
|
+
shutdown_complete, status);
|
|
244
243
|
finish_shutdown(s);
|
|
245
244
|
},
|
|
246
245
|
config,
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
|
|
26
26
|
#include "src/core/lib/event_engine/posix.h"
|
|
27
27
|
#include "src/core/lib/iomgr/ev_posix.h"
|
|
28
|
-
#include "src/core/lib/iomgr/resolve_address.h"
|
|
29
28
|
#include "src/core/lib/iomgr/socket_utils_posix.h"
|
|
30
29
|
#include "src/core/lib/iomgr/tcp_server.h"
|
|
31
30
|
#include "src/core/lib/iomgr/timer.h"
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
#include "src/core/lib/iomgr/event_engine_shims/endpoint.h"
|
|
47
47
|
#include "src/core/lib/iomgr/iocp_windows.h"
|
|
48
48
|
#include "src/core/lib/iomgr/pollset_windows.h"
|
|
49
|
-
#include "src/core/lib/iomgr/resolve_address.h"
|
|
50
49
|
#include "src/core/lib/iomgr/sockaddr.h"
|
|
51
50
|
#include "src/core/lib/iomgr/socket_windows.h"
|
|
52
51
|
#include "src/core/lib/iomgr/tcp_server.h"
|
|
@@ -206,10 +206,9 @@ static void on_read(void* tcpp, grpc_error_handle error) {
|
|
|
206
206
|
} else {
|
|
207
207
|
GRPC_TRACE_LOG(tcp, INFO) << "TCP:" << tcp << " unref read_slice";
|
|
208
208
|
grpc_slice_buffer_reset_and_unref(tcp->read_slices);
|
|
209
|
-
error =
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
grpc_core::StatusIntProperty::kRpcStatus, GRPC_STATUS_UNAVAILABLE);
|
|
209
|
+
error = absl::UnavailableError(tcp->shutting_down
|
|
210
|
+
? "TCP stream shutting down"
|
|
211
|
+
: "End of TCP stream");
|
|
213
212
|
}
|
|
214
213
|
}
|
|
215
214
|
}
|
|
@@ -238,9 +237,7 @@ static void win_read(grpc_endpoint* ep, grpc_slice_buffer* read_slices,
|
|
|
238
237
|
if (tcp->shutting_down) {
|
|
239
238
|
grpc_core::ExecCtx::Run(
|
|
240
239
|
DEBUG_LOCATION, cb,
|
|
241
|
-
|
|
242
|
-
grpc_core::StatusIntProperty::kRpcStatus,
|
|
243
|
-
GRPC_STATUS_UNAVAILABLE));
|
|
240
|
+
absl::UnavailableError("TCP socket is shutting down"));
|
|
244
241
|
return;
|
|
245
242
|
}
|
|
246
243
|
|
|
@@ -351,9 +348,7 @@ static void win_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
|
|
|
351
348
|
if (tcp->shutting_down) {
|
|
352
349
|
grpc_core::ExecCtx::Run(
|
|
353
350
|
DEBUG_LOCATION, cb,
|
|
354
|
-
|
|
355
|
-
grpc_core::StatusIntProperty::kRpcStatus,
|
|
356
|
-
GRPC_STATUS_UNAVAILABLE));
|
|
351
|
+
absl::UnavailableError("TCP socket is shutting down"));
|
|
357
352
|
return;
|
|
358
353
|
}
|
|
359
354
|
|
|
@@ -59,8 +59,7 @@ grpc_resolve_unix_domain_address(absl::string_view name) {
|
|
|
59
59
|
if (error.ok()) {
|
|
60
60
|
return std::vector<grpc_resolved_address>({addr});
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
return result;
|
|
62
|
+
return error;
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
absl::StatusOr<std::vector<grpc_resolved_address>>
|
|
@@ -71,8 +70,7 @@ grpc_resolve_unix_abstract_domain_address(const absl::string_view name) {
|
|
|
71
70
|
if (error.ok()) {
|
|
72
71
|
return std::vector<grpc_resolved_address>({addr});
|
|
73
72
|
}
|
|
74
|
-
|
|
75
|
-
return result;
|
|
73
|
+
return error;
|
|
76
74
|
}
|
|
77
75
|
|
|
78
76
|
int grpc_is_unix_socket(const grpc_resolved_address* resolved_addr) {
|
|
@@ -23,9 +23,11 @@
|
|
|
23
23
|
#include <grpc/support/string_util.h>
|
|
24
24
|
|
|
25
25
|
#include <string>
|
|
26
|
+
#include <vector>
|
|
26
27
|
|
|
27
28
|
#include "src/core/lib/iomgr/port.h"
|
|
28
|
-
#include "src/core/lib/iomgr/
|
|
29
|
+
#include "src/core/lib/iomgr/resolved_address.h"
|
|
30
|
+
#include "absl/status/statusor.h"
|
|
29
31
|
#include "absl/strings/string_view.h"
|
|
30
32
|
|
|
31
33
|
void grpc_create_socketpair_if_unix(int sv[2]);
|
data/src/core/lib/iomgr/vsock.h
CHANGED
|
@@ -23,9 +23,11 @@
|
|
|
23
23
|
#include <grpc/support/string_util.h>
|
|
24
24
|
|
|
25
25
|
#include <string>
|
|
26
|
+
#include <vector>
|
|
26
27
|
|
|
27
28
|
#include "src/core/lib/iomgr/port.h"
|
|
28
|
-
#include "src/core/lib/iomgr/
|
|
29
|
+
#include "src/core/lib/iomgr/resolved_address.h"
|
|
30
|
+
#include "absl/status/statusor.h"
|
|
29
31
|
#include "absl/strings/string_view.h"
|
|
30
32
|
|
|
31
33
|
absl::StatusOr<std::vector<grpc_resolved_address>> grpc_resolve_vsock_address(
|
|
@@ -405,7 +405,7 @@ void GrpcMemoryAllocatorImpl::Replenish() {
|
|
|
405
405
|
|
|
406
406
|
grpc_slice GrpcMemoryAllocatorImpl::MakeSlice(MemoryRequest request) {
|
|
407
407
|
auto size = Reserve(request.Increase(sizeof(SliceRefCount)));
|
|
408
|
-
void* p =
|
|
408
|
+
void* p = gpr_malloc(size);
|
|
409
409
|
new (p) SliceRefCount(shared_from_this(), size);
|
|
410
410
|
grpc_slice slice;
|
|
411
411
|
slice.refcount = static_cast<SliceRefCount*>(p);
|
|
@@ -14,10 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
#include "src/core/lib/security/authorization/rbac_policy.h"
|
|
16
16
|
|
|
17
|
-
#include <grpc/support/port_platform.h>
|
|
18
|
-
|
|
19
17
|
#include <utility>
|
|
20
18
|
|
|
19
|
+
#include "src/core/util/string.h"
|
|
21
20
|
#include "absl/strings/str_format.h"
|
|
22
21
|
#include "absl/strings/str_join.h"
|
|
23
22
|
#include "absl/strings/string_view.h"
|
|
@@ -51,36 +50,71 @@ Rbac& Rbac::operator=(Rbac&& other) noexcept {
|
|
|
51
50
|
return *this;
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
bool Rbac::operator==(const Rbac& other) const {
|
|
54
|
+
if (name != other.name) return false;
|
|
55
|
+
if (action != other.action) return false;
|
|
56
|
+
if (policies != other.policies) return false;
|
|
57
|
+
if (audit_condition != other.audit_condition) return false;
|
|
58
|
+
if (logger_configs.size() != other.logger_configs.size()) return false;
|
|
59
|
+
for (size_t i = 0; i < logger_configs.size(); ++i) {
|
|
60
|
+
if (logger_configs[i] == nullptr) {
|
|
61
|
+
if (other.logger_configs[i] != nullptr) return false;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (other.logger_configs[i] == nullptr) return false;
|
|
65
|
+
if (logger_configs[i]->name() != other.logger_configs[i]->name() ||
|
|
66
|
+
logger_configs[i]->ToString() != other.logger_configs[i]->ToString()) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
namespace {
|
|
74
|
+
|
|
75
|
+
absl::string_view AuditConditionString(Rbac::AuditCondition audit_condition) {
|
|
57
76
|
switch (audit_condition) {
|
|
58
77
|
case Rbac::AuditCondition::kNone:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
case AuditCondition::
|
|
65
|
-
|
|
66
|
-
break;
|
|
67
|
-
case AuditCondition::kOnDenyAndAllow:
|
|
68
|
-
condition_str = "OnDenyAndAllow";
|
|
69
|
-
break;
|
|
78
|
+
return "None";
|
|
79
|
+
case Rbac::AuditCondition::kOnDeny:
|
|
80
|
+
return "OnDeny";
|
|
81
|
+
case Rbac::AuditCondition::kOnAllow:
|
|
82
|
+
return "OnAllow";
|
|
83
|
+
case Rbac::AuditCondition::kOnDenyAndAllow:
|
|
84
|
+
return "OnDenyAndAllow";
|
|
70
85
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
86
|
+
return "<UNKNOWN>";
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
} // namespace
|
|
90
|
+
|
|
91
|
+
std::string Rbac::ToString() const {
|
|
92
|
+
std::string str = "Rbac{name=";
|
|
93
|
+
StrAppend(str, name);
|
|
94
|
+
StrAppend(str, ", action=");
|
|
95
|
+
StrAppend(str, action == Rbac::Action::kAllow ? "Allow" : "Deny");
|
|
96
|
+
StrAppend(str, ", audit_condition=");
|
|
97
|
+
StrAppend(str, AuditConditionString(audit_condition));
|
|
98
|
+
StrAppend(str, ", policies={");
|
|
99
|
+
bool is_first = true;
|
|
100
|
+
for (const auto& [name, policy] : policies) {
|
|
101
|
+
if (!is_first) StrAppend(str, ", ");
|
|
102
|
+
StrAppend(str, name);
|
|
103
|
+
StrAppend(str, "=");
|
|
104
|
+
StrAppend(str, policy.ToString());
|
|
105
|
+
is_first = false;
|
|
77
106
|
}
|
|
107
|
+
StrAppend(str, "}, audit_loggers={");
|
|
108
|
+
is_first = true;
|
|
78
109
|
for (const auto& config : logger_configs) {
|
|
79
|
-
|
|
80
|
-
|
|
110
|
+
if (!is_first) StrAppend(str, ", ");
|
|
111
|
+
StrAppend(str, config->name());
|
|
112
|
+
StrAppend(str, "=");
|
|
113
|
+
StrAppend(str, config->ToString());
|
|
114
|
+
is_first = false;
|
|
81
115
|
}
|
|
82
|
-
|
|
83
|
-
return
|
|
116
|
+
StrAppend(str, "}}");
|
|
117
|
+
return str;
|
|
84
118
|
}
|
|
85
119
|
|
|
86
120
|
//
|
|
@@ -100,6 +134,11 @@ Rbac::CidrRange& Rbac::CidrRange::operator=(Rbac::CidrRange&& other) noexcept {
|
|
|
100
134
|
return *this;
|
|
101
135
|
}
|
|
102
136
|
|
|
137
|
+
bool Rbac::CidrRange::operator==(const Rbac::CidrRange& other) const {
|
|
138
|
+
return address_prefix == other.address_prefix &&
|
|
139
|
+
prefix_len == other.prefix_len;
|
|
140
|
+
}
|
|
141
|
+
|
|
103
142
|
std::string Rbac::CidrRange::ToString() const {
|
|
104
143
|
return absl::StrFormat("CidrRange{address_prefix=%s,prefix_len=%d}",
|
|
105
144
|
address_prefix, prefix_len);
|
|
@@ -125,11 +164,11 @@ Rbac::Permission Rbac::Permission::MakeOrPermission(
|
|
|
125
164
|
return permission;
|
|
126
165
|
}
|
|
127
166
|
|
|
128
|
-
Rbac::Permission Rbac::Permission::MakeNotPermission(
|
|
167
|
+
Rbac::Permission Rbac::Permission::MakeNotPermission(
|
|
168
|
+
std::unique_ptr<Permission> permission) {
|
|
129
169
|
Permission not_permission;
|
|
130
170
|
not_permission.type = Permission::RuleType::kNot;
|
|
131
|
-
not_permission.permissions.push_back(
|
|
132
|
-
std::make_unique<Rbac::Permission>(std::move(permission)));
|
|
171
|
+
not_permission.permissions.push_back(std::move(permission));
|
|
133
172
|
return not_permission;
|
|
134
173
|
}
|
|
135
174
|
|
|
@@ -237,6 +276,25 @@ Rbac::Permission& Rbac::Permission::operator=(
|
|
|
237
276
|
return *this;
|
|
238
277
|
}
|
|
239
278
|
|
|
279
|
+
bool Rbac::Permission::operator==(const Rbac::Permission& other) const {
|
|
280
|
+
if (type != other.type) return false;
|
|
281
|
+
if (header_matcher != other.header_matcher) return false;
|
|
282
|
+
if (string_matcher != other.string_matcher) return false;
|
|
283
|
+
if (ip != other.ip) return false;
|
|
284
|
+
if (port != other.port) return false;
|
|
285
|
+
if (invert != other.invert) return false;
|
|
286
|
+
if (permissions.size() != other.permissions.size()) return false;
|
|
287
|
+
for (size_t i = 0; i < permissions.size(); ++i) {
|
|
288
|
+
if (permissions[i] == nullptr) {
|
|
289
|
+
if (other.permissions[i] != nullptr) return false;
|
|
290
|
+
} else {
|
|
291
|
+
if (other.permissions[i] == nullptr) return false;
|
|
292
|
+
if (*permissions[i] != *other.permissions[i]) return false;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return true;
|
|
296
|
+
}
|
|
297
|
+
|
|
240
298
|
std::string Rbac::Permission::ToString() const {
|
|
241
299
|
switch (type) {
|
|
242
300
|
case RuleType::kAnd: {
|
|
@@ -245,7 +303,7 @@ std::string Rbac::Permission::ToString() const {
|
|
|
245
303
|
for (const auto& permission : permissions) {
|
|
246
304
|
contents.push_back(permission->ToString());
|
|
247
305
|
}
|
|
248
|
-
return absl::StrFormat("and=[%s]", absl::StrJoin(contents, ","));
|
|
306
|
+
return absl::StrFormat("{and=[%s]}", absl::StrJoin(contents, ", "));
|
|
249
307
|
}
|
|
250
308
|
case RuleType::kOr: {
|
|
251
309
|
std::vector<std::string> contents;
|
|
@@ -253,24 +311,24 @@ std::string Rbac::Permission::ToString() const {
|
|
|
253
311
|
for (const auto& permission : permissions) {
|
|
254
312
|
contents.push_back(permission->ToString());
|
|
255
313
|
}
|
|
256
|
-
return absl::StrFormat("or=[%s]", absl::StrJoin(contents, ","));
|
|
314
|
+
return absl::StrFormat("{or=[%s]}", absl::StrJoin(contents, ", "));
|
|
257
315
|
}
|
|
258
316
|
case RuleType::kNot:
|
|
259
|
-
return absl::StrFormat("not %s", permissions[0]->ToString());
|
|
317
|
+
return absl::StrFormat("{not %s}", permissions[0]->ToString());
|
|
260
318
|
case RuleType::kAny:
|
|
261
|
-
return "any";
|
|
319
|
+
return "{any}";
|
|
262
320
|
case RuleType::kHeader:
|
|
263
|
-
return absl::StrFormat("header=%s", header_matcher.ToString());
|
|
321
|
+
return absl::StrFormat("{header=%s}", header_matcher.ToString());
|
|
264
322
|
case RuleType::kPath:
|
|
265
|
-
return absl::StrFormat("path=%s", string_matcher.ToString());
|
|
323
|
+
return absl::StrFormat("{path=%s}", string_matcher.ToString());
|
|
266
324
|
case RuleType::kDestIp:
|
|
267
|
-
return absl::StrFormat("dest_ip=%s", ip.ToString());
|
|
325
|
+
return absl::StrFormat("{dest_ip=%s}", ip.ToString());
|
|
268
326
|
case RuleType::kDestPort:
|
|
269
|
-
return absl::StrFormat("dest_port=%d", port);
|
|
327
|
+
return absl::StrFormat("{dest_port=%d}", port);
|
|
270
328
|
case RuleType::kMetadata:
|
|
271
|
-
return absl::StrFormat("%smetadata", invert ? "invert " : "");
|
|
329
|
+
return absl::StrFormat("{%smetadata}", invert ? "invert " : "");
|
|
272
330
|
case RuleType::kReqServerName:
|
|
273
|
-
return absl::StrFormat("requested_server_name=%s",
|
|
331
|
+
return absl::StrFormat("{requested_server_name=%s}",
|
|
274
332
|
string_matcher.ToString());
|
|
275
333
|
default:
|
|
276
334
|
return "";
|
|
@@ -297,11 +355,11 @@ Rbac::Principal Rbac::Principal::MakeOrPrincipal(
|
|
|
297
355
|
return principal;
|
|
298
356
|
}
|
|
299
357
|
|
|
300
|
-
Rbac::Principal Rbac::Principal::MakeNotPrincipal(
|
|
358
|
+
Rbac::Principal Rbac::Principal::MakeNotPrincipal(
|
|
359
|
+
std::unique_ptr<Principal> principal) {
|
|
301
360
|
Principal not_principal;
|
|
302
361
|
not_principal.type = Principal::RuleType::kNot;
|
|
303
|
-
not_principal.principals.push_back(
|
|
304
|
-
std::make_unique<Rbac::Principal>(std::move(principal)));
|
|
362
|
+
not_principal.principals.push_back(std::move(principal));
|
|
305
363
|
return not_principal;
|
|
306
364
|
}
|
|
307
365
|
|
|
@@ -409,6 +467,24 @@ Rbac::Principal& Rbac::Principal::operator=(Rbac::Principal&& other) noexcept {
|
|
|
409
467
|
return *this;
|
|
410
468
|
}
|
|
411
469
|
|
|
470
|
+
bool Rbac::Principal::operator==(const Rbac::Principal& other) const {
|
|
471
|
+
if (type != other.type) return false;
|
|
472
|
+
if (header_matcher != other.header_matcher) return false;
|
|
473
|
+
if (string_matcher != other.string_matcher) return false;
|
|
474
|
+
if (ip != other.ip) return false;
|
|
475
|
+
if (invert != other.invert) return false;
|
|
476
|
+
if (principals.size() != other.principals.size()) return false;
|
|
477
|
+
for (size_t i = 0; i < principals.size(); ++i) {
|
|
478
|
+
if (principals[i] == nullptr) {
|
|
479
|
+
if (other.principals[i] != nullptr) return false;
|
|
480
|
+
} else {
|
|
481
|
+
if (other.principals[i] == nullptr) return false;
|
|
482
|
+
if (*principals[i] != *other.principals[i]) return false;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return true;
|
|
486
|
+
}
|
|
487
|
+
|
|
412
488
|
std::string Rbac::Principal::ToString() const {
|
|
413
489
|
switch (type) {
|
|
414
490
|
case RuleType::kAnd: {
|
|
@@ -417,7 +493,7 @@ std::string Rbac::Principal::ToString() const {
|
|
|
417
493
|
for (const auto& principal : principals) {
|
|
418
494
|
contents.push_back(principal->ToString());
|
|
419
495
|
}
|
|
420
|
-
return absl::StrFormat("and=[%s]", absl::StrJoin(contents, ","));
|
|
496
|
+
return absl::StrFormat("{and=[%s]}", absl::StrJoin(contents, ", "));
|
|
421
497
|
}
|
|
422
498
|
case RuleType::kOr: {
|
|
423
499
|
std::vector<std::string> contents;
|
|
@@ -425,26 +501,26 @@ std::string Rbac::Principal::ToString() const {
|
|
|
425
501
|
for (const auto& principal : principals) {
|
|
426
502
|
contents.push_back(principal->ToString());
|
|
427
503
|
}
|
|
428
|
-
return absl::StrFormat("or=[%s]", absl::StrJoin(contents, ","));
|
|
504
|
+
return absl::StrFormat("{or=[%s]}", absl::StrJoin(contents, ", "));
|
|
429
505
|
}
|
|
430
506
|
case RuleType::kNot:
|
|
431
|
-
return absl::StrFormat("not %s", principals[0]->ToString());
|
|
507
|
+
return absl::StrFormat("{not %s}", principals[0]->ToString());
|
|
432
508
|
case RuleType::kAny:
|
|
433
|
-
return "any";
|
|
509
|
+
return "{any}";
|
|
434
510
|
case RuleType::kPrincipalName:
|
|
435
|
-
return absl::StrFormat("principal_name=%s", string_matcher->ToString());
|
|
511
|
+
return absl::StrFormat("{principal_name=%s}", string_matcher->ToString());
|
|
436
512
|
case RuleType::kSourceIp:
|
|
437
|
-
return absl::StrFormat("source_ip=%s", ip.ToString());
|
|
513
|
+
return absl::StrFormat("{source_ip=%s}", ip.ToString());
|
|
438
514
|
case RuleType::kDirectRemoteIp:
|
|
439
|
-
return absl::StrFormat("direct_remote_ip=%s", ip.ToString());
|
|
515
|
+
return absl::StrFormat("{direct_remote_ip=%s}", ip.ToString());
|
|
440
516
|
case RuleType::kRemoteIp:
|
|
441
|
-
return absl::StrFormat("remote_ip=%s", ip.ToString());
|
|
517
|
+
return absl::StrFormat("{remote_ip=%s}", ip.ToString());
|
|
442
518
|
case RuleType::kHeader:
|
|
443
|
-
return absl::StrFormat("header=%s", header_matcher.ToString());
|
|
519
|
+
return absl::StrFormat("{header=%s}", header_matcher.ToString());
|
|
444
520
|
case RuleType::kPath:
|
|
445
|
-
return absl::StrFormat("path=%s", string_matcher->ToString());
|
|
521
|
+
return absl::StrFormat("{path=%s}", string_matcher->ToString());
|
|
446
522
|
case RuleType::kMetadata:
|
|
447
|
-
return absl::StrFormat("%smetadata", invert ? "invert " : "");
|
|
523
|
+
return absl::StrFormat("{%smetadata}", invert ? "invert " : "");
|
|
448
524
|
default:
|
|
449
525
|
return "";
|
|
450
526
|
}
|
|
@@ -467,10 +543,17 @@ Rbac::Policy& Rbac::Policy::operator=(Rbac::Policy&& other) noexcept {
|
|
|
467
543
|
return *this;
|
|
468
544
|
}
|
|
469
545
|
|
|
546
|
+
bool Rbac::Policy::operator==(const Rbac::Policy& other) const {
|
|
547
|
+
return permissions == other.permissions && principals == other.principals;
|
|
548
|
+
}
|
|
549
|
+
|
|
470
550
|
std::string Rbac::Policy::ToString() const {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
551
|
+
std::string str = "{permissions=";
|
|
552
|
+
StrAppend(str, permissions.ToString());
|
|
553
|
+
StrAppend(str, ", principals=");
|
|
554
|
+
StrAppend(str, principals.ToString());
|
|
555
|
+
StrAppend(str, "}");
|
|
556
|
+
return str;
|
|
474
557
|
}
|
|
475
558
|
|
|
476
559
|
} // namespace grpc_core
|
|
@@ -44,6 +44,9 @@ struct Rbac {
|
|
|
44
44
|
kOnDenyAndAllow,
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
// TODO(roth): Unify this with
|
|
48
|
+
// XdsListenerResource::FilterChainMap::CidrRange, possibly as part of
|
|
49
|
+
// addressing https://github.com/grpc/grpc/issues/34172.
|
|
47
50
|
struct CidrRange {
|
|
48
51
|
CidrRange() = default;
|
|
49
52
|
CidrRange(std::string address_prefix, uint32_t prefix_len);
|
|
@@ -51,6 +54,9 @@ struct Rbac {
|
|
|
51
54
|
CidrRange(CidrRange&& other) noexcept;
|
|
52
55
|
CidrRange& operator=(CidrRange&& other) noexcept;
|
|
53
56
|
|
|
57
|
+
bool operator==(const CidrRange& other) const;
|
|
58
|
+
bool operator!=(const CidrRange& other) const { return !(*this == other); }
|
|
59
|
+
|
|
54
60
|
std::string ToString() const;
|
|
55
61
|
|
|
56
62
|
std::string address_prefix;
|
|
@@ -76,7 +82,7 @@ struct Rbac {
|
|
|
76
82
|
std::vector<std::unique_ptr<Permission>> permissions);
|
|
77
83
|
static Permission MakeOrPermission(
|
|
78
84
|
std::vector<std::unique_ptr<Permission>> permissions);
|
|
79
|
-
static Permission MakeNotPermission(Permission permission);
|
|
85
|
+
static Permission MakeNotPermission(std::unique_ptr<Permission> permission);
|
|
80
86
|
static Permission MakeAnyPermission();
|
|
81
87
|
static Permission MakeHeaderPermission(HeaderMatcher header_matcher);
|
|
82
88
|
static Permission MakePathPermission(StringMatcher string_matcher);
|
|
@@ -91,6 +97,9 @@ struct Rbac {
|
|
|
91
97
|
Permission(Permission&& other) noexcept;
|
|
92
98
|
Permission& operator=(Permission&& other) noexcept;
|
|
93
99
|
|
|
100
|
+
bool operator==(const Permission& other) const;
|
|
101
|
+
bool operator!=(const Permission& other) const { return !(*this == other); }
|
|
102
|
+
|
|
94
103
|
std::string ToString() const;
|
|
95
104
|
|
|
96
105
|
RuleType type = RuleType::kAnd;
|
|
@@ -124,7 +133,7 @@ struct Rbac {
|
|
|
124
133
|
std::vector<std::unique_ptr<Principal>> principals);
|
|
125
134
|
static Principal MakeOrPrincipal(
|
|
126
135
|
std::vector<std::unique_ptr<Principal>> principals);
|
|
127
|
-
static Principal MakeNotPrincipal(Principal principal);
|
|
136
|
+
static Principal MakeNotPrincipal(std::unique_ptr<Principal> principal);
|
|
128
137
|
static Principal MakeAnyPrincipal();
|
|
129
138
|
static Principal MakeAuthenticatedPrincipal(
|
|
130
139
|
std::optional<StringMatcher> string_matcher);
|
|
@@ -141,6 +150,9 @@ struct Rbac {
|
|
|
141
150
|
Principal(Principal&& other) noexcept;
|
|
142
151
|
Principal& operator=(Principal&& other) noexcept;
|
|
143
152
|
|
|
153
|
+
bool operator==(const Principal& other) const;
|
|
154
|
+
bool operator!=(const Principal& other) const { return !(*this == other); }
|
|
155
|
+
|
|
144
156
|
std::string ToString() const;
|
|
145
157
|
|
|
146
158
|
RuleType type = RuleType::kAnd;
|
|
@@ -161,6 +173,9 @@ struct Rbac {
|
|
|
161
173
|
Policy(Policy&& other) noexcept;
|
|
162
174
|
Policy& operator=(Policy&& other) noexcept;
|
|
163
175
|
|
|
176
|
+
bool operator==(const Policy& other) const;
|
|
177
|
+
bool operator!=(const Policy& other) const { return !(*this == other); }
|
|
178
|
+
|
|
164
179
|
std::string ToString() const;
|
|
165
180
|
|
|
166
181
|
Permission permissions;
|
|
@@ -174,6 +189,9 @@ struct Rbac {
|
|
|
174
189
|
Rbac(Rbac&& other) noexcept;
|
|
175
190
|
Rbac& operator=(Rbac&& other) noexcept;
|
|
176
191
|
|
|
192
|
+
bool operator==(const Rbac& other) const;
|
|
193
|
+
bool operator!=(const Rbac& other) const { return !(*this == other); }
|
|
194
|
+
|
|
177
195
|
std::string ToString() const;
|
|
178
196
|
|
|
179
197
|
// The authorization policy name or empty string in xDS case.
|
|
@@ -182,7 +200,7 @@ struct Rbac {
|
|
|
182
200
|
Action action;
|
|
183
201
|
std::map<std::string, Policy> policies;
|
|
184
202
|
|
|
185
|
-
AuditCondition audit_condition;
|
|
203
|
+
AuditCondition audit_condition = AuditCondition::kNone;
|
|
186
204
|
std::vector<std::shared_ptr<const experimental::AuditLoggerFactory::Config>>
|
|
187
205
|
logger_configs;
|
|
188
206
|
};
|