grpc 1.1.2 → 1.2.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 +1257 -404
- data/etc/roots.pem +189 -102
- data/include/grpc/census.h +7 -7
- data/include/grpc/compression.h +4 -4
- data/include/grpc/grpc.h +13 -7
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +26 -9
- data/include/grpc/impl/codegen/grpc_types.h +39 -30
- data/include/grpc/impl/codegen/slice.h +24 -6
- data/include/grpc/impl/codegen/sync.h +8 -0
- data/include/grpc/load_reporting.h +63 -0
- data/include/grpc/slice.h +37 -1
- data/include/grpc/slice_buffer.h +7 -0
- data/include/grpc/support/alloc.h +3 -0
- data/include/grpc/support/useful.h +3 -0
- data/src/core/ext/census/gen/census.pb.h +1 -1
- data/src/core/ext/census/gen/trace_context.pb.c +9 -36
- data/src/core/ext/census/gen/trace_context.pb.h +20 -26
- data/src/core/ext/census/grpc_filter.c +3 -5
- data/src/core/ext/census/trace_context.c +1 -1
- data/src/core/ext/census/trace_context.h +3 -0
- data/src/core/ext/census/trace_label.h +61 -0
- data/src/core/ext/census/trace_propagation.h +63 -0
- data/src/core/ext/census/trace_status.h +45 -0
- data/src/core/ext/census/trace_string.h +50 -0
- data/src/core/ext/census/tracing.c +31 -11
- data/src/core/ext/census/tracing.h +124 -0
- data/src/core/ext/client_channel/client_channel.c +456 -368
- data/src/core/ext/client_channel/client_channel.h +4 -0
- data/src/core/ext/client_channel/client_channel_plugin.c +6 -1
- data/src/core/ext/client_channel/connector.c +3 -3
- data/src/core/ext/client_channel/connector.h +4 -3
- data/src/core/ext/client_channel/http_connect_handshaker.c +62 -72
- data/src/core/ext/client_channel/http_connect_handshaker.h +7 -10
- data/src/core/ext/client_channel/http_proxy.c +125 -0
- data/src/core/ext/client_channel/http_proxy.h +39 -0
- data/src/core/ext/client_channel/lb_policy.c +56 -35
- data/src/core/ext/client_channel/lb_policy.h +46 -39
- data/src/core/ext/client_channel/lb_policy_factory.h +1 -0
- data/src/core/ext/client_channel/parse_address.c +32 -6
- data/src/core/ext/client_channel/proxy_mapper.c +63 -0
- data/src/core/ext/client_channel/proxy_mapper.h +89 -0
- data/src/core/ext/client_channel/proxy_mapper_registry.c +133 -0
- data/src/core/ext/client_channel/proxy_mapper_registry.h +59 -0
- data/src/core/ext/client_channel/resolver.c +16 -9
- data/src/core/ext/client_channel/resolver.h +23 -12
- data/src/core/ext/client_channel/resolver_factory.h +1 -0
- data/src/core/ext/client_channel/resolver_registry.c +15 -11
- data/src/core/ext/client_channel/resolver_registry.h +5 -3
- data/src/core/ext/client_channel/subchannel.c +44 -27
- data/src/core/ext/client_channel/subchannel.h +6 -2
- data/src/core/ext/client_channel/uri_parser.c +26 -14
- data/src/core/ext/client_channel/uri_parser.h +3 -1
- data/src/core/ext/lb_policy/grpclb/grpclb.c +220 -209
- data/src/core/ext/lb_policy/grpclb/grpclb_channel.h +56 -0
- data/src/core/ext/lb_policy/grpclb/grpclb_channel_secure.c +107 -0
- data/src/core/ext/lb_policy/grpclb/load_balancer_api.c +3 -6
- data/src/core/ext/lb_policy/pick_first/pick_first.c +71 -116
- data/src/core/ext/lb_policy/round_robin/round_robin.c +52 -67
- data/src/core/ext/load_reporting/load_reporting.c +20 -0
- data/src/core/ext/load_reporting/load_reporting.h +1 -16
- data/src/core/ext/load_reporting/load_reporting_filter.c +28 -54
- data/src/core/ext/resolver/dns/native/dns_resolver.c +31 -45
- data/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +20 -29
- data/src/core/ext/transport/chttp2/client/chttp2_connector.c +11 -8
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +11 -2
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +143 -46
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +12 -50
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +1 -1
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +1 -1
- data/src/core/ext/transport/chttp2/transport/bin_decoder.c +7 -7
- data/src/core/ext/transport/chttp2/transport/bin_encoder.c +1 -2
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +1 -2
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.c +0 -3
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +606 -374
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +17 -5
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +9 -13
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +12 -11
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +5 -6
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +100 -53
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +126 -70
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +13 -7
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +22 -19
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +6 -6
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +23 -11
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +6 -2
- data/src/core/ext/transport/chttp2/transport/internal.h +169 -42
- data/src/core/ext/transport/chttp2/transport/parsing.c +98 -41
- data/src/core/ext/transport/chttp2/transport/stream_lists.c +29 -14
- data/src/core/ext/transport/chttp2/transport/writing.c +137 -15
- data/src/core/lib/channel/channel_stack.c +14 -44
- data/src/core/lib/channel/channel_stack.h +10 -17
- data/src/core/lib/channel/channel_stack_builder.c +2 -3
- data/src/core/lib/channel/compress_filter.c +54 -46
- data/src/core/lib/channel/connected_channel.c +4 -4
- data/src/core/lib/channel/connected_channel.h +5 -0
- data/src/core/lib/channel/context.h +3 -0
- data/src/core/lib/channel/deadline_filter.c +61 -61
- data/src/core/lib/channel/deadline_filter.h +8 -5
- data/src/core/lib/channel/handshaker.c +47 -7
- data/src/core/lib/channel/handshaker.h +21 -3
- data/src/core/lib/channel/http_client_filter.c +149 -99
- data/src/core/lib/channel/http_server_filter.c +163 -147
- data/src/core/lib/channel/message_size_filter.c +15 -10
- data/src/core/lib/compression/algorithm_metadata.h +4 -4
- data/src/core/lib/compression/compression.c +17 -23
- data/src/core/lib/http/httpcli.c +3 -2
- data/src/core/lib/http/httpcli.h +2 -1
- data/src/core/lib/http/httpcli_security_connector.c +2 -3
- data/src/core/lib/http/parser.c +2 -2
- data/src/core/lib/iomgr/closure.c +6 -3
- data/src/core/lib/iomgr/closure.h +4 -2
- data/src/core/lib/iomgr/combiner.c +35 -5
- data/src/core/lib/iomgr/combiner.h +21 -2
- data/src/core/lib/iomgr/endpoint.c +3 -2
- data/src/core/lib/iomgr/endpoint.h +3 -2
- data/src/core/lib/iomgr/error.c +60 -94
- data/src/core/lib/iomgr/error.h +7 -10
- data/src/core/lib/iomgr/error_internal.h +54 -0
- data/src/core/lib/iomgr/ev_epoll_linux.c +253 -109
- data/src/core/lib/iomgr/ev_poll_posix.c +61 -29
- data/src/core/lib/iomgr/ev_posix.c +7 -8
- data/src/core/lib/iomgr/ev_posix.h +4 -4
- data/src/core/lib/iomgr/exec_ctx.c +11 -6
- data/src/core/lib/iomgr/exec_ctx.h +11 -14
- data/src/core/lib/iomgr/executor.c +2 -2
- data/src/core/lib/iomgr/load_file.c +1 -1
- data/src/core/lib/iomgr/network_status_tracker.c +5 -81
- data/src/core/lib/iomgr/pollset.h +1 -3
- data/src/core/lib/iomgr/pollset_set.h +2 -1
- data/src/core/lib/iomgr/pollset_set_uv.c +2 -1
- data/src/core/lib/iomgr/pollset_set_windows.c +2 -1
- data/src/core/lib/iomgr/pollset_uv.c +25 -11
- data/src/core/lib/iomgr/pollset_windows.c +0 -11
- data/src/core/lib/iomgr/resolve_address_uv.c +50 -2
- data/src/core/lib/iomgr/resource_quota.c +41 -11
- data/src/core/lib/iomgr/resource_quota.h +6 -0
- data/src/core/lib/iomgr/sockaddr_utils.c +33 -17
- data/src/core/lib/iomgr/sockaddr_utils.h +4 -0
- data/src/core/lib/iomgr/tcp_client_posix.c +2 -3
- data/src/core/lib/iomgr/tcp_client_uv.c +1 -3
- data/src/core/lib/iomgr/tcp_client_windows.c +21 -6
- data/src/core/lib/iomgr/tcp_posix.c +4 -5
- data/src/core/lib/iomgr/tcp_server_posix.c +269 -94
- data/src/core/lib/iomgr/tcp_server_windows.c +1 -1
- data/src/core/lib/iomgr/tcp_uv.c +11 -5
- data/src/core/lib/iomgr/tcp_windows.c +20 -7
- data/src/core/lib/iomgr/timer_generic.c +15 -22
- data/src/core/lib/iomgr/timer_generic.h +1 -1
- data/src/core/lib/iomgr/timer_uv.c +10 -6
- data/src/core/lib/iomgr/timer_uv.h +1 -1
- data/src/core/lib/iomgr/udp_server.c +45 -6
- data/src/core/lib/iomgr/udp_server.h +7 -1
- data/src/core/lib/iomgr/unix_sockets_posix.c +11 -1
- data/src/core/lib/json/json.c +1 -2
- data/src/core/lib/profiling/basic_timers.c +17 -3
- data/src/core/lib/security/context/security_context.c +3 -10
- data/src/core/lib/security/credentials/composite/composite_credentials.c +4 -8
- data/src/core/lib/security/credentials/credentials.c +48 -2
- data/src/core/lib/security/credentials/credentials.h +13 -0
- data/src/core/lib/security/credentials/credentials_metadata.c +1 -2
- data/src/core/lib/security/credentials/fake/fake_credentials.c +6 -8
- data/src/core/lib/security/credentials/fake/fake_credentials.h +15 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +3 -3
- data/src/core/lib/security/credentials/iam/iam_credentials.c +1 -2
- data/src/core/lib/security/credentials/jwt/jwt_credentials.c +1 -2
- data/src/core/lib/security/credentials/jwt/jwt_verifier.c +5 -8
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +3 -5
- data/src/core/lib/security/credentials/plugin/plugin_credentials.c +15 -13
- data/src/core/lib/security/credentials/ssl/ssl_credentials.c +2 -4
- data/src/core/lib/security/transport/client_auth_filter.c +72 -47
- data/src/core/lib/security/transport/lb_targets_info.c +70 -0
- data/src/core/lib/security/transport/lb_targets_info.h +47 -0
- data/src/core/lib/security/transport/secure_endpoint.c +3 -3
- data/src/core/lib/security/transport/security_connector.c +125 -28
- data/src/core/lib/security/transport/security_connector.h +4 -3
- data/src/core/lib/security/transport/security_handshaker.c +13 -9
- data/src/core/lib/security/transport/server_auth_filter.c +31 -40
- data/src/core/lib/security/util/b64.c +1 -1
- data/src/core/lib/slice/slice.c +110 -20
- data/src/core/lib/slice/slice_buffer.c +92 -39
- data/src/core/lib/{transport/mdstr_hash_table.c → slice/slice_hash_table.c} +40 -33
- data/src/core/lib/{transport/mdstr_hash_table.h → slice/slice_hash_table.h} +21 -21
- data/src/core/lib/slice/slice_intern.c +346 -0
- data/src/core/lib/slice/slice_internal.h +15 -0
- data/src/core/lib/slice/slice_string_helpers.c +5 -0
- data/src/core/lib/slice/slice_string_helpers.h +5 -0
- data/src/core/lib/support/alloc.c +26 -1
- data/src/core/lib/support/cmdline.c +2 -4
- data/src/core/lib/support/cpu_posix.c +2 -7
- data/src/core/lib/support/histogram.c +1 -2
- data/src/core/lib/support/log_posix.c +8 -4
- data/src/core/lib/support/spinlock.h +52 -0
- data/src/core/lib/support/subprocess_posix.c +1 -2
- data/src/core/lib/support/sync.c +7 -1
- data/src/core/lib/support/sync_posix.c +9 -0
- data/src/core/lib/support/time_windows.c +7 -1
- data/src/core/lib/surface/call.c +647 -629
- data/src/core/lib/surface/call.h +4 -1
- data/src/core/lib/surface/call_details.c +8 -2
- data/src/core/lib/surface/call_log_batch.c +17 -6
- data/src/core/lib/surface/channel.c +49 -59
- data/src/core/lib/surface/channel.h +5 -6
- data/src/core/lib/surface/completion_queue.c +16 -45
- data/src/core/lib/surface/completion_queue.h +0 -3
- data/src/core/lib/surface/init.c +6 -2
- data/src/core/lib/surface/init_secure.c +1 -1
- data/src/core/lib/surface/lame_client.c +14 -4
- data/src/core/lib/surface/server.c +79 -82
- data/src/core/lib/surface/validate_metadata.c +46 -15
- data/src/core/lib/surface/validate_metadata.h +43 -0
- data/src/core/lib/surface/version.c +2 -2
- data/src/core/lib/transport/bdp_estimator.c +104 -0
- data/src/core/lib/transport/bdp_estimator.h +76 -0
- data/src/core/lib/transport/connectivity_state.c +33 -13
- data/src/core/lib/transport/connectivity_state.h +15 -5
- data/src/core/lib/transport/error_utils.c +124 -0
- data/src/core/lib/transport/error_utils.h +56 -0
- data/src/core/{ext/transport/chttp2 → lib}/transport/http2_errors.h +18 -18
- data/src/core/lib/transport/metadata.c +259 -503
- data/src/core/lib/transport/metadata.h +69 -68
- data/src/core/lib/transport/metadata_batch.c +183 -63
- data/src/core/lib/transport/metadata_batch.h +50 -26
- data/src/core/lib/transport/pid_controller.c +28 -8
- data/src/core/lib/transport/pid_controller.h +15 -2
- data/src/core/lib/transport/service_config.c +21 -18
- data/src/core/lib/transport/service_config.h +5 -5
- data/src/core/lib/transport/static_metadata.c +753 -112
- data/src/core/lib/transport/static_metadata.h +403 -264
- data/src/core/{ext/transport/chttp2 → lib}/transport/status_conversion.c +18 -20
- data/src/core/{ext/transport/chttp2 → lib}/transport/status_conversion.h +9 -10
- data/src/core/lib/transport/timeout_encoding.c +11 -9
- data/src/core/lib/transport/timeout_encoding.h +3 -1
- data/src/core/lib/transport/transport.c +47 -87
- data/src/core/lib/transport/transport.h +20 -25
- data/src/core/lib/transport/transport_op_string.c +7 -19
- data/src/core/lib/tsi/fake_transport_security.c +2 -4
- data/src/core/lib/tsi/ssl_transport_security.c +7 -16
- data/src/core/lib/tsi/transport_security.c +2 -4
- data/src/ruby/ext/grpc/extconf.rb +4 -1
- data/src/ruby/ext/grpc/rb_byte_buffer.c +7 -0
- data/src/ruby/ext/grpc/rb_byte_buffer.h +3 -0
- data/src/ruby/ext/grpc/rb_call.c +47 -46
- data/src/ruby/ext/grpc/rb_channel.c +21 -6
- data/src/ruby/ext/grpc/rb_compression_options.c +9 -6
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +36 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +59 -8
- data/src/ruby/ext/grpc/rb_server.c +6 -4
- data/src/ruby/lib/grpc/generic/client_stub.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- metadata +33 -9
|
@@ -42,7 +42,9 @@
|
|
|
42
42
|
#include <grpc/support/sync.h>
|
|
43
43
|
|
|
44
44
|
#include "src/core/lib/slice/slice_internal.h"
|
|
45
|
+
#include "src/core/lib/slice/slice_string_helpers.h"
|
|
45
46
|
#include "src/core/lib/surface/api_trace.h"
|
|
47
|
+
#include "src/core/lib/surface/validate_metadata.h"
|
|
46
48
|
|
|
47
49
|
typedef struct {
|
|
48
50
|
void *user_data;
|
|
@@ -63,7 +65,9 @@ static void plugin_md_request_metadata_ready(void *request,
|
|
|
63
65
|
grpc_status_code status,
|
|
64
66
|
const char *error_details) {
|
|
65
67
|
/* called from application code */
|
|
66
|
-
grpc_exec_ctx exec_ctx =
|
|
68
|
+
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INITIALIZER(
|
|
69
|
+
GRPC_EXEC_CTX_FLAG_IS_FINISHED | GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP,
|
|
70
|
+
NULL, NULL);
|
|
67
71
|
grpc_metadata_plugin_request *r = (grpc_metadata_plugin_request *)request;
|
|
68
72
|
if (status != GRPC_STATUS_OK) {
|
|
69
73
|
if (error_details != NULL) {
|
|
@@ -77,13 +81,14 @@ static void plugin_md_request_metadata_ready(void *request,
|
|
|
77
81
|
bool seen_illegal_header = false;
|
|
78
82
|
grpc_credentials_md *md_array = NULL;
|
|
79
83
|
for (i = 0; i < num_md; i++) {
|
|
80
|
-
if (!
|
|
81
|
-
|
|
84
|
+
if (!GRPC_LOG_IF_ERROR("validate_metadata_from_plugin",
|
|
85
|
+
grpc_validate_header_key_is_legal(md[i].key))) {
|
|
82
86
|
seen_illegal_header = true;
|
|
83
87
|
break;
|
|
84
|
-
} else if (!grpc_is_binary_header(md[i].key
|
|
85
|
-
!
|
|
86
|
-
|
|
88
|
+
} else if (!grpc_is_binary_header(md[i].key) &&
|
|
89
|
+
!GRPC_LOG_IF_ERROR(
|
|
90
|
+
"validate_metadata_from_plugin",
|
|
91
|
+
grpc_validate_header_nonbin_value_is_legal(md[i].value))) {
|
|
87
92
|
gpr_log(GPR_ERROR, "Plugin added invalid metadata value.");
|
|
88
93
|
seen_illegal_header = true;
|
|
89
94
|
break;
|
|
@@ -95,9 +100,8 @@ static void plugin_md_request_metadata_ready(void *request,
|
|
|
95
100
|
} else if (num_md > 0) {
|
|
96
101
|
md_array = gpr_malloc(num_md * sizeof(grpc_credentials_md));
|
|
97
102
|
for (i = 0; i < num_md; i++) {
|
|
98
|
-
md_array[i].key =
|
|
99
|
-
md_array[i].value =
|
|
100
|
-
grpc_slice_from_copied_buffer(md[i].value, md[i].value_length);
|
|
103
|
+
md_array[i].key = grpc_slice_ref_internal(md[i].key);
|
|
104
|
+
md_array[i].value = grpc_slice_ref_internal(md[i].value);
|
|
101
105
|
}
|
|
102
106
|
r->cb(&exec_ctx, r->user_data, md_array, num_md, GRPC_CREDENTIALS_OK,
|
|
103
107
|
NULL);
|
|
@@ -122,8 +126,7 @@ static void plugin_get_request_metadata(grpc_exec_ctx *exec_ctx,
|
|
|
122
126
|
void *user_data) {
|
|
123
127
|
grpc_plugin_credentials *c = (grpc_plugin_credentials *)creds;
|
|
124
128
|
if (c->plugin.get_metadata != NULL) {
|
|
125
|
-
grpc_metadata_plugin_request *request =
|
|
126
|
-
memset(request, 0, sizeof(*request));
|
|
129
|
+
grpc_metadata_plugin_request *request = gpr_zalloc(sizeof(*request));
|
|
127
130
|
request->user_data = user_data;
|
|
128
131
|
request->cb = cb;
|
|
129
132
|
c->plugin.get_metadata(c->plugin.state, context,
|
|
@@ -138,11 +141,10 @@ static grpc_call_credentials_vtable plugin_vtable = {
|
|
|
138
141
|
|
|
139
142
|
grpc_call_credentials *grpc_metadata_credentials_create_from_plugin(
|
|
140
143
|
grpc_metadata_credentials_plugin plugin, void *reserved) {
|
|
141
|
-
grpc_plugin_credentials *c =
|
|
144
|
+
grpc_plugin_credentials *c = gpr_zalloc(sizeof(*c));
|
|
142
145
|
GRPC_API_TRACE("grpc_metadata_credentials_create_from_plugin(reserved=%p)", 1,
|
|
143
146
|
(reserved));
|
|
144
147
|
GPR_ASSERT(reserved == NULL);
|
|
145
|
-
memset(c, 0, sizeof(*c));
|
|
146
148
|
c->base.type = plugin.type;
|
|
147
149
|
c->base.vtable = &plugin_vtable;
|
|
148
150
|
gpr_ref_init(&c->base.refcount, 1);
|
|
@@ -121,14 +121,13 @@ static void ssl_build_config(const char *pem_root_certs,
|
|
|
121
121
|
grpc_channel_credentials *grpc_ssl_credentials_create(
|
|
122
122
|
const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair,
|
|
123
123
|
void *reserved) {
|
|
124
|
-
grpc_ssl_credentials *c =
|
|
124
|
+
grpc_ssl_credentials *c = gpr_zalloc(sizeof(grpc_ssl_credentials));
|
|
125
125
|
GRPC_API_TRACE(
|
|
126
126
|
"grpc_ssl_credentials_create(pem_root_certs=%s, "
|
|
127
127
|
"pem_key_cert_pair=%p, "
|
|
128
128
|
"reserved=%p)",
|
|
129
129
|
3, (pem_root_certs, pem_key_cert_pair, reserved));
|
|
130
130
|
GPR_ASSERT(reserved == NULL);
|
|
131
|
-
memset(c, 0, sizeof(grpc_ssl_credentials));
|
|
132
131
|
c->base.type = GRPC_CHANNEL_CREDENTIALS_TYPE_SSL;
|
|
133
132
|
c->base.vtable = &ssl_vtable;
|
|
134
133
|
gpr_ref_init(&c->base.refcount, 1);
|
|
@@ -225,7 +224,7 @@ grpc_server_credentials *grpc_ssl_server_credentials_create_ex(
|
|
|
225
224
|
grpc_ssl_client_certificate_request_type client_certificate_request,
|
|
226
225
|
void *reserved) {
|
|
227
226
|
grpc_ssl_server_credentials *c =
|
|
228
|
-
|
|
227
|
+
gpr_zalloc(sizeof(grpc_ssl_server_credentials));
|
|
229
228
|
GRPC_API_TRACE(
|
|
230
229
|
"grpc_ssl_server_credentials_create_ex("
|
|
231
230
|
"pem_root_certs=%s, pem_key_cert_pairs=%p, num_key_cert_pairs=%lu, "
|
|
@@ -233,7 +232,6 @@ grpc_server_credentials *grpc_ssl_server_credentials_create_ex(
|
|
|
233
232
|
5, (pem_root_certs, pem_key_cert_pairs, (unsigned long)num_key_cert_pairs,
|
|
234
233
|
client_certificate_request, reserved));
|
|
235
234
|
GPR_ASSERT(reserved == NULL);
|
|
236
|
-
memset(c, 0, sizeof(grpc_ssl_server_credentials));
|
|
237
235
|
c->base.type = GRPC_CHANNEL_CREDENTIALS_TYPE_SSL;
|
|
238
236
|
gpr_ref_init(&c->base.refcount, 1);
|
|
239
237
|
c->base.vtable = &ssl_server_vtable;
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
#include "src/core/lib/security/credentials/credentials.h"
|
|
46
46
|
#include "src/core/lib/security/transport/security_connector.h"
|
|
47
47
|
#include "src/core/lib/slice/slice_internal.h"
|
|
48
|
+
#include "src/core/lib/slice/slice_string_helpers.h"
|
|
48
49
|
#include "src/core/lib/support/string.h"
|
|
49
50
|
#include "src/core/lib/surface/call.h"
|
|
50
51
|
#include "src/core/lib/transport/static_metadata.h"
|
|
@@ -54,8 +55,10 @@
|
|
|
54
55
|
/* We can have a per-call credentials. */
|
|
55
56
|
typedef struct {
|
|
56
57
|
grpc_call_credentials *creds;
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
bool have_host;
|
|
59
|
+
bool have_method;
|
|
60
|
+
grpc_slice host;
|
|
61
|
+
grpc_slice method;
|
|
59
62
|
/* pollset{_set} bound to this call; if we need to make external
|
|
60
63
|
network requests, they should be done under a pollset added to this
|
|
61
64
|
pollset_set so that work can progress when this call wants work to progress
|
|
@@ -89,14 +92,12 @@ static void reset_auth_metadata_context(
|
|
|
89
92
|
auth_md_context->channel_auth_context = NULL;
|
|
90
93
|
}
|
|
91
94
|
|
|
92
|
-
static void
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
&error_slice);
|
|
99
|
-
grpc_call_next_op(exec_ctx, elem, &calld->op);
|
|
95
|
+
static void add_error(grpc_error **combined, grpc_error *error) {
|
|
96
|
+
if (error == GRPC_ERROR_NONE) return;
|
|
97
|
+
if (*combined == GRPC_ERROR_NONE) {
|
|
98
|
+
*combined = GRPC_ERROR_CREATE("Client auth metadata plugin error");
|
|
99
|
+
}
|
|
100
|
+
*combined = grpc_error_add_child(*combined, error);
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
static void on_credentials_metadata(grpc_exec_ctx *exec_ctx, void *user_data,
|
|
@@ -110,30 +111,37 @@ static void on_credentials_metadata(grpc_exec_ctx *exec_ctx, void *user_data,
|
|
|
110
111
|
grpc_metadata_batch *mdb;
|
|
111
112
|
size_t i;
|
|
112
113
|
reset_auth_metadata_context(&calld->auth_md_context);
|
|
114
|
+
grpc_error *error = GRPC_ERROR_NONE;
|
|
113
115
|
if (status != GRPC_CREDENTIALS_OK) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
error = grpc_error_set_int(
|
|
117
|
+
GRPC_ERROR_CREATE(error_details != NULL && strlen(error_details) > 0
|
|
118
|
+
? error_details
|
|
119
|
+
: "Credentials failed to get metadata."),
|
|
120
|
+
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAUTHENTICATED);
|
|
121
|
+
} else {
|
|
122
|
+
GPR_ASSERT(num_md <= MAX_CREDENTIALS_METADATA_COUNT);
|
|
123
|
+
GPR_ASSERT(op->send_initial_metadata != NULL);
|
|
124
|
+
mdb = op->send_initial_metadata;
|
|
125
|
+
for (i = 0; i < num_md; i++) {
|
|
126
|
+
add_error(&error,
|
|
127
|
+
grpc_metadata_batch_add_tail(
|
|
128
|
+
exec_ctx, mdb, &calld->md_links[i],
|
|
129
|
+
grpc_mdelem_from_slices(
|
|
130
|
+
exec_ctx, grpc_slice_ref_internal(md_elems[i].key),
|
|
131
|
+
grpc_slice_ref_internal(md_elems[i].value))));
|
|
132
|
+
}
|
|
119
133
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
grpc_metadata_batch_add_tail(
|
|
125
|
-
mdb, &calld->md_links[i],
|
|
126
|
-
grpc_mdelem_from_slices(exec_ctx,
|
|
127
|
-
grpc_slice_ref_internal(md_elems[i].key),
|
|
128
|
-
grpc_slice_ref_internal(md_elems[i].value)));
|
|
134
|
+
if (error == GRPC_ERROR_NONE) {
|
|
135
|
+
grpc_call_next_op(exec_ctx, elem, op);
|
|
136
|
+
} else {
|
|
137
|
+
grpc_transport_stream_op_finish_with_failure(exec_ctx, op, error);
|
|
129
138
|
}
|
|
130
|
-
grpc_call_next_op(exec_ctx, elem, op);
|
|
131
139
|
}
|
|
132
140
|
|
|
133
141
|
void build_auth_metadata_context(grpc_security_connector *sc,
|
|
134
142
|
grpc_auth_context *auth_context,
|
|
135
143
|
call_data *calld) {
|
|
136
|
-
char *service =
|
|
144
|
+
char *service = grpc_slice_to_c_string(calld->method);
|
|
137
145
|
char *last_slash = strrchr(service, '/');
|
|
138
146
|
char *method_name = NULL;
|
|
139
147
|
char *service_url = NULL;
|
|
@@ -149,14 +157,15 @@ void build_auth_metadata_context(grpc_security_connector *sc,
|
|
|
149
157
|
method_name = gpr_strdup(last_slash + 1);
|
|
150
158
|
}
|
|
151
159
|
if (method_name == NULL) method_name = gpr_strdup("");
|
|
160
|
+
char *host = grpc_slice_to_c_string(calld->host);
|
|
152
161
|
gpr_asprintf(&service_url, "%s://%s%s",
|
|
153
|
-
sc->url_scheme == NULL ? "" : sc->url_scheme,
|
|
154
|
-
grpc_mdstr_as_c_string(calld->host), service);
|
|
162
|
+
sc->url_scheme == NULL ? "" : sc->url_scheme, host, service);
|
|
155
163
|
calld->auth_md_context.service_url = service_url;
|
|
156
164
|
calld->auth_md_context.method_name = method_name;
|
|
157
165
|
calld->auth_md_context.channel_auth_context =
|
|
158
166
|
GRPC_AUTH_CONTEXT_REF(auth_context, "grpc_auth_metadata_context");
|
|
159
167
|
gpr_free(service);
|
|
168
|
+
gpr_free(host);
|
|
160
169
|
}
|
|
161
170
|
|
|
162
171
|
static void send_security_metadata(grpc_exec_ctx *exec_ctx,
|
|
@@ -180,8 +189,12 @@ static void send_security_metadata(grpc_exec_ctx *exec_ctx,
|
|
|
180
189
|
calld->creds = grpc_composite_call_credentials_create(channel_call_creds,
|
|
181
190
|
ctx->creds, NULL);
|
|
182
191
|
if (calld->creds == NULL) {
|
|
183
|
-
|
|
184
|
-
|
|
192
|
+
grpc_transport_stream_op_finish_with_failure(
|
|
193
|
+
exec_ctx, op,
|
|
194
|
+
grpc_error_set_int(
|
|
195
|
+
GRPC_ERROR_CREATE(
|
|
196
|
+
"Incompatible credentials set on channel and call."),
|
|
197
|
+
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAUTHENTICATED));
|
|
185
198
|
return;
|
|
186
199
|
}
|
|
187
200
|
} else {
|
|
@@ -207,9 +220,14 @@ static void on_host_checked(grpc_exec_ctx *exec_ctx, void *user_data,
|
|
|
207
220
|
send_security_metadata(exec_ctx, elem, &calld->op);
|
|
208
221
|
} else {
|
|
209
222
|
char *error_msg;
|
|
223
|
+
char *host = grpc_slice_to_c_string(calld->host);
|
|
210
224
|
gpr_asprintf(&error_msg, "Invalid host %s set in :authority metadata.",
|
|
211
|
-
|
|
212
|
-
|
|
225
|
+
host);
|
|
226
|
+
gpr_free(host);
|
|
227
|
+
grpc_call_element_signal_error(
|
|
228
|
+
exec_ctx, elem, grpc_error_set_int(GRPC_ERROR_CREATE(error_msg),
|
|
229
|
+
GRPC_ERROR_INT_GRPC_STATUS,
|
|
230
|
+
GRPC_STATUS_UNAUTHENTICATED));
|
|
213
231
|
gpr_free(error_msg);
|
|
214
232
|
}
|
|
215
233
|
}
|
|
@@ -247,23 +265,30 @@ static void auth_start_transport_op(grpc_exec_ctx *exec_ctx,
|
|
|
247
265
|
|
|
248
266
|
if (op->send_initial_metadata != NULL) {
|
|
249
267
|
for (l = op->send_initial_metadata->list.head; l != NULL; l = l->next) {
|
|
250
|
-
grpc_mdelem
|
|
268
|
+
grpc_mdelem md = l->md;
|
|
251
269
|
/* Pointer comparison is OK for md_elems created from the same context.
|
|
252
270
|
*/
|
|
253
|
-
if (md
|
|
254
|
-
if (calld->
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
calld->
|
|
271
|
+
if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_AUTHORITY)) {
|
|
272
|
+
if (calld->have_host) {
|
|
273
|
+
grpc_slice_unref_internal(exec_ctx, calld->host);
|
|
274
|
+
}
|
|
275
|
+
calld->host = grpc_slice_ref_internal(GRPC_MDVALUE(md));
|
|
276
|
+
calld->have_host = true;
|
|
277
|
+
} else if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_PATH)) {
|
|
278
|
+
if (calld->have_method) {
|
|
279
|
+
grpc_slice_unref_internal(exec_ctx, calld->method);
|
|
280
|
+
}
|
|
281
|
+
calld->method = grpc_slice_ref_internal(GRPC_MDVALUE(md));
|
|
282
|
+
calld->have_method = true;
|
|
259
283
|
}
|
|
260
284
|
}
|
|
261
|
-
if (calld->
|
|
262
|
-
|
|
285
|
+
if (calld->have_host) {
|
|
286
|
+
char *call_host = grpc_slice_to_c_string(calld->host);
|
|
263
287
|
calld->op = *op; /* Copy op (originates from the caller's stack). */
|
|
264
288
|
grpc_channel_security_connector_check_call_host(
|
|
265
289
|
exec_ctx, chand->security_connector, call_host, chand->auth_context,
|
|
266
290
|
on_host_checked, elem);
|
|
291
|
+
gpr_free(call_host);
|
|
267
292
|
GPR_TIMER_END("auth_start_transport_op", 0);
|
|
268
293
|
return; /* early exit */
|
|
269
294
|
}
|
|
@@ -277,7 +302,7 @@ static void auth_start_transport_op(grpc_exec_ctx *exec_ctx,
|
|
|
277
302
|
/* Constructor for call_data */
|
|
278
303
|
static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
|
|
279
304
|
grpc_call_element *elem,
|
|
280
|
-
grpc_call_element_args *args) {
|
|
305
|
+
const grpc_call_element_args *args) {
|
|
281
306
|
call_data *calld = elem->call_data;
|
|
282
307
|
memset(calld, 0, sizeof(*calld));
|
|
283
308
|
return GRPC_ERROR_NONE;
|
|
@@ -296,11 +321,11 @@ static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
|
|
296
321
|
void *ignored) {
|
|
297
322
|
call_data *calld = elem->call_data;
|
|
298
323
|
grpc_call_credentials_unref(exec_ctx, calld->creds);
|
|
299
|
-
if (calld->
|
|
300
|
-
|
|
324
|
+
if (calld->have_host) {
|
|
325
|
+
grpc_slice_unref_internal(exec_ctx, calld->host);
|
|
301
326
|
}
|
|
302
|
-
if (calld->
|
|
303
|
-
|
|
327
|
+
if (calld->have_method) {
|
|
328
|
+
grpc_slice_unref_internal(exec_ctx, calld->method);
|
|
304
329
|
}
|
|
305
330
|
reset_auth_metadata_context(&calld->auth_md_context);
|
|
306
331
|
}
|
|
@@ -310,7 +335,7 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
|
|
|
310
335
|
grpc_channel_element *elem,
|
|
311
336
|
grpc_channel_element_args *args) {
|
|
312
337
|
grpc_security_connector *sc =
|
|
313
|
-
|
|
338
|
+
grpc_security_connector_find_in_args(args->channel_args);
|
|
314
339
|
grpc_auth_context *auth_context =
|
|
315
340
|
grpc_find_auth_context_in_args(args->channel_args);
|
|
316
341
|
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* Copyright 2017, Google Inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
|
7
|
+
* modification, are permitted provided that the following conditions are
|
|
8
|
+
* met:
|
|
9
|
+
*
|
|
10
|
+
* * Redistributions of source code must retain the above copyright
|
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
|
12
|
+
* * Redistributions in binary form must reproduce the above
|
|
13
|
+
* copyright notice, this list of conditions and the following disclaimer
|
|
14
|
+
* in the documentation and/or other materials provided with the
|
|
15
|
+
* distribution.
|
|
16
|
+
* * Neither the name of Google Inc. nor the names of its
|
|
17
|
+
* contributors may be used to endorse or promote products derived from
|
|
18
|
+
* this software without specific prior written permission.
|
|
19
|
+
*
|
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
21
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
22
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
23
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
24
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
25
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
26
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
27
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
28
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
29
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
30
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
#include <grpc/support/log.h>
|
|
35
|
+
|
|
36
|
+
#include "src/core/lib/channel/channel_args.h"
|
|
37
|
+
#include "src/core/lib/security/transport/lb_targets_info.h"
|
|
38
|
+
|
|
39
|
+
/* Channel arg key for the mapping of LB server addresses to their names for
|
|
40
|
+
* secure naming purposes. */
|
|
41
|
+
#define GRPC_ARG_LB_SECURE_NAMING_MAP "grpc.lb_secure_naming_map"
|
|
42
|
+
|
|
43
|
+
static void *targets_info_copy(void *p) { return grpc_slice_hash_table_ref(p); }
|
|
44
|
+
static void targets_info_destroy(grpc_exec_ctx *exec_ctx, void *p) {
|
|
45
|
+
grpc_slice_hash_table_unref(exec_ctx, p);
|
|
46
|
+
}
|
|
47
|
+
static int targets_info_cmp(void *a, void *b) { return GPR_ICMP(a, b); }
|
|
48
|
+
static const grpc_arg_pointer_vtable server_to_balancer_names_vtable = {
|
|
49
|
+
targets_info_copy, targets_info_destroy, targets_info_cmp};
|
|
50
|
+
|
|
51
|
+
grpc_arg grpc_lb_targets_info_create_channel_arg(
|
|
52
|
+
grpc_slice_hash_table *targets_info) {
|
|
53
|
+
grpc_arg arg;
|
|
54
|
+
arg.type = GRPC_ARG_POINTER;
|
|
55
|
+
arg.key = GRPC_ARG_LB_SECURE_NAMING_MAP;
|
|
56
|
+
arg.value.pointer.p = targets_info;
|
|
57
|
+
arg.value.pointer.vtable = &server_to_balancer_names_vtable;
|
|
58
|
+
return arg;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
grpc_slice_hash_table *grpc_lb_targets_info_find_in_args(
|
|
62
|
+
const grpc_channel_args *args) {
|
|
63
|
+
const grpc_arg *targets_info_arg =
|
|
64
|
+
grpc_channel_args_find(args, GRPC_ARG_LB_SECURE_NAMING_MAP);
|
|
65
|
+
if (targets_info_arg != NULL) {
|
|
66
|
+
GPR_ASSERT(targets_info_arg->type == GRPC_ARG_POINTER);
|
|
67
|
+
return targets_info_arg->value.pointer.p;
|
|
68
|
+
}
|
|
69
|
+
return NULL;
|
|
70
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* Copyright 2017, Google Inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
|
7
|
+
* modification, are permitted provided that the following conditions are
|
|
8
|
+
* met:
|
|
9
|
+
*
|
|
10
|
+
* * Redistributions of source code must retain the above copyright
|
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
|
12
|
+
* * Redistributions in binary form must reproduce the above
|
|
13
|
+
* copyright notice, this list of conditions and the following disclaimer
|
|
14
|
+
* in the documentation and/or other materials provided with the
|
|
15
|
+
* distribution.
|
|
16
|
+
* * Neither the name of Google Inc. nor the names of its
|
|
17
|
+
* contributors may be used to endorse or promote products derived from
|
|
18
|
+
* this software without specific prior written permission.
|
|
19
|
+
*
|
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
21
|
+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
22
|
+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
23
|
+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
24
|
+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
25
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
26
|
+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
27
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
28
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
29
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
30
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
#ifndef GRPC_CORE_LIB_SECURITY_TRANSPORT_LB_TARGETS_INFO_H
|
|
35
|
+
#define GRPC_CORE_LIB_SECURITY_TRANSPORT_LB_TARGETS_INFO_H
|
|
36
|
+
|
|
37
|
+
#include "src/core/lib/slice/slice_hash_table.h"
|
|
38
|
+
|
|
39
|
+
/** Return a channel argument containing \a targets_info. */
|
|
40
|
+
grpc_arg grpc_lb_targets_info_create_channel_arg(
|
|
41
|
+
grpc_slice_hash_table *targets_info);
|
|
42
|
+
|
|
43
|
+
/** Return the instance of targets info in \a args or NULL */
|
|
44
|
+
grpc_slice_hash_table *grpc_lb_targets_info_find_in_args(
|
|
45
|
+
const grpc_channel_args *args);
|
|
46
|
+
|
|
47
|
+
#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_LB_TARGETS_INFO_H */
|
|
@@ -341,10 +341,10 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
|
|
|
341
341
|
GPR_TIMER_END("secure_endpoint.endpoint_write", 0);
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
-
static void endpoint_shutdown(grpc_exec_ctx *exec_ctx,
|
|
345
|
-
|
|
344
|
+
static void endpoint_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
|
|
345
|
+
grpc_error *why) {
|
|
346
346
|
secure_endpoint *ep = (secure_endpoint *)secure_ep;
|
|
347
|
-
grpc_endpoint_shutdown(exec_ctx, ep->wrapped_ep);
|
|
347
|
+
grpc_endpoint_shutdown(exec_ctx, ep->wrapped_ep, why);
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
static void endpoint_destroy(grpc_exec_ctx *exec_ctx,
|