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,406 +1,492 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
* Copyright (
|
1
|
+
/* MIT License
|
2
|
+
*
|
3
|
+
* Copyright (c) 1998 Massachusetts Institute of Technology
|
4
|
+
* Copyright (c) 2008 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:
|
4
12
|
*
|
5
|
-
*
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
15
|
-
*
|
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
|
16
26
|
*/
|
17
27
|
|
18
|
-
|
19
|
-
#include "ares_setup.h"
|
28
|
+
#include "ares_private.h"
|
20
29
|
|
21
30
|
#ifdef HAVE_ARPA_INET_H
|
22
31
|
# include <arpa/inet.h>
|
23
32
|
#endif
|
24
33
|
|
25
|
-
#include "ares.h"
|
26
34
|
#include "ares_data.h"
|
27
35
|
#include "ares_inet_net_pton.h"
|
28
|
-
#include "ares_private.h"
|
29
|
-
|
30
36
|
|
31
|
-
|
32
|
-
struct ares_addr_node **servers)
|
37
|
+
void ares_destroy_options(struct ares_options *options)
|
33
38
|
{
|
34
|
-
struct ares_addr_node *srvr_head = NULL;
|
35
|
-
struct ares_addr_node *srvr_last = NULL;
|
36
|
-
struct ares_addr_node *srvr_curr;
|
37
|
-
int status = ARES_SUCCESS;
|
38
39
|
int i;
|
39
40
|
|
40
|
-
|
41
|
-
return ARES_ENODATA;
|
41
|
+
ares_free(options->servers);
|
42
42
|
|
43
|
-
for (i = 0; i <
|
44
|
-
|
45
|
-
|
46
|
-
srvr_curr = ares_malloc_data(ARES_DATATYPE_ADDR_NODE);
|
47
|
-
if (!srvr_curr)
|
48
|
-
{
|
49
|
-
status = ARES_ENOMEM;
|
50
|
-
break;
|
51
|
-
}
|
52
|
-
if (srvr_last)
|
53
|
-
{
|
54
|
-
srvr_last->next = srvr_curr;
|
55
|
-
}
|
56
|
-
else
|
57
|
-
{
|
58
|
-
srvr_head = srvr_curr;
|
59
|
-
}
|
60
|
-
srvr_last = srvr_curr;
|
61
|
-
|
62
|
-
/* Fill this server node data */
|
63
|
-
srvr_curr->family = channel->servers[i].addr.family;
|
64
|
-
if (srvr_curr->family == AF_INET)
|
65
|
-
memcpy(&srvr_curr->addrV4, &channel->servers[i].addr.addrV4,
|
66
|
-
sizeof(srvr_curr->addrV4));
|
67
|
-
else
|
68
|
-
memcpy(&srvr_curr->addrV6, &channel->servers[i].addr.addrV6,
|
69
|
-
sizeof(srvr_curr->addrV6));
|
70
|
-
}
|
71
|
-
|
72
|
-
if (status != ARES_SUCCESS)
|
73
|
-
{
|
74
|
-
if (srvr_head)
|
75
|
-
{
|
76
|
-
ares_free_data(srvr_head);
|
77
|
-
srvr_head = NULL;
|
78
|
-
}
|
79
|
-
}
|
80
|
-
|
81
|
-
*servers = srvr_head;
|
43
|
+
for (i = 0; options->domains && i < options->ndomains; i++) {
|
44
|
+
ares_free(options->domains[i]);
|
45
|
+
}
|
82
46
|
|
83
|
-
|
47
|
+
ares_free(options->domains);
|
48
|
+
ares_free(options->sortlist);
|
49
|
+
ares_free(options->lookups);
|
50
|
+
ares_free(options->resolvconf_path);
|
51
|
+
ares_free(options->hosts_path);
|
84
52
|
}
|
85
53
|
|
86
|
-
|
87
|
-
|
54
|
+
static struct in_addr *ares_save_opt_servers(const ares_channel_t *channel,
|
55
|
+
int *nservers)
|
88
56
|
{
|
89
|
-
|
90
|
-
struct
|
91
|
-
|
92
|
-
int status = ARES_SUCCESS;
|
93
|
-
int i;
|
57
|
+
ares_slist_node_t *snode;
|
58
|
+
struct in_addr *out =
|
59
|
+
ares_malloc_zero(ares_slist_len(channel->servers) * sizeof(*out));
|
94
60
|
|
95
|
-
|
96
|
-
return ARES_ENODATA;
|
61
|
+
*nservers = 0;
|
97
62
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
srvr_curr = ares_malloc_data(ARES_DATATYPE_ADDR_PORT_NODE);
|
102
|
-
if (!srvr_curr)
|
103
|
-
{
|
104
|
-
status = ARES_ENOMEM;
|
105
|
-
break;
|
106
|
-
}
|
107
|
-
if (srvr_last)
|
108
|
-
{
|
109
|
-
srvr_last->next = srvr_curr;
|
110
|
-
}
|
111
|
-
else
|
112
|
-
{
|
113
|
-
srvr_head = srvr_curr;
|
114
|
-
}
|
115
|
-
srvr_last = srvr_curr;
|
116
|
-
|
117
|
-
/* Fill this server node data */
|
118
|
-
srvr_curr->family = channel->servers[i].addr.family;
|
119
|
-
srvr_curr->udp_port = ntohs((unsigned short)channel->servers[i].addr.udp_port);
|
120
|
-
srvr_curr->tcp_port = ntohs((unsigned short)channel->servers[i].addr.tcp_port);
|
121
|
-
if (srvr_curr->family == AF_INET)
|
122
|
-
memcpy(&srvr_curr->addrV4, &channel->servers[i].addr.addrV4,
|
123
|
-
sizeof(srvr_curr->addrV4));
|
124
|
-
else
|
125
|
-
memcpy(&srvr_curr->addrV6, &channel->servers[i].addr.addrV6,
|
126
|
-
sizeof(srvr_curr->addrV6));
|
127
|
-
}
|
63
|
+
if (out == NULL) {
|
64
|
+
return NULL;
|
65
|
+
}
|
128
66
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
}
|
67
|
+
for (snode = ares_slist_node_first(channel->servers); snode != NULL;
|
68
|
+
snode = ares_slist_node_next(snode)) {
|
69
|
+
const ares_server_t *server = ares_slist_node_val(snode);
|
70
|
+
|
71
|
+
if (server->addr.family != AF_INET) {
|
72
|
+
continue;
|
136
73
|
}
|
137
74
|
|
138
|
-
|
75
|
+
memcpy(&out[*nservers], &server->addr.addr.addr4, sizeof(*out));
|
76
|
+
(*nservers)++;
|
77
|
+
}
|
139
78
|
|
140
|
-
return
|
79
|
+
return out;
|
141
80
|
}
|
142
81
|
|
143
|
-
|
144
|
-
|
82
|
+
/* Save options from initialized channel */
|
83
|
+
int ares_save_options(const ares_channel_t *channel,
|
84
|
+
struct ares_options *options, int *optmask)
|
145
85
|
{
|
146
|
-
|
147
|
-
int num_srvrs = 0;
|
148
|
-
int i;
|
149
|
-
|
150
|
-
if (ares_library_initialized() != ARES_SUCCESS)
|
151
|
-
return ARES_ENOTINITIALIZED; /* LCOV_EXCL_LINE: n/a on non-WinSock */
|
86
|
+
size_t i;
|
152
87
|
|
153
|
-
|
88
|
+
/* NOTE: We can't zero the whole thing out, this is because the size of the
|
89
|
+
* struct ares_options changes over time, so if someone compiled
|
90
|
+
* with an older version, their struct size might be smaller and
|
91
|
+
* we might overwrite their memory! So using the optmask is critical
|
92
|
+
* here, as they could have only set options they knew about.
|
93
|
+
*
|
94
|
+
* Unfortunately ares_destroy_options() doesn't take an optmask, so
|
95
|
+
* there are a few pointers we *must* zero out otherwise we won't
|
96
|
+
* know if they were allocated or not
|
97
|
+
*/
|
98
|
+
options->servers = NULL;
|
99
|
+
options->domains = NULL;
|
100
|
+
options->sortlist = NULL;
|
101
|
+
options->lookups = NULL;
|
102
|
+
options->resolvconf_path = NULL;
|
103
|
+
options->hosts_path = NULL;
|
104
|
+
|
105
|
+
if (!ARES_CONFIG_CHECK(channel)) {
|
154
106
|
return ARES_ENODATA;
|
107
|
+
}
|
108
|
+
|
109
|
+
if (channel->optmask & ARES_OPT_FLAGS) {
|
110
|
+
options->flags = (int)channel->flags;
|
111
|
+
}
|
112
|
+
|
113
|
+
/* We convert ARES_OPT_TIMEOUT to ARES_OPT_TIMEOUTMS in
|
114
|
+
* ares_init_by_options() */
|
115
|
+
if (channel->optmask & ARES_OPT_TIMEOUTMS) {
|
116
|
+
options->timeout = (int)channel->timeout;
|
117
|
+
}
|
118
|
+
|
119
|
+
if (channel->optmask & ARES_OPT_TRIES) {
|
120
|
+
options->tries = (int)channel->tries;
|
121
|
+
}
|
155
122
|
|
156
|
-
if (
|
157
|
-
|
123
|
+
if (channel->optmask & ARES_OPT_NDOTS) {
|
124
|
+
options->ndots = (int)channel->ndots;
|
125
|
+
}
|
126
|
+
|
127
|
+
if (channel->optmask & ARES_OPT_MAXTIMEOUTMS) {
|
128
|
+
options->maxtimeout = (int)channel->maxtimeout;
|
129
|
+
}
|
158
130
|
|
159
|
-
|
131
|
+
if (channel->optmask & ARES_OPT_UDP_PORT) {
|
132
|
+
options->udp_port = channel->udp_port;
|
133
|
+
}
|
134
|
+
if (channel->optmask & ARES_OPT_TCP_PORT) {
|
135
|
+
options->tcp_port = channel->tcp_port;
|
136
|
+
}
|
160
137
|
|
161
|
-
|
162
|
-
|
163
|
-
|
138
|
+
if (channel->optmask & ARES_OPT_SOCK_STATE_CB) {
|
139
|
+
options->sock_state_cb = channel->sock_state_cb;
|
140
|
+
options->sock_state_cb_data = channel->sock_state_cb_data;
|
141
|
+
}
|
142
|
+
|
143
|
+
if (channel->optmask & ARES_OPT_SERVERS) {
|
144
|
+
options->servers = ares_save_opt_servers(channel, &options->nservers);
|
145
|
+
if (options->servers == NULL) {
|
146
|
+
return ARES_ENOMEM;
|
164
147
|
}
|
148
|
+
}
|
165
149
|
|
166
|
-
if (
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
if (!
|
171
|
-
|
150
|
+
if (channel->optmask & ARES_OPT_DOMAINS) {
|
151
|
+
options->domains = NULL;
|
152
|
+
if (channel->ndomains) {
|
153
|
+
options->domains = ares_malloc(channel->ndomains * sizeof(char *));
|
154
|
+
if (!options->domains) {
|
155
|
+
return ARES_ENOMEM;
|
156
|
+
}
|
157
|
+
|
158
|
+
for (i = 0; i < channel->ndomains; i++) {
|
159
|
+
options->domains[i] = ares_strdup(channel->domains[i]);
|
160
|
+
if (!options->domains[i]) {
|
161
|
+
options->ndomains = (int)i;
|
172
162
|
return ARES_ENOMEM;
|
173
163
|
}
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
164
|
+
}
|
165
|
+
}
|
166
|
+
options->ndomains = (int)channel->ndomains;
|
167
|
+
}
|
168
|
+
|
169
|
+
if (channel->optmask & ARES_OPT_LOOKUPS) {
|
170
|
+
options->lookups = ares_strdup(channel->lookups);
|
171
|
+
if (!options->lookups && channel->lookups) {
|
172
|
+
return ARES_ENOMEM;
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
176
|
+
if (channel->optmask & ARES_OPT_SORTLIST) {
|
177
|
+
options->sortlist = NULL;
|
178
|
+
if (channel->nsort) {
|
179
|
+
options->sortlist = ares_malloc(channel->nsort * sizeof(struct apattern));
|
180
|
+
if (!options->sortlist) {
|
181
|
+
return ARES_ENOMEM;
|
182
|
+
}
|
183
|
+
for (i = 0; i < channel->nsort; i++) {
|
184
|
+
options->sortlist[i] = channel->sortlist[i];
|
185
|
+
}
|
190
186
|
}
|
187
|
+
options->nsort = (int)channel->nsort;
|
188
|
+
}
|
189
|
+
|
190
|
+
if (channel->optmask & ARES_OPT_RESOLVCONF) {
|
191
|
+
options->resolvconf_path = ares_strdup(channel->resolvconf_path);
|
192
|
+
if (!options->resolvconf_path) {
|
193
|
+
return ARES_ENOMEM;
|
194
|
+
}
|
195
|
+
}
|
196
|
+
|
197
|
+
if (channel->optmask & ARES_OPT_HOSTS_FILE) {
|
198
|
+
options->hosts_path = ares_strdup(channel->hosts_path);
|
199
|
+
if (!options->hosts_path) {
|
200
|
+
return ARES_ENOMEM;
|
201
|
+
}
|
202
|
+
}
|
203
|
+
|
204
|
+
if (channel->optmask & ARES_OPT_SOCK_SNDBUF &&
|
205
|
+
channel->socket_send_buffer_size > 0) {
|
206
|
+
options->socket_send_buffer_size = channel->socket_send_buffer_size;
|
207
|
+
}
|
208
|
+
|
209
|
+
if (channel->optmask & ARES_OPT_SOCK_RCVBUF &&
|
210
|
+
channel->socket_receive_buffer_size > 0) {
|
211
|
+
options->socket_receive_buffer_size = channel->socket_receive_buffer_size;
|
212
|
+
}
|
213
|
+
|
214
|
+
if (channel->optmask & ARES_OPT_EDNSPSZ) {
|
215
|
+
options->ednspsz = (int)channel->ednspsz;
|
216
|
+
}
|
217
|
+
|
218
|
+
if (channel->optmask & ARES_OPT_UDP_MAX_QUERIES) {
|
219
|
+
options->udp_max_queries = (int)channel->udp_max_queries;
|
220
|
+
}
|
221
|
+
|
222
|
+
if (channel->optmask & ARES_OPT_QUERY_CACHE) {
|
223
|
+
options->qcache_max_ttl = channel->qcache_max_ttl;
|
224
|
+
}
|
225
|
+
|
226
|
+
if (channel->optmask & ARES_OPT_EVENT_THREAD) {
|
227
|
+
options->evsys = channel->evsys;
|
228
|
+
}
|
229
|
+
|
230
|
+
/* Set options for server failover behavior */
|
231
|
+
if (channel->optmask & ARES_OPT_SERVER_FAILOVER) {
|
232
|
+
options->server_failover_opts.retry_chance = channel->server_retry_chance;
|
233
|
+
options->server_failover_opts.retry_delay = channel->server_retry_delay;
|
234
|
+
}
|
235
|
+
|
236
|
+
*optmask = (int)channel->optmask;
|
191
237
|
|
192
238
|
return ARES_SUCCESS;
|
193
239
|
}
|
194
240
|
|
195
|
-
|
196
|
-
|
241
|
+
static ares_status_t ares_init_options_servers(ares_channel_t *channel,
|
242
|
+
const struct in_addr *servers,
|
243
|
+
size_t nservers)
|
197
244
|
{
|
198
|
-
|
199
|
-
|
200
|
-
int i;
|
245
|
+
ares_llist_t *slist = NULL;
|
246
|
+
ares_status_t status;
|
201
247
|
|
202
|
-
|
203
|
-
|
248
|
+
status = ares_in_addr_to_sconfig_llist(servers, nservers, &slist);
|
249
|
+
if (status != ARES_SUCCESS) {
|
250
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
251
|
+
}
|
204
252
|
|
205
|
-
|
206
|
-
return ARES_ENODATA;
|
253
|
+
status = ares_servers_update(channel, slist, ARES_TRUE);
|
207
254
|
|
208
|
-
|
209
|
-
return ARES_ENOTIMP;
|
255
|
+
ares_llist_destroy(slist);
|
210
256
|
|
211
|
-
|
257
|
+
return status;
|
258
|
+
}
|
259
|
+
|
260
|
+
ares_status_t ares_init_by_options(ares_channel_t *channel,
|
261
|
+
const struct ares_options *options,
|
262
|
+
int optmask)
|
263
|
+
{
|
264
|
+
size_t i;
|
265
|
+
|
266
|
+
if (channel == NULL) {
|
267
|
+
return ARES_ENODATA; /* LCOV_EXCL_LINE: DefensiveCoding */
|
268
|
+
}
|
212
269
|
|
213
|
-
|
214
|
-
{
|
215
|
-
|
270
|
+
if (options == NULL) {
|
271
|
+
if (optmask != 0) {
|
272
|
+
return ARES_ENODATA; /* LCOV_EXCL_LINE: DefensiveCoding */
|
216
273
|
}
|
274
|
+
return ARES_SUCCESS;
|
275
|
+
}
|
217
276
|
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
}
|
226
|
-
channel->nservers = num_srvrs;
|
227
|
-
/* Fill servers state address data */
|
228
|
-
for (i = 0, srvr = servers; srvr; i++, srvr = srvr->next)
|
229
|
-
{
|
230
|
-
channel->servers[i].addr.family = srvr->family;
|
231
|
-
channel->servers[i].addr.udp_port = htons((unsigned short)srvr->udp_port);
|
232
|
-
channel->servers[i].addr.tcp_port = htons((unsigned short)srvr->tcp_port);
|
233
|
-
if (srvr->family == AF_INET)
|
234
|
-
memcpy(&channel->servers[i].addr.addrV4, &srvr->addrV4,
|
235
|
-
sizeof(srvr->addrV4));
|
236
|
-
else
|
237
|
-
memcpy(&channel->servers[i].addr.addrV6, &srvr->addrV6,
|
238
|
-
sizeof(srvr->addrV6));
|
239
|
-
}
|
240
|
-
/* Initialize servers state remaining data */
|
241
|
-
ares__init_servers_state(channel);
|
277
|
+
/* Easy stuff. */
|
278
|
+
|
279
|
+
/* Event Thread requires threading support and is incompatible with socket
|
280
|
+
* state callbacks */
|
281
|
+
if (optmask & ARES_OPT_EVENT_THREAD) {
|
282
|
+
if (!ares_threadsafety()) {
|
283
|
+
return ARES_ENOTIMP;
|
242
284
|
}
|
285
|
+
if (optmask & ARES_OPT_SOCK_STATE_CB) {
|
286
|
+
return ARES_EFORMERR;
|
287
|
+
}
|
288
|
+
channel->evsys = options->evsys;
|
289
|
+
}
|
243
290
|
|
244
|
-
|
245
|
-
|
291
|
+
if (optmask & ARES_OPT_FLAGS) {
|
292
|
+
channel->flags = (unsigned int)options->flags;
|
293
|
+
}
|
246
294
|
|
247
|
-
|
248
|
-
/*
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
295
|
+
if (optmask & ARES_OPT_TIMEOUTMS) {
|
296
|
+
/* Apparently some integrations were passing -1 to tell c-ares to use
|
297
|
+
* the default instead of just omitting the optmask */
|
298
|
+
if (options->timeout <= 0) {
|
299
|
+
optmask &= ~(ARES_OPT_TIMEOUTMS);
|
300
|
+
} else {
|
301
|
+
channel->timeout = (unsigned int)options->timeout;
|
302
|
+
}
|
303
|
+
} else if (optmask & ARES_OPT_TIMEOUT) {
|
304
|
+
optmask &= ~(ARES_OPT_TIMEOUT);
|
305
|
+
/* Apparently some integrations were passing -1 to tell c-ares to use
|
306
|
+
* the default instead of just omitting the optmask */
|
307
|
+
if (options->timeout > 0) {
|
308
|
+
/* Convert to milliseconds */
|
309
|
+
optmask |= ARES_OPT_TIMEOUTMS;
|
310
|
+
channel->timeout = (unsigned int)options->timeout * 1000;
|
311
|
+
}
|
312
|
+
}
|
313
|
+
|
314
|
+
if (optmask & ARES_OPT_TRIES) {
|
315
|
+
if (options->tries <= 0) {
|
316
|
+
optmask &= ~(ARES_OPT_TRIES);
|
317
|
+
} else {
|
318
|
+
channel->tries = (size_t)options->tries;
|
319
|
+
}
|
320
|
+
}
|
321
|
+
|
322
|
+
if (optmask & ARES_OPT_NDOTS) {
|
323
|
+
if (options->ndots < 0) {
|
324
|
+
optmask &= ~(ARES_OPT_NDOTS);
|
325
|
+
} else {
|
326
|
+
channel->ndots = (size_t)options->ndots;
|
327
|
+
}
|
328
|
+
}
|
329
|
+
|
330
|
+
if (optmask & ARES_OPT_MAXTIMEOUTMS) {
|
331
|
+
if (options->maxtimeout <= 0) {
|
332
|
+
optmask &= ~(ARES_OPT_MAXTIMEOUTMS);
|
333
|
+
} else {
|
334
|
+
channel->maxtimeout = (size_t)options->maxtimeout;
|
335
|
+
}
|
336
|
+
}
|
337
|
+
|
338
|
+
if (optmask & ARES_OPT_ROTATE) {
|
339
|
+
channel->rotate = ARES_TRUE;
|
340
|
+
}
|
341
|
+
|
342
|
+
if (optmask & ARES_OPT_NOROTATE) {
|
343
|
+
channel->rotate = ARES_FALSE;
|
344
|
+
}
|
345
|
+
|
346
|
+
if (optmask & ARES_OPT_UDP_PORT) {
|
347
|
+
channel->udp_port = options->udp_port;
|
348
|
+
}
|
266
349
|
|
267
|
-
|
268
|
-
|
269
|
-
|
350
|
+
if (optmask & ARES_OPT_TCP_PORT) {
|
351
|
+
channel->tcp_port = options->tcp_port;
|
352
|
+
}
|
270
353
|
|
271
|
-
|
272
|
-
|
273
|
-
|
354
|
+
if (optmask & ARES_OPT_SOCK_STATE_CB) {
|
355
|
+
channel->sock_state_cb = options->sock_state_cb;
|
356
|
+
channel->sock_state_cb_data = options->sock_state_cb_data;
|
357
|
+
}
|
274
358
|
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
359
|
+
if (optmask & ARES_OPT_SOCK_SNDBUF) {
|
360
|
+
if (options->socket_send_buffer_size <= 0) {
|
361
|
+
optmask &= ~(ARES_OPT_SOCK_SNDBUF);
|
362
|
+
} else {
|
363
|
+
channel->socket_send_buffer_size = options->socket_send_buffer_size;
|
364
|
+
}
|
279
365
|
}
|
280
366
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
cc++;
|
367
|
+
if (optmask & ARES_OPT_SOCK_RCVBUF) {
|
368
|
+
if (options->socket_receive_buffer_size <= 0) {
|
369
|
+
optmask &= ~(ARES_OPT_SOCK_RCVBUF);
|
370
|
+
} else {
|
371
|
+
channel->socket_receive_buffer_size = options->socket_receive_buffer_size;
|
287
372
|
}
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
373
|
+
}
|
374
|
+
|
375
|
+
if (optmask & ARES_OPT_EDNSPSZ) {
|
376
|
+
if (options->ednspsz <= 0) {
|
377
|
+
optmask &= ~(ARES_OPT_EDNSPSZ);
|
378
|
+
} else {
|
379
|
+
channel->ednspsz = (size_t)options->ednspsz;
|
292
380
|
}
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
/* a single colon, ':' indicates an IPv4 address with port */
|
310
|
-
if ((*pp == ':') && (cc == 1))
|
311
|
-
break; /* found port */
|
312
|
-
if (!(ISDIGIT(*pp) || (*pp == ':'))) {
|
313
|
-
/* Found end of digits before we found :, so wasn't a port */
|
314
|
-
/* must allow ':' for IPv6 case of ']:' indicates we found a port */
|
315
|
-
pp = p = ptr;
|
316
|
-
break;
|
317
|
-
}
|
318
|
-
pp--;
|
319
|
-
p--;
|
320
|
-
}
|
321
|
-
if ((pp != start_host) && ((pp + 1) < ptr)) {
|
322
|
-
/* Found it. Parse over the port number */
|
323
|
-
/* when an IPv6 address is wrapped with square brackets the port
|
324
|
-
starts at pp + 2 */
|
325
|
-
if (*pp == ']')
|
326
|
-
p++; /* move p before ':' */
|
327
|
-
/* p will point to the start of the port */
|
328
|
-
port = (int)strtol(p, NULL, 10);
|
329
|
-
*pp = 0; /* null terminate host */
|
330
|
-
}
|
381
|
+
}
|
382
|
+
|
383
|
+
/* Copy the domains, if given. Keep channel->ndomains consistent so
|
384
|
+
* we can clean up in case of error.
|
385
|
+
*/
|
386
|
+
if (optmask & ARES_OPT_DOMAINS && options->ndomains > 0) {
|
387
|
+
channel->domains =
|
388
|
+
ares_malloc_zero((size_t)options->ndomains * sizeof(char *));
|
389
|
+
if (!channel->domains) {
|
390
|
+
return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
391
|
+
}
|
392
|
+
channel->ndomains = (size_t)options->ndomains;
|
393
|
+
for (i = 0; i < (size_t)options->ndomains; i++) {
|
394
|
+
channel->domains[i] = ares_strdup(options->domains[i]);
|
395
|
+
if (!channel->domains[i]) {
|
396
|
+
return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
331
397
|
}
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
if (!s) {
|
344
|
-
rv = ARES_ENOMEM;
|
345
|
-
goto out;
|
346
|
-
}
|
347
|
-
s->family = AF_INET6;
|
348
|
-
memcpy(&s->addr, &in6, sizeof(struct ares_in6_addr));
|
398
|
+
}
|
399
|
+
}
|
400
|
+
|
401
|
+
/* Set lookups, if given. */
|
402
|
+
if (optmask & ARES_OPT_LOOKUPS) {
|
403
|
+
if (options->lookups == NULL) {
|
404
|
+
optmask &= ~(ARES_OPT_LOOKUPS);
|
405
|
+
} else {
|
406
|
+
channel->lookups = ares_strdup(options->lookups);
|
407
|
+
if (!channel->lookups) {
|
408
|
+
return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
349
409
|
}
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
410
|
+
}
|
411
|
+
}
|
412
|
+
|
413
|
+
/* copy sortlist */
|
414
|
+
if (optmask & ARES_OPT_SORTLIST && options->nsort > 0) {
|
415
|
+
channel->nsort = (size_t)options->nsort;
|
416
|
+
channel->sortlist =
|
417
|
+
ares_malloc((size_t)options->nsort * sizeof(struct apattern));
|
418
|
+
if (!channel->sortlist) {
|
419
|
+
return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
420
|
+
}
|
421
|
+
for (i = 0; i < (size_t)options->nsort; i++) {
|
422
|
+
channel->sortlist[i] = options->sortlist[i];
|
423
|
+
}
|
424
|
+
}
|
425
|
+
|
426
|
+
/* Set path for resolv.conf file, if given. */
|
427
|
+
if (optmask & ARES_OPT_RESOLVCONF) {
|
428
|
+
if (options->resolvconf_path == NULL) {
|
429
|
+
optmask &= ~(ARES_OPT_RESOLVCONF);
|
430
|
+
} else {
|
431
|
+
channel->resolvconf_path = ares_strdup(options->resolvconf_path);
|
432
|
+
if (channel->resolvconf_path == NULL) {
|
433
|
+
return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
359
434
|
}
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
last = s;
|
372
|
-
}
|
435
|
+
}
|
436
|
+
}
|
437
|
+
|
438
|
+
/* Set path for hosts file, if given. */
|
439
|
+
if (optmask & ARES_OPT_HOSTS_FILE) {
|
440
|
+
if (options->hosts_path == NULL) {
|
441
|
+
optmask &= ~(ARES_OPT_HOSTS_FILE);
|
442
|
+
} else {
|
443
|
+
channel->hosts_path = ares_strdup(options->hosts_path);
|
444
|
+
if (channel->hosts_path == NULL) {
|
445
|
+
return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
373
446
|
}
|
447
|
+
}
|
448
|
+
}
|
374
449
|
|
375
|
-
|
376
|
-
|
377
|
-
|
450
|
+
if (optmask & ARES_OPT_UDP_MAX_QUERIES) {
|
451
|
+
if (options->udp_max_queries <= 0) {
|
452
|
+
optmask &= ~(ARES_OPT_UDP_MAX_QUERIES);
|
453
|
+
} else {
|
454
|
+
channel->udp_max_queries = (size_t)options->udp_max_queries;
|
378
455
|
}
|
379
456
|
}
|
380
457
|
|
381
|
-
|
458
|
+
/* As of c-ares 1.31.0, the Query Cache is on by default. The only way to
|
459
|
+
* disable it is to set options->qcache_max_ttl = 0 while specifying the
|
460
|
+
* ARES_OPT_QUERY_CACHE which will actually disable it completely. */
|
461
|
+
if (optmask & ARES_OPT_QUERY_CACHE) {
|
462
|
+
/* qcache_max_ttl is unsigned unlike the others */
|
463
|
+
channel->qcache_max_ttl = options->qcache_max_ttl;
|
464
|
+
} else {
|
465
|
+
optmask |= ARES_OPT_QUERY_CACHE;
|
466
|
+
channel->qcache_max_ttl = 3600;
|
467
|
+
}
|
382
468
|
|
383
|
-
|
384
|
-
if (
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
469
|
+
/* Initialize the ipv4 servers if provided */
|
470
|
+
if (optmask & ARES_OPT_SERVERS) {
|
471
|
+
if (options->nservers <= 0) {
|
472
|
+
optmask &= ~(ARES_OPT_SERVERS);
|
473
|
+
} else {
|
474
|
+
ares_status_t status;
|
475
|
+
status = ares_init_options_servers(channel, options->servers,
|
476
|
+
(size_t)options->nservers);
|
477
|
+
if (status != ARES_SUCCESS) {
|
478
|
+
return status; /* LCOV_EXCL_LINE: OutOfMemory */
|
479
|
+
}
|
480
|
+
}
|
390
481
|
}
|
391
482
|
|
392
|
-
|
393
|
-
|
483
|
+
/* Set fields for server failover behavior */
|
484
|
+
if (optmask & ARES_OPT_SERVER_FAILOVER) {
|
485
|
+
channel->server_retry_chance = options->server_failover_opts.retry_chance;
|
486
|
+
channel->server_retry_delay = options->server_failover_opts.retry_delay;
|
487
|
+
}
|
394
488
|
|
395
|
-
|
396
|
-
const char* _csv)
|
397
|
-
{
|
398
|
-
return set_servers_csv(channel, _csv, FALSE);
|
399
|
-
}
|
489
|
+
channel->optmask = (unsigned int)optmask;
|
400
490
|
|
401
|
-
|
402
|
-
const char* _csv)
|
403
|
-
{
|
404
|
-
return set_servers_csv(channel, _csv, TRUE);
|
491
|
+
return ARES_SUCCESS;
|
405
492
|
}
|
406
|
-
|