clickhouse-native 0.0.1
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 +7 -0
- data/ext/clickhouse_native/client.cpp +847 -0
- data/ext/clickhouse_native/extconf.rb +101 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.clang-format +11 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.git +1 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.gitattributes +63 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/CODEOWNERS +1 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/linux.yml +139 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/macos.yml +87 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/windows_mingw.yml +102 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.github/workflows/windows_msvc.yml +74 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.gitignore +280 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/.travis.yml +62 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/CMakeLists.txt +157 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/LICENSE +206 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/README.md +260 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/CMakeLists.txt +246 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/buffer.h +10 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/compressed.cpp +258 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/compressed.h +48 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/endpoints_iterator.cpp +20 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/endpoints_iterator.h +34 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/input.cpp +96 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/input.h +103 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/open_telemetry.h +23 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/output.cpp +119 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/output.h +142 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/platform.cpp +1 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/platform.h +33 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/projected_iterator.h +55 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/singleton.h +11 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/socket.cpp +489 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/socket.h +177 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/sslsocket.cpp +307 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/sslsocket.h +111 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/string_utils.h +28 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/string_view.h +142 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/uuid.h +10 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/wire_format.cpp +177 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/base/wire_format.h +79 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/block.cpp +134 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/block.h +114 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/client.cpp +1269 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/client.h +320 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/array.cpp +175 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/array.h +321 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/column.cpp +24 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/column.h +107 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/date.cpp +365 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/date.h +245 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/decimal.cpp +255 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/decimal.h +50 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/enum.cpp +123 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/enum.h +65 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/factory.cpp +285 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/factory.h +14 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/geo.cpp +108 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/geo.h +79 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip4.cpp +117 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip4.h +71 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip6.cpp +108 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/ip6.h +66 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/itemview.cpp +101 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/itemview.h +86 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/lowcardinality.cpp +527 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/lowcardinality.h +221 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/lowcardinalityadaptor.h +63 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/map.cpp +87 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/map.h +257 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/nothing.h +87 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/nullable.cpp +109 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/nullable.h +153 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/numeric.cpp +126 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/numeric.h +88 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/string.cpp +333 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/string.h +145 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/time.cpp +155 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/time.h +118 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/tuple.cpp +106 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/tuple.h +178 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/utils.h +41 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/uuid.cpp +80 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/columns/uuid.h +58 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/error_codes.h +595 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/exceptions.h +66 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/protocol.h +54 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/query.cpp +25 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/query.h +246 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/server_exception.h +16 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/type_parser.cpp +314 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/type_parser.h +89 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/types.cpp +484 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/types/types.h +397 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/clickhouse/version.h +14 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/Findcityhash.cmake +26 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/Findlz4.cmake +39 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/Findzstd.cmake +39 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/cpp17.cmake +8 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/openssl.cmake +8 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/subdirs.cmake +5 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/cmake/version.cmake +87 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/CMakeLists.txt +9 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/attributes.h +682 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/config.h +714 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/internal/bits.h +219 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/macros.h +147 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/optimization.h +241 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/options.h +238 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/policy_checks.h +111 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/base/port.h +26 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128.cc +390 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128.h +1092 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128_have_intrinsic.inc +302 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/absl/absl/numeric/int128_no_intrinsic.inc +308 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/BUCK +13 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/CMakeLists.txt +7 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/COPYING +19 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/city.cc +469 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/city.h +90 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/citycrc.h +43 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/cityhash/cityhash/config.h +118 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/BUCK +14 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/CMakeLists.txt +4 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/LICENSE +28 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/README.md +1 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-death-test.h +346 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-matchers.h +930 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-message.h +219 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-param-test.h +507 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-printers.h +1029 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-spi.h +238 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-test-part.h +184 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest-typed-test.h +329 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest.h +2495 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest_pred_impl.h +359 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/gtest_prod.h +61 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/README.md +56 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/gtest-port.h +37 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/gtest-printers.h +42 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/custom/gtest.h +37 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-death-test-internal.h +304 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-filepath.h +211 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-internal.h +1560 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-param-util.h +947 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-port-arch.h +114 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-port.h +2389 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-string.h +175 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/include/gtest/internal/gtest-type-util.h +183 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-all.cc +48 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-death-test.cc +1644 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-filepath.cc +369 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-internal-inl.h +1221 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-matchers.cc +97 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-port.cc +1433 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-printers.cc +533 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-test-part.cc +108 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest-typed-test.cc +107 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest.cc +6746 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/gtest/src/gtest_main.cc +54 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/BUCK +13 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/CMakeLists.txt +8 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/LICENSE +24 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4.c +2402 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4.h +764 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4hc.c +1554 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/lz4/lz4/lz4hc.h +438 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/BUCK +232 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/CMakeLists.txt +115 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/LICENSE +30 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/allocations.h +55 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/bits.h +200 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/bitstream.h +437 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/compiler.h +358 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/cpu.h +213 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/debug.c +24 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/debug.h +107 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/entropy_common.c +340 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/error_private.c +63 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/error_private.h +159 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/fse.h +639 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/fse_decompress.c +311 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/huf.h +273 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/mem.h +435 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/pool.c +371 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/pool.h +90 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/portability_macros.h +156 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/threading.c +176 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/threading.h +150 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/xxhash.c +24 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/xxhash.h +5686 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_common.c +48 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_deps.h +111 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_internal.h +392 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/common/zstd_trace.h +163 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/clevels.h +134 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/fse_compress.c +624 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/hist.c +181 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/hist.h +75 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/huf_compress.c +1435 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress.c +7032 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_internal.h +1532 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_literals.c +235 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_literals.h +39 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_sequences.c +442 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_sequences.h +54 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_superblock.c +577 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_compress_superblock.h +32 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_cwksp.h +742 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_double_fast.c +758 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_double_fast.h +39 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_fast.c +960 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_fast.h +38 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_lazy.c +2157 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_lazy.h +127 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_ldm.c +724 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_ldm.h +117 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_ldm_geartab.h +106 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_opt.c +1472 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstd_opt.h +56 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstdmt_compress.c +1867 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/compress/zstdmt_compress.h +113 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/huf_decompress.c +1882 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/huf_decompress_amd64.S +576 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_ddict.c +244 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_ddict.h +44 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress.c +2355 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress_block.c +2192 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress_block.h +73 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/decompress/zstd_decompress_internal.h +238 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/cover.c +1257 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/cover.h +158 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/divsufsort.c +1913 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/divsufsort.h +67 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/fastcover.c +766 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/dictBuilder/zdict.c +1127 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_legacy.h +422 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v01.c +2125 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v01.h +94 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v02.c +3477 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v02.h +93 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v03.c +3117 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v03.h +93 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v04.c +3605 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v04.h +142 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v05.c +4004 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v05.h +162 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v06.c +4113 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v06.h +172 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v07.c +4498 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/legacy/zstd_v07.h +187 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/zdict.h +474 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/zstd.h +3020 -0
- data/ext/clickhouse_native/vendor/clickhouse-cpp/contrib/zstd/zstd/zstd_errors.h +114 -0
- data/lib/clickhouse_native/clickhouse_native.bundle +0 -0
- data/lib/clickhouse_native/client.rb +50 -0
- data/lib/clickhouse_native/errors.rb +23 -0
- data/lib/clickhouse_native/pool.rb +49 -0
- data/lib/clickhouse_native/version.rb +3 -0
- data/lib/clickhouse_native.rb +8 -0
- metadata +369 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
#include "sslsocket.h"
|
|
2
|
+
#include "../client.h"
|
|
3
|
+
#include "../exceptions.h"
|
|
4
|
+
|
|
5
|
+
#include <stdexcept>
|
|
6
|
+
|
|
7
|
+
#include <openssl/ssl.h>
|
|
8
|
+
#include <openssl/x509v3.h>
|
|
9
|
+
#include <openssl/err.h>
|
|
10
|
+
#include <openssl/asn1.h>
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
namespace {
|
|
14
|
+
|
|
15
|
+
std::string getCertificateInfo(X509* cert)
|
|
16
|
+
{
|
|
17
|
+
if (!cert)
|
|
18
|
+
return "No certificate";
|
|
19
|
+
|
|
20
|
+
std::unique_ptr<BIO, decltype(&BIO_free)> mem_bio(BIO_new(BIO_s_mem()), &BIO_free);
|
|
21
|
+
X509_print(mem_bio.get(), cert);
|
|
22
|
+
|
|
23
|
+
char * data = nullptr;
|
|
24
|
+
auto len = BIO_get_mem_data(mem_bio.get(), &data);
|
|
25
|
+
if (len < 0)
|
|
26
|
+
return "Can't get certificate info due to BIO error " + std::to_string(len);
|
|
27
|
+
|
|
28
|
+
return std::string(data, len);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
void throwSSLError(SSL * ssl, int error, const char * /*location*/, const char * /*statement*/, const std::string prefix = "OpenSSL error: ") {
|
|
32
|
+
const auto detail_error = ERR_get_error();
|
|
33
|
+
auto reason = ERR_reason_error_string(detail_error);
|
|
34
|
+
reason = reason ? reason : "Unknown SSL error";
|
|
35
|
+
|
|
36
|
+
std::string reason_str = reason;
|
|
37
|
+
if (ssl) {
|
|
38
|
+
// Print certificate only if handshake isn't completed
|
|
39
|
+
if (auto ssl_session = SSL_get_session(ssl); ssl_session && SSL_get_state(ssl) != TLS_ST_OK)
|
|
40
|
+
reason_str += "\nServer certificate: " + getCertificateInfo(SSL_SESSION_get0_peer(ssl_session));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// std::cerr << "!!! SSL error at " << location
|
|
44
|
+
// << "\n\tcaused by " << statement
|
|
45
|
+
// << "\n\t: "<< reason_str << "(" << error << ")"
|
|
46
|
+
// << "\n\t last err: " << ERR_peek_last_error()
|
|
47
|
+
// << std::endl;
|
|
48
|
+
|
|
49
|
+
throw clickhouse::OpenSSLError(prefix + std::to_string(error) + " : " + reason_str);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
void configureSSL(const clickhouse::SSLParams::ConfigurationType & configuration, SSL * ssl, SSL_CTX * context = nullptr) {
|
|
53
|
+
std::unique_ptr<SSL_CONF_CTX, decltype(&SSL_CONF_CTX_free)> conf_ctx_holder(SSL_CONF_CTX_new(), SSL_CONF_CTX_free);
|
|
54
|
+
auto conf_ctx = conf_ctx_holder.get();
|
|
55
|
+
|
|
56
|
+
// To make both cmdline and flag file commands start with no prefix.
|
|
57
|
+
SSL_CONF_CTX_set1_prefix(conf_ctx, "");
|
|
58
|
+
// Allow all set of client commands, also turn on proper error reporting to reuse throwSSLError().
|
|
59
|
+
SSL_CONF_CTX_set_flags(conf_ctx, SSL_CONF_FLAG_CMDLINE | SSL_CONF_FLAG_FILE | SSL_CONF_FLAG_CLIENT | SSL_CONF_FLAG_SHOW_ERRORS | SSL_CONF_FLAG_CERTIFICATE );
|
|
60
|
+
if (ssl)
|
|
61
|
+
SSL_CONF_CTX_set_ssl(conf_ctx, ssl);
|
|
62
|
+
else if (context)
|
|
63
|
+
SSL_CONF_CTX_set_ssl_ctx(conf_ctx, context);
|
|
64
|
+
|
|
65
|
+
for (const auto & kv : configuration) {
|
|
66
|
+
const int err = SSL_CONF_cmd(conf_ctx, kv.first.c_str(), (kv.second ? kv.second->c_str() : nullptr));
|
|
67
|
+
// From the documentation:
|
|
68
|
+
// 2 - both key and value used
|
|
69
|
+
// 1 - only key used
|
|
70
|
+
// 0 - error during processing
|
|
71
|
+
// -2 - key not recodnized
|
|
72
|
+
// -3 - missing value
|
|
73
|
+
const bool value_present = !!kv.second;
|
|
74
|
+
if (err == 2 || (err == 1 && !value_present))
|
|
75
|
+
continue;
|
|
76
|
+
else if (err == 0)
|
|
77
|
+
throwSSLError(ssl, SSL_ERROR_NONE, nullptr, nullptr, "Failed to configure OpenSSL with command '" + kv.first + "' ");
|
|
78
|
+
else if (err == 1 && value_present)
|
|
79
|
+
throw clickhouse::OpenSSLError("Failed to configure OpenSSL: command '" + kv.first + "' needs no value");
|
|
80
|
+
else if (err == -2)
|
|
81
|
+
throw clickhouse::OpenSSLError("Failed to configure OpenSSL: unknown command '" + kv.first + "'");
|
|
82
|
+
else if (err == -3)
|
|
83
|
+
throw clickhouse::OpenSSLError("Failed to configure OpenSSL: command '" + kv.first + "' requires a value");
|
|
84
|
+
else
|
|
85
|
+
throw clickhouse::OpenSSLError("Failed to configure OpenSSL: command '" + kv.first + "' unknown error: " + std::to_string(err));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
#define STRINGIFY_HELPER(x) #x
|
|
90
|
+
#define STRINGIFY(x) STRINGIFY_HELPER(x)
|
|
91
|
+
#define LOCATION __FILE__ ":" STRINGIFY(__LINE__)
|
|
92
|
+
|
|
93
|
+
struct SSLInitializer {
|
|
94
|
+
SSLInitializer() {
|
|
95
|
+
SSL_library_init();
|
|
96
|
+
SSLeay_add_ssl_algorithms();
|
|
97
|
+
SSL_load_error_strings();
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
SSL_CTX * prepareSSLContext(const clickhouse::SSLParams & context_params) {
|
|
102
|
+
static const SSLInitializer ssl_initializer;
|
|
103
|
+
|
|
104
|
+
const SSL_METHOD *method = TLS_client_method();
|
|
105
|
+
std::unique_ptr<SSL_CTX, decltype(&SSL_CTX_free)> ctx(SSL_CTX_new(method), &SSL_CTX_free);
|
|
106
|
+
|
|
107
|
+
if (!ctx)
|
|
108
|
+
throw clickhouse::OpenSSLError("Failed to initialize SSL context");
|
|
109
|
+
|
|
110
|
+
#define HANDLE_SSL_CTX_ERROR(statement) do { \
|
|
111
|
+
if (const auto ret_code = (statement); !ret_code) \
|
|
112
|
+
throwSSLError(nullptr, static_cast<int>(ERR_peek_error()), LOCATION, #statement); \
|
|
113
|
+
} while(false);
|
|
114
|
+
|
|
115
|
+
if (context_params.use_default_ca_locations)
|
|
116
|
+
HANDLE_SSL_CTX_ERROR(SSL_CTX_set_default_verify_paths(ctx.get()));
|
|
117
|
+
if (!context_params.path_to_ca_directory.empty())
|
|
118
|
+
HANDLE_SSL_CTX_ERROR(
|
|
119
|
+
SSL_CTX_load_verify_locations(
|
|
120
|
+
ctx.get(),
|
|
121
|
+
nullptr,
|
|
122
|
+
context_params.path_to_ca_directory.c_str())
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
for (const auto & f : context_params.path_to_ca_files)
|
|
126
|
+
HANDLE_SSL_CTX_ERROR(SSL_CTX_load_verify_locations(ctx.get(), f.c_str(), nullptr));
|
|
127
|
+
|
|
128
|
+
if (context_params.context_options != -1)
|
|
129
|
+
SSL_CTX_set_options(ctx.get(), context_params.context_options);
|
|
130
|
+
if (context_params.min_protocol_version != -1)
|
|
131
|
+
HANDLE_SSL_CTX_ERROR(
|
|
132
|
+
SSL_CTX_set_min_proto_version(ctx.get(), context_params.min_protocol_version));
|
|
133
|
+
if (context_params.max_protocol_version != -1)
|
|
134
|
+
HANDLE_SSL_CTX_ERROR(
|
|
135
|
+
SSL_CTX_set_max_proto_version(ctx.get(), context_params.max_protocol_version));
|
|
136
|
+
|
|
137
|
+
return ctx.release();
|
|
138
|
+
#undef HANDLE_SSL_CTX_ERROR
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
auto convertConfiguration(const decltype(clickhouse::ClientOptions::SSLOptions::configuration) & configuration)
|
|
142
|
+
{
|
|
143
|
+
auto result = decltype(clickhouse::SSLParams::configuration){};
|
|
144
|
+
for (const auto & cv : configuration)
|
|
145
|
+
result.push_back({cv.command, cv.value});
|
|
146
|
+
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
clickhouse::SSLParams GetSSLParams(const clickhouse::ClientOptions& opts) {
|
|
151
|
+
const auto& ssl_options = *opts.ssl_options;
|
|
152
|
+
return clickhouse::SSLParams{
|
|
153
|
+
ssl_options.path_to_ca_files,
|
|
154
|
+
ssl_options.path_to_ca_directory,
|
|
155
|
+
ssl_options.use_default_ca_locations,
|
|
156
|
+
ssl_options.context_options,
|
|
157
|
+
ssl_options.min_protocol_version,
|
|
158
|
+
ssl_options.max_protocol_version,
|
|
159
|
+
ssl_options.use_sni,
|
|
160
|
+
ssl_options.skip_verification,
|
|
161
|
+
ssl_options.host_flags,
|
|
162
|
+
convertConfiguration(ssl_options.configuration)
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
namespace clickhouse {
|
|
169
|
+
|
|
170
|
+
SSLContext::SSLContext(SSL_CTX & context)
|
|
171
|
+
: context_(&context, &SSL_CTX_free)
|
|
172
|
+
{
|
|
173
|
+
SSL_CTX_up_ref(context_.get());
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
SSLContext::SSLContext(const SSLParams & context_params)
|
|
177
|
+
: context_(prepareSSLContext(context_params), &SSL_CTX_free)
|
|
178
|
+
{
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
SSL_CTX * SSLContext::getContext() {
|
|
182
|
+
return context_.get();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Allows caller to use returned value of `statement` if there was no error, throws exception otherwise.
|
|
186
|
+
#define HANDLE_SSL_ERROR(SSL_PTR, statement) [&] { \
|
|
187
|
+
if (const auto ret_code = (statement); ret_code <= 0) { \
|
|
188
|
+
throwSSLError(SSL_PTR, SSL_get_error(SSL_PTR, static_cast<int>(ret_code)), LOCATION, #statement); \
|
|
189
|
+
return static_cast<std::decay_t<decltype(ret_code)>>(0); \
|
|
190
|
+
} \
|
|
191
|
+
else \
|
|
192
|
+
return ret_code; \
|
|
193
|
+
} ()
|
|
194
|
+
|
|
195
|
+
/* // debug macro for tracing SSL state
|
|
196
|
+
#define LOG_SSL_STATE() std::cerr << "!!!!" << LOCATION << " @" << __FUNCTION__ \
|
|
197
|
+
<< "\t" << SSL_get_version(ssl_) << " state: " << SSL_state_string_long(ssl_) \
|
|
198
|
+
<< "\n\t handshake state: " << SSL_get_state(ssl_) \
|
|
199
|
+
<< std::endl
|
|
200
|
+
*/
|
|
201
|
+
SSLSocket::SSLSocket(const NetworkAddress& addr, const SocketTimeoutParams& timeout_params,
|
|
202
|
+
const SSLParams & ssl_params, SSLContext& context)
|
|
203
|
+
: Socket(addr, timeout_params)
|
|
204
|
+
, ssl_(SSL_new(context.getContext()), &SSL_free)
|
|
205
|
+
{
|
|
206
|
+
auto ssl = ssl_.get();
|
|
207
|
+
if (!ssl)
|
|
208
|
+
throw clickhouse::OpenSSLError("Failed to create SSL instance");
|
|
209
|
+
|
|
210
|
+
std::unique_ptr<ASN1_OCTET_STRING, decltype(&ASN1_OCTET_STRING_free)> ip_addr(a2i_IPADDRESS(addr.Host().c_str()), &ASN1_OCTET_STRING_free);
|
|
211
|
+
|
|
212
|
+
HANDLE_SSL_ERROR(ssl, SSL_set_fd(ssl, static_cast<int>(handle_)));
|
|
213
|
+
if (ssl_params.use_SNI)
|
|
214
|
+
HANDLE_SSL_ERROR(ssl, SSL_set_tlsext_host_name(ssl, addr.Host().c_str()));
|
|
215
|
+
|
|
216
|
+
if (ssl_params.host_flags != -1)
|
|
217
|
+
SSL_set_hostflags(ssl, ssl_params.host_flags);
|
|
218
|
+
HANDLE_SSL_ERROR(ssl, SSL_set1_host(ssl, addr.Host().c_str()));
|
|
219
|
+
|
|
220
|
+
// DO NOT use SSL_set_verify(ssl, SSL_VERIFY_PEER, nullptr), since
|
|
221
|
+
// we check verification result later, and that provides better error message.
|
|
222
|
+
|
|
223
|
+
if (ssl_params.configuration.size() > 0)
|
|
224
|
+
configureSSL(ssl_params.configuration, ssl);
|
|
225
|
+
|
|
226
|
+
SSL_set_connect_state(ssl);
|
|
227
|
+
HANDLE_SSL_ERROR(ssl, SSL_connect(ssl));
|
|
228
|
+
HANDLE_SSL_ERROR(ssl, SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY));
|
|
229
|
+
|
|
230
|
+
if (const auto verify_result = SSL_get_verify_result(ssl); !ssl_params.skip_verification && verify_result != X509_V_OK) {
|
|
231
|
+
auto error_message = X509_verify_cert_error_string(verify_result);
|
|
232
|
+
throw clickhouse::OpenSSLError("Failed to verify SSL connection, X509_v error: "
|
|
233
|
+
+ std::to_string(verify_result)
|
|
234
|
+
+ " " + error_message
|
|
235
|
+
+ "\nServer certificate: " + getCertificateInfo(SSL_get_peer_certificate(ssl)));
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Host name verification is done by OpenSSL itself, however if we are connecting to an ip-address,
|
|
239
|
+
// no verification is made, so we have to do it manually.
|
|
240
|
+
// Just in case if this is ever required, leave it here commented out.
|
|
241
|
+
// if (ip_addr) {
|
|
242
|
+
// // if hostname is actually an IP address
|
|
243
|
+
// HANDLE_SSL_ERROR(ssl, X509_check_ip(
|
|
244
|
+
// SSL_get_peer_certificate(ssl),
|
|
245
|
+
// ASN1_STRING_get0_data(ip_addr.get()),
|
|
246
|
+
// ASN1_STRING_length(ip_addr.get()),
|
|
247
|
+
// 0));
|
|
248
|
+
// }
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
void SSLSocket::validateParams(const SSLParams & ssl_params) {
|
|
252
|
+
// We need either SSL or SSL_CTX to properly validate configuration, so create a temporary one.
|
|
253
|
+
std::unique_ptr<SSL_CTX, decltype(&SSL_CTX_free)> ctx(SSL_CTX_new(TLS_client_method()), &SSL_CTX_free);
|
|
254
|
+
configureSSL(ssl_params.configuration, nullptr, ctx.get());
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
SSLSocketFactory::SSLSocketFactory(const ClientOptions& opts)
|
|
259
|
+
: NonSecureSocketFactory()
|
|
260
|
+
, ssl_params_(GetSSLParams(opts)) {
|
|
261
|
+
if (opts.ssl_options->ssl_context) {
|
|
262
|
+
ssl_context_ = std::make_unique<SSLContext>(*opts.ssl_options->ssl_context);
|
|
263
|
+
} else {
|
|
264
|
+
ssl_context_ = std::make_unique<SSLContext>(ssl_params_);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
SSLSocketFactory::~SSLSocketFactory() = default;
|
|
269
|
+
|
|
270
|
+
std::unique_ptr<Socket> SSLSocketFactory::doConnect(const NetworkAddress& address, const ClientOptions& opts) {
|
|
271
|
+
SocketTimeoutParams timeout_params { opts.connection_connect_timeout, opts.connection_recv_timeout, opts.connection_send_timeout };
|
|
272
|
+
return std::make_unique<SSLSocket>(address, timeout_params, ssl_params_, *ssl_context_);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
std::unique_ptr<InputStream> SSLSocket::makeInputStream() const {
|
|
276
|
+
return std::make_unique<SSLSocketInput>(ssl_.get());
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
std::unique_ptr<OutputStream> SSLSocket::makeOutputStream() const {
|
|
280
|
+
return std::make_unique<SSLSocketOutput>(ssl_.get());
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
SSLSocketInput::SSLSocketInput(SSL *ssl)
|
|
284
|
+
: ssl_(ssl)
|
|
285
|
+
{}
|
|
286
|
+
|
|
287
|
+
size_t SSLSocketInput::DoRead(void* buf, size_t len) {
|
|
288
|
+
size_t actually_read;
|
|
289
|
+
HANDLE_SSL_ERROR(ssl_, SSL_read_ex(ssl_, buf, len, &actually_read));
|
|
290
|
+
return actually_read;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
SSLSocketOutput::SSLSocketOutput(SSL *ssl)
|
|
294
|
+
: ssl_(ssl)
|
|
295
|
+
{}
|
|
296
|
+
|
|
297
|
+
size_t SSLSocketOutput::DoWrite(const void* data, size_t len) {
|
|
298
|
+
if (len > std::numeric_limits<int>::max())
|
|
299
|
+
// FIXME(vnemkov): We should do multiple `SSL_write`s in this case.
|
|
300
|
+
throw AssertionError("Failed to write too big chunk at once "
|
|
301
|
+
+ std::to_string(len) + " > " + std::to_string(std::numeric_limits<int>::max()));
|
|
302
|
+
return static_cast<size_t>(HANDLE_SSL_ERROR(ssl_, SSL_write(ssl_, data, static_cast<int>(len))));
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
#undef HANDLE_SSL_ERROR
|
|
306
|
+
|
|
307
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "socket.h"
|
|
4
|
+
|
|
5
|
+
#include <memory>
|
|
6
|
+
#include <optional>
|
|
7
|
+
#include <vector>
|
|
8
|
+
|
|
9
|
+
typedef struct ssl_ctx_st SSL_CTX;
|
|
10
|
+
typedef struct ssl_st SSL;
|
|
11
|
+
|
|
12
|
+
namespace clickhouse {
|
|
13
|
+
|
|
14
|
+
struct SSLParams
|
|
15
|
+
{
|
|
16
|
+
std::vector<std::string> path_to_ca_files;
|
|
17
|
+
std::string path_to_ca_directory;
|
|
18
|
+
bool use_default_ca_locations;
|
|
19
|
+
int context_options;
|
|
20
|
+
int min_protocol_version;
|
|
21
|
+
int max_protocol_version;
|
|
22
|
+
bool use_SNI;
|
|
23
|
+
bool skip_verification;
|
|
24
|
+
int host_flags;
|
|
25
|
+
using ConfigurationType = std::vector<std::pair<std::string, std::optional<std::string>>>;
|
|
26
|
+
ConfigurationType configuration;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
class SSLContext
|
|
30
|
+
{
|
|
31
|
+
public:
|
|
32
|
+
explicit SSLContext(SSL_CTX & context);
|
|
33
|
+
explicit SSLContext(const SSLParams & context_params);
|
|
34
|
+
~SSLContext() = default;
|
|
35
|
+
|
|
36
|
+
SSLContext(const SSLContext &) = delete;
|
|
37
|
+
SSLContext& operator=(const SSLContext &) = delete;
|
|
38
|
+
SSLContext(SSLContext &&) = delete;
|
|
39
|
+
SSLContext& operator=(SSLContext &) = delete;
|
|
40
|
+
|
|
41
|
+
private:
|
|
42
|
+
friend class SSLSocket;
|
|
43
|
+
SSL_CTX * getContext();
|
|
44
|
+
|
|
45
|
+
private:
|
|
46
|
+
std::unique_ptr<SSL_CTX, void (*)(SSL_CTX*)> context_;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
class SSLSocket : public Socket {
|
|
50
|
+
public:
|
|
51
|
+
explicit SSLSocket(const NetworkAddress& addr, const SocketTimeoutParams& timeout_params,
|
|
52
|
+
const SSLParams& ssl_params, SSLContext& context);
|
|
53
|
+
|
|
54
|
+
SSLSocket(SSLSocket &&) = default;
|
|
55
|
+
~SSLSocket() override = default;
|
|
56
|
+
|
|
57
|
+
SSLSocket(const SSLSocket & ) = delete;
|
|
58
|
+
SSLSocket& operator=(const SSLSocket & ) = delete;
|
|
59
|
+
|
|
60
|
+
std::unique_ptr<InputStream> makeInputStream() const override;
|
|
61
|
+
std::unique_ptr<OutputStream> makeOutputStream() const override;
|
|
62
|
+
|
|
63
|
+
static void validateParams(const SSLParams & ssl_params);
|
|
64
|
+
private:
|
|
65
|
+
std::unique_ptr<SSL, void (*)(SSL *s)> ssl_;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
class SSLSocketFactory : public NonSecureSocketFactory {
|
|
69
|
+
public:
|
|
70
|
+
explicit SSLSocketFactory(const ClientOptions& opts);
|
|
71
|
+
~SSLSocketFactory() override;
|
|
72
|
+
|
|
73
|
+
protected:
|
|
74
|
+
std::unique_ptr<Socket> doConnect(const NetworkAddress& address, const ClientOptions& opts) override;
|
|
75
|
+
|
|
76
|
+
private:
|
|
77
|
+
const SSLParams ssl_params_;
|
|
78
|
+
std::unique_ptr<SSLContext> ssl_context_;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
class SSLSocketInput : public InputStream {
|
|
82
|
+
public:
|
|
83
|
+
explicit SSLSocketInput(SSL *ssl);
|
|
84
|
+
~SSLSocketInput() = default;
|
|
85
|
+
|
|
86
|
+
bool Skip(size_t /*bytes*/) override {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
protected:
|
|
91
|
+
size_t DoRead(void* buf, size_t len) override;
|
|
92
|
+
|
|
93
|
+
private:
|
|
94
|
+
// Not owning
|
|
95
|
+
SSL *ssl_;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
class SSLSocketOutput : public OutputStream {
|
|
99
|
+
public:
|
|
100
|
+
explicit SSLSocketOutput(SSL *ssl);
|
|
101
|
+
~SSLSocketOutput() = default;
|
|
102
|
+
|
|
103
|
+
protected:
|
|
104
|
+
size_t DoWrite(const void* data, size_t len) override;
|
|
105
|
+
|
|
106
|
+
private:
|
|
107
|
+
// Not owning
|
|
108
|
+
SSL *ssl_;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "string_view.h"
|
|
4
|
+
|
|
5
|
+
#include <sstream>
|
|
6
|
+
#include <string>
|
|
7
|
+
|
|
8
|
+
namespace clickhouse {
|
|
9
|
+
|
|
10
|
+
template <typename T>
|
|
11
|
+
[[deprecated("Not used by clickhosue-cpp itself, and will be removed in next major release (3.0) ")]]
|
|
12
|
+
inline T FromString(const std::string& s) {
|
|
13
|
+
std::istringstream iss(s);
|
|
14
|
+
T result;
|
|
15
|
+
iss >> result;
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
template <typename T>
|
|
20
|
+
[[deprecated("Not used by clickhosue-cpp itself, and will be removed in next major release (3.0) ")]]
|
|
21
|
+
inline T FromString(const StringView& s) {
|
|
22
|
+
std::istringstream iss((std::string(s)));
|
|
23
|
+
T result;
|
|
24
|
+
iss >> result;
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <cassert>
|
|
4
|
+
#include <stdexcept>
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A lightweight non-owning read-only view into a subsequence of a string.
|
|
9
|
+
*/
|
|
10
|
+
template <
|
|
11
|
+
typename TChar,
|
|
12
|
+
typename TTraits = std::char_traits<TChar>
|
|
13
|
+
>
|
|
14
|
+
class
|
|
15
|
+
[[deprecated("Obsolete due to C++17's std::string_view. Will be removed in next major release (3.0) ")]]
|
|
16
|
+
StringViewImpl {
|
|
17
|
+
public:
|
|
18
|
+
using size_type = size_t;
|
|
19
|
+
using traits_type = TTraits;
|
|
20
|
+
using value_type = typename TTraits::char_type;
|
|
21
|
+
|
|
22
|
+
static constexpr size_type npos = size_type(-1);
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
inline StringViewImpl() noexcept
|
|
26
|
+
: data_(nullptr)
|
|
27
|
+
, size_(0)
|
|
28
|
+
{
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
constexpr inline StringViewImpl(const TChar* data, size_t len) noexcept
|
|
32
|
+
: data_(data)
|
|
33
|
+
, size_(len)
|
|
34
|
+
{
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
template <size_t len>
|
|
38
|
+
constexpr inline StringViewImpl(const TChar (&str)[len]) noexcept
|
|
39
|
+
: data_(str)
|
|
40
|
+
, size_(len - 1)
|
|
41
|
+
{
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
inline StringViewImpl(const TChar* begin, const TChar* end) noexcept
|
|
45
|
+
: data_(begin)
|
|
46
|
+
, size_(end - begin)
|
|
47
|
+
{
|
|
48
|
+
assert(begin <= end);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
inline StringViewImpl(const std::basic_string<TChar>& str) noexcept
|
|
52
|
+
: data_(str.data())
|
|
53
|
+
, size_(str.size())
|
|
54
|
+
{
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
inline TChar at(size_type pos) const {
|
|
58
|
+
if (pos >= size_)
|
|
59
|
+
throw std::out_of_range("pos must be less than len");
|
|
60
|
+
return data_[pos];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
inline const TChar* data() const noexcept {
|
|
64
|
+
return data_;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
inline bool empty() const noexcept {
|
|
68
|
+
return size_ == 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
inline bool null() const noexcept {
|
|
72
|
+
assert(size_ == 0);
|
|
73
|
+
return data_ == nullptr;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
inline size_type size() const noexcept {
|
|
77
|
+
return size_;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// to mimic std::string and std::string_view
|
|
81
|
+
inline size_type length() const noexcept {
|
|
82
|
+
return size();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public:
|
|
86
|
+
// Returns a substring [pos, pos + count).
|
|
87
|
+
// If the requested substring extends past the end of the string,
|
|
88
|
+
// or if count == npos, the returned substring is [pos, size()).
|
|
89
|
+
StringViewImpl substr(size_type pos, size_type count = npos) const {
|
|
90
|
+
if (pos >= size_)
|
|
91
|
+
throw std::out_of_range("pos must be less than len");
|
|
92
|
+
if (pos + count >= size_ || count == npos)
|
|
93
|
+
return StringViewImpl(data_ + pos, size_ - pos);
|
|
94
|
+
else
|
|
95
|
+
return StringViewImpl(data_ + pos, count);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
inline const std::basic_string<TChar> to_string() const {
|
|
99
|
+
return std::basic_string<TChar>(data_, size_);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public:
|
|
103
|
+
inline operator bool () const noexcept {
|
|
104
|
+
return !empty();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
inline explicit operator const std::basic_string<TChar> () const {
|
|
108
|
+
return to_string();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
inline TChar operator [] (size_type pos) const noexcept {
|
|
112
|
+
return data_[pos];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
inline bool operator < (const StringViewImpl& other) const noexcept {
|
|
116
|
+
if (size_ < other.size_)
|
|
117
|
+
return true;
|
|
118
|
+
if (size_ > other.size_)
|
|
119
|
+
return false;
|
|
120
|
+
return TTraits::compare(data_, other.data_, size_) < 0;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
inline bool operator == (const StringViewImpl& other) const noexcept {
|
|
124
|
+
if (size_ == other.size_)
|
|
125
|
+
return TTraits::compare(data_, other.data_, size_) == 0;
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private:
|
|
130
|
+
const TChar* data_;
|
|
131
|
+
size_t size_;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
// It creates StringView from literal constant at compile time.
|
|
136
|
+
template <typename TChar, size_t size>
|
|
137
|
+
constexpr inline StringViewImpl<TChar> MakeStringView(const TChar (&str)[size]) {
|
|
138
|
+
return StringViewImpl<TChar>(str, size - 1);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
using StringView = StringViewImpl<char>;
|