grpc 1.36.0 → 1.37.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +65 -37
- data/include/grpc/grpc.h +15 -1
- data/include/grpc/impl/codegen/port_platform.h +2 -0
- data/src/core/ext/filters/client_channel/client_channel.cc +327 -305
- data/src/core/ext/filters/client_channel/client_channel_factory.h +2 -1
- data/src/core/ext/filters/client_channel/config_selector.h +8 -0
- data/src/core/ext/filters/client_channel/dynamic_filters.cc +9 -4
- data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +24 -142
- data/src/core/ext/filters/client_channel/global_subchannel_pool.h +15 -10
- data/src/core/ext/filters/client_channel/lb_policy.cc +3 -0
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +23 -0
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +27 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +7 -22
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +2 -2
- data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +27 -67
- data/src/core/ext/filters/client_channel/local_subchannel_pool.h +10 -9
- data/src/core/ext/filters/client_channel/resolver.cc +3 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +3 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +5 -9
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +18 -3
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +295 -91
- data/src/core/ext/filters/client_channel/server_address.cc +3 -0
- data/src/core/ext/filters/client_channel/subchannel.cc +69 -146
- data/src/core/ext/filters/client_channel/subchannel.h +63 -95
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +16 -2
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +10 -8
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +1 -1
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +495 -0
- data/src/core/ext/filters/fault_injection/fault_injection_filter.h +39 -0
- data/src/core/ext/filters/fault_injection/service_config_parser.cc +189 -0
- data/src/core/ext/filters/fault_injection/service_config_parser.h +85 -0
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +1 -1
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +1 -1
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +3 -2
- data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +1 -1
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +3 -2
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +457 -170
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +39 -7
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +12 -1
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +5 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/internal.h +1 -0
- data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.c +406 -0
- data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.h +1459 -0
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +350 -0
- data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +1348 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +6 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +25 -0
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.c +144 -0
- data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.h +488 -0
- data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.c +141 -0
- data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.h +452 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +15 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +44 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.c +79 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.h +268 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +78 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +281 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +41 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +113 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +6 -5
- data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +13 -9
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +93 -0
- data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +323 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.c +36 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.h +90 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.c +46 -0
- data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.h +124 -0
- data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.c +33 -0
- data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.h +77 -0
- data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump.upbdefs.c +354 -0
- data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump.upbdefs.h +140 -0
- data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +383 -0
- data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.h +115 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +10 -7
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/metrics/v3/stats.upbdefs.c +141 -0
- data/src/core/ext/upbdefs-generated/envoy/config/metrics/v3/stats.upbdefs.h +70 -0
- data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.c +141 -0
- data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.h +70 -0
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +13 -7
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/common/fault/v3/fault.upbdefs.c +102 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/common/fault/v3/fault.upbdefs.h +55 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +120 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.h +45 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +76 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.h +35 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +21 -20
- data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c +130 -0
- data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.h +50 -0
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/node.upbdefs.c +56 -0
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/node.upbdefs.h +35 -0
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/struct.upbdefs.c +63 -0
- data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/struct.upbdefs.h +40 -0
- data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.c +44 -0
- data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.h +35 -0
- data/src/core/ext/xds/xds_api.cc +1591 -279
- data/src/core/ext/xds/xds_api.h +279 -39
- data/src/core/ext/xds/xds_bootstrap.cc +21 -5
- data/src/core/ext/xds/xds_bootstrap.h +5 -1
- data/src/core/ext/xds/xds_client.cc +168 -23
- data/src/core/ext/xds/xds_client.h +26 -0
- data/src/core/ext/xds/xds_client_stats.h +2 -2
- data/src/core/ext/xds/xds_http_fault_filter.cc +226 -0
- data/src/core/ext/xds/xds_http_fault_filter.h +63 -0
- data/src/core/ext/xds/xds_http_filters.cc +114 -0
- data/src/core/ext/xds/xds_http_filters.h +130 -0
- data/src/core/ext/xds/xds_server_config_fetcher.cc +391 -126
- data/src/core/lib/channel/channel_stack.cc +12 -0
- data/src/core/lib/channel/channel_stack.h +7 -0
- data/src/core/lib/channel/channelz.cc +92 -4
- data/src/core/lib/channel/channelz.h +30 -1
- data/src/core/lib/channel/channelz_registry.cc +14 -0
- data/src/core/lib/channel/handshaker.cc +0 -39
- data/src/core/lib/channel/handshaker.h +0 -17
- data/src/core/lib/channel/status_util.cc +12 -2
- data/src/core/lib/channel/status_util.h +5 -0
- data/src/core/lib/gpr/sync_abseil.cc +3 -6
- data/src/core/lib/gpr/sync_windows.cc +2 -2
- data/src/core/lib/gprpp/atomic.h +3 -3
- data/src/core/lib/gprpp/dual_ref_counted.h +3 -3
- data/src/core/lib/gprpp/ref_counted_ptr.h +2 -0
- data/src/core/lib/gprpp/thd.h +1 -1
- data/src/core/lib/iomgr/buffer_list.h +1 -1
- data/src/core/lib/iomgr/cfstream_handle.cc +2 -2
- data/src/core/lib/iomgr/error.h +1 -1
- data/src/core/lib/iomgr/ev_apple.cc +1 -1
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +3 -3
- data/src/core/lib/iomgr/ev_posix.cc +3 -3
- data/src/core/lib/iomgr/exec_ctx.cc +6 -2
- data/src/core/lib/iomgr/resource_quota.cc +1 -1
- data/src/core/lib/iomgr/sockaddr_utils.cc +120 -0
- data/src/core/lib/iomgr/sockaddr_utils.h +25 -0
- data/src/core/lib/iomgr/tcp_posix.cc +1 -4
- data/src/core/lib/iomgr/tcp_uv.cc +2 -2
- data/src/core/lib/iomgr/timer_generic.cc +2 -2
- data/src/core/lib/iomgr/timer_manager.cc +1 -1
- data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +1 -1
- data/src/core/lib/{security/authorization → matchers}/matchers.cc +8 -8
- data/src/core/lib/{security/authorization → matchers}/matchers.h +14 -12
- data/src/core/lib/security/security_connector/ssl_utils.cc +6 -4
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +6 -0
- data/src/core/lib/security/transport/security_handshaker.cc +32 -2
- data/src/core/lib/slice/slice_intern.cc +6 -7
- data/src/core/lib/surface/channel.h +3 -3
- data/src/core/lib/surface/completion_queue.cc +1 -1
- data/src/core/lib/surface/lame_client.cc +38 -19
- data/src/core/lib/surface/lame_client.h +4 -3
- data/src/core/lib/surface/server.cc +40 -33
- data/src/core/lib/surface/server.h +74 -15
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/metadata_batch.cc +27 -0
- data/src/core/lib/transport/metadata_batch.h +14 -0
- data/src/core/plugin_registry/grpc_plugin_registry.cc +6 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -4
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +1 -1
- data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +1 -3
- data/src/core/tsi/fake_transport_security.cc +10 -1
- data/src/ruby/ext/grpc/extconf.rb +9 -1
- data/src/ruby/ext/grpc/rb_channel.c +10 -1
- data/src/ruby/ext/grpc/rb_channel_credentials.c +11 -1
- data/src/ruby/ext/grpc/rb_channel_credentials.h +4 -0
- data/src/ruby/ext/grpc/rb_compression_options.c +1 -1
- data/src/ruby/ext/grpc/rb_enable_cpp.cc +1 -1
- data/src/ruby/ext/grpc/rb_grpc.c +4 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +4 -1
- data/src/ruby/ext/grpc/rb_server.c +13 -1
- data/src/ruby/ext/grpc/rb_server_credentials.c +19 -3
- data/src/ruby/ext/grpc/rb_server_credentials.h +4 -0
- data/src/ruby/ext/grpc/rb_xds_channel_credentials.c +215 -0
- data/src/ruby/ext/grpc/rb_xds_channel_credentials.h +35 -0
- data/src/ruby/ext/grpc/rb_xds_server_credentials.c +169 -0
- data/src/ruby/ext/grpc/rb_xds_server_credentials.h +35 -0
- data/src/ruby/lib/grpc/generic/client_stub.rb +4 -2
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/call_spec.rb +1 -1
- data/src/ruby/spec/channel_credentials_spec.rb +32 -0
- data/src/ruby/spec/channel_spec.rb +17 -6
- data/src/ruby/spec/client_auth_spec.rb +27 -1
- data/src/ruby/spec/errors_spec.rb +1 -1
- data/src/ruby/spec/generic/active_call_spec.rb +2 -2
- data/src/ruby/spec/generic/client_stub_spec.rb +4 -4
- data/src/ruby/spec/generic/rpc_server_spec.rb +1 -1
- data/src/ruby/spec/server_credentials_spec.rb +25 -0
- data/src/ruby/spec/server_spec.rb +22 -0
- data/third_party/boringssl-with-bazel/err_data.c +255 -255
- data/third_party/boringssl-with-bazel/src/crypto/cpu-arm-linux.c +11 -2
- data/third_party/boringssl-with-bazel/src/crypto/cpu-arm.c +3 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +21 -13
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +7 -5
- data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +0 -28
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.c +22 -17
- data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +3 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +4 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/cpu.h +22 -32
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +25 -9
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +0 -1
- data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +33 -19
- data/third_party/xxhash/xxhash.h +5443 -0
- metadata +93 -49
- data/src/core/lib/security/authorization/authorization_engine.cc +0 -177
- data/src/core/lib/security/authorization/authorization_engine.h +0 -84
- data/src/core/lib/security/authorization/evaluate_args.cc +0 -148
- data/src/core/lib/security/authorization/evaluate_args.h +0 -59
- data/src/core/lib/security/authorization/mock_cel/activation.h +0 -57
- data/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h +0 -44
- data/src/core/lib/security/authorization/mock_cel/cel_expression.h +0 -69
- data/src/core/lib/security/authorization/mock_cel/cel_value.h +0 -99
- data/src/core/lib/security/authorization/mock_cel/evaluator_core.h +0 -67
- data/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h +0 -57
- data/third_party/abseil-cpp/absl/container/flat_hash_set.h +0 -504
- data/third_party/upb/upb/json_decode.c +0 -1443
- data/third_party/upb/upb/json_decode.h +0 -23
- data/third_party/upb/upb/json_encode.c +0 -713
- data/third_party/upb/upb/json_encode.h +0 -36
data/src/ruby/ext/grpc/rb_grpc.c
CHANGED
@@ -40,6 +40,8 @@
|
|
40
40
|
#include "rb_loader.h"
|
41
41
|
#include "rb_server.h"
|
42
42
|
#include "rb_server_credentials.h"
|
43
|
+
#include "rb_xds_channel_credentials.h"
|
44
|
+
#include "rb_xds_server_credentials.h"
|
43
45
|
|
44
46
|
static VALUE grpc_rb_cTimeVal = Qnil;
|
45
47
|
|
@@ -321,8 +323,10 @@ void Init_grpc_c() {
|
|
321
323
|
Init_grpc_call();
|
322
324
|
Init_grpc_call_credentials();
|
323
325
|
Init_grpc_channel_credentials();
|
326
|
+
Init_grpc_xds_channel_credentials();
|
324
327
|
Init_grpc_server();
|
325
328
|
Init_grpc_server_credentials();
|
329
|
+
Init_grpc_xds_server_credentials();
|
326
330
|
Init_grpc_time_consts();
|
327
331
|
Init_grpc_compression_options();
|
328
332
|
}
|
@@ -98,6 +98,7 @@ grpc_resource_quota_ref_type grpc_resource_quota_ref_import;
|
|
98
98
|
grpc_resource_quota_unref_type grpc_resource_quota_unref_import;
|
99
99
|
grpc_resource_quota_resize_type grpc_resource_quota_resize_import;
|
100
100
|
grpc_resource_quota_set_max_threads_type grpc_resource_quota_set_max_threads_import;
|
101
|
+
grpc_dump_xds_configs_type grpc_dump_xds_configs_import;
|
101
102
|
grpc_resource_quota_arg_vtable_type grpc_resource_quota_arg_vtable_import;
|
102
103
|
grpc_channelz_get_top_channels_type grpc_channelz_get_top_channels_import;
|
103
104
|
grpc_channelz_get_servers_type grpc_channelz_get_servers_import;
|
@@ -382,6 +383,7 @@ void grpc_rb_load_imports(HMODULE library) {
|
|
382
383
|
grpc_resource_quota_unref_import = (grpc_resource_quota_unref_type) GetProcAddress(library, "grpc_resource_quota_unref");
|
383
384
|
grpc_resource_quota_resize_import = (grpc_resource_quota_resize_type) GetProcAddress(library, "grpc_resource_quota_resize");
|
384
385
|
grpc_resource_quota_set_max_threads_import = (grpc_resource_quota_set_max_threads_type) GetProcAddress(library, "grpc_resource_quota_set_max_threads");
|
386
|
+
grpc_dump_xds_configs_import = (grpc_dump_xds_configs_type) GetProcAddress(library, "grpc_dump_xds_configs");
|
385
387
|
grpc_resource_quota_arg_vtable_import = (grpc_resource_quota_arg_vtable_type) GetProcAddress(library, "grpc_resource_quota_arg_vtable");
|
386
388
|
grpc_channelz_get_top_channels_import = (grpc_channelz_get_top_channels_type) GetProcAddress(library, "grpc_channelz_get_top_channels");
|
387
389
|
grpc_channelz_get_servers_import = (grpc_channelz_get_servers_type) GetProcAddress(library, "grpc_channelz_get_servers");
|
@@ -215,7 +215,7 @@ extern grpc_server_create_type grpc_server_create_import;
|
|
215
215
|
typedef void(*grpc_server_register_completion_queue_type)(grpc_server* server, grpc_completion_queue* cq, void* reserved);
|
216
216
|
extern grpc_server_register_completion_queue_type grpc_server_register_completion_queue_import;
|
217
217
|
#define grpc_server_register_completion_queue grpc_server_register_completion_queue_import
|
218
|
-
typedef grpc_server_config_fetcher*(*grpc_server_config_fetcher_xds_create_type)();
|
218
|
+
typedef grpc_server_config_fetcher*(*grpc_server_config_fetcher_xds_create_type)(grpc_server_xds_status_notifier notifier);
|
219
219
|
extern grpc_server_config_fetcher_xds_create_type grpc_server_config_fetcher_xds_create_import;
|
220
220
|
#define grpc_server_config_fetcher_xds_create grpc_server_config_fetcher_xds_create_import
|
221
221
|
typedef void(*grpc_server_config_fetcher_destroy_type)(grpc_server_config_fetcher* config_fetcher);
|
@@ -269,6 +269,9 @@ extern grpc_resource_quota_resize_type grpc_resource_quota_resize_import;
|
|
269
269
|
typedef void(*grpc_resource_quota_set_max_threads_type)(grpc_resource_quota* resource_quota, int new_max_threads);
|
270
270
|
extern grpc_resource_quota_set_max_threads_type grpc_resource_quota_set_max_threads_import;
|
271
271
|
#define grpc_resource_quota_set_max_threads grpc_resource_quota_set_max_threads_import
|
272
|
+
typedef grpc_slice(*grpc_dump_xds_configs_type)();
|
273
|
+
extern grpc_dump_xds_configs_type grpc_dump_xds_configs_import;
|
274
|
+
#define grpc_dump_xds_configs grpc_dump_xds_configs_import
|
272
275
|
typedef const grpc_arg_pointer_vtable*(*grpc_resource_quota_arg_vtable_type)(void);
|
273
276
|
extern grpc_resource_quota_arg_vtable_type grpc_resource_quota_arg_vtable_import;
|
274
277
|
#define grpc_resource_quota_arg_vtable grpc_resource_quota_arg_vtable_import
|
@@ -31,6 +31,7 @@
|
|
31
31
|
#include "rb_completion_queue.h"
|
32
32
|
#include "rb_grpc.h"
|
33
33
|
#include "rb_server_credentials.h"
|
34
|
+
#include "rb_xds_server_credentials.h"
|
34
35
|
|
35
36
|
/* grpc_rb_cServer is the ruby class that proxies grpc_server. */
|
36
37
|
static VALUE grpc_rb_cServer = Qnil;
|
@@ -326,7 +327,18 @@ static VALUE grpc_rb_server_add_http2_port(VALUE self, VALUE port,
|
|
326
327
|
StringValueCStr(port));
|
327
328
|
}
|
328
329
|
} else {
|
329
|
-
|
330
|
+
// TODO: create a common parent class for all server-side credentials,
|
331
|
+
// then we can have a single method to retrieve the underlying
|
332
|
+
// grpc_server_credentials object, and avoid the need for this reflection
|
333
|
+
if (grpc_rb_is_server_credentials(rb_creds)) {
|
334
|
+
creds = grpc_rb_get_wrapped_server_credentials(rb_creds);
|
335
|
+
} else if (grpc_rb_is_xds_server_credentials(rb_creds)) {
|
336
|
+
creds = grpc_rb_get_wrapped_xds_server_credentials(rb_creds);
|
337
|
+
} else {
|
338
|
+
rb_raise(rb_eTypeError,
|
339
|
+
"failed to create server because credentials parameter has an "
|
340
|
+
"invalid type, want ServerCredentials or XdsServerCredentials");
|
341
|
+
}
|
330
342
|
recvd_port = grpc_server_add_secure_http2_port(
|
331
343
|
s->wrapped, StringValueCStr(port), creds);
|
332
344
|
if (recvd_port == 0) {
|
@@ -42,7 +42,7 @@ typedef struct grpc_rb_server_credentials {
|
|
42
42
|
} grpc_rb_server_credentials;
|
43
43
|
|
44
44
|
/* Destroys the server credentials instances. */
|
45
|
-
static void
|
45
|
+
static void grpc_rb_server_credentials_free_internal(void* p) {
|
46
46
|
grpc_rb_server_credentials* wrapper = NULL;
|
47
47
|
if (p == NULL) {
|
48
48
|
return;
|
@@ -59,6 +59,12 @@ static void grpc_rb_server_credentials_free(void* p) {
|
|
59
59
|
xfree(p);
|
60
60
|
}
|
61
61
|
|
62
|
+
/* Destroys the server credentials instances. */
|
63
|
+
static void grpc_rb_server_credentials_free(void* p) {
|
64
|
+
grpc_rb_server_credentials_free_internal(p);
|
65
|
+
grpc_ruby_shutdown();
|
66
|
+
}
|
67
|
+
|
62
68
|
/* Protects the mark object from GC */
|
63
69
|
static void grpc_rb_server_credentials_mark(void* p) {
|
64
70
|
grpc_rb_server_credentials* wrapper = NULL;
|
@@ -87,9 +93,9 @@ static const rb_data_type_t grpc_rb_server_credentials_data_type = {
|
|
87
93
|
};
|
88
94
|
|
89
95
|
/* Allocates ServerCredential instances.
|
90
|
-
|
91
96
|
Provides safe initial defaults for the instance fields. */
|
92
97
|
static VALUE grpc_rb_server_credentials_alloc(VALUE cls) {
|
98
|
+
grpc_ruby_init();
|
93
99
|
grpc_rb_server_credentials* wrapper = ALLOC(grpc_rb_server_credentials);
|
94
100
|
wrapper->wrapped = NULL;
|
95
101
|
wrapper->mark = Qnil;
|
@@ -202,7 +208,11 @@ static VALUE grpc_rb_server_credentials_init(VALUE self, VALUE pem_root_certs,
|
|
202
208
|
}
|
203
209
|
xfree(key_cert_pairs);
|
204
210
|
if (creds == NULL) {
|
205
|
-
rb_raise(rb_eRuntimeError,
|
211
|
+
rb_raise(rb_eRuntimeError,
|
212
|
+
"the call to grpc_ssl_server_credentials_create_ex() failed, "
|
213
|
+
"could not create a credentials, see "
|
214
|
+
"https://github.com/grpc/grpc/blob/master/TROUBLESHOOTING.md for "
|
215
|
+
"debugging tips");
|
206
216
|
return Qnil;
|
207
217
|
}
|
208
218
|
wrapper->wrapped = creds;
|
@@ -237,7 +247,13 @@ void Init_grpc_server_credentials() {
|
|
237
247
|
/* Gets the wrapped grpc_server_credentials from the ruby wrapper */
|
238
248
|
grpc_server_credentials* grpc_rb_get_wrapped_server_credentials(VALUE v) {
|
239
249
|
grpc_rb_server_credentials* wrapper = NULL;
|
250
|
+
Check_TypedStruct(v, &grpc_rb_server_credentials_data_type);
|
240
251
|
TypedData_Get_Struct(v, grpc_rb_server_credentials,
|
241
252
|
&grpc_rb_server_credentials_data_type, wrapper);
|
242
253
|
return wrapper->wrapped;
|
243
254
|
}
|
255
|
+
|
256
|
+
/* Check if v is kind of ServerCredentials */
|
257
|
+
bool grpc_rb_is_server_credentials(VALUE v) {
|
258
|
+
return rb_typeddata_is_kind_of(v, &grpc_rb_server_credentials_data_type);
|
259
|
+
}
|
@@ -20,6 +20,7 @@
|
|
20
20
|
#define GRPC_RB_SERVER_CREDENTIALS_H_
|
21
21
|
|
22
22
|
#include <ruby/ruby.h>
|
23
|
+
#include <stdbool.h>
|
23
24
|
|
24
25
|
#include <grpc/grpc_security.h>
|
25
26
|
|
@@ -29,4 +30,7 @@ void Init_grpc_server_credentials();
|
|
29
30
|
/* Gets the wrapped server_credentials from the ruby wrapper */
|
30
31
|
grpc_server_credentials* grpc_rb_get_wrapped_server_credentials(VALUE v);
|
31
32
|
|
33
|
+
/* Check if v is kind of ServerCredentials */
|
34
|
+
bool grpc_rb_is_server_credentials(VALUE v);
|
35
|
+
|
32
36
|
#endif /* GRPC_RB_SERVER_CREDENTIALS_H_ */
|
@@ -0,0 +1,215 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2021 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/grpc.h>
|
20
|
+
#include <grpc/grpc_security.h>
|
21
|
+
#include <grpc/support/alloc.h>
|
22
|
+
#include <grpc/support/log.h>
|
23
|
+
#include <ruby/ruby.h>
|
24
|
+
#include <string.h>
|
25
|
+
|
26
|
+
#include "rb_call_credentials.h"
|
27
|
+
#include "rb_channel_credentials.h"
|
28
|
+
#include "rb_grpc.h"
|
29
|
+
#include "rb_grpc_imports.generated.h"
|
30
|
+
#include "rb_xds_channel_credentials.h"
|
31
|
+
|
32
|
+
/* grpc_rb_cXdsChannelCredentials is the ruby class that proxies
|
33
|
+
grpc_channel_credentials. */
|
34
|
+
static VALUE grpc_rb_cXdsChannelCredentials = Qnil;
|
35
|
+
|
36
|
+
/* grpc_rb_xds_channel_credentials wraps a grpc_channel_credentials. It
|
37
|
+
* provides a mark object that is used to hold references to any objects used to
|
38
|
+
* create the credentials. */
|
39
|
+
typedef struct grpc_rb_xds_channel_credentials {
|
40
|
+
/* Holder of ruby objects involved in constructing the credentials */
|
41
|
+
VALUE mark;
|
42
|
+
|
43
|
+
/* The actual credentials */
|
44
|
+
grpc_channel_credentials* wrapped;
|
45
|
+
} grpc_rb_xds_channel_credentials;
|
46
|
+
|
47
|
+
static void grpc_rb_xds_channel_credentials_free_internal(void* p) {
|
48
|
+
grpc_rb_xds_channel_credentials* wrapper = NULL;
|
49
|
+
if (p == NULL) {
|
50
|
+
return;
|
51
|
+
};
|
52
|
+
wrapper = (grpc_rb_xds_channel_credentials*)p;
|
53
|
+
grpc_channel_credentials_release(wrapper->wrapped);
|
54
|
+
wrapper->wrapped = NULL;
|
55
|
+
|
56
|
+
xfree(p);
|
57
|
+
}
|
58
|
+
|
59
|
+
/* Destroys the credentials instances. */
|
60
|
+
static void grpc_rb_xds_channel_credentials_free(void* p) {
|
61
|
+
grpc_rb_xds_channel_credentials_free_internal(p);
|
62
|
+
grpc_ruby_shutdown();
|
63
|
+
}
|
64
|
+
|
65
|
+
/* Protects the mark object from GC */
|
66
|
+
static void grpc_rb_xds_channel_credentials_mark(void* p) {
|
67
|
+
grpc_rb_xds_channel_credentials* wrapper = NULL;
|
68
|
+
if (p == NULL) {
|
69
|
+
return;
|
70
|
+
}
|
71
|
+
wrapper = (grpc_rb_xds_channel_credentials*)p;
|
72
|
+
|
73
|
+
if (wrapper->mark != Qnil) {
|
74
|
+
rb_gc_mark(wrapper->mark);
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
static rb_data_type_t grpc_rb_xds_channel_credentials_data_type = {
|
79
|
+
"grpc_xds_channel_credentials",
|
80
|
+
{grpc_rb_xds_channel_credentials_mark, grpc_rb_xds_channel_credentials_free,
|
81
|
+
GRPC_RB_MEMSIZE_UNAVAILABLE, NULL},
|
82
|
+
NULL,
|
83
|
+
NULL,
|
84
|
+
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
|
85
|
+
RUBY_TYPED_FREE_IMMEDIATELY
|
86
|
+
#endif
|
87
|
+
};
|
88
|
+
|
89
|
+
/* Allocates ChannelCredential instances.
|
90
|
+
Provides safe initial defaults for the instance fields. */
|
91
|
+
static VALUE grpc_rb_xds_channel_credentials_alloc(VALUE cls) {
|
92
|
+
grpc_ruby_init();
|
93
|
+
grpc_rb_xds_channel_credentials* wrapper =
|
94
|
+
ALLOC(grpc_rb_xds_channel_credentials);
|
95
|
+
wrapper->wrapped = NULL;
|
96
|
+
wrapper->mark = Qnil;
|
97
|
+
return TypedData_Wrap_Struct(cls, &grpc_rb_xds_channel_credentials_data_type,
|
98
|
+
wrapper);
|
99
|
+
}
|
100
|
+
|
101
|
+
/* Creates a wrapping object for a given channel credentials. This should only
|
102
|
+
* be called with grpc_channel_credentials objects that are not already
|
103
|
+
* associated with any Ruby object. */
|
104
|
+
VALUE grpc_rb_xds_wrap_channel_credentials(grpc_channel_credentials* c,
|
105
|
+
VALUE mark) {
|
106
|
+
grpc_rb_xds_channel_credentials* wrapper;
|
107
|
+
if (c == NULL) {
|
108
|
+
return Qnil;
|
109
|
+
}
|
110
|
+
VALUE rb_wrapper =
|
111
|
+
grpc_rb_xds_channel_credentials_alloc(grpc_rb_cXdsChannelCredentials);
|
112
|
+
TypedData_Get_Struct(rb_wrapper, grpc_rb_xds_channel_credentials,
|
113
|
+
&grpc_rb_xds_channel_credentials_data_type, wrapper);
|
114
|
+
wrapper->wrapped = c;
|
115
|
+
wrapper->mark = mark;
|
116
|
+
return rb_wrapper;
|
117
|
+
}
|
118
|
+
|
119
|
+
/* The attribute used on the mark object to hold the fallback creds. */
|
120
|
+
static ID id_fallback_creds;
|
121
|
+
|
122
|
+
/*
|
123
|
+
call-seq:
|
124
|
+
fallback_creds: (ChannelCredentials) fallback credentials to create
|
125
|
+
XDS credentials
|
126
|
+
Initializes Credential instances. */
|
127
|
+
static VALUE grpc_rb_xds_channel_credentials_init(VALUE self,
|
128
|
+
VALUE fallback_creds) {
|
129
|
+
grpc_rb_xds_channel_credentials* wrapper = NULL;
|
130
|
+
grpc_channel_credentials* grpc_fallback_creds =
|
131
|
+
grpc_rb_get_wrapped_channel_credentials(fallback_creds);
|
132
|
+
grpc_channel_credentials* creds =
|
133
|
+
grpc_xds_credentials_create(grpc_fallback_creds);
|
134
|
+
if (creds == NULL) {
|
135
|
+
rb_raise(rb_eRuntimeError,
|
136
|
+
"the call to grpc_xds_credentials_create() failed, could not "
|
137
|
+
"create a credentials, , see "
|
138
|
+
"https://github.com/grpc/grpc/blob/master/TROUBLESHOOTING.md for "
|
139
|
+
"debugging tips");
|
140
|
+
return Qnil;
|
141
|
+
}
|
142
|
+
|
143
|
+
TypedData_Get_Struct(self, grpc_rb_xds_channel_credentials,
|
144
|
+
&grpc_rb_xds_channel_credentials_data_type, wrapper);
|
145
|
+
wrapper->wrapped = creds;
|
146
|
+
|
147
|
+
/* Add the input objects as hidden fields to preserve them. */
|
148
|
+
rb_ivar_set(self, id_fallback_creds, fallback_creds);
|
149
|
+
|
150
|
+
return self;
|
151
|
+
}
|
152
|
+
|
153
|
+
// TODO: de-duplicate this code with the similar method in
|
154
|
+
// rb_channel_credentials.c, after putting ChannelCredentials and
|
155
|
+
// XdsChannelCredentials under a common parent class
|
156
|
+
static VALUE grpc_rb_xds_channel_credentials_compose(int argc, VALUE* argv,
|
157
|
+
VALUE self) {
|
158
|
+
grpc_channel_credentials* creds;
|
159
|
+
grpc_call_credentials* other;
|
160
|
+
grpc_channel_credentials* prev = NULL;
|
161
|
+
VALUE mark;
|
162
|
+
if (argc == 0) {
|
163
|
+
return self;
|
164
|
+
}
|
165
|
+
mark = rb_ary_new();
|
166
|
+
rb_ary_push(mark, self);
|
167
|
+
creds = grpc_rb_get_wrapped_xds_channel_credentials(self);
|
168
|
+
for (int i = 0; i < argc; i++) {
|
169
|
+
rb_ary_push(mark, argv[i]);
|
170
|
+
other = grpc_rb_get_wrapped_call_credentials(argv[i]);
|
171
|
+
creds = grpc_composite_channel_credentials_create(creds, other, NULL);
|
172
|
+
if (prev != NULL) {
|
173
|
+
grpc_channel_credentials_release(prev);
|
174
|
+
}
|
175
|
+
prev = creds;
|
176
|
+
|
177
|
+
if (creds == NULL) {
|
178
|
+
rb_raise(rb_eRuntimeError,
|
179
|
+
"Failed to compose channel and call credentials");
|
180
|
+
}
|
181
|
+
}
|
182
|
+
return grpc_rb_xds_wrap_channel_credentials(creds, mark);
|
183
|
+
}
|
184
|
+
|
185
|
+
void Init_grpc_xds_channel_credentials() {
|
186
|
+
grpc_rb_cXdsChannelCredentials = rb_define_class_under(
|
187
|
+
grpc_rb_mGrpcCore, "XdsChannelCredentials", rb_cObject);
|
188
|
+
|
189
|
+
/* Allocates an object managed by the ruby runtime */
|
190
|
+
rb_define_alloc_func(grpc_rb_cXdsChannelCredentials,
|
191
|
+
grpc_rb_xds_channel_credentials_alloc);
|
192
|
+
|
193
|
+
/* Provides a ruby constructor and support for dup/clone. */
|
194
|
+
rb_define_method(grpc_rb_cXdsChannelCredentials, "initialize",
|
195
|
+
grpc_rb_xds_channel_credentials_init, 1);
|
196
|
+
rb_define_method(grpc_rb_cXdsChannelCredentials, "initialize_copy",
|
197
|
+
grpc_rb_cannot_init_copy, 1);
|
198
|
+
rb_define_method(grpc_rb_cXdsChannelCredentials, "compose",
|
199
|
+
grpc_rb_xds_channel_credentials_compose, -1);
|
200
|
+
|
201
|
+
id_fallback_creds = rb_intern("__fallback_creds");
|
202
|
+
}
|
203
|
+
|
204
|
+
/* Gets the wrapped grpc_channel_credentials from the ruby wrapper */
|
205
|
+
grpc_channel_credentials* grpc_rb_get_wrapped_xds_channel_credentials(VALUE v) {
|
206
|
+
grpc_rb_xds_channel_credentials* wrapper = NULL;
|
207
|
+
Check_TypedStruct(v, &grpc_rb_xds_channel_credentials_data_type);
|
208
|
+
TypedData_Get_Struct(v, grpc_rb_xds_channel_credentials,
|
209
|
+
&grpc_rb_xds_channel_credentials_data_type, wrapper);
|
210
|
+
return wrapper->wrapped;
|
211
|
+
}
|
212
|
+
|
213
|
+
bool grpc_rb_is_xds_channel_credentials(VALUE v) {
|
214
|
+
return rb_typeddata_is_kind_of(v, &grpc_rb_xds_channel_credentials_data_type);
|
215
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2021 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_RB_XDS_CHANNEL_CREDENTIALS_H_
|
20
|
+
#define GRPC_RB_XDS_CHANNEL_CREDENTIALS_H_
|
21
|
+
|
22
|
+
#include <grpc/grpc_security.h>
|
23
|
+
#include <ruby/ruby.h>
|
24
|
+
#include <stdbool.h>
|
25
|
+
|
26
|
+
/* Initializes the ruby ChannelCredentials class. */
|
27
|
+
void Init_grpc_xds_channel_credentials();
|
28
|
+
|
29
|
+
/* Gets the wrapped credentials from the ruby wrapper */
|
30
|
+
grpc_channel_credentials* grpc_rb_get_wrapped_xds_channel_credentials(VALUE v);
|
31
|
+
|
32
|
+
/* Check if v is kind of XdsChannelCredentials */
|
33
|
+
bool grpc_rb_is_xds_channel_credentials(VALUE v);
|
34
|
+
|
35
|
+
#endif /* GRPC_RB_XDS_CHANNEL_CREDENTIALS_H_ */
|
@@ -0,0 +1,169 @@
|
|
1
|
+
/*
|
2
|
+
*
|
3
|
+
* Copyright 2021 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 "rb_xds_server_credentials.h"
|
20
|
+
|
21
|
+
#include <grpc/grpc.h>
|
22
|
+
#include <grpc/grpc_security.h>
|
23
|
+
#include <grpc/support/log.h>
|
24
|
+
#include <ruby/ruby.h>
|
25
|
+
|
26
|
+
#include "rb_grpc.h"
|
27
|
+
#include "rb_grpc_imports.generated.h"
|
28
|
+
#include "rb_server_credentials.h"
|
29
|
+
|
30
|
+
/* grpc_rb_cXdsServerCredentials is the ruby class that proxies
|
31
|
+
grpc_server_credentials. */
|
32
|
+
static VALUE grpc_rb_cXdsServerCredentials = Qnil;
|
33
|
+
|
34
|
+
/* grpc_rb_xds_server_credentials wraps a grpc_server_credentials. It provides
|
35
|
+
a peer ruby object, 'mark' to hold references to objects involved in
|
36
|
+
constructing the server credentials. */
|
37
|
+
typedef struct grpc_rb_xds_server_credentials {
|
38
|
+
/* Holder of ruby objects involved in constructing the server credentials */
|
39
|
+
VALUE mark;
|
40
|
+
/* The actual server credentials */
|
41
|
+
grpc_server_credentials* wrapped;
|
42
|
+
} grpc_rb_xds_server_credentials;
|
43
|
+
|
44
|
+
/* Destroys the server credentials instances. */
|
45
|
+
static void grpc_rb_xds_server_credentials_free_internal(void* p) {
|
46
|
+
grpc_rb_xds_server_credentials* wrapper = NULL;
|
47
|
+
if (p == NULL) {
|
48
|
+
return;
|
49
|
+
};
|
50
|
+
wrapper = (grpc_rb_xds_server_credentials*)p;
|
51
|
+
|
52
|
+
/* Delete the wrapped object if the mark object is Qnil, which indicates that
|
53
|
+
no other object is the actual owner. */
|
54
|
+
if (wrapper->wrapped != NULL && wrapper->mark == Qnil) {
|
55
|
+
grpc_server_credentials_release(wrapper->wrapped);
|
56
|
+
wrapper->wrapped = NULL;
|
57
|
+
}
|
58
|
+
|
59
|
+
xfree(p);
|
60
|
+
}
|
61
|
+
|
62
|
+
/* Destroys the server credentials instances. */
|
63
|
+
static void grpc_rb_xds_server_credentials_free(void* p) {
|
64
|
+
grpc_rb_xds_server_credentials_free_internal(p);
|
65
|
+
grpc_ruby_shutdown();
|
66
|
+
}
|
67
|
+
|
68
|
+
/* Protects the mark object from GC */
|
69
|
+
static void grpc_rb_xds_server_credentials_mark(void* p) {
|
70
|
+
if (p == NULL) {
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
grpc_rb_xds_server_credentials* wrapper = (grpc_rb_xds_server_credentials*)p;
|
74
|
+
|
75
|
+
/* If it's not already cleaned up, mark the mark object */
|
76
|
+
if (wrapper->mark != Qnil) {
|
77
|
+
rb_gc_mark(wrapper->mark);
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
static const rb_data_type_t grpc_rb_xds_server_credentials_data_type = {
|
82
|
+
"grpc_xds_server_credentials",
|
83
|
+
{grpc_rb_xds_server_credentials_mark, grpc_rb_xds_server_credentials_free,
|
84
|
+
GRPC_RB_MEMSIZE_UNAVAILABLE, NULL},
|
85
|
+
NULL,
|
86
|
+
NULL,
|
87
|
+
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
|
88
|
+
RUBY_TYPED_FREE_IMMEDIATELY
|
89
|
+
#endif
|
90
|
+
};
|
91
|
+
|
92
|
+
/* Allocates ServerCredential instances.
|
93
|
+
Provides safe initial defaults for the instance fields. */
|
94
|
+
static VALUE grpc_rb_xds_server_credentials_alloc(VALUE cls) {
|
95
|
+
grpc_ruby_init();
|
96
|
+
grpc_rb_xds_server_credentials* wrapper =
|
97
|
+
ALLOC(grpc_rb_xds_server_credentials);
|
98
|
+
wrapper->wrapped = NULL;
|
99
|
+
wrapper->mark = Qnil;
|
100
|
+
return TypedData_Wrap_Struct(cls, &grpc_rb_xds_server_credentials_data_type,
|
101
|
+
wrapper);
|
102
|
+
}
|
103
|
+
|
104
|
+
/* The attribute used on the mark object to preserve the fallback_creds. */
|
105
|
+
static ID id_fallback_creds;
|
106
|
+
|
107
|
+
/*
|
108
|
+
call-seq:
|
109
|
+
creds = ServerCredentials.new(fallback_creds)
|
110
|
+
fallback_creds: (ServerCredentials) fallback credentials to create
|
111
|
+
XDS credentials.
|
112
|
+
Initializes ServerCredential instances. */
|
113
|
+
static VALUE grpc_rb_xds_server_credentials_init(VALUE self,
|
114
|
+
VALUE fallback_creds) {
|
115
|
+
grpc_rb_xds_server_credentials* wrapper = NULL;
|
116
|
+
grpc_server_credentials* creds = NULL;
|
117
|
+
|
118
|
+
grpc_server_credentials* grpc_fallback_creds =
|
119
|
+
grpc_rb_get_wrapped_server_credentials(fallback_creds);
|
120
|
+
creds = grpc_xds_server_credentials_create(grpc_fallback_creds);
|
121
|
+
|
122
|
+
if (creds == NULL) {
|
123
|
+
rb_raise(rb_eRuntimeError,
|
124
|
+
"the call to grpc_xds_server_credentials_create() failed, could "
|
125
|
+
"not create a credentials, see "
|
126
|
+
"https://github.com/grpc/grpc/blob/master/TROUBLESHOOTING.md for "
|
127
|
+
"debugging tips");
|
128
|
+
return Qnil;
|
129
|
+
}
|
130
|
+
TypedData_Get_Struct(self, grpc_rb_xds_server_credentials,
|
131
|
+
&grpc_rb_xds_server_credentials_data_type, wrapper);
|
132
|
+
wrapper->wrapped = creds;
|
133
|
+
|
134
|
+
/* Add the input objects as hidden fields to preserve them. */
|
135
|
+
rb_ivar_set(self, id_fallback_creds, fallback_creds);
|
136
|
+
|
137
|
+
return self;
|
138
|
+
}
|
139
|
+
|
140
|
+
void Init_grpc_xds_server_credentials() {
|
141
|
+
grpc_rb_cXdsServerCredentials = rb_define_class_under(
|
142
|
+
grpc_rb_mGrpcCore, "XdsServerCredentials", rb_cObject);
|
143
|
+
|
144
|
+
/* Allocates an object managed by the ruby runtime */
|
145
|
+
rb_define_alloc_func(grpc_rb_cXdsServerCredentials,
|
146
|
+
grpc_rb_xds_server_credentials_alloc);
|
147
|
+
|
148
|
+
/* Provides a ruby constructor and support for dup/clone. */
|
149
|
+
rb_define_method(grpc_rb_cXdsServerCredentials, "initialize",
|
150
|
+
grpc_rb_xds_server_credentials_init, 1);
|
151
|
+
rb_define_method(grpc_rb_cXdsServerCredentials, "initialize_copy",
|
152
|
+
grpc_rb_cannot_init_copy, 1);
|
153
|
+
|
154
|
+
id_fallback_creds = rb_intern("__fallback_creds");
|
155
|
+
}
|
156
|
+
|
157
|
+
/* Gets the wrapped grpc_server_credentials from the ruby wrapper */
|
158
|
+
grpc_server_credentials* grpc_rb_get_wrapped_xds_server_credentials(VALUE v) {
|
159
|
+
grpc_rb_xds_server_credentials* wrapper = NULL;
|
160
|
+
Check_TypedStruct(v, &grpc_rb_xds_server_credentials_data_type);
|
161
|
+
TypedData_Get_Struct(v, grpc_rb_xds_server_credentials,
|
162
|
+
&grpc_rb_xds_server_credentials_data_type, wrapper);
|
163
|
+
return wrapper->wrapped;
|
164
|
+
}
|
165
|
+
|
166
|
+
/* Check if v is kind of ServerCredentials */
|
167
|
+
bool grpc_rb_is_xds_server_credentials(VALUE v) {
|
168
|
+
return rb_typeddata_is_kind_of(v, &grpc_rb_xds_server_credentials_data_type);
|
169
|
+
}
|