grpc 1.83.1 → 1.84.0

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.
Files changed (322) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +21 -17
  3. data/include/grpc/credentials.h +10 -0
  4. data/include/grpc/grpc_security_constants.h +2 -0
  5. data/include/grpc/impl/channel_arg_names.h +9 -0
  6. data/src/core/call/call_filters.h +4 -2
  7. data/src/core/call/client_call.cc +20 -8
  8. data/src/core/call/client_call.h +4 -0
  9. data/src/core/call/interception_chain.cc +2 -0
  10. data/src/core/call/interception_chain.h +14 -1
  11. data/src/core/call/metadata.cc +1 -3
  12. data/src/core/call/metadata_batch.h +13 -5
  13. data/src/core/call/server_call.cc +31 -14
  14. data/src/core/call/server_call.h +4 -0
  15. data/src/core/channelz/text_encode.cc +9 -4
  16. data/src/core/channelz/v2tov1/convert.cc +2 -2
  17. data/src/core/client_channel/backup_poller.cc +1 -2
  18. data/src/core/client_channel/client_channel.cc +6 -33
  19. data/src/core/client_channel/client_channel_filter.cc +22 -55
  20. data/src/core/client_channel/client_channel_filter.h +2 -2
  21. data/src/core/client_channel/client_channel_service_config.cc +3 -19
  22. data/src/core/client_channel/direct_channel.cc +7 -1
  23. data/src/core/client_channel/direct_channel.h +2 -2
  24. data/src/core/client_channel/load_balanced_call_destination.cc +5 -3
  25. data/src/core/client_channel/retry_filter_legacy_call_data.cc +5 -12
  26. data/src/core/client_channel/subchannel.cc +310 -1058
  27. data/src/core/client_channel/subchannel.h +44 -329
  28. data/src/core/client_channel/subchannel_metrics.cc +48 -0
  29. data/src/core/client_channel/subchannel_metrics.h +60 -0
  30. data/src/core/credentials/call/external/file_external_account_credentials.cc +1 -1
  31. data/src/core/credentials/call/external/url_external_account_credentials.cc +2 -3
  32. data/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.cc +8 -24
  33. data/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.h +3 -6
  34. data/src/core/credentials/call/gdch_service_account/gdch_service_account_credentials.cc +525 -0
  35. data/src/core/credentials/call/gdch_service_account/gdch_service_account_credentials.h +138 -0
  36. data/src/core/credentials/call/json_util.h +1 -0
  37. data/src/core/credentials/call/jwt/json_token.cc +10 -2
  38. data/src/core/credentials/call/jwt/jwt_verifier.cc +15 -1
  39. data/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.cc +1 -1
  40. data/src/core/credentials/call/oauth2/oauth2_credentials.cc +42 -79
  41. data/src/core/credentials/call/oauth2/oauth2_credentials.h +2 -5
  42. data/src/core/credentials/call/token_fetcher/token_fetcher_credentials.cc +52 -31
  43. data/src/core/credentials/call/token_fetcher/token_fetcher_credentials.h +21 -8
  44. data/src/core/credentials/transport/google_default/google_default_credentials.cc +3 -4
  45. data/src/core/credentials/transport/ssl/ssl_credentials.cc +59 -72
  46. data/src/core/credentials/transport/ssl/ssl_credentials.h +9 -8
  47. data/src/core/credentials/transport/ssl/ssl_security_connector.cc +12 -6
  48. data/src/core/credentials/transport/ssl/ssl_security_connector.h +4 -4
  49. data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc +29 -18
  50. data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h +9 -6
  51. data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc +45 -56
  52. data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.h +5 -4
  53. data/src/core/credentials/transport/tls/grpc_tls_certificate_selector.h +26 -0
  54. data/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc +1 -1
  55. data/src/core/credentials/transport/tls/load_system_roots.h +2 -6
  56. data/src/core/credentials/transport/tls/load_system_roots_fallback.cc +2 -4
  57. data/src/core/credentials/transport/tls/load_system_roots_supported.cc +13 -15
  58. data/src/core/credentials/transport/tls/load_system_roots_supported.h +3 -2
  59. data/src/core/credentials/transport/tls/load_system_roots_windows.cc +5 -8
  60. data/src/core/credentials/transport/tls/spiffe_utils.cc +1 -1
  61. data/src/core/credentials/transport/tls/ssl_utils.cc +39 -28
  62. data/src/core/credentials/transport/tls/ssl_utils.h +12 -49
  63. data/src/core/credentials/transport/tls/tls_security_connector.cc +48 -33
  64. data/src/core/credentials/transport/tls/tls_security_connector.h +31 -10
  65. data/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc +15 -11
  66. data/src/core/ext/filters/http/http_filters_plugin.cc +20 -9
  67. data/src/core/ext/filters/rbac/rbac_filter.cc +43 -21
  68. data/src/core/ext/filters/rbac/rbac_filter.h +21 -3
  69. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +2 -2
  70. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +1 -1
  71. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +6 -20
  72. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +32 -67
  73. data/src/core/ext/transport/chttp2/transport/flow_control.cc +2 -0
  74. data/src/core/ext/transport/chttp2/transport/flow_control.h +78 -4
  75. data/src/core/ext/transport/chttp2/transport/frame.h +2 -0
  76. data/src/core/ext/transport/chttp2/transport/frame_data.cc +3 -4
  77. data/src/core/ext/transport/chttp2/transport/goaway.h +7 -0
  78. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +5 -3
  79. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +3 -1
  80. data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +141 -130
  81. data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +22 -22
  82. data/src/core/ext/transport/chttp2/transport/http2_server_transport.cc +402 -269
  83. data/src/core/ext/transport/chttp2/transport/http2_server_transport.h +80 -49
  84. data/src/core/ext/transport/chttp2/transport/http2_settings_promises.h +1 -2
  85. data/src/core/ext/transport/chttp2/transport/http2_status.h +38 -37
  86. data/src/core/ext/transport/chttp2/transport/http2_transport.cc +178 -5
  87. data/src/core/ext/transport/chttp2/transport/http2_transport.h +345 -5
  88. data/src/core/ext/transport/chttp2/transport/parsing.cc +5 -5
  89. data/src/core/ext/transport/chttp2/transport/ping_promise.cc +3 -2
  90. data/src/core/ext/transport/chttp2/transport/ping_promise.h +25 -5
  91. data/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc +3 -4
  92. data/src/core/ext/transport/chttp2/transport/read_context.h +30 -3
  93. data/src/core/ext/transport/chttp2/transport/stream.h +65 -23
  94. data/src/core/ext/transport/chttp2/transport/writing.cc +0 -3
  95. data/src/core/ext/transport/inproc/inproc_transport.cc +1 -5
  96. data/src/core/ext/transport/inproc/legacy_inproc_transport.cc +4 -17
  97. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb.h +1912 -0
  98. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb_minitable.c +300 -0
  99. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb_minitable.h +37 -0
  100. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upb.h +187 -0
  101. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upb_minitable.c +64 -0
  102. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upb_minitable.h +31 -0
  103. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb.h +2362 -0
  104. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb_minitable.c +556 -0
  105. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb_minitable.h +47 -0
  106. data/src/core/ext/upb-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upb.h +5 -5
  107. data/src/core/ext/upb-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upb_minitable.c +3 -3
  108. data/src/core/ext/upb-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upb_minitable.h +5 -5
  109. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upbdefs.c +453 -0
  110. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upbdefs.h +67 -0
  111. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upbdefs.c +142 -0
  112. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upbdefs.h +37 -0
  113. data/src/core/ext/upbdefs-gen/grpc/channelz/v1/channelz.upbdefs.c +715 -0
  114. data/src/core/ext/upbdefs-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upbdefs.h +44 -44
  115. data/src/core/filter/auth/server_auth_filter.cc +2 -3
  116. data/src/core/filter/composite/composite_filter.cc +45 -33
  117. data/src/core/filter/composite/composite_filter.h +5 -4
  118. data/src/core/filter/ext_proc/ext_proc_filter.cc +224 -0
  119. data/src/core/filter/ext_proc/ext_proc_filter.h +155 -0
  120. data/src/core/filter/ext_proc/ext_proc_messages.cc +701 -0
  121. data/src/core/filter/ext_proc/ext_proc_messages.h +297 -0
  122. data/src/core/filter/filter_args.h +13 -2
  123. data/src/core/handshaker/http_connect/http_proxy_mapper.cc +30 -3
  124. data/src/core/handshaker/security/security_handshaker.cc +9 -6
  125. data/src/core/lib/channel/channel_stack.cc +3 -0
  126. data/src/core/lib/channel/channel_stack.h +2 -0
  127. data/src/core/lib/channel/channel_stack_builder_impl.cc +1 -2
  128. data/src/core/lib/channel/promise_based_filter.cc +132 -20
  129. data/src/core/lib/channel/promise_based_filter.h +42 -12
  130. data/src/core/lib/compression/compression_internal.cc +4 -5
  131. data/src/core/lib/debug/trace_flags.cc +8 -0
  132. data/src/core/lib/debug/trace_flags.h +3 -0
  133. data/src/core/lib/event_engine/ares_resolver.cc +54 -50
  134. data/src/core/lib/event_engine/ares_resolver.h +3 -2
  135. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +3 -3
  136. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +4 -10
  137. data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +74 -33
  138. data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +4 -4
  139. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +6 -2
  140. data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +3 -0
  141. data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +3 -0
  142. data/src/core/lib/event_engine/windows/windows_endpoint.cc +1 -3
  143. data/src/core/lib/experiments/experiments.cc +60 -96
  144. data/src/core/lib/experiments/experiments.h +34 -50
  145. data/src/core/lib/iomgr/cfstream_handle.cc +2 -6
  146. data/src/core/lib/iomgr/endpoint_cfstream.cc +3 -10
  147. data/src/core/lib/iomgr/error.cc +2 -6
  148. data/src/core/lib/iomgr/error_cfstream.cc +1 -1
  149. data/src/core/lib/iomgr/ev_poll_posix.cc +5 -9
  150. data/src/core/lib/iomgr/event_engine_shims/closure.cc +1 -1
  151. data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +1 -2
  152. data/src/core/lib/iomgr/event_engine_shims/tcp_client.cc +1 -2
  153. data/src/core/lib/iomgr/iomgr_posix.cc +0 -4
  154. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +0 -4
  155. data/src/core/lib/iomgr/iomgr_windows.cc +0 -4
  156. data/src/core/lib/iomgr/socket_factory_posix.h +1 -1
  157. data/src/core/lib/iomgr/socket_utils_posix.cc +3 -0
  158. data/src/core/lib/iomgr/socket_utils_posix.h +3 -0
  159. data/src/core/lib/iomgr/systemd_utils.cc +0 -1
  160. data/src/core/lib/iomgr/tcp_client.h +1 -1
  161. data/src/core/lib/iomgr/tcp_posix.cc +23 -15
  162. data/src/core/lib/iomgr/tcp_server.h +1 -1
  163. data/src/core/lib/iomgr/tcp_server_posix.cc +2 -3
  164. data/src/core/lib/iomgr/tcp_server_utils_posix.h +0 -1
  165. data/src/core/lib/iomgr/tcp_server_windows.cc +0 -1
  166. data/src/core/lib/iomgr/tcp_windows.cc +5 -10
  167. data/src/core/lib/iomgr/unix_sockets_posix.cc +2 -4
  168. data/src/core/lib/iomgr/unix_sockets_posix.h +3 -1
  169. data/src/core/lib/iomgr/vsock.h +3 -1
  170. data/src/core/lib/resource_quota/memory_quota.cc +1 -1
  171. data/src/core/lib/security/authorization/rbac_policy.cc +139 -56
  172. data/src/core/lib/security/authorization/rbac_policy.h +21 -3
  173. data/src/core/lib/surface/call.cc +3 -9
  174. data/src/core/lib/surface/call_utils.h +113 -0
  175. data/src/core/lib/surface/channel_create.cc +1 -1
  176. data/src/core/lib/surface/channel_create.h +0 -2
  177. data/src/core/lib/surface/channel_init.cc +77 -38
  178. data/src/core/lib/surface/channel_init.h +30 -16
  179. data/src/core/lib/surface/filter_stack_call.cc +5 -10
  180. data/src/core/lib/surface/init.cc +13 -27
  181. data/src/core/lib/surface/version.cc +1 -1
  182. data/src/core/lib/transport/error_utils.cc +0 -27
  183. data/src/core/lib/transport/error_utils.h +0 -16
  184. data/src/core/lib/transport/transport.h +7 -5
  185. data/src/core/load_balancing/pick_first/pick_first.cc +2 -0
  186. data/src/core/load_balancing/rls/rls.cc +28 -11
  187. data/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc +33 -42
  188. data/src/core/load_balancing/weighted_round_robin/weighted_round_robin.h +0 -2
  189. data/src/core/load_balancing/xds/cds.cc +3 -1
  190. data/src/core/load_balancing/xds/xds_cluster_impl.cc +0 -1
  191. data/src/core/mitigation_engine/mitigation.h +14 -5
  192. data/src/core/mitigation_engine/mitigation_engine.h +7 -3
  193. data/src/core/mitigation_engine/mitigation_provider.h +2 -1
  194. data/src/core/plugin_registry/grpc_plugin_registry.cc +39 -8
  195. data/src/core/resolver/dns/{event_engine/event_engine_client_channel_resolver.cc → dns_resolver.cc} +42 -41
  196. data/src/core/resolver/dns/{event_engine/event_engine_client_channel_resolver.h → dns_resolver.h} +8 -5
  197. data/src/core/resolver/dns/{event_engine/service_config_helper.cc → service_config_helper.cc} +1 -1
  198. data/src/core/resolver/dns/{event_engine/service_config_helper.h → service_config_helper.h} +3 -3
  199. data/src/core/resolver/endpoint_addresses.h +3 -0
  200. data/src/core/resolver/google_c2p/google_c2p_resolver.cc +2 -1
  201. data/src/core/resolver/xds/xds_resolver.cc +35 -9
  202. data/src/core/server/server.cc +2 -6
  203. data/src/core/server/server_config_selector.h +18 -3
  204. data/src/core/server/server_config_selector_filter.cc +178 -91
  205. data/src/core/server/server_config_selector_filter.h +58 -3
  206. data/src/core/server/xds_server_config_fetcher.cc +196 -129
  207. data/src/core/server/xds_server_config_fetcher.h +49 -0
  208. data/src/core/server/xds_server_config_fetcher_legacy.cc +41 -37
  209. data/src/core/telemetry/histogram.h +94 -14
  210. data/src/core/telemetry/instrument.cc +179 -74
  211. data/src/core/telemetry/instrument.h +78 -30
  212. data/src/core/telemetry/metrics.h +5 -0
  213. data/src/core/{resolver/dns/dns_resolver_plugin.h → telemetry/telemetry_label.h} +12 -8
  214. data/src/core/tsi/alts/crypt/aes_gcm.cc +10 -13
  215. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +2 -2
  216. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +3 -1
  217. data/src/core/tsi/ssl_telemetry_utils.cc +216 -259
  218. data/src/core/tsi/ssl_telemetry_utils.h +12 -2
  219. data/src/core/tsi/ssl_transport_security.cc +238 -80
  220. data/src/core/tsi/ssl_transport_security.h +63 -33
  221. data/src/core/tsi/tls_telemetry.cc +31 -0
  222. data/src/core/tsi/tls_telemetry.h +47 -0
  223. data/src/core/tsi/transport_security.cc +2 -2
  224. data/src/core/tsi/transport_security.h +1 -1
  225. data/src/core/tsi/transport_security_interface.h +1 -1
  226. data/src/core/{resolver/dns/native/dns_resolver.h → util/address_sorting_init.cc} +21 -8
  227. data/src/core/{resolver/dns/c_ares/grpc_ares_wrapper_posix.cc → util/address_sorting_init.h} +7 -8
  228. data/src/core/util/http_client/httpcli.cc +16 -53
  229. data/src/core/util/http_client/httpcli.h +0 -7
  230. data/src/core/util/http_client/httpcli_security_connector.cc +13 -8
  231. data/src/core/util/linux/cpu.cc +1 -1
  232. data/src/core/util/load_file.cc +3 -9
  233. data/src/core/util/load_file.h +3 -4
  234. data/src/core/util/matchers.h +8 -0
  235. data/src/core/util/posix/cpu.cc +1 -1
  236. data/src/core/util/status_helper.cc +0 -20
  237. data/src/core/util/status_helper.h +3 -14
  238. data/src/core/xds/grpc/xds_audit_logger_registry.cc +51 -31
  239. data/src/core/xds/grpc/xds_audit_logger_registry.h +17 -3
  240. data/src/core/xds/grpc/xds_bootstrap_grpc.cc +2 -10
  241. data/src/core/xds/grpc/xds_bootstrap_grpc.h +8 -6
  242. data/src/core/xds/grpc/xds_bootstrap_grpc_builder.cc +488 -0
  243. data/src/core/xds/grpc/xds_bootstrap_grpc_builder.h +97 -0
  244. data/src/core/xds/grpc/xds_certificate_provider.cc +7 -7
  245. data/src/core/xds/grpc/xds_client_grpc.cc +4 -8
  246. data/src/core/xds/grpc/xds_client_grpc.h +0 -4
  247. data/src/core/xds/grpc/xds_cluster.h +1 -0
  248. data/src/core/xds/grpc/xds_cluster_parser.cc +1 -5
  249. data/src/core/xds/grpc/xds_cluster_parser.h +0 -2
  250. data/src/core/xds/grpc/xds_cluster_specifier_plugin.cc +0 -2
  251. data/src/core/xds/grpc/xds_cluster_specifier_plugin.h +0 -2
  252. data/src/core/xds/grpc/xds_common_types.cc +0 -91
  253. data/src/core/xds/grpc/xds_common_types.h +1 -47
  254. data/src/core/xds/grpc/xds_common_types_parser.cc +84 -378
  255. data/src/core/xds/grpc/xds_common_types_parser.h +9 -11
  256. data/src/core/xds/grpc/xds_endpoint_parser.cc +0 -2
  257. data/src/core/xds/grpc/xds_grpc_service_parser.cc +177 -0
  258. data/src/core/{resolver/dns/c_ares/dns_resolver_ares.h → xds/grpc/xds_grpc_service_parser.h} +14 -9
  259. data/src/core/xds/grpc/xds_http_composite_filter.cc +26 -21
  260. data/src/core/xds/grpc/xds_http_composite_filter.h +4 -3
  261. data/src/core/xds/grpc/xds_http_ext_proc_filter.cc +418 -0
  262. data/src/core/xds/grpc/xds_http_ext_proc_filter.h +89 -0
  263. data/src/core/xds/grpc/xds_http_fault_filter.cc +9 -12
  264. data/src/core/xds/grpc/xds_http_fault_filter.h +1 -4
  265. data/src/core/xds/grpc/xds_http_filter.cc +2 -1
  266. data/src/core/xds/grpc/xds_http_filter.h +6 -5
  267. data/src/core/xds/grpc/xds_http_filter_registry.cc +10 -127
  268. data/src/core/xds/grpc/xds_http_filter_registry.h +7 -59
  269. data/src/core/xds/grpc/xds_http_gcp_authn_filter.cc +13 -14
  270. data/src/core/xds/grpc/xds_http_gcp_authn_filter.h +3 -2
  271. data/src/core/xds/grpc/xds_http_rbac_filter.cc +403 -25
  272. data/src/core/xds/grpc/xds_http_rbac_filter.h +1 -3
  273. data/src/core/xds/grpc/xds_http_stateful_session_filter.cc +8 -13
  274. data/src/core/xds/grpc/xds_http_stateful_session_filter.h +1 -4
  275. data/src/core/xds/grpc/xds_lb_policy_registry.cc +0 -292
  276. data/src/core/xds/grpc/xds_lb_policy_registry.h +7 -3
  277. data/src/core/xds/grpc/xds_listener.cc +2 -0
  278. data/src/core/xds/grpc/xds_listener.h +5 -0
  279. data/src/core/xds/grpc/xds_listener_parser.cc +16 -11
  280. data/src/core/xds/grpc/xds_matcher_parse.h +3 -1
  281. data/src/core/xds/grpc/xds_metadata_parser.cc +6 -1
  282. data/src/core/xds/grpc/xds_metadata_parser.h +2 -0
  283. data/src/core/xds/grpc/xds_route_config.cc +2 -0
  284. data/src/core/xds/grpc/xds_route_config.h +3 -1
  285. data/src/core/xds/grpc/xds_route_config_parser.cc +13 -79
  286. data/src/core/xds/grpc/xds_route_config_parser.h +0 -3
  287. data/src/core/xds/grpc/xds_routing.cc +116 -69
  288. data/src/core/xds/grpc/xds_routing.h +19 -8
  289. data/src/core/xds/grpc/xds_tls_context.cc +117 -0
  290. data/src/core/xds/grpc/xds_tls_context.h +76 -0
  291. data/src/core/xds/grpc/xds_tls_context_parser.cc +275 -0
  292. data/src/core/xds/grpc/xds_tls_context_parser.h +35 -0
  293. data/src/core/xds/grpc/xds_transport_grpc.cc +41 -38
  294. data/src/core/xds/grpc/xds_transport_grpc.h +4 -2
  295. data/src/ruby/ext/grpc/rb_call.c +26 -15
  296. data/src/ruby/ext/grpc/rb_completion_queue.c +6 -5
  297. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  298. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
  299. data/src/ruby/lib/grpc/version.rb +1 -1
  300. data/src/ruby/pb/test/client.rb +5 -4
  301. data/src/ruby/spec/call_spec.rb +14 -0
  302. data/src/ruby/spec/generic/server_interceptors_spec.rb +3 -6
  303. metadata +50 -35
  304. data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/channelz.upbdefs.c +0 -716
  305. data/src/core/lib/iomgr/resolve_address.cc +0 -59
  306. data/src/core/lib/iomgr/resolve_address.h +0 -125
  307. data/src/core/lib/iomgr/resolve_address_impl.h +0 -58
  308. data/src/core/lib/iomgr/resolve_address_posix.cc +0 -184
  309. data/src/core/lib/iomgr/resolve_address_posix.h +0 -78
  310. data/src/core/lib/iomgr/resolve_address_windows.cc +0 -169
  311. data/src/core/lib/iomgr/resolve_address_windows.h +0 -76
  312. data/src/core/resolver/dns/c_ares/dns_resolver_ares.cc +0 -781
  313. data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h +0 -93
  314. data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +0 -203
  315. data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +0 -838
  316. data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc +0 -1237
  317. data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h +0 -130
  318. data/src/core/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +0 -35
  319. data/src/core/resolver/dns/dns_resolver_plugin.cc +0 -64
  320. data/src/core/resolver/dns/native/dns_resolver.cc +0 -173
  321. data/src/core/util/json/json_util.cc +0 -101
  322. data/src/core/util/json/json_util.h +0 -163
@@ -1,59 +0,0 @@
1
- //
2
- //
3
- // Copyright 2018 gRPC authors.
4
- //
5
- // Licensed under the Apache License, Version 2.0 (the "License");
6
- // you may not use this file except in compliance with the License.
7
- // You may obtain a copy of the License at
8
- //
9
- // http://www.apache.org/licenses/LICENSE-2.0
10
- //
11
- // Unless required by applicable law or agreed to in writing, software
12
- // distributed under the License is distributed on an "AS IS" BASIS,
13
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- // See the License for the specific language governing permissions and
15
- // limitations under the License.
16
- //
17
- //
18
- #include "src/core/lib/iomgr/resolve_address.h"
19
-
20
- #include <grpc/event_engine/event_engine.h>
21
- #include <grpc/support/alloc.h>
22
- #include <grpc/support/port_platform.h>
23
-
24
- #include "src/core/util/crash.h"
25
- #include "src/core/util/no_destruct.h"
26
- #include "absl/strings/str_cat.h"
27
-
28
- namespace grpc_core {
29
- const char* kDefaultSecurePort = "https";
30
-
31
- namespace {
32
- NoDestruct<std::shared_ptr<DNSResolver>> g_dns_resolver;
33
- }
34
-
35
- const DNSResolver::LookupTaskHandle DNSResolver::LookupTaskHandle::kInvalid = {
36
- -1, -1};
37
- const DNSResolver::TaskHandle DNSResolver::kNullHandle = {0, 0};
38
-
39
- void ResetDNSResolver(std::shared_ptr<DNSResolver> resolver) {
40
- *g_dns_resolver = std::move(resolver);
41
- }
42
-
43
- std::shared_ptr<DNSResolver> GetDNSResolver() { return *g_dns_resolver; }
44
-
45
- bool operator==(const DNSResolver::LookupTaskHandle& lhs,
46
- const DNSResolver::LookupTaskHandle& rhs) {
47
- return lhs.keys[0] == rhs.keys[0] && lhs.keys[1] == rhs.keys[1];
48
- }
49
-
50
- bool operator!=(const DNSResolver::LookupTaskHandle& lhs,
51
- const DNSResolver::LookupTaskHandle& rhs) {
52
- return !(lhs == rhs);
53
- }
54
-
55
- std::string DNSResolver::HandleToString(TaskHandle handle) {
56
- return absl::StrCat("{", handle.keys[0], ",", handle.keys[1], "}");
57
- }
58
-
59
- } // namespace grpc_core
@@ -1,125 +0,0 @@
1
- //
2
- //
3
- // Copyright 2015 gRPC authors.
4
- //
5
- // Licensed under the Apache License, Version 2.0 (the "License");
6
- // you may not use this file except in compliance with the License.
7
- // You may obtain a copy of the License at
8
- //
9
- // http://www.apache.org/licenses/LICENSE-2.0
10
- //
11
- // Unless required by applicable law or agreed to in writing, software
12
- // distributed under the License is distributed on an "AS IS" BASIS,
13
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- // See the License for the specific language governing permissions and
15
- // limitations under the License.
16
- //
17
- //
18
-
19
- #ifndef GRPC_SRC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H
20
- #define GRPC_SRC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H
21
-
22
- #include <grpc/event_engine/event_engine.h>
23
- #include <grpc/support/port_platform.h>
24
- #include <stddef.h>
25
-
26
- #include "src/core/lib/event_engine/handle_containers.h"
27
- #include "src/core/lib/iomgr/pollset_set.h"
28
- #include "src/core/lib/iomgr/port.h"
29
- #include "src/core/lib/iomgr/resolved_address.h"
30
- #include "src/core/util/orphanable.h"
31
- #include "src/core/util/time.h"
32
- #include "absl/container/flat_hash_set.h"
33
- #include "absl/status/statusor.h"
34
-
35
- namespace grpc_core {
36
- extern const char* kDefaultSecurePort;
37
- constexpr int kDefaultSecurePortInt = 443;
38
- constexpr Duration kDefaultDNSRequestTimeout = Duration::Minutes(2);
39
-
40
- // A singleton class used for async and blocking DNS resolution
41
- class DNSResolver {
42
- public:
43
- /// Task handle for DNS Resolution requests.
44
- struct LookupTaskHandle {
45
- intptr_t keys[2];
46
- static const LookupTaskHandle kInvalid;
47
- friend bool operator==(const LookupTaskHandle& lhs,
48
- const LookupTaskHandle& rhs);
49
- friend bool operator!=(const LookupTaskHandle& lhs,
50
- const LookupTaskHandle& rhs);
51
- };
52
- using TaskHandle = LookupTaskHandle;
53
- using TaskHandleSet = absl::flat_hash_set<
54
- TaskHandle,
55
- grpc_event_engine::experimental::TaskHandleComparator<TaskHandle>::Hash>;
56
-
57
- static const TaskHandle kNullHandle;
58
-
59
- virtual ~DNSResolver() {}
60
-
61
- static std::string HandleToString(TaskHandle handle);
62
-
63
- // Asynchronously resolve name. Use \a default_port if a port isn't designated
64
- // in \a name, otherwise use the port in \a name. On completion, \a on_done is
65
- // invoked with the result.
66
- //
67
- // Note for implementations: calls may acquire locks in \a on_done which
68
- // were previously held while starting the request. Therefore,
69
- // implementations must not invoke \a on_done inline from the call site that
70
- // starts the request. The DNSCallbackExecCtxScheduler utility may help
71
- // address this.
72
- //
73
- // \a interested_parties may be deleted after a request is cancelled.
74
- virtual TaskHandle LookupHostname(
75
- std::function<void(absl::StatusOr<std::vector<grpc_resolved_address>>)>
76
- on_resolved,
77
- absl::string_view name, absl::string_view default_port, Duration timeout,
78
- grpc_pollset_set* interested_parties, absl::string_view name_server) = 0;
79
-
80
- // Resolve name in a blocking fashion. Use \a default_port if a port isn't
81
- // designated in \a name, otherwise use the port in \a name.
82
- virtual absl::StatusOr<std::vector<grpc_resolved_address>>
83
- LookupHostnameBlocking(absl::string_view name,
84
- absl::string_view default_port) = 0;
85
-
86
- // Asynchronously resolve an SRV Record to Hostnames.
87
- // On completion, \a on_done is invoked with the result.
88
- //
89
- // The same caveats in \a LookupHostname apply here as well.
90
- //
91
- // TODO(hork): return std::vector<SRVRecord> and ask the client to do the
92
- // subsequent hostname lookups.
93
- virtual TaskHandle LookupSRV(
94
- std::function<void(absl::StatusOr<std::vector<grpc_resolved_address>>)>
95
- on_resolved,
96
- absl::string_view name, Duration timeout,
97
- grpc_pollset_set* interested_parties, absl::string_view name_server) = 0;
98
-
99
- // Asynchronously resolve a TXT Record. On completion, \a on_done is invoked
100
- // with the resulting string.
101
- //
102
- // The same caveats in \a LookupHostname apply here.
103
- virtual TaskHandle LookupTXT(
104
- std::function<void(absl::StatusOr<std::string>)> on_resolved,
105
- absl::string_view name, Duration timeout,
106
- grpc_pollset_set* interested_parties, absl::string_view name_server) = 0;
107
-
108
- // This shares the same semantics with \a EventEngine::Cancel: successfully
109
- // cancelled lookups will not have their callbacks executed, and this
110
- // method returns true. If a TaskHandle is unknown, this method should return
111
- // false.
112
- virtual bool Cancel(TaskHandle handle) = 0;
113
- };
114
-
115
- // Override the active DNS resolver which should be used for all DNS
116
- // resolution in gRPC.
117
- void ResetDNSResolver(std::shared_ptr<DNSResolver> resolver);
118
-
119
- // Get the singleton DNS resolver instance which should be used for all
120
- // DNS resolution in gRPC.
121
- std::shared_ptr<DNSResolver> GetDNSResolver();
122
-
123
- } // namespace grpc_core
124
-
125
- #endif // GRPC_SRC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H
@@ -1,58 +0,0 @@
1
- //
2
- // Copyright 2015 gRPC authors.
3
- //
4
- // Licensed under the Apache License, Version 2.0 (the "License");
5
- // you may not use this file except in compliance with the License.
6
- // You may obtain a copy of the License at
7
- //
8
- // http://www.apache.org/licenses/LICENSE-2.0
9
- //
10
- // Unless required by applicable law or agreed to in writing, software
11
- // distributed under the License is distributed on an "AS IS" BASIS,
12
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- // See the License for the specific language governing permissions and
14
- // limitations under the License.
15
- //
16
-
17
- #ifndef GRPC_SRC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_IMPL_H
18
- #define GRPC_SRC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_IMPL_H
19
-
20
- #include <grpc/support/port_platform.h>
21
- #include <stddef.h>
22
-
23
- #include "src/core/lib/iomgr/exec_ctx.h"
24
- #include "src/core/lib/iomgr/port.h"
25
- #include "src/core/lib/iomgr/resolve_address.h"
26
-
27
- namespace grpc_core {
28
-
29
- // A fire and forget class to schedule DNS resolution callbacks on the ExecCtx,
30
- // which is frequently necessary to avoid lock inversion related problems.
31
- class DNSCallbackExecCtxScheduler {
32
- public:
33
- DNSCallbackExecCtxScheduler(
34
- std::function<void(absl::StatusOr<std::vector<grpc_resolved_address>>)>
35
- on_done,
36
- absl::StatusOr<std::vector<grpc_resolved_address>> param)
37
- : on_done_(std::move(on_done)), param_(std::move(param)) {
38
- GRPC_CLOSURE_INIT(&closure_, RunCallback, this, grpc_schedule_on_exec_ctx);
39
- ExecCtx::Run(DEBUG_LOCATION, &closure_, absl::OkStatus());
40
- }
41
-
42
- private:
43
- static void RunCallback(void* arg, grpc_error_handle /* error */) {
44
- DNSCallbackExecCtxScheduler* self =
45
- static_cast<DNSCallbackExecCtxScheduler*>(arg);
46
- self->on_done_(std::move(self->param_));
47
- delete self;
48
- }
49
-
50
- const std::function<void(absl::StatusOr<std::vector<grpc_resolved_address>>)>
51
- on_done_;
52
- absl::StatusOr<std::vector<grpc_resolved_address>> param_;
53
- grpc_closure closure_;
54
- };
55
-
56
- } // namespace grpc_core
57
-
58
- #endif // GRPC_SRC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_IMPL_H
@@ -1,184 +0,0 @@
1
- //
2
- //
3
- // Copyright 2015 gRPC authors.
4
- //
5
- // Licensed under the Apache License, Version 2.0 (the "License");
6
- // you may not use this file except in compliance with the License.
7
- // You may obtain a copy of the License at
8
- //
9
- // http://www.apache.org/licenses/LICENSE-2.0
10
- //
11
- // Unless required by applicable law or agreed to in writing, software
12
- // distributed under the License is distributed on an "AS IS" BASIS,
13
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- // See the License for the specific language governing permissions and
15
- // limitations under the License.
16
- //
17
- //
18
-
19
- #include <grpc/support/port_platform.h>
20
-
21
- #include "src/core/lib/iomgr/port.h"
22
- #ifdef GRPC_POSIX_SOCKET_RESOLVE_ADDRESS
23
-
24
- #include <grpc/event_engine/event_engine.h>
25
- #include <grpc/support/alloc.h>
26
- #include <grpc/support/string_util.h>
27
- #include <grpc/support/time.h>
28
- #include <string.h>
29
- #include <sys/types.h>
30
-
31
- #include <atomic>
32
- #include <functional>
33
- #include <memory>
34
- #include <string>
35
- #include <utility>
36
- #include <vector>
37
-
38
- #include "src/core/lib/iomgr/block_annotate.h"
39
- #include "src/core/lib/iomgr/error.h"
40
- #include "src/core/lib/iomgr/exec_ctx.h"
41
- #include "src/core/lib/iomgr/resolve_address.h"
42
- #include "src/core/lib/iomgr/resolve_address_posix.h"
43
- #include "src/core/lib/iomgr/resolved_address.h"
44
- #include "src/core/lib/transport/error_utils.h"
45
- #include "src/core/util/host_port.h"
46
- #include "src/core/util/time.h"
47
- #include "src/core/util/useful.h"
48
- #include "absl/status/status.h"
49
- #include "absl/status/statusor.h"
50
- #include "absl/strings/str_cat.h"
51
- #include "absl/strings/string_view.h"
52
- namespace grpc_core {
53
-
54
- grpc_event_engine::experimental::EventEngine* NativeDNSResolver::engine() {
55
- // Optimistically, if the engine is already created, return it.
56
- auto engine_ptr = engine_ptr_.load(std::memory_order_relaxed);
57
- if (engine_ptr != nullptr) return engine_ptr;
58
- // Otherwise, create the engine under the lock.
59
- // This is only if some other thread did not already create it.
60
- MutexLock lock(&mu_);
61
- if (engine_ != nullptr) return engine_.get();
62
- engine_ = grpc_event_engine::experimental::GetDefaultEventEngine();
63
- engine_ptr_.store(engine_.get(), std::memory_order_relaxed);
64
- return engine_.get();
65
- }
66
-
67
- DNSResolver::TaskHandle NativeDNSResolver::LookupHostname(
68
- std::function<void(absl::StatusOr<std::vector<grpc_resolved_address>>)>
69
- on_done,
70
- absl::string_view name, absl::string_view default_port,
71
- Duration /* timeout */, grpc_pollset_set* /* interested_parties */,
72
- absl::string_view /* name_server */) {
73
- engine()->Run([on_done = std::move(on_done), name = std::string(name),
74
- default_port = std::string(default_port)]() {
75
- ExecCtx exec_ctx;
76
- auto result = GetDNSResolver()->LookupHostnameBlocking(name, default_port);
77
- on_done(std::move(result));
78
- });
79
- return kNullHandle;
80
- }
81
-
82
- absl::StatusOr<std::vector<grpc_resolved_address>>
83
- NativeDNSResolver::LookupHostnameBlocking(absl::string_view name,
84
- absl::string_view default_port) {
85
- ExecCtx exec_ctx;
86
- struct addrinfo hints;
87
- struct addrinfo *result = nullptr, *resp;
88
- int s;
89
- size_t i;
90
- grpc_error_handle err;
91
- std::vector<grpc_resolved_address> addresses;
92
- std::string host;
93
- std::string port;
94
- // parse name, splitting it into host and port parts
95
- SplitHostPort(name, &host, &port);
96
- if (host.empty()) {
97
- err =
98
- GRPC_ERROR_CREATE(absl::StrCat("unparsable host:port \"", name, "\""));
99
- goto done;
100
- }
101
- if (port.empty()) {
102
- if (default_port.empty()) {
103
- err = GRPC_ERROR_CREATE(absl::StrCat("no port in name \"", name, "\""));
104
- goto done;
105
- }
106
- port = std::string(default_port);
107
- }
108
- // Call getaddrinfo
109
- memset(&hints, 0, sizeof(hints));
110
- hints.ai_family = AF_UNSPEC; // ipv4 or ipv6
111
- hints.ai_socktype = SOCK_STREAM; // stream socket
112
- hints.ai_flags = AI_PASSIVE; // for wildcard IP address
113
- GRPC_SCHEDULING_START_BLOCKING_REGION;
114
- s = getaddrinfo(host.c_str(), port.c_str(), &hints, &result);
115
- GRPC_SCHEDULING_END_BLOCKING_REGION;
116
- if (s != 0) {
117
- // Retry if well-known service name is recognized
118
- const char* svc[][2] = {{"http", "80"}, {"https", "443"}};
119
- for (i = 0; i < GPR_ARRAY_SIZE(svc); i++) {
120
- if (port == svc[i][0]) {
121
- GRPC_SCHEDULING_START_BLOCKING_REGION;
122
- s = getaddrinfo(host.c_str(), svc[i][1], &hints, &result);
123
- GRPC_SCHEDULING_END_BLOCKING_REGION;
124
- break;
125
- }
126
- }
127
- }
128
- if (s != 0) {
129
- err = absl::UnknownError(absl::StrCat(
130
- "getaddrinfo(\"", name, "\"): ", gai_strerror(s), " (", s, ")"));
131
- goto done;
132
- }
133
- // Success path: fill in addrs
134
- for (resp = result; resp != nullptr; resp = resp->ai_next) {
135
- grpc_resolved_address addr;
136
- memcpy(&addr.addr, resp->ai_addr, resp->ai_addrlen);
137
- addr.len = resp->ai_addrlen;
138
- addresses.push_back(addr);
139
- }
140
- err = absl::OkStatus();
141
- done:
142
- if (result) {
143
- freeaddrinfo(result);
144
- }
145
- if (err.ok()) {
146
- return addresses;
147
- }
148
- auto error_result = grpc_error_to_absl_status(err);
149
- return error_result;
150
- }
151
-
152
- DNSResolver::TaskHandle NativeDNSResolver::LookupSRV(
153
- std::function<void(absl::StatusOr<std::vector<grpc_resolved_address>>)>
154
- on_resolved,
155
- absl::string_view /* name */, Duration /* timeout */,
156
- grpc_pollset_set* /* interested_parties */,
157
- absl::string_view /* name_server */) {
158
- engine()->Run([on_resolved] {
159
- ExecCtx exec_ctx;
160
- on_resolved(absl::UnimplementedError(
161
- "The Native resolver does not support looking up SRV records"));
162
- });
163
- return kNullHandle;
164
- };
165
-
166
- DNSResolver::TaskHandle NativeDNSResolver::LookupTXT(
167
- std::function<void(absl::StatusOr<std::string>)> on_resolved,
168
- absl::string_view /* name */, Duration /* timeout */,
169
- grpc_pollset_set* /* interested_parties */,
170
- absl::string_view /* name_server */) {
171
- // Not supported
172
- engine()->Run([on_resolved] {
173
- ExecCtx exec_ctx;
174
- on_resolved(absl::UnimplementedError(
175
- "The Native resolver does not support looking up TXT records"));
176
- });
177
- return kNullHandle;
178
- };
179
-
180
- bool NativeDNSResolver::Cancel(TaskHandle /*handle*/) { return false; }
181
-
182
- } // namespace grpc_core
183
-
184
- #endif
@@ -1,78 +0,0 @@
1
- //
2
- // Copyright 2015 gRPC authors.
3
- //
4
- // Licensed under the Apache License, Version 2.0 (the "License");
5
- // you may not use this file except in compliance with the License.
6
- // You may obtain a copy of the License at
7
- //
8
- // http://www.apache.org/licenses/LICENSE-2.0
9
- //
10
- // Unless required by applicable law or agreed to in writing, software
11
- // distributed under the License is distributed on an "AS IS" BASIS,
12
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- // See the License for the specific language governing permissions and
14
- // limitations under the License.
15
- //
16
-
17
- #ifndef GRPC_SRC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_POSIX_H
18
- #define GRPC_SRC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_POSIX_H
19
-
20
- #include <grpc/support/port_platform.h>
21
-
22
- #include <functional>
23
- #include <memory>
24
-
25
- #include "src/core/lib/iomgr/port.h"
26
- #include "src/core/lib/iomgr/resolve_address.h"
27
- #include "src/core/util/sync.h"
28
-
29
- namespace grpc_core {
30
-
31
- // A DNS resolver which uses the native platform's getaddrinfo API.
32
- class NativeDNSResolver : public DNSResolver {
33
- public:
34
- NativeDNSResolver() = default;
35
-
36
- TaskHandle LookupHostname(
37
- std::function<void(absl::StatusOr<std::vector<grpc_resolved_address>>)>
38
- on_done,
39
- absl::string_view name, absl::string_view default_port, Duration timeout,
40
- grpc_pollset_set* interested_parties,
41
- absl::string_view name_server) override;
42
-
43
- absl::StatusOr<std::vector<grpc_resolved_address>> LookupHostnameBlocking(
44
- absl::string_view name, absl::string_view default_port) override;
45
-
46
- TaskHandle LookupSRV(
47
- std::function<void(absl::StatusOr<std::vector<grpc_resolved_address>>)>
48
- on_resolved,
49
- absl::string_view name, Duration timeout,
50
- grpc_pollset_set* interested_parties,
51
- absl::string_view name_server) override;
52
-
53
- TaskHandle LookupTXT(
54
- std::function<void(absl::StatusOr<std::string>)> on_resolved,
55
- absl::string_view name, Duration timeout,
56
- grpc_pollset_set* interested_parties,
57
- absl::string_view name_server) override;
58
-
59
- // NativeDNSResolver does not support cancellation.
60
- bool Cancel(TaskHandle handle) override;
61
-
62
- private:
63
- // Lazily instantiate and return a pointer to the owned EventEngine.
64
- // The engine needs to be lazily instantiated to avoid a mutex reacquisition,
65
- // because the NativeDNSResolver is created in grpc_init, and creating an
66
- // EventEngine calls grpc_init.
67
- grpc_event_engine::experimental::EventEngine* engine();
68
-
69
- Mutex mu_;
70
- std::shared_ptr<grpc_event_engine::experimental::EventEngine> engine_
71
- ABSL_GUARDED_BY(mu_);
72
- std::atomic<grpc_event_engine::experimental::EventEngine*> engine_ptr_{
73
- nullptr};
74
- };
75
-
76
- } // namespace grpc_core
77
-
78
- #endif // GRPC_SRC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_POSIX_H
@@ -1,169 +0,0 @@
1
- //
2
- // Copyright 2015 gRPC authors.
3
- //
4
- // Licensed under the Apache License, Version 2.0 (the "License");
5
- // you may not use this file except in compliance with the License.
6
- // You may obtain a copy of the License at
7
- //
8
- // http://www.apache.org/licenses/LICENSE-2.0
9
- //
10
- // Unless required by applicable law or agreed to in writing, software
11
- // distributed under the License is distributed on an "AS IS" BASIS,
12
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- // See the License for the specific language governing permissions and
14
- // limitations under the License.
15
- //
16
-
17
- #include <grpc/support/port_platform.h>
18
-
19
- #include "src/core/lib/iomgr/port.h"
20
- #ifdef GRPC_WINSOCK_SOCKET
21
-
22
- #include <grpc/support/alloc.h>
23
- #include <grpc/support/log_windows.h>
24
- #include <grpc/support/string_util.h>
25
- #include <grpc/support/time.h>
26
- #include <inttypes.h>
27
- #include <string.h>
28
- #include <sys/types.h>
29
-
30
- #include <string>
31
-
32
- #include "src/core/lib/address_utils/sockaddr_utils.h"
33
- #include "src/core/lib/event_engine/default_event_engine.h"
34
- #include "src/core/lib/iomgr/block_annotate.h"
35
- #include "src/core/lib/iomgr/exec_ctx.h"
36
- #include "src/core/lib/iomgr/iomgr_internal.h"
37
- #include "src/core/lib/iomgr/resolve_address.h"
38
- #include "src/core/lib/iomgr/resolve_address_windows.h"
39
- #include "src/core/lib/iomgr/sockaddr.h"
40
- #include "src/core/lib/transport/error_utils.h"
41
- #include "src/core/util/crash.h"
42
- #include "src/core/util/host_port.h"
43
- #include "src/core/util/string.h"
44
- #include "src/core/util/thd.h"
45
- #include "absl/strings/str_format.h"
46
-
47
- namespace grpc_core {
48
-
49
- grpc_event_engine::experimental::EventEngine* NativeDNSResolver::engine() {
50
- // Optimistically, if the engine is already created, return it.
51
- auto engine_ptr = engine_ptr_.load(std::memory_order_relaxed);
52
- if (engine_ptr != nullptr) return engine_ptr;
53
- // Otherwise, create the engine under the lock.
54
- // This is only if some other thread did not already create it.
55
- MutexLock lock(&mu_);
56
- if (engine_ != nullptr) return engine_.get();
57
- engine_ = grpc_event_engine::experimental::GetDefaultEventEngine();
58
- engine_ptr_.store(engine_.get(), std::memory_order_relaxed);
59
- return engine_.get();
60
- }
61
-
62
- DNSResolver::TaskHandle NativeDNSResolver::LookupHostname(
63
- std::function<void(absl::StatusOr<std::vector<grpc_resolved_address>>)>
64
- on_resolved,
65
- absl::string_view name, absl::string_view default_port,
66
- Duration /* timeout */, grpc_pollset_set* /* interested_parties */,
67
- absl::string_view /* name_server */) {
68
- engine()->Run([on_resolved = std::move(on_resolved), name = std::string(name),
69
- default_port = std::string(default_port)]() {
70
- ExecCtx exec_ctx;
71
- auto result = GetDNSResolver()->LookupHostnameBlocking(name, default_port);
72
- on_resolved(std::move(result));
73
- });
74
- return kNullHandle;
75
- }
76
-
77
- absl::StatusOr<std::vector<grpc_resolved_address>>
78
- NativeDNSResolver::LookupHostnameBlocking(absl::string_view name,
79
- absl::string_view default_port) {
80
- ExecCtx exec_ctx;
81
- struct addrinfo hints;
82
- struct addrinfo *result = NULL, *resp;
83
- int s;
84
- grpc_error_handle error;
85
- std::vector<grpc_resolved_address> addresses;
86
-
87
- // parse name, splitting it into host and port parts
88
- std::string host;
89
- std::string port;
90
- SplitHostPort(name, &host, &port);
91
- if (host.empty()) {
92
- error =
93
- GRPC_ERROR_CREATE(absl::StrFormat("unparsable host:port: '%s'", name));
94
- goto done;
95
- }
96
- if (port.empty()) {
97
- if (default_port.empty()) {
98
- error = GRPC_ERROR_CREATE(absl::StrFormat("no port in name '%s'", name));
99
- goto done;
100
- }
101
- port = std::string(default_port);
102
- }
103
-
104
- // Call getaddrinfo
105
- memset(&hints, 0, sizeof(hints));
106
- hints.ai_family = AF_UNSPEC; // ipv4 or ipv6
107
- hints.ai_socktype = SOCK_STREAM; // stream socket
108
- hints.ai_flags = AI_PASSIVE; // for wildcard IP address
109
-
110
- GRPC_SCHEDULING_START_BLOCKING_REGION;
111
- s = getaddrinfo(host.c_str(), port.c_str(), &hints, &result);
112
- GRPC_SCHEDULING_END_BLOCKING_REGION;
113
- if (s != 0) {
114
- error = GRPC_WSA_ERROR(WSAGetLastError(), "getaddrinfo");
115
- goto done;
116
- }
117
-
118
- // Success path: set addrs non-NULL, fill it in
119
- for (resp = result; resp != NULL; resp = resp->ai_next) {
120
- grpc_resolved_address addr;
121
- memcpy(&addr.addr, resp->ai_addr, resp->ai_addrlen);
122
- addr.len = resp->ai_addrlen;
123
- addresses.push_back(addr);
124
- }
125
-
126
- done:
127
- if (result) {
128
- freeaddrinfo(result);
129
- }
130
- if (error.ok()) {
131
- return addresses;
132
- }
133
- auto error_result = grpc_error_to_absl_status(error);
134
- return error_result;
135
- }
136
-
137
- DNSResolver::TaskHandle NativeDNSResolver::LookupSRV(
138
- std::function<void(absl::StatusOr<std::vector<grpc_resolved_address>>)>
139
- on_resolved,
140
- absl::string_view /* name */, Duration /* deadline */,
141
- grpc_pollset_set* /* interested_parties */,
142
- absl::string_view /* name_server */) {
143
- engine()->Run([on_resolved] {
144
- ExecCtx exec_ctx;
145
- on_resolved(absl::UnimplementedError(
146
- "The Native resolver does not support looking up SRV records"));
147
- });
148
- return kNullHandle;
149
- };
150
-
151
- DNSResolver::TaskHandle NativeDNSResolver::LookupTXT(
152
- std::function<void(absl::StatusOr<std::string>)> on_resolved,
153
- absl::string_view /* name */, Duration /* timeout */,
154
- grpc_pollset_set* /* interested_parties */,
155
- absl::string_view /* name_server */) {
156
- // Not supported
157
- engine()->Run([on_resolved] {
158
- ExecCtx exec_ctx;
159
- on_resolved(absl::UnimplementedError(
160
- "The Native resolver does not support looking up TXT records"));
161
- });
162
- return kNullHandle;
163
- };
164
-
165
- bool NativeDNSResolver::Cancel(TaskHandle /*handle*/) { return false; }
166
-
167
- } // namespace grpc_core
168
-
169
- #endif