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,321 +1,623 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
/* MIT License
|
2
|
+
*
|
3
|
+
* Copyright (c) 1998 Massachusetts Institute of Technology
|
4
|
+
* Copyright (c) The c-ares project and its contributors
|
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.
|
3
24
|
*
|
4
|
-
*
|
5
|
-
* software and its documentation for any purpose and without
|
6
|
-
* fee is hereby granted, provided that the above copyright
|
7
|
-
* notice appear in all copies and that both that copyright
|
8
|
-
* notice and this permission notice appear in supporting
|
9
|
-
* documentation, and that the name of M.I.T. not be used in
|
10
|
-
* advertising or publicity pertaining to distribution of the
|
11
|
-
* software without specific, written prior permission.
|
12
|
-
* M.I.T. makes no representations about the suitability of
|
13
|
-
* this software for any purpose. It is provided "as is"
|
14
|
-
* without express or implied warranty.
|
25
|
+
* SPDX-License-Identifier: MIT
|
15
26
|
*/
|
16
27
|
|
17
|
-
#include "
|
28
|
+
#include "ares_private.h"
|
18
29
|
|
19
30
|
#ifdef HAVE_STRINGS_H
|
20
31
|
# include <strings.h>
|
21
32
|
#endif
|
22
33
|
|
23
|
-
#include "ares.h"
|
24
|
-
#include "ares_private.h"
|
25
|
-
|
26
34
|
struct search_query {
|
27
|
-
/* Arguments passed to
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
int type;
|
32
|
-
ares_callback callback;
|
33
|
-
void *arg;
|
35
|
+
/* Arguments passed to ares_search_dnsrec() */
|
36
|
+
ares_channel_t *channel;
|
37
|
+
ares_callback_dnsrec callback;
|
38
|
+
void *arg;
|
34
39
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
+
/* Duplicate of DNS record passed to ares_search_dnsrec() */
|
41
|
+
ares_dns_record_t *dnsrec;
|
42
|
+
|
43
|
+
/* Search order for names */
|
44
|
+
char **names;
|
45
|
+
size_t names_cnt;
|
46
|
+
|
47
|
+
/* State tracking progress through the search query */
|
48
|
+
size_t next_name_idx; /* next name index being attempted */
|
49
|
+
size_t timeouts; /* number of timeouts we saw for this request */
|
50
|
+
ares_bool_t ever_got_nodata; /* did we ever get ARES_ENODATA along the way? */
|
40
51
|
};
|
41
52
|
|
42
|
-
static void
|
43
|
-
|
44
|
-
|
45
|
-
|
53
|
+
static void squery_free(struct search_query *squery)
|
54
|
+
{
|
55
|
+
if (squery == NULL) {
|
56
|
+
return; /* LCOV_EXCL_LINE: DefensiveCoding */
|
57
|
+
}
|
58
|
+
ares_strsplit_free(squery->names, squery->names_cnt);
|
59
|
+
ares_dns_record_destroy(squery->dnsrec);
|
60
|
+
ares_free(squery);
|
61
|
+
}
|
46
62
|
|
47
|
-
|
48
|
-
|
63
|
+
/* End a search query by invoking the user callback and freeing the
|
64
|
+
* search_query structure.
|
65
|
+
*/
|
66
|
+
static void end_squery(struct search_query *squery, ares_status_t status,
|
67
|
+
const ares_dns_record_t *dnsrec)
|
49
68
|
{
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
int status, ndots;
|
69
|
+
squery->callback(squery->arg, status, squery->timeouts, dnsrec);
|
70
|
+
squery_free(squery);
|
71
|
+
}
|
54
72
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
73
|
+
static void search_callback(void *arg, ares_status_t status, size_t timeouts,
|
74
|
+
const ares_dns_record_t *dnsrec);
|
75
|
+
|
76
|
+
static ares_status_t ares_search_next(ares_channel_t *channel,
|
77
|
+
struct search_query *squery,
|
78
|
+
ares_bool_t *skip_cleanup)
|
79
|
+
{
|
80
|
+
ares_status_t status;
|
81
|
+
|
82
|
+
*skip_cleanup = ARES_FALSE;
|
83
|
+
|
84
|
+
/* Misuse check */
|
85
|
+
if (squery->next_name_idx >= squery->names_cnt) {
|
86
|
+
return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
|
87
|
+
}
|
88
|
+
|
89
|
+
status = ares_dns_record_query_set_name(
|
90
|
+
squery->dnsrec, 0, squery->names[squery->next_name_idx++]);
|
91
|
+
if (status != ARES_SUCCESS) {
|
92
|
+
return status;
|
93
|
+
}
|
94
|
+
|
95
|
+
status = ares_send_nolock(channel, NULL, 0, squery->dnsrec, search_callback,
|
96
|
+
squery, NULL);
|
97
|
+
|
98
|
+
if (status != ARES_EFORMERR) {
|
99
|
+
*skip_cleanup = ARES_TRUE;
|
100
|
+
}
|
101
|
+
|
102
|
+
return status;
|
103
|
+
}
|
104
|
+
|
105
|
+
static void search_callback(void *arg, ares_status_t status, size_t timeouts,
|
106
|
+
const ares_dns_record_t *dnsrec)
|
107
|
+
{
|
108
|
+
struct search_query *squery = (struct search_query *)arg;
|
109
|
+
ares_channel_t *channel = squery->channel;
|
110
|
+
|
111
|
+
ares_status_t mystatus;
|
112
|
+
ares_bool_t skip_cleanup = ARES_FALSE;
|
113
|
+
|
114
|
+
squery->timeouts += timeouts;
|
115
|
+
|
116
|
+
if (dnsrec) {
|
117
|
+
ares_dns_rcode_t rcode = ares_dns_record_get_rcode(dnsrec);
|
118
|
+
size_t ancount = ares_dns_record_rr_cnt(dnsrec, ARES_SECTION_ANSWER);
|
119
|
+
mystatus = ares_dns_query_reply_tostatus(rcode, ancount);
|
120
|
+
} else {
|
121
|
+
mystatus = status;
|
122
|
+
}
|
123
|
+
|
124
|
+
switch (mystatus) {
|
125
|
+
case ARES_ENODATA:
|
126
|
+
case ARES_ENOTFOUND:
|
127
|
+
break;
|
128
|
+
case ARES_ESERVFAIL:
|
129
|
+
case ARES_EREFUSED:
|
130
|
+
/* Issue #852, systemd-resolved may return SERVFAIL or REFUSED on a
|
131
|
+
* single label domain name. */
|
132
|
+
if (ares_name_label_cnt(squery->names[squery->next_name_idx - 1]) != 1) {
|
133
|
+
end_squery(squery, mystatus, dnsrec);
|
134
|
+
return;
|
135
|
+
}
|
136
|
+
break;
|
137
|
+
default:
|
138
|
+
end_squery(squery, mystatus, dnsrec);
|
59
139
|
return;
|
60
|
-
|
140
|
+
}
|
61
141
|
|
62
|
-
/* If
|
63
|
-
* to
|
142
|
+
/* If we ever get ARES_ENODATA along the way, record that; if the search
|
143
|
+
* should run to the very end and we got at least one ARES_ENODATA,
|
144
|
+
* then callers like ares_gethostbyname() may want to try a T_A search
|
145
|
+
* even if the last domain we queried for T_AAAA resource records
|
146
|
+
* returned ARES_ENOTFOUND.
|
64
147
|
*/
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
148
|
+
if (mystatus == ARES_ENODATA) {
|
149
|
+
squery->ever_got_nodata = ARES_TRUE;
|
150
|
+
}
|
151
|
+
|
152
|
+
if (squery->next_name_idx < squery->names_cnt) {
|
153
|
+
mystatus = ares_search_next(channel, squery, &skip_cleanup);
|
154
|
+
if (mystatus != ARES_SUCCESS && !skip_cleanup) {
|
155
|
+
end_squery(squery, mystatus, NULL);
|
70
156
|
}
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
157
|
+
return;
|
158
|
+
}
|
159
|
+
|
160
|
+
/* We have no more domains to search, return an appropriate response. */
|
161
|
+
if (mystatus == ARES_ENOTFOUND && squery->ever_got_nodata) {
|
162
|
+
end_squery(squery, ARES_ENODATA, NULL);
|
163
|
+
return;
|
164
|
+
}
|
165
|
+
|
166
|
+
end_squery(squery, mystatus, NULL);
|
167
|
+
}
|
168
|
+
|
169
|
+
/* Determine if the domain should be looked up as-is, or if it is eligible
|
170
|
+
* for search by appending domains */
|
171
|
+
static ares_bool_t ares_search_eligible(const ares_channel_t *channel,
|
172
|
+
const char *name)
|
173
|
+
{
|
174
|
+
size_t len = ares_strlen(name);
|
175
|
+
|
176
|
+
/* Name ends in '.', cannot search */
|
177
|
+
if (len && name[len - 1] == '.') {
|
178
|
+
return ARES_FALSE;
|
179
|
+
}
|
180
|
+
|
181
|
+
if (channel->flags & ARES_FLAG_NOSEARCH) {
|
182
|
+
return ARES_FALSE;
|
183
|
+
}
|
184
|
+
|
185
|
+
return ARES_TRUE;
|
186
|
+
}
|
187
|
+
|
188
|
+
size_t ares_name_label_cnt(const char *name)
|
189
|
+
{
|
190
|
+
const char *p;
|
191
|
+
size_t ndots = 0;
|
192
|
+
|
193
|
+
if (name == NULL) {
|
194
|
+
return 0;
|
195
|
+
}
|
196
|
+
|
197
|
+
for (p = name; p != NULL && *p != 0; p++) {
|
198
|
+
if (*p == '.') {
|
199
|
+
ndots++;
|
76
200
|
}
|
201
|
+
}
|
77
202
|
|
78
|
-
/*
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
203
|
+
/* Label count is 1 greater than ndots */
|
204
|
+
return ndots + 1;
|
205
|
+
}
|
206
|
+
|
207
|
+
ares_status_t ares_search_name_list(const ares_channel_t *channel,
|
208
|
+
const char *name, char ***names,
|
209
|
+
size_t *names_len)
|
210
|
+
{
|
211
|
+
ares_status_t status;
|
212
|
+
char **list = NULL;
|
213
|
+
size_t list_len = 0;
|
214
|
+
char *alias = NULL;
|
215
|
+
size_t ndots = 0;
|
216
|
+
size_t idx = 0;
|
217
|
+
size_t i;
|
218
|
+
|
219
|
+
/* Perform HOSTALIASES resolution */
|
220
|
+
status = ares_lookup_hostaliases(channel, name, &alias);
|
221
|
+
if (status == ARES_SUCCESS) {
|
222
|
+
/* If hostalias succeeds, there is no searching, it is used as-is */
|
223
|
+
list_len = 1;
|
224
|
+
list = ares_malloc_zero(sizeof(*list) * list_len);
|
225
|
+
if (list == NULL) {
|
226
|
+
status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
227
|
+
goto done; /* LCOV_EXCL_LINE: OutOfMemory */
|
86
228
|
}
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
229
|
+
list[0] = alias;
|
230
|
+
alias = NULL;
|
231
|
+
goto done;
|
232
|
+
} else if (status != ARES_ENOTFOUND) {
|
233
|
+
goto done;
|
234
|
+
}
|
235
|
+
|
236
|
+
/* See if searching is eligible at all, if not, look up as-is only */
|
237
|
+
if (!ares_search_eligible(channel, name)) {
|
238
|
+
list_len = 1;
|
239
|
+
list = ares_malloc_zero(sizeof(*list) * list_len);
|
240
|
+
if (list == NULL) {
|
241
|
+
status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
242
|
+
goto done; /* LCOV_EXCL_LINE: OutOfMemory */
|
94
243
|
}
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
squery->timeouts = 0;
|
101
|
-
squery->ever_got_nodata = 0;
|
102
|
-
|
103
|
-
/* Count the number of dots in name. */
|
104
|
-
ndots = 0;
|
105
|
-
for (p = name; *p; p++)
|
106
|
-
{
|
107
|
-
if (*p == '.')
|
108
|
-
ndots++;
|
244
|
+
list[0] = ares_strdup(name);
|
245
|
+
if (list[0] == NULL) {
|
246
|
+
status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
247
|
+
} else {
|
248
|
+
status = ARES_SUCCESS;
|
109
249
|
}
|
250
|
+
goto done;
|
251
|
+
}
|
110
252
|
|
111
|
-
/*
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
253
|
+
/* Count the number of dots in name, 1 less than label count */
|
254
|
+
ndots = ares_name_label_cnt(name);
|
255
|
+
if (ndots > 0) {
|
256
|
+
ndots--;
|
257
|
+
}
|
258
|
+
|
259
|
+
/* Allocate an entry for each search domain, plus one for as-is */
|
260
|
+
list_len = channel->ndomains + 1;
|
261
|
+
list = ares_malloc_zero(sizeof(*list) * list_len);
|
262
|
+
if (list == NULL) {
|
263
|
+
status = ARES_ENOMEM;
|
264
|
+
goto done;
|
265
|
+
}
|
266
|
+
|
267
|
+
/* Set status here, its possible there are no search domains at all, so
|
268
|
+
* status may be ARES_ENOTFOUND from ares_lookup_hostaliases(). */
|
269
|
+
status = ARES_SUCCESS;
|
270
|
+
|
271
|
+
/* Try as-is first */
|
272
|
+
if (ndots >= channel->ndots) {
|
273
|
+
list[idx] = ares_strdup(name);
|
274
|
+
if (list[idx] == NULL) {
|
275
|
+
status = ARES_ENOMEM;
|
276
|
+
goto done;
|
121
277
|
}
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
278
|
+
idx++;
|
279
|
+
}
|
280
|
+
|
281
|
+
/* Append each search suffix to the name */
|
282
|
+
for (i = 0; i < channel->ndomains; i++) {
|
283
|
+
status = ares_cat_domain(name, channel->domains[i], &list[idx]);
|
284
|
+
if (status != ARES_SUCCESS) {
|
285
|
+
goto done;
|
286
|
+
}
|
287
|
+
idx++;
|
288
|
+
}
|
289
|
+
|
290
|
+
/* Try as-is last */
|
291
|
+
if (ndots < channel->ndots) {
|
292
|
+
list[idx] = ares_strdup(name);
|
293
|
+
if (list[idx] == NULL) {
|
294
|
+
status = ARES_ENOMEM;
|
295
|
+
goto done;
|
140
296
|
}
|
297
|
+
idx++;
|
298
|
+
}
|
299
|
+
|
300
|
+
|
301
|
+
done:
|
302
|
+
if (status == ARES_SUCCESS) {
|
303
|
+
*names = list;
|
304
|
+
*names_len = list_len;
|
305
|
+
} else {
|
306
|
+
ares_strsplit_free(list, list_len);
|
307
|
+
}
|
308
|
+
|
309
|
+
ares_free(alias);
|
310
|
+
return status;
|
141
311
|
}
|
142
312
|
|
143
|
-
static
|
144
|
-
|
313
|
+
static ares_status_t ares_search_int(ares_channel_t *channel,
|
314
|
+
const ares_dns_record_t *dnsrec,
|
315
|
+
ares_callback_dnsrec callback, void *arg)
|
145
316
|
{
|
146
|
-
struct search_query *squery =
|
147
|
-
|
148
|
-
|
317
|
+
struct search_query *squery = NULL;
|
318
|
+
const char *name;
|
319
|
+
ares_status_t status = ARES_SUCCESS;
|
320
|
+
ares_bool_t skip_cleanup = ARES_FALSE;
|
149
321
|
|
150
|
-
|
322
|
+
/* Extract the name for the search. Note that searches are only supported for
|
323
|
+
* DNS records containing a single query.
|
324
|
+
*/
|
325
|
+
if (ares_dns_record_query_cnt(dnsrec) != 1) {
|
326
|
+
status = ARES_EBADQUERY;
|
327
|
+
goto fail;
|
328
|
+
}
|
151
329
|
|
152
|
-
|
153
|
-
if (status !=
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
330
|
+
status = ares_dns_record_query_get(dnsrec, 0, &name, NULL, NULL);
|
331
|
+
if (status != ARES_SUCCESS) {
|
332
|
+
goto fail;
|
333
|
+
}
|
334
|
+
|
335
|
+
/* Per RFC 7686, reject queries for ".onion" domain names with NXDOMAIN. */
|
336
|
+
if (ares_is_onion_domain(name)) {
|
337
|
+
status = ARES_ENOTFOUND;
|
338
|
+
goto fail;
|
339
|
+
}
|
340
|
+
|
341
|
+
/* Allocate a search_query structure to hold the state necessary for
|
342
|
+
* doing multiple lookups.
|
343
|
+
*/
|
344
|
+
squery = ares_malloc_zero(sizeof(*squery));
|
345
|
+
if (squery == NULL) {
|
346
|
+
status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
347
|
+
goto fail; /* LCOV_EXCL_LINE: OutOfMemory */
|
348
|
+
}
|
349
|
+
|
350
|
+
squery->channel = channel;
|
351
|
+
|
352
|
+
/* Duplicate DNS record since, name will need to be rewritten */
|
353
|
+
squery->dnsrec = ares_dns_record_duplicate(dnsrec);
|
354
|
+
if (squery->dnsrec == NULL) {
|
355
|
+
status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
356
|
+
goto fail; /* LCOV_EXCL_LINE: OutOfMemory */
|
357
|
+
}
|
358
|
+
|
359
|
+
squery->callback = callback;
|
360
|
+
squery->arg = arg;
|
361
|
+
squery->timeouts = 0;
|
362
|
+
squery->ever_got_nodata = ARES_FALSE;
|
363
|
+
|
364
|
+
status =
|
365
|
+
ares_search_name_list(channel, name, &squery->names, &squery->names_cnt);
|
366
|
+
if (status != ARES_SUCCESS) {
|
367
|
+
goto fail;
|
368
|
+
}
|
369
|
+
|
370
|
+
status = ares_search_next(channel, squery, &skip_cleanup);
|
371
|
+
if (status != ARES_SUCCESS) {
|
372
|
+
goto fail;
|
373
|
+
}
|
374
|
+
|
375
|
+
return status;
|
376
|
+
|
377
|
+
fail:
|
378
|
+
if (!skip_cleanup) {
|
379
|
+
squery_free(squery);
|
380
|
+
callback(arg, status, 0, NULL);
|
381
|
+
}
|
382
|
+
return status;
|
383
|
+
}
|
384
|
+
|
385
|
+
/* Callback argument structure passed to ares_dnsrec_convert_cb(). */
|
386
|
+
typedef struct {
|
387
|
+
ares_callback callback;
|
388
|
+
void *arg;
|
389
|
+
} dnsrec_convert_arg_t;
|
390
|
+
|
391
|
+
/*! Function to create callback arg for converting from ares_callback_dnsrec
|
392
|
+
* to ares_calback */
|
393
|
+
void *ares_dnsrec_convert_arg(ares_callback callback, void *arg)
|
394
|
+
{
|
395
|
+
dnsrec_convert_arg_t *carg = ares_malloc_zero(sizeof(*carg));
|
396
|
+
if (carg == NULL) {
|
397
|
+
return NULL;
|
398
|
+
}
|
399
|
+
carg->callback = callback;
|
400
|
+
carg->arg = arg;
|
401
|
+
return carg;
|
402
|
+
}
|
403
|
+
|
404
|
+
/*! Callback function used to convert from the ares_callback_dnsrec prototype to
|
405
|
+
* the ares_callback prototype, by writing the result and passing that to
|
406
|
+
* the inner callback.
|
407
|
+
*/
|
408
|
+
void ares_dnsrec_convert_cb(void *arg, ares_status_t status, size_t timeouts,
|
409
|
+
const ares_dns_record_t *dnsrec)
|
410
|
+
{
|
411
|
+
dnsrec_convert_arg_t *carg = arg;
|
412
|
+
unsigned char *abuf = NULL;
|
413
|
+
size_t alen = 0;
|
414
|
+
|
415
|
+
if (dnsrec != NULL) {
|
416
|
+
ares_status_t mystatus = ares_dns_write(dnsrec, &abuf, &alen);
|
417
|
+
if (mystatus != ARES_SUCCESS) {
|
418
|
+
status = mystatus;
|
202
419
|
}
|
420
|
+
}
|
421
|
+
|
422
|
+
carg->callback(carg->arg, (int)status, (int)timeouts, abuf, (int)alen);
|
423
|
+
|
424
|
+
ares_free(abuf);
|
425
|
+
ares_free(carg);
|
203
426
|
}
|
204
427
|
|
205
|
-
|
206
|
-
|
428
|
+
/* Search for a DNS name with given class and type. Wrapper around
|
429
|
+
* ares_search_int() where the DNS record to search is first constructed.
|
430
|
+
*/
|
431
|
+
void ares_search(ares_channel_t *channel, const char *name, int dnsclass,
|
432
|
+
int type, ares_callback callback, void *arg)
|
207
433
|
{
|
208
|
-
|
209
|
-
|
210
|
-
|
434
|
+
ares_status_t status;
|
435
|
+
ares_dns_record_t *dnsrec = NULL;
|
436
|
+
size_t max_udp_size;
|
437
|
+
ares_dns_flags_t rd_flag;
|
438
|
+
void *carg = NULL;
|
439
|
+
if (channel == NULL || name == NULL) {
|
440
|
+
return;
|
441
|
+
}
|
442
|
+
|
443
|
+
/* For now, ares_search_int() uses the ares_callback prototype. We need to
|
444
|
+
* wrap the callback passed to this function in ares_dnsrec_convert_cb, to
|
445
|
+
* convert from ares_callback_dnsrec to ares_callback. Allocate the convert
|
446
|
+
* arg structure here.
|
447
|
+
*/
|
448
|
+
carg = ares_dnsrec_convert_arg(callback, arg);
|
449
|
+
if (carg == NULL) {
|
450
|
+
callback(arg, ARES_ENOMEM, 0, NULL, 0);
|
451
|
+
return;
|
452
|
+
}
|
453
|
+
|
454
|
+
rd_flag = !(channel->flags & ARES_FLAG_NORECURSE) ? ARES_FLAG_RD : 0;
|
455
|
+
max_udp_size = (channel->flags & ARES_FLAG_EDNS) ? channel->ednspsz : 0;
|
456
|
+
status = ares_dns_record_create_query(
|
457
|
+
&dnsrec, name, (ares_dns_class_t)dnsclass, (ares_dns_rec_type_t)type, 0,
|
458
|
+
rd_flag, max_udp_size);
|
459
|
+
if (status != ARES_SUCCESS) {
|
460
|
+
callback(arg, (int)status, 0, NULL, 0);
|
461
|
+
ares_free(carg);
|
462
|
+
return;
|
463
|
+
}
|
464
|
+
|
465
|
+
ares_channel_lock(channel);
|
466
|
+
ares_search_int(channel, dnsrec, ares_dnsrec_convert_cb, carg);
|
467
|
+
ares_channel_unlock(channel);
|
468
|
+
|
469
|
+
ares_dns_record_destroy(dnsrec);
|
470
|
+
}
|
471
|
+
|
472
|
+
/* Search for a DNS record. Wrapper around ares_search_int(). */
|
473
|
+
ares_status_t ares_search_dnsrec(ares_channel_t *channel,
|
474
|
+
const ares_dns_record_t *dnsrec,
|
475
|
+
ares_callback_dnsrec callback, void *arg)
|
476
|
+
{
|
477
|
+
ares_status_t status;
|
478
|
+
|
479
|
+
if (channel == NULL || dnsrec == NULL || callback == NULL) {
|
480
|
+
return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
|
481
|
+
}
|
482
|
+
|
483
|
+
ares_channel_lock(channel);
|
484
|
+
status = ares_search_int(channel, dnsrec, callback, arg);
|
485
|
+
ares_channel_unlock(channel);
|
486
|
+
|
487
|
+
return status;
|
211
488
|
}
|
212
489
|
|
213
490
|
/* Concatenate two domains. */
|
214
|
-
|
491
|
+
ares_status_t ares_cat_domain(const char *name, const char *domain, char **s)
|
215
492
|
{
|
216
|
-
size_t nlen =
|
217
|
-
size_t dlen =
|
493
|
+
size_t nlen = ares_strlen(name);
|
494
|
+
size_t dlen = ares_strlen(domain);
|
218
495
|
|
219
496
|
*s = ares_malloc(nlen + 1 + dlen + 1);
|
220
|
-
if (!*s)
|
497
|
+
if (!*s) {
|
221
498
|
return ARES_ENOMEM;
|
499
|
+
}
|
222
500
|
memcpy(*s, name, nlen);
|
223
501
|
(*s)[nlen] = '.';
|
502
|
+
if (ares_streq(domain, ".")) {
|
503
|
+
/* Avoid appending the root domain to the separator, which would set *s to
|
504
|
+
an ill-formed value (ending in two consecutive dots). */
|
505
|
+
dlen = 0;
|
506
|
+
}
|
224
507
|
memcpy(*s + nlen + 1, domain, dlen);
|
225
508
|
(*s)[nlen + 1 + dlen] = 0;
|
226
509
|
return ARES_SUCCESS;
|
227
510
|
}
|
228
511
|
|
229
|
-
|
230
|
-
*
|
231
|
-
* to NULL.
|
232
|
-
*/
|
233
|
-
int ares__single_domain(ares_channel channel, const char *name, char **s)
|
512
|
+
ares_status_t ares_lookup_hostaliases(const ares_channel_t *channel,
|
513
|
+
const char *name, char **alias)
|
234
514
|
{
|
235
|
-
|
236
|
-
const char
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
size_t
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
515
|
+
ares_status_t status = ARES_SUCCESS;
|
516
|
+
const char *hostaliases = NULL;
|
517
|
+
ares_buf_t *buf = NULL;
|
518
|
+
ares_array_t *lines = NULL;
|
519
|
+
size_t num;
|
520
|
+
size_t i;
|
521
|
+
|
522
|
+
if (channel == NULL || name == NULL || alias == NULL) {
|
523
|
+
return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
|
524
|
+
}
|
525
|
+
|
526
|
+
*alias = NULL;
|
527
|
+
|
528
|
+
/* Configuration says to not perform alias lookup */
|
529
|
+
if (channel->flags & ARES_FLAG_NOALIASES) {
|
530
|
+
return ARES_ENOTFOUND;
|
531
|
+
}
|
532
|
+
|
533
|
+
/* If a domain has a '.', its not allowed to perform an alias lookup */
|
534
|
+
if (strchr(name, '.') != NULL) {
|
535
|
+
return ARES_ENOTFOUND;
|
536
|
+
}
|
537
|
+
|
538
|
+
hostaliases = getenv("HOSTALIASES");
|
539
|
+
if (hostaliases == NULL) {
|
540
|
+
status = ARES_ENOTFOUND;
|
541
|
+
goto done;
|
542
|
+
}
|
543
|
+
|
544
|
+
buf = ares_buf_create();
|
545
|
+
if (buf == NULL) {
|
546
|
+
status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
547
|
+
goto done; /* LCOV_EXCL_LINE: OutOfMemory */
|
548
|
+
}
|
549
|
+
|
550
|
+
status = ares_buf_load_file(hostaliases, buf);
|
551
|
+
if (status != ARES_SUCCESS) {
|
552
|
+
goto done;
|
553
|
+
}
|
554
|
+
|
555
|
+
/* The HOSTALIASES file is structured as one alias per line. The first
|
556
|
+
* field in the line is the simple hostname with no periods, followed by
|
557
|
+
* whitespace, then the full domain name, e.g.:
|
558
|
+
*
|
559
|
+
* c-ares www.c-ares.org
|
560
|
+
* curl www.curl.se
|
246
561
|
*/
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
562
|
+
|
563
|
+
status = ares_buf_split(buf, (const unsigned char *)"\n", 1,
|
564
|
+
ARES_BUF_SPLIT_TRIM, 0, &lines);
|
565
|
+
if (status != ARES_SUCCESS) {
|
566
|
+
goto done;
|
567
|
+
}
|
568
|
+
|
569
|
+
num = ares_array_len(lines);
|
570
|
+
for (i = 0; i < num; i++) {
|
571
|
+
ares_buf_t **bufptr = ares_array_at(lines, i);
|
572
|
+
ares_buf_t *line = *bufptr;
|
573
|
+
char hostname[64] = "";
|
574
|
+
char fqdn[256] = "";
|
575
|
+
|
576
|
+
/* Pull off hostname */
|
577
|
+
ares_buf_tag(line);
|
578
|
+
ares_buf_consume_nonwhitespace(line);
|
579
|
+
if (ares_buf_tag_fetch_string(line, hostname, sizeof(hostname)) !=
|
580
|
+
ARES_SUCCESS) {
|
581
|
+
continue;
|
251
582
|
}
|
252
583
|
|
253
|
-
|
254
|
-
{
|
255
|
-
|
256
|
-
hostaliases = getenv("HOSTALIASES");
|
257
|
-
if (hostaliases)
|
258
|
-
{
|
259
|
-
fp = fopen(hostaliases, "r");
|
260
|
-
if (fp)
|
261
|
-
{
|
262
|
-
while ((status = ares__read_line(fp, &line, &linesize))
|
263
|
-
== ARES_SUCCESS)
|
264
|
-
{
|
265
|
-
if (strncasecmp(line, name, len) != 0 ||
|
266
|
-
!ISSPACE(line[len]))
|
267
|
-
continue;
|
268
|
-
p = line + len;
|
269
|
-
while (ISSPACE(*p))
|
270
|
-
p++;
|
271
|
-
if (*p)
|
272
|
-
{
|
273
|
-
q = p + 1;
|
274
|
-
while (*q && !ISSPACE(*q))
|
275
|
-
q++;
|
276
|
-
*s = ares_malloc(q - p + 1);
|
277
|
-
if (*s)
|
278
|
-
{
|
279
|
-
memcpy(*s, p, q - p);
|
280
|
-
(*s)[q - p] = 0;
|
281
|
-
}
|
282
|
-
ares_free(line);
|
283
|
-
fclose(fp);
|
284
|
-
return (*s) ? ARES_SUCCESS : ARES_ENOMEM;
|
285
|
-
}
|
286
|
-
}
|
287
|
-
ares_free(line);
|
288
|
-
fclose(fp);
|
289
|
-
if (status != ARES_SUCCESS && status != ARES_EOF)
|
290
|
-
return status;
|
291
|
-
}
|
292
|
-
else
|
293
|
-
{
|
294
|
-
error = ERRNO;
|
295
|
-
switch(error)
|
296
|
-
{
|
297
|
-
case ENOENT:
|
298
|
-
case ESRCH:
|
299
|
-
break;
|
300
|
-
default:
|
301
|
-
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n",
|
302
|
-
error, strerror(error)));
|
303
|
-
DEBUGF(fprintf(stderr, "Error opening file: %s\n",
|
304
|
-
hostaliases));
|
305
|
-
*s = NULL;
|
306
|
-
return ARES_EFILE;
|
307
|
-
}
|
308
|
-
}
|
309
|
-
}
|
584
|
+
/* Match hostname */
|
585
|
+
if (!ares_strcaseeq(hostname, name)) {
|
586
|
+
continue;
|
310
587
|
}
|
311
588
|
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
589
|
+
/* consume whitespace */
|
590
|
+
ares_buf_consume_whitespace(line, ARES_TRUE);
|
591
|
+
|
592
|
+
/* pull off fqdn */
|
593
|
+
ares_buf_tag(line);
|
594
|
+
ares_buf_consume_nonwhitespace(line);
|
595
|
+
if (ares_buf_tag_fetch_string(line, fqdn, sizeof(fqdn)) != ARES_SUCCESS ||
|
596
|
+
ares_strlen(fqdn) == 0) {
|
597
|
+
continue;
|
317
598
|
}
|
318
599
|
|
319
|
-
|
320
|
-
|
600
|
+
/* Validate characterset */
|
601
|
+
if (!ares_is_hostname(fqdn)) {
|
602
|
+
continue;
|
603
|
+
}
|
604
|
+
|
605
|
+
*alias = ares_strdup(fqdn);
|
606
|
+
if (*alias == NULL) {
|
607
|
+
status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
608
|
+
goto done; /* LCOV_EXCL_LINE: OutOfMemory */
|
609
|
+
}
|
610
|
+
|
611
|
+
/* Good! */
|
612
|
+
status = ARES_SUCCESS;
|
613
|
+
goto done;
|
614
|
+
}
|
615
|
+
|
616
|
+
status = ARES_ENOTFOUND;
|
617
|
+
|
618
|
+
done:
|
619
|
+
ares_buf_destroy(buf);
|
620
|
+
ares_array_destroy(lines);
|
621
|
+
|
622
|
+
return status;
|
321
623
|
}
|