libcouchbase 1.2.8 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -4
  3. data/README.md +16 -8
  4. data/ext/libcouchbase/CMakeLists.txt +34 -32
  5. data/ext/libcouchbase/RELEASE_NOTES.markdown +277 -6
  6. data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +14 -0
  7. data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibevent.cmake +2 -0
  8. data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibuv.cmake +2 -1
  9. data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +2 -0
  10. data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +8 -1
  11. data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
  12. data/ext/libcouchbase/cmake/config-cmake.h.in +14 -0
  13. data/ext/libcouchbase/cmake/configure +8 -26
  14. data/ext/libcouchbase/cmake/defs.mk.in +2 -2
  15. data/ext/libcouchbase/cmake/libcouchbase.stp.in +829 -0
  16. data/ext/libcouchbase/cmake/source_files.cmake +11 -2
  17. data/ext/libcouchbase/contrib/cbsasl/CMakeLists.txt +18 -2
  18. data/ext/libcouchbase/contrib/cbsasl/include/cbsasl/cbsasl.h +44 -2
  19. data/ext/libcouchbase/contrib/cbsasl/src/client.c +285 -73
  20. data/ext/libcouchbase/contrib/cbsasl/src/common.c +4 -0
  21. data/ext/libcouchbase/contrib/cbsasl/src/scram-sha/scram_utils.c +500 -0
  22. data/ext/libcouchbase/contrib/cbsasl/src/scram-sha/scram_utils.h +99 -0
  23. data/ext/libcouchbase/contrib/cliopts/CMakeLists.txt +1 -1
  24. data/ext/libcouchbase/contrib/cliopts/cliopts.h +14 -1
  25. data/ext/libcouchbase/contrib/snappy/CMakeLists.txt +2 -3
  26. data/ext/libcouchbase/contrib/snappy/snappy-sinksource.cc +4 -0
  27. data/ext/libcouchbase/contrib/snappy/snappy-stubs-public.h +7 -5
  28. data/ext/libcouchbase/contrib/snappy/snappy.cc +7 -2
  29. data/ext/libcouchbase/example/crypto/.gitignore +2 -0
  30. data/ext/libcouchbase/example/crypto/Makefile +13 -0
  31. data/ext/libcouchbase/example/crypto/common_provider.c +24 -0
  32. data/ext/libcouchbase/example/crypto/common_provider.h +31 -0
  33. data/ext/libcouchbase/example/crypto/openssl_symmetric_decrypt.c +139 -0
  34. data/ext/libcouchbase/example/crypto/openssl_symmetric_encrypt.c +147 -0
  35. data/ext/libcouchbase/example/crypto/openssl_symmetric_provider.c +281 -0
  36. data/ext/libcouchbase/example/crypto/openssl_symmetric_provider.h +29 -0
  37. data/ext/libcouchbase/example/tracing/.gitignore +2 -0
  38. data/ext/libcouchbase/example/tracing/Makefile +8 -0
  39. data/ext/libcouchbase/example/tracing/cJSON.c +1 -0
  40. data/ext/libcouchbase/example/tracing/cJSON.h +1 -0
  41. data/ext/libcouchbase/example/tracing/tracing.c +439 -0
  42. data/ext/libcouchbase/example/tracing/views.c +444 -0
  43. data/ext/libcouchbase/include/libcouchbase/auth.h +56 -4
  44. data/ext/libcouchbase/include/libcouchbase/cbft.h +8 -0
  45. data/ext/libcouchbase/include/libcouchbase/cntl-private.h +55 -1
  46. data/ext/libcouchbase/include/libcouchbase/cntl.h +101 -1
  47. data/ext/libcouchbase/include/libcouchbase/configuration.h.in +6 -0
  48. data/ext/libcouchbase/include/libcouchbase/couchbase.h +109 -6
  49. data/ext/libcouchbase/include/libcouchbase/crypto.h +140 -0
  50. data/ext/libcouchbase/include/libcouchbase/error.h +38 -2
  51. data/ext/libcouchbase/include/libcouchbase/kvbuf.h +6 -1
  52. data/ext/libcouchbase/include/libcouchbase/metrics.h +79 -0
  53. data/ext/libcouchbase/include/libcouchbase/n1ql.h +9 -0
  54. data/ext/libcouchbase/include/libcouchbase/tracing.h +319 -0
  55. data/ext/libcouchbase/include/libcouchbase/vbucket.h +1 -1
  56. data/ext/libcouchbase/include/libcouchbase/views.h +8 -0
  57. data/ext/libcouchbase/include/memcached/protocol_binary.h +40 -10
  58. data/ext/libcouchbase/packaging/rpm/libcouchbase.spec.in +6 -14
  59. data/ext/libcouchbase/plugins/io/libuv/plugin-internal.h +3 -0
  60. data/ext/libcouchbase/plugins/io/libuv/plugin-libuv.c +1 -0
  61. data/ext/libcouchbase/plugins/io/select/plugin-select.c +4 -1
  62. data/ext/libcouchbase/src/auth-priv.h +36 -4
  63. data/ext/libcouchbase/src/auth.cc +66 -27
  64. data/ext/libcouchbase/src/bootstrap.cc +1 -1
  65. data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +12 -7
  66. data/ext/libcouchbase/src/bucketconfig/bc_http.cc +26 -17
  67. data/ext/libcouchbase/src/bucketconfig/bc_http.h +1 -1
  68. data/ext/libcouchbase/src/bucketconfig/clconfig.h +4 -2
  69. data/ext/libcouchbase/src/bucketconfig/confmon.cc +6 -3
  70. data/ext/libcouchbase/src/cbft.cc +48 -0
  71. data/ext/libcouchbase/src/cntl.cc +138 -2
  72. data/ext/libcouchbase/src/config_static.h +17 -0
  73. data/ext/libcouchbase/src/connspec.cc +54 -6
  74. data/ext/libcouchbase/src/connspec.h +9 -1
  75. data/ext/libcouchbase/src/crypto.cc +386 -0
  76. data/ext/libcouchbase/src/ctx-log-inl.h +23 -6
  77. data/ext/libcouchbase/src/dump.cc +4 -0
  78. data/ext/libcouchbase/src/getconfig.cc +1 -2
  79. data/ext/libcouchbase/src/handler.cc +65 -27
  80. data/ext/libcouchbase/src/hostlist.cc +35 -7
  81. data/ext/libcouchbase/src/hostlist.h +7 -0
  82. data/ext/libcouchbase/src/http/http-priv.h +2 -0
  83. data/ext/libcouchbase/src/http/http.cc +77 -37
  84. data/ext/libcouchbase/src/http/http_io.cc +19 -2
  85. data/ext/libcouchbase/src/instance.cc +90 -17
  86. data/ext/libcouchbase/src/internal.h +5 -0
  87. data/ext/libcouchbase/src/lcbio/connect.cc +39 -4
  88. data/ext/libcouchbase/src/lcbio/connect.h +27 -0
  89. data/ext/libcouchbase/src/lcbio/ctx.c +49 -23
  90. data/ext/libcouchbase/src/lcbio/ioutils.cc +30 -3
  91. data/ext/libcouchbase/src/lcbio/ioutils.h +2 -0
  92. data/ext/libcouchbase/src/lcbio/manager.cc +44 -8
  93. data/ext/libcouchbase/src/lcbio/manager.h +2 -0
  94. data/ext/libcouchbase/src/lcbio/rw-inl.h +1 -0
  95. data/ext/libcouchbase/src/lcbio/ssl.h +3 -5
  96. data/ext/libcouchbase/src/logging.c +1 -1
  97. data/ext/libcouchbase/src/logging.h +2 -0
  98. data/ext/libcouchbase/src/mc/compress.cc +164 -0
  99. data/ext/libcouchbase/src/mc/compress.h +7 -12
  100. data/ext/libcouchbase/src/mc/mcreq-flush-inl.h +5 -1
  101. data/ext/libcouchbase/src/mc/mcreq.c +11 -1
  102. data/ext/libcouchbase/src/mc/mcreq.h +35 -4
  103. data/ext/libcouchbase/src/mcserver/mcserver.cc +30 -7
  104. data/ext/libcouchbase/src/mcserver/mcserver.h +7 -0
  105. data/ext/libcouchbase/src/mcserver/negotiate.cc +103 -57
  106. data/ext/libcouchbase/src/mcserver/negotiate.h +2 -2
  107. data/ext/libcouchbase/src/mctx-helper.h +11 -0
  108. data/ext/libcouchbase/src/metrics.cc +132 -0
  109. data/ext/libcouchbase/src/n1ql/ixmgmt.cc +2 -1
  110. data/ext/libcouchbase/src/n1ql/n1ql.cc +66 -0
  111. data/ext/libcouchbase/src/newconfig.cc +9 -2
  112. data/ext/libcouchbase/src/operations/counter.cc +2 -1
  113. data/ext/libcouchbase/src/operations/durability-cas.cc +11 -0
  114. data/ext/libcouchbase/src/operations/durability-seqno.cc +3 -0
  115. data/ext/libcouchbase/src/operations/durability.cc +24 -2
  116. data/ext/libcouchbase/src/operations/durability_internal.h +19 -0
  117. data/ext/libcouchbase/src/operations/get.cc +4 -2
  118. data/ext/libcouchbase/src/operations/observe-seqno.cc +1 -0
  119. data/ext/libcouchbase/src/operations/observe.cc +113 -62
  120. data/ext/libcouchbase/src/operations/ping.cc +246 -67
  121. data/ext/libcouchbase/src/operations/remove.cc +2 -1
  122. data/ext/libcouchbase/src/operations/store.cc +17 -14
  123. data/ext/libcouchbase/src/operations/touch.cc +3 -0
  124. data/ext/libcouchbase/src/packetutils.h +68 -4
  125. data/ext/libcouchbase/src/probes.d +132 -161
  126. data/ext/libcouchbase/src/rdb/bigalloc.c +1 -1
  127. data/ext/libcouchbase/src/retryq.cc +6 -2
  128. data/ext/libcouchbase/src/rnd.cc +68 -0
  129. data/ext/libcouchbase/src/rnd.h +39 -0
  130. data/ext/libcouchbase/src/settings.c +27 -0
  131. data/ext/libcouchbase/src/settings.h +67 -3
  132. data/ext/libcouchbase/src/ssl/CMakeLists.txt +0 -12
  133. data/ext/libcouchbase/src/ssl/ssl_common.c +23 -4
  134. data/ext/libcouchbase/src/strcodecs/base64.c +141 -16
  135. data/ext/libcouchbase/src/strcodecs/strcodecs.h +16 -1
  136. data/ext/libcouchbase/src/trace.h +68 -61
  137. data/ext/libcouchbase/src/tracing/span.cc +289 -0
  138. data/ext/libcouchbase/src/tracing/threshold_logging_tracer.cc +171 -0
  139. data/ext/libcouchbase/src/tracing/tracer.cc +53 -0
  140. data/ext/libcouchbase/src/tracing/tracing-internal.h +213 -0
  141. data/ext/libcouchbase/src/utilities.c +5 -0
  142. data/ext/libcouchbase/src/vbucket/CMakeLists.txt +2 -2
  143. data/ext/libcouchbase/src/vbucket/vbucket.c +50 -18
  144. data/ext/libcouchbase/src/views/docreq.cc +26 -1
  145. data/ext/libcouchbase/src/views/docreq.h +17 -0
  146. data/ext/libcouchbase/src/views/viewreq.cc +64 -1
  147. data/ext/libcouchbase/src/views/viewreq.h +21 -0
  148. data/ext/libcouchbase/tests/CMakeLists.txt +6 -6
  149. data/ext/libcouchbase/tests/basic/t_base64.cc +34 -6
  150. data/ext/libcouchbase/tests/basic/t_connstr.cc +14 -0
  151. data/ext/libcouchbase/tests/basic/t_creds.cc +10 -10
  152. data/ext/libcouchbase/tests/basic/t_host.cc +22 -2
  153. data/ext/libcouchbase/tests/basic/t_scram.cc +514 -0
  154. data/ext/libcouchbase/tests/check-all.cc +6 -2
  155. data/ext/libcouchbase/tests/iotests/mock-environment.cc +64 -0
  156. data/ext/libcouchbase/tests/iotests/mock-environment.h +27 -1
  157. data/ext/libcouchbase/tests/iotests/t_confmon.cc +2 -2
  158. data/ext/libcouchbase/tests/iotests/t_forward.cc +8 -0
  159. data/ext/libcouchbase/tests/iotests/t_netfail.cc +124 -0
  160. data/ext/libcouchbase/tests/iotests/t_smoke.cc +1 -1
  161. data/ext/libcouchbase/tests/iotests/t_snappy.cc +316 -0
  162. data/ext/libcouchbase/tests/socktests/socktest.cc +2 -2
  163. data/ext/libcouchbase/tests/socktests/t_basic.cc +6 -6
  164. data/ext/libcouchbase/tests/socktests/t_manager.cc +1 -1
  165. data/ext/libcouchbase/tests/socktests/t_ssl.cc +1 -1
  166. data/ext/libcouchbase/tools/CMakeLists.txt +1 -1
  167. data/ext/libcouchbase/tools/cbc-handlers.h +17 -0
  168. data/ext/libcouchbase/tools/cbc-n1qlback.cc +7 -4
  169. data/ext/libcouchbase/tools/cbc-pillowfight.cc +408 -100
  170. data/ext/libcouchbase/tools/cbc-proxy.cc +134 -3
  171. data/ext/libcouchbase/tools/cbc-subdoc.cc +1 -2
  172. data/ext/libcouchbase/tools/cbc.cc +113 -8
  173. data/ext/libcouchbase/tools/common/histogram.cc +1 -0
  174. data/ext/libcouchbase/tools/common/options.cc +28 -1
  175. data/ext/libcouchbase/tools/common/options.h +5 -0
  176. data/ext/libcouchbase/tools/docgen/docgen.h +36 -10
  177. data/ext/libcouchbase/tools/docgen/loc.h +5 -4
  178. data/ext/libcouchbase/tools/docgen/seqgen.h +28 -0
  179. data/lib/libcouchbase/ext/libcouchbase/enums.rb +10 -0
  180. data/lib/libcouchbase/n1ql.rb +6 -1
  181. data/lib/libcouchbase/version.rb +1 -1
  182. data/spec/connection_spec.rb +6 -6
  183. metadata +38 -5
  184. data/ext/libcouchbase/cmake/Modules/FindCouchbaseSnappy.cmake +0 -11
  185. data/ext/libcouchbase/src/mc/compress.c +0 -90
  186. data/ext/libcouchbase/tools/common/my_inttypes.h +0 -22
@@ -100,6 +100,14 @@ LIBCOUCHBASE_API
100
100
  void
101
101
  lcb_fts_cancel(lcb_t, lcb_FTSHANDLE);
102
102
 
103
+ #ifdef LCB_TRACING
104
+ /**
105
+ * @uncommitted
106
+ */
107
+ LIBCOUCHBASE_API
108
+ void lcb_fts_set_parent_span(lcb_t instance, lcb_FTSHANDLE handle, lcbtrace_SPAN *span);
109
+ #endif
110
+
103
111
  /**
104
112
  * @}
105
113
  */
@@ -181,7 +181,7 @@ struct lcb_cntl_iops_info_st {
181
181
  * Similar to @ref LCB_CNTL_CONFIG_HTTP_NODES, but affects the CCCP provider
182
182
  * instead. Ports should specify the _memcached_ port
183
183
  * @cntl_arg_setonly{char** (Array of strings)}
184
- * @uncomitted
184
+ * @uncommitted
185
185
  */
186
186
  #define LCB_CNTL_CONFIG_CCCP_NODES 0x1E
187
187
 
@@ -351,4 +351,58 @@ typedef enum {
351
351
  */
352
352
  #define LCB_CNTL_KVTIMINGS 0x3C
353
353
 
354
+ /**
355
+ * @volatile
356
+ * Activate/Get library metrics per-server
357
+ *
358
+ * If using @ref LCB_CNTL_SET, then this will activate the metrics, and should
359
+ * be called immediately after lcb_create. The `arg` parameter should be a pointer
360
+ * to an integer with the activation value (any non-zero value to activate).
361
+ *
362
+ * If using @ref LCB_CNTL_GET, the `arg` parameter should be a @ref `lcb_METRICS**`
363
+ * variable, which will contain the pointer to the metrics upon completion.
364
+ */
365
+ #define LCB_CNTL_METRICS 0x49
366
+
367
+ /**
368
+ *
369
+ * @cntl_arg_both{int (as boolean)}
370
+ * @volatile
371
+ */
372
+ #define LCB_CNTL_USE_COLLECTIONS 0x4a
373
+
374
+ /**
375
+ * Activate end-to-end tracing.
376
+ *
377
+ * Use `enable_tracing` in the connection string
378
+ *
379
+ * @cntl_arg_both{int* (as boolean)}
380
+ * @uncommitted
381
+ */
382
+ #define LCB_CNTL_ENABLE_TRACING 0x4e
383
+
384
+ #define LCB_CNTL_TRACING_ORPHANED_QUEUE_FLUSH_INTERVAL 0x4f
385
+ #define LCB_CNTL_TRACING_ORPHANED_QUEUE_SIZE 0x50
386
+ #define LCB_CNTL_TRACING_THRESHOLD_QUEUE_FLUSH_INTERVAL 0x51
387
+ #define LCB_CNTL_TRACING_THRESHOLD_QUEUE_SIZE 0x52
388
+ #define LCB_CNTL_TRACING_THRESHOLD_KV 0x53
389
+ #define LCB_CNTL_TRACING_THRESHOLD_N1QL 0x54
390
+ #define LCB_CNTL_TRACING_THRESHOLD_VIEW 0x55
391
+ #define LCB_CNTL_TRACING_THRESHOLD_FTS 0x56
392
+ #define LCB_CNTL_TRACING_THRESHOLD_ANALYTICS 0x57
393
+
394
+ #define LCB_CNTL_COMPRESSION_MIN_SIZE 0x58
395
+ #define LCB_CNTL_COMPRESSION_MIN_RATIO 0x59
396
+
397
+ /**
398
+ * Do not use fast-forward map from cluster configuration.
399
+ *
400
+ * Use `vb_noremap` in the connection string
401
+ *
402
+ * @cntl_arg_both{int* (as boolean)}
403
+ * @uncommitted
404
+ */
405
+ #define LCB_CNTL_VB_NOREMAP 0x5a
406
+
407
+
354
408
  /**@}*/
@@ -425,6 +425,60 @@ typedef struct lcb_logprocs_st {
425
425
  *
426
426
  * @cntl_arg_get_and_set{lcb_logprocs**,lcb_logprocs*}*/
427
427
  #define LCB_CNTL_LOGGER 0x18
428
+
429
+ /**
430
+ * Helper to express printf spec for sensitive data. Usage:
431
+ *
432
+ * printf("Logged as " LCB_LOG_SPEC("%s") " user", LCB_LOG_UD(instance, doc->username));
433
+ */
434
+ #define LCB_LOG_SPEC(fmt) "%s" fmt "%s"
435
+
436
+ #define LCB_LOG_UD_OTAG "<ud>"
437
+ #define LCB_LOG_UD_CTAG "</ud>"
438
+ /**
439
+ * User data is data that is stored into Couchbase by the application user account.
440
+ *
441
+ * - Key and value pairs in JSON documents, or the key exclusively
442
+ * - Application/Admin usernames that identify the human person
443
+ * - Names and email addresses asked during product registration and alerting
444
+ * - Usernames
445
+ * - Document xattrs
446
+ * - Query statements included in the log file collected by support that leak
447
+ * the document fields (Select floor_price from stock).
448
+ */
449
+ #define LCB_LOG_UD(instance, val) \
450
+ lcb_is_redacting_logs(instance) ? LCB_LOG_UD_OTAG : "", val, lcb_is_redacting_logs(instance) ? LCB_LOG_UD_CTAG : ""
451
+
452
+ #define LCB_LOG_MD_OTAG "<md>"
453
+ #define LCB_LOG_MD_CTAG "</md>"
454
+ /**
455
+ * Metadata is logical data needed by Couchbase to store and process user data.
456
+ *
457
+ * - Cluster name
458
+ * - Bucket names
459
+ * - DDoc/view names
460
+ * - View code
461
+ * - Index names
462
+ * - Mapreduce Design Doc Name and Definition (IP)
463
+ * - XDCR Replication Stream Names
464
+ * - And other couchbase resource specific meta data
465
+ */
466
+ #define LCB_LOG_MD(instance, val) \
467
+ lcb_is_redacting_logs(instance) ? LCB_LOG_MD_OTAG : "", val, lcb_is_redacting_logs(instance) ? LCB_LOG_MD_CTAG : ""
468
+
469
+ #define LCB_LOG_SD_OTAG "<sd>"
470
+ #define LCB_LOG_SD_CTAG "</sd>"
471
+ /**
472
+ * System data is data from other parts of the system Couchbase interacts with over the network.
473
+ *
474
+ * - IP addresses
475
+ * - IP tables
476
+ * - Hosts names
477
+ * - Ports
478
+ * - DNS topology
479
+ */
480
+ #define LCB_LOG_SD(instance, val) \
481
+ lcb_is_redacting_logs(instance) ? LCB_LOG_SD_OTAG : "", val, lcb_is_redacting_logs(instance) ? LCB_LOG_SD_CTAG : ""
428
482
  /**@}*/
429
483
 
430
484
 
@@ -559,6 +613,31 @@ typedef enum {
559
613
  * @see LCB_CNTL_SSL_MODE
560
614
  */
561
615
  #define LCB_CNTL_SSL_CERT 0x23
616
+
617
+ /**
618
+ * @brief Get SSL private key path
619
+ *
620
+ * Retrieve the path to the private key (if any) being used.
621
+ * When key specified, the library will use it to authenticate on the services,
622
+ * skipping all other authentication mechanisms (SASL, HTTP Basic auth, etc)
623
+ *
624
+ * @cntl_arg_getonly{`char**`}
625
+ * @see LCB_CNTL_SSL_MODE
626
+ * @see https://developer.couchbase.com/documentation/server/5.0/security/security-certs-auth.html
627
+ */
628
+ #define LCB_CNTL_SSL_KEY 0x4b
629
+
630
+ /**
631
+ * @brief Get SSL trust store path
632
+ *
633
+ * Trust store might be NULL, in this case the library expects it to be concatenated with certificate.
634
+ *
635
+ * @cntl_arg_getonly{`char**`}
636
+ * @see LCB_CNTL_SSL_MODE
637
+ * @see https://developer.couchbase.com/documentation/server/5.0/security/security-certs-auth.html
638
+ */
639
+ #define LCB_CNTL_SSL_TRUSTSTORE 0x4d
640
+
562
641
  /**
563
642
  * Alias for @ref LCB_CNTL_SSL_CERT for backward compatibility.
564
643
  * @deprecated
@@ -1022,11 +1101,32 @@ typedef const char *lcb_BUCKETCRED[2];
1022
1101
  */
1023
1102
  #define LCB_CNTL_SEND_HELLO 0x47
1024
1103
 
1104
+ /**
1105
+ * Once redaction is enabled, anything at ERROR, WARN and INFO will wrap
1106
+ * sensitive information with special tags, for further processing with the goal
1107
+ * to remove or encrypt that information. DEBUG or TRACE level logging are
1108
+ * expected to have specific info.
1109
+ *
1110
+ * Use `log_redaction` in the connection string
1111
+
1112
+ * @cntl_arg_both{int* (as boolean)}
1113
+ */
1114
+ #define LCB_CNTL_LOG_REDACTION 0x4c
1115
+
1116
+ typedef enum {
1117
+ LCBTRACE_THRESHOLD_KV = 0,
1118
+ LCBTRACE_THRESHOLD_N1QL,
1119
+ LCBTRACE_THRESHOLD_VIEW,
1120
+ LCBTRACE_THRESHOLD_FTS,
1121
+ LCBTRACE_THRESHOLD_ANALYTICS,
1122
+ LCBTRACE_THRESHOLD__MAX
1123
+ } lcbtrace_THRESHOLDOPTS;
1124
+
1025
1125
  /**
1026
1126
  * This is not a command, but rather an indicator of the last item.
1027
1127
  * @internal
1028
1128
  */
1029
- #define LCB_CNTL__MAX 0x49
1129
+ #define LCB_CNTL__MAX 0x5b
1030
1130
  /**@}*/
1031
1131
 
1032
1132
  #ifdef __cplusplus
@@ -20,4 +20,10 @@
20
20
  #define LCB_VERSION_STRING "@LCB_VERSION@"
21
21
  #define LCB_VERSION @LCB_VERSION_HEX@
22
22
  #define LCB_VERSION_CHANGESET "@LCB_VERSION_CHANGESET@"
23
+
24
+ /*
25
+ * NOTE:
26
+ * This symbol might be removed in future releases once tracing will reach GA status.
27
+ */
28
+ #cmakedefine LCB_TRACING
23
29
  #endif
@@ -55,6 +55,7 @@ typedef struct lcb_http_request_st *lcb_http_request_t;
55
55
  #include <libcouchbase/configuration.h>
56
56
  #include <libcouchbase/kvbuf.h>
57
57
  #include <libcouchbase/auth.h>
58
+ #include <libcouchbase/tracing.h>
58
59
  #include <libcouchbase/_cxxwrap.h>
59
60
 
60
61
  #ifdef __cplusplus
@@ -170,10 +171,22 @@ typedef lcb_U32 lcb_USECS;
170
171
  * over the memcached port (For clusters 2.5 and above), or `all` to try with
171
172
  * _cccp_ and revert to _http_
172
173
  *
174
+ * * `truststorepath` - Specify the path (on the local filesystem) to the server's
175
+ * SSL certificate truststore. Only applicable if SSL is being used (i.e. the
176
+ * scheme is `couchbases`). The trust store is optional, and when missing,
177
+ * the library will use `certpath` as location for verification, and expect
178
+ * any extra certificates to be concatenated in there.
179
+ *
173
180
  * * `certpath` - Specify the path (on the local filesystem) to the server's
174
181
  * SSL certificate. Only applicable if SSL is being used (i.e. the scheme is
175
182
  * `couchbases`)
176
183
  *
184
+ * * `keypath` - Specify the path (on the local filesystem) to the client
185
+ * SSL private key. Only applicable if SSL client certificate authentication
186
+ * is being used (i.e. the scheme is `couchbases` and `certpath` contains
187
+ * client certificate). Read more in the server documentation:
188
+ * https://developer.couchbase.com/documentation/server/5.0/security/security-certs-auth.html
189
+ *
177
190
  * ### Bucket Identification and Credentials
178
191
  *
179
192
  * The most common settings you will wish to modify are the bucket name
@@ -692,6 +705,7 @@ typedef enum {
692
705
  LCB_CALLBACK_SDMUTATE,
693
706
  LCB_CALLBACK_NOOP, /**< lcb_noop3() */
694
707
  LCB_CALLBACK_PING, /**< lcb_ping3() */
708
+ LCB_CALLBACK_DIAG, /**< lcb_diag() */
695
709
  LCB_CALLBACK__MAX /* Number of callbacks */
696
710
  } lcb_CALLBACKTYPE;
697
711
 
@@ -1329,6 +1343,16 @@ typedef struct lcb_MULTICMD_CTX_st {
1329
1343
  * @param ctx
1330
1344
  */
1331
1345
  void (*fail)(struct lcb_MULTICMD_CTX_st *ctx);
1346
+
1347
+ #ifdef LCB_TRACING
1348
+ /**
1349
+ * Associate parent tracing span with the group operation
1350
+ *
1351
+ * @param ctx The multi context
1352
+ * @param span Parent span
1353
+ */
1354
+ void (*setspan)(struct lcb_MULTICMD_CTX_st *ctx, lcbtrace_SPAN *span);
1355
+ #endif
1332
1356
  } lcb_MULTICMD_CTX;
1333
1357
  /**@}*/
1334
1358
 
@@ -2323,7 +2347,7 @@ typedef lcb_CMDBASE lcb_CMDCBFLUSH;
2323
2347
  typedef lcb_RESPBASE lcb_RESPCBFLUSH;
2324
2348
 
2325
2349
  /**
2326
- * @uncomitted
2350
+ * @uncommitted
2327
2351
  *
2328
2352
  * Flush a bucket
2329
2353
  * This function will properly flush any type of bucket using the REST API
@@ -2449,6 +2473,7 @@ typedef struct {
2449
2473
  LCB_CMD_BASE;
2450
2474
  int services; /**< bitmap for services to ping */
2451
2475
  int options; /**< extra options, e.g. for result representation */
2476
+ const char *id; /**< optional, zero-terminated string to identify the report */
2452
2477
  } lcb_CMDPING;
2453
2478
 
2454
2479
  /**
@@ -2464,6 +2489,18 @@ typedef enum {
2464
2489
  LCB_PINGSVC__MAX
2465
2490
  } lcb_PINGSVCTYPE;
2466
2491
 
2492
+ /**
2493
+ * Status of the service
2494
+ *
2495
+ * @uncommitted
2496
+ */
2497
+ typedef enum {
2498
+ LCB_PINGSTATUS_OK = 0,
2499
+ LCB_PINGSTATUS_TIMEOUT,
2500
+ LCB_PINGSTATUS_ERROR,
2501
+ LCB_PINGSTATUS__MAX
2502
+ } lcb_PINGSTATUS;
2503
+
2467
2504
  /**
2468
2505
  * Entry describing the status of the service in the cluster.
2469
2506
  * It is part of lcb_RESPING structure.
@@ -2472,9 +2509,14 @@ typedef enum {
2472
2509
  */
2473
2510
  typedef struct {
2474
2511
  lcb_PINGSVCTYPE type; /**< type of the service */
2475
- char *server; /**< server host:port */
2512
+ /* TODO: rename to "remote" */
2513
+ const char *server; /**< server host:port */
2476
2514
  lcb_U64 latency; /**< latency in nanoseconds */
2477
- lcb_error_t status; /**< status of the operation */
2515
+ lcb_error_t rc; /**< raw return code of the operation */
2516
+ const char *local; /**< server host:port */
2517
+ const char *id; /**< service identifier (unique in scope of lcb_t connection instance) */
2518
+ const char *scope; /**< optional scope name (typically equals to the bucket name) */
2519
+ lcb_PINGSTATUS status; /**< status of the operation */
2478
2520
  } lcb_PINGSVC;
2479
2521
 
2480
2522
  /**
@@ -2532,6 +2574,54 @@ typedef struct {
2532
2574
  LIBCOUCHBASE_API
2533
2575
  lcb_error_t
2534
2576
  lcb_ping3(lcb_t instance, const void *cookie, const lcb_CMDPING *cmd);
2577
+
2578
+ typedef struct {
2579
+ LCB_CMD_BASE;
2580
+ int options; /**< extra options, e.g. for result representation */
2581
+ const char *id; /**< optional, zero-terminated string to identify the report */
2582
+ } lcb_CMDDIAG;
2583
+
2584
+ typedef struct {
2585
+ LCB_RESP_BASE
2586
+ lcb_SIZE njson; /**< length of JSON string (when #LCB_PINGOPT_F_JSON was specified) */
2587
+ const char *json; /**< pointer to JSON string */
2588
+ } lcb_RESPDIAG;
2589
+
2590
+ /**
2591
+ * @brief Returns diagnostics report about network connections.
2592
+ *
2593
+ * @uncommitted
2594
+ *
2595
+ * @par Request
2596
+ * @code{.c}
2597
+ * lcb_CMDDIAG cmd = { 0 };
2598
+ * lcb_diag(instance, fp, &cmd);
2599
+ * lcb_wait(instance);
2600
+ * @endcode
2601
+ *
2602
+ * @par Response
2603
+ * @code{.c}
2604
+ * lcb_install_callback3(instance, LCB_CALLBACK_DIAG, diag_callback);
2605
+ * void diag_callback(lcb_t, int, const lcb_RESPBASE *rb)
2606
+ * {
2607
+ * const lcb_RESPDIAG *resp = (const lcb_RESPDIAG *)rb;
2608
+ * if (resp->rc != LCB_SUCCESS) {
2609
+ * fprintf(stderr, "failed: %s\n", lcb_strerror(NULL, resp->rc));
2610
+ * } else {
2611
+ * if (resp->njson) {
2612
+ * fprintf(stderr, "\n%.*s", (int)resp->njson, resp->json);
2613
+ * }
2614
+ * }
2615
+ * }
2616
+ * @endcode
2617
+ *
2618
+ * @param instance the library handle
2619
+ * @param cookie the cookie passed in the callback
2620
+ * @param cmd command structure.
2621
+ * @return status code for scheduling.
2622
+ */
2623
+ LIBCOUCHBASE_API
2624
+ lcb_error_t lcb_diag(lcb_t instance, const void *cookie, const lcb_CMDDIAG *cmd);
2535
2625
  /**@} (Group: PING) */
2536
2626
 
2537
2627
  /**@ingroup lcb-public-api
@@ -2955,7 +3045,7 @@ void lcb_breakout(lcb_t instance);
2955
3045
  * @brief Check if instance is blocked in the event loop
2956
3046
  * @param instance the instance to run the event loop for.
2957
3047
  * @return non-zero if nobody is waiting for IO interaction
2958
- * @uncomitted
3048
+ * @uncommitted
2959
3049
  */
2960
3050
  LIBCOUCHBASE_API
2961
3051
  int lcb_is_waiting(lcb_t instance);
@@ -3240,7 +3330,7 @@ void lcb_destroy_async(lcb_t instance, const void *arg);
3240
3330
  #define LCB_DATATYPE_JSON 0x01
3241
3331
 
3242
3332
  /** @internal */
3243
- typedef enum { LCB_VALUE_RAW = 0x00, LCB_VALUE_F_JSON = 0x01, LCB_VALUE_F_SNAPPYCOMP } lcb_VALUEFLAGS;
3333
+ typedef enum { LCB_VALUE_RAW = 0x00, LCB_VALUE_F_JSON = 0x01, LCB_VALUE_F_SNAPPYCOMP = 0x02 } lcb_VALUEFLAGS;
3244
3334
 
3245
3335
 
3246
3336
  /**
@@ -3477,7 +3567,6 @@ lcb_dump(lcb_t instance, FILE *fp, lcb_U32 flags);
3477
3567
  LIBCOUCHBASE_API
3478
3568
  lcb_error_t lcb_cntl(lcb_t instance, int mode, int cmd, void *arg);
3479
3569
 
3480
-
3481
3570
  /**
3482
3571
  * Alternatively one may change configuration settings by passing a string key
3483
3572
  * and value. This may be used to provide a simple interface from a command
@@ -3532,6 +3621,7 @@ lcb_error_t lcb_cntl(lcb_t instance, int mode, int cmd, void *arg);
3532
3621
  * |@ref LCB_CNTL_CLIENT_STRING | `"client_string"` | String |
3533
3622
  * |@ref LCB_CNTL_TCP_KEEPALIVE | `"tcp_keepalive"` | Boolean |
3534
3623
  * |@ref LCB_CNTL_CONFIG_POLL_INTERVAL | `"config_poll_interval"` | Timeval |
3624
+ * |@ref LCB_CNTL_IP6POLICY | `"ipv6"` | String ("disabled", "only", "allow") |
3535
3625
  *
3536
3626
  * @committed - Note, the actual API call is considered committed and will
3537
3627
  * not disappear, however the existence of the various string settings are
@@ -3791,6 +3881,8 @@ const lcb_U32 lcb_version_g;
3791
3881
  #define LCB_SUPPORTS_SSL 1
3792
3882
  /**@brief Whether the library has experimental compression support */
3793
3883
  #define LCB_SUPPORTS_SNAPPY 2
3884
+ /**@brief Whether the library has experimental tracing support */
3885
+ #define LCB_SUPPORTS_TRACING 3
3794
3886
 
3795
3887
  /**
3796
3888
  * @committed
@@ -3845,6 +3937,8 @@ typedef enum {
3845
3937
  LCB_DUMP_PKTINFO = 0x02,
3846
3938
  /** Dump memory usage/reservation information about buffers */
3847
3939
  LCB_DUMP_BUFINFO = 0x04,
3940
+ /** Dump various metrics information */
3941
+ LCB_DUMP_METRICS = 0x08,
3848
3942
  /** Dump everything */
3849
3943
  LCB_DUMP_ALL = 0xff
3850
3944
  } lcb_DUMPFLAGS;
@@ -3938,6 +4032,15 @@ LIBCOUCHBASE_API
3938
4032
  const char *
3939
4033
  lcb_resp_get_error_ref(int cbtype, const lcb_RESPBASE *rb);
3940
4034
 
4035
+ /**
4036
+ * @volatile
4037
+ * Returns whether the library redacting logs for this connection instance.
4038
+ *
4039
+ * @return non-zero if the logs are being redacted for this instance.
4040
+ */
4041
+ LIBCOUCHBASE_API
4042
+ int lcb_is_redacting_logs(lcb_t instance);
4043
+
3941
4044
  /* Post-include some other headers */
3942
4045
  #ifdef __cplusplus
3943
4046
  }
@@ -0,0 +1,140 @@
1
+ /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2018 Couchbase, Inc.
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
+ #ifndef LCB_CRYPTO_H
19
+ #define LCB_CRYPTO_H
20
+
21
+ /**
22
+ * @file
23
+ * Field encryption
24
+ *
25
+ * @uncommitted
26
+ */
27
+
28
+ #ifdef __cplusplus
29
+ extern "C" {
30
+ #endif
31
+
32
+ typedef enum {
33
+ /* encryption (e.g. private key for assymetric ciphers) */
34
+ LCBCRYPTO_KEY_ENCRYPT = 0,
35
+ /* decryption (e.g. private key for assymetric ciphers) */
36
+ LCBCRYPTO_KEY_DECRYPT = 1,
37
+ LCBCRYPTO_KEY__MAX
38
+ } lcbcrypto_KEYTYPE;
39
+
40
+ typedef struct lcbcrypto_SIGV {
41
+ const uint8_t *data;
42
+ size_t len;
43
+ } lcbcrypto_SIGV;
44
+
45
+ struct lcbcrypto_PROVIDER;
46
+ typedef struct lcbcrypto_PROVIDER {
47
+ uint16_t version;
48
+ int16_t _refcnt;
49
+ uint64_t flags;
50
+ void *cookie;
51
+ void (*destructor)(struct lcbcrypto_PROVIDER *provider);
52
+ union {
53
+ struct {
54
+ void (*release_bytes)(struct lcbcrypto_PROVIDER *provider, void *bytes);
55
+ lcb_error_t (*load_key)(struct lcbcrypto_PROVIDER *provider, lcbcrypto_KEYTYPE type, const char *keyid,
56
+ uint8_t **key, size_t *key_len);
57
+ lcb_error_t (*generate_iv)(struct lcbcrypto_PROVIDER *provider, uint8_t **iv, size_t *iv_len);
58
+ lcb_error_t (*sign)(struct lcbcrypto_PROVIDER *provider, const lcbcrypto_SIGV *inputs, size_t input_num,
59
+ uint8_t **sig, size_t *sig_len);
60
+ lcb_error_t (*verify_signature)(struct lcbcrypto_PROVIDER *provider, const lcbcrypto_SIGV *inputs,
61
+ size_t input_num, uint8_t *sig, size_t sig_len);
62
+ lcb_error_t (*encrypt)(struct lcbcrypto_PROVIDER *provider, const uint8_t *input, size_t input_len,
63
+ const uint8_t *key, size_t key_len, const uint8_t *iv, size_t iv_len,
64
+ uint8_t **output, size_t *output_len);
65
+ lcb_error_t (*decrypt)(struct lcbcrypto_PROVIDER *provider, const uint8_t *input, size_t input_len,
66
+ const uint8_t *key, size_t key_len, const uint8_t *iv, size_t iv_len,
67
+ uint8_t **output, size_t *output_len);
68
+ } v0;
69
+ } v;
70
+ } lcbcrypto_PROVIDER;
71
+
72
+ typedef struct lcbcrypto_FIELDSPEC {
73
+ const char *name;
74
+ const char *alg;
75
+ const char *kid;
76
+ } lcbcrypto_FIELDSPEC;
77
+
78
+ typedef struct lcbcrypto_CMDENCRYPT {
79
+ uint16_t version;
80
+ const char *prefix;
81
+ const char *doc;
82
+ size_t ndoc;
83
+ char *out;
84
+ size_t nout;
85
+ lcbcrypto_FIELDSPEC *fields;
86
+ size_t nfields;
87
+ } lcbcrypto_CMDENCRYPT;
88
+
89
+ typedef struct lcbcrypto_CMDDECRYPT {
90
+ uint16_t version;
91
+ const char *prefix;
92
+ const char *doc;
93
+ size_t ndoc;
94
+ char *out;
95
+ size_t nout;
96
+ } lcbcrypto_CMDDECRYPT;
97
+
98
+ /**
99
+ * @uncommitted
100
+ */
101
+ LIBCOUCHBASE_API void lcbcrypto_register(lcb_t instance, const char *name, lcbcrypto_PROVIDER *provider);
102
+
103
+ /**
104
+ * @uncommitted
105
+ */
106
+ LIBCOUCHBASE_API void lcbcrypto_unregister(lcb_t instance, const char *name);
107
+
108
+ /**
109
+ * @uncommitted
110
+ */
111
+ LIBCOUCHBASE_API void lcbcrypto_ref(lcbcrypto_PROVIDER *provider);
112
+
113
+ /**
114
+ * @uncommitted
115
+ */
116
+ LIBCOUCHBASE_API void lcbcrypto_unref(lcbcrypto_PROVIDER *provider);
117
+
118
+ /**
119
+ * @uncommitted
120
+ *
121
+ * encrypt and replace fields specified by JSON paths (zero-terminated) with encrypted contents
122
+ */
123
+ LIBCOUCHBASE_API lcb_error_t lcbcrypto_encrypt_fields(lcb_t instance, lcbcrypto_CMDENCRYPT *cmd);
124
+
125
+ /**
126
+ * @uncommitted
127
+ *
128
+ * find and decrypt all fields in the JSON encoded object
129
+ */
130
+ LIBCOUCHBASE_API lcb_error_t lcbcrypto_decrypt_fields(lcb_t instance, lcbcrypto_CMDDECRYPT *cmd);
131
+
132
+ /** @deprecated Use @ref lcbcrypto_encrypt_fields() */
133
+ LCB_DEPR_API2(lcb_error_t lcbcrypto_encrypt_document(lcb_t instance, lcbcrypto_CMDENCRYPT *cmd), "Use lcbcrypto_encrypt_fields");
134
+ /** @deprecated Use @ref lcbcrypto_decrypt_fields() */
135
+ LCB_DEPR_API2(lcb_error_t lcbcrypto_decrypt_document(lcb_t instance, lcbcrypto_CMDDECRYPT *cmd), "Use lcbcrypto_decrypt_fields");
136
+
137
+ #ifdef __cplusplus
138
+ }
139
+ #endif
140
+ #endif /* LCB_CRYPTO_H */