libcouchbase 1.2.8 → 1.3.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.
- checksums.yaml +4 -4
- data/.travis.yml +4 -4
- data/README.md +16 -8
- data/ext/libcouchbase/CMakeLists.txt +34 -32
- data/ext/libcouchbase/RELEASE_NOTES.markdown +277 -6
- data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +14 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibevent.cmake +2 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibuv.cmake +2 -1
- data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +2 -0
- data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +8 -1
- data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
- data/ext/libcouchbase/cmake/config-cmake.h.in +14 -0
- data/ext/libcouchbase/cmake/configure +8 -26
- data/ext/libcouchbase/cmake/defs.mk.in +2 -2
- data/ext/libcouchbase/cmake/libcouchbase.stp.in +829 -0
- data/ext/libcouchbase/cmake/source_files.cmake +11 -2
- data/ext/libcouchbase/contrib/cbsasl/CMakeLists.txt +18 -2
- data/ext/libcouchbase/contrib/cbsasl/include/cbsasl/cbsasl.h +44 -2
- data/ext/libcouchbase/contrib/cbsasl/src/client.c +285 -73
- data/ext/libcouchbase/contrib/cbsasl/src/common.c +4 -0
- data/ext/libcouchbase/contrib/cbsasl/src/scram-sha/scram_utils.c +500 -0
- data/ext/libcouchbase/contrib/cbsasl/src/scram-sha/scram_utils.h +99 -0
- data/ext/libcouchbase/contrib/cliopts/CMakeLists.txt +1 -1
- data/ext/libcouchbase/contrib/cliopts/cliopts.h +14 -1
- data/ext/libcouchbase/contrib/snappy/CMakeLists.txt +2 -3
- data/ext/libcouchbase/contrib/snappy/snappy-sinksource.cc +4 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-public.h +7 -5
- data/ext/libcouchbase/contrib/snappy/snappy.cc +7 -2
- data/ext/libcouchbase/example/crypto/.gitignore +2 -0
- data/ext/libcouchbase/example/crypto/Makefile +13 -0
- data/ext/libcouchbase/example/crypto/common_provider.c +24 -0
- data/ext/libcouchbase/example/crypto/common_provider.h +31 -0
- data/ext/libcouchbase/example/crypto/openssl_symmetric_decrypt.c +139 -0
- data/ext/libcouchbase/example/crypto/openssl_symmetric_encrypt.c +147 -0
- data/ext/libcouchbase/example/crypto/openssl_symmetric_provider.c +281 -0
- data/ext/libcouchbase/example/crypto/openssl_symmetric_provider.h +29 -0
- data/ext/libcouchbase/example/tracing/.gitignore +2 -0
- data/ext/libcouchbase/example/tracing/Makefile +8 -0
- data/ext/libcouchbase/example/tracing/cJSON.c +1 -0
- data/ext/libcouchbase/example/tracing/cJSON.h +1 -0
- data/ext/libcouchbase/example/tracing/tracing.c +439 -0
- data/ext/libcouchbase/example/tracing/views.c +444 -0
- data/ext/libcouchbase/include/libcouchbase/auth.h +56 -4
- data/ext/libcouchbase/include/libcouchbase/cbft.h +8 -0
- data/ext/libcouchbase/include/libcouchbase/cntl-private.h +55 -1
- data/ext/libcouchbase/include/libcouchbase/cntl.h +101 -1
- data/ext/libcouchbase/include/libcouchbase/configuration.h.in +6 -0
- data/ext/libcouchbase/include/libcouchbase/couchbase.h +109 -6
- data/ext/libcouchbase/include/libcouchbase/crypto.h +140 -0
- data/ext/libcouchbase/include/libcouchbase/error.h +38 -2
- data/ext/libcouchbase/include/libcouchbase/kvbuf.h +6 -1
- data/ext/libcouchbase/include/libcouchbase/metrics.h +79 -0
- data/ext/libcouchbase/include/libcouchbase/n1ql.h +9 -0
- data/ext/libcouchbase/include/libcouchbase/tracing.h +319 -0
- data/ext/libcouchbase/include/libcouchbase/vbucket.h +1 -1
- data/ext/libcouchbase/include/libcouchbase/views.h +8 -0
- data/ext/libcouchbase/include/memcached/protocol_binary.h +40 -10
- data/ext/libcouchbase/packaging/rpm/libcouchbase.spec.in +6 -14
- data/ext/libcouchbase/plugins/io/libuv/plugin-internal.h +3 -0
- data/ext/libcouchbase/plugins/io/libuv/plugin-libuv.c +1 -0
- data/ext/libcouchbase/plugins/io/select/plugin-select.c +4 -1
- data/ext/libcouchbase/src/auth-priv.h +36 -4
- data/ext/libcouchbase/src/auth.cc +66 -27
- data/ext/libcouchbase/src/bootstrap.cc +1 -1
- data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +12 -7
- data/ext/libcouchbase/src/bucketconfig/bc_http.cc +26 -17
- data/ext/libcouchbase/src/bucketconfig/bc_http.h +1 -1
- data/ext/libcouchbase/src/bucketconfig/clconfig.h +4 -2
- data/ext/libcouchbase/src/bucketconfig/confmon.cc +6 -3
- data/ext/libcouchbase/src/cbft.cc +48 -0
- data/ext/libcouchbase/src/cntl.cc +138 -2
- data/ext/libcouchbase/src/config_static.h +17 -0
- data/ext/libcouchbase/src/connspec.cc +54 -6
- data/ext/libcouchbase/src/connspec.h +9 -1
- data/ext/libcouchbase/src/crypto.cc +386 -0
- data/ext/libcouchbase/src/ctx-log-inl.h +23 -6
- data/ext/libcouchbase/src/dump.cc +4 -0
- data/ext/libcouchbase/src/getconfig.cc +1 -2
- data/ext/libcouchbase/src/handler.cc +65 -27
- data/ext/libcouchbase/src/hostlist.cc +35 -7
- data/ext/libcouchbase/src/hostlist.h +7 -0
- data/ext/libcouchbase/src/http/http-priv.h +2 -0
- data/ext/libcouchbase/src/http/http.cc +77 -37
- data/ext/libcouchbase/src/http/http_io.cc +19 -2
- data/ext/libcouchbase/src/instance.cc +90 -17
- data/ext/libcouchbase/src/internal.h +5 -0
- data/ext/libcouchbase/src/lcbio/connect.cc +39 -4
- data/ext/libcouchbase/src/lcbio/connect.h +27 -0
- data/ext/libcouchbase/src/lcbio/ctx.c +49 -23
- data/ext/libcouchbase/src/lcbio/ioutils.cc +30 -3
- data/ext/libcouchbase/src/lcbio/ioutils.h +2 -0
- data/ext/libcouchbase/src/lcbio/manager.cc +44 -8
- data/ext/libcouchbase/src/lcbio/manager.h +2 -0
- data/ext/libcouchbase/src/lcbio/rw-inl.h +1 -0
- data/ext/libcouchbase/src/lcbio/ssl.h +3 -5
- data/ext/libcouchbase/src/logging.c +1 -1
- data/ext/libcouchbase/src/logging.h +2 -0
- data/ext/libcouchbase/src/mc/compress.cc +164 -0
- data/ext/libcouchbase/src/mc/compress.h +7 -12
- data/ext/libcouchbase/src/mc/mcreq-flush-inl.h +5 -1
- data/ext/libcouchbase/src/mc/mcreq.c +11 -1
- data/ext/libcouchbase/src/mc/mcreq.h +35 -4
- data/ext/libcouchbase/src/mcserver/mcserver.cc +30 -7
- data/ext/libcouchbase/src/mcserver/mcserver.h +7 -0
- data/ext/libcouchbase/src/mcserver/negotiate.cc +103 -57
- data/ext/libcouchbase/src/mcserver/negotiate.h +2 -2
- data/ext/libcouchbase/src/mctx-helper.h +11 -0
- data/ext/libcouchbase/src/metrics.cc +132 -0
- data/ext/libcouchbase/src/n1ql/ixmgmt.cc +2 -1
- data/ext/libcouchbase/src/n1ql/n1ql.cc +66 -0
- data/ext/libcouchbase/src/newconfig.cc +9 -2
- data/ext/libcouchbase/src/operations/counter.cc +2 -1
- data/ext/libcouchbase/src/operations/durability-cas.cc +11 -0
- data/ext/libcouchbase/src/operations/durability-seqno.cc +3 -0
- data/ext/libcouchbase/src/operations/durability.cc +24 -2
- data/ext/libcouchbase/src/operations/durability_internal.h +19 -0
- data/ext/libcouchbase/src/operations/get.cc +4 -2
- data/ext/libcouchbase/src/operations/observe-seqno.cc +1 -0
- data/ext/libcouchbase/src/operations/observe.cc +113 -62
- data/ext/libcouchbase/src/operations/ping.cc +246 -67
- data/ext/libcouchbase/src/operations/remove.cc +2 -1
- data/ext/libcouchbase/src/operations/store.cc +17 -14
- data/ext/libcouchbase/src/operations/touch.cc +3 -0
- data/ext/libcouchbase/src/packetutils.h +68 -4
- data/ext/libcouchbase/src/probes.d +132 -161
- data/ext/libcouchbase/src/rdb/bigalloc.c +1 -1
- data/ext/libcouchbase/src/retryq.cc +6 -2
- data/ext/libcouchbase/src/rnd.cc +68 -0
- data/ext/libcouchbase/src/rnd.h +39 -0
- data/ext/libcouchbase/src/settings.c +27 -0
- data/ext/libcouchbase/src/settings.h +67 -3
- data/ext/libcouchbase/src/ssl/CMakeLists.txt +0 -12
- data/ext/libcouchbase/src/ssl/ssl_common.c +23 -4
- data/ext/libcouchbase/src/strcodecs/base64.c +141 -16
- data/ext/libcouchbase/src/strcodecs/strcodecs.h +16 -1
- data/ext/libcouchbase/src/trace.h +68 -61
- data/ext/libcouchbase/src/tracing/span.cc +289 -0
- data/ext/libcouchbase/src/tracing/threshold_logging_tracer.cc +171 -0
- data/ext/libcouchbase/src/tracing/tracer.cc +53 -0
- data/ext/libcouchbase/src/tracing/tracing-internal.h +213 -0
- data/ext/libcouchbase/src/utilities.c +5 -0
- data/ext/libcouchbase/src/vbucket/CMakeLists.txt +2 -2
- data/ext/libcouchbase/src/vbucket/vbucket.c +50 -18
- data/ext/libcouchbase/src/views/docreq.cc +26 -1
- data/ext/libcouchbase/src/views/docreq.h +17 -0
- data/ext/libcouchbase/src/views/viewreq.cc +64 -1
- data/ext/libcouchbase/src/views/viewreq.h +21 -0
- data/ext/libcouchbase/tests/CMakeLists.txt +6 -6
- data/ext/libcouchbase/tests/basic/t_base64.cc +34 -6
- data/ext/libcouchbase/tests/basic/t_connstr.cc +14 -0
- data/ext/libcouchbase/tests/basic/t_creds.cc +10 -10
- data/ext/libcouchbase/tests/basic/t_host.cc +22 -2
- data/ext/libcouchbase/tests/basic/t_scram.cc +514 -0
- data/ext/libcouchbase/tests/check-all.cc +6 -2
- data/ext/libcouchbase/tests/iotests/mock-environment.cc +64 -0
- data/ext/libcouchbase/tests/iotests/mock-environment.h +27 -1
- data/ext/libcouchbase/tests/iotests/t_confmon.cc +2 -2
- data/ext/libcouchbase/tests/iotests/t_forward.cc +8 -0
- data/ext/libcouchbase/tests/iotests/t_netfail.cc +124 -0
- data/ext/libcouchbase/tests/iotests/t_smoke.cc +1 -1
- data/ext/libcouchbase/tests/iotests/t_snappy.cc +316 -0
- data/ext/libcouchbase/tests/socktests/socktest.cc +2 -2
- data/ext/libcouchbase/tests/socktests/t_basic.cc +6 -6
- data/ext/libcouchbase/tests/socktests/t_manager.cc +1 -1
- data/ext/libcouchbase/tests/socktests/t_ssl.cc +1 -1
- data/ext/libcouchbase/tools/CMakeLists.txt +1 -1
- data/ext/libcouchbase/tools/cbc-handlers.h +17 -0
- data/ext/libcouchbase/tools/cbc-n1qlback.cc +7 -4
- data/ext/libcouchbase/tools/cbc-pillowfight.cc +408 -100
- data/ext/libcouchbase/tools/cbc-proxy.cc +134 -3
- data/ext/libcouchbase/tools/cbc-subdoc.cc +1 -2
- data/ext/libcouchbase/tools/cbc.cc +113 -8
- data/ext/libcouchbase/tools/common/histogram.cc +1 -0
- data/ext/libcouchbase/tools/common/options.cc +28 -1
- data/ext/libcouchbase/tools/common/options.h +5 -0
- data/ext/libcouchbase/tools/docgen/docgen.h +36 -10
- data/ext/libcouchbase/tools/docgen/loc.h +5 -4
- data/ext/libcouchbase/tools/docgen/seqgen.h +28 -0
- data/lib/libcouchbase/ext/libcouchbase/enums.rb +10 -0
- data/lib/libcouchbase/n1ql.rb +6 -1
- data/lib/libcouchbase/version.rb +1 -1
- data/spec/connection_spec.rb +6 -6
- metadata +38 -5
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseSnappy.cmake +0 -11
- data/ext/libcouchbase/src/mc/compress.c +0 -90
- data/ext/libcouchbase/tools/common/my_inttypes.h +0 -22
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
#include "sllist.h"
|
|
24
24
|
#include <lcbio/ssl.h>
|
|
25
25
|
|
|
26
|
+
#define LOGFMT CTX_LOGFMT
|
|
27
|
+
#define LOGID(req) CTX_LOGID(req->ioctx)
|
|
26
28
|
using namespace lcb::http;
|
|
27
29
|
|
|
28
|
-
#define LOGFMT "<%s:%s>"
|
|
29
|
-
#define LOGID(req) get_ctx_host((req)->ioctx), get_ctx_port((req)->ioctx)
|
|
30
30
|
#define LOGARGS(req, lvl) req->instance->settings, "http-io", LCB_LOG_##lvl, __FILE__, __LINE__
|
|
31
31
|
|
|
32
32
|
void
|
|
@@ -233,6 +233,23 @@ on_connected(lcbio_SOCKET *sock, void *arg, lcb_error_t err, lcbio_OSERR syserr)
|
|
|
233
233
|
procs.cb_err = io_error;
|
|
234
234
|
procs.cb_read = io_read;
|
|
235
235
|
req->ioctx = lcbio_ctx_new(sock, arg, &procs);
|
|
236
|
+
switch (req->reqtype) {
|
|
237
|
+
case LCB_HTTP_TYPE_N1QL:
|
|
238
|
+
sock->service = LCBIO_SERVICE_N1QL;
|
|
239
|
+
break;
|
|
240
|
+
case LCB_HTTP_TYPE_VIEW:
|
|
241
|
+
sock->service = LCBIO_SERVICE_VIEW;
|
|
242
|
+
break;
|
|
243
|
+
case LCB_HTTP_TYPE_FTS:
|
|
244
|
+
sock->service = LCBIO_SERVICE_FTS;
|
|
245
|
+
break;
|
|
246
|
+
case LCB_HTTP_TYPE_CBAS:
|
|
247
|
+
sock->service = LCBIO_SERVICE_CBAS;
|
|
248
|
+
break;
|
|
249
|
+
default:
|
|
250
|
+
sock->service = LCBIO_SERVICE_MGMT;
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
236
253
|
req->ioctx->subsys = "mgmt/capi";
|
|
237
254
|
lcbio_ctx_put(req->ioctx, &req->preamble[0], req->preamble.size());
|
|
238
255
|
if (!req->body.empty()) {
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
#include "connspec.h"
|
|
20
20
|
#include "logging.h"
|
|
21
21
|
#include "hostlist.h"
|
|
22
|
+
#include "rnd.h"
|
|
22
23
|
#include "http/http.h"
|
|
23
24
|
#include "bucketconfig/clconfig.h"
|
|
24
25
|
#include <lcbio/iotable.h>
|
|
25
26
|
#include <lcbio/ssl.h>
|
|
26
27
|
#define LOGARGS(obj,lvl) (obj)->settings, "instance", LCB_LOG_##lvl, __FILE__, __LINE__
|
|
27
28
|
|
|
28
|
-
static volatile unsigned int lcb_instance_index = 0;
|
|
29
29
|
using namespace lcb;
|
|
30
30
|
|
|
31
31
|
LIBCOUCHBASE_API
|
|
@@ -56,6 +56,11 @@ LIBCOUCHBASE_API
|
|
|
56
56
|
void
|
|
57
57
|
lcb_set_auth(lcb_t instance, lcb_AUTHENTICATOR *auth)
|
|
58
58
|
{
|
|
59
|
+
if (LCBT_SETTING(instance, keypath)) {
|
|
60
|
+
lcb_log(LOGARGS(instance, WARN),
|
|
61
|
+
"Custom authenticator ignored when SSL client certificate authentication in use");
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
59
64
|
/* First increase refcount in case they are the same object(!) */
|
|
60
65
|
lcbauth_ref(auth);
|
|
61
66
|
lcbauth_unref(instance->settings->auth);
|
|
@@ -74,7 +79,11 @@ lcb_st::add_bs_host(const char *host, int port, unsigned bstype)
|
|
|
74
79
|
tname = "HTTP";
|
|
75
80
|
target = ht_nodes;
|
|
76
81
|
}
|
|
77
|
-
|
|
82
|
+
bool ipv6 = strchr(host, ':') != NULL;
|
|
83
|
+
lcb_log(LOGARGS(this, DEBUG), "Adding host " LCB_LOG_SPEC("%s%s%s:%d") " to initial %s bootstrap list",
|
|
84
|
+
this->settings->log_redaction ? LCB_LOG_SD_OTAG : "",
|
|
85
|
+
ipv6 ? "[" : "", host, ipv6 ? "]" : "", port,
|
|
86
|
+
this->settings->log_redaction ? LCB_LOG_SD_CTAG : "", tname);
|
|
78
87
|
target->add(host, port);
|
|
79
88
|
}
|
|
80
89
|
|
|
@@ -114,6 +123,8 @@ lcb_st::populate_nodes(const Connspec& spec)
|
|
|
114
123
|
const Spechost &dh = spec.hosts()[ii];
|
|
115
124
|
add_bs_host(dh, defl_http, defl_cccp);
|
|
116
125
|
}
|
|
126
|
+
lcb_log(LOGARGS(this, TRACE), "Bootstrap hosts loaded (cccp:%d, http:%d)", (int)mc_nodes->size(),
|
|
127
|
+
(int)ht_nodes->size());
|
|
117
128
|
}
|
|
118
129
|
|
|
119
130
|
lcb_error_t
|
|
@@ -148,7 +159,9 @@ lcb_st::process_dns_srv(Connspec& spec)
|
|
|
148
159
|
sh.port = std::atoi(src.port);
|
|
149
160
|
sh.type = spec.default_port();
|
|
150
161
|
spec.add_host(sh);
|
|
151
|
-
|
|
162
|
+
bool ipv6 = sh.hostname.find(':') != std::string::npos;
|
|
163
|
+
lcb_log(LOGARGS(this, INFO), "Found host %s%s%s:%d via DNS SRV", ipv6 ? "[" : "", sh.hostname.c_str(),
|
|
164
|
+
ipv6 ? "]" : "", (int)sh.port);
|
|
152
165
|
}
|
|
153
166
|
delete hl;
|
|
154
167
|
|
|
@@ -240,6 +253,11 @@ setup_ssl(lcb_t obj, const Connspec& params)
|
|
|
240
253
|
settings->certpath = strdup(optbuf);
|
|
241
254
|
}
|
|
242
255
|
|
|
256
|
+
if (lcb_getenv_nonempty("LCB_SSL_KEY", optbuf, sizeof optbuf)) {
|
|
257
|
+
lcb_log(LOGARGS(obj, INFO), "SSL key %s specified on environment", optbuf);
|
|
258
|
+
settings->keypath = strdup(optbuf);
|
|
259
|
+
}
|
|
260
|
+
|
|
243
261
|
if (lcb_getenv_nonempty("LCB_SSL_MODE", optbuf, sizeof optbuf)) {
|
|
244
262
|
if (sscanf(optbuf, "%d", &env_policy) != 1) {
|
|
245
263
|
lcb_log(LOGARGS(obj, ERR), "Invalid value for environment LCB_SSL. (%s)", optbuf);
|
|
@@ -250,10 +268,18 @@ setup_ssl(lcb_t obj, const Connspec& params)
|
|
|
250
268
|
}
|
|
251
269
|
}
|
|
252
270
|
|
|
271
|
+
if (settings->truststorepath == NULL && !params.truststorepath().empty()) {
|
|
272
|
+
settings->truststorepath = strdup(params.truststorepath().c_str());
|
|
273
|
+
}
|
|
274
|
+
|
|
253
275
|
if (settings->certpath == NULL && !params.certpath().empty()) {
|
|
254
276
|
settings->certpath = strdup(params.certpath().c_str());
|
|
255
277
|
}
|
|
256
278
|
|
|
279
|
+
if (settings->keypath == NULL && !params.keypath().empty()) {
|
|
280
|
+
settings->keypath = strdup(params.keypath().c_str());
|
|
281
|
+
}
|
|
282
|
+
|
|
257
283
|
if (env_policy == -1) {
|
|
258
284
|
settings->sslopts = params.sslopts();
|
|
259
285
|
}
|
|
@@ -264,11 +290,21 @@ setup_ssl(lcb_t obj, const Connspec& params)
|
|
|
264
290
|
} else {
|
|
265
291
|
lcb_log(LOGARGS(obj, INFO), "ssl=no_global_init. Not initializing openssl globals");
|
|
266
292
|
}
|
|
267
|
-
settings->
|
|
268
|
-
|
|
293
|
+
if (settings->keypath && !settings->certpath) {
|
|
294
|
+
lcb_log(LOGARGS(obj, ERR), "SSL key have to be specified with certificate");
|
|
295
|
+
return LCB_EINVAL;
|
|
296
|
+
}
|
|
297
|
+
settings->ssl_ctx =
|
|
298
|
+
lcbio_ssl_new(settings->truststorepath, settings->certpath, settings->keypath,
|
|
299
|
+
settings->sslopts & LCB_SSL_NOVERIFY, &err, settings);
|
|
269
300
|
if (!settings->ssl_ctx) {
|
|
270
301
|
return err;
|
|
271
302
|
}
|
|
303
|
+
} else {
|
|
304
|
+
// keypath might be used to flag, that library is using SSL authentication
|
|
305
|
+
// To avoid skipping other authentication mechanisms, cleanup the keypath.
|
|
306
|
+
free(settings->keypath);
|
|
307
|
+
settings->keypath = NULL;
|
|
272
308
|
}
|
|
273
309
|
return LCB_SUCCESS;
|
|
274
310
|
}
|
|
@@ -329,7 +365,6 @@ lcb_reinit3(lcb_t obj, const char *connstr)
|
|
|
329
365
|
Connspec params;
|
|
330
366
|
lcb_error_t err;
|
|
331
367
|
const char *errmsg = NULL;
|
|
332
|
-
memset(¶ms, 0, sizeof params);
|
|
333
368
|
err = params.parse(connstr, &errmsg);
|
|
334
369
|
|
|
335
370
|
if (err != LCB_SUCCESS) {
|
|
@@ -367,6 +402,10 @@ lcb_error_t lcb_create(lcb_t *instance,
|
|
|
367
402
|
lcb_error_t err;
|
|
368
403
|
lcb_settings *settings;
|
|
369
404
|
|
|
405
|
+
#if !defined(COMPILER_SUPPORTS_CXX11) || (defined(_MSC_VER) && _MSC_VER < 1600)
|
|
406
|
+
lcb_rnd_global_init();
|
|
407
|
+
#endif
|
|
408
|
+
|
|
370
409
|
if (options) {
|
|
371
410
|
io_priv = options->v.v0.io;
|
|
372
411
|
if (options->version > 0) {
|
|
@@ -385,6 +424,7 @@ lcb_error_t lcb_create(lcb_t *instance,
|
|
|
385
424
|
err = LCB_CLIENT_ENOMEM;
|
|
386
425
|
goto GT_DONE;
|
|
387
426
|
}
|
|
427
|
+
obj->crypto = new std::map<std::string, lcbcrypto_PROVIDER*>();
|
|
388
428
|
if (!(settings = lcb_settings_new())) {
|
|
389
429
|
err = LCB_CLIENT_ENOMEM;
|
|
390
430
|
goto GT_DONE;
|
|
@@ -394,6 +434,7 @@ lcb_error_t lcb_create(lcb_t *instance,
|
|
|
394
434
|
obj->type = type;
|
|
395
435
|
obj->settings = settings;
|
|
396
436
|
obj->settings->conntype = type;
|
|
437
|
+
obj->settings->ipv6 = spec.ipv6_policy();
|
|
397
438
|
|
|
398
439
|
settings->bucket = strdup(spec.bucket().c_str());
|
|
399
440
|
|
|
@@ -411,14 +452,21 @@ lcb_error_t lcb_create(lcb_t *instance,
|
|
|
411
452
|
}
|
|
412
453
|
|
|
413
454
|
settings->logger = lcb_init_console_logger();
|
|
414
|
-
settings->iid =
|
|
455
|
+
settings->iid = lcb_next_rand32();
|
|
415
456
|
if (spec.loglevel()) {
|
|
416
457
|
lcb_U32 val = spec.loglevel();
|
|
417
458
|
lcb_cntl(obj, LCB_CNTL_SET, LCB_CNTL_CONLOGGER_LEVEL, &val);
|
|
418
459
|
}
|
|
460
|
+
settings->log_redaction = spec.logredact();
|
|
461
|
+
if (settings->log_redaction) {
|
|
462
|
+
lcb_log(LOGARGS(obj, INFO), "Logging redaction enabled. Logs have reduced identifying information. Diagnosis "
|
|
463
|
+
"and support of issues may be challenging or not possible in this configuration");
|
|
464
|
+
}
|
|
419
465
|
|
|
420
466
|
lcb_log(LOGARGS(obj, INFO), "Version=%s, Changeset=%s", lcb_get_version(NULL), LCB_VERSION_CHANGESET);
|
|
421
|
-
lcb_log(LOGARGS(obj, INFO), "Effective connection string: %s. Bucket
|
|
467
|
+
lcb_log(LOGARGS(obj, INFO), "Effective connection string: " LCB_LOG_SPEC("%s") ". Bucket=" LCB_LOG_SPEC("%s"),
|
|
468
|
+
settings->log_redaction ? LCB_LOG_SD_OTAG : "", spec.connstr().c_str(), settings->log_redaction ? LCB_LOG_SD_CTAG : "",
|
|
469
|
+
settings->log_redaction ? LCB_LOG_MD_OTAG : "", settings->bucket, settings->log_redaction ? LCB_LOG_MD_CTAG : "");
|
|
422
470
|
|
|
423
471
|
if (io_priv == NULL) {
|
|
424
472
|
lcb_io_opt_t ops;
|
|
@@ -443,7 +491,7 @@ lcb_error_t lcb_create(lcb_t *instance,
|
|
|
443
491
|
obj->http_sockpool->set_options(pool_opts);
|
|
444
492
|
}
|
|
445
493
|
|
|
446
|
-
obj->confmon = new clconfig::Confmon(settings, obj->iotable);
|
|
494
|
+
obj->confmon = new clconfig::Confmon(settings, obj->iotable, obj);
|
|
447
495
|
obj->ht_nodes = new Hostlist();
|
|
448
496
|
obj->mc_nodes = new Hostlist();
|
|
449
497
|
obj->retryq = new RetryQueue(&obj->cmdq, obj->iotable, obj->settings);
|
|
@@ -470,11 +518,11 @@ lcb_error_t lcb_create(lcb_t *instance,
|
|
|
470
518
|
if ((err = init_providers(obj, spec)) != LCB_SUCCESS) {
|
|
471
519
|
goto GT_DONE;
|
|
472
520
|
}
|
|
473
|
-
|
|
474
|
-
if (
|
|
475
|
-
|
|
476
|
-
return err;
|
|
521
|
+
#ifdef LCB_TRACING
|
|
522
|
+
if (settings->use_tracing) {
|
|
523
|
+
settings->tracer = lcbtrace_new(obj, LCBTRACE_F_THRESHOLD);
|
|
477
524
|
}
|
|
525
|
+
#endif
|
|
478
526
|
|
|
479
527
|
obj->last_error = err;
|
|
480
528
|
GT_DONE:
|
|
@@ -487,6 +535,12 @@ lcb_error_t lcb_create(lcb_t *instance,
|
|
|
487
535
|
return err;
|
|
488
536
|
}
|
|
489
537
|
|
|
538
|
+
LIBCOUCHBASE_API
|
|
539
|
+
int lcb_is_redacting_logs(lcb_t instance)
|
|
540
|
+
{
|
|
541
|
+
return instance && instance->settings && instance->settings->log_redaction;
|
|
542
|
+
}
|
|
543
|
+
|
|
490
544
|
typedef struct {
|
|
491
545
|
lcbio_pTABLE table;
|
|
492
546
|
lcbio_pTIMER timer;
|
|
@@ -586,6 +640,13 @@ void lcb_destroy(lcb_t instance)
|
|
|
586
640
|
instance->scratch = NULL;
|
|
587
641
|
}
|
|
588
642
|
|
|
643
|
+
for (std::map< std::string, lcbcrypto_PROVIDER * >::iterator ii = instance->crypto->begin();
|
|
644
|
+
ii != instance->crypto->end(); ++ii) {
|
|
645
|
+
lcbcrypto_unref(ii->second);
|
|
646
|
+
}
|
|
647
|
+
delete instance->crypto;
|
|
648
|
+
instance->crypto = NULL;
|
|
649
|
+
|
|
589
650
|
delete[] instance->dcpinfo;
|
|
590
651
|
memset(instance, 0xff, sizeof(*instance));
|
|
591
652
|
free(instance);
|
|
@@ -721,13 +782,16 @@ LIBCOUCHBASE_API
|
|
|
721
782
|
int
|
|
722
783
|
lcb_supports_feature(int n)
|
|
723
784
|
{
|
|
724
|
-
if (n ==
|
|
725
|
-
#ifdef
|
|
726
|
-
return 0;
|
|
727
|
-
#else
|
|
785
|
+
if (n == LCB_SUPPORTS_TRACING) {
|
|
786
|
+
#ifdef LCB_TRACING
|
|
728
787
|
return 1;
|
|
788
|
+
#else
|
|
789
|
+
return 0;
|
|
729
790
|
#endif
|
|
730
791
|
}
|
|
792
|
+
if (n == LCB_SUPPORTS_SNAPPY) {
|
|
793
|
+
return 1;
|
|
794
|
+
}
|
|
731
795
|
if (n == LCB_SUPPORTS_SSL) {
|
|
732
796
|
return lcbio_ssl_supported();
|
|
733
797
|
} else {
|
|
@@ -815,6 +879,15 @@ const char *lcb_strerror_short(lcb_error_t error)
|
|
|
815
879
|
return "<FIXME: Not an LCB error>";
|
|
816
880
|
}
|
|
817
881
|
|
|
882
|
+
LCB_INTERNAL_API
|
|
883
|
+
const char *lcb_strerror_long(lcb_error_t error)
|
|
884
|
+
{
|
|
885
|
+
#define X(c, v, t, s) if (error == c) { return #c " (" #v "): " s; }
|
|
886
|
+
LCB_XERR(X)
|
|
887
|
+
#undef X
|
|
888
|
+
return "<FIXME: Not an LCB error>";
|
|
889
|
+
}
|
|
890
|
+
|
|
818
891
|
LIBCOUCHBASE_API
|
|
819
892
|
int lcb_get_errtype(lcb_error_t err)
|
|
820
893
|
{
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
#include <libcouchbase/vbucket.h>
|
|
35
35
|
#include <libcouchbase/api3.h>
|
|
36
36
|
#include <libcouchbase/pktfwd.h>
|
|
37
|
+
#include <libcouchbase/crypto.h>
|
|
37
38
|
|
|
38
39
|
/* Internal dependencies */
|
|
39
40
|
#include <lcbio/lcbio.h>
|
|
@@ -51,6 +52,8 @@
|
|
|
51
52
|
/* n1ql cache */
|
|
52
53
|
#include "n1ql/n1ql-internal.h"
|
|
53
54
|
|
|
55
|
+
#include "tracing/tracing-internal.h"
|
|
56
|
+
|
|
54
57
|
#include "hostlist.h"
|
|
55
58
|
|
|
56
59
|
#ifdef __cplusplus
|
|
@@ -135,6 +138,8 @@ struct lcb_st {
|
|
|
135
138
|
lcb_BTYPE btype; /**< Type of the bucket */
|
|
136
139
|
|
|
137
140
|
#ifdef __cplusplus
|
|
141
|
+
typedef std::map<std::string, lcbcrypto_PROVIDER *> lcb_ProviderMap;
|
|
142
|
+
lcb_ProviderMap *crypto;
|
|
138
143
|
lcb_settings* getSettings() { return settings; }
|
|
139
144
|
lcbio_pTABLE getIOT() { return iotable; }
|
|
140
145
|
inline void add_bs_host(const char *host, int port, unsigned bstype);
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
#include "settings.h"
|
|
23
23
|
#include "timer-ng.h"
|
|
24
24
|
#include "timer-cxx.h"
|
|
25
|
+
#include "rnd.h"
|
|
25
26
|
#include <errno.h>
|
|
26
27
|
|
|
27
28
|
using namespace lcb::io;
|
|
@@ -32,15 +33,22 @@ using namespace lcb::io;
|
|
|
32
33
|
#endif
|
|
33
34
|
#define LOGARGS(conn, lvl) conn->settings, "connection", LCB_LOG_##lvl, __FILE__, __LINE__
|
|
34
35
|
static const lcb_host_t *get_loghost(lcbio_SOCKET *s) {
|
|
35
|
-
static lcb_host_t host = {
|
|
36
|
+
static lcb_host_t host = {"NOHOST", "NOPORT", 0};
|
|
36
37
|
if (!s) { return &host; }
|
|
37
38
|
if (!s->info) { return &host; }
|
|
38
39
|
return &s->info->ep;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
/** Format string arguments for %p%s:%s */
|
|
42
|
-
#define CSLOGID(sock)
|
|
43
|
-
|
|
43
|
+
#define CSLOGID(sock) \
|
|
44
|
+
sock->settings->log_redaction ? LCB_LOG_SD_OTAG : "", \
|
|
45
|
+
get_loghost(sock)->ipv6 ? "[" : "", \
|
|
46
|
+
get_loghost(sock)->host, \
|
|
47
|
+
get_loghost(sock)->ipv6 ? "]" : "", \
|
|
48
|
+
get_loghost(sock)->port, \
|
|
49
|
+
sock->settings->log_redaction ? LCB_LOG_SD_CTAG : "", \
|
|
50
|
+
sock->id
|
|
51
|
+
#define CSLOGFMT "<" LCB_LOG_SPEC("%s%s%s:%s") "> (SOCK=%016" PRIx64 ") "
|
|
44
52
|
|
|
45
53
|
#define LOGARGS_T(lvl) LOGARGS(this->sock, lvl)
|
|
46
54
|
#define CSLOGID_T() CSLOGID(this->sock)
|
|
@@ -356,7 +364,8 @@ C_conncb(lcb_sockdata_t *sock, int status)
|
|
|
356
364
|
lcbio_SOCKET *s = reinterpret_cast<lcbio_SOCKET*>(sock->lcbconn);
|
|
357
365
|
Connstart *cs = reinterpret_cast<Connstart*>(s->ctx);
|
|
358
366
|
|
|
359
|
-
lcb_log(LOGARGS(s, TRACE), CSLOGFMT "Received completion handler. Status=%d. errno=%d", CSLOGID(s), status,
|
|
367
|
+
lcb_log(LOGARGS(s, TRACE), CSLOGFMT "Received completion handler. Status=%d. errno=%d [%s]", CSLOGID(s), status,
|
|
368
|
+
IOT_ERRNO(s->io), strerror(IOT_ERRNO(s->io)));
|
|
360
369
|
|
|
361
370
|
if (!--s->refcount) {
|
|
362
371
|
lcbio__destroy(s);
|
|
@@ -449,6 +458,7 @@ Connstart::Connstart(lcbio_TABLE* iot_, lcb_settings* settings_,
|
|
|
449
458
|
sock->settings = settings_;
|
|
450
459
|
sock->ctx = this;
|
|
451
460
|
sock->refcount = 1;
|
|
461
|
+
sock->id = lcb_next_rand64();
|
|
452
462
|
sock->info = reinterpret_cast<lcbio_CONNINFO*>(calloc(1, sizeof(*sock->info)));
|
|
453
463
|
sock->info->ep = *dest;
|
|
454
464
|
lcbio_table_ref(sock->io);
|
|
@@ -529,6 +539,7 @@ lcbio_wrap_fd(lcbio_pTABLE iot, lcb_settings *settings, lcb_socket_t fd)
|
|
|
529
539
|
ret->io = iot;
|
|
530
540
|
ret->refcount = 1;
|
|
531
541
|
ret->u.fd = fd;
|
|
542
|
+
ret->id = lcb_next_rand64();
|
|
532
543
|
|
|
533
544
|
lcbio_table_ref(ret->io);
|
|
534
545
|
lcb_settings_ref(ret->settings);
|
|
@@ -566,3 +577,27 @@ lcbio__destroy(lcbio_SOCKET *s)
|
|
|
566
577
|
lcb_settings_unref(s->settings);
|
|
567
578
|
free(s);
|
|
568
579
|
}
|
|
580
|
+
|
|
581
|
+
const char * lcbio_svcstr(lcbio_SERVICE service)
|
|
582
|
+
{
|
|
583
|
+
switch (service) {
|
|
584
|
+
case LCBIO_SERVICE_CFG:
|
|
585
|
+
return "config";
|
|
586
|
+
case LCBIO_SERVICE_KV:
|
|
587
|
+
return "kv";
|
|
588
|
+
case LCBIO_SERVICE_MGMT:
|
|
589
|
+
return "mgmt";
|
|
590
|
+
case LCBIO_SERVICE_VIEW:
|
|
591
|
+
return "view";
|
|
592
|
+
case LCBIO_SERVICE_N1QL:
|
|
593
|
+
return "n1ql";
|
|
594
|
+
case LCBIO_SERVICE_FTS:
|
|
595
|
+
return "fts";
|
|
596
|
+
case LCBIO_SERVICE_CBAS:
|
|
597
|
+
return "cbas";
|
|
598
|
+
case LCBIO_SERVICE_UNSPEC:
|
|
599
|
+
/* fallthrough */
|
|
600
|
+
default:
|
|
601
|
+
return "unspec";
|
|
602
|
+
}
|
|
603
|
+
}
|
|
@@ -75,12 +75,29 @@ typedef struct {
|
|
|
75
75
|
lcb_host_t ep;
|
|
76
76
|
} lcbio_CONNINFO;
|
|
77
77
|
|
|
78
|
+
struct lcb_IOMETRICS_st;
|
|
79
|
+
|
|
80
|
+
/** @brief Subsystem, which utilizes the socket */
|
|
81
|
+
typedef enum {
|
|
82
|
+
LCBIO_SERVICE_UNSPEC = 0,
|
|
83
|
+
LCBIO_SERVICE_CFG,
|
|
84
|
+
LCBIO_SERVICE_KV,
|
|
85
|
+
LCBIO_SERVICE_MGMT,
|
|
86
|
+
LCBIO_SERVICE_VIEW,
|
|
87
|
+
LCBIO_SERVICE_N1QL,
|
|
88
|
+
LCBIO_SERVICE_FTS,
|
|
89
|
+
LCBIO_SERVICE_CBAS,
|
|
90
|
+
LCBIO_SERVICE_MAX
|
|
91
|
+
} lcbio_SERVICE;
|
|
92
|
+
|
|
93
|
+
const char * lcbio_svcstr(lcbio_SERVICE service);
|
|
78
94
|
|
|
79
95
|
/** @brief Core socket structure */
|
|
80
96
|
typedef struct lcbio_SOCKET {
|
|
81
97
|
lcbio_pTABLE io;
|
|
82
98
|
lcb_settings *settings;
|
|
83
99
|
void *ctx;
|
|
100
|
+
struct lcb_IOMETRICS_st *metrics;
|
|
84
101
|
lcbio_CONNINFO *info;
|
|
85
102
|
lcbio_OSERR last_error; /**< last OS error */
|
|
86
103
|
unsigned refcount; /**< refcount on socket */
|
|
@@ -89,6 +106,9 @@ typedef struct lcbio_SOCKET {
|
|
|
89
106
|
lcb_socket_t fd;
|
|
90
107
|
} u;
|
|
91
108
|
lcb_list_t protos;
|
|
109
|
+
hrtime_t atime;
|
|
110
|
+
lcbio_SERVICE service;
|
|
111
|
+
lcb_U64 id;
|
|
92
112
|
} lcbio_SOCKET;
|
|
93
113
|
|
|
94
114
|
|
|
@@ -345,6 +365,13 @@ lcbio_table_unref(lcbio_pTABLE iot);
|
|
|
345
365
|
void
|
|
346
366
|
lcbio_table_ref(lcbio_pTABLE iot);
|
|
347
367
|
|
|
368
|
+
/**
|
|
369
|
+
* Set the metrics object for the socket. Various operations will then log
|
|
370
|
+
* the number of bytes written/received on the socket.
|
|
371
|
+
*/
|
|
372
|
+
#define \
|
|
373
|
+
lcbio_set_metrics(sock, m) (sock)->metrics = m
|
|
374
|
+
|
|
348
375
|
/** @}*/
|
|
349
376
|
|
|
350
377
|
/** @name IO Status Codes
|