grpc 1.18.0 → 1.22.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +4731 -7404
- data/etc/roots.pem +146 -0
- data/include/grpc/grpc.h +11 -6
- data/include/grpc/grpc_security.h +297 -4
- data/include/grpc/grpc_security_constants.h +1 -1
- data/include/grpc/impl/codegen/byte_buffer.h +13 -0
- data/include/grpc/impl/codegen/gpr_types.h +1 -1
- data/include/grpc/impl/codegen/grpc_types.h +30 -7
- data/include/grpc/impl/codegen/port_platform.h +88 -7
- data/include/grpc/impl/codegen/slice.h +2 -22
- data/include/grpc/impl/codegen/status.h +2 -1
- data/include/grpc/impl/codegen/sync_posix.h +18 -0
- data/include/grpc/slice.h +3 -3
- data/src/core/ext/filters/client_channel/backup_poller.cc +21 -16
- data/src/core/ext/filters/client_channel/backup_poller.h +8 -2
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +3 -1
- data/src/core/ext/filters/client_channel/client_channel.cc +2435 -1557
- data/src/core/ext/filters/client_channel/client_channel.h +2 -10
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +6 -89
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +8 -33
- data/src/core/ext/filters/client_channel/client_channel_factory.cc +22 -34
- data/src/core/ext/filters/client_channel/client_channel_factory.h +19 -38
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +9 -11
- data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +179 -0
- data/src/core/ext/filters/client_channel/global_subchannel_pool.h +68 -0
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +59 -55
- data/src/core/ext/filters/client_channel/health/health_check_client.h +20 -9
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +146 -157
- data/src/core/ext/filters/client_channel/http_connect_handshaker.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +29 -32
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +844 -859
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +3 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +2 -6
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +6 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +14 -12
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +16 -12
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +185 -312
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +143 -375
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +192 -245
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +1554 -955
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc +0 -43
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc +14 -10
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +2 -2
- data/src/core/ext/filters/client_channel/lb_policy.cc +115 -22
- data/src/core/ext/filters/client_channel/lb_policy.h +260 -129
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +5 -2
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +107 -4
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +10 -3
- data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +96 -0
- data/src/core/ext/filters/client_channel/local_subchannel_pool.h +56 -0
- data/src/core/ext/filters/client_channel/parse_address.cc +24 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +121 -122
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +84 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +3 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +179 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +24 -10
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +111 -47
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +7 -13
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +39 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc +0 -6
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +2 -64
- data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc +28 -0
- data/src/core/{lib/iomgr/network_status_tracker.cc → ext/filters/client_channel/resolver/dns/dns_resolver_selection.h} +8 -15
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +36 -82
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +111 -72
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +13 -8
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +28 -63
- data/src/core/ext/filters/client_channel/resolver.cc +54 -1
- data/src/core/ext/filters/client_channel/resolver.h +52 -23
- data/src/core/ext/filters/client_channel/resolver_factory.h +3 -1
- data/src/core/ext/filters/client_channel/resolver_registry.cc +5 -2
- data/src/core/ext/filters/client_channel/resolver_registry.h +5 -4
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +368 -241
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +58 -76
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +543 -0
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +139 -0
- data/src/core/ext/filters/client_channel/server_address.cc +4 -54
- data/src/core/ext/filters/client_channel/server_address.h +1 -13
- data/src/core/ext/filters/client_channel/service_config.cc +329 -0
- data/src/core/ext/filters/client_channel/service_config.h +205 -0
- data/src/core/ext/filters/client_channel/subchannel.cc +803 -838
- data/src/core/ext/filters/client_channel/subchannel.h +295 -128
- data/src/core/ext/filters/client_channel/subchannel_interface.h +113 -0
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +97 -0
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +94 -0
- data/src/core/ext/filters/deadline/deadline_filter.cc +3 -4
- data/src/core/ext/filters/deadline/deadline_filter.h +3 -2
- data/src/core/ext/filters/http/client/http_client_filter.cc +7 -5
- data/src/core/ext/filters/http/client/http_client_filter.h +1 -1
- data/src/core/ext/filters/http/client_authority_filter.cc +6 -3
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +4 -3
- data/src/core/ext/filters/http/server/http_server_filter.cc +18 -12
- data/src/core/ext/filters/max_age/max_age_filter.cc +5 -2
- data/src/core/ext/filters/message_size/message_size_filter.cc +119 -77
- data/src/core/ext/filters/message_size/message_size_filter.h +33 -0
- data/src/core/ext/transport/chttp2/alpn/alpn.h +1 -1
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +13 -12
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +45 -47
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +134 -143
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +68 -21
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +4 -4
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +7 -6
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +4 -3
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +9 -7
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +156 -94
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +33 -37
- data/src/core/ext/transport/chttp2/transport/frame_data.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +6 -5
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +3 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +5 -4
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +8 -6
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +6 -4
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +7 -6
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +74 -55
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +33 -11
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +3 -2
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +7 -14
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +10 -1
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +9 -5
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +9 -3
- data/src/core/ext/transport/chttp2/transport/internal.h +43 -30
- data/src/core/ext/transport/chttp2/transport/parsing.cc +52 -70
- data/src/core/ext/transport/chttp2/transport/stream_lists.cc +3 -3
- data/src/core/ext/transport/chttp2/transport/writing.cc +70 -33
- data/src/core/ext/transport/inproc/inproc_transport.cc +26 -18
- data/src/core/lib/channel/channel_args.cc +2 -101
- data/src/core/lib/channel/channel_args.h +3 -37
- data/src/core/lib/channel/channel_stack.h +10 -6
- data/src/core/lib/channel/channel_trace.cc +4 -4
- data/src/core/lib/channel/channel_trace.h +4 -4
- data/src/core/lib/channel/channelz.cc +168 -38
- data/src/core/lib/channel/channelz.h +40 -44
- data/src/core/lib/channel/channelz_registry.cc +75 -107
- data/src/core/lib/channel/channelz_registry.h +10 -28
- data/src/core/lib/channel/connected_channel.cc +2 -2
- data/src/core/lib/channel/context.h +2 -2
- data/src/core/lib/channel/handshaker.cc +151 -218
- data/src/core/lib/channel/handshaker.h +110 -101
- data/src/core/lib/channel/handshaker_factory.h +11 -19
- data/src/core/lib/channel/handshaker_registry.cc +67 -51
- data/src/core/lib/channel/handshaker_registry.h +21 -16
- data/src/core/lib/compression/algorithm_metadata.h +3 -3
- data/src/core/lib/compression/compression.cc +14 -9
- data/src/core/lib/compression/compression_args.cc +127 -0
- data/src/core/lib/compression/compression_args.h +55 -0
- data/src/core/lib/compression/compression_internal.cc +16 -12
- data/src/core/lib/compression/compression_internal.h +1 -1
- data/src/core/lib/compression/stream_compression.cc +3 -2
- data/src/core/lib/compression/stream_compression.h +2 -2
- data/src/core/lib/compression/stream_compression_gzip.cc +9 -9
- data/src/core/lib/debug/trace.cc +13 -7
- data/src/core/lib/debug/trace.h +14 -1
- data/src/core/lib/gpr/arena.h +13 -9
- data/src/core/lib/gpr/cpu_posix.cc +5 -3
- data/src/core/lib/gpr/env.h +3 -6
- data/src/core/lib/gpr/env_linux.cc +6 -1
- data/src/core/lib/gpr/env_posix.cc +5 -0
- data/src/core/lib/gpr/env_windows.cc +7 -5
- data/src/core/lib/gpr/log.cc +9 -13
- data/src/core/lib/gpr/log_posix.cc +2 -1
- data/src/core/lib/gpr/string.cc +20 -7
- data/src/core/lib/gpr/string.h +10 -3
- data/src/core/lib/gpr/sync_posix.cc +65 -4
- data/src/core/lib/gpr/time.cc +8 -0
- data/src/core/lib/gpr/time_posix.cc +21 -2
- data/src/core/lib/gprpp/arena.cc +103 -0
- data/src/core/lib/gprpp/arena.h +121 -0
- data/src/core/lib/gprpp/atomic.h +75 -5
- data/src/core/lib/gprpp/fork.cc +13 -32
- data/src/core/lib/gprpp/fork.h +5 -1
- data/src/core/lib/gprpp/global_config.h +96 -0
- data/src/core/lib/gprpp/global_config_custom.h +29 -0
- data/src/core/lib/gprpp/global_config_env.cc +135 -0
- data/src/core/lib/gprpp/global_config_env.h +131 -0
- data/src/core/lib/gprpp/global_config_generic.h +44 -0
- data/src/core/lib/gprpp/inlined_vector.h +8 -0
- data/src/core/lib/gprpp/map.h +436 -0
- data/src/core/lib/gprpp/memory.h +2 -2
- data/src/core/lib/gprpp/optional.h +48 -0
- data/src/core/lib/gprpp/orphanable.h +6 -5
- data/src/core/lib/gprpp/{mutex_lock.h → pair.h} +15 -19
- data/src/core/lib/gprpp/ref_counted.h +36 -17
- data/src/core/lib/gprpp/sync.h +126 -0
- data/src/core/lib/gprpp/thd.h +42 -7
- data/src/core/lib/gprpp/thd_posix.cc +31 -13
- data/src/core/lib/gprpp/thd_windows.cc +47 -34
- data/src/core/lib/http/httpcli.cc +6 -5
- data/src/core/lib/http/httpcli_security_connector.cc +13 -15
- data/src/core/lib/http/parser.cc +3 -2
- data/src/core/lib/http/parser.h +2 -1
- data/src/core/lib/iomgr/buffer_list.cc +182 -24
- data/src/core/lib/iomgr/buffer_list.h +72 -10
- data/src/core/lib/iomgr/call_combiner.cc +84 -90
- data/src/core/lib/iomgr/call_combiner.h +75 -82
- data/src/core/lib/iomgr/cfstream_handle.cc +203 -0
- data/src/core/lib/iomgr/cfstream_handle.h +86 -0
- data/src/core/lib/iomgr/combiner.cc +11 -3
- data/src/core/lib/iomgr/combiner.h +1 -1
- data/src/core/lib/iomgr/endpoint.cc +2 -2
- data/src/core/lib/iomgr/endpoint.h +3 -2
- data/src/core/lib/iomgr/endpoint_cfstream.cc +375 -0
- data/src/core/lib/iomgr/endpoint_cfstream.h +49 -0
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +2 -2
- data/src/core/lib/iomgr/error.cc +21 -17
- data/src/core/lib/iomgr/error.h +36 -6
- data/src/core/lib/iomgr/error_cfstream.cc +52 -0
- data/src/core/lib/iomgr/error_cfstream.h +31 -0
- data/src/core/lib/iomgr/error_internal.h +1 -1
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +44 -28
- data/src/core/lib/iomgr/ev_epollex_linux.cc +173 -194
- data/src/core/lib/iomgr/ev_poll_posix.cc +16 -487
- data/src/core/lib/iomgr/ev_posix.cc +29 -19
- data/src/core/lib/iomgr/ev_posix.h +19 -3
- data/src/core/lib/iomgr/ev_windows.cc +2 -2
- data/src/core/lib/iomgr/exec_ctx.cc +1 -0
- data/src/core/lib/iomgr/exec_ctx.h +137 -8
- data/src/core/lib/iomgr/executor.cc +147 -95
- data/src/core/lib/iomgr/executor.h +55 -49
- data/src/core/lib/iomgr/fork_posix.cc +6 -5
- data/src/core/lib/{gprpp/atomic_with_std.h → iomgr/grpc_if_nametoindex.h} +8 -13
- data/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc +42 -0
- data/src/core/lib/iomgr/{network_status_tracker.h → grpc_if_nametoindex_unsupported.cc} +15 -9
- data/src/core/lib/iomgr/internal_errqueue.cc +3 -5
- data/src/core/lib/iomgr/internal_errqueue.h +105 -3
- data/src/core/lib/iomgr/iomgr.cc +20 -13
- data/src/core/lib/iomgr/iomgr.h +15 -0
- data/src/core/lib/iomgr/iomgr_custom.cc +17 -3
- data/src/core/lib/iomgr/iomgr_custom.h +2 -0
- data/src/core/lib/iomgr/iomgr_internal.cc +10 -0
- data/src/core/lib/iomgr/iomgr_internal.h +12 -0
- data/src/core/lib/iomgr/iomgr_posix.cc +19 -2
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +93 -0
- data/src/core/lib/iomgr/iomgr_windows.cc +18 -2
- data/src/core/lib/iomgr/lockfree_event.cc +4 -4
- data/src/core/lib/iomgr/port.h +35 -0
- data/src/core/lib/iomgr/resolve_address_posix.cc +4 -3
- data/src/core/lib/iomgr/resolve_address_windows.cc +2 -1
- data/src/core/lib/iomgr/resource_quota.cc +40 -37
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +6 -2
- data/src/core/lib/iomgr/socket_windows.cc +19 -0
- data/src/core/lib/iomgr/socket_windows.h +8 -0
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +216 -0
- data/src/core/lib/iomgr/tcp_client_custom.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_posix.cc +3 -3
- data/src/core/lib/iomgr/tcp_client_windows.cc +7 -5
- data/src/core/lib/iomgr/tcp_custom.cc +10 -14
- data/src/core/lib/iomgr/tcp_posix.cc +256 -140
- data/src/core/lib/iomgr/tcp_server.cc +5 -0
- data/src/core/lib/iomgr/tcp_server.h +24 -0
- data/src/core/lib/iomgr/tcp_server_custom.cc +14 -12
- data/src/core/lib/iomgr/tcp_server_posix.cc +86 -12
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +3 -0
- data/src/core/lib/iomgr/tcp_server_windows.cc +13 -11
- data/src/core/lib/iomgr/tcp_uv.cc +5 -7
- data/src/core/lib/iomgr/tcp_windows.cc +8 -14
- data/src/core/lib/iomgr/timer.h +2 -1
- data/src/core/lib/iomgr/timer_generic.cc +16 -16
- data/src/core/lib/iomgr/timer_manager.cc +20 -11
- data/src/core/lib/iomgr/udp_server.cc +8 -6
- data/src/core/lib/iomgr/wakeup_fd_posix.cc +1 -19
- data/src/core/lib/json/json.cc +1 -4
- data/src/core/lib/profiling/basic_timers.cc +10 -4
- data/src/core/lib/security/context/security_context.cc +6 -7
- data/src/core/lib/security/context/security_context.h +3 -4
- data/src/core/lib/security/credentials/alts/alts_credentials.cc +1 -1
- data/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc +2 -2
- data/src/core/lib/security/credentials/composite/composite_credentials.h +4 -0
- data/src/core/lib/security/credentials/credentials.h +9 -1
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +15 -3
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +2 -0
- data/src/core/lib/security/credentials/jwt/json_token.cc +1 -1
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +2 -1
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +10 -6
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +3 -3
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +9 -8
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +20 -2
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +2 -2
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +192 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +210 -0
- data/src/core/lib/security/credentials/tls/spiffe_credentials.cc +129 -0
- data/src/core/lib/security/credentials/tls/spiffe_credentials.h +62 -0
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +10 -8
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +13 -12
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +7 -5
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +10 -8
- data/src/core/lib/security/security_connector/security_connector.cc +0 -1
- data/src/core/lib/security/security_connector/security_connector.h +3 -3
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +39 -38
- data/src/core/lib/security/security_connector/ssl_utils.cc +164 -26
- data/src/core/lib/security/security_connector/ssl_utils.h +70 -1
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +426 -0
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +122 -0
- data/src/core/lib/security/transport/auth_filters.h +5 -2
- data/src/core/lib/security/transport/client_auth_filter.cc +55 -50
- data/src/core/lib/security/transport/secure_endpoint.cc +6 -6
- data/src/core/lib/security/transport/security_handshaker.cc +271 -303
- data/src/core/lib/security/transport/security_handshaker.h +11 -2
- data/src/core/lib/security/transport/server_auth_filter.cc +3 -3
- data/src/core/lib/slice/b64.h +2 -2
- data/src/core/lib/slice/percent_encoding.cc +3 -3
- data/src/core/lib/slice/percent_encoding.h +3 -3
- data/src/core/lib/slice/slice.cc +174 -122
- data/src/core/lib/slice/slice_buffer.cc +54 -21
- data/src/core/lib/slice/slice_hash_table.h +4 -4
- data/src/core/lib/slice/slice_intern.cc +49 -107
- data/src/core/lib/slice/slice_internal.h +264 -3
- data/src/core/lib/slice/slice_string_helpers.cc +10 -1
- data/src/core/lib/slice/slice_string_helpers.h +3 -1
- data/src/core/lib/slice/slice_utils.h +50 -0
- data/src/core/lib/slice/slice_weak_hash_table.h +6 -6
- data/src/core/lib/surface/api_trace.h +1 -1
- data/src/core/lib/surface/byte_buffer_reader.cc +17 -0
- data/src/core/lib/surface/call.cc +67 -46
- data/src/core/lib/surface/call.h +7 -2
- data/src/core/lib/surface/call_details.cc +0 -1
- data/src/core/lib/surface/channel.cc +89 -97
- data/src/core/lib/surface/channel.h +60 -6
- data/src/core/lib/surface/channel_init.h +5 -0
- data/src/core/lib/surface/completion_queue.cc +221 -216
- data/src/core/lib/surface/completion_queue.h +2 -1
- data/src/core/lib/surface/init.cc +82 -33
- data/src/core/lib/surface/init.h +1 -0
- data/src/core/lib/surface/init_secure.cc +1 -1
- data/src/core/lib/surface/lame_client.cc +5 -7
- data/src/core/lib/surface/server.cc +42 -47
- data/src/core/lib/surface/validate_metadata.cc +14 -8
- data/src/core/lib/surface/validate_metadata.h +13 -2
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/bdp_estimator.cc +3 -3
- data/src/core/lib/transport/bdp_estimator.h +2 -2
- data/src/core/lib/transport/connectivity_state.cc +10 -40
- data/src/core/lib/transport/connectivity_state.h +0 -8
- data/src/core/lib/transport/error_utils.cc +12 -0
- data/src/core/lib/transport/metadata.cc +258 -267
- data/src/core/lib/transport/metadata.h +227 -16
- data/src/core/lib/transport/metadata_batch.cc +1 -1
- data/src/core/lib/transport/metadata_batch.h +1 -1
- data/src/core/lib/transport/static_metadata.cc +477 -399
- data/src/core/lib/transport/static_metadata.h +273 -182
- data/src/core/lib/transport/status_metadata.cc +3 -3
- data/src/core/lib/transport/timeout_encoding.cc +1 -1
- data/src/core/lib/transport/timeout_encoding.h +1 -1
- data/src/core/lib/transport/transport.cc +39 -72
- data/src/core/lib/transport/transport.h +59 -24
- data/src/core/lib/transport/transport_impl.h +1 -1
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +3 -3
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +1 -1
- data/src/core/tsi/alts/handshaker/alts_shared_resource.h +1 -1
- data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +4 -3
- data/src/core/tsi/alts/handshaker/transport_security_common_api.h +1 -1
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +1 -1
- data/src/core/tsi/fake_transport_security.cc +4 -4
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +1 -1
- data/src/core/tsi/ssl_transport_security.cc +12 -10
- data/src/core/tsi/ssl_transport_security.h +24 -4
- data/src/ruby/bin/math_pb.rb +18 -16
- data/src/ruby/ext/grpc/extconf.rb +12 -4
- data/src/ruby/ext/grpc/rb_call_credentials.c +8 -5
- data/src/ruby/ext/grpc/rb_channel.c +14 -10
- data/src/ruby/ext/grpc/rb_channel_credentials.c +8 -4
- data/src/ruby/ext/grpc/rb_compression_options.c +9 -7
- data/src/ruby/ext/grpc/rb_event_thread.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc.c +23 -24
- data/src/ruby/ext/grpc/rb_grpc.h +4 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +24 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +36 -0
- data/src/ruby/ext/grpc/rb_server.c +8 -4
- data/src/ruby/lib/grpc/errors.rb +22 -3
- data/src/ruby/lib/grpc/generic/bidi_call.rb +1 -1
- data/src/ruby/lib/grpc/generic/rpc_server.rb +2 -2
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/README.md +1 -1
- data/src/ruby/pb/grpc/health/v1/health_pb.rb +13 -10
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +18 -0
- data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +3 -1
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +58 -56
- data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +2 -0
- data/src/ruby/spec/errors_spec.rb +141 -0
- data/third_party/cares/cares/ares.h +12 -0
- data/third_party/cares/cares/ares_create_query.c +5 -1
- data/third_party/cares/cares/ares_data.c +74 -73
- data/third_party/cares/cares/ares_destroy.c +6 -1
- data/third_party/cares/cares/ares_gethostbyaddr.c +5 -5
- data/third_party/cares/cares/ares_gethostbyname.c +15 -4
- data/third_party/cares/cares/ares_getnameinfo.c +11 -0
- data/third_party/cares/cares/ares_init.c +274 -173
- data/third_party/cares/cares/ares_library_init.c +21 -3
- data/third_party/cares/cares/ares_options.c +6 -2
- data/third_party/cares/cares/ares_parse_naptr_reply.c +7 -6
- data/third_party/cares/cares/ares_parse_ptr_reply.c +4 -2
- data/third_party/cares/cares/ares_platform.c +7 -0
- data/third_party/cares/cares/ares_private.h +19 -11
- data/third_party/cares/cares/ares_process.c +27 -2
- data/third_party/cares/cares/ares_rules.h +1 -1
- data/third_party/cares/cares/ares_search.c +7 -0
- data/third_party/cares/cares/ares_send.c +6 -0
- data/third_party/cares/cares/ares_strsplit.c +174 -0
- data/third_party/cares/cares/ares_strsplit.h +43 -0
- data/third_party/cares/cares/ares_version.h +4 -4
- data/third_party/cares/cares/config-win32.h +1 -1
- data/third_party/cares/cares/inet_ntop.c +2 -3
- data/third_party/cares/config_darwin/ares_config.h +3 -0
- data/third_party/cares/config_freebsd/ares_config.h +3 -0
- data/third_party/cares/config_linux/ares_config.h +3 -0
- data/third_party/cares/config_openbsd/ares_config.h +3 -0
- metadata +83 -48
- data/src/core/ext/filters/client_channel/request_routing.cc +0 -936
- data/src/core/ext/filters/client_channel/request_routing.h +0 -177
- data/src/core/ext/filters/client_channel/subchannel_index.cc +0 -248
- data/src/core/ext/filters/client_channel/subchannel_index.h +0 -76
- data/src/core/lib/channel/handshaker_factory.cc +0 -42
- data/src/core/lib/gpr/arena.cc +0 -192
- data/src/core/lib/gprpp/atomic_with_atm.h +0 -57
- data/src/core/lib/iomgr/wakeup_fd_cv.cc +0 -107
- data/src/core/lib/iomgr/wakeup_fd_cv.h +0 -69
- data/src/core/lib/transport/service_config.cc +0 -106
- data/src/core/lib/transport/service_config.h +0 -249
@@ -44,6 +44,7 @@
|
|
44
44
|
|
45
45
|
#if defined(ANDROID) || defined(__ANDROID__)
|
46
46
|
#include <sys/system_properties.h>
|
47
|
+
#include "ares_android.h"
|
47
48
|
/* From the Bionic sources */
|
48
49
|
#define DNS_PROP_NAME_PREFIX "net.dns"
|
49
50
|
#define MAX_DNS_PROPERTIES 8
|
@@ -168,6 +169,7 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options,
|
|
168
169
|
channel->sock_config_cb_data = NULL;
|
169
170
|
channel->sock_funcs = NULL;
|
170
171
|
channel->sock_func_cb_data = NULL;
|
172
|
+
channel->resolvconf_path = NULL;
|
171
173
|
|
172
174
|
channel->last_server = 0;
|
173
175
|
channel->last_timeout_processed = (time_t)now.tv_sec;
|
@@ -235,16 +237,14 @@ done:
|
|
235
237
|
/* Something failed; clean up memory we may have allocated. */
|
236
238
|
if (channel->servers)
|
237
239
|
ares_free(channel->servers);
|
238
|
-
if (channel->
|
239
|
-
|
240
|
-
for (i = 0; i < channel->ndomains; i++)
|
241
|
-
ares_free(channel->domains[i]);
|
242
|
-
ares_free(channel->domains);
|
243
|
-
}
|
240
|
+
if (channel->ndomains != -1)
|
241
|
+
ares_strsplit_free(channel->domains, channel->ndomains);
|
244
242
|
if (channel->sortlist)
|
245
243
|
ares_free(channel->sortlist);
|
246
244
|
if(channel->lookups)
|
247
245
|
ares_free(channel->lookups);
|
246
|
+
if(channel->resolvconf_path)
|
247
|
+
ares_free(channel->resolvconf_path);
|
248
248
|
ares_free(channel);
|
249
249
|
return status;
|
250
250
|
}
|
@@ -298,7 +298,7 @@ int ares_dup(ares_channel *dest, ares_channel src)
|
|
298
298
|
(*dest)->sock_func_cb_data = src->sock_func_cb_data;
|
299
299
|
|
300
300
|
strncpy((*dest)->local_dev_name, src->local_dev_name,
|
301
|
-
sizeof(
|
301
|
+
sizeof((*dest)->local_dev_name));
|
302
302
|
(*dest)->local_ip4 = src->local_ip4;
|
303
303
|
memcpy((*dest)->local_ip6, src->local_ip6, sizeof(src->local_ip6));
|
304
304
|
|
@@ -353,6 +353,9 @@ int ares_save_options(ares_channel channel, struct ares_options *options,
|
|
353
353
|
ARES_OPT_SORTLIST|ARES_OPT_TIMEOUTMS);
|
354
354
|
(*optmask) |= (channel->rotate ? ARES_OPT_ROTATE : ARES_OPT_NOROTATE);
|
355
355
|
|
356
|
+
if (channel->resolvconf_path)
|
357
|
+
(*optmask) |= ARES_OPT_RESOLVCONF;
|
358
|
+
|
356
359
|
/* Copy easy stuff */
|
357
360
|
options->flags = channel->flags;
|
358
361
|
|
@@ -425,6 +428,13 @@ int ares_save_options(ares_channel channel, struct ares_options *options,
|
|
425
428
|
}
|
426
429
|
options->nsort = channel->nsort;
|
427
430
|
|
431
|
+
/* copy path for resolv.conf file */
|
432
|
+
if (channel->resolvconf_path) {
|
433
|
+
options->resolvconf_path = ares_strdup(channel->resolvconf_path);
|
434
|
+
if (!options->resolvconf_path)
|
435
|
+
return ARES_ENOMEM;
|
436
|
+
}
|
437
|
+
|
428
438
|
return ARES_SUCCESS;
|
429
439
|
}
|
430
440
|
|
@@ -533,6 +543,14 @@ static int init_by_options(ares_channel channel,
|
|
533
543
|
channel->nsort = options->nsort;
|
534
544
|
}
|
535
545
|
|
546
|
+
/* Set path for resolv.conf file, if given. */
|
547
|
+
if ((optmask & ARES_OPT_RESOLVCONF) && !channel->resolvconf_path)
|
548
|
+
{
|
549
|
+
channel->resolvconf_path = ares_strdup(options->resolvconf_path);
|
550
|
+
if (!channel->resolvconf_path && options->resolvconf_path)
|
551
|
+
return ARES_ENOMEM;
|
552
|
+
}
|
553
|
+
|
536
554
|
channel->optmask = optmask;
|
537
555
|
|
538
556
|
return ARES_SUCCESS;
|
@@ -585,7 +603,7 @@ static int get_REG_SZ(HKEY hKey, const char *leafKeyName, char **outptr)
|
|
585
603
|
*outptr = NULL;
|
586
604
|
|
587
605
|
/* Find out size of string stored in registry */
|
588
|
-
res =
|
606
|
+
res = RegQueryValueExA(hKey, leafKeyName, 0, NULL, NULL, &size);
|
589
607
|
if ((res != ERROR_SUCCESS && res != ERROR_MORE_DATA) || !size)
|
590
608
|
return 0;
|
591
609
|
|
@@ -596,7 +614,7 @@ static int get_REG_SZ(HKEY hKey, const char *leafKeyName, char **outptr)
|
|
596
614
|
return 0;
|
597
615
|
|
598
616
|
/* Get the value for real */
|
599
|
-
res =
|
617
|
+
res = RegQueryValueExA(hKey, leafKeyName, 0, NULL,
|
600
618
|
(unsigned char *)*outptr, &size);
|
601
619
|
if ((res != ERROR_SUCCESS) || (size == 1))
|
602
620
|
{
|
@@ -627,7 +645,7 @@ static int get_REG_SZ_9X(HKEY hKey, const char *leafKeyName, char **outptr)
|
|
627
645
|
*outptr = NULL;
|
628
646
|
|
629
647
|
/* Find out size of string stored in registry */
|
630
|
-
res =
|
648
|
+
res = RegQueryValueExA(hKey, leafKeyName, 0, &dataType, NULL, &size);
|
631
649
|
if ((res != ERROR_SUCCESS && res != ERROR_MORE_DATA) || !size)
|
632
650
|
return 0;
|
633
651
|
|
@@ -638,7 +656,7 @@ static int get_REG_SZ_9X(HKEY hKey, const char *leafKeyName, char **outptr)
|
|
638
656
|
return 0;
|
639
657
|
|
640
658
|
/* Get the value for real */
|
641
|
-
res =
|
659
|
+
res = RegQueryValueExA(hKey, leafKeyName, 0, &dataType,
|
642
660
|
(unsigned char *)*outptr, &size);
|
643
661
|
if ((res != ERROR_SUCCESS) || (size == 1))
|
644
662
|
{
|
@@ -683,11 +701,11 @@ static int get_enum_REG_SZ(HKEY hKeyParent, const char *leafKeyName,
|
|
683
701
|
for(;;)
|
684
702
|
{
|
685
703
|
enumKeyNameBuffSize = sizeof(enumKeyName);
|
686
|
-
res =
|
704
|
+
res = RegEnumKeyExA(hKeyParent, enumKeyIdx++, enumKeyName,
|
687
705
|
&enumKeyNameBuffSize, 0, NULL, NULL, NULL);
|
688
706
|
if (res != ERROR_SUCCESS)
|
689
707
|
break;
|
690
|
-
res =
|
708
|
+
res = RegOpenKeyExA(hKeyParent, enumKeyName, 0, KEY_QUERY_VALUE,
|
691
709
|
&hKeyEnum);
|
692
710
|
if (res != ERROR_SUCCESS)
|
693
711
|
continue;
|
@@ -718,7 +736,7 @@ static int get_DNS_Registry_9X(char **outptr)
|
|
718
736
|
|
719
737
|
*outptr = NULL;
|
720
738
|
|
721
|
-
res =
|
739
|
+
res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_9X, 0, KEY_READ,
|
722
740
|
&hKey_VxD_MStcp);
|
723
741
|
if (res != ERROR_SUCCESS)
|
724
742
|
return 0;
|
@@ -750,7 +768,7 @@ static int get_DNS_Registry_NT(char **outptr)
|
|
750
768
|
|
751
769
|
*outptr = NULL;
|
752
770
|
|
753
|
-
res =
|
771
|
+
res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ,
|
754
772
|
&hKey_Tcpip_Parameters);
|
755
773
|
if (res != ERROR_SUCCESS)
|
756
774
|
return 0;
|
@@ -772,7 +790,7 @@ static int get_DNS_Registry_NT(char **outptr)
|
|
772
790
|
goto done;
|
773
791
|
|
774
792
|
/* Try adapter specific parameters */
|
775
|
-
res =
|
793
|
+
res = RegOpenKeyExA(hKey_Tcpip_Parameters, "Interfaces", 0,
|
776
794
|
KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS,
|
777
795
|
&hKey_Interfaces);
|
778
796
|
if (res != ERROR_SUCCESS)
|
@@ -949,9 +967,16 @@ static BOOL ares_IsWindowsVistaOrGreater(void)
|
|
949
967
|
OSVERSIONINFO vinfo;
|
950
968
|
memset(&vinfo, 0, sizeof(vinfo));
|
951
969
|
vinfo.dwOSVersionInfoSize = sizeof(vinfo);
|
970
|
+
#ifdef _MSC_VER
|
971
|
+
#pragma warning(push)
|
972
|
+
#pragma warning(disable:4996) /* warning C4996: 'GetVersionExW': was declared deprecated */
|
973
|
+
#endif
|
952
974
|
if (!GetVersionEx(&vinfo) || vinfo.dwMajorVersion < 6)
|
953
975
|
return FALSE;
|
954
976
|
return TRUE;
|
977
|
+
#ifdef _MSC_VER
|
978
|
+
#pragma warning(pop)
|
979
|
+
#endif
|
955
980
|
}
|
956
981
|
|
957
982
|
/* A structure to hold the string form of IPv4 and IPv6 addresses so we can
|
@@ -962,6 +987,10 @@ typedef struct
|
|
962
987
|
/* The metric we sort them by. */
|
963
988
|
ULONG metric;
|
964
989
|
|
990
|
+
/* Original index of the item, used as a secondary sort parameter to make
|
991
|
+
* qsort() stable if the metrics are equal */
|
992
|
+
size_t orig_idx;
|
993
|
+
|
965
994
|
/* Room enough for the string form of any IPv4 or IPv6 address that
|
966
995
|
* ares_inet_ntop() will create. Based on the existing c-ares practice.
|
967
996
|
*/
|
@@ -976,8 +1005,12 @@ static int compareAddresses(const void *arg1,
|
|
976
1005
|
{
|
977
1006
|
const Address * const left = arg1;
|
978
1007
|
const Address * const right = arg2;
|
1008
|
+
/* Lower metric the more preferred */
|
979
1009
|
if(left->metric < right->metric) return -1;
|
980
1010
|
if(left->metric > right->metric) return 1;
|
1011
|
+
/* If metrics are equal, lower original index more preferred */
|
1012
|
+
if(left->orig_idx < right->orig_idx) return -1;
|
1013
|
+
if(left->orig_idx > right->orig_idx) return 1;
|
981
1014
|
return 0;
|
982
1015
|
}
|
983
1016
|
|
@@ -1164,7 +1197,7 @@ static int get_DNS_AdaptersAddresses(char **outptr)
|
|
1164
1197
|
/* Allocate room for another address, if necessary, else skip. */
|
1165
1198
|
if(addressesIndex == addressesSize) {
|
1166
1199
|
const size_t newSize = addressesSize + 4;
|
1167
|
-
Address * const newMem =
|
1200
|
+
Address * const newMem =
|
1168
1201
|
(Address*)ares_realloc(addresses, sizeof(Address) * newSize);
|
1169
1202
|
if(newMem == NULL) {
|
1170
1203
|
continue;
|
@@ -1184,9 +1217,12 @@ static int get_DNS_AdaptersAddresses(char **outptr)
|
|
1184
1217
|
}
|
1185
1218
|
else
|
1186
1219
|
{
|
1187
|
-
addresses[addressesIndex].metric = -1;
|
1220
|
+
addresses[addressesIndex].metric = (ULONG)-1;
|
1188
1221
|
}
|
1189
1222
|
|
1223
|
+
/* Record insertion index to make qsort stable */
|
1224
|
+
addresses[addressesIndex].orig_idx = addressesIndex;
|
1225
|
+
|
1190
1226
|
if (! ares_inet_ntop(AF_INET, &namesrvr.sa4->sin_addr,
|
1191
1227
|
addresses[addressesIndex].text,
|
1192
1228
|
sizeof(addresses[0].text))) {
|
@@ -1218,14 +1254,17 @@ static int get_DNS_AdaptersAddresses(char **outptr)
|
|
1218
1254
|
/* Save the address as the next element in addresses. */
|
1219
1255
|
addresses[addressesIndex].metric =
|
1220
1256
|
getBestRouteMetric(&ipaaEntry->Luid,
|
1221
|
-
(SOCKADDR_INET*)(namesrvr.sa),
|
1257
|
+
(SOCKADDR_INET*)(namesrvr.sa),
|
1222
1258
|
ipaaEntry->Ipv6Metric);
|
1223
1259
|
}
|
1224
1260
|
else
|
1225
1261
|
{
|
1226
|
-
addresses[addressesIndex].metric = -1;
|
1262
|
+
addresses[addressesIndex].metric = (ULONG)-1;
|
1227
1263
|
}
|
1228
1264
|
|
1265
|
+
/* Record insertion index to make qsort stable */
|
1266
|
+
addresses[addressesIndex].orig_idx = addressesIndex;
|
1267
|
+
|
1229
1268
|
if (! ares_inet_ntop(AF_INET6, &namesrvr.sa6->sin6_addr,
|
1230
1269
|
addresses[addressesIndex].text,
|
1231
1270
|
sizeof(addresses[0].text))) {
|
@@ -1240,7 +1279,8 @@ static int get_DNS_AdaptersAddresses(char **outptr)
|
|
1240
1279
|
}
|
1241
1280
|
}
|
1242
1281
|
|
1243
|
-
/* Sort all of the textual addresses by their metric
|
1282
|
+
/* Sort all of the textual addresses by their metric (and original index if
|
1283
|
+
* metrics are equal). */
|
1244
1284
|
qsort(addresses, addressesIndex, sizeof(*addresses), compareAddresses);
|
1245
1285
|
|
1246
1286
|
/* Join them all into a single string, removing duplicates. */
|
@@ -1264,7 +1304,7 @@ static int get_DNS_AdaptersAddresses(char **outptr)
|
|
1264
1304
|
|
1265
1305
|
done:
|
1266
1306
|
ares_free(addresses);
|
1267
|
-
|
1307
|
+
|
1268
1308
|
if (ipaa)
|
1269
1309
|
ares_free(ipaa);
|
1270
1310
|
|
@@ -1304,59 +1344,6 @@ static int get_DNS_Windows(char **outptr)
|
|
1304
1344
|
return get_DNS_Registry(outptr);
|
1305
1345
|
}
|
1306
1346
|
|
1307
|
-
static void replace_comma_by_space(char* str)
|
1308
|
-
{
|
1309
|
-
/* replace ',' by ' ' to coincide with resolv.conf search parameter */
|
1310
|
-
char *p;
|
1311
|
-
for (p = str; *p != '\0'; p++)
|
1312
|
-
{
|
1313
|
-
if (*p == ',')
|
1314
|
-
*p = ' ';
|
1315
|
-
}
|
1316
|
-
}
|
1317
|
-
|
1318
|
-
/* Search if 'suffix' is containted in the 'searchlist'. Returns true if yes,
|
1319
|
-
* otherwise false. 'searchlist' is a comma separated list of domain suffixes,
|
1320
|
-
* 'suffix' is one domain suffix, 'len' is the length of 'suffix'.
|
1321
|
-
* The search ignores case. E.g.:
|
1322
|
-
* contains_suffix("abc.def,ghi.jkl", "ghi.JKL") returns true */
|
1323
|
-
static bool contains_suffix(const char* const searchlist,
|
1324
|
-
const char* const suffix, const size_t len)
|
1325
|
-
{
|
1326
|
-
const char* beg = searchlist;
|
1327
|
-
const char* end;
|
1328
|
-
if (!*suffix)
|
1329
|
-
return true;
|
1330
|
-
for (;;)
|
1331
|
-
{
|
1332
|
-
while (*beg && (ISSPACE(*beg) || (*beg == ',')))
|
1333
|
-
++beg;
|
1334
|
-
if (!*beg)
|
1335
|
-
return false;
|
1336
|
-
end = beg;
|
1337
|
-
while (*end && !ISSPACE(*end) && (*end != ','))
|
1338
|
-
++end;
|
1339
|
-
if (len == (end - beg) && !strnicmp(beg, suffix, len))
|
1340
|
-
return true;
|
1341
|
-
beg = end;
|
1342
|
-
}
|
1343
|
-
}
|
1344
|
-
|
1345
|
-
/* advances list to the next suffix within a comma separated search list.
|
1346
|
-
* len is the length of the next suffix. */
|
1347
|
-
static size_t next_suffix(const char** list, const size_t advance)
|
1348
|
-
{
|
1349
|
-
const char* beg = *list + advance;
|
1350
|
-
const char* end;
|
1351
|
-
while (*beg && (ISSPACE(*beg) || (*beg == ',')))
|
1352
|
-
++beg;
|
1353
|
-
end = beg;
|
1354
|
-
while (*end && !ISSPACE(*end) && (*end != ','))
|
1355
|
-
++end;
|
1356
|
-
*list = beg;
|
1357
|
-
return end - beg;
|
1358
|
-
}
|
1359
|
-
|
1360
1347
|
/*
|
1361
1348
|
* get_SuffixList_Windows()
|
1362
1349
|
*
|
@@ -1368,7 +1355,7 @@ static size_t next_suffix(const char** list, const size_t advance)
|
|
1368
1355
|
*
|
1369
1356
|
* Returns 1 and sets *outptr when returning a dynamically allocated string.
|
1370
1357
|
*
|
1371
|
-
* Implementation supports Windows Server 2003 and newer
|
1358
|
+
* Implementation supports Windows Server 2003 and newer
|
1372
1359
|
*/
|
1373
1360
|
static int get_SuffixList_Windows(char **outptr)
|
1374
1361
|
{
|
@@ -1377,8 +1364,6 @@ static int get_SuffixList_Windows(char **outptr)
|
|
1377
1364
|
DWORD keyNameBuffSize;
|
1378
1365
|
DWORD keyIdx = 0;
|
1379
1366
|
char *p = NULL;
|
1380
|
-
char *pp;
|
1381
|
-
size_t len = 0;
|
1382
1367
|
|
1383
1368
|
*outptr = NULL;
|
1384
1369
|
|
@@ -1386,60 +1371,83 @@ static int get_SuffixList_Windows(char **outptr)
|
|
1386
1371
|
return 0;
|
1387
1372
|
|
1388
1373
|
/* 1. Global DNS Suffix Search List */
|
1389
|
-
if (
|
1374
|
+
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0,
|
1390
1375
|
KEY_READ, &hKey) == ERROR_SUCCESS)
|
1391
1376
|
{
|
1392
|
-
|
1393
|
-
|
1377
|
+
get_REG_SZ(hKey, SEARCHLIST_KEY, outptr);
|
1378
|
+
if (get_REG_SZ(hKey, DOMAIN_KEY, &p))
|
1379
|
+
{
|
1380
|
+
commajoin(outptr, p);
|
1381
|
+
ares_free(p);
|
1382
|
+
p = NULL;
|
1383
|
+
}
|
1384
|
+
RegCloseKey(hKey);
|
1385
|
+
}
|
1386
|
+
|
1387
|
+
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NT_DNSCLIENT, 0,
|
1388
|
+
KEY_READ, &hKey) == ERROR_SUCCESS)
|
1389
|
+
{
|
1390
|
+
if (get_REG_SZ(hKey, SEARCHLIST_KEY, &p))
|
1391
|
+
{
|
1392
|
+
commajoin(outptr, p);
|
1393
|
+
ares_free(p);
|
1394
|
+
p = NULL;
|
1395
|
+
}
|
1394
1396
|
RegCloseKey(hKey);
|
1395
|
-
if (*outptr)
|
1396
|
-
return 1;
|
1397
1397
|
}
|
1398
1398
|
|
1399
1399
|
/* 2. Connection Specific Search List composed of:
|
1400
1400
|
* a. Primary DNS Suffix */
|
1401
|
-
if (
|
1401
|
+
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_DNSCLIENT, 0,
|
1402
1402
|
KEY_READ, &hKey) == ERROR_SUCCESS)
|
1403
1403
|
{
|
1404
|
-
get_REG_SZ(hKey, PRIMARYDNSSUFFIX_KEY,
|
1404
|
+
if (get_REG_SZ(hKey, PRIMARYDNSSUFFIX_KEY, &p))
|
1405
|
+
{
|
1406
|
+
commajoin(outptr, p);
|
1407
|
+
ares_free(p);
|
1408
|
+
p = NULL;
|
1409
|
+
}
|
1405
1410
|
RegCloseKey(hKey);
|
1406
1411
|
}
|
1407
|
-
if (!*outptr)
|
1408
|
-
return 0;
|
1409
1412
|
|
1410
1413
|
/* b. Interface SearchList, Domain, DhcpDomain */
|
1411
|
-
if (
|
1414
|
+
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY "\\" INTERFACES_KEY, 0,
|
1412
1415
|
KEY_READ, &hKey) == ERROR_SUCCESS)
|
1413
|
-
return 0;
|
1414
|
-
for(;;)
|
1415
1416
|
{
|
1416
|
-
|
1417
|
-
if (RegEnumKeyEx(hKey, keyIdx++, keyName, &keyNameBuffSize,
|
1418
|
-
0, NULL, NULL, NULL)
|
1419
|
-
!= ERROR_SUCCESS)
|
1420
|
-
break;
|
1421
|
-
if (RegOpenKeyEx(hKey, keyName, 0, KEY_QUERY_VALUE, &hKeyEnum)
|
1422
|
-
!= ERROR_SUCCESS)
|
1423
|
-
continue;
|
1424
|
-
if (get_REG_SZ(hKeyEnum, SEARCHLIST_KEY, &p) ||
|
1425
|
-
get_REG_SZ(hKeyEnum, DOMAIN_KEY, &p) ||
|
1426
|
-
get_REG_SZ(hKeyEnum, DHCPDOMAIN_KEY, &p))
|
1417
|
+
for(;;)
|
1427
1418
|
{
|
1419
|
+
keyNameBuffSize = sizeof(keyName);
|
1420
|
+
if (RegEnumKeyExA(hKey, keyIdx++, keyName, &keyNameBuffSize,
|
1421
|
+
0, NULL, NULL, NULL)
|
1422
|
+
!= ERROR_SUCCESS)
|
1423
|
+
break;
|
1424
|
+
if (RegOpenKeyExA(hKey, keyName, 0, KEY_QUERY_VALUE, &hKeyEnum)
|
1425
|
+
!= ERROR_SUCCESS)
|
1426
|
+
continue;
|
1428
1427
|
/* p can be comma separated (SearchList) */
|
1429
|
-
|
1430
|
-
while (len = next_suffix(&pp, len))
|
1428
|
+
if (get_REG_SZ(hKeyEnum, SEARCHLIST_KEY, &p))
|
1431
1429
|
{
|
1432
|
-
|
1433
|
-
|
1430
|
+
commajoin(outptr, p);
|
1431
|
+
ares_free(p);
|
1432
|
+
p = NULL;
|
1434
1433
|
}
|
1435
|
-
|
1436
|
-
|
1434
|
+
if (get_REG_SZ(hKeyEnum, DOMAIN_KEY, &p))
|
1435
|
+
{
|
1436
|
+
commajoin(outptr, p);
|
1437
|
+
ares_free(p);
|
1438
|
+
p = NULL;
|
1439
|
+
}
|
1440
|
+
if (get_REG_SZ(hKeyEnum, DHCPDOMAIN_KEY, &p))
|
1441
|
+
{
|
1442
|
+
commajoin(outptr, p);
|
1443
|
+
ares_free(p);
|
1444
|
+
p = NULL;
|
1445
|
+
}
|
1446
|
+
RegCloseKey(hKeyEnum);
|
1437
1447
|
}
|
1438
|
-
RegCloseKey(
|
1448
|
+
RegCloseKey(hKey);
|
1439
1449
|
}
|
1440
|
-
|
1441
|
-
if (*outptr)
|
1442
|
-
replace_comma_by_space(*outptr);
|
1450
|
+
|
1443
1451
|
return *outptr != NULL;
|
1444
1452
|
}
|
1445
1453
|
|
@@ -1537,18 +1545,62 @@ static int init_by_resolv_conf(ares_channel channel)
|
|
1537
1545
|
unsigned int i;
|
1538
1546
|
char propname[PROP_NAME_MAX];
|
1539
1547
|
char propvalue[PROP_VALUE_MAX]="";
|
1548
|
+
char **dns_servers;
|
1549
|
+
char *domains;
|
1550
|
+
size_t num_servers;
|
1551
|
+
|
1552
|
+
/* Use the Android connectivity manager to get a list
|
1553
|
+
* of DNS servers. As of Android 8 (Oreo) net.dns#
|
1554
|
+
* system properties are no longer available. Google claims this
|
1555
|
+
* improves privacy. Apps now need the ACCESS_NETWORK_STATE
|
1556
|
+
* permission and must use the ConnectivityManager which
|
1557
|
+
* is Java only. */
|
1558
|
+
dns_servers = ares_get_android_server_list(MAX_DNS_PROPERTIES, &num_servers);
|
1559
|
+
if (dns_servers != NULL)
|
1560
|
+
{
|
1561
|
+
for (i = 0; i < num_servers; i++)
|
1562
|
+
{
|
1563
|
+
status = config_nameserver(&servers, &nservers, dns_servers[i]);
|
1564
|
+
if (status != ARES_SUCCESS)
|
1565
|
+
break;
|
1566
|
+
status = ARES_EOF;
|
1567
|
+
}
|
1568
|
+
for (i = 0; i < num_servers; i++)
|
1569
|
+
{
|
1570
|
+
ares_free(dns_servers[i]);
|
1571
|
+
}
|
1572
|
+
ares_free(dns_servers);
|
1573
|
+
}
|
1574
|
+
if (channel->ndomains == -1)
|
1575
|
+
{
|
1576
|
+
domains = ares_get_android_search_domains_list();
|
1577
|
+
set_search(channel, domains);
|
1578
|
+
ares_free(domains);
|
1579
|
+
}
|
1580
|
+
|
1581
|
+
# ifdef HAVE___SYSTEM_PROPERTY_GET
|
1582
|
+
/* Old way using the system property still in place as
|
1583
|
+
* a fallback. Older android versions can still use this.
|
1584
|
+
* it's possible for older apps not not have added the new
|
1585
|
+
* permission and we want to try to avoid breaking those.
|
1586
|
+
*
|
1587
|
+
* We'll only run this if we don't have any dns servers
|
1588
|
+
* because this will get the same ones (if it works). */
|
1589
|
+
if (status != ARES_EOF) {
|
1590
|
+
for (i = 1; i <= MAX_DNS_PROPERTIES; i++) {
|
1591
|
+
snprintf(propname, sizeof(propname), "%s%u", DNS_PROP_NAME_PREFIX, i);
|
1592
|
+
if (__system_property_get(propname, propvalue) < 1) {
|
1593
|
+
status = ARES_EOF;
|
1594
|
+
break;
|
1595
|
+
}
|
1540
1596
|
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1597
|
+
status = config_nameserver(&servers, &nservers, propvalue);
|
1598
|
+
if (status != ARES_SUCCESS)
|
1599
|
+
break;
|
1544
1600
|
status = ARES_EOF;
|
1545
|
-
break;
|
1546
1601
|
}
|
1547
|
-
status = config_nameserver(&servers, &nservers, propvalue);
|
1548
|
-
if (status != ARES_SUCCESS)
|
1549
|
-
break;
|
1550
|
-
status = ARES_EOF;
|
1551
1602
|
}
|
1603
|
+
# endif /* HAVE___SYSTEM_PROPERTY_GET */
|
1552
1604
|
#elif defined(CARES_USE_LIBRESOLV)
|
1553
1605
|
struct __res_state res;
|
1554
1606
|
memset(&res, 0, sizeof(res));
|
@@ -1613,6 +1665,7 @@ static int init_by_resolv_conf(ares_channel channel)
|
|
1613
1665
|
size_t linesize;
|
1614
1666
|
int error;
|
1615
1667
|
int update_domains;
|
1668
|
+
const char *resolvconf_path;
|
1616
1669
|
|
1617
1670
|
/* Don't read resolv.conf and friends if we don't have to */
|
1618
1671
|
if (ARES_CONFIG_CHECK(channel))
|
@@ -1621,7 +1674,14 @@ static int init_by_resolv_conf(ares_channel channel)
|
|
1621
1674
|
/* Only update search domains if they're not already specified */
|
1622
1675
|
update_domains = (channel->ndomains == -1);
|
1623
1676
|
|
1624
|
-
|
1677
|
+
/* Support path for resolvconf filename set by ares_init_options */
|
1678
|
+
if(channel->resolvconf_path) {
|
1679
|
+
resolvconf_path = channel->resolvconf_path;
|
1680
|
+
} else {
|
1681
|
+
resolvconf_path = PATH_RESOLV_CONF;
|
1682
|
+
}
|
1683
|
+
|
1684
|
+
fp = fopen(resolvconf_path, "r");
|
1625
1685
|
if (fp) {
|
1626
1686
|
while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS)
|
1627
1687
|
{
|
@@ -1632,10 +1692,10 @@ static int init_by_resolv_conf(ares_channel channel)
|
|
1632
1692
|
else if ((p = try_config(line, "search", ';')) && update_domains)
|
1633
1693
|
status = set_search(channel, p);
|
1634
1694
|
else if ((p = try_config(line, "nameserver", ';')) &&
|
1635
|
-
|
1695
|
+
channel->nservers == -1)
|
1636
1696
|
status = config_nameserver(&servers, &nservers, p);
|
1637
1697
|
else if ((p = try_config(line, "sortlist", ';')) &&
|
1638
|
-
|
1698
|
+
channel->nsort == -1)
|
1639
1699
|
status = config_sortlist(&sortlist, &nsort, p);
|
1640
1700
|
else if ((p = try_config(line, "options", ';')))
|
1641
1701
|
status = set_options(channel, p);
|
@@ -1655,7 +1715,7 @@ static int init_by_resolv_conf(ares_channel channel)
|
|
1655
1715
|
break;
|
1656
1716
|
default:
|
1657
1717
|
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n",
|
1658
|
-
|
1718
|
+
error, strerror(error)));
|
1659
1719
|
DEBUGF(fprintf(stderr, "Error opening file: %s\n", PATH_RESOLV_CONF));
|
1660
1720
|
status = ARES_EFILE;
|
1661
1721
|
}
|
@@ -1868,8 +1928,10 @@ static int init_by_defaults(ares_channel channel)
|
|
1868
1928
|
continue;
|
1869
1929
|
}
|
1870
1930
|
else if(res) {
|
1871
|
-
|
1872
|
-
|
1931
|
+
/* Lets not treat a gethostname failure as critical, since we
|
1932
|
+
* are ok if gethostname doesn't even exist */
|
1933
|
+
*hostname = '\0';
|
1934
|
+
break;
|
1873
1935
|
}
|
1874
1936
|
|
1875
1937
|
} while (res != 0);
|
@@ -1921,6 +1983,11 @@ static int init_by_defaults(ares_channel channel)
|
|
1921
1983
|
ares_free(channel->lookups);
|
1922
1984
|
channel->lookups = NULL;
|
1923
1985
|
}
|
1986
|
+
|
1987
|
+
if(channel->resolvconf_path) {
|
1988
|
+
ares_free(channel->resolvconf_path);
|
1989
|
+
channel->resolvconf_path = NULL;
|
1990
|
+
}
|
1924
1991
|
}
|
1925
1992
|
|
1926
1993
|
if(hostname)
|
@@ -1985,6 +2052,76 @@ static int config_lookup(ares_channel channel, const char *str,
|
|
1985
2052
|
#endif /* !WIN32 & !WATT32 & !ANDROID & !__ANDROID__ & !CARES_USE_LIBRESOLV */
|
1986
2053
|
|
1987
2054
|
#ifndef WATT32
|
2055
|
+
/* Validate that the ip address matches the subnet (network base and network
|
2056
|
+
* mask) specified. Addresses are specified in standard Network Byte Order as
|
2057
|
+
* 16 bytes, and the netmask is 0 to 128 (bits).
|
2058
|
+
*/
|
2059
|
+
static int ares_ipv6_subnet_matches(const unsigned char netbase[16],
|
2060
|
+
unsigned char netmask,
|
2061
|
+
const unsigned char ipaddr[16])
|
2062
|
+
{
|
2063
|
+
unsigned char mask[16] = { 0 };
|
2064
|
+
unsigned char i;
|
2065
|
+
|
2066
|
+
/* Misuse */
|
2067
|
+
if (netmask > 128)
|
2068
|
+
return 0;
|
2069
|
+
|
2070
|
+
/* Quickly set whole bytes */
|
2071
|
+
memset(mask, 0xFF, netmask / 8);
|
2072
|
+
|
2073
|
+
/* Set remaining bits */
|
2074
|
+
if(netmask % 8) {
|
2075
|
+
mask[netmask / 8] = (unsigned char)(0xff << (8 - (netmask % 8)));
|
2076
|
+
}
|
2077
|
+
|
2078
|
+
for (i=0; i<16; i++) {
|
2079
|
+
if ((netbase[i] & mask[i]) != (ipaddr[i] & mask[i]))
|
2080
|
+
return 0;
|
2081
|
+
}
|
2082
|
+
|
2083
|
+
return 1;
|
2084
|
+
}
|
2085
|
+
|
2086
|
+
/* Return true iff the IPv6 ipaddr is blacklisted. */
|
2087
|
+
static int ares_ipv6_server_blacklisted(const unsigned char ipaddr[16])
|
2088
|
+
{
|
2089
|
+
/* A list of blacklisted IPv6 subnets. */
|
2090
|
+
const struct {
|
2091
|
+
const unsigned char netbase[16];
|
2092
|
+
unsigned char netmask;
|
2093
|
+
} blacklist[] = {
|
2094
|
+
/* fec0::/10 was deprecated by [RFC3879] in September 2004. Formerly a
|
2095
|
+
* Site-Local scoped address prefix. These are never valid DNS servers,
|
2096
|
+
* but are known to be returned at least sometimes on Windows and Android.
|
2097
|
+
*/
|
2098
|
+
{
|
2099
|
+
{
|
2100
|
+
0xfe, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
2101
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
2102
|
+
},
|
2103
|
+
10
|
2104
|
+
}
|
2105
|
+
};
|
2106
|
+
size_t i;
|
2107
|
+
|
2108
|
+
/* See if ipaddr matches any of the entries in the blacklist. */
|
2109
|
+
for (i = 0; i < sizeof(blacklist) / sizeof(blacklist[0]); ++i) {
|
2110
|
+
if (ares_ipv6_subnet_matches(
|
2111
|
+
blacklist[i].netbase, blacklist[i].netmask, ipaddr))
|
2112
|
+
return 1;
|
2113
|
+
}
|
2114
|
+
return 0;
|
2115
|
+
}
|
2116
|
+
|
2117
|
+
/* Add the IPv4 or IPv6 nameservers in str (separated by commas) to the
|
2118
|
+
* servers list, updating servers and nservers as required.
|
2119
|
+
*
|
2120
|
+
* This will silently ignore blacklisted IPv6 nameservers as detected by
|
2121
|
+
* ares_ipv6_server_blacklisted().
|
2122
|
+
*
|
2123
|
+
* Returns an error code on failure, else ARES_SUCCESS.
|
2124
|
+
*/
|
1988
2125
|
static int config_nameserver(struct server_state **servers, int *nservers,
|
1989
2126
|
char *str)
|
1990
2127
|
{
|
@@ -2019,7 +2156,10 @@ static int config_nameserver(struct server_state **servers, int *nservers,
|
|
2019
2156
|
/* Convert textual address to binary format. */
|
2020
2157
|
if (ares_inet_pton(AF_INET, txtaddr, &host.addrV4) == 1)
|
2021
2158
|
host.family = AF_INET;
|
2022
|
-
else if (ares_inet_pton(AF_INET6, txtaddr, &host.addrV6) == 1
|
2159
|
+
else if (ares_inet_pton(AF_INET6, txtaddr, &host.addrV6) == 1
|
2160
|
+
/* Silently skip blacklisted IPv6 servers. */
|
2161
|
+
&& !ares_ipv6_server_blacklisted(
|
2162
|
+
(const unsigned char *)&host.addrV6))
|
2023
2163
|
host.family = AF_INET6;
|
2024
2164
|
else
|
2025
2165
|
continue;
|
@@ -2142,61 +2282,22 @@ static int config_sortlist(struct apattern **sortlist, int *nsort,
|
|
2142
2282
|
|
2143
2283
|
static int set_search(ares_channel channel, const char *str)
|
2144
2284
|
{
|
2145
|
-
|
2146
|
-
const char *p, *q;
|
2285
|
+
size_t cnt;
|
2147
2286
|
|
2148
2287
|
if(channel->ndomains != -1) {
|
2149
2288
|
/* LCOV_EXCL_START: all callers check ndomains == -1 */
|
2150
2289
|
/* if we already have some domains present, free them first */
|
2151
|
-
|
2152
|
-
ares_free(channel->domains[n]);
|
2153
|
-
ares_free(channel->domains);
|
2290
|
+
ares_strsplit_free(channel->domains, channel->ndomains);
|
2154
2291
|
channel->domains = NULL;
|
2155
2292
|
channel->ndomains = -1;
|
2156
2293
|
} /* LCOV_EXCL_STOP */
|
2157
2294
|
|
2158
|
-
|
2159
|
-
|
2160
|
-
|
2161
|
-
|
2162
|
-
|
2163
|
-
|
2164
|
-
p++;
|
2165
|
-
while (ISSPACE(*p))
|
2166
|
-
p++;
|
2167
|
-
n++;
|
2168
|
-
}
|
2169
|
-
|
2170
|
-
if (!n)
|
2171
|
-
{
|
2172
|
-
channel->ndomains = 0;
|
2173
|
-
return ARES_SUCCESS;
|
2174
|
-
}
|
2175
|
-
|
2176
|
-
channel->domains = ares_malloc(n * sizeof(char *));
|
2177
|
-
if (!channel->domains)
|
2178
|
-
return ARES_ENOMEM;
|
2179
|
-
|
2180
|
-
/* Now copy the domains. */
|
2181
|
-
n = 0;
|
2182
|
-
p = str;
|
2183
|
-
while (*p)
|
2184
|
-
{
|
2185
|
-
channel->ndomains = n;
|
2186
|
-
q = p;
|
2187
|
-
while (*q && !ISSPACE(*q))
|
2188
|
-
q++;
|
2189
|
-
channel->domains[n] = ares_malloc(q - p + 1);
|
2190
|
-
if (!channel->domains[n])
|
2191
|
-
return ARES_ENOMEM;
|
2192
|
-
memcpy(channel->domains[n], p, q - p);
|
2193
|
-
channel->domains[n][q - p] = 0;
|
2194
|
-
p = q;
|
2195
|
-
while (ISSPACE(*p))
|
2196
|
-
p++;
|
2197
|
-
n++;
|
2198
|
-
}
|
2199
|
-
channel->ndomains = n;
|
2295
|
+
channel->domains = ares_strsplit(str, ", ", 1, &cnt);
|
2296
|
+
channel->ndomains = (int)cnt;
|
2297
|
+
if (channel->domains == NULL || channel->ndomains == 0) {
|
2298
|
+
channel->domains = NULL;
|
2299
|
+
channel->ndomains = -1;
|
2300
|
+
}
|
2200
2301
|
|
2201
2302
|
return ARES_SUCCESS;
|
2202
2303
|
}
|