grpc 1.74.1 → 1.75.0.pre1
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 +83 -41
- data/include/grpc/credentials.h +7 -1
- data/src/core/call/client_call.cc +4 -4
- data/src/core/call/filter_fusion.h +1230 -0
- data/src/core/call/metadata.cc +22 -0
- data/src/core/call/metadata.h +24 -2
- data/src/core/channelz/channelz.cc +10 -17
- data/src/core/channelz/channelz.h +58 -19
- data/src/core/channelz/channelz_registry.cc +0 -162
- data/src/core/channelz/channelz_registry.h +14 -7
- data/src/core/channelz/property_list.cc +19 -23
- data/src/core/channelz/property_list.h +3 -1
- data/src/core/channelz/v2tov1/convert.cc +683 -0
- data/src/core/channelz/v2tov1/convert.h +58 -0
- data/src/core/channelz/v2tov1/legacy_api.cc +425 -0
- data/src/core/channelz/v2tov1/legacy_api.h +32 -0
- data/src/core/channelz/v2tov1/property_list.cc +118 -0
- data/src/core/channelz/v2tov1/property_list.h +52 -0
- data/src/core/client_channel/client_channel_filter.cc +5 -4
- data/src/core/client_channel/client_channel_filter.h +2 -2
- data/src/core/client_channel/client_channel_internal.h +2 -1
- data/src/core/client_channel/load_balanced_call_destination.cc +6 -5
- data/src/core/client_channel/subchannel.cc +14 -6
- data/src/core/client_channel/subchannel.h +2 -0
- data/src/core/config/core_configuration.cc +3 -1
- data/src/core/config/core_configuration.h +12 -0
- data/src/core/credentials/transport/alts/alts_credentials.cc +5 -0
- data/src/core/credentials/transport/alts/check_gcp_environment_windows.cc +2 -0
- data/src/core/credentials/transport/channel_creds_registry_init.cc +3 -1
- data/src/core/credentials/transport/ssl/ssl_credentials.cc +1 -1
- data/src/core/credentials/transport/ssl/ssl_security_connector.cc +8 -3
- data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc +29 -24
- data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h +19 -8
- data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc +96 -54
- data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.h +15 -2
- data/src/core/credentials/transport/tls/spiffe_utils.cc +371 -0
- data/src/core/credentials/transport/tls/spiffe_utils.h +171 -0
- data/src/core/credentials/transport/tls/ssl_utils.cc +11 -10
- data/src/core/credentials/transport/tls/ssl_utils.h +4 -2
- data/src/core/credentials/transport/tls/tls_credentials.cc +2 -0
- data/src/core/credentials/transport/tls/tls_security_connector.cc +11 -26
- data/src/core/credentials/transport/tls/tls_security_connector.h +12 -12
- data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +1 -2
- data/src/core/ext/filters/http/client/http_client_filter.cc +3 -6
- data/src/core/ext/filters/http/client_authority_filter.cc +1 -2
- data/src/core/ext/filters/http/message_compress/compression_filter.cc +8 -8
- data/src/core/ext/filters/http/server/http_server_filter.cc +3 -6
- data/src/core/ext/filters/message_size/message_size_filter.cc +4 -4
- data/src/core/ext/filters/rbac/rbac_filter.cc +1 -1
- data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +3 -5
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +3 -2
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -0
- data/src/core/ext/transport/chttp2/transport/frame.cc +89 -6
- data/src/core/ext/transport/chttp2/transport/frame.h +38 -0
- data/src/core/ext/transport/chttp2/transport/header_assembler.h +5 -14
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +4 -1
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +294 -78
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +128 -9
- data/src/core/ext/transport/chttp2/transport/http2_settings.cc +11 -38
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +52 -35
- data/src/core/ext/transport/chttp2/transport/http2_settings_manager.cc +61 -0
- data/src/core/ext/transport/chttp2/transport/http2_settings_manager.h +142 -0
- data/src/core/ext/transport/chttp2/transport/http2_transport.cc +81 -3
- data/src/core/ext/transport/chttp2/transport/http2_transport.h +12 -1
- data/src/core/ext/transport/chttp2/transport/message_assembler.h +2 -2
- data/src/core/ext/transport/chttp2/transport/parsing.cc +2 -1
- data/src/core/ext/transport/chttp2/transport/ping_promise.cc +2 -1
- data/src/core/ext/transport/chttp2/transport/ping_promise.h +22 -5
- data/src/core/ext/transport/chttp2/transport/stream_data_queue.h +607 -0
- data/src/core/ext/transport/chttp2/transport/writable_streams.h +254 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +6 -4
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb.h +4959 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb_minitable.c +1111 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb_minitable.h +108 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb.h +142 -54
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.c +18 -14
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.h +2 -2
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/channelz.upbdefs.c +716 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/channelz.upbdefs.h +227 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.c +86 -88
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.h +2 -2
- data/src/core/filter/auth/auth_filters.h +2 -2
- data/src/core/filter/fused_filters.cc +154 -0
- data/src/core/handshaker/security/legacy_secure_endpoint.cc +1 -1
- data/src/core/handshaker/security/pipelined_secure_endpoint.cc +965 -0
- data/src/core/handshaker/security/secure_endpoint.cc +28 -13
- data/src/core/handshaker/security/secure_endpoint.h +8 -0
- data/src/core/lib/channel/promise_based_filter.cc +15 -25
- data/src/core/lib/channel/promise_based_filter.h +6 -5
- data/src/core/lib/event_engine/ares_resolver.h +3 -1
- data/src/core/lib/event_engine/cf_engine/cf_engine.cc +9 -5
- data/src/core/lib/event_engine/cf_engine/cf_engine.h +2 -1
- data/src/core/lib/event_engine/cf_engine/cfsocket_listener.cc +263 -0
- data/src/core/lib/event_engine/cf_engine/cfsocket_listener.h +107 -0
- data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +31 -3
- data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +12 -0
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +12 -10
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h +6 -4
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +15 -14
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.h +7 -5
- data/src/core/lib/event_engine/posix_engine/event_poller.h +0 -8
- data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc +11 -5
- data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.h +3 -2
- data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +1 -0
- data/src/core/lib/event_engine/posix_engine/lockfree_event.cc +4 -4
- data/src/core/lib/event_engine/posix_engine/lockfree_event.h +3 -4
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +2 -2
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +188 -199
- data/src/core/lib/event_engine/posix_engine/posix_engine.h +30 -45
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +1 -1
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +1 -1
- data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc +2 -1
- data/src/core/lib/experiments/experiments.cc +120 -6
- data/src/core/lib/experiments/experiments.h +46 -3
- data/src/core/lib/iomgr/combiner.cc +1 -1
- data/src/core/lib/iomgr/exec_ctx.h +3 -9
- data/src/core/lib/iomgr/socket_mutator.cc +1 -1
- data/src/core/lib/iomgr/socket_utils_posix.cc +1 -1
- data/src/core/lib/iomgr/socket_utils_posix.h +1 -1
- data/src/core/lib/iomgr/tcp_client_posix.cc +1 -1
- data/src/core/lib/iomgr/tcp_posix.cc +3 -3
- data/src/core/lib/promise/activity.h +2 -2
- data/src/core/lib/promise/mpsc.cc +8 -8
- data/src/core/lib/promise/party.cc +7 -7
- data/src/core/lib/promise/party.h +4 -4
- data/src/core/lib/promise/poll.h +10 -0
- data/src/core/lib/resource_quota/memory_quota.cc +90 -3
- data/src/core/lib/resource_quota/memory_quota.h +20 -9
- data/src/core/lib/resource_quota/periodic_update.cc +14 -0
- data/src/core/lib/resource_quota/periodic_update.h +8 -0
- data/src/core/lib/resource_quota/resource_quota.cc +15 -4
- data/src/core/lib/resource_quota/resource_quota.h +3 -0
- data/src/core/lib/security/authorization/grpc_server_authz_filter.cc +1 -2
- data/src/core/lib/surface/call.cc +5 -5
- data/src/core/lib/surface/call.h +6 -5
- data/src/core/lib/surface/completion_queue.cc +2 -4
- data/src/core/lib/surface/filter_stack_call.cc +1 -1
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/promise_endpoint.cc +2 -2
- data/src/core/lib/transport/promise_endpoint.h +3 -3
- data/src/core/load_balancing/endpoint_list.cc +29 -2
- data/src/core/load_balancing/grpclb/client_load_reporting_filter.cc +3 -3
- data/src/core/load_balancing/grpclb/client_load_reporting_filter.h +1 -1
- data/src/core/load_balancing/pick_first/pick_first.cc +12 -5
- data/src/core/load_balancing/xds/xds_cluster_impl.cc +5 -3
- data/src/core/net/socket_mutator.cc +19 -0
- data/src/core/net/socket_mutator.h +25 -0
- data/src/core/plugin_registry/grpc_plugin_registry.cc +6 -0
- data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h +6 -1
- data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +2 -1
- data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc +8 -5
- data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h +2 -1
- data/src/core/resolver/xds/xds_dependency_manager.cc +1 -1
- data/src/core/server/server.cc +1 -1
- data/src/core/server/server_call_tracer_filter.cc +0 -66
- data/src/core/server/server_call_tracer_filter.h +64 -0
- data/src/core/server/server_config_selector_filter.cc +1 -1
- data/src/core/service_config/service_config_channel_arg_filter.cc +3 -60
- data/src/core/service_config/service_config_channel_arg_filter.h +82 -0
- data/src/core/telemetry/call_tracer.cc +20 -14
- data/src/core/telemetry/call_tracer.h +22 -17
- data/src/core/telemetry/metrics.h +8 -8
- data/src/core/telemetry/stats_data.cc +151 -151
- data/src/core/telemetry/stats_data.h +87 -87
- data/src/core/transport/auth_context.cc +20 -0
- data/src/core/transport/auth_context.h +4 -0
- data/src/core/transport/auth_context_comparator_registry.h +69 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +2 -3
- data/src/core/tsi/ssl_transport_security.cc +202 -32
- data/src/core/tsi/ssl_transport_security.h +19 -10
- data/src/core/tsi/ssl_transport_security_utils.cc +21 -0
- data/src/core/tsi/ssl_transport_security_utils.h +4 -0
- data/src/core/util/http_client/httpcli_security_connector.cc +3 -1
- data/src/core/util/latent_see.cc +178 -146
- data/src/core/util/latent_see.h +245 -188
- data/src/core/util/single_set_ptr.h +5 -2
- data/src/core/util/useful.h +91 -0
- data/src/core/util/windows/directory_reader.cc +1 -0
- data/src/core/util/windows/thd.cc +1 -3
- data/src/core/util/work_serializer.cc +1 -1
- data/src/core/xds/grpc/file_watcher_certificate_provider_factory.cc +32 -5
- data/src/core/xds/grpc/file_watcher_certificate_provider_factory.h +5 -0
- data/src/core/xds/grpc/xds_certificate_provider.cc +5 -6
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/cares/cares/include/ares.h +925 -460
- data/third_party/cares/cares/include/ares_dns.h +86 -71
- data/third_party/cares/cares/include/ares_dns_record.h +1118 -0
- data/third_party/cares/cares/include/ares_nameser.h +215 -189
- data/third_party/cares/cares/include/ares_version.h +37 -14
- data/third_party/cares/cares/src/lib/ares_addrinfo2hostent.c +305 -0
- data/third_party/cares/cares/src/lib/ares_addrinfo_localhost.c +245 -0
- data/third_party/cares/cares/src/lib/ares_android.c +216 -164
- data/third_party/cares/cares/src/lib/ares_android.h +25 -14
- data/third_party/cares/cares/src/lib/ares_cancel.c +68 -44
- data/third_party/cares/cares/src/lib/ares_close_sockets.c +137 -0
- data/third_party/cares/cares/src/lib/ares_conn.c +511 -0
- data/third_party/cares/cares/src/lib/ares_conn.h +196 -0
- data/third_party/cares/cares/src/lib/ares_cookie.c +461 -0
- data/third_party/cares/cares/src/lib/ares_data.c +93 -181
- data/third_party/cares/cares/src/lib/ares_data.h +50 -39
- data/third_party/cares/cares/src/lib/ares_destroy.c +127 -89
- data/third_party/cares/cares/src/lib/ares_free_hostent.c +35 -24
- data/third_party/cares/cares/src/lib/ares_free_string.c +24 -16
- data/third_party/cares/cares/src/lib/ares_freeaddrinfo.c +45 -38
- data/third_party/cares/cares/src/lib/ares_getaddrinfo.c +549 -663
- data/third_party/cares/cares/src/lib/ares_getenv.c +25 -15
- data/third_party/cares/cares/src/lib/ares_getenv.h +26 -18
- data/third_party/cares/cares/src/lib/ares_gethostbyaddr.c +163 -221
- data/third_party/cares/cares/src/lib/ares_gethostbyname.c +222 -223
- data/third_party/cares/cares/src/lib/ares_getnameinfo.c +328 -338
- data/third_party/cares/cares/src/lib/ares_hosts_file.c +952 -0
- data/third_party/cares/cares/src/lib/ares_inet_net_pton.h +25 -19
- data/third_party/cares/cares/src/lib/ares_init.c +425 -2091
- data/third_party/cares/cares/src/lib/ares_ipv6.h +63 -33
- data/third_party/cares/cares/src/lib/ares_library_init.c +110 -54
- data/third_party/cares/cares/src/lib/ares_metrics.c +261 -0
- data/third_party/cares/cares/src/lib/ares_options.c +418 -332
- data/third_party/cares/cares/src/lib/ares_parse_into_addrinfo.c +179 -0
- data/third_party/cares/cares/src/lib/ares_private.h +558 -356
- data/third_party/cares/cares/src/lib/ares_process.c +1224 -1369
- data/third_party/cares/cares/src/lib/ares_qcache.c +430 -0
- data/third_party/cares/cares/src/lib/ares_query.c +126 -121
- data/third_party/cares/cares/src/lib/ares_search.c +564 -262
- data/third_party/cares/cares/src/lib/ares_send.c +264 -93
- data/third_party/cares/cares/src/lib/ares_set_socket_functions.c +588 -0
- data/third_party/cares/cares/src/lib/ares_setup.h +115 -111
- data/third_party/cares/cares/src/lib/ares_socket.c +425 -0
- data/third_party/cares/cares/src/lib/ares_socket.h +163 -0
- data/third_party/cares/cares/src/lib/ares_sortaddrinfo.c +447 -0
- data/third_party/cares/cares/src/lib/ares_strerror.c +83 -48
- data/third_party/cares/cares/src/lib/ares_sysconfig.c +639 -0
- data/third_party/cares/cares/src/lib/ares_sysconfig_files.c +839 -0
- data/third_party/cares/cares/src/lib/ares_sysconfig_mac.c +373 -0
- data/third_party/cares/cares/src/lib/ares_sysconfig_win.c +621 -0
- data/third_party/cares/cares/src/lib/ares_timeout.c +136 -73
- data/third_party/cares/cares/src/lib/ares_update_servers.c +1362 -0
- data/third_party/cares/cares/src/lib/ares_version.c +29 -4
- data/third_party/cares/cares/src/lib/config-dos.h +88 -89
- data/third_party/cares/cares/src/lib/config-win32.h +122 -77
- data/third_party/cares/cares/src/lib/dsa/ares_array.c +394 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable.c +447 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable.h +174 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_asvp.c +224 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_dict.c +228 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_strvp.c +210 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_szvp.c +188 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_vpstr.c +186 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_vpvp.c +194 -0
- data/third_party/cares/cares/src/lib/dsa/ares_llist.c +382 -0
- data/third_party/cares/cares/src/lib/dsa/ares_slist.c +479 -0
- data/third_party/cares/cares/src/lib/dsa/ares_slist.h +207 -0
- data/third_party/cares/cares/src/lib/event/ares_event.h +191 -0
- data/third_party/cares/cares/src/lib/event/ares_event_configchg.c +743 -0
- data/third_party/cares/cares/src/lib/event/ares_event_epoll.c +192 -0
- data/third_party/cares/cares/src/lib/event/ares_event_kqueue.c +248 -0
- data/third_party/cares/cares/src/lib/event/ares_event_poll.c +140 -0
- data/third_party/cares/cares/src/lib/event/ares_event_select.c +159 -0
- data/third_party/cares/cares/src/lib/event/ares_event_thread.c +567 -0
- data/third_party/cares/cares/src/lib/event/ares_event_wake_pipe.c +166 -0
- data/third_party/cares/cares/src/lib/event/ares_event_win32.c +978 -0
- data/third_party/cares/cares/src/lib/event/ares_event_win32.h +161 -0
- data/third_party/cares/cares/src/lib/include/ares_array.h +276 -0
- data/third_party/cares/cares/src/lib/include/ares_buf.h +732 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_asvp.h +130 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_dict.h +123 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_strvp.h +130 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_szvp.h +118 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_vpstr.h +111 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_vpvp.h +128 -0
- data/third_party/cares/cares/src/lib/include/ares_llist.h +239 -0
- data/third_party/cares/cares/src/lib/include/ares_mem.h +38 -0
- data/third_party/cares/cares/src/lib/include/ares_str.h +244 -0
- data/third_party/cares/cares/src/lib/inet_net_pton.c +202 -157
- data/third_party/cares/cares/src/lib/inet_ntop.c +87 -69
- data/third_party/cares/cares/src/lib/legacy/ares_create_query.c +78 -0
- data/third_party/cares/cares/src/lib/legacy/ares_expand_name.c +99 -0
- data/third_party/cares/cares/src/lib/legacy/ares_expand_string.c +107 -0
- data/third_party/cares/cares/src/lib/legacy/ares_fds.c +80 -0
- data/third_party/cares/cares/src/lib/legacy/ares_getsock.c +85 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_a_reply.c +107 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_aaaa_reply.c +109 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_caa_reply.c +137 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_mx_reply.c +110 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_naptr_reply.c +132 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_ns_reply.c +154 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_ptr_reply.c +213 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_soa_reply.c +115 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_srv_reply.c +114 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_txt_reply.c +144 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_uri_reply.c +113 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_mapping.c +982 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_multistring.c +307 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_multistring.h +72 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_name.c +673 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_parse.c +1329 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_private.h +273 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_record.c +1661 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_write.c +1229 -0
- data/third_party/cares/cares/src/lib/str/ares_buf.c +1498 -0
- data/third_party/cares/cares/src/lib/str/ares_str.c +508 -0
- data/third_party/cares/cares/src/lib/str/ares_strsplit.c +90 -0
- data/third_party/cares/cares/src/lib/str/ares_strsplit.h +51 -0
- data/third_party/cares/cares/src/lib/thirdparty/apple/dnsinfo.h +122 -0
- data/third_party/cares/cares/src/lib/util/ares_iface_ips.c +628 -0
- data/third_party/cares/cares/src/lib/util/ares_iface_ips.h +139 -0
- data/third_party/cares/cares/src/lib/util/ares_math.c +158 -0
- data/third_party/cares/cares/src/lib/util/ares_math.h +45 -0
- data/third_party/cares/cares/src/lib/util/ares_rand.c +389 -0
- data/third_party/cares/cares/src/lib/util/ares_rand.h +36 -0
- data/third_party/cares/cares/src/lib/util/ares_threads.c +614 -0
- data/third_party/cares/cares/src/lib/util/ares_threads.h +60 -0
- data/third_party/cares/cares/src/lib/util/ares_time.h +48 -0
- data/third_party/cares/cares/src/lib/util/ares_timeval.c +95 -0
- data/third_party/cares/cares/src/lib/util/ares_uri.c +1626 -0
- data/third_party/cares/cares/src/lib/util/ares_uri.h +252 -0
- data/third_party/cares/cares/src/lib/windows_port.c +16 -9
- metadata +121 -49
- data/src/core/util/ring_buffer.h +0 -122
- data/third_party/cares/cares/include/ares_rules.h +0 -125
- data/third_party/cares/cares/src/lib/ares__addrinfo2hostent.c +0 -266
- data/third_party/cares/cares/src/lib/ares__addrinfo_localhost.c +0 -240
- data/third_party/cares/cares/src/lib/ares__close_sockets.c +0 -61
- data/third_party/cares/cares/src/lib/ares__get_hostent.c +0 -260
- data/third_party/cares/cares/src/lib/ares__parse_into_addrinfo.c +0 -229
- data/third_party/cares/cares/src/lib/ares__read_line.c +0 -73
- data/third_party/cares/cares/src/lib/ares__readaddrinfo.c +0 -258
- data/third_party/cares/cares/src/lib/ares__sortaddrinfo.c +0 -507
- data/third_party/cares/cares/src/lib/ares__timeval.c +0 -111
- data/third_party/cares/cares/src/lib/ares_create_query.c +0 -197
- data/third_party/cares/cares/src/lib/ares_expand_name.c +0 -311
- data/third_party/cares/cares/src/lib/ares_expand_string.c +0 -67
- data/third_party/cares/cares/src/lib/ares_fds.c +0 -59
- data/third_party/cares/cares/src/lib/ares_getsock.c +0 -66
- data/third_party/cares/cares/src/lib/ares_iphlpapi.h +0 -221
- data/third_party/cares/cares/src/lib/ares_llist.c +0 -63
- data/third_party/cares/cares/src/lib/ares_llist.h +0 -39
- data/third_party/cares/cares/src/lib/ares_mkquery.c +0 -24
- data/third_party/cares/cares/src/lib/ares_nowarn.c +0 -260
- data/third_party/cares/cares/src/lib/ares_nowarn.h +0 -61
- data/third_party/cares/cares/src/lib/ares_parse_a_reply.c +0 -90
- data/third_party/cares/cares/src/lib/ares_parse_aaaa_reply.c +0 -92
- data/third_party/cares/cares/src/lib/ares_parse_caa_reply.c +0 -199
- data/third_party/cares/cares/src/lib/ares_parse_mx_reply.c +0 -164
- data/third_party/cares/cares/src/lib/ares_parse_naptr_reply.c +0 -183
- data/third_party/cares/cares/src/lib/ares_parse_ns_reply.c +0 -177
- data/third_party/cares/cares/src/lib/ares_parse_ptr_reply.c +0 -228
- data/third_party/cares/cares/src/lib/ares_parse_soa_reply.c +0 -179
- data/third_party/cares/cares/src/lib/ares_parse_srv_reply.c +0 -168
- data/third_party/cares/cares/src/lib/ares_parse_txt_reply.c +0 -214
- data/third_party/cares/cares/src/lib/ares_parse_uri_reply.c +0 -184
- data/third_party/cares/cares/src/lib/ares_platform.c +0 -11042
- data/third_party/cares/cares/src/lib/ares_platform.h +0 -43
- data/third_party/cares/cares/src/lib/ares_rand.c +0 -279
- data/third_party/cares/cares/src/lib/ares_strcasecmp.c +0 -66
- data/third_party/cares/cares/src/lib/ares_strcasecmp.h +0 -30
- data/third_party/cares/cares/src/lib/ares_strdup.c +0 -42
- data/third_party/cares/cares/src/lib/ares_strdup.h +0 -24
- data/third_party/cares/cares/src/lib/ares_strsplit.c +0 -94
- data/third_party/cares/cares/src/lib/ares_strsplit.h +0 -42
- data/third_party/cares/cares/src/lib/ares_writev.c +0 -79
- data/third_party/cares/cares/src/lib/ares_writev.h +0 -36
- data/third_party/cares/cares/src/lib/bitncmp.c +0 -59
- data/third_party/cares/cares/src/lib/bitncmp.h +0 -26
- data/third_party/cares/cares/src/lib/setup_once.h +0 -554
- data/third_party/cares/cares/src/tools/ares_getopt.h +0 -53
@@ -0,0 +1,621 @@
|
|
1
|
+
/* MIT License
|
2
|
+
*
|
3
|
+
* Copyright (c) 1998 Massachusetts Institute of Technology
|
4
|
+
* Copyright (c) 2007 Daniel Stenberg
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
11
|
+
* furnished to do so, subject to the following conditions:
|
12
|
+
*
|
13
|
+
* The above copyright notice and this permission notice (including the next
|
14
|
+
* paragraph) shall be included in all copies or substantial portions of the
|
15
|
+
* Software.
|
16
|
+
*
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
* SOFTWARE.
|
24
|
+
*
|
25
|
+
* SPDX-License-Identifier: MIT
|
26
|
+
*/
|
27
|
+
|
28
|
+
#include "ares_private.h"
|
29
|
+
|
30
|
+
#ifdef HAVE_SYS_PARAM_H
|
31
|
+
# include <sys/param.h>
|
32
|
+
#endif
|
33
|
+
|
34
|
+
#ifdef HAVE_NETINET_IN_H
|
35
|
+
# include <netinet/in.h>
|
36
|
+
#endif
|
37
|
+
|
38
|
+
#ifdef HAVE_NETDB_H
|
39
|
+
# include <netdb.h>
|
40
|
+
#endif
|
41
|
+
|
42
|
+
#ifdef HAVE_ARPA_INET_H
|
43
|
+
# include <arpa/inet.h>
|
44
|
+
#endif
|
45
|
+
|
46
|
+
#if defined(USE_WINSOCK)
|
47
|
+
# if defined(HAVE_IPHLPAPI_H)
|
48
|
+
# include <iphlpapi.h>
|
49
|
+
# endif
|
50
|
+
# if defined(HAVE_NETIOAPI_H)
|
51
|
+
# include <netioapi.h>
|
52
|
+
# endif
|
53
|
+
#endif
|
54
|
+
|
55
|
+
#include "ares_inet_net_pton.h"
|
56
|
+
|
57
|
+
#if defined(USE_WINSOCK)
|
58
|
+
/*
|
59
|
+
* get_REG_SZ()
|
60
|
+
*
|
61
|
+
* Given a 'hKey' handle to an open registry key and a 'leafKeyName' pointer
|
62
|
+
* to the name of the registry leaf key to be queried, fetch it's string
|
63
|
+
* value and return a pointer in *outptr to a newly allocated memory area
|
64
|
+
* holding it as a null-terminated string.
|
65
|
+
*
|
66
|
+
* Returns 0 and nullifies *outptr upon inability to return a string value.
|
67
|
+
*
|
68
|
+
* Returns 1 and sets *outptr when returning a dynamically allocated string.
|
69
|
+
*
|
70
|
+
* Supported on Windows NT 3.5 and newer.
|
71
|
+
*/
|
72
|
+
static ares_bool_t get_REG_SZ(HKEY hKey, const char *leafKeyName, char **outptr)
|
73
|
+
{
|
74
|
+
DWORD size = 0;
|
75
|
+
int res;
|
76
|
+
|
77
|
+
*outptr = NULL;
|
78
|
+
|
79
|
+
/* Find out size of string stored in registry */
|
80
|
+
res = RegQueryValueExA(hKey, leafKeyName, 0, NULL, NULL, &size);
|
81
|
+
if ((res != ERROR_SUCCESS && res != ERROR_MORE_DATA) || !size) {
|
82
|
+
return ARES_FALSE;
|
83
|
+
}
|
84
|
+
|
85
|
+
/* Allocate buffer of indicated size plus one given that string
|
86
|
+
might have been stored without null termination */
|
87
|
+
*outptr = ares_malloc(size + 1);
|
88
|
+
if (!*outptr) {
|
89
|
+
return ARES_FALSE;
|
90
|
+
}
|
91
|
+
|
92
|
+
/* Get the value for real */
|
93
|
+
res = RegQueryValueExA(hKey, leafKeyName, 0, NULL, (unsigned char *)*outptr,
|
94
|
+
&size);
|
95
|
+
if ((res != ERROR_SUCCESS) || (size == 1)) {
|
96
|
+
ares_free(*outptr);
|
97
|
+
*outptr = NULL;
|
98
|
+
return ARES_FALSE;
|
99
|
+
}
|
100
|
+
|
101
|
+
/* Null terminate buffer always */
|
102
|
+
*(*outptr + size) = '\0';
|
103
|
+
|
104
|
+
return ARES_TRUE;
|
105
|
+
}
|
106
|
+
|
107
|
+
static void commanjoin(char **dst, const char * const src, const size_t len)
|
108
|
+
{
|
109
|
+
char *newbuf;
|
110
|
+
size_t newsize;
|
111
|
+
|
112
|
+
/* 1 for terminating 0 and 2 for , and terminating 0 */
|
113
|
+
newsize = len + (*dst ? (ares_strlen(*dst) + 2) : 1);
|
114
|
+
newbuf = ares_realloc(*dst, newsize);
|
115
|
+
if (!newbuf) {
|
116
|
+
return;
|
117
|
+
}
|
118
|
+
if (*dst == NULL) {
|
119
|
+
*newbuf = '\0';
|
120
|
+
}
|
121
|
+
*dst = newbuf;
|
122
|
+
if (ares_strlen(*dst) != 0) {
|
123
|
+
strcat(*dst, ",");
|
124
|
+
}
|
125
|
+
strncat(*dst, src, len);
|
126
|
+
}
|
127
|
+
|
128
|
+
/*
|
129
|
+
* commajoin()
|
130
|
+
*
|
131
|
+
* RTF code.
|
132
|
+
*/
|
133
|
+
static void commajoin(char **dst, const char *src)
|
134
|
+
{
|
135
|
+
commanjoin(dst, src, ares_strlen(src));
|
136
|
+
}
|
137
|
+
|
138
|
+
/* A structure to hold the string form of IPv4 and IPv6 addresses so we can
|
139
|
+
* sort them by a metric.
|
140
|
+
*/
|
141
|
+
typedef struct {
|
142
|
+
/* The metric we sort them by. */
|
143
|
+
ULONG metric;
|
144
|
+
|
145
|
+
/* Original index of the item, used as a secondary sort parameter to make
|
146
|
+
* qsort() stable if the metrics are equal */
|
147
|
+
size_t orig_idx;
|
148
|
+
|
149
|
+
/* Room enough for the string form of any IPv4 or IPv6 address that
|
150
|
+
* ares_inet_ntop() will create. Based on the existing c-ares practice.
|
151
|
+
*/
|
152
|
+
char text[INET6_ADDRSTRLEN + 8 + 64]; /* [%s]:NNNNN%iface */
|
153
|
+
} Address;
|
154
|
+
|
155
|
+
/* Sort Address values \a left and \a right by metric, returning the usual
|
156
|
+
* indicators for qsort().
|
157
|
+
*/
|
158
|
+
static int compareAddresses(const void *arg1, const void *arg2)
|
159
|
+
{
|
160
|
+
const Address * const left = arg1;
|
161
|
+
const Address * const right = arg2;
|
162
|
+
/* Lower metric the more preferred */
|
163
|
+
if (left->metric < right->metric) {
|
164
|
+
return -1;
|
165
|
+
}
|
166
|
+
if (left->metric > right->metric) {
|
167
|
+
return 1;
|
168
|
+
}
|
169
|
+
/* If metrics are equal, lower original index more preferred */
|
170
|
+
if (left->orig_idx < right->orig_idx) {
|
171
|
+
return -1;
|
172
|
+
}
|
173
|
+
if (left->orig_idx > right->orig_idx) {
|
174
|
+
return 1;
|
175
|
+
}
|
176
|
+
return 0;
|
177
|
+
}
|
178
|
+
|
179
|
+
#if defined(HAVE_GETBESTROUTE2) && !defined(__WATCOMC__)
|
180
|
+
/* There can be multiple routes to "the Internet". And there can be different
|
181
|
+
* DNS servers associated with each of the interfaces that offer those routes.
|
182
|
+
* We have to assume that any DNS server can serve any request. But, some DNS
|
183
|
+
* servers may only respond if requested over their associated interface. But
|
184
|
+
* we also want to use "the preferred route to the Internet" whenever possible
|
185
|
+
* (and not use DNS servers on a non-preferred route even by forcing request
|
186
|
+
* to go out on the associated non-preferred interface). i.e. We want to use
|
187
|
+
* the DNS servers associated with the same interface that we would use to
|
188
|
+
* make a general request to anything else.
|
189
|
+
*
|
190
|
+
* But, Windows won't sort the DNS servers by the metrics associated with the
|
191
|
+
* routes and interfaces _even_ though it obviously sends IP packets based on
|
192
|
+
* those same routes and metrics. So, we must do it ourselves.
|
193
|
+
*
|
194
|
+
* So, we sort the DNS servers by the same metric values used to determine how
|
195
|
+
* an outgoing IP packet will go, thus effectively using the DNS servers
|
196
|
+
* associated with the interface that the DNS requests themselves will
|
197
|
+
* travel. This gives us optimal routing and avoids issues where DNS servers
|
198
|
+
* won't respond to requests that don't arrive via some specific subnetwork
|
199
|
+
* (and thus some specific interface).
|
200
|
+
*
|
201
|
+
* This function computes the metric we use to sort. On the interface
|
202
|
+
* identified by \a luid, it determines the best route to \a dest and combines
|
203
|
+
* that route's metric with \a interfaceMetric to compute a metric for the
|
204
|
+
* destination address on that interface. This metric can be used as a weight
|
205
|
+
* to sort the DNS server addresses associated with each interface (lower is
|
206
|
+
* better).
|
207
|
+
*
|
208
|
+
* Note that by restricting the route search to the specific interface with
|
209
|
+
* which the DNS servers are associated, this function asks the question "What
|
210
|
+
* is the metric for sending IP packets to this DNS server?" which allows us
|
211
|
+
* to sort the DNS servers correctly.
|
212
|
+
*/
|
213
|
+
static ULONG getBestRouteMetric(IF_LUID * const luid, /* Can't be const :( */
|
214
|
+
const SOCKADDR_INET * const dest,
|
215
|
+
const ULONG interfaceMetric)
|
216
|
+
{
|
217
|
+
MIB_IPFORWARD_ROW2 row;
|
218
|
+
SOCKADDR_INET ignored;
|
219
|
+
if (GetBestRoute2(/* The interface to use. The index is ignored since we are
|
220
|
+
* passing a LUID.
|
221
|
+
*/
|
222
|
+
luid, 0,
|
223
|
+
/* No specific source address. */
|
224
|
+
NULL,
|
225
|
+
/* Our destination address. */
|
226
|
+
dest,
|
227
|
+
/* No options. */
|
228
|
+
0,
|
229
|
+
/* The route row. */
|
230
|
+
&row,
|
231
|
+
/* The best source address, which we don't need. */
|
232
|
+
&ignored) != NO_ERROR
|
233
|
+
/* If the metric is "unused" (-1) or too large for us to add the two
|
234
|
+
* metrics, use the worst possible, thus sorting this last.
|
235
|
+
*/
|
236
|
+
|| row.Metric == (ULONG)-1 ||
|
237
|
+
row.Metric > ((ULONG)-1) - interfaceMetric) {
|
238
|
+
/* Return the worst possible metric. */
|
239
|
+
return (ULONG)-1;
|
240
|
+
}
|
241
|
+
|
242
|
+
/* Return the metric value from that row, plus the interface metric.
|
243
|
+
*
|
244
|
+
* See
|
245
|
+
* http://msdn.microsoft.com/en-us/library/windows/desktop/aa814494(v=vs.85).aspx
|
246
|
+
* which describes the combination as a "sum".
|
247
|
+
*/
|
248
|
+
return row.Metric + interfaceMetric;
|
249
|
+
}
|
250
|
+
#endif
|
251
|
+
|
252
|
+
/*
|
253
|
+
* get_DNS_Windows()
|
254
|
+
*
|
255
|
+
* Locates DNS info using GetAdaptersAddresses() function from the Internet
|
256
|
+
* Protocol Helper (IP Helper) API. When located, this returns a pointer
|
257
|
+
* in *outptr to a newly allocated memory area holding a null-terminated
|
258
|
+
* string with a space or comma separated list of DNS IP addresses.
|
259
|
+
*
|
260
|
+
* Returns 0 and nullifies *outptr upon inability to return DNSes string.
|
261
|
+
*
|
262
|
+
* Returns 1 and sets *outptr when returning a dynamically allocated string.
|
263
|
+
*
|
264
|
+
* Implementation supports Windows XP and newer.
|
265
|
+
*/
|
266
|
+
# define IPAA_INITIAL_BUF_SZ 15 * 1024
|
267
|
+
# define IPAA_MAX_TRIES 3
|
268
|
+
|
269
|
+
static ares_bool_t get_DNS_Windows(char **outptr)
|
270
|
+
{
|
271
|
+
IP_ADAPTER_DNS_SERVER_ADDRESS *ipaDNSAddr;
|
272
|
+
IP_ADAPTER_ADDRESSES *ipaa;
|
273
|
+
IP_ADAPTER_ADDRESSES *newipaa;
|
274
|
+
IP_ADAPTER_ADDRESSES *ipaaEntry;
|
275
|
+
ULONG ReqBufsz = IPAA_INITIAL_BUF_SZ;
|
276
|
+
ULONG Bufsz = IPAA_INITIAL_BUF_SZ;
|
277
|
+
ULONG AddrFlags = 0;
|
278
|
+
int trying = IPAA_MAX_TRIES;
|
279
|
+
ULONG res;
|
280
|
+
|
281
|
+
/* The capacity of addresses, in elements. */
|
282
|
+
size_t addressesSize;
|
283
|
+
/* The number of elements in addresses. */
|
284
|
+
size_t addressesIndex = 0;
|
285
|
+
/* The addresses we will sort. */
|
286
|
+
Address *addresses;
|
287
|
+
|
288
|
+
union {
|
289
|
+
struct sockaddr *sa;
|
290
|
+
struct sockaddr_in *sa4;
|
291
|
+
struct sockaddr_in6 *sa6;
|
292
|
+
} namesrvr;
|
293
|
+
|
294
|
+
*outptr = NULL;
|
295
|
+
|
296
|
+
ipaa = ares_malloc(Bufsz);
|
297
|
+
if (!ipaa) {
|
298
|
+
return ARES_FALSE;
|
299
|
+
}
|
300
|
+
|
301
|
+
/* Start with enough room for a few DNS server addresses and we'll grow it
|
302
|
+
* as we encounter more.
|
303
|
+
*/
|
304
|
+
addressesSize = 4;
|
305
|
+
addresses = (Address *)ares_malloc(sizeof(Address) * addressesSize);
|
306
|
+
if (addresses == NULL) {
|
307
|
+
/* We need room for at least some addresses to function. */
|
308
|
+
ares_free(ipaa);
|
309
|
+
return ARES_FALSE;
|
310
|
+
}
|
311
|
+
|
312
|
+
/* Usually this call succeeds with initial buffer size */
|
313
|
+
res = GetAdaptersAddresses(AF_UNSPEC, AddrFlags, NULL, ipaa, &ReqBufsz);
|
314
|
+
if ((res != ERROR_BUFFER_OVERFLOW) && (res != ERROR_SUCCESS)) {
|
315
|
+
goto done;
|
316
|
+
}
|
317
|
+
|
318
|
+
while ((res == ERROR_BUFFER_OVERFLOW) && (--trying)) {
|
319
|
+
if (Bufsz < ReqBufsz) {
|
320
|
+
newipaa = ares_realloc(ipaa, ReqBufsz);
|
321
|
+
if (!newipaa) {
|
322
|
+
goto done;
|
323
|
+
}
|
324
|
+
Bufsz = ReqBufsz;
|
325
|
+
ipaa = newipaa;
|
326
|
+
}
|
327
|
+
res = GetAdaptersAddresses(AF_UNSPEC, AddrFlags, NULL, ipaa, &ReqBufsz);
|
328
|
+
if (res == ERROR_SUCCESS) {
|
329
|
+
break;
|
330
|
+
}
|
331
|
+
}
|
332
|
+
if (res != ERROR_SUCCESS) {
|
333
|
+
goto done;
|
334
|
+
}
|
335
|
+
|
336
|
+
for (ipaaEntry = ipaa; ipaaEntry; ipaaEntry = ipaaEntry->Next) {
|
337
|
+
if (ipaaEntry->OperStatus != IfOperStatusUp) {
|
338
|
+
continue;
|
339
|
+
}
|
340
|
+
|
341
|
+
/* For each interface, find any associated DNS servers as IPv4 or IPv6
|
342
|
+
* addresses. For each found address, find the best route to that DNS
|
343
|
+
* server address _on_ _that_ _interface_ (at this moment in time) and
|
344
|
+
* compute the resulting total metric, just as Windows routing will do.
|
345
|
+
* Then, sort all the addresses found by the metric.
|
346
|
+
*/
|
347
|
+
for (ipaDNSAddr = ipaaEntry->FirstDnsServerAddress; ipaDNSAddr != NULL;
|
348
|
+
ipaDNSAddr = ipaDNSAddr->Next) {
|
349
|
+
char ipaddr[INET6_ADDRSTRLEN] = "";
|
350
|
+
|
351
|
+
namesrvr.sa = ipaDNSAddr->Address.lpSockaddr;
|
352
|
+
|
353
|
+
if (namesrvr.sa->sa_family == AF_INET) {
|
354
|
+
if ((namesrvr.sa4->sin_addr.S_un.S_addr == INADDR_ANY) ||
|
355
|
+
(namesrvr.sa4->sin_addr.S_un.S_addr == INADDR_NONE)) {
|
356
|
+
continue;
|
357
|
+
}
|
358
|
+
|
359
|
+
/* Allocate room for another address, if necessary, else skip. */
|
360
|
+
if (addressesIndex == addressesSize) {
|
361
|
+
const size_t newSize = addressesSize + 4;
|
362
|
+
Address * const newMem =
|
363
|
+
(Address *)ares_realloc(addresses, sizeof(Address) * newSize);
|
364
|
+
if (newMem == NULL) {
|
365
|
+
continue;
|
366
|
+
}
|
367
|
+
addresses = newMem;
|
368
|
+
addressesSize = newSize;
|
369
|
+
}
|
370
|
+
|
371
|
+
# if defined(HAVE_GETBESTROUTE2) && !defined(__WATCOMC__)
|
372
|
+
/* OpenWatcom's builtin Windows SDK does not have a definition for
|
373
|
+
* MIB_IPFORWARD_ROW2, and also does not allow the usage of SOCKADDR_INET
|
374
|
+
* as a variable. Let's work around this by returning the worst possible
|
375
|
+
* metric, but only when using the OpenWatcom compiler.
|
376
|
+
* It may be worth investigating using a different version of the Windows
|
377
|
+
* SDK with OpenWatcom in the future, though this may be fixed in OpenWatcom
|
378
|
+
* 2.0.
|
379
|
+
*/
|
380
|
+
addresses[addressesIndex].metric = getBestRouteMetric(
|
381
|
+
&ipaaEntry->Luid, (SOCKADDR_INET *)((void *)(namesrvr.sa)),
|
382
|
+
ipaaEntry->Ipv4Metric);
|
383
|
+
# else
|
384
|
+
addresses[addressesIndex].metric = (ULONG)-1;
|
385
|
+
# endif
|
386
|
+
|
387
|
+
/* Record insertion index to make qsort stable */
|
388
|
+
addresses[addressesIndex].orig_idx = addressesIndex;
|
389
|
+
|
390
|
+
if (!ares_inet_ntop(AF_INET, &namesrvr.sa4->sin_addr, ipaddr,
|
391
|
+
sizeof(ipaddr))) {
|
392
|
+
continue;
|
393
|
+
}
|
394
|
+
snprintf(addresses[addressesIndex].text,
|
395
|
+
sizeof(addresses[addressesIndex].text), "[%s]:%u", ipaddr,
|
396
|
+
ntohs(namesrvr.sa4->sin_port));
|
397
|
+
++addressesIndex;
|
398
|
+
} else if (namesrvr.sa->sa_family == AF_INET6) {
|
399
|
+
unsigned int ll_scope = 0;
|
400
|
+
struct ares_addr addr;
|
401
|
+
|
402
|
+
if (memcmp(&namesrvr.sa6->sin6_addr, &ares_in6addr_any,
|
403
|
+
sizeof(namesrvr.sa6->sin6_addr)) == 0) {
|
404
|
+
continue;
|
405
|
+
}
|
406
|
+
|
407
|
+
/* Allocate room for another address, if necessary, else skip. */
|
408
|
+
if (addressesIndex == addressesSize) {
|
409
|
+
const size_t newSize = addressesSize + 4;
|
410
|
+
Address * const newMem =
|
411
|
+
(Address *)ares_realloc(addresses, sizeof(Address) * newSize);
|
412
|
+
if (newMem == NULL) {
|
413
|
+
continue;
|
414
|
+
}
|
415
|
+
addresses = newMem;
|
416
|
+
addressesSize = newSize;
|
417
|
+
}
|
418
|
+
|
419
|
+
/* See if its link-local */
|
420
|
+
memset(&addr, 0, sizeof(addr));
|
421
|
+
addr.family = AF_INET6;
|
422
|
+
memcpy(&addr.addr.addr6, &namesrvr.sa6->sin6_addr, 16);
|
423
|
+
if (ares_addr_is_linklocal(&addr)) {
|
424
|
+
ll_scope = ipaaEntry->Ipv6IfIndex;
|
425
|
+
}
|
426
|
+
|
427
|
+
# if defined(HAVE_GETBESTROUTE2) && !defined(__WATCOMC__)
|
428
|
+
addresses[addressesIndex].metric = getBestRouteMetric(
|
429
|
+
&ipaaEntry->Luid, (SOCKADDR_INET *)((void *)(namesrvr.sa)),
|
430
|
+
ipaaEntry->Ipv6Metric);
|
431
|
+
# else
|
432
|
+
addresses[addressesIndex].metric = (ULONG)-1;
|
433
|
+
# endif
|
434
|
+
|
435
|
+
/* Record insertion index to make qsort stable */
|
436
|
+
addresses[addressesIndex].orig_idx = addressesIndex;
|
437
|
+
|
438
|
+
if (!ares_inet_ntop(AF_INET6, &namesrvr.sa6->sin6_addr, ipaddr,
|
439
|
+
sizeof(ipaddr))) {
|
440
|
+
continue;
|
441
|
+
}
|
442
|
+
|
443
|
+
if (ll_scope) {
|
444
|
+
snprintf(addresses[addressesIndex].text,
|
445
|
+
sizeof(addresses[addressesIndex].text), "[%s]:%u%%%u",
|
446
|
+
ipaddr, ntohs(namesrvr.sa6->sin6_port), ll_scope);
|
447
|
+
} else {
|
448
|
+
snprintf(addresses[addressesIndex].text,
|
449
|
+
sizeof(addresses[addressesIndex].text), "[%s]:%u", ipaddr,
|
450
|
+
ntohs(namesrvr.sa6->sin6_port));
|
451
|
+
}
|
452
|
+
++addressesIndex;
|
453
|
+
} else {
|
454
|
+
/* Skip non-IPv4/IPv6 addresses completely. */
|
455
|
+
continue;
|
456
|
+
}
|
457
|
+
}
|
458
|
+
}
|
459
|
+
|
460
|
+
/* Sort all of the textual addresses by their metric (and original index if
|
461
|
+
* metrics are equal). */
|
462
|
+
qsort(addresses, addressesIndex, sizeof(*addresses), compareAddresses);
|
463
|
+
|
464
|
+
/* Join them all into a single string, removing duplicates. */
|
465
|
+
{
|
466
|
+
size_t i;
|
467
|
+
for (i = 0; i < addressesIndex; ++i) {
|
468
|
+
size_t j;
|
469
|
+
/* Look for this address text appearing previously in the results. */
|
470
|
+
for (j = 0; j < i; ++j) {
|
471
|
+
if (strcmp(addresses[j].text, addresses[i].text) == 0) {
|
472
|
+
break;
|
473
|
+
}
|
474
|
+
}
|
475
|
+
/* Iff we didn't emit this address already, emit it now. */
|
476
|
+
if (j == i) {
|
477
|
+
/* Add that to outptr (if we can). */
|
478
|
+
commajoin(outptr, addresses[i].text);
|
479
|
+
}
|
480
|
+
}
|
481
|
+
}
|
482
|
+
|
483
|
+
done:
|
484
|
+
ares_free(addresses);
|
485
|
+
|
486
|
+
if (ipaa) {
|
487
|
+
ares_free(ipaa);
|
488
|
+
}
|
489
|
+
|
490
|
+
if (!*outptr) {
|
491
|
+
return ARES_FALSE;
|
492
|
+
}
|
493
|
+
|
494
|
+
return ARES_TRUE;
|
495
|
+
}
|
496
|
+
|
497
|
+
/*
|
498
|
+
* get_SuffixList_Windows()
|
499
|
+
*
|
500
|
+
* Reads the "DNS Suffix Search List" from registry and writes the list items
|
501
|
+
* whitespace separated to outptr. If the Search List is empty, the
|
502
|
+
* "Primary Dns Suffix" is written to outptr.
|
503
|
+
*
|
504
|
+
* Returns 0 and nullifies *outptr upon inability to return the suffix list.
|
505
|
+
*
|
506
|
+
* Returns 1 and sets *outptr when returning a dynamically allocated string.
|
507
|
+
*
|
508
|
+
* Implementation supports Windows Server 2003 and newer
|
509
|
+
*/
|
510
|
+
static ares_bool_t get_SuffixList_Windows(char **outptr)
|
511
|
+
{
|
512
|
+
HKEY hKey;
|
513
|
+
HKEY hKeyEnum;
|
514
|
+
char keyName[256];
|
515
|
+
DWORD keyNameBuffSize;
|
516
|
+
DWORD keyIdx = 0;
|
517
|
+
char *p = NULL;
|
518
|
+
|
519
|
+
*outptr = NULL;
|
520
|
+
|
521
|
+
/* 1. Global DNS Suffix Search List */
|
522
|
+
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, &hKey) ==
|
523
|
+
ERROR_SUCCESS) {
|
524
|
+
get_REG_SZ(hKey, SEARCHLIST_KEY, outptr);
|
525
|
+
if (get_REG_SZ(hKey, DOMAIN_KEY, &p)) {
|
526
|
+
commajoin(outptr, p);
|
527
|
+
ares_free(p);
|
528
|
+
p = NULL;
|
529
|
+
}
|
530
|
+
RegCloseKey(hKey);
|
531
|
+
}
|
532
|
+
|
533
|
+
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NT_DNSCLIENT, 0, KEY_READ, &hKey) ==
|
534
|
+
ERROR_SUCCESS) {
|
535
|
+
if (get_REG_SZ(hKey, SEARCHLIST_KEY, &p)) {
|
536
|
+
commajoin(outptr, p);
|
537
|
+
ares_free(p);
|
538
|
+
p = NULL;
|
539
|
+
}
|
540
|
+
RegCloseKey(hKey);
|
541
|
+
}
|
542
|
+
|
543
|
+
/* 2. Connection Specific Search List composed of:
|
544
|
+
* a. Primary DNS Suffix */
|
545
|
+
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_DNSCLIENT, 0, KEY_READ, &hKey) ==
|
546
|
+
ERROR_SUCCESS) {
|
547
|
+
if (get_REG_SZ(hKey, PRIMARYDNSSUFFIX_KEY, &p)) {
|
548
|
+
commajoin(outptr, p);
|
549
|
+
ares_free(p);
|
550
|
+
p = NULL;
|
551
|
+
}
|
552
|
+
RegCloseKey(hKey);
|
553
|
+
}
|
554
|
+
|
555
|
+
/* b. Interface SearchList, Domain, DhcpDomain */
|
556
|
+
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY "\\" INTERFACES_KEY, 0,
|
557
|
+
KEY_READ, &hKey) == ERROR_SUCCESS) {
|
558
|
+
for (;;) {
|
559
|
+
keyNameBuffSize = sizeof(keyName);
|
560
|
+
if (RegEnumKeyExA(hKey, keyIdx++, keyName, &keyNameBuffSize, 0, NULL,
|
561
|
+
NULL, NULL) != ERROR_SUCCESS) {
|
562
|
+
break;
|
563
|
+
}
|
564
|
+
if (RegOpenKeyExA(hKey, keyName, 0, KEY_QUERY_VALUE, &hKeyEnum) !=
|
565
|
+
ERROR_SUCCESS) {
|
566
|
+
continue;
|
567
|
+
}
|
568
|
+
/* p can be comma separated (SearchList) */
|
569
|
+
if (get_REG_SZ(hKeyEnum, SEARCHLIST_KEY, &p)) {
|
570
|
+
commajoin(outptr, p);
|
571
|
+
ares_free(p);
|
572
|
+
p = NULL;
|
573
|
+
}
|
574
|
+
if (get_REG_SZ(hKeyEnum, DOMAIN_KEY, &p)) {
|
575
|
+
commajoin(outptr, p);
|
576
|
+
ares_free(p);
|
577
|
+
p = NULL;
|
578
|
+
}
|
579
|
+
if (get_REG_SZ(hKeyEnum, DHCPDOMAIN_KEY, &p)) {
|
580
|
+
commajoin(outptr, p);
|
581
|
+
ares_free(p);
|
582
|
+
p = NULL;
|
583
|
+
}
|
584
|
+
RegCloseKey(hKeyEnum);
|
585
|
+
}
|
586
|
+
RegCloseKey(hKey);
|
587
|
+
}
|
588
|
+
|
589
|
+
return *outptr != NULL ? ARES_TRUE : ARES_FALSE;
|
590
|
+
}
|
591
|
+
|
592
|
+
ares_status_t ares_init_sysconfig_windows(const ares_channel_t *channel,
|
593
|
+
ares_sysconfig_t *sysconfig)
|
594
|
+
{
|
595
|
+
char *line = NULL;
|
596
|
+
ares_status_t status = ARES_SUCCESS;
|
597
|
+
|
598
|
+
if (get_DNS_Windows(&line)) {
|
599
|
+
status = ares_sconfig_append_fromstr(channel, &sysconfig->sconfig, line,
|
600
|
+
ARES_TRUE);
|
601
|
+
ares_free(line);
|
602
|
+
if (status != ARES_SUCCESS) {
|
603
|
+
goto done;
|
604
|
+
}
|
605
|
+
}
|
606
|
+
|
607
|
+
if (get_SuffixList_Windows(&line)) {
|
608
|
+
sysconfig->domains = ares_strsplit(line, ", ", &sysconfig->ndomains);
|
609
|
+
ares_free(line);
|
610
|
+
if (sysconfig->domains == NULL) {
|
611
|
+
status = ARES_EFILE;
|
612
|
+
}
|
613
|
+
if (status != ARES_SUCCESS) {
|
614
|
+
goto done;
|
615
|
+
}
|
616
|
+
}
|
617
|
+
|
618
|
+
done:
|
619
|
+
return status;
|
620
|
+
}
|
621
|
+
#endif
|