grpc 1.74.1 → 1.75.0.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Makefile +83 -41
- data/include/grpc/credentials.h +7 -1
- data/src/core/call/client_call.cc +4 -4
- data/src/core/call/filter_fusion.h +1230 -0
- data/src/core/call/metadata.cc +22 -0
- data/src/core/call/metadata.h +24 -2
- data/src/core/channelz/channelz.cc +10 -17
- data/src/core/channelz/channelz.h +58 -19
- data/src/core/channelz/channelz_registry.cc +0 -162
- data/src/core/channelz/channelz_registry.h +14 -7
- data/src/core/channelz/property_list.cc +19 -23
- data/src/core/channelz/property_list.h +3 -1
- data/src/core/channelz/v2tov1/convert.cc +683 -0
- data/src/core/channelz/v2tov1/convert.h +58 -0
- data/src/core/channelz/v2tov1/legacy_api.cc +425 -0
- data/src/core/channelz/v2tov1/legacy_api.h +32 -0
- data/src/core/channelz/v2tov1/property_list.cc +118 -0
- data/src/core/channelz/v2tov1/property_list.h +52 -0
- data/src/core/client_channel/client_channel_filter.cc +5 -4
- data/src/core/client_channel/client_channel_filter.h +2 -2
- data/src/core/client_channel/client_channel_internal.h +2 -1
- data/src/core/client_channel/load_balanced_call_destination.cc +6 -5
- data/src/core/client_channel/subchannel.cc +14 -6
- data/src/core/client_channel/subchannel.h +2 -0
- data/src/core/config/core_configuration.cc +3 -1
- data/src/core/config/core_configuration.h +12 -0
- data/src/core/credentials/transport/alts/alts_credentials.cc +5 -0
- data/src/core/credentials/transport/alts/check_gcp_environment_windows.cc +2 -0
- data/src/core/credentials/transport/channel_creds_registry_init.cc +3 -1
- data/src/core/credentials/transport/ssl/ssl_credentials.cc +1 -1
- data/src/core/credentials/transport/ssl/ssl_security_connector.cc +8 -3
- data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc +29 -24
- data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h +19 -8
- data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc +96 -54
- data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.h +15 -2
- data/src/core/credentials/transport/tls/spiffe_utils.cc +371 -0
- data/src/core/credentials/transport/tls/spiffe_utils.h +171 -0
- data/src/core/credentials/transport/tls/ssl_utils.cc +11 -10
- data/src/core/credentials/transport/tls/ssl_utils.h +4 -2
- data/src/core/credentials/transport/tls/tls_credentials.cc +2 -0
- data/src/core/credentials/transport/tls/tls_security_connector.cc +11 -26
- data/src/core/credentials/transport/tls/tls_security_connector.h +12 -12
- data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +1 -2
- data/src/core/ext/filters/http/client/http_client_filter.cc +3 -6
- data/src/core/ext/filters/http/client_authority_filter.cc +1 -2
- data/src/core/ext/filters/http/message_compress/compression_filter.cc +8 -8
- data/src/core/ext/filters/http/server/http_server_filter.cc +3 -6
- data/src/core/ext/filters/message_size/message_size_filter.cc +4 -4
- data/src/core/ext/filters/rbac/rbac_filter.cc +1 -1
- data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +3 -5
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +3 -2
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -0
- data/src/core/ext/transport/chttp2/transport/frame.cc +89 -6
- data/src/core/ext/transport/chttp2/transport/frame.h +38 -0
- data/src/core/ext/transport/chttp2/transport/header_assembler.h +5 -14
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +4 -1
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +294 -78
- data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +128 -9
- data/src/core/ext/transport/chttp2/transport/http2_settings.cc +11 -38
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +52 -35
- data/src/core/ext/transport/chttp2/transport/http2_settings_manager.cc +61 -0
- data/src/core/ext/transport/chttp2/transport/http2_settings_manager.h +142 -0
- data/src/core/ext/transport/chttp2/transport/http2_transport.cc +81 -3
- data/src/core/ext/transport/chttp2/transport/http2_transport.h +12 -1
- data/src/core/ext/transport/chttp2/transport/message_assembler.h +2 -2
- data/src/core/ext/transport/chttp2/transport/parsing.cc +2 -1
- data/src/core/ext/transport/chttp2/transport/ping_promise.cc +2 -1
- data/src/core/ext/transport/chttp2/transport/ping_promise.h +22 -5
- data/src/core/ext/transport/chttp2/transport/stream_data_queue.h +607 -0
- data/src/core/ext/transport/chttp2/transport/writable_streams.h +254 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +6 -4
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb.h +4959 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb_minitable.c +1111 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb_minitable.h +108 -0
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb.h +142 -54
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.c +18 -14
- data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.h +2 -2
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/channelz.upbdefs.c +716 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/channelz.upbdefs.h +227 -0
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.c +86 -88
- data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.h +2 -2
- data/src/core/filter/auth/auth_filters.h +2 -2
- data/src/core/filter/fused_filters.cc +154 -0
- data/src/core/handshaker/security/legacy_secure_endpoint.cc +1 -1
- data/src/core/handshaker/security/pipelined_secure_endpoint.cc +965 -0
- data/src/core/handshaker/security/secure_endpoint.cc +28 -13
- data/src/core/handshaker/security/secure_endpoint.h +8 -0
- data/src/core/lib/channel/promise_based_filter.cc +15 -25
- data/src/core/lib/channel/promise_based_filter.h +6 -5
- data/src/core/lib/event_engine/ares_resolver.h +3 -1
- data/src/core/lib/event_engine/cf_engine/cf_engine.cc +9 -5
- data/src/core/lib/event_engine/cf_engine/cf_engine.h +2 -1
- data/src/core/lib/event_engine/cf_engine/cfsocket_listener.cc +263 -0
- data/src/core/lib/event_engine/cf_engine/cfsocket_listener.h +107 -0
- data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +31 -3
- data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +12 -0
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +12 -10
- data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h +6 -4
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +15 -14
- data/src/core/lib/event_engine/posix_engine/ev_poll_posix.h +7 -5
- data/src/core/lib/event_engine/posix_engine/event_poller.h +0 -8
- data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc +11 -5
- data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.h +3 -2
- data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +1 -0
- data/src/core/lib/event_engine/posix_engine/lockfree_event.cc +4 -4
- data/src/core/lib/event_engine/posix_engine/lockfree_event.h +3 -4
- data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +2 -2
- data/src/core/lib/event_engine/posix_engine/posix_engine.cc +188 -199
- data/src/core/lib/event_engine/posix_engine/posix_engine.h +30 -45
- data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +1 -1
- data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +1 -1
- data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc +2 -1
- data/src/core/lib/experiments/experiments.cc +120 -6
- data/src/core/lib/experiments/experiments.h +46 -3
- data/src/core/lib/iomgr/combiner.cc +1 -1
- data/src/core/lib/iomgr/exec_ctx.h +3 -9
- data/src/core/lib/iomgr/socket_mutator.cc +1 -1
- data/src/core/lib/iomgr/socket_utils_posix.cc +1 -1
- data/src/core/lib/iomgr/socket_utils_posix.h +1 -1
- data/src/core/lib/iomgr/tcp_client_posix.cc +1 -1
- data/src/core/lib/iomgr/tcp_posix.cc +3 -3
- data/src/core/lib/promise/activity.h +2 -2
- data/src/core/lib/promise/mpsc.cc +8 -8
- data/src/core/lib/promise/party.cc +7 -7
- data/src/core/lib/promise/party.h +4 -4
- data/src/core/lib/promise/poll.h +10 -0
- data/src/core/lib/resource_quota/memory_quota.cc +90 -3
- data/src/core/lib/resource_quota/memory_quota.h +20 -9
- data/src/core/lib/resource_quota/periodic_update.cc +14 -0
- data/src/core/lib/resource_quota/periodic_update.h +8 -0
- data/src/core/lib/resource_quota/resource_quota.cc +15 -4
- data/src/core/lib/resource_quota/resource_quota.h +3 -0
- data/src/core/lib/security/authorization/grpc_server_authz_filter.cc +1 -2
- data/src/core/lib/surface/call.cc +5 -5
- data/src/core/lib/surface/call.h +6 -5
- data/src/core/lib/surface/completion_queue.cc +2 -4
- data/src/core/lib/surface/filter_stack_call.cc +1 -1
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/promise_endpoint.cc +2 -2
- data/src/core/lib/transport/promise_endpoint.h +3 -3
- data/src/core/load_balancing/endpoint_list.cc +29 -2
- data/src/core/load_balancing/grpclb/client_load_reporting_filter.cc +3 -3
- data/src/core/load_balancing/grpclb/client_load_reporting_filter.h +1 -1
- data/src/core/load_balancing/pick_first/pick_first.cc +12 -5
- data/src/core/load_balancing/xds/xds_cluster_impl.cc +5 -3
- data/src/core/net/socket_mutator.cc +19 -0
- data/src/core/net/socket_mutator.h +25 -0
- data/src/core/plugin_registry/grpc_plugin_registry.cc +6 -0
- data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h +6 -1
- data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +2 -1
- data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc +8 -5
- data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h +2 -1
- data/src/core/resolver/xds/xds_dependency_manager.cc +1 -1
- data/src/core/server/server.cc +1 -1
- data/src/core/server/server_call_tracer_filter.cc +0 -66
- data/src/core/server/server_call_tracer_filter.h +64 -0
- data/src/core/server/server_config_selector_filter.cc +1 -1
- data/src/core/service_config/service_config_channel_arg_filter.cc +3 -60
- data/src/core/service_config/service_config_channel_arg_filter.h +82 -0
- data/src/core/telemetry/call_tracer.cc +20 -14
- data/src/core/telemetry/call_tracer.h +22 -17
- data/src/core/telemetry/metrics.h +8 -8
- data/src/core/telemetry/stats_data.cc +151 -151
- data/src/core/telemetry/stats_data.h +87 -87
- data/src/core/transport/auth_context.cc +20 -0
- data/src/core/transport/auth_context.h +4 -0
- data/src/core/transport/auth_context_comparator_registry.h +69 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +2 -3
- data/src/core/tsi/ssl_transport_security.cc +202 -32
- data/src/core/tsi/ssl_transport_security.h +19 -10
- data/src/core/tsi/ssl_transport_security_utils.cc +21 -0
- data/src/core/tsi/ssl_transport_security_utils.h +4 -0
- data/src/core/util/http_client/httpcli_security_connector.cc +3 -1
- data/src/core/util/latent_see.cc +178 -146
- data/src/core/util/latent_see.h +245 -188
- data/src/core/util/single_set_ptr.h +5 -2
- data/src/core/util/useful.h +91 -0
- data/src/core/util/windows/directory_reader.cc +1 -0
- data/src/core/util/windows/thd.cc +1 -3
- data/src/core/util/work_serializer.cc +1 -1
- data/src/core/xds/grpc/file_watcher_certificate_provider_factory.cc +32 -5
- data/src/core/xds/grpc/file_watcher_certificate_provider_factory.h +5 -0
- data/src/core/xds/grpc/xds_certificate_provider.cc +5 -6
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/cares/cares/include/ares.h +925 -460
- data/third_party/cares/cares/include/ares_dns.h +86 -71
- data/third_party/cares/cares/include/ares_dns_record.h +1118 -0
- data/third_party/cares/cares/include/ares_nameser.h +215 -189
- data/third_party/cares/cares/include/ares_version.h +37 -14
- data/third_party/cares/cares/src/lib/ares_addrinfo2hostent.c +305 -0
- data/third_party/cares/cares/src/lib/ares_addrinfo_localhost.c +245 -0
- data/third_party/cares/cares/src/lib/ares_android.c +216 -164
- data/third_party/cares/cares/src/lib/ares_android.h +25 -14
- data/third_party/cares/cares/src/lib/ares_cancel.c +68 -44
- data/third_party/cares/cares/src/lib/ares_close_sockets.c +137 -0
- data/third_party/cares/cares/src/lib/ares_conn.c +511 -0
- data/third_party/cares/cares/src/lib/ares_conn.h +196 -0
- data/third_party/cares/cares/src/lib/ares_cookie.c +461 -0
- data/third_party/cares/cares/src/lib/ares_data.c +93 -181
- data/third_party/cares/cares/src/lib/ares_data.h +50 -39
- data/third_party/cares/cares/src/lib/ares_destroy.c +127 -89
- data/third_party/cares/cares/src/lib/ares_free_hostent.c +35 -24
- data/third_party/cares/cares/src/lib/ares_free_string.c +24 -16
- data/third_party/cares/cares/src/lib/ares_freeaddrinfo.c +45 -38
- data/third_party/cares/cares/src/lib/ares_getaddrinfo.c +549 -663
- data/third_party/cares/cares/src/lib/ares_getenv.c +25 -15
- data/third_party/cares/cares/src/lib/ares_getenv.h +26 -18
- data/third_party/cares/cares/src/lib/ares_gethostbyaddr.c +163 -221
- data/third_party/cares/cares/src/lib/ares_gethostbyname.c +222 -223
- data/third_party/cares/cares/src/lib/ares_getnameinfo.c +328 -338
- data/third_party/cares/cares/src/lib/ares_hosts_file.c +952 -0
- data/third_party/cares/cares/src/lib/ares_inet_net_pton.h +25 -19
- data/third_party/cares/cares/src/lib/ares_init.c +425 -2091
- data/third_party/cares/cares/src/lib/ares_ipv6.h +63 -33
- data/third_party/cares/cares/src/lib/ares_library_init.c +110 -54
- data/third_party/cares/cares/src/lib/ares_metrics.c +261 -0
- data/third_party/cares/cares/src/lib/ares_options.c +418 -332
- data/third_party/cares/cares/src/lib/ares_parse_into_addrinfo.c +179 -0
- data/third_party/cares/cares/src/lib/ares_private.h +558 -356
- data/third_party/cares/cares/src/lib/ares_process.c +1224 -1369
- data/third_party/cares/cares/src/lib/ares_qcache.c +430 -0
- data/third_party/cares/cares/src/lib/ares_query.c +126 -121
- data/third_party/cares/cares/src/lib/ares_search.c +564 -262
- data/third_party/cares/cares/src/lib/ares_send.c +264 -93
- data/third_party/cares/cares/src/lib/ares_set_socket_functions.c +588 -0
- data/third_party/cares/cares/src/lib/ares_setup.h +115 -111
- data/third_party/cares/cares/src/lib/ares_socket.c +425 -0
- data/third_party/cares/cares/src/lib/ares_socket.h +163 -0
- data/third_party/cares/cares/src/lib/ares_sortaddrinfo.c +447 -0
- data/third_party/cares/cares/src/lib/ares_strerror.c +83 -48
- data/third_party/cares/cares/src/lib/ares_sysconfig.c +639 -0
- data/third_party/cares/cares/src/lib/ares_sysconfig_files.c +839 -0
- data/third_party/cares/cares/src/lib/ares_sysconfig_mac.c +373 -0
- data/third_party/cares/cares/src/lib/ares_sysconfig_win.c +621 -0
- data/third_party/cares/cares/src/lib/ares_timeout.c +136 -73
- data/third_party/cares/cares/src/lib/ares_update_servers.c +1362 -0
- data/third_party/cares/cares/src/lib/ares_version.c +29 -4
- data/third_party/cares/cares/src/lib/config-dos.h +88 -89
- data/third_party/cares/cares/src/lib/config-win32.h +122 -77
- data/third_party/cares/cares/src/lib/dsa/ares_array.c +394 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable.c +447 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable.h +174 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_asvp.c +224 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_dict.c +228 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_strvp.c +210 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_szvp.c +188 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_vpstr.c +186 -0
- data/third_party/cares/cares/src/lib/dsa/ares_htable_vpvp.c +194 -0
- data/third_party/cares/cares/src/lib/dsa/ares_llist.c +382 -0
- data/third_party/cares/cares/src/lib/dsa/ares_slist.c +479 -0
- data/third_party/cares/cares/src/lib/dsa/ares_slist.h +207 -0
- data/third_party/cares/cares/src/lib/event/ares_event.h +191 -0
- data/third_party/cares/cares/src/lib/event/ares_event_configchg.c +743 -0
- data/third_party/cares/cares/src/lib/event/ares_event_epoll.c +192 -0
- data/third_party/cares/cares/src/lib/event/ares_event_kqueue.c +248 -0
- data/third_party/cares/cares/src/lib/event/ares_event_poll.c +140 -0
- data/third_party/cares/cares/src/lib/event/ares_event_select.c +159 -0
- data/third_party/cares/cares/src/lib/event/ares_event_thread.c +567 -0
- data/third_party/cares/cares/src/lib/event/ares_event_wake_pipe.c +166 -0
- data/third_party/cares/cares/src/lib/event/ares_event_win32.c +978 -0
- data/third_party/cares/cares/src/lib/event/ares_event_win32.h +161 -0
- data/third_party/cares/cares/src/lib/include/ares_array.h +276 -0
- data/third_party/cares/cares/src/lib/include/ares_buf.h +732 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_asvp.h +130 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_dict.h +123 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_strvp.h +130 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_szvp.h +118 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_vpstr.h +111 -0
- data/third_party/cares/cares/src/lib/include/ares_htable_vpvp.h +128 -0
- data/third_party/cares/cares/src/lib/include/ares_llist.h +239 -0
- data/third_party/cares/cares/src/lib/include/ares_mem.h +38 -0
- data/third_party/cares/cares/src/lib/include/ares_str.h +244 -0
- data/third_party/cares/cares/src/lib/inet_net_pton.c +202 -157
- data/third_party/cares/cares/src/lib/inet_ntop.c +87 -69
- data/third_party/cares/cares/src/lib/legacy/ares_create_query.c +78 -0
- data/third_party/cares/cares/src/lib/legacy/ares_expand_name.c +99 -0
- data/third_party/cares/cares/src/lib/legacy/ares_expand_string.c +107 -0
- data/third_party/cares/cares/src/lib/legacy/ares_fds.c +80 -0
- data/third_party/cares/cares/src/lib/legacy/ares_getsock.c +85 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_a_reply.c +107 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_aaaa_reply.c +109 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_caa_reply.c +137 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_mx_reply.c +110 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_naptr_reply.c +132 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_ns_reply.c +154 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_ptr_reply.c +213 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_soa_reply.c +115 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_srv_reply.c +114 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_txt_reply.c +144 -0
- data/third_party/cares/cares/src/lib/legacy/ares_parse_uri_reply.c +113 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_mapping.c +982 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_multistring.c +307 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_multistring.h +72 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_name.c +673 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_parse.c +1329 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_private.h +273 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_record.c +1661 -0
- data/third_party/cares/cares/src/lib/record/ares_dns_write.c +1229 -0
- data/third_party/cares/cares/src/lib/str/ares_buf.c +1498 -0
- data/third_party/cares/cares/src/lib/str/ares_str.c +508 -0
- data/third_party/cares/cares/src/lib/str/ares_strsplit.c +90 -0
- data/third_party/cares/cares/src/lib/str/ares_strsplit.h +51 -0
- data/third_party/cares/cares/src/lib/thirdparty/apple/dnsinfo.h +122 -0
- data/third_party/cares/cares/src/lib/util/ares_iface_ips.c +628 -0
- data/third_party/cares/cares/src/lib/util/ares_iface_ips.h +139 -0
- data/third_party/cares/cares/src/lib/util/ares_math.c +158 -0
- data/third_party/cares/cares/src/lib/util/ares_math.h +45 -0
- data/third_party/cares/cares/src/lib/util/ares_rand.c +389 -0
- data/third_party/cares/cares/src/lib/util/ares_rand.h +36 -0
- data/third_party/cares/cares/src/lib/util/ares_threads.c +614 -0
- data/third_party/cares/cares/src/lib/util/ares_threads.h +60 -0
- data/third_party/cares/cares/src/lib/util/ares_time.h +48 -0
- data/third_party/cares/cares/src/lib/util/ares_timeval.c +95 -0
- data/third_party/cares/cares/src/lib/util/ares_uri.c +1626 -0
- data/third_party/cares/cares/src/lib/util/ares_uri.h +252 -0
- data/third_party/cares/cares/src/lib/windows_port.c +16 -9
- metadata +121 -49
- data/src/core/util/ring_buffer.h +0 -122
- data/third_party/cares/cares/include/ares_rules.h +0 -125
- data/third_party/cares/cares/src/lib/ares__addrinfo2hostent.c +0 -266
- data/third_party/cares/cares/src/lib/ares__addrinfo_localhost.c +0 -240
- data/third_party/cares/cares/src/lib/ares__close_sockets.c +0 -61
- data/third_party/cares/cares/src/lib/ares__get_hostent.c +0 -260
- data/third_party/cares/cares/src/lib/ares__parse_into_addrinfo.c +0 -229
- data/third_party/cares/cares/src/lib/ares__read_line.c +0 -73
- data/third_party/cares/cares/src/lib/ares__readaddrinfo.c +0 -258
- data/third_party/cares/cares/src/lib/ares__sortaddrinfo.c +0 -507
- data/third_party/cares/cares/src/lib/ares__timeval.c +0 -111
- data/third_party/cares/cares/src/lib/ares_create_query.c +0 -197
- data/third_party/cares/cares/src/lib/ares_expand_name.c +0 -311
- data/third_party/cares/cares/src/lib/ares_expand_string.c +0 -67
- data/third_party/cares/cares/src/lib/ares_fds.c +0 -59
- data/third_party/cares/cares/src/lib/ares_getsock.c +0 -66
- data/third_party/cares/cares/src/lib/ares_iphlpapi.h +0 -221
- data/third_party/cares/cares/src/lib/ares_llist.c +0 -63
- data/third_party/cares/cares/src/lib/ares_llist.h +0 -39
- data/third_party/cares/cares/src/lib/ares_mkquery.c +0 -24
- data/third_party/cares/cares/src/lib/ares_nowarn.c +0 -260
- data/third_party/cares/cares/src/lib/ares_nowarn.h +0 -61
- data/third_party/cares/cares/src/lib/ares_parse_a_reply.c +0 -90
- data/third_party/cares/cares/src/lib/ares_parse_aaaa_reply.c +0 -92
- data/third_party/cares/cares/src/lib/ares_parse_caa_reply.c +0 -199
- data/third_party/cares/cares/src/lib/ares_parse_mx_reply.c +0 -164
- data/third_party/cares/cares/src/lib/ares_parse_naptr_reply.c +0 -183
- data/third_party/cares/cares/src/lib/ares_parse_ns_reply.c +0 -177
- data/third_party/cares/cares/src/lib/ares_parse_ptr_reply.c +0 -228
- data/third_party/cares/cares/src/lib/ares_parse_soa_reply.c +0 -179
- data/third_party/cares/cares/src/lib/ares_parse_srv_reply.c +0 -168
- data/third_party/cares/cares/src/lib/ares_parse_txt_reply.c +0 -214
- data/third_party/cares/cares/src/lib/ares_parse_uri_reply.c +0 -184
- data/third_party/cares/cares/src/lib/ares_platform.c +0 -11042
- data/third_party/cares/cares/src/lib/ares_platform.h +0 -43
- data/third_party/cares/cares/src/lib/ares_rand.c +0 -279
- data/third_party/cares/cares/src/lib/ares_strcasecmp.c +0 -66
- data/third_party/cares/cares/src/lib/ares_strcasecmp.h +0 -30
- data/third_party/cares/cares/src/lib/ares_strdup.c +0 -42
- data/third_party/cares/cares/src/lib/ares_strdup.h +0 -24
- data/third_party/cares/cares/src/lib/ares_strsplit.c +0 -94
- data/third_party/cares/cares/src/lib/ares_strsplit.h +0 -42
- data/third_party/cares/cares/src/lib/ares_writev.c +0 -79
- data/third_party/cares/cares/src/lib/ares_writev.h +0 -36
- data/third_party/cares/cares/src/lib/bitncmp.c +0 -59
- data/third_party/cares/cares/src/lib/bitncmp.h +0 -26
- data/third_party/cares/cares/src/lib/setup_once.h +0 -554
- data/third_party/cares/cares/src/tools/ares_getopt.h +0 -53
@@ -0,0 +1,839 @@
|
|
1
|
+
/* MIT License
|
2
|
+
*
|
3
|
+
* Copyright (c) 1998 Massachusetts Institute of Technology
|
4
|
+
* Copyright (c) 2007 Daniel Stenberg
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
11
|
+
* furnished to do so, subject to the following conditions:
|
12
|
+
*
|
13
|
+
* The above copyright notice and this permission notice (including the next
|
14
|
+
* paragraph) shall be included in all copies or substantial portions of the
|
15
|
+
* Software.
|
16
|
+
*
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
* SOFTWARE.
|
24
|
+
*
|
25
|
+
* SPDX-License-Identifier: MIT
|
26
|
+
*/
|
27
|
+
|
28
|
+
#include "ares_private.h"
|
29
|
+
|
30
|
+
#ifdef HAVE_SYS_PARAM_H
|
31
|
+
# include <sys/param.h>
|
32
|
+
#endif
|
33
|
+
|
34
|
+
#ifdef HAVE_NETINET_IN_H
|
35
|
+
# include <netinet/in.h>
|
36
|
+
#endif
|
37
|
+
|
38
|
+
#ifdef HAVE_NETDB_H
|
39
|
+
# include <netdb.h>
|
40
|
+
#endif
|
41
|
+
|
42
|
+
#ifdef HAVE_ARPA_INET_H
|
43
|
+
# include <arpa/inet.h>
|
44
|
+
#endif
|
45
|
+
|
46
|
+
#if defined(ANDROID) || defined(__ANDROID__)
|
47
|
+
# include <sys/system_properties.h>
|
48
|
+
# include "ares_android.h"
|
49
|
+
/* From the Bionic sources */
|
50
|
+
# define DNS_PROP_NAME_PREFIX "net.dns"
|
51
|
+
# define MAX_DNS_PROPERTIES 8
|
52
|
+
#endif
|
53
|
+
|
54
|
+
#if defined(CARES_USE_LIBRESOLV)
|
55
|
+
# include <resolv.h>
|
56
|
+
#endif
|
57
|
+
|
58
|
+
#if defined(USE_WINSOCK) && defined(HAVE_IPHLPAPI_H)
|
59
|
+
# include <iphlpapi.h>
|
60
|
+
#endif
|
61
|
+
|
62
|
+
#include "ares_inet_net_pton.h"
|
63
|
+
|
64
|
+
static unsigned char ip_natural_mask(const struct ares_addr *addr)
|
65
|
+
{
|
66
|
+
const unsigned char *ptr = NULL;
|
67
|
+
/* This is an odd one. If a raw ipv4 address is specified, then we take
|
68
|
+
* what is called a natural mask, which means we look at the first octet
|
69
|
+
* of the ip address and for values 0-127 we assume it is a class A (/8),
|
70
|
+
* for values 128-191 we assume it is a class B (/16), and for 192-223
|
71
|
+
* we assume it is a class C (/24). 223-239 is Class D which and 240-255 is
|
72
|
+
* Class E, however, there is no pre-defined mask for this, so we'll use
|
73
|
+
* /24 as well as that's what the old code did.
|
74
|
+
*
|
75
|
+
* For IPv6, we'll use /64.
|
76
|
+
*/
|
77
|
+
|
78
|
+
if (addr->family == AF_INET6) {
|
79
|
+
return 64;
|
80
|
+
}
|
81
|
+
|
82
|
+
ptr = (const unsigned char *)&addr->addr.addr4;
|
83
|
+
if (*ptr < 128) {
|
84
|
+
return 8;
|
85
|
+
}
|
86
|
+
|
87
|
+
if (*ptr < 192) {
|
88
|
+
return 16;
|
89
|
+
}
|
90
|
+
|
91
|
+
return 24;
|
92
|
+
}
|
93
|
+
|
94
|
+
static ares_bool_t sortlist_append(struct apattern **sortlist, size_t *nsort,
|
95
|
+
const struct apattern *pat)
|
96
|
+
{
|
97
|
+
struct apattern *newsort;
|
98
|
+
|
99
|
+
newsort = ares_realloc(*sortlist, (*nsort + 1) * sizeof(*newsort));
|
100
|
+
if (newsort == NULL) {
|
101
|
+
return ARES_FALSE; /* LCOV_EXCL_LINE: OutOfMemory */
|
102
|
+
}
|
103
|
+
|
104
|
+
*sortlist = newsort;
|
105
|
+
|
106
|
+
memcpy(&(*sortlist)[*nsort], pat, sizeof(**sortlist));
|
107
|
+
(*nsort)++;
|
108
|
+
|
109
|
+
return ARES_TRUE;
|
110
|
+
}
|
111
|
+
|
112
|
+
static ares_status_t parse_sort(ares_buf_t *buf, struct apattern *pat)
|
113
|
+
{
|
114
|
+
ares_status_t status;
|
115
|
+
const unsigned char ip_charset[] = "ABCDEFabcdef0123456789.:";
|
116
|
+
char ipaddr[INET6_ADDRSTRLEN] = "";
|
117
|
+
size_t addrlen;
|
118
|
+
|
119
|
+
memset(pat, 0, sizeof(*pat));
|
120
|
+
|
121
|
+
/* Consume any leading whitespace */
|
122
|
+
ares_buf_consume_whitespace(buf, ARES_TRUE);
|
123
|
+
|
124
|
+
/* If no length, just ignore, return ENOTFOUND as an indicator */
|
125
|
+
if (ares_buf_len(buf) == 0) {
|
126
|
+
return ARES_ENOTFOUND;
|
127
|
+
}
|
128
|
+
|
129
|
+
ares_buf_tag(buf);
|
130
|
+
|
131
|
+
/* Consume ip address */
|
132
|
+
if (ares_buf_consume_charset(buf, ip_charset, sizeof(ip_charset) - 1) == 0) {
|
133
|
+
return ARES_EBADSTR;
|
134
|
+
}
|
135
|
+
|
136
|
+
/* Fetch ip address */
|
137
|
+
status = ares_buf_tag_fetch_string(buf, ipaddr, sizeof(ipaddr));
|
138
|
+
if (status != ARES_SUCCESS) {
|
139
|
+
return status;
|
140
|
+
}
|
141
|
+
|
142
|
+
/* Parse it to make sure its valid */
|
143
|
+
pat->addr.family = AF_UNSPEC;
|
144
|
+
if (ares_dns_pton(ipaddr, &pat->addr, &addrlen) == NULL) {
|
145
|
+
return ARES_EBADSTR;
|
146
|
+
}
|
147
|
+
|
148
|
+
/* See if there is a subnet mask */
|
149
|
+
if (ares_buf_begins_with(buf, (const unsigned char *)"/", 1)) {
|
150
|
+
char maskstr[16];
|
151
|
+
const unsigned char ipv4_charset[] = "0123456789.";
|
152
|
+
|
153
|
+
|
154
|
+
/* Consume / */
|
155
|
+
ares_buf_consume(buf, 1);
|
156
|
+
|
157
|
+
ares_buf_tag(buf);
|
158
|
+
|
159
|
+
/* Consume mask */
|
160
|
+
if (ares_buf_consume_charset(buf, ipv4_charset, sizeof(ipv4_charset) - 1) ==
|
161
|
+
0) {
|
162
|
+
return ARES_EBADSTR;
|
163
|
+
}
|
164
|
+
|
165
|
+
/* Fetch mask */
|
166
|
+
status = ares_buf_tag_fetch_string(buf, maskstr, sizeof(maskstr));
|
167
|
+
if (status != ARES_SUCCESS) {
|
168
|
+
return status;
|
169
|
+
}
|
170
|
+
|
171
|
+
if (ares_str_isnum(maskstr)) {
|
172
|
+
/* Numeric mask */
|
173
|
+
int mask = atoi(maskstr);
|
174
|
+
if (mask < 0 || mask > 128) {
|
175
|
+
return ARES_EBADSTR;
|
176
|
+
}
|
177
|
+
if (pat->addr.family == AF_INET && mask > 32) {
|
178
|
+
return ARES_EBADSTR;
|
179
|
+
}
|
180
|
+
pat->mask = (unsigned char)mask;
|
181
|
+
} else {
|
182
|
+
/* Ipv4 subnet style mask */
|
183
|
+
struct ares_addr maskaddr;
|
184
|
+
const unsigned char *ptr;
|
185
|
+
|
186
|
+
memset(&maskaddr, 0, sizeof(maskaddr));
|
187
|
+
maskaddr.family = AF_INET;
|
188
|
+
if (ares_dns_pton(maskstr, &maskaddr, &addrlen) == NULL) {
|
189
|
+
return ARES_EBADSTR;
|
190
|
+
}
|
191
|
+
ptr = (const unsigned char *)&maskaddr.addr.addr4;
|
192
|
+
pat->mask = (unsigned char)(ares_count_bits_u8(ptr[0]) +
|
193
|
+
ares_count_bits_u8(ptr[1]) +
|
194
|
+
ares_count_bits_u8(ptr[2]) +
|
195
|
+
ares_count_bits_u8(ptr[3]));
|
196
|
+
}
|
197
|
+
} else {
|
198
|
+
pat->mask = ip_natural_mask(&pat->addr);
|
199
|
+
}
|
200
|
+
|
201
|
+
/* Consume any trailing whitespace */
|
202
|
+
ares_buf_consume_whitespace(buf, ARES_TRUE);
|
203
|
+
|
204
|
+
/* If we have any trailing bytes other than whitespace, its a parse failure */
|
205
|
+
if (ares_buf_len(buf) != 0) {
|
206
|
+
return ARES_EBADSTR;
|
207
|
+
}
|
208
|
+
|
209
|
+
return ARES_SUCCESS;
|
210
|
+
}
|
211
|
+
|
212
|
+
ares_status_t ares_parse_sortlist(struct apattern **sortlist, size_t *nsort,
|
213
|
+
const char *str)
|
214
|
+
{
|
215
|
+
ares_buf_t *buf = NULL;
|
216
|
+
ares_status_t status = ARES_SUCCESS;
|
217
|
+
ares_array_t *arr = NULL;
|
218
|
+
size_t num = 0;
|
219
|
+
size_t i;
|
220
|
+
|
221
|
+
if (sortlist == NULL || nsort == NULL || str == NULL) {
|
222
|
+
return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */
|
223
|
+
}
|
224
|
+
|
225
|
+
if (*sortlist != NULL) {
|
226
|
+
ares_free(*sortlist);
|
227
|
+
}
|
228
|
+
|
229
|
+
*sortlist = NULL;
|
230
|
+
*nsort = 0;
|
231
|
+
|
232
|
+
buf = ares_buf_create_const((const unsigned char *)str, ares_strlen(str));
|
233
|
+
if (buf == NULL) {
|
234
|
+
status = ARES_ENOMEM;
|
235
|
+
goto done;
|
236
|
+
}
|
237
|
+
|
238
|
+
/* Split on space or semicolon */
|
239
|
+
status = ares_buf_split(buf, (const unsigned char *)" ;", 2,
|
240
|
+
ARES_BUF_SPLIT_NONE, 0, &arr);
|
241
|
+
if (status != ARES_SUCCESS) {
|
242
|
+
goto done;
|
243
|
+
}
|
244
|
+
|
245
|
+
num = ares_array_len(arr);
|
246
|
+
for (i = 0; i < num; i++) {
|
247
|
+
ares_buf_t **bufptr = ares_array_at(arr, i);
|
248
|
+
ares_buf_t *entry = *bufptr;
|
249
|
+
|
250
|
+
struct apattern pat;
|
251
|
+
|
252
|
+
status = parse_sort(entry, &pat);
|
253
|
+
if (status != ARES_SUCCESS && status != ARES_ENOTFOUND) {
|
254
|
+
goto done;
|
255
|
+
}
|
256
|
+
|
257
|
+
if (status != ARES_SUCCESS) {
|
258
|
+
continue;
|
259
|
+
}
|
260
|
+
|
261
|
+
if (!sortlist_append(sortlist, nsort, &pat)) {
|
262
|
+
status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
263
|
+
goto done; /* LCOV_EXCL_LINE: OutOfMemory */
|
264
|
+
}
|
265
|
+
}
|
266
|
+
|
267
|
+
status = ARES_SUCCESS;
|
268
|
+
|
269
|
+
done:
|
270
|
+
ares_buf_destroy(buf);
|
271
|
+
ares_array_destroy(arr);
|
272
|
+
|
273
|
+
if (status != ARES_SUCCESS) {
|
274
|
+
ares_free(*sortlist);
|
275
|
+
*sortlist = NULL;
|
276
|
+
*nsort = 0;
|
277
|
+
}
|
278
|
+
|
279
|
+
return status;
|
280
|
+
}
|
281
|
+
|
282
|
+
static ares_status_t config_search(ares_sysconfig_t *sysconfig, const char *str,
|
283
|
+
size_t max_domains)
|
284
|
+
{
|
285
|
+
if (sysconfig->domains && sysconfig->ndomains > 0) {
|
286
|
+
/* if we already have some domains present, free them first */
|
287
|
+
ares_strsplit_free(sysconfig->domains, sysconfig->ndomains);
|
288
|
+
sysconfig->domains = NULL;
|
289
|
+
sysconfig->ndomains = 0;
|
290
|
+
}
|
291
|
+
|
292
|
+
sysconfig->domains = ares_strsplit(str, ", ", &sysconfig->ndomains);
|
293
|
+
if (sysconfig->domains == NULL) {
|
294
|
+
return ARES_ENOMEM;
|
295
|
+
}
|
296
|
+
|
297
|
+
/* Truncate if necessary */
|
298
|
+
if (max_domains && sysconfig->ndomains > max_domains) {
|
299
|
+
size_t i;
|
300
|
+
for (i = max_domains; i < sysconfig->ndomains; i++) {
|
301
|
+
ares_free(sysconfig->domains[i]);
|
302
|
+
sysconfig->domains[i] = NULL;
|
303
|
+
}
|
304
|
+
sysconfig->ndomains = max_domains;
|
305
|
+
}
|
306
|
+
|
307
|
+
return ARES_SUCCESS;
|
308
|
+
}
|
309
|
+
|
310
|
+
static ares_status_t buf_fetch_string(ares_buf_t *buf, char *str,
|
311
|
+
size_t str_len)
|
312
|
+
{
|
313
|
+
ares_status_t status;
|
314
|
+
ares_buf_tag(buf);
|
315
|
+
ares_buf_consume(buf, ares_buf_len(buf));
|
316
|
+
|
317
|
+
status = ares_buf_tag_fetch_string(buf, str, str_len);
|
318
|
+
return status;
|
319
|
+
}
|
320
|
+
|
321
|
+
static ares_status_t config_lookup(ares_sysconfig_t *sysconfig, ares_buf_t *buf,
|
322
|
+
const char *separators)
|
323
|
+
{
|
324
|
+
ares_status_t status;
|
325
|
+
char lookupstr[32];
|
326
|
+
size_t lookupstr_cnt = 0;
|
327
|
+
char **lookups = NULL;
|
328
|
+
size_t num = 0;
|
329
|
+
size_t i;
|
330
|
+
size_t separators_len = ares_strlen(separators);
|
331
|
+
|
332
|
+
status =
|
333
|
+
ares_buf_split_str(buf, (const unsigned char *)separators, separators_len,
|
334
|
+
ARES_BUF_SPLIT_TRIM, 0, &lookups, &num);
|
335
|
+
if (status != ARES_SUCCESS) {
|
336
|
+
goto done;
|
337
|
+
}
|
338
|
+
|
339
|
+
for (i = 0; i < num; i++) {
|
340
|
+
const char *value = lookups[i];
|
341
|
+
char ch;
|
342
|
+
|
343
|
+
if (ares_strcaseeq(value, "dns") || ares_strcaseeq(value, "bind") ||
|
344
|
+
ares_strcaseeq(value, "resolv") || ares_strcaseeq(value, "resolve")) {
|
345
|
+
ch = 'b';
|
346
|
+
} else if (ares_strcaseeq(value, "files") ||
|
347
|
+
ares_strcaseeq(value, "file") ||
|
348
|
+
ares_strcaseeq(value, "local")) {
|
349
|
+
ch = 'f';
|
350
|
+
} else {
|
351
|
+
continue;
|
352
|
+
}
|
353
|
+
|
354
|
+
/* Look for a duplicate and ignore */
|
355
|
+
if (memchr(lookupstr, ch, lookupstr_cnt) == NULL) {
|
356
|
+
lookupstr[lookupstr_cnt++] = ch;
|
357
|
+
}
|
358
|
+
}
|
359
|
+
|
360
|
+
if (lookupstr_cnt) {
|
361
|
+
lookupstr[lookupstr_cnt] = 0;
|
362
|
+
ares_free(sysconfig->lookups);
|
363
|
+
sysconfig->lookups = ares_strdup(lookupstr);
|
364
|
+
if (sysconfig->lookups == NULL) {
|
365
|
+
status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
366
|
+
goto done; /* LCOV_EXCL_LINE: OutOfMemory */
|
367
|
+
}
|
368
|
+
}
|
369
|
+
|
370
|
+
status = ARES_SUCCESS;
|
371
|
+
|
372
|
+
done:
|
373
|
+
if (status != ARES_ENOMEM) {
|
374
|
+
status = ARES_SUCCESS;
|
375
|
+
}
|
376
|
+
ares_free_array(lookups, num, ares_free);
|
377
|
+
return status;
|
378
|
+
}
|
379
|
+
|
380
|
+
static ares_status_t process_option(ares_sysconfig_t *sysconfig,
|
381
|
+
ares_buf_t *option)
|
382
|
+
{
|
383
|
+
char **kv = NULL;
|
384
|
+
size_t num = 0;
|
385
|
+
const char *key;
|
386
|
+
const char *val;
|
387
|
+
unsigned int valint = 0;
|
388
|
+
ares_status_t status;
|
389
|
+
|
390
|
+
/* Split on : */
|
391
|
+
status = ares_buf_split_str(option, (const unsigned char *)":", 1,
|
392
|
+
ARES_BUF_SPLIT_TRIM, 2, &kv, &num);
|
393
|
+
if (status != ARES_SUCCESS) {
|
394
|
+
goto done;
|
395
|
+
}
|
396
|
+
|
397
|
+
if (num < 1) {
|
398
|
+
status = ARES_EBADSTR;
|
399
|
+
goto done;
|
400
|
+
}
|
401
|
+
|
402
|
+
key = kv[0];
|
403
|
+
if (num == 2) {
|
404
|
+
val = kv[1];
|
405
|
+
valint = (unsigned int)strtoul(val, NULL, 10);
|
406
|
+
}
|
407
|
+
|
408
|
+
if (ares_streq(key, "ndots")) {
|
409
|
+
sysconfig->ndots = valint;
|
410
|
+
} else if (ares_streq(key, "retrans") || ares_streq(key, "timeout")) {
|
411
|
+
if (valint == 0) {
|
412
|
+
return ARES_EFORMERR;
|
413
|
+
}
|
414
|
+
sysconfig->timeout_ms = valint * 1000;
|
415
|
+
} else if (ares_streq(key, "retry") || ares_streq(key, "attempts")) {
|
416
|
+
if (valint == 0) {
|
417
|
+
return ARES_EFORMERR;
|
418
|
+
}
|
419
|
+
sysconfig->tries = valint;
|
420
|
+
} else if (ares_streq(key, "rotate")) {
|
421
|
+
sysconfig->rotate = ARES_TRUE;
|
422
|
+
} else if (ares_streq(key, "use-vc") || ares_streq(key, "usevc")) {
|
423
|
+
sysconfig->usevc = ARES_TRUE;
|
424
|
+
}
|
425
|
+
|
426
|
+
done:
|
427
|
+
ares_free_array(kv, num, ares_free);
|
428
|
+
return status;
|
429
|
+
}
|
430
|
+
|
431
|
+
ares_status_t ares_sysconfig_set_options(ares_sysconfig_t *sysconfig,
|
432
|
+
const char *str)
|
433
|
+
{
|
434
|
+
ares_buf_t *buf = NULL;
|
435
|
+
ares_array_t *options = NULL;
|
436
|
+
size_t num;
|
437
|
+
size_t i;
|
438
|
+
ares_status_t status;
|
439
|
+
|
440
|
+
buf = ares_buf_create_const((const unsigned char *)str, ares_strlen(str));
|
441
|
+
if (buf == NULL) {
|
442
|
+
return ARES_ENOMEM;
|
443
|
+
}
|
444
|
+
|
445
|
+
status = ares_buf_split(buf, (const unsigned char *)" \t", 2,
|
446
|
+
ARES_BUF_SPLIT_TRIM, 0, &options);
|
447
|
+
if (status != ARES_SUCCESS) {
|
448
|
+
goto done;
|
449
|
+
}
|
450
|
+
|
451
|
+
num = ares_array_len(options);
|
452
|
+
for (i = 0; i < num; i++) {
|
453
|
+
ares_buf_t **bufptr = ares_array_at(options, i);
|
454
|
+
ares_buf_t *valbuf = *bufptr;
|
455
|
+
|
456
|
+
status = process_option(sysconfig, valbuf);
|
457
|
+
/* Out of memory is the only fatal condition */
|
458
|
+
if (status == ARES_ENOMEM) {
|
459
|
+
goto done; /* LCOV_EXCL_LINE: OutOfMemory */
|
460
|
+
}
|
461
|
+
}
|
462
|
+
|
463
|
+
status = ARES_SUCCESS;
|
464
|
+
|
465
|
+
done:
|
466
|
+
ares_array_destroy(options);
|
467
|
+
ares_buf_destroy(buf);
|
468
|
+
return status;
|
469
|
+
}
|
470
|
+
|
471
|
+
ares_status_t ares_init_by_environment(ares_sysconfig_t *sysconfig)
|
472
|
+
{
|
473
|
+
const char *localdomain;
|
474
|
+
const char *res_options;
|
475
|
+
ares_status_t status;
|
476
|
+
|
477
|
+
localdomain = getenv("LOCALDOMAIN");
|
478
|
+
if (localdomain) {
|
479
|
+
char *temp = ares_strdup(localdomain);
|
480
|
+
if (temp == NULL) {
|
481
|
+
return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
|
482
|
+
}
|
483
|
+
status = config_search(sysconfig, temp, 1);
|
484
|
+
ares_free(temp);
|
485
|
+
if (status != ARES_SUCCESS) {
|
486
|
+
return status;
|
487
|
+
}
|
488
|
+
}
|
489
|
+
|
490
|
+
res_options = getenv("RES_OPTIONS");
|
491
|
+
if (res_options) {
|
492
|
+
status = ares_sysconfig_set_options(sysconfig, res_options);
|
493
|
+
if (status != ARES_SUCCESS) {
|
494
|
+
return status;
|
495
|
+
}
|
496
|
+
}
|
497
|
+
|
498
|
+
return ARES_SUCCESS;
|
499
|
+
}
|
500
|
+
|
501
|
+
/* Configuration Files:
|
502
|
+
* /etc/resolv.conf
|
503
|
+
* - All Unix-like systems
|
504
|
+
* - Comments start with ; or #
|
505
|
+
* - Lines have a keyword followed by a value that is interpreted specific
|
506
|
+
* to the keyword:
|
507
|
+
* - Keywords:
|
508
|
+
* - nameserver - IP address of nameserver with optional port (using a :
|
509
|
+
* prefix). If using an ipv6 address and specifying a port, the ipv6
|
510
|
+
* address must be encapsulated in brackets. For link-local ipv6
|
511
|
+
* addresses, the interface can also be specified with a % prefix. e.g.:
|
512
|
+
* "nameserver [fe80::1]:1234%iface"
|
513
|
+
* This keyword may be specified multiple times.
|
514
|
+
* - search - whitespace separated list of domains
|
515
|
+
* - domain - obsolete, same as search except only a single domain
|
516
|
+
* - lookup / hostresorder - local, bind, file, files
|
517
|
+
* - sortlist - whitespace separated ip-address/netmask pairs
|
518
|
+
* - options - options controlling resolver variables
|
519
|
+
* - ndots:n - set ndots option
|
520
|
+
* - timeout:n (retrans:n) - timeout per query attempt in seconds
|
521
|
+
* - attempts:n (retry:n) - number of times resolver will send query
|
522
|
+
* - rotate - round-robin selection of name servers
|
523
|
+
* - use-vc / usevc - force tcp
|
524
|
+
* /etc/nsswitch.conf
|
525
|
+
* - Modern Linux, FreeBSD, HP-UX, Solaris
|
526
|
+
* - Search order set via:
|
527
|
+
* "hosts: files dns mdns4_minimal mdns4"
|
528
|
+
* - files is /etc/hosts
|
529
|
+
* - dns is dns
|
530
|
+
* - mdns4_minimal does mdns only if ending in .local
|
531
|
+
* - mdns4 does not limit to domains ending in .local
|
532
|
+
* /etc/netsvc.conf
|
533
|
+
* - AIX
|
534
|
+
* - Search order set via:
|
535
|
+
* "hosts = local , bind"
|
536
|
+
* - bind is dns
|
537
|
+
* - local is /etc/hosts
|
538
|
+
* /etc/svc.conf
|
539
|
+
* - Tru64
|
540
|
+
* - Same format as /etc/netsvc.conf
|
541
|
+
* /etc/host.conf
|
542
|
+
* - Early FreeBSD, Early Linux
|
543
|
+
* - Not worth supporting, format varied based on system, FreeBSD used
|
544
|
+
* just a line per search order, Linux used "order " and a comma
|
545
|
+
* delimited list of "bind" and "hosts"
|
546
|
+
*/
|
547
|
+
|
548
|
+
|
549
|
+
/* This function will only return ARES_SUCCESS or ARES_ENOMEM. Any other
|
550
|
+
* conditions are ignored. Users may mess up config files, but we want to
|
551
|
+
* process anything we can. */
|
552
|
+
ares_status_t ares_sysconfig_parse_resolv_line(const ares_channel_t *channel,
|
553
|
+
ares_sysconfig_t *sysconfig,
|
554
|
+
ares_buf_t *line)
|
555
|
+
{
|
556
|
+
char option[32];
|
557
|
+
char value[512];
|
558
|
+
ares_status_t status = ARES_SUCCESS;
|
559
|
+
|
560
|
+
/* Ignore lines beginning with a comment */
|
561
|
+
if (ares_buf_begins_with(line, (const unsigned char *)"#", 1) ||
|
562
|
+
ares_buf_begins_with(line, (const unsigned char *)";", 1)) {
|
563
|
+
return ARES_SUCCESS;
|
564
|
+
}
|
565
|
+
|
566
|
+
ares_buf_tag(line);
|
567
|
+
|
568
|
+
/* Shouldn't be possible, but if it happens, ignore the line. */
|
569
|
+
if (ares_buf_consume_nonwhitespace(line) == 0) {
|
570
|
+
return ARES_SUCCESS;
|
571
|
+
}
|
572
|
+
|
573
|
+
status = ares_buf_tag_fetch_string(line, option, sizeof(option));
|
574
|
+
if (status != ARES_SUCCESS) {
|
575
|
+
return ARES_SUCCESS;
|
576
|
+
}
|
577
|
+
|
578
|
+
ares_buf_consume_whitespace(line, ARES_TRUE);
|
579
|
+
|
580
|
+
status = buf_fetch_string(line, value, sizeof(value));
|
581
|
+
if (status != ARES_SUCCESS) {
|
582
|
+
return ARES_SUCCESS;
|
583
|
+
}
|
584
|
+
|
585
|
+
ares_str_trim(value);
|
586
|
+
if (*value == 0) {
|
587
|
+
return ARES_SUCCESS;
|
588
|
+
}
|
589
|
+
|
590
|
+
/* At this point we have a string option and a string value, both trimmed
|
591
|
+
* of leading and trailing whitespace. Lets try to evaluate them */
|
592
|
+
if (ares_streq(option, "domain")) {
|
593
|
+
/* Domain is legacy, don't overwrite an existing config set by search */
|
594
|
+
if (sysconfig->domains == NULL) {
|
595
|
+
status = config_search(sysconfig, value, 1);
|
596
|
+
}
|
597
|
+
} else if (ares_streq(option, "lookup") ||
|
598
|
+
ares_streq(option, "hostresorder")) {
|
599
|
+
ares_buf_tag_rollback(line);
|
600
|
+
status = config_lookup(sysconfig, line, " \t");
|
601
|
+
} else if (ares_streq(option, "search")) {
|
602
|
+
status = config_search(sysconfig, value, 0);
|
603
|
+
} else if (ares_streq(option, "nameserver")) {
|
604
|
+
status = ares_sconfig_append_fromstr(channel, &sysconfig->sconfig, value,
|
605
|
+
ARES_TRUE);
|
606
|
+
} else if (ares_streq(option, "sortlist")) {
|
607
|
+
/* Ignore all failures except ENOMEM. If the sysadmin set a bad
|
608
|
+
* sortlist, just ignore the sortlist, don't cause an inoperable
|
609
|
+
* channel */
|
610
|
+
status =
|
611
|
+
ares_parse_sortlist(&sysconfig->sortlist, &sysconfig->nsortlist, value);
|
612
|
+
if (status != ARES_ENOMEM) {
|
613
|
+
status = ARES_SUCCESS;
|
614
|
+
}
|
615
|
+
} else if (ares_streq(option, "options")) {
|
616
|
+
status = ares_sysconfig_set_options(sysconfig, value);
|
617
|
+
}
|
618
|
+
|
619
|
+
return status;
|
620
|
+
}
|
621
|
+
|
622
|
+
/* This function will only return ARES_SUCCESS or ARES_ENOMEM. Any other
|
623
|
+
* conditions are ignored. Users may mess up config files, but we want to
|
624
|
+
* process anything we can. */
|
625
|
+
static ares_status_t parse_nsswitch_line(const ares_channel_t *channel,
|
626
|
+
ares_sysconfig_t *sysconfig,
|
627
|
+
ares_buf_t *line)
|
628
|
+
{
|
629
|
+
char option[32];
|
630
|
+
ares_status_t status = ARES_SUCCESS;
|
631
|
+
ares_array_t *sects = NULL;
|
632
|
+
ares_buf_t **bufptr;
|
633
|
+
ares_buf_t *buf;
|
634
|
+
|
635
|
+
(void)channel;
|
636
|
+
|
637
|
+
/* Ignore lines beginning with a comment */
|
638
|
+
if (ares_buf_begins_with(line, (const unsigned char *)"#", 1)) {
|
639
|
+
return ARES_SUCCESS;
|
640
|
+
}
|
641
|
+
|
642
|
+
/* database : values (space delimited) */
|
643
|
+
status = ares_buf_split(line, (const unsigned char *)":", 1,
|
644
|
+
ARES_BUF_SPLIT_TRIM, 2, §s);
|
645
|
+
|
646
|
+
if (status != ARES_SUCCESS || ares_array_len(sects) != 2) {
|
647
|
+
goto done;
|
648
|
+
}
|
649
|
+
|
650
|
+
bufptr = ares_array_at(sects, 0);
|
651
|
+
buf = *bufptr;
|
652
|
+
|
653
|
+
status = buf_fetch_string(buf, option, sizeof(option));
|
654
|
+
if (status != ARES_SUCCESS) {
|
655
|
+
goto done;
|
656
|
+
}
|
657
|
+
|
658
|
+
/* Only support "hosts:" */
|
659
|
+
if (!ares_streq(option, "hosts")) {
|
660
|
+
goto done;
|
661
|
+
}
|
662
|
+
|
663
|
+
/* Values are space separated */
|
664
|
+
bufptr = ares_array_at(sects, 1);
|
665
|
+
buf = *bufptr;
|
666
|
+
status = config_lookup(sysconfig, buf, " \t");
|
667
|
+
|
668
|
+
done:
|
669
|
+
ares_array_destroy(sects);
|
670
|
+
if (status != ARES_ENOMEM) {
|
671
|
+
status = ARES_SUCCESS;
|
672
|
+
}
|
673
|
+
return status;
|
674
|
+
}
|
675
|
+
|
676
|
+
/* This function will only return ARES_SUCCESS or ARES_ENOMEM. Any other
|
677
|
+
* conditions are ignored. Users may mess up config files, but we want to
|
678
|
+
* process anything we can. */
|
679
|
+
static ares_status_t parse_svcconf_line(const ares_channel_t *channel,
|
680
|
+
ares_sysconfig_t *sysconfig,
|
681
|
+
ares_buf_t *line)
|
682
|
+
{
|
683
|
+
char option[32];
|
684
|
+
ares_buf_t **bufptr;
|
685
|
+
ares_buf_t *buf;
|
686
|
+
ares_status_t status = ARES_SUCCESS;
|
687
|
+
ares_array_t *sects = NULL;
|
688
|
+
|
689
|
+
(void)channel;
|
690
|
+
|
691
|
+
/* Ignore lines beginning with a comment */
|
692
|
+
if (ares_buf_begins_with(line, (const unsigned char *)"#", 1)) {
|
693
|
+
return ARES_SUCCESS;
|
694
|
+
}
|
695
|
+
|
696
|
+
/* database = values (comma delimited)*/
|
697
|
+
status = ares_buf_split(line, (const unsigned char *)"=", 1,
|
698
|
+
ARES_BUF_SPLIT_TRIM, 2, §s);
|
699
|
+
|
700
|
+
if (status != ARES_SUCCESS || ares_array_len(sects) != 2) {
|
701
|
+
goto done;
|
702
|
+
}
|
703
|
+
|
704
|
+
bufptr = ares_array_at(sects, 0);
|
705
|
+
buf = *bufptr;
|
706
|
+
status = buf_fetch_string(buf, option, sizeof(option));
|
707
|
+
if (status != ARES_SUCCESS) {
|
708
|
+
goto done;
|
709
|
+
}
|
710
|
+
|
711
|
+
/* Only support "hosts=" */
|
712
|
+
if (!ares_streq(option, "hosts")) {
|
713
|
+
goto done;
|
714
|
+
}
|
715
|
+
|
716
|
+
/* Values are comma separated */
|
717
|
+
bufptr = ares_array_at(sects, 1);
|
718
|
+
buf = *bufptr;
|
719
|
+
status = config_lookup(sysconfig, buf, ",");
|
720
|
+
|
721
|
+
done:
|
722
|
+
ares_array_destroy(sects);
|
723
|
+
if (status != ARES_ENOMEM) {
|
724
|
+
status = ARES_SUCCESS;
|
725
|
+
}
|
726
|
+
return status;
|
727
|
+
}
|
728
|
+
|
729
|
+
|
730
|
+
ares_status_t ares_sysconfig_process_buf(const ares_channel_t *channel,
|
731
|
+
ares_sysconfig_t *sysconfig,
|
732
|
+
ares_buf_t *buf,
|
733
|
+
ares_sysconfig_line_cb_t cb)
|
734
|
+
{
|
735
|
+
ares_array_t *lines = NULL;
|
736
|
+
size_t num;
|
737
|
+
size_t i;
|
738
|
+
ares_status_t status;
|
739
|
+
|
740
|
+
status = ares_buf_split(buf, (const unsigned char *)"\n", 1,
|
741
|
+
ARES_BUF_SPLIT_TRIM, 0, &lines);
|
742
|
+
if (status != ARES_SUCCESS) {
|
743
|
+
goto done;
|
744
|
+
}
|
745
|
+
|
746
|
+
num = ares_array_len(lines);
|
747
|
+
for (i = 0; i < num; i++) {
|
748
|
+
ares_buf_t **bufptr = ares_array_at(lines, i);
|
749
|
+
ares_buf_t *line = *bufptr;
|
750
|
+
|
751
|
+
status = cb(channel, sysconfig, line);
|
752
|
+
if (status != ARES_SUCCESS) {
|
753
|
+
goto done;
|
754
|
+
}
|
755
|
+
}
|
756
|
+
|
757
|
+
done:
|
758
|
+
ares_array_destroy(lines);
|
759
|
+
return status;
|
760
|
+
}
|
761
|
+
|
762
|
+
/* Should only return:
|
763
|
+
* ARES_ENOTFOUND - file not found
|
764
|
+
* ARES_EFILE - error reading file (perms)
|
765
|
+
* ARES_ENOMEM - out of memory
|
766
|
+
* ARES_SUCCESS - file processed, doesn't necessarily mean it was a good
|
767
|
+
* file, but we're not erroring out if we can't parse
|
768
|
+
* something (or anything at all) */
|
769
|
+
static ares_status_t process_config_lines(const ares_channel_t *channel,
|
770
|
+
const char *filename,
|
771
|
+
ares_sysconfig_t *sysconfig,
|
772
|
+
ares_sysconfig_line_cb_t cb)
|
773
|
+
{
|
774
|
+
ares_status_t status = ARES_SUCCESS;
|
775
|
+
ares_buf_t *buf = NULL;
|
776
|
+
|
777
|
+
buf = ares_buf_create();
|
778
|
+
if (buf == NULL) {
|
779
|
+
status = ARES_ENOMEM;
|
780
|
+
goto done;
|
781
|
+
}
|
782
|
+
|
783
|
+
status = ares_buf_load_file(filename, buf);
|
784
|
+
if (status != ARES_SUCCESS) {
|
785
|
+
goto done;
|
786
|
+
}
|
787
|
+
|
788
|
+
status = ares_sysconfig_process_buf(channel, sysconfig, buf, cb);
|
789
|
+
|
790
|
+
done:
|
791
|
+
ares_buf_destroy(buf);
|
792
|
+
|
793
|
+
return status;
|
794
|
+
}
|
795
|
+
|
796
|
+
ares_status_t ares_init_sysconfig_files(const ares_channel_t *channel,
|
797
|
+
ares_sysconfig_t *sysconfig,
|
798
|
+
ares_bool_t process_resolvconf)
|
799
|
+
{
|
800
|
+
ares_status_t status = ARES_SUCCESS;
|
801
|
+
|
802
|
+
/* Resolv.conf */
|
803
|
+
if (process_resolvconf) {
|
804
|
+
status = process_config_lines(channel,
|
805
|
+
(channel->resolvconf_path != NULL)
|
806
|
+
? channel->resolvconf_path
|
807
|
+
: PATH_RESOLV_CONF,
|
808
|
+
sysconfig, ares_sysconfig_parse_resolv_line);
|
809
|
+
if (status != ARES_SUCCESS && status != ARES_ENOTFOUND) {
|
810
|
+
goto done;
|
811
|
+
}
|
812
|
+
}
|
813
|
+
|
814
|
+
/* Nsswitch.conf */
|
815
|
+
status = process_config_lines(channel, "/etc/nsswitch.conf", sysconfig,
|
816
|
+
parse_nsswitch_line);
|
817
|
+
if (status != ARES_SUCCESS && status != ARES_ENOTFOUND) {
|
818
|
+
goto done;
|
819
|
+
}
|
820
|
+
|
821
|
+
/* netsvc.conf */
|
822
|
+
status = process_config_lines(channel, "/etc/netsvc.conf", sysconfig,
|
823
|
+
parse_svcconf_line);
|
824
|
+
if (status != ARES_SUCCESS && status != ARES_ENOTFOUND) {
|
825
|
+
goto done;
|
826
|
+
}
|
827
|
+
|
828
|
+
/* svc.conf */
|
829
|
+
status = process_config_lines(channel, "/etc/svc.conf", sysconfig,
|
830
|
+
parse_svcconf_line);
|
831
|
+
if (status != ARES_SUCCESS && status != ARES_ENOTFOUND) {
|
832
|
+
goto done;
|
833
|
+
}
|
834
|
+
|
835
|
+
status = ARES_SUCCESS;
|
836
|
+
|
837
|
+
done:
|
838
|
+
return status;
|
839
|
+
}
|