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
@@ -1,24 +1,47 @@
|
|
1
|
+
/* MIT License
|
2
|
+
*
|
3
|
+
* Copyright (c) Daniel Stenberg
|
4
|
+
*
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
10
|
+
* furnished to do so, subject to the following conditions:
|
11
|
+
*
|
12
|
+
* The above copyright notice and this permission notice (including the next
|
13
|
+
* paragraph) shall be included in all copies or substantial portions of the
|
14
|
+
* Software.
|
15
|
+
*
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
* SOFTWARE.
|
23
|
+
*
|
24
|
+
* SPDX-License-Identifier: MIT
|
25
|
+
*/
|
1
26
|
|
2
27
|
#ifndef ARES__VERSION_H
|
3
28
|
#define ARES__VERSION_H
|
4
29
|
|
5
30
|
/* This is the global package copyright */
|
6
|
-
#define ARES_COPYRIGHT "2004 -
|
31
|
+
#define ARES_COPYRIGHT "2004 - 2024 Daniel Stenberg, <daniel@haxx.se>."
|
7
32
|
|
8
33
|
#define ARES_VERSION_MAJOR 1
|
9
|
-
#define ARES_VERSION_MINOR
|
10
|
-
#define ARES_VERSION_PATCH
|
11
|
-
#define
|
12
|
-
(ARES_VERSION_MINOR<<8)|\
|
13
|
-
(ARES_VERSION_PATCH))
|
14
|
-
#define ARES_VERSION_STR "1.19.0"
|
34
|
+
#define ARES_VERSION_MINOR 34
|
35
|
+
#define ARES_VERSION_PATCH 5
|
36
|
+
#define ARES_VERSION_STR "1.34.5"
|
15
37
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
#
|
22
|
-
|
38
|
+
/* NOTE: We cannot make the version string a C preprocessor stringify operation
|
39
|
+
* due to assumptions made by integrators that aren't properly using
|
40
|
+
* pkgconf or cmake and are doing their own detection based on parsing
|
41
|
+
* this header */
|
42
|
+
|
43
|
+
#define ARES_VERSION \
|
44
|
+
((ARES_VERSION_MAJOR << 16) | (ARES_VERSION_MINOR << 8) | \
|
45
|
+
(ARES_VERSION_PATCH))
|
23
46
|
|
24
47
|
#endif
|
@@ -0,0 +1,305 @@
|
|
1
|
+
/* MIT License
|
2
|
+
*
|
3
|
+
* Copyright (c) 1998 Massachusetts Institute of Technology
|
4
|
+
* Copyright (c) 2005 Dominick Meglio
|
5
|
+
* Copyright (c) 2019 Andrew Selivanov
|
6
|
+
* Copyright (c) 2021 Brad House
|
7
|
+
*
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
9
|
+
* of this software and associated documentation files (the "Software"), to deal
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
13
|
+
* furnished to do so, subject to the following conditions:
|
14
|
+
*
|
15
|
+
* The above copyright notice and this permission notice (including the next
|
16
|
+
* paragraph) shall be included in all copies or substantial portions of the
|
17
|
+
* Software.
|
18
|
+
*
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
21
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
22
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
23
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
24
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
25
|
+
* SOFTWARE.
|
26
|
+
*
|
27
|
+
* SPDX-License-Identifier: MIT
|
28
|
+
*/
|
29
|
+
|
30
|
+
#include "ares_private.h"
|
31
|
+
|
32
|
+
#ifdef HAVE_NETINET_IN_H
|
33
|
+
# include <netinet/in.h>
|
34
|
+
#endif
|
35
|
+
#ifdef HAVE_NETDB_H
|
36
|
+
# include <netdb.h>
|
37
|
+
#endif
|
38
|
+
#ifdef HAVE_ARPA_INET_H
|
39
|
+
# include <arpa/inet.h>
|
40
|
+
#endif
|
41
|
+
|
42
|
+
#ifdef HAVE_STRINGS_H
|
43
|
+
# include <strings.h>
|
44
|
+
#endif
|
45
|
+
|
46
|
+
#ifdef HAVE_LIMITS_H
|
47
|
+
# include <limits.h>
|
48
|
+
#endif
|
49
|
+
|
50
|
+
static size_t hostent_nalias(const struct hostent *host)
|
51
|
+
{
|
52
|
+
size_t i;
|
53
|
+
for (i=0; host->h_aliases != NULL && host->h_aliases[i] != NULL; i++)
|
54
|
+
;
|
55
|
+
|
56
|
+
return i;
|
57
|
+
}
|
58
|
+
|
59
|
+
static size_t ai_nalias(const struct ares_addrinfo *ai)
|
60
|
+
{
|
61
|
+
const struct ares_addrinfo_cname *cname;
|
62
|
+
size_t i = 0;
|
63
|
+
|
64
|
+
for (cname = ai->cnames; cname != NULL; cname=cname->next) {
|
65
|
+
i++;
|
66
|
+
}
|
67
|
+
|
68
|
+
return i;
|
69
|
+
}
|
70
|
+
|
71
|
+
static size_t hostent_naddr(const struct hostent *host)
|
72
|
+
{
|
73
|
+
size_t i;
|
74
|
+
for (i=0; host->h_addr_list != NULL && host->h_addr_list[i] != NULL; i++)
|
75
|
+
;
|
76
|
+
|
77
|
+
return i;
|
78
|
+
}
|
79
|
+
|
80
|
+
static size_t ai_naddr(const struct ares_addrinfo *ai, int af)
|
81
|
+
{
|
82
|
+
const struct ares_addrinfo_node *node;
|
83
|
+
size_t i = 0;
|
84
|
+
|
85
|
+
for (node = ai->nodes; node != NULL; node=node->ai_next) {
|
86
|
+
if (af != AF_UNSPEC && af != node->ai_family)
|
87
|
+
continue;
|
88
|
+
i++;
|
89
|
+
}
|
90
|
+
|
91
|
+
return i;
|
92
|
+
}
|
93
|
+
|
94
|
+
ares_status_t ares_addrinfo2hostent(const struct ares_addrinfo *ai, int family,
|
95
|
+
struct hostent **host)
|
96
|
+
{
|
97
|
+
struct ares_addrinfo_node *next;
|
98
|
+
char **aliases = NULL;
|
99
|
+
char **addrs = NULL;
|
100
|
+
size_t naliases = 0;
|
101
|
+
size_t naddrs = 0;
|
102
|
+
size_t i;
|
103
|
+
size_t ealiases = 0;
|
104
|
+
size_t eaddrs = 0;
|
105
|
+
|
106
|
+
if (ai == NULL || host == NULL) {
|
107
|
+
return ARES_EBADQUERY; /* LCOV_EXCL_LINE: DefensiveCoding */
|
108
|
+
}
|
109
|
+
|
110
|
+
/* Use either the host set in the passed in hosts to be filled in, or the
|
111
|
+
* first node of the response as the family, since hostent can only
|
112
|
+
* represent one family. We assume getaddrinfo() returned a sorted list if
|
113
|
+
* the user requested AF_UNSPEC. */
|
114
|
+
if (family == AF_UNSPEC) {
|
115
|
+
if (*host != NULL && (*host)->h_addrtype != AF_UNSPEC) {
|
116
|
+
family = (*host)->h_addrtype;
|
117
|
+
} else if (ai->nodes != NULL) {
|
118
|
+
family = ai->nodes->ai_family;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
if (family != AF_INET && family != AF_INET6) {
|
123
|
+
return ARES_EBADQUERY; /* LCOV_EXCL_LINE: DefensiveCoding */
|
124
|
+
}
|
125
|
+
|
126
|
+
if (*host == NULL) {
|
127
|
+
*host = ares_malloc_zero(sizeof(**host));
|
128
|
+
if (!(*host)) {
|
129
|
+
goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
(*host)->h_addrtype = (HOSTENT_ADDRTYPE_TYPE)family;
|
134
|
+
if (family == AF_INET) {
|
135
|
+
(*host)->h_length = sizeof(struct in_addr);
|
136
|
+
} else if (family == AF_INET6) {
|
137
|
+
(*host)->h_length = sizeof(struct ares_in6_addr);
|
138
|
+
}
|
139
|
+
|
140
|
+
if ((*host)->h_name == NULL) {
|
141
|
+
if (ai->cnames) {
|
142
|
+
(*host)->h_name = ares_strdup(ai->cnames->name);
|
143
|
+
if ((*host)->h_name == NULL && ai->cnames->name) {
|
144
|
+
goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */
|
145
|
+
}
|
146
|
+
} else {
|
147
|
+
(*host)->h_name = ares_strdup(ai->name);
|
148
|
+
if ((*host)->h_name == NULL && ai->name) {
|
149
|
+
goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */
|
150
|
+
}
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
naliases = ai_nalias(ai);
|
155
|
+
ealiases = hostent_nalias(*host);
|
156
|
+
aliases = ares_realloc_zero((*host)->h_aliases,
|
157
|
+
ealiases * sizeof(char *),
|
158
|
+
(naliases + ealiases + 1) * sizeof(char *));
|
159
|
+
if (!aliases) {
|
160
|
+
goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */
|
161
|
+
}
|
162
|
+
(*host)->h_aliases = aliases;
|
163
|
+
|
164
|
+
if (naliases) {
|
165
|
+
const struct ares_addrinfo_cname *cname;
|
166
|
+
i = ealiases;
|
167
|
+
for (cname = ai->cnames; cname != NULL; cname = cname->next) {
|
168
|
+
if (cname->alias == NULL) {
|
169
|
+
continue;
|
170
|
+
}
|
171
|
+
(*host)->h_aliases[i] = ares_strdup(cname->alias);
|
172
|
+
if ((*host)->h_aliases[i] == NULL) {
|
173
|
+
goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */
|
174
|
+
}
|
175
|
+
i++;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
naddrs = ai_naddr(ai, family);
|
180
|
+
eaddrs = hostent_naddr(*host);
|
181
|
+
addrs = ares_realloc_zero((*host)->h_addr_list, eaddrs * sizeof(char *),
|
182
|
+
(naddrs + eaddrs + 1) * sizeof(char *));
|
183
|
+
if (addrs == NULL) {
|
184
|
+
goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */
|
185
|
+
}
|
186
|
+
(*host)->h_addr_list = addrs;
|
187
|
+
|
188
|
+
if (naddrs) {
|
189
|
+
i = eaddrs;
|
190
|
+
for (next = ai->nodes; next != NULL; next = next->ai_next) {
|
191
|
+
if (next->ai_family != family) {
|
192
|
+
continue;
|
193
|
+
}
|
194
|
+
(*host)->h_addr_list[i] = ares_malloc_zero((size_t)(*host)->h_length);
|
195
|
+
if ((*host)->h_addr_list[i] == NULL) {
|
196
|
+
goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */
|
197
|
+
}
|
198
|
+
if (family == AF_INET6) {
|
199
|
+
memcpy((*host)->h_addr_list[i],
|
200
|
+
&(CARES_INADDR_CAST(const struct sockaddr_in6 *, next->ai_addr)
|
201
|
+
->sin6_addr),
|
202
|
+
(size_t)(*host)->h_length);
|
203
|
+
}
|
204
|
+
if (family == AF_INET) {
|
205
|
+
memcpy((*host)->h_addr_list[i],
|
206
|
+
&(CARES_INADDR_CAST(const struct sockaddr_in *, next->ai_addr)
|
207
|
+
->sin_addr),
|
208
|
+
(size_t)(*host)->h_length);
|
209
|
+
}
|
210
|
+
i++;
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
if (naddrs + eaddrs == 0 && naliases + ealiases == 0) {
|
215
|
+
ares_free_hostent(*host);
|
216
|
+
*host = NULL;
|
217
|
+
return ARES_ENODATA;
|
218
|
+
}
|
219
|
+
|
220
|
+
return ARES_SUCCESS;
|
221
|
+
|
222
|
+
/* LCOV_EXCL_START: OutOfMemory */
|
223
|
+
enomem:
|
224
|
+
ares_free_hostent(*host);
|
225
|
+
*host = NULL;
|
226
|
+
return ARES_ENOMEM;
|
227
|
+
/* LCOV_EXCL_STOP */
|
228
|
+
}
|
229
|
+
|
230
|
+
ares_status_t ares_addrinfo2addrttl(const struct ares_addrinfo *ai, int family,
|
231
|
+
size_t req_naddrttls,
|
232
|
+
struct ares_addrttl *addrttls,
|
233
|
+
struct ares_addr6ttl *addr6ttls,
|
234
|
+
size_t *naddrttls)
|
235
|
+
{
|
236
|
+
struct ares_addrinfo_node *next;
|
237
|
+
struct ares_addrinfo_cname *next_cname;
|
238
|
+
int cname_ttl = INT_MAX;
|
239
|
+
|
240
|
+
if (family != AF_INET && family != AF_INET6) {
|
241
|
+
return ARES_EBADQUERY; /* LCOV_EXCL_LINE: DefensiveCoding */
|
242
|
+
}
|
243
|
+
|
244
|
+
if (ai == NULL || naddrttls == NULL) {
|
245
|
+
return ARES_EBADQUERY; /* LCOV_EXCL_LINE: DefensiveCoding */
|
246
|
+
}
|
247
|
+
|
248
|
+
if (family == AF_INET && addrttls == NULL) {
|
249
|
+
return ARES_EBADQUERY; /* LCOV_EXCL_LINE: DefensiveCoding */
|
250
|
+
}
|
251
|
+
|
252
|
+
if (family == AF_INET6 && addr6ttls == NULL) {
|
253
|
+
return ARES_EBADQUERY; /* LCOV_EXCL_LINE: DefensiveCoding */
|
254
|
+
}
|
255
|
+
|
256
|
+
if (req_naddrttls == 0) {
|
257
|
+
return ARES_EBADQUERY; /* LCOV_EXCL_LINE: DefensiveCoding */
|
258
|
+
}
|
259
|
+
|
260
|
+
*naddrttls = 0;
|
261
|
+
|
262
|
+
next_cname = ai->cnames;
|
263
|
+
while (next_cname) {
|
264
|
+
if (next_cname->ttl < cname_ttl) {
|
265
|
+
cname_ttl = next_cname->ttl;
|
266
|
+
}
|
267
|
+
next_cname = next_cname->next;
|
268
|
+
}
|
269
|
+
|
270
|
+
for (next = ai->nodes; next != NULL; next = next->ai_next) {
|
271
|
+
if (next->ai_family != family) {
|
272
|
+
continue;
|
273
|
+
}
|
274
|
+
|
275
|
+
if (*naddrttls >= req_naddrttls) {
|
276
|
+
break;
|
277
|
+
}
|
278
|
+
|
279
|
+
if (family == AF_INET6) {
|
280
|
+
if (next->ai_ttl > cname_ttl) {
|
281
|
+
addr6ttls[*naddrttls].ttl = cname_ttl;
|
282
|
+
} else {
|
283
|
+
addr6ttls[*naddrttls].ttl = next->ai_ttl;
|
284
|
+
}
|
285
|
+
|
286
|
+
memcpy(&addr6ttls[*naddrttls].ip6addr,
|
287
|
+
&(CARES_INADDR_CAST(const struct sockaddr_in6 *, next->ai_addr)
|
288
|
+
->sin6_addr),
|
289
|
+
sizeof(struct ares_in6_addr));
|
290
|
+
} else {
|
291
|
+
if (next->ai_ttl > cname_ttl) {
|
292
|
+
addrttls[*naddrttls].ttl = cname_ttl;
|
293
|
+
} else {
|
294
|
+
addrttls[*naddrttls].ttl = next->ai_ttl;
|
295
|
+
}
|
296
|
+
memcpy(&addrttls[*naddrttls].ipaddr,
|
297
|
+
&(CARES_INADDR_CAST(const struct sockaddr_in *, next->ai_addr)
|
298
|
+
->sin_addr),
|
299
|
+
sizeof(struct in_addr));
|
300
|
+
}
|
301
|
+
(*naddrttls)++;
|
302
|
+
}
|
303
|
+
|
304
|
+
return ARES_SUCCESS;
|
305
|
+
}
|
@@ -0,0 +1,245 @@
|
|
1
|
+
/* MIT License
|
2
|
+
*
|
3
|
+
* Copyright (c) Massachusetts Institute of Technology
|
4
|
+
* Copyright (c) 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_NETINET_IN_H
|
31
|
+
# include <netinet/in.h>
|
32
|
+
#endif
|
33
|
+
#ifdef HAVE_NETDB_H
|
34
|
+
# include <netdb.h>
|
35
|
+
#endif
|
36
|
+
#ifdef HAVE_ARPA_INET_H
|
37
|
+
# include <arpa/inet.h>
|
38
|
+
#endif
|
39
|
+
|
40
|
+
#if defined(USE_WINSOCK)
|
41
|
+
# if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600
|
42
|
+
# include <ws2ipdef.h>
|
43
|
+
# endif
|
44
|
+
# if defined(HAVE_IPHLPAPI_H)
|
45
|
+
# include <iphlpapi.h>
|
46
|
+
# endif
|
47
|
+
# if defined(HAVE_NETIOAPI_H)
|
48
|
+
# include <netioapi.h>
|
49
|
+
# endif
|
50
|
+
#endif
|
51
|
+
|
52
|
+
static ares_bool_t ares_ai_has_family(int aftype,
|
53
|
+
const struct ares_addrinfo_node *nodes)
|
54
|
+
{
|
55
|
+
const struct ares_addrinfo_node *node;
|
56
|
+
|
57
|
+
for (node = nodes; node != NULL; node = node->ai_next) {
|
58
|
+
if (node->ai_family == aftype)
|
59
|
+
return ARES_TRUE;
|
60
|
+
}
|
61
|
+
|
62
|
+
return ARES_FALSE;
|
63
|
+
}
|
64
|
+
|
65
|
+
ares_status_t ares_append_ai_node(int aftype, unsigned short port,
|
66
|
+
unsigned int ttl, const void *adata,
|
67
|
+
struct ares_addrinfo_node **nodes)
|
68
|
+
{
|
69
|
+
struct ares_addrinfo_node *node;
|
70
|
+
|
71
|
+
node = ares_append_addrinfo_node(nodes);
|
72
|
+
if (!node) {
|
73
|
+
return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
74
|
+
}
|
75
|
+
|
76
|
+
memset(node, 0, sizeof(*node));
|
77
|
+
|
78
|
+
if (aftype == AF_INET) {
|
79
|
+
struct sockaddr_in *sin = ares_malloc(sizeof(*sin));
|
80
|
+
if (!sin) {
|
81
|
+
return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
82
|
+
}
|
83
|
+
|
84
|
+
memset(sin, 0, sizeof(*sin));
|
85
|
+
memcpy(&sin->sin_addr.s_addr, adata, sizeof(sin->sin_addr.s_addr));
|
86
|
+
sin->sin_family = AF_INET;
|
87
|
+
sin->sin_port = htons(port);
|
88
|
+
|
89
|
+
node->ai_addr = (struct sockaddr *)sin;
|
90
|
+
node->ai_family = AF_INET;
|
91
|
+
node->ai_addrlen = sizeof(*sin);
|
92
|
+
node->ai_addr = (struct sockaddr *)sin;
|
93
|
+
node->ai_ttl = (int)ttl;
|
94
|
+
}
|
95
|
+
|
96
|
+
if (aftype == AF_INET6) {
|
97
|
+
struct sockaddr_in6 *sin6 = ares_malloc(sizeof(*sin6));
|
98
|
+
if (!sin6) {
|
99
|
+
return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
100
|
+
}
|
101
|
+
|
102
|
+
memset(sin6, 0, sizeof(*sin6));
|
103
|
+
memcpy(&sin6->sin6_addr.s6_addr, adata, sizeof(sin6->sin6_addr.s6_addr));
|
104
|
+
sin6->sin6_family = AF_INET6;
|
105
|
+
sin6->sin6_port = htons(port);
|
106
|
+
|
107
|
+
node->ai_addr = (struct sockaddr *)sin6;
|
108
|
+
node->ai_family = AF_INET6;
|
109
|
+
node->ai_addrlen = sizeof(*sin6);
|
110
|
+
node->ai_addr = (struct sockaddr *)sin6;
|
111
|
+
node->ai_ttl = (int)ttl;
|
112
|
+
}
|
113
|
+
|
114
|
+
return ARES_SUCCESS;
|
115
|
+
}
|
116
|
+
|
117
|
+
static ares_status_t
|
118
|
+
ares_default_loopback_addrs(int aftype, unsigned short port,
|
119
|
+
struct ares_addrinfo_node **nodes)
|
120
|
+
{
|
121
|
+
ares_status_t status = ARES_SUCCESS;
|
122
|
+
|
123
|
+
if ((aftype == AF_UNSPEC || aftype == AF_INET6) &&
|
124
|
+
!ares_ai_has_family(AF_INET6, *nodes)) {
|
125
|
+
struct ares_in6_addr addr6;
|
126
|
+
ares_inet_pton(AF_INET6, "::1", &addr6);
|
127
|
+
status = ares_append_ai_node(AF_INET6, port, 0, &addr6, nodes);
|
128
|
+
if (status != ARES_SUCCESS) {
|
129
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
if ((aftype == AF_UNSPEC || aftype == AF_INET) &&
|
134
|
+
!ares_ai_has_family(AF_INET, *nodes)) {
|
135
|
+
struct in_addr addr4;
|
136
|
+
ares_inet_pton(AF_INET, "127.0.0.1", &addr4);
|
137
|
+
status = ares_append_ai_node(AF_INET, port, 0, &addr4, nodes);
|
138
|
+
if (status != ARES_SUCCESS) {
|
139
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
return status;
|
144
|
+
}
|
145
|
+
|
146
|
+
static ares_status_t
|
147
|
+
ares_system_loopback_addrs(int aftype, unsigned short port,
|
148
|
+
struct ares_addrinfo_node **nodes)
|
149
|
+
{
|
150
|
+
#if defined(USE_WINSOCK) && defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600 && \
|
151
|
+
!defined(__WATCOMC__)
|
152
|
+
PMIB_UNICASTIPADDRESS_TABLE table;
|
153
|
+
unsigned int i;
|
154
|
+
ares_status_t status = ARES_ENOTFOUND;
|
155
|
+
|
156
|
+
*nodes = NULL;
|
157
|
+
|
158
|
+
if (GetUnicastIpAddressTable((ADDRESS_FAMILY)aftype, &table) != NO_ERROR) {
|
159
|
+
return ARES_ENOTFOUND;
|
160
|
+
}
|
161
|
+
|
162
|
+
for (i = 0; i < table->NumEntries; i++) {
|
163
|
+
if (table->Table[i].InterfaceLuid.Info.IfType !=
|
164
|
+
IF_TYPE_SOFTWARE_LOOPBACK) {
|
165
|
+
continue;
|
166
|
+
}
|
167
|
+
|
168
|
+
if (table->Table[i].Address.si_family == AF_INET &&
|
169
|
+
!ares_ai_has_family(AF_INET, *nodes)) {
|
170
|
+
status =
|
171
|
+
ares_append_ai_node(table->Table[i].Address.si_family, port, 0,
|
172
|
+
&table->Table[i].Address.Ipv4.sin_addr, nodes);
|
173
|
+
} else if (table->Table[i].Address.si_family == AF_INET6 &&
|
174
|
+
!ares_ai_has_family(AF_INET6, *nodes)) {
|
175
|
+
status =
|
176
|
+
ares_append_ai_node(table->Table[i].Address.si_family, port, 0,
|
177
|
+
&table->Table[i].Address.Ipv6.sin6_addr, nodes);
|
178
|
+
} else {
|
179
|
+
/* Ignore any others */
|
180
|
+
continue;
|
181
|
+
}
|
182
|
+
|
183
|
+
if (status != ARES_SUCCESS) {
|
184
|
+
goto fail;
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
if (*nodes == NULL) {
|
189
|
+
status = ARES_ENOTFOUND;
|
190
|
+
}
|
191
|
+
|
192
|
+
fail:
|
193
|
+
FreeMibTable(table);
|
194
|
+
|
195
|
+
if (status != ARES_SUCCESS) {
|
196
|
+
ares_freeaddrinfo_nodes(*nodes);
|
197
|
+
*nodes = NULL;
|
198
|
+
}
|
199
|
+
|
200
|
+
return status;
|
201
|
+
|
202
|
+
#else
|
203
|
+
(void)aftype;
|
204
|
+
(void)port;
|
205
|
+
(void)nodes;
|
206
|
+
/* Not supported on any other OS at this time */
|
207
|
+
return ARES_ENOTFOUND;
|
208
|
+
#endif
|
209
|
+
}
|
210
|
+
|
211
|
+
ares_status_t ares_addrinfo_localhost(const char *name, unsigned short port,
|
212
|
+
const struct ares_addrinfo_hints *hints,
|
213
|
+
struct ares_addrinfo *ai)
|
214
|
+
{
|
215
|
+
ares_status_t status;
|
216
|
+
|
217
|
+
/* Validate family */
|
218
|
+
switch (hints->ai_family) {
|
219
|
+
case AF_INET:
|
220
|
+
case AF_INET6:
|
221
|
+
case AF_UNSPEC:
|
222
|
+
break;
|
223
|
+
default: /* LCOV_EXCL_LINE: DefensiveCoding */
|
224
|
+
return ARES_EBADFAMILY; /* LCOV_EXCL_LINE: DefensiveCoding */
|
225
|
+
}
|
226
|
+
|
227
|
+
if (ai->name != NULL) {
|
228
|
+
ares_free(ai->name);
|
229
|
+
}
|
230
|
+
ai->name = ares_strdup(name);
|
231
|
+
if (ai->name == NULL) {
|
232
|
+
status = ARES_ENOMEM;
|
233
|
+
goto done; /* LCOV_EXCL_LINE: OutOfMemory */
|
234
|
+
}
|
235
|
+
|
236
|
+
status = ares_system_loopback_addrs(hints->ai_family, port, &ai->nodes);
|
237
|
+
if (status != ARES_SUCCESS && status != ARES_ENOTFOUND) {
|
238
|
+
goto done;
|
239
|
+
}
|
240
|
+
|
241
|
+
status = ares_default_loopback_addrs(hints->ai_family, port, &ai->nodes);
|
242
|
+
|
243
|
+
done:
|
244
|
+
return status;
|
245
|
+
}
|