From e822811f291f0776a17bb2b94eedd93e5d8c9a44 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 5 Aug 2025 15:52:58 -0700 Subject: [PATCH 001/245] reorganize rustybits into a single library with smeeclient behind the ztcontroller feature flag --- controller/CV1.cpp | 8 +- controller/CV1.hpp | 4 +- make-linux.mk | 24 +- make-mac.mk | 36 +- rustybits/Cargo.lock | 368 +- rustybits/Cargo.toml | 40 +- rustybits/{smeeclient => }/build.rs | 11 +- rustybits/smeeclient/Cargo.lock | 2998 +++++++++++++++++ rustybits/smeeclient/Cargo.toml | 21 - rustybits/smeeclient/rustfmt.toml | 1 - rustybits/smeeclient/src/ext.rs | 94 - rustybits/{zeroidc => }/src/ext.rs | 248 +- rustybits/src/lib.rs | 5 + .../src/lib.rs => src/smeeclient/mod.rs} | 5 +- .../{zeroidc/src => src/zeroidc}/error.rs | 0 .../src/lib.rs => src/zeroidc/mod.rs} | 7 +- rustybits/zeroidc/.cargo/config.toml | 11 - rustybits/zeroidc/.gitattributes | 3 - rustybits/zeroidc/Cargo.toml | 28 - rustybits/zeroidc/build.rs | 36 - rustybits/zeroidc/rustfmt.toml | 1 - service/OneService.cpp | 36 +- 22 files changed, 3492 insertions(+), 493 deletions(-) rename rustybits/{smeeclient => }/build.rs (72%) create mode 100644 rustybits/smeeclient/Cargo.lock delete mode 100644 rustybits/smeeclient/Cargo.toml delete mode 120000 rustybits/smeeclient/rustfmt.toml delete mode 100644 rustybits/smeeclient/src/ext.rs rename rustybits/{zeroidc => }/src/ext.rs (55%) create mode 100644 rustybits/src/lib.rs rename rustybits/{smeeclient/src/lib.rs => src/smeeclient/mod.rs} (97%) rename rustybits/{zeroidc/src => src/zeroidc}/error.rs (100%) rename rustybits/{zeroidc/src/lib.rs => src/zeroidc/mod.rs} (99%) delete mode 100644 rustybits/zeroidc/.cargo/config.toml delete mode 100644 rustybits/zeroidc/.gitattributes delete mode 100644 rustybits/zeroidc/Cargo.toml delete mode 100644 rustybits/zeroidc/build.rs delete mode 120000 rustybits/zeroidc/rustfmt.toml diff --git a/controller/CV1.cpp b/controller/CV1.cpp index 95d85a2807..0ba82f064f 100644 --- a/controller/CV1.cpp +++ b/controller/CV1.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include // #define REDIS_TRACE 1 @@ -153,7 +153,7 @@ CV1::CV1(const Identity& myId, const char* path, int listenPort, RedisConfig* rc CV1::~CV1() { if (_smee != NULL) { - smeeclient::smee_client_delete(_smee); + rustybits::smee_client_delete(_smee); _smee = NULL; } @@ -195,7 +195,7 @@ void CV1::configureSmee() if (scheme != NULL && host != NULL && port != NULL && ns != NULL && task_queue != NULL) { fprintf(stderr, "creating smee client\n"); std::string hostPort = std::string(scheme) + std::string("://") + std::string(host) + std::string(":") + std::string(port); - this->_smee = smeeclient::smee_client_new(hostPort.c_str(), ns, task_queue); + this->_smee = rustybits::smee_client_new(hostPort.c_str(), ns, task_queue); } else { fprintf(stderr, "Smee client not configured\n"); @@ -1850,7 +1850,7 @@ void CV1::notifyNewMember(const std::string& networkID, const std::string& membe auto span = tracer->StartSpan("cv1::notifyNewMember"); auto scope = tracer->WithActiveSpan(span); - smeeclient::smee_client_notify_network_joined(_smee, networkID.c_str(), memberID.c_str()); + rustybits::smee_client_notify_network_joined(_smee, networkID.c_str(), memberID.c_str()); } void CV1::onlineNotificationThread() diff --git a/controller/CV1.hpp b/controller/CV1.hpp index b1a362798d..d267a73075 100644 --- a/controller/CV1.hpp +++ b/controller/CV1.hpp @@ -28,7 +28,7 @@ #include #include -namespace smeeclient { +namespace rustybits { struct SmeeClient; } @@ -134,7 +134,7 @@ class CV1 : public DB { std::shared_ptr _cluster; bool _redisMemberStatus; - smeeclient::SmeeClient* _smee; + rustybits::SmeeClient* _smee; }; } // namespace ZeroTier diff --git a/make-linux.mk b/make-linux.mk index 141607a4b1..18a5dc0470 100644 --- a/make-linux.mk +++ b/make-linux.mk @@ -14,6 +14,7 @@ DEFS?= LDLIBS?= DESTDIR?= EXTRA_DEPS?= +ZT_CARGO_FLAGS?= include objects.mk ifeq ($(ZT_EXTOSDEP),1) @@ -67,7 +68,6 @@ ifeq ($(ZT_DEBUG),1) override CFLAGS+=-Wall -Wno-deprecated -g -O -pthread $(INCLUDES) $(DEFS) override CXXFLAGS+=-Wall -Wno-deprecated -g -O -std=c++17 -pthread $(INCLUDES) $(DEFS) ZT_TRACE=1 - ZT_CARGO_FLAGS= # The following line enables optimization for the crypto code, since # C25519 in particular is almost UNUSABLE in -O0 even on a 3ghz box! node/Salsa20.o node/SHA512.o node/C25519.o node/Poly1305.o: CXXFLAGS=-Wall -O2 -g -pthread $(INCLUDES) $(DEFS) @@ -77,7 +77,7 @@ else CXXFLAGS?=-O3 -fstack-protector override CXXFLAGS+=-Wall -Wno-deprecated -std=c++17 -pthread $(INCLUDES) -DNDEBUG $(DEFS) LDFLAGS?=-pie -Wl,-z,relro,-z,now - ZT_CARGO_FLAGS=--release + ZT_CARGO_FLAGS+=--release endif ifeq ($(ZT_QNAP), 1) @@ -305,9 +305,9 @@ ifeq ($(ZT_SSO_SUPPORTED), 1) ifeq ($(ZT_EMBEDDED),) override DEFS+=-DZT_SSO_SUPPORTED=1 ifeq ($(ZT_DEBUG),1) - LDLIBS+=rustybits/target/debug/libzeroidc.a -ldl -lssl -lcrypto + LDLIBS+=rustybits/target/debug/librustybits.a -ldl -lssl -lcrypto else - LDLIBS+=rustybits/target/release/libzeroidc.a -ldl -lssl -lcrypto + LDLIBS+=rustybits/target/release/librustybits.a -ldl -lssl -lcrypto endif endif endif @@ -345,10 +345,11 @@ ifeq ($(ZT_CONTROLLER),1) override LDLIBS+=-Lext/libpqxx-7.7.3/install/ubuntu22.04/$(EXT_ARCH)/lib -lpqxx -lpq ext/hiredis-1.0.2/lib/ubuntu22.04/$(EXT_ARCH)/libhiredis.a ext/redis-plus-plus-1.3.3/install/ubuntu22.04/$(EXT_ARCH)/lib/libredis++.a -lssl -lcrypto override DEFS+=-DZT_CONTROLLER_USE_LIBPQ -DZT_NO_PEER_METRICS -DZT_OPENTELEMETRY_ENABLED override INCLUDES+=-I/usr/include/postgresql -Iext/libpqxx-7.7.3/install/ubuntu22.04/$(EXT_ARCH)/include -Iext/hiredis-1.0.2/include/ -Iext/redis-plus-plus-1.3.3/install/ubuntu22.04/$(EXT_ARCH)/include/sw/ + override ZT_CARGO_FLAGS+=-F ztcontroller ifeq ($(ZT_DEBUG),1) - override LDLIBS+=rustybits/target/debug/libsmeeclient.a + override LDLIBS+=rustybits/target/debug/librustybits.a else - override LDLIBS+=rustybits/target/release/libsmeeclient.a + override LDLIBS+=rustybits/target/release/librustybits.a endif endif @@ -409,7 +410,7 @@ zerotier-idtool: zerotier-one zerotier-cli: zerotier-one ln -sf zerotier-one zerotier-cli -$(ONE_OBJS): zeroidc smeeclient +$(ONE_OBJS): zeroidc rustybits libzerotiercore.a: FORCE make CFLAGS="-O3 -fstack-protector -fPIC" CXXFLAGS="-O3 -std=c++17 -fstack-protector -fPIC" $(CORE_OBJS) @@ -477,19 +478,12 @@ debug: FORCE ifeq ($(ZT_SSO_SUPPORTED), 1) ifeq ($(ZT_EMBEDDED),) zeroidc: FORCE - export PATH=/${HOME}/.cargo/bin:$$PATH; cd rustybits && cargo build $(ZT_CARGO_FLAGS) -p zeroidc + export PATH=/${HOME}/.cargo/bin:$$PATH; cd rustybits && cargo build $(ZT_CARGO_FLAGS) endif else zeroidc: endif -ifeq ($(ZT_CONTROLLER), 1) -smeeclient: FORCE - export PATH=/${HOME}/.cargo/bin:$$PATH; cd rustybits && cargo build $(ZT_CARGO_FLAGS) -p smeeclient -else -smeeclient: -endif - # Note: keep the symlinks in /var/lib/zerotier-one to the binaries since these # provide backward compatibility with old releases where the binaries actually # lived here. Folks got scripts. diff --git a/make-mac.mk b/make-mac.mk index 69bdf7d7ff..b8fd490d30 100644 --- a/make-mac.mk +++ b/make-mac.mk @@ -31,6 +31,8 @@ include objects.mk ONE_OBJS+=osdep/MacEthernetTap.o osdep/MacKextEthernetTap.o osdep/MacDNSHelper.o ext/http-parser/http_parser.o LIBS+=-framework CoreServices -framework SystemConfiguration -framework CoreFoundation -framework Security +EXTRA_CARGO_FLAGS?= + # Official releases are signed with our Apple cert and apply software updates by default ifeq ($(ZT_OFFICIAL_RELEASE),1) DEFS+=-DZT_SOFTWARE_UPDATE_DEFAULT="\"apply\"" @@ -57,9 +59,10 @@ ONE_OBJS+=ext/libnatpmp/natpmp.o ext/libnatpmp/getgateway.o ext/miniupnpc/connec ifeq ($(ZT_CONTROLLER),1) MACOS_VERSION_MIN=10.15 override CXXFLAGS=$(CFLAGS) -std=c++17 -stdlib=libc++ - LIBS+=-L/opt/homebrew/lib -L/usr/local/opt/libpqxx/lib -L/usr/local/opt/libpq/lib -L/usr/local/opt/openssl/lib/ -lpqxx -lpq -lssl -lcrypto -lgssapi_krb5 ext/redis-plus-plus-1.1.1/install/macos/lib/libredis++.a ext/hiredis-0.14.1/lib/macos/libhiredis.a rustybits/target/libsmeeclient.a + LIBS+=-L/opt/homebrew/lib -L/usr/local/opt/libpqxx/lib -L/usr/local/opt/libpq/lib -L/usr/local/opt/openssl/lib/ -lpqxx -lpq -lssl -lcrypto -lgssapi_krb5 ext/redis-plus-plus-1.1.1/install/macos/lib/libredis++.a ext/hiredis-0.14.1/lib/macos/libhiredis.a rustybits/target/librustybits.a DEFS+=-DZT_CONTROLLER_USE_LIBPQ -DZT_CONTROLLER_USE_REDIS -DZT_CONTROLLER INCLUDES+=-I/opt/homebrew/include -I/opt/homebrew/opt/libpq/include -I/usr/local/opt/libpq/include -I/usr/local/opt/libpqxx/include -Iext/hiredis-0.14.1/include/ -Iext/redis-plus-plus-1.1.1/install/macos/include/sw/ -Irustybits/target/ + EXTRA_CARGO_FLAGS+=-F ztcontroller else MACOS_VERSION_MIN=10.13 endif @@ -77,7 +80,6 @@ ifeq ($(ZT_DEBUG),1) ARCH_FLAGS= CFLAGS+=-Wall -g $(INCLUDES) $(DEFS) $(ARCH_FLAGS) STRIP=echo - EXTRA_CARGO_FLAGS= RUST_VARIANT=debug # The following line enables optimization for the crypto code, since # C25519 in particular is almost UNUSABLE in heavy testing without it. @@ -86,7 +88,7 @@ else CFLAGS?=-O3 -fstack-protector-strong CFLAGS+=$(ARCH_FLAGS) -Wall -flto -fPIE -mmacosx-version-min=$(MACOS_VERSION_MIN) -DNDEBUG -Wno-unused-private-field $(INCLUDES) $(DEFS) STRIP=strip - EXTRA_CARGO_FLAGS=--release + EXTRA_CARGO_FLAGS+=--release RUST_VARIANT=release endif @@ -131,7 +133,7 @@ one: otel zeroidc smeeclient $(CORE_OBJS) $(ONE_OBJS) one.o mac-agent else one: otel zeroidc $(CORE_OBJS) $(ONE_OBJS) one.o mac-agent endif - $(CXX) $(CXXFLAGS) -o zerotier-one $(CORE_OBJS) $(ONE_OBJS) one.o $(LIBS) rustybits/target/libzeroidc.a + $(CXX) $(CXXFLAGS) -o zerotier-one $(CORE_OBJS) $(ONE_OBJS) one.o $(LIBS) rustybits/target/librustybits.a # $(STRIP) zerotier-one ln -sf zerotier-one zerotier-idtool ln -sf zerotier-one zerotier-cli @@ -139,21 +141,21 @@ endif zerotier-one: one -zeroidc: rustybits/target/libzeroidc.a +rustybits: rustybits/target/rustybits.a -ifeq ($(ZT_CONTROLLER),1) -smeeclient: rustybits/target/libsmeeclient.a +# ifeq ($(ZT_CONTROLLER),1) +# smeeclient: rustybits/target/libsmeeclient.a -rustybits/target/libsmeeclient.a: FORCE - cd rustybits && MACOSX_DEPLOYMENT_TARGET=$(MACOS_VERSION_MIN) cargo build -p smeeclient --target=x86_64-apple-darwin $(EXTRA_CARGO_FLAGS) - cd rustybits && MACOSX_DEPLOYMENT_TARGET=$(MACOS_VERSION_MIN) cargo build -p smeeclient --target=aarch64-apple-darwin $(EXTRA_CARGO_FLAGS) - cd rustybits && lipo -create target/x86_64-apple-darwin/$(RUST_VARIANT)/libsmeeclient.a target/aarch64-apple-darwin/$(RUST_VARIANT)/libsmeeclient.a -output target/libsmeeclient.a -endif +# rustybits/target/libsmeeclient.a: FORCE +# cd rustybits && MACOSX_DEPLOYMENT_TARGET=$(MACOS_VERSION_MIN) cargo build -F smeeclient --target=x86_64-apple-darwin $(EXTRA_CARGO_FLAGS) +# cd rustybits && MACOSX_DEPLOYMENT_TARGET=$(MACOS_VERSION_MIN) cargo build -F smeeclient --target=aarch64-apple-darwin $(EXTRA_CARGO_FLAGS) +# cd rustybits && lipo -create target/x86_64-apple-darwin/$(RUST_VARIANT)/libsmeeclient.a target/aarch64-apple-darwin/$(RUST_VARIANT)/libsmeeclient.a -output target/libsmeeclient.a +# endif -rustybits/target/libzeroidc.a: FORCE - cd rustybits && MACOSX_DEPLOYMENT_TARGET=$(MACOS_VERSION_MIN) cargo build -p zeroidc --target=x86_64-apple-darwin $(EXTRA_CARGO_FLAGS) - cd rustybits && MACOSX_DEPLOYMENT_TARGET=$(MACOS_VERSION_MIN) cargo build -p zeroidc --target=aarch64-apple-darwin $(EXTRA_CARGO_FLAGS) - cd rustybits && lipo -create target/x86_64-apple-darwin/$(RUST_VARIANT)/libzeroidc.a target/aarch64-apple-darwin/$(RUST_VARIANT)/libzeroidc.a -output target/libzeroidc.a +rustybits/target/rustybits.a: FORCE + cd rustybits && MACOSX_DEPLOYMENT_TARGET=$(MACOS_VERSION_MIN) cargo build --target=x86_64-apple-darwin $(EXTRA_CARGO_FLAGS) + cd rustybits && MACOSX_DEPLOYMENT_TARGET=$(MACOS_VERSION_MIN) cargo build --target=aarch64-apple-darwin $(EXTRA_CARGO_FLAGS) + cd rustybits && lipo -create target/x86_64-apple-darwin/$(RUST_VARIANT)/librustybits.a target/aarch64-apple-darwin/$(RUST_VARIANT)/librustybits.a -output target/librustybits.a central-controller: make ARCH_FLAGS="-arch x86_64" ZT_CONTROLLER=1 one @@ -175,7 +177,7 @@ core: libzerotiercore.a # $(STRIP) zerotier selftest: $(CORE_OBJS) $(ONE_OBJS) selftest.o - $(CXX) $(CXXFLAGS) -o zerotier-selftest selftest.o $(CORE_OBJS) $(ONE_OBJS) $(LIBS) rustybits/target/libzeroidc.a + $(CXX) $(CXXFLAGS) -o zerotier-selftest selftest.o $(CORE_OBJS) $(ONE_OBJS) $(LIBS) rustybits/target/librustybits.a $(STRIP) zerotier-selftest zerotier-selftest: selftest diff --git a/rustybits/Cargo.lock b/rustybits/Cargo.lock index 68835bddd1..86b692b3fc 100644 --- a/rustybits/Cargo.lock +++ b/rustybits/Cargo.lock @@ -48,12 +48,18 @@ dependencies = [ ] [[package]] -name = "ansi_term" -version = "0.12.1" +name = "anstream" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192" dependencies = [ - "winapi", + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", ] [[package]] @@ -62,6 +68,35 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2" +dependencies = [ + "windows-sys 0.60.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.60.2", +] + [[package]] name = "anyhow" version = "1.0.98" @@ -76,7 +111,7 @@ checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -85,17 +120,6 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.5.0" @@ -244,19 +268,19 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "cbindgen" -version = "0.20.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e3973b165dc0f435831a9e426de67e894de532754ff7a3f307c03ee5dec7dc" +checksum = "975982cdb7ad6a142be15bdf84aea7ec6a9e5d4d797c004d43185b24cfe4e684" dependencies = [ "clap", - "heck 0.3.3", - "indexmap 1.9.3", + "heck", + "indexmap 2.10.0", "log", "proc-macro2", "quote", "serde", "serde_json", - "syn 1.0.109", + "syn", "tempfile", "toml", ] @@ -293,19 +317,37 @@ dependencies = [ [[package]] name = "clap" -version = "2.34.0" +version = "4.5.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +checksum = "ed87a9d530bb41a67537289bafcac159cb3ee28460e0a4571123d2a778a6a882" dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.5.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64f4f3f3c77c94aff3c7e9aac9a2ca1974a5adf392a8bb751e827d6d127ab966" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", ] +[[package]] +name = "clap_lex" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" + +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + [[package]] name = "const-oid" version = "0.9.6" @@ -417,7 +459,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -440,8 +482,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.11.1", - "syn 2.0.104", + "strsim", + "syn", ] [[package]] @@ -452,7 +494,7 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -508,7 +550,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -518,7 +560,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.104", + "syn", ] [[package]] @@ -538,7 +580,7 @@ checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", "unicode-xid", ] @@ -562,7 +604,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -668,7 +710,7 @@ checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -680,7 +722,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -835,7 +877,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -1024,30 +1066,12 @@ dependencies = [ "foldhash", ] -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hex" version = "0.4.3" @@ -1426,6 +1450,12 @@ version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.10.5" @@ -1602,7 +1632,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -1747,6 +1777,12 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +[[package]] +name = "once_cell_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" + [[package]] name = "openidconnect" version = "3.5.0" @@ -1802,7 +1838,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -1950,7 +1986,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -2064,7 +2100,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "061c1221631e079b26479d25bbf2275bfe5917ae8419cd7e34f13bfc2aa7539a" dependencies = [ "proc-macro2", - "syn 2.0.104", + "syn", ] [[package]] @@ -2101,7 +2137,7 @@ version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be769465445e8c1474e9c5dac2018218498557af32d9ed057325ec9a41ae81bf" dependencies = [ - "heck 0.5.0", + "heck", "itertools 0.14.0", "log", "multimap", @@ -2111,7 +2147,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.104", + "syn", "tempfile", ] @@ -2125,7 +2161,7 @@ dependencies = [ "itertools 0.14.0", "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -2158,7 +2194,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07b8bf115b70a7aa5af1fd5d6e9418492e9ccb6e4785e858c938e28d132a884b" dependencies = [ - "heck 0.5.0", + "heck", "prost", "prost-build", "prost-types", @@ -2307,7 +2343,7 @@ checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -2482,7 +2518,7 @@ dependencies = [ "proc-macro2", "quote", "rustfsm_trait", - "syn 2.0.104", + "syn", ] [[package]] @@ -2565,6 +2601,27 @@ version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" +[[package]] +name = "rustybits" +version = "0.1.0" +dependencies = [ + "base64 0.21.7", + "bytes", + "cbindgen", + "jwt", + "openidconnect", + "reqwest", + "serde", + "temporal-client", + "temporal-sdk", + "temporal-sdk-core-protos", + "thiserror 1.0.69", + "time", + "tokio", + "url", + "uuid", +] + [[package]] name = "ryu" version = "1.0.20" @@ -2693,7 +2750,7 @@ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -2727,6 +2784,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -2768,7 +2834,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -2843,20 +2909,6 @@ version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" -[[package]] -name = "smeeclient" -version = "0.1.0" -dependencies = [ - "cbindgen", - "serde", - "temporal-client", - "temporal-sdk", - "temporal-sdk-core-protos", - "tokio", - "url", - "uuid", -] - [[package]] name = "socket2" version = "0.5.10" @@ -2898,12 +2950,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "strsim" version = "0.11.1" @@ -2916,17 +2962,6 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.104" @@ -2958,7 +2993,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -3157,15 +3192,6 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thiserror" version = "1.0.69" @@ -3192,7 +3218,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -3203,7 +3229,7 @@ checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -3284,7 +3310,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -3333,13 +3359,45 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.11" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ + "indexmap 2.10.0", "serde", + "serde_spanned", + "toml_datetime", + "toml_write", + "winnow", ] +[[package]] +name = "toml_write" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" + [[package]] name = "tonic" version = "0.13.1" @@ -3382,7 +3440,7 @@ dependencies = [ "prost-build", "prost-types", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -3435,7 +3493,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -3504,7 +3562,7 @@ checksum = "35f5380909ffc31b4de4f4bdf96b877175a016aa2ca98cee39fcfd8c4d53d952" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -3513,18 +3571,6 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" -[[package]] -name = "unicode-segmentation" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" - -[[package]] -name = "unicode-width" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" - [[package]] name = "unicode-xid" version = "0.2.6" @@ -3555,6 +3601,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "uuid" version = "1.17.0" @@ -3578,12 +3630,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.5" @@ -3636,7 +3682,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.104", + "syn", "wasm-bindgen-shared", ] @@ -3671,7 +3717,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3770,7 +3816,7 @@ checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -3781,7 +3827,7 @@ checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -3792,7 +3838,7 @@ checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -3803,7 +3849,7 @@ checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -4060,6 +4106,15 @@ version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" +[[package]] +name = "winnow" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3edebf492c8125044983378ecb5766203ad3b4c2f7a922bd7dd207f6d443e95" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" @@ -4105,7 +4160,7 @@ checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", "synstructure", ] @@ -4126,7 +4181,7 @@ checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] [[package]] @@ -4146,27 +4201,10 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", "synstructure", ] -[[package]] -name = "zeroidc" -version = "0.1.0" -dependencies = [ - "base64 0.21.7", - "bytes", - "cbindgen", - "jwt", - "openidconnect", - "reqwest", - "serde", - "thiserror 1.0.69", - "time", - "tokio", - "url", -] - [[package]] name = "zeroize" version = "1.8.1" @@ -4203,5 +4241,5 @@ checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.104", + "syn", ] diff --git a/rustybits/Cargo.toml b/rustybits/Cargo.toml index 3de3522173..7467de3b39 100644 --- a/rustybits/Cargo.toml +++ b/rustybits/Cargo.toml @@ -1,6 +1,40 @@ -[workspace] -resolver = "2" -members = ["smeeclient", "zeroidc"] +[package] +name = "rustybits" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["staticlib", "rlib"] + +[features] +default = ["zeroidc"] +zeroidc = [] +ztcontroller = [] + +[dependencies] +serde = { version = "1", features = ["derive"] } +temporal-sdk = { git = "https://github.com/temporalio/sdk-core", branch = "master" } +temporal-client = { git = "https://github.com/temporalio/sdk-core", branch = "master", features = [ + "telemetry", +] } +temporal-sdk-core-protos = { git = "https://github.com/temporalio/sdk-core", branch = "master" } +tokio = { version = "1.43", features = ["full"] } +uuid = { version = "1.4", features = ["v4"] } +openidconnect = { version = "3.4", default-features = false, features = [ + "reqwest", + "native-tls", + "accept-rfc3339-timestamps", +] } +base64 = "0.21" +url = "2.3" +reqwest = "0.11" +jwt = { version = "0.16", git = "https://github.com/glimberg/rust-jwt" } +time = { version = "~0.3", features = ["formatting"] } +bytes = "1.3" +thiserror = "1" + +[build-dependencies] +cbindgen = "0.29" [profile.release] strip = "debuginfo" diff --git a/rustybits/smeeclient/build.rs b/rustybits/build.rs similarity index 72% rename from rustybits/smeeclient/build.rs rename to rustybits/build.rs index 73e97bcc6b..be7973db1b 100644 --- a/rustybits/smeeclient/build.rs +++ b/rustybits/build.rs @@ -1,6 +1,6 @@ extern crate cbindgen; -use cbindgen::{Config, Language}; +use cbindgen::{Config, Language, MacroExpansionConfig}; use std::env; use std::path::PathBuf; @@ -10,10 +10,13 @@ fn main() { let package_name = env::var("CARGO_PKG_NAME").unwrap(); let output_file = target_dir().join(format!("{package_name}.h")).display().to_string(); + let meconfig = MacroExpansionConfig { bitflags: true, ..Default::default() }; + let config = Config { language: Language::C, cpp_compat: true, - namespace: Some(String::from("smeeclient")), + namespace: Some(String::from("rustybits")), + macro_expansion: meconfig, ..Default::default() }; @@ -29,8 +32,6 @@ fn target_dir() -> PathBuf { if let Ok(target) = env::var("CARGO_TARGET_DIR") { PathBuf::from(target) } else { - PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()) - .join("..") - .join("target") + PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("target") } } diff --git a/rustybits/smeeclient/Cargo.lock b/rustybits/smeeclient/Cargo.lock new file mode 100644 index 0000000000..a7eafe6f8c --- /dev/null +++ b/rustybits/smeeclient/Cargo.lock @@ -0,0 +1,2998 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anstyle" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" + +[[package]] +name = "anyhow" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" + +[[package]] +name = "async-trait" +version = "0.1.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "axum" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "021e862c184ae977658b36c4500f7feac3221ca5da43e3f25bd04ab6c79a29b5" +dependencies = [ + "axum-core", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68464cd0412f486726fb3373129ef5d2993f90c34bc2bc1c1e9943b2f4fc7ca6" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper", + "tower-layer", + "tower-service", +] + +[[package]] +name = "backoff" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62ddb9cb1ec0a098ad4bbf9344d0713fa193ae1a80af55febcff2627b6a00c1" +dependencies = [ + "getrandom 0.2.16", + "instant", + "rand 0.8.5", +] + +[[package]] +name = "backtrace" +version = "0.3.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets 0.52.6", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" + +[[package]] +name = "bumpalo" +version = "3.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" + +[[package]] +name = "bytes" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" + +[[package]] +name = "cbindgen" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51e3973b165dc0f435831a9e426de67e894de532754ff7a3f307c03ee5dec7dc" +dependencies = [ + "clap", + "heck 0.3.3", + "indexmap 1.9.3", + "log", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn 1.0.109", + "tempfile", + "toml", +] + +[[package]] +name = "cc" +version = "1.2.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3a42d84bb6b69d3a8b3eaacf0d88f179e1929695e1ad012b6cf64d9caaa5fd2" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" + +[[package]] +name = "chrono" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +dependencies = [ + "num-traits", + "serde", +] + +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +dependencies = [ + "ansi_term", + "atty", + "bitflags 1.3.2", + "strsim 0.8.0", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "crossbeam-channel" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-queue" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "darling" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.11.1", + "syn 2.0.104", +] + +[[package]] +name = "darling_macro" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "dashmap" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", +] + +[[package]] +name = "derive_builder" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "derive_builder_macro" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" +dependencies = [ + "derive_builder_core", + "syn 2.0.104", +] + +[[package]] +name = "derive_more" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", + "unicode-xid", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "downcast" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "enum-iterator" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c280b9e6b3ae19e152d8e31cf47f18389781e119d4013a2a2bb0180e5facc635" +dependencies = [ + "enum-iterator-derive", +] + +[[package]] +name = "enum-iterator-derive" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "enum_dispatch" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa18ce2bc66555b3218614519ac839ddb759a7d6720732f979ef8d13be147ecd" +dependencies = [ + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "erased-serde" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e004d887f51fcb9fef17317a2f3525c887d8aa3f4f50fed920816a688284a5b7" +dependencies = [ + "serde", + "typeid", +] + +[[package]] +name = "errno" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" +dependencies = [ + "libc", + "windows-sys 0.60.2", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fragile" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dd6caf6059519a65843af8fe2a3ae298b14b80179855aeb4adc2c1934ee619" + +[[package]] +name = "futures" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-executor" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-macro" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "futures-retry" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fde5a672a61f96552aa5ed9fd9c81c3fbdae4be9b1e205d6eaf17c83705adc0f" +dependencies = [ + "futures", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-timer" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "gethostname" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc257fdb4038301ce4b9cd1b3b51704509692bb3ff716a410cbd07925d9dae55" +dependencies = [ + "rustix", + "windows-targets 0.52.6", +] + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.1+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", + "wasm-bindgen", +] + +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + +[[package]] +name = "governor" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be93b4ec2e4710b04d9264c0c7350cdd62a8c20e5e4ac732552ebb8f0debe8eb" +dependencies = [ + "cfg-if", + "dashmap", + "futures-sink", + "futures-timer", + "futures-util", + "getrandom 0.3.3", + "no-std-compat", + "nonzero_ext", + "parking_lot", + "portable-atomic", + "quanta", + "rand 0.9.2", + "smallvec", + "spinning_top", + "web-time", +] + +[[package]] +name = "h2" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17da50a276f1e01e0ba6c029e47b7100754904ee8a278f886546e98575380785" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap 2.10.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "hashbrown" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "http" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-timeout" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" +dependencies = [ + "hyper", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d9b05277c7e8da2c93a568989bb6207bef0112e8d17df7a6eda4a3cf143bc5e" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "hyper", + "libc", + "pin-project-lite", + "socket2 0.6.0", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "icu_collections" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3" + +[[package]] +name = "icu_properties" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "potential_utf", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632" + +[[package]] +name = "icu_provider" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af" +dependencies = [ + "displaydoc", + "icu_locale_core", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" +dependencies = [ + "equivalent", + "hashbrown 0.15.4", +] + +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "inventory" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab08d7cd2c5897f2c949e5383ea7c7db03fb19130ffcfbf7eda795137ae3cb83" +dependencies = [ + "rustversion", +] + +[[package]] +name = "io-uring" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d93587f37623a1a17d94ef2bc9ada592f5465fe7732084ab7beefabe5c77c0c4" +dependencies = [ + "bitflags 2.9.1", + "cfg-if", + "libc", +] + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "js-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.174" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" + +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + +[[package]] +name = "litemap" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" + +[[package]] +name = "lock_api" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" + +[[package]] +name = "lru" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "227748d55f2f0ab4735d87fd623798cb6b664512fe979705f829c9f81c934465" +dependencies = [ + "hashbrown 0.15.4", +] + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + +[[package]] +name = "matchit" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + +[[package]] +name = "memchr" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" +dependencies = [ + "libc", + "wasi 0.11.1+wasi-snapshot-preview1", + "windows-sys 0.59.0", +] + +[[package]] +name = "mockall" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39a6bfcc6c8c7eed5ee98b9c3e33adc726054389233e201c95dab2d41a3839d2" +dependencies = [ + "cfg-if", + "downcast", + "fragile", + "mockall_derive", + "predicates", + "predicates-tree", +] + +[[package]] +name = "mockall_derive" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25ca3004c2efe9011bd4e461bd8256445052b9615405b4f7ea43fc8ca5c20898" +dependencies = [ + "cfg-if", + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "multimap" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" + +[[package]] +name = "no-std-compat" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c" + +[[package]] +name = "nonzero_ext" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38bf9645c8b145698bb0b18a4637dcacbc421ea49bef2317e4fd8065a387cf21" + +[[package]] +name = "ntapi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" +dependencies = [ + "winapi", +] + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.36.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "openssl-probe" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" + +[[package]] +name = "opentelemetry" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaf416e4cb72756655126f7dd7bb0af49c674f4c1b9903e80c009e0c37e552e6" +dependencies = [ + "futures-core", + "futures-sink", + "js-sys", + "pin-project-lite", + "thiserror", + "tracing", +] + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "parking_lot" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.6", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "petgraph" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" +dependencies = [ + "fixedbitset", + "indexmap 2.10.0", +] + +[[package]] +name = "pid" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c931ef9756cd5e3fa3d395bfe09df4dfa6f0612c6ca8f6b12927d17ca34e36" +dependencies = [ + "num-traits", +] + +[[package]] +name = "pin-project" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "portable-atomic" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" + +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "potential_utf" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5a7c30837279ca13e7c867e9e40053bc68740f988cb07f7ca6df43cc734b585" +dependencies = [ + "zerovec", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "predicates" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5d19ee57562043d37e82899fade9a22ebab7be9cef5026b07fda9cdd4293573" +dependencies = [ + "anstyle", + "predicates-core", +] + +[[package]] +name = "predicates-core" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "727e462b119fe9c93fd0eb1429a5f7647394014cf3c04ab2c0350eeb09095ffa" + +[[package]] +name = "predicates-tree" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72dd2d6d381dfb73a193c7fca536518d7caee39fc8503f74e7dc0be0531b425c" +dependencies = [ + "predicates-core", + "termtree", +] + +[[package]] +name = "prettyplease" +version = "0.2.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff24dfcda44452b9816fff4cd4227e1bb73ff5a2f1bc1105aa92fb8565ce44d2" +dependencies = [ + "proc-macro2", + "syn 2.0.104", +] + +[[package]] +name = "proc-macro2" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be769465445e8c1474e9c5dac2018218498557af32d9ed057325ec9a41ae81bf" +dependencies = [ + "heck 0.5.0", + "itertools", + "log", + "multimap", + "once_cell", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "regex", + "syn 2.0.104", + "tempfile", +] + +[[package]] +name = "prost-derive" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "prost-types" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52c2c1bf36ddb1a1c396b3601a3cec27c2462e45f07c386894ec3ccf5332bd16" +dependencies = [ + "prost", +] + +[[package]] +name = "prost-wkt" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497e1e938f0c09ef9cabe1d49437b4016e03e8f82fbbe5d1c62a9b61b9decae1" +dependencies = [ + "chrono", + "inventory", + "prost", + "serde", + "serde_derive", + "serde_json", + "typetag", +] + +[[package]] +name = "prost-wkt-build" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07b8bf115b70a7aa5af1fd5d6e9418492e9ccb6e4785e858c938e28d132a884b" +dependencies = [ + "heck 0.5.0", + "prost", + "prost-build", + "prost-types", + "quote", +] + +[[package]] +name = "prost-wkt-types" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8cdde6df0a98311c839392ca2f2f0bcecd545f86a62b4e3c6a49c336e970fe5" +dependencies = [ + "chrono", + "prost", + "prost-build", + "prost-types", + "prost-wkt", + "prost-wkt-build", + "regex", + "serde", + "serde_derive", + "serde_json", +] + +[[package]] +name = "quanta" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3ab5a9d756f0d97bdc89019bd2e4ea098cf9cde50ee7564dde6b81ccc8f06c7" +dependencies = [ + "crossbeam-utils", + "libc", + "once_cell", + "raw-cpuid", + "wasi 0.11.1+wasi-snapshot-preview1", + "web-sys", + "winapi", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.16", +] + +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.3", +] + +[[package]] +name = "raw-cpuid" +version = "11.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6df7ab838ed27997ba19a4664507e6f82b41fe6e20be42929332156e5e85146" +dependencies = [ + "bitflags 2.9.1", +] + +[[package]] +name = "redox_syscall" +version = "0.5.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" +dependencies = [ + "bitflags 2.9.1", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata 0.4.9", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.16", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "ringbuf" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe47b720588c8702e34b5979cb3271a8b1842c7cb6f57408efa70c779363488c" +dependencies = [ + "crossbeam-utils", + "portable-atomic", + "portable-atomic-util", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" + +[[package]] +name = "rustfsm" +version = "0.1.0" +source = "git+https://github.com/temporalio/sdk-core?branch=master#45687c309cfaec0d6e5d6542fdb6942eaae03180" +dependencies = [ + "rustfsm_procmacro", + "rustfsm_trait", +] + +[[package]] +name = "rustfsm_procmacro" +version = "0.1.0" +source = "git+https://github.com/temporalio/sdk-core?branch=master#45687c309cfaec0d6e5d6542fdb6942eaae03180" +dependencies = [ + "derive_more", + "proc-macro2", + "quote", + "rustfsm_trait", + "syn 2.0.104", +] + +[[package]] +name = "rustfsm_trait" +version = "0.1.0" +source = "git+https://github.com/temporalio/sdk-core?branch=master#45687c309cfaec0d6e5d6542fdb6942eaae03180" + +[[package]] +name = "rustix" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8" +dependencies = [ + "bitflags 2.9.1", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.60.2", +] + +[[package]] +name = "rustls" +version = "0.23.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ebcbd2f03de0fc1122ad9bb24b127a5a6cd51d72604a3f3c50ac459762b6cc" +dependencies = [ + "log", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pki-types" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a17884ae0c1b773f1ccd2bd4a8c72f16da897310a98b0e84bf349ad5ead92fc" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "schannel" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "security-framework" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316" +dependencies = [ + "bitflags 2.9.1", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "serde_json" +version = "1.0.142" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" +dependencies = [ + "libc", +] + +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + +[[package]] +name = "slab" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" + +[[package]] +name = "slotmap" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbff4acf519f630b3a3ddcfaea6c06b42174d9a44bc70c620e9ed1649d58b82a" +dependencies = [ + "version_check", +] + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "smeeclient" +version = "0.1.0" +dependencies = [ + "cbindgen", + "serde", + "temporal-client", + "temporal-sdk", + "temporal-sdk-core-protos", + "tokio", + "url", + "uuid", +] + +[[package]] +name = "socket2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "socket2" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "spinning_top" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96d2d1d716fb500937168cc09353ffdc7a012be8475ac7308e1bdf0e3923300" +dependencies = [ + "lock_api", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "sysinfo" +version = "0.33.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fc858248ea01b66f19d8e8a6d55f41deaf91e9d495246fd01368d99935c6c01" +dependencies = [ + "core-foundation-sys", + "libc", + "memchr", + "ntapi", + "windows", +] + +[[package]] +name = "tempfile" +version = "3.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" +dependencies = [ + "fastrand", + "getrandom 0.3.3", + "once_cell", + "rustix", + "windows-sys 0.59.0", +] + +[[package]] +name = "temporal-client" +version = "0.1.0" +source = "git+https://github.com/temporalio/sdk-core?branch=master#45687c309cfaec0d6e5d6542fdb6942eaae03180" +dependencies = [ + "anyhow", + "async-trait", + "backoff", + "base64", + "bytes", + "derive_builder", + "derive_more", + "futures-retry", + "futures-util", + "http", + "http-body-util", + "hyper", + "hyper-util", + "opentelemetry", + "parking_lot", + "slotmap", + "temporal-sdk-core-api", + "temporal-sdk-core-protos", + "thiserror", + "tokio", + "tonic", + "tower", + "tracing", + "url", + "uuid", +] + +[[package]] +name = "temporal-sdk" +version = "0.1.0-alpha.1" +source = "git+https://github.com/temporalio/sdk-core?branch=master#45687c309cfaec0d6e5d6542fdb6942eaae03180" +dependencies = [ + "anyhow", + "async-trait", + "derive_more", + "futures-util", + "parking_lot", + "prost-wkt-types", + "serde", + "temporal-client", + "temporal-sdk-core", + "temporal-sdk-core-api", + "temporal-sdk-core-protos", + "tokio", + "tokio-stream", + "tokio-util", + "tracing", +] + +[[package]] +name = "temporal-sdk-core" +version = "0.1.0" +source = "git+https://github.com/temporalio/sdk-core?branch=master#45687c309cfaec0d6e5d6542fdb6942eaae03180" +dependencies = [ + "anyhow", + "async-trait", + "crossbeam-channel", + "crossbeam-queue", + "crossbeam-utils", + "dashmap", + "derive_builder", + "derive_more", + "enum-iterator", + "enum_dispatch", + "futures-channel", + "futures-util", + "gethostname", + "governor", + "itertools", + "lru", + "mockall", + "parking_lot", + "pid", + "pin-project", + "prost", + "prost-wkt-types", + "rand 0.9.2", + "ringbuf", + "rustfsm", + "serde", + "serde_json", + "siphasher", + "slotmap", + "sysinfo", + "temporal-client", + "temporal-sdk-core-api", + "temporal-sdk-core-protos", + "thiserror", + "tokio", + "tokio-stream", + "tokio-util", + "tonic", + "tracing", + "tracing-subscriber", + "url", + "uuid", +] + +[[package]] +name = "temporal-sdk-core-api" +version = "0.1.0" +source = "git+https://github.com/temporalio/sdk-core?branch=master#45687c309cfaec0d6e5d6542fdb6942eaae03180" +dependencies = [ + "async-trait", + "derive_builder", + "derive_more", + "opentelemetry", + "prost", + "serde_json", + "temporal-sdk-core-protos", + "thiserror", + "tonic", + "tracing", + "tracing-core", + "url", +] + +[[package]] +name = "temporal-sdk-core-protos" +version = "0.1.0" +source = "git+https://github.com/temporalio/sdk-core?branch=master#45687c309cfaec0d6e5d6542fdb6942eaae03180" +dependencies = [ + "anyhow", + "base64", + "derive_more", + "prost", + "prost-build", + "prost-wkt", + "prost-wkt-build", + "prost-wkt-types", + "rand 0.9.2", + "serde", + "serde_json", + "thiserror", + "tonic", + "tonic-build", + "uuid", +] + +[[package]] +name = "termtree" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "thiserror" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "thread_local" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "tinystr" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.47.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038" +dependencies = [ + "backtrace", + "bytes", + "io-uring", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "slab", + "socket2 0.6.0", + "tokio-macros", + "windows-sys 0.59.0", +] + +[[package]] +name = "tokio-macros" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "tonic" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e581ba15a835f4d9ea06c55ab1bd4dce26fc53752c69a04aac00703bfb49ba9" +dependencies = [ + "async-trait", + "axum", + "base64", + "bytes", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-timeout", + "hyper-util", + "percent-encoding", + "pin-project", + "prost", + "rustls-native-certs", + "socket2 0.5.10", + "tokio", + "tokio-rustls", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic-build" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac6f67be712d12f0b41328db3137e0d0757645d8904b4cb7d51cd9c2279e847" +dependencies = [ + "prettyplease", + "proc-macro2", + "prost-build", + "prost-types", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "indexmap 2.10.0", + "pin-project-lite", + "slab", + "sync_wrapper", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "tracing-core" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "parking_lot", + "regex", + "sharded-slab", + "thread_local", + "tracing", + "tracing-core", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "typeid" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" + +[[package]] +name = "typetag" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f22b40dd7bfe8c14230cf9702081366421890435b2d625fa92b4acc4c3de6f" +dependencies = [ + "erased-serde", + "inventory", + "once_cell", + "serde", + "typetag-impl", +] + +[[package]] +name = "typetag-impl" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35f5380909ffc31b4de4f4bdf96b877175a016aa2ca98cee39fcfd8c4d53d952" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d" +dependencies = [ + "getrandom 0.3.3", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn 2.0.104", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143" +dependencies = [ + "windows-core", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-core" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-result", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-implement" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "windows-interface" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-result" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.3", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags 2.9.1", +] + +[[package]] +name = "writeable" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" + +[[package]] +name = "yoke" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zerotrie" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdbb9122ea75b11bf96e7492afb723e8a7fbe12c67417aa95e7e3d18144d37cd" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] diff --git a/rustybits/smeeclient/Cargo.toml b/rustybits/smeeclient/Cargo.toml deleted file mode 100644 index 6f32da35d6..0000000000 --- a/rustybits/smeeclient/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "smeeclient" -version = "0.1.0" -edition = "2021" - -[lib] -crate-type = ["staticlib", "rlib"] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -serde = { version = "1", features = ["derive"] } -temporal-sdk = { git = "https://github.com/temporalio/sdk-core", branch = "master" } -temporal-client = { git = "https://github.com/temporalio/sdk-core", branch = "master", features = ["telemetry"] } -temporal-sdk-core-protos = { git = "https://github.com/temporalio/sdk-core", branch = "master" } -tokio = { version = "1.43", features = ["full"] } -url = { version = "2" } -uuid = { version = "1.4", features = ["v4"] } - -[build-dependencies] -cbindgen = "0.20" diff --git a/rustybits/smeeclient/rustfmt.toml b/rustybits/smeeclient/rustfmt.toml deleted file mode 120000 index 39f97b043b..0000000000 --- a/rustybits/smeeclient/rustfmt.toml +++ /dev/null @@ -1 +0,0 @@ -../rustfmt.toml \ No newline at end of file diff --git a/rustybits/smeeclient/src/ext.rs b/rustybits/smeeclient/src/ext.rs deleted file mode 100644 index b5517d8662..0000000000 --- a/rustybits/smeeclient/src/ext.rs +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c)2021 ZeroTier, Inc. - * - * Use of this software is governed by the Business Source License included - * in the LICENSE.TXT file in the project's root directory. - * - * Change Date: 2026-01-01 - * - * On the date above, in accordance with the Business Source License, use - * of this software will be governed by version 2.0 of the Apache License. - */ - -#![allow(clippy::uninlined_format_args, clippy::missing_safety_doc)] - -use std::ffi::CStr; -use std::os::raw::c_char; - -use crate::NetworkJoinedParams; -use crate::SmeeClient; - -#[no_mangle] -pub unsafe extern "C" fn smee_client_new( - temporal_url: *const c_char, - namespace: *const c_char, - task_queue: *const c_char, -) -> *mut SmeeClient { - let url = unsafe { - assert!(!temporal_url.is_null()); - CStr::from_ptr(temporal_url).to_str().unwrap() - }; - - let ns = unsafe { - assert!(!namespace.is_null()); - CStr::from_ptr(namespace).to_str().unwrap() - }; - - let tq = unsafe { - assert!(!task_queue.is_null()); - CStr::from_ptr(task_queue).to_str().unwrap() - }; - - match SmeeClient::new(url, ns, tq) { - Ok(c) => Box::into_raw(Box::new(c)), - Err(e) => { - println!("error creating smee client instance: {}", e); - std::ptr::null_mut() - } - } -} - -#[no_mangle] -pub unsafe extern "C" fn smee_client_delete(ptr: *mut SmeeClient) { - if ptr.is_null() { - return; - } - let smee = unsafe { - assert!(!ptr.is_null()); - Box::from_raw(&mut *ptr) - }; - - smee.shutdown(); -} - -#[no_mangle] -pub unsafe extern "C" fn smee_client_notify_network_joined( - smee_instance: *mut SmeeClient, - network_id: *const c_char, - member_id: *const c_char, -) -> bool { - let nwid = unsafe { - assert!(!network_id.is_null()); - CStr::from_ptr(network_id).to_str().unwrap() - }; - - let mem_id = unsafe { - assert!(!member_id.is_null()); - CStr::from_ptr(member_id).to_str().unwrap() - }; - - let smee = unsafe { - assert!(!smee_instance.is_null()); - &mut *smee_instance - }; - - let params = NetworkJoinedParams::new(nwid, mem_id); - - match smee.notify_network_joined(params) { - Ok(()) => true, - Err(e) => { - println!("error notifying network joined: {0}", e); - false - } - } -} diff --git a/rustybits/zeroidc/src/ext.rs b/rustybits/src/ext.rs similarity index 55% rename from rustybits/zeroidc/src/ext.rs rename to rustybits/src/ext.rs index f0ba8b4b45..67fe2c6c32 100644 --- a/rustybits/zeroidc/src/ext.rs +++ b/rustybits/src/ext.rs @@ -14,14 +14,18 @@ use std::ffi::{CStr, CString}; use std::os::raw::c_char; use url::Url; -use crate::ZeroIDC; - -#[cfg(any( - all(target_os = "linux", target_arch = "x86"), - all(target_os = "linux", target_arch = "x86_64"), - all(target_os = "linux", target_arch = "aarch64"), - target_os = "windows", - target_os = "macos", +#[cfg(feature = "zeroidc")] +use crate::zeroidc::ZeroIDC; + +#[cfg(all( + feature = "zeroidc", + any( + all(target_os = "linux", target_arch = "x86"), + all(target_os = "linux", target_arch = "x86_64"), + all(target_os = "linux", target_arch = "aarch64"), + target_os = "windows", + target_os = "macos", + ) ))] #[no_mangle] pub unsafe extern "C" fn zeroidc_new( @@ -70,12 +74,15 @@ pub unsafe extern "C" fn zeroidc_new( } } -#[cfg(any( - all(target_os = "linux", target_arch = "x86"), - all(target_os = "linux", target_arch = "x86_64"), - all(target_os = "linux", target_arch = "aarch64"), - target_os = "windows", - target_os = "macos", +#[cfg(all( + feature = "zeroidc", + any( + all(target_os = "linux", target_arch = "x86"), + all(target_os = "linux", target_arch = "x86_64"), + all(target_os = "linux", target_arch = "aarch64"), + target_os = "windows", + target_os = "macos", + ) ))] #[no_mangle] pub unsafe extern "C" fn zeroidc_delete(ptr: *mut ZeroIDC) { @@ -93,12 +100,15 @@ pub unsafe extern "C" fn zeroidc_delete(ptr: *mut ZeroIDC) { } } -#[cfg(any( - all(target_os = "linux", target_arch = "x86"), - all(target_os = "linux", target_arch = "x86_64"), - all(target_os = "linux", target_arch = "aarch64"), - target_os = "windows", - target_os = "macos", +#[cfg(all( + feature = "zeroidc", + any( + all(target_os = "linux", target_arch = "x86"), + all(target_os = "linux", target_arch = "x86_64"), + all(target_os = "linux", target_arch = "aarch64"), + target_os = "windows", + target_os = "macos", + ) ))] #[no_mangle] pub unsafe extern "C" fn zeroidc_start(ptr: *mut ZeroIDC) { @@ -109,12 +119,15 @@ pub unsafe extern "C" fn zeroidc_start(ptr: *mut ZeroIDC) { idc.start(); } -#[cfg(any( - all(target_os = "linux", target_arch = "x86"), - all(target_os = "linux", target_arch = "x86_64"), - all(target_os = "linux", target_arch = "aarch64"), - target_os = "windows", - target_os = "macos", +#[cfg(all( + feature = "zeroidc", + any( + all(target_os = "linux", target_arch = "x86"), + all(target_os = "linux", target_arch = "x86_64"), + all(target_os = "linux", target_arch = "aarch64"), + target_os = "windows", + target_os = "macos", + ) ))] #[no_mangle] pub unsafe extern "C" fn zeroidc_stop(ptr: *mut ZeroIDC) { @@ -125,12 +138,15 @@ pub unsafe extern "C" fn zeroidc_stop(ptr: *mut ZeroIDC) { idc.stop(); } -#[cfg(any( - all(target_os = "linux", target_arch = "x86"), - all(target_os = "linux", target_arch = "x86_64"), - all(target_os = "linux", target_arch = "aarch64"), - target_os = "windows", - target_os = "macos", +#[cfg(all( + feature = "zeroidc", + any( + all(target_os = "linux", target_arch = "x86"), + all(target_os = "linux", target_arch = "x86_64"), + all(target_os = "linux", target_arch = "aarch64"), + target_os = "windows", + target_os = "macos", + ) ))] #[no_mangle] pub unsafe extern "C" fn zeroidc_is_running(ptr: *mut ZeroIDC) -> bool { @@ -142,6 +158,16 @@ pub unsafe extern "C" fn zeroidc_is_running(ptr: *mut ZeroIDC) -> bool { idc.is_running() } +#[cfg(all( + feature = "zeroidc", + any( + all(target_os = "linux", target_arch = "x86"), + all(target_os = "linux", target_arch = "x86_64"), + all(target_os = "linux", target_arch = "aarch64"), + target_os = "windows", + target_os = "macos", + ) +))] #[no_mangle] pub unsafe extern "C" fn zeroidc_get_exp_time(ptr: *mut ZeroIDC) -> u64 { let id = unsafe { @@ -152,12 +178,15 @@ pub unsafe extern "C" fn zeroidc_get_exp_time(ptr: *mut ZeroIDC) -> u64 { id.get_exp_time() } -#[cfg(any( - all(target_os = "linux", target_arch = "x86"), - all(target_os = "linux", target_arch = "x86_64"), - all(target_os = "linux", target_arch = "aarch64"), - target_os = "windows", - target_os = "macos", +#[cfg(all( + feature = "zeroidc", + any( + all(target_os = "linux", target_arch = "x86"), + all(target_os = "linux", target_arch = "x86_64"), + all(target_os = "linux", target_arch = "aarch64"), + target_os = "windows", + target_os = "macos", + ) ))] #[no_mangle] pub unsafe extern "C" fn zeroidc_set_nonce_and_csrf( @@ -186,12 +215,15 @@ pub unsafe extern "C" fn zeroidc_set_nonce_and_csrf( idc.set_nonce_and_csrf(csrf_token, nonce); } -#[cfg(any( - all(target_os = "linux", target_arch = "x86"), - all(target_os = "linux", target_arch = "x86_64"), - all(target_os = "linux", target_arch = "aarch64"), - target_os = "windows", - target_os = "macos", +#[cfg(all( + feature = "zeroidc", + any( + all(target_os = "linux", target_arch = "x86"), + all(target_os = "linux", target_arch = "x86_64"), + all(target_os = "linux", target_arch = "aarch64"), + target_os = "windows", + target_os = "macos", + ) ))] #[no_mangle] pub unsafe extern "C" fn free_cstr(s: *mut c_char) { @@ -205,12 +237,15 @@ pub unsafe extern "C" fn free_cstr(s: *mut c_char) { } } -#[cfg(any( - all(target_os = "linux", target_arch = "x86"), - all(target_os = "linux", target_arch = "x86_64"), - all(target_os = "linux", target_arch = "aarch64"), - target_os = "windows", - target_os = "macos", +#[cfg(all( + feature = "zeroidc", + any( + all(target_os = "linux", target_arch = "x86"), + all(target_os = "linux", target_arch = "x86_64"), + all(target_os = "linux", target_arch = "aarch64"), + target_os = "windows", + target_os = "macos", + ) ))] #[no_mangle] pub unsafe extern "C" fn zeroidc_get_auth_url(ptr: *mut ZeroIDC) -> *mut c_char { @@ -224,12 +259,15 @@ pub unsafe extern "C" fn zeroidc_get_auth_url(ptr: *mut ZeroIDC) -> *mut c_char s.into_raw() } -#[cfg(any( - all(target_os = "linux", target_arch = "x86"), - all(target_os = "linux", target_arch = "x86_64"), - all(target_os = "linux", target_arch = "aarch64"), - target_os = "windows", - target_os = "macos", +#[cfg(all( + feature = "zeroidc", + any( + all(target_os = "linux", target_arch = "x86"), + all(target_os = "linux", target_arch = "x86_64"), + all(target_os = "linux", target_arch = "aarch64"), + target_os = "windows", + target_os = "macos", + ) ))] #[no_mangle] pub unsafe extern "C" fn zeroidc_token_exchange(idc: *mut ZeroIDC, code: *const c_char) -> *mut c_char { @@ -314,12 +352,15 @@ pub unsafe extern "C" fn zeroidc_network_id_from_state(state: *const c_char) -> s.into_raw() } -#[cfg(any( - all(target_os = "linux", target_arch = "x86"), - all(target_os = "linux", target_arch = "x86_64"), - all(target_os = "linux", target_arch = "aarch64"), - target_os = "windows", - target_os = "macos", +#[cfg(all( + feature = "zeroidc", + any( + all(target_os = "linux", target_arch = "x86"), + all(target_os = "linux", target_arch = "x86_64"), + all(target_os = "linux", target_arch = "aarch64"), + target_os = "windows", + target_os = "macos", + ) ))] #[no_mangle] pub unsafe extern "C" fn zeroidc_kick_refresh_thread(idc: *mut ZeroIDC) { @@ -331,3 +372,86 @@ pub unsafe extern "C" fn zeroidc_kick_refresh_thread(idc: *mut ZeroIDC) { idc.kick_refresh_thread(); } + +#[cfg(feature = "ztcontroller")] +use crate::smeeclient::NetworkJoinedParams; +#[cfg(feature = "ztcontroller")] +use crate::smeeclient::SmeeClient; + +#[cfg(feature = "ztcontroller")] +#[no_mangle] +pub unsafe extern "C" fn smee_client_new( + temporal_url: *const c_char, + namespace: *const c_char, + task_queue: *const c_char, +) -> *mut SmeeClient { + let url = unsafe { + assert!(!temporal_url.is_null()); + CStr::from_ptr(temporal_url).to_str().unwrap() + }; + + let ns = unsafe { + assert!(!namespace.is_null()); + CStr::from_ptr(namespace).to_str().unwrap() + }; + + let tq = unsafe { + assert!(!task_queue.is_null()); + CStr::from_ptr(task_queue).to_str().unwrap() + }; + + match SmeeClient::new(url, ns, tq) { + Ok(c) => Box::into_raw(Box::new(c)), + Err(e) => { + println!("error creating smee client instance: {}", e); + std::ptr::null_mut() + } + } +} + +#[cfg(feature = "ztcontroller")] +#[no_mangle] +pub unsafe extern "C" fn smee_client_delete(ptr: *mut SmeeClient) { + if ptr.is_null() { + return; + } + let smee = unsafe { + assert!(!ptr.is_null()); + Box::from_raw(&mut *ptr) + }; + + smee.shutdown(); +} + +#[cfg(feature = "ztcontroller")] +#[no_mangle] +pub unsafe extern "C" fn smee_client_notify_network_joined( + smee_instance: *mut SmeeClient, + network_id: *const c_char, + member_id: *const c_char, +) -> bool { + let nwid = unsafe { + assert!(!network_id.is_null()); + CStr::from_ptr(network_id).to_str().unwrap() + }; + + let mem_id = unsafe { + assert!(!member_id.is_null()); + CStr::from_ptr(member_id).to_str().unwrap() + }; + + let smee = unsafe { + assert!(!smee_instance.is_null()); + &mut *smee_instance + }; + + let params = NetworkJoinedParams::new(nwid, mem_id); + + match smee.notify_network_joined(params) { + Ok(()) => true, + Err(e) => { + println!("error notifying network joined: {0}", e); + false + } + } +} diff --git a/rustybits/src/lib.rs b/rustybits/src/lib.rs new file mode 100644 index 0000000000..a11b77299c --- /dev/null +++ b/rustybits/src/lib.rs @@ -0,0 +1,5 @@ +pub mod ext; +#[cfg(feature = "ztcontroller")] +pub mod smeeclient; +#[cfg(feature = "zeroidc")] +pub mod zeroidc; diff --git a/rustybits/smeeclient/src/lib.rs b/rustybits/src/smeeclient/mod.rs similarity index 97% rename from rustybits/smeeclient/src/lib.rs rename to rustybits/src/smeeclient/mod.rs index 649bb06328..5779b1473f 100644 --- a/rustybits/smeeclient/src/lib.rs +++ b/rustybits/src/smeeclient/mod.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "ztcontroller")] /* * Copyright (c)2023 ZeroTier, Inc. * @@ -10,8 +11,6 @@ * of this software will be governed by version 2.0 of the Apache License. */ -pub mod ext; - use serde::{Deserialize, Serialize}; use std::str::FromStr; use std::time::Duration; @@ -37,7 +36,7 @@ pub struct NetworkJoinedParams { } impl NetworkJoinedParams { - fn new(network_id: &str, member_id: &str) -> Self { + pub fn new(network_id: &str, member_id: &str) -> Self { Self { network_id: network_id.to_string(), member_id: member_id.to_string(), diff --git a/rustybits/zeroidc/src/error.rs b/rustybits/src/zeroidc/error.rs similarity index 100% rename from rustybits/zeroidc/src/error.rs rename to rustybits/src/zeroidc/error.rs diff --git a/rustybits/zeroidc/src/lib.rs b/rustybits/src/zeroidc/mod.rs similarity index 99% rename from rustybits/zeroidc/src/lib.rs rename to rustybits/src/zeroidc/mod.rs index 493d90d7e9..a494a2df65 100644 --- a/rustybits/zeroidc/src/lib.rs +++ b/rustybits/src/zeroidc/mod.rs @@ -17,7 +17,6 @@ )] pub mod error; -pub mod ext; extern crate base64; extern crate bytes; @@ -25,7 +24,7 @@ extern crate openidconnect; extern crate time; extern crate url; -use crate::error::*; +use crate::zeroidc::error::*; use bytes::Bytes; use jwt::Token; @@ -166,12 +165,12 @@ impl ZeroIDC { Ok(idc) } - fn kick_refresh_thread(&mut self) { + pub fn kick_refresh_thread(&mut self) { let local = Arc::clone(&self.inner); local.lock().unwrap().kick = true; } - fn start(&mut self) { + pub fn start(&mut self) { let local = Arc::clone(&self.inner); if !local.lock().unwrap().running { diff --git a/rustybits/zeroidc/.cargo/config.toml b/rustybits/zeroidc/.cargo/config.toml deleted file mode 100644 index 5326b36476..0000000000 --- a/rustybits/zeroidc/.cargo/config.toml +++ /dev/null @@ -1,11 +0,0 @@ -[target.x86_64-apple-darwin] -rustflags=["-C", "link-arg=-mmacosx-version-min=10.13"] - -[target.aarch64-apple-darwin] -rustflags=["-C", "link-arg=-mmacosx-version-min=10.13"] - -[target.x86_64-pc-windows-msvc] -rustflags = ["-C", "target-feature=+crt-static"] - -[target.i686-pc-windows-msvc] -rustflags = ["-C", "target-feature=+crt-static"] diff --git a/rustybits/zeroidc/.gitattributes b/rustybits/zeroidc/.gitattributes deleted file mode 100644 index ba3a8fca87..0000000000 --- a/rustybits/zeroidc/.gitattributes +++ /dev/null @@ -1,3 +0,0 @@ -# disable autocrlf because it doesn't mix well with -# vendored rust packages -* text=false diff --git a/rustybits/zeroidc/Cargo.toml b/rustybits/zeroidc/Cargo.toml deleted file mode 100644 index e38c80e690..0000000000 --- a/rustybits/zeroidc/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "zeroidc" -version = "0.1.0" -edition = "2021" -build = "build.rs" -publish = false - -[lib] -crate-type = ["staticlib", "rlib"] - -[dependencies] -openidconnect = { version = "3.4", default-features = false, features = [ - "reqwest", - "native-tls", - "accept-rfc3339-timestamps", -] } -base64 = "0.21" -url = "2.3" -reqwest = "0.11" -jwt = { version = "0.16", git = "https://github.com/glimberg/rust-jwt" } -serde = "1.0" -time = { version = "~0.3", features = ["formatting"] } -bytes = "1.3" -thiserror = "1" -tokio = { version = ">=1.24" } - -[build-dependencies] -cbindgen = "0.20" diff --git a/rustybits/zeroidc/build.rs b/rustybits/zeroidc/build.rs deleted file mode 100644 index fbb256fc63..0000000000 --- a/rustybits/zeroidc/build.rs +++ /dev/null @@ -1,36 +0,0 @@ -extern crate cbindgen; - -use cbindgen::{Config, Language}; -use std::env; -use std::path::PathBuf; - -fn main() { - let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); - - let package_name = env::var("CARGO_PKG_NAME").unwrap(); - let output_file = target_dir().join(format!("{package_name}.h")).display().to_string(); - - let config = Config { - language: Language::C, - cpp_compat: true, - namespace: Some(String::from("zeroidc")), - ..Default::default() - }; - - cbindgen::generate_with_config(&crate_dir, config) - .unwrap() - .write_to_file(&output_file); -} - -/// Find the location of the `target/` directory. Note that this may be -/// overridden by `cmake`, so we also need to check the `CARGO_TARGET_DIR` -/// variable. -fn target_dir() -> PathBuf { - if let Ok(target) = env::var("CARGO_TARGET_DIR") { - PathBuf::from(target) - } else { - PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()) - .join("..") - .join("target") - } -} diff --git a/rustybits/zeroidc/rustfmt.toml b/rustybits/zeroidc/rustfmt.toml deleted file mode 120000 index 39f97b043b..0000000000 --- a/rustybits/zeroidc/rustfmt.toml +++ /dev/null @@ -1 +0,0 @@ -../rustfmt.toml \ No newline at end of file diff --git a/service/OneService.cpp b/service/OneService.cpp index f2895dda1d..906b8a9396 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -92,7 +92,7 @@ namespace sdkresource = opentelemetry::v1::sdk::resource; #endif #if ZT_SSO_ENABLED -#include +#include #endif #ifdef __WINDOWS__ @@ -334,8 +334,8 @@ class NetworkState { #if ZT_SSO_ENABLED if (_idc) { - zeroidc::zeroidc_stop(_idc); - zeroidc::zeroidc_delete(_idc); + rustybits::zeroidc_stop(_idc); + rustybits::zeroidc_delete(_idc); _idc = nullptr; } #endif @@ -433,7 +433,7 @@ class NetworkState { assert(_config.centralAuthURL != nullptr); assert(_config.ssoProvider != nullptr); - _idc = zeroidc::zeroidc_new(_config.issuerURL, _config.ssoClientID, _config.centralAuthURL, _config.ssoProvider, _webPort); + _idc = rustybits::zeroidc_new(_config.issuerURL, _config.ssoClientID, _config.centralAuthURL, _config.ssoProvider, _webPort); if (_idc == nullptr) { fprintf(stderr, "idc is null\n"); @@ -441,15 +441,15 @@ class NetworkState { } } - zeroidc::zeroidc_set_nonce_and_csrf(_idc, _config.ssoState, _config.ssoNonce); + rustybits::zeroidc_set_nonce_and_csrf(_idc, _config.ssoState, _config.ssoNonce); - char* url = zeroidc::zeroidc_get_auth_url(_idc); + char* url = rustybits::zeroidc_get_auth_url(_idc); memcpy(_config.authenticationURL, url, strlen(url)); _config.authenticationURL[strlen(url)] = 0; - zeroidc::free_cstr(url); + rustybits::free_cstr(url); - if (zeroidc::zeroidc_is_running(_idc) && nwc->status == ZT_NETWORK_STATUS_AUTHENTICATION_REQUIRED) { - zeroidc::zeroidc_kick_refresh_thread(_idc); + if (rustybits::zeroidc_is_running(_idc) && nwc->status == ZT_NETWORK_STATUS_AUTHENTICATION_REQUIRED) { + rustybits::zeroidc_kick_refresh_thread(_idc); } #endif } @@ -479,13 +479,13 @@ class NetworkState { return ret; } - ret = zeroidc::zeroidc_token_exchange(_idc, code); - zeroidc::zeroidc_set_nonce_and_csrf(_idc, _config.ssoState, _config.ssoNonce); + ret = rustybits::zeroidc_token_exchange(_idc, code); + rustybits::zeroidc_set_nonce_and_csrf(_idc, _config.ssoState, _config.ssoNonce); - char* url = zeroidc::zeroidc_get_auth_url(_idc); + char* url = rustybits::zeroidc_get_auth_url(_idc); memcpy(_config.authenticationURL, url, strlen(url)); _config.authenticationURL[strlen(url)] = 0; - zeroidc::free_cstr(url); + rustybits::free_cstr(url); #endif return ret; } @@ -497,7 +497,7 @@ class NetworkState { fprintf(stderr, "idc is null\n"); return 0; } - return zeroidc::zeroidc_get_exp_time(_idc); + return rustybits::zeroidc_get_exp_time(_idc); #else return 0; #endif @@ -511,7 +511,7 @@ class NetworkState { std::map > _managedRoutes; OneService::NetworkSettings _settings; #if ZT_SSO_ENABLED - zeroidc::ZeroIDC* _idc; + rustybits::ZeroIDC* _idc; #endif }; @@ -2536,13 +2536,13 @@ class OneServiceImpl : public OneService { // SSO redirect handling std::string state = req.get_param_value("state"); - char* nwid = zeroidc::zeroidc_network_id_from_state(state.c_str()); + char* nwid = rustybits::zeroidc_network_id_from_state(state.c_str()); outData["networkId"] = std::string(nwid); const uint64_t id = Utils::hexStrToU64(nwid); - zeroidc::free_cstr(nwid); + rustybits::free_cstr(nwid); Mutex::Lock l(_nets_m); if (_nets.find(id) != _nets.end()) { @@ -2574,7 +2574,7 @@ class OneServiceImpl : public OneService { res.status = 500; } - zeroidc::free_cstr(ret); + rustybits::free_cstr(ret); } }; _controlPlane.Get(ssoPath, ssoGet); From f9500ca5ff6fbdd416adc5c9d81df52f0aeb57b2 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 5 Aug 2025 16:05:51 -0700 Subject: [PATCH 002/245] fix dependencies when temporal isn't needed --- rustybits/Cargo.lock | 364 +++++++++++++++++++++++++++++++- rustybits/Cargo.toml | 16 +- rustybits/src/lib.rs | 2 + rustybits/src/pubsub/mod.rs | 11 + rustybits/src/smeeclient/mod.rs | 2 - 5 files changed, 382 insertions(+), 13 deletions(-) create mode 100644 rustybits/src/pubsub/mod.rs diff --git a/rustybits/Cargo.lock b/rustybits/Cargo.lock index 86b692b3fc..cf3c6acea4 100644 --- a/rustybits/Cargo.lock +++ b/rustybits/Cargo.lock @@ -103,6 +103,39 @@ version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" +[[package]] +name = "async-channel" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" +dependencies = [ + "concurrent-queue", + "event-listener", + "futures-core", +] + +[[package]] +name = "async-stream" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "async-trait" version = "0.1.88" @@ -147,7 +180,7 @@ dependencies = [ "rustversion", "serde", "sync_wrapper 1.0.2", - "tower", + "tower 0.5.2", "tower-layer", "tower-service", ] @@ -348,6 +381,15 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "const-oid" version = "0.9.6" @@ -389,6 +431,15 @@ dependencies = [ "libc", ] +[[package]] +name = "crc32fast" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +dependencies = [ + "cfg-if", +] + [[package]] name = "crossbeam-channel" version = "0.5.15" @@ -751,6 +802,12 @@ dependencies = [ "windows-sys 0.60.2", ] +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + [[package]] name = "fastrand" version = "2.3.0" @@ -779,6 +836,16 @@ version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" +[[package]] +name = "flate2" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "fnv" version = "1.0.7" @@ -927,6 +994,85 @@ dependencies = [ "slab", ] +[[package]] +name = "gcloud-auth" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4089aeec499899f6f1309803279763c34d898ca86c1a3e4616cba3ca6bce34b7" +dependencies = [ + "async-trait", + "base64 0.22.1", + "gcloud-metadata", + "home", + "jsonwebtoken", + "reqwest 0.12.22", + "serde", + "serde_json", + "thiserror 1.0.69", + "time", + "token-source", + "tokio", + "tracing", + "urlencoding", +] + +[[package]] +name = "gcloud-gax" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb0a39057a0654184e074ddefb734c9a326ba468663b8f329c95f0069b5ccdb5" +dependencies = [ + "http 1.3.1", + "thiserror 1.0.69", + "token-source", + "tokio", + "tokio-retry2", + "tonic", + "tower 0.4.13", + "tracing", +] + +[[package]] +name = "gcloud-googleapis" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501459a508e7887cfedc45a45ee41602ac1f66d2b61deb05f1c2256bf2faf46d" +dependencies = [ + "prost", + "prost-types", + "tonic", +] + +[[package]] +name = "gcloud-metadata" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d575310b4546530f6b21ee000c20155f11f9291fa0b67ea0949fd48aa49ed70" +dependencies = [ + "reqwest 0.12.22", + "thiserror 1.0.69", + "tokio", +] + +[[package]] +name = "gcloud-pubsub" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1d55e2652753753d902a84c56613b9ae35a36416d94e56c1268764bc7e79f05" +dependencies = [ + "async-channel", + "async-stream", + "gcloud-auth", + "gcloud-gax", + "gcloud-googleapis", + "prost-types", + "thiserror 1.0.69", + "token-source", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -1096,6 +1242,15 @@ dependencies = [ "digest", ] +[[package]] +name = "home" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "http" version = "0.2.12" @@ -1235,12 +1390,29 @@ dependencies = [ "tokio-native-tls", ] +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper 1.6.0", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f66d5bd4c6f02bf0542fad85d626775bab9258cf795a4256dcaf3161114d1df" dependencies = [ + "base64 0.22.1", "bytes", "futures-channel", "futures-core", @@ -1248,7 +1420,9 @@ dependencies = [ "http 1.3.1", "http-body 1.0.1", "hyper 1.6.0", + "ipnet", "libc", + "percent-encoding", "pin-project-lite", "socket2", "tokio", @@ -1450,6 +1624,16 @@ version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" +[[package]] +name = "iri-string" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc5ebe9c3a1a7a5127f920a418f7585e9e758e911d0466ed004f393b0e380b2" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -1490,6 +1674,21 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonwebtoken" +version = "9.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a87cc7a48537badeae96744432de36f4be2b4a34a05a5ef32e9dd8a1c169dde" +dependencies = [ + "base64 0.22.1", + "js-sys", + "pem", + "ring", + "serde", + "serde_json", + "simple_asn1", +] + [[package]] name = "jwt" version = "0.16.0" @@ -1689,6 +1888,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + [[package]] name = "num-bigint-dig" version = "0.8.4" @@ -1753,7 +1962,7 @@ dependencies = [ "getrandom 0.2.16", "http 0.2.12", "rand 0.8.5", - "reqwest", + "reqwest 0.11.27", "serde", "serde_json", "serde_path_to_error", @@ -1935,6 +2144,16 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "pem" +version = "3.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38af38e8470ac9dee3ce1bae1af9c1671fffc44ddfd8bd1d0a3445bf349a8ef3" +dependencies = [ + "base64 0.22.1", + "serde", +] + [[package]] name = "pem-rfc7468" version = "0.7.0" @@ -2405,7 +2624,7 @@ dependencies = [ "http 0.2.12", "http-body 0.4.6", "hyper 0.14.32", - "hyper-tls", + "hyper-tls 0.5.0", "ipnet", "js-sys", "log", @@ -2430,6 +2649,44 @@ dependencies = [ "winreg", ] +[[package]] +name = "reqwest" +version = "0.12.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbc931937e6ca3a06e3b6c0aa7841849b160a90351d6ab467a8b9b9959767531" +dependencies = [ + "base64 0.22.1", + "bytes", + "encoding_rs", + "futures-core", + "http 1.3.1", + "http-body 1.0.1", + "http-body-util", + "hyper 1.6.0", + "hyper-tls 0.6.0", + "hyper-util", + "js-sys", + "log", + "mime", + "native-tls", + "percent-encoding", + "pin-project-lite", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper 1.0.2", + "tokio", + "tokio-native-tls", + "tower 0.5.2", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "rfc6979" version = "0.4.0" @@ -2608,9 +2865,10 @@ dependencies = [ "base64 0.21.7", "bytes", "cbindgen", + "gcloud-pubsub", "jwt", "openidconnect", - "reqwest", + "reqwest 0.11.27", "serde", "temporal-client", "temporal-sdk", @@ -2882,6 +3140,18 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "simple_asn1" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "297f631f50729c8c99b84667867963997ec0b50f32b2a7dbcab828ef0541e8bb" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror 2.0.12", + "time", +] + [[package]] name = "siphasher" version = "1.0.1" @@ -2984,6 +3254,9 @@ name = "sync_wrapper" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] [[package]] name = "synstructure" @@ -3069,7 +3342,7 @@ dependencies = [ "thiserror 2.0.12", "tokio", "tonic", - "tower", + "tower 0.5.2", "tracing", "url", "uuid", @@ -3282,6 +3555,15 @@ dependencies = [ "zerovec", ] +[[package]] +name = "token-source" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75746ae15bef509f21039a652383104424208fdae172a964a8930858b9a78412" +dependencies = [ + "async-trait", +] + [[package]] name = "tokio" version = "1.46.1" @@ -3323,6 +3605,16 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-retry2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1264d076dd34560544a2799e40e457bd07c43d30f4a845686b031bcd8455c84f" +dependencies = [ + "pin-project", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.26.2" @@ -3408,6 +3700,7 @@ dependencies = [ "axum", "base64 0.22.1", "bytes", + "flate2", "h2 0.4.11", "http 1.3.1", "http-body 1.0.1", @@ -3423,10 +3716,11 @@ dependencies = [ "tokio", "tokio-rustls", "tokio-stream", - "tower", + "tower 0.5.2", "tower-layer", "tower-service", "tracing", + "webpki-roots 0.26.11", ] [[package]] @@ -3443,6 +3737,21 @@ dependencies = [ "syn", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "tower" version = "0.5.2" @@ -3462,6 +3771,24 @@ dependencies = [ "tracing", ] +[[package]] +name = "tower-http" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" +dependencies = [ + "bitflags 2.9.1", + "bytes", + "futures-util", + "http 1.3.1", + "http-body 1.0.1", + "iri-string", + "pin-project-lite", + "tower 0.5.2", + "tower-layer", + "tower-service", +] + [[package]] name = "tower-layer" version = "0.3.3" @@ -3480,6 +3807,7 @@ version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ + "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -3595,6 +3923,12 @@ dependencies = [ "serde", ] +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + [[package]] name = "utf8_iter" version = "1.0.4" @@ -3751,6 +4085,24 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "0.26.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" +dependencies = [ + "webpki-roots 1.0.2", +] + +[[package]] +name = "webpki-roots" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8983c3ab33d6fb807cfcdad2491c4ea8cbc8ed839181c7dfd9c67c83e261b2" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/rustybits/Cargo.toml b/rustybits/Cargo.toml index 7467de3b39..0b1776412c 100644 --- a/rustybits/Cargo.toml +++ b/rustybits/Cargo.toml @@ -9,15 +9,20 @@ crate-type = ["staticlib", "rlib"] [features] default = ["zeroidc"] zeroidc = [] -ztcontroller = [] +ztcontroller = [ + "dep:serde", + "dep:temporal-sdk", + "dep:temporal-client", + "dep:temporal-sdk-core-protos", +] [dependencies] -serde = { version = "1", features = ["derive"] } -temporal-sdk = { git = "https://github.com/temporalio/sdk-core", branch = "master" } -temporal-client = { git = "https://github.com/temporalio/sdk-core", branch = "master", features = [ +serde = { version = "1", features = ["derive"], optional = true } +temporal-sdk = { git = "https://github.com/temporalio/sdk-core", branch = "master", optional = true } +temporal-client = { git = "https://github.com/temporalio/sdk-core", branch = "master", optional = true, features = [ "telemetry", ] } -temporal-sdk-core-protos = { git = "https://github.com/temporalio/sdk-core", branch = "master" } +temporal-sdk-core-protos = { git = "https://github.com/temporalio/sdk-core", branch = "master", optional = true } tokio = { version = "1.43", features = ["full"] } uuid = { version = "1.4", features = ["v4"] } openidconnect = { version = "3.4", default-features = false, features = [ @@ -32,6 +37,7 @@ jwt = { version = "0.16", git = "https://github.com/glimberg/rust-jwt" } time = { version = "~0.3", features = ["formatting"] } bytes = "1.3" thiserror = "1" +gcloud-pubsub = { version = "1.3.0" } [build-dependencies] cbindgen = "0.29" diff --git a/rustybits/src/lib.rs b/rustybits/src/lib.rs index a11b77299c..cac1f7219d 100644 --- a/rustybits/src/lib.rs +++ b/rustybits/src/lib.rs @@ -1,5 +1,7 @@ pub mod ext; #[cfg(feature = "ztcontroller")] +pub mod pubsub; +#[cfg(feature = "ztcontroller")] pub mod smeeclient; #[cfg(feature = "zeroidc")] pub mod zeroidc; diff --git a/rustybits/src/pubsub/mod.rs b/rustybits/src/pubsub/mod.rs new file mode 100644 index 0000000000..2fe3be6bac --- /dev/null +++ b/rustybits/src/pubsub/mod.rs @@ -0,0 +1,11 @@ +/* + * Copyright (c)2023 ZeroTier, Inc. + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file in the project's root directory. + * + * Change Date: 2027-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2.0 of the Apache License. + */ diff --git a/rustybits/src/smeeclient/mod.rs b/rustybits/src/smeeclient/mod.rs index 5779b1473f..da743e4e5a 100644 --- a/rustybits/src/smeeclient/mod.rs +++ b/rustybits/src/smeeclient/mod.rs @@ -1,4 +1,3 @@ -#![cfg(feature = "ztcontroller")] /* * Copyright (c)2023 ZeroTier, Inc. * @@ -10,7 +9,6 @@ * On the date above, in accordance with the Business Source License, use * of this software will be governed by version 2.0 of the Apache License. */ - use serde::{Deserialize, Serialize}; use std::str::FromStr; use std::time::Duration; From 44d0e8157262f5ee031279a0bfb19ad0d589f5ca Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 5 Aug 2025 16:07:26 -0700 Subject: [PATCH 003/245] gcloud-pubsub only if ztcontroller is flagged --- rustybits/Cargo.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rustybits/Cargo.toml b/rustybits/Cargo.toml index 0b1776412c..797ff8bf7d 100644 --- a/rustybits/Cargo.toml +++ b/rustybits/Cargo.toml @@ -14,6 +14,7 @@ ztcontroller = [ "dep:temporal-sdk", "dep:temporal-client", "dep:temporal-sdk-core-protos", + "dep:gcloud-pubsub", ] [dependencies] @@ -37,7 +38,7 @@ jwt = { version = "0.16", git = "https://github.com/glimberg/rust-jwt" } time = { version = "~0.3", features = ["formatting"] } bytes = "1.3" thiserror = "1" -gcloud-pubsub = { version = "1.3.0" } +gcloud-pubsub = { version = "1.3.0", optional = true } [build-dependencies] cbindgen = "0.29" From a55216310ab41d3f60f7fc823beed73671668cdf Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 5 Aug 2025 16:18:21 -0700 Subject: [PATCH 004/245] fix macos build --- make-mac.mk | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/make-mac.mk b/make-mac.mk index b8fd490d30..280211b02b 100644 --- a/make-mac.mk +++ b/make-mac.mk @@ -129,9 +129,9 @@ osdep/MacDNSHelper.o: osdep/MacDNSHelper.mm $(CXX) $(CXXFLAGS) -c osdep/MacDNSHelper.mm -o osdep/MacDNSHelper.o ifeq ($(ZT_CONTROLLER),1) -one: otel zeroidc smeeclient $(CORE_OBJS) $(ONE_OBJS) one.o mac-agent +one: otel rustybits $(CORE_OBJS) $(ONE_OBJS) one.o mac-agent else -one: otel zeroidc $(CORE_OBJS) $(ONE_OBJS) one.o mac-agent +one: otel rustybits $(CORE_OBJS) $(ONE_OBJS) one.o mac-agent endif $(CXX) $(CXXFLAGS) -o zerotier-one $(CORE_OBJS) $(ONE_OBJS) one.o $(LIBS) rustybits/target/librustybits.a # $(STRIP) zerotier-one @@ -143,15 +143,6 @@ zerotier-one: one rustybits: rustybits/target/rustybits.a -# ifeq ($(ZT_CONTROLLER),1) -# smeeclient: rustybits/target/libsmeeclient.a - -# rustybits/target/libsmeeclient.a: FORCE -# cd rustybits && MACOSX_DEPLOYMENT_TARGET=$(MACOS_VERSION_MIN) cargo build -F smeeclient --target=x86_64-apple-darwin $(EXTRA_CARGO_FLAGS) -# cd rustybits && MACOSX_DEPLOYMENT_TARGET=$(MACOS_VERSION_MIN) cargo build -F smeeclient --target=aarch64-apple-darwin $(EXTRA_CARGO_FLAGS) -# cd rustybits && lipo -create target/x86_64-apple-darwin/$(RUST_VARIANT)/libsmeeclient.a target/aarch64-apple-darwin/$(RUST_VARIANT)/libsmeeclient.a -output target/libsmeeclient.a -# endif - rustybits/target/rustybits.a: FORCE cd rustybits && MACOSX_DEPLOYMENT_TARGET=$(MACOS_VERSION_MIN) cargo build --target=x86_64-apple-darwin $(EXTRA_CARGO_FLAGS) cd rustybits && MACOSX_DEPLOYMENT_TARGET=$(MACOS_VERSION_MIN) cargo build --target=aarch64-apple-darwin $(EXTRA_CARGO_FLAGS) @@ -164,7 +155,7 @@ zerotier-idtool: one zerotier-cli: one -$(ONE_OBJS): zeroidc +$(ONE_OBJS): rustybits libzerotiercore.a: $(CORE_OBJS) ar rcs libzerotiercore.a $(CORE_OBJS) From 4b3b847c7f2caa49aa66f6e0bab3dfd168a5670b Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 5 Aug 2025 16:38:57 -0700 Subject: [PATCH 005/245] fix windows bui ld --- rustybits/zeroidc.vcxproj | 24 ++++++++++++------------ windows/ZeroTierOne/ZeroTierOne.vcxproj | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/rustybits/zeroidc.vcxproj b/rustybits/zeroidc.vcxproj index 8334372384..a4318fba52 100644 --- a/rustybits/zeroidc.vcxproj +++ b/rustybits/zeroidc.vcxproj @@ -87,49 +87,49 @@ - cargo build -p zeroidc --release --target=x86_64-pc-windows-msvc + cargo build --release --target=x86_64-pc-windows-msvc cargo clean - cargo clean & cargo build -p zeroidc --release --target=x86_64-pc-windows-msvc + cargo clean & cargo build --release --target=x86_64-pc-windows-msvc NDEBUG;$(NMakePreprocessorDefinitions) - cargo build -p zeroidc --release --target=aarch64-pc-windows-msvc + cargo build --release --target=aarch64-pc-windows-msvc cargo clean - cargo clean & cargo build -p zeroidc --release --target=aarch64-pc-windows-msvc + cargo clean & cargo build --release --target=aarch64-pc-windows-msvc NDEBUG;$(NMakePreprocessorDefinitions) - cargo build -p zeroidc --target=i686-pc-windows-msvc + cargo build --target=i686-pc-windows-msvc cargo clean - cargo clean & cargo build -p zeroidc --target=i686-pc-windows-msvc + cargo clean & cargo build --target=i686-pc-windows-msvc WIN32;_DEBUG;$(NMakePreprocessorDefinitions) - cargo build -p zeroidc --target=x86_64-pc-windows-msvc + cargo build --target=x86_64-pc-windows-msvc cargo clean - cargo clean & cargo build -p zeroidc --target=x86_64-pc-windows-msvc + cargo clean & cargo build --target=x86_64-pc-windows-msvc _DEBUG;$(NMakePreprocessorDefinitions) - cargo build -p zeroidc --target=aarch64-pc-windows-msvc + cargo build --target=aarch64-pc-windows-msvc cargo clean - cargo clean & cargo build -p zeroidc --target=aarch64-pc-windows-msvc + cargo clean & cargo build --target=aarch64-pc-windows-msvc _DEBUG;$(NMakePreprocessorDefinitions) - cargo build --release -p zeroidc --target=i686-pc-windows-msvc + cargo build --release --target=i686-pc-windows-msvc cargo clean - cargo clean & cargo build -p zeroidc --release --target=i686-pc-windows-msvc + cargo clean & cargo build --release --target=i686-pc-windows-msvc WIN32;NDEBUG;$(NMakePreprocessorDefinitions) diff --git a/windows/ZeroTierOne/ZeroTierOne.vcxproj b/windows/ZeroTierOne/ZeroTierOne.vcxproj index fcf3e012aa..cfd16407fc 100644 --- a/windows/ZeroTierOne/ZeroTierOne.vcxproj +++ b/windows/ZeroTierOne/ZeroTierOne.vcxproj @@ -420,7 +420,7 @@ true - wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;zeroidc.lib;bcrypt.lib;userenv.lib;crypt32.lib;secur32.lib;ncrypt.lib;ntdll.lib;%(AdditionalDependencies) + wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;rustybits.lib;bcrypt.lib;userenv.lib;crypt32.lib;secur32.lib;ncrypt.lib;ntdll.lib;%(AdditionalDependencies) false $(SolutionDir)\..\rustybits\target\i686-pc-windows-msvc\debug\;%(AdditionalLibraryDirectories) @@ -463,7 +463,7 @@ true - wbemuuid.lib;wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;zeroidc.lib;bcrypt.lib;userenv.lib;crypt32.lib;secur32.lib;ncrypt.lib;ntdll.lib;%(AdditionalDependencies) + wbemuuid.lib;wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;rustybits.lib;bcrypt.lib;userenv.lib;crypt32.lib;secur32.lib;ncrypt.lib;ntdll.lib;%(AdditionalDependencies) false "notelemetry.obj" %(AdditionalOptions) $(SolutionDir)..\rustybits\target\x86_64-pc-windows-msvc\debug\;%(AdditionalLibraryDirectories) @@ -486,7 +486,7 @@ true - wbemuuid.lib;wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;zeroidc.lib;bcrypt.lib;userenv.lib;crypt32.lib;secur32.lib;ncrypt.lib;ntdll.lib;%(AdditionalDependencies) + wbemuuid.lib;wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;rustybits.lib;bcrypt.lib;userenv.lib;crypt32.lib;secur32.lib;ncrypt.lib;ntdll.lib;%(AdditionalDependencies) false $(SolutionDir)..\rustybits\target\aarch64-pc-windows-msvc\debug\;%(AdditionalLibraryDirectories) @@ -566,7 +566,7 @@ false true true - wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;zeroidc.lib;bcrypt.lib;userenv.lib;crypt32.lib;secur32.lib;ncrypt.lib;ntdll.lib;%(AdditionalDependencies) + wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;rustybits.lib;bcrypt.lib;userenv.lib;crypt32.lib;secur32.lib;ncrypt.lib;ntdll.lib;%(AdditionalDependencies) false $(SolutionDir)..\rustybits\target\i686-pc-windows-msvc\release\;%(AdditionalLibraryDirectories) @@ -604,7 +604,7 @@ false true true - wbemuuid.lib;wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;zeroidc.lib;bcrypt.lib;userenv.lib;crypt32.lib;secur32.lib;ncrypt.lib;ntdll.lib;%(AdditionalDependencies) + wbemuuid.lib;wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;rustybits.lib;bcrypt.lib;userenv.lib;crypt32.lib;secur32.lib;ncrypt.lib;ntdll.lib;%(AdditionalDependencies) false $(SolutionDir)..\rustybits\target\x86_64-pc-windows-msvc\release\;%(AdditionalLibraryDirectories) @@ -642,7 +642,7 @@ false true true - wbemuuid.lib;wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;zeroidc.lib;bcrypt.lib;userenv.lib;crypt32.lib;secur32.lib;ncrypt.lib;ntdll.lib;%(AdditionalDependencies) + wbemuuid.lib;wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;rustybits.lib;bcrypt.lib;userenv.lib;crypt32.lib;secur32.lib;ncrypt.lib;ntdll.lib;%(AdditionalDependencies) false $(SolutionDir)..\rustybits\target\aarch64-pc-windows-msvc\release\;%(AdditionalLibraryDirectories) From 837f15d01b65e4b31c4dd910086c8fd8525a8766 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 7 Aug 2025 11:28:22 -0700 Subject: [PATCH 006/245] tokio is needed by both temporal & gcloud pubsub, so make just one instance for the whole library, add init/shutdown functions for it exposed to C --- controller/CV1.cpp | 4 ++++ controller/CV2.cpp | 5 +++++ rustybits/src/ext.rs | 35 +++++++++++++++++++++++++++++++-- rustybits/src/pubsub/mod.rs | 18 +++++++++++++++++ rustybits/src/smeeclient/mod.rs | 19 +++++------------- 5 files changed, 65 insertions(+), 16 deletions(-) diff --git a/controller/CV1.cpp b/controller/CV1.cpp index 0ba82f064f..0f980c68f5 100644 --- a/controller/CV1.cpp +++ b/controller/CV1.cpp @@ -67,6 +67,8 @@ CV1::CV1(const Identity& myId, const char* path, int listenPort, RedisConfig* rc auto span = tracer->StartSpan("cv1::CV1"); auto scope = tracer->WithActiveSpan(span); + rustybits::init_async_runtime(); + char myAddress[64]; _myAddressStr = myId.address().toString(myAddress); _connString = std::string(path); @@ -157,6 +159,8 @@ CV1::~CV1() _smee = NULL; } + rustybits::shutdown_async_runtime(); + _run = 0; std::this_thread::sleep_for(std::chrono::milliseconds(100)); diff --git a/controller/CV2.cpp b/controller/CV2.cpp index db9effb3ce..9be950f1d1 100644 --- a/controller/CV2.cpp +++ b/controller/CV2.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include using json = nlohmann::json; @@ -43,6 +44,8 @@ CV2::CV2(const Identity& myId, const char* path, int listenPort) : DB(), _pool() auto span = tracer->StartSpan("cv2::CV2"); auto scope = tracer->WithActiveSpan(span); + rustybits::init_async_runtime(); + fprintf(stderr, "CV2::CV2\n"); char myAddress[64]; _myAddressStr = myId.address().toString(myAddress); @@ -83,6 +86,8 @@ CV2::CV2(const Identity& myId, const char* path, int listenPort) : DB(), _pool() CV2::~CV2() { + rustybits::shutdown_async_runtime(); + _run = 0; std::this_thread::sleep_for(std::chrono::milliseconds(100)); diff --git a/rustybits/src/ext.rs b/rustybits/src/ext.rs index 67fe2c6c32..1b87b9dc15 100644 --- a/rustybits/src/ext.rs +++ b/rustybits/src/ext.rs @@ -14,6 +14,38 @@ use std::ffi::{CStr, CString}; use std::os::raw::c_char; use url::Url; +static mut RT: Option = None; + +static START: std::sync::Once = std::sync::Once::new(); +static SHUTDOWN: std::sync::Once = std::sync::Once::new(); + +#[no_mangle] +pub unsafe extern "C" fn init_async_runtime() { + START.call_once(|| { + let rt = tokio::runtime::Builder::new_multi_thread() + .worker_threads(4) + .thread_name("rust-async-worker") + .enable_all() + .build() + .expect("Failed to create tokio runtime"); + + unsafe { RT = Some(rt) }; + }); +} + +#[no_mangle] +#[allow(static_mut_refs)] +pub unsafe extern "C" fn shutdown_async_runtime() { + SHUTDOWN.call_once(|| { + // Shutdown the tokio runtime + unsafe { + if let Some(rt) = RT.take() { + rt.shutdown_timeout(std::time::Duration::from_secs(5)); + } + } + }); +} + #[cfg(feature = "zeroidc")] use crate::zeroidc::ZeroIDC; @@ -419,8 +451,7 @@ pub unsafe extern "C" fn smee_client_delete(ptr: *mut SmeeClient) { assert!(!ptr.is_null()); Box::from_raw(&mut *ptr) }; - - smee.shutdown(); + drop(smee); } #[cfg(feature = "ztcontroller")] diff --git a/rustybits/src/pubsub/mod.rs b/rustybits/src/pubsub/mod.rs index 2fe3be6bac..719f52e595 100644 --- a/rustybits/src/pubsub/mod.rs +++ b/rustybits/src/pubsub/mod.rs @@ -9,3 +9,21 @@ * On the date above, in accordance with the Business Source License, use * of this software will be governed by version 2.0 of the Apache License. */ + +use gcloud_pubsub::client::{Client, ClientConfig}; + +pub struct PubSubClient { + client: Client, +} + +impl PubSubClient { + pub async fn new() -> Result> { + let config = ClientConfig::default().with_auth().await.unwrap(); + let client = Client::new(config).await?; + + // Assuming a topic name is required for the client + let topic_name = "default-topic".to_string(); + + Ok(Self { client }) + } +} diff --git a/rustybits/src/smeeclient/mod.rs b/rustybits/src/smeeclient/mod.rs index da743e4e5a..b68ac9a6b7 100644 --- a/rustybits/src/smeeclient/mod.rs +++ b/rustybits/src/smeeclient/mod.rs @@ -17,6 +17,7 @@ use temporal_sdk_core_protos::{ coresdk::AsJsonPayloadExt, temporal::api::enums::v1::{WorkflowIdConflictPolicy, WorkflowIdReusePolicy}, }; +use tokio::runtime::{Handle, Runtime}; use url::Url; use uuid::Uuid; @@ -43,16 +44,13 @@ impl NetworkJoinedParams { } pub struct SmeeClient { - tokio_rt: tokio::runtime::Runtime, client: RetryClient, task_queue: String, } impl SmeeClient { pub fn new(temporal_url: &str, namespace: &str, task_queue: &str) -> Result> { - // start tokio runtime. Required by temporal - let rt = tokio::runtime::Runtime::new()?; - + let rt = Handle::current(); let c = ClientOptionsBuilder::default() .target_url(Url::from_str(temporal_url).unwrap()) .client_name(CLIENT_NAME) @@ -61,11 +59,7 @@ impl SmeeClient { let con = rt.block_on(async { c.connect(namespace.to_string(), None).await })?; - Ok(Self { - tokio_rt: rt, - client: con, - task_queue: task_queue.to_string(), - }) + Ok(Self { client: con, task_queue: task_queue.to_string() }) } pub fn notify_network_joined(&self, params: NetworkJoinedParams) -> Result<(), Box> { @@ -89,7 +83,8 @@ impl SmeeClient { let workflow_id = Uuid::new_v4(); - self.tokio_rt.block_on(async { + let rt = Handle::current(); + rt.block_on(async { println!("calilng start_workflow"); self.client .start_workflow( @@ -105,8 +100,4 @@ impl SmeeClient { Ok(()) } - - pub fn shutdown(self) { - self.tokio_rt.shutdown_timeout(Duration::from_secs(5)) - } } From f079f8bc8247f21215b01eec62d86e7079f62ce4 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 11 Aug 2025 11:31:15 -0700 Subject: [PATCH 007/245] cleanup warnings --- rustybits/src/smeeclient/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rustybits/src/smeeclient/mod.rs b/rustybits/src/smeeclient/mod.rs index b68ac9a6b7..ddd2cc1f7e 100644 --- a/rustybits/src/smeeclient/mod.rs +++ b/rustybits/src/smeeclient/mod.rs @@ -11,13 +11,12 @@ */ use serde::{Deserialize, Serialize}; use std::str::FromStr; -use std::time::Duration; use temporal_client::{Client, ClientOptionsBuilder, RetryClient, WorkflowClientTrait, WorkflowOptions}; use temporal_sdk_core_protos::{ coresdk::AsJsonPayloadExt, temporal::api::enums::v1::{WorkflowIdConflictPolicy, WorkflowIdReusePolicy}, }; -use tokio::runtime::{Handle, Runtime}; +use tokio::runtime::Handle; use url::Url; use uuid::Uuid; From 06b2ce9f3016433df544e32b493c076269e6c935 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 12 Aug 2025 10:42:07 -0700 Subject: [PATCH 008/245] WIP: pubsub wrapper in Rust --- rustybits/Cargo.lock | 386 +++++++++++++++++++++-- rustybits/Cargo.toml | 18 +- rustybits/build.rs | 15 + rustybits/src/ext.rs | 133 +++++++- rustybits/src/pubsub/change_listener.rs | 120 +++++++ rustybits/src/pubsub/member.proto | 37 +++ rustybits/src/pubsub/member_listener.rs | 53 ++++ rustybits/src/pubsub/member_status.proto | 16 + rustybits/src/pubsub/metadata.proto | 8 + rustybits/src/pubsub/mod.rs | 24 +- rustybits/src/pubsub/network.proto | 62 ++++ rustybits/src/pubsub/network_listener.rs | 54 ++++ rustybits/src/pubsub/protobuf.rs | 3 + 13 files changed, 884 insertions(+), 45 deletions(-) create mode 100644 rustybits/src/pubsub/change_listener.rs create mode 100644 rustybits/src/pubsub/member.proto create mode 100644 rustybits/src/pubsub/member_listener.rs create mode 100644 rustybits/src/pubsub/member_status.proto create mode 100644 rustybits/src/pubsub/metadata.proto create mode 100644 rustybits/src/pubsub/network.proto create mode 100644 rustybits/src/pubsub/network_listener.rs create mode 100644 rustybits/src/pubsub/protobuf.rs diff --git a/rustybits/Cargo.lock b/rustybits/Cargo.lock index cf3c6acea4..1f0d775218 100644 --- a/rustybits/Cargo.lock +++ b/rustybits/Cargo.lock @@ -281,6 +281,56 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bollard" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97ccca1260af6a459d75994ad5acc1651bcabcbdbc41467cc9786519ab854c30" +dependencies = [ + "base64 0.22.1", + "bollard-stubs", + "bytes", + "futures-core", + "futures-util", + "hex", + "home", + "http 1.3.1", + "http-body-util", + "hyper 1.6.0", + "hyper-named-pipe", + "hyper-rustls", + "hyper-util", + "hyperlocal", + "log", + "pin-project-lite", + "rustls", + "rustls-native-certs", + "rustls-pemfile 2.2.0", + "rustls-pki-types", + "serde", + "serde_derive", + "serde_json", + "serde_repr", + "serde_urlencoded", + "thiserror 2.0.12", + "tokio", + "tokio-util", + "tower-service", + "url", + "winapi", +] + +[[package]] +name = "bollard-stubs" +version = "1.47.1-rc.27.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f179cfbddb6e77a5472703d4b30436bff32929c0aa8a9008ecf23d1d3cdd0da" +dependencies = [ + "serde", + "serde_repr", + "serde_with", +] + [[package]] name = "bumpalo" version = "3.19.0" @@ -658,6 +708,17 @@ dependencies = [ "syn", ] +[[package]] +name = "docker_credential" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d89dfcba45b4afad7450a99b39e751590463e45c04728cf555d36bb66940de8" +dependencies = [ + "base64 0.21.7", + "serde", + "serde_json", +] + [[package]] name = "downcast" version = "0.11.0" @@ -802,6 +863,17 @@ dependencies = [ "windows-sys 0.60.2", ] +[[package]] +name = "etcetera" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26c7b13d0780cb82722fd59f6f57f925e143427e4a75313a6c77243bf5326ae6" +dependencies = [ + "cfg-if", + "home", + "windows-sys 0.59.0", +] + [[package]] name = "event-listener" version = "2.5.3" @@ -830,6 +902,18 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64cd1e32ddd350061ae6edb1b082d7c54915b5c672c389143b9a63403a109f24" +[[package]] +name = "filetime" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" +dependencies = [ + "cfg-if", + "libc", + "libredox", + "windows-sys 0.59.0", +] + [[package]] name = "fixedbitset" version = "0.5.7" @@ -1038,8 +1122,8 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "501459a508e7887cfedc45a45ee41602ac1f66d2b61deb05f1c2256bf2faf46d" dependencies = [ - "prost", - "prost-types", + "prost 0.13.5", + "prost-types 0.13.5", "tonic", ] @@ -1065,7 +1149,7 @@ dependencies = [ "gcloud-auth", "gcloud-gax", "gcloud-googleapis", - "prost-types", + "prost-types 0.13.5", "thiserror 1.0.69", "token-source", "tokio", @@ -1364,6 +1448,37 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-named-pipe" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73b7d8abf35697b81a825e386fc151e0d503e8cb5fcb93cc8669c376dfd6f278" +dependencies = [ + "hex", + "hyper 1.6.0", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", + "winapi", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" +dependencies = [ + "http 1.3.1", + "hyper 1.6.0", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + [[package]] name = "hyper-timeout" version = "0.5.2" @@ -1430,6 +1545,21 @@ dependencies = [ "tracing", ] +[[package]] +name = "hyperlocal" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "986c5ce3b994526b3cd75578e62554abd09f0899d6206de48b3e96ab34ccc8c7" +dependencies = [ + "hex", + "http-body-util", + "hyper 1.6.0", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + [[package]] name = "iana-time-zone" version = "0.1.63" @@ -1724,6 +1854,17 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" +[[package]] +name = "libredox" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4488594b9328dee448adb906d8b126d9b7deb7cf5c22161ee591610bb1be83c0" +dependencies = [ + "bitflags 2.9.1", + "libc", + "redox_syscall 0.5.13", +] + [[package]] name = "linux-raw-sys" version = "0.9.4" @@ -2139,11 +2280,36 @@ checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.5.13", "smallvec", "windows-targets 0.52.6", ] +[[package]] +name = "parse-display" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914a1c2265c98e2446911282c6ac86d8524f495792c38c5bd884f80499c7538a" +dependencies = [ + "parse-display-derive", + "regex", + "regex-syntax 0.8.5", +] + +[[package]] +name = "parse-display-derive" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ae7800a4c974efd12df917266338e79a7a74415173caf7e70aa0a0707345281" +dependencies = [ + "proc-macro2", + "quote", + "regex", + "regex-syntax 0.8.5", + "structmeta", + "syn", +] + [[package]] name = "pem" version = "3.0.5" @@ -2347,7 +2513,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.13.5", +] + +[[package]] +name = "prost" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7231bd9b3d3d33c86b58adbac74b5ec0ad9f496b19d22801d773636feaa95f3d" +dependencies = [ + "bytes", + "prost-derive 0.14.1", ] [[package]] @@ -2363,8 +2539,28 @@ dependencies = [ "once_cell", "petgraph", "prettyplease", - "prost", - "prost-types", + "prost 0.13.5", + "prost-types 0.13.5", + "regex", + "syn", + "tempfile", +] + +[[package]] +name = "prost-build" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac6c3320f9abac597dcbc668774ef006702672474aad53c6d596b62e487b40b1" +dependencies = [ + "heck", + "itertools 0.14.0", + "log", + "multimap", + "once_cell", + "petgraph", + "prettyplease", + "prost 0.14.1", + "prost-types 0.14.1", "regex", "syn", "tempfile", @@ -2383,13 +2579,35 @@ dependencies = [ "syn", ] +[[package]] +name = "prost-derive" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9120690fafc389a67ba3803df527d0ec9cbbc9cc45e4cc20b332996dfb672425" +dependencies = [ + "anyhow", + "itertools 0.14.0", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "prost-types" version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52c2c1bf36ddb1a1c396b3601a3cec27c2462e45f07c386894ec3ccf5332bd16" dependencies = [ - "prost", + "prost 0.13.5", +] + +[[package]] +name = "prost-types" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9b4db3d6da204ed77bb26ba83b6122a73aeb2e87e25fbf7ad2e84c4ccbf8f72" +dependencies = [ + "prost 0.14.1", ] [[package]] @@ -2400,7 +2618,7 @@ checksum = "497e1e938f0c09ef9cabe1d49437b4016e03e8f82fbbe5d1c62a9b61b9decae1" dependencies = [ "chrono", "inventory", - "prost", + "prost 0.13.5", "serde", "serde_derive", "serde_json", @@ -2414,9 +2632,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07b8bf115b70a7aa5af1fd5d6e9418492e9ccb6e4785e858c938e28d132a884b" dependencies = [ "heck", - "prost", - "prost-build", - "prost-types", + "prost 0.13.5", + "prost-build 0.13.5", + "prost-types 0.13.5", "quote", ] @@ -2427,9 +2645,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8cdde6df0a98311c839392ca2f2f0bcecd545f86a62b4e3c6a49c336e970fe5" dependencies = [ "chrono", - "prost", - "prost-build", - "prost-types", + "prost 0.13.5", + "prost-build 0.13.5", + "prost-types 0.13.5", "prost-wkt", "prost-wkt-build", "regex", @@ -2536,6 +2754,15 @@ dependencies = [ "bitflags 2.9.1", ] +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_syscall" version = "0.5.13" @@ -2633,7 +2860,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls-pemfile", + "rustls-pemfile 1.0.4", "serde", "serde_json", "serde_urlencoded", @@ -2832,6 +3059,15 @@ dependencies = [ "base64 0.21.7", ] +[[package]] +name = "rustls-pemfile" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "rustls-pki-types" version = "1.12.0" @@ -2868,14 +3104,21 @@ dependencies = [ "gcloud-pubsub", "jwt", "openidconnect", + "prost 0.14.1", + "prost-build 0.14.1", + "prost-types 0.14.1", "reqwest 0.11.27", "serde", + "serde_json", "temporal-client", "temporal-sdk", "temporal-sdk-core-protos", + "testcontainers", + "testcontainers-modules", "thiserror 1.0.69", "time", "tokio", + "tokio-util", "url", "uuid", ] @@ -3042,6 +3285,17 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "serde_spanned" version = "0.6.9" @@ -3226,6 +3480,29 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "structmeta" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e1575d8d40908d70f6fd05537266b90ae71b15dbbe7a8b7dffa2b759306d329" +dependencies = [ + "proc-macro2", + "quote", + "structmeta-derive", + "syn", +] + +[[package]] +name = "structmeta-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "152a0b65a590ff6c3da95cabe2353ee04e6167c896b28e3b14478c2636c922fc" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "subtle" version = "2.6.1" @@ -3394,7 +3671,7 @@ dependencies = [ "parking_lot", "pid", "pin-project", - "prost", + "prost 0.13.5", "prost-wkt-types", "rand 0.9.1", "ringbuf", @@ -3427,7 +3704,7 @@ dependencies = [ "derive_builder", "derive_more", "opentelemetry", - "prost", + "prost 0.13.5", "serde_json", "temporal-sdk-core-protos", "thiserror 2.0.12", @@ -3445,8 +3722,8 @@ dependencies = [ "anyhow", "base64 0.22.1", "derive_more", - "prost", - "prost-build", + "prost 0.13.5", + "prost-build 0.13.5", "prost-wkt", "prost-wkt-build", "prost-wkt-types", @@ -3465,6 +3742,44 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" +[[package]] +name = "testcontainers" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23bb7577dca13ad86a78e8271ef5d322f37229ec83b8d98da6d996c588a1ddb1" +dependencies = [ + "async-trait", + "bollard", + "bollard-stubs", + "bytes", + "docker_credential", + "either", + "etcetera", + "futures", + "log", + "memchr", + "parse-display", + "pin-project-lite", + "serde", + "serde_json", + "serde_with", + "thiserror 2.0.12", + "tokio", + "tokio-stream", + "tokio-tar", + "tokio-util", + "url", +] + +[[package]] +name = "testcontainers-modules" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac95cde96549fc19c6bf19ef34cc42bd56e264c1cb97e700e21555be0ecf9e2" +dependencies = [ + "testcontainers", +] + [[package]] name = "thiserror" version = "1.0.69" @@ -3636,6 +3951,21 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-tar" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5714c010ca3e5c27114c1cdeb9d14641ace49874aa5626d7149e47aedace75" +dependencies = [ + "filetime", + "futures-core", + "libc", + "redox_syscall 0.3.5", + "tokio", + "tokio-stream", + "xattr", +] + [[package]] name = "tokio-util" version = "0.7.15" @@ -3710,7 +4040,7 @@ dependencies = [ "hyper-util", "percent-encoding", "pin-project", - "prost", + "prost 0.13.5", "rustls-native-certs", "socket2", "tokio", @@ -3731,8 +4061,8 @@ checksum = "eac6f67be712d12f0b41328db3137e0d0757645d8904b4cb7d51cd9c2279e847" dependencies = [ "prettyplease", "proc-macro2", - "prost-build", - "prost-types", + "prost-build 0.13.5", + "prost-types 0.13.5", "quote", "syn", ] @@ -4492,6 +4822,16 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" +[[package]] +name = "xattr" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af3a19837351dc82ba89f8a125e22a3c475f05aba604acc023d62b2739ae2909" +dependencies = [ + "libc", + "rustix", +] + [[package]] name = "yoke" version = "0.8.0" diff --git a/rustybits/Cargo.toml b/rustybits/Cargo.toml index 797ff8bf7d..3f0f82b5cf 100644 --- a/rustybits/Cargo.toml +++ b/rustybits/Cargo.toml @@ -7,24 +7,29 @@ edition = "2021" crate-type = ["staticlib", "rlib"] [features] -default = ["zeroidc"] +default = ["zeroidc", "ztcontroller"] zeroidc = [] ztcontroller = [ "dep:serde", + "dep:serde_json", "dep:temporal-sdk", "dep:temporal-client", "dep:temporal-sdk-core-protos", "dep:gcloud-pubsub", + "dep:prost", + "dep:prost-types", ] [dependencies] serde = { version = "1", features = ["derive"], optional = true } +serde_json = { version = "1", optional = true } temporal-sdk = { git = "https://github.com/temporalio/sdk-core", branch = "master", optional = true } temporal-client = { git = "https://github.com/temporalio/sdk-core", branch = "master", optional = true, features = [ "telemetry", ] } temporal-sdk-core-protos = { git = "https://github.com/temporalio/sdk-core", branch = "master", optional = true } -tokio = { version = "1.43", features = ["full"] } +tokio = { version = "1.43", features = ["full", "rt", "macros"] } +tokio-util = { version = "0.7" } uuid = { version = "1.4", features = ["v4"] } openidconnect = { version = "3.4", default-features = false, features = [ "reqwest", @@ -39,9 +44,18 @@ time = { version = "~0.3", features = ["formatting"] } bytes = "1.3" thiserror = "1" gcloud-pubsub = { version = "1.3.0", optional = true } +prost = { version = "0.14", optional = true, features = ["derive"] } +prost-types = { version = "0.14", optional = true } + +[dev-dependencies] +testcontainers = { version = "0.24", features = ["blocking"] } +testcontainers-modules = { version = "0.12.1", features = [ + "google_cloud_sdk_emulators", +] } [build-dependencies] cbindgen = "0.29" +prost-build = "0.14" [profile.release] strip = "debuginfo" diff --git a/rustybits/build.rs b/rustybits/build.rs index be7973db1b..1d0d01e36b 100644 --- a/rustybits/build.rs +++ b/rustybits/build.rs @@ -5,6 +5,21 @@ use std::env; use std::path::PathBuf; fn main() { + let mut prost_build = prost_build::Config::new(); + + prost_build + .type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]") + .compile_protos( + &[ + "src/pubsub/metadata.proto", + "src/pubsub/network.proto", + "src/pubsub/member.proto", + "src/pubsub/member_status.proto", + ], + &["src/pubsub/"], + ) + .expect("Failed to compile protobuf files"); + let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); let package_name = env::var("CARGO_PKG_NAME").unwrap(); diff --git a/rustybits/src/ext.rs b/rustybits/src/ext.rs index 1b87b9dc15..7f933de349 100644 --- a/rustybits/src/ext.rs +++ b/rustybits/src/ext.rs @@ -12,6 +12,9 @@ use std::ffi::{CStr, CString}; use std::os::raw::c_char; +use std::sync::Arc; +use std::time::Duration; +use tokio::runtime; use url::Url; static mut RT: Option = None; @@ -39,7 +42,7 @@ pub unsafe extern "C" fn shutdown_async_runtime() { SHUTDOWN.call_once(|| { // Shutdown the tokio runtime unsafe { - if let Some(rt) = RT.take() { + if let Some(rt) = RT.take() { rt.shutdown_timeout(std::time::Duration::from_secs(5)); } } @@ -486,3 +489,131 @@ pub unsafe extern "C" fn smee_client_notify_network_joined( } } } + +#[cfg(feature = "ztcontroller")] +use crate::pubsub::member_listener::MemberListener; +#[cfg(feature = "ztcontroller")] +use crate::pubsub::network_listener::NetworkListener; + +#[cfg(feature = "ztcontroller")] +#[no_mangle] +pub unsafe extern "C" fn init_network_listener( + controller_id: *const c_char, + listen_timeout: u64, +) -> *const Arc { + if listen_timeout == 0 { + println!("listen_timeout is zero"); + return std::ptr::null_mut(); + } + if controller_id.is_null() { + println!("controller_id is null"); + return std::ptr::null_mut(); + } + + let id = unsafe { CStr::from_ptr(controller_id) }.to_str().unwrap(); + + let rt = runtime::Handle::current(); + rt.block_on(async { + match NetworkListener::new(id, Duration::from_secs(listen_timeout)).await { + Ok(listener) => Arc::into_raw(Arc::new(listener)), + Err(e) => { + println!("error creating network listener: {}", e); + std::ptr::null_mut() + } + } + }) +} + +#[cfg(feature = "ztcontroller")] +#[no_mangle] +pub unsafe extern "C" fn network_listener_delete(ptr: *const Arc) { + if ptr.is_null() { + return; + } + drop(Arc::from_raw(ptr)); +} + +#[cfg(feature = "ztcontroller")] +#[no_mangle] +pub unsafe extern "C" fn network_listener_listen(ptr: *const Arc) -> bool { + use std::mem::ManuallyDrop; + if ptr.is_null() { + println!("ptr is null"); + return false; + } + + let listener = ManuallyDrop::new(unsafe { Arc::from_raw(ptr) }); + + let rt = runtime::Handle::current(); + match rt.block_on(listener.listen()) { + Ok(_) => { + println!("Network listener started successfully"); + true + } + Err(e) => { + println!("Error starting network listener: {}", e); + false + } + } +} + +#[cfg(feature = "ztcontroller")] +#[no_mangle] +pub unsafe extern "C" fn init_member_listener( + controller_id: *const c_char, + listen_timeout: u64, +) -> *const Arc { + if listen_timeout == 0 { + println!("listen_timeout is zero"); + return std::ptr::null_mut(); + } + if controller_id.is_null() { + println!("controller_id is null"); + return std::ptr::null_mut(); + } + + let id = unsafe { CStr::from_ptr(controller_id) }.to_str().unwrap(); + + let rt = runtime::Handle::current(); + rt.block_on(async { + match MemberListener::new(id, Duration::from_secs(listen_timeout)).await { + Ok(listener) => Arc::into_raw(Arc::new(listener)), + Err(e) => { + println!("error creating member listener: {}", e); + std::ptr::null_mut() + } + } + }) +} + +#[cfg(feature = "ztcontroller")] +#[no_mangle] +pub unsafe extern "C" fn member_listener_delete(ptr: *const Arc) { + if ptr.is_null() { + return; + } + drop(Arc::from_raw(ptr)); +} + +#[cfg(feature = "ztcontroller")] +#[no_mangle] +pub unsafe extern "C" fn member_listener_listen(ptr: *const Arc) -> bool { + use std::mem::ManuallyDrop; + if ptr.is_null() { + println!("ptr is null"); + return false; + } + + let listener = ManuallyDrop::new(unsafe { Arc::from_raw(ptr) }); + let rt = runtime::Handle::current(); + match rt.block_on(listener.listen()) { + Ok(_) => { + println!("Member listener started successfully"); + true + } + Err(e) => { + println!("Error starting member listener: {}", e); + false + } + } +} diff --git a/rustybits/src/pubsub/change_listener.rs b/rustybits/src/pubsub/change_listener.rs new file mode 100644 index 0000000000..f02c0bca5e --- /dev/null +++ b/rustybits/src/pubsub/change_listener.rs @@ -0,0 +1,120 @@ +use gcloud_pubsub::client::{Client, ClientConfig}; +use gcloud_pubsub::subscription::SubscriptionConfig; +use gcloud_pubsub::topic::Topic; +use std::time::Duration; +use tokio::sync::mpsc::Sender; +use tokio_util::sync::CancellationToken; + +pub struct ChangeListener { + client: Client, + topic: Topic, + subscription_name: String, + controller_id: String, + listen_timeout: Duration, + sender: Sender>, +} + +impl ChangeListener { + pub async fn new( + controller_id: &str, + topic_name: &str, + subscription_name: &str, + listen_timeout: Duration, + sender: Sender>, + ) -> Result> { + let config = ClientConfig::default().with_auth().await.unwrap(); + let client = Client::new(config).await?; + let topic = client.topic(topic_name); + Ok(Self { + client, + topic, + subscription_name: subscription_name.to_string(), + controller_id: controller_id.to_string(), + listen_timeout, + sender, + }) + } + + pub async fn listen(&self) -> Result<(), Box> { + let config = SubscriptionConfig { + enable_message_ordering: true, + filter: format!("attributes.controller_id = '{}'", self.controller_id), + ..Default::default() + }; + + let subscription = self.client.subscription(self.subscription_name.as_str()); + if !subscription.exists(None).await? { + subscription + .create(self.topic.fully_qualified_name(), config, None) + .await?; + } + + let cancel = CancellationToken::new(); + let cancel2 = cancel.clone(); + + let listen_timeout = self.listen_timeout.clone(); + tokio::spawn(async move { + tokio::time::sleep(listen_timeout).await; + cancel2.cancel(); + }); + + let tx = self.sender.clone(); + let _ = subscription + .receive( + move |message, _cancel| { + let tx2 = tx.clone(); + async move { + let data = message.message.data.clone(); + + match tx2.send(data.to_vec()).await { + Ok(_) => println!("Message sent successfully"), + Err(e) => eprintln!("Failed to send message: {}", e), + } + + match message.ack().await { + Ok(_) => println!("Message acknowledged"), + Err(e) => eprintln!("Failed to acknowledge message: {}", e), + } + } + }, + cancel.clone(), + None, + ) + .await; + + Ok(()) + } +} + +#[cfg(test)] +mod tests { + // use super::*; + + // use testcontainers::runners::AsyncRunner; + // use testcontainers_modules::google_cloud_sdk_emulators; + // use tokio; + + // #[tokio::test(flavor = "multi_thread", worker_threads = 1)] + // async fn setup_pubsub_emulator() -> Result<(), Box> { + // let container = google_cloud_sdk_emulators::CloudSdk::pubsub().start().await?; + + // let port = container.get_host_port_ipv4(8085).await?; + // let host = format!("localhost:{}", port); + + // unsafe { + // std::env::set_var("PUBSUB_EMULATOR_HOST", host); + // } + + // let cl = ChangeListener::new( + // "test_controller", + // "test_topic", + // "test_subscription", + // Duration::from_secs(10), + // ) + // .await; + + // assert!(cl.is_ok(), "Failed to connect to pubsub emulator: {:?}", cl.err()); + + // Ok(()) + // } +} diff --git a/rustybits/src/pubsub/member.proto b/rustybits/src/pubsub/member.proto new file mode 100644 index 0000000000..cdf8cc1698 --- /dev/null +++ b/rustybits/src/pubsub/member.proto @@ -0,0 +1,37 @@ +syntax = "proto3"; + +import "metadata.proto"; + +package pbmessages; + +message Member { + string device_id = 1; + string network_id = 2; + string identity = 3; // Identity of the member + bool authorized = 4; // Whether the member is authorized + repeated string ip_assignments = 5; // List of IP assignments + bool active_bridge = 6; // Whether the member is an active bridge + string tags = 7; // JSON string of tags + string capabilities = 8; // JSON string of capabilities + uint64 creation_time = 9; // Unix timestamp in milliseconds + bool no_auto_assign_ips = 10; // Whether auto IP assignment is disabled + uint64 revision = 11; // Revision number + uint64 last_authorized_time = 12; // Last time the member was authorized + uint64 last_deauthorized_time = 13; // Last time the member was deauthorized + optional string last_authorized_credential_type = 14; // Type of credential used for last authorization + optional string last_authorized_credential = 15; // Credential used for last authorization + int32 version_major = 16; // Major version of the member + int32 version_minor = 17; // Minor version of the member + int32 version_rev = 18; // Patch version of the member + int32 version_protocol = 19; // Protocol version of the member + int32 remote_trace_level = 20; // Remote trace level + optional string remote_trace_target = 21; // Remote trace target + bool sso_exepmt = 22; // Whether SSO is exempt + uint64 auth_expiry_time = 23; // Authorization expiry time in milliseconds +} + +message MemberChange { + optional Member old = 1; + optional Member new = 2; + optional Metadata metadata = 3; +} diff --git a/rustybits/src/pubsub/member_listener.rs b/rustybits/src/pubsub/member_listener.rs new file mode 100644 index 0000000000..f379e17c7e --- /dev/null +++ b/rustybits/src/pubsub/member_listener.rs @@ -0,0 +1,53 @@ +use crate::pubsub::change_listener::ChangeListener; +use crate::pubsub::protobuf::pbmessages::MemberChange; +use prost::Message; +use std::sync::Arc; +use std::time::Duration; +use tokio::sync::mpsc::Receiver; +use tokio::sync::Mutex; + +/** + * Member Listener listens for member changes and passes them back to the controller + * + * This is a wrapper around ChangeListener that specifically handles member changes. + * It uses a Tokio channel to receive messages and decodes them into MemberChange messages. + */ +pub struct MemberListener { + change_listener: ChangeListener, + rx_channel: Mutex>>, +} + +impl MemberListener { + pub async fn new(controller_id: &str, listen_timeout: Duration) -> Result, Box> { + let (tx, rx) = tokio::sync::mpsc::channel(64); + + let change_listener = ChangeListener::new( + controller_id, + "controller-member-change-stream", + format!("{}-member-change-subscription", controller_id).as_str(), + listen_timeout, + tx, + ) + .await?; + + Ok(Arc::new(Self { change_listener, rx_channel: Mutex::new(rx) })) + } + + pub async fn listen(&self) -> Result<(), Box> { + self.change_listener.listen().await + } + + pub fn change_handler(self: Arc) -> Result<(), Box> { + let this = self.clone(); + tokio::spawn(async move { + let mut rx = this.rx_channel.lock().await; + while let Some(change) = rx.recv().await { + if let Ok(m) = MemberChange::decode(change.as_slice()) { + print!("Received change: {:?}", m); + } + } + }); + + Ok(()) + } +} diff --git a/rustybits/src/pubsub/member_status.proto b/rustybits/src/pubsub/member_status.proto new file mode 100644 index 0000000000..74e5900896 --- /dev/null +++ b/rustybits/src/pubsub/member_status.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +package pbmessages; + +import "metadata.proto"; + +message MemberStatus { + Metadata metadata = 1; + string network_id = 2; + string member_id = 3; + uint64 timestamp = 4; // Unix timestamp in milliseconds + optional string ip_address = 5; // Optional IP address of the member + optional string os = 6; + optional string arch = 7; + optional string version = 8; +} \ No newline at end of file diff --git a/rustybits/src/pubsub/metadata.proto b/rustybits/src/pubsub/metadata.proto new file mode 100644 index 0000000000..a5e75dac40 --- /dev/null +++ b/rustybits/src/pubsub/metadata.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; + +package pbmessages; + +message Metadata { + string trace_id = 1; + string controller_id = 2; +} \ No newline at end of file diff --git a/rustybits/src/pubsub/mod.rs b/rustybits/src/pubsub/mod.rs index 719f52e595..8d5f2a5b0b 100644 --- a/rustybits/src/pubsub/mod.rs +++ b/rustybits/src/pubsub/mod.rs @@ -1,5 +1,5 @@ /* - * Copyright (c)2023 ZeroTier, Inc. + * Copyright (c)2025 ZeroTier, Inc. * * Use of this software is governed by the Business Source License included * in the LICENSE.TXT file in the project's root directory. @@ -9,21 +9,7 @@ * On the date above, in accordance with the Business Source License, use * of this software will be governed by version 2.0 of the Apache License. */ - -use gcloud_pubsub::client::{Client, ClientConfig}; - -pub struct PubSubClient { - client: Client, -} - -impl PubSubClient { - pub async fn new() -> Result> { - let config = ClientConfig::default().with_auth().await.unwrap(); - let client = Client::new(config).await?; - - // Assuming a topic name is required for the client - let topic_name = "default-topic".to_string(); - - Ok(Self { client }) - } -} +mod change_listener; +pub mod member_listener; +pub mod network_listener; +mod protobuf; diff --git a/rustybits/src/pubsub/network.proto b/rustybits/src/pubsub/network.proto new file mode 100644 index 0000000000..cf2586fe2f --- /dev/null +++ b/rustybits/src/pubsub/network.proto @@ -0,0 +1,62 @@ +syntax = "proto3"; + +import "metadata.proto"; + +package pbmessages; + +message IPRange { + string start_ip = 1; // Start of the IP range + string end_ip = 2; // End of the IP range +} + +message Route { + string target = 1; // Target IP or network + optional string via = 2; // Optional next hop IP +} + +message DNS { + string domain = 1; // Search domain + repeated string nameservers = 2; // List of nameservers +} + +message IPV4AssignMode { + bool zt = 1; // Whether ZeroTier is used for IPv4 assignment +} + +message IPv6AssignMode { + bool six_plane = 1; // Whether 6plane is used for IPv6 assignment + bool rfc4193 = 2; // Whether RFC 4193 is used for IPv6 assignment + bool zt = 3; // Whether ZeroTier is used for IPv6 assignment +} + +message Network { + string network_id = 1; + string capabilities = 2; // JSON string of capabilities + uint64 creation_time = 3; // Unix timestamp in milliseconds + bool enable_broadcast = 4; // Whether broadcast is enabled + repeated IPRange assignment_pools = 5; // List of IP ranges for assignment + uint32 mtu = 6; // Maximum Transmission Unit + uint32 multicast_limit = 7; // Limit for multicast messages + optional string name = 8; // Name of the network + bool is_private = 9; // Whether the network is private + uint32 remote_trace_level = 10; // Remote trace level + optional string remote_trace_target = 11; // Remote trace target + uint64 revision = 12; // Revision number + repeated Route routes = 13; // List of routes + string rules = 14; // JSON string of rules + optional string tags = 15; // JSON string of tags + IPV4AssignMode ipv4_assign_mode = 16; // IPv4 assignment mode + IPv6AssignMode ipv6_assign_mode = 17; // IPv6 assignment mode + optional DNS dns = 18; // DNS configuration + bool sso_enabled = 19; // Whether Single Sign-On is enabled + optional string sso_client_id = 20; // SSO client ID + optional string sso_authorization_endpoint = 21; // SSO authorization endpoint + optional string sso_issuer = 22; // SSO issuer + optional string sso_provider = 23; // SSO provider +} + +message NetworkChange { + optional Network old = 1; + optional Network new = 2; + optional Metadata metadata = 3; +} diff --git a/rustybits/src/pubsub/network_listener.rs b/rustybits/src/pubsub/network_listener.rs new file mode 100644 index 0000000000..e97bc74d7f --- /dev/null +++ b/rustybits/src/pubsub/network_listener.rs @@ -0,0 +1,54 @@ +use crate::pubsub::change_listener::ChangeListener; +use crate::pubsub::protobuf::pbmessages::NetworkChange; +use prost::Message; +use serde_json; +use std::sync::Arc; +use std::time::Duration; +use tokio::sync::mpsc::Receiver; +use tokio::sync::Mutex; + +/** + * Network Listener listens for network changes and passes them back to the controller + * + * This is a wrapper around ChangeListener that specifically handles network changes. + * It uses a Tokio channel to receive messages and decodes them into NetworkChange messages. + */ +pub struct NetworkListener { + change_listener: ChangeListener, + rx_channel: Mutex>>, +} + +impl NetworkListener { + pub async fn new(controller_id: &str, listen_timeout: Duration) -> Result, Box> { + let (tx, rx) = tokio::sync::mpsc::channel(64); + + let change_listener = ChangeListener::new( + controller_id, + "controller-network-change-stream", + format!("{}-network-change-subscription", controller_id).as_str(), + listen_timeout, + tx, + ) + .await?; + Ok(Arc::new(Self { change_listener, rx_channel: Mutex::new(rx) })) + } + + pub async fn listen(&self) -> Result<(), Box> { + self.change_listener.listen().await + } + + pub fn change_handler(self: Arc) -> Result<(), Box> { + let this = self.clone(); + tokio::spawn(async move { + let mut rx = this.rx_channel.lock().await; + while let Some(change) = rx.recv().await { + if let Ok(m) = NetworkChange::decode(change.as_slice()) { + let j = serde_json::to_string(&m).unwrap(); + print!("Received change: {:?}", j); + } + } + }); + + Ok(()) + } +} diff --git a/rustybits/src/pubsub/protobuf.rs b/rustybits/src/pubsub/protobuf.rs new file mode 100644 index 0000000000..aa26148657 --- /dev/null +++ b/rustybits/src/pubsub/protobuf.rs @@ -0,0 +1,3 @@ +pub(crate) mod pbmessages { + include!(concat!(env!("OUT_DIR"), "/pbmessages.rs")); +} From 0e94891e5b4031d2f5abf946655424f9bdd4bc81 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 13 Aug 2025 12:17:03 -0700 Subject: [PATCH 009/245] plumb through callbacks --- rustybits/src/ext.rs | 16 ++++++- rustybits/src/pubsub/change_listener.rs | 55 ++++++++++++++---------- rustybits/src/pubsub/member_listener.rs | 36 +++++++++++++++- rustybits/src/pubsub/network_listener.rs | 38 ++++++++++++++-- 4 files changed, 115 insertions(+), 30 deletions(-) diff --git a/rustybits/src/ext.rs b/rustybits/src/ext.rs index 7f933de349..8378d9921a 100644 --- a/rustybits/src/ext.rs +++ b/rustybits/src/ext.rs @@ -12,8 +12,11 @@ use std::ffi::{CStr, CString}; use std::os::raw::c_char; +#[cfg(feature = "ztcontroller")] +use std::os::raw::c_void; use std::sync::Arc; use std::time::Duration; +#[cfg(feature = "ztcontroller")] use tokio::runtime; use url::Url; @@ -495,11 +498,18 @@ use crate::pubsub::member_listener::MemberListener; #[cfg(feature = "ztcontroller")] use crate::pubsub::network_listener::NetworkListener; +#[cfg(feature = "ztcontroller")] +use crate::pubsub::member_listener::MemberListenerCallback; +#[cfg(feature = "ztcontroller")] +use crate::pubsub::network_listener::NetworkListenerCallback; + #[cfg(feature = "ztcontroller")] #[no_mangle] pub unsafe extern "C" fn init_network_listener( controller_id: *const c_char, listen_timeout: u64, + callback: NetworkListenerCallback, + user_ptr: *mut c_void, ) -> *const Arc { if listen_timeout == 0 { println!("listen_timeout is zero"); @@ -514,7 +524,7 @@ pub unsafe extern "C" fn init_network_listener( let rt = runtime::Handle::current(); rt.block_on(async { - match NetworkListener::new(id, Duration::from_secs(listen_timeout)).await { + match NetworkListener::new(id, Duration::from_secs(listen_timeout), callback, user_ptr).await { Ok(listener) => Arc::into_raw(Arc::new(listener)), Err(e) => { println!("error creating network listener: {}", e); @@ -562,6 +572,8 @@ pub unsafe extern "C" fn network_listener_listen(ptr: *const Arc *const Arc { if listen_timeout == 0 { println!("listen_timeout is zero"); @@ -576,7 +588,7 @@ pub unsafe extern "C" fn init_member_listener( let rt = runtime::Handle::current(); rt.block_on(async { - match MemberListener::new(id, Duration::from_secs(listen_timeout)).await { + match MemberListener::new(id, Duration::from_secs(listen_timeout), callback, user_ptr).await { Ok(listener) => Arc::into_raw(Arc::new(listener)), Err(e) => { println!("error creating member listener: {}", e); diff --git a/rustybits/src/pubsub/change_listener.rs b/rustybits/src/pubsub/change_listener.rs index f02c0bca5e..eab3f8e314 100644 --- a/rustybits/src/pubsub/change_listener.rs +++ b/rustybits/src/pubsub/change_listener.rs @@ -88,33 +88,42 @@ impl ChangeListener { #[cfg(test)] mod tests { - // use super::*; - - // use testcontainers::runners::AsyncRunner; - // use testcontainers_modules::google_cloud_sdk_emulators; - // use tokio; + use super::*; + + use testcontainers::runners::AsyncRunner; + use testcontainers::ContainerAsync; + use testcontainers_modules::google_cloud_sdk_emulators; + use testcontainers_modules::google_cloud_sdk_emulators::CloudSdk; + use tokio; + + async fn setup_pubsub_emulator() -> Result<(ContainerAsync, String), Box> { + let container = google_cloud_sdk_emulators::CloudSdk::pubsub().start().await?; + let port = container.get_host_port_ipv4(8085).await?; + let host = format!("localhost:{}", port); + Ok((container, host)) + } - // #[tokio::test(flavor = "multi_thread", worker_threads = 1)] - // async fn setup_pubsub_emulator() -> Result<(), Box> { - // let container = google_cloud_sdk_emulators::CloudSdk::pubsub().start().await?; + #[tokio::test(flavor = "multi_thread", worker_threads = 1)] + async fn test_can_connect_to_pubsub() -> Result<(), Box> { + let (_container, host) = setup_pubsub_emulator().await?; - // let port = container.get_host_port_ipv4(8085).await?; - // let host = format!("localhost:{}", port); + unsafe { + std::env::set_var("PUBSUB_EMULATOR_HOST", host); + } - // unsafe { - // std::env::set_var("PUBSUB_EMULATOR_HOST", host); - // } + let (tx, _rx) = tokio::sync::mpsc::channel(64); - // let cl = ChangeListener::new( - // "test_controller", - // "test_topic", - // "test_subscription", - // Duration::from_secs(10), - // ) - // .await; + let cl = ChangeListener::new( + "test_controller", + "test_topic", + "test_subscription", + Duration::from_secs(10), + tx, + ) + .await; - // assert!(cl.is_ok(), "Failed to connect to pubsub emulator: {:?}", cl.err()); + assert!(cl.is_ok(), "Failed to connect to pubsub emulator: {:?}", cl.err()); - // Ok(()) - // } + Ok(()) + } } diff --git a/rustybits/src/pubsub/member_listener.rs b/rustybits/src/pubsub/member_listener.rs index f379e17c7e..7b647dd018 100644 --- a/rustybits/src/pubsub/member_listener.rs +++ b/rustybits/src/pubsub/member_listener.rs @@ -1,11 +1,16 @@ use crate::pubsub::change_listener::ChangeListener; use crate::pubsub::protobuf::pbmessages::MemberChange; use prost::Message; +use std::io::Write; +use std::os::raw::c_void; +use std::sync::atomic::AtomicPtr; use std::sync::Arc; use std::time::Duration; use tokio::sync::mpsc::Receiver; use tokio::sync::Mutex; +pub type MemberListenerCallback = extern "C" fn(*const c_void, *const u8, usize); + /** * Member Listener listens for member changes and passes them back to the controller * @@ -15,10 +20,17 @@ use tokio::sync::Mutex; pub struct MemberListener { change_listener: ChangeListener, rx_channel: Mutex>>, + callback: Mutex, + user_ptr: AtomicPtr, } impl MemberListener { - pub async fn new(controller_id: &str, listen_timeout: Duration) -> Result, Box> { + pub async fn new( + controller_id: &str, + listen_timeout: Duration, + callback: MemberListenerCallback, + user_ptr: *mut c_void, + ) -> Result, Box> { let (tx, rx) = tokio::sync::mpsc::channel(64); let change_listener = ChangeListener::new( @@ -30,7 +42,12 @@ impl MemberListener { ) .await?; - Ok(Arc::new(Self { change_listener, rx_channel: Mutex::new(rx) })) + Ok(Arc::new(Self { + change_listener, + rx_channel: Mutex::new(rx), + callback: Mutex::new(callback), + user_ptr: AtomicPtr::new(user_ptr as *mut c_void), + })) } pub async fn listen(&self) -> Result<(), Box> { @@ -44,6 +61,21 @@ impl MemberListener { while let Some(change) = rx.recv().await { if let Ok(m) = MemberChange::decode(change.as_slice()) { print!("Received change: {:?}", m); + + let j = serde_json::to_string(&m).unwrap(); + let mut buffer = [0; 16384]; + let mut test: &mut [u8] = &mut buffer; + let mut size: usize = 0; + while let Ok(bytes) = test.write(j.as_bytes()) { + if bytes == 0 { + break; + } + size += bytes; + } + let callback = this.callback.lock().await; + let user_ptr = this.user_ptr.load(std::sync::atomic::Ordering::Relaxed); + + (callback)(user_ptr, test.as_ptr(), size); } } }); diff --git a/rustybits/src/pubsub/network_listener.rs b/rustybits/src/pubsub/network_listener.rs index e97bc74d7f..111bab8934 100644 --- a/rustybits/src/pubsub/network_listener.rs +++ b/rustybits/src/pubsub/network_listener.rs @@ -2,11 +2,16 @@ use crate::pubsub::change_listener::ChangeListener; use crate::pubsub::protobuf::pbmessages::NetworkChange; use prost::Message; use serde_json; +use std::io::Write; +use std::os::raw::c_void; +use std::sync::atomic::{AtomicPtr, Ordering}; use std::sync::Arc; use std::time::Duration; use tokio::sync::mpsc::Receiver; use tokio::sync::Mutex; +pub type NetworkListenerCallback = extern "C" fn(*mut c_void, *const u8, usize); + /** * Network Listener listens for network changes and passes them back to the controller * @@ -16,10 +21,17 @@ use tokio::sync::Mutex; pub struct NetworkListener { change_listener: ChangeListener, rx_channel: Mutex>>, + callback: Mutex, + user_ptr: AtomicPtr, } impl NetworkListener { - pub async fn new(controller_id: &str, listen_timeout: Duration) -> Result, Box> { + pub async fn new( + controller_id: &str, + listen_timeout: Duration, + callback: NetworkListenerCallback, + user_ptr: *mut c_void, + ) -> Result, Box> { let (tx, rx) = tokio::sync::mpsc::channel(64); let change_listener = ChangeListener::new( @@ -30,7 +42,13 @@ impl NetworkListener { tx, ) .await?; - Ok(Arc::new(Self { change_listener, rx_channel: Mutex::new(rx) })) + + Ok(Arc::new(Self { + change_listener, + rx_channel: Mutex::new(rx), + callback: Mutex::new(callback), + user_ptr: AtomicPtr::new(user_ptr as *mut c_void), + })) } pub async fn listen(&self) -> Result<(), Box> { @@ -43,8 +61,22 @@ impl NetworkListener { let mut rx = this.rx_channel.lock().await; while let Some(change) = rx.recv().await { if let Ok(m) = NetworkChange::decode(change.as_slice()) { + print!("Received change: {:?}", m); + let j = serde_json::to_string(&m).unwrap(); - print!("Received change: {:?}", j); + let mut buffer = [0; 16384]; + let mut test: &mut [u8] = &mut buffer; + let mut size: usize = 0; + while let Ok(bytes) = test.write(j.as_bytes()) { + if bytes == 0 { + break; // No more space to write + } + size += bytes; + } + let callback = this.callback.lock().await; + let user_ptr = this.user_ptr.load(Ordering::Relaxed); + + (callback)(user_ptr, test.as_ptr(), size); } } }); From bf8c9d01246e66c8e18e3f31b39d7b53e481d4d2 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 13 Aug 2025 12:25:36 -0700 Subject: [PATCH 010/245] function naming cleanup. match other things already written --- rustybits/src/ext.rs | 4 ++-- rustybits/src/pubsub/member_listener.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rustybits/src/ext.rs b/rustybits/src/ext.rs index 8378d9921a..7aa850e653 100644 --- a/rustybits/src/ext.rs +++ b/rustybits/src/ext.rs @@ -505,7 +505,7 @@ use crate::pubsub::network_listener::NetworkListenerCallback; #[cfg(feature = "ztcontroller")] #[no_mangle] -pub unsafe extern "C" fn init_network_listener( +pub unsafe extern "C" fn network_listener_new( controller_id: *const c_char, listen_timeout: u64, callback: NetworkListenerCallback, @@ -569,7 +569,7 @@ pub unsafe extern "C" fn network_listener_listen(ptr: *const Arc Date: Thu, 14 Aug 2025 12:31:42 -0700 Subject: [PATCH 011/245] updates & tests. Tests currently need to be run with --test-threads=1. Seems like the instances of the pubsub emulator stomp on each other without that --- rustybits/Cargo.lock | 2 + rustybits/Cargo.toml | 14 +- rustybits/src/ext.rs | 2 + rustybits/src/pubsub/change_listener.rs | 29 +++- rustybits/src/pubsub/member_listener.rs | 185 ++++++++++++++++++++--- rustybits/src/pubsub/network_listener.rs | 185 ++++++++++++++++++++--- 6 files changed, 368 insertions(+), 49 deletions(-) diff --git a/rustybits/Cargo.lock b/rustybits/Cargo.lock index 1f0d775218..fd6b37a348 100644 --- a/rustybits/Cargo.lock +++ b/rustybits/Cargo.lock @@ -3101,6 +3101,8 @@ dependencies = [ "base64 0.21.7", "bytes", "cbindgen", + "gcloud-gax", + "gcloud-googleapis", "gcloud-pubsub", "jwt", "openidconnect", diff --git a/rustybits/Cargo.toml b/rustybits/Cargo.toml index 3f0f82b5cf..6c1cfeb3bd 100644 --- a/rustybits/Cargo.toml +++ b/rustybits/Cargo.toml @@ -18,6 +18,10 @@ ztcontroller = [ "dep:gcloud-pubsub", "dep:prost", "dep:prost-types", + "dep:gcloud-gax", + "dep:gcloud-googleapis", + "dep:tokio", + "dep:tokio-util", ] [dependencies] @@ -28,8 +32,12 @@ temporal-client = { git = "https://github.com/temporalio/sdk-core", branch = "ma "telemetry", ] } temporal-sdk-core-protos = { git = "https://github.com/temporalio/sdk-core", branch = "master", optional = true } -tokio = { version = "1.43", features = ["full", "rt", "macros"] } -tokio-util = { version = "0.7" } +tokio = { version = "1.43", features = [ + "full", + "rt", + "macros", +], optional = true } +tokio-util = { version = "0.7", optional = true } uuid = { version = "1.4", features = ["v4"] } openidconnect = { version = "3.4", default-features = false, features = [ "reqwest", @@ -46,6 +54,8 @@ thiserror = "1" gcloud-pubsub = { version = "1.3.0", optional = true } prost = { version = "0.14", optional = true, features = ["derive"] } prost-types = { version = "0.14", optional = true } +gcloud-gax = { version = "1.2.0", optional = true } +gcloud-googleapis = { version = "1.2.0", optional = true } [dev-dependencies] testcontainers = { version = "0.24", features = ["blocking"] } diff --git a/rustybits/src/ext.rs b/rustybits/src/ext.rs index 7aa850e653..83fb864e61 100644 --- a/rustybits/src/ext.rs +++ b/rustybits/src/ext.rs @@ -25,6 +25,7 @@ static mut RT: Option = None; static START: std::sync::Once = std::sync::Once::new(); static SHUTDOWN: std::sync::Once = std::sync::Once::new(); +#[cfg(feature = "ztcontroller")] #[no_mangle] pub unsafe extern "C" fn init_async_runtime() { START.call_once(|| { @@ -39,6 +40,7 @@ pub unsafe extern "C" fn init_async_runtime() { }); } +#[cfg(feature = "ztcontroller")] #[no_mangle] #[allow(static_mut_refs)] pub unsafe extern "C" fn shutdown_async_runtime() { diff --git a/rustybits/src/pubsub/change_listener.rs b/rustybits/src/pubsub/change_listener.rs index eab3f8e314..c5ae1f9257 100644 --- a/rustybits/src/pubsub/change_listener.rs +++ b/rustybits/src/pubsub/change_listener.rs @@ -24,7 +24,12 @@ impl ChangeListener { ) -> Result> { let config = ClientConfig::default().with_auth().await.unwrap(); let client = Client::new(config).await?; + let topic = client.topic(topic_name); + if !topic.exists(None).await? { + topic.create(None, None).await?; + } + Ok(Self { client, topic, @@ -35,6 +40,14 @@ impl ChangeListener { }) } + /** + * Listens for changes on the topic and sends them to the provided sender. + * + * Listens for up to `listen_timeout` duration, at which point it will stop listening + * and return. listen will have to be called again to continue listening. + * + * If the subscription does not exist, it will create it with the specified configuration. + */ pub async fn listen(&self) -> Result<(), Box> { let config = SubscriptionConfig { enable_message_ordering: true, @@ -87,7 +100,7 @@ impl ChangeListener { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use testcontainers::runners::AsyncRunner; @@ -96,20 +109,22 @@ mod tests { use testcontainers_modules::google_cloud_sdk_emulators::CloudSdk; use tokio; - async fn setup_pubsub_emulator() -> Result<(ContainerAsync, String), Box> { + pub(crate) async fn setup_pubsub_emulator() -> Result<(ContainerAsync, String), Box> + { let container = google_cloud_sdk_emulators::CloudSdk::pubsub().start().await?; let port = container.get_host_port_ipv4(8085).await?; let host = format!("localhost:{}", port); + + unsafe { + std::env::set_var("PUBSUB_EMULATOR_HOST", host.clone()); + } + Ok((container, host)) } #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn test_can_connect_to_pubsub() -> Result<(), Box> { - let (_container, host) = setup_pubsub_emulator().await?; - - unsafe { - std::env::set_var("PUBSUB_EMULATOR_HOST", host); - } + let (_container, _host) = setup_pubsub_emulator().await?; let (tx, _rx) = tokio::sync::mpsc::channel(64); diff --git a/rustybits/src/pubsub/member_listener.rs b/rustybits/src/pubsub/member_listener.rs index 860e59cc45..993eaed14f 100644 --- a/rustybits/src/pubsub/member_listener.rs +++ b/rustybits/src/pubsub/member_listener.rs @@ -50,36 +50,181 @@ impl MemberListener { })) } - pub async fn listen(&self) -> Result<(), Box> { + pub async fn listen(self: &Arc) -> Result<(), Box> { self.change_listener.listen().await } - pub fn change_handler(self: Arc) -> Result<(), Box> { + pub async fn change_handler(self: &Arc) -> Result<(), Box> { let this = self.clone(); - tokio::spawn(async move { - let mut rx = this.rx_channel.lock().await; - while let Some(change) = rx.recv().await { - if let Ok(m) = MemberChange::decode(change.as_slice()) { - print!("Received change: {:?}", m); - - let j = serde_json::to_string(&m).unwrap(); - let mut buffer = [0; 16384]; - let mut test: &mut [u8] = &mut buffer; - let mut size: usize = 0; - while let Ok(bytes) = test.write(j.as_bytes()) { - if bytes == 0 { - break; + + let mut rx = this.rx_channel.lock().await; + while let Some(change) = rx.recv().await { + if let Ok(m) = MemberChange::decode(change.as_slice()) { + let j = serde_json::to_string(&m).unwrap(); + let mut buffer = [0; 16384]; + let mut test: &mut [u8] = &mut buffer; + let mut size: usize = 0; + while let Ok(bytes) = test.write(j.as_bytes()) { + if bytes == 0 { + break; + } + size += bytes; + } + let callback = this.callback.lock().await; + let user_ptr = this.user_ptr.load(std::sync::atomic::Ordering::Relaxed); + + (callback)(user_ptr, test.as_ptr(), size); + } else { + eprintln!("Failed to decode change"); + } + } + + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::pubsub::change_listener::tests::setup_pubsub_emulator; + use crate::pubsub::protobuf::pbmessages::{Member, MemberChange}; + + use gcloud_googleapis::pubsub::v1::PubsubMessage; + use gcloud_pubsub::client::{Client, ClientConfig}; + use std::{ + collections::HashMap, + sync::atomic::{AtomicBool, Ordering}, + }; + + extern "C" fn dummy_callback(user_ptr: *mut c_void, data: *const u8, _size: usize) { + // Dummy callback for testing + assert!(!data.is_null(), "data pointer is null"); + assert!(!user_ptr.is_null(), "user_ptr pointer is null"); + let user_ptr = unsafe { &mut *(user_ptr as *mut TestMemberListener) }; + user_ptr.callback_called(); + println!("Dummy callback invoked"); + } + + struct TestMemberListener { + dummy_callback_called: bool, + } + + impl TestMemberListener { + fn new() -> Self { + Self { dummy_callback_called: false } + } + + fn callback_called(&mut self) { + self.dummy_callback_called = true; + } + } + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_member_listener() { + println!("Setting up Pub/Sub emulator for network listener test"); + let (_container, _host) = setup_pubsub_emulator().await.unwrap(); + let mut tester = TestMemberListener::new(); + + let listener = MemberListener::new( + "testctl", + Duration::from_secs(1), + dummy_callback, + &mut tester as *mut TestMemberListener as *mut c_void, + ) + .await + .unwrap(); + + let rt = tokio::runtime::Handle::current(); + + let run = Arc::new(AtomicBool::new(true)); + rt.spawn({ + let run = run.clone(); + let l = listener.clone(); + async move { + while run.load(Ordering::Relaxed) { + match l.listen().await { + Ok(_) => { + println!("Listener exited successfully"); + } + Err(e) => { + println!("Failed to start listener: {}", e); + assert!(false, "Listener failed to start"); } - size += bytes; } - let callback = this.callback.lock().await; - let user_ptr = this.user_ptr.load(std::sync::atomic::Ordering::Relaxed); + } + } + }); - (callback)(user_ptr, test.as_ptr(), size); + rt.spawn({ + let run = run.clone(); + let l = listener.clone(); + async move { + while run.load(Ordering::Relaxed) { + match l.change_handler().await { + Ok(_) => { + println!("Change handler started successfully"); + } + Err(e) => { + println!("Failed to start change handler: {}", e); + assert!(false, "Change handler failed to start"); + } + } } } }); - Ok(()) + rt.spawn({ + async move { + let client = Client::new(ClientConfig::default()).await.unwrap(); + let topic = client.topic("controller-member-change-stream"); + if !topic.exists(None).await.unwrap() { + topic.create(None, None).await.unwrap(); + } + + let mut publisher = topic.new_publisher(None); + + let nc = MemberChange { + old: Some(Member { + device_id: "test_member".to_string(), + network_id: "test_network".to_string(), + authorized: false, + ..Default::default() + }), + new: Some(Member { + device_id: "test_member".to_string(), + network_id: "test_network".to_string(), + authorized: true, + ..Default::default() + }), + ..Default::default() + }; + + let data = MemberChange::encode_to_vec(&nc); + let message = PubsubMessage { + data: data.into(), + attributes: HashMap::from([("controller_id".to_string(), "testctl".to_string())]), + ordering_key: format!("members-{}", "test_network"), + ..Default::default() + }; + let awaiter = publisher.publish(message).await; + + match awaiter.get().await { + Ok(_) => println!("Message published successfully"), + Err(e) => { + assert!(false, "Failed to publish message: {}", e); + eprintln!("Failed to publish message: {}", e) + } + } + publisher.shutdown().await; + } + }); + + let mut counter = 0; + while !tester.dummy_callback_called && counter < 100 { + tokio::time::sleep(Duration::from_millis(100)).await; + counter += 1; + } + run.store(false, Ordering::Relaxed); + assert!(tester.dummy_callback_called, "Callback was not called"); } } diff --git a/rustybits/src/pubsub/network_listener.rs b/rustybits/src/pubsub/network_listener.rs index 111bab8934..987369220f 100644 --- a/rustybits/src/pubsub/network_listener.rs +++ b/rustybits/src/pubsub/network_listener.rs @@ -51,36 +51,181 @@ impl NetworkListener { })) } - pub async fn listen(&self) -> Result<(), Box> { + pub async fn listen(self: &Arc) -> Result<(), Box> { self.change_listener.listen().await } - pub fn change_handler(self: Arc) -> Result<(), Box> { + pub async fn change_handler(self: &Arc) -> Result<(), Box> { let this = self.clone(); - tokio::spawn(async move { - let mut rx = this.rx_channel.lock().await; - while let Some(change) = rx.recv().await { - if let Ok(m) = NetworkChange::decode(change.as_slice()) { - print!("Received change: {:?}", m); - - let j = serde_json::to_string(&m).unwrap(); - let mut buffer = [0; 16384]; - let mut test: &mut [u8] = &mut buffer; - let mut size: usize = 0; - while let Ok(bytes) = test.write(j.as_bytes()) { - if bytes == 0 { - break; // No more space to write + + let mut rx = this.rx_channel.lock().await; + while let Some(change) = rx.recv().await { + if let Ok(m) = NetworkChange::decode(change.as_slice()) { + let j = serde_json::to_string(&m).unwrap(); + let mut buffer = [0; 16384]; + let mut test: &mut [u8] = &mut buffer; + let mut size: usize = 0; + while let Ok(bytes) = test.write(j.as_bytes()) { + if bytes == 0 { + break; // No more space to write + } + size += bytes; + } + let callback = this.callback.lock().await; + let user_ptr = this.user_ptr.load(Ordering::Relaxed); + + (callback)(user_ptr, test.as_ptr(), size); + } else { + eprintln!("Failed to decode change"); + } + } + + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::pubsub::change_listener::tests::setup_pubsub_emulator; + use crate::pubsub::protobuf::pbmessages::Network; + + use gcloud_googleapis::pubsub::v1::PubsubMessage; + use gcloud_pubsub::client::{Client, ClientConfig}; + use std::{ + collections::HashMap, + sync::atomic::{AtomicBool, Ordering}, + }; + + extern "C" fn dummy_callback(user_ptr: *mut c_void, data: *const u8, _size: usize) { + // Dummy callback for testing + assert!(!data.is_null(), "data pointer is null"); + assert!(!user_ptr.is_null(), "user_ptr pointer is null"); + let user_ptr = unsafe { &mut *(user_ptr as *mut TestNetworkListenr) }; + user_ptr.callback_called(); + println!("Dummy callback invoked"); + } + + struct TestNetworkListenr { + dummy_callback_called: bool, + } + + impl TestNetworkListenr { + fn new() -> Self { + Self { dummy_callback_called: false } + } + + fn callback_called(&mut self) { + self.dummy_callback_called = true; + } + } + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn test_network_listener() { + println!("Setting up Pub/Sub emulator for network listener test"); + let (_container, _host) = setup_pubsub_emulator().await.unwrap(); + + let mut tester = TestNetworkListenr::new(); + + let listener = NetworkListener::new( + "testctl", + Duration::from_secs(1), + dummy_callback, + &mut tester as *mut TestNetworkListenr as *mut c_void, + ) + .await + .unwrap(); + + let rt = tokio::runtime::Handle::current(); + + let run = Arc::new(AtomicBool::new(true)); + rt.spawn({ + let run = run.clone(); + let l = listener.clone(); + async move { + while run.load(Ordering::Relaxed) { + match l.listen().await { + Ok(_) => { + println!("Listener exited successfully"); + } + Err(e) => { + println!("Failed to start listener: {}", e); + assert!(false, "Listener failed to start"); } - size += bytes; } - let callback = this.callback.lock().await; - let user_ptr = this.user_ptr.load(Ordering::Relaxed); + } + } + }); - (callback)(user_ptr, test.as_ptr(), size); + rt.spawn({ + let run = run.clone(); + let l = listener.clone(); + async move { + while run.load(Ordering::Relaxed) { + match l.change_handler().await { + Ok(_) => { + println!("Change handler started successfully"); + } + Err(e) => { + println!("Failed to start change handler: {}", e); + assert!(false, "Change handler failed to start"); + } + } } } }); - Ok(()) + rt.spawn({ + async move { + let client = Client::new(ClientConfig::default()).await.unwrap(); + let topic = client.topic("controller-network-change-stream"); + if !topic.exists(None).await.unwrap() { + topic.create(None, None).await.unwrap(); + } + + let mut publisher = topic.new_publisher(None); + + let nc = NetworkChange { + old: Some(Network { + network_id: "test_network".to_string(), + name: Some("Test Network".to_string()), + ..Default::default() + }), + new: Some(Network { + network_id: "test_network".to_string(), + name: Some("Test Network Updated".to_string()), + ..Default::default() + }), + ..Default::default() + }; + + let data = NetworkChange::encode_to_vec(&nc); + let message = PubsubMessage { + data: data.into(), + attributes: HashMap::from([("controller_id".to_string(), "testctl".to_string())]), + ordering_key: format!("networks-{}", "testctl"), + ..Default::default() + }; + let awaiter = publisher.publish(message).await; + + match awaiter.get().await { + Ok(_) => println!("Message published successfully"), + Err(e) => { + assert!(false, "Failed to publish message: {}", e); + eprintln!("Failed to publish message: {}", e) + } + } + publisher.shutdown().await; + } + }); + + let mut counter = 0; + while !tester.dummy_callback_called && counter < 100 { + tokio::time::sleep(Duration::from_millis(100)).await; + counter += 1; + } + + run.store(false, Ordering::Relaxed); + assert!(tester.dummy_callback_called, "Callback was not called"); } } From 3a209e29301ba69682ed2b89f1788d747891dc01 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 14 Aug 2025 12:43:00 -0700 Subject: [PATCH 012/245] expose change_handler to C via FFI --- rustybits/src/ext.rs | 60 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/rustybits/src/ext.rs b/rustybits/src/ext.rs index 83fb864e61..30ac7652b8 100644 --- a/rustybits/src/ext.rs +++ b/rustybits/src/ext.rs @@ -512,7 +512,7 @@ pub unsafe extern "C" fn network_listener_new( listen_timeout: u64, callback: NetworkListenerCallback, user_ptr: *mut c_void, -) -> *const Arc { +) -> *const NetworkListener { if listen_timeout == 0 { println!("listen_timeout is zero"); return std::ptr::null_mut(); @@ -527,7 +527,7 @@ pub unsafe extern "C" fn network_listener_new( let rt = runtime::Handle::current(); rt.block_on(async { match NetworkListener::new(id, Duration::from_secs(listen_timeout), callback, user_ptr).await { - Ok(listener) => Arc::into_raw(Arc::new(listener)), + Ok(listener) => Arc::into_raw(listener), Err(e) => { println!("error creating network listener: {}", e); std::ptr::null_mut() @@ -538,7 +538,7 @@ pub unsafe extern "C" fn network_listener_new( #[cfg(feature = "ztcontroller")] #[no_mangle] -pub unsafe extern "C" fn network_listener_delete(ptr: *const Arc) { +pub unsafe extern "C" fn network_listener_delete(ptr: *const NetworkListener) { if ptr.is_null() { return; } @@ -547,7 +547,7 @@ pub unsafe extern "C" fn network_listener_delete(ptr: *const Arc) -> bool { +pub unsafe extern "C" fn network_listener_listen(ptr: *const NetworkListener) -> bool { use std::mem::ManuallyDrop; if ptr.is_null() { println!("ptr is null"); @@ -569,6 +569,28 @@ pub unsafe extern "C" fn network_listener_listen(ptr: *const Arc { + println!("Network listener change listener completed successfully"); + } + Err(e) => { + println!("Error in network listener change listener: {}", e); + } + } +} + #[cfg(feature = "ztcontroller")] #[no_mangle] pub unsafe extern "C" fn member_listener_new( @@ -576,7 +598,7 @@ pub unsafe extern "C" fn member_listener_new( listen_timeout: u64, callback: MemberListenerCallback, user_ptr: *mut c_void, -) -> *const Arc { +) -> *const MemberListener { if listen_timeout == 0 { println!("listen_timeout is zero"); return std::ptr::null_mut(); @@ -591,7 +613,7 @@ pub unsafe extern "C" fn member_listener_new( let rt = runtime::Handle::current(); rt.block_on(async { match MemberListener::new(id, Duration::from_secs(listen_timeout), callback, user_ptr).await { - Ok(listener) => Arc::into_raw(Arc::new(listener)), + Ok(listener) => Arc::into_raw(listener), Err(e) => { println!("error creating member listener: {}", e); std::ptr::null_mut() @@ -602,7 +624,7 @@ pub unsafe extern "C" fn member_listener_new( #[cfg(feature = "ztcontroller")] #[no_mangle] -pub unsafe extern "C" fn member_listener_delete(ptr: *const Arc) { +pub unsafe extern "C" fn member_listener_delete(ptr: *const MemberListener) { if ptr.is_null() { return; } @@ -611,7 +633,7 @@ pub unsafe extern "C" fn member_listener_delete(ptr: *const Arc) #[cfg(feature = "ztcontroller")] #[no_mangle] -pub unsafe extern "C" fn member_listener_listen(ptr: *const Arc) -> bool { +pub unsafe extern "C" fn member_listener_listen(ptr: *const MemberListener) -> bool { use std::mem::ManuallyDrop; if ptr.is_null() { println!("ptr is null"); @@ -631,3 +653,25 @@ pub unsafe extern "C" fn member_listener_listen(ptr: *const Arc) } } } + +#[cfg(feature = "ztcontroller")] +#[no_mangle] +pub unsafe extern "C" fn member_listener_change_handler(ptr: *const MemberListener) { + use std::mem::ManuallyDrop; + if ptr.is_null() { + println!("ptr is null"); + return; + } + + let listener = ManuallyDrop::new(unsafe { Arc::from_raw(ptr) }); + + let rt = runtime::Handle::current(); + match rt.block_on(listener.change_handler()) { + Ok(_) => { + println!("Member listener change listener completed successfully"); + } + Err(e) => { + println!("Error in member listener change listener: {}", e); + } + } +} From a842ad8b61986ee3fbe6303140a4e145b0656793 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 14 Aug 2025 12:43:42 -0700 Subject: [PATCH 013/245] remove ztcontroller from default feature list --- rustybits/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rustybits/Cargo.toml b/rustybits/Cargo.toml index 6c1cfeb3bd..61888ab36f 100644 --- a/rustybits/Cargo.toml +++ b/rustybits/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" crate-type = ["staticlib", "rlib"] [features] -default = ["zeroidc", "ztcontroller"] +default = ["zeroidc"] zeroidc = [] ztcontroller = [ "dep:serde", From d4ee95e445177e40c635ae45b676b20547ea94dc Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 14 Aug 2025 12:51:22 -0700 Subject: [PATCH 014/245] feature cleanup --- rustybits/build.rs | 36 ++++++++++++++++++++++-------------- rustybits/src/ext.rs | 5 +++++ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/rustybits/build.rs b/rustybits/build.rs index 1d0d01e36b..451d4ac3a7 100644 --- a/rustybits/build.rs +++ b/rustybits/build.rs @@ -5,20 +5,28 @@ use std::env; use std::path::PathBuf; fn main() { - let mut prost_build = prost_build::Config::new(); - - prost_build - .type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]") - .compile_protos( - &[ - "src/pubsub/metadata.proto", - "src/pubsub/network.proto", - "src/pubsub/member.proto", - "src/pubsub/member_status.proto", - ], - &["src/pubsub/"], - ) - .expect("Failed to compile protobuf files"); + #[cfg(feature = "ztcontroller")] + { + // Ensure the `cbindgen` crate is available + cbindgen::generate("src/ext.rs") + .expect("Unable to generate bindings") + .write_to_file("rustybits.h"); + + let mut prost_build = prost_build::Config::new(); + + prost_build + .type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]") + .compile_protos( + &[ + "src/pubsub/metadata.proto", + "src/pubsub/network.proto", + "src/pubsub/member.proto", + "src/pubsub/member_status.proto", + ], + &["src/pubsub/"], + ) + .expect("Failed to compile protobuf files"); + } let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); diff --git a/rustybits/src/ext.rs b/rustybits/src/ext.rs index 30ac7652b8..50962d785f 100644 --- a/rustybits/src/ext.rs +++ b/rustybits/src/ext.rs @@ -14,15 +14,20 @@ use std::ffi::{CStr, CString}; use std::os::raw::c_char; #[cfg(feature = "ztcontroller")] use std::os::raw::c_void; +#[cfg(feature = "ztcontroller")] use std::sync::Arc; +#[cfg(feature = "ztcontroller")] use std::time::Duration; #[cfg(feature = "ztcontroller")] use tokio::runtime; use url::Url; +#[cfg(feature = "ztcontroller")] static mut RT: Option = None; +#[cfg(feature = "ztcontroller")] static START: std::sync::Once = std::sync::Once::new(); +#[cfg(feature = "ztcontroller")] static SHUTDOWN: std::sync::Once = std::sync::Once::new(); #[cfg(feature = "ztcontroller")] From e4147f7b80283214ad53b6141f67db86ed7b8f03 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 14 Aug 2025 13:00:11 -0700 Subject: [PATCH 015/245] fix build script --- rustybits/build.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/rustybits/build.rs b/rustybits/build.rs index 451d4ac3a7..c4b083adb5 100644 --- a/rustybits/build.rs +++ b/rustybits/build.rs @@ -3,15 +3,9 @@ extern crate cbindgen; use cbindgen::{Config, Language, MacroExpansionConfig}; use std::env; use std::path::PathBuf; - fn main() { #[cfg(feature = "ztcontroller")] { - // Ensure the `cbindgen` crate is available - cbindgen::generate("src/ext.rs") - .expect("Unable to generate bindings") - .write_to_file("rustybits.h"); - let mut prost_build = prost_build::Config::new(); prost_build From 4fab227c2380c0a2217fda7151e43e3979d60f18 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 14 Aug 2025 14:20:34 -0700 Subject: [PATCH 016/245] fix calling into async functions from non-async via the FFI --- rustybits/Cargo.lock | 1 + rustybits/Cargo.toml | 4 +++- rustybits/src/ext.rs | 20 ++++++++++++++------ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/rustybits/Cargo.lock b/rustybits/Cargo.lock index fd6b37a348..c037e3695a 100644 --- a/rustybits/Cargo.lock +++ b/rustybits/Cargo.lock @@ -3101,6 +3101,7 @@ dependencies = [ "base64 0.21.7", "bytes", "cbindgen", + "futures", "gcloud-gax", "gcloud-googleapis", "gcloud-pubsub", diff --git a/rustybits/Cargo.toml b/rustybits/Cargo.toml index 61888ab36f..a84bcc0ea8 100644 --- a/rustybits/Cargo.toml +++ b/rustybits/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" crate-type = ["staticlib", "rlib"] [features] -default = ["zeroidc"] +default = ["zeroidc", "ztcontroller"] zeroidc = [] ztcontroller = [ "dep:serde", @@ -22,6 +22,7 @@ ztcontroller = [ "dep:gcloud-googleapis", "dep:tokio", "dep:tokio-util", + "dep:futures", ] [dependencies] @@ -56,6 +57,7 @@ prost = { version = "0.14", optional = true, features = ["derive"] } prost-types = { version = "0.14", optional = true } gcloud-gax = { version = "1.2.0", optional = true } gcloud-googleapis = { version = "1.2.0", optional = true } +futures = { version = "0.3", optional = true } [dev-dependencies] testcontainers = { version = "0.24", features = ["blocking"] } diff --git a/rustybits/src/ext.rs b/rustybits/src/ext.rs index 50962d785f..1a21301ccf 100644 --- a/rustybits/src/ext.rs +++ b/rustybits/src/ext.rs @@ -530,7 +530,8 @@ pub unsafe extern "C" fn network_listener_new( let id = unsafe { CStr::from_ptr(controller_id) }.to_str().unwrap(); let rt = runtime::Handle::current(); - rt.block_on(async { + let _block = rt.enter(); + futures::executor::block_on(async { match NetworkListener::new(id, Duration::from_secs(listen_timeout), callback, user_ptr).await { Ok(listener) => Arc::into_raw(listener), Err(e) => { @@ -562,7 +563,9 @@ pub unsafe extern "C" fn network_listener_listen(ptr: *const NetworkListener) -> let listener = ManuallyDrop::new(unsafe { Arc::from_raw(ptr) }); let rt = runtime::Handle::current(); - match rt.block_on(listener.listen()) { + let _guard = rt.enter(); + + match futures::executor::block_on(listener.listen()) { Ok(_) => { println!("Network listener started successfully"); true @@ -586,7 +589,9 @@ pub unsafe extern "C" fn network_listener_change_handler(ptr: *const NetworkList let listener = ManuallyDrop::new(unsafe { Arc::from_raw(ptr) }); let rt = runtime::Handle::current(); - match rt.block_on(listener.change_handler()) { + let _guard = rt.enter(); + + match futures::executor::block_on(listener.change_handler()) { Ok(_) => { println!("Network listener change listener completed successfully"); } @@ -616,7 +621,8 @@ pub unsafe extern "C" fn member_listener_new( let id = unsafe { CStr::from_ptr(controller_id) }.to_str().unwrap(); let rt = runtime::Handle::current(); - rt.block_on(async { + let _block = rt.enter(); + futures::executor::block_on(async { match MemberListener::new(id, Duration::from_secs(listen_timeout), callback, user_ptr).await { Ok(listener) => Arc::into_raw(listener), Err(e) => { @@ -647,7 +653,8 @@ pub unsafe extern "C" fn member_listener_listen(ptr: *const MemberListener) -> b let listener = ManuallyDrop::new(unsafe { Arc::from_raw(ptr) }); let rt = runtime::Handle::current(); - match rt.block_on(listener.listen()) { + let _guard = rt.enter(); + match futures::executor::block_on(listener.listen()) { Ok(_) => { println!("Member listener started successfully"); true @@ -671,7 +678,8 @@ pub unsafe extern "C" fn member_listener_change_handler(ptr: *const MemberListen let listener = ManuallyDrop::new(unsafe { Arc::from_raw(ptr) }); let rt = runtime::Handle::current(); - match rt.block_on(listener.change_handler()) { + let _guard = rt.enter(); + match futures::executor::block_on(listener.change_handler()) { Ok(_) => { println!("Member listener change listener completed successfully"); } From 4237830a97d4b84409c85e9de597c49e3c1982be Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 14 Aug 2025 14:25:19 -0700 Subject: [PATCH 017/245] revert default feature list once again --- rustybits/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rustybits/Cargo.toml b/rustybits/Cargo.toml index a84bcc0ea8..72b558c741 100644 --- a/rustybits/Cargo.toml +++ b/rustybits/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" crate-type = ["staticlib", "rlib"] [features] -default = ["zeroidc", "ztcontroller"] +default = ["zeroidc"] zeroidc = [] ztcontroller = [ "dep:serde", From b90ad51723ada45a1dab9e1a5cffd3920c133827 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 15 Aug 2025 08:22:55 -0700 Subject: [PATCH 018/245] more calling async from non-async changes --- rustybits/Cargo.lock | 1 - rustybits/Cargo.toml | 2 -- rustybits/src/ext.rs | 20 ++++++-------------- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/rustybits/Cargo.lock b/rustybits/Cargo.lock index c037e3695a..fd6b37a348 100644 --- a/rustybits/Cargo.lock +++ b/rustybits/Cargo.lock @@ -3101,7 +3101,6 @@ dependencies = [ "base64 0.21.7", "bytes", "cbindgen", - "futures", "gcloud-gax", "gcloud-googleapis", "gcloud-pubsub", diff --git a/rustybits/Cargo.toml b/rustybits/Cargo.toml index 72b558c741..61888ab36f 100644 --- a/rustybits/Cargo.toml +++ b/rustybits/Cargo.toml @@ -22,7 +22,6 @@ ztcontroller = [ "dep:gcloud-googleapis", "dep:tokio", "dep:tokio-util", - "dep:futures", ] [dependencies] @@ -57,7 +56,6 @@ prost = { version = "0.14", optional = true, features = ["derive"] } prost-types = { version = "0.14", optional = true } gcloud-gax = { version = "1.2.0", optional = true } gcloud-googleapis = { version = "1.2.0", optional = true } -futures = { version = "0.3", optional = true } [dev-dependencies] testcontainers = { version = "0.24", features = ["blocking"] } diff --git a/rustybits/src/ext.rs b/rustybits/src/ext.rs index 1a21301ccf..50962d785f 100644 --- a/rustybits/src/ext.rs +++ b/rustybits/src/ext.rs @@ -530,8 +530,7 @@ pub unsafe extern "C" fn network_listener_new( let id = unsafe { CStr::from_ptr(controller_id) }.to_str().unwrap(); let rt = runtime::Handle::current(); - let _block = rt.enter(); - futures::executor::block_on(async { + rt.block_on(async { match NetworkListener::new(id, Duration::from_secs(listen_timeout), callback, user_ptr).await { Ok(listener) => Arc::into_raw(listener), Err(e) => { @@ -563,9 +562,7 @@ pub unsafe extern "C" fn network_listener_listen(ptr: *const NetworkListener) -> let listener = ManuallyDrop::new(unsafe { Arc::from_raw(ptr) }); let rt = runtime::Handle::current(); - let _guard = rt.enter(); - - match futures::executor::block_on(listener.listen()) { + match rt.block_on(listener.listen()) { Ok(_) => { println!("Network listener started successfully"); true @@ -589,9 +586,7 @@ pub unsafe extern "C" fn network_listener_change_handler(ptr: *const NetworkList let listener = ManuallyDrop::new(unsafe { Arc::from_raw(ptr) }); let rt = runtime::Handle::current(); - let _guard = rt.enter(); - - match futures::executor::block_on(listener.change_handler()) { + match rt.block_on(listener.change_handler()) { Ok(_) => { println!("Network listener change listener completed successfully"); } @@ -621,8 +616,7 @@ pub unsafe extern "C" fn member_listener_new( let id = unsafe { CStr::from_ptr(controller_id) }.to_str().unwrap(); let rt = runtime::Handle::current(); - let _block = rt.enter(); - futures::executor::block_on(async { + rt.block_on(async { match MemberListener::new(id, Duration::from_secs(listen_timeout), callback, user_ptr).await { Ok(listener) => Arc::into_raw(listener), Err(e) => { @@ -653,8 +647,7 @@ pub unsafe extern "C" fn member_listener_listen(ptr: *const MemberListener) -> b let listener = ManuallyDrop::new(unsafe { Arc::from_raw(ptr) }); let rt = runtime::Handle::current(); - let _guard = rt.enter(); - match futures::executor::block_on(listener.listen()) { + match rt.block_on(listener.listen()) { Ok(_) => { println!("Member listener started successfully"); true @@ -678,8 +671,7 @@ pub unsafe extern "C" fn member_listener_change_handler(ptr: *const MemberListen let listener = ManuallyDrop::new(unsafe { Arc::from_raw(ptr) }); let rt = runtime::Handle::current(); - let _guard = rt.enter(); - match futures::executor::block_on(listener.change_handler()) { + match rt.block_on(listener.change_handler()) { Ok(_) => { println!("Member listener change listener completed successfully"); } From 650fc0c74b9f966ee03abce1e71c6f52caa722a0 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 15 Aug 2025 16:53:58 -0700 Subject: [PATCH 019/245] Add C++ wrapper around pubsub listeners --- controller/PubSubListener.cpp | 99 +++++++++++++++++++++++++++++++++++ controller/PubSubListener.hpp | 57 ++++++++++++++++++++ objects.mk | 1 + 3 files changed, 157 insertions(+) create mode 100644 controller/PubSubListener.cpp create mode 100644 controller/PubSubListener.hpp diff --git a/controller/PubSubListener.cpp b/controller/PubSubListener.cpp new file mode 100644 index 0000000000..738bb01305 --- /dev/null +++ b/controller/PubSubListener.cpp @@ -0,0 +1,99 @@ +#ifdef ZT_CONTROLLER_USE_LIBPQ +#include "PubSubListener.hpp" + +#include "rustybits.h" + +namespace ZeroTier { + +void listener_callback(void* user_ptr, const uint8_t* payload, uintptr_t length) +{ + if (! user_ptr || ! payload || length == 0) { + fprintf(stderr, "Invalid parameters in listener_callback\n"); + return; + } + + auto* listener = static_cast(user_ptr); + std::string payload_str(reinterpret_cast(payload), length); + listener->onNotification(payload_str); +} + +NetworkListener::NetworkListener(const char* controller_id, uint64_t listen_timeout, rustybits::NetworkListenerCallback callback) : _listener(nullptr) +{ + _listener = rustybits::network_listener_new(controller_id, listen_timeout, callback, this); + _listenThread = std::thread(&NetworkListener::listenThread, this); + _changeHandlerThread = std::thread(&NetworkListener::changeHandlerThread, this); +} + +NetworkListener::~NetworkListener() +{ + if (_listener) { + rustybits::network_listener_delete(_listener); + _listener = nullptr; + } +} + +void NetworkListener::onNotification(const std::string& payload) +{ + fprintf(stderr, "Network notification received: %s\n", payload.c_str()); + // TODO: Implement the logic to handle network notifications +} + +void NetworkListener::listenThread() +{ + if (_listener) { + while (rustybits::network_listener_listen(_listener)) { + // just keep looping + } + } +} + +void NetworkListener::changeHandlerThread() +{ + if (_listener) { + rustybits::network_listener_change_handler(_listener); + } +} + +MemberListener::MemberListener(const char* controller_id, uint64_t listen_timeout, rustybits::NetworkListenerCallback callback) : _listener(nullptr) +{ + // Initialize the member listener with the provided controller ID and timeout + // The callback will be called when a member notification is received + { + _listener = rustybits::member_listener_new("controller_id", 60, listener_callback, this); + } +} + +MemberListener::~MemberListener() +{ + if (_listener) { + rustybits::member_listener_delete(_listener); + _listener = nullptr; + } +} + +void MemberListener::onNotification(const std::string& payload) +{ + fprintf(stderr, "Member notification received: %s\n", payload.c_str()); + + // TODO: Implement the logic to handle network notifications +} + +void MemberListener::listenThread() +{ + if (_listener) { + while (rustybits::member_listener_listen(_listener)) { + // just keep looping + } + } +} + +void MemberListener::changeHandlerThread() +{ + if (_listener) { + rustybits::member_listener_change_handler(_listener); + } +} + +} // namespace ZeroTier + +#endif // ZT_CONTROLLER_USE_LIBPQ \ No newline at end of file diff --git a/controller/PubSubListener.hpp b/controller/PubSubListener.hpp new file mode 100644 index 0000000000..43513e7f44 --- /dev/null +++ b/controller/PubSubListener.hpp @@ -0,0 +1,57 @@ +#ifdef ZT_CONTROLLER_USE_LIBPQ + +#ifndef ZT_CONTROLLER_PUBSUBLISTENER_HPP +#define ZT_CONTROLLER_PUBSUBLISTENER_HPP + +#include "rustybits.h" + +#include +#include +#include + +namespace ZeroTier { +class PubSubListener { + public: + virtual ~PubSubListener() + { + } + + virtual void onNotification(const std::string& payload) = 0; +}; + +class NetworkListener : public PubSubListener { + public: + NetworkListener(const char* controller_id, uint64_t listen_timeout, rustybits::NetworkListenerCallback callback); + virtual ~NetworkListener(); + + virtual void onNotification(const std::string& payload) override; + + private: + void listenThread(); + void changeHandlerThread(); + + const rustybits::NetworkListener* _listener; + std::thread _listenThread; + std::thread _changeHandlerThread; +}; + +class MemberListener : public PubSubListener { + public: + MemberListener(const char* controller_id, uint64_t listen_timeout, rustybits::MemberListenerCallback callback); + virtual ~MemberListener(); + + virtual void onNotification(const std::string& payload) override; + + private: + void listenThread(); + void changeHandlerThread(); + + const rustybits::MemberListener* _listener; + std::thread _listenThread; + std::thread _changeHandlerThread; +}; + +} // namespace ZeroTier + +#endif // ZT_CONTROLLER_PUBSUBLISTENER_HPP +#endif // ZT_CONTROLLER_USE_LIBPQ \ No newline at end of file diff --git a/objects.mk b/objects.mk index 238481a429..79bd0ab486 100644 --- a/objects.mk +++ b/objects.mk @@ -42,6 +42,7 @@ ONE_OBJS=\ controller/CtlUtil.o \ controller/CV1.o \ controller/CV2.o \ + controller/PubSubListener.o \ osdep/EthernetTap.o \ osdep/ManagedRoute.o \ osdep/Http.o \ From ebe8fdb08e2a6e68071ecbbf562bc72a85ec170a Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 20 Aug 2025 10:07:13 -0700 Subject: [PATCH 020/245] rename classes --- controller/PubSubListener.cpp | 24 ++++++++++++------------ controller/PubSubListener.hpp | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/controller/PubSubListener.cpp b/controller/PubSubListener.cpp index 738bb01305..449f5a6865 100644 --- a/controller/PubSubListener.cpp +++ b/controller/PubSubListener.cpp @@ -17,14 +17,14 @@ void listener_callback(void* user_ptr, const uint8_t* payload, uintptr_t length) listener->onNotification(payload_str); } -NetworkListener::NetworkListener(const char* controller_id, uint64_t listen_timeout, rustybits::NetworkListenerCallback callback) : _listener(nullptr) +PubSubNetworkListener::PubSubNetworkListener(const char* controller_id, uint64_t listen_timeout, rustybits::NetworkListenerCallback callback) : _listener(nullptr) { _listener = rustybits::network_listener_new(controller_id, listen_timeout, callback, this); - _listenThread = std::thread(&NetworkListener::listenThread, this); - _changeHandlerThread = std::thread(&NetworkListener::changeHandlerThread, this); + _listenThread = std::thread(&PubSubNetworkListener::listenThread, this); + _changeHandlerThread = std::thread(&PubSubNetworkListener::changeHandlerThread, this); } -NetworkListener::~NetworkListener() +PubSubNetworkListener::~PubSubNetworkListener() { if (_listener) { rustybits::network_listener_delete(_listener); @@ -32,13 +32,13 @@ NetworkListener::~NetworkListener() } } -void NetworkListener::onNotification(const std::string& payload) +void PubSubNetworkListener::onNotification(const std::string& payload) { fprintf(stderr, "Network notification received: %s\n", payload.c_str()); // TODO: Implement the logic to handle network notifications } -void NetworkListener::listenThread() +void PubSubNetworkListener::listenThread() { if (_listener) { while (rustybits::network_listener_listen(_listener)) { @@ -47,14 +47,14 @@ void NetworkListener::listenThread() } } -void NetworkListener::changeHandlerThread() +void PubSubNetworkListener::changeHandlerThread() { if (_listener) { rustybits::network_listener_change_handler(_listener); } } -MemberListener::MemberListener(const char* controller_id, uint64_t listen_timeout, rustybits::NetworkListenerCallback callback) : _listener(nullptr) +PubSubMemberListener::PubSubMemberListener(const char* controller_id, uint64_t listen_timeout, rustybits::NetworkListenerCallback callback) : _listener(nullptr) { // Initialize the member listener with the provided controller ID and timeout // The callback will be called when a member notification is received @@ -63,7 +63,7 @@ MemberListener::MemberListener(const char* controller_id, uint64_t listen_timeou } } -MemberListener::~MemberListener() +PubSubMemberListener::~PubSubMemberListener() { if (_listener) { rustybits::member_listener_delete(_listener); @@ -71,14 +71,14 @@ MemberListener::~MemberListener() } } -void MemberListener::onNotification(const std::string& payload) +void PubSubMemberListener::onNotification(const std::string& payload) { fprintf(stderr, "Member notification received: %s\n", payload.c_str()); // TODO: Implement the logic to handle network notifications } -void MemberListener::listenThread() +void PubSubMemberListener::listenThread() { if (_listener) { while (rustybits::member_listener_listen(_listener)) { @@ -87,7 +87,7 @@ void MemberListener::listenThread() } } -void MemberListener::changeHandlerThread() +void PubSubMemberListener::changeHandlerThread() { if (_listener) { rustybits::member_listener_change_handler(_listener); diff --git a/controller/PubSubListener.hpp b/controller/PubSubListener.hpp index 43513e7f44..5455ce4b9a 100644 --- a/controller/PubSubListener.hpp +++ b/controller/PubSubListener.hpp @@ -19,10 +19,10 @@ class PubSubListener { virtual void onNotification(const std::string& payload) = 0; }; -class NetworkListener : public PubSubListener { +class PubSubNetworkListener : public PubSubListener { public: - NetworkListener(const char* controller_id, uint64_t listen_timeout, rustybits::NetworkListenerCallback callback); - virtual ~NetworkListener(); + PubSubNetworkListener(const char* controller_id, uint64_t listen_timeout, rustybits::NetworkListenerCallback callback); + virtual ~PubSubNetworkListener(); virtual void onNotification(const std::string& payload) override; @@ -35,10 +35,10 @@ class NetworkListener : public PubSubListener { std::thread _changeHandlerThread; }; -class MemberListener : public PubSubListener { +class PubSubMemberListener : public PubSubListener { public: - MemberListener(const char* controller_id, uint64_t listen_timeout, rustybits::MemberListenerCallback callback); - virtual ~MemberListener(); + PubSubMemberListener(const char* controller_id, uint64_t listen_timeout, rustybits::MemberListenerCallback callback); + virtual ~PubSubMemberListener(); virtual void onNotification(const std::string& payload) override; From 95224379aaee9cd5e2a024a8fc61b31dc1c9208f Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 20 Aug 2025 17:04:28 -0700 Subject: [PATCH 021/245] Refactor Redis & Posgres notification listeners into listener subclass in new CentralDB class This allows us to interchangeably use different listeners (pgsql, redis, pubsub) depending on configuration values passed into the constructor. --- controller/CV1.hpp | 15 +- controller/CV2.hpp | 7 +- controller/CentralDB.cpp | 1618 +++++++++++++++++++++++++++ controller/CentralDB.hpp | 130 +++ controller/DB.hpp | 5 +- controller/NotificationListener.hpp | 32 + controller/PostgreSQL.cpp | 162 ++- controller/PostgreSQL.hpp | 62 + controller/PubSubListener.cpp | 164 ++- controller/PubSubListener.hpp | 29 +- controller/RedisListener.cpp | 214 ++++ controller/RedisListener.hpp | 76 ++ objects.mk | 3 + 13 files changed, 2486 insertions(+), 31 deletions(-) create mode 100644 controller/CentralDB.cpp create mode 100644 controller/CentralDB.hpp create mode 100644 controller/NotificationListener.hpp create mode 100644 controller/RedisListener.cpp create mode 100644 controller/RedisListener.hpp diff --git a/controller/CV1.hpp b/controller/CV1.hpp index d267a73075..dc8d36a20a 100644 --- a/controller/CV1.hpp +++ b/controller/CV1.hpp @@ -64,13 +64,6 @@ class CV1 : public DB { return _ready == 2; } - protected: - struct _PairHasher { - inline std::size_t operator()(const std::pair& p) const - { - return (std::size_t)(p.first ^ p.second); - } - }; virtual void _memberChanged(nlohmann::json& old, nlohmann::json& memberConfig, bool notifyListeners) { DB::_memberChanged(old, memberConfig, notifyListeners); @@ -81,6 +74,14 @@ class CV1 : public DB { DB::_networkChanged(old, networkConfig, notifyListeners); } + protected: + struct _PairHasher { + inline std::size_t operator()(const std::pair& p) const + { + return (std::size_t)(p.first ^ p.second); + } + }; + private: void initializeNetworks(); void initializeMembers(); diff --git a/controller/CV2.hpp b/controller/CV2.hpp index 09501e021f..4aed1f7a31 100644 --- a/controller/CV2.hpp +++ b/controller/CV2.hpp @@ -52,6 +52,10 @@ class CV2 : public DB { return _ready == 2; } + virtual void _memberChanged(nlohmann::json& old, nlohmann::json& memberConfig, bool notifyListeners); + + virtual void _networkChanged(nlohmann::json& old, nlohmann::json& networkConfig, bool notifyListeners); + protected: struct _PairHasher { inline std::size_t operator()(const std::pair& p) const @@ -59,9 +63,6 @@ class CV2 : public DB { return (std::size_t)(p.first ^ p.second); } }; - virtual void _memberChanged(nlohmann::json& old, nlohmann::json& memberConfig, bool notifyListeners); - - virtual void _networkChanged(nlohmann::json& old, nlohmann::json& networkConfig, bool notifyListeners); private: void initializeNetworks(); diff --git a/controller/CentralDB.cpp b/controller/CentralDB.cpp new file mode 100644 index 0000000000..eefc43c85b --- /dev/null +++ b/controller/CentralDB.cpp @@ -0,0 +1,1618 @@ +/* + * Copyright (c)2019 ZeroTier, Inc. + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file in the project's root directory. + * + * Change Date: 2026-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2.0 of the Apache License. + */ +/****/ + +#include "CentralDB.hpp" + +#ifdef ZT_CONTROLLER_USE_LIBPQ + +#include "../node/Constants.hpp" +#include "../node/SHA512.hpp" +#include "../version.h" +#include "CtlUtil.hpp" +#include "EmbeddedNetworkController.hpp" +#include "PubSubListener.hpp" +#include "Redis.hpp" +#include "RedisListener.hpp" +#include "opentelemetry/trace/provider.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +// #define REDIS_TRACE 1 + +using json = nlohmann::json; + +namespace { + +static const int DB_MINIMUM_VERSION = 38; + +} // anonymous namespace + +using namespace ZeroTier; + +using Attrs = std::vector >; +using Item = std::pair; +using ItemStream = std::vector; + +CentralDB::CentralDB(const Identity& myId, const char* path, int listenPort, CentralDB::ListenerMode mode, ControllerConfig* cc) + : DB() + , _listenerMode(mode) + , _pool() + , _myId(myId) + , _myAddress(myId.address()) + , _ready(0) + , _connected(1) + , _run(1) + , _waitNoticePrinted(false) + , _listenPort(listenPort) + , _rc(cc->redisConfig) + , _redis(NULL) + , _cluster(NULL) + , _redisMemberStatus(false) + , _smee(NULL) +{ + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("CentralDB"); + auto span = tracer->StartSpan("CentralDB::CentralDB"); + auto scope = tracer->WithActiveSpan(span); + + rustybits::init_async_runtime(); + + char myAddress[64]; + _myAddressStr = myId.address().toString(myAddress); + _connString = std::string(path); + auto f = std::make_shared(_connString); + _pool = std::make_shared >(15, 5, std::static_pointer_cast(f)); + + memset(_ssoPsk, 0, sizeof(_ssoPsk)); + char* const ssoPskHex = getenv("ZT_SSO_PSK"); +#ifdef ZT_TRACE + fprintf(stderr, "ZT_SSO_PSK: %s\n", ssoPskHex); +#endif + if (ssoPskHex) { + // SECURITY: note that ssoPskHex will always be null-terminated if libc actually + // returns something non-NULL. If the hex encodes something shorter than 48 bytes, + // it will be padded at the end with zeroes. If longer, it'll be truncated. + Utils::unhex(ssoPskHex, _ssoPsk, sizeof(_ssoPsk)); + } + const char* redisMemberStatus = getenv("ZT_REDIS_MEMBER_STATUS"); + if (redisMemberStatus && (strcmp(redisMemberStatus, "true") == 0)) { + _redisMemberStatus = true; + fprintf(stderr, "Using redis for member status\n"); + } + + auto c = _pool->borrow(); + pqxx::work txn { *c->c }; + + pqxx::row r { txn.exec1("SELECT version FROM ztc_database") }; + int dbVersion = r[0].as(); + txn.commit(); + + if (dbVersion < DB_MINIMUM_VERSION) { + fprintf(stderr, "Central database schema version too low. This controller version requires a minimum schema version of %d. Please upgrade your Central instance", DB_MINIMUM_VERSION); + exit(1); + } + _pool->unborrow(c); + + if (mode == LISTENER_MODE_REDIS && _rc != NULL) { + auto innerspan = tracer->StartSpan("CentralDB::CentralDB::configureRedis"); + auto innerscope = tracer->WithActiveSpan(innerspan); + + sw::redis::ConnectionOptions opts; + sw::redis::ConnectionPoolOptions poolOpts; + opts.host = _rc->hostname; + opts.port = _rc->port; + opts.password = _rc->password; + opts.db = 0; + opts.keep_alive = true; + opts.connect_timeout = std::chrono::seconds(3); + poolOpts.size = 25; + poolOpts.wait_timeout = std::chrono::seconds(5); + poolOpts.connection_lifetime = std::chrono::minutes(3); + poolOpts.connection_idle_time = std::chrono::minutes(1); + if (_rc->clusterMode) { + innerspan->SetAttribute("cluster_mode", "true"); + fprintf(stderr, "Using Redis in Cluster Mode\n"); + _cluster = std::make_shared(opts, poolOpts); + } + else { + innerspan->SetAttribute("cluster_mode", "false"); + fprintf(stderr, "Using Redis in Standalone Mode\n"); + _redis = std::make_shared(opts, poolOpts); + } + } + + _readyLock.lock(); + + fprintf(stderr, "[%s] NOTICE: %.10llx controller PostgreSQL waiting for initial data download..." ZT_EOL_S, ::_timestr(), (unsigned long long)_myAddress.toInt()); + _waitNoticePrinted = true; + + initializeNetworks(); + initializeMembers(); + + _heartbeatThread = std::thread(&CentralDB::heartbeat, this); + + switch (mode) { + case LISTENER_MODE_REDIS: + if (_rc != NULL) { + if (_rc->clusterMode) { + _membersDbWatcher = std::make_shared(_myAddressStr, _cluster, this); + _networksDbWatcher = std::make_shared(_myAddressStr, _cluster, this); + } + else { + _membersDbWatcher = std::make_shared(_myAddressStr, _redis, this); + _networksDbWatcher = std::make_shared(_myAddressStr, _redis, this); + } + } + else { + throw std::runtime_error("CentralDB: Redis listener mode selected but no Redis configuration provided"); + } + case LISTENER_MODE_PUBSUB: + if (cc->pubSubConfig != NULL) { + _membersDbWatcher = std::make_shared(_myAddressStr, cc->pubSubConfig->listen_timeout, this); + _networksDbWatcher = std::make_shared(_myAddressStr, cc->pubSubConfig->listen_timeout, this); + } + else { + throw std::runtime_error("CentralDB: PubSub listener mode selected but no PubSub configuration provided"); + } + break; + case LISTENER_MODE_PGSQL: + default: + _membersDbWatcher = std::make_shared(this, _pool, "member_" + _myAddressStr, 5); + _networksDbWatcher = std::make_shared(this, _pool, "network_" + _myAddressStr, 5); + break; + } + + for (int i = 0; i < ZT_CENTRAL_CONTROLLER_COMMIT_THREADS; ++i) { + _commitThread[i] = std::thread(&CentralDB::commitThread, this); + } + _onlineNotificationThread = std::thread(&CentralDB::onlineNotificationThread, this); + + configureSmee(); +} + +CentralDB::~CentralDB() +{ + if (_smee != NULL) { + rustybits::smee_client_delete(_smee); + _smee = NULL; + } + + rustybits::shutdown_async_runtime(); + + _run = 0; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + + _heartbeatThread.join(); + _commitQueue.stop(); + for (int i = 0; i < ZT_CENTRAL_CONTROLLER_COMMIT_THREADS; ++i) { + _commitThread[i].join(); + } + _onlineNotificationThread.join(); +} + +void CentralDB::configureSmee() +{ + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("CentralDB"); + auto span = tracer->StartSpan("CentralDB::configureSmee"); + auto scope = tracer->WithActiveSpan(span); + + const char* TEMPORAL_SCHEME = "ZT_TEMPORAL_SCHEME"; + const char* TEMPORAL_HOST = "ZT_TEMPORAL_HOST"; + const char* TEMPORAL_PORT = "ZT_TEMPORAL_PORT"; + const char* TEMPORAL_NAMESPACE = "ZT_TEMPORAL_NAMESPACE"; + const char* SMEE_TASK_QUEUE = "ZT_SMEE_TASK_QUEUE"; + + const char* scheme = getenv(TEMPORAL_SCHEME); + if (scheme == NULL) { + scheme = "http"; + } + const char* host = getenv(TEMPORAL_HOST); + const char* port = getenv(TEMPORAL_PORT); + const char* ns = getenv(TEMPORAL_NAMESPACE); + const char* task_queue = getenv(SMEE_TASK_QUEUE); + + if (scheme != NULL && host != NULL && port != NULL && ns != NULL && task_queue != NULL) { + fprintf(stderr, "creating smee client\n"); + std::string hostPort = std::string(scheme) + std::string("://") + std::string(host) + std::string(":") + std::string(port); + this->_smee = rustybits::smee_client_new(hostPort.c_str(), ns, task_queue); + } + else { + fprintf(stderr, "Smee client not configured\n"); + } +} + +bool CentralDB::waitForReady() +{ + while (_ready < 2) { + _readyLock.lock(); + _readyLock.unlock(); + } + return true; +} + +bool CentralDB::isReady() +{ + return ((_ready == 2) && (_connected)); +} + +bool CentralDB::save(nlohmann::json& record, bool notifyListeners) +{ + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("CentralDB"); + auto span = tracer->StartSpan("CentralDB::save"); + auto scope = tracer->WithActiveSpan(span); + + bool modified = false; + try { + if (! record.is_object()) { + fprintf(stderr, "record is not an object?!?\n"); + return false; + } + const std::string objtype = record["objtype"]; + if (objtype == "network") { + // fprintf(stderr, "network save\n"); + const uint64_t nwid = OSUtils::jsonIntHex(record["id"], 0ULL); + if (nwid) { + nlohmann::json old; + get(nwid, old); + if ((! old.is_object()) || (! _compareRecords(old, record))) { + record["revision"] = OSUtils::jsonInt(record["revision"], 0ULL) + 1ULL; + _commitQueue.post(std::pair(record, notifyListeners)); + modified = true; + } + } + } + else if (objtype == "member") { + std::string networkId = record["nwid"]; + std::string memberId = record["id"]; + const uint64_t nwid = OSUtils::jsonIntHex(record["nwid"], 0ULL); + const uint64_t id = OSUtils::jsonIntHex(record["id"], 0ULL); + // fprintf(stderr, "member save %s-%s\n", networkId.c_str(), memberId.c_str()); + if ((id) && (nwid)) { + nlohmann::json network, old; + get(nwid, network, id, old); + if ((! old.is_object()) || (! _compareRecords(old, record))) { + // fprintf(stderr, "commit queue post\n"); + record["revision"] = OSUtils::jsonInt(record["revision"], 0ULL) + 1ULL; + _commitQueue.post(std::pair(record, notifyListeners)); + modified = true; + } + else { + // fprintf(stderr, "no change\n"); + } + } + } + else { + fprintf(stderr, "uhh waaat\n"); + } + } + catch (std::exception& e) { + fprintf(stderr, "Error on PostgreSQL::save: %s\n", e.what()); + } + catch (...) { + fprintf(stderr, "Unknown error on PostgreSQL::save\n"); + } + return modified; +} + +void CentralDB::eraseNetwork(const uint64_t networkId) +{ + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("CentralDB"); + auto span = tracer->StartSpan("CentralDB::eraseNetwork"); + auto scope = tracer->WithActiveSpan(span); + char networkIdStr[17]; + span->SetAttribute("network_id", Utils::hex(networkId, networkIdStr)); + + fprintf(stderr, "PostgreSQL::eraseNetwork\n"); + char tmp2[24]; + waitForReady(); + Utils::hex(networkId, tmp2); + std::pair tmp; + tmp.first["id"] = tmp2; + tmp.first["objtype"] = "_delete_network"; + tmp.second = true; + _commitQueue.post(tmp); + nlohmann::json nullJson; + _networkChanged(tmp.first, nullJson, true); +} + +void CentralDB::eraseMember(const uint64_t networkId, const uint64_t memberId) +{ + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("CentralDB"); + auto span = tracer->StartSpan("CentralDB::eraseMember"); + auto scope = tracer->WithActiveSpan(span); + char networkIdStr[17]; + char memberIdStr[11]; + span->SetAttribute("network_id", Utils::hex(networkId, networkIdStr)); + span->SetAttribute("member_id", Utils::hex10(memberId, memberIdStr)); + + fprintf(stderr, "PostgreSQL::eraseMember\n"); + char tmp2[24]; + waitForReady(); + std::pair tmp, nw; + Utils::hex(networkId, tmp2); + tmp.first["nwid"] = tmp2; + Utils::hex(memberId, tmp2); + tmp.first["id"] = tmp2; + tmp.first["objtype"] = "_delete_member"; + tmp.second = true; + _commitQueue.post(tmp); + nlohmann::json nullJson; + _memberChanged(tmp.first, nullJson, true); +} + +void CentralDB::nodeIsOnline(const uint64_t networkId, const uint64_t memberId, const InetAddress& physicalAddress, const char* osArch) +{ + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("CentralDB"); + auto span = tracer->StartSpan("CentralDB::nodeIsOnline"); + auto scope = tracer->WithActiveSpan(span); + char networkIdStr[17]; + char memberIdStr[11]; + char ipStr[INET6_ADDRSTRLEN]; + span->SetAttribute("network_id", Utils::hex(networkId, networkIdStr)); + span->SetAttribute("member_id", Utils::hex10(memberId, memberIdStr)); + span->SetAttribute("physical_address", physicalAddress.toString(ipStr)); + span->SetAttribute("os_arch", osArch); + + std::lock_guard l(_lastOnline_l); + NodeOnlineRecord& i = _lastOnline[std::pair(networkId, memberId)]; + i.lastSeen = OSUtils::now(); + if (physicalAddress) { + i.physicalAddress = physicalAddress; + } + i.osArch = std::string(osArch); +} + +void CentralDB::nodeIsOnline(const uint64_t networkId, const uint64_t memberId, const InetAddress& physicalAddress) +{ + this->nodeIsOnline(networkId, memberId, physicalAddress, "unknown/unknown"); +} + +AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::string& redirectURL) +{ + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("CentralDB"); + auto span = tracer->StartSpan("CentralDB::getSSOAuthInfo"); + auto scope = tracer->WithActiveSpan(span); + + Metrics::db_get_sso_info++; + // NONCE is just a random character string. no semantic meaning + // state = HMAC SHA384 of Nonce based on shared sso key + // + // need nonce timeout in database? make sure it's used within X time + // X is 5 minutes for now. Make configurable later? + // + // how do we tell when a nonce is used? if auth_expiration_time is set + std::string networkId = member["nwid"]; + std::string memberId = member["id"]; + + char authenticationURL[4096] = { 0 }; + AuthInfo info; + info.enabled = true; + + // if (memberId == "a10dccea52" && networkId == "8056c2e21c24673d") { + // fprintf(stderr, "invalid authinfo for grant's machine\n"); + // info.version=1; + // return info; + // } + // fprintf(stderr, "PostgreSQL::updateMemberOnLoad: %s-%s\n", networkId.c_str(), memberId.c_str()); + std::shared_ptr c; + try { + c = _pool->borrow(); + pqxx::work w(*c->c); + + char nonceBytes[16] = { 0 }; + std::string nonce = ""; + + // check if the member exists first. + pqxx::row count = w.exec_params1("SELECT count(id) FROM ztc_member WHERE id = $1 AND network_id = $2 AND deleted = false", memberId, networkId); + if (count[0].as() == 1) { + // get active nonce, if exists. + pqxx::result r = w.exec_params( + "SELECT nonce FROM ztc_sso_expiry " + "WHERE network_id = $1 AND member_id = $2 " + "AND ((NOW() AT TIME ZONE 'UTC') <= authentication_expiry_time) AND ((NOW() AT TIME ZONE 'UTC') <= nonce_expiration)", + networkId, + memberId); + + if (r.size() == 0) { + // no active nonce. + // find an unused nonce, if one exists. + pqxx::result r = w.exec_params( + "SELECT nonce FROM ztc_sso_expiry " + "WHERE network_id = $1 AND member_id = $2 " + "AND authentication_expiry_time IS NULL AND ((NOW() AT TIME ZONE 'UTC') <= nonce_expiration)", + networkId, + memberId); + + if (r.size() == 1) { + // we have an existing nonce. Use it + nonce = r.at(0)[0].as(); + Utils::unhex(nonce.c_str(), nonceBytes, sizeof(nonceBytes)); + } + else if (r.empty()) { + // create a nonce + Utils::getSecureRandom(nonceBytes, 16); + char nonceBuf[64] = { 0 }; + Utils::hex(nonceBytes, sizeof(nonceBytes), nonceBuf); + nonce = std::string(nonceBuf); + + pqxx::result ir = w.exec_params0( + "INSERT INTO ztc_sso_expiry " + "(nonce, nonce_expiration, network_id, member_id) VALUES " + "($1, TO_TIMESTAMP($2::double precision/1000), $3, $4)", + nonce, + OSUtils::now() + 300000, + networkId, + memberId); + + w.commit(); + } + else { + // > 1 ?!? Thats an error! + fprintf(stderr, "> 1 unused nonce!\n"); + exit(6); + } + } + else if (r.size() == 1) { + nonce = r.at(0)[0].as(); + Utils::unhex(nonce.c_str(), nonceBytes, sizeof(nonceBytes)); + } + else { + // more than 1 nonce in use? Uhhh... + fprintf(stderr, "> 1 nonce in use for network member?!?\n"); + exit(7); + } + + r = w.exec_params( + "SELECT oc.client_id, oc.authorization_endpoint, oc.issuer, oc.provider, oc.sso_impl_version " + "FROM ztc_network AS n " + "INNER JOIN ztc_org o " + " ON o.owner_id = n.owner_id " + "LEFT OUTER JOIN ztc_network_oidc_config noc " + " ON noc.network_id = n.id " + "LEFT OUTER JOIN ztc_oidc_config oc " + " ON noc.client_id = oc.client_id AND oc.org_id = o.org_id " + "WHERE n.id = $1 AND n.sso_enabled = true", + networkId); + + std::string client_id = ""; + std::string authorization_endpoint = ""; + std::string issuer = ""; + std::string provider = ""; + uint64_t sso_version = 0; + + if (r.size() == 1) { + client_id = r.at(0)[0].as >().value_or(""); + authorization_endpoint = r.at(0)[1].as >().value_or(""); + issuer = r.at(0)[2].as >().value_or(""); + provider = r.at(0)[3].as >().value_or(""); + sso_version = r.at(0)[4].as >().value_or(1); + } + else if (r.size() > 1) { + fprintf(stderr, "ERROR: More than one auth endpoint for an organization?!?!? NetworkID: %s\n", networkId.c_str()); + } + else { + fprintf(stderr, "No client or auth endpoint?!?\n"); + } + + info.version = sso_version; + + // no catch all else because we don't actually care if no records exist here. just continue as normal. + if ((! client_id.empty()) && (! authorization_endpoint.empty())) { + uint8_t state[48]; + HMACSHA384(_ssoPsk, nonceBytes, sizeof(nonceBytes), state); + char state_hex[256]; + Utils::hex(state, 48, state_hex); + + if (info.version == 0) { + char url[2048] = { 0 }; + OSUtils::ztsnprintf( + url, + sizeof(authenticationURL), + "%s?response_type=id_token&response_mode=form_post&scope=openid+email+profile&redirect_uri=%s&nonce=%s&state=%s&client_id=%s", + authorization_endpoint.c_str(), + url_encode(redirectURL).c_str(), + nonce.c_str(), + state_hex, + client_id.c_str()); + info.authenticationURL = std::string(url); + } + else if (info.version == 1) { + info.ssoClientID = client_id; + info.issuerURL = issuer; + info.ssoProvider = provider; + info.ssoNonce = nonce; + info.ssoState = std::string(state_hex) + "_" + networkId; + info.centralAuthURL = redirectURL; +#ifdef ZT_DEBUG + fprintf( + stderr, + "ssoClientID: %s\nissuerURL: %s\nssoNonce: %s\nssoState: %s\ncentralAuthURL: %s\nprovider: %s\n", + info.ssoClientID.c_str(), + info.issuerURL.c_str(), + info.ssoNonce.c_str(), + info.ssoState.c_str(), + info.centralAuthURL.c_str(), + provider.c_str()); +#endif + } + } + else { + fprintf(stderr, "client_id: %s\nauthorization_endpoint: %s\n", client_id.c_str(), authorization_endpoint.c_str()); + } + } + + _pool->unborrow(c); + } + catch (std::exception& e) { + span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + fprintf(stderr, "ERROR: Error updating member on load for network %s: %s\n", networkId.c_str(), e.what()); + } + + return info; // std::string(authenticationURL); +} + +void CentralDB::initializeNetworks() +{ + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("CentralDB"); + auto span = tracer->StartSpan("CentralDB::initializeNetworks"); + auto scope = tracer->WithActiveSpan(span); + + fprintf(stderr, "Initializing networks...\n"); + + try { + char qbuf[2048]; + sprintf( + qbuf, + "SELECT id, name, configuration , (EXTRACT(EPOCH FROM creation_time AT TIME ZONE 'UTC')*1000)::bigint, " + "(EXTRACT(EPOCH FROM last_modified AT TIME ZONE 'UTC')*1000)::bigint, revision " + "FROM networks_ctl WHERE controller_id = '%s'", + _myAddressStr.c_str()); + + auto c = _pool->borrow(); + pqxx::work w(*c->c); + + fprintf(stderr, "Load networks from psql...\n"); + auto stream = pqxx::stream_from::query(w, qbuf); + std::tuple< + std::string // network ID + , + std::optional // name + , + std::string // configuration + , + std::optional // creation_time + , + std::optional // last_modified + , + std::optional // revision + > + row; + uint64_t count = 0; + uint64_t total = 0; + while (stream >> row) { + auto start = std::chrono::high_resolution_clock::now(); + + json empty; + json config; + + initNetwork(config); + + std::string nwid = std::get<0>(row); + std::string name = std::get<1>(row).value_or(""); + json cfgtmp = json::parse(std::get<2>(row)); + std::optional created_at = std::get<3>(row); + std::optional last_modified = std::get<4>(row); + std::optional revision = std::get<5>(row); + + config["id"] = nwid; + config["name"] = name; + config["creationTime"] = created_at.value_or(0); + config["lastModified"] = last_modified.value_or(0); + config["revision"] = revision.value_or(0); + config["capabilities"] = cfgtmp["capabilities"].is_array() ? cfgtmp["capabilities"] : json::array(); + config["enableBroadcast"] = cfgtmp["enableBroadcast"].is_boolean() ? cfgtmp["enableBroadcast"].get() : false; + config["mtu"] = cfgtmp["mtu"].is_number() ? cfgtmp["mtu"].get() : 2800; + config["multicastLimit"] = cfgtmp["multicastLimit"].is_number() ? cfgtmp["multicastLimit"].get() : 64; + config["private"] = cfgtmp["private"].is_boolean() ? cfgtmp["private"].get() : true; + config["remoteTraceLevel"] = cfgtmp["remoteTraceLevel"].is_number() ? cfgtmp["remoteTraceLevel"].get() : 0; + config["remoteTraceTarget"] = cfgtmp["remoteTraceTarget"].is_string() ? cfgtmp["remoteTraceTarget"].get() : ""; + config["revision"] = revision.value_or(0); + config["rules"] = cfgtmp["rules"].is_array() ? cfgtmp["rules"] : json::array(); + config["tags"] = cfgtmp["tags"].is_array() ? cfgtmp["tags"] : json::array(); + if (cfgtmp["v4AssignMode"].is_object()) { + config["v4AssignMode"] = cfgtmp["v4AssignMode"]; + } + else { + config["v4AssignMode"] = json::object(); + config["v4AssignMode"]["zt"] = true; + } + if (cfgtmp["v6AssignMode"].is_object()) { + config["v6AssignMode"] = cfgtmp["v6AssignMode"]; + } + else { + config["v6AssignMode"] = json::object(); + config["v6AssignMode"]["zt"] = true; + config["v6AssignMode"]["6plane"] = true; + config["v6AssignMode"]["rfc4193"] = false; + } + config["ssoEnabled"] = cfgtmp["ssoEnabled"].is_boolean() ? cfgtmp["ssoEnabled"].get() : false; + config["objtype"] = "network"; + config["routes"] = cfgtmp["routes"].is_array() ? cfgtmp["routes"] : json::array(); + config["clientId"] = cfgtmp["clientId"].is_string() ? cfgtmp["clientId"].get() : ""; + config["authorizationEndpoint"] = cfgtmp["authorizationEndpoint"].is_string() ? cfgtmp["authorizationEndpoint"].get() : nullptr; + config["provider"] = cfgtmp["ssoProvider"].is_string() ? cfgtmp["ssoProvider"].get() : ""; + if (! cfgtmp["dns"].is_object()) { + cfgtmp["dns"] = json::object(); + cfgtmp["dns"]["domain"] = ""; + cfgtmp["dns"]["servers"] = json::array(); + } + else { + config["dns"] = cfgtmp["dns"]; + } + config["ipAssignmentPools"] = cfgtmp["ipAssignmentPools"].is_array() ? cfgtmp["ipAssignmentPools"] : json::array(); + + Metrics::network_count++; + + _networkChanged(empty, config, false); + + auto end = std::chrono::high_resolution_clock::now(); + auto dur = std::chrono::duration_cast(end - start); + ; + total += dur.count(); + ++count; + if (count > 0 && count % 10000 == 0) { + fprintf(stderr, "Averaging %lu us per network\n", (total / count)); + } + } + + w.commit(); + _pool->unborrow(c); + fprintf(stderr, "done.\n"); + + if (++this->_ready == 2) { + if (_waitNoticePrinted) { + fprintf(stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), (unsigned long long)_myAddress.toInt()); + } + _readyLock.unlock(); + } + fprintf(stderr, "network init done\n"); + } + catch (std::exception& e) { + fprintf(stderr, "ERROR: Error initializing networks: %s\n", e.what()); + span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + std::this_thread::sleep_for(std::chrono::milliseconds(5000)); + exit(-1); + } +} + +void CentralDB::initializeMembers() +{ + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("CentralDB"); + auto span = tracer->StartSpan("CentralDB::initializeMembers"); + auto scope = tracer->WithActiveSpan(span); + + std::string memberId; + std::string networkId; + try { + std::unordered_map networkMembers; + fprintf(stderr, "Initializing Members...\n"); + + std::string setKeyBase = "network-nodes-all:{" + _myAddressStr + "}:"; + + if (_redisMemberStatus) { + fprintf(stderr, "Initialize Redis for members...\n"); + std::unique_lock l(_networks_l); + std::unordered_set deletes; + for (auto it : _networks) { + uint64_t nwid_i = it.first; + char nwidTmp[64] = { 0 }; + OSUtils::ztsnprintf(nwidTmp, sizeof(nwidTmp), "%.16llx", nwid_i); + std::string nwid(nwidTmp); + std::string key = setKeyBase + nwid; + deletes.insert(key); + } + + if (! deletes.empty()) { + try { + if (_rc->clusterMode) { + auto tx = _cluster->transaction(_myAddressStr, true, false); + for (std::string k : deletes) { + tx.del(k); + } + tx.exec(); + } + else { + auto tx = _redis->transaction(true, false); + for (std::string k : deletes) { + tx.del(k); + } + tx.exec(); + } + } + catch (sw::redis::Error& e) { + // ignore + } + } + } + + char qbuf[2048]; + sprintf( + qbuf, + "SELECT nm.device_id, nm.network_id, nm.authorized, nm.active_bridge, nm.ip_assignments, nm.no_auto_assign_ips, " + "nm.sso_exempt, (EXTRACT(EPOCH FROM nm.authentication_expiry_time AT TIME ZONE 'UTC')*1000)::bigint, " + "(EXTRACT(EPOCH FROM nm.creation_time AT TIME ZONE 'UTC')*1000)::bigint, nm.identity, " + "(EXTRACT(EPOCH FROM nm.last_authorized_time AT TIME ZONE 'UTC')*1000)::bigint, " + "(EXTRACT(EPOCH FROM nm.last_deauthorized_time AT TIME ZONE 'UTC')*1000)::bigint, " + "nm.remote_trace_level, nm.remote_trace_target, nm.revision, nm.capabilities, nm.tags " + "FROM network_memberships_ctl nm " + "INNER JOIN networks_ctl n " + " ON nm.network_id = n.id " + "WHERE n.controller_id = '%s'", + _myAddressStr.c_str()); + + auto c = _pool->borrow(); + pqxx::work w(*c->c); + fprintf(stderr, "Load members from psql...\n"); + auto stream = pqxx::stream_from::query(w, qbuf); + std::tuple< + std::string // device ID + , + std::string // network ID + , + bool // authorized + , + std::optional // active_bridge + , + std::optional // ip_assignments + , + std::optional // no_auto_assign_ips + , + std::optional // sso_exempt + , + std::optional // authentication_expiry_time + , + std::optional // creation_time + , + std::optional // identity + , + std::optional // last_authorized_time + , + std::optional // last_deauthorized_time + , + std::optional // remote_trace_level + , + std::optional // remote_trace_target + , + std::optional // revision + , + std::optional // capabilities + , + std::optional // tags + > + row; + + auto tmp = std::chrono::high_resolution_clock::now(); + uint64_t count = 0; + uint64_t total = 0; + while (stream >> row) { + auto start = std::chrono::high_resolution_clock::now(); + json empty; + json config; + + initMember(config); + + memberId = std::get<0>(row); + networkId = std::get<1>(row); + bool authorized = std::get<2>(row); + std::optional active_bridge = std::get<3>(row); + std::string ip_assignments = std::get<4>(row).value_or(""); + std::optional no_auto_assign_ips = std::get<5>(row); + std::optional sso_exempt = std::get<6>(row); + std::optional authentication_expiry_time = std::get<7>(row); + std::optional creation_time = std::get<8>(row); + std::optional identity = std::get<9>(row); + std::optional last_authorized_time = std::get<10>(row); + std::optional last_deauthorized_time = std::get<11>(row); + std::optional remote_trace_level = std::get<12>(row); + std::optional remote_trace_target = std::get<13>(row); + std::optional revision = std::get<14>(row); + std::optional capabilities = std::get<15>(row); + std::optional tags = std::get<16>(row); + + networkMembers.insert(std::pair(setKeyBase + networkId, memberId)); + + config["objtype"] = "member"; + config["id"] = memberId; + config["address"] = identity.value_or(""); + config["nwid"] = networkId; + config["authorized"] = authorized; + config["activeBridge"] = active_bridge.value_or(false); + config["ipAssignments"] = json::array(); + if (ip_assignments != "{}") { + std::string tmp = ip_assignments.substr(1, ip_assignments.length() - 2); + std::vector addrs = split(tmp, ','); + for (auto it = addrs.begin(); it != addrs.end(); ++it) { + config["ipAssignments"].push_back(*it); + } + } + config["capabilities"] = json::parse(capabilities.value_or("[]")); + config["creationTime"] = creation_time.value_or(0); + config["lastAuthorizedTime"] = last_authorized_time.value_or(0); + config["lastDeauthorizedTime"] = last_deauthorized_time.value_or(0); + config["noAutoAssignIPs"] = no_auto_assign_ips.value_or(false); + config["remoteTraceLevel"] = remote_trace_level.value_or(0); + config["remoteTraceTarget"] = remote_trace_target.value_or(nullptr); + config["revision"] = revision.value_or(0); + config["ssoExempt"] = sso_exempt.value_or(false); + config["authenticationExpiryTime"] = authentication_expiry_time.value_or(0); + config["tags"] = json::parse(tags.value_or("[]")); + config["ipAssignments"] = json::array(); + + Metrics::member_count++; + + _memberChanged(empty, config, false); + + memberId = ""; + networkId = ""; + + auto end = std::chrono::high_resolution_clock::now(); + auto dur = std::chrono::duration_cast(end - start); + total += dur.count(); + ++count; + if (count > 0 && count % 10000 == 0) { + fprintf(stderr, "Averaging %llu us per member\n", (total / count)); + } + } + if (count > 0) { + fprintf(stderr, "Took %llu us per member to load\n", (total / count)); + } + + stream.complete(); + + w.commit(); + _pool->unborrow(c); + fprintf(stderr, "done.\n"); + + if (_listenerMode == LISTENER_MODE_REDIS) + if (! networkMembers.empty()) { + if (_redisMemberStatus) { + fprintf(stderr, "Load member data into redis...\n"); + if (_rc->clusterMode) { + auto tx = _cluster->transaction(_myAddressStr, true, false); + uint64_t count = 0; + for (auto it : networkMembers) { + tx.sadd(it.first, it.second); + if (++count % 30000 == 0) { + tx.exec(); + tx = _cluster->transaction(_myAddressStr, true, false); + } + } + tx.exec(); + } + else { + auto tx = _redis->transaction(true, false); + uint64_t count = 0; + for (auto it : networkMembers) { + tx.sadd(it.first, it.second); + if (++count % 30000 == 0) { + tx.exec(); + tx = _redis->transaction(true, false); + } + } + tx.exec(); + } + fprintf(stderr, "done.\n"); + } + } + + fprintf(stderr, "Done loading members...\n"); + + if (++this->_ready == 2) { + if (_waitNoticePrinted) { + fprintf(stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), (unsigned long long)_myAddress.toInt()); + } + _readyLock.unlock(); + } + } + catch (sw::redis::Error& e) { + span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + fprintf(stderr, "ERROR: Error initializing members (redis): %s\n", e.what()); + exit(-1); + } + catch (std::exception& e) { + span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + fprintf(stderr, "ERROR: Error initializing member: %s-%s %s\n", networkId.c_str(), memberId.c_str(), e.what()); + exit(-1); + } +} + +void CentralDB::heartbeat() +{ + char publicId[1024]; + char hostnameTmp[1024]; + _myId.toString(false, publicId); + if (gethostname(hostnameTmp, sizeof(hostnameTmp)) != 0) { + hostnameTmp[0] = (char)0; + } + else { + for (int i = 0; i < (int)sizeof(hostnameTmp); ++i) { + if ((hostnameTmp[i] == '.') || (hostnameTmp[i] == 0)) { + hostnameTmp[i] = (char)0; + break; + } + } + } + const char* controllerId = _myAddressStr.c_str(); + const char* publicIdentity = publicId; + const char* hostname = hostnameTmp; + + while (_run == 1) { + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("CentralDB"); + auto span = tracer->StartSpan("CentralDB::heartbeat"); + auto scope = tracer->WithActiveSpan(span); + + // fprintf(stderr, "%s: heartbeat\n", controllerId); + auto c = _pool->borrow(); + int64_t ts = OSUtils::now(); + + if (c->c) { + std::string major = std::to_string(ZEROTIER_ONE_VERSION_MAJOR); + std::string minor = std::to_string(ZEROTIER_ONE_VERSION_MINOR); + std::string rev = std::to_string(ZEROTIER_ONE_VERSION_REVISION); + std::string version = major + "." + minor + "." + rev; + std::string versionStr = "v" + version; + + try { + pqxx::work w { *c->c }; + w.exec_params0( + "INSERT INTO controllers_ctl (id, hostname, last_heartbeat, public_identity, version) VALUES " + "($1, $2, TO_TIMESTAMP($3::double precision/1000), $4, $5) " + "ON CONFLICT (id) DO UPDATE SET hostname = EXCLUDED.hostname, last_heartbeat = EXCLUDED.last_heartbeat, " + "public_identity = EXCLUDED.public_identity, version = EXCLUDED.version", + controllerId, + hostname, + ts, + publicIdentity, + versionStr); + w.commit(); + } + catch (std::exception& e) { + fprintf(stderr, "%s: Heartbeat update failed: %s\n", controllerId, e.what()); + span->End(); + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + continue; + } + } + _pool->unborrow(c); + + try { + if (_listenerMode == LISTENER_MODE_REDIS && _redisMemberStatus) { + if (_rc->clusterMode) { + _cluster->zadd("controllers", "controllerId", ts); + } + else { + _redis->zadd("controllers", "controllerId", ts); + } + } + } + catch (sw::redis::Error& e) { + fprintf(stderr, "ERROR: Redis error in heartbeat thread: %s\n", e.what()); + } + + span->End(); + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + } + fprintf(stderr, "Exited heartbeat thread\n"); +} + +void CentralDB::commitThread() +{ + fprintf(stderr, "%s: commitThread start\n", _myAddressStr.c_str()); + std::pair qitem; + while (_commitQueue.get(qitem) & (_run == 1)) { + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("CentralDB"); + auto span = tracer->StartSpan("CentralDB::commitThread"); + auto scope = tracer->WithActiveSpan(span); + + // fprintf(stderr, "commitThread tick\n"); + if (! qitem.first.is_object()) { + fprintf(stderr, "not an object\n"); + continue; + } + + std::shared_ptr c; + try { + c = _pool->borrow(); + } + catch (std::exception& e) { + fprintf(stderr, "ERROR: %s\n", e.what()); + continue; + } + + if (! c) { + fprintf(stderr, "Error getting database connection\n"); + continue; + } + + Metrics::pgsql_commit_ticks++; + try { + nlohmann::json& config = (qitem.first); + const std::string objtype = config["objtype"]; + if (objtype == "member") { + auto mspan = tracer->StartSpan("CentralDB::commitThread::member"); + auto mscope = tracer->WithActiveSpan(mspan); + + // fprintf(stderr, "%s: commitThread: member\n", _myAddressStr.c_str()); + std::string memberId; + std::string networkId; + try { + pqxx::work w(*c->c); + + memberId = config["id"]; + networkId = config["nwid"]; + + std::string target = "NULL"; + if (! config["remoteTraceTarget"].is_null()) { + target = config["remoteTraceTarget"]; + } + + pqxx::row nwrow = w.exec_params1("SELECT COUNT(id) FROM ztc_network WHERE id = $1", networkId); + int nwcount = nwrow[0].as(); + + if (nwcount != 1) { + fprintf(stderr, "network %s does not exist. skipping member upsert\n", networkId.c_str()); + w.abort(); + _pool->unborrow(c); + continue; + } + + pqxx::row mrow = w.exec_params1("SELECT COUNT(id) FROM ztc_member WHERE id = $1 AND network_id = $2", memberId, networkId); + int membercount = mrow[0].as(); + + bool isNewMember = (membercount == 0); + + pqxx::result res = w.exec_params0( + "INSERT INTO network_memberships_ctl (device_id, network_id, authorized, active_bridge, ip_assignments, " + "no_auto_assign_ips, sso_exempt, authentication_expiry_time, capabilities, creation_time, " + "identity, last_authorized_time, last_deauthorized_time, " + "remote_trace_level, remote_trace_target, revision, tags, version_major, version_minor, " + "version_revision, version_protocol) " + "VALUES ($1, $2, $3, $4, $5, $6, $7, TO_TIMESTAMP($8::double precision/1000), $9, " + "TO_TIMESTAMP($10::double precision/1000), $11, TO_TIMESTAMP($12::double precision/1000), " + "TO_TIMESTAMP($13::double precision/1000), $14, $15, $16, $17, $18, $19, $20, $21) " + "ON CONFLICT (device_id, network_id) DO UPDATE SET " + "authorized = EXCLUDED.authorized, active_bridge = EXCLUDED.active_bridge, " + "ip_assignments = EXCLUDED.ip_assignments, no_auto_assign_ips = EXCLUDED.no_auto_assign_ips, " + "sso_exempt = EXCLUDED.sso_exempt, authentication_expiry_time = EXCLUDED.authentication_expiry_time, " + "capabilities = EXCLUDED.capabilities, creation_time = EXCLUDED.creation_time, " + "identity = EXCLUDED.identity, last_authorized_time = EXCLUDED.last_authorized_time, " + "last_deauthorized_time = EXCLUDED.last_deauthorized_time, " + "remote_trace_level = EXCLUDED.remote_trace_level, remote_trace_target = EXCLUDED.remote_trace_target, " + "revision = EXCLUDED.revision, tags = EXCLUDED.tags, version_major = EXCLUDED.version_major, " + "version_minor = EXCLUDED.version_minor, version_revision = EXCLUDED.version_revision, " + "version_protocol = EXCLUDED.version_protocol", + memberId, + networkId, + (bool)config["authorized"], + (bool)config["activeBridge"], + config["ipAssignments"].get >(), + (bool)config["noAutoAssignIps"], + (bool)config["ssoExempt"], + (uint64_t)config["authenticationExpiryTime"], + OSUtils::jsonDump(config["capabilities"], -1), + (uint64_t)config["creationTime"], + OSUtils::jsonString(config["identity"], ""), + (uint64_t)config["lastAuthorizedTime"], + (uint64_t)config["lastDeauthorizedTime"], + (int)config["remoteTraceLevel"], + target, + (uint64_t)config["revision"], + OSUtils::jsonDump(config["tags"], -1), + (int)config["vMajor"], + (int)config["vMinor"], + (int)config["vRev"], + (int)config["vProto"]); + + w.commit(); + + if (! isNewMember) { + pqxx::result res = w.exec_params0("DELETE FROM ztc_member_ip_assignment WHERE member_id = $1 AND network_id = $2", memberId, networkId); + } + + if (_smee != NULL && isNewMember) { + // TODO: Smee Notifications for New Members + // pqxx::row row = w.exec_params1( + // "SELECT " + // " count(h.hook_id) " + // "FROM " + // " ztc_hook h " + // " INNER JOIN ztc_org o ON o.org_id = h.org_id " + // " INNER JOIN ztc_network n ON n.owner_id = o.owner_id " + // " WHERE " + // "n.id = $1 ", + // networkId); + // int64_t hookCount = row[0].as(); + // if (hookCount > 0) { + // notifyNewMember(networkId, memberId); + // } + } + + const uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); + const uint64_t memberidInt = OSUtils::jsonIntHex(config["id"], 0ULL); + if (nwidInt && memberidInt) { + nlohmann::json nwOrig; + nlohmann::json memOrig; + + nlohmann::json memNew(config); + + get(nwidInt, nwOrig, memberidInt, memOrig); + + _memberChanged(memOrig, memNew, qitem.second); + } + else { + fprintf(stderr, "%s: Can't notify of change. Error parsing nwid or memberid: %llu-%llu\n", _myAddressStr.c_str(), (unsigned long long)nwidInt, (unsigned long long)memberidInt); + } + } + catch (std::exception& e) { + fprintf(stderr, "%s ERROR: Error updating member %s-%s: %s\n", _myAddressStr.c_str(), networkId.c_str(), memberId.c_str(), e.what()); + mspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + } + } + else if (objtype == "network") { + auto nspan = tracer->StartSpan("CentralDB::commitThread::network"); + auto nscope = tracer->WithActiveSpan(nspan); + + try { + // fprintf(stderr, "%s: commitThread: network\n", _myAddressStr.c_str()); + pqxx::work w(*c->c); + + std::string id = config["id"]; + + // network must already exist + pqxx::result res = w.exec_params0( + "INSERT INTO networks_ctl (id, name, configuration, controller_id, revision) " + "VALUES ($1, $2, $3, $4, $5) " + "ON CONFLICT (id) DO UPDATE SET " + "name = EXCLUDED.name, configuration = EXCLUDED.configuration, revision = EXCLUDED.revision+1", + id, + OSUtils::jsonString(config["name"], ""), + OSUtils::jsonDump(config, -1), + _myAddressStr, + ((uint64_t)config["revision"])); + + w.commit(); + + res = w.exec_params0("DELETE FROM ztc_network_assignment_pool WHERE network_id = $1", 0); + + auto pool = config["ipAssignmentPools"]; + bool err = false; + for (auto i = pool.begin(); i != pool.end(); ++i) { + std::string start = (*i)["ipRangeStart"]; + std::string end = (*i)["ipRangeEnd"]; + + res = w.exec_params0( + "INSERT INTO ztc_network_assignment_pool (network_id, ip_range_start, ip_range_end) " + "VALUES ($1, $2, $3)", + id, + start, + end); + } + + const uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); + if (nwidInt) { + nlohmann::json nwOrig; + nlohmann::json nwNew(config); + + get(nwidInt, nwOrig); + + _networkChanged(nwOrig, nwNew, qitem.second); + } + else { + fprintf(stderr, "%s: Can't notify network changed: %llu\n", _myAddressStr.c_str(), (unsigned long long)nwidInt); + } + } + catch (std::exception& e) { + nspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + fprintf(stderr, "%s ERROR: Error updating network: %s\n", _myAddressStr.c_str(), e.what()); + } + if (_listenerMode == LISTENER_MODE_REDIS && _redisMemberStatus) { + try { + std::string id = config["id"]; + std::string controllerId = _myAddressStr.c_str(); + std::string key = "networks:{" + controllerId + "}"; + if (_rc->clusterMode) { + _cluster->sadd(key, id); + } + else { + _redis->sadd(key, id); + } + } + catch (sw::redis::Error& e) { + nspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + fprintf(stderr, "ERROR: Error adding network to Redis: %s\n", e.what()); + } + } + } + else if (objtype == "_delete_network") { + auto dspan = tracer->StartSpan("CentralDB::commitThread::_delete_network"); + auto dscope = tracer->WithActiveSpan(dspan); + + // fprintf(stderr, "%s: commitThread: delete network\n", _myAddressStr.c_str()); + try { + pqxx::work w(*c->c); + std::string networkId = config["id"]; + fprintf(stderr, "Deleting network %s\n", networkId.c_str()); + w.exec_params0("DELETE FROM network_memberships_ctl WHERE network_id = $1", networkId); + w.exec_params0("DELETE FROM networks_ctl WHERE id = $1", networkId); + + w.commit(); + + uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); + json oldConfig; + get(nwidInt, oldConfig); + json empty; + _networkChanged(oldConfig, empty, qitem.second); + } + catch (std::exception& e) { + dspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + fprintf(stderr, "%s ERROR: Error deleting network: %s\n", _myAddressStr.c_str(), e.what()); + } + if (_listenerMode == LISTENER_MODE_REDIS && _redisMemberStatus) { + try { + std::string id = config["id"]; + std::string controllerId = _myAddressStr.c_str(); + std::string key = "networks:{" + controllerId + "}"; + if (_rc->clusterMode) { + _cluster->srem(key, id); + _cluster->del("network-nodes-online:{" + controllerId + "}:" + id); + } + else { + _redis->srem(key, id); + _redis->del("network-nodes-online:{" + controllerId + "}:" + id); + } + } + catch (sw::redis::Error& e) { + dspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + fprintf(stderr, "ERROR: Error adding network to Redis: %s\n", e.what()); + } + } + } + else if (objtype == "_delete_member") { + auto mspan = tracer->StartSpan("CentralDB::commitThread::_delete_member"); + auto mscope = tracer->WithActiveSpan(mspan); + + // fprintf(stderr, "%s commitThread: delete member\n", _myAddressStr.c_str()); + try { + pqxx::work w(*c->c); + + std::string memberId = config["id"]; + std::string networkId = config["nwid"]; + + pqxx::result res = w.exec_params0("DELETE FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", memberId, networkId); + + w.commit(); + + uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); + uint64_t memberidInt = OSUtils::jsonIntHex(config["id"], 0ULL); + + nlohmann::json networkConfig; + nlohmann::json oldConfig; + + get(nwidInt, networkConfig, memberidInt, oldConfig); + json empty; + _memberChanged(oldConfig, empty, qitem.second); + } + catch (std::exception& e) { + mspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + fprintf(stderr, "%s ERROR: Error deleting member: %s\n", _myAddressStr.c_str(), e.what()); + } + if (_listenerMode == LISTENER_MODE_REDIS && _redisMemberStatus) { + try { + std::string memberId = config["id"]; + std::string networkId = config["nwid"]; + std::string controllerId = _myAddressStr.c_str(); + std::string key = "network-nodes-all:{" + controllerId + "}:" + networkId; + if (_rc->clusterMode) { + _cluster->srem(key, memberId); + _cluster->del("member:{" + controllerId + "}:" + networkId + ":" + memberId); + } + else { + _redis->srem(key, memberId); + _redis->del("member:{" + controllerId + "}:" + networkId + ":" + memberId); + } + } + catch (sw::redis::Error& e) { + mspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + fprintf(stderr, "ERROR: Error deleting member from Redis: %s\n", e.what()); + } + } + } + else { + fprintf(stderr, "%s ERROR: unknown objtype\n", _myAddressStr.c_str()); + } + } + catch (std::exception& e) { + span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + fprintf(stderr, "%s ERROR: Error getting objtype: %s\n", _myAddressStr.c_str(), e.what()); + } + _pool->unborrow(c); + c.reset(); + } + + fprintf(stderr, "%s commitThread finished\n", _myAddressStr.c_str()); +} + +void CentralDB::notifyNewMember(const std::string& networkID, const std::string& memberID) +{ + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("CentralDB"); + auto span = tracer->StartSpan("CentralDB::notifyNewMember"); + auto scope = tracer->WithActiveSpan(span); + + rustybits::smee_client_notify_network_joined(_smee, networkID.c_str(), memberID.c_str()); +} + +void CentralDB::onlineNotificationThread() +{ + waitForReady(); + if (_redisMemberStatus) { + onlineNotification_Redis(); + } + else { + onlineNotification_Postgres(); + } +} + +/** + * ONLY UNCOMMENT FOR TEMPORARY DB MAINTENANCE + * + * This define temporarily turns off writing to the member status table + * so it can be reindexed when the indexes get too large. + */ + +// #define DISABLE_MEMBER_STATUS 1 + +void CentralDB::onlineNotification_Postgres() +{ + _connected = 1; + + nlohmann::json jtmp1, jtmp2; + while (_run == 1) { + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("CentralDB"); + auto span = tracer->StartSpan("CentralDB::onlineNotification_Postgres"); + auto scope = tracer->WithActiveSpan(span); + + auto c = _pool->borrow(); + auto c2 = _pool->borrow(); + try { + fprintf(stderr, "%s onlineNotification_Postgres\n", _myAddressStr.c_str()); + std::unordered_map, NodeOnlineRecord, _PairHasher> lastOnline; + { + std::lock_guard l(_lastOnline_l); + lastOnline.swap(_lastOnline); + } + +#ifndef DISABLE_MEMBER_STATUS + pqxx::work w(*c->c); + pqxx::work w2(*c2->c); + + fprintf(stderr, "online notification tick\n"); + + bool firstRun = true; + bool memberAdded = false; + int updateCount = 0; + + pqxx::pipeline pipe(w); + + for (auto i = lastOnline.begin(); i != lastOnline.end(); ++i) { + updateCount += 1; + uint64_t nwid_i = i->first.first; + char nwidTmp[64]; + char memTmp[64]; + char ipTmp[64]; + OSUtils::ztsnprintf(nwidTmp, sizeof(nwidTmp), "%.16llx", nwid_i); + OSUtils::ztsnprintf(memTmp, sizeof(memTmp), "%.10llx", i->first.second); + + if (! get(nwid_i, jtmp1, i->first.second, jtmp2)) { + continue; // skip non existent networks/members + } + + std::string networkId(nwidTmp); + std::string memberId(memTmp); + + try { + pqxx::row r = w2.exec_params1("SELECT id, network_id FROM ztc_member WHERE network_id = $1 AND id = $2", networkId, memberId); + } + catch (pqxx::unexpected_rows& e) { + continue; + } + + int64_t ts = i->second.lastSeen; + std::string ipAddr = i->second.physicalAddress.toIpString(ipTmp); + std::string timestamp = std::to_string(ts); + std::string osArch = i->second.osArch; + + std::stringstream memberUpdate; + memberUpdate << "INSERT INTO ztc_member_status (network_id, member_id, address, last_updated) VALUES " + << "('" << networkId << "', '" << memberId << "', "; + if (ipAddr.empty()) { + memberUpdate << "NULL, "; + } + else { + memberUpdate << "'" << ipAddr << "', "; + } + memberUpdate << "TO_TIMESTAMP(" << timestamp << "::double precision/1000)) " + << " ON CONFLICT (network_id, member_id) DO UPDATE SET address = EXCLUDED.address, last_updated = EXCLUDED.last_updated"; + + pipe.insert(memberUpdate.str()); + Metrics::pgsql_node_checkin++; + } + while (! pipe.empty()) { + pipe.retrieve(); + } + + pipe.complete(); + w.commit(); + fprintf(stderr, "%s: Updated online status of %d members\n", _myAddressStr.c_str(), updateCount); +#endif + } + catch (std::exception& e) { + fprintf(stderr, "%s: error in onlinenotification thread: %s\n", _myAddressStr.c_str(), e.what()); + } + _pool->unborrow(c2); + _pool->unborrow(c); + + ConnectionPoolStats stats = _pool->get_stats(); + fprintf(stderr, "%s pool stats: in use size: %llu, available size: %llu, total: %llu\n", _myAddressStr.c_str(), stats.borrowed_size, stats.pool_size, (stats.borrowed_size + stats.pool_size)); + + span->End(); + + std::this_thread::sleep_for(std::chrono::seconds(10)); + } + fprintf(stderr, "%s: Fell out of run loop in onlineNotificationThread\n", _myAddressStr.c_str()); + if (_run == 1) { + fprintf(stderr, "ERROR: %s onlineNotificationThread should still be running! Exiting Controller.\n", _myAddressStr.c_str()); + exit(6); + } +} + +void CentralDB::onlineNotification_Redis() +{ + _connected = 1; + + char buf[11] = { 0 }; + std::string controllerId = std::string(_myAddress.toString(buf)); + + while (_run == 1) { + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("CentralDB"); + auto span = tracer->StartSpan("CentralDB::onlineNotification_Redis"); + auto scope = tracer->WithActiveSpan(span); + + fprintf(stderr, "onlineNotification tick\n"); + auto start = std::chrono::high_resolution_clock::now(); + uint64_t count = 0; + + std::unordered_map, NodeOnlineRecord, _PairHasher> lastOnline; + { + std::lock_guard l(_lastOnline_l); + lastOnline.swap(_lastOnline); + } + try { + if (! lastOnline.empty()) { + if (_rc->clusterMode) { + auto tx = _cluster->transaction(controllerId, true, false); + count = _doRedisUpdate(tx, controllerId, lastOnline); + } + else { + auto tx = _redis->transaction(true, false); + count = _doRedisUpdate(tx, controllerId, lastOnline); + } + } + } + catch (sw::redis::Error& e) { + fprintf(stderr, "Error in online notification thread (redis): %s\n", e.what()); + } + + auto end = std::chrono::high_resolution_clock::now(); + auto dur = std::chrono::duration_cast(end - start); + auto total = dur.count(); + + fprintf(stderr, "onlineNotification ran in %llu ms\n", total); + span->End(); + + std::this_thread::sleep_for(std::chrono::seconds(5)); + } +} + +uint64_t CentralDB::_doRedisUpdate(sw::redis::Transaction& tx, std::string& controllerId, std::unordered_map, NodeOnlineRecord, _PairHasher>& lastOnline) +{ + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("CentralDB"); + auto span = tracer->StartSpan("CentralDB::_doRedisUpdate"); + auto scope = tracer->WithActiveSpan(span); + + nlohmann::json jtmp1, jtmp2; + uint64_t count = 0; + for (auto i = lastOnline.begin(); i != lastOnline.end(); ++i) { + uint64_t nwid_i = i->first.first; + uint64_t memberid_i = i->first.second; + char nwidTmp[64]; + char memTmp[64]; + char ipTmp[64]; + OSUtils::ztsnprintf(nwidTmp, sizeof(nwidTmp), "%.16llx", nwid_i); + OSUtils::ztsnprintf(memTmp, sizeof(memTmp), "%.10llx", memberid_i); + + if (! get(nwid_i, jtmp1, memberid_i, jtmp2)) { + continue; // skip non existent members/networks + } + + std::string networkId(nwidTmp); + std::string memberId(memTmp); + + int64_t ts = i->second.lastSeen; + std::string ipAddr = i->second.physicalAddress.toIpString(ipTmp); + std::string timestamp = std::to_string(ts); + std::string osArch = i->second.osArch; + + std::unordered_map record = { { "id", memberId }, { "address", ipAddr }, { "last_updated", std::to_string(ts) } }; + tx.zadd("nodes-online:{" + controllerId + "}", memberId, ts) + .zadd("nodes-online2:{" + controllerId + "}", networkId + "-" + memberId, ts) + .zadd("network-nodes-online:{" + controllerId + "}:" + networkId, memberId, ts) + .zadd("active-networks:{" + controllerId + "}", networkId, ts) + .sadd("network-nodes-all:{" + controllerId + "}:" + networkId, memberId) + .hmset("member:{" + controllerId + "}:" + networkId + ":" + memberId, record.begin(), record.end()); + ++count; + Metrics::redis_node_checkin++; + } + + // expire records from all-nodes and network-nodes member list + uint64_t expireOld = OSUtils::now() - 300000; + + tx.zremrangebyscore("nodes-online:{" + controllerId + "}", sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); + tx.zremrangebyscore("nodes-online2:{" + controllerId + "}", sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); + tx.zremrangebyscore("active-networks:{" + controllerId + "}", sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); + { + std::shared_lock l(_networks_l); + for (const auto& it : _networks) { + uint64_t nwid_i = it.first; + char nwidTmp[64]; + OSUtils::ztsnprintf(nwidTmp, sizeof(nwidTmp), "%.16llx", nwid_i); + tx.zremrangebyscore("network-nodes-online:{" + controllerId + "}:" + nwidTmp, sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); + } + } + tx.exec(); + fprintf(stderr, "%s: Updated online status of %d members\n", _myAddressStr.c_str(), count); + + return count; +} + +#endif // ZT_CONTROLLER_USE_LIBPQ diff --git a/controller/CentralDB.hpp b/controller/CentralDB.hpp new file mode 100644 index 0000000000..83f313e4dd --- /dev/null +++ b/controller/CentralDB.hpp @@ -0,0 +1,130 @@ +#ifdef ZT_CONTROLLER_USE_LIBPQ + +#ifndef ZT_CONTROLLER_CENTRAL_DB_HPP +#define ZT_CONTROLLER_CENTRAL_DB_HPP + +#define ZT_CENTRAL_CONTROLLER_COMMIT_THREADS 4 + +#include "../node/Metrics.hpp" +#include "ConnectionPool.hpp" +#include "DB.hpp" +#include "NotificationListener.hpp" +#include "PostgreSQL.hpp" + +#include +#include +#include + +namespace rustybits { +struct SmeeClient; +} + +namespace ZeroTier { + +struct RedisConfig; +struct PubSubConfig; +struct PostgresNotifyConfig; + +struct ControllerConfig { + RedisConfig* redisConfig; + PubSubConfig* pubSubConfig; + PostgresNotifyConfig* postgresNotifyConfig; +}; + +class CentralDB : public DB { + public: + enum ListenerMode { + LISTENER_MODE_PGSQL = 0, + LISTENER_MODE_REDIS = 1, + LISTENER_MODE_PUBSUB = 2, + }; + + CentralDB(const Identity& myId, const char* path, int listenPort, CentralDB::ListenerMode mode, ControllerConfig* cc); + virtual ~CentralDB(); + + virtual bool waitForReady(); + virtual bool isReady(); + virtual bool save(nlohmann::json& record, bool notifyListeners); + virtual void eraseNetwork(const uint64_t networkId); + virtual void eraseMember(const uint64_t networkId, const uint64_t memberId); + virtual void nodeIsOnline(const uint64_t networkId, const uint64_t memberId, const InetAddress& physicalAddress); + virtual void nodeIsOnline(const uint64_t networkId, const uint64_t memberId, const InetAddress& physicalAddress, const char* osArch); + virtual AuthInfo getSSOAuthInfo(const nlohmann::json& member, const std::string& redirectURL); + + virtual bool ready() + { + return _ready == 2; + } + + virtual void _memberChanged(nlohmann::json& old, nlohmann::json& memberConfig, bool notifyListeners) + { + DB::_memberChanged(old, memberConfig, notifyListeners); + } + + virtual void _networkChanged(nlohmann::json& old, nlohmann::json& networkConfig, bool notifyListeners) + { + DB::_networkChanged(old, networkConfig, notifyListeners); + } + + protected: + struct _PairHasher { + inline std::size_t operator()(const std::pair& p) const + { + return (std::size_t)(p.first ^ p.second); + } + }; + + private: + void initializeNetworks(); + void initializeMembers(); + void heartbeat(); + + void commitThread(); + void onlineNotificationThread(); + void onlineNotification_Postgres(); + void onlineNotification_Redis(); + uint64_t _doRedisUpdate(sw::redis::Transaction& tx, std::string& controllerId, std::unordered_map, NodeOnlineRecord, _PairHasher>& lastOnline); + + void configureSmee(); + void notifyNewMember(const std::string& networkID, const std::string& memberID); + + enum OverrideMode { ALLOW_PGBOUNCER_OVERRIDE = 0, NO_OVERRIDE = 1 }; + + ListenerMode _listenerMode; + std::shared_ptr > _pool; + + const Identity _myId; + const Address _myAddress; + std::string _myAddressStr; + std::string _connString; + + BlockingQueue > _commitQueue; + + std::thread _heartbeatThread; + std::shared_ptr _membersDbWatcher; + std::shared_ptr _networksDbWatcher; + std::thread _commitThread[ZT_CENTRAL_CONTROLLER_COMMIT_THREADS]; + std::thread _onlineNotificationThread; + + std::unordered_map, NodeOnlineRecord, _PairHasher> _lastOnline; + + mutable std::mutex _lastOnline_l; + mutable std::mutex _readyLock; + std::atomic _ready, _connected, _run; + mutable volatile bool _waitNoticePrinted; + + int _listenPort; + uint8_t _ssoPsk[48]; + + RedisConfig* _rc; + std::shared_ptr _redis; + std::shared_ptr _cluster; + bool _redisMemberStatus; + + rustybits::SmeeClient* _smee; +}; + +} // namespace ZeroTier + +#endif // ZT_CONTROLLER_CENTRAL_DB_HPP +#endif // ZT_CONTROLLER_USE_LIBPQ \ No newline at end of file diff --git a/controller/DB.hpp b/controller/DB.hpp index 01b6f1266b..7ebff84ef4 100644 --- a/controller/DB.hpp +++ b/controller/DB.hpp @@ -145,6 +145,9 @@ class DB { _changeListeners.push_back(listener); } + virtual void _memberChanged(nlohmann::json& old, nlohmann::json& memberConfig, bool notifyListeners); + virtual void _networkChanged(nlohmann::json& old, nlohmann::json& networkConfig, bool notifyListeners); + protected: static inline bool _compareRecords(const nlohmann::json& a, const nlohmann::json& b) { @@ -181,8 +184,6 @@ class DB { std::shared_mutex lock; }; - virtual void _memberChanged(nlohmann::json& old, nlohmann::json& memberConfig, bool notifyListeners); - virtual void _networkChanged(nlohmann::json& old, nlohmann::json& networkConfig, bool notifyListeners); void _fillSummaryInfo(const std::shared_ptr<_Network>& nw, NetworkSummaryInfo& info); std::vector _changeListeners; diff --git a/controller/NotificationListener.hpp b/controller/NotificationListener.hpp new file mode 100644 index 0000000000..e1b1d8f9ca --- /dev/null +++ b/controller/NotificationListener.hpp @@ -0,0 +1,32 @@ +#ifndef NOTIFICATION_LISTENER_HPP +#define NOTIFICATION_LISTENER_HPP + +#include + +namespace ZeroTier { + +/** + * Base class for notification listeners + * + * This class is used to receive notifications from various sources such as Redis, PostgreSQL, etc. + */ +class NotificationListener { + public: + NotificationListener() = default; + virtual ~NotificationListener() + { + } + + /** + * Called when a notification is received. + * + * Payload should be parsed and passed to the database handler's save method. + * + * @param payload The payload of the notification. + */ + virtual void onNotification(const std::string& payload) = 0; +}; + +} // namespace ZeroTier + +#endif // NOTIFICATION_LISTENER_HPP \ No newline at end of file diff --git a/controller/PostgreSQL.cpp b/controller/PostgreSQL.cpp index 3bc8646012..9f6d80bd86 100644 --- a/controller/PostgreSQL.cpp +++ b/controller/PostgreSQL.cpp @@ -2,10 +2,168 @@ #include "PostgreSQL.hpp" +#include "opentelemetry/trace/provider.h" + #include -using namespace nlohmann; +namespace ZeroTier { + +PostgresMemberListener::PostgresMemberListener(DB* db, std::shared_ptr > pool, const std::string& channel, uint64_t timeout) + : NotificationListener() + , _db(db) + , _pool(pool) + , _notification_timeout(timeout) + , _listenerThread() +{ + _conn = _pool->borrow(); + _receiver = new _notificationReceiver(this, *_conn->c, channel); + _run = true; + _listenerThread = std::thread(&PostgresMemberListener::listen, this); +} + +PostgresMemberListener::~PostgresMemberListener() +{ + _run = false; + if (_listenerThread.joinable()) { + _listenerThread.join(); + } + delete _receiver; + if (_conn) { + _pool->unborrow(_conn); + _conn.reset(); + } +} + +void PostgresMemberListener::listen() +{ + while (_run) { + _conn->c->await_notification(_notification_timeout, 0); + } +} + +void PostgresMemberListener::onNotification(const std::string& payload) +{ + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("PostgresMemberNotificationListener"); + auto span = tracer->StartSpan("PostgresMemberNotificationListener::onNotification"); + auto scope = tracer->WithActiveSpan(span); + span->SetAttribute("payload", payload); + + fprintf(stderr, "Member Notification received: %s\n", payload.c_str()); + Metrics::pgsql_mem_notification++; + nlohmann::json tmp(nlohmann::json::parse(payload)); + nlohmann::json& ov = tmp["old_val"]; + nlohmann::json& nv = tmp["new_val"]; + nlohmann::json oldConfig, newConfig; + if (ov.is_object()) + oldConfig = ov; + if (nv.is_object()) + newConfig = nv; + + if (oldConfig.is_object() && newConfig.is_object()) { + _db->save(newConfig, true); + fprintf(stderr, "payload sent\n"); + } + else if (newConfig.is_object() && ! oldConfig.is_object()) { + // new member + Metrics::member_count++; + _db->save(newConfig, true); + fprintf(stderr, "new member payload sent\n"); + } + else if (! newConfig.is_object() && oldConfig.is_object()) { + // member delete + uint64_t networkId = OSUtils::jsonIntHex(oldConfig["nwid"], 0ULL); + uint64_t memberId = OSUtils::jsonIntHex(oldConfig["id"], 0ULL); + if (memberId && networkId) { + _db->eraseMember(networkId, memberId); + fprintf(stderr, "member delete payload sent\n"); + } + } +} + +PostgresNetworkListener::PostgresNetworkListener(DB* db, std::shared_ptr > pool, const std::string& channel, uint64_t timeout) + : NotificationListener() + , _db(db) + , _pool(pool) + , _notification_timeout(timeout) + , _listenerThread() +{ + _conn = _pool->borrow(); + _receiver = new _notificationReceiver(this, *_conn->c, channel); + _run = true; + _listenerThread = std::thread(&PostgresNetworkListener::listen, this); +} + +PostgresNetworkListener::~PostgresNetworkListener() +{ + _run = false; + if (_listenerThread.joinable()) { + _listenerThread.join(); + } + delete _receiver; + if (_conn) { + _pool->unborrow(_conn); + _conn.reset(); + } +} + +void PostgresNetworkListener::listen() +{ + while (_run) { + _conn->c->await_notification(_notification_timeout, 0); + } +} + +void PostgresNetworkListener::onNotification(const std::string& payload) +{ + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("db_network_notification"); + auto span = tracer->StartSpan("db_network_notification::operator()"); + auto scope = tracer->WithActiveSpan(span); + span->SetAttribute("payload", payload); + + fprintf(stderr, "Network Notification received: %s\n", payload.c_str()); + Metrics::pgsql_net_notification++; + nlohmann::json tmp(nlohmann::json::parse(payload)); + + nlohmann::json& ov = tmp["old_val"]; + nlohmann::json& nv = tmp["new_val"]; + nlohmann::json oldConfig, newConfig; + + if (ov.is_object()) + oldConfig = ov; + if (nv.is_object()) + newConfig = nv; + + if (oldConfig.is_object() && newConfig.is_object()) { + std::string nwid = oldConfig["id"]; + span->SetAttribute("action", "network_change"); + span->SetAttribute("network_id", nwid); + _db->save(newConfig, true); + fprintf(stderr, "payload sent\n"); + } + else if (newConfig.is_object() && ! oldConfig.is_object()) { + std::string nwid = newConfig["id"]; + span->SetAttribute("network_id", nwid); + span->SetAttribute("action", "new_network"); + // new network + _db->save(newConfig, true); + fprintf(stderr, "new network payload sent\n"); + } + else if (! newConfig.is_object() && oldConfig.is_object()) { + // network delete + span->SetAttribute("action", "delete_network"); + std::string nwid = oldConfig["id"]; + span->SetAttribute("network_id", nwid); + uint64_t networkId = Utils::hexStrToU64(nwid.c_str()); + span->SetAttribute("network_id_int", networkId); + if (networkId) { + _db->eraseNetwork(networkId); + fprintf(stderr, "network delete payload sent\n"); + } + } +} -using namespace ZeroTier; +} // namespace ZeroTier #endif \ No newline at end of file diff --git a/controller/PostgreSQL.hpp b/controller/PostgreSQL.hpp index 41f36e3c58..af96a40fde 100644 --- a/controller/PostgreSQL.hpp +++ b/controller/PostgreSQL.hpp @@ -18,6 +18,7 @@ #include "ConnectionPool.hpp" #include "DB.hpp" +#include "NotificationListener.hpp" #include "opentelemetry/trace/provider.h" #include @@ -188,6 +189,67 @@ struct NodeOnlineRecord { std::string osArch; }; +/** + * internal class for listening to PostgreSQL notification channels. + */ +template class _notificationReceiver : public pqxx::notification_receiver { + public: + _notificationReceiver(T* p, pqxx::connection& c, const std::string& channel) : pqxx::notification_receiver(c, channel), _listener(p) + { + fprintf(stderr, "initialize PostgresMemberNotificationListener::_notificationReceiver\n"); + } + + virtual void operator()(const std::string& payload, int backendPid) + { + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("notification_receiver"); + auto span = tracer->StartSpan("notification_receiver::operator()"); + auto scope = tracer->WithActiveSpan(span); + _listener->onNotification(payload); + } + + private: + T* _listener; +}; + +class PostgresMemberListener : public NotificationListener { + public: + PostgresMemberListener(DB* db, std::shared_ptr > pool, const std::string& channel, uint64_t timeout); + virtual ~PostgresMemberListener(); + + virtual void listen(); + + virtual void onNotification(const std::string& payload) override; + + private: + bool _run = false; + DB* _db; + std::shared_ptr > _pool; + std::shared_ptr _conn; + uint64_t _notification_timeout; + std::thread _listenerThread; + _notificationReceiver* _receiver; +}; + +class PostgresNetworkListener : public NotificationListener { + public: + PostgresNetworkListener(DB* db, std::shared_ptr > pool, const std::string& channel, uint64_t timeout); + virtual ~PostgresNetworkListener(); + + virtual void listen(); + + virtual void onNotification(const std::string& payload) override; + + private: + bool _run = false; + DB* _db; + std::shared_ptr > _pool; + std::shared_ptr _conn; + uint64_t _notification_timeout; + std::thread _listenerThread; + _notificationReceiver* _receiver; +}; + } // namespace ZeroTier #endif // ZT_CONTROLLER_POSTGRESQL_HPP diff --git a/controller/PubSubListener.cpp b/controller/PubSubListener.cpp index 449f5a6865..a533431806 100644 --- a/controller/PubSubListener.cpp +++ b/controller/PubSubListener.cpp @@ -1,8 +1,12 @@ #ifdef ZT_CONTROLLER_USE_LIBPQ #include "PubSubListener.hpp" +#include "DB.hpp" +#include "opentelemetry/trace/provider.h" #include "rustybits.h" +#include + namespace ZeroTier { void listener_callback(void* user_ptr, const uint8_t* payload, uintptr_t length) @@ -17,15 +21,20 @@ void listener_callback(void* user_ptr, const uint8_t* payload, uintptr_t length) listener->onNotification(payload_str); } -PubSubNetworkListener::PubSubNetworkListener(const char* controller_id, uint64_t listen_timeout, rustybits::NetworkListenerCallback callback) : _listener(nullptr) +PubSubNetworkListener::PubSubNetworkListener(std::string controller_id, uint64_t listen_timeout, DB* db) : _run(true), _controller_id(controller_id), _db(db), _listener(nullptr) { - _listener = rustybits::network_listener_new(controller_id, listen_timeout, callback, this); + _listener = rustybits::network_listener_new(_controller_id.c_str(), listen_timeout, listener_callback, this); _listenThread = std::thread(&PubSubNetworkListener::listenThread, this); _changeHandlerThread = std::thread(&PubSubNetworkListener::changeHandlerThread, this); } PubSubNetworkListener::~PubSubNetworkListener() { + _run = false; + if (_listenThread.joinable()) { + _listenThread.join(); + } + if (_listener) { rustybits::network_listener_delete(_listener); _listener = nullptr; @@ -34,15 +43,74 @@ PubSubNetworkListener::~PubSubNetworkListener() void PubSubNetworkListener::onNotification(const std::string& payload) { + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("PubSubNetworkListener"); + auto span = tracer->StartSpan("PubSubNetworkListener::onNotification"); + auto scope = tracer->WithActiveSpan(span); + span->SetAttribute("payload", payload); + fprintf(stderr, "Network notification received: %s\n", payload.c_str()); - // TODO: Implement the logic to handle network notifications + + try { + nlohmann::json j = nlohmann::json::parse(payload); + nlohmann::json& ov_tmp = j["old"]; + nlohmann::json& nv_tmp = j["new"]; + nlohmann::json oldConfig, newConfig; + + if (ov_tmp.is_object()) { + // TODO: copy old configuration to oldConfig + // changing key names along the way + } + if (nv_tmp.is_object()) { + // TODO: copy new configuration to newConfig + // changing key names along the way + } + + if (oldConfig.is_object() && newConfig.is_object()) { + // network modification + std::string nwid = oldConfig["id"].get(); + span->SetAttribute("action", "network_change"); + span->SetAttribute("network_id", nwid); + _db->save(newConfig, _db->isReady()); + } + else if (newConfig.is_object() && ! oldConfig.is_object()) { + // new network + std::string nwid = newConfig["id"]; + span->SetAttribute("network_id", nwid); + span->SetAttribute("action", "new_network"); + _db->save(newConfig, _db->isReady()); + } + else if (! newConfig.is_object() && oldConfig.is_object()) { + // network deletion + std::string nwid = oldConfig["id"]; + span->SetAttribute("action", "delete_network"); + span->SetAttribute("network_id", nwid); + + uint64_t networkId = Utils::hexStrToU64(nwid.c_str()); + if (networkId) { + _db->eraseNetwork(networkId); + } + } + } + catch (const nlohmann::json::parse_error& e) { + fprintf(stderr, "JSON parse error: %s\n", e.what()); + span->SetAttribute("error", e.what()); + span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + return; + } + catch (const std::exception& e) { + fprintf(stderr, "Exception in PubSubNetworkListener: %s\n", e.what()); + span->SetAttribute("error", e.what()); + span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + return; + } } void PubSubNetworkListener::listenThread() { if (_listener) { - while (rustybits::network_listener_listen(_listener)) { - // just keep looping + while (_run) { + rustybits::network_listener_listen(_listener); } } } @@ -54,17 +122,21 @@ void PubSubNetworkListener::changeHandlerThread() } } -PubSubMemberListener::PubSubMemberListener(const char* controller_id, uint64_t listen_timeout, rustybits::NetworkListenerCallback callback) : _listener(nullptr) +PubSubMemberListener::PubSubMemberListener(std::string controller_id, uint64_t listen_timeout, DB* db) : _run(true), _controller_id(controller_id), _db(db), _listener(nullptr) { - // Initialize the member listener with the provided controller ID and timeout - // The callback will be called when a member notification is received - { - _listener = rustybits::member_listener_new("controller_id", 60, listener_callback, this); - } + _run = true; + _listener = rustybits::member_listener_new(_controller_id.c_str(), listen_timeout, listener_callback, this); + _listenThread = std::thread(&PubSubMemberListener::listenThread, this); + _changeHandlerThread = std::thread(&PubSubMemberListener::changeHandlerThread, this); } PubSubMemberListener::~PubSubMemberListener() { + _run = false; + if (_listenThread.joinable()) { + _listenThread.join(); + } + if (_listener) { rustybits::member_listener_delete(_listener); _listener = nullptr; @@ -73,16 +145,80 @@ PubSubMemberListener::~PubSubMemberListener() void PubSubMemberListener::onNotification(const std::string& payload) { + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("PubSubMemberListener"); + auto span = tracer->StartSpan("PubSubMemberListener::onNotification"); + auto scope = tracer->WithActiveSpan(span); + span->SetAttribute("payload", payload); + fprintf(stderr, "Member notification received: %s\n", payload.c_str()); - // TODO: Implement the logic to handle network notifications + try { + nlohmann::json tmp; + nlohmann::json old_tmp = tmp["old"]; + nlohmann::json new_tmp = tmp["new"]; + nlohmann::json oldConfig, newConfig; + + if (old_tmp.is_object()) { + // TODO: copy old configuration to oldConfig + } + + if (new_tmp.is_object()) { + // TODO: copy new configuration to newConfig + } + + if (oldConfig.is_object() && newConfig.is_object()) { + // member modification + std::string memberID = oldConfig["id"].get(); + std::string networkID = oldConfig["nwid"].get(); + span->SetAttribute("action", "member_change"); + span->SetAttribute("member_id", memberID); + span->SetAttribute("network_id", networkID); + _db->save(newConfig, _db->isReady()); + } + else if (newConfig.is_object() && ! oldConfig.is_object()) { + // new member + std::string memberID = newConfig["id"].get(); + std::string networkID = newConfig["nwid"].get(); + span->SetAttribute("action", "new_member"); + span->SetAttribute("member_id", memberID); + span->SetAttribute("network_id", networkID); + _db->save(newConfig, _db->isReady()); + } + else if (! newConfig.is_object() && oldConfig.is_object()) { + // member deletion + std::string memberID = oldConfig["id"].get(); + std::string networkID = oldConfig["nwid"].get(); + span->SetAttribute("action", "delete_member"); + span->SetAttribute("member_id", memberID); + span->SetAttribute("network_id", networkID); + + uint64_t networkId = Utils::hexStrToU64(networkID.c_str()); + uint64_t memberId = Utils::hexStrToU64(memberID.c_str()); + if (networkId && memberId) { + _db->eraseMember(networkId, memberId); + } + } + } + catch (const nlohmann::json::parse_error& e) { + fprintf(stderr, "JSON parse error: %s\n", e.what()); + span->SetAttribute("error", e.what()); + span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + return; + } + catch (const std::exception& e) { + fprintf(stderr, "Exception in PubSubMemberListener: %s\n", e.what()); + span->SetAttribute("error", e.what()); + span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + return; + } } void PubSubMemberListener::listenThread() { if (_listener) { - while (rustybits::member_listener_listen(_listener)) { - // just keep looping + while (_run) { + rustybits::member_listener_listen(_listener); } } } diff --git a/controller/PubSubListener.hpp b/controller/PubSubListener.hpp index 5455ce4b9a..93b9e36d80 100644 --- a/controller/PubSubListener.hpp +++ b/controller/PubSubListener.hpp @@ -3,6 +3,7 @@ #ifndef ZT_CONTROLLER_PUBSUBLISTENER_HPP #define ZT_CONTROLLER_PUBSUBLISTENER_HPP +#include "NotificationListener.hpp" #include "rustybits.h" #include @@ -10,7 +11,17 @@ #include namespace ZeroTier { -class PubSubListener { +class DB; + +struct PubSubConfig { + const char* controller_id; + uint64_t listen_timeout; +}; + +/** + * Base class for GCP PubSub listeners + */ +class PubSubListener : public NotificationListener { public: virtual ~PubSubListener() { @@ -19,9 +30,12 @@ class PubSubListener { virtual void onNotification(const std::string& payload) = 0; }; +/** + * Listener for network notifications via GCP PubSub + */ class PubSubNetworkListener : public PubSubListener { public: - PubSubNetworkListener(const char* controller_id, uint64_t listen_timeout, rustybits::NetworkListenerCallback callback); + PubSubNetworkListener(std::string controller_id, uint64_t listen_timeout, DB* db); virtual ~PubSubNetworkListener(); virtual void onNotification(const std::string& payload) override; @@ -30,14 +44,20 @@ class PubSubNetworkListener : public PubSubListener { void listenThread(); void changeHandlerThread(); + bool _run = false; + std::string _controller_id; + DB* _db; const rustybits::NetworkListener* _listener; std::thread _listenThread; std::thread _changeHandlerThread; }; +/** + * Listener for member notifications via GCP PubSub + */ class PubSubMemberListener : public PubSubListener { public: - PubSubMemberListener(const char* controller_id, uint64_t listen_timeout, rustybits::MemberListenerCallback callback); + PubSubMemberListener(std::string controller_id, uint64_t listen_timeout, DB* db); virtual ~PubSubMemberListener(); virtual void onNotification(const std::string& payload) override; @@ -46,6 +66,9 @@ class PubSubMemberListener : public PubSubListener { void listenThread(); void changeHandlerThread(); + bool _run = false; + std::string _controller_id; + DB* _db; const rustybits::MemberListener* _listener; std::thread _listenThread; std::thread _changeHandlerThread; diff --git a/controller/RedisListener.cpp b/controller/RedisListener.cpp new file mode 100644 index 0000000000..7668d083a6 --- /dev/null +++ b/controller/RedisListener.cpp @@ -0,0 +1,214 @@ +#ifdef ZT_CONTROLLER_USE_LIBPQ + +#include "RedisListener.hpp" + +#include "../node/Metrics.hpp" +#include "nlohmann/json.hpp" +#include "opentelemetry/trace/provider.h" + +#include +#include +#include + +namespace ZeroTier { + +using Attrs = std::vector >; +using Item = std::pair; +using ItemStream = std::vector; + +RedisListener::RedisListener(std::string controller_id, std::shared_ptr redis) : _controller_id(controller_id), _redis(redis), _is_cluster(false), _run(false) +{ +} + +RedisListener::RedisListener(std::string controller_id, std::shared_ptr cluster) : _controller_id(controller_id), _cluster(cluster), _is_cluster(true), _run(false) +{ +} + +RedisListener::~RedisListener() +{ + _run = false; + if (_listenThread.joinable()) { + _listenThread.join(); + } +} + +RedisNetworkListener::RedisNetworkListener(std::string controller_id, std::shared_ptr redis, DB* db) : RedisListener(controller_id, redis), _db(db) +{ + // Additional initialization for network listener if needed +} + +RedisNetworkListener::RedisNetworkListener(std::string controller_id, std::shared_ptr cluster, DB* db) : RedisListener(controller_id, cluster), _db(db) +{ + // Additional initialization for network listener if needed +} + +RedisNetworkListener::~RedisNetworkListener() +{ + // Destructor logic if needed +} + +void RedisNetworkListener::listen() +{ + std::string key = "network-stream:{" + _controller_id + "}"; + std::string lastID = "0"; + while (_run) { + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("RedisNetworkListener"); + auto span = tracer->StartSpan("RedisNetworkListener::listen"); + auto scope = tracer->WithActiveSpan(span); + + try { + nlohmann::json tmp; + std::unordered_map result; + if (_is_cluster) { + _cluster->xread(key, lastID, std::chrono::seconds(1), 0, std::inserter(result, result.end())); + } + else { + _redis->xread(key, lastID, std::chrono::seconds(1), 0, std::inserter(result, result.end())); + } + + if (! result.empty()) { + for (auto element : result) { + for (auto rec : element.second) { + std::string id = rec.first; + auto attrs = rec.second; + + for (auto a : attrs) { + try { + tmp = nlohmann::json::parse(a.second); + tmp = nlohmann::json::parse(a.second); + nlohmann::json& ov = tmp["old_val"]; + nlohmann::json& nv = tmp["new_val"]; + nlohmann::json oldConfig, newConfig; + if (ov.is_object()) + oldConfig = ov; + if (nv.is_object()) + newConfig = nv; + if (oldConfig.is_object() || newConfig.is_object()) { + _db->_networkChanged(oldConfig, newConfig, true); + } + } + catch (const nlohmann::json::parse_error& e) { + fprintf(stderr, "JSON parse error: %s\n", e.what()); + } + catch (const std::exception& e) { + fprintf(stderr, "Exception in Redis network listener: %s\n", e.what()); + } + } + if (_is_cluster) { + _cluster->xdel(key, id); + } + else { + _redis->xdel(key, id); + } + lastID = id; + } + Metrics::redis_net_notification++; + } + } + } + catch (sw::redis::Error& e) { + fprintf(stderr, "Error in Redis network listener: %s\n", e.what()); + } + catch (const std::exception& e) { + fprintf(stderr, "Exception in Redis network listener: %s\n", e.what()); + } + } +} + +void RedisNetworkListener::onNotification(const std::string& payload) +{ + // Handle notifications if needed +} + +RedisMemberListener::RedisMemberListener(std::string controller_id, std::shared_ptr redis, DB* db) : RedisListener(controller_id, redis), _db(db) +{ + // Additional initialization for member listener if needed +} + +RedisMemberListener::RedisMemberListener(std::string controller_id, std::shared_ptr cluster, DB* db) : RedisListener(controller_id, cluster), _db(db) +{ + // Additional initialization for member listener if needed +} + +RedisMemberListener::~RedisMemberListener() +{ + // Destructor logic if needed +} + +void RedisMemberListener::listen() +{ + std::string key = "member-stream:{" + _controller_id + "}"; + std::string lastID = "0"; + fprintf(stderr, "Listening to Redis member stream: %s\n", key.c_str()); + while (_run) { + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("RedisMemberListener"); + auto span = tracer->StartSpan("RedisMemberListener::listen"); + auto scope = tracer->WithActiveSpan(span); + + try { + nlohmann::json tmp; + std::unordered_map result; + if (_is_cluster) { + _cluster->xread(key, lastID, std::chrono::seconds(1), 0, std::inserter(result, result.end())); + } + else { + _redis->xread(key, lastID, std::chrono::seconds(1), 0, std::inserter(result, result.end())); + } + + if (! result.empty()) { + for (auto element : result) { + for (auto rec : element.second) { + std::string id = rec.first; + auto attrs = rec.second; + + for (auto a : attrs) { + try { + tmp = nlohmann::json::parse(a.second); + nlohmann::json& ov = tmp["old_val"]; + nlohmann::json& nv = tmp["new_val"]; + nlohmann::json oldConfig, newConfig; + if (ov.is_object()) + oldConfig = ov; + if (nv.is_object()) + newConfig = nv; + if (oldConfig.is_object() || newConfig.is_object()) { + _db->_memberChanged(oldConfig, newConfig, true); + } + } + catch (const nlohmann::json::parse_error& e) { + fprintf(stderr, "JSON parse error: %s\n", e.what()); + } + catch (const std::exception& e) { + fprintf(stderr, "Exception in Redis member listener: %s\n", e.what()); + } + } + if (_is_cluster) { + _cluster->xdel(key, id); + } + else { + _redis->xdel(key, id); + } + lastID = id; + } + Metrics::redis_mem_notification++; + } + } + } + catch (sw::redis::Error& e) { + fprintf(stderr, "Error in Redis member listener: %s\n", e.what()); + } + catch (const std::exception& e) { + fprintf(stderr, "Exception in Redis member listener: %s\n", e.what()); + } + } +} + +void RedisMemberListener::onNotification(const std::string& payload) +{ +} + +} // namespace ZeroTier + +#endif // ZT_CONTROLLER_USE_LIBPQ \ No newline at end of file diff --git a/controller/RedisListener.hpp b/controller/RedisListener.hpp new file mode 100644 index 0000000000..2e7e426241 --- /dev/null +++ b/controller/RedisListener.hpp @@ -0,0 +1,76 @@ +#ifdef ZT_CONTROLLER_USE_LIBPQ + +#ifndef ZT_CONTROLLER_REDIS_LISTENER_HPP +#define ZT_CONTROLLER_REDIS_LISTENER_HPP + +#include "DB.hpp" +#include "NotificationListener.hpp" +#include "Redis.hpp" + +#include +#include +#include +#include + +namespace ZeroTier { + +class RedisListener : public NotificationListener { + public: + RedisListener(std::string controller_id, std::shared_ptr redis); + RedisListener(std::string controller_id, std::shared_ptr cluster); + + virtual ~RedisListener(); + + virtual void listen() = 0; + virtual void onNotification(const std::string& payload) override + { + } + + void start() + { + _run = true; + _listenThread = std::thread(&RedisListener::listen, this); + } + + protected: + std::string _controller_id; + std::shared_ptr _redis; + std::shared_ptr _cluster; + bool _is_cluster = false; + bool _run = false; + + private: + std::thread _listenThread; +}; + +class RedisNetworkListener : public RedisListener { + public: + RedisNetworkListener(std::string controller_id, std::shared_ptr redis, DB* db); + RedisNetworkListener(std::string controller_id, std::shared_ptr cluster, DB* db); + virtual ~RedisNetworkListener(); + + virtual void listen() override; + virtual void onNotification(const std::string& payload) override; + + private: + DB* _db; +}; + +class RedisMemberListener : public RedisListener { + public: + RedisMemberListener(std::string controller_id, std::shared_ptr redis, DB* db); + RedisMemberListener(std::string controller_id, std::shared_ptr cluster, DB* db); + virtual ~RedisMemberListener(); + + virtual void listen() override; + virtual void onNotification(const std::string& payload) override; + + private: + DB* _db; +}; + +} // namespace ZeroTier + +#endif // ZT_CONTROLLER_REDIS_LISTENER_HPP + +#endif // ZT_CONTROLLER_USE_LIBPQ \ No newline at end of file diff --git a/objects.mk b/objects.mk index 79bd0ab486..2e20a759b7 100644 --- a/objects.mk +++ b/objects.mk @@ -42,7 +42,10 @@ ONE_OBJS=\ controller/CtlUtil.o \ controller/CV1.o \ controller/CV2.o \ + controller/CentralDB.o \ controller/PubSubListener.o \ + controller/RedisListener.o \ + controller/PostgreSQL.o \ osdep/EthernetTap.o \ osdep/ManagedRoute.o \ osdep/Http.o \ From 2833d0e4f4a9bc3e1914d9daca71deaf648d5c56 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 20 Aug 2025 17:07:56 -0700 Subject: [PATCH 022/245] make whether SSO is enabled a switchable config value --- controller/CentralDB.cpp | 318 ++++++++++++++++++++------------------- controller/CentralDB.hpp | 2 + 2 files changed, 163 insertions(+), 157 deletions(-) diff --git a/controller/CentralDB.cpp b/controller/CentralDB.cpp index eefc43c85b..ad054b6910 100644 --- a/controller/CentralDB.cpp +++ b/controller/CentralDB.cpp @@ -53,6 +53,7 @@ using ItemStream = std::vector; CentralDB::CentralDB(const Identity& myId, const char* path, int listenPort, CentralDB::ListenerMode mode, ControllerConfig* cc) : DB() , _listenerMode(mode) + , _controllerConfig(cc) , _pool() , _myId(myId) , _myAddress(myId.address()) @@ -391,187 +392,190 @@ void CentralDB::nodeIsOnline(const uint64_t networkId, const uint64_t memberId, AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::string& redirectURL) { - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("CentralDB"); - auto span = tracer->StartSpan("CentralDB::getSSOAuthInfo"); - auto scope = tracer->WithActiveSpan(span); + if (_controllerConfig->ssoEnabled) { + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("CentralDB"); + auto span = tracer->StartSpan("CentralDB::getSSOAuthInfo"); + auto scope = tracer->WithActiveSpan(span); - Metrics::db_get_sso_info++; - // NONCE is just a random character string. no semantic meaning - // state = HMAC SHA384 of Nonce based on shared sso key - // - // need nonce timeout in database? make sure it's used within X time - // X is 5 minutes for now. Make configurable later? - // - // how do we tell when a nonce is used? if auth_expiration_time is set - std::string networkId = member["nwid"]; - std::string memberId = member["id"]; - - char authenticationURL[4096] = { 0 }; - AuthInfo info; - info.enabled = true; - - // if (memberId == "a10dccea52" && networkId == "8056c2e21c24673d") { - // fprintf(stderr, "invalid authinfo for grant's machine\n"); - // info.version=1; - // return info; - // } - // fprintf(stderr, "PostgreSQL::updateMemberOnLoad: %s-%s\n", networkId.c_str(), memberId.c_str()); - std::shared_ptr c; - try { - c = _pool->borrow(); - pqxx::work w(*c->c); + Metrics::db_get_sso_info++; + // NONCE is just a random character string. no semantic meaning + // state = HMAC SHA384 of Nonce based on shared sso key + // + // need nonce timeout in database? make sure it's used within X time + // X is 5 minutes for now. Make configurable later? + // + // how do we tell when a nonce is used? if auth_expiration_time is set + std::string networkId = member["nwid"]; + std::string memberId = member["id"]; + + char authenticationURL[4096] = { 0 }; + AuthInfo info; + info.enabled = true; + + // if (memberId == "a10dccea52" && networkId == "8056c2e21c24673d") { + // fprintf(stderr, "invalid authinfo for grant's machine\n"); + // info.version=1; + // return info; + // } + // fprintf(stderr, "PostgreSQL::updateMemberOnLoad: %s-%s\n", networkId.c_str(), memberId.c_str()); + std::shared_ptr c; + try { + c = _pool->borrow(); + pqxx::work w(*c->c); + + char nonceBytes[16] = { 0 }; + std::string nonce = ""; - char nonceBytes[16] = { 0 }; - std::string nonce = ""; - - // check if the member exists first. - pqxx::row count = w.exec_params1("SELECT count(id) FROM ztc_member WHERE id = $1 AND network_id = $2 AND deleted = false", memberId, networkId); - if (count[0].as() == 1) { - // get active nonce, if exists. - pqxx::result r = w.exec_params( - "SELECT nonce FROM ztc_sso_expiry " - "WHERE network_id = $1 AND member_id = $2 " - "AND ((NOW() AT TIME ZONE 'UTC') <= authentication_expiry_time) AND ((NOW() AT TIME ZONE 'UTC') <= nonce_expiration)", - networkId, - memberId); - - if (r.size() == 0) { - // no active nonce. - // find an unused nonce, if one exists. + // check if the member exists first. + pqxx::row count = w.exec_params1("SELECT count(id) FROM ztc_member WHERE id = $1 AND network_id = $2 AND deleted = false", memberId, networkId); + if (count[0].as() == 1) { + // get active nonce, if exists. pqxx::result r = w.exec_params( "SELECT nonce FROM ztc_sso_expiry " "WHERE network_id = $1 AND member_id = $2 " - "AND authentication_expiry_time IS NULL AND ((NOW() AT TIME ZONE 'UTC') <= nonce_expiration)", + "AND ((NOW() AT TIME ZONE 'UTC') <= authentication_expiry_time) AND ((NOW() AT TIME ZONE 'UTC') <= nonce_expiration)", networkId, memberId); - if (r.size() == 1) { - // we have an existing nonce. Use it - nonce = r.at(0)[0].as(); - Utils::unhex(nonce.c_str(), nonceBytes, sizeof(nonceBytes)); - } - else if (r.empty()) { - // create a nonce - Utils::getSecureRandom(nonceBytes, 16); - char nonceBuf[64] = { 0 }; - Utils::hex(nonceBytes, sizeof(nonceBytes), nonceBuf); - nonce = std::string(nonceBuf); - - pqxx::result ir = w.exec_params0( - "INSERT INTO ztc_sso_expiry " - "(nonce, nonce_expiration, network_id, member_id) VALUES " - "($1, TO_TIMESTAMP($2::double precision/1000), $3, $4)", - nonce, - OSUtils::now() + 300000, + if (r.size() == 0) { + // no active nonce. + // find an unused nonce, if one exists. + pqxx::result r = w.exec_params( + "SELECT nonce FROM ztc_sso_expiry " + "WHERE network_id = $1 AND member_id = $2 " + "AND authentication_expiry_time IS NULL AND ((NOW() AT TIME ZONE 'UTC') <= nonce_expiration)", networkId, memberId); - w.commit(); + if (r.size() == 1) { + // we have an existing nonce. Use it + nonce = r.at(0)[0].as(); + Utils::unhex(nonce.c_str(), nonceBytes, sizeof(nonceBytes)); + } + else if (r.empty()) { + // create a nonce + Utils::getSecureRandom(nonceBytes, 16); + char nonceBuf[64] = { 0 }; + Utils::hex(nonceBytes, sizeof(nonceBytes), nonceBuf); + nonce = std::string(nonceBuf); + + pqxx::result ir = w.exec_params0( + "INSERT INTO ztc_sso_expiry " + "(nonce, nonce_expiration, network_id, member_id) VALUES " + "($1, TO_TIMESTAMP($2::double precision/1000), $3, $4)", + nonce, + OSUtils::now() + 300000, + networkId, + memberId); + + w.commit(); + } + else { + // > 1 ?!? Thats an error! + fprintf(stderr, "> 1 unused nonce!\n"); + exit(6); + } + } + else if (r.size() == 1) { + nonce = r.at(0)[0].as(); + Utils::unhex(nonce.c_str(), nonceBytes, sizeof(nonceBytes)); } else { - // > 1 ?!? Thats an error! - fprintf(stderr, "> 1 unused nonce!\n"); - exit(6); + // more than 1 nonce in use? Uhhh... + fprintf(stderr, "> 1 nonce in use for network member?!?\n"); + exit(7); } - } - else if (r.size() == 1) { - nonce = r.at(0)[0].as(); - Utils::unhex(nonce.c_str(), nonceBytes, sizeof(nonceBytes)); - } - else { - // more than 1 nonce in use? Uhhh... - fprintf(stderr, "> 1 nonce in use for network member?!?\n"); - exit(7); - } - r = w.exec_params( - "SELECT oc.client_id, oc.authorization_endpoint, oc.issuer, oc.provider, oc.sso_impl_version " - "FROM ztc_network AS n " - "INNER JOIN ztc_org o " - " ON o.owner_id = n.owner_id " - "LEFT OUTER JOIN ztc_network_oidc_config noc " - " ON noc.network_id = n.id " - "LEFT OUTER JOIN ztc_oidc_config oc " - " ON noc.client_id = oc.client_id AND oc.org_id = o.org_id " - "WHERE n.id = $1 AND n.sso_enabled = true", - networkId); - - std::string client_id = ""; - std::string authorization_endpoint = ""; - std::string issuer = ""; - std::string provider = ""; - uint64_t sso_version = 0; - - if (r.size() == 1) { - client_id = r.at(0)[0].as >().value_or(""); - authorization_endpoint = r.at(0)[1].as >().value_or(""); - issuer = r.at(0)[2].as >().value_or(""); - provider = r.at(0)[3].as >().value_or(""); - sso_version = r.at(0)[4].as >().value_or(1); - } - else if (r.size() > 1) { - fprintf(stderr, "ERROR: More than one auth endpoint for an organization?!?!? NetworkID: %s\n", networkId.c_str()); - } - else { - fprintf(stderr, "No client or auth endpoint?!?\n"); - } + r = w.exec_params( + "SELECT oc.client_id, oc.authorization_endpoint, oc.issuer, oc.provider, oc.sso_impl_version " + "FROM ztc_network AS n " + "INNER JOIN ztc_org o " + " ON o.owner_id = n.owner_id " + "LEFT OUTER JOIN ztc_network_oidc_config noc " + " ON noc.network_id = n.id " + "LEFT OUTER JOIN ztc_oidc_config oc " + " ON noc.client_id = oc.client_id AND oc.org_id = o.org_id " + "WHERE n.id = $1 AND n.sso_enabled = true", + networkId); + + std::string client_id = ""; + std::string authorization_endpoint = ""; + std::string issuer = ""; + std::string provider = ""; + uint64_t sso_version = 0; - info.version = sso_version; - - // no catch all else because we don't actually care if no records exist here. just continue as normal. - if ((! client_id.empty()) && (! authorization_endpoint.empty())) { - uint8_t state[48]; - HMACSHA384(_ssoPsk, nonceBytes, sizeof(nonceBytes), state); - char state_hex[256]; - Utils::hex(state, 48, state_hex); - - if (info.version == 0) { - char url[2048] = { 0 }; - OSUtils::ztsnprintf( - url, - sizeof(authenticationURL), - "%s?response_type=id_token&response_mode=form_post&scope=openid+email+profile&redirect_uri=%s&nonce=%s&state=%s&client_id=%s", - authorization_endpoint.c_str(), - url_encode(redirectURL).c_str(), - nonce.c_str(), - state_hex, - client_id.c_str()); - info.authenticationURL = std::string(url); + if (r.size() == 1) { + client_id = r.at(0)[0].as >().value_or(""); + authorization_endpoint = r.at(0)[1].as >().value_or(""); + issuer = r.at(0)[2].as >().value_or(""); + provider = r.at(0)[3].as >().value_or(""); + sso_version = r.at(0)[4].as >().value_or(1); } - else if (info.version == 1) { - info.ssoClientID = client_id; - info.issuerURL = issuer; - info.ssoProvider = provider; - info.ssoNonce = nonce; - info.ssoState = std::string(state_hex) + "_" + networkId; - info.centralAuthURL = redirectURL; + else if (r.size() > 1) { + fprintf(stderr, "ERROR: More than one auth endpoint for an organization?!?!? NetworkID: %s\n", networkId.c_str()); + } + else { + fprintf(stderr, "No client or auth endpoint?!?\n"); + } + + info.version = sso_version; + + // no catch all else because we don't actually care if no records exist here. just continue as normal. + if ((! client_id.empty()) && (! authorization_endpoint.empty())) { + uint8_t state[48]; + HMACSHA384(_ssoPsk, nonceBytes, sizeof(nonceBytes), state); + char state_hex[256]; + Utils::hex(state, 48, state_hex); + + if (info.version == 0) { + char url[2048] = { 0 }; + OSUtils::ztsnprintf( + url, + sizeof(authenticationURL), + "%s?response_type=id_token&response_mode=form_post&scope=openid+email+profile&redirect_uri=%s&nonce=%s&state=%s&client_id=%s", + authorization_endpoint.c_str(), + url_encode(redirectURL).c_str(), + nonce.c_str(), + state_hex, + client_id.c_str()); + info.authenticationURL = std::string(url); + } + else if (info.version == 1) { + info.ssoClientID = client_id; + info.issuerURL = issuer; + info.ssoProvider = provider; + info.ssoNonce = nonce; + info.ssoState = std::string(state_hex) + "_" + networkId; + info.centralAuthURL = redirectURL; #ifdef ZT_DEBUG - fprintf( - stderr, - "ssoClientID: %s\nissuerURL: %s\nssoNonce: %s\nssoState: %s\ncentralAuthURL: %s\nprovider: %s\n", - info.ssoClientID.c_str(), - info.issuerURL.c_str(), - info.ssoNonce.c_str(), - info.ssoState.c_str(), - info.centralAuthURL.c_str(), - provider.c_str()); + fprintf( + stderr, + "ssoClientID: %s\nissuerURL: %s\nssoNonce: %s\nssoState: %s\ncentralAuthURL: %s\nprovider: %s\n", + info.ssoClientID.c_str(), + info.issuerURL.c_str(), + info.ssoNonce.c_str(), + info.ssoState.c_str(), + info.centralAuthURL.c_str(), + provider.c_str()); #endif + } + } + else { + fprintf(stderr, "client_id: %s\nauthorization_endpoint: %s\n", client_id.c_str(), authorization_endpoint.c_str()); } } - else { - fprintf(stderr, "client_id: %s\nauthorization_endpoint: %s\n", client_id.c_str(), authorization_endpoint.c_str()); - } + + _pool->unborrow(c); + } + catch (std::exception& e) { + span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + fprintf(stderr, "ERROR: Error updating member on load for network %s: %s\n", networkId.c_str(), e.what()); } - _pool->unborrow(c); - } - catch (std::exception& e) { - span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "ERROR: Error updating member on load for network %s: %s\n", networkId.c_str(), e.what()); + return info; // std::string(authenticationURL); } - - return info; // std::string(authenticationURL); + return AuthInfo(); } void CentralDB::initializeNetworks() diff --git a/controller/CentralDB.hpp b/controller/CentralDB.hpp index 83f313e4dd..ebb0105ecc 100644 --- a/controller/CentralDB.hpp +++ b/controller/CentralDB.hpp @@ -26,6 +26,7 @@ struct PubSubConfig; struct PostgresNotifyConfig; struct ControllerConfig { + bool ssoEnabled; RedisConfig* redisConfig; PubSubConfig* pubSubConfig; PostgresNotifyConfig* postgresNotifyConfig; @@ -91,6 +92,7 @@ class CentralDB : public DB { enum OverrideMode { ALLOW_PGBOUNCER_OVERRIDE = 0, NO_OVERRIDE = 1 }; ListenerMode _listenerMode; + ControllerConfig* _controllerConfig; std::shared_ptr > _pool; const Identity _myId; From f8a4a5d6af8a031ea11355b60808fe911fdcb520 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 25 Aug 2025 15:09:10 -0700 Subject: [PATCH 023/245] rework protobuf messages PubSub allows us to do schema validation, however it only allows one top level message at a time. Move other sub-message declarations under the main message declaration so that we can enable schema validation in the pubsub stream directly --- rustybits/build.rs | 1 - rustybits/src/pubsub/member.proto | 60 +++++++------- rustybits/src/pubsub/member_listener.rs | 3 +- rustybits/src/pubsub/member_status.proto | 11 ++- rustybits/src/pubsub/metadata.proto | 8 -- rustybits/src/pubsub/network.proto | 101 ++++++++++++----------- rustybits/src/pubsub/network_listener.rs | 3 +- 7 files changed, 95 insertions(+), 92 deletions(-) delete mode 100644 rustybits/src/pubsub/metadata.proto diff --git a/rustybits/build.rs b/rustybits/build.rs index c4b083adb5..e5d61181ea 100644 --- a/rustybits/build.rs +++ b/rustybits/build.rs @@ -12,7 +12,6 @@ fn main() { .type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]") .compile_protos( &[ - "src/pubsub/metadata.proto", "src/pubsub/network.proto", "src/pubsub/member.proto", "src/pubsub/member_status.proto", diff --git a/rustybits/src/pubsub/member.proto b/rustybits/src/pubsub/member.proto index cdf8cc1698..511f1a8d7f 100644 --- a/rustybits/src/pubsub/member.proto +++ b/rustybits/src/pubsub/member.proto @@ -1,37 +1,39 @@ syntax = "proto3"; -import "metadata.proto"; - package pbmessages; -message Member { - string device_id = 1; - string network_id = 2; - string identity = 3; // Identity of the member - bool authorized = 4; // Whether the member is authorized - repeated string ip_assignments = 5; // List of IP assignments - bool active_bridge = 6; // Whether the member is an active bridge - string tags = 7; // JSON string of tags - string capabilities = 8; // JSON string of capabilities - uint64 creation_time = 9; // Unix timestamp in milliseconds - bool no_auto_assign_ips = 10; // Whether auto IP assignment is disabled - uint64 revision = 11; // Revision number - uint64 last_authorized_time = 12; // Last time the member was authorized - uint64 last_deauthorized_time = 13; // Last time the member was deauthorized - optional string last_authorized_credential_type = 14; // Type of credential used for last authorization - optional string last_authorized_credential = 15; // Credential used for last authorization - int32 version_major = 16; // Major version of the member - int32 version_minor = 17; // Minor version of the member - int32 version_rev = 18; // Patch version of the member - int32 version_protocol = 19; // Protocol version of the member - int32 remote_trace_level = 20; // Remote trace level - optional string remote_trace_target = 21; // Remote trace target - bool sso_exepmt = 22; // Whether SSO is exempt - uint64 auth_expiry_time = 23; // Authorization expiry time in milliseconds -} - message MemberChange { + message Member { + string device_id = 1; + string network_id = 2; + string identity = 3; // Identity of the member + bool authorized = 4; // Whether the member is authorized + repeated string ip_assignments = 5; // List of IP assignments + bool active_bridge = 6; // Whether the member is an active bridge + string tags = 7; // JSON string of tags + string capabilities = 8; // JSON string of capabilities + uint64 creation_time = 9; // Unix timestamp in milliseconds + bool no_auto_assign_ips = 10; // Whether auto IP assignment is disabled + uint64 revision = 11; // Revision number + uint64 last_authorized_time = 12; // Last time the member was authorized + uint64 last_deauthorized_time = 13; // Last time the member was deauthorized + optional string last_authorized_credential_type = 14; // Type of credential used for last authorization + optional string last_authorized_credential = 15; // Credential used for last authorization + int32 version_major = 16; // Major version of the member + int32 version_minor = 17; // Minor version of the member + int32 version_rev = 18; // Patch version of the member + int32 version_protocol = 19; // Protocol version of the member + int32 remote_trace_level = 20; // Remote trace level + optional string remote_trace_target = 21; // Remote trace target + bool sso_exepmt = 22; // Whether SSO is exempt + uint64 auth_expiry_time = 23; // Authorization expiry time in milliseconds + } + message MemberChangeMetadata { + string trace_id = 1; + string controller_id = 2; + } + optional Member old = 1; optional Member new = 2; - optional Metadata metadata = 3; + optional MemberChangeMetadata metadata = 3; } diff --git a/rustybits/src/pubsub/member_listener.rs b/rustybits/src/pubsub/member_listener.rs index 993eaed14f..63ac6bff3f 100644 --- a/rustybits/src/pubsub/member_listener.rs +++ b/rustybits/src/pubsub/member_listener.rs @@ -87,7 +87,8 @@ impl MemberListener { mod tests { use super::*; use crate::pubsub::change_listener::tests::setup_pubsub_emulator; - use crate::pubsub::protobuf::pbmessages::{Member, MemberChange}; + use crate::pubsub::protobuf::pbmessages::member_change::Member; + use crate::pubsub::protobuf::pbmessages::MemberChange; use gcloud_googleapis::pubsub::v1::PubsubMessage; use gcloud_pubsub::client::{Client, ClientConfig}; diff --git a/rustybits/src/pubsub/member_status.proto b/rustybits/src/pubsub/member_status.proto index 74e5900896..2483905176 100644 --- a/rustybits/src/pubsub/member_status.proto +++ b/rustybits/src/pubsub/member_status.proto @@ -2,10 +2,15 @@ syntax = "proto3"; package pbmessages; -import "metadata.proto"; + message MemberStatus { - Metadata metadata = 1; + message MemberStatusMetadata { + string trace_id = 1; + string controller_id = 2; + } + + MemberStatusMetadata metadata = 1; string network_id = 2; string member_id = 3; uint64 timestamp = 4; // Unix timestamp in milliseconds @@ -13,4 +18,4 @@ message MemberStatus { optional string os = 6; optional string arch = 7; optional string version = 8; -} \ No newline at end of file +} diff --git a/rustybits/src/pubsub/metadata.proto b/rustybits/src/pubsub/metadata.proto deleted file mode 100644 index a5e75dac40..0000000000 --- a/rustybits/src/pubsub/metadata.proto +++ /dev/null @@ -1,8 +0,0 @@ -syntax = "proto3"; - -package pbmessages; - -message Metadata { - string trace_id = 1; - string controller_id = 2; -} \ No newline at end of file diff --git a/rustybits/src/pubsub/network.proto b/rustybits/src/pubsub/network.proto index cf2586fe2f..fc2a21385d 100644 --- a/rustybits/src/pubsub/network.proto +++ b/rustybits/src/pubsub/network.proto @@ -1,62 +1,65 @@ syntax = "proto3"; -import "metadata.proto"; - package pbmessages; -message IPRange { - string start_ip = 1; // Start of the IP range - string end_ip = 2; // End of the IP range -} +message NetworkChange { + message NetworkChangeMetadata { + string trace_id = 1; + string controller_id = 2; + } -message Route { - string target = 1; // Target IP or network - optional string via = 2; // Optional next hop IP -} + message IPRange { + string start_ip = 1; // Start of the IP range + string end_ip = 2; // End of the IP range + } -message DNS { - string domain = 1; // Search domain - repeated string nameservers = 2; // List of nameservers -} + message Route { + string target = 1; // Target IP or network + optional string via = 2; // Optional next hop IP + } -message IPV4AssignMode { - bool zt = 1; // Whether ZeroTier is used for IPv4 assignment -} + message DNS { + string domain = 1; // Search domain + repeated string nameservers = 2; // List of nameservers + } -message IPv6AssignMode { - bool six_plane = 1; // Whether 6plane is used for IPv6 assignment - bool rfc4193 = 2; // Whether RFC 4193 is used for IPv6 assignment - bool zt = 3; // Whether ZeroTier is used for IPv6 assignment -} + message IPV4AssignMode { + bool zt = 1; // Whether ZeroTier is used for IPv4 assignment + } -message Network { - string network_id = 1; - string capabilities = 2; // JSON string of capabilities - uint64 creation_time = 3; // Unix timestamp in milliseconds - bool enable_broadcast = 4; // Whether broadcast is enabled - repeated IPRange assignment_pools = 5; // List of IP ranges for assignment - uint32 mtu = 6; // Maximum Transmission Unit - uint32 multicast_limit = 7; // Limit for multicast messages - optional string name = 8; // Name of the network - bool is_private = 9; // Whether the network is private - uint32 remote_trace_level = 10; // Remote trace level - optional string remote_trace_target = 11; // Remote trace target - uint64 revision = 12; // Revision number - repeated Route routes = 13; // List of routes - string rules = 14; // JSON string of rules - optional string tags = 15; // JSON string of tags - IPV4AssignMode ipv4_assign_mode = 16; // IPv4 assignment mode - IPv6AssignMode ipv6_assign_mode = 17; // IPv6 assignment mode - optional DNS dns = 18; // DNS configuration - bool sso_enabled = 19; // Whether Single Sign-On is enabled - optional string sso_client_id = 20; // SSO client ID - optional string sso_authorization_endpoint = 21; // SSO authorization endpoint - optional string sso_issuer = 22; // SSO issuer - optional string sso_provider = 23; // SSO provider -} + message IPv6AssignMode { + bool six_plane = 1; // Whether 6plane is used for IPv6 assignment + bool rfc4193 = 2; // Whether RFC 4193 is used for IPv6 assignment + bool zt = 3; // Whether ZeroTier is used for IPv6 assignment + } + + message Network { + string network_id = 1; + string capabilities = 2; // JSON string of capabilities + uint64 creation_time = 3; // Unix timestamp in milliseconds + bool enable_broadcast = 4; // Whether broadcast is enabled + repeated IPRange assignment_pools = 5; // List of IP ranges for assignment + uint32 mtu = 6; // Maximum Transmission Unit + uint32 multicast_limit = 7; // Limit for multicast messages + optional string name = 8; // Name of the network + bool is_private = 9; // Whether the network is private + uint32 remote_trace_level = 10; // Remote trace level + optional string remote_trace_target = 11; // Remote trace target + uint64 revision = 12; // Revision number + repeated Route routes = 13; // List of routes + string rules = 14; // JSON string of rules + optional string tags = 15; // JSON string of tags + IPV4AssignMode ipv4_assign_mode = 16; // IPv4 assignment mode + IPv6AssignMode ipv6_assign_mode = 17; // IPv6 assignment mode + optional DNS dns = 18; // DNS configuration + bool sso_enabled = 19; // Whether Single Sign-On is enabled + optional string sso_client_id = 20; // SSO client ID + optional string sso_authorization_endpoint = 21; // SSO authorization endpoint + optional string sso_issuer = 22; // SSO issuer + optional string sso_provider = 23; // SSO provider + } -message NetworkChange { optional Network old = 1; optional Network new = 2; - optional Metadata metadata = 3; + optional NetworkChangeMetadata metadata = 3; } diff --git a/rustybits/src/pubsub/network_listener.rs b/rustybits/src/pubsub/network_listener.rs index 987369220f..1478d0859f 100644 --- a/rustybits/src/pubsub/network_listener.rs +++ b/rustybits/src/pubsub/network_listener.rs @@ -88,7 +88,8 @@ impl NetworkListener { mod tests { use super::*; use crate::pubsub::change_listener::tests::setup_pubsub_emulator; - use crate::pubsub::protobuf::pbmessages::Network; + use crate::pubsub::protobuf::pbmessages::network_change::Network; + use crate::pubsub::protobuf::pbmessages::NetworkChange; use gcloud_googleapis::pubsub::v1::PubsubMessage; use gcloud_pubsub::client::{Client, ClientConfig}; From 7f3b15011ef44646d01255161b945b45a434a320 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 27 Aug 2025 16:23:02 -0700 Subject: [PATCH 024/245] Update central controller build to use CMake + conda Muuuuch easier to use external dependencies now Also tried out conan and vcpkg. Ran into dependency issues when solving for packages to install with conan. vcpkg is just obtuse as all hell to install and not easy to integrate --- .gitignore | 1 + CMakeLists.txt | 133 +- build_central_controller.sh | 18 + cmake/cpp-httplib.cmake | 21 + cmake/miniupnpc.cmake | 30 + cmake/redis-plus-plus.cmake | 19 + controller/CMakeLists.txt | 75 + controller/CV1.hpp | 2 +- controller/CV2.hpp | 2 +- controller/CentralDB.hpp | 2 +- controller/EmbeddedNetworkController.hpp | 4 + controller/LFDB.cpp | 4 + controller/README_CENTRAL_CONTROLLER.md | 56 + controller/RedisListener.hpp | 2 +- ext/CMakeLists.txt | 12 + .../Dockerfile.run_base2 | 23 + .../3rdparty/http-client-lite/CMakeLists.txt | 2 +- .../core/CMakeLists.txt | 2 +- .../simpleapi/CMakeLists.txt | 2 +- make-linux.mk | 2 +- node/CMakeLists.txt | 94 + osdep/CMakeLists.txt | 59 + osdep/ExtOsdep.cpp | 4 + rustybits/Cargo.toml | 2 +- rustybits/smeeclient/Cargo.lock | 2998 ----------------- service/CMakeLists.txt | 50 + service/OneService.cpp | 11 +- 27 files changed, 615 insertions(+), 3015 deletions(-) create mode 100755 build_central_controller.sh create mode 100644 cmake/cpp-httplib.cmake create mode 100644 cmake/miniupnpc.cmake create mode 100644 cmake/redis-plus-plus.cmake create mode 100644 controller/CMakeLists.txt create mode 100644 controller/README_CENTRAL_CONTROLLER.md create mode 100644 ext/CMakeLists.txt create mode 100644 ext/central-controller-docker/Dockerfile.run_base2 create mode 100644 node/CMakeLists.txt create mode 100644 osdep/CMakeLists.txt delete mode 100644 rustybits/smeeclient/Cargo.lock create mode 100644 service/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 04a7d1eac5..ec162c2f39 100755 --- a/.gitignore +++ b/.gitignore @@ -141,3 +141,4 @@ snap/.snapcraft tcp-proxy/tcp-proxy rustybits/target ext/installfiles/windows/*.back*.aip +build/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index fff7808e10..ddd8a738db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,133 @@ # CMake build script for libzerotiercore.a -cmake_minimum_required (VERSION 2.8) -project (zerotiercore) +cmake_minimum_required (VERSION 3.13) +project (zerotier-one LANGUAGES CXX C) + +option(ZT1_CENTRAL_CONTROLLER "Build with ZeroTier Central Controller support" OFF) set (PROJ_DIR ${PROJECT_SOURCE_DIR}) -set (ZT_DEFS -std=c++11) -file(GLOB core_src_glob ${PROJ_DIR}/node/*.cpp) -add_library(zerotiercore STATIC ${core_src_glob}) +execute_process(COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE CPU_ARCHITECTURE) +set(CPU_ARCHITECTURE ${CPU_ARCHITECTURE} CACHE STRING "Target CPU architecture (detected automatically)") +message(STATUS "Detected CPU architecture: ${CPU_ARCHITECTURE}") +if(CPU_ARCHITECTURE STREQUAL "x86_64") + add_definitions( + -DZT_ARCHITECTURE=2 + -DZT_USE_X64_ASM_SALSA=1 + -DZT_USE_X64_ASM_ED25519=1 + -DZT_SSO_SUPPORTED=1 + -DZT_USE_X64_ASM_SALSA2012=1 + -DZT_USE_FAST_X64_ED25519=1 + ) +elseif(CPU_ARCHITECTURE STREQUAL "aarch64") + add_definitions(-DZT_ARCHITECTURE=4 -DZT_U-DZT_ARCH_ARM_HAS_NEON=1 -DZT_SSO_SUPPORTED=1) + add_compile_options(-march=armv8-a+crypto -mtune=generic -mstrict-align) +endif() + +include(FetchContent) +include(ExternalProject) + +add_definitions(-DCMAKE_BUILD) + +find_package(OpenSSL REQUIRED) +find_package(nlohmann_json REQUIRED) +find_package(inja REQUIRED) + +set(CMAKE_THREDAD_PREFER_PTHREAD TRUE CACHE INTERNAL "Use pthreads" FORCE) +set(THREADS_PREFER_PTHREAD_FLAG TRUE CACHE INTERNAL "Use pthreads" FORCE) +find_package(Threads REQUIRED) +if(CMAKE_USE_PTHREADS_INIT) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") +endif() + +if(ZT1_CENTRAL_CONTROLLER) + find_package(PostgreSQL REQUIRED) + find_package(opentelemetry-cpp REQUIRED COMPONENTS api sdk) + find_package(google_cloud_cpp_bigtable REQUIRED) + find_package(google_cloud_cpp_pubsub REQUIRED) +else() + find_package(opentelemetry-cpp REQUIRED COMPONENTS api) +endif() + +if(ZT1_CENTRAL_CONTROLLER) + set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to" FORCE) + set(CMAKE_CXX_STANDARD_REQUIRED True CACHE BOOL "C++ standard required" FORCE) + set(CMAKE_CXX_EXTENSIONS ON CACHE BOOL "Enable compiler-specific extensions" FORCE) + add_definitions(-DZT_CONTROLLER_USE_LIBPQ) + set(CONTROLLER_RUST_FEATURES ztcontroller) + set(RUST_BUILD_COMMAND cargo build --release -F ${CONTROLLER_RUST_FEATURES}) +else() + set(CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard to conform to") + set(CMAKE_CXX_STANDARD_REQUIRED True CACHE BOOL "C++ standard required") + set(CMAKE_CXX_EXTENSIONS ON CACHE BOOL "Enable compiler-specific extensions") + set(RUST_BUILD_COMMAND "cargo build --release") +endif() + +# build rustybits +ExternalProject_Add( + rustybits_build + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND "" + # PREFIX ${PROJ_DIR}/rustybits + BUILD_COMMAND cd ${PROJ_DIR}/rustybits && ${RUST_BUILD_COMMAND} + INSTALL_COMMAND "" + BUILD_BYPRODUCTS ${PROJ_DIR}/rustybits/target/release/librustybits.a ${PROJ_DIR}/rustybits/target/rustybits.h + ) +set(RUSTYBITS_LIB ${PROJ_DIR}/rustybits/target/release/librustybits.a) +set(RUSTYBITS_INCLUDE_DIR ${PROJ_DIR}/rustybits/target) +add_library(rustybits STATIC IMPORTED GLOBAL) +set_property(TARGET rustybits PROPERTY IMPORTED_LOCATION ${RUSTYBITS_LIB}) +add_dependencies(rustybits rustybits_build) + +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack") +# Get & build dependencies not in conda +include (cmake/cpp-httplib.cmake) +include (cmake/redis-plus-plus.cmake) +include (cmake/miniupnpc.cmake) + +add_subdirectory(ext) +add_subdirectory(node) +add_subdirectory(osdep) +add_subdirectory(service) +add_subdirectory(controller) + +set(LINKED_LIBRARIES + prometheus-cpp-lite + zerotier-service + zerotier-osdep + zerotier-core + zerotier-controller + Threads::Threads + nlohmann_json::nlohmann_json + opentelemetry-cpp::api + rustybits + OpenSSL::Crypto + OpenSSL::SSL + Threads::Threads +) + +if(ZT1_CENTRAL_CONTROLLER) + list(APPEND LINKED_LIBRARIES + opentelemetry-cpp::sdk) +endif() + + +add_executable(zerotier-one + one.cpp + ext/http-parser/http_parser.c) + +target_link_libraries(zerotier-one + ${LINKED_LIBRARIES} +) + +add_executable(zerotier-selftest + selftest.cpp +) -target_compile_options(zerotiercore PRIVATE ${ZT_DEFS}) +target_link_libraries(zerotier-selftest + zerotier-core + Threads::Threads + nlohmann_json::nlohmann_json + prometheus-cpp-lite + Threads::Threads) \ No newline at end of file diff --git a/build_central_controller.sh b/build_central_controller.sh new file mode 100755 index 0000000000..5c6665a0cb --- /dev/null +++ b/build_central_controller.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -e + +cmake -DCMAKE_BUILD_TYPE=Release -DZT1_CENTRAL_CONTROLLER=1 -DCMAKE_INSTALL_PREFIX=$PWD -S . -B build/ -DCMAKE_INSTALL_PREFIX=$(shell pwd)/build-out +cmake --build build/ --target all -j4 --verbose + +ARCH=$(uname -m) +if [ "$ARCH" = "x86_64" ]; then + ARCH="amd64" +elif [ "$ARCH" = "aarch64" ]; then + ARCH="arm64" +fi + +if [ -z "$TARGET_DOCKER_REPO" ]; then + TARGET_DOCKER_REPO="us-central1-docker.pkg.dev/zerotier-421eb9/docker-images" +fi + +docker build -platform linux/$ARCH -t $TARGET_DOCKER_REPO/ztcentral-controller:$(git rev-parse --short HEAD)-$ARCH -f ext/central-controller/docker/Dockerfile.central-controller . --load --push \ No newline at end of file diff --git a/cmake/cpp-httplib.cmake b/cmake/cpp-httplib.cmake new file mode 100644 index 0000000000..d1834c4081 --- /dev/null +++ b/cmake/cpp-httplib.cmake @@ -0,0 +1,21 @@ + +set(FETCHCONTENT_QUIET OFF) + +FetchContent_Declare( + cpp-httplib + GIT_REPOSITORY https://github.com/yhirose/cpp-httplib.git + GIT_TAG v0.25.0 + GIT_SHALLOW ON +) +set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "") +set(HTTPLIB_COMPILE OFF CACHE INTERNAL "") +set(HTTPLIB_USE_ZLIB_IF_AVAILABLE ON CACHE INTERNAL "Use zlib if available") +set(HTTPLIB_USE_BROTLI_IF_AVAILABLE ON CACHE INTERNAL "Use brotli if available") +set(HTTPLIB_USE_OPENSSL_IF_AVAILABLE ON CACHE INTERNAL "Use OpenSSL if available") +set(HTTPLIB_USE_ZSTD_IF_AVAILABLE ON CACHE INTERNAL "Use zstd if available") +FetchContent_MakeAvailable(cpp-httplib) + +if (NOT TARGET httplib::httplib) + message(FATAL_ERROR "A required cpp-httplib target (cpp-httplib) was not imported") +endif() + diff --git a/cmake/miniupnpc.cmake b/cmake/miniupnpc.cmake new file mode 100644 index 0000000000..c743721ff4 --- /dev/null +++ b/cmake/miniupnpc.cmake @@ -0,0 +1,30 @@ +set(FETCHCONTENT_QUIET OFF) + +FetchContent_Declare( + miniupnpc + URL https://github.com/miniupnp/miniupnp/releases/download/miniupnpc_2_3_3/miniupnpc-2.3.3.tar.gz + DOWNLOAD_EXTRACT_TIMESTAMP TRUE +) +set(UPNPC_BUILD_TESTS FALSE CACHE INTERNAL "Build tests" FORCE) +set(UPNPC_BUILD_SHARED FALSE CACHE INTERNAL "Build shared library" FORCE) +set(UPNPC_BUILD_STATIC TRUE CACHE INTERNAL "Build static library" FORCE) +set(UPNPC_BUILD_SAMPLE FALSE CACHE INTERNAL "Build sample" FORCE) + +FetchContent_MakeAvailable(miniupnpc) + +if (NOT TARGET miniupnpc::miniupnpc) + message(FATAL_ERROR "A required miniupnpc target (miniupnpc::miniupnpc) was not imported") +endif() +add_definitions(-DZT_USE_MINIUPNPC) + +FetchContent_Declare( + libnatpmp + GIT_REPOSITORY https://github.com/miniupnp/libnatpmp.git + GIT_TAG master + GIT_SHALLOW ON +) +FetchContent_MakeAvailable(libnatpmp) + +if (NOT TARGET natpmp) + message(FATAL_ERROR "A required libnatpmp target (natpmp) was not imported") +endif() diff --git a/cmake/redis-plus-plus.cmake b/cmake/redis-plus-plus.cmake new file mode 100644 index 0000000000..7fa99ea733 --- /dev/null +++ b/cmake/redis-plus-plus.cmake @@ -0,0 +1,19 @@ +set(FETCHCONTENT_QUIET OFF) + +FetchContent_Declare( + redis-plus-plus + GIT_REPOSITORY https://github.com/sewenew/redis-plus-plus.git + GIT_TAG 1.3.15 + GIT_SHALLOW ON +) +set(REDIS_PLUS_PLUS_BUILD_STATIC ON CACHE INTERNAL "Build static library" FORCE) +set(REDIS_PLUS_PLUS_BUILD_SHARED ON CACHE INTERNAL "Build shared library" FORCE) +set(REDIS_PLUS_PLUS_BUILD_TEST OFF CACHE INTERNAL "Build tests" FORCE) +set(REDIS_PLUS_PLUS_BUILD_STATIC_WITH_PIC ON CACHE INTERNAL "Build static library with PIC" FORCE) +set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Build shared libraries" FORCE) + +FetchContent_MakeAvailable(redis-plus-plus) +if(NOT TARGET redis++::redis++_static) + message(FATAL_ERROR "A required redis-plus-plus target (redis++::redis++) was not imported") +endif() +message(STATUS "redis-plus-plus imported") diff --git a/controller/CMakeLists.txt b/controller/CMakeLists.txt new file mode 100644 index 0000000000..482956606b --- /dev/null +++ b/controller/CMakeLists.txt @@ -0,0 +1,75 @@ +cmake_minimum_required(VERSION 3.13) +project(zerotier-controller) + + +set(SRC_FILES + DB.cpp + DB.hpp + DBMirrorSet.cpp + DBMirrorSet.hpp + EmbeddedNetworkController.cpp + EmbeddedNetworkController.hpp + FileDB.cpp + FileDB.hpp + LFDB.cpp + LFDB.hpp + CtlUtil.cpp + CtlUtil.hpp +) + +set(INCLUDE_DIRS + "${httplib_SOURCE_DIR}" + ${RUSTYBITS_INCLUDE_DIR} +) + +set(LINK_LIBS + zerotier-osdep + nlohmann_json::nlohmann_json + opentelemetry-cpp::api + rustybits + Threads::Threads + prometheus-cpp-lite + Threads::Threads +) + +if (ZT1_CENTRAL_CONTROLLER) + find_package(PostgreSQL REQUIRED) + + list(APPEND SRC_FILES + CV1.cpp + CV1.hpp + CV2.cpp + CV2.hpp + CentralDB.cpp + CentralDB.hpp + NotificationListener.hpp + PostgreSQL.cpp + PostgreSQL.hpp + PubSubListener.cpp + PubSubListener.hpp + Redis.hpp + RedisListener.cpp + RedisListener.hpp) + + list(APPEND INCLUDE_DIRS + ${PostgreSQL_INCLUDE_DIRS} + "${redis++_BUILD_DIR}/src" + ${pqxx_INCLUDE_DIRS} + ) + + list(APPEND LINK_LIBS + redis++::redis++_static + pqxx + ${PostgreSQL_LIBRARIES} + ) +endif() + +add_library(zerotier-controller STATIC ${SRC_FILES}) + +target_include_directories(zerotier-controller PRIVATE ${INCLUDE_DIRS}) + +add_dependencies(zerotier-controller redis++::redis++) + +target_link_libraries(zerotier-controller + ${LINK_LIBS} +) diff --git a/controller/CV1.hpp b/controller/CV1.hpp index dc8d36a20a..e65cdb2af3 100644 --- a/controller/CV1.hpp +++ b/controller/CV1.hpp @@ -26,7 +26,7 @@ #include #include -#include +#include namespace rustybits { struct SmeeClient; diff --git a/controller/CV2.hpp b/controller/CV2.hpp index 4aed1f7a31..12c3ed4408 100644 --- a/controller/CV2.hpp +++ b/controller/CV2.hpp @@ -26,7 +26,7 @@ #include #include -#include +#include namespace ZeroTier { diff --git a/controller/CentralDB.hpp b/controller/CentralDB.hpp index ebb0105ecc..156e82e9a8 100644 --- a/controller/CentralDB.hpp +++ b/controller/CentralDB.hpp @@ -13,7 +13,7 @@ #include #include -#include +#include namespace rustybits { struct SmeeClient; diff --git a/controller/EmbeddedNetworkController.hpp b/controller/EmbeddedNetworkController.hpp index 111417bfb9..61fcba839e 100644 --- a/controller/EmbeddedNetworkController.hpp +++ b/controller/EmbeddedNetworkController.hpp @@ -26,7 +26,11 @@ #include "DBMirrorSet.hpp" #include +#ifdef CMAKE_BUILD +#include +#else #include +#endif #include #include #include diff --git a/controller/LFDB.cpp b/controller/LFDB.cpp index 77fa8ffe11..35532a7f58 100644 --- a/controller/LFDB.cpp +++ b/controller/LFDB.cpp @@ -13,7 +13,11 @@ #include "LFDB.hpp" +#ifdef CMAKE_BUILD +#include "httplib.h" +#else #include "../ext/cpp-httplib/httplib.h" +#endif #include "../osdep/OSUtils.hpp" #include diff --git a/controller/README_CENTRAL_CONTROLLER.md b/controller/README_CENTRAL_CONTROLLER.md new file mode 100644 index 0000000000..7d8268c3f1 --- /dev/null +++ b/controller/README_CENTRAL_CONTROLLER.md @@ -0,0 +1,56 @@ +# Central Controller Builds + +NOTE: for ZeroTier, Inc Internal use only. We do not support these builds for external use, nor do we guarantee this will work for anyone but us. + +## Prerequisites + +`cmake` is used for builds and `conda` is used to manage external dependencies. + +First, install `conda`: + +```bash +wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o /tmp/miniconda.sh +bash /tmp/miniconda.sh -b -u -p $HOME/miniconda3 +``` + +Initialize conda: + +```bash +source ~/miniconda3/bin/activate +conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main +conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r +conda config --set channel_priority strict +``` + +Install external dependencies: + +```bash +conda install -y -c conda-forge \ + conda-forge::cmake \ + conda-forge::git \ + conda-forge::cxx-compiler \ + conda-forge::c-compiler \ + conda-forge::make \ + conda-forge::pkg-config \ + conda-forge::libpqxx=7.7.3 \ + conda-forge::libopentelemetry-cpp=1.21.0 \ + conda-forge::libopentelemetry-cpp-headers=1.21.0 \ + conda-forge::google-cloud-cpp=2.39.0 \ + conda-forge::libgoogle-cloud=2.39.0 \ + conda-forge::rust=1.89.0 \ + conda-forge::inja=3.3.0 \ + conda-forge::libhiredis=1.3.0 \ + conda-forge::nlohmann_json=3.12.0 +``` + +## Build the Central Controller Binary + + +```bash +cmake -DCMAKE_BUILD_TYPE=Release -DZT1_CENTRAL_CONTROLLER=1 -DCMAKE_INSTALL_PREFIX=$PWD/out -S . -B build/ -DCMAKE_INSTALL_PREFIX=$(shell pwd)/build-out +cmake --build build/ --target all -j8 --verbose +``` + +## Packaging via Docker + +TODO: write me \ No newline at end of file diff --git a/controller/RedisListener.hpp b/controller/RedisListener.hpp index 2e7e426241..4cc67bd6b9 100644 --- a/controller/RedisListener.hpp +++ b/controller/RedisListener.hpp @@ -8,8 +8,8 @@ #include "Redis.hpp" #include -#include #include +#include #include namespace ZeroTier { diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt new file mode 100644 index 0000000000..650174241c --- /dev/null +++ b/ext/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.13) +project(ext) + +file(GLOB_RECURSE PROM_CORE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/prometheus-cpp-lite-1.0/core/include/*.h ) +set(PROMETHEUS_CPP_LITE_HEADERS ${PROM_CORE_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/prometheus-cpp-lite-1.0/simpleapi/include) + + +add_library(prometheus-cpp-lite INTERFACE) +target_sources(prometheus-cpp-lite INTERFACE ${PROMETHEUS_CPP_LITE_HEADERS}) +target_include_directories(prometheus-cpp-lite INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/prometheus-cpp-lite-1.0/simpleapi/include ${CMAKE_CURRENT_SOURCE_DIR}/prometheus-cpp-lite-1.0/core/include) +add_custom_target(prometheus-cpp-lite-ide SOURCES ${PROMETHEUS_CPP_LITE_HEADERS}) +set(prometheus-cpp-lite_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/prometheus-cpp-lite-1.0/simpleapi/include ${CMAKE_CURRENT_SOURCE_DIR}/prometheus-cpp-lite-1.0/core/include PARENT_SCOPE) diff --git a/ext/central-controller-docker/Dockerfile.run_base2 b/ext/central-controller-docker/Dockerfile.run_base2 new file mode 100644 index 0000000000..c64f04ab67 --- /dev/null +++ b/ext/central-controller-docker/Dockerfile.run_base2 @@ -0,0 +1,23 @@ +FROM continuumio/miniconda3:25.3.1-1 + +LABEL maintainer="ZeroTier Inc." + +RUN conda config --set channel_priority strict && \ + conda install -y -c conda-forge \ + conda-forge::cmake=3.25.1 \ + conda-forge::git \ + conda-forge::cxx-compiler \ + conda-forge::c-compiler \ + conda-forge::make \ + conda-forge::pkg-config \ + conda-forge::libpqxx=7.7.3 \ + conda-forge::libopentelemetry-cpp=1.21.0 \ + conda-forge::libopentelemetry-cpp-headers=1.21.0 \ + conda-forge::google-cloud-cpp=2.39.0 \ + conda-forge::libgoogle-cloud=2.39.0 \ + conda-forge::rust=1.89.0 \ + conda-forge::inja=3.3.0 \ + conda-forge::libhiredis=1.3.0 \ + conda-forge::nlohmann_json=3.12.0 + +# ADD . /src \ No newline at end of file diff --git a/ext/prometheus-cpp-lite-1.0/3rdparty/http-client-lite/CMakeLists.txt b/ext/prometheus-cpp-lite-1.0/3rdparty/http-client-lite/CMakeLists.txt index 177cdb974c..e7412e7f2e 100644 --- a/ext/prometheus-cpp-lite-1.0/3rdparty/http-client-lite/CMakeLists.txt +++ b/ext/prometheus-cpp-lite-1.0/3rdparty/http-client-lite/CMakeLists.txt @@ -5,7 +5,7 @@ # Distributed under the MIT License. # (See accompanying file LICENSE or copy at https://mit-license.org/) -cmake_minimum_required(VERSION 3.3 FATAL_ERROR) +cmake_minimum_required(VERSION 3.13 FATAL_ERROR) project(http-client-lite) ## Set output binary diff --git a/ext/prometheus-cpp-lite-1.0/core/CMakeLists.txt b/ext/prometheus-cpp-lite-1.0/core/CMakeLists.txt index 70c932218f..38ff920ba8 100644 --- a/ext/prometheus-cpp-lite-1.0/core/CMakeLists.txt +++ b/ext/prometheus-cpp-lite-1.0/core/CMakeLists.txt @@ -1,5 +1,5 @@ project(prometheus-cpp-lite-core) -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.13) file(GLOB_RECURSE PROMETHEUS_CPP_LITE_HEADERS *.h) diff --git a/ext/prometheus-cpp-lite-1.0/simpleapi/CMakeLists.txt b/ext/prometheus-cpp-lite-1.0/simpleapi/CMakeLists.txt index 19dc9e1f3a..fce2ef7228 100644 --- a/ext/prometheus-cpp-lite-1.0/simpleapi/CMakeLists.txt +++ b/ext/prometheus-cpp-lite-1.0/simpleapi/CMakeLists.txt @@ -1,5 +1,5 @@ project(prometheus-cpp-simpleapi) -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.13) add_library (${PROJECT_NAME} STATIC "./src/simpleapi.cpp" ) target_sources (${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include/prometheus/simpleapi.h") diff --git a/make-linux.mk b/make-linux.mk index 18a5dc0470..eab6dee5e8 100644 --- a/make-linux.mk +++ b/make-linux.mk @@ -344,7 +344,7 @@ ifeq ($(ZT_CONTROLLER),1) override CXXFLAGS+=-Wall -Wno-deprecated -std=c++17 -pthread $(INCLUDES) -DNDEBUG $(DEFS) override LDLIBS+=-Lext/libpqxx-7.7.3/install/ubuntu22.04/$(EXT_ARCH)/lib -lpqxx -lpq ext/hiredis-1.0.2/lib/ubuntu22.04/$(EXT_ARCH)/libhiredis.a ext/redis-plus-plus-1.3.3/install/ubuntu22.04/$(EXT_ARCH)/lib/libredis++.a -lssl -lcrypto override DEFS+=-DZT_CONTROLLER_USE_LIBPQ -DZT_NO_PEER_METRICS -DZT_OPENTELEMETRY_ENABLED - override INCLUDES+=-I/usr/include/postgresql -Iext/libpqxx-7.7.3/install/ubuntu22.04/$(EXT_ARCH)/include -Iext/hiredis-1.0.2/include/ -Iext/redis-plus-plus-1.3.3/install/ubuntu22.04/$(EXT_ARCH)/include/sw/ + override INCLUDES+=-I/usr/include/postgresql -Iext/libpqxx-7.7.3/install/ubuntu22.04/$(EXT_ARCH)/include -Iext/hiredis-1.0.2/include/ -Iext/redis-plus-plus-1.3.3/install/ubuntu22.04/$(EXT_ARCH)/include override ZT_CARGO_FLAGS+=-F ztcontroller ifeq ($(ZT_DEBUG),1) override LDLIBS+=rustybits/target/debug/librustybits.a diff --git a/node/CMakeLists.txt b/node/CMakeLists.txt new file mode 100644 index 0000000000..b74935e1cd --- /dev/null +++ b/node/CMakeLists.txt @@ -0,0 +1,94 @@ +cmake_minimum_required(VERSION 3.13) +project(zerotier-core LANGUAGES CXX ASM) + + +file (GLOB core_src_glob ${PROJ_DIR}/node/*.cpp) +file (GLOB core_hdr_glob ${PROJ_DIR}/node/*.hpp) + +if(${CPU_ARCHITECTURE} STREQUAL "x86_64") + set(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp -z noexecstack") + set(ASM_SALSA_DIR ${CMAKE_SOURCE_DIR}/ext/x64-salsa2012-asm) + set(ASM_ED25519_DIR ${CMAKE_SOURCE_DIR}/ext/ed25519-amd64-asm) + list(APPEND core_src_glob + ${ASM_SALSA_DIR}/salsa2012.s + #${ASM_ED25519_DIR}/batch.c + ${ASM_ED25519_DIR}/choose_t.s + ${ASM_ED25519_DIR}/consts.s + ${ASM_ED25519_DIR}/fe25519_add.s + ${ASM_ED25519_DIR}/fe25519_freeze.s + ${ASM_ED25519_DIR}/fe25519_getparity.c + ${ASM_ED25519_DIR}/fe25519_invert.c + ${ASM_ED25519_DIR}/fe25519_iseq.c + ${ASM_ED25519_DIR}/fe25519_iszero.c + ${ASM_ED25519_DIR}/fe25519_mul.s + ${ASM_ED25519_DIR}/fe25519_neg.c + ${ASM_ED25519_DIR}/fe25519_pack.c + ${ASM_ED25519_DIR}/fe25519_pow2523.c + ${ASM_ED25519_DIR}/fe25519_setint.c + ${ASM_ED25519_DIR}/fe25519_square.s + ${ASM_ED25519_DIR}/fe25519_sub.s + ${ASM_ED25519_DIR}/fe25519_unpack.c + ${ASM_ED25519_DIR}/ge25519_add_p1p1.s + ${ASM_ED25519_DIR}/ge25519_add.c + ${ASM_ED25519_DIR}/ge25519_base.c + ${ASM_ED25519_DIR}/ge25519_dbl_p1p1.s + ${ASM_ED25519_DIR}/ge25519_double_scalarmult.c + ${ASM_ED25519_DIR}/ge25519_double.c + ${ASM_ED25519_DIR}/ge25519_isneutral.c + ${ASM_ED25519_DIR}/ge25519_multi_scalarmult.c + ${ASM_ED25519_DIR}/ge25519_nielsadd_p1p1.s + ${ASM_ED25519_DIR}/ge25519_nielsadd2.s + ${ASM_ED25519_DIR}/ge25519_p1p1_to_p2.s + ${ASM_ED25519_DIR}/ge25519_p1p1_to_p3.s + ${ASM_ED25519_DIR}/ge25519_pack.c + ${ASM_ED25519_DIR}/ge25519_pnielsadd_p1p1.s + ${ASM_ED25519_DIR}/ge25519_scalarmult_base.c + ${ASM_ED25519_DIR}/ge25519_unpackneg.c + ${ASM_ED25519_DIR}/heap_rootreplaced_1limb.s + ${ASM_ED25519_DIR}/heap_rootreplaced_2limbs.s + ${ASM_ED25519_DIR}/heap_rootreplaced_3limbs.s + ${ASM_ED25519_DIR}/heap_rootreplaced.s + ${ASM_ED25519_DIR}/hram.c + ${ASM_ED25519_DIR}/index_heap.c + #${ASM_ED25519_DIR}/keypair.c + #${ASM_ED25519_DIR}/open.c + ${ASM_ED25519_DIR}/sc25519_add.s + ${ASM_ED25519_DIR}/sc25519_barrett.s + ${ASM_ED25519_DIR}/sc25519_from_shortsc.c + ${ASM_ED25519_DIR}/sc25519_from32bytes.c + ${ASM_ED25519_DIR}/sc25519_from64bytes.c + ${ASM_ED25519_DIR}/sc25519_iszero.c + ${ASM_ED25519_DIR}/sc25519_lt.s + ${ASM_ED25519_DIR}/sc25519_mul_shortsc.c + ${ASM_ED25519_DIR}/sc25519_mul.c + ${ASM_ED25519_DIR}/sc25519_slide.c + ${ASM_ED25519_DIR}/sc25519_sub_nored.s + ${ASM_ED25519_DIR}/sc25519_to32bytes.c + ${ASM_ED25519_DIR}/sc25519_window4.c + ${ASM_ED25519_DIR}/sign.c + ${ASM_ED25519_DIR}/ull4_mul.s + ) + list(APPEND core_hdr_glob + ${ASM_SALSA_DIR}/salsa2012.h + ${ASM_ED25519_DIR}/fe25519.h + ${ASM_ED25519_DIR}/ge25519.h + ${ASM_ED25519_DIR}/hram.h + ${ASM_ED25519_DIR}/index_heap.h + ${ASM_ED25519_DIR}/sc25519.h) + set_property(SOURCE ${ASM_ED25519_DIR}/fe25519_freeze.s PROPERTY COMPILE_FLAGS "-z noexecstack") +elseif(${CPU_ARCHITECTURE} STREQUAL "aarch64") + +endif() + +add_library(zerotier-core STATIC ${core_src_glob} ${core_hdr_glob}) + +target_include_directories(zerotier-core + PRIVATE + ${prometheus-cpp-lite_INCLUDE} +) +target_link_libraries(zerotier-core + PRIVATE + nlohmann_json::nlohmann_json + Threads::Threads + prometheus-cpp-lite + Threads::Threads) diff --git a/osdep/CMakeLists.txt b/osdep/CMakeLists.txt new file mode 100644 index 0000000000..7d476dbf8b --- /dev/null +++ b/osdep/CMakeLists.txt @@ -0,0 +1,59 @@ +cmake_minimum_required(VERSION 3.13) +project(osdep LANGUAGES CXX ASM) + +set(SRC_FILES + Arp.cpp + Arp.hpp + Binder.hpp + BlockingQueue.hpp + EthernetTap.cpp + EthernetTap.hpp + Http.cpp + Http.hpp + ManagedRoute.cpp + ManagedRoute.hpp + NeighborDiscovery.cpp + NeighborDiscovery.hpp + OSUtils.cpp + OSUtils.hpp + Phy.hpp + PortMapper.cpp + PortMapper.hpp + Thread.hpp +) + +option(EXT_OSDEP "Build with external osdep feature" OFF) + +if(EXT_OSDEP) + add_definitions(-DZT_EXTOSDEP) + list(APPEND SRC_FILES + ExtOsdep.cpp + ExtOsdep.hpp) +endif() + +if(LINUX) + list(APPEND SRC_FILES + LinuxEthernetTap.cpp + LinuxEthernetTap.hpp + LinuxNetLink.cpp + LinuxNetLink.hpp) +endif() + +if(MACOS) + list(APPEND SRC_FILES + MacOSEthernetTap.cpp + MacOSEthernetTap.hpp + MacKextEthernetTap.cpp + MacKextEthernetTap.hpp) +endif() + +add_library(zerotier-osdep STATIC ${SRC_FILES}) +target_link_libraries(zerotier-osdep + PRIVATE + nlohmann_json::nlohmann_json + Threads::Threads + prometheus-cpp-lite + Threads::Threads + miniupnpc::miniupnpc + natpmp +) diff --git a/osdep/ExtOsdep.cpp b/osdep/ExtOsdep.cpp index 47543ae4d8..7bd0001e80 100644 --- a/osdep/ExtOsdep.cpp +++ b/osdep/ExtOsdep.cpp @@ -23,6 +23,8 @@ #define ZT_TAP_BUF_SIZE 16384 +#ifdef ZT_EXTOSDEP + namespace ZeroTier { static int eodFd = -1; @@ -626,3 +628,5 @@ void ExtOsdepTap::setMtu(unsigned int mtu) } } // namespace ZeroTier + +#endif // ZT_EXTOSDEP \ No newline at end of file diff --git a/rustybits/Cargo.toml b/rustybits/Cargo.toml index 61888ab36f..6c1cfeb3bd 100644 --- a/rustybits/Cargo.toml +++ b/rustybits/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" crate-type = ["staticlib", "rlib"] [features] -default = ["zeroidc"] +default = ["zeroidc", "ztcontroller"] zeroidc = [] ztcontroller = [ "dep:serde", diff --git a/rustybits/smeeclient/Cargo.lock b/rustybits/smeeclient/Cargo.lock deleted file mode 100644 index a7eafe6f8c..0000000000 --- a/rustybits/smeeclient/Cargo.lock +++ /dev/null @@ -1,2998 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 4 - -[[package]] -name = "addr2line" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler2" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" - -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - -[[package]] -name = "allocator-api2" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" - -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - -[[package]] -name = "anstyle" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" - -[[package]] -name = "anyhow" -version = "1.0.98" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" - -[[package]] -name = "async-trait" -version = "0.1.88" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "atomic-waker" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" - -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - -[[package]] -name = "autocfg" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" - -[[package]] -name = "axum" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "021e862c184ae977658b36c4500f7feac3221ca5da43e3f25bd04ab6c79a29b5" -dependencies = [ - "axum-core", - "bytes", - "futures-util", - "http", - "http-body", - "http-body-util", - "itoa", - "matchit", - "memchr", - "mime", - "percent-encoding", - "pin-project-lite", - "rustversion", - "serde", - "sync_wrapper", - "tower", - "tower-layer", - "tower-service", -] - -[[package]] -name = "axum-core" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68464cd0412f486726fb3373129ef5d2993f90c34bc2bc1c1e9943b2f4fc7ca6" -dependencies = [ - "bytes", - "futures-core", - "http", - "http-body", - "http-body-util", - "mime", - "pin-project-lite", - "rustversion", - "sync_wrapper", - "tower-layer", - "tower-service", -] - -[[package]] -name = "backoff" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62ddb9cb1ec0a098ad4bbf9344d0713fa193ae1a80af55febcff2627b6a00c1" -dependencies = [ - "getrandom 0.2.16", - "instant", - "rand 0.8.5", -] - -[[package]] -name = "backtrace" -version = "0.3.75" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" -dependencies = [ - "addr2line", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", - "windows-targets 0.52.6", -] - -[[package]] -name = "base64" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" - -[[package]] -name = "bumpalo" -version = "3.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" - -[[package]] -name = "bytes" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" - -[[package]] -name = "cbindgen" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e3973b165dc0f435831a9e426de67e894de532754ff7a3f307c03ee5dec7dc" -dependencies = [ - "clap", - "heck 0.3.3", - "indexmap 1.9.3", - "log", - "proc-macro2", - "quote", - "serde", - "serde_json", - "syn 1.0.109", - "tempfile", - "toml", -] - -[[package]] -name = "cc" -version = "1.2.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3a42d84bb6b69d3a8b3eaacf0d88f179e1929695e1ad012b6cf64d9caaa5fd2" -dependencies = [ - "shlex", -] - -[[package]] -name = "cfg-if" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" - -[[package]] -name = "chrono" -version = "0.4.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" -dependencies = [ - "num-traits", - "serde", -] - -[[package]] -name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim 0.8.0", - "textwrap", - "unicode-width", - "vec_map", -] - -[[package]] -name = "core-foundation" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" - -[[package]] -name = "crossbeam-channel" -version = "0.5.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-queue" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" - -[[package]] -name = "darling" -version = "0.20.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.20.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim 0.11.1", - "syn 2.0.104", -] - -[[package]] -name = "darling_macro" -version = "0.20.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" -dependencies = [ - "darling_core", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "dashmap" -version = "6.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" -dependencies = [ - "cfg-if", - "crossbeam-utils", - "hashbrown 0.14.5", - "lock_api", - "once_cell", - "parking_lot_core", -] - -[[package]] -name = "derive_builder" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" -dependencies = [ - "derive_builder_macro", -] - -[[package]] -name = "derive_builder_core" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "derive_builder_macro" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" -dependencies = [ - "derive_builder_core", - "syn 2.0.104", -] - -[[package]] -name = "derive_more" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678" -dependencies = [ - "derive_more-impl", -] - -[[package]] -name = "derive_more-impl" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", - "unicode-xid", -] - -[[package]] -name = "displaydoc" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "downcast" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" - -[[package]] -name = "either" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" - -[[package]] -name = "enum-iterator" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c280b9e6b3ae19e152d8e31cf47f18389781e119d4013a2a2bb0180e5facc635" -dependencies = [ - "enum-iterator-derive", -] - -[[package]] -name = "enum-iterator-derive" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "enum_dispatch" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa18ce2bc66555b3218614519ac839ddb759a7d6720732f979ef8d13be147ecd" -dependencies = [ - "once_cell", - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "equivalent" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" - -[[package]] -name = "erased-serde" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e004d887f51fcb9fef17317a2f3525c887d8aa3f4f50fed920816a688284a5b7" -dependencies = [ - "serde", - "typeid", -] - -[[package]] -name = "errno" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" -dependencies = [ - "libc", - "windows-sys 0.60.2", -] - -[[package]] -name = "fastrand" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" - -[[package]] -name = "fixedbitset" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - -[[package]] -name = "form_urlencoded" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "fragile" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28dd6caf6059519a65843af8fe2a3ae298b14b80179855aeb4adc2c1934ee619" - -[[package]] -name = "futures" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" - -[[package]] -name = "futures-executor" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" - -[[package]] -name = "futures-macro" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "futures-retry" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fde5a672a61f96552aa5ed9fd9c81c3fbdae4be9b1e205d6eaf17c83705adc0f" -dependencies = [ - "futures", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "futures-sink" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" - -[[package]] -name = "futures-task" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" - -[[package]] -name = "futures-timer" -version = "3.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" - -[[package]] -name = "futures-util" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - -[[package]] -name = "gethostname" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc257fdb4038301ce4b9cd1b3b51704509692bb3ff716a410cbd07925d9dae55" -dependencies = [ - "rustix", - "windows-targets 0.52.6", -] - -[[package]] -name = "getrandom" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.11.1+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" -dependencies = [ - "cfg-if", - "js-sys", - "libc", - "r-efi", - "wasi 0.14.2+wasi-0.2.4", - "wasm-bindgen", -] - -[[package]] -name = "gimli" -version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" - -[[package]] -name = "governor" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be93b4ec2e4710b04d9264c0c7350cdd62a8c20e5e4ac732552ebb8f0debe8eb" -dependencies = [ - "cfg-if", - "dashmap", - "futures-sink", - "futures-timer", - "futures-util", - "getrandom 0.3.3", - "no-std-compat", - "nonzero_ext", - "parking_lot", - "portable-atomic", - "quanta", - "rand 0.9.2", - "smallvec", - "spinning_top", - "web-time", -] - -[[package]] -name = "h2" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17da50a276f1e01e0ba6c029e47b7100754904ee8a278f886546e98575380785" -dependencies = [ - "atomic-waker", - "bytes", - "fnv", - "futures-core", - "futures-sink", - "http", - "indexmap 2.10.0", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - -[[package]] -name = "hashbrown" -version = "0.15.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" -dependencies = [ - "allocator-api2", - "equivalent", - "foldhash", -] - -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - -[[package]] -name = "http" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" -dependencies = [ - "bytes", - "http", -] - -[[package]] -name = "http-body-util" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" -dependencies = [ - "bytes", - "futures-core", - "http", - "http-body", - "pin-project-lite", -] - -[[package]] -name = "httparse" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" - -[[package]] -name = "httpdate" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" - -[[package]] -name = "hyper" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "smallvec", - "tokio", - "want", -] - -[[package]] -name = "hyper-timeout" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" -dependencies = [ - "hyper", - "hyper-util", - "pin-project-lite", - "tokio", - "tower-service", -] - -[[package]] -name = "hyper-util" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d9b05277c7e8da2c93a568989bb6207bef0112e8d17df7a6eda4a3cf143bc5e" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "http", - "http-body", - "hyper", - "libc", - "pin-project-lite", - "socket2 0.6.0", - "tokio", - "tower-service", - "tracing", -] - -[[package]] -name = "icu_collections" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47" -dependencies = [ - "displaydoc", - "potential_utf", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_locale_core" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a" -dependencies = [ - "displaydoc", - "litemap", - "tinystr", - "writeable", - "zerovec", -] - -[[package]] -name = "icu_normalizer" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_normalizer_data", - "icu_properties", - "icu_provider", - "smallvec", - "zerovec", -] - -[[package]] -name = "icu_normalizer_data" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3" - -[[package]] -name = "icu_properties" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_locale_core", - "icu_properties_data", - "icu_provider", - "potential_utf", - "zerotrie", - "zerovec", -] - -[[package]] -name = "icu_properties_data" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632" - -[[package]] -name = "icu_provider" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af" -dependencies = [ - "displaydoc", - "icu_locale_core", - "stable_deref_trait", - "tinystr", - "writeable", - "yoke", - "zerofrom", - "zerotrie", - "zerovec", -] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "idna" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" -dependencies = [ - "idna_adapter", - "smallvec", - "utf8_iter", -] - -[[package]] -name = "idna_adapter" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" -dependencies = [ - "icu_normalizer", - "icu_properties", -] - -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] - -[[package]] -name = "indexmap" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" -dependencies = [ - "equivalent", - "hashbrown 0.15.4", -] - -[[package]] -name = "instant" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "inventory" -version = "0.3.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab08d7cd2c5897f2c949e5383ea7c7db03fb19130ffcfbf7eda795137ae3cb83" -dependencies = [ - "rustversion", -] - -[[package]] -name = "io-uring" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d93587f37623a1a17d94ef2bc9ada592f5465fe7732084ab7beefabe5c77c0c4" -dependencies = [ - "bitflags 2.9.1", - "cfg-if", - "libc", -] - -[[package]] -name = "itertools" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" - -[[package]] -name = "js-sys" -version = "0.3.77" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" -dependencies = [ - "once_cell", - "wasm-bindgen", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - -[[package]] -name = "libc" -version = "0.2.174" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" - -[[package]] -name = "linux-raw-sys" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" - -[[package]] -name = "litemap" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" - -[[package]] -name = "lock_api" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" - -[[package]] -name = "lru" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "227748d55f2f0ab4735d87fd623798cb6b664512fe979705f829c9f81c934465" -dependencies = [ - "hashbrown 0.15.4", -] - -[[package]] -name = "matchers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" -dependencies = [ - "regex-automata 0.1.10", -] - -[[package]] -name = "matchit" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" - -[[package]] -name = "memchr" -version = "2.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" - -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - -[[package]] -name = "miniz_oxide" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" -dependencies = [ - "adler2", -] - -[[package]] -name = "mio" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" -dependencies = [ - "libc", - "wasi 0.11.1+wasi-snapshot-preview1", - "windows-sys 0.59.0", -] - -[[package]] -name = "mockall" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39a6bfcc6c8c7eed5ee98b9c3e33adc726054389233e201c95dab2d41a3839d2" -dependencies = [ - "cfg-if", - "downcast", - "fragile", - "mockall_derive", - "predicates", - "predicates-tree", -] - -[[package]] -name = "mockall_derive" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25ca3004c2efe9011bd4e461bd8256445052b9615405b4f7ea43fc8ca5c20898" -dependencies = [ - "cfg-if", - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "multimap" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" - -[[package]] -name = "no-std-compat" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c" - -[[package]] -name = "nonzero_ext" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bf9645c8b145698bb0b18a4637dcacbc421ea49bef2317e4fd8065a387cf21" - -[[package]] -name = "ntapi" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" -dependencies = [ - "winapi", -] - -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - -[[package]] -name = "object" -version = "0.36.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" -dependencies = [ - "memchr", -] - -[[package]] -name = "once_cell" -version = "1.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" - -[[package]] -name = "openssl-probe" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" - -[[package]] -name = "opentelemetry" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf416e4cb72756655126f7dd7bb0af49c674f4c1b9903e80c009e0c37e552e6" -dependencies = [ - "futures-core", - "futures-sink", - "js-sys", - "pin-project-lite", - "thiserror", - "tracing", -] - -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - -[[package]] -name = "parking_lot" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets 0.52.6", -] - -[[package]] -name = "percent-encoding" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" - -[[package]] -name = "petgraph" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" -dependencies = [ - "fixedbitset", - "indexmap 2.10.0", -] - -[[package]] -name = "pid" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7c931ef9756cd5e3fa3d395bfe09df4dfa6f0612c6ca8f6b12927d17ca34e36" -dependencies = [ - "num-traits", -] - -[[package]] -name = "pin-project" -version = "1.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "portable-atomic" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" - -[[package]] -name = "portable-atomic-util" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" -dependencies = [ - "portable-atomic", -] - -[[package]] -name = "potential_utf" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5a7c30837279ca13e7c867e9e40053bc68740f988cb07f7ca6df43cc734b585" -dependencies = [ - "zerovec", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" -dependencies = [ - "zerocopy", -] - -[[package]] -name = "predicates" -version = "3.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5d19ee57562043d37e82899fade9a22ebab7be9cef5026b07fda9cdd4293573" -dependencies = [ - "anstyle", - "predicates-core", -] - -[[package]] -name = "predicates-core" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "727e462b119fe9c93fd0eb1429a5f7647394014cf3c04ab2c0350eeb09095ffa" - -[[package]] -name = "predicates-tree" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72dd2d6d381dfb73a193c7fca536518d7caee39fc8503f74e7dc0be0531b425c" -dependencies = [ - "predicates-core", - "termtree", -] - -[[package]] -name = "prettyplease" -version = "0.2.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff24dfcda44452b9816fff4cd4227e1bb73ff5a2f1bc1105aa92fb8565ce44d2" -dependencies = [ - "proc-macro2", - "syn 2.0.104", -] - -[[package]] -name = "proc-macro2" -version = "1.0.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "prost" -version = "0.13.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.13.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be769465445e8c1474e9c5dac2018218498557af32d9ed057325ec9a41ae81bf" -dependencies = [ - "heck 0.5.0", - "itertools", - "log", - "multimap", - "once_cell", - "petgraph", - "prettyplease", - "prost", - "prost-types", - "regex", - "syn 2.0.104", - "tempfile", -] - -[[package]] -name = "prost-derive" -version = "0.13.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "prost-types" -version = "0.13.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52c2c1bf36ddb1a1c396b3601a3cec27c2462e45f07c386894ec3ccf5332bd16" -dependencies = [ - "prost", -] - -[[package]] -name = "prost-wkt" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497e1e938f0c09ef9cabe1d49437b4016e03e8f82fbbe5d1c62a9b61b9decae1" -dependencies = [ - "chrono", - "inventory", - "prost", - "serde", - "serde_derive", - "serde_json", - "typetag", -] - -[[package]] -name = "prost-wkt-build" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b8bf115b70a7aa5af1fd5d6e9418492e9ccb6e4785e858c938e28d132a884b" -dependencies = [ - "heck 0.5.0", - "prost", - "prost-build", - "prost-types", - "quote", -] - -[[package]] -name = "prost-wkt-types" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cdde6df0a98311c839392ca2f2f0bcecd545f86a62b4e3c6a49c336e970fe5" -dependencies = [ - "chrono", - "prost", - "prost-build", - "prost-types", - "prost-wkt", - "prost-wkt-build", - "regex", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "quanta" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3ab5a9d756f0d97bdc89019bd2e4ea098cf9cde50ee7564dde6b81ccc8f06c7" -dependencies = [ - "crossbeam-utils", - "libc", - "once_cell", - "raw-cpuid", - "wasi 0.11.1+wasi-snapshot-preview1", - "web-sys", - "winapi", -] - -[[package]] -name = "quote" -version = "1.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "r-efi" -version = "5.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - -[[package]] -name = "rand" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" -dependencies = [ - "rand_chacha 0.9.0", - "rand_core 0.9.3", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" -dependencies = [ - "ppv-lite86", - "rand_core 0.9.3", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.16", -] - -[[package]] -name = "rand_core" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" -dependencies = [ - "getrandom 0.3.3", -] - -[[package]] -name = "raw-cpuid" -version = "11.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6df7ab838ed27997ba19a4664507e6f82b41fe6e20be42929332156e5e85146" -dependencies = [ - "bitflags 2.9.1", -] - -[[package]] -name = "redox_syscall" -version = "0.5.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" -dependencies = [ - "bitflags 2.9.1", -] - -[[package]] -name = "regex" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata 0.4.9", - "regex-syntax 0.8.5", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", -] - -[[package]] -name = "regex-automata" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax 0.8.5", -] - -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - -[[package]] -name = "regex-syntax" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" - -[[package]] -name = "ring" -version = "0.17.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" -dependencies = [ - "cc", - "cfg-if", - "getrandom 0.2.16", - "libc", - "untrusted", - "windows-sys 0.52.0", -] - -[[package]] -name = "ringbuf" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe47b720588c8702e34b5979cb3271a8b1842c7cb6f57408efa70c779363488c" -dependencies = [ - "crossbeam-utils", - "portable-atomic", - "portable-atomic-util", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" - -[[package]] -name = "rustfsm" -version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?branch=master#45687c309cfaec0d6e5d6542fdb6942eaae03180" -dependencies = [ - "rustfsm_procmacro", - "rustfsm_trait", -] - -[[package]] -name = "rustfsm_procmacro" -version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?branch=master#45687c309cfaec0d6e5d6542fdb6942eaae03180" -dependencies = [ - "derive_more", - "proc-macro2", - "quote", - "rustfsm_trait", - "syn 2.0.104", -] - -[[package]] -name = "rustfsm_trait" -version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?branch=master#45687c309cfaec0d6e5d6542fdb6942eaae03180" - -[[package]] -name = "rustix" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8" -dependencies = [ - "bitflags 2.9.1", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.60.2", -] - -[[package]] -name = "rustls" -version = "0.23.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ebcbd2f03de0fc1122ad9bb24b127a5a6cd51d72604a3f3c50ac459762b6cc" -dependencies = [ - "log", - "once_cell", - "ring", - "rustls-pki-types", - "rustls-webpki", - "subtle", - "zeroize", -] - -[[package]] -name = "rustls-native-certs" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" -dependencies = [ - "openssl-probe", - "rustls-pki-types", - "schannel", - "security-framework", -] - -[[package]] -name = "rustls-pki-types" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" -dependencies = [ - "zeroize", -] - -[[package]] -name = "rustls-webpki" -version = "0.103.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a17884ae0c1b773f1ccd2bd4a8c72f16da897310a98b0e84bf349ad5ead92fc" -dependencies = [ - "ring", - "rustls-pki-types", - "untrusted", -] - -[[package]] -name = "rustversion" -version = "1.0.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" - -[[package]] -name = "ryu" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" - -[[package]] -name = "schannel" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" -dependencies = [ - "windows-sys 0.59.0", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "security-framework" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316" -dependencies = [ - "bitflags 2.9.1", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "serde" -version = "1.0.219" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.219" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "serde_json" -version = "1.0.142" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" -dependencies = [ - "itoa", - "memchr", - "ryu", - "serde", -] - -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - -[[package]] -name = "signal-hook-registry" -version = "1.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" -dependencies = [ - "libc", -] - -[[package]] -name = "siphasher" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" - -[[package]] -name = "slab" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" - -[[package]] -name = "slotmap" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbff4acf519f630b3a3ddcfaea6c06b42174d9a44bc70c620e9ed1649d58b82a" -dependencies = [ - "version_check", -] - -[[package]] -name = "smallvec" -version = "1.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" - -[[package]] -name = "smeeclient" -version = "0.1.0" -dependencies = [ - "cbindgen", - "serde", - "temporal-client", - "temporal-sdk", - "temporal-sdk-core-protos", - "tokio", - "url", - "uuid", -] - -[[package]] -name = "socket2" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "socket2" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807" -dependencies = [ - "libc", - "windows-sys 0.59.0", -] - -[[package]] -name = "spinning_top" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96d2d1d716fb500937168cc09353ffdc7a012be8475ac7308e1bdf0e3923300" -dependencies = [ - "lock_api", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - -[[package]] -name = "strsim" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" - -[[package]] -name = "subtle" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.104" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "sync_wrapper" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" - -[[package]] -name = "synstructure" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "sysinfo" -version = "0.33.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fc858248ea01b66f19d8e8a6d55f41deaf91e9d495246fd01368d99935c6c01" -dependencies = [ - "core-foundation-sys", - "libc", - "memchr", - "ntapi", - "windows", -] - -[[package]] -name = "tempfile" -version = "3.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" -dependencies = [ - "fastrand", - "getrandom 0.3.3", - "once_cell", - "rustix", - "windows-sys 0.59.0", -] - -[[package]] -name = "temporal-client" -version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?branch=master#45687c309cfaec0d6e5d6542fdb6942eaae03180" -dependencies = [ - "anyhow", - "async-trait", - "backoff", - "base64", - "bytes", - "derive_builder", - "derive_more", - "futures-retry", - "futures-util", - "http", - "http-body-util", - "hyper", - "hyper-util", - "opentelemetry", - "parking_lot", - "slotmap", - "temporal-sdk-core-api", - "temporal-sdk-core-protos", - "thiserror", - "tokio", - "tonic", - "tower", - "tracing", - "url", - "uuid", -] - -[[package]] -name = "temporal-sdk" -version = "0.1.0-alpha.1" -source = "git+https://github.com/temporalio/sdk-core?branch=master#45687c309cfaec0d6e5d6542fdb6942eaae03180" -dependencies = [ - "anyhow", - "async-trait", - "derive_more", - "futures-util", - "parking_lot", - "prost-wkt-types", - "serde", - "temporal-client", - "temporal-sdk-core", - "temporal-sdk-core-api", - "temporal-sdk-core-protos", - "tokio", - "tokio-stream", - "tokio-util", - "tracing", -] - -[[package]] -name = "temporal-sdk-core" -version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?branch=master#45687c309cfaec0d6e5d6542fdb6942eaae03180" -dependencies = [ - "anyhow", - "async-trait", - "crossbeam-channel", - "crossbeam-queue", - "crossbeam-utils", - "dashmap", - "derive_builder", - "derive_more", - "enum-iterator", - "enum_dispatch", - "futures-channel", - "futures-util", - "gethostname", - "governor", - "itertools", - "lru", - "mockall", - "parking_lot", - "pid", - "pin-project", - "prost", - "prost-wkt-types", - "rand 0.9.2", - "ringbuf", - "rustfsm", - "serde", - "serde_json", - "siphasher", - "slotmap", - "sysinfo", - "temporal-client", - "temporal-sdk-core-api", - "temporal-sdk-core-protos", - "thiserror", - "tokio", - "tokio-stream", - "tokio-util", - "tonic", - "tracing", - "tracing-subscriber", - "url", - "uuid", -] - -[[package]] -name = "temporal-sdk-core-api" -version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?branch=master#45687c309cfaec0d6e5d6542fdb6942eaae03180" -dependencies = [ - "async-trait", - "derive_builder", - "derive_more", - "opentelemetry", - "prost", - "serde_json", - "temporal-sdk-core-protos", - "thiserror", - "tonic", - "tracing", - "tracing-core", - "url", -] - -[[package]] -name = "temporal-sdk-core-protos" -version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?branch=master#45687c309cfaec0d6e5d6542fdb6942eaae03180" -dependencies = [ - "anyhow", - "base64", - "derive_more", - "prost", - "prost-build", - "prost-wkt", - "prost-wkt-build", - "prost-wkt-types", - "rand 0.9.2", - "serde", - "serde_json", - "thiserror", - "tonic", - "tonic-build", - "uuid", -] - -[[package]] -name = "termtree" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - -[[package]] -name = "thiserror" -version = "2.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "2.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "thread_local" -version = "1.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "tinystr" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b" -dependencies = [ - "displaydoc", - "zerovec", -] - -[[package]] -name = "tokio" -version = "1.47.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038" -dependencies = [ - "backtrace", - "bytes", - "io-uring", - "libc", - "mio", - "parking_lot", - "pin-project-lite", - "signal-hook-registry", - "slab", - "socket2 0.6.0", - "tokio-macros", - "windows-sys 0.59.0", -] - -[[package]] -name = "tokio-macros" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "tokio-rustls" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" -dependencies = [ - "rustls", - "tokio", -] - -[[package]] -name = "tokio-stream" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.7.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - -[[package]] -name = "tonic" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e581ba15a835f4d9ea06c55ab1bd4dce26fc53752c69a04aac00703bfb49ba9" -dependencies = [ - "async-trait", - "axum", - "base64", - "bytes", - "h2", - "http", - "http-body", - "http-body-util", - "hyper", - "hyper-timeout", - "hyper-util", - "percent-encoding", - "pin-project", - "prost", - "rustls-native-certs", - "socket2 0.5.10", - "tokio", - "tokio-rustls", - "tokio-stream", - "tower", - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "tonic-build" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac6f67be712d12f0b41328db3137e0d0757645d8904b4cb7d51cd9c2279e847" -dependencies = [ - "prettyplease", - "proc-macro2", - "prost-build", - "prost-types", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "tower" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" -dependencies = [ - "futures-core", - "futures-util", - "indexmap 2.10.0", - "pin-project-lite", - "slab", - "sync_wrapper", - "tokio", - "tokio-util", - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "tower-layer" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" - -[[package]] -name = "tower-service" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" - -[[package]] -name = "tracing" -version = "0.1.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" -dependencies = [ - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "tracing-core" -version = "0.1.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" -dependencies = [ - "once_cell", - "valuable", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" -dependencies = [ - "matchers", - "nu-ansi-term", - "once_cell", - "parking_lot", - "regex", - "sharded-slab", - "thread_local", - "tracing", - "tracing-core", -] - -[[package]] -name = "try-lock" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" - -[[package]] -name = "typeid" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" - -[[package]] -name = "typetag" -version = "0.2.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f22b40dd7bfe8c14230cf9702081366421890435b2d625fa92b4acc4c3de6f" -dependencies = [ - "erased-serde", - "inventory", - "once_cell", - "serde", - "typetag-impl", -] - -[[package]] -name = "typetag-impl" -version = "0.2.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35f5380909ffc31b4de4f4bdf96b877175a016aa2ca98cee39fcfd8c4d53d952" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "unicode-ident" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" - -[[package]] -name = "unicode-segmentation" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" - -[[package]] -name = "unicode-width" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" - -[[package]] -name = "unicode-xid" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" - -[[package]] -name = "untrusted" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" - -[[package]] -name = "url" -version = "2.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - -[[package]] -name = "utf8_iter" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" - -[[package]] -name = "uuid" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d" -dependencies = [ - "getrandom 0.3.3", - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "valuable" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" - -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.11.1+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" - -[[package]] -name = "wasi" -version = "0.14.2+wasi-0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" -dependencies = [ - "wit-bindgen-rt", -] - -[[package]] -name = "wasm-bindgen" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" -dependencies = [ - "cfg-if", - "once_cell", - "rustversion", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" -dependencies = [ - "bumpalo", - "log", - "proc-macro2", - "quote", - "syn 2.0.104", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "web-sys" -version = "0.3.77" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "web-time" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows" -version = "0.57.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143" -dependencies = [ - "windows-core", - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-core" -version = "0.57.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d" -dependencies = [ - "windows-implement", - "windows-interface", - "windows-result", - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-implement" -version = "0.57.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "windows-interface" -version = "0.57.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "windows-link" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" - -[[package]] -name = "windows-result" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" -dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-sys" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" -dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-sys" -version = "0.60.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" -dependencies = [ - "windows-targets 0.53.3", -] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm 0.52.6", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", -] - -[[package]] -name = "windows-targets" -version = "0.53.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" -dependencies = [ - "windows-link", - "windows_aarch64_gnullvm 0.53.0", - "windows_aarch64_msvc 0.53.0", - "windows_i686_gnu 0.53.0", - "windows_i686_gnullvm 0.53.0", - "windows_i686_msvc 0.53.0", - "windows_x86_64_gnu 0.53.0", - "windows_x86_64_gnullvm 0.53.0", - "windows_x86_64_msvc 0.53.0", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnu" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_i686_msvc" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.53.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" - -[[package]] -name = "wit-bindgen-rt" -version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" -dependencies = [ - "bitflags 2.9.1", -] - -[[package]] -name = "writeable" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" - -[[package]] -name = "yoke" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc" -dependencies = [ - "serde", - "stable_deref_trait", - "yoke-derive", - "zerofrom", -] - -[[package]] -name = "yoke-derive" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", - "synstructure", -] - -[[package]] -name = "zerocopy" -version = "0.8.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "zerofrom" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" -dependencies = [ - "zerofrom-derive", -] - -[[package]] -name = "zerofrom-derive" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", - "synstructure", -] - -[[package]] -name = "zeroize" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" - -[[package]] -name = "zerotrie" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595" -dependencies = [ - "displaydoc", - "yoke", - "zerofrom", -] - -[[package]] -name = "zerovec" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdbb9122ea75b11bf96e7492afb723e8a7fbe12c67417aa95e7e3d18144d37cd" -dependencies = [ - "yoke", - "zerofrom", - "zerovec-derive", -] - -[[package]] -name = "zerovec-derive" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] diff --git a/service/CMakeLists.txt b/service/CMakeLists.txt new file mode 100644 index 0000000000..da38d9a4c0 --- /dev/null +++ b/service/CMakeLists.txt @@ -0,0 +1,50 @@ +cmake_minimum_required(VERSION 3.13) +project(service) + +file(GLOB service_src_glob ${PROJ_DIR}/service/*.cpp) +file(GLOB service_hdr_glob ${PROJ_DIR}/service/*.hpp) + +add_library(zerotier-service STATIC ${service_src_glob} ${service_hdr_glob}) + +set(INCLUDE_DIRS + "${httplib_SOURCE_DIR}" + ${RUSTYBITS_INCLUDE_DIR} +) + +find_package(OpenSSL REQUIRED) + +set(LINK_LIBS + zerotier-osdep + zerotier-core + prometheus-cpp-lite + nlohmann_json::nlohmann_json + Threads::Threads + opentelemetry-cpp::api + Threads::Threads + OpenSSL::Crypto + OpenSSL::SSL + rustybits +) + +if(ZT1_CENTRAL_CONTROLLER) + add_definitions(-DZT_CONTROLLER_USE_LIBPQ) + list(APPEND INCLUDE_DIRS + ${PostgreSQL_INCLUDE_DIRS} + "${redis++_BUILD_DIR}/src" + ${pqxx_INCLUDE_DIRS} + ) + list(APPEND LINK_LIBS + pqxx + opentelemetry-cpp::sdk + ) +endif() + +target_include_directories(zerotier-service + PRIVATE + ${INCLUDE_DIRS} +) + + +target_link_libraries(zerotier-service + ${LINK_LIBS} +) diff --git a/service/OneService.cpp b/service/OneService.cpp index 906b8a9396..a535a48957 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -57,7 +57,11 @@ #include "OneService.hpp" #include "SoftwareUpdater.hpp" +#ifdef CMAKE_BUILD +#include +#else #include +#endif #ifdef ZT_OPENTELEMETRY_ENABLED #include "opentelemetry/exporters/memory/in_memory_data.h" @@ -139,8 +143,10 @@ extern "C" { using json = nlohmann::json; #include "../controller/EmbeddedNetworkController.hpp" +#ifdef ZT_CONTROLLER_USE_LIBPQ #include "../controller/PostgreSQL.hpp" #include "../controller/Redis.hpp" +#endif #include "../osdep/EthernetTap.hpp" #ifdef __WINDOWS__ #include "../osdep/WindowsEthernetTap.hpp" @@ -2851,13 +2857,14 @@ class OneServiceImpl : public OneService { std::string linkSelectMethodStr; if (customPolicy.contains("linkSelectMethod")) { linkSelectMethodStr = OSUtils::jsonString(customPolicy["linkSelectMethod"], "always"); - } else { + } + else { linkSelectMethodStr = OSUtils::jsonString(customPolicy["activeReselect"], "always"); if (customPolicy.contains("activeReselect")) { fprintf(stderr, "warning: 'activeReselect' is deprecated, please use 'linkSelectMethod' instead in policy '%s'\n", customPolicyStr.c_str()); } } - + if (linkSelectMethodStr == "always") { newTemplateBond->setLinkSelectMethod(ZT_BOND_RESELECTION_POLICY_ALWAYS); } From 9bdd564bdca15e0a191de056e60170bcb729bdad Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 27 Aug 2025 16:23:55 -0700 Subject: [PATCH 025/245] spacing --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ddd8a738db..ee7563dc43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,6 +81,7 @@ set_property(TARGET rustybits PROPERTY IMPORTED_LOCATION ${RUSTYBITS_LIB}) add_dependencies(rustybits rustybits_build) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack") + # Get & build dependencies not in conda include (cmake/cpp-httplib.cmake) include (cmake/redis-plus-plus.cmake) From 3187c2ffcedc7d2f2f874dd5c0f477898849c6bf Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 28 Aug 2025 17:00:06 -0700 Subject: [PATCH 026/245] clang format change (not applied project-wide yet) --- .clang-format | 93 +++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/.clang-format b/.clang-format index 400349f157..96477b5f77 100644 --- a/.clang-format +++ b/.clang-format @@ -4,72 +4,71 @@ BreakBeforeBraces: Stroustrup IndentWidth: 4 TabWidth: 4 AlignAfterOpenBracket: AlwaysBreak -AlignConsecutiveMacros: 'true' -AlignConsecutiveAssignments: 'false' -AlignConsecutiveDeclarations: 'false' +AlignConsecutiveMacros: "true" +AlignConsecutiveAssignments: "false" +AlignConsecutiveDeclarations: "false" AlignEscapedNewlines: Right -AlignOperands: 'true' -AlignTrailingComments: 'true' -AllowAllArgumentsOnNextLine: 'false' -AllowAllConstructorInitializersOnNextLine: 'false' -AllowAllParametersOfDeclarationOnNextLine: 'false' -AllowShortBlocksOnASingleLine: 'true' -AllowShortCaseLabelsOnASingleLine: 'false' +AlignOperands: "true" +AlignTrailingComments: "true" +AllowAllArgumentsOnNextLine: "false" +AllowAllConstructorInitializersOnNextLine: "false" +AllowAllParametersOfDeclarationOnNextLine: "false" +AllowShortBlocksOnASingleLine: "true" +AllowShortCaseLabelsOnASingleLine: "false" AllowShortFunctionsOnASingleLine: None AllowShortIfStatementsOnASingleLine: Never AlwaysBreakAfterReturnType: None -BinPackArguments: 'false' -BinPackParameters: 'false' +BinPackArguments: "true" +BinPackParameters: OnePerLine BreakBeforeBinaryOperators: NonAssignment -BreakBeforeTernaryOperators: 'true' +BreakBeforeTernaryOperators: "true" BreakConstructorInitializers: BeforeComma BreakInheritanceList: BeforeComma -CompactNamespaces: 'false' -ConstructorInitializerAllOnOneLineOrOnePerLine: 'true' -ConstructorInitializerIndentWidth: '4' -ContinuationIndentWidth: '4' -Cpp11BracedListStyle: 'false' -FixNamespaceComments: 'true' +CompactNamespaces: "false" +ConstructorInitializerAllOnOneLineOrOnePerLine: "true" +ConstructorInitializerIndentWidth: "4" +ContinuationIndentWidth: "4" +Cpp11BracedListStyle: "false" +FixNamespaceComments: "true" IncludeBlocks: Regroup -IndentCaseLabels: 'true' +IndentCaseLabels: "true" IndentPPDirectives: None -IndentWrappedFunctionNames: 'false' -KeepEmptyLinesAtTheStartOfBlocks: 'false' -MaxEmptyLinesToKeep: '1' +IndentWrappedFunctionNames: "false" +KeepEmptyLinesAtTheStartOfBlocks: "false" +MaxEmptyLinesToKeep: "1" NamespaceIndentation: None PointerAlignment: Left -ReflowComments: 'true' -SortIncludes: 'true' -SortUsingDeclarations: 'true' -SpaceAfterCStyleCast: 'false' -SpaceAfterLogicalNot: 'true' -SpaceAfterTemplateKeyword: 'true' -SpaceBeforeAssignmentOperators: 'true' -SpaceBeforeCpp11BracedList: 'true' -SpaceBeforeCtorInitializerColon: 'true' -SpaceBeforeInheritanceColon: 'true' +ReflowComments: "true" +SortIncludes: "true" +SortUsingDeclarations: "true" +SpaceAfterCStyleCast: "false" +SpaceAfterLogicalNot: "true" +SpaceAfterTemplateKeyword: "true" +SpaceBeforeAssignmentOperators: "true" +SpaceBeforeCpp11BracedList: "true" +SpaceBeforeCtorInitializerColon: "true" +SpaceBeforeInheritanceColon: "true" SpaceBeforeParens: ControlStatements -SpaceBeforeRangeBasedForLoopColon: 'true' -SpaceInEmptyParentheses: 'false' -SpacesBeforeTrailingComments: '3' -SpacesInAngles: 'false' -SpacesInCStyleCastParentheses: 'false' -SpacesInContainerLiterals: 'true' -SpacesInParentheses: 'false' -SpacesInSquareBrackets: 'false' -UseTab: 'Always' +SpaceBeforeRangeBasedForLoopColon: "true" +SpaceInEmptyParentheses: "false" +SpacesBeforeTrailingComments: "3" +SpacesInAngles: "false" +SpacesInCStyleCastParentheses: "false" +SpacesInContainerLiterals: "true" +SpacesInParentheses: "false" +SpacesInSquareBrackets: "false" +UseTab: "Always" --- Language: Cpp Standard: Cpp03 -ColumnLimit: '240' +ColumnLimit: "120" --- Language: ObjC -ColumnLimit: '240' +ColumnLimit: "120" --- Language: Java -ColumnLimit: '240' +ColumnLimit: "120" --- Language: CSharp -ColumnLimit: '240' -... +ColumnLimit: "120" From 85f23356a3f782b556b4cb7d244a84424bd7d323 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 28 Aug 2025 17:03:59 -0700 Subject: [PATCH 027/245] add a StatusWriter class hierarchy for writing member status updates * Postgres Direct * Redis * BigTable --- controller/BigTableStatusWriter.cpp | 98 ++++++++++++++++++++++ controller/BigTableStatusWriter.hpp | 37 +++++++++ controller/CMakeLists.txt | 14 +++- controller/PostgresStatusWriter.cpp | 99 ++++++++++++++++++++++ controller/PostgresStatusWriter.hpp | 39 +++++++++ controller/RedisStatusWriter.cpp | 122 ++++++++++++++++++++++++++++ controller/RedisStatusWriter.hpp | 46 +++++++++++ controller/StatusWriter.cpp | 1 + controller/StatusWriter.hpp | 43 ++++++++++ 9 files changed, 498 insertions(+), 1 deletion(-) create mode 100644 controller/BigTableStatusWriter.cpp create mode 100644 controller/BigTableStatusWriter.hpp create mode 100644 controller/PostgresStatusWriter.cpp create mode 100644 controller/PostgresStatusWriter.hpp create mode 100644 controller/RedisStatusWriter.cpp create mode 100644 controller/RedisStatusWriter.hpp create mode 100644 controller/StatusWriter.cpp create mode 100644 controller/StatusWriter.hpp diff --git a/controller/BigTableStatusWriter.cpp b/controller/BigTableStatusWriter.cpp new file mode 100644 index 0000000000..4406b28844 --- /dev/null +++ b/controller/BigTableStatusWriter.cpp @@ -0,0 +1,98 @@ +#include "BigTableStatusWriter.hpp" + +#include +#include +#include + +namespace cbt = google::cloud::bigtable; + +namespace ZeroTier { + +const std::string nodeInfoColumnFamily = "node_info"; +const std::string checkInColumnFamily = "check_in"; + +const std::string osColumn = "os"; +const std::string archColumn = "arch"; +const std::string versionColumn = "version"; +const std::string ipv4Column = "ipv4"; +const std::string ipv6Column = "ipv6"; +const std::string lastSeenColumn = "last_seen"; + +BigTableStatusWriter::BigTableStatusWriter( + const std::string& project_id, + const std::string& instance_id, + const std::string& table_id) + : _project_id(project_id) + , _instance_id(instance_id) + , _table_id(table_id) +{ +} + +BigTableStatusWriter::~BigTableStatusWriter() +{ + writePending(); +} + +void BigTableStatusWriter::updateNodeStatus( + const std::string& network_id, + const std::string& node_id, + const std::string& os, + const std::string& arch, + const std::string& version, + const InetAddress& address, + int64_t last_seen) +{ + std::lock_guard l(_lock); + _pending.push_back({ network_id, node_id, os, arch, version, address, last_seen }); + if (_pending.size() >= 100) { + writePending(); + } +} + +size_t BigTableStatusWriter::queueLength() const +{ + std::lock_guard l(_lock); + return _pending.size(); +} + +void BigTableStatusWriter::writePending() +{ + std::vector toWrite; + { + std::lock_guard l(_lock); + toWrite.swap(_pending); + } + if (toWrite.empty()) { + return; + } + + namespace cbt = google::cloud::bigtable; + cbt::Table table(cbt::MakeDataConnection(), cbt::TableResource(_project_id, _instance_id, _table_id)); + + cbt::BulkMutation bulk; + for (const auto& entry : toWrite) { + std::string row_key = entry.network_id + "#" + entry.node_id; + cbt::SingleRowMutation m(row_key); + m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, osColumn, entry.os)); + m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, archColumn, entry.arch)); + m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, versionColumn, entry.version)); + char buf[64] = { 0 }; + if (entry.address.ss_family == AF_INET) { + m.emplace_back(cbt::SetCell(checkInColumnFamily, ipv4Column, entry.address.toString(buf))); + } + else if (entry.address.ss_family == AF_INET6) { + m.emplace_back(cbt::SetCell(checkInColumnFamily, ipv6Column, entry.address.toString(buf))); + } + int64_t ts = entry.last_seen; + m.emplace_back(cbt::SetCell(checkInColumnFamily, lastSeenColumn, std::move(ts))); + bulk.push_back(std::move(m)); + } + + std::vector failures = table.BulkApply(bulk); + for (auto const& r : failures) { + // Handle error (log it, retry, etc.) + std::cerr << "Error writing to BigTable: " << r.status() << "\n"; + } +} + +} // namespace ZeroTier \ No newline at end of file diff --git a/controller/BigTableStatusWriter.hpp b/controller/BigTableStatusWriter.hpp new file mode 100644 index 0000000000..85c1e0b4d8 --- /dev/null +++ b/controller/BigTableStatusWriter.hpp @@ -0,0 +1,37 @@ +#ifndef BIGTABLESTATUSWRITER_HPP +#define BIGTABLESTATUSWRITER_HPP + +#include "StatusWriter.hpp" + +#include +#include + +namespace ZeroTier { +class BigTableStatusWriter : public StatusWriter { + public: + BigTableStatusWriter(const std::string& project_id, const std::string& instance_id, const std::string& table_id); + virtual ~BigTableStatusWriter(); + + virtual void updateNodeStatus( + const std::string& network_id, + const std::string& node_id, + const std::string& os, + const std::string& arch, + const std::string& version, + const InetAddress& address, + int64_t last_seen) override; + virtual size_t queueLength() const override; + virtual void writePending() override; + + private: + const std::string _project_id; + const std::string _instance_id; + const std::string _table_id; + + mutable std::mutex _lock; + std::vector _pending; +}; + +} // namespace ZeroTier + +#endif \ No newline at end of file diff --git a/controller/CMakeLists.txt b/controller/CMakeLists.txt index 482956606b..ea11b39524 100644 --- a/controller/CMakeLists.txt +++ b/controller/CMakeLists.txt @@ -49,18 +49,30 @@ if (ZT1_CENTRAL_CONTROLLER) PubSubListener.hpp Redis.hpp RedisListener.cpp - RedisListener.hpp) + RedisListener.hpp + StatusWriter.cpp + StatusWriter.hpp + BigTableStatusWriter.cpp + BigTableStatusWriter.hpp + PostgresStatusWriter.cpp + PostgresStatusWriter.hpp + RedisStatusWriter.cpp + RedisStatusWriter.hpp + ) list(APPEND INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIRS} "${redis++_BUILD_DIR}/src" ${pqxx_INCLUDE_DIRS} + ) list(APPEND LINK_LIBS redis++::redis++_static pqxx ${PostgreSQL_LIBRARIES} + google-cloud-cpp::bigtable + google-cloud-cpp::pubsub ) endif() diff --git a/controller/PostgresStatusWriter.cpp b/controller/PostgresStatusWriter.cpp new file mode 100644 index 0000000000..3e59028452 --- /dev/null +++ b/controller/PostgresStatusWriter.cpp @@ -0,0 +1,99 @@ +#include "PostgresStatusWriter.hpp" + +#include "../node/Metrics.hpp" + +#include +#include + +namespace ZeroTier { + +PostgresStatusWriter::PostgresStatusWriter(std::shared_ptr > pool) : _pool(pool) +{ +} + +PostgresStatusWriter::~PostgresStatusWriter() +{ + writePending(); +} + +void PostgresStatusWriter::updateNodeStatus( + const std::string& network_id, + const std::string& node_id, + const std::string& os, + const std::string& arch, + const std::string& version, + const InetAddress& address, + int64_t last_seen) +{ + std::lock_guard l(_lock); + _pending.push_back({ network_id, node_id, os, arch, version, address, last_seen }); +} + +size_t PostgresStatusWriter::queueLength() const +{ + std::lock_guard l(_lock); + return _pending.size(); +} + +void PostgresStatusWriter::writePending() +{ + std::vector toWrite; + { + std::lock_guard l(_lock); + toWrite.swap(_pending); + } + if (toWrite.empty()) { + return; + } + + try { + auto conn = _pool->borrow(); + pqxx::work w(*conn->c); + + pqxx::pipeline pipe(w); + for (const auto& entry : toWrite) { + char iptmp[64] = { 0 }; + nlohmann::json record = { + { entry.address.toIpString(iptmp), entry.last_seen }, + }; + + try { + // check if the member exists first. + // + // exec_params1 will throw pqxx::unexpected_rows if not exactly one row is returned. If that's the + // case, skip this record and move on. + w.exec_params1( + "SELECT device_id, network_id FROM network_memberships_ctl WHERE network_id = $1 AND device_id = " + "$2", + entry.network_id, entry.node_id); + } + catch (pqxx::unexpected_rows& e) { + continue; + } + + std::string insert_statement = + "INSERT INTO network_memberships_ctl (device_id, network_id, last_seen, os, arch) " + "VALUES ('" + + w.esc(entry.node_id) + "', '" + w.esc(entry.network_id) + "', '" + w.esc(record.dump()) + + "'::JSONB, " + "'" + + w.esc(entry.os) + "', '" + w.esc(entry.arch) + + "') " + "ON CONFLICT (device_id, network_id) DO UPDATE SET os = EXCLUDED.os, arch = EXCLUDED.arch, " + "last_seen = network_memberships_ctl.last_seen || EXCLUDED.last_seen"; + + pipe.insert(insert_statement); + Metrics::pgsql_node_checkin++; + } + + pipe.complete(); + w.commit(); + _pool->unborrow(conn); + } + catch (const std::exception& e) { + // Log the error + fprintf(stderr, "Error writing to Postgres: %s\n", e.what()); + } +} + +} // namespace ZeroTier \ No newline at end of file diff --git a/controller/PostgresStatusWriter.hpp b/controller/PostgresStatusWriter.hpp new file mode 100644 index 0000000000..375fcf5f71 --- /dev/null +++ b/controller/PostgresStatusWriter.hpp @@ -0,0 +1,39 @@ +#ifndef POSTGRES_STATUS_WRITER_HPP +#define POSTGRES_STATUS_WRITER_HPP + +#include "PostgreSQL.hpp" +#include "StatusWriter.hpp" + +#include +#include +#include +#include + +namespace ZeroTier { + +class PostgresStatusWriter : public StatusWriter { + public: + PostgresStatusWriter(std::shared_ptr > pool); + virtual ~PostgresStatusWriter(); + + virtual void updateNodeStatus( + const std::string& network_id, + const std::string& node_id, + const std::string& os, + const std::string& arch, + const std::string& version, + const InetAddress& address, + int64_t last_seen) override; + virtual size_t queueLength() const override; + virtual void writePending() override; + + private: + std::shared_ptr > _pool; + + mutable std::mutex _lock; + std::vector _pending; +}; + +} // namespace ZeroTier + +#endif // POSTGRES_STATUS_WRITER_HPP \ No newline at end of file diff --git a/controller/RedisStatusWriter.cpp b/controller/RedisStatusWriter.cpp new file mode 100644 index 0000000000..c222d26a23 --- /dev/null +++ b/controller/RedisStatusWriter.cpp @@ -0,0 +1,122 @@ +#include "RedisStatusWriter.hpp" + +#include "../node/Metrics.hpp" +#include "../osdep/OSUtils.hpp" + +#include +#include + +namespace ZeroTier { + +RedisStatusWriter::RedisStatusWriter(std::shared_ptr redis, std::string controller_id) + : _redis(redis) + , _mode(REDIS_MODE_STANDALONE) +{ +} + +RedisStatusWriter::RedisStatusWriter(std::shared_ptr cluster, std::string controller_id) + : _cluster(cluster) + , _mode(REDIS_MODE_CLUSTER) +{ +} + +RedisStatusWriter::~RedisStatusWriter() +{ + writePending(); +} + +void RedisStatusWriter::updateNodeStatus( + const std::string& network_id, + const std::string& node_id, + const std::string& os, + const std::string& arch, + const std::string& version, + const InetAddress& address, + int64_t last_seen) +{ + std::lock_guard l(_lock); + _pending.push_back({ network_id, node_id, os, arch, version, address, last_seen }); +} + +size_t RedisStatusWriter::queueLength() const +{ + std::lock_guard l(_lock); + return _pending.size(); +} + +void RedisStatusWriter::writePending() +{ + try { + if (_mode == REDIS_MODE_STANDALONE) { + auto tx = _redis->transaction(true, false); + _doWritePending(tx); + } + else if (_mode == REDIS_MODE_CLUSTER) { + auto tx = _cluster->transaction(_controller_id, true, false); + _doWritePending(tx); + } + } + catch (const sw::redis::Error& e) { + // Log the error + fprintf(stderr, "Error writing to Redis: %s\n", e.what()); + } +} + +void RedisStatusWriter::_doWritePending(sw::redis::Transaction& tx) +{ + std::vector toWrite; + { + std::lock_guard l(_lock); + toWrite.swap(_pending); + } + if (toWrite.empty()) { + return; + } + + std::set networksUpdated; + uint64_t updateCount = 0; + for (const auto& entry : _pending) { + char iptmp[64] = { 0 }; + std::string ipAddr = entry.address.toIpString(iptmp); + std::unordered_map record = { + { "id", entry.node_id }, { "address", ipAddr }, { "last_updated", std::to_string(entry.last_seen) }, + { "os", entry.os }, { "arch", entry.arch }, { "version", entry.version } + }; + + tx.zadd("nodes-online:{" + _controller_id + "}", entry.node_id, entry.last_seen) + .zadd("nodes-online2:{" + _controller_id + "}", entry.network_id + "-" + entry.node_id, entry.last_seen) + .zadd("network-nodes-online:{" + _controller_id + "}:" + entry.network_id, entry.node_id, entry.last_seen) + .zadd("active-networks:{" + _controller_id + "}", entry.network_id, entry.last_seen) + .sadd("network-nodes-all:{" + _controller_id + "}:" + entry.network_id, entry.node_id) + .hmset( + "member:{" + _controller_id + "}:" + entry.network_id + ":" + entry.node_id, record.begin(), + record.end()); + networksUpdated.insert(entry.network_id); + ++updateCount; + Metrics::redis_node_checkin++; + } + + // expire records from all-nodes and network-nodes member list + uint64_t expireOld = OSUtils::now() - 300000; + + tx.zremrangebyscore( + "nodes-online:{" + _controller_id + "}", + sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); + tx.zremrangebyscore( + "nodes-online2:{" + _controller_id + "}", + sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); + tx.zremrangebyscore( + "active-networks:{" + _controller_id + "}", + sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); + + for (const auto& nwid : networksUpdated) { + tx.zremrangebyscore( + "network-nodes-online:{" + _controller_id + "}:" + nwid, + sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); + } + + fprintf(stderr, "%s: Updated online status of %d members\n", _controller_id.c_str(), updateCount); + tx.exec(); +} + +} // namespace ZeroTier \ No newline at end of file diff --git a/controller/RedisStatusWriter.hpp b/controller/RedisStatusWriter.hpp new file mode 100644 index 0000000000..ac0ffd8668 --- /dev/null +++ b/controller/RedisStatusWriter.hpp @@ -0,0 +1,46 @@ +#ifndef REDIS_STATUS_WRITER_HPP +#define REDIS_STATUS_WRITER_HPP + +#include "Redis.hpp" +#include "StatusWriter.hpp" + +#include +#include +#include + +namespace ZeroTier { + +class RedisStatusWriter : public StatusWriter { + public: + RedisStatusWriter(std::shared_ptr redis, std::string controller_id); + RedisStatusWriter(std::shared_ptr cluster, std::string controller_id); + virtual ~RedisStatusWriter(); + + virtual void updateNodeStatus( + const std::string& network_id, + const std::string& node_id, + const std::string& os, + const std::string& arch, + const std::string& version, + const InetAddress& address, + int64_t last_seen) override; + virtual size_t queueLength() const override; + virtual void writePending() override; + + private: + void _doWritePending(sw::redis::Transaction& tx); + + std::string _controller_id; + + enum RedisMode { REDIS_MODE_STANDALONE, REDIS_MODE_CLUSTER }; + std::shared_ptr _redis; + std::shared_ptr _cluster; + RedisMode _mode = REDIS_MODE_STANDALONE; + + mutable std::mutex _lock; + std::vector _pending; +}; + +} // namespace ZeroTier + +#endif // REDIS_STATUS_WRITER_HPP \ No newline at end of file diff --git a/controller/StatusWriter.cpp b/controller/StatusWriter.cpp new file mode 100644 index 0000000000..b61ec1251c --- /dev/null +++ b/controller/StatusWriter.cpp @@ -0,0 +1 @@ +#include "StatusWriter.hpp" diff --git a/controller/StatusWriter.hpp b/controller/StatusWriter.hpp new file mode 100644 index 0000000000..37b2dd06e7 --- /dev/null +++ b/controller/StatusWriter.hpp @@ -0,0 +1,43 @@ +#ifndef STATUS_WRITER_HPP +#define STATUS_WRITER_HPP + +#include "../node/InetAddress.hpp" + +#include + +namespace ZeroTier { + +/** + * Abstract interface for writing status information somewhere. + * + * Implementations might write to a database, a file, or something else. + */ +class StatusWriter { + public: + virtual ~StatusWriter() = 0; + + virtual void updateNodeStatus( + const std::string& network_id, + const std::string& node_id, + const std::string& os, + const std::string& arch, + const std::string& version, + const InetAddress& address, + int64_t last_seen) = 0; + virtual size_t queueLength() const = 0; + virtual void writePending() = 0; +}; + +struct PendingStatusEntry { + std::string network_id; + std::string node_id; + std::string os; + std::string arch; + std::string version; + InetAddress address; + int64_t last_seen; +}; + +} // namespace ZeroTier + +#endif // STATUS_WRITER_HPP From d119547a9509bd0d1a2530d0f49c26c4e89814a5 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 1 Sep 2025 09:18:01 -0700 Subject: [PATCH 028/245] wire up status writers --- controller/BigTableStatusWriter.hpp | 6 + controller/CentralDB.cpp | 428 ++++++++++------------------ controller/CentralDB.hpp | 28 +- controller/PostgreSQL.hpp | 25 +- 4 files changed, 204 insertions(+), 283 deletions(-) diff --git a/controller/BigTableStatusWriter.hpp b/controller/BigTableStatusWriter.hpp index 85c1e0b4d8..8abc81ca32 100644 --- a/controller/BigTableStatusWriter.hpp +++ b/controller/BigTableStatusWriter.hpp @@ -7,6 +7,12 @@ #include namespace ZeroTier { +struct BigTableConfig { + std::string project_id; + std::string instance_id; + std::string table_id; +}; + class BigTableStatusWriter : public StatusWriter { public: BigTableStatusWriter(const std::string& project_id, const std::string& instance_id, const std::string& table_id); diff --git a/controller/CentralDB.cpp b/controller/CentralDB.cpp index ad054b6910..29b388c3bb 100644 --- a/controller/CentralDB.cpp +++ b/controller/CentralDB.cpp @@ -18,11 +18,14 @@ #include "../node/Constants.hpp" #include "../node/SHA512.hpp" #include "../version.h" +#include "BigTableStatusWriter.hpp" #include "CtlUtil.hpp" #include "EmbeddedNetworkController.hpp" +#include "PostgresStatusWriter.hpp" #include "PubSubListener.hpp" #include "Redis.hpp" #include "RedisListener.hpp" +#include "RedisStatusWriter.hpp" #include "opentelemetry/trace/provider.h" #include @@ -50,9 +53,16 @@ using Attrs = std::vector >; using Item = std::pair; using ItemStream = std::vector; -CentralDB::CentralDB(const Identity& myId, const char* path, int listenPort, CentralDB::ListenerMode mode, ControllerConfig* cc) +CentralDB::CentralDB( + const Identity& myId, + const char* path, + int listenPort, + CentralDB::ListenerMode listenMode, + CentralDB::StatusWriterMode statusMode, + ControllerConfig* cc) : DB() - , _listenerMode(mode) + , _listenerMode(listenMode) + , _statusWriterMode(statusMode) , _controllerConfig(cc) , _pool() , _myId(myId) @@ -79,7 +89,8 @@ CentralDB::CentralDB(const Identity& myId, const char* path, int listenPort, Cen _myAddressStr = myId.address().toString(myAddress); _connString = std::string(path); auto f = std::make_shared(_connString); - _pool = std::make_shared >(15, 5, std::static_pointer_cast(f)); + _pool = + std::make_shared >(15, 5, std::static_pointer_cast(f)); memset(_ssoPsk, 0, sizeof(_ssoPsk)); char* const ssoPskHex = getenv("ZT_SSO_PSK"); @@ -106,12 +117,16 @@ CentralDB::CentralDB(const Identity& myId, const char* path, int listenPort, Cen txn.commit(); if (dbVersion < DB_MINIMUM_VERSION) { - fprintf(stderr, "Central database schema version too low. This controller version requires a minimum schema version of %d. Please upgrade your Central instance", DB_MINIMUM_VERSION); + fprintf( + stderr, + "Central database schema version too low. This controller version requires a minimum schema version of " + "%d. Please upgrade your Central instance", + DB_MINIMUM_VERSION); exit(1); } _pool->unborrow(c); - if (mode == LISTENER_MODE_REDIS && _rc != NULL) { + if ((listenMode == LISTENER_MODE_REDIS || statusMode == STATUS_WRITER_MODE_REDIS) && _rc != NULL) { auto innerspan = tracer->StartSpan("CentralDB::CentralDB::configureRedis"); auto innerscope = tracer->WithActiveSpan(innerspan); @@ -141,7 +156,9 @@ CentralDB::CentralDB(const Identity& myId, const char* path, int listenPort, Cen _readyLock.lock(); - fprintf(stderr, "[%s] NOTICE: %.10llx controller PostgreSQL waiting for initial data download..." ZT_EOL_S, ::_timestr(), (unsigned long long)_myAddress.toInt()); + fprintf( + stderr, "[%s] NOTICE: %.10llx controller PostgreSQL waiting for initial data download..." ZT_EOL_S, + ::_timestr(), (unsigned long long)_myAddress.toInt()); _waitNoticePrinted = true; initializeNetworks(); @@ -149,7 +166,7 @@ CentralDB::CentralDB(const Identity& myId, const char* path, int listenPort, Cen _heartbeatThread = std::thread(&CentralDB::heartbeat, this); - switch (mode) { + switch (listenMode) { case LISTENER_MODE_REDIS: if (_rc != NULL) { if (_rc->clusterMode) { @@ -166,11 +183,14 @@ CentralDB::CentralDB(const Identity& myId, const char* path, int listenPort, Cen } case LISTENER_MODE_PUBSUB: if (cc->pubSubConfig != NULL) { - _membersDbWatcher = std::make_shared(_myAddressStr, cc->pubSubConfig->listen_timeout, this); - _networksDbWatcher = std::make_shared(_myAddressStr, cc->pubSubConfig->listen_timeout, this); + _membersDbWatcher = + std::make_shared(_myAddressStr, cc->pubSubConfig->listen_timeout, this); + _networksDbWatcher = + std::make_shared(_myAddressStr, cc->pubSubConfig->listen_timeout, this); } else { - throw std::runtime_error("CentralDB: PubSub listener mode selected but no PubSub configuration provided"); + throw std::runtime_error( + "CentralDB: PubSub listener mode selected but no PubSub configuration provided"); } break; case LISTENER_MODE_PGSQL: @@ -180,6 +200,30 @@ CentralDB::CentralDB(const Identity& myId, const char* path, int listenPort, Cen break; } + switch (statusMode) { + case STATUS_WRITER_MODE_REDIS: + if (_rc != NULL) { + if (_rc->clusterMode) { + _statusWriter = std::make_shared(_cluster, _myAddressStr); + } + else { + _statusWriter = std::make_shared(_redis, _myAddressStr); + } + } + else { + throw std::runtime_error("CentralDB: Redis status mode selected but no Redis configuration provided"); + } + break; + case STATUS_WRITER_MODE_BIGTABLE: + _statusWriter = std::make_shared( + cc->bigTableConfig->project_id, cc->bigTableConfig->instance_id, cc->bigTableConfig->table_id); + break; + case STATUS_WRITER_MODE_PGSQL: + default: + _statusWriter = std::make_shared(_pool); + break; + } + for (int i = 0; i < ZT_CENTRAL_CONTROLLER_COMMIT_THREADS; ++i) { _commitThread[i] = std::thread(&CentralDB::commitThread, this); } @@ -232,7 +276,8 @@ void CentralDB::configureSmee() if (scheme != NULL && host != NULL && port != NULL && ns != NULL && task_queue != NULL) { fprintf(stderr, "creating smee client\n"); - std::string hostPort = std::string(scheme) + std::string("://") + std::string(host) + std::string(":") + std::string(port); + std::string hostPort = + std::string(scheme) + std::string("://") + std::string(host) + std::string(":") + std::string(port); this->_smee = rustybits::smee_client_new(hostPort.c_str(), ns, task_queue); } else { @@ -362,7 +407,11 @@ void CentralDB::eraseMember(const uint64_t networkId, const uint64_t memberId) _memberChanged(tmp.first, nullJson, true); } -void CentralDB::nodeIsOnline(const uint64_t networkId, const uint64_t memberId, const InetAddress& physicalAddress, const char* osArch) +void CentralDB::nodeIsOnline( + const uint64_t networkId, + const uint64_t memberId, + const InetAddress& physicalAddress, + const char* osArch) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("CentralDB"); @@ -428,15 +477,17 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri std::string nonce = ""; // check if the member exists first. - pqxx::row count = w.exec_params1("SELECT count(id) FROM ztc_member WHERE id = $1 AND network_id = $2 AND deleted = false", memberId, networkId); + pqxx::row count = w.exec_params1( + "SELECT count(id) FROM ztc_member WHERE id = $1 AND network_id = $2 AND deleted = false", memberId, + networkId); if (count[0].as() == 1) { // get active nonce, if exists. pqxx::result r = w.exec_params( "SELECT nonce FROM ztc_sso_expiry " "WHERE network_id = $1 AND member_id = $2 " - "AND ((NOW() AT TIME ZONE 'UTC') <= authentication_expiry_time) AND ((NOW() AT TIME ZONE 'UTC') <= nonce_expiration)", - networkId, - memberId); + "AND ((NOW() AT TIME ZONE 'UTC') <= authentication_expiry_time) AND ((NOW() AT TIME ZONE 'UTC') <= " + "nonce_expiration)", + networkId, memberId); if (r.size() == 0) { // no active nonce. @@ -445,8 +496,7 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri "SELECT nonce FROM ztc_sso_expiry " "WHERE network_id = $1 AND member_id = $2 " "AND authentication_expiry_time IS NULL AND ((NOW() AT TIME ZONE 'UTC') <= nonce_expiration)", - networkId, - memberId); + networkId, memberId); if (r.size() == 1) { // we have an existing nonce. Use it @@ -464,10 +514,7 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri "INSERT INTO ztc_sso_expiry " "(nonce, nonce_expiration, network_id, member_id) VALUES " "($1, TO_TIMESTAMP($2::double precision/1000), $3, $4)", - nonce, - OSUtils::now() + 300000, - networkId, - memberId); + nonce, OSUtils::now() + 300000, networkId, memberId); w.commit(); } @@ -513,7 +560,9 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri sso_version = r.at(0)[4].as >().value_or(1); } else if (r.size() > 1) { - fprintf(stderr, "ERROR: More than one auth endpoint for an organization?!?!? NetworkID: %s\n", networkId.c_str()); + fprintf( + stderr, "ERROR: More than one auth endpoint for an organization?!?!? NetworkID: %s\n", + networkId.c_str()); } else { fprintf(stderr, "No client or auth endpoint?!?\n"); @@ -531,13 +580,10 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri if (info.version == 0) { char url[2048] = { 0 }; OSUtils::ztsnprintf( - url, - sizeof(authenticationURL), - "%s?response_type=id_token&response_mode=form_post&scope=openid+email+profile&redirect_uri=%s&nonce=%s&state=%s&client_id=%s", - authorization_endpoint.c_str(), - url_encode(redirectURL).c_str(), - nonce.c_str(), - state_hex, + url, sizeof(authenticationURL), + "%s?response_type=id_token&response_mode=form_post&scope=openid+email+profile&redirect_uri=" + "%s&nonce=%s&state=%s&client_id=%s", + authorization_endpoint.c_str(), url_encode(redirectURL).c_str(), nonce.c_str(), state_hex, client_id.c_str()); info.authenticationURL = std::string(url); } @@ -551,18 +597,17 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri #ifdef ZT_DEBUG fprintf( stderr, - "ssoClientID: %s\nissuerURL: %s\nssoNonce: %s\nssoState: %s\ncentralAuthURL: %s\nprovider: %s\n", - info.ssoClientID.c_str(), - info.issuerURL.c_str(), - info.ssoNonce.c_str(), - info.ssoState.c_str(), - info.centralAuthURL.c_str(), - provider.c_str()); + "ssoClientID: %s\nissuerURL: %s\nssoNonce: %s\nssoState: %s\ncentralAuthURL: %s\nprovider: " + "%s\n", + info.ssoClientID.c_str(), info.issuerURL.c_str(), info.ssoNonce.c_str(), + info.ssoState.c_str(), info.centralAuthURL.c_str(), provider.c_str()); #endif } } else { - fprintf(stderr, "client_id: %s\nauthorization_endpoint: %s\n", client_id.c_str(), authorization_endpoint.c_str()); + fprintf( + stderr, "client_id: %s\nauthorization_endpoint: %s\n", client_id.c_str(), + authorization_endpoint.c_str()); } } @@ -638,12 +683,16 @@ void CentralDB::initializeNetworks() config["lastModified"] = last_modified.value_or(0); config["revision"] = revision.value_or(0); config["capabilities"] = cfgtmp["capabilities"].is_array() ? cfgtmp["capabilities"] : json::array(); - config["enableBroadcast"] = cfgtmp["enableBroadcast"].is_boolean() ? cfgtmp["enableBroadcast"].get() : false; + config["enableBroadcast"] = + cfgtmp["enableBroadcast"].is_boolean() ? cfgtmp["enableBroadcast"].get() : false; config["mtu"] = cfgtmp["mtu"].is_number() ? cfgtmp["mtu"].get() : 2800; - config["multicastLimit"] = cfgtmp["multicastLimit"].is_number() ? cfgtmp["multicastLimit"].get() : 64; + config["multicastLimit"] = + cfgtmp["multicastLimit"].is_number() ? cfgtmp["multicastLimit"].get() : 64; config["private"] = cfgtmp["private"].is_boolean() ? cfgtmp["private"].get() : true; - config["remoteTraceLevel"] = cfgtmp["remoteTraceLevel"].is_number() ? cfgtmp["remoteTraceLevel"].get() : 0; - config["remoteTraceTarget"] = cfgtmp["remoteTraceTarget"].is_string() ? cfgtmp["remoteTraceTarget"].get() : ""; + config["remoteTraceLevel"] = + cfgtmp["remoteTraceLevel"].is_number() ? cfgtmp["remoteTraceLevel"].get() : 0; + config["remoteTraceTarget"] = + cfgtmp["remoteTraceTarget"].is_string() ? cfgtmp["remoteTraceTarget"].get() : ""; config["revision"] = revision.value_or(0); config["rules"] = cfgtmp["rules"].is_array() ? cfgtmp["rules"] : json::array(); config["tags"] = cfgtmp["tags"].is_array() ? cfgtmp["tags"] : json::array(); @@ -667,7 +716,9 @@ void CentralDB::initializeNetworks() config["objtype"] = "network"; config["routes"] = cfgtmp["routes"].is_array() ? cfgtmp["routes"] : json::array(); config["clientId"] = cfgtmp["clientId"].is_string() ? cfgtmp["clientId"].get() : ""; - config["authorizationEndpoint"] = cfgtmp["authorizationEndpoint"].is_string() ? cfgtmp["authorizationEndpoint"].get() : nullptr; + config["authorizationEndpoint"] = cfgtmp["authorizationEndpoint"].is_string() + ? cfgtmp["authorizationEndpoint"].get() + : nullptr; config["provider"] = cfgtmp["ssoProvider"].is_string() ? cfgtmp["ssoProvider"].get() : ""; if (! cfgtmp["dns"].is_object()) { cfgtmp["dns"] = json::object(); @@ -677,7 +728,8 @@ void CentralDB::initializeNetworks() else { config["dns"] = cfgtmp["dns"]; } - config["ipAssignmentPools"] = cfgtmp["ipAssignmentPools"].is_array() ? cfgtmp["ipAssignmentPools"] : json::array(); + config["ipAssignmentPools"] = + cfgtmp["ipAssignmentPools"].is_array() ? cfgtmp["ipAssignmentPools"] : json::array(); Metrics::network_count++; @@ -699,7 +751,9 @@ void CentralDB::initializeNetworks() if (++this->_ready == 2) { if (_waitNoticePrinted) { - fprintf(stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), (unsigned long long)_myAddress.toInt()); + fprintf( + stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), + (unsigned long long)_myAddress.toInt()); } _readyLock.unlock(); } @@ -767,7 +821,8 @@ void CentralDB::initializeMembers() char qbuf[2048]; sprintf( qbuf, - "SELECT nm.device_id, nm.network_id, nm.authorized, nm.active_bridge, nm.ip_assignments, nm.no_auto_assign_ips, " + "SELECT nm.device_id, nm.network_id, nm.authorized, nm.active_bridge, nm.ip_assignments, " + "nm.no_auto_assign_ips, " "nm.sso_exempt, (EXTRACT(EPOCH FROM nm.authentication_expiry_time AT TIME ZONE 'UTC')*1000)::bigint, " "(EXTRACT(EPOCH FROM nm.creation_time AT TIME ZONE 'UTC')*1000)::bigint, nm.identity, " "(EXTRACT(EPOCH FROM nm.last_authorized_time AT TIME ZONE 'UTC')*1000)::bigint, " @@ -938,7 +993,9 @@ void CentralDB::initializeMembers() if (++this->_ready == 2) { if (_waitNoticePrinted) { - fprintf(stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), (unsigned long long)_myAddress.toInt()); + fprintf( + stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), + (unsigned long long)_myAddress.toInt()); } _readyLock.unlock(); } @@ -997,13 +1054,10 @@ void CentralDB::heartbeat() w.exec_params0( "INSERT INTO controllers_ctl (id, hostname, last_heartbeat, public_identity, version) VALUES " "($1, $2, TO_TIMESTAMP($3::double precision/1000), $4, $5) " - "ON CONFLICT (id) DO UPDATE SET hostname = EXCLUDED.hostname, last_heartbeat = EXCLUDED.last_heartbeat, " + "ON CONFLICT (id) DO UPDATE SET hostname = EXCLUDED.hostname, last_heartbeat = " + "EXCLUDED.last_heartbeat, " "public_identity = EXCLUDED.public_identity, version = EXCLUDED.version", - controllerId, - hostname, - ts, - publicIdentity, - versionStr); + controllerId, hostname, ts, publicIdentity, versionStr); w.commit(); } catch (std::exception& e) { @@ -1097,13 +1151,15 @@ void CentralDB::commitThread() continue; } - pqxx::row mrow = w.exec_params1("SELECT COUNT(id) FROM ztc_member WHERE id = $1 AND network_id = $2", memberId, networkId); + pqxx::row mrow = w.exec_params1( + "SELECT COUNT(id) FROM ztc_member WHERE id = $1 AND network_id = $2", memberId, networkId); int membercount = mrow[0].as(); bool isNewMember = (membercount == 0); pqxx::result res = w.exec_params0( - "INSERT INTO network_memberships_ctl (device_id, network_id, authorized, active_bridge, ip_assignments, " + "INSERT INTO network_memberships_ctl (device_id, network_id, authorized, active_bridge, " + "ip_assignments, " "no_auto_assign_ips, sso_exempt, authentication_expiry_time, capabilities, creation_time, " "identity, last_authorized_time, last_deauthorized_time, " "remote_trace_level, remote_trace_target, revision, tags, version_major, version_minor, " @@ -1114,40 +1170,31 @@ void CentralDB::commitThread() "ON CONFLICT (device_id, network_id) DO UPDATE SET " "authorized = EXCLUDED.authorized, active_bridge = EXCLUDED.active_bridge, " "ip_assignments = EXCLUDED.ip_assignments, no_auto_assign_ips = EXCLUDED.no_auto_assign_ips, " - "sso_exempt = EXCLUDED.sso_exempt, authentication_expiry_time = EXCLUDED.authentication_expiry_time, " + "sso_exempt = EXCLUDED.sso_exempt, authentication_expiry_time = " + "EXCLUDED.authentication_expiry_time, " "capabilities = EXCLUDED.capabilities, creation_time = EXCLUDED.creation_time, " "identity = EXCLUDED.identity, last_authorized_time = EXCLUDED.last_authorized_time, " "last_deauthorized_time = EXCLUDED.last_deauthorized_time, " - "remote_trace_level = EXCLUDED.remote_trace_level, remote_trace_target = EXCLUDED.remote_trace_target, " + "remote_trace_level = EXCLUDED.remote_trace_level, remote_trace_target = " + "EXCLUDED.remote_trace_target, " "revision = EXCLUDED.revision, tags = EXCLUDED.tags, version_major = EXCLUDED.version_major, " "version_minor = EXCLUDED.version_minor, version_revision = EXCLUDED.version_revision, " "version_protocol = EXCLUDED.version_protocol", - memberId, - networkId, - (bool)config["authorized"], - (bool)config["activeBridge"], - config["ipAssignments"].get >(), - (bool)config["noAutoAssignIps"], - (bool)config["ssoExempt"], - (uint64_t)config["authenticationExpiryTime"], - OSUtils::jsonDump(config["capabilities"], -1), - (uint64_t)config["creationTime"], - OSUtils::jsonString(config["identity"], ""), - (uint64_t)config["lastAuthorizedTime"], - (uint64_t)config["lastDeauthorizedTime"], - (int)config["remoteTraceLevel"], - target, - (uint64_t)config["revision"], - OSUtils::jsonDump(config["tags"], -1), - (int)config["vMajor"], - (int)config["vMinor"], - (int)config["vRev"], - (int)config["vProto"]); + memberId, networkId, (bool)config["authorized"], (bool)config["activeBridge"], + config["ipAssignments"].get >(), (bool)config["noAutoAssignIps"], + (bool)config["ssoExempt"], (uint64_t)config["authenticationExpiryTime"], + OSUtils::jsonDump(config["capabilities"], -1), (uint64_t)config["creationTime"], + OSUtils::jsonString(config["identity"], ""), (uint64_t)config["lastAuthorizedTime"], + (uint64_t)config["lastDeauthorizedTime"], (int)config["remoteTraceLevel"], target, + (uint64_t)config["revision"], OSUtils::jsonDump(config["tags"], -1), (int)config["vMajor"], + (int)config["vMinor"], (int)config["vRev"], (int)config["vProto"]); w.commit(); if (! isNewMember) { - pqxx::result res = w.exec_params0("DELETE FROM ztc_member_ip_assignment WHERE member_id = $1 AND network_id = $2", memberId, networkId); + pqxx::result res = w.exec_params0( + "DELETE FROM ztc_member_ip_assignment WHERE member_id = $1 AND network_id = $2", memberId, + networkId); } if (_smee != NULL && isNewMember) { @@ -1181,11 +1228,15 @@ void CentralDB::commitThread() _memberChanged(memOrig, memNew, qitem.second); } else { - fprintf(stderr, "%s: Can't notify of change. Error parsing nwid or memberid: %llu-%llu\n", _myAddressStr.c_str(), (unsigned long long)nwidInt, (unsigned long long)memberidInt); + fprintf( + stderr, "%s: Can't notify of change. Error parsing nwid or memberid: %llu-%llu\n", + _myAddressStr.c_str(), (unsigned long long)nwidInt, (unsigned long long)memberidInt); } } catch (std::exception& e) { - fprintf(stderr, "%s ERROR: Error updating member %s-%s: %s\n", _myAddressStr.c_str(), networkId.c_str(), memberId.c_str(), e.what()); + fprintf( + stderr, "%s ERROR: Error updating member %s-%s: %s\n", _myAddressStr.c_str(), networkId.c_str(), + memberId.c_str(), e.what()); mspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); } } @@ -1205,10 +1256,7 @@ void CentralDB::commitThread() "VALUES ($1, $2, $3, $4, $5) " "ON CONFLICT (id) DO UPDATE SET " "name = EXCLUDED.name, configuration = EXCLUDED.configuration, revision = EXCLUDED.revision+1", - id, - OSUtils::jsonString(config["name"], ""), - OSUtils::jsonDump(config, -1), - _myAddressStr, + id, OSUtils::jsonString(config["name"], ""), OSUtils::jsonDump(config, -1), _myAddressStr, ((uint64_t)config["revision"])); w.commit(); @@ -1224,9 +1272,7 @@ void CentralDB::commitThread() res = w.exec_params0( "INSERT INTO ztc_network_assignment_pool (network_id, ip_range_start, ip_range_end) " "VALUES ($1, $2, $3)", - id, - start, - end); + id, start, end); } const uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); @@ -1239,7 +1285,9 @@ void CentralDB::commitThread() _networkChanged(nwOrig, nwNew, qitem.second); } else { - fprintf(stderr, "%s: Can't notify network changed: %llu\n", _myAddressStr.c_str(), (unsigned long long)nwidInt); + fprintf( + stderr, "%s: Can't notify network changed: %llu\n", _myAddressStr.c_str(), + (unsigned long long)nwidInt); } } catch (std::exception& e) { @@ -1319,7 +1367,9 @@ void CentralDB::commitThread() std::string memberId = config["id"]; std::string networkId = config["nwid"]; - pqxx::result res = w.exec_params0("DELETE FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", memberId, networkId); + pqxx::result res = w.exec_params0( + "DELETE FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", memberId, + networkId); w.commit(); @@ -1386,56 +1436,22 @@ void CentralDB::notifyNewMember(const std::string& networkID, const std::string& void CentralDB::onlineNotificationThread() { waitForReady(); - if (_redisMemberStatus) { - onlineNotification_Redis(); - } - else { - onlineNotification_Postgres(); - } -} - -/** - * ONLY UNCOMMENT FOR TEMPORARY DB MAINTENANCE - * - * This define temporarily turns off writing to the member status table - * so it can be reindexed when the indexes get too large. - */ - -// #define DISABLE_MEMBER_STATUS 1 - -void CentralDB::onlineNotification_Postgres() -{ - _connected = 1; - - nlohmann::json jtmp1, jtmp2; while (_run == 1) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("CentralDB"); - auto span = tracer->StartSpan("CentralDB::onlineNotification_Postgres"); + auto span = tracer->StartSpan("CentralDB::onlineNotificationThread"); auto scope = tracer->WithActiveSpan(span); - auto c = _pool->borrow(); - auto c2 = _pool->borrow(); try { - fprintf(stderr, "%s onlineNotification_Postgres\n", _myAddressStr.c_str()); std::unordered_map, NodeOnlineRecord, _PairHasher> lastOnline; { std::lock_guard l(_lastOnline_l); lastOnline.swap(_lastOnline); } -#ifndef DISABLE_MEMBER_STATUS + uint64_t updateCount = 0; + auto c = _pool->borrow(); pqxx::work w(*c->c); - pqxx::work w2(*c2->c); - - fprintf(stderr, "online notification tick\n"); - - bool firstRun = true; - bool memberAdded = false; - int updateCount = 0; - - pqxx::pipeline pipe(w); - for (auto i = lastOnline.begin(); i != lastOnline.end(); ++i) { updateCount += 1; uint64_t nwid_i = i->first.first; @@ -1444,6 +1460,7 @@ void CentralDB::onlineNotification_Postgres() char ipTmp[64]; OSUtils::ztsnprintf(nwidTmp, sizeof(nwidTmp), "%.16llx", nwid_i); OSUtils::ztsnprintf(memTmp, sizeof(memTmp), "%.10llx", i->first.second); + nlohmann::json jtmp1, jtmp2; if (! get(nwid_i, jtmp1, i->first.second, jtmp2)) { continue; // skip non existent networks/members @@ -1453,7 +1470,8 @@ void CentralDB::onlineNotification_Postgres() std::string memberId(memTmp); try { - pqxx::row r = w2.exec_params1("SELECT id, network_id FROM ztc_member WHERE network_id = $1 AND id = $2", networkId, memberId); + pqxx::row r = w.exec_params1( + "SELECT id, network_id FROM ztc_member WHERE network_id = $1 AND id = $2", networkId, memberId); } catch (pqxx::unexpected_rows& e) { continue; @@ -1463,160 +1481,24 @@ void CentralDB::onlineNotification_Postgres() std::string ipAddr = i->second.physicalAddress.toIpString(ipTmp); std::string timestamp = std::to_string(ts); std::string osArch = i->second.osArch; - - std::stringstream memberUpdate; - memberUpdate << "INSERT INTO ztc_member_status (network_id, member_id, address, last_updated) VALUES " - << "('" << networkId << "', '" << memberId << "', "; - if (ipAddr.empty()) { - memberUpdate << "NULL, "; - } - else { - memberUpdate << "'" << ipAddr << "', "; + std::vector osArchSplit = split(osArch, '/'); + std::string os = "unknown"; + std::string arch = "unknown"; + if (osArchSplit.size() == 2) { + os = osArchSplit[0]; + arch = osArchSplit[1]; } - memberUpdate << "TO_TIMESTAMP(" << timestamp << "::double precision/1000)) " - << " ON CONFLICT (network_id, member_id) DO UPDATE SET address = EXCLUDED.address, last_updated = EXCLUDED.last_updated"; - pipe.insert(memberUpdate.str()); - Metrics::pgsql_node_checkin++; + _statusWriter->updateNodeStatus(networkId, memberId, os, arch, "", i->second.physicalAddress, ts); } - while (! pipe.empty()) { - pipe.retrieve(); - } - - pipe.complete(); + _statusWriter->writePending(); w.commit(); - fprintf(stderr, "%s: Updated online status of %d members\n", _myAddressStr.c_str(), updateCount); -#endif + _pool->unborrow(c); } catch (std::exception& e) { fprintf(stderr, "%s: error in onlinenotification thread: %s\n", _myAddressStr.c_str(), e.what()); } - _pool->unborrow(c2); - _pool->unborrow(c); - - ConnectionPoolStats stats = _pool->get_stats(); - fprintf(stderr, "%s pool stats: in use size: %llu, available size: %llu, total: %llu\n", _myAddressStr.c_str(), stats.borrowed_size, stats.pool_size, (stats.borrowed_size + stats.pool_size)); - - span->End(); - - std::this_thread::sleep_for(std::chrono::seconds(10)); - } - fprintf(stderr, "%s: Fell out of run loop in onlineNotificationThread\n", _myAddressStr.c_str()); - if (_run == 1) { - fprintf(stderr, "ERROR: %s onlineNotificationThread should still be running! Exiting Controller.\n", _myAddressStr.c_str()); - exit(6); } } -void CentralDB::onlineNotification_Redis() -{ - _connected = 1; - - char buf[11] = { 0 }; - std::string controllerId = std::string(_myAddress.toString(buf)); - - while (_run == 1) { - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("CentralDB"); - auto span = tracer->StartSpan("CentralDB::onlineNotification_Redis"); - auto scope = tracer->WithActiveSpan(span); - - fprintf(stderr, "onlineNotification tick\n"); - auto start = std::chrono::high_resolution_clock::now(); - uint64_t count = 0; - - std::unordered_map, NodeOnlineRecord, _PairHasher> lastOnline; - { - std::lock_guard l(_lastOnline_l); - lastOnline.swap(_lastOnline); - } - try { - if (! lastOnline.empty()) { - if (_rc->clusterMode) { - auto tx = _cluster->transaction(controllerId, true, false); - count = _doRedisUpdate(tx, controllerId, lastOnline); - } - else { - auto tx = _redis->transaction(true, false); - count = _doRedisUpdate(tx, controllerId, lastOnline); - } - } - } - catch (sw::redis::Error& e) { - fprintf(stderr, "Error in online notification thread (redis): %s\n", e.what()); - } - - auto end = std::chrono::high_resolution_clock::now(); - auto dur = std::chrono::duration_cast(end - start); - auto total = dur.count(); - - fprintf(stderr, "onlineNotification ran in %llu ms\n", total); - span->End(); - - std::this_thread::sleep_for(std::chrono::seconds(5)); - } -} - -uint64_t CentralDB::_doRedisUpdate(sw::redis::Transaction& tx, std::string& controllerId, std::unordered_map, NodeOnlineRecord, _PairHasher>& lastOnline) -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("CentralDB"); - auto span = tracer->StartSpan("CentralDB::_doRedisUpdate"); - auto scope = tracer->WithActiveSpan(span); - - nlohmann::json jtmp1, jtmp2; - uint64_t count = 0; - for (auto i = lastOnline.begin(); i != lastOnline.end(); ++i) { - uint64_t nwid_i = i->first.first; - uint64_t memberid_i = i->first.second; - char nwidTmp[64]; - char memTmp[64]; - char ipTmp[64]; - OSUtils::ztsnprintf(nwidTmp, sizeof(nwidTmp), "%.16llx", nwid_i); - OSUtils::ztsnprintf(memTmp, sizeof(memTmp), "%.10llx", memberid_i); - - if (! get(nwid_i, jtmp1, memberid_i, jtmp2)) { - continue; // skip non existent members/networks - } - - std::string networkId(nwidTmp); - std::string memberId(memTmp); - - int64_t ts = i->second.lastSeen; - std::string ipAddr = i->second.physicalAddress.toIpString(ipTmp); - std::string timestamp = std::to_string(ts); - std::string osArch = i->second.osArch; - - std::unordered_map record = { { "id", memberId }, { "address", ipAddr }, { "last_updated", std::to_string(ts) } }; - tx.zadd("nodes-online:{" + controllerId + "}", memberId, ts) - .zadd("nodes-online2:{" + controllerId + "}", networkId + "-" + memberId, ts) - .zadd("network-nodes-online:{" + controllerId + "}:" + networkId, memberId, ts) - .zadd("active-networks:{" + controllerId + "}", networkId, ts) - .sadd("network-nodes-all:{" + controllerId + "}:" + networkId, memberId) - .hmset("member:{" + controllerId + "}:" + networkId + ":" + memberId, record.begin(), record.end()); - ++count; - Metrics::redis_node_checkin++; - } - - // expire records from all-nodes and network-nodes member list - uint64_t expireOld = OSUtils::now() - 300000; - - tx.zremrangebyscore("nodes-online:{" + controllerId + "}", sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); - tx.zremrangebyscore("nodes-online2:{" + controllerId + "}", sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); - tx.zremrangebyscore("active-networks:{" + controllerId + "}", sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); - { - std::shared_lock l(_networks_l); - for (const auto& it : _networks) { - uint64_t nwid_i = it.first; - char nwidTmp[64]; - OSUtils::ztsnprintf(nwidTmp, sizeof(nwidTmp), "%.16llx", nwid_i); - tx.zremrangebyscore("network-nodes-online:{" + controllerId + "}:" + nwidTmp, sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); - } - } - tx.exec(); - fprintf(stderr, "%s: Updated online status of %d members\n", _myAddressStr.c_str(), count); - - return count; -} - #endif // ZT_CONTROLLER_USE_LIBPQ diff --git a/controller/CentralDB.hpp b/controller/CentralDB.hpp index 156e82e9a8..6a3755952f 100644 --- a/controller/CentralDB.hpp +++ b/controller/CentralDB.hpp @@ -10,6 +10,7 @@ #include "DB.hpp" #include "NotificationListener.hpp" #include "PostgreSQL.hpp" +#include "StatusWriter.hpp" #include #include @@ -24,12 +25,14 @@ namespace ZeroTier { struct RedisConfig; struct PubSubConfig; struct PostgresNotifyConfig; +struct BigTableConfig; struct ControllerConfig { bool ssoEnabled; RedisConfig* redisConfig; PubSubConfig* pubSubConfig; PostgresNotifyConfig* postgresNotifyConfig; + BigTableConfig* bigTableConfig; }; class CentralDB : public DB { @@ -40,7 +43,19 @@ class CentralDB : public DB { LISTENER_MODE_PUBSUB = 2, }; - CentralDB(const Identity& myId, const char* path, int listenPort, CentralDB::ListenerMode mode, ControllerConfig* cc); + enum StatusWriterMode { + STATUS_WRITER_MODE_PGSQL = 0, + STATUS_WRITER_MODE_REDIS = 1, + STATUS_WRITER_MODE_BIGTABLE = 2, + }; + + CentralDB( + const Identity& myId, + const char* path, + int listenPort, + CentralDB::ListenerMode mode, + CentralDB::StatusWriterMode statusMode, + ControllerConfig* cc); virtual ~CentralDB(); virtual bool waitForReady(); @@ -49,7 +64,11 @@ class CentralDB : public DB { virtual void eraseNetwork(const uint64_t networkId); virtual void eraseMember(const uint64_t networkId, const uint64_t memberId); virtual void nodeIsOnline(const uint64_t networkId, const uint64_t memberId, const InetAddress& physicalAddress); - virtual void nodeIsOnline(const uint64_t networkId, const uint64_t memberId, const InetAddress& physicalAddress, const char* osArch); + virtual void nodeIsOnline( + const uint64_t networkId, + const uint64_t memberId, + const InetAddress& physicalAddress, + const char* osArch); virtual AuthInfo getSSOAuthInfo(const nlohmann::json& member, const std::string& redirectURL); virtual bool ready() @@ -82,9 +101,6 @@ class CentralDB : public DB { void commitThread(); void onlineNotificationThread(); - void onlineNotification_Postgres(); - void onlineNotification_Redis(); - uint64_t _doRedisUpdate(sw::redis::Transaction& tx, std::string& controllerId, std::unordered_map, NodeOnlineRecord, _PairHasher>& lastOnline); void configureSmee(); void notifyNewMember(const std::string& networkID, const std::string& memberID); @@ -92,6 +108,7 @@ class CentralDB : public DB { enum OverrideMode { ALLOW_PGBOUNCER_OVERRIDE = 0, NO_OVERRIDE = 1 }; ListenerMode _listenerMode; + StatusWriterMode _statusWriterMode; ControllerConfig* _controllerConfig; std::shared_ptr > _pool; @@ -105,6 +122,7 @@ class CentralDB : public DB { std::thread _heartbeatThread; std::shared_ptr _membersDbWatcher; std::shared_ptr _networksDbWatcher; + std::shared_ptr _statusWriter; std::thread _commitThread[ZT_CENTRAL_CONTROLLER_COMMIT_THREADS]; std::thread _onlineNotificationThread; diff --git a/controller/PostgreSQL.hpp b/controller/PostgreSQL.hpp index af96a40fde..fd1fd951de 100644 --- a/controller/PostgreSQL.hpp +++ b/controller/PostgreSQL.hpp @@ -61,7 +61,9 @@ class PostgresConnFactory : public ConnectionFactory { template class MemberNotificationReceiver : public pqxx::notification_receiver { public: - MemberNotificationReceiver(T* p, pqxx::connection& c, const std::string& channel) : pqxx::notification_receiver(c, channel), _psql(p) + MemberNotificationReceiver(T* p, pqxx::connection& c, const std::string& channel) + : pqxx::notification_receiver(c, channel) + , _psql(p) { fprintf(stderr, "initialize MemberNotificationReceiver\n"); } @@ -118,7 +120,9 @@ template class MemberNotificationReceiver : public pqxx::notificati template class NetworkNotificationReceiver : public pqxx::notification_receiver { public: - NetworkNotificationReceiver(T* p, pqxx::connection& c, const std::string& channel) : pqxx::notification_receiver(c, channel), _psql(p) + NetworkNotificationReceiver(T* p, pqxx::connection& c, const std::string& channel) + : pqxx::notification_receiver(c, channel) + , _psql(p) { fprintf(stderr, "initialize NetworkrNotificationReceiver\n"); } @@ -187,6 +191,7 @@ struct NodeOnlineRecord { uint64_t lastSeen; InetAddress physicalAddress; std::string osArch; + std::string version; }; /** @@ -194,7 +199,9 @@ struct NodeOnlineRecord { */ template class _notificationReceiver : public pqxx::notification_receiver { public: - _notificationReceiver(T* p, pqxx::connection& c, const std::string& channel) : pqxx::notification_receiver(c, channel), _listener(p) + _notificationReceiver(T* p, pqxx::connection& c, const std::string& channel) + : pqxx::notification_receiver(c, channel) + , _listener(p) { fprintf(stderr, "initialize PostgresMemberNotificationListener::_notificationReceiver\n"); } @@ -214,7 +221,11 @@ template class _notificationReceiver : public pqxx::notification_re class PostgresMemberListener : public NotificationListener { public: - PostgresMemberListener(DB* db, std::shared_ptr > pool, const std::string& channel, uint64_t timeout); + PostgresMemberListener( + DB* db, + std::shared_ptr > pool, + const std::string& channel, + uint64_t timeout); virtual ~PostgresMemberListener(); virtual void listen(); @@ -233,7 +244,11 @@ class PostgresMemberListener : public NotificationListener { class PostgresNetworkListener : public NotificationListener { public: - PostgresNetworkListener(DB* db, std::shared_ptr > pool, const std::string& channel, uint64_t timeout); + PostgresNetworkListener( + DB* db, + std::shared_ptr > pool, + const std::string& channel, + uint64_t timeout); virtual ~PostgresNetworkListener(); virtual void listen(); From e347f895b81e663364f1bdfda2c07ead95287c29 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 1 Sep 2025 09:44:39 -0700 Subject: [PATCH 029/245] add sleep at end of online notificaiton loop --- controller/CentralDB.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/controller/CentralDB.cpp b/controller/CentralDB.cpp index 29b388c3bb..1b1e4d554b 100644 --- a/controller/CentralDB.cpp +++ b/controller/CentralDB.cpp @@ -1498,6 +1498,8 @@ void CentralDB::onlineNotificationThread() catch (std::exception& e) { fprintf(stderr, "%s: error in onlinenotification thread: %s\n", _myAddressStr.c_str(), e.what()); } + + std::this_thread::sleep_for(std::chrono::seconds(10)); } } From b114896e7bbb29595ba06019dde2f4e14ee4f57e Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 1 Sep 2025 14:25:15 -0700 Subject: [PATCH 030/245] PubSub to gcloud-cpp library for simplicity's sake --- controller/CMakeLists.txt | 13 +- controller/CV1.cpp | 290 ++++++++++++---------- controller/CentralDB.cpp | 27 +- controller/PubSubListener.cpp | 312 ++++++++++++++++++------ controller/PubSubListener.hpp | 44 ++-- controller/protobuf/member.proto | 39 +++ controller/protobuf/member_status.proto | 21 ++ controller/protobuf/network.proto | 66 +++++ 8 files changed, 575 insertions(+), 237 deletions(-) create mode 100644 controller/protobuf/member.proto create mode 100644 controller/protobuf/member_status.proto create mode 100644 controller/protobuf/network.proto diff --git a/controller/CMakeLists.txt b/controller/CMakeLists.txt index ea11b39524..670858caa2 100644 --- a/controller/CMakeLists.txt +++ b/controller/CMakeLists.txt @@ -34,6 +34,7 @@ set(LINK_LIBS if (ZT1_CENTRAL_CONTROLLER) find_package(PostgreSQL REQUIRED) + find_package(protobuf REQUIRED) list(APPEND SRC_FILES CV1.cpp @@ -64,7 +65,7 @@ if (ZT1_CENTRAL_CONTROLLER) ${PostgreSQL_INCLUDE_DIRS} "${redis++_BUILD_DIR}/src" ${pqxx_INCLUDE_DIRS} - + "${CMAKE_CURRENT_BINARY_DIR}" ) list(APPEND LINK_LIBS @@ -78,6 +79,16 @@ endif() add_library(zerotier-controller STATIC ${SRC_FILES}) +if (ZT1_CENTRAL_CONTROLLER) + file(GLOB PROTO_FILES "${CMAKE_CURRENT_SOURCE_DIR}/protobuf/*.proto") + protobuf_generate( + TARGET zerotier-controller + LANGUAGE cpp + PROTOS ${PROTO_FILES} + APPEND_PATH + ) +endif() + target_include_directories(zerotier-controller PRIVATE ${INCLUDE_DIRS}) add_dependencies(zerotier-controller redis++::redis++) diff --git a/controller/CV1.cpp b/controller/CV1.cpp index e571365550..e739561bbf 100644 --- a/controller/CV1.cpp +++ b/controller/CV1.cpp @@ -73,7 +73,8 @@ CV1::CV1(const Identity& myId, const char* path, int listenPort, RedisConfig* rc _myAddressStr = myId.address().toString(myAddress); _connString = std::string(path); auto f = std::make_shared(_connString); - _pool = std::make_shared >(15, 5, std::static_pointer_cast(f)); + _pool = + std::make_shared >(15, 5, std::static_pointer_cast(f)); memset(_ssoPsk, 0, sizeof(_ssoPsk)); char* const ssoPskHex = getenv("ZT_SSO_PSK"); @@ -100,7 +101,11 @@ CV1::CV1(const Identity& myId, const char* path, int listenPort, RedisConfig* rc txn.commit(); if (dbVersion < DB_MINIMUM_VERSION) { - fprintf(stderr, "Central database schema version too low. This controller version requires a minimum schema version of %d. Please upgrade your Central instance", DB_MINIMUM_VERSION); + fprintf( + stderr, + "Central database schema version too low. This controller version requires a minimum schema version of " + "%d. Please upgrade your Central instance", + DB_MINIMUM_VERSION); exit(1); } _pool->unborrow(c); @@ -135,7 +140,9 @@ CV1::CV1(const Identity& myId, const char* path, int listenPort, RedisConfig* rc _readyLock.lock(); - fprintf(stderr, "[%s] NOTICE: %.10llx controller PostgreSQL waiting for initial data download..." ZT_EOL_S, ::_timestr(), (unsigned long long)_myAddress.toInt()); + fprintf( + stderr, "[%s] NOTICE: %.10llx controller PostgreSQL waiting for initial data download..." ZT_EOL_S, + ::_timestr(), (unsigned long long)_myAddress.toInt()); _waitNoticePrinted = true; initializeNetworks(); @@ -198,7 +205,8 @@ void CV1::configureSmee() if (scheme != NULL && host != NULL && port != NULL && ns != NULL && task_queue != NULL) { fprintf(stderr, "creating smee client\n"); - std::string hostPort = std::string(scheme) + std::string("://") + std::string(host) + std::string(":") + std::string(port); + std::string hostPort = + std::string(scheme) + std::string("://") + std::string(host) + std::string(":") + std::string(port); this->_smee = rustybits::smee_client_new(hostPort.c_str(), ns, task_queue); } else { @@ -328,7 +336,11 @@ void CV1::eraseMember(const uint64_t networkId, const uint64_t memberId) _memberChanged(tmp.first, nullJson, true); } -void CV1::nodeIsOnline(const uint64_t networkId, const uint64_t memberId, const InetAddress& physicalAddress, const char* osArch) +void CV1::nodeIsOnline( + const uint64_t networkId, + const uint64_t memberId, + const InetAddress& physicalAddress, + const char* osArch) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("cv1"); @@ -393,15 +405,17 @@ AuthInfo CV1::getSSOAuthInfo(const nlohmann::json& member, const std::string& re std::string nonce = ""; // check if the member exists first. - pqxx::row count = w.exec_params1("SELECT count(id) FROM ztc_member WHERE id = $1 AND network_id = $2 AND deleted = false", memberId, networkId); + pqxx::row count = w.exec_params1( + "SELECT count(id) FROM ztc_member WHERE id = $1 AND network_id = $2 AND deleted = false", memberId, + networkId); if (count[0].as() == 1) { // get active nonce, if exists. pqxx::result r = w.exec_params( "SELECT nonce FROM ztc_sso_expiry " "WHERE network_id = $1 AND member_id = $2 " - "AND ((NOW() AT TIME ZONE 'UTC') <= authentication_expiry_time) AND ((NOW() AT TIME ZONE 'UTC') <= nonce_expiration)", - networkId, - memberId); + "AND ((NOW() AT TIME ZONE 'UTC') <= authentication_expiry_time) AND ((NOW() AT TIME ZONE 'UTC') <= " + "nonce_expiration)", + networkId, memberId); if (r.size() == 0) { // no active nonce. @@ -410,8 +424,7 @@ AuthInfo CV1::getSSOAuthInfo(const nlohmann::json& member, const std::string& re "SELECT nonce FROM ztc_sso_expiry " "WHERE network_id = $1 AND member_id = $2 " "AND authentication_expiry_time IS NULL AND ((NOW() AT TIME ZONE 'UTC') <= nonce_expiration)", - networkId, - memberId); + networkId, memberId); if (r.size() == 1) { // we have an existing nonce. Use it @@ -429,10 +442,7 @@ AuthInfo CV1::getSSOAuthInfo(const nlohmann::json& member, const std::string& re "INSERT INTO ztc_sso_expiry " "(nonce, nonce_expiration, network_id, member_id) VALUES " "($1, TO_TIMESTAMP($2::double precision/1000), $3, $4)", - nonce, - OSUtils::now() + 300000, - networkId, - memberId); + nonce, OSUtils::now() + 300000, networkId, memberId); w.commit(); } @@ -478,7 +488,9 @@ AuthInfo CV1::getSSOAuthInfo(const nlohmann::json& member, const std::string& re sso_version = r.at(0)[4].as >().value_or(1); } else if (r.size() > 1) { - fprintf(stderr, "ERROR: More than one auth endpoint for an organization?!?!? NetworkID: %s\n", networkId.c_str()); + fprintf( + stderr, "ERROR: More than one auth endpoint for an organization?!?!? NetworkID: %s\n", + networkId.c_str()); } else { fprintf(stderr, "No client or auth endpoint?!?\n"); @@ -496,13 +508,10 @@ AuthInfo CV1::getSSOAuthInfo(const nlohmann::json& member, const std::string& re if (info.version == 0) { char url[2048] = { 0 }; OSUtils::ztsnprintf( - url, - sizeof(authenticationURL), - "%s?response_type=id_token&response_mode=form_post&scope=openid+email+profile&redirect_uri=%s&nonce=%s&state=%s&client_id=%s", - authorization_endpoint.c_str(), - url_encode(redirectURL).c_str(), - nonce.c_str(), - state_hex, + url, sizeof(authenticationURL), + "%s?response_type=id_token&response_mode=form_post&scope=openid+email+profile&redirect_uri=%s&" + "nonce=%s&state=%s&client_id=%s", + authorization_endpoint.c_str(), url_encode(redirectURL).c_str(), nonce.c_str(), state_hex, client_id.c_str()); info.authenticationURL = std::string(url); } @@ -516,18 +525,17 @@ AuthInfo CV1::getSSOAuthInfo(const nlohmann::json& member, const std::string& re #ifdef ZT_DEBUG fprintf( stderr, - "ssoClientID: %s\nissuerURL: %s\nssoNonce: %s\nssoState: %s\ncentralAuthURL: %s\nprovider: %s\n", - info.ssoClientID.c_str(), - info.issuerURL.c_str(), - info.ssoNonce.c_str(), - info.ssoState.c_str(), - info.centralAuthURL.c_str(), - provider.c_str()); + "ssoClientID: %s\nissuerURL: %s\nssoNonce: %s\nssoState: %s\ncentralAuthURL: %s\nprovider: " + "%s\n", + info.ssoClientID.c_str(), info.issuerURL.c_str(), info.ssoNonce.c_str(), info.ssoState.c_str(), + info.centralAuthURL.c_str(), provider.c_str()); #endif } } else { - fprintf(stderr, "client_id: %s\nauthorization_endpoint: %s\n", client_id.c_str(), authorization_endpoint.c_str()); + fprintf( + stderr, "client_id: %s\nauthorization_endpoint: %s\n", client_id.c_str(), + authorization_endpoint.c_str()); } } @@ -573,13 +581,18 @@ void CV1::initializeNetworks() char qbuf[2048] = { 0 }; sprintf( qbuf, - "SELECT n.id, (EXTRACT(EPOCH FROM n.creation_time AT TIME ZONE 'UTC')*1000)::bigint as creation_time, n.capabilities, " - "n.enable_broadcast, (EXTRACT(EPOCH FROM n.last_modified AT TIME ZONE 'UTC')*1000)::bigint AS last_modified, n.mtu, n.multicast_limit, n.name, n.private, n.remote_trace_level, " - "n.remote_trace_target, n.revision, n.rules, n.tags, n.v4_assign_mode, n.v6_assign_mode, n.sso_enabled, (CASE WHEN n.sso_enabled THEN noc.client_id ELSE NULL END) as client_id, " + "SELECT n.id, (EXTRACT(EPOCH FROM n.creation_time AT TIME ZONE 'UTC')*1000)::bigint as creation_time, " + "n.capabilities, " + "n.enable_broadcast, (EXTRACT(EPOCH FROM n.last_modified AT TIME ZONE 'UTC')*1000)::bigint AS " + "last_modified, n.mtu, n.multicast_limit, n.name, n.private, n.remote_trace_level, " + "n.remote_trace_target, n.revision, n.rules, n.tags, n.v4_assign_mode, n.v6_assign_mode, n.sso_enabled, " + "(CASE WHEN n.sso_enabled THEN noc.client_id ELSE NULL END) as client_id, " "(CASE WHEN n.sso_enabled THEN oc.authorization_endpoint ELSE NULL END) as authorization_endpoint, " "(CASE WHEN n.sso_enabled THEN oc.provider ELSE NULL END) as provider, d.domain, d.servers, " - "ARRAY(SELECT CONCAT(host(ip_range_start),'|', host(ip_range_end)) FROM ztc_network_assignment_pool WHERE network_id = n.id) AS assignment_pool, " - "ARRAY(SELECT CONCAT(host(address),'/',bits::text,'|',COALESCE(host(via), 'NULL'))FROM ztc_network_route WHERE network_id = n.id) AS routes " + "ARRAY(SELECT CONCAT(host(ip_range_start),'|', host(ip_range_end)) FROM ztc_network_assignment_pool WHERE " + "network_id = n.id) AS assignment_pool, " + "ARRAY(SELECT CONCAT(host(address),'/',bits::text,'|',COALESCE(host(via), 'NULL'))FROM ztc_network_route " + "WHERE network_id = n.id) AS routes " "FROM ztc_network n " "LEFT OUTER JOIN ztc_org o " " ON o.owner_id = n.owner_id " @@ -813,7 +826,9 @@ void CV1::initializeNetworks() if (++this->_ready == 2) { if (_waitNoticePrinted) { - fprintf(stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), (unsigned long long)_myAddress.toInt()); + fprintf( + stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), + (unsigned long long)_myAddress.toInt()); } _readyLock.unlock(); } @@ -899,12 +914,14 @@ void CV1::initializeMembers() " FROM ztc_sso_expiry e " " INNER JOIN ztc_network n1 " " ON n1.id = e.network_id AND n1.deleted = TRUE " - " WHERE e.network_id = m.network_id AND e.member_id = m.id AND n.sso_enabled = TRUE AND e.authentication_expiry_time IS NOT NULL " + " WHERE e.network_id = m.network_id AND e.member_id = m.id AND n.sso_enabled = TRUE AND " + "e.authentication_expiry_time IS NOT NULL " " ORDER BY e.authentication_expiry_time DESC LIMIT 1 " " ) " " ELSE NULL " " END) AS authentication_expiry_time, " - "ARRAY(SELECT DISTINCT address FROM ztc_member_ip_assignment WHERE member_id = m.id AND network_id = m.network_id) AS assigned_addresses " + "ARRAY(SELECT DISTINCT address FROM ztc_member_ip_assignment WHERE member_id = m.id AND network_id = " + "m.network_id) AS assigned_addresses " "FROM ztc_member m " "INNER JOIN ztc_network n " " ON n.id = m.network_id " @@ -1089,7 +1106,9 @@ void CV1::initializeMembers() if (++this->_ready == 2) { if (_waitNoticePrinted) { - fprintf(stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), (unsigned long long)_myAddress.toInt()); + fprintf( + stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), + (unsigned long long)_myAddress.toInt()); } _readyLock.unlock(); } @@ -1150,13 +1169,17 @@ void CV1::heartbeat() pqxx::work w { *c->c }; pqxx::result res = w.exec0( - "INSERT INTO ztc_controller (id, cluster_host, last_alive, public_identity, v_major, v_minor, v_rev, v_build, host_port, use_redis, redis_member_status) " + "INSERT INTO ztc_controller (id, cluster_host, last_alive, public_identity, v_major, v_minor, " + "v_rev, v_build, host_port, use_redis, redis_member_status) " "VALUES (" - + w.quote(controllerId) + ", " + w.quote(hostname) + ", TO_TIMESTAMP(" + now + "::double precision/1000), " + w.quote(publicIdentity) + ", " + major + ", " + minor + ", " + rev + ", " + build + ", " + host_port + ", " - + use_redis + ", " + redis_mem_status + + w.quote(controllerId) + ", " + w.quote(hostname) + ", TO_TIMESTAMP(" + now + + "::double precision/1000), " + w.quote(publicIdentity) + ", " + major + ", " + minor + ", " + rev + + ", " + build + ", " + host_port + ", " + use_redis + ", " + redis_mem_status + ") " - "ON CONFLICT (id) DO UPDATE SET cluster_host = EXCLUDED.cluster_host, last_alive = EXCLUDED.last_alive, " - "public_identity = EXCLUDED.public_identity, v_major = EXCLUDED.v_major, v_minor = EXCLUDED.v_minor, " + "ON CONFLICT (id) DO UPDATE SET cluster_host = EXCLUDED.cluster_host, last_alive = " + "EXCLUDED.last_alive, " + "public_identity = EXCLUDED.public_identity, v_major = EXCLUDED.v_major, v_minor = " + "EXCLUDED.v_minor, " "v_rev = EXCLUDED.v_rev, v_build = EXCLUDED.v_rev, host_port = EXCLUDED.host_port, " "use_redis = EXCLUDED.use_redis, redis_member_status = EXCLUDED.redis_member_status"); w.commit(); @@ -1200,7 +1223,8 @@ void CV1::membersDbWatcher() } if (_run == 1) { - fprintf(stderr, "ERROR: %s membersDbWatcher should still be running! Exiting Controller.\n", _myAddressStr.c_str()); + fprintf( + stderr, "ERROR: %s membersDbWatcher should still be running! Exiting Controller.\n", _myAddressStr.c_str()); exit(9); } fprintf(stderr, "Exited membersDbWatcher\n"); @@ -1306,7 +1330,9 @@ void CV1::networksDbWatcher() } if (_run == 1) { - fprintf(stderr, "ERROR: %s networksDbWatcher should still be running! Exiting Controller.\n", _myAddressStr.c_str()); + fprintf( + stderr, "ERROR: %s networksDbWatcher should still be running! Exiting Controller.\n", + _myAddressStr.c_str()); exit(8); } fprintf(stderr, "Exited networksDbWatcher\n"); @@ -1383,7 +1409,9 @@ void CV1::_networksWatcher_Redis() } } catch (std::exception& e) { - fprintf(stderr, "json parse error in networkWatcher_Redis: what: %s json: %s\n", e.what(), a.second.c_str()); + fprintf( + stderr, "json parse error in networkWatcher_Redis: what: %s json: %s\n", e.what(), + a.second.c_str()); } } if (_rc->clusterMode) { @@ -1468,7 +1496,8 @@ void CV1::commitThread() continue; } - pqxx::row mrow = w.exec_params1("SELECT COUNT(id) FROM ztc_member WHERE id = $1 AND network_id = $2", memberId, networkId); + pqxx::row mrow = w.exec_params1( + "SELECT COUNT(id) FROM ztc_member WHERE id = $1 AND network_id = $2", memberId, networkId); int membercount = mrow[0].as(); bool isNewMember = false; @@ -1478,27 +1507,17 @@ void CV1::commitThread() pqxx::result res = w.exec_params0( "INSERT INTO ztc_member (id, network_id, active_bridge, authorized, capabilities, " "identity, last_authorized_time, last_deauthorized_time, no_auto_assign_ips, " - "remote_trace_level, remote_trace_target, revision, tags, v_major, v_minor, v_rev, v_proto) " + "remote_trace_level, remote_trace_target, revision, tags, v_major, v_minor, v_rev, " + "v_proto) " "VALUES ($1, $2, $3, $4, $5, $6, " "TO_TIMESTAMP($7::double precision/1000), TO_TIMESTAMP($8::double precision/1000), " "$9, $10, $11, $12, $13, $14, $15, $16, $17)", - memberId, - networkId, - (bool)config["activeBridge"], - (bool)config["authorized"], - OSUtils::jsonDump(config["capabilities"], -1), - OSUtils::jsonString(config["identity"], ""), - (uint64_t)config["lastAuthorizedTime"], - (uint64_t)config["lastDeauthorizedTime"], - (bool)config["noAutoAssignIps"], - (int)config["remoteTraceLevel"], - target, - (uint64_t)config["revision"], - OSUtils::jsonDump(config["tags"], -1), - (int)config["vMajor"], - (int)config["vMinor"], - (int)config["vRev"], - (int)config["vProto"]); + memberId, networkId, (bool)config["activeBridge"], (bool)config["authorized"], + OSUtils::jsonDump(config["capabilities"], -1), OSUtils::jsonString(config["identity"], ""), + (uint64_t)config["lastAuthorizedTime"], (uint64_t)config["lastDeauthorizedTime"], + (bool)config["noAutoAssignIps"], (int)config["remoteTraceLevel"], target, + (uint64_t)config["revision"], OSUtils::jsonDump(config["tags"], -1), (int)config["vMajor"], + (int)config["vMinor"], (int)config["vRev"], (int)config["vProto"]); } else { // existing member @@ -1510,27 +1529,18 @@ void CV1::commitThread() "no_auto_assign_ips = $9, remote_trace_level = $10, remote_trace_target= $11, " "revision = $12, tags = $13, v_major = $14, v_minor = $15, v_rev = $16, v_proto = $17 " "WHERE id = $1 AND network_id = $2", - memberId, - networkId, - (bool)config["activeBridge"], - (bool)config["authorized"], - OSUtils::jsonDump(config["capabilities"], -1), - OSUtils::jsonString(config["identity"], ""), - (uint64_t)config["lastAuthorizedTime"], - (uint64_t)config["lastDeauthorizedTime"], - (bool)config["noAutoAssignIps"], - (int)config["remoteTraceLevel"], - target, - (uint64_t)config["revision"], - OSUtils::jsonDump(config["tags"], -1), - (int)config["vMajor"], - (int)config["vMinor"], - (int)config["vRev"], - (int)config["vProto"]); + memberId, networkId, (bool)config["activeBridge"], (bool)config["authorized"], + OSUtils::jsonDump(config["capabilities"], -1), OSUtils::jsonString(config["identity"], ""), + (uint64_t)config["lastAuthorizedTime"], (uint64_t)config["lastDeauthorizedTime"], + (bool)config["noAutoAssignIps"], (int)config["remoteTraceLevel"], target, + (uint64_t)config["revision"], OSUtils::jsonDump(config["tags"], -1), (int)config["vMajor"], + (int)config["vMinor"], (int)config["vRev"], (int)config["vProto"]); } if (! isNewMember) { - pqxx::result res = w.exec_params0("DELETE FROM ztc_member_ip_assignment WHERE member_id = $1 AND network_id = $2", memberId, networkId); + pqxx::result res = w.exec_params0( + "DELETE FROM ztc_member_ip_assignment WHERE member_id = $1 AND network_id = $2", memberId, + networkId); } std::vector assignments; @@ -1542,7 +1552,10 @@ void CV1::commitThread() continue; } - pqxx::result res = w.exec_params0("INSERT INTO ztc_member_ip_assignment (member_id, network_id, address) VALUES ($1, $2, $3) ON CONFLICT (network_id, member_id, address) DO NOTHING", memberId, networkId, addr); + pqxx::result res = w.exec_params0( + "INSERT INTO ztc_member_ip_assignment (member_id, network_id, address) VALUES ($1, $2, $3) " + "ON CONFLICT (network_id, member_id, address) DO NOTHING", + memberId, networkId, addr); assignments.push_back(addr); } @@ -1586,11 +1599,15 @@ void CV1::commitThread() _memberChanged(memOrig, memNew, qitem.second); } else { - fprintf(stderr, "%s: Can't notify of change. Error parsing nwid or memberid: %llu-%llu\n", _myAddressStr.c_str(), (unsigned long long)nwidInt, (unsigned long long)memberidInt); + fprintf( + stderr, "%s: Can't notify of change. Error parsing nwid or memberid: %llu-%llu\n", + _myAddressStr.c_str(), (unsigned long long)nwidInt, (unsigned long long)memberidInt); } } catch (std::exception& e) { - fprintf(stderr, "%s ERROR: Error updating member %s-%s: %s\n", _myAddressStr.c_str(), networkId.c_str(), memberId.c_str(), e.what()); + fprintf( + stderr, "%s ERROR: Error updating member %s-%s: %s\n", _myAddressStr.c_str(), networkId.c_str(), + memberId.c_str(), e.what()); mspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); } } @@ -1619,12 +1636,14 @@ void CV1::commitThread() // did not previously exist. If the record already exists owner_id is left // unchanged, so owner_id should be left out of the update clause. pqxx::result res = w.exec_params0( - "INSERT INTO ztc_network (id, creation_time, owner_id, controller_id, capabilities, enable_broadcast, " + "INSERT INTO ztc_network (id, creation_time, owner_id, controller_id, capabilities, " + "enable_broadcast, " "last_modified, mtu, multicast_limit, name, private, " "remote_trace_level, remote_trace_target, rules, rules_source, " "tags, v4_assign_mode, v6_assign_mode, sso_enabled) VALUES (" "$1, TO_TIMESTAMP($5::double precision/1000), " - "(SELECT user_id AS owner_id FROM ztc_global_permissions WHERE authorize = true AND del = true AND modify = true AND read = true LIMIT 1)," + "(SELECT user_id AS owner_id FROM ztc_global_permissions WHERE authorize = true AND del = true " + "AND modify = true AND read = true LIMIT 1)," "$2, $3, $4, TO_TIMESTAMP($5::double precision/1000), " "$6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17) " "ON CONFLICT (id) DO UPDATE set controller_id = EXCLUDED.controller_id, " @@ -1636,25 +1655,15 @@ void CV1::commitThread() "rules_source = EXCLUDED.rules_source, tags = EXCLUDED.tags, " "v4_assign_mode = EXCLUDED.v4_assign_mode, v6_assign_mode = EXCLUDED.v6_assign_mode, " "sso_enabled = EXCLUDED.sso_enabled", - id, - _myAddressStr, - OSUtils::jsonDump(config["capabilities"], -1), - (bool)config["enableBroadcast"], - OSUtils::now(), - (int)config["mtu"], - (int)config["multicastLimit"], - OSUtils::jsonString(config["name"], ""), - (bool)config["private"], - (int)config["remoteTraceLevel"], - remoteTraceTarget, - OSUtils::jsonDump(config["rules"], -1), - rulesSource, - OSUtils::jsonDump(config["tags"], -1), - OSUtils::jsonDump(config["v4AssignMode"], -1), - OSUtils::jsonDump(config["v6AssignMode"], -1), + id, _myAddressStr, OSUtils::jsonDump(config["capabilities"], -1), + (bool)config["enableBroadcast"], OSUtils::now(), (int)config["mtu"], + (int)config["multicastLimit"], OSUtils::jsonString(config["name"], ""), (bool)config["private"], + (int)config["remoteTraceLevel"], remoteTraceTarget, OSUtils::jsonDump(config["rules"], -1), + rulesSource, OSUtils::jsonDump(config["tags"], -1), + OSUtils::jsonDump(config["v4AssignMode"], -1), OSUtils::jsonDump(config["v6AssignMode"], -1), OSUtils::jsonBool(config["ssoEnabled"], false)); - res = w.exec_params0("DELETE FROM ztc_network_assignment_pool WHERE network_id = $1", 0); + res = w.exec_params0("DELETE FROM ztc_network_assignment_pool WHERE network_id = $1", id); auto pool = config["ipAssignmentPools"]; bool err = false; @@ -1665,9 +1674,7 @@ void CV1::commitThread() res = w.exec_params0( "INSERT INTO ztc_network_assignment_pool (network_id, ip_range_start, ip_range_end) " "VALUES ($1, $2, $3)", - id, - start, - end); + id, start, end); } res = w.exec_params0("DELETE FROM ztc_network_route WHERE network_id = $1", id); @@ -1692,7 +1699,9 @@ void CV1::commitThread() via = (*i)["via"]; } - res = w.exec_params0("INSERT INTO ztc_network_route (network_id, address, bits, via) VALUES ($1, $2, $3, $4)", id, targetAddr, targetBits, (via == "NULL" ? NULL : via.c_str())); + res = w.exec_params0( + "INSERT INTO ztc_network_route (network_id, address, bits, via) VALUES ($1, $2, $3, $4)", + id, targetAddr, targetBits, (via == "NULL" ? NULL : via.c_str())); } if (err) { fprintf(stderr, "%s: route add error\n", _myAddressStr.c_str()); @@ -1715,7 +1724,10 @@ void CV1::commitThread() std::string s = servers.str(); - res = w.exec_params0("INSERT INTO ztc_network_dns (network_id, domain, servers) VALUES ($1, $2, $3) ON CONFLICT (network_id) DO UPDATE SET domain = EXCLUDED.domain, servers = EXCLUDED.servers", id, domain, s); + res = w.exec_params0( + "INSERT INTO ztc_network_dns (network_id, domain, servers) VALUES ($1, $2, $3) ON CONFLICT " + "(network_id) DO UPDATE SET domain = EXCLUDED.domain, servers = EXCLUDED.servers", + id, domain, s); w.commit(); @@ -1729,7 +1741,9 @@ void CV1::commitThread() _networkChanged(nwOrig, nwNew, qitem.second); } else { - fprintf(stderr, "%s: Can't notify network changed: %llu\n", _myAddressStr.c_str(), (unsigned long long)nwidInt); + fprintf( + stderr, "%s: Can't notify network changed: %llu\n", _myAddressStr.c_str(), + (unsigned long long)nwidInt); } } catch (std::exception& e) { @@ -1803,7 +1817,9 @@ void CV1::commitThread() std::string memberId = config["id"]; std::string networkId = config["nwid"]; - pqxx::result res = w.exec_params0("UPDATE ztc_member SET hidden = true, deleted = true WHERE id = $1 AND network_id = $2", memberId, networkId); + pqxx::result res = w.exec_params0( + "UPDATE ztc_member SET hidden = true, deleted = true WHERE id = $1 AND network_id = $2", + memberId, networkId); w.commit(); } @@ -1927,7 +1943,8 @@ void CV1::onlineNotification_Postgres() std::string memberId(memTmp); try { - pqxx::row r = w2.exec_params1("SELECT id, network_id FROM ztc_member WHERE network_id = $1 AND id = $2", networkId, memberId); + pqxx::row r = w2.exec_params1( + "SELECT id, network_id FROM ztc_member WHERE network_id = $1 AND id = $2", networkId, memberId); } catch (pqxx::unexpected_rows& e) { continue; @@ -1946,8 +1963,9 @@ void CV1::onlineNotification_Postgres() } std::stringstream memberUpdate; - memberUpdate << "INSERT INTO ztc_member_status (network_id, member_id, address, last_updated, os, arch) VALUES " - << "('" << networkId << "', '" << memberId << "', "; + memberUpdate + << "INSERT INTO ztc_member_status (network_id, member_id, address, last_updated, os, arch) VALUES " + << "('" << networkId << "', '" << memberId << "', "; if (ipAddr.empty()) { memberUpdate << "NULL, "; } @@ -1958,7 +1976,8 @@ void CV1::onlineNotification_Postgres() << "'" << os << "', " << "'" << arch << "'" << ") " - << " ON CONFLICT (network_id, member_id) DO UPDATE SET address = EXCLUDED.address, last_updated = EXCLUDED.last_updated, " + << " ON CONFLICT (network_id, member_id) DO UPDATE SET address = EXCLUDED.address, " + "last_updated = EXCLUDED.last_updated, " << "os = EXCLUDED.os, arch = EXCLUDED.arch"; pipe.insert(memberUpdate.str()); @@ -1980,7 +1999,9 @@ void CV1::onlineNotification_Postgres() _pool->unborrow(c); ConnectionPoolStats stats = _pool->get_stats(); - fprintf(stderr, "%s pool stats: in use size: %llu, available size: %llu, total: %llu\n", _myAddressStr.c_str(), stats.borrowed_size, stats.pool_size, (stats.borrowed_size + stats.pool_size)); + fprintf( + stderr, "%s pool stats: in use size: %llu, available size: %llu, total: %llu\n", _myAddressStr.c_str(), + stats.borrowed_size, stats.pool_size, (stats.borrowed_size + stats.pool_size)); span->End(); @@ -1988,7 +2009,9 @@ void CV1::onlineNotification_Postgres() } fprintf(stderr, "%s: Fell out of run loop in onlineNotificationThread\n", _myAddressStr.c_str()); if (_run == 1) { - fprintf(stderr, "ERROR: %s onlineNotificationThread should still be running! Exiting Controller.\n", _myAddressStr.c_str()); + fprintf( + stderr, "ERROR: %s onlineNotificationThread should still be running! Exiting Controller.\n", + _myAddressStr.c_str()); exit(6); } } @@ -2042,7 +2065,10 @@ void CV1::onlineNotification_Redis() } } -uint64_t CV1::_doRedisUpdate(sw::redis::Transaction& tx, std::string& controllerId, std::unordered_map, NodeOnlineRecord, _PairHasher>& lastOnline) +uint64_t CV1::_doRedisUpdate( + sw::redis::Transaction& tx, + std::string& controllerId, + std::unordered_map, NodeOnlineRecord, _PairHasher>& lastOnline) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("cv1"); @@ -2079,7 +2105,11 @@ uint64_t CV1::_doRedisUpdate(sw::redis::Transaction& tx, std::string& controller arch = osArchSplit[1]; } - std::unordered_map record = { { "id", memberId }, { "address", ipAddr }, { "last_updated", std::to_string(ts) }, { "os", os }, { "arch", arch } }; + std::unordered_map record = { { "id", memberId }, + { "address", ipAddr }, + { "last_updated", std::to_string(ts) }, + { "os", os }, + { "arch", arch } }; tx.zadd("nodes-online:{" + controllerId + "}", memberId, ts) .zadd("nodes-online2:{" + controllerId + "}", networkId + "-" + memberId, ts) .zadd("network-nodes-online:{" + controllerId + "}:" + networkId, memberId, ts) @@ -2093,16 +2123,24 @@ uint64_t CV1::_doRedisUpdate(sw::redis::Transaction& tx, std::string& controller // expire records from all-nodes and network-nodes member list uint64_t expireOld = OSUtils::now() - 300000; - tx.zremrangebyscore("nodes-online:{" + controllerId + "}", sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); - tx.zremrangebyscore("nodes-online2:{" + controllerId + "}", sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); - tx.zremrangebyscore("active-networks:{" + controllerId + "}", sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); + tx.zremrangebyscore( + "nodes-online:{" + controllerId + "}", + sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); + tx.zremrangebyscore( + "nodes-online2:{" + controllerId + "}", + sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); + tx.zremrangebyscore( + "active-networks:{" + controllerId + "}", + sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); { std::shared_lock l(_networks_l); for (const auto& it : _networks) { uint64_t nwid_i = it.first; char nwidTmp[64]; OSUtils::ztsnprintf(nwidTmp, sizeof(nwidTmp), "%.16llx", nwid_i); - tx.zremrangebyscore("network-nodes-online:{" + controllerId + "}:" + nwidTmp, sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); + tx.zremrangebyscore( + "network-nodes-online:{" + controllerId + "}:" + nwidTmp, + sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); } } tx.exec(); diff --git a/controller/CentralDB.cpp b/controller/CentralDB.cpp index 1b1e4d554b..80cfa69828 100644 --- a/controller/CentralDB.cpp +++ b/controller/CentralDB.cpp @@ -184,9 +184,9 @@ CentralDB::CentralDB( case LISTENER_MODE_PUBSUB: if (cc->pubSubConfig != NULL) { _membersDbWatcher = - std::make_shared(_myAddressStr, cc->pubSubConfig->listen_timeout, this); + std::make_shared(_myAddressStr, cc->pubSubConfig->project, this); _networksDbWatcher = - std::make_shared(_myAddressStr, cc->pubSubConfig->listen_timeout, this); + std::make_shared(_myAddressStr, cc->pubSubConfig->project, this); } else { throw std::runtime_error( @@ -1250,7 +1250,6 @@ void CentralDB::commitThread() std::string id = config["id"]; - // network must already exist pqxx::result res = w.exec_params0( "INSERT INTO networks_ctl (id, name, configuration, controller_id, revision) " "VALUES ($1, $2, $3, $4, $5) " @@ -1261,19 +1260,19 @@ void CentralDB::commitThread() w.commit(); - res = w.exec_params0("DELETE FROM ztc_network_assignment_pool WHERE network_id = $1", 0); + // res = w.exec_params0("DELETE FROM ztc_network_assignment_pool WHERE network_id = $1", 0); - auto pool = config["ipAssignmentPools"]; - bool err = false; - for (auto i = pool.begin(); i != pool.end(); ++i) { - std::string start = (*i)["ipRangeStart"]; - std::string end = (*i)["ipRangeEnd"]; + // auto pool = config["ipAssignmentPools"]; + // bool err = false; + // for (auto i = pool.begin(); i != pool.end(); ++i) { + // std::string start = (*i)["ipRangeStart"]; + // std::string end = (*i)["ipRangeEnd"]; - res = w.exec_params0( - "INSERT INTO ztc_network_assignment_pool (network_id, ip_range_start, ip_range_end) " - "VALUES ($1, $2, $3)", - id, start, end); - } + // res = w.exec_params0( + // "INSERT INTO ztc_network_assignment_pool (network_id, ip_range_start, ip_range_end) " + // "VALUES ($1, $2, $3)", + // id, start, end); + // } const uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); if (nwidInt) { diff --git a/controller/PubSubListener.cpp b/controller/PubSubListener.cpp index a533431806..36eb2b14f5 100644 --- a/controller/PubSubListener.cpp +++ b/controller/PubSubListener.cpp @@ -2,68 +2,129 @@ #include "PubSubListener.hpp" #include "DB.hpp" +#include "member.pb.h" +#include "network.pb.h" #include "opentelemetry/trace/provider.h" #include "rustybits.h" +#include +#include +#include +#include +#include +#include #include +namespace pubsub = ::google::cloud::pubsub; +namespace pubsub_admin = ::google::cloud::pubsub_admin; + namespace ZeroTier { -void listener_callback(void* user_ptr, const uint8_t* payload, uintptr_t length) +nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc); +nlohmann::json toJson(const pbmessages::MemberChange_Member& mc); + +PubSubListener::PubSubListener(std::string controller_id, std::string project, std::string topic) + : _controller_id(controller_id) + , _project(project) + , _topic(topic) + , _subscription_id("sub-" + controller_id + "-network-changes") + , _run(false) + , _adminClient(pubsub_admin::MakeSubscriptionAdminConnection()) + , _subscription(pubsub::Subscription(_project, _subscription_id)) { - if (! user_ptr || ! payload || length == 0) { - fprintf(stderr, "Invalid parameters in listener_callback\n"); - return; + GOOGLE_PROTOBUF_VERIFY_VERSION; + + google::pubsub::v1::Subscription request; + request.set_name(_subscription.FullName()); + request.set_topic(pubsub::Topic(project, topic).FullName()); + request.set_filter("(attributes.controller_id=\"" + _controller_id + "\")"); + auto sub = _adminClient.CreateSubscription(request); + if (! sub.ok()) { + fprintf(stderr, "Failed to create subscription: %s\n", sub.status().message().c_str()); + throw std::runtime_error("Failed to create subscription"); } - auto* listener = static_cast(user_ptr); - std::string payload_str(reinterpret_cast(payload), length); - listener->onNotification(payload_str); -} + if (sub.status().code() == google::cloud::StatusCode::kAlreadyExists) { + fprintf(stderr, "Subscription already exists\n"); + throw std::runtime_error("Subscription already exists"); + } -PubSubNetworkListener::PubSubNetworkListener(std::string controller_id, uint64_t listen_timeout, DB* db) : _run(true), _controller_id(controller_id), _db(db), _listener(nullptr) -{ - _listener = rustybits::network_listener_new(_controller_id.c_str(), listen_timeout, listener_callback, this); - _listenThread = std::thread(&PubSubNetworkListener::listenThread, this); - _changeHandlerThread = std::thread(&PubSubNetworkListener::changeHandlerThread, this); + _subscriber = std::make_shared(pubsub::MakeSubscriberConnection(_subscription)); + + _run = true; + _subscriberThread = std::thread(&PubSubListener::subscribe, this); } -PubSubNetworkListener::~PubSubNetworkListener() +PubSubListener::~PubSubListener() { _run = false; - if (_listenThread.joinable()) { - _listenThread.join(); + _session.cancel(); + if (_subscriberThread.joinable()) { + _subscriberThread.join(); } +} + +void PubSubListener::subscribe() +{ + while (_run) { + _session = _subscriber->Subscribe([this](pubsub::Message const& m, pubsub::AckHandler h) { + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("PubSubListener"); + auto span = tracer->StartSpan("PubSubListener::onMessage"); + auto scope = tracer->WithActiveSpan(span); + span->SetAttribute("message_id", m.message_id()); + span->SetAttribute("ordering_key", m.ordering_key()); + span->SetAttribute("attributes", m.attributes().size()); - if (_listener) { - rustybits::network_listener_delete(_listener); - _listener = nullptr; + fprintf(stderr, "Received message %s\n", m.message_id().c_str()); + onNotification(m.data()); + std::move(h).ack(); + span->SetStatus(opentelemetry::trace::StatusCode::kOk); + return true; + }); + auto status = _session.get(); + if (! status.ok() && _run) { + fprintf(stderr, "Error during Subscribe: %s\n", status.message().c_str()); + } } } +PubSubNetworkListener::PubSubNetworkListener(std::string controller_id, std::string project, DB* db) + : PubSubListener(controller_id, project, "controller-network-change-stream") + , _db(db) +{ +} + +PubSubNetworkListener::~PubSubNetworkListener() +{ +} + void PubSubNetworkListener::onNotification(const std::string& payload) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("PubSubNetworkListener"); auto span = tracer->StartSpan("PubSubNetworkListener::onNotification"); auto scope = tracer->WithActiveSpan(span); - span->SetAttribute("payload", payload); - fprintf(stderr, "Network notification received: %s\n", payload.c_str()); + pbmessages::NetworkChange nc; + if (! nc.ParseFromString(payload)) { + fprintf(stderr, "Failed to parse NetworkChange protobuf message\n"); + span->SetAttribute("error", "Failed to parse NetworkChange protobuf message"); + span->SetStatus(opentelemetry::trace::StatusCode::kError, "Failed to parse protobuf"); + return; + } + + fprintf(stderr, "Network notification received"); try { - nlohmann::json j = nlohmann::json::parse(payload); - nlohmann::json& ov_tmp = j["old"]; - nlohmann::json& nv_tmp = j["new"]; nlohmann::json oldConfig, newConfig; - if (ov_tmp.is_object()) { - // TODO: copy old configuration to oldConfig - // changing key names along the way + if (nc.has_old()) { + oldConfig = toJson(nc.old()); } - if (nv_tmp.is_object()) { - // TODO: copy new configuration to newConfig - // changing key names along the way + + if (nc.has_new_()) { + newConfig = toJson(nc.new_()); } if (oldConfig.is_object() && newConfig.is_object()) { @@ -106,41 +167,14 @@ void PubSubNetworkListener::onNotification(const std::string& payload) } } -void PubSubNetworkListener::listenThread() -{ - if (_listener) { - while (_run) { - rustybits::network_listener_listen(_listener); - } - } -} - -void PubSubNetworkListener::changeHandlerThread() +PubSubMemberListener::PubSubMemberListener(std::string controller_id, std::string project, DB* db) + : PubSubListener(controller_id, project, "controller-member-change-stream") + , _db(db) { - if (_listener) { - rustybits::network_listener_change_handler(_listener); - } -} - -PubSubMemberListener::PubSubMemberListener(std::string controller_id, uint64_t listen_timeout, DB* db) : _run(true), _controller_id(controller_id), _db(db), _listener(nullptr) -{ - _run = true; - _listener = rustybits::member_listener_new(_controller_id.c_str(), listen_timeout, listener_callback, this); - _listenThread = std::thread(&PubSubMemberListener::listenThread, this); - _changeHandlerThread = std::thread(&PubSubMemberListener::changeHandlerThread, this); } PubSubMemberListener::~PubSubMemberListener() { - _run = false; - if (_listenThread.joinable()) { - _listenThread.join(); - } - - if (_listener) { - rustybits::member_listener_delete(_listener); - _listener = nullptr; - } } void PubSubMemberListener::onNotification(const std::string& payload) @@ -149,22 +183,27 @@ void PubSubMemberListener::onNotification(const std::string& payload) auto tracer = provider->GetTracer("PubSubMemberListener"); auto span = tracer->StartSpan("PubSubMemberListener::onNotification"); auto scope = tracer->WithActiveSpan(span); - span->SetAttribute("payload", payload); - fprintf(stderr, "Member notification received: %s\n", payload.c_str()); + pbmessages::MemberChange mc; + if (! mc.ParseFromString(payload)) { + fprintf(stderr, "Failed to parse MemberChange protobuf message\n"); + span->SetAttribute("error", "Failed to parse MemberChange protobuf message"); + span->SetStatus(opentelemetry::trace::StatusCode::kError, "Failed to parse protobuf"); + return; + } + + fprintf(stderr, "Member notification received"); try { nlohmann::json tmp; - nlohmann::json old_tmp = tmp["old"]; - nlohmann::json new_tmp = tmp["new"]; nlohmann::json oldConfig, newConfig; - if (old_tmp.is_object()) { - // TODO: copy old configuration to oldConfig + if (mc.has_old()) { + oldConfig = toJson(mc.old()); } - if (new_tmp.is_object()) { - // TODO: copy new configuration to newConfig + if (mc.has_new_()) { + newConfig = toJson(mc.new_()); } if (oldConfig.is_object() && newConfig.is_object()) { @@ -214,20 +253,143 @@ void PubSubMemberListener::onNotification(const std::string& payload) } } -void PubSubMemberListener::listenThread() +nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc) { - if (_listener) { - while (_run) { - rustybits::member_listener_listen(_listener); + nlohmann::json out; + + out["id"] = nc.network_id(); + out["name"] = nc.name(); + out["capabilities"] = OSUtils::jsonParse(nc.capabilities()); + out["mtu"] = nc.mtu(); + out["multicastLimit"] = nc.multicast_limit(); + out["private"] = nc.is_private(); + out["remoteTraceLevel"] = nc.remote_trace_level(); + if (nc.has_remote_trace_target()) { + out["remoteTraceTarget"] = nc.remote_trace_target(); + } + else { + out["remoteTraceTarget"] = ""; + } + out["rules"] = OSUtils::jsonParse(nc.rules()); + out["rulesSource"] = nc.rules_source(); + out["tags"] = OSUtils::jsonParse(nc.tags()); + + if (nc.has_ipv4_assign_mode()) { + nlohmann::json ipv4mode; + ipv4mode["zt"] = nc.ipv4_assign_mode().zt(); + out["ipv4AssignMode"] = ipv4mode; + } + if (nc.has_ipv6_assign_mode()) { + nlohmann::json ipv6mode; + ipv6mode["6plane"] = nc.ipv6_assign_mode().six_plane(); + ipv6mode["rfc4193"] = nc.ipv6_assign_mode().rfc4193(); + ipv6mode["zt"] = nc.ipv6_assign_mode().zt(); + out["ipv6AssignMode"] = ipv6mode; + } + + if (nc.assignment_pools_size() > 0) { + nlohmann::json pools = nlohmann::json::array(); + for (const auto& p : nc.assignment_pools()) { + nlohmann::json pool; + pool["ipRangeStart"] = p.start_ip(); + pool["ipRangeEnd"] = p.end_ip(); + pools.push_back(pool); } + out["assignmentPools"] = pools; } + + if (nc.routes_size() > 0) { + nlohmann::json routes = nlohmann::json::array(); + for (const auto& r : nc.routes()) { + nlohmann::json route; + route["target"] = r.target(); + if (r.has_via()) { + route["via"] = r.via(); + } + routes.push_back(route); + } + out["routes"] = routes; + } + + if (nc.has_dns()) { + nlohmann::json dns; + if (nc.dns().nameservers_size() > 0) { + nlohmann::json servers = nlohmann::json::array(); + for (const auto& s : nc.dns().nameservers()) { + servers.push_back(s); + } + dns["servers"] = servers; + } + dns["domain"] = nc.dns().domain(); + + out["dns"] = dns; + } + + out["ssoEnabled"] = nc.sso_enabled(); + nlohmann::json sso; + if (nc.sso_enabled()) { + sso = nlohmann::json::object(); + if (nc.has_sso_client_id()) { + sso["ssoClientId"] = nc.sso_client_id(); + } + + if (nc.has_sso_authorization_endpoint()) { + sso["ssoAuthorizationEndpoint"] = nc.sso_authorization_endpoint(); + } + + if (nc.has_sso_issuer()) { + sso["ssoIssuer"] = nc.sso_issuer(); + } + + if (nc.has_sso_provider()) { + sso["ssoProvider"] = nc.sso_provider(); + } + } + out["ssoConfig"] = sso; + + return out; } -void PubSubMemberListener::changeHandlerThread() +nlohmann::json toJson(const pbmessages::MemberChange_Member& mc) { - if (_listener) { - rustybits::member_listener_change_handler(_listener); + nlohmann::json out; + out["id"] = mc.device_id(); + out["nwid"] = mc.network_id(); + if (mc.has_remote_trace_target()) { + out["remoteTraceTarget"] = mc.remote_trace_target(); } + else { + out["remoteTraceTarget"] = ""; + } + out["authorized"] = mc.authorized(); + out["activeBridge"] = mc.active_bridge(); + + auto ipAssignments = mc.ip_assignments(); + if (ipAssignments.size() > 0) { + nlohmann::json assignments = nlohmann::json::array(); + for (const auto& ip : ipAssignments) { + assignments.push_back(ip); + } + out["ipAssignments"] = assignments; + } + + out["noAutoAssignIps"] = mc.no_auto_assign_ips(); + out["ssoExempt"] = mc.sso_exepmt(); + out["authenticationExpiryTime"] = mc.auth_expiry_time(); + out["capabilities"] = OSUtils::jsonParse(mc.capabilities()); + out["creationTime"] = mc.creation_time(); + out["identity"] = mc.identity(); + out["lastAuthorizedTime"] = mc.last_authorized_time(); + out["lastDeauthorizedTime"] = mc.last_deauthorized_time(); + out["remoteTraceLevel"] = mc.remote_trace_level(); + out["revision"] = mc.revision(); + out["tags"] = OSUtils::jsonParse(mc.tags()); + out["versionMajor"] = mc.version_major(); + out["versionMinor"] = mc.version_minor(); + out["versionRev"] = mc.version_rev(); + out["versionProtocol"] = mc.version_protocol(); + + return out; } } // namespace ZeroTier diff --git a/controller/PubSubListener.hpp b/controller/PubSubListener.hpp index 93b9e36d80..10d78ea94a 100644 --- a/controller/PubSubListener.hpp +++ b/controller/PubSubListener.hpp @@ -6,6 +6,8 @@ #include "NotificationListener.hpp" #include "rustybits.h" +#include +#include #include #include #include @@ -15,6 +17,8 @@ class DB; struct PubSubConfig { const char* controller_id; + std::string project; + std::string topic; uint64_t listen_timeout; }; @@ -23,11 +27,25 @@ struct PubSubConfig { */ class PubSubListener : public NotificationListener { public: - virtual ~PubSubListener() - { - } + PubSubListener(std::string controller_id, std::string project, std::string topic); + virtual ~PubSubListener(); virtual void onNotification(const std::string& payload) = 0; + + protected: + std::string _controller_id; + std::string _project; + std::string _topic; + std::string _subscription_id; + + private: + void subscribe(); + bool _run = false; + google::cloud::pubsub_admin::SubscriptionAdminClient _adminClient; + google::cloud::pubsub::Subscription _subscription; + std::shared_ptr _subscriber; + google::cloud::future _session; + std::thread _subscriberThread; }; /** @@ -35,21 +53,13 @@ class PubSubListener : public NotificationListener { */ class PubSubNetworkListener : public PubSubListener { public: - PubSubNetworkListener(std::string controller_id, uint64_t listen_timeout, DB* db); + PubSubNetworkListener(std::string controller_id, std::string project, DB* db); virtual ~PubSubNetworkListener(); virtual void onNotification(const std::string& payload) override; private: - void listenThread(); - void changeHandlerThread(); - - bool _run = false; - std::string _controller_id; DB* _db; - const rustybits::NetworkListener* _listener; - std::thread _listenThread; - std::thread _changeHandlerThread; }; /** @@ -57,21 +67,13 @@ class PubSubNetworkListener : public PubSubListener { */ class PubSubMemberListener : public PubSubListener { public: - PubSubMemberListener(std::string controller_id, uint64_t listen_timeout, DB* db); + PubSubMemberListener(std::string controller_id, std::string project, DB* db); virtual ~PubSubMemberListener(); virtual void onNotification(const std::string& payload) override; private: - void listenThread(); - void changeHandlerThread(); - - bool _run = false; - std::string _controller_id; DB* _db; - const rustybits::MemberListener* _listener; - std::thread _listenThread; - std::thread _changeHandlerThread; }; } // namespace ZeroTier diff --git a/controller/protobuf/member.proto b/controller/protobuf/member.proto new file mode 100644 index 0000000000..511f1a8d7f --- /dev/null +++ b/controller/protobuf/member.proto @@ -0,0 +1,39 @@ +syntax = "proto3"; + +package pbmessages; + +message MemberChange { + message Member { + string device_id = 1; + string network_id = 2; + string identity = 3; // Identity of the member + bool authorized = 4; // Whether the member is authorized + repeated string ip_assignments = 5; // List of IP assignments + bool active_bridge = 6; // Whether the member is an active bridge + string tags = 7; // JSON string of tags + string capabilities = 8; // JSON string of capabilities + uint64 creation_time = 9; // Unix timestamp in milliseconds + bool no_auto_assign_ips = 10; // Whether auto IP assignment is disabled + uint64 revision = 11; // Revision number + uint64 last_authorized_time = 12; // Last time the member was authorized + uint64 last_deauthorized_time = 13; // Last time the member was deauthorized + optional string last_authorized_credential_type = 14; // Type of credential used for last authorization + optional string last_authorized_credential = 15; // Credential used for last authorization + int32 version_major = 16; // Major version of the member + int32 version_minor = 17; // Minor version of the member + int32 version_rev = 18; // Patch version of the member + int32 version_protocol = 19; // Protocol version of the member + int32 remote_trace_level = 20; // Remote trace level + optional string remote_trace_target = 21; // Remote trace target + bool sso_exepmt = 22; // Whether SSO is exempt + uint64 auth_expiry_time = 23; // Authorization expiry time in milliseconds + } + message MemberChangeMetadata { + string trace_id = 1; + string controller_id = 2; + } + + optional Member old = 1; + optional Member new = 2; + optional MemberChangeMetadata metadata = 3; +} diff --git a/controller/protobuf/member_status.proto b/controller/protobuf/member_status.proto new file mode 100644 index 0000000000..2483905176 --- /dev/null +++ b/controller/protobuf/member_status.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +package pbmessages; + + + +message MemberStatus { + message MemberStatusMetadata { + string trace_id = 1; + string controller_id = 2; + } + + MemberStatusMetadata metadata = 1; + string network_id = 2; + string member_id = 3; + uint64 timestamp = 4; // Unix timestamp in milliseconds + optional string ip_address = 5; // Optional IP address of the member + optional string os = 6; + optional string arch = 7; + optional string version = 8; +} diff --git a/controller/protobuf/network.proto b/controller/protobuf/network.proto new file mode 100644 index 0000000000..c2b6868f78 --- /dev/null +++ b/controller/protobuf/network.proto @@ -0,0 +1,66 @@ +syntax = "proto3"; + +package pbmessages; + +message NetworkChange { + message NetworkChangeMetadata { + string trace_id = 1; + string controller_id = 2; + } + + message IPRange { + string start_ip = 1; // Start of the IP range + string end_ip = 2; // End of the IP range + } + + message Route { + string target = 1; // Target IP or network + optional string via = 2; // Optional next hop IP + } + + message DNS { + string domain = 1; // Search domain + repeated string nameservers = 2; // List of nameservers + } + + message IPV4AssignMode { + bool zt = 1; // Whether ZeroTier is used for IPv4 assignment + } + + message IPv6AssignMode { + bool six_plane = 1; // Whether 6plane is used for IPv6 assignment + bool rfc4193 = 2; // Whether RFC 4193 is used for IPv6 assignment + bool zt = 3; // Whether ZeroTier is used for IPv6 assignment + } + + message Network { + string network_id = 1; + string capabilities = 2; // JSON string of capabilities + uint64 creation_time = 3; // Unix timestamp in milliseconds + bool enable_broadcast = 4; // Whether broadcast is enabled + repeated IPRange assignment_pools = 5; // List of IP ranges for assignment + uint32 mtu = 6; // Maximum Transmission Unit + uint32 multicast_limit = 7; // Limit for multicast messages + optional string name = 8; // Name of the network + bool is_private = 9; // Whether the network is private + uint32 remote_trace_level = 10; // Remote trace level + optional string remote_trace_target = 11; // Remote trace target + uint64 revision = 12; // Revision number + repeated Route routes = 13; // List of routes + string rules = 14; // JSON string of rules + optional string tags = 15; // JSON string of tags + IPV4AssignMode ipv4_assign_mode = 16; // IPv4 assignment mode + IPv6AssignMode ipv6_assign_mode = 17; // IPv6 assignment mode + optional DNS dns = 18; // DNS configuration + bool sso_enabled = 19; // Whether Single Sign-On is enabled + optional string sso_client_id = 20; // SSO client ID + optional string sso_authorization_endpoint = 21; // SSO authorization endpoint + optional string sso_issuer = 22; // SSO issuer + optional string sso_provider = 23; // SSO provider + string rules_source = 24; // source code for rules + } + + optional Network old = 1; + optional Network new = 2; + optional NetworkChangeMetadata metadata = 3; +} From db6e698245247d8ce0c6dd4e79c664f90aa8e22a Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 1 Sep 2025 14:40:18 -0700 Subject: [PATCH 031/245] rework the pubsub listener again so the subscription is set up on its own thread --- controller/PubSubListener.cpp | 53 ++++++++++++++++++++++------------- controller/PubSubListener.hpp | 1 - 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/controller/PubSubListener.cpp b/controller/PubSubListener.cpp index 36eb2b14f5..72905a77aa 100644 --- a/controller/PubSubListener.cpp +++ b/controller/PubSubListener.cpp @@ -58,7 +58,6 @@ PubSubListener::PubSubListener(std::string controller_id, std::string project, s PubSubListener::~PubSubListener() { _run = false; - _session.cancel(); if (_subscriberThread.joinable()) { _subscriberThread.join(); } @@ -67,24 +66,40 @@ PubSubListener::~PubSubListener() void PubSubListener::subscribe() { while (_run) { - _session = _subscriber->Subscribe([this](pubsub::Message const& m, pubsub::AckHandler h) { - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("PubSubListener"); - auto span = tracer->StartSpan("PubSubListener::onMessage"); - auto scope = tracer->WithActiveSpan(span); - span->SetAttribute("message_id", m.message_id()); - span->SetAttribute("ordering_key", m.ordering_key()); - span->SetAttribute("attributes", m.attributes().size()); - - fprintf(stderr, "Received message %s\n", m.message_id().c_str()); - onNotification(m.data()); - std::move(h).ack(); - span->SetStatus(opentelemetry::trace::StatusCode::kOk); - return true; - }); - auto status = _session.get(); - if (! status.ok() && _run) { - fprintf(stderr, "Error during Subscribe: %s\n", status.message().c_str()); + try { + fprintf(stderr, "Starting new subscription session\n"); + auto session = _subscriber->Subscribe([this](pubsub::Message const& m, pubsub::AckHandler h) { + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("PubSubListener"); + auto span = tracer->StartSpan("PubSubListener::onMessage"); + auto scope = tracer->WithActiveSpan(span); + span->SetAttribute("message_id", m.message_id()); + span->SetAttribute("ordering_key", m.ordering_key()); + span->SetAttribute("attributes", m.attributes().size()); + + fprintf(stderr, "Received message %s\n", m.message_id().c_str()); + onNotification(m.data()); + std::move(h).ack(); + span->SetStatus(opentelemetry::trace::StatusCode::kOk); + return true; + }); + + auto result = session.wait_for(std::chrono::seconds(10)); + if (result == std::future_status::timeout) { + session.cancel(); + std::this_thread::sleep_for(std::chrono::seconds(5)); + continue; + } + + if (! session.valid()) { + fprintf(stderr, "Subscription session no longer valid\n"); + std::this_thread::sleep_for(std::chrono::seconds(5)); + continue; + } + } + catch (google::cloud::Status const& status) { + fprintf(stderr, "Subscription terminated with status: %s\n", status.message().c_str()); + std::this_thread::sleep_for(std::chrono::seconds(5)); } } } diff --git a/controller/PubSubListener.hpp b/controller/PubSubListener.hpp index 10d78ea94a..b8f08aeaeb 100644 --- a/controller/PubSubListener.hpp +++ b/controller/PubSubListener.hpp @@ -44,7 +44,6 @@ class PubSubListener : public NotificationListener { google::cloud::pubsub_admin::SubscriptionAdminClient _adminClient; google::cloud::pubsub::Subscription _subscription; std::shared_ptr _subscriber; - google::cloud::future _session; std::thread _subscriberThread; }; From 0f6378359277cd92a7fdf080b2a7b9406ec7c973 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 1 Sep 2025 14:55:16 -0700 Subject: [PATCH 032/245] remove rust-based pubsub --- rustybits/Cargo.lock | 359 +---------------------- rustybits/Cargo.toml | 12 +- rustybits/build.rs | 17 -- rustybits/src/ext.rs | 189 +----------- rustybits/src/lib.rs | 2 - rustybits/src/pubsub/change_listener.rs | 144 --------- rustybits/src/pubsub/member.proto | 39 --- rustybits/src/pubsub/member_listener.rs | 231 --------------- rustybits/src/pubsub/member_status.proto | 21 -- rustybits/src/pubsub/mod.rs | 15 - rustybits/src/pubsub/network.proto | 65 ---- rustybits/src/pubsub/network_listener.rs | 232 --------------- rustybits/src/pubsub/protobuf.rs | 3 - 13 files changed, 8 insertions(+), 1321 deletions(-) delete mode 100644 rustybits/src/pubsub/change_listener.rs delete mode 100644 rustybits/src/pubsub/member.proto delete mode 100644 rustybits/src/pubsub/member_listener.rs delete mode 100644 rustybits/src/pubsub/member_status.proto delete mode 100644 rustybits/src/pubsub/mod.rs delete mode 100644 rustybits/src/pubsub/network.proto delete mode 100644 rustybits/src/pubsub/network_listener.rs delete mode 100644 rustybits/src/pubsub/protobuf.rs diff --git a/rustybits/Cargo.lock b/rustybits/Cargo.lock index fd6b37a348..a4da1e15e4 100644 --- a/rustybits/Cargo.lock +++ b/rustybits/Cargo.lock @@ -103,39 +103,6 @@ version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" -[[package]] -name = "async-channel" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" -dependencies = [ - "concurrent-queue", - "event-listener", - "futures-core", -] - -[[package]] -name = "async-stream" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" -dependencies = [ - "async-stream-impl", - "futures-core", - "pin-project-lite", -] - -[[package]] -name = "async-stream-impl" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "async-trait" version = "0.1.88" @@ -180,7 +147,7 @@ dependencies = [ "rustversion", "serde", "sync_wrapper 1.0.2", - "tower 0.5.2", + "tower", "tower-layer", "tower-service", ] @@ -431,15 +398,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" -[[package]] -name = "concurrent-queue" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "const-oid" version = "0.9.6" @@ -481,15 +439,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crc32fast" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" -dependencies = [ - "cfg-if", -] - [[package]] name = "crossbeam-channel" version = "0.5.15" @@ -874,12 +823,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "event-listener" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" - [[package]] name = "fastrand" version = "2.3.0" @@ -920,16 +863,6 @@ version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" -[[package]] -name = "flate2" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" -dependencies = [ - "crc32fast", - "miniz_oxide", -] - [[package]] name = "fnv" version = "1.0.7" @@ -1078,85 +1011,6 @@ dependencies = [ "slab", ] -[[package]] -name = "gcloud-auth" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4089aeec499899f6f1309803279763c34d898ca86c1a3e4616cba3ca6bce34b7" -dependencies = [ - "async-trait", - "base64 0.22.1", - "gcloud-metadata", - "home", - "jsonwebtoken", - "reqwest 0.12.22", - "serde", - "serde_json", - "thiserror 1.0.69", - "time", - "token-source", - "tokio", - "tracing", - "urlencoding", -] - -[[package]] -name = "gcloud-gax" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0a39057a0654184e074ddefb734c9a326ba468663b8f329c95f0069b5ccdb5" -dependencies = [ - "http 1.3.1", - "thiserror 1.0.69", - "token-source", - "tokio", - "tokio-retry2", - "tonic", - "tower 0.4.13", - "tracing", -] - -[[package]] -name = "gcloud-googleapis" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501459a508e7887cfedc45a45ee41602ac1f66d2b61deb05f1c2256bf2faf46d" -dependencies = [ - "prost 0.13.5", - "prost-types 0.13.5", - "tonic", -] - -[[package]] -name = "gcloud-metadata" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d575310b4546530f6b21ee000c20155f11f9291fa0b67ea0949fd48aa49ed70" -dependencies = [ - "reqwest 0.12.22", - "thiserror 1.0.69", - "tokio", -] - -[[package]] -name = "gcloud-pubsub" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1d55e2652753753d902a84c56613b9ae35a36416d94e56c1268764bc7e79f05" -dependencies = [ - "async-channel", - "async-stream", - "gcloud-auth", - "gcloud-gax", - "gcloud-googleapis", - "prost-types 0.13.5", - "thiserror 1.0.69", - "token-source", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -1505,29 +1359,12 @@ dependencies = [ "tokio-native-tls", ] -[[package]] -name = "hyper-tls" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" -dependencies = [ - "bytes", - "http-body-util", - "hyper 1.6.0", - "hyper-util", - "native-tls", - "tokio", - "tokio-native-tls", - "tower-service", -] - [[package]] name = "hyper-util" version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f66d5bd4c6f02bf0542fad85d626775bab9258cf795a4256dcaf3161114d1df" dependencies = [ - "base64 0.22.1", "bytes", "futures-channel", "futures-core", @@ -1535,9 +1372,7 @@ dependencies = [ "http 1.3.1", "http-body 1.0.1", "hyper 1.6.0", - "ipnet", "libc", - "percent-encoding", "pin-project-lite", "socket2", "tokio", @@ -1754,16 +1589,6 @@ version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" -[[package]] -name = "iri-string" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbc5ebe9c3a1a7a5127f920a418f7585e9e758e911d0466ed004f393b0e380b2" -dependencies = [ - "memchr", - "serde", -] - [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -1804,21 +1629,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "jsonwebtoken" -version = "9.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a87cc7a48537badeae96744432de36f4be2b4a34a05a5ef32e9dd8a1c169dde" -dependencies = [ - "base64 0.22.1", - "js-sys", - "pem", - "ring", - "serde", - "serde_json", - "simple_asn1", -] - [[package]] name = "jwt" version = "0.16.0" @@ -2029,16 +1839,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "num-bigint" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" -dependencies = [ - "num-integer", - "num-traits", -] - [[package]] name = "num-bigint-dig" version = "0.8.4" @@ -2103,7 +1903,7 @@ dependencies = [ "getrandom 0.2.16", "http 0.2.12", "rand 0.8.5", - "reqwest 0.11.27", + "reqwest", "serde", "serde_json", "serde_path_to_error", @@ -2310,16 +2110,6 @@ dependencies = [ "syn", ] -[[package]] -name = "pem" -version = "3.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38af38e8470ac9dee3ce1bae1af9c1671fffc44ddfd8bd1d0a3445bf349a8ef3" -dependencies = [ - "base64 0.22.1", - "serde", -] - [[package]] name = "pem-rfc7468" version = "0.7.0" @@ -2851,7 +2641,7 @@ dependencies = [ "http 0.2.12", "http-body 0.4.6", "hyper 0.14.32", - "hyper-tls 0.5.0", + "hyper-tls", "ipnet", "js-sys", "log", @@ -2876,44 +2666,6 @@ dependencies = [ "winreg", ] -[[package]] -name = "reqwest" -version = "0.12.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbc931937e6ca3a06e3b6c0aa7841849b160a90351d6ab467a8b9b9959767531" -dependencies = [ - "base64 0.22.1", - "bytes", - "encoding_rs", - "futures-core", - "http 1.3.1", - "http-body 1.0.1", - "http-body-util", - "hyper 1.6.0", - "hyper-tls 0.6.0", - "hyper-util", - "js-sys", - "log", - "mime", - "native-tls", - "percent-encoding", - "pin-project-lite", - "rustls-pki-types", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper 1.0.2", - "tokio", - "tokio-native-tls", - "tower 0.5.2", - "tower-http", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - [[package]] name = "rfc6979" version = "0.4.0" @@ -3101,15 +2853,10 @@ dependencies = [ "base64 0.21.7", "bytes", "cbindgen", - "gcloud-gax", - "gcloud-googleapis", - "gcloud-pubsub", "jwt", "openidconnect", - "prost 0.14.1", "prost-build 0.14.1", - "prost-types 0.14.1", - "reqwest 0.11.27", + "reqwest", "serde", "serde_json", "temporal-client", @@ -3396,18 +3143,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "simple_asn1" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "297f631f50729c8c99b84667867963997ec0b50f32b2a7dbcab828ef0541e8bb" -dependencies = [ - "num-bigint", - "num-traits", - "thiserror 2.0.12", - "time", -] - [[package]] name = "siphasher" version = "1.0.1" @@ -3533,9 +3268,6 @@ name = "sync_wrapper" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" -dependencies = [ - "futures-core", -] [[package]] name = "synstructure" @@ -3621,7 +3353,7 @@ dependencies = [ "thiserror 2.0.12", "tokio", "tonic", - "tower 0.5.2", + "tower", "tracing", "url", "uuid", @@ -3872,15 +3604,6 @@ dependencies = [ "zerovec", ] -[[package]] -name = "token-source" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75746ae15bef509f21039a652383104424208fdae172a964a8930858b9a78412" -dependencies = [ - "async-trait", -] - [[package]] name = "tokio" version = "1.46.1" @@ -3922,16 +3645,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-retry2" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1264d076dd34560544a2799e40e457bd07c43d30f4a845686b031bcd8455c84f" -dependencies = [ - "pin-project", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.26.2" @@ -4032,7 +3745,6 @@ dependencies = [ "axum", "base64 0.22.1", "bytes", - "flate2", "h2 0.4.11", "http 1.3.1", "http-body 1.0.1", @@ -4048,11 +3760,10 @@ dependencies = [ "tokio", "tokio-rustls", "tokio-stream", - "tower 0.5.2", + "tower", "tower-layer", "tower-service", "tracing", - "webpki-roots 0.26.11", ] [[package]] @@ -4069,21 +3780,6 @@ dependencies = [ "syn", ] -[[package]] -name = "tower" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" -dependencies = [ - "futures-core", - "futures-util", - "pin-project", - "pin-project-lite", - "tower-layer", - "tower-service", - "tracing", -] - [[package]] name = "tower" version = "0.5.2" @@ -4103,24 +3799,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "tower-http" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" -dependencies = [ - "bitflags 2.9.1", - "bytes", - "futures-util", - "http 1.3.1", - "http-body 1.0.1", - "iri-string", - "pin-project-lite", - "tower 0.5.2", - "tower-layer", - "tower-service", -] - [[package]] name = "tower-layer" version = "0.3.3" @@ -4139,7 +3817,6 @@ version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ - "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -4255,12 +3932,6 @@ dependencies = [ "serde", ] -[[package]] -name = "urlencoding" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" - [[package]] name = "utf8_iter" version = "1.0.4" @@ -4417,24 +4088,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki-roots" -version = "0.26.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" -dependencies = [ - "webpki-roots 1.0.2", -] - -[[package]] -name = "webpki-roots" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8983c3ab33d6fb807cfcdad2491c4ea8cbc8ed839181c7dfd9c67c83e261b2" -dependencies = [ - "rustls-pki-types", -] - [[package]] name = "winapi" version = "0.3.9" diff --git a/rustybits/Cargo.toml b/rustybits/Cargo.toml index 6c1cfeb3bd..9f718d1911 100644 --- a/rustybits/Cargo.toml +++ b/rustybits/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" crate-type = ["staticlib", "rlib"] [features] -default = ["zeroidc", "ztcontroller"] +default = ["zeroidc"] zeroidc = [] ztcontroller = [ "dep:serde", @@ -15,11 +15,6 @@ ztcontroller = [ "dep:temporal-sdk", "dep:temporal-client", "dep:temporal-sdk-core-protos", - "dep:gcloud-pubsub", - "dep:prost", - "dep:prost-types", - "dep:gcloud-gax", - "dep:gcloud-googleapis", "dep:tokio", "dep:tokio-util", ] @@ -51,11 +46,6 @@ jwt = { version = "0.16", git = "https://github.com/glimberg/rust-jwt" } time = { version = "~0.3", features = ["formatting"] } bytes = "1.3" thiserror = "1" -gcloud-pubsub = { version = "1.3.0", optional = true } -prost = { version = "0.14", optional = true, features = ["derive"] } -prost-types = { version = "0.14", optional = true } -gcloud-gax = { version = "1.2.0", optional = true } -gcloud-googleapis = { version = "1.2.0", optional = true } [dev-dependencies] testcontainers = { version = "0.24", features = ["blocking"] } diff --git a/rustybits/build.rs b/rustybits/build.rs index e5d61181ea..d756ef3f3b 100644 --- a/rustybits/build.rs +++ b/rustybits/build.rs @@ -4,23 +4,6 @@ use cbindgen::{Config, Language, MacroExpansionConfig}; use std::env; use std::path::PathBuf; fn main() { - #[cfg(feature = "ztcontroller")] - { - let mut prost_build = prost_build::Config::new(); - - prost_build - .type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]") - .compile_protos( - &[ - "src/pubsub/network.proto", - "src/pubsub/member.proto", - "src/pubsub/member_status.proto", - ], - &["src/pubsub/"], - ) - .expect("Failed to compile protobuf files"); - } - let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); let package_name = env::var("CARGO_PKG_NAME").unwrap(); diff --git a/rustybits/src/ext.rs b/rustybits/src/ext.rs index 50962d785f..bf6dcea916 100644 --- a/rustybits/src/ext.rs +++ b/rustybits/src/ext.rs @@ -13,12 +13,6 @@ use std::ffi::{CStr, CString}; use std::os::raw::c_char; #[cfg(feature = "ztcontroller")] -use std::os::raw::c_void; -#[cfg(feature = "ztcontroller")] -use std::sync::Arc; -#[cfg(feature = "ztcontroller")] -use std::time::Duration; -#[cfg(feature = "ztcontroller")] use tokio::runtime; use url::Url; @@ -34,7 +28,7 @@ static SHUTDOWN: std::sync::Once = std::sync::Once::new(); #[no_mangle] pub unsafe extern "C" fn init_async_runtime() { START.call_once(|| { - let rt = tokio::runtime::Builder::new_multi_thread() + let rt = runtime::Builder::new_multi_thread() .worker_threads(4) .thread_name("rust-async-worker") .enable_all() @@ -499,184 +493,3 @@ pub unsafe extern "C" fn smee_client_notify_network_joined( } } } - -#[cfg(feature = "ztcontroller")] -use crate::pubsub::member_listener::MemberListener; -#[cfg(feature = "ztcontroller")] -use crate::pubsub::network_listener::NetworkListener; - -#[cfg(feature = "ztcontroller")] -use crate::pubsub::member_listener::MemberListenerCallback; -#[cfg(feature = "ztcontroller")] -use crate::pubsub::network_listener::NetworkListenerCallback; - -#[cfg(feature = "ztcontroller")] -#[no_mangle] -pub unsafe extern "C" fn network_listener_new( - controller_id: *const c_char, - listen_timeout: u64, - callback: NetworkListenerCallback, - user_ptr: *mut c_void, -) -> *const NetworkListener { - if listen_timeout == 0 { - println!("listen_timeout is zero"); - return std::ptr::null_mut(); - } - if controller_id.is_null() { - println!("controller_id is null"); - return std::ptr::null_mut(); - } - - let id = unsafe { CStr::from_ptr(controller_id) }.to_str().unwrap(); - - let rt = runtime::Handle::current(); - rt.block_on(async { - match NetworkListener::new(id, Duration::from_secs(listen_timeout), callback, user_ptr).await { - Ok(listener) => Arc::into_raw(listener), - Err(e) => { - println!("error creating network listener: {}", e); - std::ptr::null_mut() - } - } - }) -} - -#[cfg(feature = "ztcontroller")] -#[no_mangle] -pub unsafe extern "C" fn network_listener_delete(ptr: *const NetworkListener) { - if ptr.is_null() { - return; - } - drop(Arc::from_raw(ptr)); -} - -#[cfg(feature = "ztcontroller")] -#[no_mangle] -pub unsafe extern "C" fn network_listener_listen(ptr: *const NetworkListener) -> bool { - use std::mem::ManuallyDrop; - if ptr.is_null() { - println!("ptr is null"); - return false; - } - - let listener = ManuallyDrop::new(unsafe { Arc::from_raw(ptr) }); - - let rt = runtime::Handle::current(); - match rt.block_on(listener.listen()) { - Ok(_) => { - println!("Network listener started successfully"); - true - } - Err(e) => { - println!("Error starting network listener: {}", e); - false - } - } -} - -#[cfg(feature = "ztcontroller")] -#[no_mangle] -pub unsafe extern "C" fn network_listener_change_handler(ptr: *const NetworkListener) { - use std::mem::ManuallyDrop; - if ptr.is_null() { - println!("ptr is null"); - return; - } - - let listener = ManuallyDrop::new(unsafe { Arc::from_raw(ptr) }); - - let rt = runtime::Handle::current(); - match rt.block_on(listener.change_handler()) { - Ok(_) => { - println!("Network listener change listener completed successfully"); - } - Err(e) => { - println!("Error in network listener change listener: {}", e); - } - } -} - -#[cfg(feature = "ztcontroller")] -#[no_mangle] -pub unsafe extern "C" fn member_listener_new( - controller_id: *const c_char, - listen_timeout: u64, - callback: MemberListenerCallback, - user_ptr: *mut c_void, -) -> *const MemberListener { - if listen_timeout == 0 { - println!("listen_timeout is zero"); - return std::ptr::null_mut(); - } - if controller_id.is_null() { - println!("controller_id is null"); - return std::ptr::null_mut(); - } - - let id = unsafe { CStr::from_ptr(controller_id) }.to_str().unwrap(); - - let rt = runtime::Handle::current(); - rt.block_on(async { - match MemberListener::new(id, Duration::from_secs(listen_timeout), callback, user_ptr).await { - Ok(listener) => Arc::into_raw(listener), - Err(e) => { - println!("error creating member listener: {}", e); - std::ptr::null_mut() - } - } - }) -} - -#[cfg(feature = "ztcontroller")] -#[no_mangle] -pub unsafe extern "C" fn member_listener_delete(ptr: *const MemberListener) { - if ptr.is_null() { - return; - } - drop(Arc::from_raw(ptr)); -} - -#[cfg(feature = "ztcontroller")] -#[no_mangle] -pub unsafe extern "C" fn member_listener_listen(ptr: *const MemberListener) -> bool { - use std::mem::ManuallyDrop; - if ptr.is_null() { - println!("ptr is null"); - return false; - } - - let listener = ManuallyDrop::new(unsafe { Arc::from_raw(ptr) }); - let rt = runtime::Handle::current(); - match rt.block_on(listener.listen()) { - Ok(_) => { - println!("Member listener started successfully"); - true - } - Err(e) => { - println!("Error starting member listener: {}", e); - false - } - } -} - -#[cfg(feature = "ztcontroller")] -#[no_mangle] -pub unsafe extern "C" fn member_listener_change_handler(ptr: *const MemberListener) { - use std::mem::ManuallyDrop; - if ptr.is_null() { - println!("ptr is null"); - return; - } - - let listener = ManuallyDrop::new(unsafe { Arc::from_raw(ptr) }); - - let rt = runtime::Handle::current(); - match rt.block_on(listener.change_handler()) { - Ok(_) => { - println!("Member listener change listener completed successfully"); - } - Err(e) => { - println!("Error in member listener change listener: {}", e); - } - } -} diff --git a/rustybits/src/lib.rs b/rustybits/src/lib.rs index cac1f7219d..a11b77299c 100644 --- a/rustybits/src/lib.rs +++ b/rustybits/src/lib.rs @@ -1,7 +1,5 @@ pub mod ext; #[cfg(feature = "ztcontroller")] -pub mod pubsub; -#[cfg(feature = "ztcontroller")] pub mod smeeclient; #[cfg(feature = "zeroidc")] pub mod zeroidc; diff --git a/rustybits/src/pubsub/change_listener.rs b/rustybits/src/pubsub/change_listener.rs deleted file mode 100644 index c5ae1f9257..0000000000 --- a/rustybits/src/pubsub/change_listener.rs +++ /dev/null @@ -1,144 +0,0 @@ -use gcloud_pubsub::client::{Client, ClientConfig}; -use gcloud_pubsub::subscription::SubscriptionConfig; -use gcloud_pubsub::topic::Topic; -use std::time::Duration; -use tokio::sync::mpsc::Sender; -use tokio_util::sync::CancellationToken; - -pub struct ChangeListener { - client: Client, - topic: Topic, - subscription_name: String, - controller_id: String, - listen_timeout: Duration, - sender: Sender>, -} - -impl ChangeListener { - pub async fn new( - controller_id: &str, - topic_name: &str, - subscription_name: &str, - listen_timeout: Duration, - sender: Sender>, - ) -> Result> { - let config = ClientConfig::default().with_auth().await.unwrap(); - let client = Client::new(config).await?; - - let topic = client.topic(topic_name); - if !topic.exists(None).await? { - topic.create(None, None).await?; - } - - Ok(Self { - client, - topic, - subscription_name: subscription_name.to_string(), - controller_id: controller_id.to_string(), - listen_timeout, - sender, - }) - } - - /** - * Listens for changes on the topic and sends them to the provided sender. - * - * Listens for up to `listen_timeout` duration, at which point it will stop listening - * and return. listen will have to be called again to continue listening. - * - * If the subscription does not exist, it will create it with the specified configuration. - */ - pub async fn listen(&self) -> Result<(), Box> { - let config = SubscriptionConfig { - enable_message_ordering: true, - filter: format!("attributes.controller_id = '{}'", self.controller_id), - ..Default::default() - }; - - let subscription = self.client.subscription(self.subscription_name.as_str()); - if !subscription.exists(None).await? { - subscription - .create(self.topic.fully_qualified_name(), config, None) - .await?; - } - - let cancel = CancellationToken::new(); - let cancel2 = cancel.clone(); - - let listen_timeout = self.listen_timeout.clone(); - tokio::spawn(async move { - tokio::time::sleep(listen_timeout).await; - cancel2.cancel(); - }); - - let tx = self.sender.clone(); - let _ = subscription - .receive( - move |message, _cancel| { - let tx2 = tx.clone(); - async move { - let data = message.message.data.clone(); - - match tx2.send(data.to_vec()).await { - Ok(_) => println!("Message sent successfully"), - Err(e) => eprintln!("Failed to send message: {}", e), - } - - match message.ack().await { - Ok(_) => println!("Message acknowledged"), - Err(e) => eprintln!("Failed to acknowledge message: {}", e), - } - } - }, - cancel.clone(), - None, - ) - .await; - - Ok(()) - } -} - -#[cfg(test)] -pub(crate) mod tests { - use super::*; - - use testcontainers::runners::AsyncRunner; - use testcontainers::ContainerAsync; - use testcontainers_modules::google_cloud_sdk_emulators; - use testcontainers_modules::google_cloud_sdk_emulators::CloudSdk; - use tokio; - - pub(crate) async fn setup_pubsub_emulator() -> Result<(ContainerAsync, String), Box> - { - let container = google_cloud_sdk_emulators::CloudSdk::pubsub().start().await?; - let port = container.get_host_port_ipv4(8085).await?; - let host = format!("localhost:{}", port); - - unsafe { - std::env::set_var("PUBSUB_EMULATOR_HOST", host.clone()); - } - - Ok((container, host)) - } - - #[tokio::test(flavor = "multi_thread", worker_threads = 1)] - async fn test_can_connect_to_pubsub() -> Result<(), Box> { - let (_container, _host) = setup_pubsub_emulator().await?; - - let (tx, _rx) = tokio::sync::mpsc::channel(64); - - let cl = ChangeListener::new( - "test_controller", - "test_topic", - "test_subscription", - Duration::from_secs(10), - tx, - ) - .await; - - assert!(cl.is_ok(), "Failed to connect to pubsub emulator: {:?}", cl.err()); - - Ok(()) - } -} diff --git a/rustybits/src/pubsub/member.proto b/rustybits/src/pubsub/member.proto deleted file mode 100644 index 511f1a8d7f..0000000000 --- a/rustybits/src/pubsub/member.proto +++ /dev/null @@ -1,39 +0,0 @@ -syntax = "proto3"; - -package pbmessages; - -message MemberChange { - message Member { - string device_id = 1; - string network_id = 2; - string identity = 3; // Identity of the member - bool authorized = 4; // Whether the member is authorized - repeated string ip_assignments = 5; // List of IP assignments - bool active_bridge = 6; // Whether the member is an active bridge - string tags = 7; // JSON string of tags - string capabilities = 8; // JSON string of capabilities - uint64 creation_time = 9; // Unix timestamp in milliseconds - bool no_auto_assign_ips = 10; // Whether auto IP assignment is disabled - uint64 revision = 11; // Revision number - uint64 last_authorized_time = 12; // Last time the member was authorized - uint64 last_deauthorized_time = 13; // Last time the member was deauthorized - optional string last_authorized_credential_type = 14; // Type of credential used for last authorization - optional string last_authorized_credential = 15; // Credential used for last authorization - int32 version_major = 16; // Major version of the member - int32 version_minor = 17; // Minor version of the member - int32 version_rev = 18; // Patch version of the member - int32 version_protocol = 19; // Protocol version of the member - int32 remote_trace_level = 20; // Remote trace level - optional string remote_trace_target = 21; // Remote trace target - bool sso_exepmt = 22; // Whether SSO is exempt - uint64 auth_expiry_time = 23; // Authorization expiry time in milliseconds - } - message MemberChangeMetadata { - string trace_id = 1; - string controller_id = 2; - } - - optional Member old = 1; - optional Member new = 2; - optional MemberChangeMetadata metadata = 3; -} diff --git a/rustybits/src/pubsub/member_listener.rs b/rustybits/src/pubsub/member_listener.rs deleted file mode 100644 index 63ac6bff3f..0000000000 --- a/rustybits/src/pubsub/member_listener.rs +++ /dev/null @@ -1,231 +0,0 @@ -use crate::pubsub::change_listener::ChangeListener; -use crate::pubsub::protobuf::pbmessages::MemberChange; -use prost::Message; -use std::io::Write; -use std::os::raw::c_void; -use std::sync::atomic::AtomicPtr; -use std::sync::Arc; -use std::time::Duration; -use tokio::sync::mpsc::Receiver; -use tokio::sync::Mutex; - -pub type MemberListenerCallback = extern "C" fn(*mut c_void, *const u8, usize); - -/** - * Member Listener listens for member changes and passes them back to the controller - * - * This is a wrapper around ChangeListener that specifically handles member changes. - * It uses a Tokio channel to receive messages and decodes them into MemberChange messages. - */ -pub struct MemberListener { - change_listener: ChangeListener, - rx_channel: Mutex>>, - callback: Mutex, - user_ptr: AtomicPtr, -} - -impl MemberListener { - pub async fn new( - controller_id: &str, - listen_timeout: Duration, - callback: MemberListenerCallback, - user_ptr: *mut c_void, - ) -> Result, Box> { - let (tx, rx) = tokio::sync::mpsc::channel(64); - - let change_listener = ChangeListener::new( - controller_id, - "controller-member-change-stream", - format!("{}-member-change-subscription", controller_id).as_str(), - listen_timeout, - tx, - ) - .await?; - - Ok(Arc::new(Self { - change_listener, - rx_channel: Mutex::new(rx), - callback: Mutex::new(callback), - user_ptr: AtomicPtr::new(user_ptr as *mut c_void), - })) - } - - pub async fn listen(self: &Arc) -> Result<(), Box> { - self.change_listener.listen().await - } - - pub async fn change_handler(self: &Arc) -> Result<(), Box> { - let this = self.clone(); - - let mut rx = this.rx_channel.lock().await; - while let Some(change) = rx.recv().await { - if let Ok(m) = MemberChange::decode(change.as_slice()) { - let j = serde_json::to_string(&m).unwrap(); - let mut buffer = [0; 16384]; - let mut test: &mut [u8] = &mut buffer; - let mut size: usize = 0; - while let Ok(bytes) = test.write(j.as_bytes()) { - if bytes == 0 { - break; - } - size += bytes; - } - let callback = this.callback.lock().await; - let user_ptr = this.user_ptr.load(std::sync::atomic::Ordering::Relaxed); - - (callback)(user_ptr, test.as_ptr(), size); - } else { - eprintln!("Failed to decode change"); - } - } - - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::pubsub::change_listener::tests::setup_pubsub_emulator; - use crate::pubsub::protobuf::pbmessages::member_change::Member; - use crate::pubsub::protobuf::pbmessages::MemberChange; - - use gcloud_googleapis::pubsub::v1::PubsubMessage; - use gcloud_pubsub::client::{Client, ClientConfig}; - use std::{ - collections::HashMap, - sync::atomic::{AtomicBool, Ordering}, - }; - - extern "C" fn dummy_callback(user_ptr: *mut c_void, data: *const u8, _size: usize) { - // Dummy callback for testing - assert!(!data.is_null(), "data pointer is null"); - assert!(!user_ptr.is_null(), "user_ptr pointer is null"); - let user_ptr = unsafe { &mut *(user_ptr as *mut TestMemberListener) }; - user_ptr.callback_called(); - println!("Dummy callback invoked"); - } - - struct TestMemberListener { - dummy_callback_called: bool, - } - - impl TestMemberListener { - fn new() -> Self { - Self { dummy_callback_called: false } - } - - fn callback_called(&mut self) { - self.dummy_callback_called = true; - } - } - - #[tokio::test(flavor = "multi_thread", worker_threads = 2)] - async fn test_member_listener() { - println!("Setting up Pub/Sub emulator for network listener test"); - let (_container, _host) = setup_pubsub_emulator().await.unwrap(); - let mut tester = TestMemberListener::new(); - - let listener = MemberListener::new( - "testctl", - Duration::from_secs(1), - dummy_callback, - &mut tester as *mut TestMemberListener as *mut c_void, - ) - .await - .unwrap(); - - let rt = tokio::runtime::Handle::current(); - - let run = Arc::new(AtomicBool::new(true)); - rt.spawn({ - let run = run.clone(); - let l = listener.clone(); - async move { - while run.load(Ordering::Relaxed) { - match l.listen().await { - Ok(_) => { - println!("Listener exited successfully"); - } - Err(e) => { - println!("Failed to start listener: {}", e); - assert!(false, "Listener failed to start"); - } - } - } - } - }); - - rt.spawn({ - let run = run.clone(); - let l = listener.clone(); - async move { - while run.load(Ordering::Relaxed) { - match l.change_handler().await { - Ok(_) => { - println!("Change handler started successfully"); - } - Err(e) => { - println!("Failed to start change handler: {}", e); - assert!(false, "Change handler failed to start"); - } - } - } - } - }); - - rt.spawn({ - async move { - let client = Client::new(ClientConfig::default()).await.unwrap(); - let topic = client.topic("controller-member-change-stream"); - if !topic.exists(None).await.unwrap() { - topic.create(None, None).await.unwrap(); - } - - let mut publisher = topic.new_publisher(None); - - let nc = MemberChange { - old: Some(Member { - device_id: "test_member".to_string(), - network_id: "test_network".to_string(), - authorized: false, - ..Default::default() - }), - new: Some(Member { - device_id: "test_member".to_string(), - network_id: "test_network".to_string(), - authorized: true, - ..Default::default() - }), - ..Default::default() - }; - - let data = MemberChange::encode_to_vec(&nc); - let message = PubsubMessage { - data: data.into(), - attributes: HashMap::from([("controller_id".to_string(), "testctl".to_string())]), - ordering_key: format!("members-{}", "test_network"), - ..Default::default() - }; - let awaiter = publisher.publish(message).await; - - match awaiter.get().await { - Ok(_) => println!("Message published successfully"), - Err(e) => { - assert!(false, "Failed to publish message: {}", e); - eprintln!("Failed to publish message: {}", e) - } - } - publisher.shutdown().await; - } - }); - - let mut counter = 0; - while !tester.dummy_callback_called && counter < 100 { - tokio::time::sleep(Duration::from_millis(100)).await; - counter += 1; - } - run.store(false, Ordering::Relaxed); - assert!(tester.dummy_callback_called, "Callback was not called"); - } -} diff --git a/rustybits/src/pubsub/member_status.proto b/rustybits/src/pubsub/member_status.proto deleted file mode 100644 index 2483905176..0000000000 --- a/rustybits/src/pubsub/member_status.proto +++ /dev/null @@ -1,21 +0,0 @@ -syntax = "proto3"; - -package pbmessages; - - - -message MemberStatus { - message MemberStatusMetadata { - string trace_id = 1; - string controller_id = 2; - } - - MemberStatusMetadata metadata = 1; - string network_id = 2; - string member_id = 3; - uint64 timestamp = 4; // Unix timestamp in milliseconds - optional string ip_address = 5; // Optional IP address of the member - optional string os = 6; - optional string arch = 7; - optional string version = 8; -} diff --git a/rustybits/src/pubsub/mod.rs b/rustybits/src/pubsub/mod.rs deleted file mode 100644 index 8d5f2a5b0b..0000000000 --- a/rustybits/src/pubsub/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c)2025 ZeroTier, Inc. - * - * Use of this software is governed by the Business Source License included - * in the LICENSE.TXT file in the project's root directory. - * - * Change Date: 2027-01-01 - * - * On the date above, in accordance with the Business Source License, use - * of this software will be governed by version 2.0 of the Apache License. - */ -mod change_listener; -pub mod member_listener; -pub mod network_listener; -mod protobuf; diff --git a/rustybits/src/pubsub/network.proto b/rustybits/src/pubsub/network.proto deleted file mode 100644 index fc2a21385d..0000000000 --- a/rustybits/src/pubsub/network.proto +++ /dev/null @@ -1,65 +0,0 @@ -syntax = "proto3"; - -package pbmessages; - -message NetworkChange { - message NetworkChangeMetadata { - string trace_id = 1; - string controller_id = 2; - } - - message IPRange { - string start_ip = 1; // Start of the IP range - string end_ip = 2; // End of the IP range - } - - message Route { - string target = 1; // Target IP or network - optional string via = 2; // Optional next hop IP - } - - message DNS { - string domain = 1; // Search domain - repeated string nameservers = 2; // List of nameservers - } - - message IPV4AssignMode { - bool zt = 1; // Whether ZeroTier is used for IPv4 assignment - } - - message IPv6AssignMode { - bool six_plane = 1; // Whether 6plane is used for IPv6 assignment - bool rfc4193 = 2; // Whether RFC 4193 is used for IPv6 assignment - bool zt = 3; // Whether ZeroTier is used for IPv6 assignment - } - - message Network { - string network_id = 1; - string capabilities = 2; // JSON string of capabilities - uint64 creation_time = 3; // Unix timestamp in milliseconds - bool enable_broadcast = 4; // Whether broadcast is enabled - repeated IPRange assignment_pools = 5; // List of IP ranges for assignment - uint32 mtu = 6; // Maximum Transmission Unit - uint32 multicast_limit = 7; // Limit for multicast messages - optional string name = 8; // Name of the network - bool is_private = 9; // Whether the network is private - uint32 remote_trace_level = 10; // Remote trace level - optional string remote_trace_target = 11; // Remote trace target - uint64 revision = 12; // Revision number - repeated Route routes = 13; // List of routes - string rules = 14; // JSON string of rules - optional string tags = 15; // JSON string of tags - IPV4AssignMode ipv4_assign_mode = 16; // IPv4 assignment mode - IPv6AssignMode ipv6_assign_mode = 17; // IPv6 assignment mode - optional DNS dns = 18; // DNS configuration - bool sso_enabled = 19; // Whether Single Sign-On is enabled - optional string sso_client_id = 20; // SSO client ID - optional string sso_authorization_endpoint = 21; // SSO authorization endpoint - optional string sso_issuer = 22; // SSO issuer - optional string sso_provider = 23; // SSO provider - } - - optional Network old = 1; - optional Network new = 2; - optional NetworkChangeMetadata metadata = 3; -} diff --git a/rustybits/src/pubsub/network_listener.rs b/rustybits/src/pubsub/network_listener.rs deleted file mode 100644 index 1478d0859f..0000000000 --- a/rustybits/src/pubsub/network_listener.rs +++ /dev/null @@ -1,232 +0,0 @@ -use crate::pubsub::change_listener::ChangeListener; -use crate::pubsub::protobuf::pbmessages::NetworkChange; -use prost::Message; -use serde_json; -use std::io::Write; -use std::os::raw::c_void; -use std::sync::atomic::{AtomicPtr, Ordering}; -use std::sync::Arc; -use std::time::Duration; -use tokio::sync::mpsc::Receiver; -use tokio::sync::Mutex; - -pub type NetworkListenerCallback = extern "C" fn(*mut c_void, *const u8, usize); - -/** - * Network Listener listens for network changes and passes them back to the controller - * - * This is a wrapper around ChangeListener that specifically handles network changes. - * It uses a Tokio channel to receive messages and decodes them into NetworkChange messages. - */ -pub struct NetworkListener { - change_listener: ChangeListener, - rx_channel: Mutex>>, - callback: Mutex, - user_ptr: AtomicPtr, -} - -impl NetworkListener { - pub async fn new( - controller_id: &str, - listen_timeout: Duration, - callback: NetworkListenerCallback, - user_ptr: *mut c_void, - ) -> Result, Box> { - let (tx, rx) = tokio::sync::mpsc::channel(64); - - let change_listener = ChangeListener::new( - controller_id, - "controller-network-change-stream", - format!("{}-network-change-subscription", controller_id).as_str(), - listen_timeout, - tx, - ) - .await?; - - Ok(Arc::new(Self { - change_listener, - rx_channel: Mutex::new(rx), - callback: Mutex::new(callback), - user_ptr: AtomicPtr::new(user_ptr as *mut c_void), - })) - } - - pub async fn listen(self: &Arc) -> Result<(), Box> { - self.change_listener.listen().await - } - - pub async fn change_handler(self: &Arc) -> Result<(), Box> { - let this = self.clone(); - - let mut rx = this.rx_channel.lock().await; - while let Some(change) = rx.recv().await { - if let Ok(m) = NetworkChange::decode(change.as_slice()) { - let j = serde_json::to_string(&m).unwrap(); - let mut buffer = [0; 16384]; - let mut test: &mut [u8] = &mut buffer; - let mut size: usize = 0; - while let Ok(bytes) = test.write(j.as_bytes()) { - if bytes == 0 { - break; // No more space to write - } - size += bytes; - } - let callback = this.callback.lock().await; - let user_ptr = this.user_ptr.load(Ordering::Relaxed); - - (callback)(user_ptr, test.as_ptr(), size); - } else { - eprintln!("Failed to decode change"); - } - } - - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::pubsub::change_listener::tests::setup_pubsub_emulator; - use crate::pubsub::protobuf::pbmessages::network_change::Network; - use crate::pubsub::protobuf::pbmessages::NetworkChange; - - use gcloud_googleapis::pubsub::v1::PubsubMessage; - use gcloud_pubsub::client::{Client, ClientConfig}; - use std::{ - collections::HashMap, - sync::atomic::{AtomicBool, Ordering}, - }; - - extern "C" fn dummy_callback(user_ptr: *mut c_void, data: *const u8, _size: usize) { - // Dummy callback for testing - assert!(!data.is_null(), "data pointer is null"); - assert!(!user_ptr.is_null(), "user_ptr pointer is null"); - let user_ptr = unsafe { &mut *(user_ptr as *mut TestNetworkListenr) }; - user_ptr.callback_called(); - println!("Dummy callback invoked"); - } - - struct TestNetworkListenr { - dummy_callback_called: bool, - } - - impl TestNetworkListenr { - fn new() -> Self { - Self { dummy_callback_called: false } - } - - fn callback_called(&mut self) { - self.dummy_callback_called = true; - } - } - - #[tokio::test(flavor = "multi_thread", worker_threads = 2)] - async fn test_network_listener() { - println!("Setting up Pub/Sub emulator for network listener test"); - let (_container, _host) = setup_pubsub_emulator().await.unwrap(); - - let mut tester = TestNetworkListenr::new(); - - let listener = NetworkListener::new( - "testctl", - Duration::from_secs(1), - dummy_callback, - &mut tester as *mut TestNetworkListenr as *mut c_void, - ) - .await - .unwrap(); - - let rt = tokio::runtime::Handle::current(); - - let run = Arc::new(AtomicBool::new(true)); - rt.spawn({ - let run = run.clone(); - let l = listener.clone(); - async move { - while run.load(Ordering::Relaxed) { - match l.listen().await { - Ok(_) => { - println!("Listener exited successfully"); - } - Err(e) => { - println!("Failed to start listener: {}", e); - assert!(false, "Listener failed to start"); - } - } - } - } - }); - - rt.spawn({ - let run = run.clone(); - let l = listener.clone(); - async move { - while run.load(Ordering::Relaxed) { - match l.change_handler().await { - Ok(_) => { - println!("Change handler started successfully"); - } - Err(e) => { - println!("Failed to start change handler: {}", e); - assert!(false, "Change handler failed to start"); - } - } - } - } - }); - - rt.spawn({ - async move { - let client = Client::new(ClientConfig::default()).await.unwrap(); - let topic = client.topic("controller-network-change-stream"); - if !topic.exists(None).await.unwrap() { - topic.create(None, None).await.unwrap(); - } - - let mut publisher = topic.new_publisher(None); - - let nc = NetworkChange { - old: Some(Network { - network_id: "test_network".to_string(), - name: Some("Test Network".to_string()), - ..Default::default() - }), - new: Some(Network { - network_id: "test_network".to_string(), - name: Some("Test Network Updated".to_string()), - ..Default::default() - }), - ..Default::default() - }; - - let data = NetworkChange::encode_to_vec(&nc); - let message = PubsubMessage { - data: data.into(), - attributes: HashMap::from([("controller_id".to_string(), "testctl".to_string())]), - ordering_key: format!("networks-{}", "testctl"), - ..Default::default() - }; - let awaiter = publisher.publish(message).await; - - match awaiter.get().await { - Ok(_) => println!("Message published successfully"), - Err(e) => { - assert!(false, "Failed to publish message: {}", e); - eprintln!("Failed to publish message: {}", e) - } - } - publisher.shutdown().await; - } - }); - - let mut counter = 0; - while !tester.dummy_callback_called && counter < 100 { - tokio::time::sleep(Duration::from_millis(100)).await; - counter += 1; - } - - run.store(false, Ordering::Relaxed); - assert!(tester.dummy_callback_called, "Callback was not called"); - } -} diff --git a/rustybits/src/pubsub/protobuf.rs b/rustybits/src/pubsub/protobuf.rs deleted file mode 100644 index aa26148657..0000000000 --- a/rustybits/src/pubsub/protobuf.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub(crate) mod pbmessages { - include!(concat!(env!("OUT_DIR"), "/pbmessages.rs")); -} From 496e69e6661ef63597d49d91d0ac11abee2d5870 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 1 Sep 2025 15:29:27 -0700 Subject: [PATCH 033/245] add def for new style controllers --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee7563dc43..fb6fe52b1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,7 +54,7 @@ if(ZT1_CENTRAL_CONTROLLER) set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to" FORCE) set(CMAKE_CXX_STANDARD_REQUIRED True CACHE BOOL "C++ standard required" FORCE) set(CMAKE_CXX_EXTENSIONS ON CACHE BOOL "Enable compiler-specific extensions" FORCE) - add_definitions(-DZT_CONTROLLER_USE_LIBPQ) + add_definitions(-DZT_CONTROLLER_USE_LIBPQ -DZT1_CENTRAL_CONTROLLER) set(CONTROLLER_RUST_FEATURES ztcontroller) set(RUST_BUILD_COMMAND cargo build --release -F ${CONTROLLER_RUST_FEATURES}) else() From 4ddb1fbe583b7d9d4271b8474545fad3c6b45b1e Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 2 Sep 2025 07:49:41 -0700 Subject: [PATCH 034/245] Create the pubsub topic if it doesn't exist --- nonfree/controller/PubSubListener.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 72905a77aa..8c6b48e4ac 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -34,6 +35,29 @@ PubSubListener::PubSubListener(std::string controller_id, std::string project, s { GOOGLE_PROTOBUF_VERIFY_VERSION; + // Create Topic if it doesn't exist + // this is only really needed for testing with the emulator + // in production the topic should be created via terraform or gcloud + // before starting the controller + auto topicAdminClient = pubsub_admin::TopicAdminClient(pubsub_admin::MakeTopicAdminConnection()); + auto topicName = pubsub::Topic(project, topic).FullName(); + auto topicResult = topicAdminClient.GetTopic(topicName); + if (! topicResult.ok()) { + // Only create if not found + if (topicResult.status().code() == google::cloud::StatusCode::kNotFound) { + auto createResult = topicAdminClient.CreateTopic(topicName); + if (! createResult.ok()) { + fprintf(stderr, "Failed to create topic: %s\n", createResult.status().message().c_str()); + throw std::runtime_error("Failed to create topic"); + } + fprintf(stderr, "Created topic: %s\n", topicName.c_str()); + } + else { + fprintf(stderr, "Failed to get topic: %s\n", topicResult.status().message().c_str()); + throw std::runtime_error("Failed to get topic"); + } + } + google::pubsub::v1::Subscription request; request.set_name(_subscription.FullName()); request.set_topic(pubsub::Topic(project, topic).FullName()); From a5bd262b3a2569252c28a3ccbe49376ee2535029 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 2 Sep 2025 13:30:08 -0700 Subject: [PATCH 035/245] Wiring through initialization of the CentralDB version of the controller Still need to do the actual configuration from local.conf --- CMakeLists.txt | 2 +- nonfree/controller/BigTableStatusWriter.hpp | 5 - nonfree/controller/CMakeLists.txt | 2 + nonfree/controller/CentralDB.cpp | 42 ++++---- nonfree/controller/CentralDB.hpp | 20 +--- nonfree/controller/ControllerConfig.hpp | 66 ++++++++++++ .../controller/EmbeddedNetworkController.cpp | 101 ++++++++++++++++++ .../controller/EmbeddedNetworkController.hpp | 15 +++ nonfree/controller/PubSubListener.cpp | 1 + nonfree/controller/PubSubListener.hpp | 7 -- nonfree/controller/StatusWriter.hpp | 2 +- service/CMakeLists.txt | 1 + service/OneService.cpp | 18 +++- 13 files changed, 230 insertions(+), 52 deletions(-) create mode 100644 nonfree/controller/ControllerConfig.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index c705c2853b..d527ff4a90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,7 +54,7 @@ if(ZT1_CENTRAL_CONTROLLER) set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to" FORCE) set(CMAKE_CXX_STANDARD_REQUIRED True CACHE BOOL "C++ standard required" FORCE) set(CMAKE_CXX_EXTENSIONS ON CACHE BOOL "Enable compiler-specific extensions" FORCE) - add_definitions(-DZT_CONTROLLER_USE_LIBPQ -DZT1_CENTRAL_CONTROLLER) + add_definitions(-DZT_NONFREE_CONTROLLER=1 -DZT_CONTROLLER_USE_LIBPQ=1 -DZT1_CENTRAL_CONTROLLER=1) set(CONTROLLER_RUST_FEATURES ztcontroller) set(RUST_BUILD_COMMAND cargo build --release -F ${CONTROLLER_RUST_FEATURES}) else() diff --git a/nonfree/controller/BigTableStatusWriter.hpp b/nonfree/controller/BigTableStatusWriter.hpp index 8abc81ca32..61657c797f 100644 --- a/nonfree/controller/BigTableStatusWriter.hpp +++ b/nonfree/controller/BigTableStatusWriter.hpp @@ -7,11 +7,6 @@ #include namespace ZeroTier { -struct BigTableConfig { - std::string project_id; - std::string instance_id; - std::string table_id; -}; class BigTableStatusWriter : public StatusWriter { public: diff --git a/nonfree/controller/CMakeLists.txt b/nonfree/controller/CMakeLists.txt index 57560ce205..07760c675a 100644 --- a/nonfree/controller/CMakeLists.txt +++ b/nonfree/controller/CMakeLists.txt @@ -41,6 +41,7 @@ if (ZT1_CENTRAL_CONTROLLER) CV2.hpp CentralDB.cpp CentralDB.hpp + ControllerConfig.hpp NotificationListener.hpp PostgreSQL.cpp PostgreSQL.hpp @@ -55,6 +56,7 @@ if (ZT1_CENTRAL_CONTROLLER) BigTableStatusWriter.hpp PostgresStatusWriter.cpp PostgresStatusWriter.hpp + Redis.hpp RedisStatusWriter.cpp RedisStatusWriter.hpp ) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 846565e0ff..f42f504149 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -19,6 +19,7 @@ #include "../../node/SHA512.hpp" #include "../../version.h" #include "BigTableStatusWriter.hpp" +#include "ControllerConfig.hpp" #include "CtlUtil.hpp" #include "EmbeddedNetworkController.hpp" #include "PostgresStatusWriter.hpp" @@ -55,15 +56,15 @@ using ItemStream = std::vector; CentralDB::CentralDB( const Identity& myId, - const char* path, + const char* connString, int listenPort, CentralDB::ListenerMode listenMode, CentralDB::StatusWriterMode statusMode, - ControllerConfig* cc) + const ControllerConfig* cc) : DB() , _listenerMode(listenMode) , _statusWriterMode(statusMode) - , _controllerConfig(cc) + , _cc(cc) , _pool() , _myId(myId) , _myAddress(myId.address()) @@ -72,7 +73,6 @@ CentralDB::CentralDB( , _run(1) , _waitNoticePrinted(false) , _listenPort(listenPort) - , _rc(cc->redisConfig) , _redis(NULL) , _cluster(NULL) , _redisMemberStatus(false) @@ -87,7 +87,7 @@ CentralDB::CentralDB( char myAddress[64]; _myAddressStr = myId.address().toString(myAddress); - _connString = std::string(path); + _connString = std::string(connString); auto f = std::make_shared(_connString); _pool = std::make_shared >(15, 5, std::static_pointer_cast(f)); @@ -126,15 +126,15 @@ CentralDB::CentralDB( } _pool->unborrow(c); - if ((listenMode == LISTENER_MODE_REDIS || statusMode == STATUS_WRITER_MODE_REDIS) && _rc != NULL) { + if ((listenMode == LISTENER_MODE_REDIS || statusMode == STATUS_WRITER_MODE_REDIS) && _cc->redisConfig != NULL) { auto innerspan = tracer->StartSpan("CentralDB::CentralDB::configureRedis"); auto innerscope = tracer->WithActiveSpan(innerspan); sw::redis::ConnectionOptions opts; sw::redis::ConnectionPoolOptions poolOpts; - opts.host = _rc->hostname; - opts.port = _rc->port; - opts.password = _rc->password; + opts.host = _cc->redisConfig->hostname; + opts.port = _cc->redisConfig->port; + opts.password = _cc->redisConfig->password; opts.db = 0; opts.keep_alive = true; opts.connect_timeout = std::chrono::seconds(3); @@ -142,7 +142,7 @@ CentralDB::CentralDB( poolOpts.wait_timeout = std::chrono::seconds(5); poolOpts.connection_lifetime = std::chrono::minutes(3); poolOpts.connection_idle_time = std::chrono::minutes(1); - if (_rc->clusterMode) { + if (_cc->redisConfig->clusterMode) { innerspan->SetAttribute("cluster_mode", "true"); fprintf(stderr, "Using Redis in Cluster Mode\n"); _cluster = std::make_shared(opts, poolOpts); @@ -168,8 +168,8 @@ CentralDB::CentralDB( switch (listenMode) { case LISTENER_MODE_REDIS: - if (_rc != NULL) { - if (_rc->clusterMode) { + if (_cc->redisConfig != NULL) { + if (_cc->redisConfig->clusterMode) { _membersDbWatcher = std::make_shared(_myAddressStr, _cluster, this); _networksDbWatcher = std::make_shared(_myAddressStr, _cluster, this); } @@ -202,8 +202,8 @@ CentralDB::CentralDB( switch (statusMode) { case STATUS_WRITER_MODE_REDIS: - if (_rc != NULL) { - if (_rc->clusterMode) { + if (_cc->redisConfig != NULL) { + if (_cc->redisConfig->clusterMode) { _statusWriter = std::make_shared(_cluster, _myAddressStr); } else { @@ -441,7 +441,7 @@ void CentralDB::nodeIsOnline(const uint64_t networkId, const uint64_t memberId, AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::string& redirectURL) { - if (_controllerConfig->ssoEnabled) { + if (_cc->ssoEnabled) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("CentralDB"); auto span = tracer->StartSpan("CentralDB::getSSOAuthInfo"); @@ -797,7 +797,7 @@ void CentralDB::initializeMembers() if (! deletes.empty()) { try { - if (_rc->clusterMode) { + if (_cc->redisConfig->clusterMode) { auto tx = _cluster->transaction(_myAddressStr, true, false); for (std::string k : deletes) { tx.del(k); @@ -961,7 +961,7 @@ void CentralDB::initializeMembers() if (! networkMembers.empty()) { if (_redisMemberStatus) { fprintf(stderr, "Load member data into redis...\n"); - if (_rc->clusterMode) { + if (_cc->redisConfig->clusterMode) { auto tx = _cluster->transaction(_myAddressStr, true, false); uint64_t count = 0; for (auto it : networkMembers) { @@ -1071,7 +1071,7 @@ void CentralDB::heartbeat() try { if (_listenerMode == LISTENER_MODE_REDIS && _redisMemberStatus) { - if (_rc->clusterMode) { + if (_cc->redisConfig->clusterMode) { _cluster->zadd("controllers", "controllerId", ts); } else { @@ -1298,7 +1298,7 @@ void CentralDB::commitThread() std::string id = config["id"]; std::string controllerId = _myAddressStr.c_str(); std::string key = "networks:{" + controllerId + "}"; - if (_rc->clusterMode) { + if (_cc->redisConfig->clusterMode) { _cluster->sadd(key, id); } else { @@ -1340,7 +1340,7 @@ void CentralDB::commitThread() std::string id = config["id"]; std::string controllerId = _myAddressStr.c_str(); std::string key = "networks:{" + controllerId + "}"; - if (_rc->clusterMode) { + if (_cc->redisConfig->clusterMode) { _cluster->srem(key, id); _cluster->del("network-nodes-online:{" + controllerId + "}:" + id); } @@ -1392,7 +1392,7 @@ void CentralDB::commitThread() std::string networkId = config["nwid"]; std::string controllerId = _myAddressStr.c_str(); std::string key = "network-nodes-all:{" + controllerId + "}:" + networkId; - if (_rc->clusterMode) { + if (_cc->redisConfig->clusterMode) { _cluster->srem(key, memberId); _cluster->del("member:{" + controllerId + "}:" + networkId + ":" + memberId); } diff --git a/nonfree/controller/CentralDB.hpp b/nonfree/controller/CentralDB.hpp index e130c6344b..0ffd1e562b 100644 --- a/nonfree/controller/CentralDB.hpp +++ b/nonfree/controller/CentralDB.hpp @@ -21,19 +21,8 @@ struct SmeeClient; } namespace ZeroTier { - struct RedisConfig; -struct PubSubConfig; -struct PostgresNotifyConfig; -struct BigTableConfig; - -struct ControllerConfig { - bool ssoEnabled; - RedisConfig* redisConfig; - PubSubConfig* pubSubConfig; - PostgresNotifyConfig* postgresNotifyConfig; - BigTableConfig* bigTableConfig; -}; +struct ControllerConfig; class CentralDB : public DB { public: @@ -51,11 +40,11 @@ class CentralDB : public DB { CentralDB( const Identity& myId, - const char* path, + const char* connString, int listenPort, CentralDB::ListenerMode mode, CentralDB::StatusWriterMode statusMode, - ControllerConfig* cc); + const ControllerConfig* cc); virtual ~CentralDB(); virtual bool waitForReady(); @@ -109,7 +98,7 @@ class CentralDB : public DB { ListenerMode _listenerMode; StatusWriterMode _statusWriterMode; - ControllerConfig* _controllerConfig; + const ControllerConfig* _cc; std::shared_ptr > _pool; const Identity _myId; @@ -136,7 +125,6 @@ class CentralDB : public DB { int _listenPort; uint8_t _ssoPsk[48]; - RedisConfig* _rc; std::shared_ptr _redis; std::shared_ptr _cluster; bool _redisMemberStatus; diff --git a/nonfree/controller/ControllerConfig.hpp b/nonfree/controller/ControllerConfig.hpp new file mode 100644 index 0000000000..3ee3c8ea59 --- /dev/null +++ b/nonfree/controller/ControllerConfig.hpp @@ -0,0 +1,66 @@ +#ifndef CONTROLLER_CONFIG_HPP +#define CONTROLLER_CONFIG_HPP + +#include "Redis.hpp" + +#include + +namespace ZeroTier { + +struct PubSubConfig { + std::string project; +}; + +struct PostgresNotifyConfig { + std::string channel; +}; + +struct BigTableConfig { + std::string project_id; + std::string instance_id; + std::string table_id; +}; + +struct ControllerConfig { + bool ssoEnabled; + std::string listenMode; + std::string statusMode; + RedisConfig* redisConfig; + PubSubConfig* pubSubConfig; + PostgresNotifyConfig* postgresNotifyConfig; + BigTableConfig* bigTableConfig; + + ControllerConfig() + : ssoEnabled(false) + , listenMode("") + , statusMode("") + , redisConfig(nullptr) + , pubSubConfig(nullptr) + , postgresNotifyConfig(nullptr) + , bigTableConfig(nullptr) + { + } + + ~ControllerConfig() + { + if (redisConfig) { + delete redisConfig; + redisConfig = nullptr; + } + if (pubSubConfig) { + delete pubSubConfig; + pubSubConfig = nullptr; + } + if (postgresNotifyConfig) { + delete postgresNotifyConfig; + postgresNotifyConfig = nullptr; + } + if (bigTableConfig) { + delete bigTableConfig; + bigTableConfig = nullptr; + } + } +}; + +} // namespace ZeroTier +#endif // CONTROLLER_CONFIG_HPP \ No newline at end of file diff --git a/nonfree/controller/EmbeddedNetworkController.cpp b/nonfree/controller/EmbeddedNetworkController.cpp index c29feb6201..dd8092603b 100644 --- a/nonfree/controller/EmbeddedNetworkController.cpp +++ b/nonfree/controller/EmbeddedNetworkController.cpp @@ -26,6 +26,10 @@ #ifdef ZT_CONTROLLER_USE_LIBPQ #include "CV1.hpp" #include "CV2.hpp" +#include "CentralDB.hpp" +#ifdef ZT1_CENTRAL_CONTROLLER +#include "ControllerConfig.hpp" +#endif #endif #include "../../node/CertificateOfMembership.hpp" @@ -559,6 +563,61 @@ EmbeddedNetworkController::EmbeddedNetworkController( { } +#ifdef ZT1_CENTRAL_CONTROLLER +EmbeddedNetworkController::EmbeddedNetworkController( + Node* node, + const char* ztPath, + const char* dbPath, + int listenPort, + const ControllerConfig* cc) + : _startTime(OSUtils::now()) + , _listenPort(listenPort) + , _node(node) + , _ztPath(ztPath) + , _path(dbPath) + , _signingId() + , _signingIdAddressString() + , _sender((NetworkController::Sender*)0) + , _db(this) + , _queue() + , _threads() + , _threads_l() + , _memberStatus() + , _memberStatus_l() + , _expiringSoon() + , _expiringSoon_l() + , _rc(nullptr) + , _cc(cc) + , _ssoExpiryRunning(true) + , _ssoExpiry(std::thread(&EmbeddedNetworkController::_ssoExpiryThread, this)) +#ifdef CENTRAL_CONTROLLER_REQUEST_BENCHMARK + , _member_status_lookup { "nc_member_status_lookup", "" } + , _member_status_lookup_count { "nc_member_status_lookup_count", "" } + , _node_is_online { "nc_node_is_online", "" } + , _node_is_online_count { "nc_node_is_online_count", "" } + , _get_and_init_member { "nc_get_and_init_member", "" } + , _get_and_init_member_count { "nc_get_and_init_member_count", "" } + , _have_identity { "nc_have_identity", "" } + , _have_identity_count { "nc_have_identity_count", "" } + , _determine_auth { "nc_determine_auth", "" } + , _determine_auth_count { "nc_determine_auth_count", "" } + , _sso_check { "nc_sso_check", "" } + , _sso_check_count { "nc_sso_check_count", "" } + , _auth_check { "nc_auth_check", "" } + , _auth_check_count { "nc_auth_check_count", "" } + , _json_schlep { "nc_json_schlep", "" } + , _json_schlep_count { "nc_json_schlep_count", "" } + , _issue_certificate { "nc_issue_certificate", "" } + , _issue_certificate_count { "nc_issue_certificate_count", "" } + , _save_member { "nc_save_member", "" } + , _save_member_count { "nc_save_member_count", "" } + , _send_netconf { "nc_send_netconf2", "" } + , _send_netconf_count { "nc_send_netconf2_count", "" } +#endif +{ +} +#endif + EmbeddedNetworkController::~EmbeddedNetworkController() { std::lock_guard l(_threads_l); @@ -587,6 +646,47 @@ void EmbeddedNetworkController::init(const Identity& signingId, Sender* sender) _sender = sender; _signingIdAddressString = signingId.address().toString(tmp); +#ifdef ZT1_CENTRAL_CONTROLLER + if (! _cc) { + throw std::runtime_error("controller config required"); + } + + if (_path.length() > 9 || (_path.substr(0, 9) != "postgres:")) { + throw std::runtime_error("central controller requires postgres db"); + } + + const char* connString = _path.substr(9).c_str(); + + CentralDB::ListenerMode lm; + if (_cc->listenMode == "pgsql") { + lm = CentralDB::LISTENER_MODE_PGSQL; + } + else if (_cc->listenMode == "redis") { + lm = CentralDB::LISTENER_MODE_REDIS; + } + else if (_cc->listenMode == "pubsub") { + lm = CentralDB::LISTENER_MODE_PUBSUB; + } + else { + throw std::runtime_error("unsupported listen mode"); + } + + CentralDB::StatusWriterMode sm; + if (_cc->statusMode == "pgsql") { + sm = CentralDB::STATUS_WRITER_MODE_PGSQL; + } + else if (_cc->statusMode == "redis") { + sm = CentralDB::STATUS_WRITER_MODE_REDIS; + } + else if (_cc->statusMode == "bigtable") { + sm = CentralDB::STATUS_WRITER_MODE_BIGTABLE; + } + else { + throw std::runtime_error("unsupported status mode"); + } + + _db.addDB(std::shared_ptr(new CentralDB(_signingId, connString, _listenPort, lm, sm, _cc))); +#else #ifdef ZT_CONTROLLER_USE_LIBPQ if ((_path.length() > 9) && (_path.substr(0, 9) == "postgres:")) { fprintf(stderr, "CV1\n"); @@ -603,6 +703,7 @@ void EmbeddedNetworkController::init(const Identity& signingId, Sender* sender) #ifdef ZT_CONTROLLER_USE_LIBPQ } #endif +#endif // ZT1_CENTRAL_CONTROLLER _db.waitForReady(); } diff --git a/nonfree/controller/EmbeddedNetworkController.hpp b/nonfree/controller/EmbeddedNetworkController.hpp index 3886c63913..085ece3c87 100644 --- a/nonfree/controller/EmbeddedNetworkController.hpp +++ b/nonfree/controller/EmbeddedNetworkController.hpp @@ -30,6 +30,10 @@ namespace ZeroTier { class Node; struct RedisConfig; +#ifdef ZT1_CENTRAL_CONTROLLER +class ControllerConfig; +#endif + class EmbeddedNetworkController : public NetworkController , public DB::ChangeListener { @@ -39,6 +43,14 @@ class EmbeddedNetworkController * @param dbPath Database path (file path or database credentials) */ EmbeddedNetworkController(Node* node, const char* ztPath, const char* dbPath, int listenPort, RedisConfig* rc); +#ifdef ZT1_CENTRAL_CONTROLLER + EmbeddedNetworkController( + Node* node, + const char* ztPath, + const char* dbPath, + int listenPort, + const ControllerConfig* cc); +#endif virtual ~EmbeddedNetworkController(); virtual void init(const Identity& signingId, Sender* sender); @@ -146,6 +158,9 @@ class EmbeddedNetworkController std::mutex _expiringSoon_l; RedisConfig* _rc; +#ifdef ZT1_CENTRAL_CONTROLLER + const ControllerConfig* _cc; +#endif std::string _ssoRedirectURL; bool _ssoExpiryRunning; diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 8c6b48e4ac..5126c0fcb9 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -1,6 +1,7 @@ #ifdef ZT_CONTROLLER_USE_LIBPQ #include "PubSubListener.hpp" +#include "ControllerConfig.hpp" #include "DB.hpp" #include "member.pb.h" #include "network.pb.h" diff --git a/nonfree/controller/PubSubListener.hpp b/nonfree/controller/PubSubListener.hpp index b8f08aeaeb..5c6aa712c8 100644 --- a/nonfree/controller/PubSubListener.hpp +++ b/nonfree/controller/PubSubListener.hpp @@ -15,13 +15,6 @@ namespace ZeroTier { class DB; -struct PubSubConfig { - const char* controller_id; - std::string project; - std::string topic; - uint64_t listen_timeout; -}; - /** * Base class for GCP PubSub listeners */ diff --git a/nonfree/controller/StatusWriter.hpp b/nonfree/controller/StatusWriter.hpp index 29e7f350de..78b36f5869 100644 --- a/nonfree/controller/StatusWriter.hpp +++ b/nonfree/controller/StatusWriter.hpp @@ -14,7 +14,7 @@ namespace ZeroTier { */ class StatusWriter { public: - virtual ~StatusWriter() = 0; + virtual ~StatusWriter() = default; virtual void updateNodeStatus( const std::string& network_id, diff --git a/service/CMakeLists.txt b/service/CMakeLists.txt index da38d9a4c0..359d578b57 100644 --- a/service/CMakeLists.txt +++ b/service/CMakeLists.txt @@ -35,6 +35,7 @@ if(ZT1_CENTRAL_CONTROLLER) ) list(APPEND LINK_LIBS pqxx + redis++::redis++_static opentelemetry-cpp::sdk ) endif() diff --git a/service/OneService.cpp b/service/OneService.cpp index aea7901946..8ebc855894 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -130,6 +130,10 @@ using json = nlohmann::json; #include "../nonfree/controller/EmbeddedNetworkController.hpp" #include "../nonfree/controller/PostgreSQL.hpp" #include "../nonfree/controller/Redis.hpp" +#ifdef ZT1_CENTRAL_CONTROLLER +#include "../nonfree/controller/CentralDB.hpp" +#include "../nonfree/controller/ControllerConfig.hpp" +#endif #include "../osdep/EthernetTap.hpp" #ifdef __WINDOWS__ #include "../osdep/WindowsEthernetTap.hpp" @@ -1009,6 +1013,10 @@ class OneServiceImpl : public OneService { double _exporterSampleRate; #endif +#ifdef ZT1_CENTRAL_CONTROLLER + ControllerConfig _controllerConfig; +#endif + // end member variables ---------------------------------------------------- OneServiceImpl(const char* hp, unsigned int port) @@ -1055,6 +1063,9 @@ class OneServiceImpl : public OneService { , _traceProvider(nullptr) , _exporterEndpoint() , _exporterSampleRate(1.0) +#endif +#ifdef ZT1_CENTRAL_CONTROLLER + , _controllerConfig() #endif { _ports[0] = 0; @@ -1351,10 +1362,15 @@ class OneServiceImpl : public OneService { // Delete legacy iddb.d if present (cleanup) OSUtils::rmDashRf((_homePath + ZT_PATH_SEPARATOR_S "iddb.d").c_str()); - // Network controller is now enabled by default for desktop and server + // Network controller is now disabled by default for desktop and server #ifdef ZT_NONFREE_CONTROLLER +#ifdef ZT1_CENTRAL_CONTROLLER + _controller = new EmbeddedNetworkController( + _node, _homePath.c_str(), _controllerDbPath.c_str(), _ports[0], &_controllerConfig); +#else _controller = new EmbeddedNetworkController(_node, _homePath.c_str(), _controllerDbPath.c_str(), _ports[0], _rc); +#endif if (! _ssoRedirectURL.empty()) { _controller->setSSORedirectURL(_ssoRedirectURL); } From 0753556aa346ff27c00ca159808c9146b6625a58 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 2 Sep 2025 14:04:00 -0700 Subject: [PATCH 036/245] wire up configuration. New config block in local.conf for controllers: ``` { "settings": { ...standard zt1 local.conf settings... }, "controller": { "listenMode": (pgsql|redis|pubsub), "statusMode": (pgsql|redis|bigtable), "redis": { "hostname": ..., "port": 6379, "clusterMode": true }, "pubsub": { "project_id": }, "bigtable": { "project_id": , "instance_id": , "table_id": } } } ``` --- nonfree/controller/CentralDB.cpp | 4 +- nonfree/controller/ControllerConfig.hpp | 12 +----- service/OneService.cpp | 54 +++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 13 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index f42f504149..c102dab28f 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -184,9 +184,9 @@ CentralDB::CentralDB( case LISTENER_MODE_PUBSUB: if (cc->pubSubConfig != NULL) { _membersDbWatcher = - std::make_shared(_myAddressStr, cc->pubSubConfig->project, this); + std::make_shared(_myAddressStr, cc->pubSubConfig->project_id, this); _networksDbWatcher = - std::make_shared(_myAddressStr, cc->pubSubConfig->project, this); + std::make_shared(_myAddressStr, cc->pubSubConfig->project_id, this); } else { throw std::runtime_error( diff --git a/nonfree/controller/ControllerConfig.hpp b/nonfree/controller/ControllerConfig.hpp index 3ee3c8ea59..b082b793bb 100644 --- a/nonfree/controller/ControllerConfig.hpp +++ b/nonfree/controller/ControllerConfig.hpp @@ -8,11 +8,7 @@ namespace ZeroTier { struct PubSubConfig { - std::string project; -}; - -struct PostgresNotifyConfig { - std::string channel; + std::string project_id; }; struct BigTableConfig { @@ -27,7 +23,6 @@ struct ControllerConfig { std::string statusMode; RedisConfig* redisConfig; PubSubConfig* pubSubConfig; - PostgresNotifyConfig* postgresNotifyConfig; BigTableConfig* bigTableConfig; ControllerConfig() @@ -36,7 +31,6 @@ struct ControllerConfig { , statusMode("") , redisConfig(nullptr) , pubSubConfig(nullptr) - , postgresNotifyConfig(nullptr) , bigTableConfig(nullptr) { } @@ -51,10 +45,6 @@ struct ControllerConfig { delete pubSubConfig; pubSubConfig = nullptr; } - if (postgresNotifyConfig) { - delete postgresNotifyConfig; - postgresNotifyConfig = nullptr; - } if (bigTableConfig) { delete bigTableConfig; bigTableConfig = nullptr; diff --git a/service/OneService.cpp b/service/OneService.cpp index 8ebc855894..3a5911138a 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -1790,6 +1790,60 @@ class OneServiceImpl : public OneService { _node->setPhysicalPathConfiguration( reinterpret_cast(&(i->first)), &(i->second)); } + +#ifdef ZT1_CENTRAL_CONTROLLER + // Central Controller Mode Settings + json& cc = lc["controller"]; + if (cc.is_object()) { + _controllerConfig.listenMode = OSUtils::jsonString(cc["listenMode"], "pgsql"); + _controllerConfig.statusMode = OSUtils::jsonString(cc["statusMode"], "pgsql"); + + // redis settings + if (cc["redis"].is_object() && _rc == NULL) { + json& redis = cc["redis"]; + _rc = new RedisConfig; + _rc->hostname = OSUtils::jsonString(redis["hostname"], ""); + _rc->port = OSUtils::jsonInt(redis["port"], 6379); + _rc->password = OSUtils::jsonString(redis["password"], ""); + _rc->clusterMode = OSUtils::jsonBool(redis["clusterMode"], false); + _controllerConfig.redisConfig = _rc; + } + else if (cc["redis"].is_object() && _rc != NULL) { + _controllerConfig.redisConfig = _rc; + } + if ((_controllerConfig.listenMode == "redis" || _controllerConfig.statusMode == "redis") + && ! _controllerConfig.redisConfig) { + fprintf( + stderr, + "ERROR: redis listenMode or statusMode requires redis configuration in local.conf" ZT_EOL_S); + exit(1); + } + + // pubsub settings + if (cc["pubsub"].is_object()) { + json& ps = cc["pubsub"]; + _controllerConfig.pubSubConfig = new PubSubConfig(); + _controllerConfig.pubSubConfig->project_id = OSUtils::jsonString(ps["project_id"], ""); + } + if (_controllerConfig.listenMode == "pubsub" && ! _controllerConfig.pubSubConfig) { + fprintf(stderr, "ERROR: pubsub listenMode requires pubsub configuration in local.conf" ZT_EOL_S); + exit(1); + } + + // bigtable settings + if (cc["bigtable"].is_object()) { + json& bt = cc["bigtable"]; + _controllerConfig.bigTableConfig = new BigTableConfig(); + _controllerConfig.bigTableConfig->project_id = OSUtils::jsonString(bt["project_id"], ""); + _controllerConfig.bigTableConfig->instance_id = OSUtils::jsonString(bt["instance_id"], ""); + _controllerConfig.bigTableConfig->table_id = OSUtils::jsonString(bt["table_id"], ""); + } + if (_controllerConfig.listenMode == "bigtable" && ! _controllerConfig.bigTableConfig) { + fprintf(stderr, "ERROR: bigtable listenMode requires bigtable configuration in local.conf" ZT_EOL_S); + exit(1); + } + } +#endif } virtual ReasonForTermination reasonForTermination() const From 70f9fe041234944ed95fa5c4eec0b97238c9c846 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 2 Sep 2025 14:15:28 -0700 Subject: [PATCH 037/245] update central controller readme with config block --- .../controller/README_CENTRAL_CONTROLLER.md | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/nonfree/controller/README_CENTRAL_CONTROLLER.md b/nonfree/controller/README_CENTRAL_CONTROLLER.md index 7d8268c3f1..9fd7f7707d 100644 --- a/nonfree/controller/README_CENTRAL_CONTROLLER.md +++ b/nonfree/controller/README_CENTRAL_CONTROLLER.md @@ -53,4 +53,36 @@ cmake --build build/ --target all -j8 --verbose ## Packaging via Docker -TODO: write me \ No newline at end of file +TODO: write me + + +## Configuration + +Central Controller has new configuration options outside of the normal "settings" block of `local.conf`. + +```json +{ + "settings": { + ...standard zt1 local.conf settings... + }, + "controller": { + "listenMode": (pgsql|redis|pubsub), + "statusMode": (pgsql|redis|bigtable), + "redis": { + "hostname": ..., + "port": 6379, + "clusterMode": true + }, + "pubsub": { + "project_id": + }, + "bigtable": { + "project_id": , + "instance_id": , + "table_id": + } + } +} +``` + +Configuration checks for invalid configurations like `listenMode = "pubsub"`, but without a `"pubsub"` config block. From 2a647d497a4a3eb0fb7dc0570496f224c103a38b Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 2 Sep 2025 16:25:16 -0700 Subject: [PATCH 038/245] remove otel warning --- service/OneService.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/service/OneService.cpp b/service/OneService.cpp index 3a5911138a..a097156b79 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -1766,8 +1766,6 @@ class OneServiceImpl : public OneService { stderr, "WARNING: OpenTelemetry exporter settings are not set. Traces will not be exported." ZT_EOL_S); } -#else - fprintf(stderr, "WARNING: OpenTelemetry support is not enabled. Traces will not be exported." ZT_EOL_S); #endif // Bind to wildcard instead of to specific interfaces (disables full tunnel capability) From 7c1bfc97c49ee2086f171cd316109749a8c21e9a Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 08:18:56 -0700 Subject: [PATCH 039/245] setup github action for building --- .github/workflows/central-controller.yaml | 41 +++++++++++++++++++ environment.yml | 19 +++++++++ .../controller/README_CENTRAL_CONTROLLER.md | 18 +------- 3 files changed, 62 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/central-controller.yaml create mode 100644 environment.yml diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml new file mode 100644 index 0000000000..4908e7113a --- /dev/null +++ b/.github/workflows/central-controller.yaml @@ -0,0 +1,41 @@ +# on: +# workflow_dispatch: +on: + push: + workflow_dispatch: + +jobs: + central_controller: + name: Central Controller Build + runs-on: [gha-runner-x64, gha-runner-arm64] + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Get Date + id: get-date + run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT + shell: bash + - name: Cache Conda + uses: actions/cache@v4 + with: + path: ~/miniconda3 + key: ${{ runner.os }}-${{ runner.arch }}-${{ steps.get-date.outputs.today }}-conda-${{ hashFiles('**/environment.yml') }} + - name: Setup Miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + auto-update-conda: false + channel-priority: strict + activate-environment: central_controller + environment-file: environment.yml + use-only-tar-bz2: true + - name: Setup CMake + uses: threeal/cmake-action@v2.1.0 + with: + options: | + -DCMAKE_BUILD_TYPE=Release + -DZT1_CENTRAL_CONTROLLER=1 + - name: Build + run: cmake --build . --config Release -- -j 4 + - name: SelfTest + run: | + ./build/zerotier-selftest \ No newline at end of file diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000000..bdaabcf1c9 --- /dev/null +++ b/environment.yml @@ -0,0 +1,19 @@ +name: central_controller +channels: + - conda-forge +dependencies: + - conda-forge::cmake=3.27.4 + - conda-forge::git + - conda-forge::cxx-compiler + - conda-forge::c-compiler + - conda-forge::make + - conda-forge::pkg-config + - conda-forge::libpqxx=7.7.3 + - conda-forge::libopentelemetry-cpp=1.21.0 + - conda-forge::libopentelemetry-cpp-headers=1.21.0 + - conda-forge::google-cloud-cpp=2.39.0 + - conda-forge::libgoogle-cloud=2.39.0 + - conda-forge::rust=1.89.0 + - conda-forge::inja=3.3.0 + - conda-forge::libhiredis=1.3.0 + - conda-forge::nlohmann_json=3.12.0 diff --git a/nonfree/controller/README_CENTRAL_CONTROLLER.md b/nonfree/controller/README_CENTRAL_CONTROLLER.md index 9fd7f7707d..3b37e3c32d 100644 --- a/nonfree/controller/README_CENTRAL_CONTROLLER.md +++ b/nonfree/controller/README_CENTRAL_CONTROLLER.md @@ -25,22 +25,8 @@ conda config --set channel_priority strict Install external dependencies: ```bash -conda install -y -c conda-forge \ - conda-forge::cmake \ - conda-forge::git \ - conda-forge::cxx-compiler \ - conda-forge::c-compiler \ - conda-forge::make \ - conda-forge::pkg-config \ - conda-forge::libpqxx=7.7.3 \ - conda-forge::libopentelemetry-cpp=1.21.0 \ - conda-forge::libopentelemetry-cpp-headers=1.21.0 \ - conda-forge::google-cloud-cpp=2.39.0 \ - conda-forge::libgoogle-cloud=2.39.0 \ - conda-forge::rust=1.89.0 \ - conda-forge::inja=3.3.0 \ - conda-forge::libhiredis=1.3.0 \ - conda-forge::nlohmann_json=3.12.0 +conda env create -f environment.yaml +conda env activate central_controller ``` ## Build the Central Controller Binary From 0f1336389576d385bf50d05a960d9619a6c6d19a Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 08:22:47 -0700 Subject: [PATCH 040/245] runs-on matrix --- .github/workflows/central-controller.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index 4908e7113a..50dcc6eb76 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -7,7 +7,10 @@ on: jobs: central_controller: name: Central Controller Build - runs-on: [gha-runner-x64, gha-runner-arm64] + strategy: + matrix: + runner: [gha-runner-x64, gha-runner-arm64] + runs-on: ${{ matrix.runner }} steps: - name: checkout uses: actions/checkout@v4 From 09f1ee77e19d09c63517325c1dd7c799648e98b8 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 08:26:08 -0700 Subject: [PATCH 041/245] skip caching until this all works --- .github/workflows/central-controller.yaml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index 50dcc6eb76..48de11a360 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -14,18 +14,19 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 - - name: Get Date - id: get-date - run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT - shell: bash - - name: Cache Conda - uses: actions/cache@v4 - with: - path: ~/miniconda3 - key: ${{ runner.os }}-${{ runner.arch }}-${{ steps.get-date.outputs.today }}-conda-${{ hashFiles('**/environment.yml') }} + # - name: Get Date + # id: get-date + # run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT + # shell: bash + # - name: Cache Conda + # uses: actions/cache@v4 + # with: + # path: ~/miniconda3 + # key: ${{ runner.os }}-${{ runner.arch }}-${{ steps.get-date.outputs.today }}-conda-${{ hashFiles('**/environment.yml') }} - name: Setup Miniconda uses: conda-incubator/setup-miniconda@v3 with: + conda-remove-defaults: true auto-update-conda: false channel-priority: strict activate-environment: central_controller From 97681b589e31ec7ef0a1fd0d121f5f09babcfaa0 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 08:37:30 -0700 Subject: [PATCH 042/245] trying to get this working --- .github/workflows/central-controller.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index 48de11a360..859badbe35 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -27,6 +27,7 @@ jobs: uses: conda-incubator/setup-miniconda@v3 with: conda-remove-defaults: true + miniconda-version: "latest" auto-update-conda: false channel-priority: strict activate-environment: central_controller From e1db40d9329b89f22997dfff607ce0f58a6b82ed Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 08:39:02 -0700 Subject: [PATCH 043/245] test --- .github/workflows/central-controller.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index 859badbe35..34e1232874 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -32,7 +32,7 @@ jobs: channel-priority: strict activate-environment: central_controller environment-file: environment.yml - use-only-tar-bz2: true + use-only-tar-bz2: false - name: Setup CMake uses: threeal/cmake-action@v2.1.0 with: From cab33dfc89ed135dfd4b13766722ca994e874e0e Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 08:45:33 -0700 Subject: [PATCH 044/245] no linux/arm64 build available for google-cloud-cpp 2.39 :/. Downgrade to 2.38 --- environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment.yml b/environment.yml index bdaabcf1c9..905c13feec 100644 --- a/environment.yml +++ b/environment.yml @@ -11,7 +11,7 @@ dependencies: - conda-forge::libpqxx=7.7.3 - conda-forge::libopentelemetry-cpp=1.21.0 - conda-forge::libopentelemetry-cpp-headers=1.21.0 - - conda-forge::google-cloud-cpp=2.39.0 + - conda-forge::google-cloud-cpp=2.38.0 - conda-forge::libgoogle-cloud=2.39.0 - conda-forge::rust=1.89.0 - conda-forge::inja=3.3.0 From 22484c708f37abf9763f751a8af18d378af3775c Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 08:51:21 -0700 Subject: [PATCH 045/245] dependency juggling --- environment.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/environment.yml b/environment.yml index 905c13feec..6ac54a314f 100644 --- a/environment.yml +++ b/environment.yml @@ -8,11 +8,11 @@ dependencies: - conda-forge::c-compiler - conda-forge::make - conda-forge::pkg-config - - conda-forge::libpqxx=7.7.3 + - conda-forge::libpqxx=7.10.1 - conda-forge::libopentelemetry-cpp=1.21.0 - conda-forge::libopentelemetry-cpp-headers=1.21.0 - conda-forge::google-cloud-cpp=2.38.0 - - conda-forge::libgoogle-cloud=2.39.0 + - conda-forge::libgoogle-cloud=2.38.0 - conda-forge::rust=1.89.0 - conda-forge::inja=3.3.0 - conda-forge::libhiredis=1.3.0 From 3ad36c773dcd9de2a8c26f85d94e8bbcba6a6b3b Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 08:55:29 -0700 Subject: [PATCH 046/245] fix cmake options --- .github/workflows/central-controller.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index 34e1232874..d3a0b82533 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -37,8 +37,8 @@ jobs: uses: threeal/cmake-action@v2.1.0 with: options: | - -DCMAKE_BUILD_TYPE=Release - -DZT1_CENTRAL_CONTROLLER=1 + CMAKE_BUILD_TYPE=Release + ZT1_CENTRAL_CONTROLLER=1 - name: Build run: cmake --build . --config Release -- -j 4 - name: SelfTest From f43bc3d10ca85ae572a278b659c720d64eda9a87 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 09:00:36 -0700 Subject: [PATCH 047/245] more conda --- .github/workflows/central-controller.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index d3a0b82533..ca94bca4af 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -33,6 +33,11 @@ jobs: activate-environment: central_controller environment-file: environment.yml use-only-tar-bz2: false + - name: Activate Conda + run: | + echo "CONDA_BASE=$(conda info --base)" >> $GITHUB_ENV + source "$CONDA_BASE/etc/profile.d/conda.sh" + conda activate central_controller - name: Setup CMake uses: threeal/cmake-action@v2.1.0 with: From 21e20f21049feeb693437a6b77b0d018f84299e4 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 09:04:40 -0700 Subject: [PATCH 048/245] more conda --- .github/workflows/central-controller.yaml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index ca94bca4af..7c741f6f76 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -33,11 +33,11 @@ jobs: activate-environment: central_controller environment-file: environment.yml use-only-tar-bz2: false - - name: Activate Conda - run: | - echo "CONDA_BASE=$(conda info --base)" >> $GITHUB_ENV - source "$CONDA_BASE/etc/profile.d/conda.sh" - conda activate central_controller + # - name: Activate Conda + # run: | + # echo "CONDA_BASE=$(conda info --base)" >> $GITHUB_ENV + # source "$CONDA_BASE/etc/profile.d/conda.sh" + # conda activate central_controller - name: Setup CMake uses: threeal/cmake-action@v2.1.0 with: @@ -45,7 +45,11 @@ jobs: CMAKE_BUILD_TYPE=Release ZT1_CENTRAL_CONTROLLER=1 - name: Build - run: cmake --build . --config Release -- -j 4 + run: | + source ~/miniconda3/etc/profile.d/conda.sh + conda activate central_controller + cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DZT1_CENTRAL_CONTROLLER=1 + cmake --build . --config Release -- -j 4 - name: SelfTest run: | ./build/zerotier-selftest \ No newline at end of file From 648f0915e512df82b6c4efe07e599ac31cce63f8 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 09:09:17 -0700 Subject: [PATCH 049/245] skip cmake action --- .github/workflows/central-controller.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index 7c741f6f76..05e660a9df 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -38,12 +38,12 @@ jobs: # echo "CONDA_BASE=$(conda info --base)" >> $GITHUB_ENV # source "$CONDA_BASE/etc/profile.d/conda.sh" # conda activate central_controller - - name: Setup CMake - uses: threeal/cmake-action@v2.1.0 - with: - options: | - CMAKE_BUILD_TYPE=Release - ZT1_CENTRAL_CONTROLLER=1 + # - name: Setup CMake + # uses: threeal/cmake-action@v2.1.0 + # with: + # options: | + # CMAKE_BUILD_TYPE=Release + # ZT1_CENTRAL_CONTROLLER=1 - name: Build run: | source ~/miniconda3/etc/profile.d/conda.sh From 3470ceb13dabb16d54d4cc98d63ac964bc80eb18 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 09:12:04 -0700 Subject: [PATCH 050/245] cmake --build args --- .github/workflows/central-controller.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index 05e660a9df..da228f2bea 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -49,7 +49,7 @@ jobs: source ~/miniconda3/etc/profile.d/conda.sh conda activate central_controller cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DZT1_CENTRAL_CONTROLLER=1 - cmake --build . --config Release -- -j 4 + cmake --build build/ --target all -j4 --verbose - name: SelfTest run: | ./build/zerotier-selftest \ No newline at end of file From d3f1ec74ba1004de7cc0a1b2e6c5cf30a878f72a Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 09:20:13 -0700 Subject: [PATCH 051/245] fix arm64 build flag --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d527ff4a90..3674b58415 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ if(CPU_ARCHITECTURE STREQUAL "x86_64") -DZT_USE_FAST_X64_ED25519=1 ) elseif(CPU_ARCHITECTURE STREQUAL "aarch64") - add_definitions(-DZT_ARCHITECTURE=4 -DZT_U-DZT_ARCH_ARM_HAS_NEON=1 -DZT_SSO_SUPPORTED=1) + add_definitions(-DZT_ARCHITECTURE=4 -DZT_ARCH_ARM_HAS_NEON=1 -DZT_SSO_SUPPORTED=1) add_compile_options(-march=armv8-a+crypto -mtune=generic -mstrict-align) endif() From 0f3a5148b11d1a8a83d59645c3052f2824ff9122 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 09:29:33 -0700 Subject: [PATCH 052/245] fix deps for selftest --- CMakeLists.txt | 3 ++- osdep/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3674b58415..fbf29b9db0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,7 +127,8 @@ add_executable(zerotier-selftest ) target_link_libraries(zerotier-selftest - zerotier-core + zerotier-core + zerotier-osdep Threads::Threads nlohmann_json::nlohmann_json prometheus-cpp-lite diff --git a/osdep/CMakeLists.txt b/osdep/CMakeLists.txt index 7d476dbf8b..43e4cb8ce5 100644 --- a/osdep/CMakeLists.txt +++ b/osdep/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.13) -project(osdep LANGUAGES CXX ASM) +project(zerotier-osdep LANGUAGES CXX ASM) set(SRC_FILES Arp.cpp From d31b3a08db7e465bc1d7a5d6ae1a01a03bf78634 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 10:08:16 -0700 Subject: [PATCH 053/245] set ZT_AES_NEON for arm64 --- CMakeLists.txt | 4 ++-- nonfree/controller/BigTableStatusWriter.cpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fbf29b9db0..681490d306 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ if(CPU_ARCHITECTURE STREQUAL "x86_64") -DZT_USE_FAST_X64_ED25519=1 ) elseif(CPU_ARCHITECTURE STREQUAL "aarch64") - add_definitions(-DZT_ARCHITECTURE=4 -DZT_ARCH_ARM_HAS_NEON=1 -DZT_SSO_SUPPORTED=1) + add_definitions(-DZT_ARCHITECTURE=4 -DZT_ARCH_ARM_HAS_NEON=1 -DZT_SSO_SUPPORTED=1 -DZT_AES_NEON=1) add_compile_options(-march=armv8-a+crypto -mtune=generic -mstrict-align) endif() @@ -132,4 +132,4 @@ target_link_libraries(zerotier-selftest Threads::Threads nlohmann_json::nlohmann_json prometheus-cpp-lite - Threads::Threads) \ No newline at end of file + Threads::Threads) diff --git a/nonfree/controller/BigTableStatusWriter.cpp b/nonfree/controller/BigTableStatusWriter.cpp index 4406b28844..108090cab5 100644 --- a/nonfree/controller/BigTableStatusWriter.cpp +++ b/nonfree/controller/BigTableStatusWriter.cpp @@ -1,5 +1,7 @@ #include "BigTableStatusWriter.hpp" +#include "ControllerConfig.hpp" + #include #include #include From 1dae4c4c5f58ea0f3eefe741fb4c551a0275dd78 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 10:23:33 -0700 Subject: [PATCH 054/245] cache conda environment --- .github/workflows/central-controller.yaml | 37 +++++++---------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index da228f2bea..2f7dc73b06 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -14,36 +14,21 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 - # - name: Get Date - # id: get-date - # run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT - # shell: bash - # - name: Cache Conda - # uses: actions/cache@v4 - # with: - # path: ~/miniconda3 - # key: ${{ runner.os }}-${{ runner.arch }}-${{ steps.get-date.outputs.today }}-conda-${{ hashFiles('**/environment.yml') }} - name: Setup Miniconda uses: conda-incubator/setup-miniconda@v3 with: - conda-remove-defaults: true - miniconda-version: "latest" - auto-update-conda: false - channel-priority: strict + miniconda-version: latest activate-environment: central_controller - environment-file: environment.yml - use-only-tar-bz2: false - # - name: Activate Conda - # run: | - # echo "CONDA_BASE=$(conda info --base)" >> $GITHUB_ENV - # source "$CONDA_BASE/etc/profile.d/conda.sh" - # conda activate central_controller - # - name: Setup CMake - # uses: threeal/cmake-action@v2.1.0 - # with: - # options: | - # CMAKE_BUILD_TYPE=Release - # ZT1_CENTRAL_CONTROLLER=1 + - name: Conda Environment Cache + id: cache + uses: actions/cache@v4 + with: + path: ${{ env.CONDA }}/envs + key: ${{ runner.os }}-${{ runner.arch }}-conda-${{ hashFiles('environment.yml') }} + - name: Update Conda Environment + run: + source ~/miniconda3/etc/profile.d/conda.sh + conda env update --file environment.yml - name: Build run: | source ~/miniconda3/etc/profile.d/conda.sh From 43955747063b38d2791eca86777fa8a5e46c7b61 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 10:27:06 -0700 Subject: [PATCH 055/245] cache conda environment --- .github/workflows/central-controller.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index 2f7dc73b06..ba390666ba 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -28,6 +28,7 @@ jobs: - name: Update Conda Environment run: source ~/miniconda3/etc/profile.d/conda.sh + conda env activate central_controller conda env update --file environment.yml - name: Build run: | From b09956ae59c8f3968f48d0fd4a8e41f51f1ede2e Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 10:28:42 -0700 Subject: [PATCH 056/245] fix run arg --- .github/workflows/central-controller.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index ba390666ba..7f1c257810 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -26,7 +26,7 @@ jobs: path: ${{ env.CONDA }}/envs key: ${{ runner.os }}-${{ runner.arch }}-conda-${{ hashFiles('environment.yml') }} - name: Update Conda Environment - run: + run: | source ~/miniconda3/etc/profile.d/conda.sh conda env activate central_controller conda env update --file environment.yml From 3ff4d67d21de3155a17b6d5db76c435175a878bc Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 10:29:53 -0700 Subject: [PATCH 057/245] bump --- .github/workflows/central-controller.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index 7f1c257810..958f0331ef 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -28,7 +28,6 @@ jobs: - name: Update Conda Environment run: | source ~/miniconda3/etc/profile.d/conda.sh - conda env activate central_controller conda env update --file environment.yml - name: Build run: | From a841e96bd2611e697600c2923d47435de7d8531e Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 10:40:31 -0700 Subject: [PATCH 058/245] put git branch ref into cache key name --- .github/workflows/central-controller.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index 958f0331ef..1d16ef1502 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -24,7 +24,7 @@ jobs: uses: actions/cache@v4 with: path: ${{ env.CONDA }}/envs - key: ${{ runner.os }}-${{ runner.arch }}-conda-${{ hashFiles('environment.yml') }} + key: ${{ runner.os }}-${{ runner.arch }}-${{ github.ref_name }}-conda-${{ hashFiles('environment.yml') }} - name: Update Conda Environment run: | source ~/miniconda3/etc/profile.d/conda.sh From 3f3e684811e4e8cafb3cc7e275366e6b887246b0 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 10:42:22 -0700 Subject: [PATCH 059/245] only update conda env if cache was not hit --- .github/workflows/central-controller.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index 1d16ef1502..39ce3a87bc 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -26,6 +26,7 @@ jobs: path: ${{ env.CONDA }}/envs key: ${{ runner.os }}-${{ runner.arch }}-${{ github.ref_name }}-conda-${{ hashFiles('environment.yml') }} - name: Update Conda Environment + if: steps.cache.outputs.cache-hit != 'true' run: | source ~/miniconda3/etc/profile.d/conda.sh conda env update --file environment.yml From 000f3d5a8c1bb5e4b0d6a318b7fdc6e48e7b7f1c Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 11:37:26 -0700 Subject: [PATCH 060/245] let's build a docker image --- .github/workflows/central-controller.yaml | 66 ++++++++++++++++++- .../Dockerfile.conda | 23 +++++++ .../Dockerfile.run_base2 | 23 ------- 3 files changed, 88 insertions(+), 24 deletions(-) create mode 100644 ext/central-controller-docker/Dockerfile.conda delete mode 100644 ext/central-controller-docker/Dockerfile.run_base2 diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index 39ce3a87bc..4fb340227b 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -38,4 +38,68 @@ jobs: cmake --build build/ --target all -j4 --verbose - name: SelfTest run: | - ./build/zerotier-selftest \ No newline at end of file + ./build/zerotier-selftest + + - name: GCP Auth + uses: google-github-actions/auth@v2 + with: + credentials_json: ${{ secrets.DOCKER_REGISTRY_WRITER}} + + - name: Set up GCloud CLI + uses: google-github-actions/setup-gcloud@v2 + + - name: Docker Auth + run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet + + - name: Get branch name and sanitize + id: branch + run: | + BRANCH_NAME="${GITHUB_REF##*/}" + SANITIZED_BRANCH="${BRANCH_NAME//\//-}" + echo "branch_name=$SANITIZED_BRANCH" >> $GITHUB_OUTPUT + + - name: Get short git commit SHA + id: sha + run: | + calculatedSha=$(git rev-parse --short ${{ github.sha }}) + echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV + + - name: Build and push Docker Image + run: | + docker build -t us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ steps.sha.outputs.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} -f ext/central-controller-docker/Dockerfile.conda . + docker push us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ steps.sha.outputs.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} + + multi-arch-docker: + runs-on: gha-runner-x64 + needs: central_controller + steps: + - name: GCP Auth + uses: google-github-actions/auth@v2 + with: + credentials_json: ${{ secrets.DOCKER_REGISTRY_WRITER}} + + - name: Set up GCloud CLI + uses: google-github-actions/setup-gcloud@v2 + + - name: Docker Auth + run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet + + - name: Get branch name and sanitize + id: branch + run: | + BRANCH_NAME="${GITHUB_REF##*/}" + SANITIZED_BRANCH="${BRANCH_NAME//\//-}" + echo "branch_name=$SANITIZED_BRANCH" >> $GITHUB_OUTPUT + + - name: Get short git commit SHA + id: sha + run: | + calculatedSha=$(git rev-parse --short ${{ github.sha }}) + echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV + + - name: Create and push multi-arch manifest + run: | + docker manifest create us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ steps.sha.outputs.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} \ + --amend us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ steps.sha.outputs.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-x64 \ + --amend us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ steps.sha.outputs.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-ARM64 + docker manifest push us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ steps.sha.outputs.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} diff --git a/ext/central-controller-docker/Dockerfile.conda b/ext/central-controller-docker/Dockerfile.conda new file mode 100644 index 0000000000..0358240c71 --- /dev/null +++ b/ext/central-controller-docker/Dockerfile.conda @@ -0,0 +1,23 @@ +FROM golang:bookworm AS go_base +RUN go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest + + +FROM continuumio/miniconda3:25.3.1-1 + +LABEL maintainer="ZeroTier Inc." + +ADD environment.yml /tmp/environment.yml + +RUN conda env create -f /tmp/environment.yml && \ + conda clean -a -y + +COPY --from=go_base /go/bin/migrate /usr/local/bin/migrate +COPY ext/central-controller-docker/migrations /migrations +ADD build/zerotier-one /usr/local/bin/zerotier-one +RUN chmod a+x /usr/local/bin/zerotier-one +# RUN echo "/usr/local/lib64" > /etc/ld.so.conf.d/usr-local-lib64.conf && ldconfig + +ADD ext/central-controller-docker/main.sh / +RUN chmod a+x /main.sh + +ENTRYPOINT ["/main.sh"] diff --git a/ext/central-controller-docker/Dockerfile.run_base2 b/ext/central-controller-docker/Dockerfile.run_base2 deleted file mode 100644 index c64f04ab67..0000000000 --- a/ext/central-controller-docker/Dockerfile.run_base2 +++ /dev/null @@ -1,23 +0,0 @@ -FROM continuumio/miniconda3:25.3.1-1 - -LABEL maintainer="ZeroTier Inc." - -RUN conda config --set channel_priority strict && \ - conda install -y -c conda-forge \ - conda-forge::cmake=3.25.1 \ - conda-forge::git \ - conda-forge::cxx-compiler \ - conda-forge::c-compiler \ - conda-forge::make \ - conda-forge::pkg-config \ - conda-forge::libpqxx=7.7.3 \ - conda-forge::libopentelemetry-cpp=1.21.0 \ - conda-forge::libopentelemetry-cpp-headers=1.21.0 \ - conda-forge::google-cloud-cpp=2.39.0 \ - conda-forge::libgoogle-cloud=2.39.0 \ - conda-forge::rust=1.89.0 \ - conda-forge::inja=3.3.0 \ - conda-forge::libhiredis=1.3.0 \ - conda-forge::nlohmann_json=3.12.0 - -# ADD . /src \ No newline at end of file From 7fd112eb4feb8a15d5d2a6dbbce1488e1a57ae12 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 11:50:09 -0700 Subject: [PATCH 061/245] fix short hash --- .github/workflows/central-controller.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index 4fb340227b..8f91db27c0 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -66,8 +66,8 @@ jobs: - name: Build and push Docker Image run: | - docker build -t us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ steps.sha.outputs.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} -f ext/central-controller-docker/Dockerfile.conda . - docker push us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ steps.sha.outputs.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} + docker build -t us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} -f ext/central-controller-docker/Dockerfile.conda . + docker push us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} multi-arch-docker: runs-on: gha-runner-x64 @@ -99,7 +99,7 @@ jobs: - name: Create and push multi-arch manifest run: | - docker manifest create us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ steps.sha.outputs.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} \ - --amend us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ steps.sha.outputs.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-x64 \ - --amend us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ steps.sha.outputs.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-ARM64 - docker manifest push us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ steps.sha.outputs.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} + docker manifest create us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} \ + --amend us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-x64 \ + --amend us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-ARM64 + docker manifest push us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} From 594d227f9250f63679cbb84cfd19f05c653fa69e Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 12:18:21 -0700 Subject: [PATCH 062/245] fix multi-arch manifest creation --- .github/workflows/central-controller.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index 8f91db27c0..a78fe11f93 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -73,6 +73,9 @@ jobs: runs-on: gha-runner-x64 needs: central_controller steps: + - name: Checkout + uses: actions/checkout@v4 + - name: GCP Auth uses: google-github-actions/auth@v2 with: @@ -100,6 +103,6 @@ jobs: - name: Create and push multi-arch manifest run: | docker manifest create us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} \ - --amend us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-x64 \ + --amend us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-X64 \ --amend us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-ARM64 docker manifest push us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} From 4abf90247d8a4b0024d6010693319893667bcfba Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 13:22:21 -0700 Subject: [PATCH 063/245] update ld.so.conf for paths to libraries --- ext/central-controller-docker/Dockerfile.conda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/central-controller-docker/Dockerfile.conda b/ext/central-controller-docker/Dockerfile.conda index 0358240c71..311dd8705f 100644 --- a/ext/central-controller-docker/Dockerfile.conda +++ b/ext/central-controller-docker/Dockerfile.conda @@ -15,7 +15,7 @@ COPY --from=go_base /go/bin/migrate /usr/local/bin/migrate COPY ext/central-controller-docker/migrations /migrations ADD build/zerotier-one /usr/local/bin/zerotier-one RUN chmod a+x /usr/local/bin/zerotier-one -# RUN echo "/usr/local/lib64" > /etc/ld.so.conf.d/usr-local-lib64.conf && ldconfig +RUN echo "/opt/conda/envs/central_controller/lib" > /etc/ld.so.conf.d/conda-central-controller.conf && ldconfig ADD ext/central-controller-docker/main.sh / RUN chmod a+x /main.sh From 9d73c346b7ea5510f2f62cfd0d1f2e1e3f8f1a90 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 13:48:38 -0700 Subject: [PATCH 064/245] new modified startup script for central controller docker images with support for configuring bigtable, pubsub, redis --- .../Dockerfile.conda | 2 +- ext/central-controller-docker/main-new.sh | 166 ++++++++++++++++++ 2 files changed, 167 insertions(+), 1 deletion(-) create mode 100755 ext/central-controller-docker/main-new.sh diff --git a/ext/central-controller-docker/Dockerfile.conda b/ext/central-controller-docker/Dockerfile.conda index 311dd8705f..844e01ec22 100644 --- a/ext/central-controller-docker/Dockerfile.conda +++ b/ext/central-controller-docker/Dockerfile.conda @@ -17,7 +17,7 @@ ADD build/zerotier-one /usr/local/bin/zerotier-one RUN chmod a+x /usr/local/bin/zerotier-one RUN echo "/opt/conda/envs/central_controller/lib" > /etc/ld.so.conf.d/conda-central-controller.conf && ldconfig -ADD ext/central-controller-docker/main.sh / +ADD ext/central-controller-docker/main-new.sh /main.sh RUN chmod a+x /main.sh ENTRYPOINT ["/main.sh"] diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh new file mode 100755 index 0000000000..f3e48b3245 --- /dev/null +++ b/ext/central-controller-docker/main-new.sh @@ -0,0 +1,166 @@ +#!/bin/bash + +conda activate central_controller + +if [ -z "$ZT_DB_HOST" ]; then + echo '*** FAILED: ZT_DB_HOST environment variable not defined' + exit 1 +fi +if [ -z "$ZT_DB_PORT" ]; then + echo '*** FAILED: ZT_DB_PORT environment variable not defined' + exit 1 +fi +if [ -z "$ZT_DB_NAME" ]; then + echo '*** FAILED: ZT_DB_NAME environment variable not defined' + exit 1 +fi +if [ -z "$ZT_DB_USER" ]; then + echo '*** FAILED: ZT_DB_USER environment variable not defined' + exit 1 +fi +if [ -z "$ZT_DB_PASSWORD" ]; then + echo '*** FAILED: ZT_DB_PASSWORD environment variable not defined' + exit 1 +fi + +REDIS="" +if [ "$ZT_USE_REDIS" == "true" ]; then + if [ -z "$ZT_REDIS_HOST" ]; then + echo '*** FAILED: ZT_REDIS_HOST environment variable not defined' + exit 1 + fi + + if [ -z "$ZT_REDIS_PORT" ]; then + echo '*** FAILED: ZT_REDIS_PORT enivronment variable not defined' + exit 1 + fi + + if [ -z "$ZT_REDIS_CLUSTER_MODE" ]; then + echo '*** FAILED: ZT_REDIS_CLUSTER_MODE environment variable not defined' + exit 1 + fi + + REDIS=", \"redis\": { + \"hostname\": \"${ZT_REDIS_HOST}\", + \"port\": ${ZT_REDIS_PORT}, + \"clusterMode\": ${ZT_REDIS_CLUSTER_MODE}, + \"password\": \"${ZT_REDIS_PASSWORD}\" + } + " +else + REDIS="\"redis\": null" +fi + +mkdir -p /var/lib/zerotier-one + +pushd /var/lib/zerotier-one +if [ -d "$ZT_IDENTITY_PATH" ]; then + echo '*** Using existing ZT identity from path $ZT_IDENTITY_PATH' + + ln -s $ZT_IDENTITY_PATH/identity.public identity.public + ln -s $ZT_IDENTITY_PATH/identity.secret identity.secret + if [ -L "$ZT_IDENTITY_PATH/authtoken.secret" ] && [ -e "$ZT_IDENTITY_PATH/authtoken.secret" ]; then + ln -s $ZT_IDENTITY_PATH/authtoken.secret authtoken.secret + ln -s $ZT_IDENTITY_PATH/authtoken.secret metricstoken.secret + fi +fi +popd + +DEFAULT_PORT=9993 +DEFAULT_LB_MODE=false + +APP_NAME="controller-$(cat /var/lib/zerotier-one/identity.public | cut -d ':' -f 1)" + +BIGTABLE_CONF="" +if [ "$ZT_USE_BIGTABLE" == "true" ]; then + if [ -z "$ZT_BIGTABLE_PROJECT" ] || [ -z "$ZT_BIGTABLE_INSTANCE" ] || [ -z "$ZT_BIGTABLE_TABLE" ]; then + echo '*** FAILED: ZT_BIGTABLE_PROJECT, ZT_BIGTABLE_INSTANCE, and ZT_BIGTABLE_TABLE environment variables must all be defined to use Bigtable as a controller backend' + exit 1 + fi + + BIGTABLE_CONF=", \"bigtable\": { + \"project\": \"${ZT_BIGTABLE_PROJECT}\", + \"instance\": \"${ZT_BIGTABLE_INSTANCE}\", + \"table\": \"${ZT_BIGTABLE_TABLE}\" + }, + " +fi + + +PUBSUB_CONF="" +if [ "$ZT_USE_PUBSUB" == "true" ]; then + if [ -z "$ZT_PUBSUB_PROJECT" ]; then + echo '*** FAILED: ZT_PUBSUB_PROJECT environment variable must be defined to use PubSub as a controller backend' + exit 1 + fi + + PUBSUB_CONF=", \"pubsub\": { + \"project\": \"${ZT_CTL_PUBSUB_PROJECT}\" + } + " +fi + +echo "{ + \"settings\": { + \"controllerDbPath\": \"postgres:host=${ZT_DB_HOST} port=${ZT_DB_PORT} dbname=${ZT_DB_NAME} user=${ZT_DB_USER} password=${ZT_DB_PASSWORD} application_name=${APP_NAME} sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}\", + \"portMappingEnabled\": true, + \"softwareUpdate\": \"disable\", + \"interfacePrefixBlacklist\": [ + \"inot\", + \"nat64\" + ], + \"lowBandwidthMode\": ${ZT_LB_MODE:-$DEFAULT_LB_MODE}, + \"ssoRedirectURL\": \"${ZT_SSO_REDIRECT_URL}\", + \"allowManagementFrom\": [\"127.0.0.1\", \"::1\", \"10.0.0.0/8\"], + \"otel\": { + \"exporterEndpoint\": \"${ZT_EXPORTER_ENDPOINT}\", + \"exporterSampleRate\": ${ZT_EXPORTER_SAMPLE_RATE:-0} + } + ${REDIS} + }, + \"controller\": { + \"listenMode\": \"${ZT_LISTEN_MODE:-pgsql}\", + \"statusMode\": \"`${ZT_STATUS_MODE:-pgsql}\" + ${REDIS} + ${BIGTABLE_CONF} + ${PUBSUB_CONF} + } +} +" > /var/lib/zerotier-one/local.conf + +if [ -n "$DB_SERVER_CA" ]; then + echo "secret list" + chmod 600 /secrets/db/*.pem + ls -l /secrets/db/ + until /usr/bin/pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT} -d "sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}"; do + echo "Waiting for PostgreSQL..."; + sleep 2; + done +else + until /usr/bin/pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT}; do + echo "Waiting for PostgreSQL..."; + sleep 2; + done +fi + + +echo "Migrating database (if needed)..." +if [ -n "$DB_SERVER_CA" ]; then + /usr/local/bin/migrate -source file:///migrations -database "postgres://$ZT_DB_USER:$ZT_DB_PASSWORD@$ZT_DB_HOST:$ZT_DB_PORT/$ZT_DB_NAME?x-migrations-table=controller_migrations&sslmode=verify-full&sslrootcert=$DB_SERVER_CA&sslcert=$DB_CLIENT_CERT&sslkey=$DB_CLIENT_KEY" up +else + /usr/local/bin/migrate -source file:///migrations -database "postgres://$ZT_DB_USER:$ZT_DB_PASSWORD@$ZT_DB_HOST:$ZT_DB_PORT/$ZT_DB_NAME?x-migrations-table=controller_migrations&sslmode=disable" up +fi + +if [ -n "$ZT_TEMPORAL_HOST" ] && [ -n "$ZT_TEMPORAL_PORT" ]; then + echo "waiting for temporal..." + while ! nc -z ${ZT_TEMPORAL_HOST} ${ZT_TEMPORAL_PORT}; do + echo "waiting..."; + sleep 1; + done + echo "Temporal is up" +fi + +export GLIBCXX_FORCE_NEW=1 +export GLIBCPP_FORCE_NEW=1 +export LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libjemalloc.so.2" +exec /usr/local/bin/zerotier-one -p${ZT_CONTROLLER_PORT:-$DEFAULT_PORT} /var/lib/zerotier-one From 3ad352c08e2ddca6ed26ac349c6cb137a051eda8 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 13:56:04 -0700 Subject: [PATCH 065/245] no trailing comma on bigtable block --- ext/central-controller-docker/main-new.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index f3e48b3245..fbd646e4d2 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -79,10 +79,10 @@ if [ "$ZT_USE_BIGTABLE" == "true" ]; then fi BIGTABLE_CONF=", \"bigtable\": { - \"project\": \"${ZT_BIGTABLE_PROJECT}\", - \"instance\": \"${ZT_BIGTABLE_INSTANCE}\", - \"table\": \"${ZT_BIGTABLE_TABLE}\" - }, + \"project\": \"${ZT_BIGTABLE_PROJECT}\", + \"instance\": \"${ZT_BIGTABLE_INSTANCE}\", + \"table\": \"${ZT_BIGTABLE_TABLE}\" + } " fi From 6ceb8eac97e2292eecfceca9f374bced65b06306 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 13:56:32 -0700 Subject: [PATCH 066/245] text alignment --- ext/central-controller-docker/main-new.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index fbd646e4d2..dd967594f6 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -95,9 +95,9 @@ if [ "$ZT_USE_PUBSUB" == "true" ]; then fi PUBSUB_CONF=", \"pubsub\": { - \"project\": \"${ZT_CTL_PUBSUB_PROJECT}\" - } - " + \"project\": \"${ZT_CTL_PUBSUB_PROJECT}\" + } +" fi echo "{ From 4f07599992da3d55045a850950f08f54b7379b28 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 3 Sep 2025 15:04:51 -0700 Subject: [PATCH 067/245] add jemalloc --- environment.yml | 1 + ext/central-controller-docker/main-new.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/environment.yml b/environment.yml index 6ac54a314f..9a51cb7b7e 100644 --- a/environment.yml +++ b/environment.yml @@ -17,3 +17,4 @@ dependencies: - conda-forge::inja=3.3.0 - conda-forge::libhiredis=1.3.0 - conda-forge::nlohmann_json=3.12.0 + - conda-forge::jemalloc=5.3.0 diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index dd967594f6..40c336792d 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -162,5 +162,5 @@ fi export GLIBCXX_FORCE_NEW=1 export GLIBCPP_FORCE_NEW=1 -export LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libjemalloc.so.2" +export LD_PRELOAD="/opt/conda/envs/central_controller/lib/libjemalloc.so.2" exec /usr/local/bin/zerotier-one -p${ZT_CONTROLLER_PORT:-$DEFAULT_PORT} /var/lib/zerotier-one From 2416c42df707b40abefe7fbbb5d93e16cf7bb7f5 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 08:48:54 -0700 Subject: [PATCH 068/245] change tag to match existing --- .github/workflows/central-controller.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index a78fe11f93..9a48b94569 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -66,8 +66,8 @@ jobs: - name: Build and push Docker Image run: | - docker build -t us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} -f ext/central-controller-docker/Dockerfile.conda . - docker push us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} + docker build -t us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} -f ext/central-controller-docker/Dockerfile.conda . + docker push us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} multi-arch-docker: runs-on: gha-runner-x64 @@ -75,7 +75,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - + - name: GCP Auth uses: google-github-actions/auth@v2 with: @@ -102,7 +102,7 @@ jobs: - name: Create and push multi-arch manifest run: | - docker manifest create us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} \ - --amend us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-X64 \ - --amend us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-ARM64 - docker manifest push us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/central-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} + docker manifest create us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} \ + --amend us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-X64 \ + --amend us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-ARM64 + docker manifest push us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} From 4516e6a34074718deeb87c81a371eb6116173e0c Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 09:27:08 -0700 Subject: [PATCH 069/245] need a conda init here first apparently --- ext/central-controller-docker/main-new.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index 40c336792d..324101230b 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -1,5 +1,6 @@ #!/bin/bash +conda init conda activate central_controller if [ -z "$ZT_DB_HOST" ]; then From 96aa893df43a49c9d5182ca1635dcc800449deea Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 09:50:19 -0700 Subject: [PATCH 070/245] stray backtick --- ext/central-controller-docker/main-new.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index 324101230b..2aa177b3c0 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -121,7 +121,7 @@ echo "{ }, \"controller\": { \"listenMode\": \"${ZT_LISTEN_MODE:-pgsql}\", - \"statusMode\": \"`${ZT_STATUS_MODE:-pgsql}\" + \"statusMode\": \"${ZT_STATUS_MODE:-pgsql}\" ${REDIS} ${BIGTABLE_CONF} ${PUBSUB_CONF} From 158d24545a1d2619e8d8b554097dba871dc44e98 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 10:30:08 -0700 Subject: [PATCH 071/245] also have to add postgres to the container for pg_isready --- environment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/environment.yml b/environment.yml index 9a51cb7b7e..53d15b3662 100644 --- a/environment.yml +++ b/environment.yml @@ -18,3 +18,4 @@ dependencies: - conda-forge::libhiredis=1.3.0 - conda-forge::nlohmann_json=3.12.0 - conda-forge::jemalloc=5.3.0 + - conda-forge::postgresql=17.6 From 1da9e24905be89f61dd4299fbac25000d7e0bb4c Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 11:03:30 -0700 Subject: [PATCH 072/245] no absolute path for pg_isready --- ext/central-controller-docker/main-new.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index 2aa177b3c0..a967daa5cf 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -133,12 +133,12 @@ if [ -n "$DB_SERVER_CA" ]; then echo "secret list" chmod 600 /secrets/db/*.pem ls -l /secrets/db/ - until /usr/bin/pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT} -d "sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}"; do + until pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT} -d "sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}"; do echo "Waiting for PostgreSQL..."; sleep 2; done else - until /usr/bin/pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT}; do + until pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT}; do echo "Waiting for PostgreSQL..."; sleep 2; done From 092fc268d326ce8397396fd4017b6973cb540180 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 11:11:14 -0700 Subject: [PATCH 073/245] ok back to full path --- ext/central-controller-docker/main-new.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index a967daa5cf..79249e5794 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -133,12 +133,12 @@ if [ -n "$DB_SERVER_CA" ]; then echo "secret list" chmod 600 /secrets/db/*.pem ls -l /secrets/db/ - until pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT} -d "sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}"; do + until /opt/conda/envs/central_controller/bin/pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT} -d "sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}"; do echo "Waiting for PostgreSQL..."; sleep 2; done else - until pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT}; do + until /opt/conda/envs/central_controller/bin/pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT}; do echo "Waiting for PostgreSQL..."; sleep 2; done From d216a3739f2b01f196361169d0076f1b3ee68f33 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 11:14:34 -0700 Subject: [PATCH 074/245] run process in conda env directly from docker --- ext/central-controller-docker/Dockerfile.conda | 4 +++- ext/central-controller-docker/main-new.sh | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ext/central-controller-docker/Dockerfile.conda b/ext/central-controller-docker/Dockerfile.conda index 844e01ec22..6c131abe8e 100644 --- a/ext/central-controller-docker/Dockerfile.conda +++ b/ext/central-controller-docker/Dockerfile.conda @@ -20,4 +20,6 @@ RUN echo "/opt/conda/envs/central_controller/lib" > /etc/ld.so.conf.d/conda-cent ADD ext/central-controller-docker/main-new.sh /main.sh RUN chmod a+x /main.sh -ENTRYPOINT ["/main.sh"] +SHELL ["conda", "run", "--no-capture-output", "-n", "central_controller", "/bin/bash", "-c"] + +ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "central_controller", "/main.sh"] diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index 79249e5794..08f427bf9e 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -1,7 +1,7 @@ #!/bin/bash -conda init -conda activate central_controller +# conda init +# conda activate central_controller if [ -z "$ZT_DB_HOST" ]; then echo '*** FAILED: ZT_DB_HOST environment variable not defined' @@ -133,12 +133,12 @@ if [ -n "$DB_SERVER_CA" ]; then echo "secret list" chmod 600 /secrets/db/*.pem ls -l /secrets/db/ - until /opt/conda/envs/central_controller/bin/pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT} -d "sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}"; do + until pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT} -d "sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}"; do echo "Waiting for PostgreSQL..."; sleep 2; done else - until /opt/conda/envs/central_controller/bin/pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT}; do + until pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT}; do echo "Waiting for PostgreSQL..."; sleep 2; done From c9c8e95d60b6b6389e1f242989b621b421d74fd9 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 11:16:48 -0700 Subject: [PATCH 075/245] debug output of main script --- ext/central-controller-docker/main-new.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index 08f427bf9e..e54e197fde 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -165,3 +165,8 @@ export GLIBCXX_FORCE_NEW=1 export GLIBCPP_FORCE_NEW=1 export LD_PRELOAD="/opt/conda/envs/central_controller/lib/libjemalloc.so.2" exec /usr/local/bin/zerotier-one -p${ZT_CONTROLLER_PORT:-$DEFAULT_PORT} /var/lib/zerotier-one +if [ $? -ne 0 ]; then + echo '*** FAILED: zerotier-one exited unexpectedly' + cat /var/lib/zerotier-one/local.conf + exit 1 +fi \ No newline at end of file From b94fa2d95da5c136885e2d4f149201d9ccb6c1d8 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 11:18:08 -0700 Subject: [PATCH 076/245] . --- ext/central-controller-docker/main-new.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index e54e197fde..093603d580 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -164,7 +164,8 @@ fi export GLIBCXX_FORCE_NEW=1 export GLIBCPP_FORCE_NEW=1 export LD_PRELOAD="/opt/conda/envs/central_controller/lib/libjemalloc.so.2" -exec /usr/local/bin/zerotier-one -p${ZT_CONTROLLER_PORT:-$DEFAULT_PORT} /var/lib/zerotier-one +#exec +/usr/local/bin/zerotier-one -p${ZT_CONTROLLER_PORT:-$DEFAULT_PORT} /var/lib/zerotier-one if [ $? -ne 0 ]; then echo '*** FAILED: zerotier-one exited unexpectedly' cat /var/lib/zerotier-one/local.conf From 7e4e7ef753d751af98a20fd3fda54899cfb0c90f Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 11:19:22 -0700 Subject: [PATCH 077/245] fix case for redis: null --- ext/central-controller-docker/main-new.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index 093603d580..d2e3e6056f 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -49,7 +49,7 @@ if [ "$ZT_USE_REDIS" == "true" ]; then } " else - REDIS="\"redis\": null" + REDIS=", \"redis\": null" fi mkdir -p /var/lib/zerotier-one From ce84de605d1413319f702d42eb5cfc4f59c3333b Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 11:24:01 -0700 Subject: [PATCH 078/245] and instead of or in postgres check --- nonfree/controller/EmbeddedNetworkController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nonfree/controller/EmbeddedNetworkController.cpp b/nonfree/controller/EmbeddedNetworkController.cpp index dd8092603b..05332f936c 100644 --- a/nonfree/controller/EmbeddedNetworkController.cpp +++ b/nonfree/controller/EmbeddedNetworkController.cpp @@ -651,7 +651,7 @@ void EmbeddedNetworkController::init(const Identity& signingId, Sender* sender) throw std::runtime_error("controller config required"); } - if (_path.length() > 9 || (_path.substr(0, 9) != "postgres:")) { + if (_path.length() > 9 && (_path.substr(0, 9) != "postgres:")) { throw std::runtime_error("central controller requires postgres db"); } From 686653509a076520f6d5aa6713e12511583d4b06 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 11:27:59 -0700 Subject: [PATCH 079/245] debug printf --- nonfree/controller/CentralDB.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index c102dab28f..a7471129f1 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -88,6 +88,7 @@ CentralDB::CentralDB( char myAddress[64]; _myAddressStr = myId.address().toString(myAddress); _connString = std::string(connString); + fprintf(stderr, "connstring: %s\n", _connString.c_str()); auto f = std::make_shared(_connString); _pool = std::make_shared >(15, 5, std::static_pointer_cast(f)); From f33e706887cb872e346963fee42ab54aa874646d Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 11:42:53 -0700 Subject: [PATCH 080/245] get a running controller in docker --- ext/central-controller-docker/main-new.sh | 8 +----- nonfree/controller/CentralDB.cpp | 25 +------------------ .../controller/EmbeddedNetworkController.cpp | 4 +-- 3 files changed, 4 insertions(+), 33 deletions(-) diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index d2e3e6056f..f40933ef2c 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -164,10 +164,4 @@ fi export GLIBCXX_FORCE_NEW=1 export GLIBCPP_FORCE_NEW=1 export LD_PRELOAD="/opt/conda/envs/central_controller/lib/libjemalloc.so.2" -#exec -/usr/local/bin/zerotier-one -p${ZT_CONTROLLER_PORT:-$DEFAULT_PORT} /var/lib/zerotier-one -if [ $? -ne 0 ]; then - echo '*** FAILED: zerotier-one exited unexpectedly' - cat /var/lib/zerotier-one/local.conf - exit 1 -fi \ No newline at end of file +exec /usr/local/bin/zerotier-one -p${ZT_CONTROLLER_PORT:-$DEFAULT_PORT} /var/lib/zerotier-one diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index a7471129f1..fd5b07c625 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -42,12 +42,6 @@ using json = nlohmann::json; -namespace { - -static const int DB_MINIMUM_VERSION = 38; - -} // anonymous namespace - using namespace ZeroTier; using Attrs = std::vector >; @@ -88,7 +82,7 @@ CentralDB::CentralDB( char myAddress[64]; _myAddressStr = myId.address().toString(myAddress); _connString = std::string(connString); - fprintf(stderr, "connstring: %s\n", _connString.c_str()); + auto f = std::make_shared(_connString); _pool = std::make_shared >(15, 5, std::static_pointer_cast(f)); @@ -110,23 +104,6 @@ CentralDB::CentralDB( fprintf(stderr, "Using redis for member status\n"); } - auto c = _pool->borrow(); - pqxx::work txn { *c->c }; - - pqxx::row r { txn.exec1("SELECT version FROM ztc_database") }; - int dbVersion = r[0].as(); - txn.commit(); - - if (dbVersion < DB_MINIMUM_VERSION) { - fprintf( - stderr, - "Central database schema version too low. This controller version requires a minimum schema version of " - "%d. Please upgrade your Central instance", - DB_MINIMUM_VERSION); - exit(1); - } - _pool->unborrow(c); - if ((listenMode == LISTENER_MODE_REDIS || statusMode == STATUS_WRITER_MODE_REDIS) && _cc->redisConfig != NULL) { auto innerspan = tracer->StartSpan("CentralDB::CentralDB::configureRedis"); auto innerscope = tracer->WithActiveSpan(innerspan); diff --git a/nonfree/controller/EmbeddedNetworkController.cpp b/nonfree/controller/EmbeddedNetworkController.cpp index 05332f936c..c708e4f3b3 100644 --- a/nonfree/controller/EmbeddedNetworkController.cpp +++ b/nonfree/controller/EmbeddedNetworkController.cpp @@ -655,7 +655,7 @@ void EmbeddedNetworkController::init(const Identity& signingId, Sender* sender) throw std::runtime_error("central controller requires postgres db"); } - const char* connString = _path.substr(9).c_str(); + std::string connString = _path.substr(9); CentralDB::ListenerMode lm; if (_cc->listenMode == "pgsql") { @@ -685,7 +685,7 @@ void EmbeddedNetworkController::init(const Identity& signingId, Sender* sender) throw std::runtime_error("unsupported status mode"); } - _db.addDB(std::shared_ptr(new CentralDB(_signingId, connString, _listenPort, lm, sm, _cc))); + _db.addDB(std::shared_ptr(new CentralDB(_signingId, connString.c_str(), _listenPort, lm, sm, _cc))); #else #ifdef ZT_CONTROLLER_USE_LIBPQ if ((_path.length() > 9) && (_path.substr(0, 9) == "postgres:")) { From 73e3287fd662ef2063157bed2eadc4f188dcb880 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 12:14:32 -0700 Subject: [PATCH 081/245] debugging runtime link issues on arm64 --- ext/central-controller-docker/Dockerfile.conda | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ext/central-controller-docker/Dockerfile.conda b/ext/central-controller-docker/Dockerfile.conda index 6c131abe8e..2193cbc735 100644 --- a/ext/central-controller-docker/Dockerfile.conda +++ b/ext/central-controller-docker/Dockerfile.conda @@ -8,8 +8,7 @@ LABEL maintainer="ZeroTier Inc." ADD environment.yml /tmp/environment.yml -RUN conda env create -f /tmp/environment.yml && \ - conda clean -a -y +RUN conda env create -f /tmp/environment.yml COPY --from=go_base /go/bin/migrate /usr/local/bin/migrate COPY ext/central-controller-docker/migrations /migrations From 2264452ad874c0f9551fc6bc23f4d70e59dc30ca Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 12:19:53 -0700 Subject: [PATCH 082/245] try to make this work on both x64 & arm64 --- ext/central-controller-docker/Dockerfile.conda | 4 ++-- ext/central-controller-docker/main-new.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/central-controller-docker/Dockerfile.conda b/ext/central-controller-docker/Dockerfile.conda index 2193cbc735..ad73f9d4ca 100644 --- a/ext/central-controller-docker/Dockerfile.conda +++ b/ext/central-controller-docker/Dockerfile.conda @@ -14,8 +14,8 @@ COPY --from=go_base /go/bin/migrate /usr/local/bin/migrate COPY ext/central-controller-docker/migrations /migrations ADD build/zerotier-one /usr/local/bin/zerotier-one RUN chmod a+x /usr/local/bin/zerotier-one -RUN echo "/opt/conda/envs/central_controller/lib" > /etc/ld.so.conf.d/conda-central-controller.conf && ldconfig - +# RUN echo "/opt/conda/envs/central_controller/lib" > /etc/ld.so.conf.d/conda-central-controller.conf +# RUN echo "/opt/conda/envs/central_controller/x86_64-conda-linux-gnu/lib" > /etc/ld.so.conf.d/conda-central-controller-gnu.conf && ldconfig ADD ext/central-controller-docker/main-new.sh /main.sh RUN chmod a+x /main.sh diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index f40933ef2c..9901c28271 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -1,7 +1,7 @@ #!/bin/bash # conda init -# conda activate central_controller +conda activate central_controller if [ -z "$ZT_DB_HOST" ]; then echo '*** FAILED: ZT_DB_HOST environment variable not defined' From 7d5a60b44ebeff38b41af91db1d710bbd4ac240f Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 13:08:27 -0700 Subject: [PATCH 083/245] will this make arm64 containers work? --- ext/central-controller-docker/Dockerfile.conda | 15 ++++++++------- ext/central-controller-docker/main-new.sh | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ext/central-controller-docker/Dockerfile.conda b/ext/central-controller-docker/Dockerfile.conda index ad73f9d4ca..5c7e5314b9 100644 --- a/ext/central-controller-docker/Dockerfile.conda +++ b/ext/central-controller-docker/Dockerfile.conda @@ -6,19 +6,20 @@ FROM continuumio/miniconda3:25.3.1-1 LABEL maintainer="ZeroTier Inc." -ADD environment.yml /tmp/environment.yml - -RUN conda env create -f /tmp/environment.yml +ADD environment.yml /environment.yml +RUN conda env create -f /environment.yml && \ + conda clean -a -y +SHELL ["conda", "run", "--no-capture-output", "-n", "central_controller", "/bin/bash", "-c"] COPY --from=go_base /go/bin/migrate /usr/local/bin/migrate COPY ext/central-controller-docker/migrations /migrations ADD build/zerotier-one /usr/local/bin/zerotier-one RUN chmod a+x /usr/local/bin/zerotier-one -# RUN echo "/opt/conda/envs/central_controller/lib" > /etc/ld.so.conf.d/conda-central-controller.conf -# RUN echo "/opt/conda/envs/central_controller/x86_64-conda-linux-gnu/lib" > /etc/ld.so.conf.d/conda-central-controller-gnu.conf && ldconfig +RUN echo "/opt/conda/envs/central_controller/lib" > /etc/ld.so.conf.d/conda-central-controller.conf && \ + echo "/opt/conda/envs/central_controller/`uname -m`-conda-linux-gnu/lib" > /etc/ld.so.conf.d/conda-central-controller-x64.conf && \ + ldconfig + ADD ext/central-controller-docker/main-new.sh /main.sh RUN chmod a+x /main.sh -SHELL ["conda", "run", "--no-capture-output", "-n", "central_controller", "/bin/bash", "-c"] - ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "central_controller", "/main.sh"] diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index 9901c28271..f40933ef2c 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -1,7 +1,7 @@ #!/bin/bash # conda init -conda activate central_controller +# conda activate central_controller if [ -z "$ZT_DB_HOST" ]; then echo '*** FAILED: ZT_DB_HOST environment variable not defined' From 40f650871741f49d106357ee0b3e100804790184 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 13:50:11 -0700 Subject: [PATCH 084/245] add conda builder dockerfile --- .../Dockerfile.conda_builder | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 ext/central-controller-docker/Dockerfile.conda_builder diff --git a/ext/central-controller-docker/Dockerfile.conda_builder b/ext/central-controller-docker/Dockerfile.conda_builder new file mode 100644 index 0000000000..131a90c691 --- /dev/null +++ b/ext/central-controller-docker/Dockerfile.conda_builder @@ -0,0 +1,11 @@ +FROM continuumio/miniconda3:25.3.1-1 + +LABEL maintainer="ZeroTier Inc." + +ADD environment.yml /environment.yml +RUN conda env create -f /environment.yml && \ + conda clean -a -y + +ADD . /ZeroTierOne +SHELL ["conda", "run", "--no-capture-output", "-n", "central_controller", "/bin/bash", "-c"] +ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "central_controller", "/bin/bash"] \ No newline at end of file From 70d24fc7eb1c3c9f1a8a96a31d8c66461c224dfd Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 14:02:58 -0700 Subject: [PATCH 085/245] trying to build in a docker container --- environment.yml => conda_env_build.yml | 1 - conda_env_run.yml | 14 +++++++++++ .../Dockerfile.conda | 2 +- .../Dockerfile.conda_builder | 3 +-- ext/central-controller-docker/Dockerfile.new | 25 +++++++++++++++++++ 5 files changed, 41 insertions(+), 4 deletions(-) rename environment.yml => conda_env_build.yml (94%) create mode 100644 conda_env_run.yml create mode 100644 ext/central-controller-docker/Dockerfile.new diff --git a/environment.yml b/conda_env_build.yml similarity index 94% rename from environment.yml rename to conda_env_build.yml index 53d15b3662..9a51cb7b7e 100644 --- a/environment.yml +++ b/conda_env_build.yml @@ -18,4 +18,3 @@ dependencies: - conda-forge::libhiredis=1.3.0 - conda-forge::nlohmann_json=3.12.0 - conda-forge::jemalloc=5.3.0 - - conda-forge::postgresql=17.6 diff --git a/conda_env_run.yml b/conda_env_run.yml new file mode 100644 index 0000000000..3ad8b606f2 --- /dev/null +++ b/conda_env_run.yml @@ -0,0 +1,14 @@ +name: central_controller +channels: + - conda-forge +dependencies: + - conda-forge::pkg-config + - conda-forge::libpqxx=7.10.1 + - conda-forge::libopentelemetry-cpp=1.21.0 + - conda-forge::google-cloud-cpp=2.38.0 + - conda-forge::libgoogle-cloud=2.38.0 + - conda-forge::inja=3.3.0 + - conda-forge::libhiredis=1.3.0 + - conda-forge::nlohmann_json=3.12.0 + - conda-forge::jemalloc=5.3.0 + - conda-forge::postgresql=17.6 diff --git a/ext/central-controller-docker/Dockerfile.conda b/ext/central-controller-docker/Dockerfile.conda index 5c7e5314b9..7d1bbc64cc 100644 --- a/ext/central-controller-docker/Dockerfile.conda +++ b/ext/central-controller-docker/Dockerfile.conda @@ -22,4 +22,4 @@ RUN echo "/opt/conda/envs/central_controller/lib" > /etc/ld.so.conf.d/conda-cent ADD ext/central-controller-docker/main-new.sh /main.sh RUN chmod a+x /main.sh -ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "central_controller", "/main.sh"] +ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "central_controller", "/bin/bash", "-c", "/main.sh"] diff --git a/ext/central-controller-docker/Dockerfile.conda_builder b/ext/central-controller-docker/Dockerfile.conda_builder index 131a90c691..42be3ab8bc 100644 --- a/ext/central-controller-docker/Dockerfile.conda_builder +++ b/ext/central-controller-docker/Dockerfile.conda_builder @@ -2,10 +2,9 @@ FROM continuumio/miniconda3:25.3.1-1 LABEL maintainer="ZeroTier Inc." -ADD environment.yml /environment.yml +ADD conda_env_build.yml /environment.yml RUN conda env create -f /environment.yml && \ conda clean -a -y -ADD . /ZeroTierOne SHELL ["conda", "run", "--no-capture-output", "-n", "central_controller", "/bin/bash", "-c"] ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "central_controller", "/bin/bash"] \ No newline at end of file diff --git a/ext/central-controller-docker/Dockerfile.new b/ext/central-controller-docker/Dockerfile.new new file mode 100644 index 0000000000..18245494cc --- /dev/null +++ b/ext/central-controller-docker/Dockerfile.new @@ -0,0 +1,25 @@ +FROM us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/controller_conda_builder:latest AS controller_conda_builder +ADD . /ZeroTierOne +WORKDIR /ZeroTierOne +SHELL ["conda", "run", "--no-capture-output", "-n", "central_controller", "/bin/bash", "-c"] +RUN cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DZT1_CENTRAL_CONTROLLER=1 && cmake --build build/ --target all -j4 --verbose + +FROM golang:bookworm AS go_base +RUN go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest + +FROM continuumio/miniconda3:25.3.1-1 +LABEL maintainer="ZeroTier Inc." +ADD conda_env_run.yml /environment.yml +RUN conda env create -f /environment.yml && \ + conda clean -a -y +SHELL ["conda", "run", "--no-capture-output", "-n", "central_controller", "/bin/bash", "-c"] +COPY --from=go_base /go/bin/migrate /usr/local/bin/migrate +COPY --from=controller_conda_builder /ZeroTierOne/build/zerotier-one /usr/local/bin/zerotier-one +COPY ext/central-controller-docker/migrations /migrations +RUN chmod a+x /usr/local/bin/zerotier-one +# RUN echo "/opt/conda/envs/central_controller/lib" > /etc/ld.so.conf.d/conda-central-controller.conf && \ +# echo "/opt/conda/envs/central_controller/`uname -m`-conda-linux-gnu/lib" > /etc/ld.so.conf.d/conda-central-controller-x64.conf && \ +# ldconfig +ADD ext/central-controller-docker/main-new.sh /main.sh +RUN chmod a+x /main.sh +ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "central_controller", "/bin/bash", "-c", "/main.sh"] \ No newline at end of file From 8bd96d360f02bcb62e239dbf570f6aeef506edf7 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 14:14:59 -0700 Subject: [PATCH 086/245] build in containers --- .github/workflows/central-controller.yaml | 75 ++++++++++++----------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index 9a48b94569..bc0730c13b 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -14,32 +14,47 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 - - name: Setup Miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - miniconda-version: latest - activate-environment: central_controller - - name: Conda Environment Cache - id: cache - uses: actions/cache@v4 - with: - path: ${{ env.CONDA }}/envs - key: ${{ runner.os }}-${{ runner.arch }}-${{ github.ref_name }}-conda-${{ hashFiles('environment.yml') }} - - name: Update Conda Environment - if: steps.cache.outputs.cache-hit != 'true' - run: | - source ~/miniconda3/etc/profile.d/conda.sh - conda env update --file environment.yml - - name: Build + # - name: Setup Miniconda + # uses: conda-incubator/setup-miniconda@v3 + # with: + # miniconda-version: latest + # activate-environment: central_controller + # - name: Conda Environment Cache + # id: cache + # uses: actions/cache@v4 + # with: + # path: ${{ env.CONDA }}/envs + # key: ${{ runner.os }}-${{ runner.arch }}-${{ github.ref_name }}-conda-${{ hashFiles('environment.yml') }} + # - name: Update Conda Environment + # if: steps.cache.outputs.cache-hit != 'true' + # run: | + # source ~/miniconda3/etc/profile.d/conda.sh + # conda env update --file environment.yml + # - name: Build + # run: | + # source ~/miniconda3/etc/profile.d/conda.sh + # conda activate central_controller + # cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DZT1_CENTRAL_CONTROLLER=1 + # cmake --build build/ --target all -j4 --verbose + # - name: SelfTest + # run: | + # ./build/zerotier-selftest + - name: Get branch name and sanitize + id: branch run: | - source ~/miniconda3/etc/profile.d/conda.sh - conda activate central_controller - cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DZT1_CENTRAL_CONTROLLER=1 - cmake --build build/ --target all -j4 --verbose - - name: SelfTest + BRANCH_NAME="${GITHUB_REF##*/}" + SANITIZED_BRANCH="${BRANCH_NAME//\//-}" + echo "branch_name=$SANITIZED_BRANCH" >> $GITHUB_OUTPUT + + - name: Get short git commit SHA + id: sha run: | - ./build/zerotier-selftest + calculatedSha=$(git rev-parse --short ${{ github.sha }}) + echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV + - name: Build + run: | + docker build -t us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} -f ext/central-controller-docker/Dockerfile.new . - name: GCP Auth uses: google-github-actions/auth@v2 with: @@ -51,22 +66,8 @@ jobs: - name: Docker Auth run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet - - name: Get branch name and sanitize - id: branch - run: | - BRANCH_NAME="${GITHUB_REF##*/}" - SANITIZED_BRANCH="${BRANCH_NAME//\//-}" - echo "branch_name=$SANITIZED_BRANCH" >> $GITHUB_OUTPUT - - - name: Get short git commit SHA - id: sha - run: | - calculatedSha=$(git rev-parse --short ${{ github.sha }}) - echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV - - name: Build and push Docker Image run: | - docker build -t us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} -f ext/central-controller-docker/Dockerfile.conda . docker push us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} multi-arch-docker: From 67526d494a5ee37fb2ab70e954002faf4c68b28b Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 14:15:51 -0700 Subject: [PATCH 087/245] move up docker auth --- .github/workflows/central-controller.yaml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index bc0730c13b..a20dfb3971 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -14,6 +14,13 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 + + - name: Set up GCloud CLI + uses: google-github-actions/setup-gcloud@v2 + + - name: Docker Auth + run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet + # - name: Setup Miniconda # uses: conda-incubator/setup-miniconda@v3 # with: @@ -60,11 +67,7 @@ jobs: with: credentials_json: ${{ secrets.DOCKER_REGISTRY_WRITER}} - - name: Set up GCloud CLI - uses: google-github-actions/setup-gcloud@v2 - - - name: Docker Auth - run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet + - name: Build and push Docker Image run: | From 3616c4026b82cf05ea88d64a668b318608b1c7e8 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 14:23:49 -0700 Subject: [PATCH 088/245] move up the gcp auth step --- .github/workflows/central-controller.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index a20dfb3971..29053be69b 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -14,13 +14,18 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 - + + - name: GCP Auth + uses: google-github-actions/auth@v2 + with: + credentials_json: ${{ secrets.DOCKER_REGISTRY_WRITER}} + - name: Set up GCloud CLI uses: google-github-actions/setup-gcloud@v2 - name: Docker Auth run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet - + # - name: Setup Miniconda # uses: conda-incubator/setup-miniconda@v3 # with: @@ -62,12 +67,7 @@ jobs: - name: Build run: | docker build -t us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} -f ext/central-controller-docker/Dockerfile.new . - - name: GCP Auth - uses: google-github-actions/auth@v2 - with: - credentials_json: ${{ secrets.DOCKER_REGISTRY_WRITER}} - - name: Build and push Docker Image run: | From dcd583f62ba539fdbacc13b0eeac265c4bffa73b Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 14:47:58 -0700 Subject: [PATCH 089/245] cleanup controller github action --- .github/workflows/central-controller.yaml | 36 ++--------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index 29053be69b..ba1e7a6e39 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -26,31 +26,6 @@ jobs: - name: Docker Auth run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet - # - name: Setup Miniconda - # uses: conda-incubator/setup-miniconda@v3 - # with: - # miniconda-version: latest - # activate-environment: central_controller - # - name: Conda Environment Cache - # id: cache - # uses: actions/cache@v4 - # with: - # path: ${{ env.CONDA }}/envs - # key: ${{ runner.os }}-${{ runner.arch }}-${{ github.ref_name }}-conda-${{ hashFiles('environment.yml') }} - # - name: Update Conda Environment - # if: steps.cache.outputs.cache-hit != 'true' - # run: | - # source ~/miniconda3/etc/profile.d/conda.sh - # conda env update --file environment.yml - # - name: Build - # run: | - # source ~/miniconda3/etc/profile.d/conda.sh - # conda activate central_controller - # cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DZT1_CENTRAL_CONTROLLER=1 - # cmake --build build/ --target all -j4 --verbose - # - name: SelfTest - # run: | - # ./build/zerotier-selftest - name: Get branch name and sanitize id: branch run: | @@ -64,15 +39,10 @@ jobs: calculatedSha=$(git rev-parse --short ${{ github.sha }}) echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV - - name: Build + - name: Build & Push Docker Image run: | - docker build -t us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} -f ext/central-controller-docker/Dockerfile.new . - - - - name: Build and push Docker Image - run: | - docker push us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} - + docker build -t us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} -f ext/central-controller-docker/Dockerfile.new . --push + multi-arch-docker: runs-on: gha-runner-x64 needs: central_controller From f208007226d176a5370fcbab8fdf175644759f1b Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 14:48:04 -0700 Subject: [PATCH 090/245] enable otel exporter --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 681490d306..bb5355cd35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,7 +54,7 @@ if(ZT1_CENTRAL_CONTROLLER) set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to" FORCE) set(CMAKE_CXX_STANDARD_REQUIRED True CACHE BOOL "C++ standard required" FORCE) set(CMAKE_CXX_EXTENSIONS ON CACHE BOOL "Enable compiler-specific extensions" FORCE) - add_definitions(-DZT_NONFREE_CONTROLLER=1 -DZT_CONTROLLER_USE_LIBPQ=1 -DZT1_CENTRAL_CONTROLLER=1) + add_definitions(-DZT_NONFREE_CONTROLLER=1 -DZT_CONTROLLER_USE_LIBPQ=1 -DZT1_CENTRAL_CONTROLLER=1 -DZT_OPENTELEMETRY_ENABLED=1) set(CONTROLLER_RUST_FEATURES ztcontroller) set(RUST_BUILD_COMMAND cargo build --release -F ${CONTROLLER_RUST_FEATURES}) else() From b16d9372b82c15052ca4caeea5782f53bdc9722c Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 15:11:57 -0700 Subject: [PATCH 091/245] fix otel exporting --- CMakeLists.txt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb5355cd35..cf2d25bfca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,7 @@ endif() if(ZT1_CENTRAL_CONTROLLER) find_package(PostgreSQL REQUIRED) - find_package(opentelemetry-cpp REQUIRED COMPONENTS api sdk) + find_package(opentelemetry-cpp REQUIRED COMPONENTS api sdk exporters_otlp_grpc exporters_otlp_http exporters_prometheus ) find_package(google_cloud_cpp_bigtable REQUIRED) find_package(google_cloud_cpp_pubsub REQUIRED) else() @@ -110,7 +110,18 @@ set(LINKED_LIBRARIES if(ZT1_CENTRAL_CONTROLLER) list(APPEND LINKED_LIBRARIES - opentelemetry-cpp::sdk) + opentelemetry-cpp::sdk + opentelemetry-cpp::trace + opentelemetry-cpp::proto_grpc + opentelemetry-cpp::otlp_grpc_client + opentelemetry-cpp::otlp_grpc_exporter + opentelemetry-cpp::otlp_grpc_log_record_exporter + opentelemetry-cpp::otlp_grpc_metrics_exporter + opentelemetry-cpp::otlp_http_exporter + opentelemetry-cpp::otlp_http_log_record_exporter + opentelemetry-cpp::otlp_http_metric_exporter + opentelemetry-cpp::prometheus_exporter + ) endif() From 20746b27545390b2d3fcefb23a74a75fe0c1b282 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 15:41:33 -0700 Subject: [PATCH 092/245] query fix --- nonfree/controller/CV2.cpp | 188 +++++++++++++++++-------------- nonfree/controller/CentralDB.cpp | 2 +- 2 files changed, 107 insertions(+), 83 deletions(-) diff --git a/nonfree/controller/CV2.cpp b/nonfree/controller/CV2.cpp index 01631ab4e8..8e2d6cdf97 100644 --- a/nonfree/controller/CV2.cpp +++ b/nonfree/controller/CV2.cpp @@ -28,7 +28,16 @@ namespace { using namespace ZeroTier; -CV2::CV2(const Identity& myId, const char* path, int listenPort) : DB(), _pool(), _myId(myId), _myAddress(myId.address()), _ready(0), _connected(1), _run(1), _waitNoticePrinted(false), _listenPort(listenPort) +CV2::CV2(const Identity& myId, const char* path, int listenPort) + : DB() + , _pool() + , _myId(myId) + , _myAddress(myId.address()) + , _ready(0) + , _connected(1) + , _run(1) + , _waitNoticePrinted(false) + , _listenPort(listenPort) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("cv2"); @@ -44,7 +53,8 @@ CV2::CV2(const Identity& myId, const char* path, int listenPort) : DB(), _pool() _connString = std::string(path); auto f = std::make_shared(_connString); - _pool = std::make_shared >(15, 5, std::static_pointer_cast(f)); + _pool = + std::make_shared >(15, 5, std::static_pointer_cast(f)); memset(_ssoPsk, 0, sizeof(_ssoPsk)); char* const ssoPskHex = getenv("ZT_SSO_PSK"); @@ -60,7 +70,9 @@ CV2::CV2(const Identity& myId, const char* path, int listenPort) : DB(), _pool() _readyLock.lock(); - fprintf(stderr, "[%s] NOTICE: %.10llx controller PostgreSQL waiting for initial data download..." ZT_EOL_S, ::_timestr(), (unsigned long long)_myAddress.toInt()); + fprintf( + stderr, "[%s] NOTICE: %.10llx controller PostgreSQL waiting for initial data download..." ZT_EOL_S, + ::_timestr(), (unsigned long long)_myAddress.toInt()); _waitNoticePrinted = true; initializeNetworks(); @@ -229,7 +241,11 @@ void CV2::eraseMember(const uint64_t networkId, const uint64_t memberId) //_memberChanged(tmp.first, nullJson, isReady()); } -void CV2::nodeIsOnline(const uint64_t networkId, const uint64_t memberId, const InetAddress& physicalAddress, const char* osArch) +void CV2::nodeIsOnline( + const uint64_t networkId, + const uint64_t memberId, + const InetAddress& physicalAddress, + const char* osArch) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("cv2"); @@ -295,21 +311,21 @@ AuthInfo CV2::getSSOAuthInfo(const nlohmann::json& member, const std::string& re // std::string nonce = ""; // // check if the member exists first. - // pqxx::row count = w.exec_params1("SELECT count(id) FROM ztc_member WHERE id = $1 AND network_id = $2 AND deleted = false", memberId, networkId); - // if (count[0].as() == 1) { + // pqxx::row count = w.exec_params1("SELECT count(id) FROM ztc_member WHERE id = $1 AND network_id = $2 AND + // deleted = false", memberId, networkId); if (count[0].as() == 1) { // // get active nonce, if exists. // pqxx::result r = w.exec_params("SELECT nonce FROM ztc_sso_expiry " // "WHERE network_id = $1 AND member_id = $2 " - // "AND ((NOW() AT TIME ZONE 'UTC') <= authentication_expiry_time) AND ((NOW() AT TIME ZONE 'UTC') <= nonce_expiration)", - // networkId, memberId); + // "AND ((NOW() AT TIME ZONE 'UTC') <= authentication_expiry_time) AND ((NOW() AT TIME ZONE 'UTC') + // <= nonce_expiration)", networkId, memberId); // if (r.size() == 0) { // // no active nonce. // // find an unused nonce, if one exists. // pqxx::result r = w.exec_params("SELECT nonce FROM ztc_sso_expiry " // "WHERE network_id = $1 AND member_id = $2 " - // "AND authentication_expiry_time IS NULL AND ((NOW() AT TIME ZONE 'UTC') <= nonce_expiration)", - // networkId, memberId); + // "AND authentication_expiry_time IS NULL AND ((NOW() AT TIME ZONE 'UTC') <= + // nonce_expiration)", networkId, memberId); // if (r.size() == 1) { // // we have an existing nonce. Use it @@ -366,15 +382,14 @@ AuthInfo CV2::getSSOAuthInfo(const nlohmann::json& member, const std::string& re // provider = r.at(0)[3].as>().value_or(""); // sso_version = r.at(0)[4].as>().value_or(1); // } else if (r.size() > 1) { - // fprintf(stderr, "ERROR: More than one auth endpoint for an organization?!?!? NetworkID: %s\n", networkId.c_str()); - // } else { - // fprintf(stderr, "No client or auth endpoint?!?\n"); + // fprintf(stderr, "ERROR: More than one auth endpoint for an organization?!?!? NetworkID: %s\n", + // networkId.c_str()); } else { fprintf(stderr, "No client or auth endpoint?!?\n"); // } // info.version = sso_version; - // // no catch all else because we don't actually care if no records exist here. just continue as normal. - // if ((!client_id.empty())&&(!authorization_endpoint.empty())) { + // // no catch all else because we don't actually care if no records exist here. just continue as + // normal. if ((!client_id.empty())&&(!authorization_endpoint.empty())) { // uint8_t state[48]; // HMACSHA384(_ssoPsk, nonceBytes, sizeof(nonceBytes), state); @@ -401,17 +416,16 @@ AuthInfo CV2::getSSOAuthInfo(const nlohmann::json& member, const std::string& re // #ifdef ZT_DEBUG // fprintf( // stderr, - // "ssoClientID: %s\nissuerURL: %s\nssoNonce: %s\nssoState: %s\ncentralAuthURL: %s\nprovider: %s\n", - // info.ssoClientID.c_str(), - // info.issuerURL.c_str(), - // info.ssoNonce.c_str(), + // "ssoClientID: %s\nissuerURL: %s\nssoNonce: %s\nssoState: %s\ncentralAuthURL: + // %s\nprovider: %s\n", info.ssoClientID.c_str(), info.issuerURL.c_str(), info.ssoNonce.c_str(), // info.ssoState.c_str(), // info.centralAuthURL.c_str(), // provider.c_str()); // #endif // } // } else { - // fprintf(stderr, "client_id: %s\nauthorization_endpoint: %s\n", client_id.c_str(), authorization_endpoint.c_str()); + // fprintf(stderr, "client_id: %s\nauthorization_endpoint: %s\n", client_id.c_str(), + // authorization_endpoint.c_str()); // } // } @@ -485,12 +499,16 @@ void CV2::initializeNetworks() config["lastModified"] = last_modified.value_or(0); config["revision"] = revision.value_or(0); config["capabilities"] = cfgtmp["capabilities"].is_array() ? cfgtmp["capabilities"] : json::array(); - config["enableBroadcast"] = cfgtmp["enableBroadcast"].is_boolean() ? cfgtmp["enableBroadcast"].get() : false; + config["enableBroadcast"] = + cfgtmp["enableBroadcast"].is_boolean() ? cfgtmp["enableBroadcast"].get() : false; config["mtu"] = cfgtmp["mtu"].is_number() ? cfgtmp["mtu"].get() : 2800; - config["multicastLimit"] = cfgtmp["multicastLimit"].is_number() ? cfgtmp["multicastLimit"].get() : 64; + config["multicastLimit"] = + cfgtmp["multicastLimit"].is_number() ? cfgtmp["multicastLimit"].get() : 64; config["private"] = cfgtmp["private"].is_boolean() ? cfgtmp["private"].get() : true; - config["remoteTraceLevel"] = cfgtmp["remoteTraceLevel"].is_number() ? cfgtmp["remoteTraceLevel"].get() : 0; - config["remoteTraceTarget"] = cfgtmp["remoteTraceTarget"].is_string() ? cfgtmp["remoteTraceTarget"].get() : ""; + config["remoteTraceLevel"] = + cfgtmp["remoteTraceLevel"].is_number() ? cfgtmp["remoteTraceLevel"].get() : 0; + config["remoteTraceTarget"] = + cfgtmp["remoteTraceTarget"].is_string() ? cfgtmp["remoteTraceTarget"].get() : ""; config["revision"] = revision.value_or(0); config["rules"] = cfgtmp["rules"].is_array() ? cfgtmp["rules"] : json::array(); config["tags"] = cfgtmp["tags"].is_array() ? cfgtmp["tags"] : json::array(); @@ -514,7 +532,9 @@ void CV2::initializeNetworks() config["objtype"] = "network"; config["routes"] = cfgtmp["routes"].is_array() ? cfgtmp["routes"] : json::array(); config["clientId"] = cfgtmp["clientId"].is_string() ? cfgtmp["clientId"].get() : ""; - config["authorizationEndpoint"] = cfgtmp["authorizationEndpoint"].is_string() ? cfgtmp["authorizationEndpoint"].get() : nullptr; + config["authorizationEndpoint"] = cfgtmp["authorizationEndpoint"].is_string() + ? cfgtmp["authorizationEndpoint"].get() + : nullptr; config["provider"] = cfgtmp["ssoProvider"].is_string() ? cfgtmp["ssoProvider"].get() : ""; if (! cfgtmp["dns"].is_object()) { cfgtmp["dns"] = json::object(); @@ -524,7 +544,8 @@ void CV2::initializeNetworks() else { config["dns"] = cfgtmp["dns"]; } - config["ipAssignmentPools"] = cfgtmp["ipAssignmentPools"].is_array() ? cfgtmp["ipAssignmentPools"] : json::array(); + config["ipAssignmentPools"] = + cfgtmp["ipAssignmentPools"].is_array() ? cfgtmp["ipAssignmentPools"] : json::array(); Metrics::network_count++; @@ -546,7 +567,9 @@ void CV2::initializeNetworks() if (++this->_ready == 2) { if (_waitNoticePrinted) { - fprintf(stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), (unsigned long long)_myAddress.toInt()); + fprintf( + stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), + (unsigned long long)_myAddress.toInt()); } _readyLock.unlock(); } @@ -573,7 +596,8 @@ void CV2::initializeMembers() char qbuf[2048]; sprintf( qbuf, - "SELECT nm.device_id, nm.network_id, nm.authorized, nm.active_bridge, nm.ip_assignments, nm.no_auto_assign_ips, " + "SELECT nm.device_id, nm.network_id, nm.authorized, nm.active_bridge, nm.ip_assignments, " + "nm.no_auto_assign_ips, " "nm.sso_exempt, (EXTRACT(EPOCH FROM nm.authentication_expiry_time AT TIME ZONE 'UTC')*1000)::bigint, " "(EXTRACT(EPOCH FROM nm.creation_time AT TIME ZONE 'UTC')*1000)::bigint, nm.identity, " "(EXTRACT(EPOCH FROM nm.last_authorized_time AT TIME ZONE 'UTC')*1000)::bigint, " @@ -705,7 +729,9 @@ void CV2::initializeMembers() if (++this->_ready == 2) { if (_waitNoticePrinted) { - fprintf(stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), (unsigned long long)_myAddress.toInt()); + fprintf( + stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), + (unsigned long long)_myAddress.toInt()); } _readyLock.unlock(); } @@ -759,13 +785,10 @@ void CV2::heartbeat() w.exec_params0( "INSERT INTO controllers_ctl (id, hostname, last_heartbeat, public_identity, version) VALUES " "($1, $2, TO_TIMESTAMP($3::double precision/1000), $4, $5) " - "ON CONFLICT (id) DO UPDATE SET hostname = EXCLUDED.hostname, last_heartbeat = EXCLUDED.last_heartbeat, " + "ON CONFLICT (id) DO UPDATE SET hostname = EXCLUDED.hostname, last_heartbeat = " + "EXCLUDED.last_heartbeat, " "public_identity = EXCLUDED.public_identity, version = EXCLUDED.version", - controllerId, - hostname, - ts, - publicIdentity, - versionStr); + controllerId, hostname, ts, publicIdentity, versionStr); w.commit(); } catch (std::exception& e) { @@ -876,7 +899,7 @@ void CV2::commitThread() target = config["remoteTraceTarget"]; } - pqxx::row nwrow = w.exec_params1("SELECT COUNT(id) FROM networks WHERE id = $1", networkId); + pqxx::row nwrow = w.exec_params1("SELECT COUNT(id) FROM networks_ctl WHERE id = $1", networkId); int nwcount = nwrow[0].as(); if (nwcount != 1) { @@ -887,12 +910,13 @@ void CV2::commitThread() } // only needed for hooks, and no hooks for now - // pqxx::row mrow = w.exec_params1("SELECT COUNT(id) FROM device_networks WHERE device_id = $1 AND network_id = $2", memberId, networkId); - // int membercount = mrow[0].as(); - // bool isNewMember = (membercount == 0); + // pqxx::row mrow = w.exec_params1("SELECT COUNT(id) FROM device_networks WHERE device_id = $1 AND + // network_id = $2", memberId, networkId); int membercount = mrow[0].as(); bool isNewMember = + // (membercount == 0); pqxx::result res = w.exec_params0( - "INSERT INTO network_memberships_ctl (device_id, network_id, authorized, active_bridge, ip_assignments, " + "INSERT INTO network_memberships_ctl (device_id, network_id, authorized, active_bridge, " + "ip_assignments, " "no_auto_assign_ips, sso_exempt, authentication_expiry_time, capabilities, creation_time, " "identity, last_authorized_time, last_deauthorized_time, " "remote_trace_level, remote_trace_target, revision, tags, version_major, version_minor, " @@ -903,35 +927,24 @@ void CV2::commitThread() "ON CONFLICT (device_id, network_id) DO UPDATE SET " "authorized = EXCLUDED.authorized, active_bridge = EXCLUDED.active_bridge, " "ip_assignments = EXCLUDED.ip_assignments, no_auto_assign_ips = EXCLUDED.no_auto_assign_ips, " - "sso_exempt = EXCLUDED.sso_exempt, authentication_expiry_time = EXCLUDED.authentication_expiry_time, " + "sso_exempt = EXCLUDED.sso_exempt, authentication_expiry_time = " + "EXCLUDED.authentication_expiry_time, " "capabilities = EXCLUDED.capabilities, creation_time = EXCLUDED.creation_time, " "identity = EXCLUDED.identity, last_authorized_time = EXCLUDED.last_authorized_time, " "last_deauthorized_time = EXCLUDED.last_deauthorized_time, " - "remote_trace_level = EXCLUDED.remote_trace_level, remote_trace_target = EXCLUDED.remote_trace_target, " + "remote_trace_level = EXCLUDED.remote_trace_level, remote_trace_target = " + "EXCLUDED.remote_trace_target, " "revision = EXCLUDED.revision, tags = EXCLUDED.tags, version_major = EXCLUDED.version_major, " "version_minor = EXCLUDED.version_minor, version_revision = EXCLUDED.version_revision, " "version_protocol = EXCLUDED.version_protocol", - memberId, - networkId, - (bool)config["authorized"], - (bool)config["activeBridge"], - config["ipAssignments"].get >(), - (bool)config["noAutoAssignIps"], - (bool)config["ssoExempt"], - (uint64_t)config["authenticationExpiryTime"], - OSUtils::jsonDump(config["capabilities"], -1), - (uint64_t)config["creationTime"], - OSUtils::jsonString(config["identity"], ""), - (uint64_t)config["lastAuthorizedTime"], - (uint64_t)config["lastDeauthorizedTime"], - (int)config["remoteTraceLevel"], - target, - (uint64_t)config["revision"], - OSUtils::jsonDump(config["tags"], -1), - (int)config["vMajor"], - (int)config["vMinor"], - (int)config["vRev"], - (int)config["vProto"]); + memberId, networkId, (bool)config["authorized"], (bool)config["activeBridge"], + config["ipAssignments"].get >(), (bool)config["noAutoAssignIps"], + (bool)config["ssoExempt"], (uint64_t)config["authenticationExpiryTime"], + OSUtils::jsonDump(config["capabilities"], -1), (uint64_t)config["creationTime"], + OSUtils::jsonString(config["identity"], ""), (uint64_t)config["lastAuthorizedTime"], + (uint64_t)config["lastDeauthorizedTime"], (int)config["remoteTraceLevel"], target, + (uint64_t)config["revision"], OSUtils::jsonDump(config["tags"], -1), (int)config["vMajor"], + (int)config["vMinor"], (int)config["vRev"], (int)config["vProto"]); w.commit(); @@ -967,7 +980,9 @@ void CV2::commitThread() _memberChanged(memOrig, memNew, qitem.second); } else { - fprintf(stderr, "%s: Can't notify of change. Error parsing nwid or memberid: %llu-%llu\n", _myAddressStr.c_str(), (unsigned long long)nwidInt, (unsigned long long)memberidInt); + fprintf( + stderr, "%s: Can't notify of change. Error parsing nwid or memberid: %llu-%llu\n", + _myAddressStr.c_str(), (unsigned long long)nwidInt, (unsigned long long)memberidInt); } } catch (pqxx::data_exception& e) { @@ -985,7 +1000,9 @@ void CV2::commitThread() } catch (std::exception& e) { std::string cfgDump = OSUtils::jsonDump(config, 2); - fprintf(stderr, "%s ERROR: Error updating member %s-%s: %s\njsonDump: %s\n", _myAddressStr.c_str(), networkId.c_str(), memberId.c_str(), e.what(), cfgDump.c_str()); + fprintf( + stderr, "%s ERROR: Error updating member %s-%s: %s\njsonDump: %s\n", _myAddressStr.c_str(), + networkId.c_str(), memberId.c_str(), e.what(), cfgDump.c_str()); mspan->SetStatus(opentelemetry::trace::StatusCode::kError, "std::exception"); mspan->SetAttribute("error", e.what()); mspan->SetAttribute("config", cfgDump); @@ -1007,10 +1024,7 @@ void CV2::commitThread() "VALUES ($1, $2, $3, $4, $5) " "ON CONFLICT (id) DO UPDATE SET " "name = EXCLUDED.name, configuration = EXCLUDED.configuration, revision = EXCLUDED.revision+1", - id, - OSUtils::jsonString(config["name"], ""), - OSUtils::jsonDump(config, -1), - _myAddressStr, + id, OSUtils::jsonString(config["name"], ""), OSUtils::jsonDump(config, -1), _myAddressStr, ((uint64_t)config["revision"])); w.commit(); @@ -1025,7 +1039,9 @@ void CV2::commitThread() _networkChanged(nwOrig, nwNew, qitem.second); } else { - fprintf(stderr, "%s: Can't notify network changed: %llu\n", _myAddressStr.c_str(), (unsigned long long)nwidInt); + fprintf( + stderr, "%s: Can't notify network changed: %llu\n", _myAddressStr.c_str(), + (unsigned long long)nwidInt); } } catch (pqxx::data_exception& e) { @@ -1083,7 +1099,9 @@ void CV2::commitThread() std::string memberId = config["id"]; std::string networkId = config["nwid"]; - pqxx::result res = w.exec_params0("DELETE FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", memberId, networkId); + pqxx::result res = w.exec_params0( + "DELETE FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", memberId, + networkId); w.commit(); @@ -1173,7 +1191,10 @@ void CV2::onlineNotificationThread() std::string memberId(memTmp); try { - pqxx::row r = w2.exec_params1("SELECT device_id, network_id FROM network_memberships_ctl WHERE network_id = $1 AND device_id = $2", networkId, memberId); + pqxx::row r = w2.exec_params1( + "SELECT device_id, network_id FROM network_memberships_ctl WHERE network_id = $1 AND device_id " + "= $2", + networkId, memberId); } catch (pqxx::unexpected_rows& e) { continue; @@ -1195,15 +1216,16 @@ void CV2::onlineNotificationThread() { ipAddr, ts }, }; - std::string device_network_insert = "INSERT INTO network_memberships_ctl (device_id, network_id, last_seen, os, arch) " - "VALUES ('" - + w2.esc(memberId) + "', '" + w2.esc(networkId) + "', '" + w2.esc(record.dump()) - + "'::JSONB, " - "'" - + w2.esc(os) + "', '" + w2.esc(arch) - + "') " - "ON CONFLICT (device_id, network_id) DO UPDATE SET os = EXCLUDED.os, arch = EXCLUDED.arch, " - "last_seen = network_memberships_ctl.last_seen || EXCLUDED.last_seen"; + std::string device_network_insert = + "INSERT INTO network_memberships_ctl (device_id, network_id, last_seen, os, arch) " + "VALUES ('" + + w2.esc(memberId) + "', '" + w2.esc(networkId) + "', '" + w2.esc(record.dump()) + + "'::JSONB, " + "'" + + w2.esc(os) + "', '" + w2.esc(arch) + + "') " + "ON CONFLICT (device_id, network_id) DO UPDATE SET os = EXCLUDED.os, arch = EXCLUDED.arch, " + "last_seen = network_memberships_ctl.last_seen || EXCLUDED.last_seen"; pipe.insert(device_network_insert); Metrics::pgsql_node_checkin++; @@ -1233,7 +1255,9 @@ void CV2::onlineNotificationThread() fprintf(stderr, "%s: Fell out of run loop in onlineNotificationThread\n", _myAddressStr.c_str()); if (_run == 1) { - fprintf(stderr, "ERROR: %s onlineNotificationThread should still be running! Exiting Controller.\n", _myAddressStr.c_str()); + fprintf( + stderr, "ERROR: %s onlineNotificationThread should still be running! Exiting Controller.\n", + _myAddressStr.c_str()); exit(6); } } diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index fd5b07c625..d5520ede28 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1119,7 +1119,7 @@ void CentralDB::commitThread() target = config["remoteTraceTarget"]; } - pqxx::row nwrow = w.exec_params1("SELECT COUNT(id) FROM ztc_network WHERE id = $1", networkId); + pqxx::row nwrow = w.exec_params1("SELECT COUNT(id) FROM networks_ctl WHERE id = $1", networkId); int nwcount = nwrow[0].as(); if (nwcount != 1) { From 3b7958aec10c4636d50ca7ed38da471068f1850f Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 16:07:28 -0700 Subject: [PATCH 093/245] another query fix --- nonfree/controller/CentralDB.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index d5520ede28..38e89e9914 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1130,7 +1130,8 @@ void CentralDB::commitThread() } pqxx::row mrow = w.exec_params1( - "SELECT COUNT(id) FROM ztc_member WHERE id = $1 AND network_id = $2", memberId, networkId); + "SELECT COUNT(id) FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", + memberId, networkId); int membercount = mrow[0].as(); bool isNewMember = (membercount == 0); From e9565cf97cf01c49c9c69bbbf0c74dcae89bc741 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 16:11:22 -0700 Subject: [PATCH 094/245] another query fix --- nonfree/controller/CentralDB.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 38e89e9914..2c2c4d0504 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1170,11 +1170,11 @@ void CentralDB::commitThread() w.commit(); - if (! isNewMember) { - pqxx::result res = w.exec_params0( - "DELETE FROM ztc_member_ip_assignment WHERE member_id = $1 AND network_id = $2", memberId, - networkId); - } + // if (! isNewMember) { + // pqxx::result res = w.exec_params0( + // "DELETE FROM ztc_member_ip_assignment WHERE member_id = $1 AND network_id = $2", memberId, + // networkId); + // } if (_smee != NULL && isNewMember) { // TODO: Smee Notifications for New Members @@ -1448,8 +1448,9 @@ void CentralDB::onlineNotificationThread() std::string memberId(memTmp); try { - pqxx::row r = w.exec_params1( - "SELECT id, network_id FROM ztc_member WHERE network_id = $1 AND id = $2", networkId, memberId); + "SELECT device_id, network_id FROM network_memberships_ctl WHERE network_id = $1 AND device_id " + "= $2", + networkId, memberId); } catch (pqxx::unexpected_rows& e) { continue; From a18e370d48b8ac79fe45af5d9a29af92d4a2db86 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 16:31:16 -0700 Subject: [PATCH 095/245] another query fix --- nonfree/controller/CentralDB.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 2c2c4d0504..4ae23a01b3 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1130,7 +1130,7 @@ void CentralDB::commitThread() } pqxx::row mrow = w.exec_params1( - "SELECT COUNT(id) FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", + "SELECT COUNT(device_id) FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", memberId, networkId); int membercount = mrow[0].as(); @@ -1170,12 +1170,6 @@ void CentralDB::commitThread() w.commit(); - // if (! isNewMember) { - // pqxx::result res = w.exec_params0( - // "DELETE FROM ztc_member_ip_assignment WHERE member_id = $1 AND network_id = $2", memberId, - // networkId); - // } - if (_smee != NULL && isNewMember) { // TODO: Smee Notifications for New Members // pqxx::row row = w.exec_params1( From a061c86594660238e0ed1c23eac77a3352f84759 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 17:00:15 -0700 Subject: [PATCH 096/245] fix --- nonfree/controller/CentralDB.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 4ae23a01b3..aea8f5f78b 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1442,7 +1442,8 @@ void CentralDB::onlineNotificationThread() std::string memberId(memTmp); try { - "SELECT device_id, network_id FROM network_memberships_ctl WHERE network_id = $1 AND device_id " + pqxx::row r = w2.exec_params1( + "SELECT device_id, network_id FROM network_memberships_ctl WHERE network_id = $1 AND device_id " "= $2", networkId, memberId); } From 48ff61b392d4c8ea6569b576b6bca434975b8fb4 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 17:28:14 -0700 Subject: [PATCH 097/245] fix --- nonfree/controller/CentralDB.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index aea8f5f78b..46349c7342 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1442,7 +1442,7 @@ void CentralDB::onlineNotificationThread() std::string memberId(memTmp); try { - pqxx::row r = w2.exec_params1( + pqxx::row r = w.exec_params1( "SELECT device_id, network_id FROM network_memberships_ctl WHERE network_id = $1 AND device_id " "= $2", networkId, memberId); From 282d7c7f9d907c643e66fe11997cb0cd518c1123 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 4 Sep 2025 17:45:38 -0700 Subject: [PATCH 098/245] another fix --- nonfree/controller/CentralDB.cpp | 4 ++++ nonfree/controller/PostgresStatusWriter.cpp | 14 -------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 46349c7342..04ee52f449 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1442,6 +1442,10 @@ void CentralDB::onlineNotificationThread() std::string memberId(memTmp); try { + // check if the member exists first. + // + // exec_params1 will throw pqxx::unexpected_rows if not exactly one row is returned. If that's the + // case, skip this record and move on. pqxx::row r = w.exec_params1( "SELECT device_id, network_id FROM network_memberships_ctl WHERE network_id = $1 AND device_id " "= $2", diff --git a/nonfree/controller/PostgresStatusWriter.cpp b/nonfree/controller/PostgresStatusWriter.cpp index 5e59e73f52..e16fb038e5 100644 --- a/nonfree/controller/PostgresStatusWriter.cpp +++ b/nonfree/controller/PostgresStatusWriter.cpp @@ -57,20 +57,6 @@ void PostgresStatusWriter::writePending() { entry.address.toIpString(iptmp), entry.last_seen }, }; - try { - // check if the member exists first. - // - // exec_params1 will throw pqxx::unexpected_rows if not exactly one row is returned. If that's the - // case, skip this record and move on. - w.exec_params1( - "SELECT device_id, network_id FROM network_memberships_ctl WHERE network_id = $1 AND device_id = " - "$2", - entry.network_id, entry.node_id); - } - catch (pqxx::unexpected_rows& e) { - continue; - } - std::string insert_statement = "INSERT INTO network_memberships_ctl (device_id, network_id, last_seen, os, arch) " "VALUES ('" From ba6200fb9656833302724e282f4c823b2093ee5c Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 5 Sep 2025 08:19:32 -0700 Subject: [PATCH 099/245] add a ChangeSource enum to the change protobuf messages --- nonfree/controller/protobuf/member.proto | 8 ++++++++ nonfree/controller/protobuf/network.proto | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/nonfree/controller/protobuf/member.proto b/nonfree/controller/protobuf/member.proto index 511f1a8d7f..a10e2839b0 100644 --- a/nonfree/controller/protobuf/member.proto +++ b/nonfree/controller/protobuf/member.proto @@ -33,7 +33,15 @@ message MemberChange { string controller_id = 2; } + enum ChangeSource { + UNKNOWN = 0; + CV1 = 1; + CV2 = 2; + CONTROLLER = 3; + } + optional Member old = 1; optional Member new = 2; optional MemberChangeMetadata metadata = 3; + optional ChangeSource change_source = 4; } diff --git a/nonfree/controller/protobuf/network.proto b/nonfree/controller/protobuf/network.proto index c2b6868f78..1fe359dfe1 100644 --- a/nonfree/controller/protobuf/network.proto +++ b/nonfree/controller/protobuf/network.proto @@ -60,7 +60,15 @@ message NetworkChange { string rules_source = 24; // source code for rules } + enum ChangeSource { + UNKNOWN = 0; + CV1 = 1; + CV2 = 2; + CONTROLLER = 3; + } + optional Network old = 1; optional Network new = 2; optional NetworkChangeMetadata metadata = 3; + optional ChangeSource change_source = 4; } From 74f05254700ee1741eb9bfaddfcbb3e36d544981 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 5 Sep 2025 08:40:03 -0700 Subject: [PATCH 100/245] Add `frontend` column to networks & network_memberships tables so the controller knows which system owns the networks & members --- .../migrations/0003_frontend_down.sql | 5 +++++ .../migrations/0003_frontend_up.sql | 5 +++++ nonfree/controller/CentralDB.cpp | 9 ++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 ext/central-controller-docker/migrations/0003_frontend_down.sql create mode 100644 ext/central-controller-docker/migrations/0003_frontend_up.sql diff --git a/ext/central-controller-docker/migrations/0003_frontend_down.sql b/ext/central-controller-docker/migrations/0003_frontend_down.sql new file mode 100644 index 0000000000..870eeaa42a --- /dev/null +++ b/ext/central-controller-docker/migrations/0003_frontend_down.sql @@ -0,0 +1,5 @@ +ALTER TABLE network_memberships_ctl + DROP COLUMN frontend; + +ALTER TABLE networks_ctl + DROP COLUMN frontend; \ No newline at end of file diff --git a/ext/central-controller-docker/migrations/0003_frontend_up.sql b/ext/central-controller-docker/migrations/0003_frontend_up.sql new file mode 100644 index 0000000000..cb9824496e --- /dev/null +++ b/ext/central-controller-docker/migrations/0003_frontend_up.sql @@ -0,0 +1,5 @@ +ALTER TABLE networks_ctl + ADD COLUMN frontend TEXT NOT NULL DEFAULT 'cv2'; + +ALTER TABLE network_memberships_ctl + ADD COLUMN frontend TEXT NOT NULL DEFAULT 'cv2'; \ No newline at end of file diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 04ee52f449..1eb591f2a8 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -615,7 +615,7 @@ void CentralDB::initializeNetworks() sprintf( qbuf, "SELECT id, name, configuration , (EXTRACT(EPOCH FROM creation_time AT TIME ZONE 'UTC')*1000)::bigint, " - "(EXTRACT(EPOCH FROM last_modified AT TIME ZONE 'UTC')*1000)::bigint, revision " + "(EXTRACT(EPOCH FROM last_modified AT TIME ZONE 'UTC')*1000)::bigint, revision, frontend " "FROM networks_ctl WHERE controller_id = '%s'", _myAddressStr.c_str()); @@ -636,6 +636,8 @@ void CentralDB::initializeNetworks() std::optional // last_modified , std::optional // revision + , + std::string // frontend > row; uint64_t count = 0; @@ -708,6 +710,7 @@ void CentralDB::initializeNetworks() } config["ipAssignmentPools"] = cfgtmp["ipAssignmentPools"].is_array() ? cfgtmp["ipAssignmentPools"] : json::array(); + config["frontend"] = std::get<6>(row); Metrics::network_count++; @@ -806,6 +809,7 @@ void CentralDB::initializeMembers() "(EXTRACT(EPOCH FROM nm.last_authorized_time AT TIME ZONE 'UTC')*1000)::bigint, " "(EXTRACT(EPOCH FROM nm.last_deauthorized_time AT TIME ZONE 'UTC')*1000)::bigint, " "nm.remote_trace_level, nm.remote_trace_target, nm.revision, nm.capabilities, nm.tags " + "nm.frontend " "FROM network_memberships_ctl nm " "INNER JOIN networks_ctl n " " ON nm.network_id = n.id " @@ -850,6 +854,8 @@ void CentralDB::initializeMembers() std::optional // capabilities , std::optional // tags + , + std::string // frontend > row; @@ -909,6 +915,7 @@ void CentralDB::initializeMembers() config["authenticationExpiryTime"] = authentication_expiry_time.value_or(0); config["tags"] = json::parse(tags.value_or("[]")); config["ipAssignments"] = json::array(); + config["frontend"] = std::get<17>(row); Metrics::member_count++; From 024824c2fe18bf1ec99691951f3b761d22ddecb8 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 5 Sep 2025 14:52:16 -0700 Subject: [PATCH 101/245] wire up pubsub outgoing status changes from controller -> CV2 --- nonfree/controller/BigTableStatusWriter.cpp | 28 ++++- nonfree/controller/BigTableStatusWriter.hpp | 13 +- nonfree/controller/CMakeLists.txt | 2 + nonfree/controller/CentralDB.cpp | 25 +++- nonfree/controller/CtlUtil.cpp | 81 ++++++++++++- nonfree/controller/CtlUtil.hpp | 5 + nonfree/controller/PostgresStatusWriter.cpp | 5 +- nonfree/controller/PostgresStatusWriter.hpp | 3 +- nonfree/controller/PubSubListener.cpp | 70 ++++++----- nonfree/controller/PubSubWriter.cpp | 125 ++++++++++++++++++++ nonfree/controller/PubSubWriter.hpp | 39 ++++++ nonfree/controller/RedisStatusWriter.cpp | 5 +- nonfree/controller/RedisStatusWriter.hpp | 3 +- nonfree/controller/StatusWriter.hpp | 4 +- 14 files changed, 359 insertions(+), 49 deletions(-) create mode 100644 nonfree/controller/PubSubWriter.cpp create mode 100644 nonfree/controller/PubSubWriter.hpp diff --git a/nonfree/controller/BigTableStatusWriter.cpp b/nonfree/controller/BigTableStatusWriter.cpp index 108090cab5..61f75f3247 100644 --- a/nonfree/controller/BigTableStatusWriter.cpp +++ b/nonfree/controller/BigTableStatusWriter.cpp @@ -1,10 +1,12 @@ #include "BigTableStatusWriter.hpp" #include "ControllerConfig.hpp" +#include "PubSubWriter.hpp" #include #include #include +#include namespace cbt = google::cloud::bigtable; @@ -23,10 +25,12 @@ const std::string lastSeenColumn = "last_seen"; BigTableStatusWriter::BigTableStatusWriter( const std::string& project_id, const std::string& instance_id, - const std::string& table_id) + const std::string& table_id, + std::shared_ptr pubsubWriter) : _project_id(project_id) , _instance_id(instance_id) , _table_id(table_id) + , _pubsubWriter(pubsubWriter) { } @@ -42,13 +46,16 @@ void BigTableStatusWriter::updateNodeStatus( const std::string& arch, const std::string& version, const InetAddress& address, - int64_t last_seen) + int64_t last_seen, + const std::string& frontend) { + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("BigTableStatusWriter"); + auto span = tracer->StartSpan("BigTableStatusWriter::updateNodeStatus"); + auto scope = tracer->WithActiveSpan(span); + std::lock_guard l(_lock); - _pending.push_back({ network_id, node_id, os, arch, version, address, last_seen }); - if (_pending.size() >= 100) { - writePending(); - } + _pending.push_back({ network_id, node_id, os, arch, version, address, last_seen, frontend }); } size_t BigTableStatusWriter::queueLength() const @@ -59,6 +66,11 @@ size_t BigTableStatusWriter::queueLength() const void BigTableStatusWriter::writePending() { + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("BigTableStatusWriter"); + auto span = tracer->StartSpan("BigTableStatusWriter::writePending"); + auto scope = tracer->WithActiveSpan(span); + std::vector toWrite; { std::lock_guard l(_lock); @@ -88,6 +100,10 @@ void BigTableStatusWriter::writePending() int64_t ts = entry.last_seen; m.emplace_back(cbt::SetCell(checkInColumnFamily, lastSeenColumn, std::move(ts))); bulk.push_back(std::move(m)); + + // TODO: Check performance on this. May need to bach these. + _pubsubWriter->publishStatusChange( + entry.target, entry.network_id, entry.node_id, entry.os, entry.arch, entry.version, entry.last_seen); } std::vector failures = table.BulkApply(bulk); diff --git a/nonfree/controller/BigTableStatusWriter.hpp b/nonfree/controller/BigTableStatusWriter.hpp index 61657c797f..00ab0647f4 100644 --- a/nonfree/controller/BigTableStatusWriter.hpp +++ b/nonfree/controller/BigTableStatusWriter.hpp @@ -3,14 +3,21 @@ #include "StatusWriter.hpp" +#include #include #include namespace ZeroTier { +class PubSubWriter; + class BigTableStatusWriter : public StatusWriter { public: - BigTableStatusWriter(const std::string& project_id, const std::string& instance_id, const std::string& table_id); + BigTableStatusWriter( + const std::string& project_id, + const std::string& instance_id, + const std::string& table_id, + std::shared_ptr pubsubWriter); virtual ~BigTableStatusWriter(); virtual void updateNodeStatus( @@ -20,7 +27,8 @@ class BigTableStatusWriter : public StatusWriter { const std::string& arch, const std::string& version, const InetAddress& address, - int64_t last_seen) override; + int64_t last_seen, + const std::string& frontend) override; virtual size_t queueLength() const override; virtual void writePending() override; @@ -31,6 +39,7 @@ class BigTableStatusWriter : public StatusWriter { mutable std::mutex _lock; std::vector _pending; + std::shared_ptr _pubsubWriter; }; } // namespace ZeroTier diff --git a/nonfree/controller/CMakeLists.txt b/nonfree/controller/CMakeLists.txt index 07760c675a..4593f5daf6 100644 --- a/nonfree/controller/CMakeLists.txt +++ b/nonfree/controller/CMakeLists.txt @@ -47,6 +47,8 @@ if (ZT1_CENTRAL_CONTROLLER) PostgreSQL.hpp PubSubListener.cpp PubSubListener.hpp + PubSubWriter.cpp + PubSubWriter.hpp Redis.hpp RedisListener.cpp RedisListener.hpp diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 1eb591f2a8..a351b42baf 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -24,6 +24,7 @@ #include "EmbeddedNetworkController.hpp" #include "PostgresStatusWriter.hpp" #include "PubSubListener.hpp" +#include "PubSubWriter.hpp" #include "Redis.hpp" #include "RedisListener.hpp" #include "RedisStatusWriter.hpp" @@ -178,6 +179,7 @@ CentralDB::CentralDB( break; } + std::shared_ptr pubsubWriter; switch (statusMode) { case STATUS_WRITER_MODE_REDIS: if (_cc->redisConfig != NULL) { @@ -193,8 +195,21 @@ CentralDB::CentralDB( } break; case STATUS_WRITER_MODE_BIGTABLE: + if (cc->bigTableConfig == NULL) { + throw std::runtime_error( + "CentralDB: BigTable status mode selected but no BigTable configuration provided"); + } + if (cc->pubSubConfig == NULL) { + throw std::runtime_error( + "CentralDB: BigTable status mode selected but no PubSub configuration provided"); + } + + pubsubWriter = std::make_shared( + cc->pubSubConfig->project_id, "ctl-member-status-update-stream", _myAddressStr); + _statusWriter = std::make_shared( - cc->bigTableConfig->project_id, cc->bigTableConfig->instance_id, cc->bigTableConfig->table_id); + cc->bigTableConfig->project_id, cc->bigTableConfig->instance_id, cc->bigTableConfig->table_id, + pubsubWriter); break; case STATUS_WRITER_MODE_PGSQL: default: @@ -1439,9 +1454,9 @@ void CentralDB::onlineNotificationThread() char ipTmp[64]; OSUtils::ztsnprintf(nwidTmp, sizeof(nwidTmp), "%.16llx", nwid_i); OSUtils::ztsnprintf(memTmp, sizeof(memTmp), "%.10llx", i->first.second); - nlohmann::json jtmp1, jtmp2; + nlohmann::json network, member; - if (! get(nwid_i, jtmp1, i->first.second, jtmp2)) { + if (! get(nwid_i, network, i->first.second, member)) { continue; // skip non existent networks/members } @@ -1469,12 +1484,14 @@ void CentralDB::onlineNotificationThread() std::vector osArchSplit = split(osArch, '/'); std::string os = "unknown"; std::string arch = "unknown"; + std::string frontend = member["frontend"].get(); if (osArchSplit.size() == 2) { os = osArchSplit[0]; arch = osArchSplit[1]; } - _statusWriter->updateNodeStatus(networkId, memberId, os, arch, "", i->second.physicalAddress, ts); + _statusWriter->updateNodeStatus( + networkId, memberId, os, arch, "", i->second.physicalAddress, ts, frontend); } _statusWriter->writePending(); w.commit(); diff --git a/nonfree/controller/CtlUtil.cpp b/nonfree/controller/CtlUtil.cpp index 51a5535cfb..4ec5fa9876 100644 --- a/nonfree/controller/CtlUtil.cpp +++ b/nonfree/controller/CtlUtil.cpp @@ -9,6 +9,23 @@ #include #include +#ifdef ZT1_CENTRAL_CONTROLLER +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace pubsub = ::google::cloud::pubsub; +namespace pubsub_admin = ::google::cloud::pubsub_admin; +namespace bigtable_admin = ::google::cloud::bigtable_admin; +#endif + namespace ZeroTier { const char* _timestr() @@ -63,6 +80,68 @@ std::string url_encode(const std::string& value) return escaped.str(); } -} // namespace ZeroTier +#ifdef ZT1_CENTRAL_CONTROLLER +void create_gcp_pubsub_topic_if_needed(std::string project_id, std::string topic_id) +{ + // This is a no-op if the topic already exists. + auto topicAdminClient = pubsub_admin::TopicAdminClient(pubsub_admin::MakeTopicAdminConnection()); + auto topicName = pubsub::Topic(project_id, topic_id).FullName(); + auto topicResult = topicAdminClient.GetTopic(topicName); + if (! topicResult.ok()) { + // Only create if not found + if (topicResult.status().code() == google::cloud::StatusCode::kNotFound) { + auto createResult = topicAdminClient.CreateTopic(topicName); + if (! createResult.ok()) { + fprintf(stderr, "Failed to create topic: %s\n", createResult.status().message().c_str()); + throw std::runtime_error("Failed to create topic"); + } + fprintf(stderr, "Created topic: %s\n", topicName.c_str()); + } + else { + fprintf(stderr, "Failed to get topic: %s\n", topicResult.status().message().c_str()); + throw std::runtime_error("Failed to get topic"); + } + } +} + +// void create_bigtable_table(std::string project_id, std::string instance_id) +// { +// auto bigtableAdminClient = +// bigtable_admin::BigtableTableAdminClient(bigtable_admin::MakeBigtableTableAdminConnection()); + +// std::string table_id = "member_status"; +// std::string table_name = "projects/" + project_id + "/instances/" + instance_id + "/tables/" + table_id; + +// // Check if the table exists +// auto table = bigtableAdminClient.GetTable(table_name); +// if (! table.ok()) { +// if (table.status().code() == google::cloud::StatusCode::kNotFound) { +// google::bigtable::admin::v2::Table table_config; +// table_config.set_name(table_id); +// auto families = table_config.mutable_column_families(); +// // Define column families +// // Column family "node_info" with max 1 version +// // google::bigtable::admin::v2::ColumnFamily* node_info = table_config.add_column_families(); +// // Column family "check_in" with max 1 version +// auto create_result = bigtableAdminClient.CreateTable( +// "projects/" + project_id + "/instances/" + instance_id, table_id, table_config); + +// if (! create_result.ok()) { +// fprintf( +// stderr, "Failed to create Bigtable table member_status: %s\n", +// create_result.status().message().c_str()); +// throw std::runtime_error("Failed to create Bigtable table"); +// } +// fprintf(stderr, "Created Bigtable table: member_status\n"); +// } +// else { +// fprintf(stderr, "Failed to get Bigtable table member_status: %s\n", table.status().message().c_str()); +// throw std::runtime_error("Failed to get Bigtable table"); +// } +// } +// } +#endif + +} // namespace ZeroTier #endif diff --git a/nonfree/controller/CtlUtil.hpp b/nonfree/controller/CtlUtil.hpp index 5347f9a4d1..b010d1c79e 100644 --- a/nonfree/controller/CtlUtil.hpp +++ b/nonfree/controller/CtlUtil.hpp @@ -15,6 +15,11 @@ const char* _timestr(); std::vector split(std::string str, char delim); std::string url_encode(const std::string& value); + +#ifdef ZT1_CENTRAL_CONTROLLER +void create_gcp_pubsub_topic_if_needed(std::string project_id, std::string topic_id); +#endif + } // namespace ZeroTier #endif // namespace ZeroTier diff --git a/nonfree/controller/PostgresStatusWriter.cpp b/nonfree/controller/PostgresStatusWriter.cpp index e16fb038e5..b44f27bb20 100644 --- a/nonfree/controller/PostgresStatusWriter.cpp +++ b/nonfree/controller/PostgresStatusWriter.cpp @@ -23,10 +23,11 @@ void PostgresStatusWriter::updateNodeStatus( const std::string& arch, const std::string& version, const InetAddress& address, - int64_t last_seen) + int64_t last_seen, + const std::string& /* frontend unused */) { std::lock_guard l(_lock); - _pending.push_back({ network_id, node_id, os, arch, version, address, last_seen }); + _pending.push_back({ network_id, node_id, os, arch, version, address, last_seen, "" }); } size_t PostgresStatusWriter::queueLength() const diff --git a/nonfree/controller/PostgresStatusWriter.hpp b/nonfree/controller/PostgresStatusWriter.hpp index 375fcf5f71..2f4c1f0ea0 100644 --- a/nonfree/controller/PostgresStatusWriter.hpp +++ b/nonfree/controller/PostgresStatusWriter.hpp @@ -23,7 +23,8 @@ class PostgresStatusWriter : public StatusWriter { const std::string& arch, const std::string& version, const InetAddress& address, - int64_t last_seen) override; + int64_t last_seen, + const std::string& /* frontend unused */) override; virtual size_t queueLength() const override; virtual void writePending() override; diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 5126c0fcb9..f4f14db993 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -2,6 +2,7 @@ #include "PubSubListener.hpp" #include "ControllerConfig.hpp" +#include "CtlUtil.hpp" #include "DB.hpp" #include "member.pb.h" #include "network.pb.h" @@ -22,8 +23,8 @@ namespace pubsub_admin = ::google::cloud::pubsub_admin; namespace ZeroTier { -nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc); -nlohmann::json toJson(const pbmessages::MemberChange_Member& mc); +nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::NetworkChange_ChangeSource source); +nlohmann::json toJson(const pbmessages::MemberChange_Member& mc, pbmessages::MemberChange_ChangeSource source); PubSubListener::PubSubListener(std::string controller_id, std::string project, std::string topic) : _controller_id(controller_id) @@ -36,27 +37,10 @@ PubSubListener::PubSubListener(std::string controller_id, std::string project, s { GOOGLE_PROTOBUF_VERIFY_VERSION; - // Create Topic if it doesn't exist - // this is only really needed for testing with the emulator - // in production the topic should be created via terraform or gcloud - // before starting the controller - auto topicAdminClient = pubsub_admin::TopicAdminClient(pubsub_admin::MakeTopicAdminConnection()); - auto topicName = pubsub::Topic(project, topic).FullName(); - auto topicResult = topicAdminClient.GetTopic(topicName); - if (! topicResult.ok()) { - // Only create if not found - if (topicResult.status().code() == google::cloud::StatusCode::kNotFound) { - auto createResult = topicAdminClient.CreateTopic(topicName); - if (! createResult.ok()) { - fprintf(stderr, "Failed to create topic: %s\n", createResult.status().message().c_str()); - throw std::runtime_error("Failed to create topic"); - } - fprintf(stderr, "Created topic: %s\n", topicName.c_str()); - } - else { - fprintf(stderr, "Failed to get topic: %s\n", topicResult.status().message().c_str()); - throw std::runtime_error("Failed to get topic"); - } + // If PUBSUB_EMULATOR_HOST is set, create the topic if it doesn't exist + const char* emulatorHost = std::getenv("PUBSUB_EMULATOR_HOST"); + if (emulatorHost != nullptr) { + create_gcp_pubsub_topic_if_needed(project, topic); } google::pubsub::v1::Subscription request; @@ -160,11 +144,11 @@ void PubSubNetworkListener::onNotification(const std::string& payload) nlohmann::json oldConfig, newConfig; if (nc.has_old()) { - oldConfig = toJson(nc.old()); + oldConfig = toJson(nc.old(), nc.change_source()); } if (nc.has_new_()) { - newConfig = toJson(nc.new_()); + newConfig = toJson(nc.new_(), nc.change_source()); } if (oldConfig.is_object() && newConfig.is_object()) { @@ -239,11 +223,11 @@ void PubSubMemberListener::onNotification(const std::string& payload) nlohmann::json oldConfig, newConfig; if (mc.has_old()) { - oldConfig = toJson(mc.old()); + oldConfig = toJson(mc.old(), mc.change_source()); } if (mc.has_new_()) { - newConfig = toJson(mc.new_()); + newConfig = toJson(mc.new_(), mc.change_source()); } if (oldConfig.is_object() && newConfig.is_object()) { @@ -293,7 +277,7 @@ void PubSubMemberListener::onNotification(const std::string& payload) } } -nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc) +nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::NetworkChange_ChangeSource source) { nlohmann::json out; @@ -386,11 +370,25 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc) } } out["ssoConfig"] = sso; + switch (source) { + case pbmessages::NetworkChange_ChangeSource_CV1: + out["change_source"] = "cv1"; + break; + case pbmessages::NetworkChange_ChangeSource_CV2: + out["change_source"] = "cv2"; + break; + case pbmessages::NetworkChange_ChangeSource_CONTROLLER: + out["change_source"] = "controller"; + break; + default: + out["change_source"] = "unknown"; + break; + } return out; } -nlohmann::json toJson(const pbmessages::MemberChange_Member& mc) +nlohmann::json toJson(const pbmessages::MemberChange_Member& mc, pbmessages::MemberChange_ChangeSource source) { nlohmann::json out; out["id"] = mc.device_id(); @@ -428,6 +426,20 @@ nlohmann::json toJson(const pbmessages::MemberChange_Member& mc) out["versionMinor"] = mc.version_minor(); out["versionRev"] = mc.version_rev(); out["versionProtocol"] = mc.version_protocol(); + switch (source) { + case pbmessages::MemberChange_ChangeSource_CV1: + out["change_source"] = "cv1"; + break; + case pbmessages::MemberChange_ChangeSource_CV2: + out["change_source"] = "cv2"; + break; + case pbmessages::MemberChange_ChangeSource_CONTROLLER: + out["change_source"] = "controller"; + break; + default: + out["change_source"] = "unknown"; + break; + } return out; } diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp new file mode 100644 index 0000000000..7eed8100ce --- /dev/null +++ b/nonfree/controller/PubSubWriter.cpp @@ -0,0 +1,125 @@ +#include "PubSubWriter.hpp" + +#include "CtlUtil.hpp" +#include "member.pb.h" +#include "member_status.pb.h" +#include "network.pb.h" + +#include +#include +#include +#include +#include +#include + +namespace pubsub = ::google::cloud::pubsub; + +namespace ZeroTier { +PubSubWriter::PubSubWriter(std::string controller_id, std::string project, std::string topic) + : _controller_id(controller_id) + , _project(project) + , _topic(topic) +{ + GOOGLE_PROTOBUF_VERIFY_VERSION; + + // If PUBSUB_EMULATOR_HOST is set, create the topic if it doesn't exist + const char* emulatorHost = std::getenv("PUBSUB_EMULATOR_HOST"); + if (emulatorHost != nullptr) { + create_gcp_pubsub_topic_if_needed(project, topic); + } + + auto options = + ::google::cloud::Options {} + .set(pubsub::LimitedTimeRetryPolicy(std::chrono::seconds(5)).clone()) + .set( + pubsub::ExponentialBackoffPolicy(std::chrono::milliseconds(100), std::chrono::seconds(2), 1.3).clone()); + auto publisher = pubsub::MakePublisherConnection(pubsub::Topic(project, topic), std::move(options)); + _publisher = std::make_shared(std::move(publisher)); +} + +PubSubWriter::~PubSubWriter() +{ +} + +bool PubSubWriter::publishMessage(const std::string& payload, const std::string& frontend) +{ + std::vector > attributes; + if (! frontend.empty()) { + attributes.emplace_back("frontend", frontend); + } + attributes.emplace_back("controller_id", _controller_id); + + auto msg = pubsub::MessageBuilder {}.SetData(payload).SetAttributes(attributes).Build(); + auto message_id = _publisher->Publish(std::move(msg)).get(); + if (! message_id) { + fprintf(stderr, "Failed to publish message: %s\n", std::move(message_id).status().message().c_str()); + return false; + } + + fprintf(stderr, "Published message to %s\n", _topic.c_str()); + return true; +} + +bool PubSubWriter::publishNetworkChange(const nlohmann::json& networkJson, const std::string& frontend) +{ + pbmessages::NetworkChange nc; + // nc.mutable_new_()->CopyFrom(fromJson(networkJson)); + std::string payload; + if (! nc.SerializeToString(&payload)) { + fprintf(stderr, "Failed to serialize NetworkChange protobuf message\n"); + return false; + } + + return publishMessage(payload, frontend); +} + +bool PubSubWriter::publishMemberChange(const nlohmann::json& memberJson, const std::string& frontend) +{ + pbmessages::MemberChange mc; + // mc.mutable_new_()->CopyFrom(fromJson(memberJson)); + std::string payload; + if (! mc.SerializeToString(&payload)) { + fprintf(stderr, "Failed to serialize MemberChange protobuf message\n"); + return false; + } + + return publishMessage(payload, frontend); +} + +bool PubSubWriter::publishStatusChange( + std::string frontend, + std::string network_id, + std::string node_id, + std::string os, + std::string arch, + std::string version, + int64_t last_seen) +{ + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("PubSubWriter"); + auto span = tracer->StartSpan("PubSubWriter::publishStatusChange"); + auto scope = tracer->WithActiveSpan(span); + + pbmessages::MemberStatus_MemberStatusMetadata metadata; + metadata.set_controller_id(_controller_id); + metadata.set_trace_id(""); // TODO: generate a trace ID + + pbmessages::MemberStatus ms; + ms.set_network_id(network_id); + ms.set_member_id(node_id); + ms.set_os(os); + ms.set_arch(arch); + ms.set_version(version); + ms.set_timestamp(last_seen); + ms.set_allocated_metadata(&metadata); + + std::string payload; + if (! ms.SerializeToString(&payload)) { + fprintf(stderr, "Failed to serialize StatusChange protobuf message\n"); + return false; + } + + return publishMessage(payload, frontend); +} + +} // namespace ZeroTier \ No newline at end of file diff --git a/nonfree/controller/PubSubWriter.hpp b/nonfree/controller/PubSubWriter.hpp new file mode 100644 index 0000000000..10265a8518 --- /dev/null +++ b/nonfree/controller/PubSubWriter.hpp @@ -0,0 +1,39 @@ +#ifndef ZT_CONTROLLER_PUBSUBWRITER_HPP +#define ZT_CONTROLLER_PUBSUBWRITER_HPP + +#include +#include +#include +#include + +namespace ZeroTier { + +class PubSubWriter { + public: + PubSubWriter(std::string controller_id, std::string project, std::string topic); + virtual ~PubSubWriter(); + + bool publishNetworkChange(const nlohmann::json& networkJson, const std::string& frontend = ""); + bool publishMemberChange(const nlohmann::json& memberJson, const std::string& frontend = ""); + bool publishStatusChange( + std::string frontend, + std::string network_id, + std::string node_id, + std::string os, + std::string arch, + std::string version, + int64_t last_seen); + + protected: + bool publishMessage(const std::string& payload, const std::string& frontend = ""); + + private: + std::string _controller_id; + std::string _project; + std::string _topic; + std::shared_ptr _publisher; +}; + +} // namespace ZeroTier + +#endif // ZT_CONTROLLER_PUBSUBWRITER_HPP \ No newline at end of file diff --git a/nonfree/controller/RedisStatusWriter.cpp b/nonfree/controller/RedisStatusWriter.cpp index 9ad04eb249..e74dce4ff5 100644 --- a/nonfree/controller/RedisStatusWriter.cpp +++ b/nonfree/controller/RedisStatusWriter.cpp @@ -32,10 +32,11 @@ void RedisStatusWriter::updateNodeStatus( const std::string& arch, const std::string& version, const InetAddress& address, - int64_t last_seen) + int64_t last_seen, + const std::string& /* frontend unused */) { std::lock_guard l(_lock); - _pending.push_back({ network_id, node_id, os, arch, version, address, last_seen }); + _pending.push_back({ network_id, node_id, os, arch, version, address, last_seen, "" }); } size_t RedisStatusWriter::queueLength() const diff --git a/nonfree/controller/RedisStatusWriter.hpp b/nonfree/controller/RedisStatusWriter.hpp index ac0ffd8668..dc05c77efd 100644 --- a/nonfree/controller/RedisStatusWriter.hpp +++ b/nonfree/controller/RedisStatusWriter.hpp @@ -23,7 +23,8 @@ class RedisStatusWriter : public StatusWriter { const std::string& arch, const std::string& version, const InetAddress& address, - int64_t last_seen) override; + int64_t last_seen, + const std::string& /* frontend unused */) override; virtual size_t queueLength() const override; virtual void writePending() override; diff --git a/nonfree/controller/StatusWriter.hpp b/nonfree/controller/StatusWriter.hpp index 78b36f5869..500005b96b 100644 --- a/nonfree/controller/StatusWriter.hpp +++ b/nonfree/controller/StatusWriter.hpp @@ -23,7 +23,8 @@ class StatusWriter { const std::string& arch, const std::string& version, const InetAddress& address, - int64_t last_seen) = 0; + int64_t last_seen, + const std::string& target) = 0; virtual size_t queueLength() const = 0; virtual void writePending() = 0; }; @@ -36,6 +37,7 @@ struct PendingStatusEntry { std::string version; InetAddress address; int64_t last_seen; + std::string target; }; } // namespace ZeroTier From 7ad264df92e32cbeec37397938aae6ec3c1606e7 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 5 Sep 2025 15:20:33 -0700 Subject: [PATCH 102/245] whoops. mesed up the migrate naming convention --- .../migrations/{0003_frontend_down.sql => 0003_frontend.down.sql} | 0 .../migrations/{0003_frontend_up.sql => 0003_frontend.up.sql} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename ext/central-controller-docker/migrations/{0003_frontend_down.sql => 0003_frontend.down.sql} (100%) rename ext/central-controller-docker/migrations/{0003_frontend_up.sql => 0003_frontend.up.sql} (100%) diff --git a/ext/central-controller-docker/migrations/0003_frontend_down.sql b/ext/central-controller-docker/migrations/0003_frontend.down.sql similarity index 100% rename from ext/central-controller-docker/migrations/0003_frontend_down.sql rename to ext/central-controller-docker/migrations/0003_frontend.down.sql diff --git a/ext/central-controller-docker/migrations/0003_frontend_up.sql b/ext/central-controller-docker/migrations/0003_frontend.up.sql similarity index 100% rename from ext/central-controller-docker/migrations/0003_frontend_up.sql rename to ext/central-controller-docker/migrations/0003_frontend.up.sql From 3d72a43a199ce0baaeb5fc834b7ec84dc6ef1deb Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Sat, 6 Sep 2025 12:37:28 -0700 Subject: [PATCH 103/245] misc bugfixes --- ext/central-controller-docker/main-new.sh | 12 ++- nonfree/controller/BigTableStatusWriter.cpp | 87 +++++++++++++++++---- nonfree/controller/BigTableStatusWriter.hpp | 2 + nonfree/controller/CentralDB.cpp | 9 ++- nonfree/controller/PubSubListener.cpp | 5 +- nonfree/controller/PubSubWriter.cpp | 5 +- nonfree/controller/PubSubWriter.hpp | 2 +- tmp/local.conf | 33 ++++++++ 8 files changed, 131 insertions(+), 24 deletions(-) create mode 100644 tmp/local.conf diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index f40933ef2c..aa0dba0fa3 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -80,9 +80,9 @@ if [ "$ZT_USE_BIGTABLE" == "true" ]; then fi BIGTABLE_CONF=", \"bigtable\": { - \"project\": \"${ZT_BIGTABLE_PROJECT}\", - \"instance\": \"${ZT_BIGTABLE_INSTANCE}\", - \"table\": \"${ZT_BIGTABLE_TABLE}\" + \"project_id\": \"${ZT_BIGTABLE_PROJECT}\", + \"instance_id\": \"${ZT_BIGTABLE_INSTANCE}\", + \"table_id\": \"${ZT_BIGTABLE_TABLE}\" } " fi @@ -96,7 +96,7 @@ if [ "$ZT_USE_PUBSUB" == "true" ]; then fi PUBSUB_CONF=", \"pubsub\": { - \"project\": \"${ZT_CTL_PUBSUB_PROJECT}\" + \"project_id\": \"${ZT_PUBSUB_PROJECT}\" } " fi @@ -161,6 +161,10 @@ if [ -n "$ZT_TEMPORAL_HOST" ] && [ -n "$ZT_TEMPORAL_PORT" ]; then echo "Temporal is up" fi +cat /var/lib/zerotier-one/local.conf + +export GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes +export LIBC_FATAL_STDERR_=1 export GLIBCXX_FORCE_NEW=1 export GLIBCPP_FORCE_NEW=1 export LD_PRELOAD="/opt/conda/envs/central_controller/lib/libjemalloc.so.2" diff --git a/nonfree/controller/BigTableStatusWriter.cpp b/nonfree/controller/BigTableStatusWriter.cpp index 61f75f3247..8c525cc68e 100644 --- a/nonfree/controller/BigTableStatusWriter.cpp +++ b/nonfree/controller/BigTableStatusWriter.cpp @@ -31,12 +31,22 @@ BigTableStatusWriter::BigTableStatusWriter( , _instance_id(instance_id) , _table_id(table_id) , _pubsubWriter(pubsubWriter) + , _table(nullptr) { + _table = new cbt::Table(cbt::MakeDataConnection(), cbt::TableResource(_project_id, _instance_id, _table_id)); + fprintf( + stderr, "BigTableStatusWriter for project %s instance %s table %s\n", project_id.c_str(), instance_id.c_str(), + table_id.c_str()); } BigTableStatusWriter::~BigTableStatusWriter() { writePending(); + + if (_table != nullptr) { + delete _table; + _table = nullptr; + } } void BigTableStatusWriter::updateNodeStatus( @@ -79,11 +89,8 @@ void BigTableStatusWriter::writePending() if (toWrite.empty()) { return; } + fprintf(stderr, "Writing %zu pending status entries to BigTable\n", toWrite.size()); - namespace cbt = google::cloud::bigtable; - cbt::Table table(cbt::MakeDataConnection(), cbt::TableResource(_project_id, _instance_id, _table_id)); - - cbt::BulkMutation bulk; for (const auto& entry : toWrite) { std::string row_key = entry.network_id + "#" + entry.node_id; cbt::SingleRowMutation m(row_key); @@ -91,26 +98,74 @@ void BigTableStatusWriter::writePending() m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, archColumn, entry.arch)); m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, versionColumn, entry.version)); char buf[64] = { 0 }; + std::string addressStr = entry.address.toString(buf); if (entry.address.ss_family == AF_INET) { - m.emplace_back(cbt::SetCell(checkInColumnFamily, ipv4Column, entry.address.toString(buf))); + m.emplace_back(cbt::SetCell(checkInColumnFamily, ipv4Column, std::move(addressStr))); } else if (entry.address.ss_family == AF_INET6) { - m.emplace_back(cbt::SetCell(checkInColumnFamily, ipv6Column, entry.address.toString(buf))); + m.emplace_back(cbt::SetCell(checkInColumnFamily, ipv6Column, std::move(addressStr))); } int64_t ts = entry.last_seen; m.emplace_back(cbt::SetCell(checkInColumnFamily, lastSeenColumn, std::move(ts))); - bulk.push_back(std::move(m)); - // TODO: Check performance on this. May need to bach these. - _pubsubWriter->publishStatusChange( - entry.target, entry.network_id, entry.node_id, entry.os, entry.arch, entry.version, entry.last_seen); - } - - std::vector failures = table.BulkApply(bulk); - for (auto const& r : failures) { - // Handle error (log it, retry, etc.) - std::cerr << "Error writing to BigTable: " << r.status() << "\n"; + try { + auto status = _table->Apply(std::move(m)); + if (! status.ok()) { + fprintf(stderr, "Error writing to BigTable: %s\n", status.message().c_str()); + } + else { + _pubsubWriter->publishStatusChange( + entry.target, entry.network_id, entry.node_id, entry.os, entry.arch, entry.version, + entry.last_seen); + } + } + catch (const std::exception& e) { + fprintf(stderr, "Exception writing to BigTable: %s\n", e.what()); + span->SetAttribute("error", e.what()); + span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + return; + } } + // cbt::BulkMutation bulk; + // for (const auto& entry : toWrite) { + // std::string row_key = entry.network_id + "#" + entry.node_id; + // cbt::SingleRowMutation m(row_key); + // m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, osColumn, entry.os)); + // m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, archColumn, entry.arch)); + // m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, versionColumn, entry.version)); + // char buf[64] = { 0 }; + // std::string addressStr = entry.address.toString(buf); + // if (entry.address.ss_family == AF_INET) { + // m.emplace_back(cbt::SetCell(checkInColumnFamily, ipv4Column, std::move(addressStr))); + // } + // else if (entry.address.ss_family == AF_INET6) { + // m.emplace_back(cbt::SetCell(checkInColumnFamily, ipv6Column, std::move(addressStr))); + // } + // int64_t ts = entry.last_seen; + // m.emplace_back(cbt::SetCell(checkInColumnFamily, lastSeenColumn, std::move(ts))); + // bulk.emplace_back(m); + + // // TODO: Check performance on this. May need to bach these. + // _pubsubWriter->publishStatusChange( + // entry.target, entry.network_id, entry.node_id, entry.os, entry.arch, entry.version, entry.last_seen); + // } + + // fprintf(stderr, "Applying %zu mutations to BigTable\n", bulk.size()); + + // try { + // std::vector failures = table.BulkApply(std::move(bulk)); + // fprintf(stderr, "BigTable write completed with %zu failures\n", failures.size()); + // for (auto const& r : failures) { + // // Handle error (log it, retry, etc.) + // std::cerr << "Error writing to BigTable: " << r.status() << "\n"; + // } + // } + // catch (const std::exception& e) { + // fprintf(stderr, "Exception writing to BigTable: %s\n", e.what()); + // span->SetAttribute("error", e.what()); + // span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + // return; + // } } } // namespace ZeroTier \ No newline at end of file diff --git a/nonfree/controller/BigTableStatusWriter.hpp b/nonfree/controller/BigTableStatusWriter.hpp index 00ab0647f4..750b46685c 100644 --- a/nonfree/controller/BigTableStatusWriter.hpp +++ b/nonfree/controller/BigTableStatusWriter.hpp @@ -3,6 +3,7 @@ #include "StatusWriter.hpp" +#include #include #include #include @@ -40,6 +41,7 @@ class BigTableStatusWriter : public StatusWriter { mutable std::mutex _lock; std::vector _pending; std::shared_ptr _pubsubWriter; + google::cloud::bigtable::Table* _table; }; } // namespace ZeroTier diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index a351b42baf..668e025ebc 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -147,6 +147,7 @@ CentralDB::CentralDB( switch (listenMode) { case LISTENER_MODE_REDIS: + fprintf(stderr, "Using Redis for change listeners\n"); if (_cc->redisConfig != NULL) { if (_cc->redisConfig->clusterMode) { _membersDbWatcher = std::make_shared(_myAddressStr, _cluster, this); @@ -161,6 +162,7 @@ CentralDB::CentralDB( throw std::runtime_error("CentralDB: Redis listener mode selected but no Redis configuration provided"); } case LISTENER_MODE_PUBSUB: + fprintf(stderr, "Using PubSub for change listeners\n"); if (cc->pubSubConfig != NULL) { _membersDbWatcher = std::make_shared(_myAddressStr, cc->pubSubConfig->project_id, this); @@ -174,6 +176,7 @@ CentralDB::CentralDB( break; case LISTENER_MODE_PGSQL: default: + fprintf(stderr, "Using PostgreSQL for change listeners\n"); _membersDbWatcher = std::make_shared(this, _pool, "member_" + _myAddressStr, 5); _networksDbWatcher = std::make_shared(this, _pool, "network_" + _myAddressStr, 5); break; @@ -182,6 +185,7 @@ CentralDB::CentralDB( std::shared_ptr pubsubWriter; switch (statusMode) { case STATUS_WRITER_MODE_REDIS: + fprintf(stderr, "Using Redis for status writer\n"); if (_cc->redisConfig != NULL) { if (_cc->redisConfig->clusterMode) { _statusWriter = std::make_shared(_cluster, _myAddressStr); @@ -195,6 +199,7 @@ CentralDB::CentralDB( } break; case STATUS_WRITER_MODE_BIGTABLE: + fprintf(stderr, "Using BigTable for status writer\n"); if (cc->bigTableConfig == NULL) { throw std::runtime_error( "CentralDB: BigTable status mode selected but no BigTable configuration provided"); @@ -213,6 +218,7 @@ CentralDB::CentralDB( break; case STATUS_WRITER_MODE_PGSQL: default: + fprintf(stderr, "Using PostgreSQL for status writer\n"); _statusWriter = std::make_shared(_pool); break; } @@ -823,7 +829,7 @@ void CentralDB::initializeMembers() "(EXTRACT(EPOCH FROM nm.creation_time AT TIME ZONE 'UTC')*1000)::bigint, nm.identity, " "(EXTRACT(EPOCH FROM nm.last_authorized_time AT TIME ZONE 'UTC')*1000)::bigint, " "(EXTRACT(EPOCH FROM nm.last_deauthorized_time AT TIME ZONE 'UTC')*1000)::bigint, " - "nm.remote_trace_level, nm.remote_trace_target, nm.revision, nm.capabilities, nm.tags " + "nm.remote_trace_level, nm.remote_trace_target, nm.revision, nm.capabilities, nm.tags, " "nm.frontend " "FROM network_memberships_ctl nm " "INNER JOIN networks_ctl n " @@ -1492,6 +1498,7 @@ void CentralDB::onlineNotificationThread() _statusWriter->updateNodeStatus( networkId, memberId, os, arch, "", i->second.physicalAddress, ts, frontend); + fprintf(stderr, "sent node status update\n"); } _statusWriter->writePending(); w.commit(); diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index f4f14db993..c6af9534e9 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -30,11 +30,14 @@ PubSubListener::PubSubListener(std::string controller_id, std::string project, s : _controller_id(controller_id) , _project(project) , _topic(topic) - , _subscription_id("sub-" + controller_id + "-network-changes") + , _subscription_id("sub-" + controller_id + "-" + topic) , _run(false) , _adminClient(pubsub_admin::MakeSubscriptionAdminConnection()) , _subscription(pubsub::Subscription(_project, _subscription_id)) { + fprintf( + stderr, "PubSubListener for controller %s project %s topic %s subscription %s\n", controller_id.c_str(), + project.c_str(), topic.c_str(), _subscription_id.c_str()); GOOGLE_PROTOBUF_VERIFY_VERSION; // If PUBSUB_EMULATOR_HOST is set, create the topic if it doesn't exist diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index 7eed8100ce..25698f363f 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -15,11 +15,14 @@ namespace pubsub = ::google::cloud::pubsub; namespace ZeroTier { -PubSubWriter::PubSubWriter(std::string controller_id, std::string project, std::string topic) +PubSubWriter::PubSubWriter(std::string project, std::string topic, std::string controller_id) : _controller_id(controller_id) , _project(project) , _topic(topic) { + fprintf( + stderr, "PubSubWriter for controller %s project %s topic %s\n", controller_id.c_str(), project.c_str(), + topic.c_str()); GOOGLE_PROTOBUF_VERIFY_VERSION; // If PUBSUB_EMULATOR_HOST is set, create the topic if it doesn't exist diff --git a/nonfree/controller/PubSubWriter.hpp b/nonfree/controller/PubSubWriter.hpp index 10265a8518..170403d39a 100644 --- a/nonfree/controller/PubSubWriter.hpp +++ b/nonfree/controller/PubSubWriter.hpp @@ -10,7 +10,7 @@ namespace ZeroTier { class PubSubWriter { public: - PubSubWriter(std::string controller_id, std::string project, std::string topic); + PubSubWriter(std::string project, std::string topic, std::string controller_id); virtual ~PubSubWriter(); bool publishNetworkChange(const nlohmann::json& networkJson, const std::string& frontend = ""); diff --git a/tmp/local.conf b/tmp/local.conf new file mode 100644 index 0000000000..9555b24d37 --- /dev/null +++ b/tmp/local.conf @@ -0,0 +1,33 @@ +{ + "settings": { + "controllerDbPath": "postgres:host=postgres port=5432 dbname=central user=testuser password=test_password application_name=controller-203e4472cf sslmode=prefer sslcert= sslkey= sslrootcert=", + "portMappingEnabled": true, + "softwareUpdate": "disable", + "interfacePrefixBlacklist": [ + "inot", + "nat64" + ], + "lowBandwidthMode": false, + "ssoRedirectURL": "", + "allowManagementFrom": ["127.0.0.1", "::1", "10.0.0.0/8"], + "otel": { + "exporterEndpoint": "jaeger:4317", + "exporterSampleRate": 1 + } + , "redis": null + }, + "controller": { + "listenMode": "pubsub", + "statusMode": "bigtable" + , "redis": null + , "bigtable": { + "project_id": "arbitrary-project", + "instance_id": "arbitrary-instance", + "table_id": "member_status" + } + + , "pubsub": { + "project_id": "arbitrary-project" + } + } +} From 69efa924e27eecae4e295b9d5adde97837d826e6 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Sat, 6 Sep 2025 15:01:48 -0700 Subject: [PATCH 104/245] apply patch to libnatpmp repo so we can compile on macOS with CMake --- cmake/miniupnpc.cmake | 2 ++ ext/cmake-patches/libnatpmp.patch | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 ext/cmake-patches/libnatpmp.patch diff --git a/cmake/miniupnpc.cmake b/cmake/miniupnpc.cmake index c743721ff4..44565a58ad 100644 --- a/cmake/miniupnpc.cmake +++ b/cmake/miniupnpc.cmake @@ -22,6 +22,8 @@ FetchContent_Declare( GIT_REPOSITORY https://github.com/miniupnp/libnatpmp.git GIT_TAG master GIT_SHALLOW ON + PATCH_COMMAND git apply ${CMAKE_SOURCE_DIR}/ext/cmake-patches/libnatpmp.patch + UPDATE_DISCONNECTED TRUE ) FetchContent_MakeAvailable(libnatpmp) diff --git a/ext/cmake-patches/libnatpmp.patch b/ext/cmake-patches/libnatpmp.patch new file mode 100644 index 0000000000..5b14957076 --- /dev/null +++ b/ext/cmake-patches/libnatpmp.patch @@ -0,0 +1,19 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 16af4aa..1eb89f7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,6 +1,6 @@ + cmake_minimum_required(VERSION 3.5) + +-file(STRINGS VERSION PVER) ++set(PVER "20120821") + + project(natpmp + LANGUAGES C +diff --git a/VERSION b/VERSION +deleted file mode 100644 +index 2ed7994..0000000 +--- a/VERSION ++++ /dev/null +@@ -1 +0,0 @@ +-20120821 From 36219c59aea3124c84ff15a5eaa22f40d423ead1 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Sat, 6 Sep 2025 15:02:48 -0700 Subject: [PATCH 105/245] compiler on mac doesn't like this. not really needed though --- nonfree/controller/PubSubListener.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index c6af9534e9..26f5b27c0d 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -87,7 +87,6 @@ void PubSubListener::subscribe() auto scope = tracer->WithActiveSpan(span); span->SetAttribute("message_id", m.message_id()); span->SetAttribute("ordering_key", m.ordering_key()); - span->SetAttribute("attributes", m.attributes().size()); fprintf(stderr, "Received message %s\n", m.message_id().c_str()); onNotification(m.data()); From a78ac17d10804b0d9361d8fa085fbe8141534201 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Sat, 6 Sep 2025 15:02:59 -0700 Subject: [PATCH 106/245] fix compile & link on macOS --- CMakeLists.txt | 11 ++++++++++- osdep/CMakeLists.txt | 14 ++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf2d25bfca..8159cd1634 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ if(CPU_ARCHITECTURE STREQUAL "x86_64") -DZT_USE_X64_ASM_SALSA2012=1 -DZT_USE_FAST_X64_ED25519=1 ) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack") elseif(CPU_ARCHITECTURE STREQUAL "aarch64") add_definitions(-DZT_ARCHITECTURE=4 -DZT_ARCH_ARM_HAS_NEON=1 -DZT_SSO_SUPPORTED=1 -DZT_AES_NEON=1) add_compile_options(-march=armv8-a+crypto -mtune=generic -mstrict-align) @@ -80,7 +81,7 @@ add_library(rustybits STATIC IMPORTED GLOBAL) set_property(TARGET rustybits PROPERTY IMPORTED_LOCATION ${RUSTYBITS_LIB}) add_dependencies(rustybits rustybits_build) -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack") + # Get & build dependencies not in conda include (cmake/cpp-httplib.cmake) @@ -124,6 +125,14 @@ if(ZT1_CENTRAL_CONTROLLER) ) endif() +if (APPLE) + find_library(COREFOUNDATION_LIBRARY CoreFoundation) + find_library(SECURITY_LIBRARY Security) + find_library(SYSTEM_CONFIGURATION_LIBRARY SystemConfiguration) + find_library(CARBON Carbon) + find_library(CORESERVICES_LIBRARY CoreServices) + list(APPEND LINKED_LIBRARIES ${COREFOUNDATION_LIBRARY} ${SECURITY_LIBRARY} ${CARBON_LIBRARY} ${SYSTEM_CONFIGURATION_LIBRARY} ${CORESERVICES_LIBRARY}) +endif() add_executable(zerotier-one one.cpp diff --git a/osdep/CMakeLists.txt b/osdep/CMakeLists.txt index 43e4cb8ce5..a1f09b3106 100644 --- a/osdep/CMakeLists.txt +++ b/osdep/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.13) project(zerotier-osdep LANGUAGES CXX ASM) +if(APPLE) + enable_language(OBJCXX) +endif() + set(SRC_FILES Arp.cpp Arp.hpp @@ -39,12 +43,14 @@ if(LINUX) LinuxNetLink.hpp) endif() -if(MACOS) +if(APPLE) list(APPEND SRC_FILES - MacOSEthernetTap.cpp - MacOSEthernetTap.hpp + MacEthernetTap.cpp + MacEthernetTap.hpp MacKextEthernetTap.cpp - MacKextEthernetTap.hpp) + MacKextEthernetTap.hpp + MacDNSHelper.mm + MacDNSHelper.hpp) endif() add_library(zerotier-osdep STATIC ${SRC_FILES}) From 71d68e9a60ec712329183d8b679e3432cdad2d87 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 8 Sep 2025 08:49:23 -0700 Subject: [PATCH 107/245] fix stack corruption in DB::get --- CMakeLists.txt | 16 ++++++++++++++-- nonfree/controller/DB.cpp | 13 ++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8159cd1634..99898c4eb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,12 +4,14 @@ cmake_minimum_required (VERSION 3.13) project (zerotier-one LANGUAGES CXX C) option(ZT1_CENTRAL_CONTROLLER "Build with ZeroTier Central Controller support" OFF) - +oiption(ADDRESS_SANITIZER "Build with Address Sanitizer enabled (only for x86_64/arm64)" OFF +) set (PROJ_DIR ${PROJECT_SOURCE_DIR}) execute_process(COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE CPU_ARCHITECTURE) set(CPU_ARCHITECTURE ${CPU_ARCHITECTURE} CACHE STRING "Target CPU architecture (detected automatically)") message(STATUS "Detected CPU architecture: ${CPU_ARCHITECTURE}") + if(CPU_ARCHITECTURE STREQUAL "x86_64") add_definitions( -DZT_ARCHITECTURE=2 @@ -20,9 +22,19 @@ if(CPU_ARCHITECTURE STREQUAL "x86_64") -DZT_USE_FAST_X64_ED25519=1 ) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack") -elseif(CPU_ARCHITECTURE STREQUAL "aarch64") + + if(ADDRESS_SANITIZER) + add_compile_options(-fsanitize=address) + add_link_options(-fsanitize=address) + endif() +elseif(CPU_ARCHITECTURE STREQUAL "aarch64" OR CPU_ARCHITECTURE STREQUAL "arm64") add_definitions(-DZT_ARCHITECTURE=4 -DZT_ARCH_ARM_HAS_NEON=1 -DZT_SSO_SUPPORTED=1 -DZT_AES_NEON=1) add_compile_options(-march=armv8-a+crypto -mtune=generic -mstrict-align) + + if(ADDRESS_SANITIZER) + add_compile_options(-fsanitize=address) + add_link_options(-fsanitize=address) + endif() endif() include(FetchContent) diff --git a/nonfree/controller/DB.cpp b/nonfree/controller/DB.cpp index e71fe6eeef..ad0766d4ff 100644 --- a/nonfree/controller/DB.cpp +++ b/nonfree/controller/DB.cpp @@ -216,14 +216,21 @@ bool DB::get(const uint64_t networkId, nlohmann::json& network, const uint64_t m return true; } -bool DB::get(const uint64_t networkId, nlohmann::json& network, const uint64_t memberId, nlohmann::json& member, NetworkSummaryInfo& info) +bool DB::get( + const uint64_t networkId, + nlohmann::json& network, + const uint64_t memberId, + nlohmann::json& member, + NetworkSummaryInfo& info) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("db"); auto span = tracer->StartSpan("db::getNetworkAndMemberAndSummary"); auto scope = tracer->WithActiveSpan(span); - char networkIdStr[17]; - char memberIdStr[11]; + char networkIdStr[32]; + memset(networkIdStr, 0, sizeof(networkIdStr)); + char memberIdStr[32]; + memset(memberIdStr, 0, sizeof(memberIdStr)); span->SetAttribute("network_id", Utils::hex(networkId, networkIdStr)); span->SetAttribute("member_id", Utils::hex(memberId, memberIdStr)); From ebf66b79202234a8befb17433505fc4c4b24ab07 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 8 Sep 2025 08:53:35 -0700 Subject: [PATCH 108/245] fix typo in cmake file --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 99898c4eb3..c13af6dcd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required (VERSION 3.13) project (zerotier-one LANGUAGES CXX C) option(ZT1_CENTRAL_CONTROLLER "Build with ZeroTier Central Controller support" OFF) -oiption(ADDRESS_SANITIZER "Build with Address Sanitizer enabled (only for x86_64/arm64)" OFF +option(ADDRESS_SANITIZER "Build with Address Sanitizer enabled (only for x86_64/arm64)" OFF ) set (PROJ_DIR ${PROJECT_SOURCE_DIR}) From 006ced29002e4b06b878e710f0c17a48edb25571 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 8 Sep 2025 09:05:00 -0700 Subject: [PATCH 109/245] more fixes --- nonfree/controller/DB.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/nonfree/controller/DB.cpp b/nonfree/controller/DB.cpp index ad0766d4ff..a0d76f6c91 100644 --- a/nonfree/controller/DB.cpp +++ b/nonfree/controller/DB.cpp @@ -164,7 +164,8 @@ bool DB::get(const uint64_t networkId, nlohmann::json& network) auto tracer = provider->GetTracer("db"); auto span = tracer->StartSpan("db::getNetwork"); auto scope = tracer->WithActiveSpan(span); - char networkIdStr[17]; + char networkIdStr[32]; + memset(networkIdStr, 0, sizeof(networkIdStr)); span->SetAttribute("network_id", Utils::hex(networkId, networkIdStr)); waitForReady(); @@ -190,8 +191,10 @@ bool DB::get(const uint64_t networkId, nlohmann::json& network, const uint64_t m auto tracer = provider->GetTracer("db"); auto span = tracer->StartSpan("db::getNetworkAndMember"); auto scope = tracer->WithActiveSpan(span); - char networkIdStr[17]; - char memberIdStr[11]; + char networkIdStr[32]; + memset(networkIdStr, 0, sizeof(networkIdStr)); + char memberIdStr[32]; + memset(memberIdStr, 0, sizeof(memberIdStr)); span->SetAttribute("network_id", Utils::hex(networkId, networkIdStr)); span->SetAttribute("member_id", Utils::hex(networkId, memberIdStr)); @@ -263,7 +266,8 @@ bool DB::get(const uint64_t networkId, nlohmann::json& network, std::vectorGetTracer("db"); auto span = tracer->StartSpan("db::getNetworkAndMembers"); auto scope = tracer->WithActiveSpan(span); - char networkIdStr[17]; + char networkIdStr[32]; + memset(networkIdStr, 0, sizeof(networkIdStr)); span->SetAttribute("network_id", Utils::hex(networkId, networkIdStr)); waitForReady(); From 190d836b421a777b8349bf306078d0034c844256 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 8 Sep 2025 09:49:26 -0700 Subject: [PATCH 110/245] alloc meatadata with new so pubsub can delete it --- nonfree/controller/PubSubWriter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index 25698f363f..2fe3f52d5d 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -103,9 +103,9 @@ bool PubSubWriter::publishStatusChange( auto span = tracer->StartSpan("PubSubWriter::publishStatusChange"); auto scope = tracer->WithActiveSpan(span); - pbmessages::MemberStatus_MemberStatusMetadata metadata; - metadata.set_controller_id(_controller_id); - metadata.set_trace_id(""); // TODO: generate a trace ID + pbmessages::MemberStatus_MemberStatusMetadata* metadata = new pbmessages::MemberStatus_MemberStatusMetadata(); + metadata->set_controller_id(_controller_id); + metadata->set_trace_id(""); // TODO: generate a trace ID pbmessages::MemberStatus ms; ms.set_network_id(network_id); @@ -114,7 +114,7 @@ bool PubSubWriter::publishStatusChange( ms.set_arch(arch); ms.set_version(version); ms.set_timestamp(last_seen); - ms.set_allocated_metadata(&metadata); + ms.set_allocated_metadata(metadata); std::string payload; if (! ms.SerializeToString(&payload)) { From f51bfdb666c091908317b86d1ea52fc581e2ed47 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 8 Sep 2025 10:25:32 -0700 Subject: [PATCH 111/245] delete pubsub subscription on shutdown --- nonfree/controller/PubSubListener.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 26f5b27c0d..514a4522a9 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -73,6 +73,11 @@ PubSubListener::~PubSubListener() if (_subscriberThread.joinable()) { _subscriberThread.join(); } + + auto status = _adminClient.DeleteSubscription(_subscription.FullName()); + if (! status.ok()) { + fprintf(stderr, "Failed to delete subscription: %s\n", status.message().c_str()); + } } void PubSubListener::subscribe() From 88f08fa58c0cf76917fa3189bb9813732d4131a2 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 8 Sep 2025 10:29:30 -0700 Subject: [PATCH 112/245] append 8 random hex chars to the subscription id --- nonfree/controller/CtlUtil.cpp | 15 +++++++++++++++ nonfree/controller/CtlUtil.hpp | 4 +++- nonfree/controller/PubSubListener.cpp | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/nonfree/controller/CtlUtil.cpp b/nonfree/controller/CtlUtil.cpp index 4ec5fa9876..36aad01b09 100644 --- a/nonfree/controller/CtlUtil.cpp +++ b/nonfree/controller/CtlUtil.cpp @@ -80,6 +80,21 @@ std::string url_encode(const std::string& value) return escaped.str(); } +std::string random_hex_string(std::size_t length) +{ + static const char hex_chars[] = "0123456789abcdef"; + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_int_distribution<> dis(0, 15); + + std::string result; + result.reserve(length); + for (std::size_t i = 0; i < length; ++i) { + result += hex_chars[dis(gen)]; + } + return result; +} + #ifdef ZT1_CENTRAL_CONTROLLER void create_gcp_pubsub_topic_if_needed(std::string project_id, std::string topic_id) { diff --git a/nonfree/controller/CtlUtil.hpp b/nonfree/controller/CtlUtil.hpp index b010d1c79e..5ae541959d 100644 --- a/nonfree/controller/CtlUtil.hpp +++ b/nonfree/controller/CtlUtil.hpp @@ -16,8 +16,10 @@ std::vector split(std::string str, char delim); std::string url_encode(const std::string& value); +std::string random_hex_string(std::size_t length) + #ifdef ZT1_CENTRAL_CONTROLLER -void create_gcp_pubsub_topic_if_needed(std::string project_id, std::string topic_id); + void create_gcp_pubsub_topic_if_needed(std::string project_id, std::string topic_id); #endif } // namespace ZeroTier diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 514a4522a9..31f3eeff13 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -35,6 +35,7 @@ PubSubListener::PubSubListener(std::string controller_id, std::string project, s , _adminClient(pubsub_admin::MakeSubscriptionAdminConnection()) , _subscription(pubsub::Subscription(_project, _subscription_id)) { + _subscription_id = _subscription_id + "-" + random_hex_string(8); fprintf( stderr, "PubSubListener for controller %s project %s topic %s subscription %s\n", controller_id.c_str(), project.c_str(), topic.c_str(), _subscription_id.c_str()); From 934aa93ef8ff98b1778ccee75241f4c2a4100237 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 8 Sep 2025 10:32:57 -0700 Subject: [PATCH 113/245] forgot a ; --- nonfree/controller/CtlUtil.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nonfree/controller/CtlUtil.hpp b/nonfree/controller/CtlUtil.hpp index 5ae541959d..46faed2b7d 100644 --- a/nonfree/controller/CtlUtil.hpp +++ b/nonfree/controller/CtlUtil.hpp @@ -16,10 +16,10 @@ std::vector split(std::string str, char delim); std::string url_encode(const std::string& value); -std::string random_hex_string(std::size_t length) +std::string random_hex_string(std::size_t length); #ifdef ZT1_CENTRAL_CONTROLLER - void create_gcp_pubsub_topic_if_needed(std::string project_id, std::string topic_id); +void create_gcp_pubsub_topic_if_needed(std::string project_id, std::string topic_id); #endif } // namespace ZeroTier From 1ba4ccd98d73d87eef38bd84f11bd8a3cf8b7300 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 8 Sep 2025 10:46:01 -0700 Subject: [PATCH 114/245] pass version info to status writer --- nonfree/controller/CentralDB.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 668e025ebc..c8037e033b 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1491,13 +1491,18 @@ void CentralDB::onlineNotificationThread() std::string os = "unknown"; std::string arch = "unknown"; std::string frontend = member["frontend"].get(); + + std::string vMajor = OSUtils::jsonString(member["vMajor"], "0"); + std::string vMinor = OSUtils::jsonString(member["vMinor"], "0"); + std::string vRev = OSUtils::jsonString(member["vRev"], "0"); + std::string version = "v" + vMajor + "." + vMinor + "." + vRev; if (osArchSplit.size() == 2) { os = osArchSplit[0]; arch = osArchSplit[1]; } _statusWriter->updateNodeStatus( - networkId, memberId, os, arch, "", i->second.physicalAddress, ts, frontend); + networkId, memberId, os, arch, version, i->second.physicalAddress, ts, frontend); fprintf(stderr, "sent node status update\n"); } _statusWriter->writePending(); From 1d65c1e43ece313224ebf5b0841bed264ff5095a Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 8 Sep 2025 10:50:10 -0700 Subject: [PATCH 115/245] back to bulk apply for status updates in BigTable --- nonfree/controller/BigTableStatusWriter.cpp | 73 +++++---------------- 1 file changed, 17 insertions(+), 56 deletions(-) diff --git a/nonfree/controller/BigTableStatusWriter.cpp b/nonfree/controller/BigTableStatusWriter.cpp index 8c525cc68e..09447ed077 100644 --- a/nonfree/controller/BigTableStatusWriter.cpp +++ b/nonfree/controller/BigTableStatusWriter.cpp @@ -91,6 +91,7 @@ void BigTableStatusWriter::writePending() } fprintf(stderr, "Writing %zu pending status entries to BigTable\n", toWrite.size()); + cbt::BulkMutation bulk; for (const auto& entry : toWrite) { std::string row_key = entry.network_id + "#" + entry.node_id; cbt::SingleRowMutation m(row_key); @@ -107,65 +108,25 @@ void BigTableStatusWriter::writePending() } int64_t ts = entry.last_seen; m.emplace_back(cbt::SetCell(checkInColumnFamily, lastSeenColumn, std::move(ts))); + bulk.emplace_back(m); + } - try { - auto status = _table->Apply(std::move(m)); - if (! status.ok()) { - fprintf(stderr, "Error writing to BigTable: %s\n", status.message().c_str()); - } - else { - _pubsubWriter->publishStatusChange( - entry.target, entry.network_id, entry.node_id, entry.os, entry.arch, entry.version, - entry.last_seen); - } - } - catch (const std::exception& e) { - fprintf(stderr, "Exception writing to BigTable: %s\n", e.what()); - span->SetAttribute("error", e.what()); - span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - return; + fprintf(stderr, "Applying %zu mutations to BigTable\n", bulk.size()); + + try { + std::vector failures = _table->BulkApply(std::move(bulk)); + fprintf(stderr, "BigTable write completed with %zu failures\n", failures.size()); + for (auto const& r : failures) { + // Handle error (log it, retry, etc.) + std::cerr << "Error writing to BigTable: " << r.status() << "\n"; } } - // cbt::BulkMutation bulk; - // for (const auto& entry : toWrite) { - // std::string row_key = entry.network_id + "#" + entry.node_id; - // cbt::SingleRowMutation m(row_key); - // m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, osColumn, entry.os)); - // m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, archColumn, entry.arch)); - // m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, versionColumn, entry.version)); - // char buf[64] = { 0 }; - // std::string addressStr = entry.address.toString(buf); - // if (entry.address.ss_family == AF_INET) { - // m.emplace_back(cbt::SetCell(checkInColumnFamily, ipv4Column, std::move(addressStr))); - // } - // else if (entry.address.ss_family == AF_INET6) { - // m.emplace_back(cbt::SetCell(checkInColumnFamily, ipv6Column, std::move(addressStr))); - // } - // int64_t ts = entry.last_seen; - // m.emplace_back(cbt::SetCell(checkInColumnFamily, lastSeenColumn, std::move(ts))); - // bulk.emplace_back(m); - - // // TODO: Check performance on this. May need to bach these. - // _pubsubWriter->publishStatusChange( - // entry.target, entry.network_id, entry.node_id, entry.os, entry.arch, entry.version, entry.last_seen); - // } - - // fprintf(stderr, "Applying %zu mutations to BigTable\n", bulk.size()); - - // try { - // std::vector failures = table.BulkApply(std::move(bulk)); - // fprintf(stderr, "BigTable write completed with %zu failures\n", failures.size()); - // for (auto const& r : failures) { - // // Handle error (log it, retry, etc.) - // std::cerr << "Error writing to BigTable: " << r.status() << "\n"; - // } - // } - // catch (const std::exception& e) { - // fprintf(stderr, "Exception writing to BigTable: %s\n", e.what()); - // span->SetAttribute("error", e.what()); - // span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - // return; - // } + catch (const std::exception& e) { + fprintf(stderr, "Exception writing to BigTable: %s\n", e.what()); + span->SetAttribute("error", e.what()); + span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + return; + } } } // namespace ZeroTier \ No newline at end of file From facca364fba65a6ff3cbe3dd3017b9c0f4a5634c Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 8 Sep 2025 11:00:17 -0700 Subject: [PATCH 116/245] only update os, architecture and client version if they've changed (or don't exist) --- nonfree/controller/BigTableStatusWriter.cpp | 32 +++++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/nonfree/controller/BigTableStatusWriter.cpp b/nonfree/controller/BigTableStatusWriter.cpp index 09447ed077..59c36eb65a 100644 --- a/nonfree/controller/BigTableStatusWriter.cpp +++ b/nonfree/controller/BigTableStatusWriter.cpp @@ -94,10 +94,36 @@ void BigTableStatusWriter::writePending() cbt::BulkMutation bulk; for (const auto& entry : toWrite) { std::string row_key = entry.network_id + "#" + entry.node_id; + + // read the latest values from BigTable for this row key + std::map latest_values; + try { + auto row = _table->ReadRow(row_key, cbt::Filter::Latest(1)); + if (row->first) { + for (const auto& cell : row->second.cells()) { + if (cell.family_name() == nodeInfoColumnFamily) { + latest_values[cell.column_qualifier()] = cell.value(); + } + } + } + } + catch (const std::exception& e) { + fprintf(stderr, "Exception reading from BigTable: %s\n", e.what()); + } + cbt::SingleRowMutation m(row_key); - m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, osColumn, entry.os)); - m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, archColumn, entry.arch)); - m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, versionColumn, entry.version)); + + // only update if value has changed + if (latest_values[osColumn] != entry.os) { + m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, osColumn, entry.os)); + } + if (latest_values[archColumn] != entry.arch) { + m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, archColumn, entry.arch)); + } + if (latest_values[versionColumn] != entry.version) { + m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, versionColumn, entry.version)); + } + char buf[64] = { 0 }; std::string addressStr = entry.address.toString(buf); if (entry.address.ss_family == AF_INET) { From ee87eb31018a145abd04e2884b7ab007a3ab9f41 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 8 Sep 2025 11:34:03 -0700 Subject: [PATCH 117/245] removing some log output --- nonfree/controller/CentralDB.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index c8037e033b..8944594b26 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1503,7 +1503,6 @@ void CentralDB::onlineNotificationThread() _statusWriter->updateNodeStatus( networkId, memberId, os, arch, version, i->second.physicalAddress, ts, frontend); - fprintf(stderr, "sent node status update\n"); } _statusWriter->writePending(); w.commit(); From 012443acfad140913658c32896120cae71833463 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 8 Sep 2025 16:01:50 -0700 Subject: [PATCH 118/245] wire up pubsub notifications from controller to frontend --- nonfree/controller/BigTableStatusWriter.cpp | 4 +- nonfree/controller/BigTableStatusWriter.hpp | 7 +- nonfree/controller/CMakeLists.txt | 2 + nonfree/controller/CentralDB.cpp | 260 ++++++++++++++++-- nonfree/controller/CentralDB.hpp | 7 + .../controller/ControllerChangeNotifier.cpp | 52 ++++ .../controller/ControllerChangeNotifier.hpp | 52 ++++ nonfree/controller/PubSubListener.cpp | 2 +- nonfree/controller/PubSubWriter.cpp | 179 +++++++++++- nonfree/controller/PubSubWriter.hpp | 8 +- nonfree/controller/protobuf/member.proto | 2 +- nonfree/controller/protobuf/network.proto | 4 +- 12 files changed, 524 insertions(+), 55 deletions(-) create mode 100644 nonfree/controller/ControllerChangeNotifier.cpp create mode 100644 nonfree/controller/ControllerChangeNotifier.hpp diff --git a/nonfree/controller/BigTableStatusWriter.cpp b/nonfree/controller/BigTableStatusWriter.cpp index 59c36eb65a..44180b65a3 100644 --- a/nonfree/controller/BigTableStatusWriter.cpp +++ b/nonfree/controller/BigTableStatusWriter.cpp @@ -25,12 +25,10 @@ const std::string lastSeenColumn = "last_seen"; BigTableStatusWriter::BigTableStatusWriter( const std::string& project_id, const std::string& instance_id, - const std::string& table_id, - std::shared_ptr pubsubWriter) + const std::string& table_id) : _project_id(project_id) , _instance_id(instance_id) , _table_id(table_id) - , _pubsubWriter(pubsubWriter) , _table(nullptr) { _table = new cbt::Table(cbt::MakeDataConnection(), cbt::TableResource(_project_id, _instance_id, _table_id)); diff --git a/nonfree/controller/BigTableStatusWriter.hpp b/nonfree/controller/BigTableStatusWriter.hpp index 750b46685c..ce687121f9 100644 --- a/nonfree/controller/BigTableStatusWriter.hpp +++ b/nonfree/controller/BigTableStatusWriter.hpp @@ -14,11 +14,7 @@ class PubSubWriter; class BigTableStatusWriter : public StatusWriter { public: - BigTableStatusWriter( - const std::string& project_id, - const std::string& instance_id, - const std::string& table_id, - std::shared_ptr pubsubWriter); + BigTableStatusWriter(const std::string& project_id, const std::string& instance_id, const std::string& table_id); virtual ~BigTableStatusWriter(); virtual void updateNodeStatus( @@ -40,7 +36,6 @@ class BigTableStatusWriter : public StatusWriter { mutable std::mutex _lock; std::vector _pending; - std::shared_ptr _pubsubWriter; google::cloud::bigtable::Table* _table; }; diff --git a/nonfree/controller/CMakeLists.txt b/nonfree/controller/CMakeLists.txt index 4593f5daf6..9a50709777 100644 --- a/nonfree/controller/CMakeLists.txt +++ b/nonfree/controller/CMakeLists.txt @@ -42,6 +42,8 @@ if (ZT1_CENTRAL_CONTROLLER) CentralDB.cpp CentralDB.hpp ControllerConfig.hpp + ControllerChangeNotifier.cpp + ControllerChangeNotifier.hpp NotificationListener.hpp PostgreSQL.cpp PostgreSQL.hpp diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 8944594b26..759c4d09ed 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -19,6 +19,7 @@ #include "../../node/SHA512.hpp" #include "../../version.h" #include "BigTableStatusWriter.hpp" +#include "ControllerChangeNotifier.hpp" #include "ControllerConfig.hpp" #include "CtlUtil.hpp" #include "EmbeddedNetworkController.hpp" @@ -168,6 +169,7 @@ CentralDB::CentralDB( std::make_shared(_myAddressStr, cc->pubSubConfig->project_id, this); _networksDbWatcher = std::make_shared(_myAddressStr, cc->pubSubConfig->project_id, this); + _changeNotifier = std::make_shared(_myAddressStr, cc->pubSubConfig->project_id); } else { throw std::runtime_error( @@ -209,12 +211,8 @@ CentralDB::CentralDB( "CentralDB: BigTable status mode selected but no PubSub configuration provided"); } - pubsubWriter = std::make_shared( - cc->pubSubConfig->project_id, "ctl-member-status-update-stream", _myAddressStr); - _statusWriter = std::make_shared( - cc->bigTableConfig->project_id, cc->bigTableConfig->instance_id, cc->bigTableConfig->table_id, - pubsubWriter); + cc->bigTableConfig->project_id, cc->bigTableConfig->instance_id, cc->bigTableConfig->table_id); break; case STATUS_WRITER_MODE_PGSQL: default: @@ -223,6 +221,7 @@ CentralDB::CentralDB( break; } + // start background threads for (int i = 0; i < ZT_CENTRAL_CONTROLLER_COMMIT_THREADS; ++i) { _commitThread[i] = std::thread(&CentralDB::commitThread, this); } @@ -935,7 +934,6 @@ void CentralDB::initializeMembers() config["ssoExempt"] = sso_exempt.value_or(false); config["authenticationExpiryTime"] = authentication_expiry_time.value_or(0); config["tags"] = json::parse(tags.value_or("[]")); - config["ipAssignments"] = json::array(); config["frontend"] = std::get<17>(row); Metrics::member_count++; @@ -1147,8 +1145,12 @@ void CentralDB::commitThread() target = config["remoteTraceTarget"]; } - pqxx::row nwrow = w.exec_params1("SELECT COUNT(id) FROM networks_ctl WHERE id = $1", networkId); + // get network and the frontend it is assigned to + // if network does not exist, skip member update + pqxx::row nwrow = w.exec_params1( + "SELECT COUNT(id), frontend FROM networks_ctl WHERE id = $1 GROUP BY frontend", networkId); int nwcount = nwrow[0].as(); + std::string frontend = nwrow[1].as(); if (nwcount != 1) { fprintf(stderr, "network %s does not exist. skipping member upsert\n", networkId.c_str()); @@ -1161,9 +1163,28 @@ void CentralDB::commitThread() "SELECT COUNT(device_id) FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", memberId, networkId); int membercount = mrow[0].as(); - bool isNewMember = (membercount == 0); + std::string change_source = config["change_source"]; + if (! isNewMember && change_source != "controller" && frontend != change_source) { + // if it is not a new member and the change source is not the controller and doesn't match the + // frontend, don't apply the change. + continue; + } + + if (_listenerMode == LISTENER_MODE_PUBSUB) { + // Publish change to pubsub stream + + if (config["change_source"].is_null() || config["change_source"] == "controller") { + nlohmann::json oldMember; + nlohmann::json newMember = config; + if (! isNewMember) { + oldMember = _getNetworkMember(w, networkId, memberId); + } + _changeNotifier->notifyMemberChange(oldMember, newMember, frontend); + } + } + pqxx::result res = w.exec_params0( "INSERT INTO network_memberships_ctl (device_id, network_id, authorized, active_bridge, " "ip_assignments, " @@ -1251,30 +1272,42 @@ void CentralDB::commitThread() std::string id = config["id"]; + pqxx::row nwrow = w.exec_params1( + "SELECT COUNT(id), frontend FROM networks_ctl WHERE id = $1 GROUP BY frontend", id); + int nwcount = nwrow[0].as(); + std::string frontend = nwrow[1].as(); + bool isNewNetwork = (nwcount == 0); + + std::string change_source = config["change_source"]; + if (! isNewNetwork && change_source != "controller" && frontend != change_source) { + // if it is not a new network and the change source is not the controller and doesn't match the + // frontend, don't apply the change. + continue; + } + + if (_listenerMode == LISTENER_MODE_PUBSUB) { + // Publish change to pubsub stream + if (config["change_source"].is_null() || config["change_source"] == "controller") { + nlohmann::json oldNetwork; + nlohmann::json newNetwork = config; + if (! isNewNetwork) { + oldNetwork = _getNetwork(w, id); + } + _changeNotifier->notifyNetworkChange(oldNetwork, newNetwork, frontend); + } + } + pqxx::result res = w.exec_params0( - "INSERT INTO networks_ctl (id, name, configuration, controller_id, revision) " - "VALUES ($1, $2, $3, $4, $5) " + "INSERT INTO networks_ctl (id, name, configuration, controller_id, revision, frontend) " + "VALUES ($1, $2, $3, $4, $5, $6) " "ON CONFLICT (id) DO UPDATE SET " - "name = EXCLUDED.name, configuration = EXCLUDED.configuration, revision = EXCLUDED.revision+1", + "name = EXCLUDED.name, configuration = EXCLUDED.configuration, revision = EXCLUDED.revision+1, " + "frontend = EXCLUDED.frontend", id, OSUtils::jsonString(config["name"], ""), OSUtils::jsonDump(config, -1), _myAddressStr, - ((uint64_t)config["revision"])); + ((uint64_t)config["revision"]), change_source); w.commit(); - // res = w.exec_params0("DELETE FROM ztc_network_assignment_pool WHERE network_id = $1", 0); - - // auto pool = config["ipAssignmentPools"]; - // bool err = false; - // for (auto i = pool.begin(); i != pool.end(); ++i) { - // std::string start = (*i)["ipRangeStart"]; - // std::string end = (*i)["ipRangeEnd"]; - - // res = w.exec_params0( - // "INSERT INTO ztc_network_assignment_pool (network_id, ip_range_start, ip_range_end) " - // "VALUES ($1, $2, $3)", - // id, start, end); - // } - const uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); if (nwidInt) { nlohmann::json nwOrig; @@ -1516,4 +1549,179 @@ void CentralDB::onlineNotificationThread() } } +nlohmann::json CentralDB::_getNetworkMember(pqxx::work& tx, const std::string networkID, const std::string memberID) +{ + nlohmann::json out; + + try { + pqxx::row row = tx.exec_params1( + "SELECT nm.device_id, nm.network_id, nm.authorized, nm.active_bridge, nm.ip_assignments, " + "nm.no_auto_assign_ips, " + "nm.sso_exempt, (EXTRACT(EPOCH FROM nm.authentication_expiry_time AT TIME ZONE 'UTC')*1000)::bigint, " + "(EXTRACT(EPOCH FROM nm.creation_time AT TIME ZONE 'UTC')*1000)::bigint, nm.identity, " + "(EXTRACT(EPOCH FROM nm.last_authorized_time AT TIME ZONE 'UTC')*1000)::bigint, " + "(EXTRACT(EPOCH FROM nm.last_deauthorized_time AT TIME ZONE 'UTC')*1000)::bigint, " + "nm.remote_trace_level, nm.remote_trace_target, nm.revision, nm.capabilities, nm.tags, " + "nm.frontend " + "FROM network_memberships_ctl nm " + "INNER JOIN networks_ctl n " + " ON nm.network_id = n.id " + "WHERE nm.network_id = $1 AND nm.device_id = $2", + networkID, memberID); + + bool authorized = row[2].as(); + std::optional active_bridge = + row[3].is_null() ? std::optional() : std::optional(row[3].as()); + std::string ip_assignments = row[4].is_null() ? "{}" : row[4].as(); + std::optional no_auto_assign_ips = + row[5].is_null() ? std::optional() : std::optional(row[5].as()); + std::optional sso_exempt = + row[6].is_null() ? std::optional() : std::optional(row[6].as()); + std::optional authentication_expiry_time = + row[7].is_null() ? std::optional() : std::optional(row[7].as()); + std::optional creation_time = + row[8].is_null() ? std::optional() : std::optional(row[8].as()); + std::optional identity = + row[9].is_null() ? std::optional() : std::optional(row[9].as()); + std::optional last_authorized_time = + row[10].is_null() ? std::optional() : std::optional(row[10].as()); + std::optional last_deauthorized_time = + row[11].is_null() ? std::optional() : std::optional(row[11].as()); + std::optional remote_trace_level = + row[12].is_null() ? std::optional() : std::optional(row[12].as()); + std::optional remote_trace_target = + row[13].is_null() ? std::optional() : std::optional(row[13].as()); + std::optional revision = + row[14].is_null() ? std::optional() : std::optional(row[14].as()); + std::optional capabilities = + row[15].is_null() ? std::optional() : std::optional(row[15].as()); + std::optional tags = + row[16].is_null() ? std::optional() : std::optional(row[16].as()); + std::string frontend = row[17].is_null() ? "" : row[17].as(); + + out["objtype"] = "member"; + out["id"] = memberID; + out["nwid"] = networkID; + out["address"] = identity.value_or(""); + out["authorized"] = authorized; + out["activeBridge"] = active_bridge.value_or(false); + out["ipAssignments"] = json::array(); + if (ip_assignments != "{}" && ip_assignments != "[]") { + std::string tmp = ip_assignments.substr(1, ip_assignments.length() - 2); + std::vector addrs = split(tmp, ','); + for (auto it = addrs.begin(); it != addrs.end(); ++it) { + out["ipAssignments"].push_back(*it); + } + } + out["capabilities"] = json::parse(capabilities.value_or("[]")); + out["creationTime"] = creation_time.value_or(0); + out["lastAuthorizedTime"] = last_authorized_time.value_or(0); + out["lastDeauthorizedTime"] = last_deauthorized_time.value_or(0); + out["noAutoAssignIps"] = no_auto_assign_ips.value_or(false); + out["remoteTraceLevel"] = remote_trace_level.value_or(0); + out["remoteTraceTarget"] = remote_trace_target.value_or(nullptr); + out["revision"] = revision.value_or(0); + out["ssoExempt"] = sso_exempt.value_or(false); + out["authenticationExpiryTime"] = authentication_expiry_time.value_or(0); + out["tags"] = json::parse(tags.value_or("[]")); + out["frontend"] = frontend; + } + catch (std::exception& e) { + fprintf( + stderr, "ERROR: Error getting network member %s-%s: %s\n", networkID.c_str(), memberID.c_str(), e.what()); + return nlohmann::json(); + } + + return out; +} + +nlohmann::json CentralDB::_getNetwork(pqxx::work& tx, const std::string networkID) +{ + nlohmann::json out; + + try { + std::optional name; + std::string cfg; + std::optional creation_time; + std::optional last_modified; + std::optional revision; + std::string frontend; + + pqxx::row row = tx.exec_params1( + "SELECT id, name, configuration , (EXTRACT(EPOCH FROM creation_time AT TIME ZONE 'UTC')*1000)::bigint, " + "(EXTRACT(EPOCH FROM last_modified AT TIME ZONE 'UTC')*1000)::bigint, revision, frontend " + "FROM networks_ctl WHERE id = $1", + networkID); + + cfg = row[2].as(); + creation_time = row[3].is_null() ? std::optional() : std::optional(row[3].as()); + last_modified = row[4].is_null() ? std::optional() : std::optional(row[4].as()); + revision = row[5].is_null() ? std::optional() : std::optional(row[5].as()); + frontend = row[6].is_null() ? "" : row[6].as(); + + nlohmann::json cfgtmp = nlohmann::json::parse(cfg); + if (! cfgtmp.is_object()) { + fprintf(stderr, "ERROR: Network %s configuration is not a JSON object\n", networkID.c_str()); + return nlohmann::json(); + } + + out["objtype"] = "network"; + out["id"] = row[0].as(); + out["name"] = row[1].is_null() ? "" : row[1].as(); + out["creationTime"] = creation_time.value_or(0); + out["lastModified"] = last_modified.value_or(0); + out["revision"] = revision.value_or(0); + out["capabilities"] = cfgtmp["capabilities"].is_array() ? cfgtmp["capabilities"] : json::array(); + out["enableBroadcast"] = cfgtmp["enableBroadcast"].is_boolean() ? cfgtmp["enableBroadcast"].get() : false; + out["mtu"] = cfgtmp["mtu"].is_number() ? cfgtmp["mtu"].get() : 2800; + out["multicastLimit"] = cfgtmp["multicastLimit"].is_number() ? cfgtmp["multicastLimit"].get() : 64; + out["private"] = cfgtmp["private"].is_boolean() ? cfgtmp["private"].get() : true; + out["remoteTraceLevel"] = + cfgtmp["remoteTraceLevel"].is_number() ? cfgtmp["remoteTraceLevel"].get() : 0; + out["remoteTraceTarget"] = + cfgtmp["remoteTraceTarget"].is_string() ? cfgtmp["remoteTraceTarget"].get() : ""; + out["revision"] = revision.value_or(0); + out["rules"] = cfgtmp["rules"].is_array() ? cfgtmp["rules"] : json::array(); + out["tags"] = cfgtmp["tags"].is_array() ? cfgtmp["tags"] : json::array(); + if (cfgtmp["v4AssignMode"].is_object()) { + out["v4AssignMode"] = cfgtmp["v4AssignMode"]; + } + else { + out["v4AssignMode"] = json::object(); + out["v4AssignMode"]["zt"] = true; + } + if (cfgtmp["v6AssignMode"].is_object()) { + out["v6AssignMode"] = cfgtmp["v6AssignMode"]; + } + else { + out["v6AssignMode"] = json::object(); + out["v6AssignMode"]["zt"] = true; + out["v6AssignMode"]["6plane"] = true; + out["v6AssignMode"]["rfc4193"] = false; + } + out["ssoEnabled"] = cfgtmp["ssoEnabled"].is_boolean() ? cfgtmp["ssoEnabled"].get() : false; + out["objtype"] = "network"; + out["routes"] = cfgtmp["routes"].is_array() ? cfgtmp["routes"] : json::array(); + out["clientId"] = cfgtmp["clientId"].is_string() ? cfgtmp["clientId"].get() : ""; + out["authorizationEndpoint"] = + cfgtmp["authorizationEndpoint"].is_string() ? cfgtmp["authorizationEndpoint"].get() : nullptr; + out["provider"] = cfgtmp["ssoProvider"].is_string() ? cfgtmp["ssoProvider"].get() : ""; + if (! cfgtmp["dns"].is_object()) { + cfgtmp["dns"] = json::object(); + cfgtmp["dns"]["domain"] = ""; + cfgtmp["dns"]["servers"] = json::array(); + } + else { + out["dns"] = cfgtmp["dns"]; + } + out["ipAssignmentPools"] = cfgtmp["ipAssignmentPools"].is_array() ? cfgtmp["ipAssignmentPools"] : json::array(); + out["frontend"] = row[6].as(); + } + catch (std::exception& e) { + fprintf(stderr, "ERROR: Error getting network %s: %s\n", networkID.c_str(), e.what()); + return nlohmann::json(); + } + return out; +} + #endif // ZT_CONTROLLER_USE_LIBPQ diff --git a/nonfree/controller/CentralDB.hpp b/nonfree/controller/CentralDB.hpp index 0ffd1e562b..932bd001fc 100644 --- a/nonfree/controller/CentralDB.hpp +++ b/nonfree/controller/CentralDB.hpp @@ -23,6 +23,7 @@ struct SmeeClient; namespace ZeroTier { struct RedisConfig; struct ControllerConfig; +struct ControllerChangeNotifier; class CentralDB : public DB { public: @@ -94,6 +95,11 @@ class CentralDB : public DB { void configureSmee(); void notifyNewMember(const std::string& networkID, const std::string& memberID); + nlohmann::json _getNetworkMember(pqxx::work& tx, const std::string networkID, const std::string memberID); + + nlohmann::json _getNetwork(pqxx::work& tx, const std::string networkID); + + private: enum OverrideMode { ALLOW_PGBOUNCER_OVERRIDE = 0, NO_OVERRIDE = 1 }; ListenerMode _listenerMode; @@ -112,6 +118,7 @@ class CentralDB : public DB { std::shared_ptr _membersDbWatcher; std::shared_ptr _networksDbWatcher; std::shared_ptr _statusWriter; + std::shared_ptr _changeNotifier; std::thread _commitThread[ZT_CENTRAL_CONTROLLER_COMMIT_THREADS]; std::thread _onlineNotificationThread; diff --git a/nonfree/controller/ControllerChangeNotifier.cpp b/nonfree/controller/ControllerChangeNotifier.cpp new file mode 100644 index 0000000000..74d52754fb --- /dev/null +++ b/nonfree/controller/ControllerChangeNotifier.cpp @@ -0,0 +1,52 @@ +#include "ControllerChangeNotifier.hpp" + +#include "PubSubWriter.hpp" + +namespace ZeroTier { + +PubSubChangeNotifier::PubSubChangeNotifier(std::string controllerID, std::string project) + : ControllerChangeNotifier() + , _cv1networkChangeWriter(std::make_shared(project, "ctl-to-cv1-network-change-stream", controllerID)) + , _cv1memberChangeWriter(std::make_shared(project, "ctl-to-cv1-member-change-stream", controllerID)) + , _cv2networkChangeWriter(std::make_shared(project, "ctl-to-cv2-network-change-stream", controllerID)) + , _cv2memberChangeWriter(std::make_shared(project, "ctl-to-cv2-member-change-stream", controllerID)) +{ +} + +PubSubChangeNotifier::~PubSubChangeNotifier() +{ +} + +void PubSubChangeNotifier::notifyNetworkChange( + const nlohmann::json& oldNetwork, + const nlohmann::json& newNetwork, + const std::string& frontend) +{ + if (frontend == "cv1") { + _cv1networkChangeWriter->publishNetworkChange(oldNetwork, newNetwork); + } + else if (frontend == "cv2") { + _cv2networkChangeWriter->publishNetworkChange(oldNetwork, newNetwork); + } + else { + throw std::runtime_error("Unknown frontend: " + frontend); + } +} + +void PubSubChangeNotifier::notifyMemberChange( + const nlohmann::json& oldMember, + const nlohmann::json newMember, + const std::string& frontend) +{ + if (frontend == "cv1") { + _cv1memberChangeWriter->publishMemberChange(oldMember, newMember); + } + else if (frontend == "cv2") { + _cv2memberChangeWriter->publishMemberChange(oldMember, newMember); + } + else { + throw std::runtime_error("Unknown frontend: " + frontend); + } +} + +} // namespace ZeroTier \ No newline at end of file diff --git a/nonfree/controller/ControllerChangeNotifier.hpp b/nonfree/controller/ControllerChangeNotifier.hpp new file mode 100644 index 0000000000..ba8b210e3e --- /dev/null +++ b/nonfree/controller/ControllerChangeNotifier.hpp @@ -0,0 +1,52 @@ +#ifndef CONTROLLERCHANGENOTIFIER_HPP +#define CONTROLLERCHANGENOTIFIER_HPP + +#include +#include +#include + +namespace ZeroTier { + +class PubSubWriter; + +class ControllerChangeNotifier { + public: + virtual ~ControllerChangeNotifier() = default; + + virtual void notifyNetworkChange( + const nlohmann::json& oldNetwork, + const nlohmann::json& newNetwork, + const std::string& frontend = "") = 0; + + virtual void notifyMemberChange( + const nlohmann::json& oldMember, + const nlohmann::json newMember, + const std::string& frontend = "") = 0; +}; + +class PubSubChangeNotifier : public ControllerChangeNotifier { + public: + PubSubChangeNotifier(std::string controllerID, std::string project); + virtual ~PubSubChangeNotifier(); + + virtual void notifyNetworkChange( + const nlohmann::json& oldNetwork, + const nlohmann::json& newNetwork, + const std::string& frontend = "") override; + + virtual void notifyMemberChange( + const nlohmann::json& oldMember, + const nlohmann::json newMember, + const std::string& frontend = "") override; + + private: + std::shared_ptr _cv1networkChangeWriter; + std::shared_ptr _cv1memberChangeWriter; + + std::shared_ptr _cv2networkChangeWriter; + std::shared_ptr _cv2memberChangeWriter; +}; + +} // namespace ZeroTier + +#endif // CONTROLLERCHANGENOTIFIER_HPP \ No newline at end of file diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 31f3eeff13..c4e7fb58dc 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -420,7 +420,7 @@ nlohmann::json toJson(const pbmessages::MemberChange_Member& mc, pbmessages::Mem } out["noAutoAssignIps"] = mc.no_auto_assign_ips(); - out["ssoExempt"] = mc.sso_exepmt(); + out["ssoExempt"] = mc.sso_exempt(); out["authenticationExpiryTime"] = mc.auth_expiry_time(); out["capabilities"] = OSUtils::jsonParse(mc.capabilities()); out["creationTime"] = mc.creation_time(); diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index 2fe3f52d5d..c1bd7d5685 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -1,5 +1,6 @@ #include "PubSubWriter.hpp" +#include "../../osdep/OSUtils.hpp" #include "CtlUtil.hpp" #include "member.pb.h" #include "member_status.pb.h" @@ -15,6 +16,12 @@ namespace pubsub = ::google::cloud::pubsub; namespace ZeroTier { + +pbmessages::NetworkChange +networkChangeFromJson(std::string controllerID, const nlohmann::json& oldNetwork, const nlohmann::json& newNetwork); +pbmessages::MemberChange +memberChangeFromJson(std::string controllerID, const nlohmann::json& oldMember, const nlohmann::json& newMember); + PubSubWriter::PubSubWriter(std::string project, std::string topic, std::string controller_id) : _controller_id(controller_id) , _project(project) @@ -44,12 +51,9 @@ PubSubWriter::~PubSubWriter() { } -bool PubSubWriter::publishMessage(const std::string& payload, const std::string& frontend) +bool PubSubWriter::publishMessage(const std::string& payload) { std::vector > attributes; - if (! frontend.empty()) { - attributes.emplace_back("frontend", frontend); - } attributes.emplace_back("controller_id", _controller_id); auto msg = pubsub::MessageBuilder {}.SetData(payload).SetAttributes(attributes).Build(); @@ -63,30 +67,28 @@ bool PubSubWriter::publishMessage(const std::string& payload, const std::string& return true; } -bool PubSubWriter::publishNetworkChange(const nlohmann::json& networkJson, const std::string& frontend) +bool PubSubWriter::publishNetworkChange(const nlohmann::json& oldNetwork, const nlohmann::json& newNetwork) { - pbmessages::NetworkChange nc; - // nc.mutable_new_()->CopyFrom(fromJson(networkJson)); + pbmessages::NetworkChange nc = networkChangeFromJson(_controller_id, oldNetwork, newNetwork); std::string payload; if (! nc.SerializeToString(&payload)) { fprintf(stderr, "Failed to serialize NetworkChange protobuf message\n"); return false; } - return publishMessage(payload, frontend); + return publishMessage(payload); } -bool PubSubWriter::publishMemberChange(const nlohmann::json& memberJson, const std::string& frontend) +bool PubSubWriter::publishMemberChange(const nlohmann::json& oldMember, const nlohmann::json& newMember) { - pbmessages::MemberChange mc; - // mc.mutable_new_()->CopyFrom(fromJson(memberJson)); + pbmessages::MemberChange mc = memberChangeFromJson(_controller_id, oldMember, newMember); std::string payload; if (! mc.SerializeToString(&payload)) { fprintf(stderr, "Failed to serialize MemberChange protobuf message\n"); return false; } - return publishMessage(payload, frontend); + return publishMessage(payload); } bool PubSubWriter::publishStatusChange( @@ -122,7 +124,158 @@ bool PubSubWriter::publishStatusChange( return false; } - return publishMessage(payload, frontend); + return publishMessage(payload); +} + +pbmessages::NetworkChange_Network* networkFromJson(const nlohmann::json& j) +{ + if (! j.is_object()) { + return nullptr; + } + + pbmessages::NetworkChange_Network* n = new pbmessages::NetworkChange_Network(); + n->set_network_id(j.value("id", "")); + n->set_name(j.value("name", "")); + n->set_capabilities(OSUtils::jsonDump(j.value("capabilities", "[]"), -1)); + n->set_creation_time(j.value("creationTime", 0)); + n->set_enable_broadcast(j.value("enableBroadcast", false)); + + for (const auto& p : j["ipAssignmentPools"]) { + if (p.is_object()) { + auto pool = n->add_assignment_pools(); + pool->set_start_ip(p.value("ipRangeStart", "")); + pool->set_end_ip(p.value("ipRangeEnd", "")); + } + } + + n->set_mtu(j.value("mtu", 2800)); + n->set_multicast_limit(j.value("multicastLimit", 32)); + n->set_is_private(j.value("private", true)); + n->set_remote_trace_level(j.value("remoteTraceLevel", 0)); + n->set_remote_trace_target(j.value("remoteTraceTarget", "")); + n->set_revision(j.value("revision", 0)); + + for (const auto& p : j["routes"]) { + if (p.is_object()) { + auto r = n->add_routes(); + r->set_target(p.value("target", "")); + r->set_via(p.value("via", "")); + } + } + + n->set_rules(""); + n->set_tags(OSUtils::jsonDump(j.value("tags", "[]"), -1)); + + pbmessages::NetworkChange_IPV4AssignMode* v4am = new pbmessages::NetworkChange_IPV4AssignMode(); + if (j["v4AssignMode"].is_object()) { + v4am->set_zt(j["v4AssignMode"].value("zt", false)); + } + n->set_allocated_ipv4_assign_mode(v4am); + + pbmessages::NetworkChange_IPV6AssignMode* v6am = new pbmessages::NetworkChange_IPV6AssignMode(); + if (j["v6AssignMode"].is_object()) { + v6am->set_zt(j["v6AssignMode"].value("zt", false)); + v6am->set_six_plane(j["v6AssignMode"].value("6plane", false)); + v6am->set_rfc4193(j["v6AssignMode"].value("rfc4193", false)); + } + n->set_allocated_ipv6_assign_mode(v6am); + + nlohmann::json jdns = j.value("dns", nullptr); + if (jdns.is_object()) { + pbmessages::NetworkChange_DNS* dns = new pbmessages::NetworkChange_DNS(); + dns->set_domain(jdns.value("domain", "")); + for (const auto& s : jdns["servers"]) { + if (s.is_string()) { + auto server = dns->add_nameservers(); + *server = s; + } + } + n->set_allocated_dns(dns); + } + + n->set_sso_enabled(j.value("ssoEnabled", false)); + if (j.value("ssoEnabled", false)) { + n->set_sso_provider(j.value("provider", "")); + n->set_sso_client_id(j.value("clientId", "")); + n->set_sso_authorization_endpoint(j.value("authorizationEndpoint", "")); + n->set_sso_issuer(j.value("issuer", "")); + n->set_sso_provider(j.value("provider", "")); + } + + n->set_rules_source(""); + + return n; +} + +pbmessages::NetworkChange +networkChangeFromJson(std::string controllerID, const nlohmann::json& oldNetwork, const nlohmann::json& newNetwork) +{ + pbmessages::NetworkChange nc; + nc.set_allocated_old(networkFromJson(oldNetwork)); + nc.set_allocated_new_(networkFromJson(newNetwork)); + nc.set_change_source(pbmessages::NetworkChange_ChangeSource::NetworkChange_ChangeSource_CONTROLLER); + + pbmessages::NetworkChange_NetworkChangeMetadata* metadata = new pbmessages::NetworkChange_NetworkChangeMetadata(); + metadata->set_controller_id(controllerID); + metadata->set_trace_id(""); // TODO: generate a trace ID + nc.set_allocated_metadata(metadata); + + return nc; +} + +pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) +{ + if (! j.is_object()) { + return nullptr; + } + + pbmessages::MemberChange_Member* m = new pbmessages::MemberChange_Member(); + m->set_network_id(j.value("networkId", "")); + m->set_device_id(j.value("id", "")); + m->set_identity(j.value("identity", "")); + m->set_authorized(j.value("authorized", false)); + for (const auto& addr : j.value("ipAssignments", nlohmann::json::array())) { + if (addr.is_string()) { + auto a = m->add_ip_assignments(); + *a = addr; + } + } + m->set_active_bridge(j.value("activeBridge", false)); + m->set_tags(OSUtils::jsonDump(j.value("tags", "[]"), -1)); + m->set_capabilities(OSUtils::jsonDump(j.value("capabilities", "[]"), -1)); + m->set_creation_time(j.value("creationTime", 0)); + m->set_no_auto_assign_ips(j.value("noAutoAssignIps", false)); + m->set_revision(j.value("revision", 0)); + m->set_last_authorized_time(j.value("lastAuthorizedTime", 0)); + m->set_last_deauthorized_time(j.value("lastDeauthorizedTime", 0)); + m->set_last_authorized_credential_type(j.value("lastAuthorizedCredentialType", nullptr)); + m->set_last_authorized_credential(j.value("lastAuthorizedCredential", nullptr)); + m->set_version_major(j.value("versionMajor", 0)); + m->set_version_minor(j.value("versionMinor", 0)); + m->set_version_rev(j.value("versionRev", 0)); + m->set_version_protocol(j.value("versionProtocol", 0)); + m->set_remote_trace_level(j.value("remoteTraceLevel", 0)); + m->set_remote_trace_target(j.value("remoteTraceTarget", "")); + m->set_sso_exempt(j.value("ssoExempt", false)); + m->set_auth_expiry_time(j.value("authExpiryTime", 0)); + + return m; +} + +pbmessages::MemberChange +memberChangeFromJson(std::string controllerID, const nlohmann::json& oldMember, const nlohmann::json& newMember) +{ + pbmessages::MemberChange mc; + mc.set_allocated_old(memberFromJson(oldMember)); + mc.set_allocated_new_(memberFromJson(newMember)); + mc.set_change_source(pbmessages::MemberChange_ChangeSource::MemberChange_ChangeSource_CONTROLLER); + + pbmessages::MemberChange_MemberChangeMetadata* metadata = new pbmessages::MemberChange_MemberChangeMetadata(); + metadata->set_controller_id(controllerID); + metadata->set_trace_id(""); // TODO: generate a trace ID + mc.set_allocated_metadata(metadata); + + return mc; } } // namespace ZeroTier \ No newline at end of file diff --git a/nonfree/controller/PubSubWriter.hpp b/nonfree/controller/PubSubWriter.hpp index 170403d39a..26a7bc9eec 100644 --- a/nonfree/controller/PubSubWriter.hpp +++ b/nonfree/controller/PubSubWriter.hpp @@ -13,8 +13,10 @@ class PubSubWriter { PubSubWriter(std::string project, std::string topic, std::string controller_id); virtual ~PubSubWriter(); - bool publishNetworkChange(const nlohmann::json& networkJson, const std::string& frontend = ""); - bool publishMemberChange(const nlohmann::json& memberJson, const std::string& frontend = ""); + bool publishNetworkChange(const nlohmann::json& oldNetwork, const nlohmann::json& newNetwork); + + bool publishMemberChange(const nlohmann::json& oldMember, const nlohmann::json& newMember); + bool publishStatusChange( std::string frontend, std::string network_id, @@ -25,7 +27,7 @@ class PubSubWriter { int64_t last_seen); protected: - bool publishMessage(const std::string& payload, const std::string& frontend = ""); + bool publishMessage(const std::string& payload); private: std::string _controller_id; diff --git a/nonfree/controller/protobuf/member.proto b/nonfree/controller/protobuf/member.proto index a10e2839b0..04a1add556 100644 --- a/nonfree/controller/protobuf/member.proto +++ b/nonfree/controller/protobuf/member.proto @@ -25,7 +25,7 @@ message MemberChange { int32 version_protocol = 19; // Protocol version of the member int32 remote_trace_level = 20; // Remote trace level optional string remote_trace_target = 21; // Remote trace target - bool sso_exepmt = 22; // Whether SSO is exempt + bool sso_exempt = 22; // Whether SSO is exempt uint64 auth_expiry_time = 23; // Authorization expiry time in milliseconds } message MemberChangeMetadata { diff --git a/nonfree/controller/protobuf/network.proto b/nonfree/controller/protobuf/network.proto index 1fe359dfe1..41bbb73e87 100644 --- a/nonfree/controller/protobuf/network.proto +++ b/nonfree/controller/protobuf/network.proto @@ -27,7 +27,7 @@ message NetworkChange { bool zt = 1; // Whether ZeroTier is used for IPv4 assignment } - message IPv6AssignMode { + message IPV6AssignMode { bool six_plane = 1; // Whether 6plane is used for IPv6 assignment bool rfc4193 = 2; // Whether RFC 4193 is used for IPv6 assignment bool zt = 3; // Whether ZeroTier is used for IPv6 assignment @@ -50,7 +50,7 @@ message NetworkChange { string rules = 14; // JSON string of rules optional string tags = 15; // JSON string of tags IPV4AssignMode ipv4_assign_mode = 16; // IPv4 assignment mode - IPv6AssignMode ipv6_assign_mode = 17; // IPv6 assignment mode + IPV6AssignMode ipv6_assign_mode = 17; // IPv6 assignment mode optional DNS dns = 18; // DNS configuration bool sso_enabled = 19; // Whether Single Sign-On is enabled optional string sso_client_id = 20; // SSO client ID From 7aa451bec1d3713610ae41564378014695f99b1f Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 10 Sep 2025 07:43:21 -0700 Subject: [PATCH 119/245] clean up deprecation warnings in pqxx --- nonfree/controller/CentralDB.cpp | 220 ++++++++++++++++++------------- 1 file changed, 131 insertions(+), 89 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 759c4d09ed..1b320306d7 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -475,26 +475,28 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri std::string nonce = ""; // check if the member exists first. - pqxx::row count = w.exec_params1( - "SELECT count(id) FROM ztc_member WHERE id = $1 AND network_id = $2 AND deleted = false", memberId, - networkId); + pqxx::row count = + w.exec( + "SELECT count(id) FROM ztc_member WHERE id = $1 AND network_id = $2 AND deleted = false", + pqxx::params { memberId, networkId }) + .one_row(); if (count[0].as() == 1) { // get active nonce, if exists. - pqxx::result r = w.exec_params( + pqxx::result r = w.exec( "SELECT nonce FROM ztc_sso_expiry " "WHERE network_id = $1 AND member_id = $2 " "AND ((NOW() AT TIME ZONE 'UTC') <= authentication_expiry_time) AND ((NOW() AT TIME ZONE 'UTC') <= " "nonce_expiration)", - networkId, memberId); + pqxx::params { networkId, memberId }); if (r.size() == 0) { // no active nonce. // find an unused nonce, if one exists. - pqxx::result r = w.exec_params( + pqxx::result r = w.exec( "SELECT nonce FROM ztc_sso_expiry " "WHERE network_id = $1 AND member_id = $2 " "AND authentication_expiry_time IS NULL AND ((NOW() AT TIME ZONE 'UTC') <= nonce_expiration)", - networkId, memberId); + pqxx::params { networkId, memberId }); if (r.size() == 1) { // we have an existing nonce. Use it @@ -508,11 +510,11 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri Utils::hex(nonceBytes, sizeof(nonceBytes), nonceBuf); nonce = std::string(nonceBuf); - pqxx::result ir = w.exec_params0( + pqxx::result ir = w.exec( "INSERT INTO ztc_sso_expiry " "(nonce, nonce_expiration, network_id, member_id) VALUES " "($1, TO_TIMESTAMP($2::double precision/1000), $3, $4)", - nonce, OSUtils::now() + 300000, networkId, memberId); + pqxx::params { nonce, OSUtils::now() + 300000, networkId, memberId }); w.commit(); } @@ -532,7 +534,7 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri exit(7); } - r = w.exec_params( + r = w.exec( "SELECT oc.client_id, oc.authorization_endpoint, oc.issuer, oc.provider, oc.sso_impl_version " "FROM ztc_network AS n " "INNER JOIN ztc_org o " @@ -542,7 +544,7 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri "LEFT OUTER JOIN ztc_oidc_config oc " " ON noc.client_id = oc.client_id AND oc.org_id = o.org_id " "WHERE n.id = $1 AND n.sso_enabled = true", - networkId); + pqxx::params { networkId }); std::string client_id = ""; std::string authorization_endpoint = ""; @@ -1055,13 +1057,14 @@ void CentralDB::heartbeat() try { pqxx::work w { *c->c }; - w.exec_params0( - "INSERT INTO controllers_ctl (id, hostname, last_heartbeat, public_identity, version) VALUES " - "($1, $2, TO_TIMESTAMP($3::double precision/1000), $4, $5) " - "ON CONFLICT (id) DO UPDATE SET hostname = EXCLUDED.hostname, last_heartbeat = " - "EXCLUDED.last_heartbeat, " - "public_identity = EXCLUDED.public_identity, version = EXCLUDED.version", - controllerId, hostname, ts, publicIdentity, versionStr); + w.exec( + "INSERT INTO controllers_ctl (id, hostname, last_heartbeat, public_identity, version) VALUES " + "($1, $2, TO_TIMESTAMP($3::double precision/1000), $4, $5) " + "ON CONFLICT (id) DO UPDATE SET hostname = EXCLUDED.hostname, last_heartbeat = " + "EXCLUDED.last_heartbeat, " + "public_identity = EXCLUDED.public_identity, version = EXCLUDED.version", + pqxx::params { controllerId, hostname, ts, publicIdentity, versionStr }) + .no_rows(); w.commit(); } catch (std::exception& e) { @@ -1147,8 +1150,11 @@ void CentralDB::commitThread() // get network and the frontend it is assigned to // if network does not exist, skip member update - pqxx::row nwrow = w.exec_params1( - "SELECT COUNT(id), frontend FROM networks_ctl WHERE id = $1 GROUP BY frontend", networkId); + pqxx::row nwrow = + w.exec( + "SELECT COUNT(id), frontend FROM networks_ctl WHERE id = $1 GROUP BY frontend", + pqxx::params { networkId }) + .one_row(); int nwcount = nwrow[0].as(); std::string frontend = nwrow[1].as(); @@ -1159,13 +1165,18 @@ void CentralDB::commitThread() continue; } - pqxx::row mrow = w.exec_params1( - "SELECT COUNT(device_id) FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", - memberId, networkId); + pqxx::row mrow = w.exec( + "SELECT COUNT(device_id) FROM network_memberships_ctl WHERE device_id = $1 " + "AND network_id = $2", + pqxx::params { memberId, networkId }) + .one_row(); int membercount = mrow[0].as(); bool isNewMember = (membercount == 0); - std::string change_source = config["change_source"]; + std::string change_source; + if (! config["change_source"].is_null()) { + change_source = config["change_source"]; + } if (! isNewMember && change_source != "controller" && frontend != change_source) { // if it is not a new member and the change source is not the controller and doesn't match the // frontend, don't apply the change. @@ -1185,37 +1196,54 @@ void CentralDB::commitThread() } } - pqxx::result res = w.exec_params0( - "INSERT INTO network_memberships_ctl (device_id, network_id, authorized, active_bridge, " - "ip_assignments, " - "no_auto_assign_ips, sso_exempt, authentication_expiry_time, capabilities, creation_time, " - "identity, last_authorized_time, last_deauthorized_time, " - "remote_trace_level, remote_trace_target, revision, tags, version_major, version_minor, " - "version_revision, version_protocol) " - "VALUES ($1, $2, $3, $4, $5, $6, $7, TO_TIMESTAMP($8::double precision/1000), $9, " - "TO_TIMESTAMP($10::double precision/1000), $11, TO_TIMESTAMP($12::double precision/1000), " - "TO_TIMESTAMP($13::double precision/1000), $14, $15, $16, $17, $18, $19, $20, $21) " - "ON CONFLICT (device_id, network_id) DO UPDATE SET " - "authorized = EXCLUDED.authorized, active_bridge = EXCLUDED.active_bridge, " - "ip_assignments = EXCLUDED.ip_assignments, no_auto_assign_ips = EXCLUDED.no_auto_assign_ips, " - "sso_exempt = EXCLUDED.sso_exempt, authentication_expiry_time = " - "EXCLUDED.authentication_expiry_time, " - "capabilities = EXCLUDED.capabilities, creation_time = EXCLUDED.creation_time, " - "identity = EXCLUDED.identity, last_authorized_time = EXCLUDED.last_authorized_time, " - "last_deauthorized_time = EXCLUDED.last_deauthorized_time, " - "remote_trace_level = EXCLUDED.remote_trace_level, remote_trace_target = " - "EXCLUDED.remote_trace_target, " - "revision = EXCLUDED.revision, tags = EXCLUDED.tags, version_major = EXCLUDED.version_major, " - "version_minor = EXCLUDED.version_minor, version_revision = EXCLUDED.version_revision, " - "version_protocol = EXCLUDED.version_protocol", - memberId, networkId, (bool)config["authorized"], (bool)config["activeBridge"], - config["ipAssignments"].get >(), (bool)config["noAutoAssignIps"], - (bool)config["ssoExempt"], (uint64_t)config["authenticationExpiryTime"], - OSUtils::jsonDump(config["capabilities"], -1), (uint64_t)config["creationTime"], - OSUtils::jsonString(config["identity"], ""), (uint64_t)config["lastAuthorizedTime"], - (uint64_t)config["lastDeauthorizedTime"], (int)config["remoteTraceLevel"], target, - (uint64_t)config["revision"], OSUtils::jsonDump(config["tags"], -1), (int)config["vMajor"], - (int)config["vMinor"], (int)config["vRev"], (int)config["vProto"]); + pqxx::result res = + w.exec( + "INSERT INTO network_memberships_ctl (device_id, network_id, authorized, active_bridge, " + "ip_assignments, " + "no_auto_assign_ips, sso_exempt, authentication_expiry_time, capabilities, creation_time, " + "identity, last_authorized_time, last_deauthorized_time, " + "remote_trace_level, remote_trace_target, revision, tags, version_major, version_minor, " + "version_revision, version_protocol) " + "VALUES ($1, $2, $3, $4, $5, $6, $7, TO_TIMESTAMP($8::double precision/1000), $9, " + "TO_TIMESTAMP($10::double precision/1000), $11, TO_TIMESTAMP($12::double precision/1000), " + "TO_TIMESTAMP($13::double precision/1000), $14, $15, $16, $17, $18, $19, $20, $21) " + "ON CONFLICT (device_id, network_id) DO UPDATE SET " + "authorized = EXCLUDED.authorized, active_bridge = EXCLUDED.active_bridge, " + "ip_assignments = EXCLUDED.ip_assignments, no_auto_assign_ips = " + "EXCLUDED.no_auto_assign_ips, " + "sso_exempt = EXCLUDED.sso_exempt, authentication_expiry_time = " + "EXCLUDED.authentication_expiry_time, " + "capabilities = EXCLUDED.capabilities, creation_time = EXCLUDED.creation_time, " + "identity = EXCLUDED.identity, last_authorized_time = EXCLUDED.last_authorized_time, " + "last_deauthorized_time = EXCLUDED.last_deauthorized_time, " + "remote_trace_level = EXCLUDED.remote_trace_level, remote_trace_target = " + "EXCLUDED.remote_trace_target, " + "revision = EXCLUDED.revision, tags = EXCLUDED.tags, version_major = " + "EXCLUDED.version_major, " + "version_minor = EXCLUDED.version_minor, version_revision = EXCLUDED.version_revision, " + "version_protocol = EXCLUDED.version_protocol", + pqxx::params { memberId, + networkId, + (bool)config["authorized"], + (bool)config["activeBridge"], + config["ipAssignments"].get >(), + (bool)config["noAutoAssignIps"], + (bool)config["ssoExempt"], + (uint64_t)config["authenticationExpiryTime"], + OSUtils::jsonDump(config["capabilities"], -1), + (uint64_t)config["creationTime"], + OSUtils::jsonString(config["identity"], ""), + (uint64_t)config["lastAuthorizedTime"], + (uint64_t)config["lastDeauthorizedTime"], + (int)config["remoteTraceLevel"], + target, + (uint64_t)config["revision"], + OSUtils::jsonDump(config["tags"], -1), + (int)config["vMajor"], + (int)config["vMinor"], + (int)config["vRev"], + (int)config["vProto"] }) + .no_rows(); w.commit(); @@ -1272,13 +1300,19 @@ void CentralDB::commitThread() std::string id = config["id"]; - pqxx::row nwrow = w.exec_params1( - "SELECT COUNT(id), frontend FROM networks_ctl WHERE id = $1 GROUP BY frontend", id); + pqxx::row nwrow = + w.exec( + "SELECT COUNT(id), frontend FROM networks_ctl WHERE id = $1 GROUP BY frontend", + pqxx::params { id }) + .one_row(); int nwcount = nwrow[0].as(); std::string frontend = nwrow[1].as(); bool isNewNetwork = (nwcount == 0); - std::string change_source = config["change_source"]; + std::string change_source; + if (! config["change_source"].is_null()) { + change_source = config["change_source"]; + } if (! isNewNetwork && change_source != "controller" && frontend != change_source) { // if it is not a new network and the change source is not the controller and doesn't match the // frontend, don't apply the change. @@ -1297,14 +1331,14 @@ void CentralDB::commitThread() } } - pqxx::result res = w.exec_params0( + pqxx::result res = w.exec( "INSERT INTO networks_ctl (id, name, configuration, controller_id, revision, frontend) " "VALUES ($1, $2, $3, $4, $5, $6) " "ON CONFLICT (id) DO UPDATE SET " "name = EXCLUDED.name, configuration = EXCLUDED.configuration, revision = EXCLUDED.revision+1, " "frontend = EXCLUDED.frontend", - id, OSUtils::jsonString(config["name"], ""), OSUtils::jsonDump(config, -1), _myAddressStr, - ((uint64_t)config["revision"]), change_source); + pqxx::params { id, OSUtils::jsonString(config["name"], ""), OSUtils::jsonDump(config, -1), + _myAddressStr, ((uint64_t)config["revision"]), change_source }); w.commit(); @@ -1354,8 +1388,8 @@ void CentralDB::commitThread() pqxx::work w(*c->c); std::string networkId = config["id"]; fprintf(stderr, "Deleting network %s\n", networkId.c_str()); - w.exec_params0("DELETE FROM network_memberships_ctl WHERE network_id = $1", networkId); - w.exec_params0("DELETE FROM networks_ctl WHERE id = $1", networkId); + w.exec("DELETE FROM network_memberships_ctl WHERE network_id = $1", pqxx::params { networkId }); + w.exec("DELETE FROM networks_ctl WHERE id = $1", pqxx::params { networkId }); w.commit(); @@ -1400,9 +1434,11 @@ void CentralDB::commitThread() std::string memberId = config["id"]; std::string networkId = config["nwid"]; - pqxx::result res = w.exec_params0( - "DELETE FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", memberId, - networkId); + pqxx::result res = + w.exec( + "DELETE FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", + pqxx::params { memberId, networkId }) + .no_rows(); w.commit(); @@ -1507,10 +1543,12 @@ void CentralDB::onlineNotificationThread() // // exec_params1 will throw pqxx::unexpected_rows if not exactly one row is returned. If that's the // case, skip this record and move on. - pqxx::row r = w.exec_params1( - "SELECT device_id, network_id FROM network_memberships_ctl WHERE network_id = $1 AND device_id " - "= $2", - networkId, memberId); + pqxx::row r = w.exec( + "SELECT device_id, network_id FROM network_memberships_ctl WHERE network_id = " + "$1 AND device_id " + "= $2", + pqxx::params { networkId, memberId }) + .one_row(); } catch (pqxx::unexpected_rows& e) { continue; @@ -1554,20 +1592,22 @@ nlohmann::json CentralDB::_getNetworkMember(pqxx::work& tx, const std::string ne nlohmann::json out; try { - pqxx::row row = tx.exec_params1( - "SELECT nm.device_id, nm.network_id, nm.authorized, nm.active_bridge, nm.ip_assignments, " - "nm.no_auto_assign_ips, " - "nm.sso_exempt, (EXTRACT(EPOCH FROM nm.authentication_expiry_time AT TIME ZONE 'UTC')*1000)::bigint, " - "(EXTRACT(EPOCH FROM nm.creation_time AT TIME ZONE 'UTC')*1000)::bigint, nm.identity, " - "(EXTRACT(EPOCH FROM nm.last_authorized_time AT TIME ZONE 'UTC')*1000)::bigint, " - "(EXTRACT(EPOCH FROM nm.last_deauthorized_time AT TIME ZONE 'UTC')*1000)::bigint, " - "nm.remote_trace_level, nm.remote_trace_target, nm.revision, nm.capabilities, nm.tags, " - "nm.frontend " - "FROM network_memberships_ctl nm " - "INNER JOIN networks_ctl n " - " ON nm.network_id = n.id " - "WHERE nm.network_id = $1 AND nm.device_id = $2", - networkID, memberID); + pqxx::row row = + tx.exec( + "SELECT nm.device_id, nm.network_id, nm.authorized, nm.active_bridge, nm.ip_assignments, " + "nm.no_auto_assign_ips, " + "nm.sso_exempt, (EXTRACT(EPOCH FROM nm.authentication_expiry_time AT TIME ZONE 'UTC')*1000)::bigint, " + "(EXTRACT(EPOCH FROM nm.creation_time AT TIME ZONE 'UTC')*1000)::bigint, nm.identity, " + "(EXTRACT(EPOCH FROM nm.last_authorized_time AT TIME ZONE 'UTC')*1000)::bigint, " + "(EXTRACT(EPOCH FROM nm.last_deauthorized_time AT TIME ZONE 'UTC')*1000)::bigint, " + "nm.remote_trace_level, nm.remote_trace_target, nm.revision, nm.capabilities, nm.tags, " + "nm.frontend " + "FROM network_memberships_ctl nm " + "INNER JOIN networks_ctl n " + " ON nm.network_id = n.id " + "WHERE nm.network_id = $1 AND nm.device_id = $2", + pqxx::params { networkID, memberID }) + .one_row(); bool authorized = row[2].as(); std::optional active_bridge = @@ -1647,11 +1687,13 @@ nlohmann::json CentralDB::_getNetwork(pqxx::work& tx, const std::string networkI std::optional revision; std::string frontend; - pqxx::row row = tx.exec_params1( - "SELECT id, name, configuration , (EXTRACT(EPOCH FROM creation_time AT TIME ZONE 'UTC')*1000)::bigint, " - "(EXTRACT(EPOCH FROM last_modified AT TIME ZONE 'UTC')*1000)::bigint, revision, frontend " - "FROM networks_ctl WHERE id = $1", - networkID); + pqxx::row row = tx.exec( + "SELECT id, name, configuration , (EXTRACT(EPOCH FROM creation_time AT TIME ZONE " + "'UTC')*1000)::bigint, " + "(EXTRACT(EPOCH FROM last_modified AT TIME ZONE 'UTC')*1000)::bigint, revision, frontend " + "FROM networks_ctl WHERE id = $1", + pqxx::params { networkID }) + .one_row(); cfg = row[2].as(); creation_time = row[3].is_null() ? std::optional() : std::optional(row[3].as()); From 493cc4fe4f7e87e1ca0b38b5e2697cbb3641d93a Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 10 Sep 2025 08:13:56 -0700 Subject: [PATCH 120/245] fix version string --- nonfree/controller/CentralDB.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 1b320306d7..9dc103d256 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1563,10 +1563,19 @@ void CentralDB::onlineNotificationThread() std::string arch = "unknown"; std::string frontend = member["frontend"].get(); - std::string vMajor = OSUtils::jsonString(member["vMajor"], "0"); - std::string vMinor = OSUtils::jsonString(member["vMinor"], "0"); - std::string vRev = OSUtils::jsonString(member["vRev"], "0"); - std::string version = "v" + vMajor + "." + vMinor + "." + vRev; + int vMajor = OSUtils::jsonInt(member["vMajor"], 0); + int vMinor = OSUtils::jsonInt(member["vMinor"], 0); + int vRev = OSUtils::jsonInt(member["vRev"], 0); + std::string version; + if (vMajor <= 0 && vMinor <= 0 && vRev <= 0) { + vMajor = 0; + vMinor = 0; + vRev = 0; + version = "unknown"; + } + else { + version = "v" + std::to_string(vMajor) + "." + std::to_string(vMinor) + "." + std::to_string(vRev); + } if (osArchSplit.size() == 2) { os = osArchSplit[0]; arch = osArchSplit[1]; From 1ce37e777088a75aff68ed5389e0a0d839551951 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 11 Sep 2025 10:02:45 -0700 Subject: [PATCH 121/245] add `use_for_new_networks` column in controller table --- .../migrations/0004_use_controller_flag.down.sql | 1 + .../migrations/0004_use_controller_flag.up.sql | 1 + 2 files changed, 2 insertions(+) create mode 100644 ext/central-controller-docker/migrations/0004_use_controller_flag.down.sql create mode 100644 ext/central-controller-docker/migrations/0004_use_controller_flag.up.sql diff --git a/ext/central-controller-docker/migrations/0004_use_controller_flag.down.sql b/ext/central-controller-docker/migrations/0004_use_controller_flag.down.sql new file mode 100644 index 0000000000..afcd9c3f76 --- /dev/null +++ b/ext/central-controller-docker/migrations/0004_use_controller_flag.down.sql @@ -0,0 +1 @@ +ALTER TABLE controllers_ctl DROP COLUMN IF EXISTS use_for_new_networks; \ No newline at end of file diff --git a/ext/central-controller-docker/migrations/0004_use_controller_flag.up.sql b/ext/central-controller-docker/migrations/0004_use_controller_flag.up.sql new file mode 100644 index 0000000000..b723b0172c --- /dev/null +++ b/ext/central-controller-docker/migrations/0004_use_controller_flag.up.sql @@ -0,0 +1 @@ +ALTER TABLE controllers_ctl ADD COLUMN IF NOT EXISTS use_for_new_networks boolean DEFAULT true NOT NULL; \ No newline at end of file From ad1fc5fb3d93562558ba7a8c8a53e7496c164c39 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Sat, 13 Sep 2025 10:05:20 -0700 Subject: [PATCH 122/245] add tables for the controller load log and sso nonces & expiry --- .../migrations/0005_controller_log.down.sql | 3 +++ .../migrations/0005_controller_log.up.sql | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 ext/central-controller-docker/migrations/0005_controller_log.down.sql create mode 100644 ext/central-controller-docker/migrations/0005_controller_log.up.sql diff --git a/ext/central-controller-docker/migrations/0005_controller_log.down.sql b/ext/central-controller-docker/migrations/0005_controller_log.down.sql new file mode 100644 index 0000000000..fecab6b5b3 --- /dev/null +++ b/ext/central-controller-docker/migrations/0005_controller_log.down.sql @@ -0,0 +1,3 @@ +DROP INDEX IF EXISTS ctl_check_time_ix; +DROP INDEX IF EXISTS ctl_id_ix; +DROP TABLE IF EXISTS controller_log; diff --git a/ext/central-controller-docker/migrations/0005_controller_log.up.sql b/ext/central-controller-docker/migrations/0005_controller_log.up.sql new file mode 100644 index 0000000000..985b719b91 --- /dev/null +++ b/ext/central-controller-docker/migrations/0005_controller_log.up.sql @@ -0,0 +1,19 @@ +CREATE TABLE IF NOT EXISTS controller_log ( + controller_id CHAR(10) NOT NULL REFERENCES ztc_controller(id) ON DELETE CASCADE, + check_time TIMESTAMP WITH TIME ZONE NOT NULL, + load_factor REAL, + PRIMARY KEY (controller_id, check_time) +); +CREATE INDEX IF NOT EXISTS ctl_check_time_ix ON public.controller_log USING btree (check_time); +CREATE INDEX IF NOT EXISTS ctl_id_ix ON public.controller_log USING btree (controller_id); + +CREATE TABLE IF NOT EXISTS sso_expiry ( + nonce TEXT PRIMARY KEY, + nonce_expiration TIMESTAMP WITH TIME ZONE NOT NULL, + network_id CHARACTER(16) NOT NULL, + member_id CHARACTER(10) NOT NULL, + creation_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT (current_timestamp AT TIME ZONE 'UTC'), + email TEXT, + authentication_expiry_time TIMESTAMP WITH TIME ZONE, + FOREIGN KEY (network_id, member_id) REFERENCES network_memberships_ctl(network_id, device_id) ON DELETE CASCADE +); From cb2de5aae1fc51148eac9d07428b207f75b522a6 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Sat, 13 Sep 2025 10:29:45 -0700 Subject: [PATCH 123/245] fix migration --- .../migrations/0005_controller_log.up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/central-controller-docker/migrations/0005_controller_log.up.sql b/ext/central-controller-docker/migrations/0005_controller_log.up.sql index 985b719b91..eafb9edec8 100644 --- a/ext/central-controller-docker/migrations/0005_controller_log.up.sql +++ b/ext/central-controller-docker/migrations/0005_controller_log.up.sql @@ -1,5 +1,5 @@ CREATE TABLE IF NOT EXISTS controller_log ( - controller_id CHAR(10) NOT NULL REFERENCES ztc_controller(id) ON DELETE CASCADE, + controller_id CHAR(10) NOT NULL REFERENCES controllers_ctl(id) ON DELETE CASCADE, check_time TIMESTAMP WITH TIME ZONE NOT NULL, load_factor REAL, PRIMARY KEY (controller_id, check_time) From 6113bad61e60abf7728b8b04dc6481423c41624e Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 18 Sep 2025 09:33:04 -0700 Subject: [PATCH 124/245] make pubsub topics configurable Also for pubsub trips back to CV1/CV2, rather than having 2 queues for each service (networks & members), theres now only a single queue for each change type, and `frontend = (cv1|cv2)` attribute is set on the message for filtering. --- ext/central-controller-docker/main-new.sh | 11 ++++++- nonfree/controller/CentralDB.cpp | 12 ++++--- .../controller/ControllerChangeNotifier.cpp | 32 ++++++------------- .../controller/ControllerChangeNotifier.hpp | 13 ++++---- nonfree/controller/ControllerConfig.hpp | 4 +++ nonfree/controller/PubSubListener.cpp | 8 ++--- nonfree/controller/PubSubListener.hpp | 4 +-- nonfree/controller/PubSubWriter.cpp | 22 +++++++++---- nonfree/controller/PubSubWriter.hpp | 10 ++++-- service/OneService.cpp | 8 +++++ 10 files changed, 74 insertions(+), 50 deletions(-) diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index aa0dba0fa3..b7085997a4 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -95,8 +95,17 @@ if [ "$ZT_USE_PUBSUB" == "true" ]; then exit 1 fi + if [ -z "$ZT_PUBSUB_MEMBER_CHANGE_RECV_TOPIC" ] || [ -z "$ZT_PUBSUB_MEMBER_CHANGE_SEND_TOPIC" ] || [ -z "$ZT_PUBSUB_NETWORK_CHANGE_RECV_TOPIC" ] || [ -z "$ZT_PUBSUB_NETWORK_CHANGE_SEND_TOPIC" ]; then + echo '*** FAILED: ZT_PUBSUB_MEMBER_CHANGE_RECV_TOPIC, ZT_PUBSUB_MEMBER_CHANGE_SEND_TOPIC, ZT_PUBSUB_NETWORK_CHANGE_RECV_TOPIC, and ZT_PUBSUB_NETWORK_CHANGE_SEND_TOPIC environment variables must all be defined to use PubSub as a controller backend' + exit 1 + fi + PUBSUB_CONF=", \"pubsub\": { - \"project_id\": \"${ZT_PUBSUB_PROJECT}\" + \"project_id\": \"${ZT_PUBSUB_PROJECT}\", + \"member_change_recv_topic\": \"${ZT_PUBSUB_MEMBER_CHANGE_RECV_TOPIC}\", + \"member_change_send_topic\": \"${ZT_PUBSUB_MEMBER_CHANGE_SEND_TOPIC}\", + \"network_change_recv_topic\": \"${ZT_PUBSUB_NETWORK_CHANGE_RECV_TOPIC}\", + \"network_change_send_topic\": \"${ZT_PUBSUB_NETWORK_CHANGE_SEND_TOPIC}\" } " fi diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 9dc103d256..5d85de4412 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -165,11 +165,13 @@ CentralDB::CentralDB( case LISTENER_MODE_PUBSUB: fprintf(stderr, "Using PubSub for change listeners\n"); if (cc->pubSubConfig != NULL) { - _membersDbWatcher = - std::make_shared(_myAddressStr, cc->pubSubConfig->project_id, this); - _networksDbWatcher = - std::make_shared(_myAddressStr, cc->pubSubConfig->project_id, this); - _changeNotifier = std::make_shared(_myAddressStr, cc->pubSubConfig->project_id); + _membersDbWatcher = std::make_shared( + _myAddressStr, cc->pubSubConfig->project_id, cc->pubSubConfig->member_change_recv_topic, this); + _networksDbWatcher = std::make_shared( + _myAddressStr, cc->pubSubConfig->project_id, cc->pubSubConfig->network_change_recv_topic, this); + _changeNotifier = std::make_shared( + _myAddressStr, cc->pubSubConfig->project_id, cc->pubSubConfig->member_change_send_topic, + cc->pubSubConfig->network_change_send_topic); } else { throw std::runtime_error( diff --git a/nonfree/controller/ControllerChangeNotifier.cpp b/nonfree/controller/ControllerChangeNotifier.cpp index 74d52754fb..2f1bf67fb4 100644 --- a/nonfree/controller/ControllerChangeNotifier.cpp +++ b/nonfree/controller/ControllerChangeNotifier.cpp @@ -4,12 +4,14 @@ namespace ZeroTier { -PubSubChangeNotifier::PubSubChangeNotifier(std::string controllerID, std::string project) +PubSubChangeNotifier::PubSubChangeNotifier( + std::string controllerID, + std::string project, + std::string memberChangeTopic, + std::string networkChangeTopic) : ControllerChangeNotifier() - , _cv1networkChangeWriter(std::make_shared(project, "ctl-to-cv1-network-change-stream", controllerID)) - , _cv1memberChangeWriter(std::make_shared(project, "ctl-to-cv1-member-change-stream", controllerID)) - , _cv2networkChangeWriter(std::make_shared(project, "ctl-to-cv2-network-change-stream", controllerID)) - , _cv2memberChangeWriter(std::make_shared(project, "ctl-to-cv2-member-change-stream", controllerID)) + , _networkChangeWriter(std::make_shared(project, networkChangeTopic, controllerID)) + , _memberChangeWriter(std::make_shared(project, memberChangeTopic, controllerID)) { } @@ -22,15 +24,7 @@ void PubSubChangeNotifier::notifyNetworkChange( const nlohmann::json& newNetwork, const std::string& frontend) { - if (frontend == "cv1") { - _cv1networkChangeWriter->publishNetworkChange(oldNetwork, newNetwork); - } - else if (frontend == "cv2") { - _cv2networkChangeWriter->publishNetworkChange(oldNetwork, newNetwork); - } - else { - throw std::runtime_error("Unknown frontend: " + frontend); - } + _networkChangeWriter->publishNetworkChange(oldNetwork, newNetwork, frontend); } void PubSubChangeNotifier::notifyMemberChange( @@ -38,15 +32,7 @@ void PubSubChangeNotifier::notifyMemberChange( const nlohmann::json newMember, const std::string& frontend) { - if (frontend == "cv1") { - _cv1memberChangeWriter->publishMemberChange(oldMember, newMember); - } - else if (frontend == "cv2") { - _cv2memberChangeWriter->publishMemberChange(oldMember, newMember); - } - else { - throw std::runtime_error("Unknown frontend: " + frontend); - } + _memberChangeWriter->publishMemberChange(oldMember, newMember, frontend); } } // namespace ZeroTier \ No newline at end of file diff --git a/nonfree/controller/ControllerChangeNotifier.hpp b/nonfree/controller/ControllerChangeNotifier.hpp index ba8b210e3e..2a5e000ff4 100644 --- a/nonfree/controller/ControllerChangeNotifier.hpp +++ b/nonfree/controller/ControllerChangeNotifier.hpp @@ -26,7 +26,11 @@ class ControllerChangeNotifier { class PubSubChangeNotifier : public ControllerChangeNotifier { public: - PubSubChangeNotifier(std::string controllerID, std::string project); + PubSubChangeNotifier( + std::string controllerID, + std::string project, + std::string memberChangeTopic, + std::string networkChangeTopic); virtual ~PubSubChangeNotifier(); virtual void notifyNetworkChange( @@ -40,11 +44,8 @@ class PubSubChangeNotifier : public ControllerChangeNotifier { const std::string& frontend = "") override; private: - std::shared_ptr _cv1networkChangeWriter; - std::shared_ptr _cv1memberChangeWriter; - - std::shared_ptr _cv2networkChangeWriter; - std::shared_ptr _cv2memberChangeWriter; + std::shared_ptr _networkChangeWriter; + std::shared_ptr _memberChangeWriter; }; } // namespace ZeroTier diff --git a/nonfree/controller/ControllerConfig.hpp b/nonfree/controller/ControllerConfig.hpp index b082b793bb..2df1736c7a 100644 --- a/nonfree/controller/ControllerConfig.hpp +++ b/nonfree/controller/ControllerConfig.hpp @@ -9,6 +9,10 @@ namespace ZeroTier { struct PubSubConfig { std::string project_id; + std::string member_change_recv_topic; + std::string member_change_send_topic; + std::string network_change_recv_topic; + std::string network_change_send_topic; }; struct BigTableConfig { diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index c4e7fb58dc..0d87ff47c9 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -121,8 +121,8 @@ void PubSubListener::subscribe() } } -PubSubNetworkListener::PubSubNetworkListener(std::string controller_id, std::string project, DB* db) - : PubSubListener(controller_id, project, "controller-network-change-stream") +PubSubNetworkListener::PubSubNetworkListener(std::string controller_id, std::string project, std::string topic, DB* db) + : PubSubListener(controller_id, project, topic) , _db(db) { } @@ -199,8 +199,8 @@ void PubSubNetworkListener::onNotification(const std::string& payload) } } -PubSubMemberListener::PubSubMemberListener(std::string controller_id, std::string project, DB* db) - : PubSubListener(controller_id, project, "controller-member-change-stream") +PubSubMemberListener::PubSubMemberListener(std::string controller_id, std::string project, std::string topic, DB* db) + : PubSubListener(controller_id, project, topic) , _db(db) { } diff --git a/nonfree/controller/PubSubListener.hpp b/nonfree/controller/PubSubListener.hpp index 5c6aa712c8..6e7f17c640 100644 --- a/nonfree/controller/PubSubListener.hpp +++ b/nonfree/controller/PubSubListener.hpp @@ -45,7 +45,7 @@ class PubSubListener : public NotificationListener { */ class PubSubNetworkListener : public PubSubListener { public: - PubSubNetworkListener(std::string controller_id, std::string project, DB* db); + PubSubNetworkListener(std::string controller_id, std::string project, std::string topic, DB* db); virtual ~PubSubNetworkListener(); virtual void onNotification(const std::string& payload) override; @@ -59,7 +59,7 @@ class PubSubNetworkListener : public PubSubListener { */ class PubSubMemberListener : public PubSubListener { public: - PubSubMemberListener(std::string controller_id, std::string project, DB* db); + PubSubMemberListener(std::string controller_id, std::string project, std::string topic, DB* db); virtual ~PubSubMemberListener(); virtual void onNotification(const std::string& payload) override; diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index c1bd7d5685..fcba2c2fa3 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -51,11 +51,15 @@ PubSubWriter::~PubSubWriter() { } -bool PubSubWriter::publishMessage(const std::string& payload) +bool PubSubWriter::publishMessage(const std::string& payload, const std::string& frontend) { std::vector > attributes; attributes.emplace_back("controller_id", _controller_id); + if (! frontend.empty()) { + attributes.emplace_back("frontend", frontend); + } + auto msg = pubsub::MessageBuilder {}.SetData(payload).SetAttributes(attributes).Build(); auto message_id = _publisher->Publish(std::move(msg)).get(); if (! message_id) { @@ -67,7 +71,10 @@ bool PubSubWriter::publishMessage(const std::string& payload) return true; } -bool PubSubWriter::publishNetworkChange(const nlohmann::json& oldNetwork, const nlohmann::json& newNetwork) +bool PubSubWriter::publishNetworkChange( + const nlohmann::json& oldNetwork, + const nlohmann::json& newNetwork, + const std::string& frontend) { pbmessages::NetworkChange nc = networkChangeFromJson(_controller_id, oldNetwork, newNetwork); std::string payload; @@ -76,10 +83,13 @@ bool PubSubWriter::publishNetworkChange(const nlohmann::json& oldNetwork, const return false; } - return publishMessage(payload); + return publishMessage(payload, frontend); } -bool PubSubWriter::publishMemberChange(const nlohmann::json& oldMember, const nlohmann::json& newMember) +bool PubSubWriter::publishMemberChange( + const nlohmann::json& oldMember, + const nlohmann::json& newMember, + const std::string& frontend) { pbmessages::MemberChange mc = memberChangeFromJson(_controller_id, oldMember, newMember); std::string payload; @@ -88,7 +98,7 @@ bool PubSubWriter::publishMemberChange(const nlohmann::json& oldMember, const nl return false; } - return publishMessage(payload); + return publishMessage(payload, frontend); } bool PubSubWriter::publishStatusChange( @@ -124,7 +134,7 @@ bool PubSubWriter::publishStatusChange( return false; } - return publishMessage(payload); + return publishMessage(payload, ""); } pbmessages::NetworkChange_Network* networkFromJson(const nlohmann::json& j) diff --git a/nonfree/controller/PubSubWriter.hpp b/nonfree/controller/PubSubWriter.hpp index 26a7bc9eec..bdc0103932 100644 --- a/nonfree/controller/PubSubWriter.hpp +++ b/nonfree/controller/PubSubWriter.hpp @@ -13,9 +13,13 @@ class PubSubWriter { PubSubWriter(std::string project, std::string topic, std::string controller_id); virtual ~PubSubWriter(); - bool publishNetworkChange(const nlohmann::json& oldNetwork, const nlohmann::json& newNetwork); + bool publishNetworkChange( + const nlohmann::json& oldNetwork, + const nlohmann::json& newNetwork, + const std::string& frontend); - bool publishMemberChange(const nlohmann::json& oldMember, const nlohmann::json& newMember); + bool + publishMemberChange(const nlohmann::json& oldMember, const nlohmann::json& newMember, const std::string& frontend); bool publishStatusChange( std::string frontend, @@ -27,7 +31,7 @@ class PubSubWriter { int64_t last_seen); protected: - bool publishMessage(const std::string& payload); + bool publishMessage(const std::string& payload, const std::string& frontend); private: std::string _controller_id; diff --git a/service/OneService.cpp b/service/OneService.cpp index a097156b79..128eb46d2e 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -1822,6 +1822,14 @@ class OneServiceImpl : public OneService { json& ps = cc["pubsub"]; _controllerConfig.pubSubConfig = new PubSubConfig(); _controllerConfig.pubSubConfig->project_id = OSUtils::jsonString(ps["project_id"], ""); + _controllerConfig.pubSubConfig->member_change_recv_topic = + OSUtils::jsonString(ps["member_change_recv_topic"], ""); + _controllerConfig.pubSubConfig->member_change_send_topic = + OSUtils::jsonString(ps["member_change_send_topic"], ""); + _controllerConfig.pubSubConfig->network_change_recv_topic = + OSUtils::jsonString(ps["network_change_recv_topic"], ""); + _controllerConfig.pubSubConfig->network_change_send_topic = + OSUtils::jsonString(ps["network_change_send_topic"], ""); } if (_controllerConfig.listenMode == "pubsub" && ! _controllerConfig.pubSubConfig) { fprintf(stderr, "ERROR: pubsub listenMode requires pubsub configuration in local.conf" ZT_EOL_S); From d96d3b27d22b27079728a84862fdc7531aaf5ba3 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 22 Sep 2025 10:52:06 -0700 Subject: [PATCH 125/245] try making the controller attach to an existing pubsub subscription if it already exists --- nonfree/controller/PubSubListener.cpp | 33 ++++++++++++++++----------- nonfree/controller/PubSubListener.hpp | 2 +- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 0d87ff47c9..b1a7187f6c 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -30,12 +30,13 @@ PubSubListener::PubSubListener(std::string controller_id, std::string project, s : _controller_id(controller_id) , _project(project) , _topic(topic) - , _subscription_id("sub-" + controller_id + "-" + topic) + , _subscription_id() , _run(false) , _adminClient(pubsub_admin::MakeSubscriptionAdminConnection()) - , _subscription(pubsub::Subscription(_project, _subscription_id)) + , _subscription(nullptr) { - _subscription_id = _subscription_id + "-" + random_hex_string(8); + _subscription_id = "sub-" + controller_id + "-" + topic; // + "-" + random_hex_string(8); + _subscription = new pubsub::Subscription(_project, _subscription_id); fprintf( stderr, "PubSubListener for controller %s project %s topic %s subscription %s\n", controller_id.c_str(), project.c_str(), topic.c_str(), _subscription_id.c_str()); @@ -48,21 +49,22 @@ PubSubListener::PubSubListener(std::string controller_id, std::string project, s } google::pubsub::v1::Subscription request; - request.set_name(_subscription.FullName()); + request.set_name(_subscription->FullName()); request.set_topic(pubsub::Topic(project, topic).FullName()); request.set_filter("(attributes.controller_id=\"" + _controller_id + "\")"); auto sub = _adminClient.CreateSubscription(request); if (! sub.ok()) { - fprintf(stderr, "Failed to create subscription: %s\n", sub.status().message().c_str()); - throw std::runtime_error("Failed to create subscription"); - } - - if (sub.status().code() == google::cloud::StatusCode::kAlreadyExists) { - fprintf(stderr, "Subscription already exists\n"); - throw std::runtime_error("Subscription already exists"); + if (sub.status().code() == google::cloud::StatusCode::kAlreadyExists) { + fprintf(stderr, "Subscription already exists. Attaching to it\n"); + // throw std::runtime_error("Subscription already exists"); + } + else { + fprintf(stderr, "Failed to create subscription: %s\n", sub.status().message().c_str()); + throw std::runtime_error("Failed to create subscription"); + } } - _subscriber = std::make_shared(pubsub::MakeSubscriberConnection(_subscription)); + _subscriber = std::make_shared(pubsub::MakeSubscriberConnection(*_subscription)); _run = true; _subscriberThread = std::thread(&PubSubListener::subscribe, this); @@ -75,10 +77,15 @@ PubSubListener::~PubSubListener() _subscriberThread.join(); } - auto status = _adminClient.DeleteSubscription(_subscription.FullName()); + auto status = _adminClient.DeleteSubscription(_subscription->FullName()); if (! status.ok()) { fprintf(stderr, "Failed to delete subscription: %s\n", status.message().c_str()); } + + if (_subscription) { + delete _subscription; + _subscription = nullptr; + } } void PubSubListener::subscribe() diff --git a/nonfree/controller/PubSubListener.hpp b/nonfree/controller/PubSubListener.hpp index 6e7f17c640..2efe8c8195 100644 --- a/nonfree/controller/PubSubListener.hpp +++ b/nonfree/controller/PubSubListener.hpp @@ -35,7 +35,7 @@ class PubSubListener : public NotificationListener { void subscribe(); bool _run = false; google::cloud::pubsub_admin::SubscriptionAdminClient _adminClient; - google::cloud::pubsub::Subscription _subscription; + google::cloud::pubsub::Subscription* _subscription; std::shared_ptr _subscriber; std::thread _subscriberThread; }; From 6196e87303e1f8c75e31a4f162932acb5ca60781 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 22 Sep 2025 16:32:28 -0700 Subject: [PATCH 126/245] only create the subscription if pubsub emulator is being used. --- nonfree/controller/CtlUtil.cpp | 33 +++++++++++++++++++++++++++ nonfree/controller/CtlUtil.hpp | 6 +++++ nonfree/controller/PubSubListener.cpp | 25 +++----------------- 3 files changed, 42 insertions(+), 22 deletions(-) diff --git a/nonfree/controller/CtlUtil.cpp b/nonfree/controller/CtlUtil.cpp index 36aad01b09..8e6452f335 100644 --- a/nonfree/controller/CtlUtil.cpp +++ b/nonfree/controller/CtlUtil.cpp @@ -119,6 +119,39 @@ void create_gcp_pubsub_topic_if_needed(std::string project_id, std::string topic } } +void create_gcp_pubsub_subscription_if_needed( + std::string project_id, + std::string subscription_id, + std::string topic_id, + std::string controller_id) +{ + // This is a no-op if the subscription already exists. + auto subscriptionAdminClient = + pubsub_admin::SubscriptionAdminClient(pubsub_admin::MakeSubscriptionAdminConnection()); + auto topicName = pubsub::Topic(project_id, topic_id).FullName(); + auto subscriptionName = pubsub::Subscription(project_id, subscription_id).FullName(); + + auto sub = subscriptionAdminClient.GetSubscription(subscriptionName); + if (! sub.ok()) { + if (sub.status().code() == google::cloud::StatusCode::kNotFound) { + google::pubsub::v1::Subscription request; + request.set_name(subscription_id); + request.set_topic(pubsub::Topic(project_id, topic_id).FullName()); + request.set_filter("(attributes.controller_id=\"" + controller_id + "\")"); + auto createResult = subscriptionAdminClient.CreateSubscription(request); + if (! createResult.ok()) { + fprintf(stderr, "Failed to create subscription: %s\n", createResult.status().message().c_str()); + throw std::runtime_error("Failed to create subscription"); + } + fprintf(stderr, "Created subscription: %s\n", subscriptionName.c_str()); + } + else { + fprintf(stderr, "Failed to get subscription: %s\n", sub.status().message().c_str()); + throw std::runtime_error("Failed to get subscription"); + } + } +} + // void create_bigtable_table(std::string project_id, std::string instance_id) // { // auto bigtableAdminClient = diff --git a/nonfree/controller/CtlUtil.hpp b/nonfree/controller/CtlUtil.hpp index 46faed2b7d..c10322012a 100644 --- a/nonfree/controller/CtlUtil.hpp +++ b/nonfree/controller/CtlUtil.hpp @@ -20,6 +20,12 @@ std::string random_hex_string(std::size_t length); #ifdef ZT1_CENTRAL_CONTROLLER void create_gcp_pubsub_topic_if_needed(std::string project_id, std::string topic_id); + +void create_gcp_pubsub_subscription_if_needed( + std::string project_id, + std::string subscription_id, + std::string topic_id, + std::string controller_id); #endif } // namespace ZeroTier diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index b1a7187f6c..8e727e8d56 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -35,33 +35,19 @@ PubSubListener::PubSubListener(std::string controller_id, std::string project, s , _adminClient(pubsub_admin::MakeSubscriptionAdminConnection()) , _subscription(nullptr) { + GOOGLE_PROTOBUF_VERIFY_VERSION; + _subscription_id = "sub-" + controller_id + "-" + topic; // + "-" + random_hex_string(8); _subscription = new pubsub::Subscription(_project, _subscription_id); fprintf( stderr, "PubSubListener for controller %s project %s topic %s subscription %s\n", controller_id.c_str(), project.c_str(), topic.c_str(), _subscription_id.c_str()); - GOOGLE_PROTOBUF_VERIFY_VERSION; // If PUBSUB_EMULATOR_HOST is set, create the topic if it doesn't exist const char* emulatorHost = std::getenv("PUBSUB_EMULATOR_HOST"); if (emulatorHost != nullptr) { create_gcp_pubsub_topic_if_needed(project, topic); - } - - google::pubsub::v1::Subscription request; - request.set_name(_subscription->FullName()); - request.set_topic(pubsub::Topic(project, topic).FullName()); - request.set_filter("(attributes.controller_id=\"" + _controller_id + "\")"); - auto sub = _adminClient.CreateSubscription(request); - if (! sub.ok()) { - if (sub.status().code() == google::cloud::StatusCode::kAlreadyExists) { - fprintf(stderr, "Subscription already exists. Attaching to it\n"); - // throw std::runtime_error("Subscription already exists"); - } - else { - fprintf(stderr, "Failed to create subscription: %s\n", sub.status().message().c_str()); - throw std::runtime_error("Failed to create subscription"); - } + create_gcp_pubsub_subscription_if_needed(_project, _subscription_id, _topic, _controller_id); } _subscriber = std::make_shared(pubsub::MakeSubscriberConnection(*_subscription)); @@ -77,11 +63,6 @@ PubSubListener::~PubSubListener() _subscriberThread.join(); } - auto status = _adminClient.DeleteSubscription(_subscription->FullName()); - if (! status.ok()) { - fprintf(stderr, "Failed to delete subscription: %s\n", status.message().c_str()); - } - if (_subscription) { delete _subscription; _subscription = nullptr; From 069d7c1862009e8f0a7512a4abd063819b7f310f Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 25 Sep 2025 15:14:30 -0700 Subject: [PATCH 127/245] set objtype on messages received via PubSub --- nonfree/controller/CentralDB.cpp | 10 +++++----- nonfree/controller/PubSubListener.cpp | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 5d85de4412..a05d9bb37d 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -351,10 +351,10 @@ bool CentralDB::save(nlohmann::json& record, bool notifyListeners) } } catch (std::exception& e) { - fprintf(stderr, "Error on PostgreSQL::save: %s\n", e.what()); + fprintf(stderr, "Error on CentralDB::save: %s\n", e.what()); } catch (...) { - fprintf(stderr, "Unknown error on PostgreSQL::save\n"); + fprintf(stderr, "Unknown error on CentralDB::save\n"); } return modified; } @@ -368,7 +368,7 @@ void CentralDB::eraseNetwork(const uint64_t networkId) char networkIdStr[17]; span->SetAttribute("network_id", Utils::hex(networkId, networkIdStr)); - fprintf(stderr, "PostgreSQL::eraseNetwork\n"); + fprintf(stderr, "CentralDB::eraseNetwork\n"); char tmp2[24]; waitForReady(); Utils::hex(networkId, tmp2); @@ -392,7 +392,7 @@ void CentralDB::eraseMember(const uint64_t networkId, const uint64_t memberId) span->SetAttribute("network_id", Utils::hex(networkId, networkIdStr)); span->SetAttribute("member_id", Utils::hex10(memberId, memberIdStr)); - fprintf(stderr, "PostgreSQL::eraseMember\n"); + fprintf(stderr, "CentralDB::eraseMember\n"); char tmp2[24]; waitForReady(); std::pair tmp, nw; @@ -467,7 +467,7 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri // info.version=1; // return info; // } - // fprintf(stderr, "PostgreSQL::updateMemberOnLoad: %s-%s\n", networkId.c_str(), memberId.c_str()); + // fprintf(stderr, "CentralDB::updateMemberOnLoad: %s-%s\n", networkId.c_str(), memberId.c_str()); std::shared_ptr c; try { c = _pool->borrow(); diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 8e727e8d56..250bf00c98 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -277,6 +277,7 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N { nlohmann::json out; + out["objtype"] = "network"; out["id"] = nc.network_id(); out["name"] = nc.name(); out["capabilities"] = OSUtils::jsonParse(nc.capabilities()); @@ -387,6 +388,7 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N nlohmann::json toJson(const pbmessages::MemberChange_Member& mc, pbmessages::MemberChange_ChangeSource source) { nlohmann::json out; + out["objtype"] = "member"; out["id"] = mc.device_id(); out["nwid"] = mc.network_id(); if (mc.has_remote_trace_target()) { From e51e516f856614bb2a3ffc5633638c656439b8d1 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 25 Sep 2025 15:38:28 -0700 Subject: [PATCH 128/245] fix subscription creation --- nonfree/controller/CtlUtil.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nonfree/controller/CtlUtil.cpp b/nonfree/controller/CtlUtil.cpp index 8e6452f335..4ed30b040e 100644 --- a/nonfree/controller/CtlUtil.cpp +++ b/nonfree/controller/CtlUtil.cpp @@ -134,8 +134,9 @@ void create_gcp_pubsub_subscription_if_needed( auto sub = subscriptionAdminClient.GetSubscription(subscriptionName); if (! sub.ok()) { if (sub.status().code() == google::cloud::StatusCode::kNotFound) { + fprintf(stderr, "Creating subscription %s for topic %s\n", subscriptionName.c_str(), topicName.c_str()); google::pubsub::v1::Subscription request; - request.set_name(subscription_id); + request.set_name(subscriptionName); request.set_topic(pubsub::Topic(project_id, topic_id).FullName()); request.set_filter("(attributes.controller_id=\"" + controller_id + "\")"); auto createResult = subscriptionAdminClient.CreateSubscription(request); From c6b7c263d26ba3eb320470f745888a29323f99d6 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 25 Sep 2025 16:09:57 -0700 Subject: [PATCH 129/245] query fix for new networks --- nonfree/controller/CentralDB.cpp | 16 ++++++++++++---- nonfree/controller/PubSubListener.cpp | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index a05d9bb37d..b39ac6dd18 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1303,21 +1303,29 @@ void CentralDB::commitThread() std::string id = config["id"]; pqxx::row nwrow = - w.exec( - "SELECT COUNT(id), frontend FROM networks_ctl WHERE id = $1 GROUP BY frontend", - pqxx::params { id }) + w.exec("SELECT COUNT(id) frontend FROM networks_ctl WHERE id = $1", pqxx::params { id }) .one_row(); int nwcount = nwrow[0].as(); - std::string frontend = nwrow[1].as(); bool isNewNetwork = (nwcount == 0); + std::string frontend = ""; + + if (! isNewNetwork) { + pqxx::row nwrow = + w.exec("SELECT frontend FROM networks_ctl WHERE id = $1", pqxx::params { id }).one_row(); + frontend = nwrow[0].as(); + } std::string change_source; if (! config["change_source"].is_null()) { change_source = config["change_source"]; } + if (! isNewNetwork && change_source != "controller" && frontend != change_source) { // if it is not a new network and the change source is not the controller and doesn't match the // frontend, don't apply the change. + fprintf( + stderr, "Skipping network update %s. isNewNetwork: %s, change_source: %s, frontend: %s\n", + id.c_str(), isNewNetwork ? "true" : "false", change_source.c_str(), frontend.c_str()); continue; } diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 250bf00c98..623b3ba973 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -134,7 +134,7 @@ void PubSubNetworkListener::onNotification(const std::string& payload) return; } - fprintf(stderr, "Network notification received"); + fprintf(stderr, "Network notification received\n"); try { nlohmann::json oldConfig, newConfig; From 315bf240fc9899020befcab1f95a05185abeec77 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 25 Sep 2025 16:34:08 -0700 Subject: [PATCH 130/245] json field fix --- nonfree/controller/CentralDB.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index b39ac6dd18..177b97da4e 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1352,7 +1352,7 @@ void CentralDB::commitThread() w.commit(); - const uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); + const uint64_t nwidInt = OSUtils::jsonIntHex(config["id"], 0ULL); if (nwidInt) { nlohmann::json nwOrig; nlohmann::json nwNew(config); From 97d20a115565988243449d2d872fe8fc810a7ec4 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 30 Sep 2025 10:32:21 -0700 Subject: [PATCH 131/245] more logging for errors on pubsub listener --- nonfree/controller/PubSubListener.cpp | 12 +- nonfree/controller/PubSubWriter.cpp | 184 ++++++++++++++------------ 2 files changed, 106 insertions(+), 90 deletions(-) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 623b3ba973..7ec59b5ed4 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -56,7 +56,7 @@ PubSubListener::PubSubListener(std::string controller_id, std::string project, s _subscriberThread = std::thread(&PubSubListener::subscribe, this); } -PubSubListener::~PubSubListener() +PubSubListener::~PubSubListener()` { _run = false; if (_subscriberThread.joinable()) { @@ -174,13 +174,14 @@ void PubSubNetworkListener::onNotification(const std::string& payload) } } catch (const nlohmann::json::parse_error& e) { - fprintf(stderr, "JSON parse error: %s\n", e.what()); + fprintf(stderr, "PubSubNetworkListener JSON parse error: %s\n", e.what()); span->SetAttribute("error", e.what()); span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + fprintf(stderr, "payload: %s\n", payload.c_str()); return; } catch (const std::exception& e) { - fprintf(stderr, "Exception in PubSubNetworkListener: %s\n", e.what()); + fprintf(stderr, "PubSubNetworkListener Exception in PubSubNetworkListener: %s\n", e.what()); span->SetAttribute("error", e.what()); span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); return; @@ -260,13 +261,14 @@ void PubSubMemberListener::onNotification(const std::string& payload) } } catch (const nlohmann::json::parse_error& e) { - fprintf(stderr, "JSON parse error: %s\n", e.what()); + fprintf(stderr, "PubSubMemberListener JSON parse error: %s\n", e.what()); span->SetAttribute("error", e.what()); span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + fprintf(stderr, "payload: %s\n", payload.c_str()); return; } catch (const std::exception& e) { - fprintf(stderr, "Exception in PubSubMemberListener: %s\n", e.what()); + fprintf(stderr, "PubSubMemberListener Exception in PubSubMemberListener: %s\n", e.what()); span->SetAttribute("error", e.what()); span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); return; diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index fcba2c2fa3..ee9ba8bd92 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -144,75 +144,82 @@ pbmessages::NetworkChange_Network* networkFromJson(const nlohmann::json& j) } pbmessages::NetworkChange_Network* n = new pbmessages::NetworkChange_Network(); - n->set_network_id(j.value("id", "")); - n->set_name(j.value("name", "")); - n->set_capabilities(OSUtils::jsonDump(j.value("capabilities", "[]"), -1)); - n->set_creation_time(j.value("creationTime", 0)); - n->set_enable_broadcast(j.value("enableBroadcast", false)); - - for (const auto& p : j["ipAssignmentPools"]) { - if (p.is_object()) { - auto pool = n->add_assignment_pools(); - pool->set_start_ip(p.value("ipRangeStart", "")); - pool->set_end_ip(p.value("ipRangeEnd", "")); + try { + n->set_network_id(j.value("id", "")); + n->set_name(j.value("name", "")); + n->set_capabilities(OSUtils::jsonDump(j.value("capabilities", "[]"), -1)); + n->set_creation_time(j.value("creationTime", 0)); + n->set_enable_broadcast(j.value("enableBroadcast", false)); + + for (const auto& p : j["ipAssignmentPools"]) { + if (p.is_object()) { + auto pool = n->add_assignment_pools(); + pool->set_start_ip(p.value("ipRangeStart", "")); + pool->set_end_ip(p.value("ipRangeEnd", "")); + } } - } - n->set_mtu(j.value("mtu", 2800)); - n->set_multicast_limit(j.value("multicastLimit", 32)); - n->set_is_private(j.value("private", true)); - n->set_remote_trace_level(j.value("remoteTraceLevel", 0)); - n->set_remote_trace_target(j.value("remoteTraceTarget", "")); - n->set_revision(j.value("revision", 0)); - - for (const auto& p : j["routes"]) { - if (p.is_object()) { - auto r = n->add_routes(); - r->set_target(p.value("target", "")); - r->set_via(p.value("via", "")); + n->set_mtu(j.value("mtu", 2800)); + n->set_multicast_limit(j.value("multicastLimit", 32)); + n->set_is_private(j.value("private", true)); + n->set_remote_trace_level(j.value("remoteTraceLevel", 0)); + n->set_remote_trace_target(j.value("remoteTraceTarget", "")); + n->set_revision(j.value("revision", 0)); + + for (const auto& p : j["routes"]) { + if (p.is_object()) { + auto r = n->add_routes(); + r->set_target(p.value("target", "")); + r->set_via(p.value("via", "")); + } } - } - n->set_rules(""); - n->set_tags(OSUtils::jsonDump(j.value("tags", "[]"), -1)); + n->set_rules(""); + n->set_tags(OSUtils::jsonDump(j.value("tags", "[]"), -1)); - pbmessages::NetworkChange_IPV4AssignMode* v4am = new pbmessages::NetworkChange_IPV4AssignMode(); - if (j["v4AssignMode"].is_object()) { - v4am->set_zt(j["v4AssignMode"].value("zt", false)); - } - n->set_allocated_ipv4_assign_mode(v4am); + pbmessages::NetworkChange_IPV4AssignMode* v4am = new pbmessages::NetworkChange_IPV4AssignMode(); + if (j["v4AssignMode"].is_object()) { + v4am->set_zt(j["v4AssignMode"].value("zt", false)); + } + n->set_allocated_ipv4_assign_mode(v4am); - pbmessages::NetworkChange_IPV6AssignMode* v6am = new pbmessages::NetworkChange_IPV6AssignMode(); - if (j["v6AssignMode"].is_object()) { - v6am->set_zt(j["v6AssignMode"].value("zt", false)); - v6am->set_six_plane(j["v6AssignMode"].value("6plane", false)); - v6am->set_rfc4193(j["v6AssignMode"].value("rfc4193", false)); - } - n->set_allocated_ipv6_assign_mode(v6am); - - nlohmann::json jdns = j.value("dns", nullptr); - if (jdns.is_object()) { - pbmessages::NetworkChange_DNS* dns = new pbmessages::NetworkChange_DNS(); - dns->set_domain(jdns.value("domain", "")); - for (const auto& s : jdns["servers"]) { - if (s.is_string()) { - auto server = dns->add_nameservers(); - *server = s; + pbmessages::NetworkChange_IPV6AssignMode* v6am = new pbmessages::NetworkChange_IPV6AssignMode(); + if (j["v6AssignMode"].is_object()) { + v6am->set_zt(j["v6AssignMode"].value("zt", false)); + v6am->set_six_plane(j["v6AssignMode"].value("6plane", false)); + v6am->set_rfc4193(j["v6AssignMode"].value("rfc4193", false)); + } + n->set_allocated_ipv6_assign_mode(v6am); + + nlohmann::json jdns = j.value("dns", nullptr); + if (jdns.is_object()) { + pbmessages::NetworkChange_DNS* dns = new pbmessages::NetworkChange_DNS(); + dns->set_domain(jdns.value("domain", "")); + for (const auto& s : jdns["servers"]) { + if (s.is_string()) { + auto server = dns->add_nameservers(); + *server = s; + } } + n->set_allocated_dns(dns); } - n->set_allocated_dns(dns); - } - n->set_sso_enabled(j.value("ssoEnabled", false)); - if (j.value("ssoEnabled", false)) { - n->set_sso_provider(j.value("provider", "")); - n->set_sso_client_id(j.value("clientId", "")); - n->set_sso_authorization_endpoint(j.value("authorizationEndpoint", "")); - n->set_sso_issuer(j.value("issuer", "")); - n->set_sso_provider(j.value("provider", "")); - } + n->set_sso_enabled(j.value("ssoEnabled", false)); + if (j.value("ssoEnabled", false)) { + n->set_sso_provider(j.value("provider", "")); + n->set_sso_client_id(j.value("clientId", "")); + n->set_sso_authorization_endpoint(j.value("authorizationEndpoint", "")); + n->set_sso_issuer(j.value("issuer", "")); + n->set_sso_provider(j.value("provider", "")); + } - n->set_rules_source(""); + n->set_rules_source(j.value("rulesSource", "")); + } + catch (const std::exception& e) { + fprintf(stderr, "Exception parsing network JSON: %s\n", e.what()); + delete n; + return nullptr; + } return n; } @@ -240,34 +247,41 @@ pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) } pbmessages::MemberChange_Member* m = new pbmessages::MemberChange_Member(); - m->set_network_id(j.value("networkId", "")); - m->set_device_id(j.value("id", "")); - m->set_identity(j.value("identity", "")); - m->set_authorized(j.value("authorized", false)); - for (const auto& addr : j.value("ipAssignments", nlohmann::json::array())) { - if (addr.is_string()) { - auto a = m->add_ip_assignments(); - *a = addr; + try { + m->set_network_id(j.value("networkId", "")); + m->set_device_id(j.value("id", "")); + m->set_identity(j.value("identity", "")); + m->set_authorized(j.value("authorized", false)); + for (const auto& addr : j.value("ipAssignments", nlohmann::json::array())) { + if (addr.is_string()) { + auto a = m->add_ip_assignments(); + *a = addr; + } } + m->set_active_bridge(j.value("activeBridge", false)); + m->set_tags(OSUtils::jsonDump(j.value("tags", "[]"), -1)); + m->set_capabilities(OSUtils::jsonDump(j.value("capabilities", "[]"), -1)); + m->set_creation_time(j.value("creationTime", 0)); + m->set_no_auto_assign_ips(j.value("noAutoAssignIps", false)); + m->set_revision(j.value("revision", 0)); + m->set_last_authorized_time(j.value("lastAuthorizedTime", 0)); + m->set_last_deauthorized_time(j.value("lastDeauthorizedTime", 0)); + m->set_last_authorized_credential_type(j.value("lastAuthorizedCredentialType", nullptr)); + m->set_last_authorized_credential(j.value("lastAuthorizedCredential", nullptr)); + m->set_version_major(j.value("versionMajor", 0)); + m->set_version_minor(j.value("versionMinor", 0)); + m->set_version_rev(j.value("versionRev", 0)); + m->set_version_protocol(j.value("versionProtocol", 0)); + m->set_remote_trace_level(j.value("remoteTraceLevel", 0)); + m->set_remote_trace_target(j.value("remoteTraceTarget", "")); + m->set_sso_exempt(j.value("ssoExempt", false)); + m->set_auth_expiry_time(j.value("authExpiryTime", 0)); + } + catch (const std::exception& e) { + fprintf(stderr, "Exception parsing member JSON: %s\n", e.what()); + delete m; + return nullptr; } - m->set_active_bridge(j.value("activeBridge", false)); - m->set_tags(OSUtils::jsonDump(j.value("tags", "[]"), -1)); - m->set_capabilities(OSUtils::jsonDump(j.value("capabilities", "[]"), -1)); - m->set_creation_time(j.value("creationTime", 0)); - m->set_no_auto_assign_ips(j.value("noAutoAssignIps", false)); - m->set_revision(j.value("revision", 0)); - m->set_last_authorized_time(j.value("lastAuthorizedTime", 0)); - m->set_last_deauthorized_time(j.value("lastDeauthorizedTime", 0)); - m->set_last_authorized_credential_type(j.value("lastAuthorizedCredentialType", nullptr)); - m->set_last_authorized_credential(j.value("lastAuthorizedCredential", nullptr)); - m->set_version_major(j.value("versionMajor", 0)); - m->set_version_minor(j.value("versionMinor", 0)); - m->set_version_rev(j.value("versionRev", 0)); - m->set_version_protocol(j.value("versionProtocol", 0)); - m->set_remote_trace_level(j.value("remoteTraceLevel", 0)); - m->set_remote_trace_target(j.value("remoteTraceTarget", "")); - m->set_sso_exempt(j.value("ssoExempt", false)); - m->set_auth_expiry_time(j.value("authExpiryTime", 0)); return m; } From 02908e5202b1386cd94bf2f5737bde722487ac88 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 30 Sep 2025 10:52:00 -0700 Subject: [PATCH 132/245] stray ` got in there --- nonfree/controller/PubSubListener.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 7ec59b5ed4..dde85c7405 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -56,7 +56,7 @@ PubSubListener::PubSubListener(std::string controller_id, std::string project, s _subscriberThread = std::thread(&PubSubListener::subscribe, this); } -PubSubListener::~PubSubListener()` +PubSubListener::~PubSubListener() { _run = false; if (_subscriberThread.joinable()) { From 20a67ab1de85dffa98d7de6c3b83bb2f624f834c Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 1 Oct 2025 08:06:40 -0700 Subject: [PATCH 133/245] fix attempted null -> string conversion --- nonfree/controller/CentralDB.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 177b97da4e..1fa82b965a 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -680,6 +680,7 @@ void CentralDB::initializeNetworks() std::optional created_at = std::get<3>(row); std::optional last_modified = std::get<4>(row); std::optional revision = std::get<5>(row); + std::string frontend = std::get<6>(row); config["id"] = nwid; config["name"] = name; @@ -717,12 +718,17 @@ void CentralDB::initializeNetworks() config["v6AssignMode"]["rfc4193"] = false; } config["ssoEnabled"] = cfgtmp["ssoEnabled"].is_boolean() ? cfgtmp["ssoEnabled"].get() : false; + if (config["ssoConfig"].is_object()) { + config["ssoConfig"] = cfgtmp["ssoConfig"]; + } + else { + config["ssoConfig"] = empty; + } config["objtype"] = "network"; config["routes"] = cfgtmp["routes"].is_array() ? cfgtmp["routes"] : json::array(); config["clientId"] = cfgtmp["clientId"].is_string() ? cfgtmp["clientId"].get() : ""; - config["authorizationEndpoint"] = cfgtmp["authorizationEndpoint"].is_string() - ? cfgtmp["authorizationEndpoint"].get() - : nullptr; + config["authorizationEndpoint"] = + cfgtmp["authorizationEndpoint"].is_string() ? cfgtmp["authorizationEndpoint"].get() : ""; config["provider"] = cfgtmp["ssoProvider"].is_string() ? cfgtmp["ssoProvider"].get() : ""; if (! cfgtmp["dns"].is_object()) { cfgtmp["dns"] = json::object(); @@ -734,7 +740,7 @@ void CentralDB::initializeNetworks() } config["ipAssignmentPools"] = cfgtmp["ipAssignmentPools"].is_array() ? cfgtmp["ipAssignmentPools"] : json::array(); - config["frontend"] = std::get<6>(row); + config["frontend"] = frontend; Metrics::network_count++; @@ -742,7 +748,7 @@ void CentralDB::initializeNetworks() auto end = std::chrono::high_resolution_clock::now(); auto dur = std::chrono::duration_cast(end - start); - ; + total += dur.count(); ++count; if (count > 0 && count % 10000 == 0) { From b4f018b918c7b1bc5d18a6be1577aba6e0fa5b75 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 1 Oct 2025 09:07:08 -0700 Subject: [PATCH 134/245] debug output from parsing pubsub messages --- nonfree/controller/PubSubListener.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index dde85c7405..2a7402a608 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -133,7 +133,7 @@ void PubSubNetworkListener::onNotification(const std::string& payload) span->SetStatus(opentelemetry::trace::StatusCode::kError, "Failed to parse protobuf"); return; } - + fprintf(stderr, "PubSubNetworkListener: parsed protobuf message. %s\n", nc.DebugString().c_str()); fprintf(stderr, "Network notification received\n"); try { @@ -212,7 +212,7 @@ void PubSubMemberListener::onNotification(const std::string& payload) span->SetStatus(opentelemetry::trace::StatusCode::kError, "Failed to parse protobuf"); return; } - + fprintf(stderr, "PubSubMemberListener: parsed protobuf message. %s\n", mc.DebugString().c_str()); fprintf(stderr, "Member notification received"); try { @@ -318,7 +318,10 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N pool["ipRangeEnd"] = p.end_ip(); pools.push_back(pool); } - out["assignmentPools"] = pools; + out["ipAssignmentPools"] = pools; + } + else { + out["ipAssignmentPools"] = nlohmann::json::array(); } if (nc.routes_size() > 0) { @@ -343,6 +346,9 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N } dns["servers"] = servers; } + else { + dns["servers"] = nlohmann::json::array(); + } dns["domain"] = nc.dns().domain(); out["dns"] = dns; From f028213c7f68a869022beca6a75fdd7553ed6470 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 1 Oct 2025 12:40:50 -0700 Subject: [PATCH 135/245] debug output --- nonfree/controller/CentralDB.cpp | 7 ++++--- nonfree/controller/PubSubListener.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 1fa82b965a..10d0618f30 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -314,12 +314,13 @@ bool CentralDB::save(nlohmann::json& record, bool notifyListeners) } const std::string objtype = record["objtype"]; if (objtype == "network") { - // fprintf(stderr, "network save\n"); + fprintf(stderr, "CentralDB network save %s\n", record["id"].get().c_str()); const uint64_t nwid = OSUtils::jsonIntHex(record["id"], 0ULL); if (nwid) { nlohmann::json old; get(nwid, old); if ((! old.is_object()) || (! _compareRecords(old, record))) { + fprintf(stderr, "posting network change to commit queue\n"); record["revision"] = OSUtils::jsonInt(record["revision"], 0ULL) + 1ULL; _commitQueue.post(std::pair(record, notifyListeners)); modified = true; @@ -331,12 +332,12 @@ bool CentralDB::save(nlohmann::json& record, bool notifyListeners) std::string memberId = record["id"]; const uint64_t nwid = OSUtils::jsonIntHex(record["nwid"], 0ULL); const uint64_t id = OSUtils::jsonIntHex(record["id"], 0ULL); - // fprintf(stderr, "member save %s-%s\n", networkId.c_str(), memberId.c_str()); + fprintf(stderr, "member save %s-%s\n", networkId.c_str(), memberId.c_str()); if ((id) && (nwid)) { nlohmann::json network, old; get(nwid, network, id, old); if ((! old.is_object()) || (! _compareRecords(old, record))) { - // fprintf(stderr, "commit queue post\n"); + fprintf(stderr, "posting member change to commit queue\n"); record["revision"] = OSUtils::jsonInt(record["revision"], 0ULL) + 1ULL; _commitQueue.post(std::pair(record, notifyListeners)); modified = true; diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 2a7402a608..3e313dfe8c 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -140,13 +140,22 @@ void PubSubNetworkListener::onNotification(const std::string& payload) nlohmann::json oldConfig, newConfig; if (nc.has_old()) { + fprintf(stderr, "has old network config\n"); oldConfig = toJson(nc.old(), nc.change_source()); } if (nc.has_new_()) { + fprintf(stderr, "has new network config\n"); newConfig = toJson(nc.new_(), nc.change_source()); } + if (! nc.has_old() && ! nc.has_new_()) { + fprintf(stderr, "NetworkChange message has no old or new network config\n"); + span->SetAttribute("error", "NetworkChange message has no old or new network config"); + span->SetStatus(opentelemetry::trace::StatusCode::kError, "No old or new config"); + return; + } + if (oldConfig.is_object() && newConfig.is_object()) { // network modification std::string nwid = oldConfig["id"].get(); @@ -186,6 +195,13 @@ void PubSubNetworkListener::onNotification(const std::string& payload) span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); return; } + catch (...) { + fprintf(stderr, "PubSubNetworkListener Unknown exception in PubSubNetworkListener\n"); + span->SetAttribute("error", "Unknown exception in PubSubNetworkListener"); + span->SetStatus(opentelemetry::trace::StatusCode::kError, "Unknown exception"); + return; + } + fprintf(stderr, "PubSubNetworkListener onNotification complete\n"); } PubSubMemberListener::PubSubMemberListener(std::string controller_id, std::string project, std::string topic, DB* db) @@ -220,13 +236,22 @@ void PubSubMemberListener::onNotification(const std::string& payload) nlohmann::json oldConfig, newConfig; if (mc.has_old()) { + fprintf(stderr, "has old member config\n"); oldConfig = toJson(mc.old(), mc.change_source()); } if (mc.has_new_()) { + fprintf(stderr, "has new member config\n"); newConfig = toJson(mc.new_(), mc.change_source()); } + if (! mc.has_old() && ! mc.has_new_()) { + fprintf(stderr, "MemberChange message has no old or new member config\n"); + span->SetAttribute("error", "MemberChange message has no old or new member config"); + span->SetStatus(opentelemetry::trace::StatusCode::kError, "No old or new config"); + return; + } + if (oldConfig.is_object() && newConfig.is_object()) { // member modification std::string memberID = oldConfig["id"].get(); From dad1a1eda623df3043b8b3c50cf6c648a2fd8176 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 1 Oct 2025 13:12:45 -0700 Subject: [PATCH 136/245] more logging --- nonfree/controller/CentralDB.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 10d0618f30..43fba7647a 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1146,11 +1146,13 @@ void CentralDB::commitThread() // fprintf(stderr, "%s: commitThread: member\n", _myAddressStr.c_str()); std::string memberId; std::string networkId; + try { pqxx::work w(*c->c); memberId = config["id"]; networkId = config["nwid"]; + fprintf(stderr, "commit member %s-%s\n", networkId.c_str(), memberId.c_str()); std::string target = "NULL"; if (! config["remoteTraceTarget"].is_null()) { @@ -1308,6 +1310,7 @@ void CentralDB::commitThread() pqxx::work w(*c->c); std::string id = config["id"]; + fprintf(stderr, "commit network %s\n", id.c_str()); pqxx::row nwrow = w.exec("SELECT COUNT(id) frontend FROM networks_ctl WHERE id = $1", pqxx::params { id }) @@ -1451,6 +1454,8 @@ void CentralDB::commitThread() std::string memberId = config["id"]; std::string networkId = config["nwid"]; + fprintf(stderr, "Deleting member %s-%s\n", networkId.c_str(), memberId.c_str()); + pqxx::result res = w.exec( "DELETE FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", From aecd7fdace0daba0d949885029adf707da668671 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 1 Oct 2025 13:13:58 -0700 Subject: [PATCH 137/245] more logging --- nonfree/controller/CentralDB.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 43fba7647a..92d5fe9a4a 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1115,7 +1115,7 @@ void CentralDB::commitThread() auto span = tracer->StartSpan("CentralDB::commitThread"); auto scope = tracer->WithActiveSpan(span); - // fprintf(stderr, "commitThread tick\n"); + fprintf(stderr, "commitThread tick\n"); if (! qitem.first.is_object()) { fprintf(stderr, "not an object\n"); continue; From 1f557b516f47111c3b9dda5082f872a60b4788eb Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 1 Oct 2025 13:30:25 -0700 Subject: [PATCH 138/245] more debug output --- nonfree/controller/CentralDB.cpp | 2 +- nonfree/controller/PubSubWriter.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 92d5fe9a4a..a360f1f7be 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1583,7 +1583,7 @@ void CentralDB::onlineNotificationThread() std::vector osArchSplit = split(osArch, '/'); std::string os = "unknown"; std::string arch = "unknown"; - std::string frontend = member["frontend"].get(); + std::string frontend = network["frontend"].get(); int vMajor = OSUtils::jsonInt(member["vMajor"], 0); int vMinor = OSUtils::jsonInt(member["vMinor"], 0); diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index ee9ba8bd92..e389df7263 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -246,6 +246,8 @@ pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) return nullptr; } + fprintf(stderr, "memberFromJSON: %s\n", j.dump().c_str()); + pbmessages::MemberChange_Member* m = new pbmessages::MemberChange_Member(); try { m->set_network_id(j.value("networkId", "")); From 7faf705e10b026135ed69e291c42bc1eecd7c610 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 1 Oct 2025 13:33:02 -0700 Subject: [PATCH 139/245] make the default an empty array here --- nonfree/controller/PubSubWriter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index e389df7263..3ca9609255 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -261,8 +261,8 @@ pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) } } m->set_active_bridge(j.value("activeBridge", false)); - m->set_tags(OSUtils::jsonDump(j.value("tags", "[]"), -1)); - m->set_capabilities(OSUtils::jsonDump(j.value("capabilities", "[]"), -1)); + m->set_tags(OSUtils::jsonDump(j.value("tags", nlohmann::json::array()), -1)); + m->set_capabilities(OSUtils::jsonDump(j.value("capabilities", nlohmann::json::array()), -1)); m->set_creation_time(j.value("creationTime", 0)); m->set_no_auto_assign_ips(j.value("noAutoAssignIps", false)); m->set_revision(j.value("revision", 0)); From 80f82132dd45e073a81a77e3eafd870505987624 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 1 Oct 2025 14:00:17 -0700 Subject: [PATCH 140/245] fix tags/capabilities? --- nonfree/controller/PubSubWriter.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index 3ca9609255..95561d088a 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -261,8 +261,26 @@ pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) } } m->set_active_bridge(j.value("activeBridge", false)); - m->set_tags(OSUtils::jsonDump(j.value("tags", nlohmann::json::array()), -1)); - m->set_capabilities(OSUtils::jsonDump(j.value("capabilities", nlohmann::json::array()), -1)); + if (j["tags"].is_array()) { + nlohmann::json tags = j["tags"]; + std::string tagsStr = OSUtils::jsonDump(tags, -1); + m->set_tags(tagsStr); + } + else { + nlohmann::json tags = nlohmann::json::array(); + std::string tagsStr = OSUtils::jsonDump(tags, -1); + m->set_tags(tagsStr); + } + if (j["capabilities"].is_array()) { + nlohmann::json caps = j["capabilities"]; + std::string capsStr = OSUtils::jsonDump(caps, -1); + m->set_capabilities(capsStr); + } + else { + nlohmann::json caps = nlohmann::json::array(); + std::string capsStr = OSUtils::jsonDump(caps, -1); + m->set_capabilities(capsStr); + } m->set_creation_time(j.value("creationTime", 0)); m->set_no_auto_assign_ips(j.value("noAutoAssignIps", false)); m->set_revision(j.value("revision", 0)); From a8b5c89efac0a2192987db123a3375709aedb22d Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 1 Oct 2025 15:05:34 -0700 Subject: [PATCH 141/245] think this is where things are crashing, but I'm not sure why yet. Comment it out to make sure --- nonfree/controller/PubSubWriter.cpp | 40 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index 95561d088a..a91c83f30b 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -261,26 +261,26 @@ pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) } } m->set_active_bridge(j.value("activeBridge", false)); - if (j["tags"].is_array()) { - nlohmann::json tags = j["tags"]; - std::string tagsStr = OSUtils::jsonDump(tags, -1); - m->set_tags(tagsStr); - } - else { - nlohmann::json tags = nlohmann::json::array(); - std::string tagsStr = OSUtils::jsonDump(tags, -1); - m->set_tags(tagsStr); - } - if (j["capabilities"].is_array()) { - nlohmann::json caps = j["capabilities"]; - std::string capsStr = OSUtils::jsonDump(caps, -1); - m->set_capabilities(capsStr); - } - else { - nlohmann::json caps = nlohmann::json::array(); - std::string capsStr = OSUtils::jsonDump(caps, -1); - m->set_capabilities(capsStr); - } + // if (j["tags"].is_array()) { + // nlohmann::json tags = j["tags"]; + // std::string tagsStr = OSUtils::jsonDump(tags, -1); + // m->set_tags(tagsStr); + // } + // else { + // nlohmann::json tags = nlohmann::json::array(); + // std::string tagsStr = OSUtils::jsonDump(tags, -1); + // m->set_tags(tagsStr); + // } + // if (j["capabilities"].is_array()) { + // nlohmann::json caps = j["capabilities"]; + // std::string capsStr = OSUtils::jsonDump(caps, -1); + // m->set_capabilities(capsStr); + // } + // else { + // nlohmann::json caps = nlohmann::json::array(); + // std::string capsStr = OSUtils::jsonDump(caps, -1); + // m->set_capabilities(capsStr); + // } m->set_creation_time(j.value("creationTime", 0)); m->set_no_auto_assign_ips(j.value("noAutoAssignIps", false)); m->set_revision(j.value("revision", 0)); From fb7536959774f8ac106894cb181f32d8331685d8 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 1 Oct 2025 16:08:06 -0700 Subject: [PATCH 142/245] throwing stuff at the wall cuz I can't actually debug this right now --- nonfree/controller/PubSubWriter.cpp | 111 +++++++++++++++++----------- 1 file changed, 67 insertions(+), 44 deletions(-) diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index a91c83f30b..b7128220f9 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -17,9 +17,9 @@ namespace pubsub = ::google::cloud::pubsub; namespace ZeroTier { -pbmessages::NetworkChange +pbmessages::NetworkChange* networkChangeFromJson(std::string controllerID, const nlohmann::json& oldNetwork, const nlohmann::json& newNetwork); -pbmessages::MemberChange +pbmessages::MemberChange* memberChangeFromJson(std::string controllerID, const nlohmann::json& oldMember, const nlohmann::json& newMember); PubSubWriter::PubSubWriter(std::string project, std::string topic, std::string controller_id) @@ -53,6 +53,7 @@ PubSubWriter::~PubSubWriter() bool PubSubWriter::publishMessage(const std::string& payload, const std::string& frontend) { + fprintf(stderr, "Publishing message to %s\n", _topic.c_str()); std::vector > attributes; attributes.emplace_back("controller_id", _controller_id); @@ -76,13 +77,15 @@ bool PubSubWriter::publishNetworkChange( const nlohmann::json& newNetwork, const std::string& frontend) { - pbmessages::NetworkChange nc = networkChangeFromJson(_controller_id, oldNetwork, newNetwork); + fprintf(stderr, "Publishing network change\n"); + pbmessages::NetworkChange* nc = networkChangeFromJson(_controller_id, oldNetwork, newNetwork); std::string payload; - if (! nc.SerializeToString(&payload)) { + if (! nc->SerializeToString(&payload)) { fprintf(stderr, "Failed to serialize NetworkChange protobuf message\n"); + delete nc; return false; } - + delete nc; return publishMessage(payload, frontend); } @@ -91,13 +94,16 @@ bool PubSubWriter::publishMemberChange( const nlohmann::json& newMember, const std::string& frontend) { - pbmessages::MemberChange mc = memberChangeFromJson(_controller_id, oldMember, newMember); + fprintf(stderr, "Publishing member change\n"); + pbmessages::MemberChange* mc = memberChangeFromJson(_controller_id, oldMember, newMember); std::string payload; - if (! mc.SerializeToString(&payload)) { + if (! mc->SerializeToString(&payload)) { fprintf(stderr, "Failed to serialize MemberChange protobuf message\n"); + delete mc; return false; } + delete mc; return publishMessage(payload, frontend); } @@ -224,18 +230,19 @@ pbmessages::NetworkChange_Network* networkFromJson(const nlohmann::json& j) return n; } -pbmessages::NetworkChange +pbmessages::NetworkChange* networkChangeFromJson(std::string controllerID, const nlohmann::json& oldNetwork, const nlohmann::json& newNetwork) { - pbmessages::NetworkChange nc; - nc.set_allocated_old(networkFromJson(oldNetwork)); - nc.set_allocated_new_(networkFromJson(newNetwork)); - nc.set_change_source(pbmessages::NetworkChange_ChangeSource::NetworkChange_ChangeSource_CONTROLLER); + pbmessages::NetworkChange* nc = new pbmessages::NetworkChange(); + + nc->set_allocated_old(networkFromJson(oldNetwork)); + nc->set_allocated_new_(networkFromJson(newNetwork)); + nc->set_change_source(pbmessages::NetworkChange_ChangeSource::NetworkChange_ChangeSource_CONTROLLER); pbmessages::NetworkChange_NetworkChangeMetadata* metadata = new pbmessages::NetworkChange_NetworkChangeMetadata(); metadata->set_controller_id(controllerID); metadata->set_trace_id(""); // TODO: generate a trace ID - nc.set_allocated_metadata(metadata); + nc->set_allocated_metadata(metadata); return nc; } @@ -243,6 +250,7 @@ networkChangeFromJson(std::string controllerID, const nlohmann::json& oldNetwork pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) { if (! j.is_object()) { + fprintf(stderr, "memberFromJson: JSON is not an object\n"); return nullptr; } @@ -254,33 +262,40 @@ pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) m->set_device_id(j.value("id", "")); m->set_identity(j.value("identity", "")); m->set_authorized(j.value("authorized", false)); - for (const auto& addr : j.value("ipAssignments", nlohmann::json::array())) { - if (addr.is_string()) { - auto a = m->add_ip_assignments(); - *a = addr; + if (j["ipAssignments"].is_array()) { + fprintf(stderr, "memberFromJSON: has ipAssignments\n"); + for (const auto& addr : j["ipAssignments"]) { + if (addr.is_string()) { + auto a = m->add_ip_assignments(); + std::string address = addr.get(); + *a = address; + } } } + else { + fprintf(stderr, "memberFromJSON: no ipAssignments\n"); + } m->set_active_bridge(j.value("activeBridge", false)); - // if (j["tags"].is_array()) { - // nlohmann::json tags = j["tags"]; - // std::string tagsStr = OSUtils::jsonDump(tags, -1); - // m->set_tags(tagsStr); - // } - // else { - // nlohmann::json tags = nlohmann::json::array(); - // std::string tagsStr = OSUtils::jsonDump(tags, -1); - // m->set_tags(tagsStr); - // } - // if (j["capabilities"].is_array()) { - // nlohmann::json caps = j["capabilities"]; - // std::string capsStr = OSUtils::jsonDump(caps, -1); - // m->set_capabilities(capsStr); - // } - // else { - // nlohmann::json caps = nlohmann::json::array(); - // std::string capsStr = OSUtils::jsonDump(caps, -1); - // m->set_capabilities(capsStr); - // } + if (j["tags"].is_array()) { + nlohmann::json tags = j["tags"]; + std::string tagsStr = OSUtils::jsonDump(tags, -1); + m->set_tags(tagsStr); + } + else { + nlohmann::json tags = nlohmann::json::array(); + std::string tagsStr = OSUtils::jsonDump(tags, -1); + m->set_tags(tagsStr); + } + if (j["capabilities"].is_array()) { + nlohmann::json caps = j["capabilities"]; + std::string capsStr = OSUtils::jsonDump(caps, -1); + m->set_capabilities(capsStr); + } + else { + nlohmann::json caps = nlohmann::json::array(); + std::string capsStr = OSUtils::jsonDump(caps, -1); + m->set_capabilities(capsStr); + } m->set_creation_time(j.value("creationTime", 0)); m->set_no_auto_assign_ips(j.value("noAutoAssignIps", false)); m->set_revision(j.value("revision", 0)); @@ -302,22 +317,30 @@ pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) delete m; return nullptr; } - + fprintf(stderr, "memberFromJSON complete\n"); return m; } -pbmessages::MemberChange +pbmessages::MemberChange* memberChangeFromJson(std::string controllerID, const nlohmann::json& oldMember, const nlohmann::json& newMember) { - pbmessages::MemberChange mc; - mc.set_allocated_old(memberFromJson(oldMember)); - mc.set_allocated_new_(memberFromJson(newMember)); - mc.set_change_source(pbmessages::MemberChange_ChangeSource::MemberChange_ChangeSource_CONTROLLER); + fprintf(stderr, "memberrChangeFromJson: old: %s\n", oldMember.dump().c_str()); + fprintf(stderr, "memberrChangeFromJson: new: %s\n", newMember.dump().c_str()); + pbmessages::MemberChange* mc = new pbmessages::MemberChange(); + pbmessages::MemberChange_Member* om = memberFromJson(oldMember); + if (om != nullptr) { + mc->set_allocated_old(om); + } + pbmessages::MemberChange_Member* nm = memberFromJson(newMember); + if (nm != nullptr) { + mc->set_allocated_new_(nm); + } + mc->set_change_source(pbmessages::MemberChange_ChangeSource::MemberChange_ChangeSource_CONTROLLER); pbmessages::MemberChange_MemberChangeMetadata* metadata = new pbmessages::MemberChange_MemberChangeMetadata(); metadata->set_controller_id(controllerID); metadata->set_trace_id(""); // TODO: generate a trace ID - mc.set_allocated_metadata(metadata); + mc->set_allocated_metadata(metadata); return mc; } From 3bbf19459455668cb8727ca84b2dca70ecaa1ddd Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 1 Oct 2025 16:25:27 -0700 Subject: [PATCH 143/245] pubsub writer should work now --- nonfree/controller/PubSubWriter.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index b7128220f9..21c2a6cfa4 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -275,42 +275,67 @@ pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) else { fprintf(stderr, "memberFromJSON: no ipAssignments\n"); } + fprintf(stderr, "ipAssignments set\n"); m->set_active_bridge(j.value("activeBridge", false)); + fprintf(stderr, "activeBridge set\n"); if (j["tags"].is_array()) { + fprintf(stderr, "memberFromJSON: has tags\n"); nlohmann::json tags = j["tags"]; std::string tagsStr = OSUtils::jsonDump(tags, -1); m->set_tags(tagsStr); + fprintf(stderr, "tags set\n"); } else { + fprintf(stderr, "memberFromJSON: no tags\n"); nlohmann::json tags = nlohmann::json::array(); std::string tagsStr = OSUtils::jsonDump(tags, -1); m->set_tags(tagsStr); + fprintf(stderr, "tags set\n"); } if (j["capabilities"].is_array()) { + fprintf(stderr, "memberFromJSON: has capabilities\n"); nlohmann::json caps = j["capabilities"]; std::string capsStr = OSUtils::jsonDump(caps, -1); m->set_capabilities(capsStr); + fprintf(stderr, "capabilities set\n"); } else { + fprintf(stderr, "memberFromJSON: no capabilities\n"); nlohmann::json caps = nlohmann::json::array(); std::string capsStr = OSUtils::jsonDump(caps, -1); m->set_capabilities(capsStr); + fprintf(stderr, "capabilities set\n"); } m->set_creation_time(j.value("creationTime", 0)); + fprintf(stderr, "creationTime set\n"); m->set_no_auto_assign_ips(j.value("noAutoAssignIps", false)); + fprintf(stderr, "noAutoAssignIps set\n"); m->set_revision(j.value("revision", 0)); + fprintf(stderr, "revision set\n"); m->set_last_authorized_time(j.value("lastAuthorizedTime", 0)); + fprintf(stderr, "lastAuthorizedTime set\n"); m->set_last_deauthorized_time(j.value("lastDeauthorizedTime", 0)); - m->set_last_authorized_credential_type(j.value("lastAuthorizedCredentialType", nullptr)); - m->set_last_authorized_credential(j.value("lastAuthorizedCredential", nullptr)); + fprintf(stderr, "lastDeauthorizedTime set\n"); + m->set_last_authorized_credential_type(j.value("lastAuthorizedCredentialType", "")); + fprintf(stderr, "lastAuthorizedCredentialType set\n"); + m->set_last_authorized_credential(j.value("lastAuthorizedCredential", "")); + fprintf(stderr, "lastAuthorizedCredential set\n"); m->set_version_major(j.value("versionMajor", 0)); + fprintf(stderr, "versionMajor set\n"); m->set_version_minor(j.value("versionMinor", 0)); + fprintf(stderr, "versionMinor set\n"); m->set_version_rev(j.value("versionRev", 0)); + fprintf(stderr, "versionRev set\n"); m->set_version_protocol(j.value("versionProtocol", 0)); + fprintf(stderr, "versionProtocol set\n"); m->set_remote_trace_level(j.value("remoteTraceLevel", 0)); + fprintf(stderr, "remoteTraceLevel set\n"); m->set_remote_trace_target(j.value("remoteTraceTarget", "")); + fprintf(stderr, "remoteTraceTarget set\n"); m->set_sso_exempt(j.value("ssoExempt", false)); + fprintf(stderr, "ssoExempt set\n"); m->set_auth_expiry_time(j.value("authExpiryTime", 0)); + fprintf(stderr, "authExpiryTime set\n"); } catch (const std::exception& e) { fprintf(stderr, "Exception parsing member JSON: %s\n", e.what()); From 0d21250b6232308cfe116c7455c23788ee6a2c43 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 1 Oct 2025 16:33:17 -0700 Subject: [PATCH 144/245] one last json parsing fix --- nonfree/controller/CentralDB.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index a360f1f7be..b3d1338c60 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1583,7 +1583,7 @@ void CentralDB::onlineNotificationThread() std::vector osArchSplit = split(osArch, '/'); std::string os = "unknown"; std::string arch = "unknown"; - std::string frontend = network["frontend"].get(); + std::string frontend = OSUtils::jsonString(network["frontend"], ""); int vMajor = OSUtils::jsonInt(member["vMajor"], 0); int vMinor = OSUtils::jsonInt(member["vMinor"], 0); From 4861b7df1ec28529a04ffe294279ab5fe0363217 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 1 Oct 2025 17:18:31 -0700 Subject: [PATCH 145/245] one last json parsing fix. but really this time --- nonfree/controller/PubSubWriter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index 21c2a6cfa4..ae7dcf0017 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -316,9 +316,9 @@ pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) fprintf(stderr, "lastAuthorizedTime set\n"); m->set_last_deauthorized_time(j.value("lastDeauthorizedTime", 0)); fprintf(stderr, "lastDeauthorizedTime set\n"); - m->set_last_authorized_credential_type(j.value("lastAuthorizedCredentialType", "")); + m->set_last_authorized_credential_type(OSUtils::jsonString(j["lastAuthorizedCredentialType"], "")); fprintf(stderr, "lastAuthorizedCredentialType set\n"); - m->set_last_authorized_credential(j.value("lastAuthorizedCredential", "")); + m->set_last_authorized_credential(OSUtils::jsonString(j["lastAuthorizedCredential"], "")); fprintf(stderr, "lastAuthorizedCredential set\n"); m->set_version_major(j.value("versionMajor", 0)); fprintf(stderr, "versionMajor set\n"); @@ -330,7 +330,7 @@ pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) fprintf(stderr, "versionProtocol set\n"); m->set_remote_trace_level(j.value("remoteTraceLevel", 0)); fprintf(stderr, "remoteTraceLevel set\n"); - m->set_remote_trace_target(j.value("remoteTraceTarget", "")); + m->set_remote_trace_target(OSUtils::jsonString(j["remoteTraceTarget"], "")); fprintf(stderr, "remoteTraceTarget set\n"); m->set_sso_exempt(j.value("ssoExempt", false)); fprintf(stderr, "ssoExempt set\n"); From a75d06ad64af6d55d37ec22ef625f99f369bddda Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 2 Oct 2025 11:35:03 -0700 Subject: [PATCH 146/245] cleaning up some gross JSON code --- nonfree/controller/PubSubWriter.cpp | 138 +++++++++++++--------------- 1 file changed, 63 insertions(+), 75 deletions(-) diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index ae7dcf0017..d5193ab285 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -151,53 +151,69 @@ pbmessages::NetworkChange_Network* networkFromJson(const nlohmann::json& j) pbmessages::NetworkChange_Network* n = new pbmessages::NetworkChange_Network(); try { - n->set_network_id(j.value("id", "")); - n->set_name(j.value("name", "")); + n->set_network_id(OSUtils::jsonString(j["id"], "")); + n->set_name(OSUtils::jsonString(j["name"], "")); n->set_capabilities(OSUtils::jsonDump(j.value("capabilities", "[]"), -1)); - n->set_creation_time(j.value("creationTime", 0)); - n->set_enable_broadcast(j.value("enableBroadcast", false)); + n->set_creation_time(OSUtils::jsonInt(j["creationTime"], 0)); + n->set_enable_broadcast(OSUtils::jsonBool(j["enableBroadcast"], false)); for (const auto& p : j["ipAssignmentPools"]) { if (p.is_object()) { auto pool = n->add_assignment_pools(); - pool->set_start_ip(p.value("ipRangeStart", "")); - pool->set_end_ip(p.value("ipRangeEnd", "")); + pool->set_start_ip(OSUtils::jsonString(p["ipRangeStart"], "")); + pool->set_end_ip(OSUtils::jsonString(p["ipRangeEnd"], "")); } } - n->set_mtu(j.value("mtu", 2800)); - n->set_multicast_limit(j.value("multicastLimit", 32)); - n->set_is_private(j.value("private", true)); - n->set_remote_trace_level(j.value("remoteTraceLevel", 0)); - n->set_remote_trace_target(j.value("remoteTraceTarget", "")); - n->set_revision(j.value("revision", 0)); + n->set_mtu(OSUtils::jsonInt(j["mtu"], 2800)); + n->set_multicast_limit(OSUtils::jsonInt(j["multicastLimit"], 32)); + n->set_is_private(OSUtils::jsonBool(j["private"], true)); + n->set_remote_trace_level(OSUtils::jsonInt(j["remoteTraceLevel"], 0)); + n->set_remote_trace_target(OSUtils::jsonString(j["remoteTraceTarget"], "")); + n->set_revision(OSUtils::jsonInt(j["revision"], 0)); for (const auto& p : j["routes"]) { if (p.is_object()) { auto r = n->add_routes(); - r->set_target(p.value("target", "")); - r->set_via(p.value("via", "")); + r->set_target(OSUtils::jsonString(p["target"], "")); + r->set_via(OSUtils::jsonString(p["via"], "")); } } + std::string rules; + if (j["rules"].is_array()) { + rules = OSUtils::jsonDump(j["rules"], -1); + } + else { + rules = "[]"; + } + n->set_rules(rules); - n->set_rules(""); - n->set_tags(OSUtils::jsonDump(j.value("tags", "[]"), -1)); + std::string tags; + if (j["tags"].is_array()) { + tags = OSUtils::jsonDump(j["tags"], -1); + } + else { + tags = "[]"; + } + n->set_tags(tags); pbmessages::NetworkChange_IPV4AssignMode* v4am = new pbmessages::NetworkChange_IPV4AssignMode(); if (j["v4AssignMode"].is_object()) { - v4am->set_zt(j["v4AssignMode"].value("zt", false)); + nlohmann::json am = j["v4AssignMode"]; + v4am->set_zt(OSUtils::jsonBool(am["zt"], false)); } n->set_allocated_ipv4_assign_mode(v4am); pbmessages::NetworkChange_IPV6AssignMode* v6am = new pbmessages::NetworkChange_IPV6AssignMode(); if (j["v6AssignMode"].is_object()) { - v6am->set_zt(j["v6AssignMode"].value("zt", false)); - v6am->set_six_plane(j["v6AssignMode"].value("6plane", false)); - v6am->set_rfc4193(j["v6AssignMode"].value("rfc4193", false)); + nlohmann::json am = j["v6AssignMode"]; + v6am->set_zt(OSUtils::jsonBool(am["zt"], false)); + v6am->set_six_plane(OSUtils::jsonBool(am["6plane"], false)); + v6am->set_rfc4193(OSUtils::jsonBool(am["rfc4193"], false)); } n->set_allocated_ipv6_assign_mode(v6am); - nlohmann::json jdns = j.value("dns", nullptr); + nlohmann::json jdns = j["dns"]; if (jdns.is_object()) { pbmessages::NetworkChange_DNS* dns = new pbmessages::NetworkChange_DNS(); dns->set_domain(jdns.value("domain", "")); @@ -210,16 +226,17 @@ pbmessages::NetworkChange_Network* networkFromJson(const nlohmann::json& j) n->set_allocated_dns(dns); } - n->set_sso_enabled(j.value("ssoEnabled", false)); - if (j.value("ssoEnabled", false)) { - n->set_sso_provider(j.value("provider", "")); - n->set_sso_client_id(j.value("clientId", "")); - n->set_sso_authorization_endpoint(j.value("authorizationEndpoint", "")); - n->set_sso_issuer(j.value("issuer", "")); - n->set_sso_provider(j.value("provider", "")); + n->set_sso_enabled(OSUtils::jsonBool(j["ssoEnabled"], false)); + nlohmann::json ssocfg = j["ssoConfig"]; + if (ssocfg.is_object()) { + n->set_sso_provider(OSUtils::jsonString(ssocfg["provider"], "")); + n->set_sso_client_id(OSUtils::jsonString(ssocfg["clientId"], "")); + n->set_sso_authorization_endpoint(OSUtils::jsonString(ssocfg["authorizationEndpoint"], "")); + n->set_sso_issuer(OSUtils::jsonString(ssocfg["issuer"], "")); + n->set_sso_provider(OSUtils::jsonString(ssocfg["provider"], "")); } - n->set_rules_source(j.value("rulesSource", "")); + n->set_rules_source(OSUtils::jsonString(j["rulesSource"], "")); } catch (const std::exception& e) { fprintf(stderr, "Exception parsing network JSON: %s\n", e.what()); @@ -258,12 +275,11 @@ pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) pbmessages::MemberChange_Member* m = new pbmessages::MemberChange_Member(); try { - m->set_network_id(j.value("networkId", "")); - m->set_device_id(j.value("id", "")); - m->set_identity(j.value("identity", "")); - m->set_authorized(j.value("authorized", false)); + m->set_network_id(OSUtils::jsonString(j["nwid"], "")); + m->set_device_id(OSUtils::jsonString(j["id"], "")); + m->set_identity(OSUtils::jsonString(j["identity"], "")); + m->set_authorized(OSUtils::jsonBool(j["authorized"], false)); if (j["ipAssignments"].is_array()) { - fprintf(stderr, "memberFromJSON: has ipAssignments\n"); for (const auto& addr : j["ipAssignments"]) { if (addr.is_string()) { auto a = m->add_ip_assignments(); @@ -272,70 +288,42 @@ pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) } } } - else { - fprintf(stderr, "memberFromJSON: no ipAssignments\n"); - } - fprintf(stderr, "ipAssignments set\n"); - m->set_active_bridge(j.value("activeBridge", false)); - fprintf(stderr, "activeBridge set\n"); + m->set_active_bridge(OSUtils::jsonBool(j["activeBridge"], false)); if (j["tags"].is_array()) { - fprintf(stderr, "memberFromJSON: has tags\n"); nlohmann::json tags = j["tags"]; std::string tagsStr = OSUtils::jsonDump(tags, -1); m->set_tags(tagsStr); - fprintf(stderr, "tags set\n"); } else { - fprintf(stderr, "memberFromJSON: no tags\n"); nlohmann::json tags = nlohmann::json::array(); std::string tagsStr = OSUtils::jsonDump(tags, -1); m->set_tags(tagsStr); - fprintf(stderr, "tags set\n"); } if (j["capabilities"].is_array()) { - fprintf(stderr, "memberFromJSON: has capabilities\n"); nlohmann::json caps = j["capabilities"]; std::string capsStr = OSUtils::jsonDump(caps, -1); m->set_capabilities(capsStr); - fprintf(stderr, "capabilities set\n"); } else { - fprintf(stderr, "memberFromJSON: no capabilities\n"); nlohmann::json caps = nlohmann::json::array(); std::string capsStr = OSUtils::jsonDump(caps, -1); m->set_capabilities(capsStr); - fprintf(stderr, "capabilities set\n"); } - m->set_creation_time(j.value("creationTime", 0)); - fprintf(stderr, "creationTime set\n"); - m->set_no_auto_assign_ips(j.value("noAutoAssignIps", false)); - fprintf(stderr, "noAutoAssignIps set\n"); - m->set_revision(j.value("revision", 0)); - fprintf(stderr, "revision set\n"); - m->set_last_authorized_time(j.value("lastAuthorizedTime", 0)); - fprintf(stderr, "lastAuthorizedTime set\n"); - m->set_last_deauthorized_time(j.value("lastDeauthorizedTime", 0)); - fprintf(stderr, "lastDeauthorizedTime set\n"); + m->set_creation_time(OSUtils::jsonInt(j["creationTime"], 0)); + m->set_no_auto_assign_ips(OSUtils::jsonBool(j["noAutoAssignIps"], false)); + m->set_revision(OSUtils::jsonInt(j["revision"], 0)); + m->set_last_authorized_time(OSUtils::jsonInt(j["lastAuthorizedTime"], 0)); + m->set_last_deauthorized_time(OSUtils::jsonInt(j["lastDeauthorizedTime"], 0)); m->set_last_authorized_credential_type(OSUtils::jsonString(j["lastAuthorizedCredentialType"], "")); - fprintf(stderr, "lastAuthorizedCredentialType set\n"); m->set_last_authorized_credential(OSUtils::jsonString(j["lastAuthorizedCredential"], "")); - fprintf(stderr, "lastAuthorizedCredential set\n"); - m->set_version_major(j.value("versionMajor", 0)); - fprintf(stderr, "versionMajor set\n"); - m->set_version_minor(j.value("versionMinor", 0)); - fprintf(stderr, "versionMinor set\n"); - m->set_version_rev(j.value("versionRev", 0)); - fprintf(stderr, "versionRev set\n"); - m->set_version_protocol(j.value("versionProtocol", 0)); - fprintf(stderr, "versionProtocol set\n"); - m->set_remote_trace_level(j.value("remoteTraceLevel", 0)); - fprintf(stderr, "remoteTraceLevel set\n"); + m->set_version_major(OSUtils::jsonInt(j["versionMajor"], 0)); + m->set_version_minor(OSUtils::jsonInt(j["versionMinor"], 0)); + m->set_version_rev(OSUtils::jsonInt(j["versionRev"], 0)); + m->set_version_protocol(OSUtils::jsonInt(j["versionProtocol"], 0)); + m->set_remote_trace_level(OSUtils::jsonInt(j["remoteTraceLevel"], 0)); m->set_remote_trace_target(OSUtils::jsonString(j["remoteTraceTarget"], "")); - fprintf(stderr, "remoteTraceTarget set\n"); - m->set_sso_exempt(j.value("ssoExempt", false)); - fprintf(stderr, "ssoExempt set\n"); - m->set_auth_expiry_time(j.value("authExpiryTime", 0)); - fprintf(stderr, "authExpiryTime set\n"); + m->set_sso_exempt(OSUtils::jsonBool(j["ssoExempt"], false)); + m->set_auth_expiry_time(OSUtils::jsonInt(j["authExpiryTime"], 0)); } catch (const std::exception& e) { fprintf(stderr, "Exception parsing member JSON: %s\n", e.what()); From 18714c778572129ae6c5a5e4054c5ca366979fec Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 2 Oct 2025 11:56:44 -0700 Subject: [PATCH 147/245] add explicit nack if there's an error processing a pubsub message --- nonfree/controller/NotificationListener.hpp | 2 +- nonfree/controller/PostgreSQL.cpp | 18 +++++++--- nonfree/controller/PostgreSQL.hpp | 4 +-- nonfree/controller/PubSubListener.cpp | 38 +++++++++++++-------- nonfree/controller/PubSubListener.hpp | 6 ++-- nonfree/controller/RedisListener.cpp | 6 ++-- nonfree/controller/RedisListener.hpp | 7 ++-- 7 files changed, 51 insertions(+), 30 deletions(-) diff --git a/nonfree/controller/NotificationListener.hpp b/nonfree/controller/NotificationListener.hpp index e1b1d8f9ca..49170228c6 100644 --- a/nonfree/controller/NotificationListener.hpp +++ b/nonfree/controller/NotificationListener.hpp @@ -24,7 +24,7 @@ class NotificationListener { * * @param payload The payload of the notification. */ - virtual void onNotification(const std::string& payload) = 0; + virtual bool onNotification(const std::string& payload) = 0; }; } // namespace ZeroTier diff --git a/nonfree/controller/PostgreSQL.cpp b/nonfree/controller/PostgreSQL.cpp index eb1d461249..e6c96c3c24 100644 --- a/nonfree/controller/PostgreSQL.cpp +++ b/nonfree/controller/PostgreSQL.cpp @@ -12,7 +12,11 @@ namespace ZeroTier { -PostgresMemberListener::PostgresMemberListener(DB* db, std::shared_ptr > pool, const std::string& channel, uint64_t timeout) +PostgresMemberListener::PostgresMemberListener( + DB* db, + std::shared_ptr > pool, + const std::string& channel, + uint64_t timeout) : NotificationListener() , _db(db) , _pool(pool) @@ -45,7 +49,7 @@ void PostgresMemberListener::listen() } } -void PostgresMemberListener::onNotification(const std::string& payload) +bool PostgresMemberListener::onNotification(const std::string& payload) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("PostgresMemberNotificationListener"); @@ -83,9 +87,14 @@ void PostgresMemberListener::onNotification(const std::string& payload) fprintf(stderr, "member delete payload sent\n"); } } + return true; } -PostgresNetworkListener::PostgresNetworkListener(DB* db, std::shared_ptr > pool, const std::string& channel, uint64_t timeout) +PostgresNetworkListener::PostgresNetworkListener( + DB* db, + std::shared_ptr > pool, + const std::string& channel, + uint64_t timeout) : NotificationListener() , _db(db) , _pool(pool) @@ -118,7 +127,7 @@ void PostgresNetworkListener::listen() } } -void PostgresNetworkListener::onNotification(const std::string& payload) +bool PostgresNetworkListener::onNotification(const std::string& payload) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("db_network_notification"); @@ -166,6 +175,7 @@ void PostgresNetworkListener::onNotification(const std::string& payload) fprintf(stderr, "network delete payload sent\n"); } } + return true; } } // namespace ZeroTier diff --git a/nonfree/controller/PostgreSQL.hpp b/nonfree/controller/PostgreSQL.hpp index 46409e1b33..5779153cce 100644 --- a/nonfree/controller/PostgreSQL.hpp +++ b/nonfree/controller/PostgreSQL.hpp @@ -221,7 +221,7 @@ class PostgresMemberListener : public NotificationListener { virtual void listen(); - virtual void onNotification(const std::string& payload) override; + virtual bool onNotification(const std::string& payload) override; private: bool _run = false; @@ -244,7 +244,7 @@ class PostgresNetworkListener : public NotificationListener { virtual void listen(); - virtual void onNotification(const std::string& payload) override; + virtual bool onNotification(const std::string& payload) override; private: bool _run = false; diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 3e313dfe8c..bba666efdb 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -83,10 +83,16 @@ void PubSubListener::subscribe() span->SetAttribute("ordering_key", m.ordering_key()); fprintf(stderr, "Received message %s\n", m.message_id().c_str()); - onNotification(m.data()); - std::move(h).ack(); - span->SetStatus(opentelemetry::trace::StatusCode::kOk); - return true; + if (onNotification(m.data())) { + std::move(h).ack(); + span->SetStatus(opentelemetry::trace::StatusCode::kOk); + return true; + } + else { + std::move(h).nack(); + span->SetStatus(opentelemetry::trace::StatusCode::kError, "onNotification failed"); + return false; + } }); auto result = session.wait_for(std::chrono::seconds(10)); @@ -119,7 +125,7 @@ PubSubNetworkListener::~PubSubNetworkListener() { } -void PubSubNetworkListener::onNotification(const std::string& payload) +bool PubSubNetworkListener::onNotification(const std::string& payload) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("PubSubNetworkListener"); @@ -131,7 +137,7 @@ void PubSubNetworkListener::onNotification(const std::string& payload) fprintf(stderr, "Failed to parse NetworkChange protobuf message\n"); span->SetAttribute("error", "Failed to parse NetworkChange protobuf message"); span->SetStatus(opentelemetry::trace::StatusCode::kError, "Failed to parse protobuf"); - return; + return false; } fprintf(stderr, "PubSubNetworkListener: parsed protobuf message. %s\n", nc.DebugString().c_str()); fprintf(stderr, "Network notification received\n"); @@ -153,7 +159,7 @@ void PubSubNetworkListener::onNotification(const std::string& payload) fprintf(stderr, "NetworkChange message has no old or new network config\n"); span->SetAttribute("error", "NetworkChange message has no old or new network config"); span->SetStatus(opentelemetry::trace::StatusCode::kError, "No old or new config"); - return; + return false; } if (oldConfig.is_object() && newConfig.is_object()) { @@ -187,21 +193,22 @@ void PubSubNetworkListener::onNotification(const std::string& payload) span->SetAttribute("error", e.what()); span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); fprintf(stderr, "payload: %s\n", payload.c_str()); - return; + return false; } catch (const std::exception& e) { fprintf(stderr, "PubSubNetworkListener Exception in PubSubNetworkListener: %s\n", e.what()); span->SetAttribute("error", e.what()); span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - return; + return false; } catch (...) { fprintf(stderr, "PubSubNetworkListener Unknown exception in PubSubNetworkListener\n"); span->SetAttribute("error", "Unknown exception in PubSubNetworkListener"); span->SetStatus(opentelemetry::trace::StatusCode::kError, "Unknown exception"); - return; + return false; } fprintf(stderr, "PubSubNetworkListener onNotification complete\n"); + return true; } PubSubMemberListener::PubSubMemberListener(std::string controller_id, std::string project, std::string topic, DB* db) @@ -214,7 +221,7 @@ PubSubMemberListener::~PubSubMemberListener() { } -void PubSubMemberListener::onNotification(const std::string& payload) +bool PubSubMemberListener::onNotification(const std::string& payload) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("PubSubMemberListener"); @@ -226,7 +233,7 @@ void PubSubMemberListener::onNotification(const std::string& payload) fprintf(stderr, "Failed to parse MemberChange protobuf message\n"); span->SetAttribute("error", "Failed to parse MemberChange protobuf message"); span->SetStatus(opentelemetry::trace::StatusCode::kError, "Failed to parse protobuf"); - return; + return false; } fprintf(stderr, "PubSubMemberListener: parsed protobuf message. %s\n", mc.DebugString().c_str()); fprintf(stderr, "Member notification received"); @@ -249,7 +256,7 @@ void PubSubMemberListener::onNotification(const std::string& payload) fprintf(stderr, "MemberChange message has no old or new member config\n"); span->SetAttribute("error", "MemberChange message has no old or new member config"); span->SetStatus(opentelemetry::trace::StatusCode::kError, "No old or new config"); - return; + return false; } if (oldConfig.is_object() && newConfig.is_object()) { @@ -290,14 +297,15 @@ void PubSubMemberListener::onNotification(const std::string& payload) span->SetAttribute("error", e.what()); span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); fprintf(stderr, "payload: %s\n", payload.c_str()); - return; + return false; } catch (const std::exception& e) { fprintf(stderr, "PubSubMemberListener Exception in PubSubMemberListener: %s\n", e.what()); span->SetAttribute("error", e.what()); span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - return; + return false; } + return true; } nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::NetworkChange_ChangeSource source) diff --git a/nonfree/controller/PubSubListener.hpp b/nonfree/controller/PubSubListener.hpp index 2efe8c8195..71e65983a2 100644 --- a/nonfree/controller/PubSubListener.hpp +++ b/nonfree/controller/PubSubListener.hpp @@ -23,7 +23,7 @@ class PubSubListener : public NotificationListener { PubSubListener(std::string controller_id, std::string project, std::string topic); virtual ~PubSubListener(); - virtual void onNotification(const std::string& payload) = 0; + virtual bool onNotification(const std::string& payload) = 0; protected: std::string _controller_id; @@ -48,7 +48,7 @@ class PubSubNetworkListener : public PubSubListener { PubSubNetworkListener(std::string controller_id, std::string project, std::string topic, DB* db); virtual ~PubSubNetworkListener(); - virtual void onNotification(const std::string& payload) override; + virtual bool onNotification(const std::string& payload) override; private: DB* _db; @@ -62,7 +62,7 @@ class PubSubMemberListener : public PubSubListener { PubSubMemberListener(std::string controller_id, std::string project, std::string topic, DB* db); virtual ~PubSubMemberListener(); - virtual void onNotification(const std::string& payload) override; + virtual bool onNotification(const std::string& payload) override; private: DB* _db; diff --git a/nonfree/controller/RedisListener.cpp b/nonfree/controller/RedisListener.cpp index f01bfa6783..a5100df6cd 100644 --- a/nonfree/controller/RedisListener.cpp +++ b/nonfree/controller/RedisListener.cpp @@ -131,9 +131,10 @@ void RedisNetworkListener::listen() } } -void RedisNetworkListener::onNotification(const std::string& payload) +bool RedisNetworkListener::onNotification(const std::string& payload) { // Handle notifications if needed + return true; } RedisMemberListener::RedisMemberListener(std::string controller_id, std::shared_ptr redis, DB* db) @@ -227,8 +228,9 @@ void RedisMemberListener::listen() } } -void RedisMemberListener::onNotification(const std::string& payload) +bool RedisMemberListener::onNotification(const std::string& payload) { + return true; } } // namespace ZeroTier diff --git a/nonfree/controller/RedisListener.hpp b/nonfree/controller/RedisListener.hpp index 4cc67bd6b9..e9e4323425 100644 --- a/nonfree/controller/RedisListener.hpp +++ b/nonfree/controller/RedisListener.hpp @@ -22,8 +22,9 @@ class RedisListener : public NotificationListener { virtual ~RedisListener(); virtual void listen() = 0; - virtual void onNotification(const std::string& payload) override + virtual bool onNotification(const std::string& payload) override { + return true; } void start() @@ -50,7 +51,7 @@ class RedisNetworkListener : public RedisListener { virtual ~RedisNetworkListener(); virtual void listen() override; - virtual void onNotification(const std::string& payload) override; + virtual bool onNotification(const std::string& payload) override; private: DB* _db; @@ -63,7 +64,7 @@ class RedisMemberListener : public RedisListener { virtual ~RedisMemberListener(); virtual void listen() override; - virtual void onNotification(const std::string& payload) override; + virtual bool onNotification(const std::string& payload) override; private: DB* _db; From 1ef7ea0fe6d05cf9c7ba5cb3bbab81d2178ff5bb Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 2 Oct 2025 15:04:57 -0700 Subject: [PATCH 148/245] Fixing more JSON issues --- nonfree/controller/CentralDB.cpp | 54 +++++++++++++++++------- osdep/OSUtils.cpp | 72 +++++++++++++++++++++++++------- osdep/OSUtils.hpp | 1 + 3 files changed, 97 insertions(+), 30 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index b3d1338c60..fa9fa8a066 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1207,6 +1207,30 @@ void CentralDB::commitThread() } } + std::vector ipAssignments; + if (config["ipAssignments"].is_array()) { + for (auto& ip : config["ipAssignments"]) { + if (ip.is_string()) { + ipAssignments.push_back(ip.get()); + } + } + } + + fprintf(stderr, "member json: %s\n", config.dump().c_str()); + + int64_t vMajor = OSUtils::jsonUInt(config["vMajor"], 0); + int64_t vMinor = OSUtils::jsonUInt(config["vMinor"], 0); + int64_t vRev = OSUtils::jsonUInt(config["vRev"], 0); + int64_t vProto = OSUtils::jsonUInt(config["vProto"], 0); + if (vMajor < 0) + vMajor = 0; + if (vMinor < 0) + vMinor = 0; + if (vRev < 0) + vRev = 0; + if (vProto < 0) + vProto = 0; + pqxx::result res = w.exec( "INSERT INTO network_memberships_ctl (device_id, network_id, authorized, active_bridge, " @@ -1235,25 +1259,25 @@ void CentralDB::commitThread() "version_protocol = EXCLUDED.version_protocol", pqxx::params { memberId, networkId, - (bool)config["authorized"], - (bool)config["activeBridge"], - config["ipAssignments"].get >(), - (bool)config["noAutoAssignIps"], - (bool)config["ssoExempt"], - (uint64_t)config["authenticationExpiryTime"], + OSUtils::jsonBool(config["authorized"], false), + OSUtils::jsonBool(config["activeBridge"], false), + ipAssignments, + OSUtils::jsonBool(config["noAutoAssignIps"], false), + OSUtils::jsonBool(config["ssoExempt"], false), + OSUtils::jsonInt(config["authenticationExpiryTime"], 0), OSUtils::jsonDump(config["capabilities"], -1), - (uint64_t)config["creationTime"], + OSUtils::jsonInt(config["creationTime"], OSUtils::now()), OSUtils::jsonString(config["identity"], ""), - (uint64_t)config["lastAuthorizedTime"], - (uint64_t)config["lastDeauthorizedTime"], - (int)config["remoteTraceLevel"], + OSUtils::jsonInt(config["lastAuthorizedTime"], 0), + OSUtils::jsonInt(config["lastDeauthorizedTime"], 0), + OSUtils::jsonInt(config["remoteTraceLevel"], 0), target, - (uint64_t)config["revision"], + OSUtils::jsonInt(config["revision"], 0), OSUtils::jsonDump(config["tags"], -1), - (int)config["vMajor"], - (int)config["vMinor"], - (int)config["vRev"], - (int)config["vProto"] }) + vMajor, + vMinor, + vRev, + vProto }) .no_rows(); w.commit(); diff --git a/osdep/OSUtils.cpp b/osdep/OSUtils.cpp index 2fee8f194d..078adfca94 100644 --- a/osdep/OSUtils.cpp +++ b/osdep/OSUtils.cpp @@ -9,6 +9,7 @@ #include "../node/Constants.hpp" #include "../node/Utils.hpp" +#include #include #include #include @@ -109,7 +110,9 @@ std::vector OSUtils::listDirectory(const char* path, bool includeDi WIN32_FIND_DATAA ffd; if ((hFind = FindFirstFileA((std::string(path) + "\\*").c_str(), &ffd)) != INVALID_HANDLE_VALUE) { do { - if ((strcmp(ffd.cFileName, ".")) && (strcmp(ffd.cFileName, "..")) && (((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) || (((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) && (includeDirectories)))) + if ((strcmp(ffd.cFileName, ".")) && (strcmp(ffd.cFileName, "..")) + && (((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) + || (((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) && (includeDirectories)))) r.push_back(std::string(ffd.cFileName)); } while (FindNextFileA(hFind, &ffd)); FindClose(hFind); @@ -125,7 +128,8 @@ std::vector OSUtils::listDirectory(const char* path, bool includeDi if (readdir_r(d, &de, &dptr)) break; if (dptr) { - if ((strcmp(dptr->d_name, ".")) && (strcmp(dptr->d_name, "..")) && ((dptr->d_type != DT_DIR) || (includeDirectories))) + if ((strcmp(dptr->d_name, ".")) && (strcmp(dptr->d_name, "..")) + && ((dptr->d_type != DT_DIR) || (includeDirectories))) r.push_back(std::string(dptr->d_name)); } else @@ -149,7 +153,8 @@ long OSUtils::cleanDirectory(const char* path, const int64_t olderThan) char tmp[4096]; if ((hFind = FindFirstFileA((std::string(path) + "\\*").c_str(), &ffd)) != INVALID_HANDLE_VALUE) { do { - if ((strcmp(ffd.cFileName, ".")) && (strcmp(ffd.cFileName, "..")) && ((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)) { + if ((strcmp(ffd.cFileName, ".")) && (strcmp(ffd.cFileName, "..")) + && ((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)) { date.HighPart = ffd.ftLastWriteTime.dwHighDateTime; date.LowPart = ffd.ftLastWriteTime.dwLowDateTime; if (date.QuadPart > 0) { @@ -258,7 +263,10 @@ void OSUtils::lockDownFile(const char* path, bool isDir) startupInfo.cb = sizeof(startupInfo); memset(&startupInfo, 0, sizeof(STARTUPINFOA)); memset(&processInfo, 0, sizeof(PROCESS_INFORMATION)); - if (CreateProcessA(NULL, (LPSTR)(std::string("C:\\Windows\\System32\\icacls.exe \"") + path + "\" /inheritance:d /Q").c_str(), NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &startupInfo, &processInfo)) { + if (CreateProcessA( + NULL, + (LPSTR)(std::string("C:\\Windows\\System32\\icacls.exe \"") + path + "\" /inheritance:d /Q").c_str(), + NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &startupInfo, &processInfo)) { WaitForSingleObject(processInfo.hProcess, INFINITE); CloseHandle(processInfo.hProcess); CloseHandle(processInfo.hThread); @@ -267,7 +275,11 @@ void OSUtils::lockDownFile(const char* path, bool isDir) startupInfo.cb = sizeof(startupInfo); memset(&startupInfo, 0, sizeof(STARTUPINFOA)); memset(&processInfo, 0, sizeof(PROCESS_INFORMATION)); - if (CreateProcessA(NULL, (LPSTR)(std::string("C:\\Windows\\System32\\icacls.exe \"") + path + "\" /remove *S-1-5-32-545 /Q").c_str(), NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &startupInfo, &processInfo)) { + if (CreateProcessA( + NULL, + (LPSTR)(std::string("C:\\Windows\\System32\\icacls.exe \"") + path + "\" /remove *S-1-5-32-545 /Q") + .c_str(), + NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &startupInfo, &processInfo)) { WaitForSingleObject(processInfo.hProcess, INFINITE); CloseHandle(processInfo.hProcess); CloseHandle(processInfo.hThread); @@ -277,7 +289,11 @@ void OSUtils::lockDownFile(const char* path, bool isDir) startupInfo.cb = sizeof(startupInfo); memset(&startupInfo, 0, sizeof(STARTUPINFOA)); memset(&processInfo, 0, sizeof(PROCESS_INFORMATION)); - if (CreateProcessA(NULL, (LPSTR)(std::string("C:\\Windows\\System32\\icacls.exe \"") + path + "\" /remove:g Everyone /t /c /Q").c_str(), NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &startupInfo, &processInfo)) { + if (CreateProcessA( + NULL, + (LPSTR)(std::string("C:\\Windows\\System32\\icacls.exe \"") + path + "\" /remove:g Everyone /t /c /Q") + .c_str(), + NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &startupInfo, &processInfo)) { WaitForSingleObject(processInfo.hProcess, INFINITE); CloseHandle(processInfo.hProcess); CloseHandle(processInfo.hThread); @@ -507,6 +523,25 @@ uint64_t OSUtils::jsonInt(const nlohmann::json& jv, const uint64_t dfl) return dfl; } +int64_t OSUtils::jsonUInt(const nlohmann::json& jv, const int64_t dfl) +{ + try { + if (jv.is_number()) { + return (int64_t)jv; + } + else if (jv.is_string()) { + std::string s = jv; + return Utils::strTo64(s.c_str()); + } + else if (jv.is_boolean()) { + return ((bool)jv ? 1LL : 0LL); + } + } + catch (...) { + } + return dfl; +} + double OSUtils::jsonDouble(const nlohmann::json& jv, const double dfl) { try { @@ -614,14 +649,21 @@ std::string OSUtils::jsonBinFromHex(const nlohmann::json& jv) #endif // OMIT_JSON_SUPPORT // Used to convert HTTP header names to ASCII lower case -const unsigned char OSUtils::TOLOWER_TABLE[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, - 0x1d, 0x1e, 0x1f, ' ', '!', '"', '#', '$', '%', '&', 0x27, '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - ':', ';', '<', '=', '>', '?', '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', - 'w', 'x', 'y', 'z', '{', '|', '}', '~', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', - 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, - 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, - 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, - 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }; +const unsigned char OSUtils::TOLOWER_TABLE[256] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, + 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, ' ', '!', '"', '#', '$', '%', + '&', 0x27, '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', + '9', ':', ';', '<', '=', '>', '?', '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', + 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', + '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', + 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, + 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, + 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, + 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, + 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, + 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, + 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff +}; } // namespace ZeroTier diff --git a/osdep/OSUtils.hpp b/osdep/OSUtils.hpp index b122a0c946..6a63ff615d 100644 --- a/osdep/OSUtils.hpp +++ b/osdep/OSUtils.hpp @@ -293,6 +293,7 @@ class OSUtils { static nlohmann::json jsonParse(const std::string& buf); static std::string jsonDump(const nlohmann::json& j, int indentation = 1); static uint64_t jsonInt(const nlohmann::json& jv, const uint64_t dfl); + static int64_t jsonUInt(const nlohmann::json& jv, const int64_t dfl); static double jsonDouble(const nlohmann::json& jv, const double dfl); static uint64_t jsonIntHex(const nlohmann::json& jv, const uint64_t dfl); static bool jsonBool(const nlohmann::json& jv, const bool dfl); From 6df7366753d0ab3bd074fdd913f7f56cc1b16956 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 2 Oct 2025 16:00:08 -0700 Subject: [PATCH 149/245] no need for these timeouts --- nonfree/controller/PubSubListener.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index bba666efdb..ee3f1939f9 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -98,19 +98,16 @@ void PubSubListener::subscribe() auto result = session.wait_for(std::chrono::seconds(10)); if (result == std::future_status::timeout) { session.cancel(); - std::this_thread::sleep_for(std::chrono::seconds(5)); continue; } if (! session.valid()) { fprintf(stderr, "Subscription session no longer valid\n"); - std::this_thread::sleep_for(std::chrono::seconds(5)); continue; } } catch (google::cloud::Status const& status) { fprintf(stderr, "Subscription terminated with status: %s\n", status.message().c_str()); - std::this_thread::sleep_for(std::chrono::seconds(5)); } } } From fe221b93599e72e2886298ae1662f2682347850b Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 6 Oct 2025 14:24:57 -0700 Subject: [PATCH 150/245] debug output for IP addressing & fixing order of operations in a couple of places. Only send notification of a change to pubsub after it's been written to the DB --- nonfree/controller/CentralDB.cpp | 54 ++++++++++--------- .../controller/EmbeddedNetworkController.cpp | 16 +++++- nonfree/controller/PubSubListener.cpp | 14 +++-- 3 files changed, 55 insertions(+), 29 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index fa9fa8a066..e2a90c0166 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1189,25 +1189,18 @@ void CentralDB::commitThread() change_source = config["change_source"]; } if (! isNewMember && change_source != "controller" && frontend != change_source) { + fprintf( + stderr, "skipping member %s-%s update. change source: %s, frontend: %s\n", + networkId.c_str(), memberId.c_str(), change_source.c_str(), frontend.c_str()); // if it is not a new member and the change source is not the controller and doesn't match the // frontend, don't apply the change. continue; } - if (_listenerMode == LISTENER_MODE_PUBSUB) { - // Publish change to pubsub stream - - if (config["change_source"].is_null() || config["change_source"] == "controller") { - nlohmann::json oldMember; - nlohmann::json newMember = config; - if (! isNewMember) { - oldMember = _getNetworkMember(w, networkId, memberId); - } - _changeNotifier->notifyMemberChange(oldMember, newMember, frontend); - } - } - std::vector ipAssignments; + fprintf( + stderr, "Saving IP Assignments: \n\tipAssignments: %s\n", + OSUtils::jsonDump(config["ipAssignments"], -1).c_str()); if (config["ipAssignments"].is_array()) { for (auto& ip : config["ipAssignments"]) { if (ip.is_string()) { @@ -1282,6 +1275,19 @@ void CentralDB::commitThread() w.commit(); + if (_listenerMode == LISTENER_MODE_PUBSUB) { + // Publish change to pubsub stream + + if (config["change_source"].is_null() || config["change_source"] == "controller") { + nlohmann::json oldMember; + nlohmann::json newMember = config; + if (! isNewMember) { + oldMember = _getNetworkMember(w, networkId, memberId); + } + _changeNotifier->notifyMemberChange(oldMember, newMember, frontend); + } + } + if (_smee != NULL && isNewMember) { // TODO: Smee Notifications for New Members // pqxx::row row = w.exec_params1( @@ -1363,6 +1369,17 @@ void CentralDB::commitThread() continue; } + pqxx::result res = w.exec( + "INSERT INTO networks_ctl (id, name, configuration, controller_id, revision, frontend) " + "VALUES ($1, $2, $3, $4, $5, $6) " + "ON CONFLICT (id) DO UPDATE SET " + "name = EXCLUDED.name, configuration = EXCLUDED.configuration, revision = EXCLUDED.revision+1, " + "frontend = EXCLUDED.frontend", + pqxx::params { id, OSUtils::jsonString(config["name"], ""), OSUtils::jsonDump(config, -1), + _myAddressStr, ((uint64_t)config["revision"]), change_source }); + + w.commit(); + if (_listenerMode == LISTENER_MODE_PUBSUB) { // Publish change to pubsub stream if (config["change_source"].is_null() || config["change_source"] == "controller") { @@ -1375,17 +1392,6 @@ void CentralDB::commitThread() } } - pqxx::result res = w.exec( - "INSERT INTO networks_ctl (id, name, configuration, controller_id, revision, frontend) " - "VALUES ($1, $2, $3, $4, $5, $6) " - "ON CONFLICT (id) DO UPDATE SET " - "name = EXCLUDED.name, configuration = EXCLUDED.configuration, revision = EXCLUDED.revision+1, " - "frontend = EXCLUDED.frontend", - pqxx::params { id, OSUtils::jsonString(config["name"], ""), OSUtils::jsonDump(config, -1), - _myAddressStr, ((uint64_t)config["revision"]), change_source }); - - w.commit(); - const uint64_t nwidInt = OSUtils::jsonIntHex(config["id"], 0ULL); if (nwidInt) { nlohmann::json nwOrig; diff --git a/nonfree/controller/EmbeddedNetworkController.cpp b/nonfree/controller/EmbeddedNetworkController.cpp index c708e4f3b3..f442bc6a8f 100644 --- a/nonfree/controller/EmbeddedNetworkController.cpp +++ b/nonfree/controller/EmbeddedNetworkController.cpp @@ -2301,10 +2301,20 @@ void EmbeddedNetworkController::_request( } } + fprintf(stderr, "haveManagedIpv4AutoAssignment=%s\n", haveManagedIpv4AutoAssignment ? "true" : "false"); + fprintf(stderr, "ipAssignmentPools.is_array()=%s\n", ipAssignmentPools.is_array() ? "true" : "false"); + fprintf(stderr, "v4AssignMode.is_object()=%s\n", v4AssignMode.is_object() ? "true" : "false"); + fprintf( + stderr, "v4AssignMode[\"zt\"]=%s\n", + (v4AssignMode.is_object() && OSUtils::jsonBool(v4AssignMode["zt"], false)) ? "true" : "false"); + fprintf(stderr, "noAutoAssignIps=%s\n", noAutoAssignIps ? "true" : "false"); + if ((ipAssignmentPools.is_array()) && ((v4AssignMode.is_object()) && (OSUtils::jsonBool(v4AssignMode["zt"], false))) && (! haveManagedIpv4AutoAssignment) && (! noAutoAssignIps)) { + fprintf(stderr, "Trying to do managed IPv4 auto-assignment\n"); for (unsigned long p = 0; ((p < ipAssignmentPools.size()) && (! haveManagedIpv4AutoAssignment)); ++p) { json& pool = ipAssignmentPools[p]; + fprintf(stderr, " considering pool %lu: %s\n", p, OSUtils::jsonDump(pool, 2).c_str()); if (pool.is_object()) { InetAddress ipRangeStartIA(OSUtils::jsonString(pool["ipRangeStart"], "").c_str()); InetAddress ipRangeEndIA(OSUtils::jsonString(pool["ipRangeEnd"], "").c_str()); @@ -2314,8 +2324,10 @@ void EmbeddedNetworkController::_request( uint32_t ipRangeEnd = Utils::ntoh((uint32_t)(reinterpret_cast(&ipRangeEndIA)->sin_addr.s_addr)); - if ((ipRangeEnd < ipRangeStart) || (ipRangeStart == 0)) + if ((ipRangeEnd < ipRangeStart) || (ipRangeStart == 0)) { + fprintf(stderr, " bad ip range range\n"); continue; + } uint32_t ipRangeLen = ipRangeEnd - ipRangeStart; // Start with the LSB of the member's address @@ -2353,6 +2365,7 @@ void EmbeddedNetworkController::_request( char tmpip[64]; const std::string ipStr(ip4.toIpString(tmpip)); if (std::find(ipAssignments.begin(), ipAssignments.end(), ipStr) == ipAssignments.end()) { + fprintf(stderr, " assigning %s\n", ipStr.c_str()); ipAssignments.push_back(ipStr); member["ipAssignments"] = ipAssignments; if (nc->staticIpCount < ZT_MAX_ZT_ASSIGNED_ADDRESSES) { @@ -2426,6 +2439,7 @@ void EmbeddedNetworkController::_request( c10++; b10.start(); #endif + member["change_source"] = "controller"; DB::cleanMember(member); _db.save(member, true); #ifdef CENTRAL_CONTROLLER_REQUEST_BENCHMARK diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index ee3f1939f9..e22626f176 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -358,11 +358,17 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N nlohmann::json routes = nlohmann::json::array(); for (const auto& r : nc.routes()) { nlohmann::json route; - route["target"] = r.target(); - if (r.has_via()) { - route["via"] = r.via(); + std::string target = r.target(); + if (target.length() > 0) { + route["target"] = r.target(); + if (r.has_via()) { + route["via"] = r.via(); + } + else { + route["via"] = nullptr; + } + routes.push_back(route); } - routes.push_back(route); } out["routes"] = routes; } From 6b74bf289af416849297db8e7f6f12ab811e3717 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 6 Oct 2025 15:10:42 -0700 Subject: [PATCH 151/245] fix assign mode json --- nonfree/controller/PubSubListener.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index e22626f176..efdd2c3be6 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -330,14 +330,27 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N if (nc.has_ipv4_assign_mode()) { nlohmann::json ipv4mode; ipv4mode["zt"] = nc.ipv4_assign_mode().zt(); - out["ipv4AssignMode"] = ipv4mode; + out["v4AssignMode"] = ipv4mode; } + else { + nlohmann::json ipv4mode = nlohmann::json::object(); + out["zt"] = false; + out["v4AssignMode"] = ipv4mode; + } + if (nc.has_ipv6_assign_mode()) { nlohmann::json ipv6mode; ipv6mode["6plane"] = nc.ipv6_assign_mode().six_plane(); ipv6mode["rfc4193"] = nc.ipv6_assign_mode().rfc4193(); ipv6mode["zt"] = nc.ipv6_assign_mode().zt(); - out["ipv6AssignMode"] = ipv6mode; + out["v6AssignMode"] = ipv6mode; + } + else { + nlohmann::json ipv6mode = nlohmann::json::object(); + ipv6mode["6plane"] = false; + ipv6mode["rfc4193"] = false; + ipv6mode["zt"] = false; + out["v6AssignMode"] = ipv6mode; } if (nc.assignment_pools_size() > 0) { From 946d96f48260cc3538d1b1337b8fed5cee96be3b Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 9 Oct 2025 14:34:24 -0700 Subject: [PATCH 152/245] dont NACK failed messages. That gets us into a loop of failing the same messages over and over again --- nonfree/controller/PubSubListener.cpp | 1 - rustybits/Cargo.lock | 33 ++++++++++++--------------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index efdd2c3be6..934cf65e81 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -89,7 +89,6 @@ void PubSubListener::subscribe() return true; } else { - std::move(h).nack(); span->SetStatus(opentelemetry::trace::StatusCode::kError, "onNotification failed"); return false; } diff --git a/rustybits/Cargo.lock b/rustybits/Cargo.lock index c405a1ac25..4ba4788db6 100644 --- a/rustybits/Cargo.lock +++ b/rustybits/Cargo.lock @@ -324,7 +324,7 @@ checksum = "975982cdb7ad6a142be15bdf84aea7ec6a9e5d4d797c004d43185b24cfe4e684" dependencies = [ "clap", "heck", - "indexmap 2.10.0", + "indexmap 2.11.0", "log", "proc-macro2", "quote", @@ -858,6 +858,12 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "find-msvc-tools" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fd99930f64d146689264c637b5af2f0233a933bef0d8570e2526bf9e083192d" + [[package]] name = "fixedbitset" version = "0.5.7" @@ -1683,7 +1689,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4488594b9328dee448adb906d8b126d9b7deb7cf5c22161ee591610bb1be83c0" dependencies = [ - "bitflags 2.9.2", + "bitflags 2.9.4", "libc", "redox_syscall 0.5.17", ] @@ -2112,7 +2118,7 @@ checksum = "914a1c2265c98e2446911282c6ac86d8524f495792c38c5bd884f80499c7538a" dependencies = [ "parse-display-derive", "regex", - "regex-syntax 0.8.5", + "regex-syntax", ] [[package]] @@ -2124,7 +2130,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "regex-syntax 0.8.5", + "regex-syntax", "structmeta", "syn", ] @@ -3736,7 +3742,7 @@ version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ - "indexmap 2.10.0", + "indexmap 2.11.0", "serde", "serde_spanned", "toml_datetime", @@ -4167,9 +4173,9 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" dependencies = [ - "proc-macro2", - "quote", - "syn", + "windows-core", + "windows-link", + "windows-threading", ] [[package]] @@ -4183,17 +4189,6 @@ dependencies = [ "syn", ] -[[package]] -name = "windows-interface" -version = "0.57.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "windows-interface" version = "0.59.1" From 46a8cd7b67127ba9985ee44c63ea9462040d254d Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 9 Oct 2025 14:39:46 -0700 Subject: [PATCH 153/245] robustify the handling of tags/capabilities/rules which are strings of encoded json --- nonfree/controller/PubSubListener.cpp | 36 ++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 934cf65e81..dbb2281865 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -311,7 +311,17 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N out["objtype"] = "network"; out["id"] = nc.network_id(); out["name"] = nc.name(); - out["capabilities"] = OSUtils::jsonParse(nc.capabilities()); + + if (nc.has_capabilities()) { + std::string caps = nc.capabilities(); + if (caps == "null") { + out["capabilities"] = "null"; + } + else { + out["capabilities"] = OSUtils::jsonParse(caps); + } + out["capabilities"] = OSUtils::jsonParse(caps); + } out["mtu"] = nc.mtu(); out["multicastLimit"] = nc.multicast_limit(); out["private"] = nc.is_private(); @@ -322,9 +332,29 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N else { out["remoteTraceTarget"] = ""; } - out["rules"] = OSUtils::jsonParse(nc.rules()); + + if (nc.has_rules()) { + std::string rules = nc.rules(); + if (rules == "null") { + out["rules"] = "[]"; + } + else { + out["rules"] = OSUtils::jsonParse(rules); + } + } out["rulesSource"] = nc.rules_source(); - out["tags"] = OSUtils::jsonParse(nc.tags()); + if (nc.has_tags()) { + std::string tags = nc.tags(); + if (tags == "[]") { + out["tags"] = "[]"; + } + else { + out["tags"] = OSUtils::jsonParse(tags); + } + } + else { + out["tags"] = "[]"; + } if (nc.has_ipv4_assign_mode()) { nlohmann::json ipv4mode; From 47367673f909dfc7323f5221c1304cf2244e75b8 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 9 Oct 2025 14:47:25 -0700 Subject: [PATCH 154/245] more robustifying incoming messages --- nonfree/controller/PubSubListener.cpp | 36 +++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index dbb2281865..459dc28a10 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -322,6 +322,9 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N } out["capabilities"] = OSUtils::jsonParse(caps); } + else { + out["capabilities"] = "[]"; + } out["mtu"] = nc.mtu(); out["multicastLimit"] = nc.multicast_limit(); out["private"] = nc.is_private(); @@ -342,7 +345,12 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N out["rules"] = OSUtils::jsonParse(rules); } } + else { + out["rules"] = "[]"; + } + out["rulesSource"] = nc.rules_source(); + if (nc.has_tags()) { std::string tags = nc.tags(); if (tags == "[]") { @@ -498,14 +506,38 @@ nlohmann::json toJson(const pbmessages::MemberChange_Member& mc, pbmessages::Mem out["noAutoAssignIps"] = mc.no_auto_assign_ips(); out["ssoExempt"] = mc.sso_exempt(); out["authenticationExpiryTime"] = mc.auth_expiry_time(); - out["capabilities"] = OSUtils::jsonParse(mc.capabilities()); + if (mc.has_capabilities()) { + std::string caps = mc.capabilities(); + if (caps == "null") { + out["capabilities"] = "[]"; + } + else { + out["capabilities"] = OSUtils::jsonParse(caps); + } + } + else { + out["capabilities"] = "[]"; + } out["creationTime"] = mc.creation_time(); out["identity"] = mc.identity(); out["lastAuthorizedTime"] = mc.last_authorized_time(); out["lastDeauthorizedTime"] = mc.last_deauthorized_time(); out["remoteTraceLevel"] = mc.remote_trace_level(); out["revision"] = mc.revision(); - out["tags"] = OSUtils::jsonParse(mc.tags()); + + if (mc.has_tags()) { + std::string tags = mc.tags(); + if (tags == "[]") { + out["tags"] = "[]"; + } + else { + out["tags"] = OSUtils::jsonParse(tags); + } + } + else { + out["tags"] = "[]"; + } + out["versionMajor"] = mc.version_major(); out["versionMinor"] = mc.version_minor(); out["versionRev"] = mc.version_rev(); From e3f65ff3597aca5579584d46443b021b98c385e7 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 9 Oct 2025 15:02:16 -0700 Subject: [PATCH 155/245] compiler fix --- nonfree/controller/PubSubListener.cpp | 69 +++++++++------------------ 1 file changed, 23 insertions(+), 46 deletions(-) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 459dc28a10..3d64dde616 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -312,19 +312,14 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N out["id"] = nc.network_id(); out["name"] = nc.name(); - if (nc.has_capabilities()) { - std::string caps = nc.capabilities(); - if (caps == "null") { - out["capabilities"] = "null"; - } - else { - out["capabilities"] = OSUtils::jsonParse(caps); - } - out["capabilities"] = OSUtils::jsonParse(caps); + std::string caps = nc.capabilities(); + if (caps == "null") { + out["capabilities"] = "null"; } else { - out["capabilities"] = "[]"; + out["capabilities"] = OSUtils::jsonParse(caps); } + out["mtu"] = nc.mtu(); out["multicastLimit"] = nc.multicast_limit(); out["private"] = nc.is_private(); @@ -336,32 +331,22 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N out["remoteTraceTarget"] = ""; } - if (nc.has_rules()) { - std::string rules = nc.rules(); - if (rules == "null") { - out["rules"] = "[]"; - } - else { - out["rules"] = OSUtils::jsonParse(rules); - } + std::string rules = nc.rules(); + if (rules == "null") { + out["rules"] = "[]"; } else { - out["rules"] = "[]"; + out["rules"] = OSUtils::jsonParse(rules); } out["rulesSource"] = nc.rules_source(); - if (nc.has_tags()) { - std::string tags = nc.tags(); - if (tags == "[]") { - out["tags"] = "[]"; - } - else { - out["tags"] = OSUtils::jsonParse(tags); - } + std::string tags = nc.tags(); + if (tags == "[]") { + out["tags"] = "[]"; } else { - out["tags"] = "[]"; + out["tags"] = OSUtils::jsonParse(tags); } if (nc.has_ipv4_assign_mode()) { @@ -506,18 +491,15 @@ nlohmann::json toJson(const pbmessages::MemberChange_Member& mc, pbmessages::Mem out["noAutoAssignIps"] = mc.no_auto_assign_ips(); out["ssoExempt"] = mc.sso_exempt(); out["authenticationExpiryTime"] = mc.auth_expiry_time(); - if (mc.has_capabilities()) { - std::string caps = mc.capabilities(); - if (caps == "null") { - out["capabilities"] = "[]"; - } - else { - out["capabilities"] = OSUtils::jsonParse(caps); - } + + std::string caps = mc.capabilities(); + if (caps == "null") { + out["capabilities"] = "[]"; } else { - out["capabilities"] = "[]"; + out["capabilities"] = OSUtils::jsonParse(caps); } + out["creationTime"] = mc.creation_time(); out["identity"] = mc.identity(); out["lastAuthorizedTime"] = mc.last_authorized_time(); @@ -525,17 +507,12 @@ nlohmann::json toJson(const pbmessages::MemberChange_Member& mc, pbmessages::Mem out["remoteTraceLevel"] = mc.remote_trace_level(); out["revision"] = mc.revision(); - if (mc.has_tags()) { - std::string tags = mc.tags(); - if (tags == "[]") { - out["tags"] = "[]"; - } - else { - out["tags"] = OSUtils::jsonParse(tags); - } + std::string tags = mc.tags(); + if (tags == "null") { + out["tags"] = "[]"; } else { - out["tags"] = "[]"; + out["tags"] = OSUtils::jsonParse(tags); } out["versionMajor"] = mc.version_major(); From 19ccc98f910dcdff8fea73473d3ce2487326f653 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 9 Oct 2025 15:28:48 -0700 Subject: [PATCH 156/245] more variations on checking json --- nonfree/controller/PubSubListener.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 3d64dde616..1cd7f45a6d 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -313,8 +313,11 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N out["name"] = nc.name(); std::string caps = nc.capabilities(); - if (caps == "null") { - out["capabilities"] = "null"; + if (caps.length() == 0) { + out["capabilities"] = "[]"; + } + else if (caps == "null") { + out["capabilities"] = "[]"; } else { out["capabilities"] = OSUtils::jsonParse(caps); @@ -332,7 +335,10 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N } std::string rules = nc.rules(); - if (rules == "null") { + if (rules.length() == 0) { + out["rules"] = "[]"; + } + else if (rules == "null") { out["rules"] = "[]"; } else { @@ -342,7 +348,10 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N out["rulesSource"] = nc.rules_source(); std::string tags = nc.tags(); - if (tags == "[]") { + if (tags.length() == 0) { + out["tags"] = "[]"; + } + else if (tags == "[]") { out["tags"] = "[]"; } else { @@ -493,7 +502,10 @@ nlohmann::json toJson(const pbmessages::MemberChange_Member& mc, pbmessages::Mem out["authenticationExpiryTime"] = mc.auth_expiry_time(); std::string caps = mc.capabilities(); - if (caps == "null") { + if (caps.length() == 0) { + out["capabilities"] = "[]"; + } + else if (caps == "null") { out["capabilities"] = "[]"; } else { @@ -508,7 +520,10 @@ nlohmann::json toJson(const pbmessages::MemberChange_Member& mc, pbmessages::Mem out["revision"] = mc.revision(); std::string tags = mc.tags(); - if (tags == "null") { + if (tags.length() == 0) { + out["tags"] = "[]"; + } + else if (tags == "null") { out["tags"] = "[]"; } else { From bf0fe2c09abb7a7697f588e3d16564d52b277126 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 9 Oct 2025 15:39:40 -0700 Subject: [PATCH 157/245] these should be empty json arrays, not just "[]". Actually these *should* be structs, not filling out json. Adding this to the tech debt backlog --- nonfree/controller/PubSubListener.cpp | 110 +++++++++++++++++--------- 1 file changed, 71 insertions(+), 39 deletions(-) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 1cd7f45a6d..cf830e19c5 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -312,15 +312,21 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N out["id"] = nc.network_id(); out["name"] = nc.name(); - std::string caps = nc.capabilities(); - if (caps.length() == 0) { - out["capabilities"] = "[]"; - } - else if (caps == "null") { - out["capabilities"] = "[]"; + try { + std::string caps = nc.capabilities(); + if (caps.length() == 0) { + out["capabilities"] = nlohmann::json::array(); + } + else if (caps == "null") { + out["capabilities"] = nlohmann::json::array(); + } + else { + out["capabilities"] = OSUtils::jsonParse(caps); + } } - else { - out["capabilities"] = OSUtils::jsonParse(caps); + catch (const nlohmann::json::parse_error& e) { + fprintf(stderr, "toJson Network capabilities JSON parse error: %s\n", e.what()); + out["capabilities"] = nlohmann::json::array(); } out["mtu"] = nc.mtu(); @@ -334,29 +340,41 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N out["remoteTraceTarget"] = ""; } - std::string rules = nc.rules(); - if (rules.length() == 0) { - out["rules"] = "[]"; - } - else if (rules == "null") { - out["rules"] = "[]"; + try { + std::string rules = nc.rules(); + if (rules.length() == 0) { + out["rules"] = nlohmann::json::array(); + } + else if (rules == "null") { + out["rules"] = nlohmann::json::array(); + } + else { + out["rules"] = OSUtils::jsonParse(rules); + } } - else { - out["rules"] = OSUtils::jsonParse(rules); + catch (const nlohmann::json::parse_error& e) { + fprintf(stderr, "toJson Network rules JSON parse error: %s\n", e.what()); + out["rules"] = nlohmann::json::array(); } out["rulesSource"] = nc.rules_source(); - std::string tags = nc.tags(); - if (tags.length() == 0) { - out["tags"] = "[]"; + try { + std::string tags = nc.tags(); + if (tags.length() == 0) { + out["tags"] = nlohmann::json::array(); + } + else if (tags == "[]") { + out["tags"] = nlohmann::json::array(); + } + else { + out["tags"] = OSUtils::jsonParse(tags); + } } - else if (tags == "[]") { + catch (const nlohmann::json::parse_error& e) { + fprintf(stderr, "toJson Network tags JSON parse error: %s\n", e.what()); out["tags"] = "[]"; } - else { - out["tags"] = OSUtils::jsonParse(tags); - } if (nc.has_ipv4_assign_mode()) { nlohmann::json ipv4mode; @@ -501,15 +519,22 @@ nlohmann::json toJson(const pbmessages::MemberChange_Member& mc, pbmessages::Mem out["ssoExempt"] = mc.sso_exempt(); out["authenticationExpiryTime"] = mc.auth_expiry_time(); - std::string caps = mc.capabilities(); - if (caps.length() == 0) { - out["capabilities"] = "[]"; - } - else if (caps == "null") { - out["capabilities"] = "[]"; + try { + std::string caps = mc.capabilities(); + if (caps.length() == 0) { + out["capabilities"] = nlohmann::json::array(); + } + else if (caps == "null") { + out["capabilities"] = nlohmann::json::array(); + } + else { + out["capabilities"] = OSUtils::jsonParse(caps); + } } - else { - out["capabilities"] = OSUtils::jsonParse(caps); + catch (const nlohmann::json::parse_error& e) { + fprintf(stderr, "MemberChange member capabilities JSON parse error: %s\n", e.what()); + fprintf(stderr, "capabilities: %s\n", mc.capabilities().c_str()); + out["capabilities"] = nlohmann::json::array(); } out["creationTime"] = mc.creation_time(); @@ -519,15 +544,22 @@ nlohmann::json toJson(const pbmessages::MemberChange_Member& mc, pbmessages::Mem out["remoteTraceLevel"] = mc.remote_trace_level(); out["revision"] = mc.revision(); - std::string tags = mc.tags(); - if (tags.length() == 0) { - out["tags"] = "[]"; - } - else if (tags == "null") { - out["tags"] = "[]"; + try { + std::string tags = mc.tags(); + if (tags.length() == 0) { + out["tags"] = nlohmann::json::array(); + } + else if (tags == "null") { + out["tags"] = nlohmann::json::array(); + } + else { + out["tags"] = OSUtils::jsonParse(tags); + } } - else { - out["tags"] = OSUtils::jsonParse(tags); + catch (const nlohmann::json::parse_error& e) { + fprintf(stderr, "MemberChange member tags JSON parse error: %s\n", e.what()); + fprintf(stderr, "tags: %s\n", mc.tags().c_str()); + out["tags"] = nlohmann::json::array(); } out["versionMajor"] = mc.version_major(); From 77aa8c7bf8d42ff3b64c71be937c737d9a458318 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 9 Oct 2025 15:47:34 -0700 Subject: [PATCH 158/245] missed one --- nonfree/controller/PubSubListener.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index cf830e19c5..1e93a47a3e 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -373,7 +373,7 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N } catch (const nlohmann::json::parse_error& e) { fprintf(stderr, "toJson Network tags JSON parse error: %s\n", e.what()); - out["tags"] = "[]"; + out["tags"] = nlohmann::json::array(); } if (nc.has_ipv4_assign_mode()) { From 76ba89060b75552ff8c3709a96697a50881a5c99 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 9 Oct 2025 16:29:43 -0700 Subject: [PATCH 159/245] ensure change source is controller if otherwise unset --- nonfree/controller/CentralDB.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index e2a90c0166..3f1a93c037 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1188,6 +1188,9 @@ void CentralDB::commitThread() if (! config["change_source"].is_null()) { change_source = config["change_source"]; } + else { + change_source = "controller"; + } if (! isNewMember && change_source != "controller" && frontend != change_source) { fprintf( stderr, "skipping member %s-%s update. change source: %s, frontend: %s\n", From c21ff23477b648d9cc7201c9feb545ce361844e4 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 27 Oct 2025 09:44:36 +0100 Subject: [PATCH 160/245] Added some more logging to the ctl around deauths --- nonfree/controller/DB.cpp | 5 +++++ nonfree/controller/EmbeddedNetworkController.cpp | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/nonfree/controller/DB.cpp b/nonfree/controller/DB.cpp index a0d76f6c91..c6d7f74484 100644 --- a/nonfree/controller/DB.cpp +++ b/nonfree/controller/DB.cpp @@ -511,9 +511,14 @@ void DB::_networkChanged(nlohmann::json& old, nlohmann::json& networkConfig, boo this->get(networkId, network, members); for (auto i = members.begin(); i != members.end(); ++i) { const std::string nodeID = (*i)["id"]; + fprintf( + stderr, "Deauthorizing member %s on network %s due to network deletion\n", nodeID.c_str(), + ids.c_str()); const uint64_t memberId = Utils::hexStrToU64(nodeID.c_str()); std::unique_lock ll(_changeListeners_l); for (auto j = _changeListeners.begin(); j != _changeListeners.end(); ++j) { + fprintf( + stderr, "Notifying listener of deauthorization of %s on %s\n", nodeID.c_str(), ids.c_str()); (*j)->onNetworkMemberDeauthorize(this, networkId, memberId); } } diff --git a/nonfree/controller/EmbeddedNetworkController.cpp b/nonfree/controller/EmbeddedNetworkController.cpp index f442bc6a8f..eb8c8c0431 100644 --- a/nonfree/controller/EmbeddedNetworkController.cpp +++ b/nonfree/controller/EmbeddedNetworkController.cpp @@ -1655,6 +1655,7 @@ void EmbeddedNetworkController::onNetworkMemberDeauthorize(const void* db, uint6 auto span = tracer->StartSpan("embedded_controller::onNetworkMemberDeauthorize"); auto scope = tracer->WithActiveSpan(span); + fprintf(stderr, "Member Deauthorized: nwid=%.16llx, nodeid=%.10llx\n", networkId, memberId); const int64_t now = OSUtils::now(); Revocation rev( (uint32_t)_node->prng(), networkId, 0, now, ZT_REVOCATION_FLAG_FAST_PROPAGATE, Address(memberId), @@ -1663,8 +1664,13 @@ void EmbeddedNetworkController::onNetworkMemberDeauthorize(const void* db, uint6 { std::lock_guard l(_memberStatus_l); for (auto i = _memberStatus.begin(); i != _memberStatus.end(); ++i) { - if ((i->first.networkId == networkId) && (i->second.online(now))) + if ((i->first.networkId == networkId) && (i->second.online(now))) { _node->ncSendRevocation(Address(i->first.nodeId), rev); + fprintf(stderr, " Sent revocation to %.10llx\n", i->first.nodeId); + } + else { + fprintf(stderr, " Not sending revocation to %.10llx\n", i->first.nodeId); + } } } } From 30c4484731b28fe14961f16d23442b9d40476177 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 27 Oct 2025 11:01:36 +0100 Subject: [PATCH 161/245] Set ordering key on pubsub message publishing. --- nonfree/controller/CtlUtil.cpp | 1 + nonfree/controller/PubSubWriter.cpp | 34 ++++++++++++++++++++++++----- nonfree/controller/PubSubWriter.hpp | 2 +- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/nonfree/controller/CtlUtil.cpp b/nonfree/controller/CtlUtil.cpp index 4ed30b040e..32ce008ba2 100644 --- a/nonfree/controller/CtlUtil.cpp +++ b/nonfree/controller/CtlUtil.cpp @@ -139,6 +139,7 @@ void create_gcp_pubsub_subscription_if_needed( request.set_name(subscriptionName); request.set_topic(pubsub::Topic(project_id, topic_id).FullName()); request.set_filter("(attributes.controller_id=\"" + controller_id + "\")"); + request.set_enable_message_ordering(true); auto createResult = subscriptionAdminClient.CreateSubscription(request); if (! createResult.ok()) { fprintf(stderr, "Failed to create subscription: %s\n", createResult.status().message().c_str()); diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index d5193ab285..00bd26598d 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -51,7 +51,10 @@ PubSubWriter::~PubSubWriter() { } -bool PubSubWriter::publishMessage(const std::string& payload, const std::string& frontend) +bool PubSubWriter::publishMessage( + const std::string& payload, + const std::string& frontend, + const std::string& orderingKey) { fprintf(stderr, "Publishing message to %s\n", _topic.c_str()); std::vector > attributes; @@ -61,7 +64,11 @@ bool PubSubWriter::publishMessage(const std::string& payload, const std::string& attributes.emplace_back("frontend", frontend); } - auto msg = pubsub::MessageBuilder {}.SetData(payload).SetAttributes(attributes).Build(); + auto msg_tmp = pubsub::MessageBuilder {}.SetData(payload).SetAttributes(attributes); + if (! orderingKey.empty()) { + msg_tmp.SetOrderingKey(orderingKey); + } + auto msg = std::move(msg_tmp).Build(); auto message_id = _publisher->Publish(std::move(msg)).get(); if (! message_id) { fprintf(stderr, "Failed to publish message: %s\n", std::move(message_id).status().message().c_str()); @@ -79,6 +86,15 @@ bool PubSubWriter::publishNetworkChange( { fprintf(stderr, "Publishing network change\n"); pbmessages::NetworkChange* nc = networkChangeFromJson(_controller_id, oldNetwork, newNetwork); + + std::string networkID; + if (nc->has_new_()) { + networkID = nc->new_().network_id(); + } + else if (nc->has_old()) { + networkID = nc->old().network_id(); + } + std::string payload; if (! nc->SerializeToString(&payload)) { fprintf(stderr, "Failed to serialize NetworkChange protobuf message\n"); @@ -86,7 +102,7 @@ bool PubSubWriter::publishNetworkChange( return false; } delete nc; - return publishMessage(payload, frontend); + return publishMessage(payload, frontend, networkID); } bool PubSubWriter::publishMemberChange( @@ -96,6 +112,14 @@ bool PubSubWriter::publishMemberChange( { fprintf(stderr, "Publishing member change\n"); pbmessages::MemberChange* mc = memberChangeFromJson(_controller_id, oldMember, newMember); + std::string memberID; + if (mc->has_new_()) { + memberID = mc->new_().network_id() + "-" + mc->new_().device_id(); + } + else if (mc->has_old()) { + memberID = mc->old().network_id() + "-" + mc->old().device_id(); + } + std::string payload; if (! mc->SerializeToString(&payload)) { fprintf(stderr, "Failed to serialize MemberChange protobuf message\n"); @@ -104,7 +128,7 @@ bool PubSubWriter::publishMemberChange( } delete mc; - return publishMessage(payload, frontend); + return publishMessage(payload, frontend, memberID); } bool PubSubWriter::publishStatusChange( @@ -140,7 +164,7 @@ bool PubSubWriter::publishStatusChange( return false; } - return publishMessage(payload, ""); + return publishMessage(payload, "", ""); } pbmessages::NetworkChange_Network* networkFromJson(const nlohmann::json& j) diff --git a/nonfree/controller/PubSubWriter.hpp b/nonfree/controller/PubSubWriter.hpp index bdc0103932..9db4d0b9dd 100644 --- a/nonfree/controller/PubSubWriter.hpp +++ b/nonfree/controller/PubSubWriter.hpp @@ -31,7 +31,7 @@ class PubSubWriter { int64_t last_seen); protected: - bool publishMessage(const std::string& payload, const std::string& frontend); + bool publishMessage(const std::string& payload, const std::string& frontend, const std::string& orderingKey); private: std::string _controller_id; From 5c27068b801cad779fa42884a344ca12fbaf2a6d Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 30 Oct 2025 13:47:50 +0100 Subject: [PATCH 162/245] Enable cross-service propagation of otel trace metadata --- nonfree/controller/CentralDB.cpp | 976 ++++++++++++++------------ nonfree/controller/CentralDB.hpp | 15 +- nonfree/controller/OtelCarrier.hpp | 47 ++ nonfree/controller/PubSubListener.cpp | 53 +- nonfree/controller/PubSubWriter.cpp | 21 +- service/OneService.cpp | 18 + 6 files changed, 658 insertions(+), 472 deletions(-) create mode 100644 nonfree/controller/OtelCarrier.hpp diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 3f1a93c037..5646f8c778 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -23,12 +23,14 @@ #include "ControllerConfig.hpp" #include "CtlUtil.hpp" #include "EmbeddedNetworkController.hpp" +#include "OtelCarrier.hpp" #include "PostgresStatusWriter.hpp" #include "PubSubListener.hpp" #include "PubSubWriter.hpp" #include "Redis.hpp" #include "RedisListener.hpp" #include "RedisStatusWriter.hpp" +#include "opentelemetry/context/propagation/global_propagator.h" #include "opentelemetry/trace/provider.h" #include @@ -314,6 +316,9 @@ bool CentralDB::save(nlohmann::json& record, bool notifyListeners) } const std::string objtype = record["objtype"]; if (objtype == "network") { + auto span = tracer->StartSpan("CentralDB::save::network"); + auto scope = tracer->WithActiveSpan(span); + fprintf(stderr, "CentralDB network save %s\n", record["id"].get().c_str()); const uint64_t nwid = OSUtils::jsonIntHex(record["id"], 0ULL); if (nwid) { @@ -322,12 +327,23 @@ bool CentralDB::save(nlohmann::json& record, bool notifyListeners) if ((! old.is_object()) || (! _compareRecords(old, record))) { fprintf(stderr, "posting network change to commit queue\n"); record["revision"] = OSUtils::jsonInt(record["revision"], 0ULL) + 1ULL; - _commitQueue.post(std::pair(record, notifyListeners)); + _queueItem qi; + qi.jsonData = record; + qi.notifyListeners = notifyListeners; + OtelCarrier > carrier(qi.traceContext); + auto current_ctx = opentelemetry::context::RuntimeContext::GetCurrent(); + auto propagator = + opentelemetry::context::propagation::GlobalTextMapPropagator::GetGlobalPropagator(); + propagator->Inject(carrier, current_ctx); + _commitQueue.post(qi); modified = true; } } } else if (objtype == "member") { + auto span = tracer->StartSpan("CentralDB::save::member"); + auto scope = tracer->WithActiveSpan(span); + std::string networkId = record["nwid"]; std::string memberId = record["id"]; const uint64_t nwid = OSUtils::jsonIntHex(record["nwid"], 0ULL); @@ -339,7 +355,17 @@ bool CentralDB::save(nlohmann::json& record, bool notifyListeners) if ((! old.is_object()) || (! _compareRecords(old, record))) { fprintf(stderr, "posting member change to commit queue\n"); record["revision"] = OSUtils::jsonInt(record["revision"], 0ULL) + 1ULL; - _commitQueue.post(std::pair(record, notifyListeners)); + + _queueItem qi; + qi.jsonData = record; + qi.notifyListeners = notifyListeners; + OtelCarrier > carrier(qi.traceContext); + auto current_ctx = opentelemetry::context::RuntimeContext::GetCurrent(); + auto propagator = + opentelemetry::context::propagation::GlobalTextMapPropagator::GetGlobalPropagator(); + propagator->Inject(carrier, current_ctx); + _commitQueue.post(qi); + modified = true; } else { @@ -373,13 +399,19 @@ void CentralDB::eraseNetwork(const uint64_t networkId) char tmp2[24]; waitForReady(); Utils::hex(networkId, tmp2); - std::pair tmp; - tmp.first["id"] = tmp2; - tmp.first["objtype"] = "_delete_network"; - tmp.second = true; - _commitQueue.post(tmp); + + _queueItem qi; + qi.jsonData["id"] = tmp2; + qi.jsonData["objtype"] = "_delete_network"; + qi.notifyListeners = true; + OtelCarrier > carrier(qi.traceContext); + auto current_ctx = opentelemetry::context::RuntimeContext::GetCurrent(); + auto propagator = opentelemetry::context::propagation::GlobalTextMapPropagator::GetGlobalPropagator(); + propagator->Inject(carrier, current_ctx); + _commitQueue.post(qi); + nlohmann::json nullJson; - _networkChanged(tmp.first, nullJson, true); + _networkChanged(qi.jsonData, nullJson, true); } void CentralDB::eraseMember(const uint64_t networkId, const uint64_t memberId) @@ -396,16 +428,20 @@ void CentralDB::eraseMember(const uint64_t networkId, const uint64_t memberId) fprintf(stderr, "CentralDB::eraseMember\n"); char tmp2[24]; waitForReady(); - std::pair tmp, nw; - Utils::hex(networkId, tmp2); - tmp.first["nwid"] = tmp2; - Utils::hex(memberId, tmp2); - tmp.first["id"] = tmp2; - tmp.first["objtype"] = "_delete_member"; - tmp.second = true; - _commitQueue.post(tmp); + + _queueItem qi; + qi.jsonData["nwid"] = tmp2; + qi.jsonData["id"] = tmp2; + qi.jsonData["objtype"] = "_delete_member"; + qi.notifyListeners = true; + OtelCarrier > carrier(qi.traceContext); + auto current_ctx = opentelemetry::context::RuntimeContext::GetCurrent(); + auto propagator = opentelemetry::context::propagation::GlobalTextMapPropagator::GetGlobalPropagator(); + propagator->Inject(carrier, current_ctx); + _commitQueue.post(qi); + nlohmann::json nullJson; - _memberChanged(tmp.first, nullJson, true); + _memberChanged(qi.jsonData, nullJson, true); } void CentralDB::nodeIsOnline( @@ -1108,440 +1144,464 @@ void CentralDB::heartbeat() void CentralDB::commitThread() { fprintf(stderr, "%s: commitThread start\n", _myAddressStr.c_str()); - std::pair qitem; + _queueItem qitem; while (_commitQueue.get(qitem) & (_run == 1)) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("CentralDB"); - auto span = tracer->StartSpan("CentralDB::commitThread"); - auto scope = tracer->WithActiveSpan(span); - fprintf(stderr, "commitThread tick\n"); - if (! qitem.first.is_object()) { - fprintf(stderr, "not an object\n"); - continue; + fprintf(stderr, "checking qitem trace context\n"); + for (auto const& kv : qitem.traceContext) { + fprintf(stderr, "traceContext: %s: %s\n", kv.first.c_str(), kv.second.c_str()); } - std::shared_ptr c; - try { - c = _pool->borrow(); - } - catch (std::exception& e) { - fprintf(stderr, "ERROR: %s\n", e.what()); - continue; - } + auto propagator = opentelemetry::context::propagation::GlobalTextMapPropagator::GetGlobalPropagator(); + OtelCarrier > carrier(qitem.traceContext); + auto current_ctx = opentelemetry::context::RuntimeContext::GetCurrent(); + auto new_context = propagator->Extract(carrier, current_ctx); + auto remote_span = opentelemetry::trace::GetSpan(new_context); + auto remote_scope = tracer->WithActiveSpan(remote_span); - if (! c) { - fprintf(stderr, "Error getting database connection\n"); - continue; - } + { + auto span = tracer->StartSpan("CentralDB::commitThread"); + auto scope = tracer->WithActiveSpan(span); - Metrics::pgsql_commit_ticks++; - try { - nlohmann::json& config = (qitem.first); - const std::string objtype = config["objtype"]; - if (objtype == "member") { - auto mspan = tracer->StartSpan("CentralDB::commitThread::member"); - auto mscope = tracer->WithActiveSpan(mspan); + fprintf(stderr, "commitThread tick\n"); + if (! qitem.jsonData.is_object()) { + fprintf(stderr, "not an object\n"); + continue; + } - // fprintf(stderr, "%s: commitThread: member\n", _myAddressStr.c_str()); - std::string memberId; - std::string networkId; + std::shared_ptr c; + try { + c = _pool->borrow(); + } + catch (std::exception& e) { + fprintf(stderr, "ERROR: %s\n", e.what()); + continue; + } - try { - pqxx::work w(*c->c); + if (! c) { + fprintf(stderr, "Error getting database connection\n"); + continue; + } - memberId = config["id"]; - networkId = config["nwid"]; - fprintf(stderr, "commit member %s-%s\n", networkId.c_str(), memberId.c_str()); + Metrics::pgsql_commit_ticks++; + try { + nlohmann::json& config = (qitem.jsonData); + const std::string objtype = config["objtype"]; + if (objtype == "member") { + auto mspan = tracer->StartSpan("CentralDB::commitThread::member"); + auto mscope = tracer->WithActiveSpan(mspan); - std::string target = "NULL"; - if (! config["remoteTraceTarget"].is_null()) { - target = config["remoteTraceTarget"]; - } + // fprintf(stderr, "%s: commitThread: member\n", _myAddressStr.c_str()); + std::string memberId; + std::string networkId; - // get network and the frontend it is assigned to - // if network does not exist, skip member update - pqxx::row nwrow = - w.exec( - "SELECT COUNT(id), frontend FROM networks_ctl WHERE id = $1 GROUP BY frontend", - pqxx::params { networkId }) - .one_row(); - int nwcount = nwrow[0].as(); - std::string frontend = nwrow[1].as(); + try { + pqxx::work w(*c->c); - if (nwcount != 1) { - fprintf(stderr, "network %s does not exist. skipping member upsert\n", networkId.c_str()); - w.abort(); - _pool->unborrow(c); - continue; - } + memberId = config["id"]; + networkId = config["nwid"]; + fprintf(stderr, "commit member %s-%s\n", networkId.c_str(), memberId.c_str()); - pqxx::row mrow = w.exec( - "SELECT COUNT(device_id) FROM network_memberships_ctl WHERE device_id = $1 " - "AND network_id = $2", - pqxx::params { memberId, networkId }) - .one_row(); - int membercount = mrow[0].as(); - bool isNewMember = (membercount == 0); - - std::string change_source; - if (! config["change_source"].is_null()) { - change_source = config["change_source"]; - } - else { - change_source = "controller"; - } - if (! isNewMember && change_source != "controller" && frontend != change_source) { - fprintf( - stderr, "skipping member %s-%s update. change source: %s, frontend: %s\n", - networkId.c_str(), memberId.c_str(), change_source.c_str(), frontend.c_str()); - // if it is not a new member and the change source is not the controller and doesn't match the - // frontend, don't apply the change. - continue; - } + std::string target = "NULL"; + if (! config["remoteTraceTarget"].is_null()) { + target = config["remoteTraceTarget"]; + } - std::vector ipAssignments; - fprintf( - stderr, "Saving IP Assignments: \n\tipAssignments: %s\n", - OSUtils::jsonDump(config["ipAssignments"], -1).c_str()); - if (config["ipAssignments"].is_array()) { - for (auto& ip : config["ipAssignments"]) { - if (ip.is_string()) { - ipAssignments.push_back(ip.get()); + // get network and the frontend it is assigned to + // if network does not exist, skip member update + pqxx::row nwrow = + w.exec( + "SELECT COUNT(id), frontend FROM networks_ctl WHERE id = $1 GROUP BY frontend", + pqxx::params { networkId }) + .one_row(); + int nwcount = nwrow[0].as(); + std::string frontend = nwrow[1].as(); + + if (nwcount != 1) { + fprintf(stderr, "network %s does not exist. skipping member upsert\n", networkId.c_str()); + w.abort(); + _pool->unborrow(c); + continue; + } + + pqxx::row mrow = + w.exec( + "SELECT COUNT(device_id) FROM network_memberships_ctl WHERE device_id = $1 " + "AND network_id = $2", + pqxx::params { memberId, networkId }) + .one_row(); + int membercount = mrow[0].as(); + bool isNewMember = (membercount == 0); + + std::string change_source; + if (! config["change_source"].is_null()) { + change_source = config["change_source"]; + } + else { + change_source = "controller"; + } + if (! isNewMember && change_source != "controller" && frontend != change_source) { + fprintf( + stderr, "skipping member %s-%s update. change source: %s, frontend: %s\n", + networkId.c_str(), memberId.c_str(), change_source.c_str(), frontend.c_str()); + // if it is not a new member and the change source is not the controller and doesn't match + // the frontend, don't apply the change. + continue; + } + + std::vector ipAssignments; + fprintf( + stderr, "Saving IP Assignments: \n\tipAssignments: %s\n", + OSUtils::jsonDump(config["ipAssignments"], -1).c_str()); + if (config["ipAssignments"].is_array()) { + for (auto& ip : config["ipAssignments"]) { + if (ip.is_string()) { + ipAssignments.push_back(ip.get()); + } } } - } - fprintf(stderr, "member json: %s\n", config.dump().c_str()); + fprintf(stderr, "member json: %s\n", config.dump().c_str()); + + int64_t vMajor = OSUtils::jsonUInt(config["vMajor"], 0); + int64_t vMinor = OSUtils::jsonUInt(config["vMinor"], 0); + int64_t vRev = OSUtils::jsonUInt(config["vRev"], 0); + int64_t vProto = OSUtils::jsonUInt(config["vProto"], 0); + if (vMajor < 0) + vMajor = 0; + if (vMinor < 0) + vMinor = 0; + if (vRev < 0) + vRev = 0; + if (vProto < 0) + vProto = 0; + + pqxx::result res = + w.exec( + "INSERT INTO network_memberships_ctl (device_id, network_id, authorized, " + "active_bridge, " + "ip_assignments, " + "no_auto_assign_ips, sso_exempt, authentication_expiry_time, capabilities, " + "creation_time, " + "identity, last_authorized_time, last_deauthorized_time, " + "remote_trace_level, remote_trace_target, revision, tags, version_major, " + "version_minor, " + "version_revision, version_protocol) " + "VALUES ($1, $2, $3, $4, $5, $6, $7, TO_TIMESTAMP($8::double precision/1000), $9, " + "TO_TIMESTAMP($10::double precision/1000), $11, TO_TIMESTAMP($12::double " + "precision/1000), " + "TO_TIMESTAMP($13::double precision/1000), $14, $15, $16, $17, $18, $19, $20, $21) " + "ON CONFLICT (device_id, network_id) DO UPDATE SET " + "authorized = EXCLUDED.authorized, active_bridge = EXCLUDED.active_bridge, " + "ip_assignments = EXCLUDED.ip_assignments, no_auto_assign_ips = " + "EXCLUDED.no_auto_assign_ips, " + "sso_exempt = EXCLUDED.sso_exempt, authentication_expiry_time = " + "EXCLUDED.authentication_expiry_time, " + "capabilities = EXCLUDED.capabilities, creation_time = EXCLUDED.creation_time, " + "identity = EXCLUDED.identity, last_authorized_time = EXCLUDED.last_authorized_time, " + "last_deauthorized_time = EXCLUDED.last_deauthorized_time, " + "remote_trace_level = EXCLUDED.remote_trace_level, remote_trace_target = " + "EXCLUDED.remote_trace_target, " + "revision = EXCLUDED.revision, tags = EXCLUDED.tags, version_major = " + "EXCLUDED.version_major, " + "version_minor = EXCLUDED.version_minor, version_revision = " + "EXCLUDED.version_revision, " + "version_protocol = EXCLUDED.version_protocol", + pqxx::params { memberId, + networkId, + OSUtils::jsonBool(config["authorized"], false), + OSUtils::jsonBool(config["activeBridge"], false), + ipAssignments, + OSUtils::jsonBool(config["noAutoAssignIps"], false), + OSUtils::jsonBool(config["ssoExempt"], false), + OSUtils::jsonInt(config["authenticationExpiryTime"], 0), + OSUtils::jsonDump(config["capabilities"], -1), + OSUtils::jsonInt(config["creationTime"], OSUtils::now()), + OSUtils::jsonString(config["identity"], ""), + OSUtils::jsonInt(config["lastAuthorizedTime"], 0), + OSUtils::jsonInt(config["lastDeauthorizedTime"], 0), + OSUtils::jsonInt(config["remoteTraceLevel"], 0), + target, + OSUtils::jsonInt(config["revision"], 0), + OSUtils::jsonDump(config["tags"], -1), + vMajor, + vMinor, + vRev, + vProto }) + .no_rows(); - int64_t vMajor = OSUtils::jsonUInt(config["vMajor"], 0); - int64_t vMinor = OSUtils::jsonUInt(config["vMinor"], 0); - int64_t vRev = OSUtils::jsonUInt(config["vRev"], 0); - int64_t vProto = OSUtils::jsonUInt(config["vProto"], 0); - if (vMajor < 0) - vMajor = 0; - if (vMinor < 0) - vMinor = 0; - if (vRev < 0) - vRev = 0; - if (vProto < 0) - vProto = 0; - - pqxx::result res = - w.exec( - "INSERT INTO network_memberships_ctl (device_id, network_id, authorized, active_bridge, " - "ip_assignments, " - "no_auto_assign_ips, sso_exempt, authentication_expiry_time, capabilities, creation_time, " - "identity, last_authorized_time, last_deauthorized_time, " - "remote_trace_level, remote_trace_target, revision, tags, version_major, version_minor, " - "version_revision, version_protocol) " - "VALUES ($1, $2, $3, $4, $5, $6, $7, TO_TIMESTAMP($8::double precision/1000), $9, " - "TO_TIMESTAMP($10::double precision/1000), $11, TO_TIMESTAMP($12::double precision/1000), " - "TO_TIMESTAMP($13::double precision/1000), $14, $15, $16, $17, $18, $19, $20, $21) " - "ON CONFLICT (device_id, network_id) DO UPDATE SET " - "authorized = EXCLUDED.authorized, active_bridge = EXCLUDED.active_bridge, " - "ip_assignments = EXCLUDED.ip_assignments, no_auto_assign_ips = " - "EXCLUDED.no_auto_assign_ips, " - "sso_exempt = EXCLUDED.sso_exempt, authentication_expiry_time = " - "EXCLUDED.authentication_expiry_time, " - "capabilities = EXCLUDED.capabilities, creation_time = EXCLUDED.creation_time, " - "identity = EXCLUDED.identity, last_authorized_time = EXCLUDED.last_authorized_time, " - "last_deauthorized_time = EXCLUDED.last_deauthorized_time, " - "remote_trace_level = EXCLUDED.remote_trace_level, remote_trace_target = " - "EXCLUDED.remote_trace_target, " - "revision = EXCLUDED.revision, tags = EXCLUDED.tags, version_major = " - "EXCLUDED.version_major, " - "version_minor = EXCLUDED.version_minor, version_revision = EXCLUDED.version_revision, " - "version_protocol = EXCLUDED.version_protocol", - pqxx::params { memberId, - networkId, - OSUtils::jsonBool(config["authorized"], false), - OSUtils::jsonBool(config["activeBridge"], false), - ipAssignments, - OSUtils::jsonBool(config["noAutoAssignIps"], false), - OSUtils::jsonBool(config["ssoExempt"], false), - OSUtils::jsonInt(config["authenticationExpiryTime"], 0), - OSUtils::jsonDump(config["capabilities"], -1), - OSUtils::jsonInt(config["creationTime"], OSUtils::now()), - OSUtils::jsonString(config["identity"], ""), - OSUtils::jsonInt(config["lastAuthorizedTime"], 0), - OSUtils::jsonInt(config["lastDeauthorizedTime"], 0), - OSUtils::jsonInt(config["remoteTraceLevel"], 0), - target, - OSUtils::jsonInt(config["revision"], 0), - OSUtils::jsonDump(config["tags"], -1), - vMajor, - vMinor, - vRev, - vProto }) - .no_rows(); - - w.commit(); - - if (_listenerMode == LISTENER_MODE_PUBSUB) { - // Publish change to pubsub stream - - if (config["change_source"].is_null() || config["change_source"] == "controller") { - nlohmann::json oldMember; - nlohmann::json newMember = config; - if (! isNewMember) { - oldMember = _getNetworkMember(w, networkId, memberId); + w.commit(); + + if (_listenerMode == LISTENER_MODE_PUBSUB) { + // Publish change to pubsub stream + + if (config["change_source"].is_null() || config["change_source"] == "controller") { + nlohmann::json oldMember; + nlohmann::json newMember = config; + if (! isNewMember) { + oldMember = _getNetworkMember(w, networkId, memberId); + } + _changeNotifier->notifyMemberChange(oldMember, newMember, frontend); } - _changeNotifier->notifyMemberChange(oldMember, newMember, frontend); } - } - if (_smee != NULL && isNewMember) { - // TODO: Smee Notifications for New Members - // pqxx::row row = w.exec_params1( - // "SELECT " - // " count(h.hook_id) " - // "FROM " - // " ztc_hook h " - // " INNER JOIN ztc_org o ON o.org_id = h.org_id " - // " INNER JOIN ztc_network n ON n.owner_id = o.owner_id " - // " WHERE " - // "n.id = $1 ", - // networkId); - // int64_t hookCount = row[0].as(); - // if (hookCount > 0) { - // notifyNewMember(networkId, memberId); - // } - } + if (_smee != NULL && isNewMember) { + // TODO: Smee Notifications for New Members + // pqxx::row row = w.exec_params1( + // "SELECT " + // " count(h.hook_id) " + // "FROM " + // " ztc_hook h " + // " INNER JOIN ztc_org o ON o.org_id = h.org_id " + // " INNER JOIN ztc_network n ON n.owner_id = o.owner_id " + // " WHERE " + // "n.id = $1 ", + // networkId); + // int64_t hookCount = row[0].as(); + // if (hookCount > 0) { + // notifyNewMember(networkId, memberId); + // } + } - const uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); - const uint64_t memberidInt = OSUtils::jsonIntHex(config["id"], 0ULL); - if (nwidInt && memberidInt) { - nlohmann::json nwOrig; - nlohmann::json memOrig; + const uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); + const uint64_t memberidInt = OSUtils::jsonIntHex(config["id"], 0ULL); + if (nwidInt && memberidInt) { + nlohmann::json nwOrig; + nlohmann::json memOrig; - nlohmann::json memNew(config); + nlohmann::json memNew(config); - get(nwidInt, nwOrig, memberidInt, memOrig); + get(nwidInt, nwOrig, memberidInt, memOrig); - _memberChanged(memOrig, memNew, qitem.second); + _memberChanged(memOrig, memNew, qitem.notifyListeners); + } + else { + fprintf( + stderr, "%s: Can't notify of change. Error parsing nwid or memberid: %llu-%llu\n", + _myAddressStr.c_str(), (unsigned long long)nwidInt, (unsigned long long)memberidInt); + } } - else { + catch (std::exception& e) { fprintf( - stderr, "%s: Can't notify of change. Error parsing nwid or memberid: %llu-%llu\n", - _myAddressStr.c_str(), (unsigned long long)nwidInt, (unsigned long long)memberidInt); + stderr, "%s ERROR: Error updating member %s-%s: %s\n", _myAddressStr.c_str(), + networkId.c_str(), memberId.c_str(), e.what()); + mspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); } } - catch (std::exception& e) { - fprintf( - stderr, "%s ERROR: Error updating member %s-%s: %s\n", _myAddressStr.c_str(), networkId.c_str(), - memberId.c_str(), e.what()); - mspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - } - } - else if (objtype == "network") { - auto nspan = tracer->StartSpan("CentralDB::commitThread::network"); - auto nscope = tracer->WithActiveSpan(nspan); - - try { - // fprintf(stderr, "%s: commitThread: network\n", _myAddressStr.c_str()); - pqxx::work w(*c->c); + else if (objtype == "network") { + auto nspan = tracer->StartSpan("CentralDB::commitThread::network"); + auto nscope = tracer->WithActiveSpan(nspan); - std::string id = config["id"]; - fprintf(stderr, "commit network %s\n", id.c_str()); + try { + // fprintf(stderr, "%s: commitThread: network\n", _myAddressStr.c_str()); + pqxx::work w(*c->c); - pqxx::row nwrow = - w.exec("SELECT COUNT(id) frontend FROM networks_ctl WHERE id = $1", pqxx::params { id }) - .one_row(); - int nwcount = nwrow[0].as(); - bool isNewNetwork = (nwcount == 0); - std::string frontend = ""; + std::string id = config["id"]; + fprintf(stderr, "commit network %s\n", id.c_str()); - if (! isNewNetwork) { pqxx::row nwrow = - w.exec("SELECT frontend FROM networks_ctl WHERE id = $1", pqxx::params { id }).one_row(); - frontend = nwrow[0].as(); - } + w.exec("SELECT COUNT(id) frontend FROM networks_ctl WHERE id = $1", pqxx::params { id }) + .one_row(); + int nwcount = nwrow[0].as(); + bool isNewNetwork = (nwcount == 0); + std::string frontend = ""; + + if (! isNewNetwork) { + pqxx::row nwrow = + w.exec("SELECT frontend FROM networks_ctl WHERE id = $1", pqxx::params { id }) + .one_row(); + frontend = nwrow[0].as(); + } - std::string change_source; - if (! config["change_source"].is_null()) { - change_source = config["change_source"]; - } + std::string change_source; + if (! config["change_source"].is_null()) { + change_source = config["change_source"]; + } - if (! isNewNetwork && change_source != "controller" && frontend != change_source) { - // if it is not a new network and the change source is not the controller and doesn't match the - // frontend, don't apply the change. - fprintf( - stderr, "Skipping network update %s. isNewNetwork: %s, change_source: %s, frontend: %s\n", - id.c_str(), isNewNetwork ? "true" : "false", change_source.c_str(), frontend.c_str()); - continue; - } + if (! isNewNetwork && change_source != "controller" && frontend != change_source) { + // if it is not a new network and the change source is not the controller and doesn't match + // the frontend, don't apply the change. + fprintf( + stderr, + "Skipping network update %s. isNewNetwork: %s, change_source: %s, frontend: %s\n", + id.c_str(), isNewNetwork ? "true" : "false", change_source.c_str(), frontend.c_str()); + continue; + } + + pqxx::result res = w.exec( + "INSERT INTO networks_ctl (id, name, configuration, controller_id, revision, frontend) " + "VALUES ($1, $2, $3, $4, $5, $6) " + "ON CONFLICT (id) DO UPDATE SET " + "name = EXCLUDED.name, configuration = EXCLUDED.configuration, revision = " + "EXCLUDED.revision+1, " + "frontend = EXCLUDED.frontend", + pqxx::params { id, OSUtils::jsonString(config["name"], ""), OSUtils::jsonDump(config, -1), + _myAddressStr, ((uint64_t)config["revision"]), change_source }); - pqxx::result res = w.exec( - "INSERT INTO networks_ctl (id, name, configuration, controller_id, revision, frontend) " - "VALUES ($1, $2, $3, $4, $5, $6) " - "ON CONFLICT (id) DO UPDATE SET " - "name = EXCLUDED.name, configuration = EXCLUDED.configuration, revision = EXCLUDED.revision+1, " - "frontend = EXCLUDED.frontend", - pqxx::params { id, OSUtils::jsonString(config["name"], ""), OSUtils::jsonDump(config, -1), - _myAddressStr, ((uint64_t)config["revision"]), change_source }); - - w.commit(); - - if (_listenerMode == LISTENER_MODE_PUBSUB) { - // Publish change to pubsub stream - if (config["change_source"].is_null() || config["change_source"] == "controller") { - nlohmann::json oldNetwork; - nlohmann::json newNetwork = config; - if (! isNewNetwork) { - oldNetwork = _getNetwork(w, id); + w.commit(); + + if (_listenerMode == LISTENER_MODE_PUBSUB) { + // Publish change to pubsub stream + if (config["change_source"].is_null() || config["change_source"] == "controller") { + nlohmann::json oldNetwork; + nlohmann::json newNetwork = config; + if (! isNewNetwork) { + oldNetwork = _getNetwork(w, id); + } + _changeNotifier->notifyNetworkChange(oldNetwork, newNetwork, frontend); } - _changeNotifier->notifyNetworkChange(oldNetwork, newNetwork, frontend); } - } - const uint64_t nwidInt = OSUtils::jsonIntHex(config["id"], 0ULL); - if (nwidInt) { - nlohmann::json nwOrig; - nlohmann::json nwNew(config); + const uint64_t nwidInt = OSUtils::jsonIntHex(config["id"], 0ULL); + if (nwidInt) { + nlohmann::json nwOrig; + nlohmann::json nwNew(config); - get(nwidInt, nwOrig); + get(nwidInt, nwOrig); - _networkChanged(nwOrig, nwNew, qitem.second); - } - else { - fprintf( - stderr, "%s: Can't notify network changed: %llu\n", _myAddressStr.c_str(), - (unsigned long long)nwidInt); - } - } - catch (std::exception& e) { - nspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "%s ERROR: Error updating network: %s\n", _myAddressStr.c_str(), e.what()); - } - if (_listenerMode == LISTENER_MODE_REDIS && _redisMemberStatus) { - try { - std::string id = config["id"]; - std::string controllerId = _myAddressStr.c_str(); - std::string key = "networks:{" + controllerId + "}"; - if (_cc->redisConfig->clusterMode) { - _cluster->sadd(key, id); + _networkChanged(nwOrig, nwNew, qitem.notifyListeners); } else { - _redis->sadd(key, id); + fprintf( + stderr, "%s: Can't notify network changed: %llu\n", _myAddressStr.c_str(), + (unsigned long long)nwidInt); } } - catch (sw::redis::Error& e) { + catch (std::exception& e) { nspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "ERROR: Error adding network to Redis: %s\n", e.what()); + fprintf(stderr, "%s ERROR: Error updating network: %s\n", _myAddressStr.c_str(), e.what()); + } + if (_listenerMode == LISTENER_MODE_REDIS && _redisMemberStatus) { + try { + std::string id = config["id"]; + std::string controllerId = _myAddressStr.c_str(); + std::string key = "networks:{" + controllerId + "}"; + if (_cc->redisConfig->clusterMode) { + _cluster->sadd(key, id); + } + else { + _redis->sadd(key, id); + } + } + catch (sw::redis::Error& e) { + nspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + fprintf(stderr, "ERROR: Error adding network to Redis: %s\n", e.what()); + } } } - } - else if (objtype == "_delete_network") { - auto dspan = tracer->StartSpan("CentralDB::commitThread::_delete_network"); - auto dscope = tracer->WithActiveSpan(dspan); + else if (objtype == "_delete_network") { + auto dspan = tracer->StartSpan("CentralDB::commitThread::_delete_network"); + auto dscope = tracer->WithActiveSpan(dspan); - // fprintf(stderr, "%s: commitThread: delete network\n", _myAddressStr.c_str()); - try { - pqxx::work w(*c->c); - std::string networkId = config["id"]; - fprintf(stderr, "Deleting network %s\n", networkId.c_str()); - w.exec("DELETE FROM network_memberships_ctl WHERE network_id = $1", pqxx::params { networkId }); - w.exec("DELETE FROM networks_ctl WHERE id = $1", pqxx::params { networkId }); - - w.commit(); - - uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); - json oldConfig; - get(nwidInt, oldConfig); - json empty; - _networkChanged(oldConfig, empty, qitem.second); - } - catch (std::exception& e) { - dspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "%s ERROR: Error deleting network: %s\n", _myAddressStr.c_str(), e.what()); - } - if (_listenerMode == LISTENER_MODE_REDIS && _redisMemberStatus) { + // fprintf(stderr, "%s: commitThread: delete network\n", _myAddressStr.c_str()); try { - std::string id = config["id"]; - std::string controllerId = _myAddressStr.c_str(); - std::string key = "networks:{" + controllerId + "}"; - if (_cc->redisConfig->clusterMode) { - _cluster->srem(key, id); - _cluster->del("network-nodes-online:{" + controllerId + "}:" + id); - } - else { - _redis->srem(key, id); - _redis->del("network-nodes-online:{" + controllerId + "}:" + id); - } + pqxx::work w(*c->c); + std::string networkId = config["id"]; + fprintf(stderr, "Deleting network %s\n", networkId.c_str()); + w.exec("DELETE FROM network_memberships_ctl WHERE network_id = $1", pqxx::params { networkId }); + w.exec("DELETE FROM networks_ctl WHERE id = $1", pqxx::params { networkId }); + + w.commit(); + + uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); + json oldConfig; + get(nwidInt, oldConfig); + json empty; + _networkChanged(oldConfig, empty, qitem.notifyListeners); } - catch (sw::redis::Error& e) { + catch (std::exception& e) { dspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "ERROR: Error adding network to Redis: %s\n", e.what()); + fprintf(stderr, "%s ERROR: Error deleting network: %s\n", _myAddressStr.c_str(), e.what()); + } + if (_listenerMode == LISTENER_MODE_REDIS && _redisMemberStatus) { + try { + std::string id = config["id"]; + std::string controllerId = _myAddressStr.c_str(); + std::string key = "networks:{" + controllerId + "}"; + if (_cc->redisConfig->clusterMode) { + _cluster->srem(key, id); + _cluster->del("network-nodes-online:{" + controllerId + "}:" + id); + } + else { + _redis->srem(key, id); + _redis->del("network-nodes-online:{" + controllerId + "}:" + id); + } + } + catch (sw::redis::Error& e) { + dspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + fprintf(stderr, "ERROR: Error adding network to Redis: %s\n", e.what()); + } } } - } - else if (objtype == "_delete_member") { - auto mspan = tracer->StartSpan("CentralDB::commitThread::_delete_member"); - auto mscope = tracer->WithActiveSpan(mspan); + else if (objtype == "_delete_member") { + auto mspan = tracer->StartSpan("CentralDB::commitThread::_delete_member"); + auto mscope = tracer->WithActiveSpan(mspan); - // fprintf(stderr, "%s commitThread: delete member\n", _myAddressStr.c_str()); - try { - pqxx::work w(*c->c); + // fprintf(stderr, "%s commitThread: delete member\n", _myAddressStr.c_str()); + try { + pqxx::work w(*c->c); - std::string memberId = config["id"]; - std::string networkId = config["nwid"]; + std::string memberId = config["id"]; + std::string networkId = config["nwid"]; - fprintf(stderr, "Deleting member %s-%s\n", networkId.c_str(), memberId.c_str()); + fprintf(stderr, "Deleting member %s-%s\n", networkId.c_str(), memberId.c_str()); - pqxx::result res = - w.exec( - "DELETE FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", - pqxx::params { memberId, networkId }) - .no_rows(); + pqxx::result res = + w.exec( + "DELETE FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", + pqxx::params { memberId, networkId }) + .no_rows(); - w.commit(); + w.commit(); - uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); - uint64_t memberidInt = OSUtils::jsonIntHex(config["id"], 0ULL); + uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); + uint64_t memberidInt = OSUtils::jsonIntHex(config["id"], 0ULL); - nlohmann::json networkConfig; - nlohmann::json oldConfig; + nlohmann::json networkConfig; + nlohmann::json oldConfig; - get(nwidInt, networkConfig, memberidInt, oldConfig); - json empty; - _memberChanged(oldConfig, empty, qitem.second); - } - catch (std::exception& e) { - mspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "%s ERROR: Error deleting member: %s\n", _myAddressStr.c_str(), e.what()); - } - if (_listenerMode == LISTENER_MODE_REDIS && _redisMemberStatus) { - try { - std::string memberId = config["id"]; - std::string networkId = config["nwid"]; - std::string controllerId = _myAddressStr.c_str(); - std::string key = "network-nodes-all:{" + controllerId + "}:" + networkId; - if (_cc->redisConfig->clusterMode) { - _cluster->srem(key, memberId); - _cluster->del("member:{" + controllerId + "}:" + networkId + ":" + memberId); - } - else { - _redis->srem(key, memberId); - _redis->del("member:{" + controllerId + "}:" + networkId + ":" + memberId); - } + get(nwidInt, networkConfig, memberidInt, oldConfig); + json empty; + _memberChanged(oldConfig, empty, qitem.notifyListeners); } - catch (sw::redis::Error& e) { + catch (std::exception& e) { mspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "ERROR: Error deleting member from Redis: %s\n", e.what()); + fprintf(stderr, "%s ERROR: Error deleting member: %s\n", _myAddressStr.c_str(), e.what()); + } + if (_listenerMode == LISTENER_MODE_REDIS && _redisMemberStatus) { + try { + std::string memberId = config["id"]; + std::string networkId = config["nwid"]; + std::string controllerId = _myAddressStr.c_str(); + std::string key = "network-nodes-all:{" + controllerId + "}:" + networkId; + if (_cc->redisConfig->clusterMode) { + _cluster->srem(key, memberId); + _cluster->del("member:{" + controllerId + "}:" + networkId + ":" + memberId); + } + else { + _redis->srem(key, memberId); + _redis->del("member:{" + controllerId + "}:" + networkId + ":" + memberId); + } + } + catch (sw::redis::Error& e) { + mspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + fprintf(stderr, "ERROR: Error deleting member from Redis: %s\n", e.what()); + } } } + else { + fprintf(stderr, "%s ERROR: unknown objtype\n", _myAddressStr.c_str()); + } } - else { - fprintf(stderr, "%s ERROR: unknown objtype\n", _myAddressStr.c_str()); + catch (std::exception& e) { + span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + fprintf(stderr, "%s ERROR: Error getting objtype: %s\n", _myAddressStr.c_str(), e.what()); } + _pool->unborrow(c); + c.reset(); } - catch (std::exception& e) { - span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "%s ERROR: Error getting objtype: %s\n", _myAddressStr.c_str(), e.what()); - } - _pool->unborrow(c); - c.reset(); } fprintf(stderr, "%s commitThread finished\n", _myAddressStr.c_str()); @@ -1561,90 +1621,94 @@ void CentralDB::onlineNotificationThread() { waitForReady(); while (_run == 1) { - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("CentralDB"); - auto span = tracer->StartSpan("CentralDB::onlineNotificationThread"); - auto scope = tracer->WithActiveSpan(span); + { + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("CentralDB"); + auto span = tracer->StartSpan("CentralDB::onlineNotificationThread"); + auto scope = tracer->WithActiveSpan(span); - try { - std::unordered_map, NodeOnlineRecord, _PairHasher> lastOnline; - { - std::lock_guard l(_lastOnline_l); - lastOnline.swap(_lastOnline); - } + try { + std::unordered_map, NodeOnlineRecord, _PairHasher> lastOnline; + { + std::lock_guard l(_lastOnline_l); + lastOnline.swap(_lastOnline); + } - uint64_t updateCount = 0; - auto c = _pool->borrow(); - pqxx::work w(*c->c); - for (auto i = lastOnline.begin(); i != lastOnline.end(); ++i) { - updateCount += 1; - uint64_t nwid_i = i->first.first; - char nwidTmp[64]; - char memTmp[64]; - char ipTmp[64]; - OSUtils::ztsnprintf(nwidTmp, sizeof(nwidTmp), "%.16llx", nwid_i); - OSUtils::ztsnprintf(memTmp, sizeof(memTmp), "%.10llx", i->first.second); - nlohmann::json network, member; + uint64_t updateCount = 0; + auto c = _pool->borrow(); + pqxx::work w(*c->c); + for (auto i = lastOnline.begin(); i != lastOnline.end(); ++i) { + updateCount += 1; + uint64_t nwid_i = i->first.first; + char nwidTmp[64]; + char memTmp[64]; + char ipTmp[64]; + OSUtils::ztsnprintf(nwidTmp, sizeof(nwidTmp), "%.16llx", nwid_i); + OSUtils::ztsnprintf(memTmp, sizeof(memTmp), "%.10llx", i->first.second); + nlohmann::json network, member; + + if (! get(nwid_i, network, i->first.second, member)) { + continue; // skip non existent networks/members + } - if (! get(nwid_i, network, i->first.second, member)) { - continue; // skip non existent networks/members - } + std::string networkId(nwidTmp); + std::string memberId(memTmp); - std::string networkId(nwidTmp); - std::string memberId(memTmp); + try { + // check if the member exists first. + // + // exec_params1 will throw pqxx::unexpected_rows if not exactly one row is returned. If that's + // the case, skip this record and move on. + pqxx::row r = + w.exec( + "SELECT device_id, network_id FROM network_memberships_ctl WHERE network_id = " + "$1 AND device_id " + "= $2", + pqxx::params { networkId, memberId }) + .one_row(); + } + catch (pqxx::unexpected_rows& e) { + continue; + } - try { - // check if the member exists first. - // - // exec_params1 will throw pqxx::unexpected_rows if not exactly one row is returned. If that's the - // case, skip this record and move on. - pqxx::row r = w.exec( - "SELECT device_id, network_id FROM network_memberships_ctl WHERE network_id = " - "$1 AND device_id " - "= $2", - pqxx::params { networkId, memberId }) - .one_row(); - } - catch (pqxx::unexpected_rows& e) { - continue; - } + int64_t ts = i->second.lastSeen; + std::string ipAddr = i->second.physicalAddress.toIpString(ipTmp); + std::string timestamp = std::to_string(ts); + std::string osArch = i->second.osArch; + std::vector osArchSplit = split(osArch, '/'); + std::string os = "unknown"; + std::string arch = "unknown"; + std::string frontend = OSUtils::jsonString(network["frontend"], ""); + + int vMajor = OSUtils::jsonInt(member["vMajor"], 0); + int vMinor = OSUtils::jsonInt(member["vMinor"], 0); + int vRev = OSUtils::jsonInt(member["vRev"], 0); + std::string version; + if (vMajor <= 0 && vMinor <= 0 && vRev <= 0) { + vMajor = 0; + vMinor = 0; + vRev = 0; + version = "unknown"; + } + else { + version = + "v" + std::to_string(vMajor) + "." + std::to_string(vMinor) + "." + std::to_string(vRev); + } + if (osArchSplit.size() == 2) { + os = osArchSplit[0]; + arch = osArchSplit[1]; + } - int64_t ts = i->second.lastSeen; - std::string ipAddr = i->second.physicalAddress.toIpString(ipTmp); - std::string timestamp = std::to_string(ts); - std::string osArch = i->second.osArch; - std::vector osArchSplit = split(osArch, '/'); - std::string os = "unknown"; - std::string arch = "unknown"; - std::string frontend = OSUtils::jsonString(network["frontend"], ""); - - int vMajor = OSUtils::jsonInt(member["vMajor"], 0); - int vMinor = OSUtils::jsonInt(member["vMinor"], 0); - int vRev = OSUtils::jsonInt(member["vRev"], 0); - std::string version; - if (vMajor <= 0 && vMinor <= 0 && vRev <= 0) { - vMajor = 0; - vMinor = 0; - vRev = 0; - version = "unknown"; - } - else { - version = "v" + std::to_string(vMajor) + "." + std::to_string(vMinor) + "." + std::to_string(vRev); + _statusWriter->updateNodeStatus( + networkId, memberId, os, arch, version, i->second.physicalAddress, ts, frontend); } - if (osArchSplit.size() == 2) { - os = osArchSplit[0]; - arch = osArchSplit[1]; - } - - _statusWriter->updateNodeStatus( - networkId, memberId, os, arch, version, i->second.physicalAddress, ts, frontend); + _statusWriter->writePending(); + w.commit(); + _pool->unborrow(c); + } + catch (std::exception& e) { + fprintf(stderr, "%s: error in onlinenotification thread: %s\n", _myAddressStr.c_str(), e.what()); } - _statusWriter->writePending(); - w.commit(); - _pool->unborrow(c); - } - catch (std::exception& e) { - fprintf(stderr, "%s: error in onlinenotification thread: %s\n", _myAddressStr.c_str(), e.what()); } std::this_thread::sleep_for(std::chrono::seconds(10)); diff --git a/nonfree/controller/CentralDB.hpp b/nonfree/controller/CentralDB.hpp index 932bd001fc..ed4a160609 100644 --- a/nonfree/controller/CentralDB.hpp +++ b/nonfree/controller/CentralDB.hpp @@ -112,7 +112,20 @@ class CentralDB : public DB { std::string _myAddressStr; std::string _connString; - BlockingQueue > _commitQueue; + struct _queueItem { + _queueItem() : jsonData(), notifyListeners(false), traceContext() + { + } + + ~_queueItem() + { + } + + nlohmann::json jsonData; + bool notifyListeners; + std::map traceContext; + }; + BlockingQueue<_queueItem> _commitQueue; std::thread _heartbeatThread; std::shared_ptr _membersDbWatcher; diff --git a/nonfree/controller/OtelCarrier.hpp b/nonfree/controller/OtelCarrier.hpp new file mode 100644 index 0000000000..10a7105305 --- /dev/null +++ b/nonfree/controller/OtelCarrier.hpp @@ -0,0 +1,47 @@ +#ifndef OTEL_CARRIER_HPP +#define OTEL_CARRIER_HPP + +#include "opentelemetry/context/propagation/text_map_propagator.h" +#include "opentelemetry/trace/propagation/http_trace_context.h" + +namespace nostd = opentelemetry::nostd; + +namespace ZeroTier { + +template class OtelCarrier : public opentelemetry::context::propagation::TextMapCarrier { + public: + OtelCarrier(T& headers) : headers_(headers) + { + } + + OtelCarrier() = default; + + virtual nostd::string_view Get(nostd::string_view key) const noexcept override + { + std::string key_to_compare = key.data(); + + if (key == opentelemetry::trace::propagation::kTraceParent) { + key_to_compare = "traceparent"; + } + else if (key == opentelemetry::trace::propagation::kTraceState) { + key_to_compare = "tracestate"; + } + auto it = headers_.find(key_to_compare); + if (it != headers_.end()) { + return it->second; + } + + return ""; + } + + virtual void Set(nostd::string_view key, nostd::string_view value) noexcept override + { + headers_.insert(std::pair(std::string(key), std::string(value))); + } + + T& headers_; +}; + +} // namespace ZeroTier + +#endif // OTEL_CARRIER_HPP \ No newline at end of file diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 1e93a47a3e..a155864991 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -4,11 +4,16 @@ #include "ControllerConfig.hpp" #include "CtlUtil.hpp" #include "DB.hpp" +#include "OtelCarrier.hpp" #include "member.pb.h" #include "network.pb.h" +#include "opentelemetry/context/propagation/global_propagator.h" +#include "opentelemetry/trace/propagation/http_trace_context.h" #include "opentelemetry/trace/provider.h" +#include "opentelemetry/trace/tracer.h" #include "rustybits.h" +#include #include #include #include @@ -50,7 +55,9 @@ PubSubListener::PubSubListener(std::string controller_id, std::string project, s create_gcp_pubsub_subscription_if_needed(_project, _subscription_id, _topic, _controller_id); } - _subscriber = std::make_shared(pubsub::MakeSubscriberConnection(*_subscription)); + _subscriber = std::make_shared( + pubsub::MakeSubscriberConnection(*_subscription), + google::cloud::Options {}.set(true)); _run = true; _subscriberThread = std::thread(&PubSubListener::subscribe, this); @@ -77,20 +84,38 @@ void PubSubListener::subscribe() auto session = _subscriber->Subscribe([this](pubsub::Message const& m, pubsub::AckHandler h) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("PubSubListener"); - auto span = tracer->StartSpan("PubSubListener::onMessage"); - auto scope = tracer->WithActiveSpan(span); - span->SetAttribute("message_id", m.message_id()); - span->SetAttribute("ordering_key", m.ordering_key()); - - fprintf(stderr, "Received message %s\n", m.message_id().c_str()); - if (onNotification(m.data())) { - std::move(h).ack(); - span->SetStatus(opentelemetry::trace::StatusCode::kOk); - return true; + + auto propagator = opentelemetry::context::propagation::GlobalTextMapPropagator::GetGlobalPropagator(); + auto attrs = m.attributes(); + std::map attrs_map; + for (auto const& kv : m.attributes()) { + fprintf(stderr, "Message attribute: %s=%s\n", kv.first.c_str(), kv.second.c_str()); + attrs_map.emplace(kv.first, kv.second); } - else { - span->SetStatus(opentelemetry::trace::StatusCode::kError, "onNotification failed"); - return false; + + OtelCarrier > carrier(attrs_map); + + auto current_ctx = opentelemetry::context::RuntimeContext::GetCurrent(); + auto new_context = propagator->Extract(carrier, current_ctx); + auto remote_span = opentelemetry::trace::GetSpan(new_context); + auto remote_scope = tracer->WithActiveSpan(remote_span); + + { + auto span = tracer->StartSpan("PubSubListener::onMessage"); + auto scope = tracer->WithActiveSpan(span); + span->SetAttribute("message_id", m.message_id()); + span->SetAttribute("ordering_key", m.ordering_key()); + + fprintf(stderr, "Received message %s\n", m.message_id().c_str()); + if (onNotification(m.data())) { + std::move(h).ack(); + span->SetStatus(opentelemetry::trace::StatusCode::kOk); + return true; + } + else { + span->SetStatus(opentelemetry::trace::StatusCode::kError, "onNotification failed"); + return false; + } } }); diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index 00bd26598d..c35800abc9 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -2,9 +2,11 @@ #include "../../osdep/OSUtils.hpp" #include "CtlUtil.hpp" +#include "OtelCarrier.hpp" #include "member.pb.h" #include "member_status.pb.h" #include "network.pb.h" +#include "opentelemetry/context/propagation/global_propagator.h" #include #include @@ -42,7 +44,8 @@ PubSubWriter::PubSubWriter(std::string project, std::string topic, std::string c ::google::cloud::Options {} .set(pubsub::LimitedTimeRetryPolicy(std::chrono::seconds(5)).clone()) .set( - pubsub::ExponentialBackoffPolicy(std::chrono::milliseconds(100), std::chrono::seconds(2), 1.3).clone()); + pubsub::ExponentialBackoffPolicy(std::chrono::milliseconds(100), std::chrono::seconds(2), 1.3).clone()) + .set(true); auto publisher = pubsub::MakePublisherConnection(pubsub::Topic(project, topic), std::move(options)); _publisher = std::make_shared(std::move(publisher)); } @@ -56,10 +59,26 @@ bool PubSubWriter::publishMessage( const std::string& frontend, const std::string& orderingKey) { + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("PubSubWriter"); + auto span = tracer->StartSpan("PubSubWriter::publishMessage"); + auto scope = tracer->WithActiveSpan(span); + fprintf(stderr, "Publishing message to %s\n", _topic.c_str()); std::vector > attributes; attributes.emplace_back("controller_id", _controller_id); + std::map attrs_map; + OtelCarrier > carrier(attrs_map); + auto propagator = opentelemetry::context::propagation::GlobalTextMapPropagator::GetGlobalPropagator(); + auto current_ctx = opentelemetry::context::RuntimeContext::GetCurrent(); + propagator->Inject(carrier, current_ctx); + + for (const auto& kv : attrs_map) { + fprintf(stderr, "Attributes injected: %s=%s\n", kv.first.c_str(), kv.second.c_str()); + attributes.emplace_back(kv.first, kv.second); + } + if (! frontend.empty()) { attributes.emplace_back("frontend", frontend); } diff --git a/service/OneService.cpp b/service/OneService.cpp index 605f9345a0..107562cbfd 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -49,6 +49,10 @@ #endif #ifdef ZT_OPENTELEMETRY_ENABLED +#include "opentelemetry/baggage/propagation/baggage_propagator.h" +#include "opentelemetry/context/propagation/composite_propagator.h" +#include "opentelemetry/context/propagation/global_propagator.h" +#include "opentelemetry/context/propagation/text_map_propagator.h" #include "opentelemetry/exporters/memory/in_memory_data.h" #include "opentelemetry/exporters/otlp/otlp_grpc_exporter.h" #include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h" @@ -68,6 +72,7 @@ #include "opentelemetry/sdk/trace/tracer.h" #include "opentelemetry/sdk/trace/tracer_context.h" #include "opentelemetry/sdk/trace/tracer_provider.h" +#include "opentelemetry/trace/propagation/http_trace_context.h" #include "opentelemetry/trace/provider.h" namespace sdktrace = opentelemetry::v1::sdk::trace; @@ -1169,6 +1174,19 @@ class OneServiceImpl : public OneService { _traceProvider = opentelemetry::nostd::shared_ptr( new sdktrace::TracerProvider(std::move(tracer_context))); sdktrace::Provider::SetTracerProvider(_traceProvider); + + std::vector > propagators; + propagators.push_back( + std::unique_ptr( + new opentelemetry::trace::propagation::HttpTraceContext())); + propagators.push_back( + std::unique_ptr( + new opentelemetry::baggage::propagation::BaggagePropagator())); + + auto p = opentelemetry::nostd::shared_ptr( + new opentelemetry::context::propagation::CompositePropagator(std::move(propagators))); + + opentelemetry::context::propagation::GlobalTextMapPropagator::SetGlobalPropagator(p); } } From 50daf9537bca6ee736edd750ddae025f7113ac22 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 11 Nov 2025 18:40:47 -0800 Subject: [PATCH 163/245] controller build readme update --- nonfree/controller/README_CENTRAL_CONTROLLER.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nonfree/controller/README_CENTRAL_CONTROLLER.md b/nonfree/controller/README_CENTRAL_CONTROLLER.md index 3b37e3c32d..1bf2abdf1f 100644 --- a/nonfree/controller/README_CENTRAL_CONTROLLER.md +++ b/nonfree/controller/README_CENTRAL_CONTROLLER.md @@ -25,7 +25,7 @@ conda config --set channel_priority strict Install external dependencies: ```bash -conda env create -f environment.yaml +conda env create -f conda_env_build.yaml conda env activate central_controller ``` @@ -39,8 +39,7 @@ cmake --build build/ --target all -j8 --verbose ## Packaging via Docker -TODO: write me - +Handled by GitHub Actions ## Configuration From 2ba50f4544d17845082945dbb836139c9b276bd9 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 12 Nov 2025 16:17:03 -0800 Subject: [PATCH 164/245] set --provenance false on docker build to try and fix docker image creation issue --- .github/workflows/central-controller.yaml | 112 +++++++++++----------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index ba1e7a6e39..209cc0522f 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -12,71 +12,71 @@ jobs: runner: [gha-runner-x64, gha-runner-arm64] runs-on: ${{ matrix.runner }} steps: - - name: checkout - uses: actions/checkout@v4 - - - name: GCP Auth - uses: google-github-actions/auth@v2 - with: - credentials_json: ${{ secrets.DOCKER_REGISTRY_WRITER}} - - - name: Set up GCloud CLI - uses: google-github-actions/setup-gcloud@v2 + - name: checkout + uses: actions/checkout@v4 - - name: Docker Auth - run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet + - name: GCP Auth + uses: google-github-actions/auth@v2 + with: + credentials_json: ${{ secrets.DOCKER_REGISTRY_WRITER}} - - name: Get branch name and sanitize - id: branch - run: | - BRANCH_NAME="${GITHUB_REF##*/}" - SANITIZED_BRANCH="${BRANCH_NAME//\//-}" - echo "branch_name=$SANITIZED_BRANCH" >> $GITHUB_OUTPUT - - - name: Get short git commit SHA - id: sha - run: | - calculatedSha=$(git rev-parse --short ${{ github.sha }}) - echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV + - name: Set up GCloud CLI + uses: google-github-actions/setup-gcloud@v2 + + - name: Docker Auth + run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet + + - name: Get branch name and sanitize + id: branch + run: | + BRANCH_NAME="${GITHUB_REF##*/}" + SANITIZED_BRANCH="${BRANCH_NAME//\//-}" + echo "branch_name=$SANITIZED_BRANCH" >> $GITHUB_OUTPUT + + - name: Get short git commit SHA + id: sha + run: | + calculatedSha=$(git rev-parse --short ${{ github.sha }}) + echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV + + - name: Build & Push Docker Image + run: | + docker build -t us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} -f ext/central-controller-docker/Dockerfile.new --provenance false . --push - - name: Build & Push Docker Image - run: | - docker build -t us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} -f ext/central-controller-docker/Dockerfile.new . --push - multi-arch-docker: runs-on: gha-runner-x64 needs: central_controller steps: - - name: Checkout - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 + + - name: GCP Auth + uses: google-github-actions/auth@v2 + with: + credentials_json: ${{ secrets.DOCKER_REGISTRY_WRITER}} - - name: GCP Auth - uses: google-github-actions/auth@v2 - with: - credentials_json: ${{ secrets.DOCKER_REGISTRY_WRITER}} + - name: Set up GCloud CLI + uses: google-github-actions/setup-gcloud@v2 - - name: Set up GCloud CLI - uses: google-github-actions/setup-gcloud@v2 + - name: Docker Auth + run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet - - name: Docker Auth - run: gcloud auth configure-docker us-central1-docker.pkg.dev --quiet + - name: Get branch name and sanitize + id: branch + run: | + BRANCH_NAME="${GITHUB_REF##*/}" + SANITIZED_BRANCH="${BRANCH_NAME//\//-}" + echo "branch_name=$SANITIZED_BRANCH" >> $GITHUB_OUTPUT - - name: Get branch name and sanitize - id: branch - run: | - BRANCH_NAME="${GITHUB_REF##*/}" - SANITIZED_BRANCH="${BRANCH_NAME//\//-}" - echo "branch_name=$SANITIZED_BRANCH" >> $GITHUB_OUTPUT - - - name: Get short git commit SHA - id: sha - run: | - calculatedSha=$(git rev-parse --short ${{ github.sha }}) - echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV + - name: Get short git commit SHA + id: sha + run: | + calculatedSha=$(git rev-parse --short ${{ github.sha }}) + echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV - - name: Create and push multi-arch manifest - run: | - docker manifest create us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} \ - --amend us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-X64 \ - --amend us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-ARM64 - docker manifest push us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} + - name: Create and push multi-arch manifest + run: | + docker manifest create us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} \ + --amend us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-X64 \ + --amend us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-ARM64 + docker manifest push us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} From ccb9a45d214f259c18d765339c51aaf0dfe68a2a Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 23 Jan 2026 11:53:06 -0800 Subject: [PATCH 165/245] Remove extra verbose logging from controller --- nonfree/controller/BigTableStatusWriter.cpp | 1 - nonfree/controller/CentralDB.cpp | 28 ------------------- .../controller/EmbeddedNetworkController.cpp | 17 +---------- nonfree/controller/PostgreSQL.cpp | 8 ------ nonfree/controller/PubSubListener.cpp | 8 ------ nonfree/controller/PubSubWriter.cpp | 10 ------- 6 files changed, 1 insertion(+), 71 deletions(-) diff --git a/nonfree/controller/BigTableStatusWriter.cpp b/nonfree/controller/BigTableStatusWriter.cpp index 44180b65a3..b524270eef 100644 --- a/nonfree/controller/BigTableStatusWriter.cpp +++ b/nonfree/controller/BigTableStatusWriter.cpp @@ -87,7 +87,6 @@ void BigTableStatusWriter::writePending() if (toWrite.empty()) { return; } - fprintf(stderr, "Writing %zu pending status entries to BigTable\n", toWrite.size()); cbt::BulkMutation bulk; for (const auto& entry : toWrite) { diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 5646f8c778..50deb49ade 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -319,13 +319,11 @@ bool CentralDB::save(nlohmann::json& record, bool notifyListeners) auto span = tracer->StartSpan("CentralDB::save::network"); auto scope = tracer->WithActiveSpan(span); - fprintf(stderr, "CentralDB network save %s\n", record["id"].get().c_str()); const uint64_t nwid = OSUtils::jsonIntHex(record["id"], 0ULL); if (nwid) { nlohmann::json old; get(nwid, old); if ((! old.is_object()) || (! _compareRecords(old, record))) { - fprintf(stderr, "posting network change to commit queue\n"); record["revision"] = OSUtils::jsonInt(record["revision"], 0ULL) + 1ULL; _queueItem qi; qi.jsonData = record; @@ -348,12 +346,10 @@ bool CentralDB::save(nlohmann::json& record, bool notifyListeners) std::string memberId = record["id"]; const uint64_t nwid = OSUtils::jsonIntHex(record["nwid"], 0ULL); const uint64_t id = OSUtils::jsonIntHex(record["id"], 0ULL); - fprintf(stderr, "member save %s-%s\n", networkId.c_str(), memberId.c_str()); if ((id) && (nwid)) { nlohmann::json network, old; get(nwid, network, id, old); if ((! old.is_object()) || (! _compareRecords(old, record))) { - fprintf(stderr, "posting member change to commit queue\n"); record["revision"] = OSUtils::jsonInt(record["revision"], 0ULL) + 1ULL; _queueItem qi; @@ -395,7 +391,6 @@ void CentralDB::eraseNetwork(const uint64_t networkId) char networkIdStr[17]; span->SetAttribute("network_id", Utils::hex(networkId, networkIdStr)); - fprintf(stderr, "CentralDB::eraseNetwork\n"); char tmp2[24]; waitForReady(); Utils::hex(networkId, tmp2); @@ -425,7 +420,6 @@ void CentralDB::eraseMember(const uint64_t networkId, const uint64_t memberId) span->SetAttribute("network_id", Utils::hex(networkId, networkIdStr)); span->SetAttribute("member_id", Utils::hex10(memberId, memberIdStr)); - fprintf(stderr, "CentralDB::eraseMember\n"); char tmp2[24]; waitForReady(); @@ -1149,11 +1143,6 @@ void CentralDB::commitThread() auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("CentralDB"); - fprintf(stderr, "checking qitem trace context\n"); - for (auto const& kv : qitem.traceContext) { - fprintf(stderr, "traceContext: %s: %s\n", kv.first.c_str(), kv.second.c_str()); - } - auto propagator = opentelemetry::context::propagation::GlobalTextMapPropagator::GetGlobalPropagator(); OtelCarrier > carrier(qitem.traceContext); auto current_ctx = opentelemetry::context::RuntimeContext::GetCurrent(); @@ -1202,7 +1191,6 @@ void CentralDB::commitThread() memberId = config["id"]; networkId = config["nwid"]; - fprintf(stderr, "commit member %s-%s\n", networkId.c_str(), memberId.c_str()); std::string target = "NULL"; if (! config["remoteTraceTarget"].is_null()) { @@ -1243,18 +1231,12 @@ void CentralDB::commitThread() change_source = "controller"; } if (! isNewMember && change_source != "controller" && frontend != change_source) { - fprintf( - stderr, "skipping member %s-%s update. change source: %s, frontend: %s\n", - networkId.c_str(), memberId.c_str(), change_source.c_str(), frontend.c_str()); // if it is not a new member and the change source is not the controller and doesn't match // the frontend, don't apply the change. continue; } std::vector ipAssignments; - fprintf( - stderr, "Saving IP Assignments: \n\tipAssignments: %s\n", - OSUtils::jsonDump(config["ipAssignments"], -1).c_str()); if (config["ipAssignments"].is_array()) { for (auto& ip : config["ipAssignments"]) { if (ip.is_string()) { @@ -1263,8 +1245,6 @@ void CentralDB::commitThread() } } - fprintf(stderr, "member json: %s\n", config.dump().c_str()); - int64_t vMajor = OSUtils::jsonUInt(config["vMajor"], 0); int64_t vMinor = OSUtils::jsonUInt(config["vMinor"], 0); int64_t vRev = OSUtils::jsonUInt(config["vRev"], 0); @@ -1399,7 +1379,6 @@ void CentralDB::commitThread() pqxx::work w(*c->c); std::string id = config["id"]; - fprintf(stderr, "commit network %s\n", id.c_str()); pqxx::row nwrow = w.exec("SELECT COUNT(id) frontend FROM networks_ctl WHERE id = $1", pqxx::params { id }) @@ -1423,10 +1402,6 @@ void CentralDB::commitThread() if (! isNewNetwork && change_source != "controller" && frontend != change_source) { // if it is not a new network and the change source is not the controller and doesn't match // the frontend, don't apply the change. - fprintf( - stderr, - "Skipping network update %s. isNewNetwork: %s, change_source: %s, frontend: %s\n", - id.c_str(), isNewNetwork ? "true" : "false", change_source.c_str(), frontend.c_str()); continue; } @@ -1499,7 +1474,6 @@ void CentralDB::commitThread() try { pqxx::work w(*c->c); std::string networkId = config["id"]; - fprintf(stderr, "Deleting network %s\n", networkId.c_str()); w.exec("DELETE FROM network_memberships_ctl WHERE network_id = $1", pqxx::params { networkId }); w.exec("DELETE FROM networks_ctl WHERE id = $1", pqxx::params { networkId }); @@ -1546,8 +1520,6 @@ void CentralDB::commitThread() std::string memberId = config["id"]; std::string networkId = config["nwid"]; - fprintf(stderr, "Deleting member %s-%s\n", networkId.c_str(), memberId.c_str()); - pqxx::result res = w.exec( "DELETE FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", diff --git a/nonfree/controller/EmbeddedNetworkController.cpp b/nonfree/controller/EmbeddedNetworkController.cpp index eb8c8c0431..48134c036a 100644 --- a/nonfree/controller/EmbeddedNetworkController.cpp +++ b/nonfree/controller/EmbeddedNetworkController.cpp @@ -1655,7 +1655,6 @@ void EmbeddedNetworkController::onNetworkMemberDeauthorize(const void* db, uint6 auto span = tracer->StartSpan("embedded_controller::onNetworkMemberDeauthorize"); auto scope = tracer->WithActiveSpan(span); - fprintf(stderr, "Member Deauthorized: nwid=%.16llx, nodeid=%.10llx\n", networkId, memberId); const int64_t now = OSUtils::now(); Revocation rev( (uint32_t)_node->prng(), networkId, 0, now, ZT_REVOCATION_FLAG_FAST_PROPAGATE, Address(memberId), @@ -1666,10 +1665,7 @@ void EmbeddedNetworkController::onNetworkMemberDeauthorize(const void* db, uint6 for (auto i = _memberStatus.begin(); i != _memberStatus.end(); ++i) { if ((i->first.networkId == networkId) && (i->second.online(now))) { _node->ncSendRevocation(Address(i->first.nodeId), rev); - fprintf(stderr, " Sent revocation to %.10llx\n", i->first.nodeId); - } - else { - fprintf(stderr, " Not sending revocation to %.10llx\n", i->first.nodeId); + // fprintf(stderr, " Sent revocation to %.10llx\n", i->first.nodeId); } } } @@ -2307,20 +2303,10 @@ void EmbeddedNetworkController::_request( } } - fprintf(stderr, "haveManagedIpv4AutoAssignment=%s\n", haveManagedIpv4AutoAssignment ? "true" : "false"); - fprintf(stderr, "ipAssignmentPools.is_array()=%s\n", ipAssignmentPools.is_array() ? "true" : "false"); - fprintf(stderr, "v4AssignMode.is_object()=%s\n", v4AssignMode.is_object() ? "true" : "false"); - fprintf( - stderr, "v4AssignMode[\"zt\"]=%s\n", - (v4AssignMode.is_object() && OSUtils::jsonBool(v4AssignMode["zt"], false)) ? "true" : "false"); - fprintf(stderr, "noAutoAssignIps=%s\n", noAutoAssignIps ? "true" : "false"); - if ((ipAssignmentPools.is_array()) && ((v4AssignMode.is_object()) && (OSUtils::jsonBool(v4AssignMode["zt"], false))) && (! haveManagedIpv4AutoAssignment) && (! noAutoAssignIps)) { - fprintf(stderr, "Trying to do managed IPv4 auto-assignment\n"); for (unsigned long p = 0; ((p < ipAssignmentPools.size()) && (! haveManagedIpv4AutoAssignment)); ++p) { json& pool = ipAssignmentPools[p]; - fprintf(stderr, " considering pool %lu: %s\n", p, OSUtils::jsonDump(pool, 2).c_str()); if (pool.is_object()) { InetAddress ipRangeStartIA(OSUtils::jsonString(pool["ipRangeStart"], "").c_str()); InetAddress ipRangeEndIA(OSUtils::jsonString(pool["ipRangeEnd"], "").c_str()); @@ -2371,7 +2357,6 @@ void EmbeddedNetworkController::_request( char tmpip[64]; const std::string ipStr(ip4.toIpString(tmpip)); if (std::find(ipAssignments.begin(), ipAssignments.end(), ipStr) == ipAssignments.end()) { - fprintf(stderr, " assigning %s\n", ipStr.c_str()); ipAssignments.push_back(ipStr); member["ipAssignments"] = ipAssignments; if (nc->staticIpCount < ZT_MAX_ZT_ASSIGNED_ADDRESSES) { diff --git a/nonfree/controller/PostgreSQL.cpp b/nonfree/controller/PostgreSQL.cpp index e6c96c3c24..7d1edbb05d 100644 --- a/nonfree/controller/PostgreSQL.cpp +++ b/nonfree/controller/PostgreSQL.cpp @@ -57,7 +57,6 @@ bool PostgresMemberListener::onNotification(const std::string& payload) auto scope = tracer->WithActiveSpan(span); span->SetAttribute("payload", payload); - fprintf(stderr, "Member Notification received: %s\n", payload.c_str()); Metrics::pgsql_mem_notification++; nlohmann::json tmp(nlohmann::json::parse(payload)); nlohmann::json& ov = tmp["old_val"]; @@ -70,13 +69,11 @@ bool PostgresMemberListener::onNotification(const std::string& payload) if (oldConfig.is_object() && newConfig.is_object()) { _db->save(newConfig, true); - fprintf(stderr, "payload sent\n"); } else if (newConfig.is_object() && ! oldConfig.is_object()) { // new member Metrics::member_count++; _db->save(newConfig, true); - fprintf(stderr, "new member payload sent\n"); } else if (! newConfig.is_object() && oldConfig.is_object()) { // member delete @@ -84,7 +81,6 @@ bool PostgresMemberListener::onNotification(const std::string& payload) uint64_t memberId = OSUtils::jsonIntHex(oldConfig["id"], 0ULL); if (memberId && networkId) { _db->eraseMember(networkId, memberId); - fprintf(stderr, "member delete payload sent\n"); } } return true; @@ -135,7 +131,6 @@ bool PostgresNetworkListener::onNotification(const std::string& payload) auto scope = tracer->WithActiveSpan(span); span->SetAttribute("payload", payload); - fprintf(stderr, "Network Notification received: %s\n", payload.c_str()); Metrics::pgsql_net_notification++; nlohmann::json tmp(nlohmann::json::parse(payload)); @@ -153,7 +148,6 @@ bool PostgresNetworkListener::onNotification(const std::string& payload) span->SetAttribute("action", "network_change"); span->SetAttribute("network_id", nwid); _db->save(newConfig, true); - fprintf(stderr, "payload sent\n"); } else if (newConfig.is_object() && ! oldConfig.is_object()) { std::string nwid = newConfig["id"]; @@ -161,7 +155,6 @@ bool PostgresNetworkListener::onNotification(const std::string& payload) span->SetAttribute("action", "new_network"); // new network _db->save(newConfig, true); - fprintf(stderr, "new network payload sent\n"); } else if (! newConfig.is_object() && oldConfig.is_object()) { // network delete @@ -172,7 +165,6 @@ bool PostgresNetworkListener::onNotification(const std::string& payload) span->SetAttribute("network_id_int", networkId); if (networkId) { _db->eraseNetwork(networkId); - fprintf(stderr, "network delete payload sent\n"); } } return true; diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index a155864991..2f08369033 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -80,7 +80,6 @@ void PubSubListener::subscribe() { while (_run) { try { - fprintf(stderr, "Starting new subscription session\n"); auto session = _subscriber->Subscribe([this](pubsub::Message const& m, pubsub::AckHandler h) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("PubSubListener"); @@ -89,7 +88,6 @@ void PubSubListener::subscribe() auto attrs = m.attributes(); std::map attrs_map; for (auto const& kv : m.attributes()) { - fprintf(stderr, "Message attribute: %s=%s\n", kv.first.c_str(), kv.second.c_str()); attrs_map.emplace(kv.first, kv.second); } @@ -106,7 +104,6 @@ void PubSubListener::subscribe() span->SetAttribute("message_id", m.message_id()); span->SetAttribute("ordering_key", m.ordering_key()); - fprintf(stderr, "Received message %s\n", m.message_id().c_str()); if (onNotification(m.data())) { std::move(h).ack(); span->SetStatus(opentelemetry::trace::StatusCode::kOk); @@ -160,8 +157,6 @@ bool PubSubNetworkListener::onNotification(const std::string& payload) span->SetStatus(opentelemetry::trace::StatusCode::kError, "Failed to parse protobuf"); return false; } - fprintf(stderr, "PubSubNetworkListener: parsed protobuf message. %s\n", nc.DebugString().c_str()); - fprintf(stderr, "Network notification received\n"); try { nlohmann::json oldConfig, newConfig; @@ -228,7 +223,6 @@ bool PubSubNetworkListener::onNotification(const std::string& payload) span->SetStatus(opentelemetry::trace::StatusCode::kError, "Unknown exception"); return false; } - fprintf(stderr, "PubSubNetworkListener onNotification complete\n"); return true; } @@ -256,8 +250,6 @@ bool PubSubMemberListener::onNotification(const std::string& payload) span->SetStatus(opentelemetry::trace::StatusCode::kError, "Failed to parse protobuf"); return false; } - fprintf(stderr, "PubSubMemberListener: parsed protobuf message. %s\n", mc.DebugString().c_str()); - fprintf(stderr, "Member notification received"); try { nlohmann::json tmp; diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index c35800abc9..42217b7fe2 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -64,7 +64,6 @@ bool PubSubWriter::publishMessage( auto span = tracer->StartSpan("PubSubWriter::publishMessage"); auto scope = tracer->WithActiveSpan(span); - fprintf(stderr, "Publishing message to %s\n", _topic.c_str()); std::vector > attributes; attributes.emplace_back("controller_id", _controller_id); @@ -75,7 +74,6 @@ bool PubSubWriter::publishMessage( propagator->Inject(carrier, current_ctx); for (const auto& kv : attrs_map) { - fprintf(stderr, "Attributes injected: %s=%s\n", kv.first.c_str(), kv.second.c_str()); attributes.emplace_back(kv.first, kv.second); } @@ -94,7 +92,6 @@ bool PubSubWriter::publishMessage( return false; } - fprintf(stderr, "Published message to %s\n", _topic.c_str()); return true; } @@ -103,7 +100,6 @@ bool PubSubWriter::publishNetworkChange( const nlohmann::json& newNetwork, const std::string& frontend) { - fprintf(stderr, "Publishing network change\n"); pbmessages::NetworkChange* nc = networkChangeFromJson(_controller_id, oldNetwork, newNetwork); std::string networkID; @@ -129,7 +125,6 @@ bool PubSubWriter::publishMemberChange( const nlohmann::json& newMember, const std::string& frontend) { - fprintf(stderr, "Publishing member change\n"); pbmessages::MemberChange* mc = memberChangeFromJson(_controller_id, oldMember, newMember); std::string memberID; if (mc->has_new_()) { @@ -314,8 +309,6 @@ pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) return nullptr; } - fprintf(stderr, "memberFromJSON: %s\n", j.dump().c_str()); - pbmessages::MemberChange_Member* m = new pbmessages::MemberChange_Member(); try { m->set_network_id(OSUtils::jsonString(j["nwid"], "")); @@ -373,15 +366,12 @@ pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) delete m; return nullptr; } - fprintf(stderr, "memberFromJSON complete\n"); return m; } pbmessages::MemberChange* memberChangeFromJson(std::string controllerID, const nlohmann::json& oldMember, const nlohmann::json& newMember) { - fprintf(stderr, "memberrChangeFromJson: old: %s\n", oldMember.dump().c_str()); - fprintf(stderr, "memberrChangeFromJson: new: %s\n", newMember.dump().c_str()); pbmessages::MemberChange* mc = new pbmessages::MemberChange(); pbmessages::MemberChange_Member* om = memberFromJson(oldMember); if (om != nullptr) { From 35f7bf2291ec0e4fbc4a9e35d38c9d4af4747910 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 23 Jan 2026 13:06:02 -0800 Subject: [PATCH 166/245] disable peer metrics in Central controller --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c13af6dcd7..9d40ef9e7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ if(ZT1_CENTRAL_CONTROLLER) set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to" FORCE) set(CMAKE_CXX_STANDARD_REQUIRED True CACHE BOOL "C++ standard required" FORCE) set(CMAKE_CXX_EXTENSIONS ON CACHE BOOL "Enable compiler-specific extensions" FORCE) - add_definitions(-DZT_NONFREE_CONTROLLER=1 -DZT_CONTROLLER_USE_LIBPQ=1 -DZT1_CENTRAL_CONTROLLER=1 -DZT_OPENTELEMETRY_ENABLED=1) + add_definitions(-DZT_NONFREE_CONTROLLER=1 -DZT_CONTROLLER_USE_LIBPQ=1 -DZT1_CENTRAL_CONTROLLER=1 -DZT_OPENTELEMETRY_ENABLED=1 -DZT_NO_PEER_METRICS=1) set(CONTROLLER_RUST_FEATURES ztcontroller) set(RUST_BUILD_COMMAND cargo build --release -F ${CONTROLLER_RUST_FEATURES}) else() From c653e764b80001f2c0ef0ca149e1e0104aac5d5e Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 24 Feb 2026 14:01:33 -0800 Subject: [PATCH 167/245] WIP: Update sso info retrieval method --- .../migrations/0005_controller_log.down.sql | 3 -- .../0005_controller_log_and_sso.down.sql | 6 +++ ...sql => 0005_controller_log_and_sso.up.sql} | 14 ++++++- nonfree/controller/CentralDB.cpp | 28 ++++++-------- nonfree/controller/protobuf/sso.proto | 38 +++++++++++++++++++ 5 files changed, 68 insertions(+), 21 deletions(-) delete mode 100644 ext/central-controller-docker/migrations/0005_controller_log.down.sql create mode 100644 ext/central-controller-docker/migrations/0005_controller_log_and_sso.down.sql rename ext/central-controller-docker/migrations/{0005_controller_log.up.sql => 0005_controller_log_and_sso.up.sql} (64%) create mode 100644 nonfree/controller/protobuf/sso.proto diff --git a/ext/central-controller-docker/migrations/0005_controller_log.down.sql b/ext/central-controller-docker/migrations/0005_controller_log.down.sql deleted file mode 100644 index fecab6b5b3..0000000000 --- a/ext/central-controller-docker/migrations/0005_controller_log.down.sql +++ /dev/null @@ -1,3 +0,0 @@ -DROP INDEX IF EXISTS ctl_check_time_ix; -DROP INDEX IF EXISTS ctl_id_ix; -DROP TABLE IF EXISTS controller_log; diff --git a/ext/central-controller-docker/migrations/0005_controller_log_and_sso.down.sql b/ext/central-controller-docker/migrations/0005_controller_log_and_sso.down.sql new file mode 100644 index 0000000000..86a2f1ff69 --- /dev/null +++ b/ext/central-controller-docker/migrations/0005_controller_log_and_sso.down.sql @@ -0,0 +1,6 @@ +DROP INDEX IF EXISTS ctl_check_time_ix; +DROP INDEX IF EXISTS ctl_id_ix; +DROP TABLE IF EXISTS controller_log; +DROP INDEX IF EXISTS sso_expiry_network_member_ix; +DROP TABLE IF EXISTS sso_expiry; +DROP TABLE IF EXISTS oidc_config; \ No newline at end of file diff --git a/ext/central-controller-docker/migrations/0005_controller_log.up.sql b/ext/central-controller-docker/migrations/0005_controller_log_and_sso.up.sql similarity index 64% rename from ext/central-controller-docker/migrations/0005_controller_log.up.sql rename to ext/central-controller-docker/migrations/0005_controller_log_and_sso.up.sql index eafb9edec8..58cdbc4b29 100644 --- a/ext/central-controller-docker/migrations/0005_controller_log.up.sql +++ b/ext/central-controller-docker/migrations/0005_controller_log_and_sso.up.sql @@ -11,9 +11,19 @@ CREATE TABLE IF NOT EXISTS sso_expiry ( nonce TEXT PRIMARY KEY, nonce_expiration TIMESTAMP WITH TIME ZONE NOT NULL, network_id CHARACTER(16) NOT NULL, - member_id CHARACTER(10) NOT NULL, + device_id CHARACTER(10) NOT NULL, creation_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT (current_timestamp AT TIME ZONE 'UTC'), email TEXT, authentication_expiry_time TIMESTAMP WITH TIME ZONE, - FOREIGN KEY (network_id, member_id) REFERENCES network_memberships_ctl(network_id, device_id) ON DELETE CASCADE + FOREIGN KEY (network_id, device_id) REFERENCES network_memberships_ctl(network_id, device_id) ON DELETE CASCADE ); +CREATE INDEX IF NOT EXISTS sso_expiry_network_member_ix ON public.sso_expiry (network_id, device_id); + +CREATE TABLE IF NOT EXISTS oidc_config ( + client_id TEXT NOT NULL, + issuer TEXT NOT NULL, + authorization_endpoint TEXT NOT NULL, + sso_impl_version BIGINT NOT NULL DEFAULT 1, + provider TEXT NOT NULL DEFAULT 'default', + PRIMARY KEY (client_id) +); \ No newline at end of file diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 50deb49ade..c550dd8c03 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -510,14 +510,14 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri // check if the member exists first. pqxx::row count = w.exec( - "SELECT count(id) FROM ztc_member WHERE id = $1 AND network_id = $2 AND deleted = false", + "SELECT count(id) FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", pqxx::params { memberId, networkId }) .one_row(); if (count[0].as() == 1) { // get active nonce, if exists. pqxx::result r = w.exec( - "SELECT nonce FROM ztc_sso_expiry " - "WHERE network_id = $1 AND member_id = $2 " + "SELECT nonce FROM sso_expiry " + "WHERE network_id = $1 AND device_id = $2 " "AND ((NOW() AT TIME ZONE 'UTC') <= authentication_expiry_time) AND ((NOW() AT TIME ZONE 'UTC') <= " "nonce_expiration)", pqxx::params { networkId, memberId }); @@ -526,8 +526,8 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri // no active nonce. // find an unused nonce, if one exists. pqxx::result r = w.exec( - "SELECT nonce FROM ztc_sso_expiry " - "WHERE network_id = $1 AND member_id = $2 " + "SELECT nonce FROM sso_expiry " + "WHERE network_id = $1 AND device_id = $2 " "AND authentication_expiry_time IS NULL AND ((NOW() AT TIME ZONE 'UTC') <= nonce_expiration)", pqxx::params { networkId, memberId }); @@ -544,8 +544,8 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri nonce = std::string(nonceBuf); pqxx::result ir = w.exec( - "INSERT INTO ztc_sso_expiry " - "(nonce, nonce_expiration, network_id, member_id) VALUES " + "INSERT INTO sso_expiry " + "(nonce, nonce_expiration, network_id, device_id) VALUES " "($1, TO_TIMESTAMP($2::double precision/1000), $3, $4)", pqxx::params { nonce, OSUtils::now() + 300000, networkId, memberId }); @@ -568,15 +568,11 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri } r = w.exec( - "SELECT oc.client_id, oc.authorization_endpoint, oc.issuer, oc.provider, oc.sso_impl_version " - "FROM ztc_network AS n " - "INNER JOIN ztc_org o " - " ON o.owner_id = n.owner_id " - "LEFT OUTER JOIN ztc_network_oidc_config noc " - " ON noc.network_id = n.id " - "LEFT OUTER JOIN ztc_oidc_config oc " - " ON noc.client_id = oc.client_id AND oc.org_id = o.org_id " - "WHERE n.id = $1 AND n.sso_enabled = true", + "SELECT oc.client_id, oc.authorization_endpoint, oc.issuer, oc.provider, 1 AS sso_impl_version " + "FROM oidc_config oc " + "INNER JOIN networks_ctl n " + " ON oc.client_id = n.configuration->'ssoConfig'->>'ssoClientId' " + "WHERE n.id = $1 AND n.configuration->>'ssoEnabled' = 'true' ", pqxx::params { networkId }); std::string client_id = ""; diff --git a/nonfree/controller/protobuf/sso.proto b/nonfree/controller/protobuf/sso.proto new file mode 100644 index 0000000000..1474b89b81 --- /dev/null +++ b/nonfree/controller/protobuf/sso.proto @@ -0,0 +1,38 @@ +syntax = "proto3"; + +package pbmessages; + +message SSOUpdate +{ + // Enum for the type of SSO nonce update message + enum MessageType { + UNKNOWN = 0; + + // From Controller to CV1/CV2 to update nonce information + CTL_NONCE_UPDATE = 1; + + // From CV1/CV2 to Controller to update authentication status + CV1_AUTH_UPDATE = 2; + } + + message NonceUpdate + { + string nonce = 1; + uint64 nonce_expiration = 2; + string network_id = 3; + string device_id = 4; + } + + message AuthUpdate + { + string nonce = 1; + uint64 authentication_expiry = 2; + string network_id = 3; + string device_id = 4; + string email = 5; + } + + MessageType message_type = 1; + optional SSOUpdate.NonceUpdate nonce_update = 2; + optional SSOUpdate.AuthUpdate auth_update = 3; +} \ No newline at end of file From 0f0e6b3b163c4c7ab76e3643163a2b971b643c2e Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 25 Feb 2026 13:37:04 -0800 Subject: [PATCH 168/245] add a linked_id column to the oidc_config table. Required to get the list of configs for a particular org that the controller has. Named it `linked_id` rather than `org_id` since we don't know what it will be linked to in CV2 --- .../migrations/0005_controller_log_and_sso.up.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/central-controller-docker/migrations/0005_controller_log_and_sso.up.sql b/ext/central-controller-docker/migrations/0005_controller_log_and_sso.up.sql index 58cdbc4b29..ca1776ac98 100644 --- a/ext/central-controller-docker/migrations/0005_controller_log_and_sso.up.sql +++ b/ext/central-controller-docker/migrations/0005_controller_log_and_sso.up.sql @@ -21,9 +21,10 @@ CREATE INDEX IF NOT EXISTS sso_expiry_network_member_ix ON public.sso_expiry (ne CREATE TABLE IF NOT EXISTS oidc_config ( client_id TEXT NOT NULL, + linked_id TEXT NOT NULL, issuer TEXT NOT NULL, authorization_endpoint TEXT NOT NULL, sso_impl_version BIGINT NOT NULL DEFAULT 1, provider TEXT NOT NULL DEFAULT 'default', - PRIMARY KEY (client_id) + PRIMARY KEY (client_id, linked_id) ); \ No newline at end of file From ae7ee51b9d8cc5d77f165fd69d89b41765d42912 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 25 Feb 2026 14:36:53 -0800 Subject: [PATCH 169/245] fix db migrations --- .../migrations/0005_controller_log_and_sso.down.sql | 1 - .../migrations/0005_controller_log_and_sso.up.sql | 11 ----------- .../migrations/0006_oidc_config.down.sql | 2 ++ .../migrations/0006_oidc_config.up.sql | 13 +++++++++++++ 4 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 ext/central-controller-docker/migrations/0006_oidc_config.down.sql create mode 100644 ext/central-controller-docker/migrations/0006_oidc_config.up.sql diff --git a/ext/central-controller-docker/migrations/0005_controller_log_and_sso.down.sql b/ext/central-controller-docker/migrations/0005_controller_log_and_sso.down.sql index 86a2f1ff69..3327b86acf 100644 --- a/ext/central-controller-docker/migrations/0005_controller_log_and_sso.down.sql +++ b/ext/central-controller-docker/migrations/0005_controller_log_and_sso.down.sql @@ -3,4 +3,3 @@ DROP INDEX IF EXISTS ctl_id_ix; DROP TABLE IF EXISTS controller_log; DROP INDEX IF EXISTS sso_expiry_network_member_ix; DROP TABLE IF EXISTS sso_expiry; -DROP TABLE IF EXISTS oidc_config; \ No newline at end of file diff --git a/ext/central-controller-docker/migrations/0005_controller_log_and_sso.up.sql b/ext/central-controller-docker/migrations/0005_controller_log_and_sso.up.sql index ca1776ac98..c9f4ac22dd 100644 --- a/ext/central-controller-docker/migrations/0005_controller_log_and_sso.up.sql +++ b/ext/central-controller-docker/migrations/0005_controller_log_and_sso.up.sql @@ -17,14 +17,3 @@ CREATE TABLE IF NOT EXISTS sso_expiry ( authentication_expiry_time TIMESTAMP WITH TIME ZONE, FOREIGN KEY (network_id, device_id) REFERENCES network_memberships_ctl(network_id, device_id) ON DELETE CASCADE ); -CREATE INDEX IF NOT EXISTS sso_expiry_network_member_ix ON public.sso_expiry (network_id, device_id); - -CREATE TABLE IF NOT EXISTS oidc_config ( - client_id TEXT NOT NULL, - linked_id TEXT NOT NULL, - issuer TEXT NOT NULL, - authorization_endpoint TEXT NOT NULL, - sso_impl_version BIGINT NOT NULL DEFAULT 1, - provider TEXT NOT NULL DEFAULT 'default', - PRIMARY KEY (client_id, linked_id) -); \ No newline at end of file diff --git a/ext/central-controller-docker/migrations/0006_oidc_config.down.sql b/ext/central-controller-docker/migrations/0006_oidc_config.down.sql new file mode 100644 index 0000000000..e65d94c80a --- /dev/null +++ b/ext/central-controller-docker/migrations/0006_oidc_config.down.sql @@ -0,0 +1,2 @@ +DROP TABLE IF EXISTS oidc_config; +ALTER TABLE sso_expiry RENAME COLUMN device_id TO member_id; \ No newline at end of file diff --git a/ext/central-controller-docker/migrations/0006_oidc_config.up.sql b/ext/central-controller-docker/migrations/0006_oidc_config.up.sql new file mode 100644 index 0000000000..d86a0a258b --- /dev/null +++ b/ext/central-controller-docker/migrations/0006_oidc_config.up.sql @@ -0,0 +1,13 @@ +CREATE INDEX IF NOT EXISTS sso_expiry_network_member_ix ON public.sso_expiry (network_id, device_id); + +ALTER TABLE sso_expiry RENAME COLUMN member_id TO device_id; + +CREATE TABLE IF NOT EXISTS oidc_config ( + client_id TEXT NOT NULL, + linked_id TEXT NOT NULL, + issuer TEXT NOT NULL, + authorization_endpoint TEXT NOT NULL, + sso_impl_version BIGINT NOT NULL DEFAULT 1, + provider TEXT NOT NULL DEFAULT 'default', + PRIMARY KEY (client_id, linked_id) +); \ No newline at end of file From 0ad6b19705561b9892e9d934ed2fb60270ea3c0c Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 25 Feb 2026 14:37:27 -0800 Subject: [PATCH 170/245] drop index --- .../migrations/0006_oidc_config.down.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/central-controller-docker/migrations/0006_oidc_config.down.sql b/ext/central-controller-docker/migrations/0006_oidc_config.down.sql index e65d94c80a..73d36af1d2 100644 --- a/ext/central-controller-docker/migrations/0006_oidc_config.down.sql +++ b/ext/central-controller-docker/migrations/0006_oidc_config.down.sql @@ -1,2 +1,3 @@ DROP TABLE IF EXISTS oidc_config; -ALTER TABLE sso_expiry RENAME COLUMN device_id TO member_id; \ No newline at end of file +ALTER TABLE sso_expiry RENAME COLUMN device_id TO member_id; +DROP INDEX IF EXISTS sso_expiry_network_member_ix; From 38f4d124b067d25fdbb6fba7ea9873f81afb0e86 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 25 Feb 2026 15:04:40 -0800 Subject: [PATCH 171/245] woops. out of order here --- .../migrations/0006_oidc_config.up.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ext/central-controller-docker/migrations/0006_oidc_config.up.sql b/ext/central-controller-docker/migrations/0006_oidc_config.up.sql index d86a0a258b..8e80b633da 100644 --- a/ext/central-controller-docker/migrations/0006_oidc_config.up.sql +++ b/ext/central-controller-docker/migrations/0006_oidc_config.up.sql @@ -1,6 +1,5 @@ -CREATE INDEX IF NOT EXISTS sso_expiry_network_member_ix ON public.sso_expiry (network_id, device_id); - ALTER TABLE sso_expiry RENAME COLUMN member_id TO device_id; +CREATE INDEX IF NOT EXISTS sso_expiry_network_member_ix ON public.sso_expiry (network_id, device_id); CREATE TABLE IF NOT EXISTS oidc_config ( client_id TEXT NOT NULL, From 03aa33bba7f28ebaacd0c2f79371e025bb1d43b4 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 12 Mar 2026 09:20:05 -0700 Subject: [PATCH 172/245] set network member frontend based on the network its a member of --- nonfree/controller/CentralDB.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index c550dd8c03..f0db50db6c 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1264,11 +1264,12 @@ void CentralDB::commitThread() "identity, last_authorized_time, last_deauthorized_time, " "remote_trace_level, remote_trace_target, revision, tags, version_major, " "version_minor, " - "version_revision, version_protocol) " + "version_revision, version_protocol, frontend) " "VALUES ($1, $2, $3, $4, $5, $6, $7, TO_TIMESTAMP($8::double precision/1000), $9, " "TO_TIMESTAMP($10::double precision/1000), $11, TO_TIMESTAMP($12::double " "precision/1000), " - "TO_TIMESTAMP($13::double precision/1000), $14, $15, $16, $17, $18, $19, $20, $21) " + "TO_TIMESTAMP($13::double precision/1000), $14, $15, $16, $17, $18, $19, $20, $21, " + "$22) " "ON CONFLICT (device_id, network_id) DO UPDATE SET " "authorized = EXCLUDED.authorized, active_bridge = EXCLUDED.active_bridge, " "ip_assignments = EXCLUDED.ip_assignments, no_auto_assign_ips = " @@ -1284,7 +1285,8 @@ void CentralDB::commitThread() "EXCLUDED.version_major, " "version_minor = EXCLUDED.version_minor, version_revision = " "EXCLUDED.version_revision, " - "version_protocol = EXCLUDED.version_protocol", + "version_protocol = EXCLUDED.version_protocol, " + "frontend = EXCLUDED.frontend", pqxx::params { memberId, networkId, OSUtils::jsonBool(config["authorized"], false), @@ -1305,7 +1307,8 @@ void CentralDB::commitThread() vMajor, vMinor, vRev, - vProto }) + vProto, + frontend }) .no_rows(); w.commit(); From a840b94e0db2a825b3a7cefc95661402574d3111 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 17 Mar 2026 14:42:49 -0700 Subject: [PATCH 173/245] add SSO nonce/auth PubSub messaging with frontend routing Publish CTL_NONCE_UPDATE to PubSub when nonces are created or reused in getSSOAuthInfo(), with the network's frontend as a message attribute so only the correct CV frontend receives it. Listen for ZT1_AUTH_UPDATE messages and update sso_expiry.authentication_expiry_time accordingly, with a network existence check before applying. - Add sso_send_topic/sso_recv_topic to PubSubConfig - Add PubSubWriter::publishSSONonceUpdate() with frontend param - Add PubSubSSOListener class for inbound auth updates - Rename CV1_AUTH_UPDATE to ZT1_AUTH_UPDATE in sso.proto - Fix pre-existing connection pool leak in getSSOAuthInfo() catch block --- nonfree/controller/CentralDB.cpp | 39 +++++++- nonfree/controller/CentralDB.hpp | 3 + nonfree/controller/ControllerConfig.hpp | 2 + nonfree/controller/PubSubListener.cpp | 97 +++++++++++++++++++ nonfree/controller/PubSubListener.hpp | 20 ++++ nonfree/controller/PubSubWriter.cpp | 32 ++++++ nonfree/controller/PubSubWriter.hpp | 7 ++ .../controller/README_CENTRAL_CONTROLLER.md | 2 +- nonfree/controller/protobuf/sso.proto | 2 +- service/OneService.cpp | 4 + 10 files changed, 205 insertions(+), 3 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index f0db50db6c..84f24024c2 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -174,6 +174,14 @@ CentralDB::CentralDB( _changeNotifier = std::make_shared( _myAddressStr, cc->pubSubConfig->project_id, cc->pubSubConfig->member_change_send_topic, cc->pubSubConfig->network_change_send_topic); + if (! cc->pubSubConfig->sso_send_topic.empty()) { + _ssoNonceWriter = std::make_shared( + cc->pubSubConfig->project_id, cc->pubSubConfig->sso_send_topic, _myAddressStr); + } + if (! cc->pubSubConfig->sso_recv_topic.empty()) { + _ssoAuthListener = std::make_shared( + _myAddressStr, cc->pubSubConfig->project_id, cc->pubSubConfig->sso_recv_topic, _pool); + } } else { throw std::runtime_error( @@ -514,6 +522,17 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri pqxx::params { memberId, networkId }) .one_row(); if (count[0].as() == 1) { + // Query the network's frontend while the transaction is guaranteed open + std::string frontend; + if (_ssoNonceWriter) { + pqxx::result fr = w.exec( + "SELECT frontend FROM networks_ctl WHERE id = $1", + pqxx::params { networkId }); + if (fr.size() == 1) { + frontend = fr.at(0)[0].as >().value_or(""); + } + } + // get active nonce, if exists. pqxx::result r = w.exec( "SELECT nonce FROM sso_expiry " @@ -543,11 +562,17 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri Utils::hex(nonceBytes, sizeof(nonceBytes), nonceBuf); nonce = std::string(nonceBuf); + uint64_t nonceExpiration = OSUtils::now() + 300000ULL; pqxx::result ir = w.exec( "INSERT INTO sso_expiry " "(nonce, nonce_expiration, network_id, device_id) VALUES " "($1, TO_TIMESTAMP($2::double precision/1000), $3, $4)", - pqxx::params { nonce, OSUtils::now() + 300000, networkId, memberId }); + pqxx::params { nonce, nonceExpiration, networkId, memberId }); + + if (_ssoNonceWriter) { + _ssoNonceWriter->publishSSONonceUpdate( + nonce, nonceExpiration, networkId, memberId, frontend); + } w.commit(); } @@ -567,6 +592,15 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri exit(7); } + // For reused nonces (non-INSERT paths), publish the nonce update here. + // New nonces are published inside the INSERT branch above (before w.commit()). + // We use 0 for nonceExpiration on reused nonces since the actual + // expiration is already stored in the database. + if (_ssoNonceWriter && ! nonce.empty()) { + _ssoNonceWriter->publishSSONonceUpdate( + nonce, 0, networkId, memberId, frontend); + } + r = w.exec( "SELECT oc.client_id, oc.authorization_endpoint, oc.issuer, oc.provider, 1 AS sso_impl_version " "FROM oidc_config oc " @@ -645,6 +679,9 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri catch (std::exception& e) { span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); fprintf(stderr, "ERROR: Error updating member on load for network %s: %s\n", networkId.c_str(), e.what()); + if (c) { + _pool->unborrow(c); + } } return info; // std::string(authenticationURL); diff --git a/nonfree/controller/CentralDB.hpp b/nonfree/controller/CentralDB.hpp index ed4a160609..9f8c4c37f0 100644 --- a/nonfree/controller/CentralDB.hpp +++ b/nonfree/controller/CentralDB.hpp @@ -24,6 +24,7 @@ namespace ZeroTier { struct RedisConfig; struct ControllerConfig; struct ControllerChangeNotifier; +class PubSubWriter; class CentralDB : public DB { public: @@ -132,6 +133,8 @@ class CentralDB : public DB { std::shared_ptr _networksDbWatcher; std::shared_ptr _statusWriter; std::shared_ptr _changeNotifier; + std::shared_ptr _ssoAuthListener; + std::shared_ptr _ssoNonceWriter; std::thread _commitThread[ZT_CENTRAL_CONTROLLER_COMMIT_THREADS]; std::thread _onlineNotificationThread; diff --git a/nonfree/controller/ControllerConfig.hpp b/nonfree/controller/ControllerConfig.hpp index 2df1736c7a..ed9dc7fd25 100644 --- a/nonfree/controller/ControllerConfig.hpp +++ b/nonfree/controller/ControllerConfig.hpp @@ -13,6 +13,8 @@ struct PubSubConfig { std::string member_change_send_topic; std::string network_change_recv_topic; std::string network_change_send_topic; + std::string sso_send_topic; + std::string sso_recv_topic; }; struct BigTableConfig { diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 2f08369033..9ce3c12d9f 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -7,6 +7,7 @@ #include "OtelCarrier.hpp" #include "member.pb.h" #include "network.pb.h" +#include "sso.pb.h" #include "opentelemetry/context/propagation/global_propagator.h" #include "opentelemetry/trace/propagation/http_trace_context.h" #include "opentelemetry/trace/provider.h" @@ -601,6 +602,102 @@ nlohmann::json toJson(const pbmessages::MemberChange_Member& mc, pbmessages::Mem return out; } +PubSubSSOListener::PubSubSSOListener( + std::string controller_id, + std::string project, + std::string topic, + std::shared_ptr > pool) + : PubSubListener(controller_id, project, topic) + , _pool(pool) +{ +} + +PubSubSSOListener::~PubSubSSOListener() +{ +} + +bool PubSubSSOListener::onNotification(const std::string& payload) +{ + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("PubSubSSOListener"); + auto span = tracer->StartSpan("PubSubSSOListener::onNotification"); + auto scope = tracer->WithActiveSpan(span); + + pbmessages::SSOUpdate msg; + if (! msg.ParseFromString(payload)) { + fprintf(stderr, "Failed to parse SSOUpdate protobuf message\n"); + span->SetStatus(opentelemetry::trace::StatusCode::kError, "Failed to parse protobuf"); + return false; + } + + if (msg.message_type() != pbmessages::SSOUpdate::ZT1_AUTH_UPDATE) { + fprintf(stderr, "PubSubSSOListener: ignoring non-ZT1_AUTH_UPDATE message type %d\n", msg.message_type()); + return true; + } + + if (! msg.has_auth_update()) { + fprintf(stderr, "PubSubSSOListener: ZT1_AUTH_UPDATE message missing auth_update\n"); + span->SetStatus(opentelemetry::trace::StatusCode::kError, "Missing auth_update"); + return false; + } + + const auto& au = msg.auth_update(); + std::string nonce = au.nonce(); + uint64_t authExpiry = au.authentication_expiry(); + std::string networkId = au.network_id(); + std::string deviceId = au.device_id(); + + span->SetAttribute("network_id", networkId); + span->SetAttribute("device_id", deviceId); + span->SetAttribute("nonce", nonce); + + std::shared_ptr c; + try { + c = _pool->borrow(); + pqxx::work w(*c->c); + + // Verify network exists and log its frontend for traceability + pqxx::result fr = w.exec( + "SELECT frontend FROM networks_ctl WHERE id = $1", + pqxx::params { networkId }); + if (fr.empty()) { + fprintf(stderr, "PubSubSSOListener: ignoring auth update for unknown network=%s\n", + networkId.c_str()); + w.abort(); + _pool->unborrow(c); + return true; // ack — no point redelivering for a nonexistent network + } + std::string frontend = fr.at(0)[0].as >().value_or(""); + span->SetAttribute("frontend", frontend); + + pqxx::result res = w.exec( + "UPDATE sso_expiry " + "SET authentication_expiry_time = TO_TIMESTAMP($1::double precision / 1000) " + "WHERE nonce = $2 AND network_id = $3 AND device_id = $4", + pqxx::params { authExpiry, nonce, networkId, deviceId }); + + w.commit(); + + if (res.affected_rows() == 0) { + fprintf( + stderr, "PubSubSSOListener: no sso_expiry row matched for nonce=%s network=%s device=%s\n", + nonce.c_str(), networkId.c_str(), deviceId.c_str()); + } + + _pool->unborrow(c); + } + catch (std::exception& e) { + fprintf(stderr, "PubSubSSOListener: error updating sso_expiry: %s\n", e.what()); + span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + if (c) { + _pool->unborrow(c); + } + return false; + } + + return true; +} + } // namespace ZeroTier #endif // ZT_CONTROLLER_USE_LIBPQ \ No newline at end of file diff --git a/nonfree/controller/PubSubListener.hpp b/nonfree/controller/PubSubListener.hpp index 71e65983a2..3fe52543b8 100644 --- a/nonfree/controller/PubSubListener.hpp +++ b/nonfree/controller/PubSubListener.hpp @@ -3,7 +3,9 @@ #ifndef ZT_CONTROLLER_PUBSUBLISTENER_HPP #define ZT_CONTROLLER_PUBSUBLISTENER_HPP +#include "ConnectionPool.hpp" #include "NotificationListener.hpp" +#include "PostgreSQL.hpp" #include "rustybits.h" #include @@ -68,6 +70,24 @@ class PubSubMemberListener : public PubSubListener { DB* _db; }; +/** + * Listener for SSO auth update notifications via GCP PubSub + */ +class PubSubSSOListener : public PubSubListener { + public: + PubSubSSOListener( + std::string controller_id, + std::string project, + std::string topic, + std::shared_ptr > pool); + virtual ~PubSubSSOListener(); + + virtual bool onNotification(const std::string& payload) override; + + private: + std::shared_ptr > _pool; +}; + } // namespace ZeroTier #endif // ZT_CONTROLLER_PUBSUBLISTENER_HPP diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index 42217b7fe2..21ac15d644 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -6,6 +6,7 @@ #include "member.pb.h" #include "member_status.pb.h" #include "network.pb.h" +#include "sso.pb.h" #include "opentelemetry/context/propagation/global_propagator.h" #include @@ -181,6 +182,37 @@ bool PubSubWriter::publishStatusChange( return publishMessage(payload, "", ""); } +bool PubSubWriter::publishSSONonceUpdate( + const std::string& nonce, + uint64_t nonceExpiration, + const std::string& networkId, + const std::string& deviceId, + const std::string& frontend) +{ + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("PubSubWriter"); + auto span = tracer->StartSpan("PubSubWriter::publishSSONonceUpdate"); + auto scope = tracer->WithActiveSpan(span); + + pbmessages::SSOUpdate msg; + msg.set_message_type(pbmessages::SSOUpdate::CTL_NONCE_UPDATE); + + pbmessages::SSOUpdate_NonceUpdate* nu = new pbmessages::SSOUpdate_NonceUpdate(); + nu->set_nonce(nonce); + nu->set_nonce_expiration(nonceExpiration); + nu->set_network_id(networkId); + nu->set_device_id(deviceId); + msg.set_allocated_nonce_update(nu); + + std::string payload; + if (! msg.SerializeToString(&payload)) { + fprintf(stderr, "Failed to serialize SSOUpdate protobuf message\n"); + return false; + } + + return publishMessage(payload, frontend, networkId + "-" + deviceId); +} + pbmessages::NetworkChange_Network* networkFromJson(const nlohmann::json& j) { if (! j.is_object()) { diff --git a/nonfree/controller/PubSubWriter.hpp b/nonfree/controller/PubSubWriter.hpp index 9db4d0b9dd..f55a9ac85c 100644 --- a/nonfree/controller/PubSubWriter.hpp +++ b/nonfree/controller/PubSubWriter.hpp @@ -30,6 +30,13 @@ class PubSubWriter { std::string version, int64_t last_seen); + bool publishSSONonceUpdate( + const std::string& nonce, + uint64_t nonceExpiration, + const std::string& networkId, + const std::string& deviceId, + const std::string& frontend); + protected: bool publishMessage(const std::string& payload, const std::string& frontend, const std::string& orderingKey); diff --git a/nonfree/controller/README_CENTRAL_CONTROLLER.md b/nonfree/controller/README_CENTRAL_CONTROLLER.md index 1bf2abdf1f..927af7668d 100644 --- a/nonfree/controller/README_CENTRAL_CONTROLLER.md +++ b/nonfree/controller/README_CENTRAL_CONTROLLER.md @@ -26,7 +26,7 @@ Install external dependencies: ```bash conda env create -f conda_env_build.yaml -conda env activate central_controller +conda activate central_controller ``` ## Build the Central Controller Binary diff --git a/nonfree/controller/protobuf/sso.proto b/nonfree/controller/protobuf/sso.proto index 1474b89b81..6a16dc7885 100644 --- a/nonfree/controller/protobuf/sso.proto +++ b/nonfree/controller/protobuf/sso.proto @@ -12,7 +12,7 @@ message SSOUpdate CTL_NONCE_UPDATE = 1; // From CV1/CV2 to Controller to update authentication status - CV1_AUTH_UPDATE = 2; + ZT1_AUTH_UPDATE = 2; } message NonceUpdate diff --git a/service/OneService.cpp b/service/OneService.cpp index af47f72d97..f6de39b95c 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -1848,6 +1848,10 @@ class OneServiceImpl : public OneService { OSUtils::jsonString(ps["network_change_recv_topic"], ""); _controllerConfig.pubSubConfig->network_change_send_topic = OSUtils::jsonString(ps["network_change_send_topic"], ""); + _controllerConfig.pubSubConfig->sso_send_topic = + OSUtils::jsonString(ps["sso_send_topic"], ""); + _controllerConfig.pubSubConfig->sso_recv_topic = + OSUtils::jsonString(ps["sso_recv_topic"], ""); } if (_controllerConfig.listenMode == "pubsub" && ! _controllerConfig.pubSubConfig) { fprintf(stderr, "ERROR: pubsub listenMode requires pubsub configuration in local.conf" ZT_EOL_S); From 2c57f85e25ad482feabebb872fcb6b1f034508ef Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 17 Mar 2026 16:30:25 -0700 Subject: [PATCH 174/245] add assigned_central_version column to controllers_ctl Allow controllers to advertise which central version (cv1, cv2, or all) they are assigned to handle via a new configurable field. The value is persisted to the database on each heartbeat and validated at startup against the DB CHECK constraint. --- .../migrations/0007_assigned_version.down.sql | 1 + .../migrations/0007_assigned_version.up.sql | 1 + nonfree/controller/CentralDB.cpp | 10 ++++++---- nonfree/controller/CentralDB.hpp | 1 + nonfree/controller/ControllerConfig.hpp | 2 ++ service/OneService.cpp | 11 +++++++++++ 6 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 ext/central-controller-docker/migrations/0007_assigned_version.down.sql create mode 100644 ext/central-controller-docker/migrations/0007_assigned_version.up.sql diff --git a/ext/central-controller-docker/migrations/0007_assigned_version.down.sql b/ext/central-controller-docker/migrations/0007_assigned_version.down.sql new file mode 100644 index 0000000000..db77e5cdbc --- /dev/null +++ b/ext/central-controller-docker/migrations/0007_assigned_version.down.sql @@ -0,0 +1 @@ +ALTER TABLE controllers_ctl DROP COLUMN IF EXISTS assigned_central_version; diff --git a/ext/central-controller-docker/migrations/0007_assigned_version.up.sql b/ext/central-controller-docker/migrations/0007_assigned_version.up.sql new file mode 100644 index 0000000000..821d3535dd --- /dev/null +++ b/ext/central-controller-docker/migrations/0007_assigned_version.up.sql @@ -0,0 +1 @@ +ALTER TABLE controllers_ctl ADD COLUMN IF NOT EXISTS assigned_central_version text DEFAULT 'all' NOT NULL CONSTRAINT controllers_ctl_assigned_central_version_check CHECK (assigned_central_version IN ('cv1', 'cv2', 'all')); diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 84f24024c2..e151e855cd 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -63,6 +63,7 @@ CentralDB::CentralDB( , _listenerMode(listenMode) , _statusWriterMode(statusMode) , _cc(cc) + , _assignedCentralVersion(cc->assignedCentralVersion) , _pool() , _myId(myId) , _myAddress(myId.address()) @@ -1130,12 +1131,13 @@ void CentralDB::heartbeat() try { pqxx::work w { *c->c }; w.exec( - "INSERT INTO controllers_ctl (id, hostname, last_heartbeat, public_identity, version) VALUES " - "($1, $2, TO_TIMESTAMP($3::double precision/1000), $4, $5) " + "INSERT INTO controllers_ctl (id, hostname, last_heartbeat, public_identity, version, assigned_central_version) VALUES " + "($1, $2, TO_TIMESTAMP($3::double precision/1000), $4, $5, $6) " "ON CONFLICT (id) DO UPDATE SET hostname = EXCLUDED.hostname, last_heartbeat = " "EXCLUDED.last_heartbeat, " - "public_identity = EXCLUDED.public_identity, version = EXCLUDED.version", - pqxx::params { controllerId, hostname, ts, publicIdentity, versionStr }) + "public_identity = EXCLUDED.public_identity, version = EXCLUDED.version, " + "assigned_central_version = EXCLUDED.assigned_central_version", + pqxx::params { controllerId, hostname, ts, publicIdentity, versionStr, _assignedCentralVersion }) .no_rows(); w.commit(); } diff --git a/nonfree/controller/CentralDB.hpp b/nonfree/controller/CentralDB.hpp index 9f8c4c37f0..94210114a4 100644 --- a/nonfree/controller/CentralDB.hpp +++ b/nonfree/controller/CentralDB.hpp @@ -106,6 +106,7 @@ class CentralDB : public DB { ListenerMode _listenerMode; StatusWriterMode _statusWriterMode; const ControllerConfig* _cc; + std::string _assignedCentralVersion; std::shared_ptr > _pool; const Identity _myId; diff --git a/nonfree/controller/ControllerConfig.hpp b/nonfree/controller/ControllerConfig.hpp index ed9dc7fd25..6c2ec4d112 100644 --- a/nonfree/controller/ControllerConfig.hpp +++ b/nonfree/controller/ControllerConfig.hpp @@ -27,6 +27,7 @@ struct ControllerConfig { bool ssoEnabled; std::string listenMode; std::string statusMode; + std::string assignedCentralVersion; RedisConfig* redisConfig; PubSubConfig* pubSubConfig; BigTableConfig* bigTableConfig; @@ -35,6 +36,7 @@ struct ControllerConfig { : ssoEnabled(false) , listenMode("") , statusMode("") + , assignedCentralVersion("all") , redisConfig(nullptr) , pubSubConfig(nullptr) , bigTableConfig(nullptr) diff --git a/service/OneService.cpp b/service/OneService.cpp index f6de39b95c..5bf6a15994 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -1813,6 +1813,17 @@ class OneServiceImpl : public OneService { if (cc.is_object()) { _controllerConfig.listenMode = OSUtils::jsonString(cc["listenMode"], "pgsql"); _controllerConfig.statusMode = OSUtils::jsonString(cc["statusMode"], "pgsql"); + // Valid values must match CHECK constraint in migration 0007_assigned_version + { + const std::string av = OSUtils::jsonString(cc["assignedCentralVersion"], "all"); + if (av != "cv1" && av != "cv2" && av != "all") { + fprintf( + stderr, + "ERROR: assignedCentralVersion must be one of 'cv1', 'cv2', or 'all'" ZT_EOL_S); + exit(1); + } + _controllerConfig.assignedCentralVersion = av; + } // redis settings if (cc["redis"].is_object() && _rc == NULL) { From d9507dd8951d984927cd5b619790c4375447dbec Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 18 Mar 2026 13:17:38 -0700 Subject: [PATCH 175/245] Undo change to old migration that shouldn't have been made --- .../migrations/0005_controller_log_and_sso.up.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/central-controller-docker/migrations/0005_controller_log_and_sso.up.sql b/ext/central-controller-docker/migrations/0005_controller_log_and_sso.up.sql index c9f4ac22dd..276811781b 100644 --- a/ext/central-controller-docker/migrations/0005_controller_log_and_sso.up.sql +++ b/ext/central-controller-docker/migrations/0005_controller_log_and_sso.up.sql @@ -11,9 +11,9 @@ CREATE TABLE IF NOT EXISTS sso_expiry ( nonce TEXT PRIMARY KEY, nonce_expiration TIMESTAMP WITH TIME ZONE NOT NULL, network_id CHARACTER(16) NOT NULL, - device_id CHARACTER(10) NOT NULL, + member_id CHARACTER(10) NOT NULL, creation_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT (current_timestamp AT TIME ZONE 'UTC'), email TEXT, authentication_expiry_time TIMESTAMP WITH TIME ZONE, - FOREIGN KEY (network_id, device_id) REFERENCES network_memberships_ctl(network_id, device_id) ON DELETE CASCADE + FOREIGN KEY (network_id, member_id) REFERENCES network_memberships_ctl(network_id, member_id) ON DELETE CASCADE ); From 7faf30d0ccf1fb6bf5a7e039630f05145866270b Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 18 Mar 2026 13:51:16 -0700 Subject: [PATCH 176/245] another fix --- .../migrations/0005_controller_log_and_sso.up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/central-controller-docker/migrations/0005_controller_log_and_sso.up.sql b/ext/central-controller-docker/migrations/0005_controller_log_and_sso.up.sql index 276811781b..eafb9edec8 100644 --- a/ext/central-controller-docker/migrations/0005_controller_log_and_sso.up.sql +++ b/ext/central-controller-docker/migrations/0005_controller_log_and_sso.up.sql @@ -15,5 +15,5 @@ CREATE TABLE IF NOT EXISTS sso_expiry ( creation_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT (current_timestamp AT TIME ZONE 'UTC'), email TEXT, authentication_expiry_time TIMESTAMP WITH TIME ZONE, - FOREIGN KEY (network_id, member_id) REFERENCES network_memberships_ctl(network_id, member_id) ON DELETE CASCADE + FOREIGN KEY (network_id, member_id) REFERENCES network_memberships_ctl(network_id, device_id) ON DELETE CASCADE ); From e49b347a8fec24f4ed3382f7734168b2e1b24ea0 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 19 Mar 2026 11:56:17 -0700 Subject: [PATCH 177/245] plumb through config changes for sso pubsub --- ext/central-controller-docker/main-new.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index b7085997a4..185736e68e 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -105,7 +105,9 @@ if [ "$ZT_USE_PUBSUB" == "true" ]; then \"member_change_recv_topic\": \"${ZT_PUBSUB_MEMBER_CHANGE_RECV_TOPIC}\", \"member_change_send_topic\": \"${ZT_PUBSUB_MEMBER_CHANGE_SEND_TOPIC}\", \"network_change_recv_topic\": \"${ZT_PUBSUB_NETWORK_CHANGE_RECV_TOPIC}\", - \"network_change_send_topic\": \"${ZT_PUBSUB_NETWORK_CHANGE_SEND_TOPIC}\" + \"network_change_send_topic\": \"${ZT_PUBSUB_NETWORK_CHANGE_SEND_TOPIC}\", + \"sso_send_topic\": \"${ZT_PUBSUB_SSO_SEND_TOPIC}\", + \"sso_recv_topic\": \"${ZT_PUBSUB_SSO_RECV_TOPIC}\" } " fi From 7ec42461d890537c137d798c2fd2d2142b6f5655 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 19 Mar 2026 11:57:35 -0700 Subject: [PATCH 178/245] configure assigned central version in startup script --- ext/central-controller-docker/main-new.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index 185736e68e..c443a78474 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -132,7 +132,8 @@ echo "{ }, \"controller\": { \"listenMode\": \"${ZT_LISTEN_MODE:-pgsql}\", - \"statusMode\": \"${ZT_STATUS_MODE:-pgsql}\" + \"statusMode\": \"${ZT_STATUS_MODE:-pgsql}\", + \"assignedCentralVersion\": \"${ZT_ASSIGNED_CENTRAL_VERSION:-all}\" ${REDIS} ${BIGTABLE_CONF} ${PUBSUB_CONF} From b047038ca1689ca682260ea347227d37156da417 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 31 Mar 2026 08:48:00 -0700 Subject: [PATCH 179/245] print a message when the SSO PSK is configured --- nonfree/controller/CentralDB.cpp | 318 ++++++++++++++----------------- 1 file changed, 147 insertions(+), 171 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index e151e855cd..ac41250ac6 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -52,13 +52,12 @@ using Attrs = std::vector >; using Item = std::pair; using ItemStream = std::vector; -CentralDB::CentralDB( - const Identity& myId, - const char* connString, - int listenPort, - CentralDB::ListenerMode listenMode, - CentralDB::StatusWriterMode statusMode, - const ControllerConfig* cc) +CentralDB::CentralDB(const Identity& myId, + const char* connString, + int listenPort, + CentralDB::ListenerMode listenMode, + CentralDB::StatusWriterMode statusMode, + const ControllerConfig* cc) : DB() , _listenerMode(listenMode) , _statusWriterMode(statusMode) @@ -102,6 +101,7 @@ CentralDB::CentralDB( // returns something non-NULL. If the hex encodes something shorter than 48 bytes, // it will be padded at the end with zeroes. If longer, it'll be truncated. Utils::unhex(ssoPskHex, _ssoPsk, sizeof(_ssoPsk)); + fprintf(stderr, "SSO PSK configured\n"); } const char* redisMemberStatus = getenv("ZT_REDIS_MEMBER_STATUS"); if (redisMemberStatus && (strcmp(redisMemberStatus, "true") == 0)) { @@ -139,9 +139,8 @@ CentralDB::CentralDB( _readyLock.lock(); - fprintf( - stderr, "[%s] NOTICE: %.10llx controller PostgreSQL waiting for initial data download..." ZT_EOL_S, - ::_timestr(), (unsigned long long)_myAddress.toInt()); + fprintf(stderr, "[%s] NOTICE: %.10llx controller PostgreSQL waiting for initial data download..." ZT_EOL_S, + ::_timestr(), (unsigned long long)_myAddress.toInt()); _waitNoticePrinted = true; initializeNetworks(); @@ -172,16 +171,16 @@ CentralDB::CentralDB( _myAddressStr, cc->pubSubConfig->project_id, cc->pubSubConfig->member_change_recv_topic, this); _networksDbWatcher = std::make_shared( _myAddressStr, cc->pubSubConfig->project_id, cc->pubSubConfig->network_change_recv_topic, this); - _changeNotifier = std::make_shared( - _myAddressStr, cc->pubSubConfig->project_id, cc->pubSubConfig->member_change_send_topic, - cc->pubSubConfig->network_change_send_topic); + _changeNotifier = std::make_shared(_myAddressStr, cc->pubSubConfig->project_id, + cc->pubSubConfig->member_change_send_topic, + cc->pubSubConfig->network_change_send_topic); if (! cc->pubSubConfig->sso_send_topic.empty()) { - _ssoNonceWriter = std::make_shared( - cc->pubSubConfig->project_id, cc->pubSubConfig->sso_send_topic, _myAddressStr); + _ssoNonceWriter = std::make_shared(cc->pubSubConfig->project_id, + cc->pubSubConfig->sso_send_topic, _myAddressStr); } if (! cc->pubSubConfig->sso_recv_topic.empty()) { - _ssoAuthListener = std::make_shared( - _myAddressStr, cc->pubSubConfig->project_id, cc->pubSubConfig->sso_recv_topic, _pool); + _ssoAuthListener = std::make_shared(_myAddressStr, cc->pubSubConfig->project_id, + cc->pubSubConfig->sso_recv_topic, _pool); } } else { @@ -306,9 +305,7 @@ bool CentralDB::waitForReady() } bool CentralDB::isReady() -{ - return ((_ready == 2) && (_connected)); -} +{ return ((_ready == 2) && (_connected)); } bool CentralDB::save(nlohmann::json& record, bool notifyListeners) { @@ -447,11 +444,10 @@ void CentralDB::eraseMember(const uint64_t networkId, const uint64_t memberId) _memberChanged(qi.jsonData, nullJson, true); } -void CentralDB::nodeIsOnline( - const uint64_t networkId, - const uint64_t memberId, - const InetAddress& physicalAddress, - const char* osArch) +void CentralDB::nodeIsOnline(const uint64_t networkId, + const uint64_t memberId, + const InetAddress& physicalAddress, + const char* osArch) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("CentralDB"); @@ -475,9 +471,7 @@ void CentralDB::nodeIsOnline( } void CentralDB::nodeIsOnline(const uint64_t networkId, const uint64_t memberId, const InetAddress& physicalAddress) -{ - this->nodeIsOnline(networkId, memberId, physicalAddress, "unknown/unknown"); -} +{ this->nodeIsOnline(networkId, memberId, physicalAddress, "unknown/unknown"); } AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::string& redirectURL) { @@ -518,17 +512,15 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri // check if the member exists first. pqxx::row count = - w.exec( - "SELECT count(id) FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", - pqxx::params { memberId, networkId }) + w.exec("SELECT count(id) FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", + pqxx::params { memberId, networkId }) .one_row(); if (count[0].as() == 1) { // Query the network's frontend while the transaction is guaranteed open std::string frontend; if (_ssoNonceWriter) { - pqxx::result fr = w.exec( - "SELECT frontend FROM networks_ctl WHERE id = $1", - pqxx::params { networkId }); + pqxx::result fr = + w.exec("SELECT frontend FROM networks_ctl WHERE id = $1", pqxx::params { networkId }); if (fr.size() == 1) { frontend = fr.at(0)[0].as >().value_or(""); } @@ -564,15 +556,14 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri nonce = std::string(nonceBuf); uint64_t nonceExpiration = OSUtils::now() + 300000ULL; - pqxx::result ir = w.exec( - "INSERT INTO sso_expiry " - "(nonce, nonce_expiration, network_id, device_id) VALUES " - "($1, TO_TIMESTAMP($2::double precision/1000), $3, $4)", - pqxx::params { nonce, nonceExpiration, networkId, memberId }); + pqxx::result ir = w.exec("INSERT INTO sso_expiry " + "(nonce, nonce_expiration, network_id, device_id) VALUES " + "($1, TO_TIMESTAMP($2::double precision/1000), $3, $4)", + pqxx::params { nonce, nonceExpiration, networkId, memberId }); if (_ssoNonceWriter) { - _ssoNonceWriter->publishSSONonceUpdate( - nonce, nonceExpiration, networkId, memberId, frontend); + _ssoNonceWriter->publishSSONonceUpdate(nonce, nonceExpiration, networkId, memberId, + frontend); } w.commit(); @@ -598,8 +589,7 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri // We use 0 for nonceExpiration on reused nonces since the actual // expiration is already stored in the database. if (_ssoNonceWriter && ! nonce.empty()) { - _ssoNonceWriter->publishSSONonceUpdate( - nonce, 0, networkId, memberId, frontend); + _ssoNonceWriter->publishSSONonceUpdate(nonce, 0, networkId, memberId, frontend); } r = w.exec( @@ -624,9 +614,8 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri sso_version = r.at(0)[4].as >().value_or(1); } else if (r.size() > 1) { - fprintf( - stderr, "ERROR: More than one auth endpoint for an organization?!?!? NetworkID: %s\n", - networkId.c_str()); + fprintf(stderr, "ERROR: More than one auth endpoint for an organization?!?!? NetworkID: %s\n", + networkId.c_str()); } else { fprintf(stderr, "No client or auth endpoint?!?\n"); @@ -669,9 +658,8 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri } } else { - fprintf( - stderr, "client_id: %s\nauthorization_endpoint: %s\n", client_id.c_str(), - authorization_endpoint.c_str()); + fprintf(stderr, "client_id: %s\nauthorization_endpoint: %s\n", client_id.c_str(), + authorization_endpoint.c_str()); } } @@ -701,33 +689,31 @@ void CentralDB::initializeNetworks() try { char qbuf[2048]; - sprintf( - qbuf, - "SELECT id, name, configuration , (EXTRACT(EPOCH FROM creation_time AT TIME ZONE 'UTC')*1000)::bigint, " - "(EXTRACT(EPOCH FROM last_modified AT TIME ZONE 'UTC')*1000)::bigint, revision, frontend " - "FROM networks_ctl WHERE controller_id = '%s'", - _myAddressStr.c_str()); + sprintf(qbuf, + "SELECT id, name, configuration , (EXTRACT(EPOCH FROM creation_time AT TIME ZONE 'UTC')*1000)::bigint, " + "(EXTRACT(EPOCH FROM last_modified AT TIME ZONE 'UTC')*1000)::bigint, revision, frontend " + "FROM networks_ctl WHERE controller_id = '%s'", + _myAddressStr.c_str()); auto c = _pool->borrow(); pqxx::work w(*c->c); fprintf(stderr, "Load networks from psql...\n"); auto stream = pqxx::stream_from::query(w, qbuf); - std::tuple< - std::string // network ID - , - std::optional // name - , - std::string // configuration - , - std::optional // creation_time - , - std::optional // last_modified - , - std::optional // revision - , - std::string // frontend - > + std::tuple // name + , + std::string // configuration + , + std::optional // creation_time + , + std::optional // last_modified + , + std::optional // revision + , + std::string // frontend + > row; uint64_t count = 0; uint64_t total = 0; @@ -827,9 +813,8 @@ void CentralDB::initializeNetworks() if (++this->_ready == 2) { if (_waitNoticePrinted) { - fprintf( - stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), - (unsigned long long)_myAddress.toInt()); + fprintf(stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, + _timestr(), (unsigned long long)_myAddress.toInt()); } _readyLock.unlock(); } @@ -895,63 +880,61 @@ void CentralDB::initializeMembers() } char qbuf[2048]; - sprintf( - qbuf, - "SELECT nm.device_id, nm.network_id, nm.authorized, nm.active_bridge, nm.ip_assignments, " - "nm.no_auto_assign_ips, " - "nm.sso_exempt, (EXTRACT(EPOCH FROM nm.authentication_expiry_time AT TIME ZONE 'UTC')*1000)::bigint, " - "(EXTRACT(EPOCH FROM nm.creation_time AT TIME ZONE 'UTC')*1000)::bigint, nm.identity, " - "(EXTRACT(EPOCH FROM nm.last_authorized_time AT TIME ZONE 'UTC')*1000)::bigint, " - "(EXTRACT(EPOCH FROM nm.last_deauthorized_time AT TIME ZONE 'UTC')*1000)::bigint, " - "nm.remote_trace_level, nm.remote_trace_target, nm.revision, nm.capabilities, nm.tags, " - "nm.frontend " - "FROM network_memberships_ctl nm " - "INNER JOIN networks_ctl n " - " ON nm.network_id = n.id " - "WHERE n.controller_id = '%s'", - _myAddressStr.c_str()); + sprintf(qbuf, + "SELECT nm.device_id, nm.network_id, nm.authorized, nm.active_bridge, nm.ip_assignments, " + "nm.no_auto_assign_ips, " + "nm.sso_exempt, (EXTRACT(EPOCH FROM nm.authentication_expiry_time AT TIME ZONE 'UTC')*1000)::bigint, " + "(EXTRACT(EPOCH FROM nm.creation_time AT TIME ZONE 'UTC')*1000)::bigint, nm.identity, " + "(EXTRACT(EPOCH FROM nm.last_authorized_time AT TIME ZONE 'UTC')*1000)::bigint, " + "(EXTRACT(EPOCH FROM nm.last_deauthorized_time AT TIME ZONE 'UTC')*1000)::bigint, " + "nm.remote_trace_level, nm.remote_trace_target, nm.revision, nm.capabilities, nm.tags, " + "nm.frontend " + "FROM network_memberships_ctl nm " + "INNER JOIN networks_ctl n " + " ON nm.network_id = n.id " + "WHERE n.controller_id = '%s'", + _myAddressStr.c_str()); auto c = _pool->borrow(); pqxx::work w(*c->c); fprintf(stderr, "Load members from psql...\n"); auto stream = pqxx::stream_from::query(w, qbuf); - std::tuple< - std::string // device ID - , - std::string // network ID - , - bool // authorized - , - std::optional // active_bridge - , - std::optional // ip_assignments - , - std::optional // no_auto_assign_ips - , - std::optional // sso_exempt - , - std::optional // authentication_expiry_time - , - std::optional // creation_time - , - std::optional // identity - , - std::optional // last_authorized_time - , - std::optional // last_deauthorized_time - , - std::optional // remote_trace_level - , - std::optional // remote_trace_target - , - std::optional // revision - , - std::optional // capabilities - , - std::optional // tags - , - std::string // frontend - > + std::tuple // active_bridge + , + std::optional // ip_assignments + , + std::optional // no_auto_assign_ips + , + std::optional // sso_exempt + , + std::optional // authentication_expiry_time + , + std::optional // creation_time + , + std::optional // identity + , + std::optional // last_authorized_time + , + std::optional // last_deauthorized_time + , + std::optional // remote_trace_level + , + std::optional // remote_trace_target + , + std::optional // revision + , + std::optional // capabilities + , + std::optional // tags + , + std::string // frontend + > row; auto tmp = std::chrono::high_resolution_clock::now(); @@ -1072,9 +1055,8 @@ void CentralDB::initializeMembers() if (++this->_ready == 2) { if (_waitNoticePrinted) { - fprintf( - stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), - (unsigned long long)_myAddress.toInt()); + fprintf(stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, + _timestr(), (unsigned long long)_myAddress.toInt()); } _readyLock.unlock(); } @@ -1130,14 +1112,14 @@ void CentralDB::heartbeat() try { pqxx::work w { *c->c }; - w.exec( - "INSERT INTO controllers_ctl (id, hostname, last_heartbeat, public_identity, version, assigned_central_version) VALUES " - "($1, $2, TO_TIMESTAMP($3::double precision/1000), $4, $5, $6) " - "ON CONFLICT (id) DO UPDATE SET hostname = EXCLUDED.hostname, last_heartbeat = " - "EXCLUDED.last_heartbeat, " - "public_identity = EXCLUDED.public_identity, version = EXCLUDED.version, " - "assigned_central_version = EXCLUDED.assigned_central_version", - pqxx::params { controllerId, hostname, ts, publicIdentity, versionStr, _assignedCentralVersion }) + w.exec("INSERT INTO controllers_ctl (id, hostname, last_heartbeat, public_identity, version, " + "assigned_central_version) VALUES " + "($1, $2, TO_TIMESTAMP($3::double precision/1000), $4, $5, $6) " + "ON CONFLICT (id) DO UPDATE SET hostname = EXCLUDED.hostname, last_heartbeat = " + "EXCLUDED.last_heartbeat, " + "public_identity = EXCLUDED.public_identity, version = EXCLUDED.version, " + "assigned_central_version = EXCLUDED.assigned_central_version", + pqxx::params { controllerId, hostname, ts, publicIdentity, versionStr, _assignedCentralVersion }) .no_rows(); w.commit(); } @@ -1235,9 +1217,8 @@ void CentralDB::commitThread() // get network and the frontend it is assigned to // if network does not exist, skip member update pqxx::row nwrow = - w.exec( - "SELECT COUNT(id), frontend FROM networks_ctl WHERE id = $1 GROUP BY frontend", - pqxx::params { networkId }) + w.exec("SELECT COUNT(id), frontend FROM networks_ctl WHERE id = $1 GROUP BY frontend", + pqxx::params { networkId }) .one_row(); int nwcount = nwrow[0].as(); std::string frontend = nwrow[1].as(); @@ -1250,10 +1231,9 @@ void CentralDB::commitThread() } pqxx::row mrow = - w.exec( - "SELECT COUNT(device_id) FROM network_memberships_ctl WHERE device_id = $1 " - "AND network_id = $2", - pqxx::params { memberId, networkId }) + w.exec("SELECT COUNT(device_id) FROM network_memberships_ctl WHERE device_id = $1 " + "AND network_id = $2", + pqxx::params { memberId, networkId }) .one_row(); int membercount = mrow[0].as(); bool isNewMember = (membercount == 0); @@ -1396,15 +1376,14 @@ void CentralDB::commitThread() _memberChanged(memOrig, memNew, qitem.notifyListeners); } else { - fprintf( - stderr, "%s: Can't notify of change. Error parsing nwid or memberid: %llu-%llu\n", - _myAddressStr.c_str(), (unsigned long long)nwidInt, (unsigned long long)memberidInt); + fprintf(stderr, "%s: Can't notify of change. Error parsing nwid or memberid: %llu-%llu\n", + _myAddressStr.c_str(), (unsigned long long)nwidInt, + (unsigned long long)memberidInt); } } catch (std::exception& e) { - fprintf( - stderr, "%s ERROR: Error updating member %s-%s: %s\n", _myAddressStr.c_str(), - networkId.c_str(), memberId.c_str(), e.what()); + fprintf(stderr, "%s ERROR: Error updating member %s-%s: %s\n", _myAddressStr.c_str(), + networkId.c_str(), memberId.c_str(), e.what()); mspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); } } @@ -1477,9 +1456,8 @@ void CentralDB::commitThread() _networkChanged(nwOrig, nwNew, qitem.notifyListeners); } else { - fprintf( - stderr, "%s: Can't notify network changed: %llu\n", _myAddressStr.c_str(), - (unsigned long long)nwidInt); + fprintf(stderr, "%s: Can't notify network changed: %llu\n", _myAddressStr.c_str(), + (unsigned long long)nwidInt); } } catch (std::exception& e) { @@ -1559,9 +1537,8 @@ void CentralDB::commitThread() std::string networkId = config["nwid"]; pqxx::result res = - w.exec( - "DELETE FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", - pqxx::params { memberId, networkId }) + w.exec("DELETE FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", + pqxx::params { memberId, networkId }) .no_rows(); w.commit(); @@ -1670,11 +1647,10 @@ void CentralDB::onlineNotificationThread() // exec_params1 will throw pqxx::unexpected_rows if not exactly one row is returned. If that's // the case, skip this record and move on. pqxx::row r = - w.exec( - "SELECT device_id, network_id FROM network_memberships_ctl WHERE network_id = " - "$1 AND device_id " - "= $2", - pqxx::params { networkId, memberId }) + w.exec("SELECT device_id, network_id FROM network_memberships_ctl WHERE network_id = " + "$1 AND device_id " + "= $2", + pqxx::params { networkId, memberId }) .one_row(); } catch (pqxx::unexpected_rows& e) { @@ -1709,8 +1685,8 @@ void CentralDB::onlineNotificationThread() arch = osArchSplit[1]; } - _statusWriter->updateNodeStatus( - networkId, memberId, os, arch, version, i->second.physicalAddress, ts, frontend); + _statusWriter->updateNodeStatus(networkId, memberId, os, arch, version, i->second.physicalAddress, + ts, frontend); } _statusWriter->writePending(); w.commit(); @@ -1805,8 +1781,8 @@ nlohmann::json CentralDB::_getNetworkMember(pqxx::work& tx, const std::string ne out["frontend"] = frontend; } catch (std::exception& e) { - fprintf( - stderr, "ERROR: Error getting network member %s-%s: %s\n", networkID.c_str(), memberID.c_str(), e.what()); + fprintf(stderr, "ERROR: Error getting network member %s-%s: %s\n", networkID.c_str(), memberID.c_str(), + e.what()); return nlohmann::json(); } @@ -1825,13 +1801,13 @@ nlohmann::json CentralDB::_getNetwork(pqxx::work& tx, const std::string networkI std::optional revision; std::string frontend; - pqxx::row row = tx.exec( - "SELECT id, name, configuration , (EXTRACT(EPOCH FROM creation_time AT TIME ZONE " - "'UTC')*1000)::bigint, " - "(EXTRACT(EPOCH FROM last_modified AT TIME ZONE 'UTC')*1000)::bigint, revision, frontend " - "FROM networks_ctl WHERE id = $1", - pqxx::params { networkID }) - .one_row(); + pqxx::row row = + tx.exec("SELECT id, name, configuration , (EXTRACT(EPOCH FROM creation_time AT TIME ZONE " + "'UTC')*1000)::bigint, " + "(EXTRACT(EPOCH FROM last_modified AT TIME ZONE 'UTC')*1000)::bigint, revision, frontend " + "FROM networks_ctl WHERE id = $1", + pqxx::params { networkID }) + .one_row(); cfg = row[2].as(); creation_time = row[3].is_null() ? std::optional() : std::optional(row[3].as()); From 895b06033d90efca72ebabdfa0cd67c2b52fa658 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 31 Mar 2026 10:56:04 -0700 Subject: [PATCH 180/245] temporary logging --- nonfree/controller/PubSubWriter.cpp | 55 +++++++++++++---------------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index 21ac15d644..ed391a3878 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -6,8 +6,8 @@ #include "member.pb.h" #include "member_status.pb.h" #include "network.pb.h" -#include "sso.pb.h" #include "opentelemetry/context/propagation/global_propagator.h" +#include "sso.pb.h" #include #include @@ -30,9 +30,8 @@ PubSubWriter::PubSubWriter(std::string project, std::string topic, std::string c , _project(project) , _topic(topic) { - fprintf( - stderr, "PubSubWriter for controller %s project %s topic %s\n", controller_id.c_str(), project.c_str(), - topic.c_str()); + fprintf(stderr, "PubSubWriter for controller %s project %s topic %s\n", controller_id.c_str(), project.c_str(), + topic.c_str()); GOOGLE_PROTOBUF_VERIFY_VERSION; // If PUBSUB_EMULATOR_HOST is set, create the topic if it doesn't exist @@ -55,10 +54,9 @@ PubSubWriter::~PubSubWriter() { } -bool PubSubWriter::publishMessage( - const std::string& payload, - const std::string& frontend, - const std::string& orderingKey) +bool PubSubWriter::publishMessage(const std::string& payload, + const std::string& frontend, + const std::string& orderingKey) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("PubSubWriter"); @@ -96,10 +94,9 @@ bool PubSubWriter::publishMessage( return true; } -bool PubSubWriter::publishNetworkChange( - const nlohmann::json& oldNetwork, - const nlohmann::json& newNetwork, - const std::string& frontend) +bool PubSubWriter::publishNetworkChange(const nlohmann::json& oldNetwork, + const nlohmann::json& newNetwork, + const std::string& frontend) { pbmessages::NetworkChange* nc = networkChangeFromJson(_controller_id, oldNetwork, newNetwork); @@ -121,10 +118,9 @@ bool PubSubWriter::publishNetworkChange( return publishMessage(payload, frontend, networkID); } -bool PubSubWriter::publishMemberChange( - const nlohmann::json& oldMember, - const nlohmann::json& newMember, - const std::string& frontend) +bool PubSubWriter::publishMemberChange(const nlohmann::json& oldMember, + const nlohmann::json& newMember, + const std::string& frontend) { pbmessages::MemberChange* mc = memberChangeFromJson(_controller_id, oldMember, newMember); std::string memberID; @@ -146,14 +142,13 @@ bool PubSubWriter::publishMemberChange( return publishMessage(payload, frontend, memberID); } -bool PubSubWriter::publishStatusChange( - std::string frontend, - std::string network_id, - std::string node_id, - std::string os, - std::string arch, - std::string version, - int64_t last_seen) +bool PubSubWriter::publishStatusChange(std::string frontend, + std::string network_id, + std::string node_id, + std::string os, + std::string arch, + std::string version, + int64_t last_seen) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("PubSubWriter"); @@ -182,12 +177,11 @@ bool PubSubWriter::publishStatusChange( return publishMessage(payload, "", ""); } -bool PubSubWriter::publishSSONonceUpdate( - const std::string& nonce, - uint64_t nonceExpiration, - const std::string& networkId, - const std::string& deviceId, - const std::string& frontend) +bool PubSubWriter::publishSSONonceUpdate(const std::string& nonce, + uint64_t nonceExpiration, + const std::string& networkId, + const std::string& deviceId, + const std::string& frontend) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("PubSubWriter"); @@ -338,6 +332,7 @@ pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) { if (! j.is_object()) { fprintf(stderr, "memberFromJson: JSON is not an object\n"); + fprintf(stderr, "JSON: %s\n", j.dump().c_str()); return nullptr; } From 78b25f4ae2da2c37198b3335a53daa6f3aa19e63 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 31 Mar 2026 13:24:03 -0700 Subject: [PATCH 181/245] update settings to enable SSO networks --- ext/central-controller-docker/main-new.sh | 3 ++- service/OneService.cpp | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index c443a78474..360f22126a 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -133,7 +133,8 @@ echo "{ \"controller\": { \"listenMode\": \"${ZT_LISTEN_MODE:-pgsql}\", \"statusMode\": \"${ZT_STATUS_MODE:-pgsql}\", - \"assignedCentralVersion\": \"${ZT_ASSIGNED_CENTRAL_VERSION:-all}\" + \"assignedCentralVersion\": \"${ZT_ASSIGNED_CENTRAL_VERSION:-all}\", + \"ssoEnabled\": ${ZT_SSO_ENABLED:-false} ${REDIS} ${BIGTABLE_CONF} ${PUBSUB_CONF} diff --git a/service/OneService.cpp b/service/OneService.cpp index 5bf6a15994..13280e8d10 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -1825,6 +1825,8 @@ class OneServiceImpl : public OneService { _controllerConfig.assignedCentralVersion = av; } + _controllerConfig.ssoEnabled = OSUtils::jsonBool(cc["ssoEnabled"], false); + // redis settings if (cc["redis"].is_object() && _rc == NULL) { json& redis = cc["redis"]; From dd6e69f530297b6d03544659bedfb3228f9f99bc Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 31 Mar 2026 14:04:30 -0700 Subject: [PATCH 182/245] sso query fix in controller --- nonfree/controller/CentralDB.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index ac41250ac6..8f4d66c082 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -512,7 +512,7 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri // check if the member exists first. pqxx::row count = - w.exec("SELECT count(id) FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", + w.exec("SELECT count(*) FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", pqxx::params { memberId, networkId }) .one_row(); if (count[0].as() == 1) { From 20f7311622f19d64673ee9fc670d2a143ec5bd34 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 1 Apr 2026 09:48:05 -0700 Subject: [PATCH 183/245] Skip redundant nonce sending with an expiry time of 0 --- nonfree/controller/CentralDB.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 8f4d66c082..6e65a90f25 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -584,14 +584,6 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri exit(7); } - // For reused nonces (non-INSERT paths), publish the nonce update here. - // New nonces are published inside the INSERT branch above (before w.commit()). - // We use 0 for nonceExpiration on reused nonces since the actual - // expiration is already stored in the database. - if (_ssoNonceWriter && ! nonce.empty()) { - _ssoNonceWriter->publishSSONonceUpdate(nonce, 0, networkId, memberId, frontend); - } - r = w.exec( "SELECT oc.client_id, oc.authorization_endpoint, oc.issuer, oc.provider, 1 AS sso_impl_version " "FROM oidc_config oc " From ea5c91b0e93f9196daed6c64c9b17e809babae97 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 2 Apr 2026 10:04:23 -0700 Subject: [PATCH 184/245] Remove smee from CentralDB. Now handled in CV1 on new member join via pubsub integration when a new member comes through --- nonfree/controller/CentralDB.cpp | 74 -------------------------------- nonfree/controller/CentralDB.hpp | 47 ++++++-------------- 2 files changed, 14 insertions(+), 107 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 6e65a90f25..82b315b2f8 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -39,7 +39,6 @@ #include #include #include -#include #include // #define REDIS_TRACE 1 @@ -74,15 +73,12 @@ CentralDB::CentralDB(const Identity& myId, , _redis(NULL) , _cluster(NULL) , _redisMemberStatus(false) - , _smee(NULL) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("CentralDB"); auto span = tracer->StartSpan("CentralDB::CentralDB"); auto scope = tracer->WithActiveSpan(span); - rustybits::init_async_runtime(); - char myAddress[64]; _myAddressStr = myId.address().toString(myAddress); _connString = std::string(connString); @@ -238,19 +234,10 @@ CentralDB::CentralDB(const Identity& myId, _commitThread[i] = std::thread(&CentralDB::commitThread, this); } _onlineNotificationThread = std::thread(&CentralDB::onlineNotificationThread, this); - - configureSmee(); } CentralDB::~CentralDB() { - if (_smee != NULL) { - rustybits::smee_client_delete(_smee); - _smee = NULL; - } - - rustybits::shutdown_async_runtime(); - _run = 0; std::this_thread::sleep_for(std::chrono::milliseconds(100)); @@ -262,39 +249,6 @@ CentralDB::~CentralDB() _onlineNotificationThread.join(); } -void CentralDB::configureSmee() -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("CentralDB"); - auto span = tracer->StartSpan("CentralDB::configureSmee"); - auto scope = tracer->WithActiveSpan(span); - - const char* TEMPORAL_SCHEME = "ZT_TEMPORAL_SCHEME"; - const char* TEMPORAL_HOST = "ZT_TEMPORAL_HOST"; - const char* TEMPORAL_PORT = "ZT_TEMPORAL_PORT"; - const char* TEMPORAL_NAMESPACE = "ZT_TEMPORAL_NAMESPACE"; - const char* SMEE_TASK_QUEUE = "ZT_SMEE_TASK_QUEUE"; - - const char* scheme = getenv(TEMPORAL_SCHEME); - if (scheme == NULL) { - scheme = "http"; - } - const char* host = getenv(TEMPORAL_HOST); - const char* port = getenv(TEMPORAL_PORT); - const char* ns = getenv(TEMPORAL_NAMESPACE); - const char* task_queue = getenv(SMEE_TASK_QUEUE); - - if (scheme != NULL && host != NULL && port != NULL && ns != NULL && task_queue != NULL) { - fprintf(stderr, "creating smee client\n"); - std::string hostPort = - std::string(scheme) + std::string("://") + std::string(host) + std::string(":") + std::string(port); - this->_smee = rustybits::smee_client_new(hostPort.c_str(), ns, task_queue); - } - else { - fprintf(stderr, "Smee client not configured\n"); - } -} - bool CentralDB::waitForReady() { while (_ready < 2) { @@ -1337,24 +1291,6 @@ void CentralDB::commitThread() } } - if (_smee != NULL && isNewMember) { - // TODO: Smee Notifications for New Members - // pqxx::row row = w.exec_params1( - // "SELECT " - // " count(h.hook_id) " - // "FROM " - // " ztc_hook h " - // " INNER JOIN ztc_org o ON o.org_id = h.org_id " - // " INNER JOIN ztc_network n ON n.owner_id = o.owner_id " - // " WHERE " - // "n.id = $1 ", - // networkId); - // int64_t hookCount = row[0].as(); - // if (hookCount > 0) { - // notifyNewMember(networkId, memberId); - // } - } - const uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); const uint64_t memberidInt = OSUtils::jsonIntHex(config["id"], 0ULL); if (nwidInt && memberidInt) { @@ -1586,16 +1522,6 @@ void CentralDB::commitThread() fprintf(stderr, "%s commitThread finished\n", _myAddressStr.c_str()); } -void CentralDB::notifyNewMember(const std::string& networkID, const std::string& memberID) -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("CentralDB"); - auto span = tracer->StartSpan("CentralDB::notifyNewMember"); - auto scope = tracer->WithActiveSpan(span); - - rustybits::smee_client_notify_network_joined(_smee, networkID.c_str(), memberID.c_str()); -} - void CentralDB::onlineNotificationThread() { waitForReady(); diff --git a/nonfree/controller/CentralDB.hpp b/nonfree/controller/CentralDB.hpp index 94210114a4..51b8fadae9 100644 --- a/nonfree/controller/CentralDB.hpp +++ b/nonfree/controller/CentralDB.hpp @@ -16,10 +16,6 @@ #include #include -namespace rustybits { -struct SmeeClient; -} - namespace ZeroTier { struct RedisConfig; struct ControllerConfig; @@ -40,13 +36,12 @@ class CentralDB : public DB { STATUS_WRITER_MODE_BIGTABLE = 2, }; - CentralDB( - const Identity& myId, - const char* connString, - int listenPort, - CentralDB::ListenerMode mode, - CentralDB::StatusWriterMode statusMode, - const ControllerConfig* cc); + CentralDB(const Identity& myId, + const char* connString, + int listenPort, + CentralDB::ListenerMode mode, + CentralDB::StatusWriterMode statusMode, + const ControllerConfig* cc); virtual ~CentralDB(); virtual bool waitForReady(); @@ -55,34 +50,25 @@ class CentralDB : public DB { virtual void eraseNetwork(const uint64_t networkId); virtual void eraseMember(const uint64_t networkId, const uint64_t memberId); virtual void nodeIsOnline(const uint64_t networkId, const uint64_t memberId, const InetAddress& physicalAddress); - virtual void nodeIsOnline( - const uint64_t networkId, - const uint64_t memberId, - const InetAddress& physicalAddress, - const char* osArch); + virtual void nodeIsOnline(const uint64_t networkId, + const uint64_t memberId, + const InetAddress& physicalAddress, + const char* osArch); virtual AuthInfo getSSOAuthInfo(const nlohmann::json& member, const std::string& redirectURL); virtual bool ready() - { - return _ready == 2; - } + { return _ready == 2; } virtual void _memberChanged(nlohmann::json& old, nlohmann::json& memberConfig, bool notifyListeners) - { - DB::_memberChanged(old, memberConfig, notifyListeners); - } + { DB::_memberChanged(old, memberConfig, notifyListeners); } virtual void _networkChanged(nlohmann::json& old, nlohmann::json& networkConfig, bool notifyListeners) - { - DB::_networkChanged(old, networkConfig, notifyListeners); - } + { DB::_networkChanged(old, networkConfig, notifyListeners); } protected: struct _PairHasher { inline std::size_t operator()(const std::pair& p) const - { - return (std::size_t)(p.first ^ p.second); - } + { return (std::size_t)(p.first ^ p.second); } }; private: @@ -93,9 +79,6 @@ class CentralDB : public DB { void commitThread(); void onlineNotificationThread(); - void configureSmee(); - void notifyNewMember(const std::string& networkID, const std::string& memberID); - nlohmann::json _getNetworkMember(pqxx::work& tx, const std::string networkID, const std::string memberID); nlohmann::json _getNetwork(pqxx::work& tx, const std::string networkID); @@ -152,8 +135,6 @@ class CentralDB : public DB { std::shared_ptr _redis; std::shared_ptr _cluster; bool _redisMemberStatus; - - rustybits::SmeeClient* _smee; }; } // namespace ZeroTier From af7eae5d9e59fcf52d471cc0aaec975caad37ea9 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 3 Apr 2026 09:52:55 -0700 Subject: [PATCH 185/245] Added a little bit more logging for the node checkin/bigtable write process --- nonfree/controller/BigTableStatusWriter.cpp | 1 + nonfree/controller/CentralDB.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/nonfree/controller/BigTableStatusWriter.cpp b/nonfree/controller/BigTableStatusWriter.cpp index b524270eef..0403d14d7b 100644 --- a/nonfree/controller/BigTableStatusWriter.cpp +++ b/nonfree/controller/BigTableStatusWriter.cpp @@ -85,6 +85,7 @@ void BigTableStatusWriter::writePending() toWrite.swap(_pending); } if (toWrite.empty()) { + fprintf(stderr, "BigTableStatusWriter::writePending: nothing to write\n"); return; } diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 82b315b2f8..77f96c6e7e 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1539,11 +1539,10 @@ void CentralDB::onlineNotificationThread() lastOnline.swap(_lastOnline); } - uint64_t updateCount = 0; + uint64_t writtenCount = 0; auto c = _pool->borrow(); pqxx::work w(*c->c); for (auto i = lastOnline.begin(); i != lastOnline.end(); ++i) { - updateCount += 1; uint64_t nwid_i = i->first.first; char nwidTmp[64]; char memTmp[64]; @@ -1605,7 +1604,10 @@ void CentralDB::onlineNotificationThread() _statusWriter->updateNodeStatus(networkId, memberId, os, arch, version, i->second.physicalAddress, ts, frontend); + writtenCount++; } + fprintf(stderr, "onlineNotificationThread: %llu entries in lastOnline, %llu passed to status writer\n", + (unsigned long long)lastOnline.size(), (unsigned long long)writtenCount); _statusWriter->writePending(); w.commit(); _pool->unborrow(c); From 1f3a04f303a67c6555b9ca93ade752ff377037db Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 3 Apr 2026 10:28:28 -0700 Subject: [PATCH 186/245] periodic queue size logging, and fix some db connection leaks --- nonfree/controller/CentralDB.cpp | 8 ++++++-- nonfree/controller/EmbeddedNetworkController.cpp | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 77f96c6e7e..8df064c8ca 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1071,6 +1071,7 @@ void CentralDB::heartbeat() } catch (std::exception& e) { fprintf(stderr, "%s: Heartbeat update failed: %s\n", controllerId, e.what()); + _pool->unborrow(c); span->End(); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); continue; @@ -1532,6 +1533,7 @@ void CentralDB::onlineNotificationThread() auto span = tracer->StartSpan("CentralDB::onlineNotificationThread"); auto scope = tracer->WithActiveSpan(span); + std::shared_ptr c; try { std::unordered_map, NodeOnlineRecord, _PairHasher> lastOnline; { @@ -1540,7 +1542,7 @@ void CentralDB::onlineNotificationThread() } uint64_t writtenCount = 0; - auto c = _pool->borrow(); + c = _pool->borrow(); pqxx::work w(*c->c); for (auto i = lastOnline.begin(); i != lastOnline.end(); ++i) { uint64_t nwid_i = i->first.first; @@ -1610,11 +1612,13 @@ void CentralDB::onlineNotificationThread() (unsigned long long)lastOnline.size(), (unsigned long long)writtenCount); _statusWriter->writePending(); w.commit(); - _pool->unborrow(c); } catch (std::exception& e) { fprintf(stderr, "%s: error in onlinenotification thread: %s\n", _myAddressStr.c_str(), e.what()); } + if (c) { + _pool->unborrow(c); + } } std::this_thread::sleep_for(std::chrono::seconds(10)); diff --git a/nonfree/controller/EmbeddedNetworkController.cpp b/nonfree/controller/EmbeddedNetworkController.cpp index 48134c036a..f0213d27a8 100644 --- a/nonfree/controller/EmbeddedNetworkController.cpp +++ b/nonfree/controller/EmbeddedNetworkController.cpp @@ -2462,19 +2462,24 @@ void EmbeddedNetworkController::_startThreads() } const long hwc = std::max((long)std::thread::hardware_concurrency(), (long)1); for (long t = 0; t < hwc; ++t) { - _threads.emplace_back([this]() { + _threads.emplace_back([this, t]() { Metrics::network_config_request_threads++; + uint64_t processedCount = 0; + uint64_t idleIterations = 0; for (;;) { _RQEntry* qe = (_RQEntry*)0; - Metrics::network_config_request_queue_size = _queue.size(); + auto queueSize = _queue.size(); + Metrics::network_config_request_queue_size = queueSize; auto timedWaitResult = _queue.get(qe, 1000); if (timedWaitResult == BlockingQueue<_RQEntry*>::STOP) { break; } else if (timedWaitResult == BlockingQueue<_RQEntry*>::OK) { + idleIterations = 0; if (qe) { try { _request(qe->nwid, qe->fromAddr, qe->requestPacketId, qe->identity, qe->metaData); + processedCount++; } catch (std::exception& e) { fprintf( @@ -2490,6 +2495,13 @@ void EmbeddedNetworkController::_startThreads() qe = nullptr; } } + else { + // Periodic liveness log every ~30s (30 timeout iterations of 1000ms) + if (++idleIterations % 30 == 0) { + fprintf(stderr, "request worker %ld: alive, queue_size=%lu, total_processed=%llu\n", + t, (unsigned long)queueSize, (unsigned long long)processedCount); + } + } } Metrics::network_config_request_threads--; }); From 4ca5c9b820b08e53438e7e2fcf53ba653bfe281f Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Sat, 11 Apr 2026 07:40:11 -0700 Subject: [PATCH 187/245] fix poison pill blocking proccessing --- nonfree/controller/PubSubListener.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 9ce3c12d9f..2e777c9be4 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -106,14 +106,18 @@ void PubSubListener::subscribe() span->SetAttribute("ordering_key", m.ordering_key()); if (onNotification(m.data())) { - std::move(h).ack(); span->SetStatus(opentelemetry::trace::StatusCode::kOk); - return true; } else { + // Always ack even on failure — permanent errors (bad protobuf, + // missing fields, JSON parse) will never succeed on retry and + // would block all subsequent messages on this ordering key. + fprintf(stderr, "onNotification failed for message %s (ordering_key=%s); acking to avoid poison pill\n", + m.message_id().c_str(), m.ordering_key().c_str()); span->SetStatus(opentelemetry::trace::StatusCode::kError, "onNotification failed"); - return false; } + std::move(h).ack(); + return true; } }); From 910334c2a5777ef6315971e87cab18fbb235694b Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Sat, 11 Apr 2026 09:30:21 -0700 Subject: [PATCH 188/245] Fix silent PubSub message loss in controller subscription loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 10-second session.cancel() loop raced with in-flight acks — when cancel fired while the GCP client was processing messages, acks were lost before reaching the server. With message ordering enabled, an unacked message blocks all subsequent messages on that ordering key, causing silent stalls with no error output. Two fixes: - Replace the cancel/reconnect timer with a blocking session.get(), storing the session future so the destructor can cancel on shutdown. - Always ack messages even when onNotification fails — permanent errors (bad protobuf, missing fields) will never succeed on retry and would otherwise poison the ordering key indefinitely. --- nonfree/controller/PubSubListener.cpp | 30 ++++++++++++++++++++------- nonfree/controller/PubSubListener.hpp | 3 +++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 2e777c9be4..1313310bfc 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -67,6 +67,12 @@ PubSubListener::PubSubListener(std::string controller_id, std::string project, s PubSubListener::~PubSubListener() { _run = false; + { + std::lock_guard lock(_sessionMutex); + if (_hasSession) { + _session.cancel(); + } + } if (_subscriberThread.joinable()) { _subscriberThread.join(); } @@ -121,15 +127,25 @@ void PubSubListener::subscribe() } }); - auto result = session.wait_for(std::chrono::seconds(10)); - if (result == std::future_status::timeout) { - session.cancel(); - continue; + { + std::lock_guard lock(_sessionMutex); + _session = std::move(session); + _hasSession = true; + } + + // Block until the session ends (server disconnect, error, or + // cancel from destructor). Do NOT cancel on a timer — cancelling + // races with in-flight acks and silently drops messages, + // especially with ordering enabled. + auto status = _session.get(); + + { + std::lock_guard lock(_sessionMutex); + _hasSession = false; } - if (! session.valid()) { - fprintf(stderr, "Subscription session no longer valid\n"); - continue; + if (! status.ok()) { + fprintf(stderr, "Subscription session ended: %s\n", status.message().c_str()); } } catch (google::cloud::Status const& status) { diff --git a/nonfree/controller/PubSubListener.hpp b/nonfree/controller/PubSubListener.hpp index 3fe52543b8..ddde76423f 100644 --- a/nonfree/controller/PubSubListener.hpp +++ b/nonfree/controller/PubSubListener.hpp @@ -36,6 +36,9 @@ class PubSubListener : public NotificationListener { private: void subscribe(); bool _run = false; + std::mutex _sessionMutex; + google::cloud::future _session; + bool _hasSession = false; google::cloud::pubsub_admin::SubscriptionAdminClient _adminClient; google::cloud::pubsub::Subscription* _subscription; std::shared_ptr _subscriber; From d2361a9a66d746cf7c4e98b127bd96b58584f3d4 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Sat, 11 Apr 2026 12:39:05 -0700 Subject: [PATCH 189/245] logging --- nonfree/controller/PubSubListener.cpp | 78 +++++++++++++++------------ 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index 1313310bfc..c8ddcebc4c 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -87,44 +87,54 @@ void PubSubListener::subscribe() { while (_run) { try { + fprintf(stderr, "PubSubListener::subscribe: starting session for subscription %s\n", _subscription_id.c_str()); auto session = _subscriber->Subscribe([this](pubsub::Message const& m, pubsub::AckHandler h) { - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("PubSubListener"); - - auto propagator = opentelemetry::context::propagation::GlobalTextMapPropagator::GetGlobalPropagator(); - auto attrs = m.attributes(); - std::map attrs_map; - for (auto const& kv : m.attributes()) { - attrs_map.emplace(kv.first, kv.second); - } - - OtelCarrier > carrier(attrs_map); - - auto current_ctx = opentelemetry::context::RuntimeContext::GetCurrent(); - auto new_context = propagator->Extract(carrier, current_ctx); - auto remote_span = opentelemetry::trace::GetSpan(new_context); - auto remote_scope = tracer->WithActiveSpan(remote_span); - - { - auto span = tracer->StartSpan("PubSubListener::onMessage"); - auto scope = tracer->WithActiveSpan(span); - span->SetAttribute("message_id", m.message_id()); - span->SetAttribute("ordering_key", m.ordering_key()); - - if (onNotification(m.data())) { - span->SetStatus(opentelemetry::trace::StatusCode::kOk); + try { + fprintf(stderr, "PubSubListener callback invoked: subscription=%s message_id=%s ordering_key=%s\n", + _subscription_id.c_str(), m.message_id().c_str(), m.ordering_key().c_str()); + auto provider = opentelemetry::trace::Provider::GetTracerProvider(); + auto tracer = provider->GetTracer("PubSubListener"); + + auto propagator = opentelemetry::context::propagation::GlobalTextMapPropagator::GetGlobalPropagator(); + auto attrs = m.attributes(); + std::map attrs_map; + for (auto const& kv : m.attributes()) { + attrs_map.emplace(kv.first, kv.second); } - else { - // Always ack even on failure — permanent errors (bad protobuf, - // missing fields, JSON parse) will never succeed on retry and - // would block all subsequent messages on this ordering key. - fprintf(stderr, "onNotification failed for message %s (ordering_key=%s); acking to avoid poison pill\n", - m.message_id().c_str(), m.ordering_key().c_str()); - span->SetStatus(opentelemetry::trace::StatusCode::kError, "onNotification failed"); + + OtelCarrier > carrier(attrs_map); + + auto current_ctx = opentelemetry::context::RuntimeContext::GetCurrent(); + auto new_context = propagator->Extract(carrier, current_ctx); + auto remote_span = opentelemetry::trace::GetSpan(new_context); + auto remote_scope = tracer->WithActiveSpan(remote_span); + + { + auto span = tracer->StartSpan("PubSubListener::onMessage"); + auto scope = tracer->WithActiveSpan(span); + span->SetAttribute("message_id", m.message_id()); + span->SetAttribute("ordering_key", m.ordering_key()); + + if (onNotification(m.data())) { + span->SetStatus(opentelemetry::trace::StatusCode::kOk); + } + else { + fprintf(stderr, "onNotification failed for message %s (ordering_key=%s); acking to avoid poison pill\n", + m.message_id().c_str(), m.ordering_key().c_str()); + span->SetStatus(opentelemetry::trace::StatusCode::kError, "onNotification failed"); + } } - std::move(h).ack(); - return true; } + catch (const std::exception& e) { + fprintf(stderr, "PubSubListener callback exception: %s (subscription=%s message_id=%s)\n", + e.what(), _subscription_id.c_str(), m.message_id().c_str()); + } + catch (...) { + fprintf(stderr, "PubSubListener callback unknown exception (subscription=%s message_id=%s)\n", + _subscription_id.c_str(), m.message_id().c_str()); + } + std::move(h).ack(); + return true; }); { From 0e8ec661c8eff027653d1653bee20df7e06d62a2 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Sat, 11 Apr 2026 13:42:44 -0700 Subject: [PATCH 190/245] make sure subscribe pulls stay running --- nonfree/controller/PubSubListener.cpp | 38 ++++++++++++++++++++------- nonfree/controller/PubSubListener.hpp | 1 + 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index c8ddcebc4c..e3b02f1f9e 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -88,10 +88,11 @@ void PubSubListener::subscribe() while (_run) { try { fprintf(stderr, "PubSubListener::subscribe: starting session for subscription %s\n", _subscription_id.c_str()); + _lastMessageTime.store(std::chrono::steady_clock::now()); + auto session = _subscriber->Subscribe([this](pubsub::Message const& m, pubsub::AckHandler h) { + _lastMessageTime.store(std::chrono::steady_clock::now()); try { - fprintf(stderr, "PubSubListener callback invoked: subscription=%s message_id=%s ordering_key=%s\n", - _subscription_id.c_str(), m.message_id().c_str(), m.ordering_key().c_str()); auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("PubSubListener"); @@ -143,19 +144,38 @@ void PubSubListener::subscribe() _hasSession = true; } - // Block until the session ends (server disconnect, error, or - // cancel from destructor). Do NOT cancel on a timer — cancelling - // races with in-flight acks and silently drops messages, - // especially with ordering enabled. - auto status = _session.get(); + // Poll the session with a timeout. If no messages have been + // received for 60 seconds, assume the pull stream is frozen + // and cancel so we can reconnect. This avoids the old + // 10-second blind cancel that raced with in-flight acks. + while (_run) { + auto result = _session.wait_for(std::chrono::seconds(15)); + if (result == std::future_status::ready) { + break; // session ended naturally + } + auto idle = std::chrono::steady_clock::now() - _lastMessageTime.load(); + if (idle > std::chrono::seconds(60)) { + fprintf(stderr, "PubSubListener: no messages for 60s on %s, reconnecting\n", + _subscription_id.c_str()); + _session.cancel(); + break; + } + } { std::lock_guard lock(_sessionMutex); _hasSession = false; } - if (! status.ok()) { - fprintf(stderr, "Subscription session ended: %s\n", status.message().c_str()); + // Retrieve the session status (blocks until cancel or natural end completes) + try { + auto status = _session.get(); + if (! status.ok()) { + fprintf(stderr, "Subscription session ended: %s\n", status.message().c_str()); + } + } + catch (...) { + fprintf(stderr, "Subscription session ended with exception on %s\n", _subscription_id.c_str()); } } catch (google::cloud::Status const& status) { diff --git a/nonfree/controller/PubSubListener.hpp b/nonfree/controller/PubSubListener.hpp index ddde76423f..026e956b85 100644 --- a/nonfree/controller/PubSubListener.hpp +++ b/nonfree/controller/PubSubListener.hpp @@ -39,6 +39,7 @@ class PubSubListener : public NotificationListener { std::mutex _sessionMutex; google::cloud::future _session; bool _hasSession = false; + std::atomic _lastMessageTime; google::cloud::pubsub_admin::SubscriptionAdminClient _adminClient; google::cloud::pubsub::Subscription* _subscription; std::shared_ptr _subscriber; From 23d395d781e4b7c1d1c844f0c0938fcba78a2b35 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 30 Apr 2026 09:41:24 -0700 Subject: [PATCH 191/245] change sso topic names for clarity --- ext/central-controller-docker/main-new.sh | 4 ++-- nonfree/controller/CentralDB.cpp | 8 ++++---- nonfree/controller/ControllerConfig.hpp | 4 ++-- service/OneService.cpp | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index 360f22126a..4f3935785d 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -106,8 +106,8 @@ if [ "$ZT_USE_PUBSUB" == "true" ]; then \"member_change_send_topic\": \"${ZT_PUBSUB_MEMBER_CHANGE_SEND_TOPIC}\", \"network_change_recv_topic\": \"${ZT_PUBSUB_NETWORK_CHANGE_RECV_TOPIC}\", \"network_change_send_topic\": \"${ZT_PUBSUB_NETWORK_CHANGE_SEND_TOPIC}\", - \"sso_send_topic\": \"${ZT_PUBSUB_SSO_SEND_TOPIC}\", - \"sso_recv_topic\": \"${ZT_PUBSUB_SSO_RECV_TOPIC}\" + \"sso_nonce_publish_topic\": \"${ZT_PUBSUB_SSO_NONCE_PUBLISH_TOPIC}\", + \"sso_auth_subscribe_topic\": \"${ZT_PUBSUB_SSO_AUTH_SUBSCRIBE_TOPIC}\" } " fi diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 8df064c8ca..0ec7a41f30 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -170,13 +170,13 @@ CentralDB::CentralDB(const Identity& myId, _changeNotifier = std::make_shared(_myAddressStr, cc->pubSubConfig->project_id, cc->pubSubConfig->member_change_send_topic, cc->pubSubConfig->network_change_send_topic); - if (! cc->pubSubConfig->sso_send_topic.empty()) { + if (! cc->pubSubConfig->sso_nonce_publish_topic.empty()) { _ssoNonceWriter = std::make_shared(cc->pubSubConfig->project_id, - cc->pubSubConfig->sso_send_topic, _myAddressStr); + cc->pubSubConfig->sso_nonce_publish_topic, _myAddressStr); } - if (! cc->pubSubConfig->sso_recv_topic.empty()) { + if (! cc->pubSubConfig->sso_auth_subscribe_topic.empty()) { _ssoAuthListener = std::make_shared(_myAddressStr, cc->pubSubConfig->project_id, - cc->pubSubConfig->sso_recv_topic, _pool); + cc->pubSubConfig->sso_auth_subscribe_topic, _pool); } } else { diff --git a/nonfree/controller/ControllerConfig.hpp b/nonfree/controller/ControllerConfig.hpp index 6c2ec4d112..68799c5348 100644 --- a/nonfree/controller/ControllerConfig.hpp +++ b/nonfree/controller/ControllerConfig.hpp @@ -13,8 +13,8 @@ struct PubSubConfig { std::string member_change_send_topic; std::string network_change_recv_topic; std::string network_change_send_topic; - std::string sso_send_topic; - std::string sso_recv_topic; + std::string sso_nonce_publish_topic; + std::string sso_auth_subscribe_topic; }; struct BigTableConfig { diff --git a/service/OneService.cpp b/service/OneService.cpp index 13280e8d10..e327fd842d 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -1861,10 +1861,10 @@ class OneServiceImpl : public OneService { OSUtils::jsonString(ps["network_change_recv_topic"], ""); _controllerConfig.pubSubConfig->network_change_send_topic = OSUtils::jsonString(ps["network_change_send_topic"], ""); - _controllerConfig.pubSubConfig->sso_send_topic = - OSUtils::jsonString(ps["sso_send_topic"], ""); - _controllerConfig.pubSubConfig->sso_recv_topic = - OSUtils::jsonString(ps["sso_recv_topic"], ""); + _controllerConfig.pubSubConfig->sso_nonce_publish_topic = + OSUtils::jsonString(ps["sso_nonce_publish_topic"], ""); + _controllerConfig.pubSubConfig->sso_auth_subscribe_topic = + OSUtils::jsonString(ps["sso_auth_subscribe_topic"], ""); } if (_controllerConfig.listenMode == "pubsub" && ! _controllerConfig.pubSubConfig) { fprintf(stderr, "ERROR: pubsub listenMode requires pubsub configuration in local.conf" ZT_EOL_S); From 8c3a7771089f9ed794a3f0219cf11e96cd5a9b1d Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 4 May 2026 16:27:45 -0700 Subject: [PATCH 192/245] addressing pr comments --- nonfree/controller/CentralDB.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 0ec7a41f30..0e98ae5891 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -160,6 +160,7 @@ CentralDB::CentralDB(const Identity& myId, else { throw std::runtime_error("CentralDB: Redis listener mode selected but no Redis configuration provided"); } + break; case LISTENER_MODE_PUBSUB: fprintf(stderr, "Using PubSub for change listeners\n"); if (cc->pubSubConfig != NULL) { @@ -171,12 +172,12 @@ CentralDB::CentralDB(const Identity& myId, cc->pubSubConfig->member_change_send_topic, cc->pubSubConfig->network_change_send_topic); if (! cc->pubSubConfig->sso_nonce_publish_topic.empty()) { - _ssoNonceWriter = std::make_shared(cc->pubSubConfig->project_id, - cc->pubSubConfig->sso_nonce_publish_topic, _myAddressStr); + _ssoNonceWriter = std::make_shared( + cc->pubSubConfig->project_id, cc->pubSubConfig->sso_nonce_publish_topic, _myAddressStr); } if (! cc->pubSubConfig->sso_auth_subscribe_topic.empty()) { - _ssoAuthListener = std::make_shared(_myAddressStr, cc->pubSubConfig->project_id, - cc->pubSubConfig->sso_auth_subscribe_topic, _pool); + _ssoAuthListener = std::make_shared( + _myAddressStr, cc->pubSubConfig->project_id, cc->pubSubConfig->sso_auth_subscribe_topic, _pool); } } else { @@ -449,13 +450,6 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri char authenticationURL[4096] = { 0 }; AuthInfo info; info.enabled = true; - - // if (memberId == "a10dccea52" && networkId == "8056c2e21c24673d") { - // fprintf(stderr, "invalid authinfo for grant's machine\n"); - // info.version=1; - // return info; - // } - // fprintf(stderr, "CentralDB::updateMemberOnLoad: %s-%s\n", networkId.c_str(), memberId.c_str()); std::shared_ptr c; try { c = _pool->borrow(); @@ -519,8 +513,6 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri _ssoNonceWriter->publishSSONonceUpdate(nonce, nonceExpiration, networkId, memberId, frontend); } - - w.commit(); } else { // > 1 ?!? Thats an error! @@ -608,7 +600,7 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri authorization_endpoint.c_str()); } } - + w.commit(); _pool->unborrow(c); } catch (std::exception& e) { @@ -1103,7 +1095,7 @@ void CentralDB::commitThread() { fprintf(stderr, "%s: commitThread start\n", _myAddressStr.c_str()); _queueItem qitem; - while (_commitQueue.get(qitem) & (_run == 1)) { + while (_commitQueue.get(qitem) && (_run == 1)) { auto provider = opentelemetry::trace::Provider::GetTracerProvider(); auto tracer = provider->GetTracer("CentralDB"); From f0522a7cdbdf15834487d0f534332456232ec582 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 8 May 2026 10:58:05 -0700 Subject: [PATCH 193/245] fix a typo in some json handling that could be affecting an issue I'm tracking down --- nonfree/controller/PubSubWriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index ed391a3878..d8e2bcb465 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -386,7 +386,7 @@ pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) m->set_remote_trace_level(OSUtils::jsonInt(j["remoteTraceLevel"], 0)); m->set_remote_trace_target(OSUtils::jsonString(j["remoteTraceTarget"], "")); m->set_sso_exempt(OSUtils::jsonBool(j["ssoExempt"], false)); - m->set_auth_expiry_time(OSUtils::jsonInt(j["authExpiryTime"], 0)); + m->set_auth_expiry_time(OSUtils::jsonInt(j["authenticationExpiryTime"], 0)); } catch (const std::exception& e) { fprintf(stderr, "Exception parsing member JSON: %s\n", e.what()); From b79592c71f48dca18f9662d011827206b0f1fe5b Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 13 May 2026 10:28:15 -0700 Subject: [PATCH 194/245] Bugfix pass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ssoConfig checked wrong variable DNS missing-branch wrote to input not output SSO fields renamed to sso* and nested under ssoConfig (across CentralDB, DB defaults, migration_models) Member identity populated into the right field; address = memberId noAutoAssignIPs → noAutoAssignIps casing Member version columns now SELECTed + populated (both sites) removeTraceLevel typo in DB.cpp defaults 8. eraseMember uninitialized tmp2 — member deletes now actually delete 9. Connection leak on continue in both commit branches 10. Unsafe (uint64_t)config["revision"] cast → OSUtils::jsonInt 11. target = "NULL" literal text → std::optional for real SQL NULL ~13 unsafe direct json→string casts → OSUtils::jsonString; dead vars removed from save(); change_source blocks use is_string() checks. Heartbeat zadd literal "controllerId" → variable Network revision double-increment removed PubSub notifier now sees actual old state (DB query moved before INSERT in both branches) _delete_network reads config["id"] instead of config["nwid"] ip_assignments empty-string guards added at both sites (also closes G) ensure last_modified is set on every write to networks & members --- nonfree/controller/CentralDB.cpp | 179 ++++++++++++++++++------------- nonfree/controller/DB.cpp | 11 +- 2 files changed, 114 insertions(+), 76 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 0e98ae5891..7f74614c14 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -275,7 +275,7 @@ bool CentralDB::save(nlohmann::json& record, bool notifyListeners) fprintf(stderr, "record is not an object?!?\n"); return false; } - const std::string objtype = record["objtype"]; + const std::string objtype = OSUtils::jsonString(record["objtype"], ""); if (objtype == "network") { auto span = tracer->StartSpan("CentralDB::save::network"); auto scope = tracer->WithActiveSpan(span); @@ -303,8 +303,6 @@ bool CentralDB::save(nlohmann::json& record, bool notifyListeners) auto span = tracer->StartSpan("CentralDB::save::member"); auto scope = tracer->WithActiveSpan(span); - std::string networkId = record["nwid"]; - std::string memberId = record["id"]; const uint64_t nwid = OSUtils::jsonIntHex(record["nwid"], 0ULL); const uint64_t id = OSUtils::jsonIntHex(record["id"], 0ULL); if ((id) && (nwid)) { @@ -381,12 +379,11 @@ void CentralDB::eraseMember(const uint64_t networkId, const uint64_t memberId) span->SetAttribute("network_id", Utils::hex(networkId, networkIdStr)); span->SetAttribute("member_id", Utils::hex10(memberId, memberIdStr)); - char tmp2[24]; waitForReady(); _queueItem qi; - qi.jsonData["nwid"] = tmp2; - qi.jsonData["id"] = tmp2; + qi.jsonData["nwid"] = networkIdStr; + qi.jsonData["id"] = memberIdStr; qi.jsonData["objtype"] = "_delete_member"; qi.notifyListeners = true; OtelCarrier > carrier(qi.traceContext); @@ -707,22 +704,20 @@ void CentralDB::initializeNetworks() config["v6AssignMode"]["rfc4193"] = false; } config["ssoEnabled"] = cfgtmp["ssoEnabled"].is_boolean() ? cfgtmp["ssoEnabled"].get() : false; - if (config["ssoConfig"].is_object()) { - config["ssoConfig"] = cfgtmp["ssoConfig"]; - } - else { - config["ssoConfig"] = empty; - } + nlohmann::json ssocfg = cfgtmp["ssoConfig"].is_object() ? cfgtmp["ssoConfig"] : nlohmann::json::object(); + ssocfg["ssoClientId"] = ssocfg["ssoClientId"].is_string() ? ssocfg["ssoClientId"].get() : ""; + ssocfg["ssoAuthorizationEndpoint"] = ssocfg["ssoAuthorizationEndpoint"].is_string() + ? ssocfg["ssoAuthorizationEndpoint"].get() + : nullptr; + ssocfg["ssoIssuer"] = ssocfg["ssoIssuer"].is_string() ? ssocfg["ssoIssuer"].get() : ""; + ssocfg["ssoProvider"] = ssocfg["ssoProvider"].is_string() ? ssocfg["ssoProvider"].get() : ""; + config["ssoConfig"] = ssocfg; config["objtype"] = "network"; config["routes"] = cfgtmp["routes"].is_array() ? cfgtmp["routes"] : json::array(); - config["clientId"] = cfgtmp["clientId"].is_string() ? cfgtmp["clientId"].get() : ""; - config["authorizationEndpoint"] = - cfgtmp["authorizationEndpoint"].is_string() ? cfgtmp["authorizationEndpoint"].get() : ""; - config["provider"] = cfgtmp["ssoProvider"].is_string() ? cfgtmp["ssoProvider"].get() : ""; if (! cfgtmp["dns"].is_object()) { - cfgtmp["dns"] = json::object(); - cfgtmp["dns"]["domain"] = ""; - cfgtmp["dns"]["servers"] = json::array(); + config["dns"] = json::object(); + config["dns"]["domain"] = ""; + config["dns"]["servers"] = json::array(); } else { config["dns"] = cfgtmp["dns"]; @@ -826,7 +821,7 @@ void CentralDB::initializeMembers() "(EXTRACT(EPOCH FROM nm.last_authorized_time AT TIME ZONE 'UTC')*1000)::bigint, " "(EXTRACT(EPOCH FROM nm.last_deauthorized_time AT TIME ZONE 'UTC')*1000)::bigint, " "nm.remote_trace_level, nm.remote_trace_target, nm.revision, nm.capabilities, nm.tags, " - "nm.frontend " + "nm.frontend, nm.version_major, nm.version_minor, nm.version_revision, nm.version_protocol " "FROM network_memberships_ctl nm " "INNER JOIN networks_ctl n " " ON nm.network_id = n.id " @@ -872,6 +867,14 @@ void CentralDB::initializeMembers() std::optional // tags , std::string // frontend + , + std::optional // version_major + , + std::optional // version_minor + , + std::optional // version_revision + , + std::optional // version_protocol > row; @@ -907,12 +910,13 @@ void CentralDB::initializeMembers() config["objtype"] = "member"; config["id"] = memberId; - config["address"] = identity.value_or(""); + config["address"] = memberId; + config["identity"] = identity.value_or(""); config["nwid"] = networkId; config["authorized"] = authorized; config["activeBridge"] = active_bridge.value_or(false); config["ipAssignments"] = json::array(); - if (ip_assignments != "{}") { + if (! ip_assignments.empty() && ip_assignments != "{}" && ip_assignments != "[]") { std::string tmp = ip_assignments.substr(1, ip_assignments.length() - 2); std::vector addrs = split(tmp, ','); for (auto it = addrs.begin(); it != addrs.end(); ++it) { @@ -923,7 +927,7 @@ void CentralDB::initializeMembers() config["creationTime"] = creation_time.value_or(0); config["lastAuthorizedTime"] = last_authorized_time.value_or(0); config["lastDeauthorizedTime"] = last_deauthorized_time.value_or(0); - config["noAutoAssignIPs"] = no_auto_assign_ips.value_or(false); + config["noAutoAssignIps"] = no_auto_assign_ips.value_or(false); config["remoteTraceLevel"] = remote_trace_level.value_or(0); config["remoteTraceTarget"] = remote_trace_target.value_or(nullptr); config["revision"] = revision.value_or(0); @@ -931,6 +935,10 @@ void CentralDB::initializeMembers() config["authenticationExpiryTime"] = authentication_expiry_time.value_or(0); config["tags"] = json::parse(tags.value_or("[]")); config["frontend"] = std::get<17>(row); + config["vMajor"] = std::get<18>(row).value_or(-1); + config["vMinor"] = std::get<19>(row).value_or(-1); + config["vRev"] = std::get<20>(row).value_or(-1); + config["vProto"] = std::get<21>(row).value_or(-1); Metrics::member_count++; @@ -1074,10 +1082,10 @@ void CentralDB::heartbeat() try { if (_listenerMode == LISTENER_MODE_REDIS && _redisMemberStatus) { if (_cc->redisConfig->clusterMode) { - _cluster->zadd("controllers", "controllerId", ts); + _cluster->zadd("controllers", controllerId, ts); } else { - _redis->zadd("controllers", "controllerId", ts); + _redis->zadd("controllers", controllerId, ts); } } } @@ -1133,7 +1141,7 @@ void CentralDB::commitThread() Metrics::pgsql_commit_ticks++; try { nlohmann::json& config = (qitem.jsonData); - const std::string objtype = config["objtype"]; + const std::string objtype = OSUtils::jsonString(config["objtype"], ""); if (objtype == "member") { auto mspan = tracer->StartSpan("CentralDB::commitThread::member"); auto mscope = tracer->WithActiveSpan(mspan); @@ -1145,12 +1153,12 @@ void CentralDB::commitThread() try { pqxx::work w(*c->c); - memberId = config["id"]; - networkId = config["nwid"]; + memberId = OSUtils::jsonString(config["id"], ""); + networkId = OSUtils::jsonString(config["nwid"], ""); - std::string target = "NULL"; - if (! config["remoteTraceTarget"].is_null()) { - target = config["remoteTraceTarget"]; + std::optional target; + if (config["remoteTraceTarget"].is_string()) { + target = config["remoteTraceTarget"].get(); } // get network and the frontend it is assigned to @@ -1177,16 +1185,15 @@ void CentralDB::commitThread() int membercount = mrow[0].as(); bool isNewMember = (membercount == 0); - std::string change_source; - if (! config["change_source"].is_null()) { - change_source = config["change_source"]; - } - else { - change_source = "controller"; + std::string change_source = "controller"; + if (config["change_source"].is_string()) { + change_source = config["change_source"].get(); } if (! isNewMember && change_source != "controller" && frontend != change_source) { // if it is not a new member and the change source is not the controller and doesn't match // the frontend, don't apply the change. + w.abort(); + _pool->unborrow(c); continue; } @@ -1212,6 +1219,14 @@ void CentralDB::commitThread() if (vProto < 0) vProto = 0; + // Capture old DB state before INSERT so PubSub notifier sees real prior values. + // Must happen before w.commit() — _getNetworkMember reuses this transaction. + nlohmann::json oldMember; + if (! isNewMember && _listenerMode == LISTENER_MODE_PUBSUB + && (config["change_source"].is_null() || config["change_source"] == "controller")) { + oldMember = _getNetworkMember(w, networkId, memberId); + } + pqxx::result res = w.exec( "INSERT INTO network_memberships_ctl (device_id, network_id, authorized, " @@ -1244,7 +1259,7 @@ void CentralDB::commitThread() "version_minor = EXCLUDED.version_minor, version_revision = " "EXCLUDED.version_revision, " "version_protocol = EXCLUDED.version_protocol, " - "frontend = EXCLUDED.frontend", + "frontend = EXCLUDED.frontend, last_modified = now()", pqxx::params { memberId, networkId, OSUtils::jsonBool(config["authorized"], false), @@ -1272,15 +1287,9 @@ void CentralDB::commitThread() w.commit(); if (_listenerMode == LISTENER_MODE_PUBSUB) { - // Publish change to pubsub stream - + // Publish change to pubsub stream — oldMember was captured before INSERT if (config["change_source"].is_null() || config["change_source"] == "controller") { - nlohmann::json oldMember; - nlohmann::json newMember = config; - if (! isNewMember) { - oldMember = _getNetworkMember(w, networkId, memberId); - } - _changeNotifier->notifyMemberChange(oldMember, newMember, frontend); + _changeNotifier->notifyMemberChange(oldMember, config, frontend); } } @@ -1316,7 +1325,7 @@ void CentralDB::commitThread() // fprintf(stderr, "%s: commitThread: network\n", _myAddressStr.c_str()); pqxx::work w(*c->c); - std::string id = config["id"]; + std::string id = OSUtils::jsonString(config["id"], ""); pqxx::row nwrow = w.exec("SELECT COUNT(id) frontend FROM networks_ctl WHERE id = $1", pqxx::params { id }) @@ -1333,37 +1342,42 @@ void CentralDB::commitThread() } std::string change_source; - if (! config["change_source"].is_null()) { - change_source = config["change_source"]; + if (config["change_source"].is_string()) { + change_source = config["change_source"].get(); } if (! isNewNetwork && change_source != "controller" && frontend != change_source) { // if it is not a new network and the change source is not the controller and doesn't match // the frontend, don't apply the change. + w.abort(); + _pool->unborrow(c); continue; } + // Capture old DB state before INSERT so PubSub notifier sees real prior values. + // Must happen before w.commit() — _getNetwork reuses this transaction. + nlohmann::json oldNetwork; + if (! isNewNetwork && _listenerMode == LISTENER_MODE_PUBSUB + && (config["change_source"].is_null() || config["change_source"] == "controller")) { + oldNetwork = _getNetwork(w, id); + } + pqxx::result res = w.exec( "INSERT INTO networks_ctl (id, name, configuration, controller_id, revision, frontend) " "VALUES ($1, $2, $3, $4, $5, $6) " "ON CONFLICT (id) DO UPDATE SET " "name = EXCLUDED.name, configuration = EXCLUDED.configuration, revision = " - "EXCLUDED.revision+1, " - "frontend = EXCLUDED.frontend", + "EXCLUDED.revision, " + "frontend = EXCLUDED.frontend, last_modified = now()", pqxx::params { id, OSUtils::jsonString(config["name"], ""), OSUtils::jsonDump(config, -1), - _myAddressStr, ((uint64_t)config["revision"]), change_source }); + _myAddressStr, OSUtils::jsonInt(config["revision"], 0), change_source }); w.commit(); if (_listenerMode == LISTENER_MODE_PUBSUB) { - // Publish change to pubsub stream + // Publish change to pubsub stream — oldNetwork was captured before INSERT if (config["change_source"].is_null() || config["change_source"] == "controller") { - nlohmann::json oldNetwork; - nlohmann::json newNetwork = config; - if (! isNewNetwork) { - oldNetwork = _getNetwork(w, id); - } - _changeNotifier->notifyNetworkChange(oldNetwork, newNetwork, frontend); + _changeNotifier->notifyNetworkChange(oldNetwork, config, frontend); } } @@ -1387,7 +1401,7 @@ void CentralDB::commitThread() } if (_listenerMode == LISTENER_MODE_REDIS && _redisMemberStatus) { try { - std::string id = config["id"]; + std::string id = OSUtils::jsonString(config["id"], ""); std::string controllerId = _myAddressStr.c_str(); std::string key = "networks:{" + controllerId + "}"; if (_cc->redisConfig->clusterMode) { @@ -1410,13 +1424,13 @@ void CentralDB::commitThread() // fprintf(stderr, "%s: commitThread: delete network\n", _myAddressStr.c_str()); try { pqxx::work w(*c->c); - std::string networkId = config["id"]; + std::string networkId = OSUtils::jsonString(config["id"], ""); w.exec("DELETE FROM network_memberships_ctl WHERE network_id = $1", pqxx::params { networkId }); w.exec("DELETE FROM networks_ctl WHERE id = $1", pqxx::params { networkId }); w.commit(); - uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); + uint64_t nwidInt = OSUtils::jsonIntHex(config["id"], 0ULL); json oldConfig; get(nwidInt, oldConfig); json empty; @@ -1428,7 +1442,7 @@ void CentralDB::commitThread() } if (_listenerMode == LISTENER_MODE_REDIS && _redisMemberStatus) { try { - std::string id = config["id"]; + std::string id = OSUtils::jsonString(config["id"], ""); std::string controllerId = _myAddressStr.c_str(); std::string key = "networks:{" + controllerId + "}"; if (_cc->redisConfig->clusterMode) { @@ -1454,8 +1468,8 @@ void CentralDB::commitThread() try { pqxx::work w(*c->c); - std::string memberId = config["id"]; - std::string networkId = config["nwid"]; + std::string memberId = OSUtils::jsonString(config["id"], ""); + std::string networkId = OSUtils::jsonString(config["nwid"], ""); pqxx::result res = w.exec("DELETE FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", @@ -1480,8 +1494,8 @@ void CentralDB::commitThread() } if (_listenerMode == LISTENER_MODE_REDIS && _redisMemberStatus) { try { - std::string memberId = config["id"]; - std::string networkId = config["nwid"]; + std::string memberId = OSUtils::jsonString(config["id"], ""); + std::string networkId = OSUtils::jsonString(config["nwid"], ""); std::string controllerId = _myAddressStr.c_str(); std::string key = "network-nodes-all:{" + controllerId + "}:" + networkId; if (_cc->redisConfig->clusterMode) { @@ -1631,7 +1645,7 @@ nlohmann::json CentralDB::_getNetworkMember(pqxx::work& tx, const std::string ne "(EXTRACT(EPOCH FROM nm.last_authorized_time AT TIME ZONE 'UTC')*1000)::bigint, " "(EXTRACT(EPOCH FROM nm.last_deauthorized_time AT TIME ZONE 'UTC')*1000)::bigint, " "nm.remote_trace_level, nm.remote_trace_target, nm.revision, nm.capabilities, nm.tags, " - "nm.frontend " + "nm.frontend, nm.version_major, nm.version_minor, nm.version_revision, nm.version_protocol " "FROM network_memberships_ctl nm " "INNER JOIN networks_ctl n " " ON nm.network_id = n.id " @@ -1668,15 +1682,24 @@ nlohmann::json CentralDB::_getNetworkMember(pqxx::work& tx, const std::string ne std::optional tags = row[16].is_null() ? std::optional() : std::optional(row[16].as()); std::string frontend = row[17].is_null() ? "" : row[17].as(); + std::optional version_major = + row[18].is_null() ? std::optional() : std::optional(row[18].as()); + std::optional version_minor = + row[19].is_null() ? std::optional() : std::optional(row[19].as()); + std::optional version_revision = + row[20].is_null() ? std::optional() : std::optional(row[20].as()); + std::optional version_protocol = + row[21].is_null() ? std::optional() : std::optional(row[21].as()); out["objtype"] = "member"; out["id"] = memberID; out["nwid"] = networkID; - out["address"] = identity.value_or(""); + out["address"] = memberID; + out["identity"] = identity.value_or(""); out["authorized"] = authorized; out["activeBridge"] = active_bridge.value_or(false); out["ipAssignments"] = json::array(); - if (ip_assignments != "{}" && ip_assignments != "[]") { + if (! ip_assignments.empty() && ip_assignments != "{}" && ip_assignments != "[]") { std::string tmp = ip_assignments.substr(1, ip_assignments.length() - 2); std::vector addrs = split(tmp, ','); for (auto it = addrs.begin(); it != addrs.end(); ++it) { @@ -1695,6 +1718,10 @@ nlohmann::json CentralDB::_getNetworkMember(pqxx::work& tx, const std::string ne out["authenticationExpiryTime"] = authentication_expiry_time.value_or(0); out["tags"] = json::parse(tags.value_or("[]")); out["frontend"] = frontend; + out["vMajor"] = version_major.value_or(-1); + out["vMinor"] = version_minor.value_or(-1); + out["vRev"] = version_revision.value_or(-1); + out["vProto"] = version_protocol.value_or(-1); } catch (std::exception& e) { fprintf(stderr, "ERROR: Error getting network member %s-%s: %s\n", networkID.c_str(), memberID.c_str(), @@ -1772,12 +1799,16 @@ nlohmann::json CentralDB::_getNetwork(pqxx::work& tx, const std::string networkI out["v6AssignMode"]["rfc4193"] = false; } out["ssoEnabled"] = cfgtmp["ssoEnabled"].is_boolean() ? cfgtmp["ssoEnabled"].get() : false; + nlohmann::json ssocfg = cfgtmp["ssoConfig"].is_object() ? cfgtmp["ssoConfig"] : nlohmann::json::object(); + ssocfg["ssoClientId"] = ssocfg["ssoClientId"].is_string() ? ssocfg["ssoClientId"].get() : ""; + ssocfg["ssoAuthorizationEndpoint"] = ssocfg["ssoAuthorizationEndpoint"].is_string() + ? ssocfg["ssoAuthorizationEndpoint"].get() + : nullptr; + ssocfg["ssoIssuer"] = ssocfg["ssoIssuer"].is_string() ? ssocfg["ssoIssuer"].get() : ""; + ssocfg["ssoProvider"] = ssocfg["ssoProvider"].is_string() ? ssocfg["ssoProvider"].get() : ""; + out["ssoConfig"] = ssocfg; out["objtype"] = "network"; out["routes"] = cfgtmp["routes"].is_array() ? cfgtmp["routes"] : json::array(); - out["clientId"] = cfgtmp["clientId"].is_string() ? cfgtmp["clientId"].get() : ""; - out["authorizationEndpoint"] = - cfgtmp["authorizationEndpoint"].is_string() ? cfgtmp["authorizationEndpoint"].get() : nullptr; - out["provider"] = cfgtmp["ssoProvider"].is_string() ? cfgtmp["ssoProvider"].get() : ""; if (! cfgtmp["dns"].is_object()) { cfgtmp["dns"] = json::object(); cfgtmp["dns"]["domain"] = ""; diff --git a/nonfree/controller/DB.cpp b/nonfree/controller/DB.cpp index c6d7f74484..d54da6287c 100644 --- a/nonfree/controller/DB.cpp +++ b/nonfree/controller/DB.cpp @@ -51,7 +51,7 @@ void DB::initNetwork(nlohmann::json& network) network["mtu"] = ZT_DEFAULT_MTU; if (! network.count("remoteTraceTarget")) network["remoteTraceTarget"] = nlohmann::json(); - if (! network.count("removeTraceLevel")) + if (! network.count("remoteTraceLevel")) network["remoteTraceLevel"] = 0; if (! network.count("rulesSource")) network["rulesSource"] = ""; @@ -67,6 +67,13 @@ void DB::initNetwork(nlohmann::json& network) network["clientId"] = ""; if (! network.count("authorizationEndpoint")) network["authorizationEndpoint"] = ""; + if (! network.count("ssoConfig")) { + network["ssoConfig"] = nlohmann::json::object(); + network["ssoConfig"]["ssoClientId"] = ""; + network["ssoConfig"]["ssoAuthorizationEndpoint"] = nullptr; + network["ssoConfig"]["ssoIssuer"] = ""; + network["ssoConfig"]["ssoProvider"] = ""; + } network["objtype"] = "network"; } @@ -116,7 +123,7 @@ void DB::initMember(nlohmann::json& member) member["vProto"] = -1; if (! member.count("remoteTraceTarget")) member["remoteTraceTarget"] = nlohmann::json(); - if (! member.count("removeTraceLevel")) + if (! member.count("remoteTraceLevel")) member["remoteTraceLevel"] = 0; member["objtype"] = "member"; } From 7b44e0a3a5abaa12291b3d717afdb321523eabc4 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 13 May 2026 10:40:02 -0700 Subject: [PATCH 195/245] Fix json key inconsistency in pubsub writer --- nonfree/controller/PubSubWriter.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index d8e2bcb465..c9dac3eee7 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -293,11 +293,10 @@ pbmessages::NetworkChange_Network* networkFromJson(const nlohmann::json& j) n->set_sso_enabled(OSUtils::jsonBool(j["ssoEnabled"], false)); nlohmann::json ssocfg = j["ssoConfig"]; if (ssocfg.is_object()) { - n->set_sso_provider(OSUtils::jsonString(ssocfg["provider"], "")); - n->set_sso_client_id(OSUtils::jsonString(ssocfg["clientId"], "")); - n->set_sso_authorization_endpoint(OSUtils::jsonString(ssocfg["authorizationEndpoint"], "")); - n->set_sso_issuer(OSUtils::jsonString(ssocfg["issuer"], "")); - n->set_sso_provider(OSUtils::jsonString(ssocfg["provider"], "")); + n->set_sso_client_id(OSUtils::jsonString(ssocfg["ssoClientId"], "")); + n->set_sso_authorization_endpoint(OSUtils::jsonString(ssocfg["ssoAuthorizationEndpoint"], "")); + n->set_sso_issuer(OSUtils::jsonString(ssocfg["ssoIssuer"], "")); + n->set_sso_provider(OSUtils::jsonString(ssocfg["ssoProvider"], "")); } n->set_rules_source(OSUtils::jsonString(j["rulesSource"], "")); From 1c755845f0bed421bff3469f11d696c4e16ba313 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 13 May 2026 11:01:39 -0700 Subject: [PATCH 196/245] align JSON keys between CentralDB and PubSub listener/writer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Default enableBroadcast to true on load (initializeNetworks and _getNetwork) to match DB::initNetwork. Networks whose JSONB lacks the field now get broadcast on instead of off, which is the documented ZeroTier default. - Stop overwriting networks_ctl.frontend on every UPDATE. It should remain whatever was set at INSERT. The early-exit guard already prevents cross-frontend writes from applying, so dropping the SET preserves correctness. Members are unaffected — they source frontend from the network row, not the change payload. - Add enableBroadcast, creationTime, and revision to PubSubListener's network toJson. The protobuf carries them, but the listener was dropping them on inbound, which caused revision to reset on every PubSub-delivered network update. - Rename member version keys to vMajor/vMinor/vRev/vProto in both PubSubListener (incoming) and PubSubWriter (outgoing). CentralDB, EmbeddedNetworkController, and the rest of the codebase already use these names; the listener/writer were the only sites using versionMajor/Minor/Rev/Protocol, so member version info was being silently dropped through PubSub in both directions. - Pass newMember by const reference in ControllerChangeNotifier::notifyMemberChange to match notifyNetworkChange. Avoids a full JSON copy on every member notify. - Remove duplicate nlohmann::json::parse call in RedisNetworkListener. --- nonfree/controller/CentralDB.cpp | 7 +++---- nonfree/controller/ControllerChangeNotifier.cpp | 2 +- nonfree/controller/ControllerChangeNotifier.hpp | 4 ++-- nonfree/controller/PubSubListener.cpp | 11 +++++++---- nonfree/controller/PubSubWriter.cpp | 8 ++++---- nonfree/controller/RedisListener.cpp | 1 - 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 7f74614c14..d3e19642e5 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -675,7 +675,7 @@ void CentralDB::initializeNetworks() config["revision"] = revision.value_or(0); config["capabilities"] = cfgtmp["capabilities"].is_array() ? cfgtmp["capabilities"] : json::array(); config["enableBroadcast"] = - cfgtmp["enableBroadcast"].is_boolean() ? cfgtmp["enableBroadcast"].get() : false; + cfgtmp["enableBroadcast"].is_boolean() ? cfgtmp["enableBroadcast"].get() : true; config["mtu"] = cfgtmp["mtu"].is_number() ? cfgtmp["mtu"].get() : 2800; config["multicastLimit"] = cfgtmp["multicastLimit"].is_number() ? cfgtmp["multicastLimit"].get() : 64; @@ -1367,8 +1367,7 @@ void CentralDB::commitThread() "VALUES ($1, $2, $3, $4, $5, $6) " "ON CONFLICT (id) DO UPDATE SET " "name = EXCLUDED.name, configuration = EXCLUDED.configuration, revision = " - "EXCLUDED.revision, " - "frontend = EXCLUDED.frontend, last_modified = now()", + "EXCLUDED.revision, last_modified = now()", pqxx::params { id, OSUtils::jsonString(config["name"], ""), OSUtils::jsonDump(config, -1), _myAddressStr, OSUtils::jsonInt(config["revision"], 0), change_source }); @@ -1771,7 +1770,7 @@ nlohmann::json CentralDB::_getNetwork(pqxx::work& tx, const std::string networkI out["lastModified"] = last_modified.value_or(0); out["revision"] = revision.value_or(0); out["capabilities"] = cfgtmp["capabilities"].is_array() ? cfgtmp["capabilities"] : json::array(); - out["enableBroadcast"] = cfgtmp["enableBroadcast"].is_boolean() ? cfgtmp["enableBroadcast"].get() : false; + out["enableBroadcast"] = cfgtmp["enableBroadcast"].is_boolean() ? cfgtmp["enableBroadcast"].get() : true; out["mtu"] = cfgtmp["mtu"].is_number() ? cfgtmp["mtu"].get() : 2800; out["multicastLimit"] = cfgtmp["multicastLimit"].is_number() ? cfgtmp["multicastLimit"].get() : 64; out["private"] = cfgtmp["private"].is_boolean() ? cfgtmp["private"].get() : true; diff --git a/nonfree/controller/ControllerChangeNotifier.cpp b/nonfree/controller/ControllerChangeNotifier.cpp index 2f1bf67fb4..43420d1f65 100644 --- a/nonfree/controller/ControllerChangeNotifier.cpp +++ b/nonfree/controller/ControllerChangeNotifier.cpp @@ -29,7 +29,7 @@ void PubSubChangeNotifier::notifyNetworkChange( void PubSubChangeNotifier::notifyMemberChange( const nlohmann::json& oldMember, - const nlohmann::json newMember, + const nlohmann::json& newMember, const std::string& frontend) { _memberChangeWriter->publishMemberChange(oldMember, newMember, frontend); diff --git a/nonfree/controller/ControllerChangeNotifier.hpp b/nonfree/controller/ControllerChangeNotifier.hpp index 2a5e000ff4..98e5d81bb6 100644 --- a/nonfree/controller/ControllerChangeNotifier.hpp +++ b/nonfree/controller/ControllerChangeNotifier.hpp @@ -20,7 +20,7 @@ class ControllerChangeNotifier { virtual void notifyMemberChange( const nlohmann::json& oldMember, - const nlohmann::json newMember, + const nlohmann::json& newMember, const std::string& frontend = "") = 0; }; @@ -40,7 +40,7 @@ class PubSubChangeNotifier : public ControllerChangeNotifier { virtual void notifyMemberChange( const nlohmann::json& oldMember, - const nlohmann::json newMember, + const nlohmann::json& newMember, const std::string& frontend = "") override; private: diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index e3b02f1f9e..c997dd5027 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -400,6 +400,9 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N out["mtu"] = nc.mtu(); out["multicastLimit"] = nc.multicast_limit(); out["private"] = nc.is_private(); + out["enableBroadcast"] = nc.enable_broadcast(); + out["creationTime"] = nc.creation_time(); + out["revision"] = nc.revision(); out["remoteTraceLevel"] = nc.remote_trace_level(); if (nc.has_remote_trace_target()) { out["remoteTraceTarget"] = nc.remote_trace_target(); @@ -630,10 +633,10 @@ nlohmann::json toJson(const pbmessages::MemberChange_Member& mc, pbmessages::Mem out["tags"] = nlohmann::json::array(); } - out["versionMajor"] = mc.version_major(); - out["versionMinor"] = mc.version_minor(); - out["versionRev"] = mc.version_rev(); - out["versionProtocol"] = mc.version_protocol(); + out["vMajor"] = mc.version_major(); + out["vMinor"] = mc.version_minor(); + out["vRev"] = mc.version_rev(); + out["vProto"] = mc.version_protocol(); switch (source) { case pbmessages::MemberChange_ChangeSource_CV1: out["change_source"] = "cv1"; diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index c9dac3eee7..18b7387cfb 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -378,10 +378,10 @@ pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) m->set_last_deauthorized_time(OSUtils::jsonInt(j["lastDeauthorizedTime"], 0)); m->set_last_authorized_credential_type(OSUtils::jsonString(j["lastAuthorizedCredentialType"], "")); m->set_last_authorized_credential(OSUtils::jsonString(j["lastAuthorizedCredential"], "")); - m->set_version_major(OSUtils::jsonInt(j["versionMajor"], 0)); - m->set_version_minor(OSUtils::jsonInt(j["versionMinor"], 0)); - m->set_version_rev(OSUtils::jsonInt(j["versionRev"], 0)); - m->set_version_protocol(OSUtils::jsonInt(j["versionProtocol"], 0)); + m->set_version_major(OSUtils::jsonInt(j["vMajor"], 0)); + m->set_version_minor(OSUtils::jsonInt(j["vMinor"], 0)); + m->set_version_rev(OSUtils::jsonInt(j["vRev"], 0)); + m->set_version_protocol(OSUtils::jsonInt(j["vProto"], 0)); m->set_remote_trace_level(OSUtils::jsonInt(j["remoteTraceLevel"], 0)); m->set_remote_trace_target(OSUtils::jsonString(j["remoteTraceTarget"], "")); m->set_sso_exempt(OSUtils::jsonBool(j["ssoExempt"], false)); diff --git a/nonfree/controller/RedisListener.cpp b/nonfree/controller/RedisListener.cpp index a5100df6cd..31ae46f014 100644 --- a/nonfree/controller/RedisListener.cpp +++ b/nonfree/controller/RedisListener.cpp @@ -90,7 +90,6 @@ void RedisNetworkListener::listen() for (auto a : attrs) { try { - tmp = nlohmann::json::parse(a.second); tmp = nlohmann::json::parse(a.second); nlohmann::json& ov = tmp["old_val"]; nlohmann::json& nv = tmp["new_val"]; From ac20c320cf4ef6f787fa4ef7836a2baa0a0d615c Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 14 May 2026 13:07:13 -0700 Subject: [PATCH 197/245] update network.proto in line with CV1 and CV2 --- nonfree/controller/CentralDB.cpp | 1 + nonfree/controller/PubSubListener.cpp | 12 ++---------- nonfree/controller/PubSubWriter.cpp | 4 +--- nonfree/controller/protobuf/network.proto | 6 +++--- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index d3e19642e5..b64262b94e 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -532,6 +532,7 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri "FROM oidc_config oc " "INNER JOIN networks_ctl n " " ON oc.client_id = n.configuration->'ssoConfig'->>'ssoClientId' " + " AND oc.linked_id = n.configuration->'ssoConfig'->>'ssoLinkedId' " "WHERE n.id = $1 AND n.configuration->>'ssoEnabled' = 'true' ", pqxx::params { networkId }); diff --git a/nonfree/controller/PubSubListener.cpp b/nonfree/controller/PubSubListener.cpp index c997dd5027..725bf4f5f4 100644 --- a/nonfree/controller/PubSubListener.cpp +++ b/nonfree/controller/PubSubListener.cpp @@ -531,16 +531,8 @@ nlohmann::json toJson(const pbmessages::NetworkChange_Network& nc, pbmessages::N sso["ssoClientId"] = nc.sso_client_id(); } - if (nc.has_sso_authorization_endpoint()) { - sso["ssoAuthorizationEndpoint"] = nc.sso_authorization_endpoint(); - } - - if (nc.has_sso_issuer()) { - sso["ssoIssuer"] = nc.sso_issuer(); - } - - if (nc.has_sso_provider()) { - sso["ssoProvider"] = nc.sso_provider(); + if (nc.has_sso_linked_id()) { + sso["ssoLinkedId"] = nc.sso_linked_id(); } } out["ssoConfig"] = sso; diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index 18b7387cfb..2d9b53cbda 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -294,9 +294,7 @@ pbmessages::NetworkChange_Network* networkFromJson(const nlohmann::json& j) nlohmann::json ssocfg = j["ssoConfig"]; if (ssocfg.is_object()) { n->set_sso_client_id(OSUtils::jsonString(ssocfg["ssoClientId"], "")); - n->set_sso_authorization_endpoint(OSUtils::jsonString(ssocfg["ssoAuthorizationEndpoint"], "")); - n->set_sso_issuer(OSUtils::jsonString(ssocfg["ssoIssuer"], "")); - n->set_sso_provider(OSUtils::jsonString(ssocfg["ssoProvider"], "")); + n->set_sso_linked_id(OSUtils::jsonString(ssocfg["ssoLinkedId"], "")); } n->set_rules_source(OSUtils::jsonString(j["rulesSource"], "")); diff --git a/nonfree/controller/protobuf/network.proto b/nonfree/controller/protobuf/network.proto index 41bbb73e87..af5f183a11 100644 --- a/nonfree/controller/protobuf/network.proto +++ b/nonfree/controller/protobuf/network.proto @@ -54,10 +54,10 @@ message NetworkChange { optional DNS dns = 18; // DNS configuration bool sso_enabled = 19; // Whether Single Sign-On is enabled optional string sso_client_id = 20; // SSO client ID - optional string sso_authorization_endpoint = 21; // SSO authorization endpoint - optional string sso_issuer = 22; // SSO issuer - optional string sso_provider = 23; // SSO provider string rules_source = 24; // source code for rules + optional string sso_linked_id = 25; // FK into oidc_config(linked_id); paired with sso_client_id resolves the row holding issuer/authorization_endpoint/provider + reserved 21, 22, 23; + reserved "sso_authorization_endpoint", "sso_issuer", "sso_provider"; } enum ChangeSource { From 9a9a8c09c3233de8e222214050793a5ed4ccbba2 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 14 May 2026 15:30:44 -0700 Subject: [PATCH 198/245] fix for missing field in json --- nonfree/controller/CentralDB.cpp | 12 ++---------- nonfree/controller/DB.cpp | 1 + 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index b64262b94e..d8b16c6e8c 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -707,11 +707,7 @@ void CentralDB::initializeNetworks() config["ssoEnabled"] = cfgtmp["ssoEnabled"].is_boolean() ? cfgtmp["ssoEnabled"].get() : false; nlohmann::json ssocfg = cfgtmp["ssoConfig"].is_object() ? cfgtmp["ssoConfig"] : nlohmann::json::object(); ssocfg["ssoClientId"] = ssocfg["ssoClientId"].is_string() ? ssocfg["ssoClientId"].get() : ""; - ssocfg["ssoAuthorizationEndpoint"] = ssocfg["ssoAuthorizationEndpoint"].is_string() - ? ssocfg["ssoAuthorizationEndpoint"].get() - : nullptr; - ssocfg["ssoIssuer"] = ssocfg["ssoIssuer"].is_string() ? ssocfg["ssoIssuer"].get() : ""; - ssocfg["ssoProvider"] = ssocfg["ssoProvider"].is_string() ? ssocfg["ssoProvider"].get() : ""; + ssocfg["ssoLinkedId"] = ssocfg["ssoLinkedId"].is_string() ? ssocfg["ssoLinkedId"].get() : ""; config["ssoConfig"] = ssocfg; config["objtype"] = "network"; config["routes"] = cfgtmp["routes"].is_array() ? cfgtmp["routes"] : json::array(); @@ -1801,11 +1797,7 @@ nlohmann::json CentralDB::_getNetwork(pqxx::work& tx, const std::string networkI out["ssoEnabled"] = cfgtmp["ssoEnabled"].is_boolean() ? cfgtmp["ssoEnabled"].get() : false; nlohmann::json ssocfg = cfgtmp["ssoConfig"].is_object() ? cfgtmp["ssoConfig"] : nlohmann::json::object(); ssocfg["ssoClientId"] = ssocfg["ssoClientId"].is_string() ? ssocfg["ssoClientId"].get() : ""; - ssocfg["ssoAuthorizationEndpoint"] = ssocfg["ssoAuthorizationEndpoint"].is_string() - ? ssocfg["ssoAuthorizationEndpoint"].get() - : nullptr; - ssocfg["ssoIssuer"] = ssocfg["ssoIssuer"].is_string() ? ssocfg["ssoIssuer"].get() : ""; - ssocfg["ssoProvider"] = ssocfg["ssoProvider"].is_string() ? ssocfg["ssoProvider"].get() : ""; + ssocfg["ssoLinkedId"] = ssocfg["ssoLinkedId"].is_string() ? ssocfg["ssoLinkedId"].get() : ""; out["ssoConfig"] = ssocfg; out["objtype"] = "network"; out["routes"] = cfgtmp["routes"].is_array() ? cfgtmp["routes"] : json::array(); diff --git a/nonfree/controller/DB.cpp b/nonfree/controller/DB.cpp index d54da6287c..67547b280e 100644 --- a/nonfree/controller/DB.cpp +++ b/nonfree/controller/DB.cpp @@ -70,6 +70,7 @@ void DB::initNetwork(nlohmann::json& network) if (! network.count("ssoConfig")) { network["ssoConfig"] = nlohmann::json::object(); network["ssoConfig"]["ssoClientId"] = ""; + network["ssoConfig"]["ssoLinkedId"] = ""; network["ssoConfig"]["ssoAuthorizationEndpoint"] = nullptr; network["ssoConfig"]["ssoIssuer"] = ""; network["ssoConfig"]["ssoProvider"] = ""; From 80f5e81d8c5748cfaa699c5ee60031bd667278aa Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 19 May 2026 11:09:02 -0700 Subject: [PATCH 199/245] ensure controller doesn't change assigned frontend --- nonfree/controller/CentralDB.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index d8b16c6e8c..92a88caaad 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1359,14 +1359,20 @@ void CentralDB::commitThread() oldNetwork = _getNetwork(w, id); } + // For new networks, tag the row with the originating frontend (change_source). + // For existing networks, reuse the stored frontend so the ON CONFLICT update + // is self-healing rather than ownership-changing (a controller-originated + // message must not silently overwrite the per-network owner). + std::string frontendParam = isNewNetwork ? change_source : frontend; + pqxx::result res = w.exec( "INSERT INTO networks_ctl (id, name, configuration, controller_id, revision, frontend) " "VALUES ($1, $2, $3, $4, $5, $6) " "ON CONFLICT (id) DO UPDATE SET " "name = EXCLUDED.name, configuration = EXCLUDED.configuration, revision = " - "EXCLUDED.revision, last_modified = now()", + "EXCLUDED.revision, frontend = EXCLUDED.frontend, last_modified = now()", pqxx::params { id, OSUtils::jsonString(config["name"], ""), OSUtils::jsonDump(config, -1), - _myAddressStr, OSUtils::jsonInt(config["revision"], 0), change_source }); + _myAddressStr, OSUtils::jsonInt(config["revision"], 0), frontendParam }); w.commit(); From b1427153aa81d83429e94bbca9900f3845caf1d4 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 27 May 2026 07:52:25 -0700 Subject: [PATCH 200/245] handle nulls for remote trace target --- nonfree/controller/CentralDB.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 92a88caaad..00d0760316 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1153,7 +1153,9 @@ void CentralDB::commitThread() memberId = OSUtils::jsonString(config["id"], ""); networkId = OSUtils::jsonString(config["nwid"], ""); - std::optional target; + // Default to "" so a null/absent remoteTraceTarget is written as an + // empty string rather than SQL NULL. + std::optional target = ""; if (config["remoteTraceTarget"].is_string()) { target = config["remoteTraceTarget"].get(); } From 346dc907a1e86144c747c344d645116484d836a6 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 28 May 2026 08:03:07 -0700 Subject: [PATCH 201/245] remove noisy log --- nonfree/controller/PubSubWriter.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/nonfree/controller/PubSubWriter.cpp b/nonfree/controller/PubSubWriter.cpp index 2d9b53cbda..eaf4ea26b8 100644 --- a/nonfree/controller/PubSubWriter.cpp +++ b/nonfree/controller/PubSubWriter.cpp @@ -328,8 +328,6 @@ networkChangeFromJson(std::string controllerID, const nlohmann::json& oldNetwork pbmessages::MemberChange_Member* memberFromJson(const nlohmann::json& j) { if (! j.is_object()) { - fprintf(stderr, "memberFromJson: JSON is not an object\n"); - fprintf(stderr, "JSON: %s\n", j.dump().c_str()); return nullptr; } From 3dffacc02468b28351949ed6ec9d9ccd4894567a Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 28 May 2026 09:12:38 -0700 Subject: [PATCH 202/245] cargo fix --- rustybits/Cargo.lock | 544 +++++++++++++++++++------------- rustybits/Cargo.toml | 8 +- rustybits/smeeclient/Cargo.toml | 21 -- 3 files changed, 336 insertions(+), 237 deletions(-) delete mode 100644 rustybits/smeeclient/Cargo.toml diff --git a/rustybits/Cargo.lock b/rustybits/Cargo.lock index 2e2f78d8a2..abe3960696 100644 --- a/rustybits/Cargo.lock +++ b/rustybits/Cargo.lock @@ -90,7 +90,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -210,6 +210,56 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bollard" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97ccca1260af6a459d75994ad5acc1651bcabcbdbc41467cc9786519ab854c30" +dependencies = [ + "base64 0.22.1", + "bollard-stubs", + "bytes", + "futures-core", + "futures-util", + "hex", + "home", + "http 1.4.0", + "http-body-util", + "hyper 1.9.0", + "hyper-named-pipe", + "hyper-rustls", + "hyper-util", + "hyperlocal", + "log", + "pin-project-lite", + "rustls", + "rustls-native-certs", + "rustls-pemfile 2.2.0", + "rustls-pki-types", + "serde", + "serde_derive", + "serde_json", + "serde_repr", + "serde_urlencoded", + "thiserror 2.0.18", + "tokio", + "tokio-util", + "tower-service", + "url", + "winapi", +] + +[[package]] +name = "bollard-stubs" +version = "1.47.1-rc.27.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f179cfbddb6e77a5472703d4b30436bff32929c0aa8a9008ecf23d1d3cdd0da" +dependencies = [ + "serde", + "serde_repr", + "serde_with", +] + [[package]] name = "bs58" version = "0.5.1" @@ -239,7 +289,7 @@ checksum = "975982cdb7ad6a142be15bdf84aea7ec6a9e5d4d797c004d43185b24cfe4e684" dependencies = [ "clap", "heck", - "indexmap 2.11.0", + "indexmap 2.14.0", "log", "proc-macro2", "quote", @@ -277,7 +327,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-link 0.2.1", + "windows-link", ] [[package]] @@ -433,7 +483,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -466,8 +516,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.11.1", - "syn 2.0.117", + "strsim", + "syn", ] [[package]] @@ -479,8 +529,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.11.1", - "syn 2.0.117", + "strsim", + "syn", ] [[package]] @@ -491,7 +541,7 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core 0.20.11", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -502,7 +552,7 @@ checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" dependencies = [ "darling_core 0.23.0", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -558,7 +608,7 @@ dependencies = [ "darling 0.20.11", "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -568,7 +618,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.117", + "syn", ] [[package]] @@ -590,7 +640,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.117", + "syn", "unicode-xid", ] @@ -614,7 +664,18 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", +] + +[[package]] +name = "docker_credential" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29547a1dc60885a552306986316bc9701ba120c1a8db6769fa68691529ad373d" +dependencies = [ + "base64 0.22.1", + "serde", + "serde_json", ] [[package]] @@ -720,7 +781,7 @@ checksum = "685adfa4d6f3d765a26bc5dbc936577de9abf756c1feeb3089b01dd395034842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -732,7 +793,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -795,6 +856,16 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +[[package]] +name = "filetime" +version = "0.2.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c287a33c7f0a620c38e641e7f60827713987b3c0f26e8ddc9462cc69cf75759" +dependencies = [ + "cfg-if", + "libc", +] + [[package]] name = "find-msvc-tools" version = "0.1.9" @@ -819,12 +890,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" -[[package]] -name = "foldhash" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" - [[package]] name = "foreign-types" version = "0.3.2" @@ -914,7 +979,7 @@ checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -981,7 +1046,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" dependencies = [ "rustix", - "windows-link 0.2.1", + "windows-link", ] [[package]] @@ -1026,9 +1091,9 @@ dependencies = [ [[package]] name = "governor" -version = "0.10.4" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9efcab3c1958580ff1f25a2a41be1668f7603d849bb63af523b208a3cc1223b8" +checksum = "be93b4ec2e4710b04d9264c0c7350cdd62a8c20e5e4ac732552ebb8f0debe8eb" dependencies = [ "cfg-if", "dashmap", @@ -1036,7 +1101,7 @@ dependencies = [ "futures-timer", "futures-util", "getrandom 0.3.4", - "hashbrown 0.16.1", + "no-std-compat", "nonzero_ext", "parking_lot", "portable-atomic", @@ -1113,19 +1178,10 @@ name = "hashbrown" version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" -dependencies = [ - "foldhash 0.1.5", -] - -[[package]] -name = "hashbrown" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ "allocator-api2", "equivalent", - "foldhash 0.2.0", + "foldhash", ] [[package]] @@ -1293,7 +1349,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73b7d8abf35697b81a825e386fc151e0d503e8cb5fcb93cc8669c376dfd6f278" dependencies = [ "hex", - "hyper 1.7.0", + "hyper 1.9.0", "hyper-util", "pin-project-lite", "tokio", @@ -1307,8 +1363,8 @@ version = "0.27.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" dependencies = [ - "http 1.3.1", - "hyper 1.7.0", + "http 1.4.0", + "hyper 1.9.0", "hyper-util", "rustls", "rustls-pki-types", @@ -1371,7 +1427,7 @@ checksum = "986c5ce3b994526b3cd75578e62554abd09f0899d6206de48b3e96ab34ccc8c7" dependencies = [ "hex", "http-body-util", - "hyper 1.7.0", + "hyper 1.9.0", "hyper-util", "pin-project-lite", "tokio", @@ -1647,17 +1703,6 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" -[[package]] -name = "libredox" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4488594b9328dee448adb906d8b126d9b7deb7cf5c22161ee591610bb1be83c0" -dependencies = [ - "bitflags 2.9.4", - "libc", - "redox_syscall 0.5.17", -] - [[package]] name = "linux-raw-sys" version = "0.12.1" @@ -1687,11 +1732,11 @@ checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] name = "lru" -version = "0.16.4" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f66e8d5d03f609abc3a39e6f08e4164ebf1447a732906d39eb9b99b7919ef39" +checksum = "227748d55f2f0ab4735d87fd623798cb6b664512fe979705f829c9f81c934465" dependencies = [ - "hashbrown 0.16.1", + "hashbrown 0.15.5", ] [[package]] @@ -1755,7 +1800,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -1781,6 +1826,12 @@ dependencies = [ "tempfile", ] +[[package]] +name = "no-std-compat" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c" + [[package]] name = "nonzero_ext" version = "0.3.0" @@ -1877,25 +1928,6 @@ dependencies = [ "url", ] -[[package]] -name = "objc2-core-foundation" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" -dependencies = [ - "bitflags 2.11.1", -] - -[[package]] -name = "objc2-io-kit" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15" -dependencies = [ - "libc", - "objc2-core-foundation", -] - [[package]] name = "once_cell" version = "1.21.4" @@ -1962,7 +1994,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -2048,9 +2080,9 @@ checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.17", + "redox_syscall 0.5.18", "smallvec", - "windows-link 0.2.1", + "windows-link", ] [[package]] @@ -2103,6 +2135,17 @@ dependencies = [ "indexmap 2.14.0", ] +[[package]] +name = "petgraph" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" +dependencies = [ + "fixedbitset", + "hashbrown 0.15.5", + "indexmap 2.14.0", +] + [[package]] name = "pid" version = "4.0.0" @@ -2129,7 +2172,7 @@ checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -2237,7 +2280,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", - "syn 2.0.117", + "syn", ] [[package]] @@ -2270,12 +2313,12 @@ dependencies = [ [[package]] name = "prost" -version = "0.14.1" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7231bd9b3d3d33c86b58adbac74b5ec0ad9f496b19d22801d773636feaa95f3d" +checksum = "d2ea70524a2f82d518bce41317d0fae74151505651af45faf1ffbd6fd33f0568" dependencies = [ "bytes", - "prost-derive 0.14.1", + "prost-derive 0.14.3", ] [[package]] @@ -2289,12 +2332,31 @@ dependencies = [ "log", "multimap", "once_cell", - "petgraph", + "petgraph 0.7.1", "prettyplease", "prost 0.13.5", "prost-types 0.13.5", "regex", - "syn 2.0.117", + "syn", + "tempfile", +] + +[[package]] +name = "prost-build" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "343d3bd7056eda839b03204e68deff7d1b13aba7af2b2fd16890697274262ee7" +dependencies = [ + "heck", + "itertools 0.14.0", + "log", + "multimap", + "petgraph 0.8.3", + "prettyplease", + "prost 0.14.3", + "prost-types 0.14.3", + "regex", + "syn", "tempfile", ] @@ -2308,7 +2370,20 @@ dependencies = [ "itertools 0.14.0", "proc-macro2", "quote", - "syn 2.0.117", + "syn", +] + +[[package]] +name = "prost-derive" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27c6023962132f4b30eb4c172c91ce92d933da334c59c23cddee82358ddafb0b" +dependencies = [ + "anyhow", + "itertools 0.14.0", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -2322,11 +2397,11 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.14.1" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9b4db3d6da204ed77bb26ba83b6122a73aeb2e87e25fbf7ad2e84c4ccbf8f72" +checksum = "8991c4cbdb8bc5b11f0b074ffe286c30e523de90fee5ba8132f1399f23cb3dd7" dependencies = [ - "prost 0.14.1", + "prost 0.14.3", ] [[package]] @@ -2479,6 +2554,15 @@ dependencies = [ "bitflags 2.11.1", ] +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_syscall" version = "0.5.18" @@ -2505,7 +2589,7 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -2644,7 +2728,7 @@ dependencies = [ [[package]] name = "rustfsm" version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" +source = "git+https://github.com/temporalio/sdk-core?branch=master#23f495a68f4d025e88c4a6859579587079f5460c" dependencies = [ "rustfsm_procmacro", "rustfsm_trait", @@ -2653,19 +2737,19 @@ dependencies = [ [[package]] name = "rustfsm_procmacro" version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" +source = "git+https://github.com/temporalio/sdk-core?branch=master#23f495a68f4d025e88c4a6859579587079f5460c" dependencies = [ "derive_more", "proc-macro2", "quote", "rustfsm_trait", - "syn 2.0.117", + "syn", ] [[package]] name = "rustfsm_trait" version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" +source = "git+https://github.com/temporalio/sdk-core?branch=master#23f495a68f4d025e88c4a6859579587079f5460c" [[package]] name = "rustix" @@ -2760,7 +2844,7 @@ dependencies = [ "cbindgen", "jwt", "openidconnect", - "prost-build 0.14.1", + "prost-build 0.14.3", "reqwest", "serde", "serde_json", @@ -2902,7 +2986,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -2999,7 +3083,7 @@ dependencies = [ "darling 0.23.0", "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -3161,17 +3245,6 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.117" @@ -3203,20 +3276,19 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] name = "sysinfo" -version = "0.37.2" +version = "0.33.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16607d5caffd1c07ce073528f9ed972d88db15dd44023fa57142963be3feb11f" +checksum = "4fc858248ea01b66f19d8e8a6d55f41deaf91e9d495246fd01368d99935c6c01" dependencies = [ + "core-foundation-sys", "libc", "memchr", "ntapi", - "objc2-core-foundation", - "objc2-io-kit", "windows", ] @@ -3257,7 +3329,7 @@ dependencies = [ [[package]] name = "temporal-client" version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" +source = "git+https://github.com/temporalio/sdk-core?branch=master#23f495a68f4d025e88c4a6859579587079f5460c" dependencies = [ "anyhow", "async-trait", @@ -3289,7 +3361,7 @@ dependencies = [ [[package]] name = "temporal-sdk" version = "0.1.0-alpha.1" -source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" +source = "git+https://github.com/temporalio/sdk-core?branch=master#23f495a68f4d025e88c4a6859579587079f5460c" dependencies = [ "anyhow", "async-trait", @@ -3311,7 +3383,7 @@ dependencies = [ [[package]] name = "temporal-sdk-core" version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" +source = "git+https://github.com/temporalio/sdk-core?branch=master#23f495a68f4d025e88c4a6859579587079f5460c" dependencies = [ "anyhow", "async-trait", @@ -3360,7 +3432,7 @@ dependencies = [ [[package]] name = "temporal-sdk-core-api" version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" +source = "git+https://github.com/temporalio/sdk-core?branch=master#23f495a68f4d025e88c4a6859579587079f5460c" dependencies = [ "async-trait", "derive_builder", @@ -3379,7 +3451,7 @@ dependencies = [ [[package]] name = "temporal-sdk-core-protos" version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" +source = "git+https://github.com/temporalio/sdk-core?branch=master#23f495a68f4d025e88c4a6859579587079f5460c" dependencies = [ "anyhow", "base64 0.22.1", @@ -3425,7 +3497,7 @@ dependencies = [ "serde", "serde_json", "serde_with", - "thiserror 2.0.16", + "thiserror 2.0.18", "tokio", "tokio-stream", "tokio-tar", @@ -3468,7 +3540,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -3479,7 +3551,7 @@ checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -3572,7 +3644,7 @@ checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -3661,7 +3733,7 @@ version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ - "indexmap 2.11.0", + "indexmap 2.14.0", "serde", "serde_spanned", "toml_datetime", @@ -3717,7 +3789,7 @@ dependencies = [ "prost-build 0.13.5", "prost-types 0.13.5", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -3770,7 +3842,7 @@ checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -3839,7 +3911,7 @@ checksum = "cf808357c6ed7e13ba0f3277ec8d8f21b2d501274895104263985330c726c1c5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -3854,12 +3926,6 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9629274872b2bfaf8d66f5f15725007f635594914870f65218920345aa11aa8c" -[[package]] -name = "unicode-width" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" - [[package]] name = "unicode-xid" version = "0.2.6" @@ -4001,7 +4067,7 @@ dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.117", + "syn", "wasm-bindgen-shared", ] @@ -4092,37 +4158,24 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.61.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" -dependencies = [ - "windows-collections", - "windows-core 0.61.2", - "windows-future", - "windows-link 0.1.3", - "windows-numerics", -] - -[[package]] -name = "windows-collections" -version = "0.2.0" +version = "0.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" +checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143" dependencies = [ - "windows-core 0.61.2", + "windows-core 0.57.0", + "windows-targets 0.52.6", ] [[package]] name = "windows-core" -version = "0.61.2" +version = "0.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d" dependencies = [ - "windows-implement", - "windows-interface", - "windows-link 0.1.3", - "windows-result 0.3.4", - "windows-strings 0.4.2", + "windows-implement 0.57.0", + "windows-interface 0.57.0", + "windows-result 0.1.2", + "windows-targets 0.52.6", ] [[package]] @@ -4131,22 +4184,22 @@ version = "0.62.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" dependencies = [ - "windows-implement", - "windows-interface", - "windows-link 0.2.1", + "windows-implement 0.60.2", + "windows-interface 0.59.3", + "windows-link", "windows-result 0.4.1", - "windows-strings 0.5.1", + "windows-strings", ] [[package]] -name = "windows-future" -version = "0.2.1" +name = "windows-implement" +version = "0.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" +checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" dependencies = [ - "windows-core 0.61.2", - "windows-link 0.1.3", - "windows-threading", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -4157,25 +4210,30 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] name = "windows-interface" -version = "0.59.3" +version = "0.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] -name = "windows-link" -version = "0.1.3" +name = "windows-interface" +version = "0.59.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "windows-link" @@ -4183,23 +4241,13 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" -[[package]] -name = "windows-numerics" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" -dependencies = [ - "windows-core 0.61.2", - "windows-link 0.1.3", -] - [[package]] name = "windows-result" -version = "0.3.4" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" dependencies = [ - "windows-link 0.1.3", + "windows-targets 0.52.6", ] [[package]] @@ -4208,16 +4256,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" dependencies = [ - "windows-link 0.2.1", -] - -[[package]] -name = "windows-strings" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" -dependencies = [ - "windows-link 0.1.3", + "windows-link", ] [[package]] @@ -4226,7 +4265,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" dependencies = [ - "windows-link 0.2.1", + "windows-link", ] [[package]] @@ -4247,13 +4286,31 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.5", +] + [[package]] name = "windows-sys" version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ - "windows-link 0.2.1", + "windows-link", ] [[package]] @@ -4280,7 +4337,7 @@ dependencies = [ "windows_aarch64_gnullvm 0.52.6", "windows_aarch64_msvc 0.52.6", "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm", + "windows_i686_gnullvm 0.52.6", "windows_i686_msvc 0.52.6", "windows_x86_64_gnu 0.52.6", "windows_x86_64_gnullvm 0.52.6", @@ -4288,12 +4345,20 @@ dependencies = [ ] [[package]] -name = "windows-threading" -version = "0.1.0" +name = "windows-targets" +version = "0.53.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" dependencies = [ - "windows-link 0.1.3", + "windows-link", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", ] [[package]] @@ -4308,6 +4373,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -4320,6 +4391,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -4332,12 +4409,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -4350,6 +4439,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -4362,6 +4457,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -4374,6 +4475,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" @@ -4386,6 +4493,21 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" + +[[package]] +name = "winnow" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" @@ -4418,7 +4540,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" dependencies = [ "anyhow", - "heck 0.5.0", + "heck", "wit-parser", ] @@ -4429,10 +4551,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" dependencies = [ "anyhow", - "heck 0.5.0", + "heck", "indexmap 2.14.0", "prettyplease", - "syn 2.0.117", + "syn", "wasm-metadata", "wit-bindgen-core", "wit-component", @@ -4448,7 +4570,7 @@ dependencies = [ "prettyplease", "proc-macro2", "quote", - "syn 2.0.117", + "syn", "wit-bindgen-core", "wit-bindgen-rust", ] @@ -4525,7 +4647,7 @@ checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", "synstructure", ] @@ -4546,7 +4668,7 @@ checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] @@ -4566,7 +4688,7 @@ checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", "synstructure", ] @@ -4606,7 +4728,7 @@ checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn", ] [[package]] diff --git a/rustybits/Cargo.toml b/rustybits/Cargo.toml index 9f718d1911..abcd5afdd5 100644 --- a/rustybits/Cargo.toml +++ b/rustybits/Cargo.toml @@ -22,11 +22,9 @@ ztcontroller = [ [dependencies] serde = { version = "1", features = ["derive"], optional = true } serde_json = { version = "1", optional = true } -temporal-sdk = { git = "https://github.com/temporalio/sdk-core", branch = "master", optional = true } -temporal-client = { git = "https://github.com/temporalio/sdk-core", branch = "master", optional = true, features = [ - "telemetry", -] } -temporal-sdk-core-protos = { git = "https://github.com/temporalio/sdk-core", branch = "master", optional = true } +temporal-sdk = { git = "https://github.com/temporalio/sdk-core", rev = "4614dcb8f4ffd2cb244eb0a19d7485c896e3459e", optional = true } +temporal-client = { git = "https://github.com/temporalio/sdk-core", rev = "4614dcb8f4ffd2cb244eb0a19d7485c896e3459e", features = ["telemetry"], optional = true } +temporal-sdk-core-protos = { git = "https://github.com/temporalio/sdk-core", rev = "4614dcb8f4ffd2cb244eb0a19d7485c896e3459e", optional = true} tokio = { version = "1.43", features = [ "full", "rt", diff --git a/rustybits/smeeclient/Cargo.toml b/rustybits/smeeclient/Cargo.toml deleted file mode 100644 index 61cf11e039..0000000000 --- a/rustybits/smeeclient/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "smeeclient" -version = "0.1.0" -edition = "2021" - -[lib] -crate-type = ["staticlib", "rlib"] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -serde = { version = "1", features = ["derive"] } -temporal-sdk = { git = "https://github.com/temporalio/sdk-core", rev = "4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" } -temporal-client = { git = "https://github.com/temporalio/sdk-core", rev = "4614dcb8f4ffd2cb244eb0a19d7485c896e3459e", features = ["telemetry"] } -temporal-sdk-core-protos = { git = "https://github.com/temporalio/sdk-core", rev = "4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" } -tokio = { version = "1.43", features = ["full"] } -url = { version = "2" } -uuid = { version = "1.4", features = ["v4"] } - -[build-dependencies] -cbindgen = "0.20" From f76e6b916c663cbed909cb6e44f0f68f582bbf06 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 28 May 2026 09:25:39 -0700 Subject: [PATCH 203/245] This workflow does need to be removed from this branch. once finally merged it'll be irrelevant. --- .github/workflows/central-controller-cv1.yaml | 67 ------------------- 1 file changed, 67 deletions(-) delete mode 100644 .github/workflows/central-controller-cv1.yaml diff --git a/.github/workflows/central-controller-cv1.yaml b/.github/workflows/central-controller-cv1.yaml deleted file mode 100644 index 6fcdbcfbe6..0000000000 --- a/.github/workflows/central-controller-cv1.yaml +++ /dev/null @@ -1,67 +0,0 @@ -name: Central Controller CV1 Build and Push - -on: - push: - pull_request: - workflow_dispatch: - -jobs: - central_controller: - name: Central Controller CV1 Build - strategy: - matrix: - runner: [gha-runner-x64, gha-runner-arm64] - runs-on: ${{ matrix.runner }} - steps: - - name: checkout - uses: actions/checkout@v4 - - - name: Docker Auth - run: echo "${{ secrets.PORTUS_PW }}" | docker login registry.zerotier.com -u ${{ secrets.PORTUS_USER }} --password-stdin - - - name: Get branch name and sanitize - id: branch - run: | - BRANCH_NAME="${GITHUB_REF##*/}" - SANITIZED_BRANCH="${BRANCH_NAME//\//-}" - echo "branch_name=$SANITIZED_BRANCH" >> $GITHUB_OUTPUT - - - name: Get short git commit SHA - id: sha - run: | - calculatedSha=$(git rev-parse --short ${{ github.sha }}) - echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV - - - name: Build & Push Docker Image - run: | - docker build --provenance false --no-cache -t registry.zerotier.com/zerotier-central/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} -f ext/central-controller-docker/Dockerfile . --push - - multi-arch-docker: - runs-on: gha-runner-x64 - needs: central_controller - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Docker Auth - run: echo "${{ secrets.PORTUS_PW }}" | docker login registry.zerotier.com -u ${{ secrets.PORTUS_USER }} --password-stdin - - - name: Get branch name and sanitize - id: branch - run: | - BRANCH_NAME="${GITHUB_REF##*/}" - SANITIZED_BRANCH="${BRANCH_NAME//\//-}" - echo "branch_name=$SANITIZED_BRANCH" >> $GITHUB_OUTPUT - - - name: Get short git commit SHA - id: sha - run: | - calculatedSha=$(git rev-parse --short ${{ github.sha }}) - echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV - - - name: Create and push multi-arch manifest - run: | - docker manifest create registry.zerotier.com/zerotier-central/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} \ - --amend registry.zerotier.com/zerotier-central/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-X64 \ - --amend registry.zerotier.com/zerotier-central/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-ARM64 - docker manifest push registry.zerotier.com/zerotier-central/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }} From 174130c080e3e61c97788c5eca65a8471c70a734 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 2 Jun 2026 13:43:50 -0700 Subject: [PATCH 204/245] More sso error logging & removing a few logs as well --- rustybits/Cargo.lock | 193 +++++++++++++++++++++++------------ rustybits/src/zeroidc/mod.rs | 91 ++++++++++++++--- 2 files changed, 206 insertions(+), 78 deletions(-) diff --git a/rustybits/Cargo.lock b/rustybits/Cargo.lock index abe3960696..96d14ec26f 100644 --- a/rustybits/Cargo.lock +++ b/rustybits/Cargo.lock @@ -327,7 +327,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-link", + "windows-link 0.2.1", ] [[package]] @@ -890,6 +890,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + [[package]] name = "foreign-types" version = "0.3.2" @@ -1046,7 +1052,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" dependencies = [ "rustix", - "windows-link", + "windows-link 0.2.1", ] [[package]] @@ -1091,9 +1097,9 @@ dependencies = [ [[package]] name = "governor" -version = "0.8.1" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be93b4ec2e4710b04d9264c0c7350cdd62a8c20e5e4ac732552ebb8f0debe8eb" +checksum = "9efcab3c1958580ff1f25a2a41be1668f7603d849bb63af523b208a3cc1223b8" dependencies = [ "cfg-if", "dashmap", @@ -1101,7 +1107,7 @@ dependencies = [ "futures-timer", "futures-util", "getrandom 0.3.4", - "no-std-compat", + "hashbrown 0.16.1", "nonzero_ext", "parking_lot", "portable-atomic", @@ -1178,10 +1184,19 @@ name = "hashbrown" version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash 0.1.5", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ "allocator-api2", "equivalent", - "foldhash", + "foldhash 0.2.0", ] [[package]] @@ -1732,11 +1747,11 @@ checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] name = "lru" -version = "0.13.0" +version = "0.16.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "227748d55f2f0ab4735d87fd623798cb6b664512fe979705f829c9f81c934465" +checksum = "7f66e8d5d03f609abc3a39e6f08e4164ebf1447a732906d39eb9b99b7919ef39" dependencies = [ - "hashbrown 0.15.5", + "hashbrown 0.16.1", ] [[package]] @@ -1826,12 +1841,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "no-std-compat" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c" - [[package]] name = "nonzero_ext" version = "0.3.0" @@ -1928,6 +1937,25 @@ dependencies = [ "url", ] +[[package]] +name = "objc2-core-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" +dependencies = [ + "bitflags 2.11.1", +] + +[[package]] +name = "objc2-io-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15" +dependencies = [ + "libc", + "objc2-core-foundation", +] + [[package]] name = "once_cell" version = "1.21.4" @@ -2082,7 +2110,7 @@ dependencies = [ "libc", "redox_syscall 0.5.18", "smallvec", - "windows-link", + "windows-link 0.2.1", ] [[package]] @@ -2728,7 +2756,7 @@ dependencies = [ [[package]] name = "rustfsm" version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?branch=master#23f495a68f4d025e88c4a6859579587079f5460c" +source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" dependencies = [ "rustfsm_procmacro", "rustfsm_trait", @@ -2737,7 +2765,7 @@ dependencies = [ [[package]] name = "rustfsm_procmacro" version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?branch=master#23f495a68f4d025e88c4a6859579587079f5460c" +source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" dependencies = [ "derive_more", "proc-macro2", @@ -2749,7 +2777,7 @@ dependencies = [ [[package]] name = "rustfsm_trait" version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?branch=master#23f495a68f4d025e88c4a6859579587079f5460c" +source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" [[package]] name = "rustix" @@ -3281,14 +3309,15 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.33.1" +version = "0.37.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fc858248ea01b66f19d8e8a6d55f41deaf91e9d495246fd01368d99935c6c01" +checksum = "16607d5caffd1c07ce073528f9ed972d88db15dd44023fa57142963be3feb11f" dependencies = [ - "core-foundation-sys", "libc", "memchr", "ntapi", + "objc2-core-foundation", + "objc2-io-kit", "windows", ] @@ -3329,7 +3358,7 @@ dependencies = [ [[package]] name = "temporal-client" version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?branch=master#23f495a68f4d025e88c4a6859579587079f5460c" +source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" dependencies = [ "anyhow", "async-trait", @@ -3361,7 +3390,7 @@ dependencies = [ [[package]] name = "temporal-sdk" version = "0.1.0-alpha.1" -source = "git+https://github.com/temporalio/sdk-core?branch=master#23f495a68f4d025e88c4a6859579587079f5460c" +source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" dependencies = [ "anyhow", "async-trait", @@ -3383,7 +3412,7 @@ dependencies = [ [[package]] name = "temporal-sdk-core" version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?branch=master#23f495a68f4d025e88c4a6859579587079f5460c" +source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" dependencies = [ "anyhow", "async-trait", @@ -3432,7 +3461,7 @@ dependencies = [ [[package]] name = "temporal-sdk-core-api" version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?branch=master#23f495a68f4d025e88c4a6859579587079f5460c" +source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" dependencies = [ "async-trait", "derive_builder", @@ -3451,7 +3480,7 @@ dependencies = [ [[package]] name = "temporal-sdk-core-protos" version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?branch=master#23f495a68f4d025e88c4a6859579587079f5460c" +source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" dependencies = [ "anyhow", "base64 0.22.1", @@ -4158,24 +4187,37 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.57.0" +version = "0.61.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12342cb4d8e3b046f3d80effd474a7a02447231330ef77d71daa6fbc40681143" +checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" dependencies = [ - "windows-core 0.57.0", - "windows-targets 0.52.6", + "windows-collections", + "windows-core 0.61.2", + "windows-future", + "windows-link 0.1.3", + "windows-numerics", +] + +[[package]] +name = "windows-collections" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" +dependencies = [ + "windows-core 0.61.2", ] [[package]] name = "windows-core" -version = "0.57.0" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" dependencies = [ - "windows-implement 0.57.0", - "windows-interface 0.57.0", - "windows-result 0.1.2", - "windows-targets 0.52.6", + "windows-implement", + "windows-interface", + "windows-link 0.1.3", + "windows-result 0.3.4", + "windows-strings 0.4.2", ] [[package]] @@ -4184,22 +4226,22 @@ version = "0.62.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" dependencies = [ - "windows-implement 0.60.2", - "windows-interface 0.59.3", - "windows-link", + "windows-implement", + "windows-interface", + "windows-link 0.2.1", "windows-result 0.4.1", - "windows-strings", + "windows-strings 0.5.1", ] [[package]] -name = "windows-implement" -version = "0.57.0" +name = "windows-future" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" +checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" dependencies = [ - "proc-macro2", - "quote", - "syn", + "windows-core 0.61.2", + "windows-link 0.1.3", + "windows-threading", ] [[package]] @@ -4215,9 +4257,9 @@ dependencies = [ [[package]] name = "windows-interface" -version = "0.57.0" +version = "0.59.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", @@ -4225,15 +4267,10 @@ dependencies = [ ] [[package]] -name = "windows-interface" -version = "0.59.3" +name = "windows-link" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" [[package]] name = "windows-link" @@ -4241,13 +4278,23 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" +[[package]] +name = "windows-numerics" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" +dependencies = [ + "windows-core 0.61.2", + "windows-link 0.1.3", +] + [[package]] name = "windows-result" -version = "0.1.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" dependencies = [ - "windows-targets 0.52.6", + "windows-link 0.1.3", ] [[package]] @@ -4256,7 +4303,16 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" dependencies = [ - "windows-link", + "windows-link 0.2.1", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link 0.1.3", ] [[package]] @@ -4265,7 +4321,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" dependencies = [ - "windows-link", + "windows-link 0.2.1", ] [[package]] @@ -4310,7 +4366,7 @@ version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ - "windows-link", + "windows-link 0.2.1", ] [[package]] @@ -4350,7 +4406,7 @@ version = "0.53.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" dependencies = [ - "windows-link", + "windows-link 0.2.1", "windows_aarch64_gnullvm 0.53.1", "windows_aarch64_msvc 0.53.1", "windows_i686_gnu 0.53.1", @@ -4361,6 +4417,15 @@ dependencies = [ "windows_x86_64_msvc 0.53.1", ] +[[package]] +name = "windows-threading" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6" +dependencies = [ + "windows-link 0.1.3", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" diff --git a/rustybits/src/zeroidc/mod.rs b/rustybits/src/zeroidc/mod.rs index 973c9babba..8bd219d885 100644 --- a/rustybits/src/zeroidc/mod.rs +++ b/rustybits/src/zeroidc/mod.rs @@ -287,9 +287,13 @@ impl ZeroIDC { println!("Central post failed: {}", r.status()); println!("hit url: {}", r.url().as_str()); println!("Status: {}", r.status()); - if let Ok(body) = r.bytes() { - if let Ok(body) = std::str::from_utf8(&body) { - println!("Body: {}", body); + #[cfg(debug_assertions)] + { + // response body may contain tokens; debug only + if let Ok(body) = r.bytes() { + if let Ok(body) = std::str::from_utf8(&body) { + println!("Body: {}", body); + } } } @@ -470,7 +474,10 @@ impl ZeroIDC { let res = (*local.lock().unwrap()).as_opt().map(|i| { if let Some(verifier) = i.pkce_verifier.take() { let token_response = i.oidc_client.as_ref().map(|c| { - println!("auth code: {}", code); + #[cfg(debug_assertions)] + { + println!("auth code: {}", code); + } let r = c .exchange_code(AuthorizationCode::new(code.to_string())) @@ -480,10 +487,11 @@ impl ZeroIDC { // validate the token hashes match r { Ok(res) => { + println!("token exchange: received token response from IdP token endpoint"); let n = match i.nonce.clone() { Some(n) => n, None => { - println!("no nonce"); + println!("token exchange FAILED: no nonce stored on the ZeroIDC client"); i.running = false; return None; } @@ -492,16 +500,27 @@ impl ZeroIDC { let id = match res.id_token() { Some(t) => t, None => { - println!("no id token"); + println!( + "token exchange FAILED: no id_token in IdP response \ + (check that the 'openid' scope is requested and the client is OIDC, not OAuth-only)" + ); i.running = false; return None; } }; + #[cfg(debug_assertions)] + { + println!("token exchange: raw id_token = {}", id.to_string()); + } let claims = match id.claims(&c.id_token_verifier(), &n) { Ok(c) => c, - Err(_e) => { - println!("no claims"); + Err(e) => { + // Most common real-world failure: nonce mismatch, signature + // verification failure, issuer mismatch, audience/client-id + // mismatch, or expired token. + println!("token exchange FAILED: id_token claims verification error: {}", e); + println!("\tsource: {:?}", e.source()); i.running = false; return None; } @@ -509,34 +528,66 @@ impl ZeroIDC { let signing_algo = match id.signing_alg() { Ok(s) => s, - Err(_) => { - println!("no signing algorithm"); + Err(e) => { + println!("token exchange FAILED: could not determine id_token signing algorithm: {}", e); i.running = false; return None; } }; + println!("token exchange: id_token claims verified, signing_alg={:?}", signing_algo); if let Some(expected_hash) = claims.access_token_hash() { let actual_hash = match AccessTokenHash::from_token(res.access_token(), &signing_algo) { Ok(h) => h, Err(e) => { - println!("Error hashing access token: {}", e); + println!("token exchange FAILED: error hashing access token: {}", e); i.running = false; return None; } }; if actual_hash != *expected_hash { - println!("token hash error"); + println!( + "token exchange FAILED: access token hash mismatch (at_hash) — expected {:?}, got {:?}", + expected_hash, actual_hash + ); i.running = false; return None; } + } else { + println!("token exchange: no at_hash claim present, skipping access-token hash check"); } Some(res) } Err(e) => { - println!("token response error: {:?}", e.to_string()); - println!("\t {:?}", e.source()); + // This is the IdP token endpoint rejecting the code exchange itself: + // invalid_grant (expired/reused code), redirect_uri/client_secret/PKCE + // mismatch, or a network/TLS failure reaching the token endpoint. + println!("token exchange FAILED: error requesting tokens from IdP token endpoint: {}", e); + match &e { + openidconnect::RequestTokenError::ServerResponse(resp) => { + // OAuth error body from the IdP token endpoint, e.g. + // invalid_grant / invalid_client / unauthorized_client / + // invalid_request, optionally with an error_description. + println!("\tIdP OAuth error: {}", resp); + println!("\tIdP OAuth error (full): {:?}", resp); + } + openidconnect::RequestTokenError::Request(req) => { + println!("\trequest/transport error reaching IdP: {:?}", req); + } + openidconnect::RequestTokenError::Parse(parse_err, _raw) => { + println!("\tfailed to parse IdP response: {}", parse_err); + #[cfg(debug_assertions)] + { + // raw body may contain tokens on a 200 misparse; debug only + println!("\traw IdP response body: {}", String::from_utf8_lossy(_raw)); + } + } + other => { + println!("\tother token error: {:?}", other); + } + } + println!("\tsource: {:?}", e.source()); i.running = false; None } @@ -560,6 +611,7 @@ impl ZeroIDC { if split.len() == 2 { let params = [("id_token", id_token.to_string()), ("state", split[0].to_string())]; let client = reqwest::blocking::Client::new(); + println!("token exchange: POSTing id_token + state to central auth endpoint {}", i.auth_endpoint); let res = client.post(i.auth_endpoint.clone()).form(¶ms).send(); match res { @@ -642,6 +694,17 @@ impl ZeroIDC { } } else { i.running = false; + match token_response { + None => println!( + "token exchange FAILED: no OIDC client configured on the ZeroIDC instance \ + (discovery never produced a client) -> 'invalid token response'" + ), + Some(None) => println!( + "token exchange FAILED: token exchange/validation closure returned None \ + (see the specific 'token exchange FAILED' line above) -> 'invalid token response'" + ), + Some(Some(_)) => unreachable!(), + } Err(SSOExchangeError::new("invalid token response".to_string())) } } else { From eec53a586652819134d638e2c9cc046cd8b3aca6 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 2 Jun 2026 14:54:55 -0700 Subject: [PATCH 205/245] Add handling sso networks for both CV1 & CV2 simultaneously --- ext/central-controller-docker/main-new.sh | 42 +++++++++++++++++++++++ nonfree/controller/CentralDB.cpp | 28 +++++++++++---- nonfree/controller/ControllerConfig.hpp | 3 ++ service/OneService.cpp | 31 +++++++++++++++++ 4 files changed, 98 insertions(+), 6 deletions(-) diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh index 4f3935785d..73d1b495e0 100755 --- a/ext/central-controller-docker/main-new.sh +++ b/ext/central-controller-docker/main-new.sh @@ -112,6 +112,47 @@ if [ "$ZT_USE_PUBSUB" == "true" ]; then " fi +# Backwards compatibility: if the per-frontend URLs aren't set but the legacy +# ZT_SSO_REDIRECT_URL and ZT_ASSIGNED_CENTRAL_VERSION are both populated, map +# the legacy URL into the new format keyed by the assigned Central version. +if [ -z "$ZT_SSO_REDIRECT_URL_CV1" ] && [ -z "$ZT_SSO_REDIRECT_URL_CV2" ]; then + if [ -n "$ZT_SSO_REDIRECT_URL" ] && [ -n "$ZT_ASSIGNED_CENTRAL_VERSION" ]; then + case "$ZT_ASSIGNED_CENTRAL_VERSION" in + cv1) + ZT_SSO_REDIRECT_URL_CV1="$ZT_SSO_REDIRECT_URL" + ;; + cv2) + ZT_SSO_REDIRECT_URL_CV2="$ZT_SSO_REDIRECT_URL" + ;; + all) + echo '*** FAILED: controllers assigned to "all" must define ZT_SSO_REDIRECT_URL_CV1 and ZT_SSO_REDIRECT_URL_CV2; the legacy ZT_SSO_REDIRECT_URL cannot serve both Central versions' + exit 1 + ;; + esac + fi +fi + +# Per-frontend Central SSO redirect URLs. SSO-enabled networks are routed to the +# SSO endpoint of the Central version ("cv1" or "cv2") they belong to. +SSO_REDIRECT_URLS_CONF="" +if [ -n "$ZT_SSO_REDIRECT_URL_CV1" ] || [ -n "$ZT_SSO_REDIRECT_URL_CV2" ]; then + SSO_REDIRECT_URLS="" + if [ -n "$ZT_SSO_REDIRECT_URL_CV1" ]; then + SSO_REDIRECT_URLS="\"cv1\": \"${ZT_SSO_REDIRECT_URL_CV1}\"" + fi + if [ -n "$ZT_SSO_REDIRECT_URL_CV2" ]; then + if [ -n "$SSO_REDIRECT_URLS" ]; then + SSO_REDIRECT_URLS="${SSO_REDIRECT_URLS}, + " + fi + SSO_REDIRECT_URLS="${SSO_REDIRECT_URLS}\"cv2\": \"${ZT_SSO_REDIRECT_URL_CV2}\"" + fi + SSO_REDIRECT_URLS_CONF=", \"ssoRedirectURLs\": { + ${SSO_REDIRECT_URLS} + } +" +fi + echo "{ \"settings\": { \"controllerDbPath\": \"postgres:host=${ZT_DB_HOST} port=${ZT_DB_PORT} dbname=${ZT_DB_NAME} user=${ZT_DB_USER} password=${ZT_DB_PASSWORD} application_name=${APP_NAME} sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}\", @@ -135,6 +176,7 @@ echo "{ \"statusMode\": \"${ZT_STATUS_MODE:-pgsql}\", \"assignedCentralVersion\": \"${ZT_ASSIGNED_CENTRAL_VERSION:-all}\", \"ssoEnabled\": ${ZT_SSO_ENABLED:-false} + ${SSO_REDIRECT_URLS_CONF} ${REDIS} ${BIGTABLE_CONF} ${PUBSUB_CONF} diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 00d0760316..1d0bff385e 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -461,9 +461,11 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri pqxx::params { memberId, networkId }) .one_row(); if (count[0].as() == 1) { - // Query the network's frontend while the transaction is guaranteed open + // Query the network's frontend while the transaction is guaranteed open. + // It selects which Central's SSO redirect URL the member is sent to and + // tags the nonce publish for PubSub routing. std::string frontend; - if (_ssoNonceWriter) { + { pqxx::result fr = w.exec("SELECT frontend FROM networks_ctl WHERE id = $1", pqxx::params { networkId }); if (fr.size() == 1) { @@ -559,8 +561,22 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri info.version = sso_version; + // Every SSO-enabled network must resolve to the redirect URL configured + // for the Central frontend ("cv1" or "cv2") it belongs to. + std::string ssoRedirectURL; + auto fu = _cc->ssoRedirectURLs.find(frontend); + if (fu != _cc->ssoRedirectURLs.end()) { + ssoRedirectURL = fu->second; + } + + if (ssoRedirectURL.empty()) { + span->SetStatus(opentelemetry::trace::StatusCode::kError, + "no SSO redirect URL configured for frontend"); + fprintf(stderr, "ERROR: no SSO redirect URL configured for frontend '%s' of network %s\n", + frontend.c_str(), networkId.c_str()); + } // no catch all else because we don't actually care if no records exist here. just continue as normal. - if ((! client_id.empty()) && (! authorization_endpoint.empty())) { + else if ((! client_id.empty()) && (! authorization_endpoint.empty())) { uint8_t state[48]; HMACSHA384(_ssoPsk, nonceBytes, sizeof(nonceBytes), state); char state_hex[256]; @@ -572,8 +588,8 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri url, sizeof(authenticationURL), "%s?response_type=id_token&response_mode=form_post&scope=openid+email+profile&redirect_uri=" "%s&nonce=%s&state=%s&client_id=%s", - authorization_endpoint.c_str(), url_encode(redirectURL).c_str(), nonce.c_str(), state_hex, - client_id.c_str()); + authorization_endpoint.c_str(), url_encode(ssoRedirectURL).c_str(), nonce.c_str(), + state_hex, client_id.c_str()); info.authenticationURL = std::string(url); } else if (info.version == 1) { @@ -582,7 +598,7 @@ AuthInfo CentralDB::getSSOAuthInfo(const nlohmann::json& member, const std::stri info.ssoProvider = provider; info.ssoNonce = nonce; info.ssoState = std::string(state_hex) + "_" + networkId; - info.centralAuthURL = redirectURL; + info.centralAuthURL = ssoRedirectURL; #ifdef ZT_DEBUG fprintf( stderr, diff --git a/nonfree/controller/ControllerConfig.hpp b/nonfree/controller/ControllerConfig.hpp index 68799c5348..773bf314ef 100644 --- a/nonfree/controller/ControllerConfig.hpp +++ b/nonfree/controller/ControllerConfig.hpp @@ -3,6 +3,7 @@ #include "Redis.hpp" +#include #include namespace ZeroTier { @@ -28,6 +29,8 @@ struct ControllerConfig { std::string listenMode; std::string statusMode; std::string assignedCentralVersion; + // Central SSO redirect URLs keyed by frontend ("cv1" or "cv2") + std::map ssoRedirectURLs; RedisConfig* redisConfig; PubSubConfig* pubSubConfig; BigTableConfig* bigTableConfig; diff --git a/service/OneService.cpp b/service/OneService.cpp index 6952da4eb5..e7ca4eeeb5 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -1836,6 +1836,37 @@ class OneServiceImpl : public OneService { _controllerConfig.ssoEnabled = OSUtils::jsonBool(cc["ssoEnabled"], false); + // Central SSO redirect URLs keyed by frontend. Networks are routed to the + // SSO endpoint of the Central version ("cv1" or "cv2") they belong to. + if (cc["ssoRedirectURLs"].is_object()) { + json& urls = cc["ssoRedirectURLs"]; + for (json::iterator i(urls.begin()); i != urls.end(); ++i) { + if ((i.key() != "cv1") && (i.key() != "cv2")) { + fprintf(stderr, "ERROR: ssoRedirectURLs keys must be one of 'cv1' or 'cv2'" ZT_EOL_S); + exit(1); + } + _controllerConfig.ssoRedirectURLs[i.key()] = OSUtils::jsonString(i.value(), ""); + } + } + if (_controllerConfig.ssoEnabled) { + const std::string& av = _controllerConfig.assignedCentralVersion; + const char* required[2] = { "cv1", "cv2" }; + for (int i = 0; i < 2; ++i) { + if ((av != "all") && (av != required[i])) { + continue; + } + auto it = _controllerConfig.ssoRedirectURLs.find(required[i]); + if ((it == _controllerConfig.ssoRedirectURLs.end()) || it->second.empty()) { + fprintf( + stderr, + "ERROR: controller.ssoRedirectURLs must contain a non-empty '%s' entry when ssoEnabled " + "is true" ZT_EOL_S, + required[i]); + exit(1); + } + } + } + // redis settings if (cc["redis"].is_object() && _rc == NULL) { json& redis = cc["redis"]; From af7c882315d6e8c4ca35a31c2c02f9a6fa92663e Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 10 Jun 2026 13:28:40 -0700 Subject: [PATCH 206/245] perf(controller): drop per-row BigTable reads in status writer writePending() did a synchronous ReadRow per queued node to avoid rewriting unchanged os/arch/version. With thousands of check-ins per cycle that's thousands of sequential round-trips every 10s, and the read was nearly pointless since last_seen and the IP cell are written every cycle anyway. Replace it with an in-process cache of the last-written node_info per row (keyed by a 64-bit hash of the row key). node_info is emitted only when changed, new, or past its refresh window; check_in is still written every cycle. Failed rows are dropped from the cache so they're rewritten next cycle, and stale entries are evicted (24h TTL). Net result: one BulkApply per cycle, no read RPCs. --- nonfree/controller/BigTableStatusWriter.cpp | 85 +++++++++++++++------ nonfree/controller/BigTableStatusWriter.hpp | 15 ++++ nonfree/controller/CentralDB.cpp | 73 +++++++++++++----- 3 files changed, 129 insertions(+), 44 deletions(-) diff --git a/nonfree/controller/BigTableStatusWriter.cpp b/nonfree/controller/BigTableStatusWriter.cpp index 0403d14d7b..7ac5c33abc 100644 --- a/nonfree/controller/BigTableStatusWriter.cpp +++ b/nonfree/controller/BigTableStatusWriter.cpp @@ -1,8 +1,10 @@ #include "BigTableStatusWriter.hpp" +#include "../../osdep/OSUtils.hpp" #include "ControllerConfig.hpp" #include "PubSubWriter.hpp" +#include #include #include #include @@ -22,6 +24,15 @@ const std::string ipv4Column = "ipv4"; const std::string ipv6Column = "ipv6"; const std::string lastSeenColumn = "last_seen"; +// node_info changes rarely, so we skip rewriting an unchanged row. As a safety +// net we still rewrite it at most this often, so the cell can never age out from +// under us if the GC policy is ever changed to union (OR) semantics. +static const int64_t kNodeInfoRefreshMs = 6LL * 24 * 60 * 60 * 1000; // 6 days +// Drop cache entries for rows we haven't seen within this window (node assumed +// offline), so the cache tracks the active set rather than every node ever seen. +static const int64_t kCacheEntryTtlMs = 24LL * 60 * 60 * 1000; // 24 hours +static const int64_t kEvictionIntervalMs = 60LL * 60 * 1000; // sweep at most hourly + BigTableStatusWriter::BigTableStatusWriter( const std::string& project_id, const std::string& instance_id, @@ -30,6 +41,7 @@ BigTableStatusWriter::BigTableStatusWriter( , _instance_id(instance_id) , _table_id(table_id) , _table(nullptr) + , _lastEvictionMs(0) { _table = new cbt::Table(cbt::MakeDataConnection(), cbt::TableResource(_project_id, _instance_id, _table_id)); fprintf( @@ -89,39 +101,40 @@ void BigTableStatusWriter::writePending() return; } + const int64_t nowMs = OSUtils::now(); + const std::hash hasher; + cbt::BulkMutation bulk; + // Row-key hash for each mutation, aligned with bulk's indices, so a failed + // mutation can invalidate its cache entry (FailedMutation::original_index()). + std::vector bulkRowHashes; + bulkRowHashes.reserve(toWrite.size()); + for (const auto& entry : toWrite) { std::string row_key = entry.network_id + "#" + entry.node_id; - - // read the latest values from BigTable for this row key - std::map latest_values; - try { - auto row = _table->ReadRow(row_key, cbt::Filter::Latest(1)); - if (row->first) { - for (const auto& cell : row->second.cells()) { - if (cell.family_name() == nodeInfoColumnFamily) { - latest_values[cell.column_qualifier()] = cell.value(); - } - } - } - } - catch (const std::exception& e) { - fprintf(stderr, "Exception reading from BigTable: %s\n", e.what()); - } + const uint64_t keyHash = hasher(row_key); cbt::SingleRowMutation m(row_key); - // only update if value has changed - if (latest_values[osColumn] != entry.os) { + // node_info (os/arch/version) changes rarely. Write it only when our + // last-written value for this row differs, or hasn't been refreshed in a + // while -- no read RPC, the controller is the sole writer of node_info. + const uint64_t valueHash = hasher(entry.os + "|" + entry.arch + "|" + entry.version); + auto it = _lastNodeInfo.find(keyHash); + const bool writeNodeInfo = (it == _lastNodeInfo.end()) || (it->second.valueHash != valueHash) + || ((nowMs - it->second.lastWrittenMs) > kNodeInfoRefreshMs); + + if (writeNodeInfo) { m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, osColumn, entry.os)); - } - if (latest_values[archColumn] != entry.arch) { m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, archColumn, entry.arch)); - } - if (latest_values[versionColumn] != entry.version) { m.emplace_back(cbt::SetCell(nodeInfoColumnFamily, versionColumn, entry.version)); + _lastNodeInfo[keyHash] = NodeInfoState { valueHash, nowMs, nowMs }; + } + else { + it->second.lastSeenMs = nowMs; } + // check_in (ip + last_seen) changes every cycle, so it's always written. char buf[64] = { 0 }; std::string addressStr = entry.address.toString(buf); if (entry.address.ss_family == AF_INET) { @@ -132,7 +145,9 @@ void BigTableStatusWriter::writePending() } int64_t ts = entry.last_seen; m.emplace_back(cbt::SetCell(checkInColumnFamily, lastSeenColumn, std::move(ts))); + bulk.emplace_back(m); + bulkRowHashes.push_back(keyHash); } fprintf(stderr, "Applying %zu mutations to BigTable\n", bulk.size()); @@ -141,16 +156,40 @@ void BigTableStatusWriter::writePending() std::vector failures = _table->BulkApply(std::move(bulk)); fprintf(stderr, "BigTable write completed with %zu failures\n", failures.size()); for (auto const& r : failures) { - // Handle error (log it, retry, etc.) std::cerr << "Error writing to BigTable: " << r.status() << "\n"; + // Drop the cache entry for any failed row so its node_info is rewritten + // next cycle rather than being assumed durably written. + const int idx = r.original_index(); + if (idx >= 0 && static_cast(idx) < bulkRowHashes.size()) { + _lastNodeInfo.erase(bulkRowHashes[idx]); + } } } catch (const std::exception& e) { fprintf(stderr, "Exception writing to BigTable: %s\n", e.what()); span->SetAttribute("error", e.what()); span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + // The batch's outcome is unknown, so clear the rows it covered to force a + // node_info rewrite next cycle rather than trusting an optimistic update. + for (uint64_t keyHash : bulkRowHashes) { + _lastNodeInfo.erase(keyHash); + } return; } + + // Periodically evict rows we haven't seen lately so the cache tracks the + // currently-active node set rather than growing for the process's lifetime. + if ((nowMs - _lastEvictionMs) > kEvictionIntervalMs) { + for (auto it = _lastNodeInfo.begin(); it != _lastNodeInfo.end();) { + if ((nowMs - it->second.lastSeenMs) > kCacheEntryTtlMs) { + it = _lastNodeInfo.erase(it); + } + else { + ++it; + } + } + _lastEvictionMs = nowMs; + } } } // namespace ZeroTier \ No newline at end of file diff --git a/nonfree/controller/BigTableStatusWriter.hpp b/nonfree/controller/BigTableStatusWriter.hpp index ce687121f9..b245a74dae 100644 --- a/nonfree/controller/BigTableStatusWriter.hpp +++ b/nonfree/controller/BigTableStatusWriter.hpp @@ -3,10 +3,12 @@ #include "StatusWriter.hpp" +#include #include #include #include #include +#include namespace ZeroTier { @@ -37,6 +39,19 @@ class BigTableStatusWriter : public StatusWriter { mutable std::mutex _lock; std::vector _pending; google::cloud::bigtable::Table* _table; + + // In-process record of the node_info (os/arch/version) we last wrote for each + // row, so we can skip rewriting it when it hasn't changed -- no read RPC needed. + // Keyed by a 64-bit hash of the row key to keep the map compact. Only touched + // from writePending(), which is serialized on a single thread, so it needs no + // lock of its own. + struct NodeInfoState { + uint64_t valueHash; // hash of the os|arch|version last written + int64_t lastWrittenMs; // when node_info was last written (periodic refresh) + int64_t lastSeenMs; // when this row last appeared in a batch (eviction) + }; + std::unordered_map _lastNodeInfo; + int64_t _lastEvictionMs; }; } // namespace ZeroTier diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index 1d0bff385e..ba525a5c98 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include // #define REDIS_TRACE 1 @@ -1567,9 +1568,51 @@ void CentralDB::onlineNotificationThread() lastOnline.swap(_lastOnline); } + // Phase 1: a single batched query to find which (network, member) pairs the + // controller actually has in the DB. The IDs come from %.16llx / %.10llx, so + // they're pure hex -- safe to build the array literals directly with no escaping. + // The two arrays are position-aligned and zipped back into rows by unnest(). + std::set > existing; + if (! lastOnline.empty()) { + std::string nwArray = "{"; + std::string memArray = "{"; + bool first = true; + for (auto i = lastOnline.begin(); i != lastOnline.end(); ++i) { + char nwidTmp[64]; + char memTmp[64]; + OSUtils::ztsnprintf(nwidTmp, sizeof(nwidTmp), "%.16llx", i->first.first); + OSUtils::ztsnprintf(memTmp, sizeof(memTmp), "%.10llx", i->first.second); + if (! first) { + nwArray += ','; + memArray += ','; + } + first = false; + nwArray += nwidTmp; + memArray += memTmp; + } + nwArray += "}"; + memArray += "}"; + + c = _pool->borrow(); + pqxx::work w(*c->c); + pqxx::result r = w.exec( + "SELECT nm.network_id, nm.device_id " + "FROM network_memberships_ctl nm " + "JOIN unnest($1::text[], $2::text[]) AS v(network_id, device_id) " + " ON nm.network_id = v.network_id AND nm.device_id = v.device_id", + pqxx::params { nwArray, memArray }); + w.commit(); // Postgres txn closes here, before any BigTable I/O + _pool->unborrow(c); + c.reset(); + + for (const auto& row : r) { + existing.emplace(row[0].as(), row[1].as()); + } + } + + // Phase 2: build the status updates with NO Postgres transaction open, so the + // connection isn't pinned (idle in transaction) during the BigTable writes. uint64_t writtenCount = 0; - c = _pool->borrow(); - pqxx::work w(*c->c); for (auto i = lastOnline.begin(); i != lastOnline.end(); ++i) { uint64_t nwid_i = i->first.first; char nwidTmp[64]; @@ -1577,31 +1620,20 @@ void CentralDB::onlineNotificationThread() char ipTmp[64]; OSUtils::ztsnprintf(nwidTmp, sizeof(nwidTmp), "%.16llx", nwid_i); OSUtils::ztsnprintf(memTmp, sizeof(memTmp), "%.10llx", i->first.second); - nlohmann::json network, member; - - if (! get(nwid_i, network, i->first.second, member)) { - continue; // skip non existent networks/members - } std::string networkId(nwidTmp); std::string memberId(memTmp); - try { - // check if the member exists first. - // - // exec_params1 will throw pqxx::unexpected_rows if not exactly one row is returned. If that's - // the case, skip this record and move on. - pqxx::row r = - w.exec("SELECT device_id, network_id FROM network_memberships_ctl WHERE network_id = " - "$1 AND device_id " - "= $2", - pqxx::params { networkId, memberId }) - .one_row(); - } - catch (pqxx::unexpected_rows& e) { + // skip devices the controller doesn't have in the DB + if (existing.find(std::make_pair(networkId, memberId)) == existing.end()) { continue; } + nlohmann::json network, member; + if (! get(nwid_i, network, i->first.second, member)) { + continue; // skip non existent networks/members + } + int64_t ts = i->second.lastSeen; std::string ipAddr = i->second.physicalAddress.toIpString(ipTmp); std::string timestamp = std::to_string(ts); @@ -1637,7 +1669,6 @@ void CentralDB::onlineNotificationThread() fprintf(stderr, "onlineNotificationThread: %llu entries in lastOnline, %llu passed to status writer\n", (unsigned long long)lastOnline.size(), (unsigned long long)writtenCount); _statusWriter->writePending(); - w.commit(); } catch (std::exception& e) { fprintf(stderr, "%s: error in onlinenotification thread: %s\n", _myAddressStr.c_str(), e.what()); From a001eba98fd476a3daed00226bd0a0a1b4f07f8b Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 10 Jun 2026 14:05:46 -0700 Subject: [PATCH 207/245] better closed connection handling to postgres --- nonfree/controller/ConnectionPool.hpp | 29 ++++++++++++++++++++++++++- nonfree/controller/PostgreSQL.hpp | 8 ++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/nonfree/controller/ConnectionPool.hpp b/nonfree/controller/ConnectionPool.hpp index 2588ae3a96..acabd3cb77 100644 --- a/nonfree/controller/ConnectionPool.hpp +++ b/nonfree/controller/ConnectionPool.hpp @@ -30,6 +30,16 @@ struct ConnectionUnavailable : std::exception { class Connection { public: virtual ~Connection() {}; + + /** + * @return false if this connection is known to be dead/unusable, so the pool + * can discard and replace it rather than handing it out again. Defaults to + * true for connection types that don't implement a health check. + */ + virtual bool alive() const + { + return true; + } }; class ConnectionFactory { @@ -85,6 +95,20 @@ template class ConnectionPool { std::unique_lock l(m_poolMutex); + // Discard any dead connections sitting idle in the pool so we never hand + // one out. This forces the size checks below to replenish with fresh + // connections, which is what lets the pool recover after the DB server + // drops every connection (e.g. an AlloyDB maintenance restart). + for (auto it = m_pool.begin(); it != m_pool.end();) { + if (! (*it)->alive()) { + it = m_pool.erase(it); + Metrics::pool_avail--; + } + else { + ++it; + } + } + while ((m_pool.size() + m_borrowed.size()) < m_minPoolSize) { std::shared_ptr conn = m_factory->create(); m_pool.push_back(conn); @@ -160,7 +184,10 @@ template class ConnectionPool { std::unique_lock lock(m_poolMutex); m_borrowed.erase(conn); Metrics::pool_in_use--; - if ((m_pool.size() + m_borrowed.size()) < m_maxPoolSize) { + // Only return live connections to the pool. A dead one (e.g. the caller + // hit an error because the DB dropped it) is let go here so its slot is + // replaced with a fresh connection on the next borrow(). + if (conn->alive() && (m_pool.size() + m_borrowed.size()) < m_maxPoolSize) { Metrics::pool_avail++; m_pool.push_back(conn); } diff --git a/nonfree/controller/PostgreSQL.hpp b/nonfree/controller/PostgreSQL.hpp index 5779153cce..11fb1cff08 100644 --- a/nonfree/controller/PostgreSQL.hpp +++ b/nonfree/controller/PostgreSQL.hpp @@ -28,6 +28,14 @@ class PostgresConnection : public Connection { { } + // A pqxx::connection whose backend has gone away (server restart, AlloyDB + // maintenance, network drop) reports is_open() == false and cannot be reused + // -- pqxx 7 has no reconnect. Returning false here makes the pool drop it. + virtual bool alive() const override + { + return c && c->is_open(); + } + std::shared_ptr c; int a; }; From a3a45a75a7d61148bc2227003db4de312f81b2ea Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 10 Jun 2026 14:29:07 -0700 Subject: [PATCH 208/245] Better data handling if a db write fails --- nonfree/controller/CentralDB.cpp | 49 ++++++++++++++++++++++++++++++++ nonfree/controller/CentralDB.hpp | 13 ++++++++- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index ba525a5c98..af04439313 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1113,6 +1113,40 @@ void CentralDB::heartbeat() fprintf(stderr, "Exited heartbeat thread\n"); } +void CentralDB::_requeueFailedCommit(_queueItem& qitem) +{ + // The PubSub message that produced this change was already acked when it was + // enqueued, so a failed DB write would otherwise be lost. Re-queue it (with + // capped backoff) so transient failures -- e.g. an AlloyDB maintenance restart + // -- are retried rather than dropped. A genuinely poison item is dropped after + // a bounded number of attempts so it can't spin a commit thread forever. + if (_run != 1) { + // shutting down -- don't requeue + return; + } + if (qitem.retryCount >= ZT_CENTRAL_CONTROLLER_MAX_COMMIT_RETRIES) { + fprintf(stderr, "%s ERROR: dropping %s change after %d failed commit attempts\n", _myAddressStr.c_str(), + OSUtils::jsonString(qitem.jsonData["objtype"], "?").c_str(), qitem.retryCount); + return; + } + ++qitem.retryCount; + + // Capped linear backoff, slept in small chunks so shutdown stays responsive. + int64_t backoffMs = (int64_t)qitem.retryCount * 500LL; + if (backoffMs > 10000LL) { + backoffMs = 10000LL; + } + for (int64_t slept = 0; slept < backoffMs && _run == 1;) { + int64_t chunk = (backoffMs - slept) < 250LL ? (backoffMs - slept) : 250LL; + std::this_thread::sleep_for(std::chrono::milliseconds(chunk)); + slept += chunk; + } + if (_run != 1) { + return; + } + _commitQueue.post(qitem); +} + void CentralDB::commitThread() { fprintf(stderr, "%s: commitThread start\n", _myAddressStr.c_str()); @@ -1138,17 +1172,21 @@ void CentralDB::commitThread() continue; } + bool commitFailed = false; + std::shared_ptr c; try { c = _pool->borrow(); } catch (std::exception& e) { fprintf(stderr, "ERROR: %s\n", e.what()); + _requeueFailedCommit(qitem); continue; } if (! c) { fprintf(stderr, "Error getting database connection\n"); + _requeueFailedCommit(qitem); continue; } @@ -1331,6 +1369,7 @@ void CentralDB::commitThread() fprintf(stderr, "%s ERROR: Error updating member %s-%s: %s\n", _myAddressStr.c_str(), networkId.c_str(), memberId.c_str(), e.what()); mspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); + commitFailed = true; } } else if (objtype == "network") { @@ -1419,6 +1458,7 @@ void CentralDB::commitThread() catch (std::exception& e) { nspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); fprintf(stderr, "%s ERROR: Error updating network: %s\n", _myAddressStr.c_str(), e.what()); + commitFailed = true; } if (_listenerMode == LISTENER_MODE_REDIS && _redisMemberStatus) { try { @@ -1460,6 +1500,7 @@ void CentralDB::commitThread() catch (std::exception& e) { dspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); fprintf(stderr, "%s ERROR: Error deleting network: %s\n", _myAddressStr.c_str(), e.what()); + commitFailed = true; } if (_listenerMode == LISTENER_MODE_REDIS && _redisMemberStatus) { try { @@ -1512,6 +1553,7 @@ void CentralDB::commitThread() catch (std::exception& e) { mspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); fprintf(stderr, "%s ERROR: Error deleting member: %s\n", _myAddressStr.c_str(), e.what()); + commitFailed = true; } if (_listenerMode == LISTENER_MODE_REDIS && _redisMemberStatus) { try { @@ -1541,9 +1583,16 @@ void CentralDB::commitThread() catch (std::exception& e) { span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); fprintf(stderr, "%s ERROR: Error getting objtype: %s\n", _myAddressStr.c_str(), e.what()); + commitFailed = true; } _pool->unborrow(c); c.reset(); + + // Re-queue on a failed DB write so the (already-acked) change isn't lost. + // Done after the connection is returned so we never sleep holding one. + if (commitFailed) { + _requeueFailedCommit(qitem); + } } } diff --git a/nonfree/controller/CentralDB.hpp b/nonfree/controller/CentralDB.hpp index 51b8fadae9..a235b30a6a 100644 --- a/nonfree/controller/CentralDB.hpp +++ b/nonfree/controller/CentralDB.hpp @@ -5,6 +5,12 @@ #define ZT_CENTRAL_CONTROLLER_COMMIT_THREADS 4 +// Max times a change is re-queued after a failed DB write before it is dropped. +// Stopgap durability: the PubSub message was already acked at enqueue time, so a +// dropped commit would otherwise be lost. Re-queuing rides out transient DB +// outages (e.g. an AlloyDB maintenance restart) at the cost of in-memory buffering. +#define ZT_CENTRAL_CONTROLLER_MAX_COMMIT_RETRIES 100 + #include "../../node/Metrics.hpp" #include "ConnectionPool.hpp" #include "DB.hpp" @@ -98,7 +104,7 @@ class CentralDB : public DB { std::string _connString; struct _queueItem { - _queueItem() : jsonData(), notifyListeners(false), traceContext() + _queueItem() : jsonData(), notifyListeners(false), traceContext(), retryCount(0) { } @@ -109,9 +115,14 @@ class CentralDB : public DB { nlohmann::json jsonData; bool notifyListeners; std::map traceContext; + int retryCount; }; BlockingQueue<_queueItem> _commitQueue; + // Re-queue a change whose DB write failed, with capped backoff, until it + // succeeds or ZT_CENTRAL_CONTROLLER_MAX_COMMIT_RETRIES attempts is reached. + void _requeueFailedCommit(_queueItem& qitem); + std::thread _heartbeatThread; std::shared_ptr _membersDbWatcher; std::shared_ptr _networksDbWatcher; From fede9b9afbd8efb56be4158591d9a5928e9b044f Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 10 Jun 2026 15:44:05 -0700 Subject: [PATCH 209/245] better logging of commit thread ticks shows whats happening on each --- nonfree/controller/CentralDB.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index af04439313..f81d96d40b 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1166,12 +1166,25 @@ void CentralDB::commitThread() auto span = tracer->StartSpan("CentralDB::commitThread"); auto scope = tracer->WithActiveSpan(span); - fprintf(stderr, "commitThread tick\n"); if (! qitem.jsonData.is_object()) { - fprintf(stderr, "not an object\n"); + fprintf(stderr, "commitThread tick: skipping non-object queue item\n"); continue; } + // Describe the operation this tick is performing. nwid/id cover every + // objtype: member/_delete_member set both; network/_delete_network use id + // as the network id. + const std::string tickObjtype = OSUtils::jsonString(qitem.jsonData["objtype"], "?"); + const std::string tickNwid = OSUtils::jsonString(qitem.jsonData["nwid"], ""); + const std::string tickId = OSUtils::jsonString(qitem.jsonData["id"], ""); + span->SetAttribute("objtype", tickObjtype); + span->SetAttribute("nwid", tickNwid); + span->SetAttribute("id", tickId); + span->SetAttribute("retry", qitem.retryCount); + fprintf(stderr, "%s commitThread tick: objtype=%s nwid=%s id=%s retry=%d notify=%d\n", + _myAddressStr.c_str(), tickObjtype.c_str(), tickNwid.empty() ? "-" : tickNwid.c_str(), + tickId.empty() ? "-" : tickId.c_str(), qitem.retryCount, qitem.notifyListeners ? 1 : 0); + bool commitFailed = false; std::shared_ptr c; From 85eec45372680185c276a67b66b7600b60da3419 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 10 Jun 2026 15:46:12 -0700 Subject: [PATCH 210/245] remove db check from onlineNotificationThread --- nonfree/controller/CentralDB.cpp | 58 +++----------------------------- 1 file changed, 5 insertions(+), 53 deletions(-) diff --git a/nonfree/controller/CentralDB.cpp b/nonfree/controller/CentralDB.cpp index f81d96d40b..e634e7aaca 100644 --- a/nonfree/controller/CentralDB.cpp +++ b/nonfree/controller/CentralDB.cpp @@ -1622,7 +1622,6 @@ void CentralDB::onlineNotificationThread() auto span = tracer->StartSpan("CentralDB::onlineNotificationThread"); auto scope = tracer->WithActiveSpan(span); - std::shared_ptr c; try { std::unordered_map, NodeOnlineRecord, _PairHasher> lastOnline; { @@ -1630,50 +1629,11 @@ void CentralDB::onlineNotificationThread() lastOnline.swap(_lastOnline); } - // Phase 1: a single batched query to find which (network, member) pairs the - // controller actually has in the DB. The IDs come from %.16llx / %.10llx, so - // they're pure hex -- safe to build the array literals directly with no escaping. - // The two arrays are position-aligned and zipped back into rows by unnest(). - std::set > existing; - if (! lastOnline.empty()) { - std::string nwArray = "{"; - std::string memArray = "{"; - bool first = true; - for (auto i = lastOnline.begin(); i != lastOnline.end(); ++i) { - char nwidTmp[64]; - char memTmp[64]; - OSUtils::ztsnprintf(nwidTmp, sizeof(nwidTmp), "%.16llx", i->first.first); - OSUtils::ztsnprintf(memTmp, sizeof(memTmp), "%.10llx", i->first.second); - if (! first) { - nwArray += ','; - memArray += ','; - } - first = false; - nwArray += nwidTmp; - memArray += memTmp; - } - nwArray += "}"; - memArray += "}"; - - c = _pool->borrow(); - pqxx::work w(*c->c); - pqxx::result r = w.exec( - "SELECT nm.network_id, nm.device_id " - "FROM network_memberships_ctl nm " - "JOIN unnest($1::text[], $2::text[]) AS v(network_id, device_id) " - " ON nm.network_id = v.network_id AND nm.device_id = v.device_id", - pqxx::params { nwArray, memArray }); - w.commit(); // Postgres txn closes here, before any BigTable I/O - _pool->unborrow(c); - c.reset(); - - for (const auto& row : r) { - existing.emplace(row[0].as(), row[1].as()); - } - } - - // Phase 2: build the status updates with NO Postgres transaction open, so the - // connection isn't pinned (idle in transaction) during the BigTable writes. + // Build status updates straight from the controller's in-memory view. get() + // below is an authoritative membership check -- it returns false for any + // network/member this controller doesn't hold -- so there's no need to query + // Postgres to confirm existence. This also keeps status flowing to the status + // writer even while the database is unavailable. uint64_t writtenCount = 0; for (auto i = lastOnline.begin(); i != lastOnline.end(); ++i) { uint64_t nwid_i = i->first.first; @@ -1686,11 +1646,6 @@ void CentralDB::onlineNotificationThread() std::string networkId(nwidTmp); std::string memberId(memTmp); - // skip devices the controller doesn't have in the DB - if (existing.find(std::make_pair(networkId, memberId)) == existing.end()) { - continue; - } - nlohmann::json network, member; if (! get(nwid_i, network, i->first.second, member)) { continue; // skip non existent networks/members @@ -1735,9 +1690,6 @@ void CentralDB::onlineNotificationThread() catch (std::exception& e) { fprintf(stderr, "%s: error in onlinenotification thread: %s\n", _myAddressStr.c_str(), e.what()); } - if (c) { - _pool->unborrow(c); - } } std::this_thread::sleep_for(std::chrono::seconds(10)); From 407bfdfd0bfa5ac50c176934fb609f44d5e0e55f Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 10 Jun 2026 16:45:29 -0700 Subject: [PATCH 211/245] fix pubsub flood on ctl startup --- nonfree/controller/DB.hpp | 47 ++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/nonfree/controller/DB.hpp b/nonfree/controller/DB.hpp index 0eb4b6f2b8..e174ff724c 100644 --- a/nonfree/controller/DB.hpp +++ b/nonfree/controller/DB.hpp @@ -142,24 +142,39 @@ class DB { protected: static inline bool _compareRecords(const nlohmann::json& a, const nlohmann::json& b) { - if (a.is_object() == b.is_object()) { - if (a.is_object()) { - if (a.size() != b.size()) - return false; - auto amap = a.get(); - auto bmap = b.get(); - for (auto ai = amap.begin(); ai != amap.end(); ++ai) { - if (ai->first != "revision") { // ignore revision, compare only non-revision-counter fields - auto bi = bmap.find(ai->first); - if ((bi == bmap.end()) || (bi->second != ai->second)) - return false; - } - } - return true; - } + if (a.is_object() != b.is_object()) + return false; + if (! a.is_object()) return (a == b); + + // Ignore fields that are metadata about the change rather than record state: + // "revision" is a monotonic counter, and "change_source" tags which frontend/ + // controller originated the write. Neither should make an otherwise-identical + // record look modified -- and "change_source" is frequently present on only one + // side (a record freshly loaded from the DB carries none), so it can't be handled + // by a plain size comparison. + auto ignored = [](const std::string& k) { return (k == "revision") || (k == "change_source"); }; + + auto amap = a.get(); + auto bmap = b.get(); + + size_t aFields = 0; + for (auto ai = amap.begin(); ai != amap.end(); ++ai) { + if (ignored(ai->first)) + continue; + ++aFields; + auto bi = bmap.find(ai->first); + if ((bi == bmap.end()) || (bi->second != ai->second)) + return false; + } + + // Ensure b has no extra (non-ignored) fields that a lacks. + size_t bFields = 0; + for (auto bi = bmap.begin(); bi != bmap.end(); ++bi) { + if (! ignored(bi->first)) + ++bFields; } - return false; + return aFields == bFields; } struct _Network { From a4904c97b015e09e0b916a190c42e4ccc67afdd0 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 12 Jun 2026 16:23:04 -0700 Subject: [PATCH 212/245] Repo cleanup. * Remove now dead separate CV1/CV2 implementations. Consolidated into CentralDB. * Remove smeeclient. No longer needed. --- CMakeLists.txt | 6 +- make-linux.mk | 1 - make-mac.mk | 1 - nonfree/controller/CMakeLists.txt | 6 +- nonfree/controller/CV1.cpp | 2135 ----------------- nonfree/controller/CV1.hpp | 143 -- nonfree/controller/CV2.cpp | 1264 ---------- nonfree/controller/CV2.hpp | 100 - .../controller/EmbeddedNetworkController.cpp | 19 +- objects-nonfree.mk | 4 +- rustybits/Cargo.lock | 1459 +---------- rustybits/Cargo.toml | 22 - rustybits/src/ext.rs | 121 - rustybits/src/lib.rs | 2 - rustybits/src/smeeclient/mod.rs | 98 - rustybits/zeroidc.vcxproj | 2 +- rustybits/zeroidc.vcxproj.filters | 2 +- windows/ZeroTierOne/ZeroTierOne.vcxproj | 4 - .../ZeroTierOne/ZeroTierOne.vcxproj.filters | 12 - 19 files changed, 43 insertions(+), 5358 deletions(-) delete mode 100644 nonfree/controller/CV1.cpp delete mode 100644 nonfree/controller/CV1.hpp delete mode 100644 nonfree/controller/CV2.cpp delete mode 100644 nonfree/controller/CV2.hpp delete mode 100644 rustybits/src/smeeclient/mod.rs diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d40ef9e7c..da26af2d2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,15 +68,15 @@ if(ZT1_CENTRAL_CONTROLLER) set(CMAKE_CXX_STANDARD_REQUIRED True CACHE BOOL "C++ standard required" FORCE) set(CMAKE_CXX_EXTENSIONS ON CACHE BOOL "Enable compiler-specific extensions" FORCE) add_definitions(-DZT_NONFREE_CONTROLLER=1 -DZT_CONTROLLER_USE_LIBPQ=1 -DZT1_CENTRAL_CONTROLLER=1 -DZT_OPENTELEMETRY_ENABLED=1 -DZT_NO_PEER_METRICS=1) - set(CONTROLLER_RUST_FEATURES ztcontroller) - set(RUST_BUILD_COMMAND cargo build --release -F ${CONTROLLER_RUST_FEATURES}) else() set(CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard to conform to") set(CMAKE_CXX_STANDARD_REQUIRED True CACHE BOOL "C++ standard required") set(CMAKE_CXX_EXTENSIONS ON CACHE BOOL "Enable compiler-specific extensions") - set(RUST_BUILD_COMMAND "cargo build --release") endif() +# rustybits build command (unquoted so it expands as separate shell arguments) +set(RUST_BUILD_COMMAND cargo build --release) + # build rustybits ExternalProject_Add( rustybits_build diff --git a/make-linux.mk b/make-linux.mk index 4fa462bfe7..94b257a782 100644 --- a/make-linux.mk +++ b/make-linux.mk @@ -351,7 +351,6 @@ ifeq ($(ZT_CONTROLLER),1) override LDLIBS+=-Lext/libpqxx-7.7.3/install/ubuntu22.04/$(EXT_ARCH)/lib -lpqxx -lpq ext/hiredis-1.0.2/lib/ubuntu22.04/$(EXT_ARCH)/libhiredis.a ext/redis-plus-plus-1.3.3/install/ubuntu22.04/$(EXT_ARCH)/lib/libredis++.a -lssl -lcrypto override DEFS+=-DZT_CONTROLLER_USE_LIBPQ -DZT_NO_PEER_METRICS -DZT_OPENTELEMETRY_ENABLED override INCLUDES+=-I/usr/include/postgresql -Iext/libpqxx-7.7.3/install/ubuntu22.04/$(EXT_ARCH)/include -Iext/hiredis-1.0.2/include/ -Iext/redis-plus-plus-1.3.3/install/ubuntu22.04/$(EXT_ARCH)/include - override ZT_CARGO_FLAGS+=-F ztcontroller ifeq ($(ZT_DEBUG),1) override LDLIBS+=rustybits/target/debug/librustybits.a else diff --git a/make-mac.mk b/make-mac.mk index 28b3a605fa..f86c798288 100644 --- a/make-mac.mk +++ b/make-mac.mk @@ -58,7 +58,6 @@ ifeq ($(ZT_CONTROLLER),1) LIBS+=-L/opt/homebrew/lib -L/usr/local/opt/libpqxx/lib -L/usr/local/opt/libpq/lib -L/usr/local/opt/openssl/lib/ -lpqxx -lpq -lssl -lcrypto -lgssapi_krb5 ext/redis-plus-plus-1.1.1/install/macos/lib/libredis++.a ext/hiredis-0.14.1/lib/macos/libhiredis.a rustybits/target/librustybits.a override DEFS+=-DZT_CONTROLLER_USE_LIBPQ -DZT_CONTROLLER_USE_REDIS -DZT_CONTROLLER INCLUDES+=-I/opt/homebrew/include -I/opt/homebrew/opt/libpq/include -I/usr/local/opt/libpq/include -I/usr/local/opt/libpqxx/include -Iext/hiredis-0.14.1/include/ -Iext/redis-plus-plus-1.1.1/install/macos/include/sw/ -Irustybits/target/ - EXTRA_CARGO_FLAGS+=-F ztcontroller else MACOS_VERSION_MIN=10.13 endif diff --git a/nonfree/controller/CMakeLists.txt b/nonfree/controller/CMakeLists.txt index 9a50709777..5fdf424662 100644 --- a/nonfree/controller/CMakeLists.txt +++ b/nonfree/controller/CMakeLists.txt @@ -32,13 +32,9 @@ set(LINK_LIBS if (ZT1_CENTRAL_CONTROLLER) find_package(PostgreSQL REQUIRED) - find_package(protobuf REQUIRED) + find_package(protobuf CONFIG REQUIRED) list(APPEND SRC_FILES - CV1.cpp - CV1.hpp - CV2.cpp - CV2.hpp CentralDB.cpp CentralDB.hpp ControllerConfig.hpp diff --git a/nonfree/controller/CV1.cpp b/nonfree/controller/CV1.cpp deleted file mode 100644 index 9bbe975986..0000000000 --- a/nonfree/controller/CV1.cpp +++ /dev/null @@ -1,2135 +0,0 @@ -/* (c) ZeroTier, Inc. - * See LICENSE.txt in nonfree/ - */ - -#include "CV1.hpp" - -#ifdef ZT_CONTROLLER_USE_LIBPQ - -#include "../../node/Constants.hpp" -#include "../../node/SHA512.hpp" -#include "../../version.h" -#include "CtlUtil.hpp" -#include "EmbeddedNetworkController.hpp" -#include "Redis.hpp" -#include "opentelemetry/trace/provider.h" - -#include -#include -#include -#include -#include -#include - -// #define REDIS_TRACE 1 - -using json = nlohmann::json; - -namespace { - -static const int DB_MINIMUM_VERSION = 38; - -} // anonymous namespace - -using namespace ZeroTier; - -using Attrs = std::vector >; -using Item = std::pair; -using ItemStream = std::vector; - -CV1::CV1(const Identity& myId, const char* path, int listenPort, RedisConfig* rc) - : DB() - , _pool() - , _myId(myId) - , _myAddress(myId.address()) - , _ready(0) - , _connected(1) - , _run(1) - , _waitNoticePrinted(false) - , _listenPort(listenPort) - , _rc(rc) - , _redis(NULL) - , _cluster(NULL) - , _redisMemberStatus(false) - , _smee(NULL) -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv1"); - auto span = tracer->StartSpan("cv1::CV1"); - auto scope = tracer->WithActiveSpan(span); - - rustybits::init_async_runtime(); - - char myAddress[64]; - _myAddressStr = myId.address().toString(myAddress); - _connString = std::string(path); - auto f = std::make_shared(_connString); - _pool = - std::make_shared >(15, 5, std::static_pointer_cast(f)); - - memset(_ssoPsk, 0, sizeof(_ssoPsk)); - char* const ssoPskHex = getenv("ZT_SSO_PSK"); -#ifdef ZT_TRACE - fprintf(stderr, "ZT_SSO_PSK: %s\n", ssoPskHex); -#endif - if (ssoPskHex) { - // SECURITY: note that ssoPskHex will always be null-terminated if libc actually - // returns something non-NULL. If the hex encodes something shorter than 48 bytes, - // it will be padded at the end with zeroes. If longer, it'll be truncated. - Utils::unhex(ssoPskHex, _ssoPsk, sizeof(_ssoPsk)); - } - const char* redisMemberStatus = getenv("ZT_REDIS_MEMBER_STATUS"); - if (redisMemberStatus && (strcmp(redisMemberStatus, "true") == 0)) { - _redisMemberStatus = true; - fprintf(stderr, "Using redis for member status\n"); - } - - auto c = _pool->borrow(); - pqxx::work txn { *c->c }; - - pqxx::row r { txn.exec1("SELECT version FROM ztc_database") }; - int dbVersion = r[0].as(); - txn.commit(); - - if (dbVersion < DB_MINIMUM_VERSION) { - fprintf( - stderr, - "Central database schema version too low. This controller version requires a minimum schema version of " - "%d. Please upgrade your Central instance", - DB_MINIMUM_VERSION); - exit(1); - } - _pool->unborrow(c); - - if (_rc != NULL) { - auto innerspan = tracer->StartSpan("cv1::CV1::configureRedis"); - auto innerscope = tracer->WithActiveSpan(innerspan); - - sw::redis::ConnectionOptions opts; - sw::redis::ConnectionPoolOptions poolOpts; - opts.host = _rc->hostname; - opts.port = _rc->port; - opts.password = _rc->password; - opts.db = 0; - opts.keep_alive = true; - opts.connect_timeout = std::chrono::seconds(3); - poolOpts.size = 25; - poolOpts.wait_timeout = std::chrono::seconds(5); - poolOpts.connection_lifetime = std::chrono::minutes(3); - poolOpts.connection_idle_time = std::chrono::minutes(1); - if (_rc->clusterMode) { - innerspan->SetAttribute("cluster_mode", "true"); - fprintf(stderr, "Using Redis in Cluster Mode\n"); - _cluster = std::make_shared(opts, poolOpts); - } - else { - innerspan->SetAttribute("cluster_mode", "false"); - fprintf(stderr, "Using Redis in Standalone Mode\n"); - _redis = std::make_shared(opts, poolOpts); - } - } - - _readyLock.lock(); - - fprintf( - stderr, "[%s] NOTICE: %.10llx controller PostgreSQL waiting for initial data download..." ZT_EOL_S, - ::_timestr(), (unsigned long long)_myAddress.toInt()); - _waitNoticePrinted = true; - - initializeNetworks(); - initializeMembers(); - - _heartbeatThread = std::thread(&CV1::heartbeat, this); - _membersDbWatcher = std::thread(&CV1::membersDbWatcher, this); - _networksDbWatcher = std::thread(&CV1::networksDbWatcher, this); - for (int i = 0; i < ZT_CENTRAL_CONTROLLER_COMMIT_THREADS; ++i) { - _commitThread[i] = std::thread(&CV1::commitThread, this); - } - _onlineNotificationThread = std::thread(&CV1::onlineNotificationThread, this); - - configureSmee(); -} - -CV1::~CV1() -{ - if (_smee != NULL) { - rustybits::smee_client_delete(_smee); - _smee = NULL; - } - - rustybits::shutdown_async_runtime(); - - _run = 0; - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - - _heartbeatThread.join(); - _membersDbWatcher.join(); - _networksDbWatcher.join(); - _commitQueue.stop(); - for (int i = 0; i < ZT_CENTRAL_CONTROLLER_COMMIT_THREADS; ++i) { - _commitThread[i].join(); - } - _onlineNotificationThread.join(); -} - -void CV1::configureSmee() -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv1"); - auto span = tracer->StartSpan("cv1::configureSmee"); - auto scope = tracer->WithActiveSpan(span); - - const char* TEMPORAL_SCHEME = "ZT_TEMPORAL_SCHEME"; - const char* TEMPORAL_HOST = "ZT_TEMPORAL_HOST"; - const char* TEMPORAL_PORT = "ZT_TEMPORAL_PORT"; - const char* TEMPORAL_NAMESPACE = "ZT_TEMPORAL_NAMESPACE"; - const char* SMEE_TASK_QUEUE = "ZT_SMEE_TASK_QUEUE"; - - const char* scheme = getenv(TEMPORAL_SCHEME); - if (scheme == NULL) { - scheme = "http"; - } - const char* host = getenv(TEMPORAL_HOST); - const char* port = getenv(TEMPORAL_PORT); - const char* ns = getenv(TEMPORAL_NAMESPACE); - const char* task_queue = getenv(SMEE_TASK_QUEUE); - - if (scheme != NULL && host != NULL && port != NULL && ns != NULL && task_queue != NULL) { - fprintf(stderr, "creating smee client\n"); - std::string hostPort = - std::string(scheme) + std::string("://") + std::string(host) + std::string(":") + std::string(port); - this->_smee = rustybits::smee_client_new(hostPort.c_str(), ns, task_queue); - } - else { - fprintf(stderr, "Smee client not configured\n"); - } -} - -bool CV1::waitForReady() -{ - while (_ready < 2) { - _readyLock.lock(); - _readyLock.unlock(); - } - return true; -} - -bool CV1::isReady() -{ return ((_ready == 2) && (_connected)); } - -bool CV1::save(nlohmann::json& record, bool notifyListeners) -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv1"); - auto span = tracer->StartSpan("cv1::save"); - auto scope = tracer->WithActiveSpan(span); - - bool modified = false; - try { - if (! record.is_object()) { - fprintf(stderr, "record is not an object?!?\n"); - return false; - } - const std::string objtype = record["objtype"]; - if (objtype == "network") { - // fprintf(stderr, "network save\n"); - const uint64_t nwid = OSUtils::jsonIntHex(record["id"], 0ULL); - if (nwid) { - nlohmann::json old; - get(nwid, old); - if ((! old.is_object()) || (! _compareRecords(old, record))) { - record["revision"] = OSUtils::jsonInt(record["revision"], 0ULL) + 1ULL; - _commitQueue.post(std::pair(record, notifyListeners)); - modified = true; - } - } - } - else if (objtype == "member") { - std::string networkId = record["nwid"]; - std::string memberId = record["id"]; - const uint64_t nwid = OSUtils::jsonIntHex(record["nwid"], 0ULL); - const uint64_t id = OSUtils::jsonIntHex(record["id"], 0ULL); - // fprintf(stderr, "member save %s-%s\n", networkId.c_str(), memberId.c_str()); - if ((id) && (nwid)) { - nlohmann::json network, old; - get(nwid, network, id, old); - if ((! old.is_object()) || (! _compareRecords(old, record))) { - // fprintf(stderr, "commit queue post\n"); - record["revision"] = OSUtils::jsonInt(record["revision"], 0ULL) + 1ULL; - _commitQueue.post(std::pair(record, notifyListeners)); - modified = true; - } - else { - // fprintf(stderr, "no change\n"); - } - } - } - else { - fprintf(stderr, "uhh waaat\n"); - } - } - catch (std::exception& e) { - fprintf(stderr, "Error on PostgreSQL::save: %s\n", e.what()); - } - catch (...) { - fprintf(stderr, "Unknown error on PostgreSQL::save\n"); - } - return modified; -} - -void CV1::eraseNetwork(const uint64_t networkId) -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv1"); - auto span = tracer->StartSpan("cv1::eraseNetwork"); - auto scope = tracer->WithActiveSpan(span); - char networkIdStr[17]; - span->SetAttribute("network_id", Utils::hex(networkId, networkIdStr)); - - fprintf(stderr, "PostgreSQL::eraseNetwork\n"); - char tmp2[24]; - waitForReady(); - Utils::hex(networkId, tmp2); - std::pair tmp; - tmp.first["id"] = tmp2; - tmp.first["objtype"] = "_delete_network"; - tmp.second = true; - _commitQueue.post(tmp); - nlohmann::json nullJson; - _networkChanged(tmp.first, nullJson, true); -} - -void CV1::eraseMember(const uint64_t networkId, const uint64_t memberId) -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv1"); - auto span = tracer->StartSpan("cv1::eraseMember"); - auto scope = tracer->WithActiveSpan(span); - char networkIdStr[17]; - char memberIdStr[11]; - span->SetAttribute("network_id", Utils::hex(networkId, networkIdStr)); - span->SetAttribute("member_id", Utils::hex10(memberId, memberIdStr)); - - fprintf(stderr, "PostgreSQL::eraseMember\n"); - char tmp2[24]; - waitForReady(); - std::pair tmp, nw; - Utils::hex(networkId, tmp2); - tmp.first["nwid"] = tmp2; - Utils::hex(memberId, tmp2); - tmp.first["id"] = tmp2; - tmp.first["objtype"] = "_delete_member"; - tmp.second = true; - _commitQueue.post(tmp); - nlohmann::json nullJson; - _memberChanged(tmp.first, nullJson, true); -} - -void CV1::nodeIsOnline( - const uint64_t networkId, - const uint64_t memberId, - const InetAddress& physicalAddress, - const char* osArch) -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv1"); - auto span = tracer->StartSpan("cv1::nodeIsOnline"); - auto scope = tracer->WithActiveSpan(span); - char networkIdStr[17]; - char memberIdStr[11]; - char ipStr[INET6_ADDRSTRLEN]; - span->SetAttribute("network_id", Utils::hex(networkId, networkIdStr)); - span->SetAttribute("member_id", Utils::hex10(memberId, memberIdStr)); - span->SetAttribute("physical_address", physicalAddress.toString(ipStr)); - span->SetAttribute("os_arch", osArch); - - std::lock_guard l(_lastOnline_l); - NodeOnlineRecord& i = _lastOnline[std::pair(networkId, memberId)]; - i.lastSeen = OSUtils::now(); - if (physicalAddress) { - i.physicalAddress = physicalAddress; - } - i.osArch = std::string(osArch); -} - -void CV1::nodeIsOnline(const uint64_t networkId, const uint64_t memberId, const InetAddress& physicalAddress) -{ this->nodeIsOnline(networkId, memberId, physicalAddress, "unknown/unknown"); } - -AuthInfo CV1::getSSOAuthInfo(const nlohmann::json& member, const std::string& redirectURL) -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv1"); - auto span = tracer->StartSpan("cv1::getSSOAuthInfo"); - auto scope = tracer->WithActiveSpan(span); - - Metrics::db_get_sso_info++; - // NONCE is just a random character string. no semantic meaning - // state = HMAC SHA384 of Nonce based on shared sso key - // - // need nonce timeout in database? make sure it's used within X time - // X is 5 minutes for now. Make configurable later? - // - // how do we tell when a nonce is used? if auth_expiration_time is set - std::string networkId = member["nwid"]; - std::string memberId = member["id"]; - - char authenticationURL[4096] = { 0 }; - AuthInfo info; - info.enabled = true; - - // if (memberId == "a10dccea52" && networkId == "8056c2e21c24673d") { - // fprintf(stderr, "invalid authinfo for grant's machine\n"); - // info.version=1; - // return info; - // } - // fprintf(stderr, "PostgreSQL::updateMemberOnLoad: %s-%s\n", networkId.c_str(), memberId.c_str()); - std::shared_ptr c; - try { - c = _pool->borrow(); - pqxx::work w(*c->c); - - char nonceBytes[16] = { 0 }; - std::string nonce = ""; - - // check if the member exists first. - pqxx::row count = w.exec_params1( - "SELECT count(id) FROM ztc_member WHERE id = $1 AND network_id = $2 AND deleted = false", memberId, - networkId); - if (count[0].as() == 1) { - // get active nonce, if exists. - pqxx::result r = w.exec_params("SELECT nonce FROM ztc_sso_expiry " - "WHERE network_id = $1 AND member_id = $2 " - "AND ((NOW() AT TIME ZONE 'UTC') <= authentication_expiry_time) AND ((NOW() AT TIME ZONE 'UTC') <= nonce_expiration)", - networkId, - memberId); - - if (r.size() == 0) { - // no active nonce. - // find an unused nonce, if one exists. - pqxx::result r = w.exec_params( - "SELECT nonce FROM ztc_sso_expiry " - "WHERE network_id = $1 AND member_id = $2 " - "AND authentication_expiry_time IS NULL AND ((NOW() AT TIME ZONE 'UTC') <= nonce_expiration)", - networkId, memberId); - - if (r.size() == 1) { - // we have an existing nonce. Use it - nonce = r.at(0)[0].as(); - Utils::unhex(nonce.c_str(), nonceBytes, sizeof(nonceBytes)); - } - else if (r.empty()) { - // create a nonce - Utils::getSecureRandom(nonceBytes, 16); - char nonceBuf[64] = { 0 }; - Utils::hex(nonceBytes, sizeof(nonceBytes), nonceBuf); - nonce = std::string(nonceBuf); - - pqxx::result ir = w.exec_params0( - "INSERT INTO ztc_sso_expiry " - "(nonce, nonce_expiration, network_id, member_id) VALUES " - "($1, TO_TIMESTAMP($2::double precision/1000), $3, $4)", - nonce, OSUtils::now() + 300000, networkId, memberId); - - w.commit(); - } - else { - // > 1 ?!? Thats an error! - fprintf(stderr, "> 1 unused nonce!\n"); - exit(6); - } - } - else if (r.size() == 1) { - nonce = r.at(0)[0].as(); - Utils::unhex(nonce.c_str(), nonceBytes, sizeof(nonceBytes)); - } - else { - // more than 1 nonce in use? Uhhh... - fprintf(stderr, "> 1 nonce in use for network member?!?\n"); - exit(7); - } - - r = w.exec_params("SELECT oc.client_id, oc.authorization_endpoint, oc.issuer, oc.provider, oc.sso_impl_version " - "FROM ztc_network AS n " - "INNER JOIN ztc_org o " - " ON o.owner_id = n.owner_id " - "LEFT OUTER JOIN ztc_network_oidc_config noc " - " ON noc.network_id = n.id " - "LEFT OUTER JOIN ztc_oidc_config oc " - " ON noc.client_id = oc.client_id AND oc.org_id = o.org_id " - "WHERE n.id = $1 AND n.sso_enabled = true", - networkId); - - std::string client_id = ""; - std::string authorization_endpoint = ""; - std::string issuer = ""; - std::string provider = ""; - uint64_t sso_version = 0; - - if (r.size() == 1) { - client_id = r.at(0)[0].as >().value_or(""); - authorization_endpoint = r.at(0)[1].as >().value_or(""); - issuer = r.at(0)[2].as >().value_or(""); - provider = r.at(0)[3].as >().value_or(""); - sso_version = r.at(0)[4].as >().value_or(1); - } - else if (r.size() > 1) { - fprintf( - stderr, "ERROR: More than one auth endpoint for an organization?!?!? NetworkID: %s\n", - networkId.c_str()); - } - else { - fprintf(stderr, "No client or auth endpoint?!?\n"); - } - - info.version = sso_version; - - // no catch all else because we don't actually care if no records exist here. just continue as normal. - if ((! client_id.empty()) && (! authorization_endpoint.empty())) { - uint8_t state[48]; - HMACSHA384(_ssoPsk, nonceBytes, sizeof(nonceBytes), state); - char state_hex[256]; - Utils::hex(state, 48, state_hex); - - if (info.version == 0) { - char url[2048] = { 0 }; - OSUtils::ztsnprintf( - url, sizeof(authenticationURL), - "%s?response_type=id_token&response_mode=form_post&scope=openid+email+profile&redirect_uri=%s&" - "nonce=%s&state=%s&client_id=%s", - authorization_endpoint.c_str(), url_encode(redirectURL).c_str(), nonce.c_str(), state_hex, - client_id.c_str()); - info.authenticationURL = std::string(url); - } - else if (info.version == 1) { - info.ssoClientID = client_id; - info.issuerURL = issuer; - info.ssoProvider = provider; - info.ssoNonce = nonce; - info.ssoState = std::string(state_hex) + "_" + networkId; - info.centralAuthURL = redirectURL; -#ifdef ZT_DEBUG - fprintf( - stderr, - "ssoClientID: %s\nissuerURL: %s\nssoNonce: %s\nssoState: %s\ncentralAuthURL: %s\nprovider: " - "%s\n", - info.ssoClientID.c_str(), info.issuerURL.c_str(), info.ssoNonce.c_str(), info.ssoState.c_str(), - info.centralAuthURL.c_str(), provider.c_str()); -#endif - } - } - else { - fprintf( - stderr, "client_id: %s\nauthorization_endpoint: %s\n", client_id.c_str(), - authorization_endpoint.c_str()); - } - } - - _pool->unborrow(c); - } - catch (std::exception& e) { - span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "ERROR: Error updating member on load for network %s: %s\n", networkId.c_str(), e.what()); - } - - return info; // std::string(authenticationURL); -} - -void CV1::initializeNetworks() -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv1"); - auto span = tracer->StartSpan("cv1::initializeNetworks"); - auto scope = tracer->WithActiveSpan(span); - - try { - std::string setKey = "networks:{" + _myAddressStr + "}"; - - fprintf(stderr, "Initializing Networks...\n"); - - if (_redisMemberStatus) { - fprintf(stderr, "Init Redis for networks...\n"); - try { - if (_rc->clusterMode) { - _cluster->del(setKey); - } - else { - _redis->del(setKey); - } - } - catch (sw::redis::Error& e) { - // ignore. if this key doesn't exist, there's no reason to delete it - } - } - - std::unordered_set networkSet; - - char qbuf[2048] = { 0 }; - sprintf( - qbuf, - "SELECT n.id, (EXTRACT(EPOCH FROM n.creation_time AT TIME ZONE 'UTC')*1000)::bigint as creation_time, " - "n.capabilities, " - "n.enable_broadcast, (EXTRACT(EPOCH FROM n.last_modified AT TIME ZONE 'UTC')*1000)::bigint AS " - "last_modified, n.mtu, n.multicast_limit, n.name, n.private, n.remote_trace_level, " - "n.remote_trace_target, n.revision, n.rules, n.tags, n.v4_assign_mode, n.v6_assign_mode, n.sso_enabled, " - "(CASE WHEN n.sso_enabled THEN noc.client_id ELSE NULL END) as client_id, " - "(CASE WHEN n.sso_enabled THEN oc.authorization_endpoint ELSE NULL END) as authorization_endpoint, " - "(CASE WHEN n.sso_enabled THEN oc.provider ELSE NULL END) as provider, d.domain, d.servers, " - "ARRAY(SELECT CONCAT(host(ip_range_start),'|', host(ip_range_end)) FROM ztc_network_assignment_pool WHERE " - "network_id = n.id) AS assignment_pool, " - "ARRAY(SELECT CONCAT(host(address),'/',bits::text,'|',COALESCE(host(via), 'NULL'))FROM ztc_network_route " - "WHERE network_id = n.id) AS routes " - "FROM ztc_network n " - "LEFT OUTER JOIN ztc_org o " - " ON o.owner_id = n.owner_id " - "LEFT OUTER JOIN ztc_network_oidc_config noc " - " ON noc.network_id = n.id " - "LEFT OUTER JOIN ztc_oidc_config oc " - " ON noc.client_id = oc.client_id AND oc.org_id = o.org_id " - "LEFT OUTER JOIN ztc_network_dns d " - " ON d.network_id = n.id " - "WHERE deleted = false AND controller_id = '%s'", - _myAddressStr.c_str()); - auto c = _pool->borrow(); - auto c2 = _pool->borrow(); - pqxx::work w { *c->c }; - - fprintf(stderr, "Load networks from psql...\n"); - auto stream = pqxx::stream_from::query(w, qbuf); - - std::tuple // creationTime - , - std::optional // capabilities - , - std::optional // enableBroadcast - , - std::optional // lastModified - , - std::optional // mtu - , - std::optional // multicastLimit - , - std::optional // name - , - bool // private - , - std::optional // remoteTraceLevel - , - std::optional // remoteTraceTarget - , - std::optional // revision - , - std::optional // rules - , - std::optional // tags - , - std::optional // v4AssignMode - , - std::optional // v6AssignMode - , - std::optional // ssoEnabled - , - std::optional // clientId - , - std::optional // authorizationEndpoint - , - std::optional // ssoProvider - , - std::optional // domain - , - std::optional // servers - , - std::string // assignmentPoolString - , - std::string // routeString - > - row; - - uint64_t count = 0; - auto tmp = std::chrono::high_resolution_clock::now(); - uint64_t total = 0; - while (stream >> row) { - auto start = std::chrono::high_resolution_clock::now(); - - json empty; - json config; - - initNetwork(config); - - std::string nwid = std::get<0>(row); - std::optional creationTime = std::get<1>(row); - std::optional capabilities = std::get<2>(row); - std::optional enableBroadcast = std::get<3>(row); - std::optional lastModified = std::get<4>(row); - std::optional mtu = std::get<5>(row); - std::optional multicastLimit = std::get<6>(row); - std::optional name = std::get<7>(row); - bool isPrivate = std::get<8>(row); - std::optional remoteTraceLevel = std::get<9>(row); - std::optional remoteTraceTarget = std::get<10>(row); - std::optional revision = std::get<11>(row); - std::optional rules = std::get<12>(row); - std::optional tags = std::get<13>(row); - std::optional v4AssignMode = std::get<14>(row); - std::optional v6AssignMode = std::get<15>(row); - std::optional ssoEnabled = std::get<16>(row); - std::optional clientId = std::get<17>(row); - std::optional authorizationEndpoint = std::get<18>(row); - std::optional ssoProvider = std::get<19>(row); - std::optional dnsDomain = std::get<20>(row); - std::optional dnsServers = std::get<21>(row); - std::string assignmentPoolString = std::get<22>(row); - std::string routesString = std::get<23>(row); - - config["id"] = nwid; - config["nwid"] = nwid; - config["creationTime"] = creationTime.value_or(0); - config["capabilities"] = json::parse(capabilities.value_or("[]")); - config["enableBroadcast"] = enableBroadcast.value_or(false); - config["lastModified"] = lastModified.value_or(0); - config["mtu"] = mtu.value_or(2800); - config["multicastLimit"] = multicastLimit.value_or(64); - config["name"] = name.value_or(""); - config["private"] = isPrivate; - config["remoteTraceLevel"] = remoteTraceLevel.value_or(0); - config["remoteTraceTarget"] = remoteTraceTarget.value_or(""); - config["revision"] = revision.value_or(0); - config["rules"] = json::parse(rules.value_or("[]")); - config["tags"] = json::parse(tags.value_or("[]")); - config["v4AssignMode"] = json::parse(v4AssignMode.value_or("{}")); - config["v6AssignMode"] = json::parse(v6AssignMode.value_or("{}")); - config["ssoEnabled"] = ssoEnabled.value_or(false); - config["objtype"] = "network"; - config["ipAssignmentPools"] = json::array(); - config["routes"] = json::array(); - config["clientId"] = clientId.value_or(""); - config["authorizationEndpoint"] = authorizationEndpoint.value_or(""); - config["provider"] = ssoProvider.value_or(""); - - networkSet.insert(nwid); - - if (dnsDomain.has_value()) { - std::string serverList = dnsServers.value(); - json obj; - auto servers = json::array(); - if (serverList.rfind("{", 0) != std::string::npos) { - serverList = serverList.substr(1, serverList.size() - 2); - std::stringstream ss(serverList); - while (ss.good()) { - std::string server; - std::getline(ss, server, ','); - servers.push_back(server); - } - } - obj["domain"] = dnsDomain.value(); - obj["servers"] = servers; - config["dns"] = obj; - } - - config["ipAssignmentPools"] = json::array(); - if (assignmentPoolString != "{}") { - std::string tmp = assignmentPoolString.substr(1, assignmentPoolString.size() - 2); - std::vector assignmentPools = split(tmp, ','); - for (auto it = assignmentPools.begin(); it != assignmentPools.end(); ++it) { - std::vector r = split(*it, '|'); - json ip; - ip["ipRangeStart"] = r[0]; - ip["ipRangeEnd"] = r[1]; - config["ipAssignmentPools"].push_back(ip); - } - } - - config["routes"] = json::array(); - if (routesString != "{}") { - std::string tmp = routesString.substr(1, routesString.size() - 2); - std::vector routes = split(tmp, ','); - for (auto it = routes.begin(); it != routes.end(); ++it) { - std::vector r = split(*it, '|'); - json route; - route["target"] = r[0]; - route["via"] = ((route["via"] == "NULL") ? nullptr : r[1]); - config["routes"].push_back(route); - } - } - - Metrics::network_count++; - - _networkChanged(empty, config, false); - - auto end = std::chrono::high_resolution_clock::now(); - auto dur = std::chrono::duration_cast(end - start); - ; - total += dur.count(); - ++count; - if (count > 0 && count % 10000 == 0) { - fprintf(stderr, "Averaging %llu us per network\n", (total / count)); - } - } - - if (count > 0) { - fprintf(stderr, "Took %llu us per network to load\n", (total / count)); - } - stream.complete(); - - w.commit(); - _pool->unborrow(c2); - _pool->unborrow(c); - fprintf(stderr, "done.\n"); - - if (! networkSet.empty()) { - if (_redisMemberStatus) { - fprintf(stderr, "adding networks to redis...\n"); - if (_rc->clusterMode) { - auto tx = _cluster->transaction(_myAddressStr, true, false); - uint64_t count = 0; - for (std::string nwid : networkSet) { - tx.sadd(setKey, nwid); - if (++count % 30000 == 0) { - tx.exec(); - tx = _cluster->transaction(_myAddressStr, true, false); - } - } - tx.exec(); - } - else { - auto tx = _redis->transaction(true, false); - uint64_t count = 0; - for (std::string nwid : networkSet) { - tx.sadd(setKey, nwid); - if (++count % 30000 == 0) { - tx.exec(); - tx = _redis->transaction(true, false); - } - } - tx.exec(); - } - fprintf(stderr, "done.\n"); - } - } - - if (++this->_ready == 2) { - if (_waitNoticePrinted) { - fprintf( - stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), - (unsigned long long)_myAddress.toInt()); - } - _readyLock.unlock(); - } - fprintf(stderr, "network init done.\n"); - } - catch (sw::redis::Error& e) { - span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "ERROR: Error initializing networks in Redis: %s\n", e.what()); - std::this_thread::sleep_for(std::chrono::milliseconds(5000)); - exit(-1); - } - catch (std::exception& e) { - span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "ERROR: Error initializing networks: %s\n", e.what()); - std::this_thread::sleep_for(std::chrono::milliseconds(5000)); - exit(-1); - } -} - -void CV1::initializeMembers() -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv1"); - auto span = tracer->StartSpan("cv1::initializeMembers"); - auto scope = tracer->WithActiveSpan(span); - - std::string memberId; - std::string networkId; - try { - std::unordered_map networkMembers; - fprintf(stderr, "Initializing Members...\n"); - - std::string setKeyBase = "network-nodes-all:{" + _myAddressStr + "}:"; - - if (_redisMemberStatus) { - fprintf(stderr, "Initialize Redis for members...\n"); - std::unique_lock l(_networks_l); - std::unordered_set deletes; - for (auto it : _networks) { - uint64_t nwid_i = it.first; - char nwidTmp[64] = { 0 }; - OSUtils::ztsnprintf(nwidTmp, sizeof(nwidTmp), "%.16llx", nwid_i); - std::string nwid(nwidTmp); - std::string key = setKeyBase + nwid; - deletes.insert(key); - } - - if (! deletes.empty()) { - try { - if (_rc->clusterMode) { - auto tx = _cluster->transaction(_myAddressStr, true, false); - for (std::string k : deletes) { - tx.del(k); - } - tx.exec(); - } - else { - auto tx = _redis->transaction(true, false); - for (std::string k : deletes) { - tx.del(k); - } - tx.exec(); - } - } - catch (sw::redis::Error& e) { - // ignore - } - } - } - - char qbuf[2048]; - sprintf( - qbuf, - "SELECT m.id, m.network_id, m.active_bridge, m.authorized, m.capabilities, " - "(EXTRACT(EPOCH FROM m.creation_time AT TIME ZONE 'UTC')*1000)::bigint, m.identity, " - "(EXTRACT(EPOCH FROM m.last_authorized_time AT TIME ZONE 'UTC')*1000)::bigint, " - "(EXTRACT(EPOCH FROM m.last_deauthorized_time AT TIME ZONE 'UTC')*1000)::bigint, " - "m.remote_trace_level, m.remote_trace_target, m.tags, m.v_major, m.v_minor, m.v_rev, m.v_proto, " - "m.no_auto_assign_ips, m.revision, m.sso_exempt, " - "(CASE WHEN n.sso_enabled = TRUE AND m.sso_exempt = FALSE THEN " - " ( " - " SELECT (EXTRACT(EPOCH FROM e.authentication_expiry_time)*1000)::bigint " - " FROM ztc_sso_expiry e " - " INNER JOIN ztc_network n1 " - " ON n1.id = e.network_id AND n1.deleted = TRUE " - " WHERE e.network_id = m.network_id AND e.member_id = m.id AND n.sso_enabled = TRUE AND " - "e.authentication_expiry_time IS NOT NULL " - " ORDER BY e.authentication_expiry_time DESC LIMIT 1 " - " ) " - " ELSE NULL " - " END) AS authentication_expiry_time, " - "ARRAY(SELECT DISTINCT address FROM ztc_member_ip_assignment WHERE member_id = m.id AND network_id = " - "m.network_id) AS assigned_addresses " - "FROM ztc_member m " - "INNER JOIN ztc_network n " - " ON n.id = m.network_id " - "WHERE n.controller_id = '%s' AND n.deleted = FALSE AND m.deleted = FALSE", - _myAddressStr.c_str()); - auto c = _pool->borrow(); - auto c2 = _pool->borrow(); - pqxx::work w { *c->c }; - - fprintf(stderr, "Load members from psql...\n"); - auto stream = pqxx::stream_from::query(w, qbuf); - - std::tuple // activeBridge - , - std::optional // authorized - , - std::optional // capabilities - , - std::optional // creationTime - , - std::optional // identity - , - std::optional // lastAuthorizedTime - , - std::optional // lastDeauthorizedTime - , - std::optional // remoteTraceLevel - , - std::optional // remoteTraceTarget - , - std::optional // tags - , - std::optional // vMajor - , - std::optional // vMinor - , - std::optional // vRev - , - std::optional // vProto - , - std::optional // noAutoAssignIps - , - std::optional // revision - , - std::optional // ssoExempt - , - std::optional // authenticationExpiryTime - , - std::string // assignedAddresses - > - row; - - uint64_t count = 0; - auto tmp = std::chrono::high_resolution_clock::now(); - uint64_t total = 0; - while (stream >> row) { - auto start = std::chrono::high_resolution_clock::now(); - json empty; - json config; - - initMember(config); - - memberId = std::get<0>(row); - networkId = std::get<1>(row); - std::optional activeBridge = std::get<2>(row); - std::optional authorized = std::get<3>(row); - std::optional capabilities = std::get<4>(row); - std::optional creationTime = std::get<5>(row); - std::optional identity = std::get<6>(row); - std::optional lastAuthorizedTime = std::get<7>(row); - std::optional lastDeauthorizedTime = std::get<8>(row); - std::optional remoteTraceLevel = std::get<9>(row); - std::optional remoteTraceTarget = std::get<10>(row); - std::optional tags = std::get<11>(row); - std::optional vMajor = std::get<12>(row); - std::optional vMinor = std::get<13>(row); - std::optional vRev = std::get<14>(row); - std::optional vProto = std::get<15>(row); - std::optional noAutoAssignIps = std::get<16>(row); - std::optional revision = std::get<17>(row); - std::optional ssoExempt = std::get<18>(row); - std::optional authenticationExpiryTime = std::get<19>(row); - std::string assignedAddresses = std::get<20>(row); - - networkMembers.insert(std::pair(setKeyBase + networkId, memberId)); - - config["id"] = memberId; - config["address"] = memberId; - config["nwid"] = networkId; - config["activeBridge"] = activeBridge.value_or(false); - config["authorized"] = authorized.value_or(false); - config["capabilities"] = json::parse(capabilities.value_or("[]")); - config["creationTime"] = creationTime.value_or(0); - config["identity"] = identity.value_or(""); - config["lastAuthorizedTime"] = lastAuthorizedTime.value_or(0); - config["lastDeauthorizedTime"] = lastDeauthorizedTime.value_or(0); - config["remoteTraceLevel"] = remoteTraceLevel.value_or(0); - config["remoteTraceTarget"] = remoteTraceTarget.value_or(""); - config["tags"] = json::parse(tags.value_or("[]")); - config["vMajor"] = vMajor.value_or(-1); - config["vMinor"] = vMinor.value_or(-1); - config["vRev"] = vRev.value_or(-1); - config["vProto"] = vProto.value_or(-1); - config["noAutoAssignIps"] = noAutoAssignIps.value_or(false); - config["revision"] = revision.value_or(0); - config["ssoExempt"] = ssoExempt.value_or(false); - config["authenticationExpiryTime"] = authenticationExpiryTime.value_or(0); - config["objtype"] = "member"; - config["ipAssignments"] = json::array(); - - if (assignedAddresses != "{}") { - std::string tmp = assignedAddresses.substr(1, assignedAddresses.size() - 2); - std::vector addrs = split(tmp, ','); - for (auto it = addrs.begin(); it != addrs.end(); ++it) { - config["ipAssignments"].push_back(*it); - } - } - - Metrics::member_count++; - - _memberChanged(empty, config, false); - - memberId = ""; - networkId = ""; - - auto end = std::chrono::high_resolution_clock::now(); - auto dur = std::chrono::duration_cast(end - start); - total += dur.count(); - ++count; - if (count > 0 && count % 10000 == 0) { - fprintf(stderr, "Averaging %llu us per member\n", (total / count)); - } - } - if (count > 0) { - fprintf(stderr, "Took %llu us per member to load\n", (total / count)); - } - - stream.complete(); - - w.commit(); - _pool->unborrow(c2); - _pool->unborrow(c); - fprintf(stderr, "done.\n"); - - if (! networkMembers.empty()) { - if (_redisMemberStatus) { - fprintf(stderr, "Load member data into redis...\n"); - if (_rc->clusterMode) { - auto tx = _cluster->transaction(_myAddressStr, true, false); - uint64_t count = 0; - for (auto it : networkMembers) { - tx.sadd(it.first, it.second); - if (++count % 30000 == 0) { - tx.exec(); - tx = _cluster->transaction(_myAddressStr, true, false); - } - } - tx.exec(); - } - else { - auto tx = _redis->transaction(true, false); - uint64_t count = 0; - for (auto it : networkMembers) { - tx.sadd(it.first, it.second); - if (++count % 30000 == 0) { - tx.exec(); - tx = _redis->transaction(true, false); - } - } - tx.exec(); - } - fprintf(stderr, "done.\n"); - } - } - - fprintf(stderr, "Done loading members...\n"); - - if (++this->_ready == 2) { - if (_waitNoticePrinted) { - fprintf( - stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), - (unsigned long long)_myAddress.toInt()); - } - _readyLock.unlock(); - } - } - catch (sw::redis::Error& e) { - span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "ERROR: Error initializing members (redis): %s\n", e.what()); - exit(-1); - } - catch (std::exception& e) { - span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "ERROR: Error initializing member: %s-%s %s\n", networkId.c_str(), memberId.c_str(), e.what()); - exit(-1); - } -} - -void CV1::heartbeat() -{ - char publicId[1024]; - char hostnameTmp[1024]; - _myId.toString(false, publicId); - if (gethostname(hostnameTmp, sizeof(hostnameTmp)) != 0) { - hostnameTmp[0] = (char)0; - } - else { - for (int i = 0; i < (int)sizeof(hostnameTmp); ++i) { - if ((hostnameTmp[i] == '.') || (hostnameTmp[i] == 0)) { - hostnameTmp[i] = (char)0; - break; - } - } - } - const char* controllerId = _myAddressStr.c_str(); - const char* publicIdentity = publicId; - const char* hostname = hostnameTmp; - - while (_run == 1) { - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv1"); - auto span = tracer->StartSpan("cv1::heartbeat"); - auto scope = tracer->WithActiveSpan(span); - - // fprintf(stderr, "%s: heartbeat\n", controllerId); - auto c = _pool->borrow(); - int64_t ts = OSUtils::now(); - - if (c->c) { - std::string major = std::to_string(ZEROTIER_ONE_VERSION_MAJOR); - std::string minor = std::to_string(ZEROTIER_ONE_VERSION_MINOR); - std::string rev = std::to_string(ZEROTIER_ONE_VERSION_REVISION); - std::string build = std::to_string(ZEROTIER_ONE_VERSION_BUILD); - std::string now = std::to_string(ts); - std::string host_port = std::to_string(_listenPort); - std::string notification_transport = (_rc != NULL) ? "redis" : "postgres"; - std::string use_redis = (_rc != NULL) ? "true" : "false"; - std::string redis_mem_status = (_redisMemberStatus) ? "true" : "false"; - - try { - pqxx::work w { *c->c }; - - pqxx::result res = w.exec0( - "INSERT INTO ztc_controller (id, cluster_host, last_alive, public_identity, v_major, v_minor, " - "v_rev, v_build, host_port, use_redis, redis_member_status) " - "VALUES (" - + w.quote(controllerId) + ", " + w.quote(hostname) + ", TO_TIMESTAMP(" + now - + "::double precision/1000), " + w.quote(publicIdentity) + ", " + major + ", " + minor + ", " + rev - + ", " + build + ", " + host_port + ", " + use_redis + ", " + redis_mem_status - + ") " - "ON CONFLICT (id) DO UPDATE SET cluster_host = EXCLUDED.cluster_host, last_alive = " - "EXCLUDED.last_alive, " - "public_identity = EXCLUDED.public_identity, v_major = EXCLUDED.v_major, v_minor = " - "EXCLUDED.v_minor, " - "v_rev = EXCLUDED.v_rev, v_build = EXCLUDED.v_rev, host_port = EXCLUDED.host_port, " - "use_redis = EXCLUDED.use_redis, redis_member_status = EXCLUDED.redis_member_status"); - w.commit(); - } - catch (std::exception& e) { - fprintf(stderr, "%s: Heartbeat update failed: %s\n", controllerId, e.what()); - span->End(); - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - continue; - } - } - _pool->unborrow(c); - - try { - if (_redisMemberStatus) { - if (_rc->clusterMode) { - _cluster->zadd("controllers", "controllerId", ts); - } - else { - _redis->zadd("controllers", "controllerId", ts); - } - } - } - catch (sw::redis::Error& e) { - fprintf(stderr, "ERROR: Redis error in heartbeat thread: %s\n", e.what()); - } - - span->End(); - std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - } - fprintf(stderr, "Exited heartbeat thread\n"); -} - -void CV1::membersDbWatcher() -{ - if (_rc) { - _membersWatcher_Redis(); - } - else { - _membersWatcher_Postgres(); - } - - if (_run == 1) { - fprintf( - stderr, "ERROR: %s membersDbWatcher should still be running! Exiting Controller.\n", _myAddressStr.c_str()); - exit(9); - } - fprintf(stderr, "Exited membersDbWatcher\n"); -} - -void CV1::_membersWatcher_Postgres() -{ - auto c = _pool->borrow(); - - std::string stream = "member_" + _myAddressStr; - - fprintf(stderr, "Listening to member stream: %s\n", stream.c_str()); - MemberNotificationReceiver m(this, *c->c, stream); - - while (_run == 1) { - c->c->await_notification(5, 0); - } - - _pool->unborrow(c); -} - -void CV1::_membersWatcher_Redis() -{ - char buf[11] = { 0 }; - std::string key = "member-stream:{" + std::string(_myAddress.toString(buf)) + "}"; - std::string lastID = "0"; - fprintf(stderr, "Listening to member stream: %s\n", key.c_str()); - while (_run == 1) { - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv1"); - auto span = tracer->StartSpan("cv1::_membersWatcher_Redis"); - auto scope = tracer->WithActiveSpan(span); - - try { - json tmp; - std::unordered_map result; - if (_rc->clusterMode) { - _cluster->xread(key, lastID, std::chrono::seconds(1), 0, std::inserter(result, result.end())); - } - else { - _redis->xread(key, lastID, std::chrono::seconds(1), 0, std::inserter(result, result.end())); - } - if (! result.empty()) { - for (auto element : result) { -#ifdef REDIS_TRACE - fprintf(stdout, "Received notification from: %s\n", element.first.c_str()); -#endif - for (auto rec : element.second) { - std::string id = rec.first; - auto attrs = rec.second; -#ifdef REDIS_TRACE - fprintf(stdout, "Record ID: %s\n", id.c_str()); - fprintf(stdout, "attrs len: %lu\n", attrs.size()); -#endif - for (auto a : attrs) { -#ifdef REDIS_TRACE - fprintf(stdout, "key: %s\nvalue: %s\n", a.first.c_str(), a.second.c_str()); -#endif - try { - tmp = json::parse(a.second); - json& ov = tmp["old_val"]; - json& nv = tmp["new_val"]; - json oldConfig, newConfig; - if (ov.is_object()) - oldConfig = ov; - if (nv.is_object()) - newConfig = nv; - if (oldConfig.is_object() || newConfig.is_object()) { - _memberChanged(oldConfig, newConfig, (this->_ready >= 2)); - } - } - catch (...) { - fprintf(stderr, "json parse error in _membersWatcher_Redis: %s\n", a.second.c_str()); - } - } - if (_rc->clusterMode) { - _cluster->xdel(key, id); - } - else { - _redis->xdel(key, id); - } - lastID = id; - Metrics::redis_mem_notification++; - } - } - } - } - catch (sw::redis::Error& e) { - span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "Error in Redis members watcher: %s\n", e.what()); - } - } - fprintf(stderr, "membersWatcher ended\n"); -} - -void CV1::networksDbWatcher() -{ - if (_rc) { - _networksWatcher_Redis(); - } - else { - _networksWatcher_Postgres(); - } - - if (_run == 1) { - fprintf( - stderr, "ERROR: %s networksDbWatcher should still be running! Exiting Controller.\n", - _myAddressStr.c_str()); - exit(8); - } - fprintf(stderr, "Exited networksDbWatcher\n"); -} - -void CV1::_networksWatcher_Postgres() -{ - std::string stream = "network_" + _myAddressStr; - - fprintf(stderr, "Listening to member stream: %s\n", stream.c_str()); - - auto c = _pool->borrow(); - - NetworkNotificationReceiver n(this, *c->c, stream); - - while (_run == 1) { - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv1"); - auto span = tracer->StartSpan("cv1::_networksWatcher_Postgres"); - auto scope = tracer->WithActiveSpan(span); - - c->c->await_notification(5, 0); - } -} - -void CV1::_networksWatcher_Redis() -{ - char buf[11] = { 0 }; - std::string key = "network-stream:{" + std::string(_myAddress.toString(buf)) + "}"; - std::string lastID = "0"; - while (_run == 1) { - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv1"); - auto span = tracer->StartSpan("cv1::_networksWatcher_Redis"); - auto scope = tracer->WithActiveSpan(span); - - try { - json tmp; - std::unordered_map result; - if (_rc->clusterMode) { - _cluster->xread(key, lastID, std::chrono::seconds(1), 0, std::inserter(result, result.end())); - } - else { - _redis->xread(key, lastID, std::chrono::seconds(1), 0, std::inserter(result, result.end())); - } - - if (! result.empty()) { - for (auto element : result) { -#ifdef REDIS_TRACE - fprintf(stdout, "Received notification from: %s\n", element.first.c_str()); -#endif - for (auto rec : element.second) { - std::string id = rec.first; - auto attrs = rec.second; -#ifdef REDIS_TRACE - fprintf(stdout, "Record ID: %s\n", id.c_str()); - fprintf(stdout, "attrs len: %lu\n", attrs.size()); -#endif - for (auto a : attrs) { -#ifdef REDIS_TRACE - fprintf(stdout, "key: %s\nvalue: %s\n", a.first.c_str(), a.second.c_str()); -#endif - try { - tmp = json::parse(a.second); - json& ov = tmp["old_val"]; - json& nv = tmp["new_val"]; - json oldConfig, newConfig; - if (ov.is_object()) - oldConfig = ov; - if (nv.is_object()) - newConfig = nv; - if (oldConfig.is_object() || newConfig.is_object()) { - _networkChanged(oldConfig, newConfig, (this->_ready >= 2)); - } - } - catch (std::exception& e) { - fprintf( - stderr, "json parse error in networkWatcher_Redis: what: %s json: %s\n", e.what(), - a.second.c_str()); - } - } - if (_rc->clusterMode) { - _cluster->xdel(key, id); - } - else { - _redis->xdel(key, id); - } - lastID = id; - } - Metrics::redis_net_notification++; - } - } - } - catch (sw::redis::Error& e) { - span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "Error in Redis networks watcher: %s\n", e.what()); - } - } - fprintf(stderr, "networksWatcher ended\n"); -} - -void CV1::commitThread() -{ - fprintf(stderr, "%s: commitThread start\n", _myAddressStr.c_str()); - std::pair qitem; - while (_commitQueue.get(qitem) && (_run == 1)) { - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv1"); - auto span = tracer->StartSpan("cv1::commitThread"); - auto scope = tracer->WithActiveSpan(span); - - // fprintf(stderr, "commitThread tick\n"); - if (! qitem.first.is_object()) { - fprintf(stderr, "not an object\n"); - continue; - } - - std::shared_ptr c; - try { - c = _pool->borrow(); - } - catch (std::exception& e) { - fprintf(stderr, "ERROR: %s\n", e.what()); - continue; - } - - if (! c) { - fprintf(stderr, "Error getting database connection\n"); - continue; - } - - Metrics::pgsql_commit_ticks++; - try { - nlohmann::json& config = (qitem.first); - const std::string objtype = config["objtype"]; - if (objtype == "member") { - auto mspan = tracer->StartSpan("cv1::commitThread::member"); - auto mscope = tracer->WithActiveSpan(mspan); - - // fprintf(stderr, "%s: commitThread: member\n", _myAddressStr.c_str()); - std::string memberId; - std::string networkId; - try { - pqxx::work w(*c->c); - - memberId = config["id"]; - networkId = config["nwid"]; - - std::string target = "NULL"; - if (! config["remoteTraceTarget"].is_null()) { - target = config["remoteTraceTarget"]; - } - - pqxx::row nwrow = w.exec_params1("SELECT COUNT(id) FROM ztc_network WHERE id = $1", networkId); - int nwcount = nwrow[0].as(); - - if (nwcount != 1) { - fprintf(stderr, "network %s does not exist. skipping member upsert\n", networkId.c_str()); - w.abort(); - _pool->unborrow(c); - continue; - } - - pqxx::row mrow = w.exec_params1( - "SELECT COUNT(id) FROM ztc_member WHERE id = $1 AND network_id = $2", memberId, networkId); - int membercount = mrow[0].as(); - - bool isNewMember = false; - if (membercount == 0) { - // new member - isNewMember = true; - pqxx::result res = w.exec_params0( - "INSERT INTO ztc_member (id, network_id, active_bridge, authorized, capabilities, " - "identity, last_authorized_time, last_deauthorized_time, no_auto_assign_ips, " - "remote_trace_level, remote_trace_target, revision, tags, v_major, v_minor, v_rev, " - "v_proto) " - "VALUES ($1, $2, $3, $4, $5, $6, " - "TO_TIMESTAMP($7::double precision/1000), TO_TIMESTAMP($8::double precision/1000), " - "$9, $10, $11, $12, $13, $14, $15, $16, $17)", - memberId, networkId, (bool)config["activeBridge"], (bool)config["authorized"], - OSUtils::jsonDump(config["capabilities"], -1), OSUtils::jsonString(config["identity"], ""), - (uint64_t)config["lastAuthorizedTime"], (uint64_t)config["lastDeauthorizedTime"], - (bool)config["noAutoAssignIps"], (int)config["remoteTraceLevel"], target, - (uint64_t)config["revision"], OSUtils::jsonDump(config["tags"], -1), (int)config["vMajor"], - (int)config["vMinor"], (int)config["vRev"], (int)config["vProto"]); - } - else { - // existing member - pqxx::result res = w.exec_params0( - "UPDATE ztc_member " - "SET active_bridge = $3, authorized = $4, capabilities = $5, identity = $6, " - "last_authorized_time = TO_TIMESTAMP($7::double precision/1000), " - "last_deauthorized_time = TO_TIMESTAMP($8::double precision/1000), " - "no_auto_assign_ips = $9, remote_trace_level = $10, remote_trace_target= $11, " - "revision = $12, tags = $13, v_major = $14, v_minor = $15, v_rev = $16, v_proto = $17 " - "WHERE id = $1 AND network_id = $2", - memberId, networkId, (bool)config["activeBridge"], (bool)config["authorized"], - OSUtils::jsonDump(config["capabilities"], -1), OSUtils::jsonString(config["identity"], ""), - (uint64_t)config["lastAuthorizedTime"], (uint64_t)config["lastDeauthorizedTime"], - (bool)config["noAutoAssignIps"], (int)config["remoteTraceLevel"], target, - (uint64_t)config["revision"], OSUtils::jsonDump(config["tags"], -1), (int)config["vMajor"], - (int)config["vMinor"], (int)config["vRev"], (int)config["vProto"]); - } - - if (! isNewMember) { - pqxx::result res = w.exec_params0( - "DELETE FROM ztc_member_ip_assignment WHERE member_id = $1 AND network_id = $2", memberId, - networkId); - } - - std::vector assignments; - bool ipAssignError = false; - for (auto i = config["ipAssignments"].begin(); i != config["ipAssignments"].end(); ++i) { - std::string addr = *i; - - if (std::find(assignments.begin(), assignments.end(), addr) != assignments.end()) { - continue; - } - - pqxx::result res = w.exec_params0( - "INSERT INTO ztc_member_ip_assignment (member_id, network_id, address) VALUES ($1, $2, $3) " - "ON CONFLICT (network_id, member_id, address) DO NOTHING", - memberId, networkId, addr); - - assignments.push_back(addr); - } - if (ipAssignError) { - fprintf(stderr, "%s: ipAssignError\n", _myAddressStr.c_str()); - w.abort(); - _pool->unborrow(c); - c.reset(); - continue; - } - - w.commit(); - - if (_smee != NULL && isNewMember) { - pqxx::row row = w.exec_params1("SELECT " - " count(h.hook_id) " - "FROM " - " ztc_hook h " - " INNER JOIN ztc_org o ON o.org_id = h.org_id " - " INNER JOIN ztc_network n ON n.owner_id = o.owner_id " - " WHERE " - "n.id = $1 ", - networkId); - int64_t hookCount = row[0].as(); - if (hookCount > 0) { - notifyNewMember(networkId, memberId); - } - } - - const uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); - const uint64_t memberidInt = OSUtils::jsonIntHex(config["id"], 0ULL); - if (nwidInt && memberidInt) { - nlohmann::json nwOrig; - nlohmann::json memOrig; - - nlohmann::json memNew(config); - - get(nwidInt, nwOrig, memberidInt, memOrig); - - _memberChanged(memOrig, memNew, qitem.second); - } - else { - fprintf( - stderr, "%s: Can't notify of change. Error parsing nwid or memberid: %llu-%llu\n", - _myAddressStr.c_str(), (unsigned long long)nwidInt, (unsigned long long)memberidInt); - } - } - catch (std::exception& e) { - fprintf( - stderr, "%s ERROR: Error updating member %s-%s: %s\n", _myAddressStr.c_str(), networkId.c_str(), - memberId.c_str(), e.what()); - mspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - } - } - else if (objtype == "network") { - auto nspan = tracer->StartSpan("cv1::commitThread::network"); - auto nscope = tracer->WithActiveSpan(nspan); - - try { - // fprintf(stderr, "%s: commitThread: network\n", _myAddressStr.c_str()); - pqxx::work w(*c->c); - - std::string id = config["id"]; - std::string remoteTraceTarget = ""; - if (! config["remoteTraceTarget"].is_null()) { - remoteTraceTarget = config["remoteTraceTarget"]; - } - std::string rulesSource = ""; - if (config["rulesSource"].is_string()) { - rulesSource = config["rulesSource"]; - } - - // This ugly query exists because when we want to mirror networks to/from - // another data store (e.g. FileDB or LFDB) it is possible to get a network - // that doesn't exist in Central's database. This does an upsert and sets - // the owner_id to the "first" global admin in the user DB if the record - // did not previously exist. If the record already exists owner_id is left - // unchanged, so owner_id should be left out of the update clause. - pqxx::result res = w.exec_params0( - "INSERT INTO ztc_network (id, creation_time, owner_id, controller_id, capabilities, " - "enable_broadcast, " - "last_modified, mtu, multicast_limit, name, private, " - "remote_trace_level, remote_trace_target, rules, rules_source, " - "tags, v4_assign_mode, v6_assign_mode, sso_enabled) VALUES (" - "$1, TO_TIMESTAMP($5::double precision/1000), " - "(SELECT user_id AS owner_id FROM ztc_global_permissions WHERE authorize = true AND del = true " - "AND modify = true AND read = true LIMIT 1)," - "$2, $3, $4, TO_TIMESTAMP($5::double precision/1000), " - "$6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17) " - "ON CONFLICT (id) DO UPDATE set controller_id = EXCLUDED.controller_id, " - "capabilities = EXCLUDED.capabilities, enable_broadcast = EXCLUDED.enable_broadcast, " - "last_modified = EXCLUDED.last_modified, mtu = EXCLUDED.mtu, " - "multicast_limit = EXCLUDED.multicast_limit, name = EXCLUDED.name, " - "private = EXCLUDED.private, remote_trace_level = EXCLUDED.remote_trace_level, " - "remote_trace_target = EXCLUDED.remote_trace_target, rules = EXCLUDED.rules, " - "rules_source = EXCLUDED.rules_source, tags = EXCLUDED.tags, " - "v4_assign_mode = EXCLUDED.v4_assign_mode, v6_assign_mode = EXCLUDED.v6_assign_mode, " - "sso_enabled = EXCLUDED.sso_enabled", - id, _myAddressStr, OSUtils::jsonDump(config["capabilities"], -1), - (bool)config["enableBroadcast"], OSUtils::now(), (int)config["mtu"], - (int)config["multicastLimit"], OSUtils::jsonString(config["name"], ""), (bool)config["private"], - (int)config["remoteTraceLevel"], remoteTraceTarget, OSUtils::jsonDump(config["rules"], -1), - rulesSource, OSUtils::jsonDump(config["tags"], -1), - OSUtils::jsonDump(config["v4AssignMode"], -1), OSUtils::jsonDump(config["v6AssignMode"], -1), - OSUtils::jsonBool(config["ssoEnabled"], false)); - - res = w.exec_params0("DELETE FROM ztc_network_assignment_pool WHERE network_id = $1", id); - - auto pool = config["ipAssignmentPools"]; - bool err = false; - for (auto i = pool.begin(); i != pool.end(); ++i) { - std::string start = (*i)["ipRangeStart"]; - std::string end = (*i)["ipRangeEnd"]; - - res = w.exec_params0( - "INSERT INTO ztc_network_assignment_pool (network_id, ip_range_start, ip_range_end) " - "VALUES ($1, $2, $3)", - id, start, end); - } - - res = w.exec_params0("DELETE FROM ztc_network_route WHERE network_id = $1", id); - - auto routes = config["routes"]; - err = false; - for (auto i = routes.begin(); i != routes.end(); ++i) { - std::string t = (*i)["target"]; - std::vector target; - std::istringstream f(t); - std::string s; - while (std::getline(f, s, '/')) { - target.push_back(s); - } - if (target.empty() || target.size() != 2) { - continue; - } - std::string targetAddr = target[0]; - std::string targetBits = target[1]; - std::string via = "NULL"; - if (! (*i)["via"].is_null()) { - via = (*i)["via"]; - } - - res = w.exec_params0( - "INSERT INTO ztc_network_route (network_id, address, bits, via) VALUES ($1, $2, $3, $4)", - id, targetAddr, targetBits, (via == "NULL" ? NULL : via.c_str())); - } - if (err) { - fprintf(stderr, "%s: route add error\n", _myAddressStr.c_str()); - w.abort(); - _pool->unborrow(c); - continue; - } - - auto dns = config["dns"]; - std::string domain = dns["domain"]; - std::stringstream servers; - servers << "{"; - for (auto j = dns["servers"].begin(); j < dns["servers"].end(); ++j) { - servers << *j; - if ((j + 1) != dns["servers"].end()) { - servers << ","; - } - } - servers << "}"; - - std::string s = servers.str(); - - res = w.exec_params0( - "INSERT INTO ztc_network_dns (network_id, domain, servers) VALUES ($1, $2, $3) ON CONFLICT " - "(network_id) DO UPDATE SET domain = EXCLUDED.domain, servers = EXCLUDED.servers", - id, domain, s); - - w.commit(); - - const uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); - if (nwidInt) { - nlohmann::json nwOrig; - nlohmann::json nwNew(config); - - get(nwidInt, nwOrig); - - _networkChanged(nwOrig, nwNew, qitem.second); - } - else { - fprintf( - stderr, "%s: Can't notify network changed: %llu\n", _myAddressStr.c_str(), - (unsigned long long)nwidInt); - } - } - catch (std::exception& e) { - nspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "%s ERROR: Error updating network: %s\n", _myAddressStr.c_str(), e.what()); - } - if (_redisMemberStatus) { - try { - std::string id = config["id"]; - std::string controllerId = _myAddressStr.c_str(); - std::string key = "networks:{" + controllerId + "}"; - if (_rc->clusterMode) { - _cluster->sadd(key, id); - } - else { - _redis->sadd(key, id); - } - } - catch (sw::redis::Error& e) { - nspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "ERROR: Error adding network to Redis: %s\n", e.what()); - } - } - } - else if (objtype == "_delete_network") { - auto dspan = tracer->StartSpan("cv1::commitThread::_delete_network"); - auto dscope = tracer->WithActiveSpan(dspan); - - // fprintf(stderr, "%s: commitThread: delete network\n", _myAddressStr.c_str()); - try { - pqxx::work w(*c->c); - - std::string networkId = config["nwid"]; - - pqxx::result res = w.exec_params0("UPDATE ztc_network SET deleted = true WHERE id = $1", networkId); - - w.commit(); - } - catch (std::exception& e) { - dspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "%s ERROR: Error deleting network: %s\n", _myAddressStr.c_str(), e.what()); - } - if (_redisMemberStatus) { - try { - std::string id = config["id"]; - std::string controllerId = _myAddressStr.c_str(); - std::string key = "networks:{" + controllerId + "}"; - if (_rc->clusterMode) { - _cluster->srem(key, id); - _cluster->del("network-nodes-online:{" + controllerId + "}:" + id); - } - else { - _redis->srem(key, id); - _redis->del("network-nodes-online:{" + controllerId + "}:" + id); - } - } - catch (sw::redis::Error& e) { - dspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "ERROR: Error adding network to Redis: %s\n", e.what()); - } - } - } - else if (objtype == "_delete_member") { - auto mspan = tracer->StartSpan("cv1::commitThread::_delete_member"); - auto mscope = tracer->WithActiveSpan(mspan); - - // fprintf(stderr, "%s commitThread: delete member\n", _myAddressStr.c_str()); - try { - pqxx::work w(*c->c); - - std::string memberId = config["id"]; - std::string networkId = config["nwid"]; - - pqxx::result res = w.exec_params0( - "UPDATE ztc_member SET hidden = true, deleted = true WHERE id = $1 AND network_id = $2", - memberId, networkId); - - w.commit(); - } - catch (std::exception& e) { - mspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "%s ERROR: Error deleting member: %s\n", _myAddressStr.c_str(), e.what()); - } - if (_redisMemberStatus) { - try { - std::string memberId = config["id"]; - std::string networkId = config["nwid"]; - std::string controllerId = _myAddressStr.c_str(); - std::string key = "network-nodes-all:{" + controllerId + "}:" + networkId; - if (_rc->clusterMode) { - _cluster->srem(key, memberId); - _cluster->del("member:{" + controllerId + "}:" + networkId + ":" + memberId); - } - else { - _redis->srem(key, memberId); - _redis->del("member:{" + controllerId + "}:" + networkId + ":" + memberId); - } - } - catch (sw::redis::Error& e) { - mspan->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "ERROR: Error deleting member from Redis: %s\n", e.what()); - } - } - } - else { - fprintf(stderr, "%s ERROR: unknown objtype\n", _myAddressStr.c_str()); - } - } - catch (std::exception& e) { - span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - fprintf(stderr, "%s ERROR: Error getting objtype: %s\n", _myAddressStr.c_str(), e.what()); - } - _pool->unborrow(c); - c.reset(); - } - - fprintf(stderr, "%s commitThread finished\n", _myAddressStr.c_str()); -} - -void CV1::notifyNewMember(const std::string& networkID, const std::string& memberID) -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv1"); - auto span = tracer->StartSpan("cv1::notifyNewMember"); - auto scope = tracer->WithActiveSpan(span); - - rustybits::smee_client_notify_network_joined(_smee, networkID.c_str(), memberID.c_str()); -} - -void CV1::onlineNotificationThread() -{ - waitForReady(); - if (_redisMemberStatus) { - onlineNotification_Redis(); - } - else { - onlineNotification_Postgres(); - } -} - -/** - * ONLY UNCOMMENT FOR TEMPORARY DB MAINTENANCE - * - * This define temporarily turns off writing to the member status table - * so it can be reindexed when the indexes get too large. - */ - -// #define DISABLE_MEMBER_STATUS 1 - -void CV1::onlineNotification_Postgres() -{ - _connected = 1; - - nlohmann::json jtmp1, jtmp2; - while (_run == 1) { - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv1"); - auto span = tracer->StartSpan("cv1::onlineNotification_Postgres"); - auto scope = tracer->WithActiveSpan(span); - - auto c = _pool->borrow(); - auto c2 = _pool->borrow(); - try { - fprintf(stderr, "%s onlineNotification_Postgres\n", _myAddressStr.c_str()); - std::unordered_map, NodeOnlineRecord, _PairHasher> lastOnline; - { - std::lock_guard l(_lastOnline_l); - lastOnline.swap(_lastOnline); - } - -#ifndef DISABLE_MEMBER_STATUS - pqxx::work w(*c->c); - pqxx::work w2(*c2->c); - - fprintf(stderr, "online notification tick\n"); - - bool firstRun = true; - bool memberAdded = false; - int updateCount = 0; - - pqxx::pipeline pipe(w); - - for (auto i = lastOnline.begin(); i != lastOnline.end(); ++i) { - updateCount += 1; - uint64_t nwid_i = i->first.first; - char nwidTmp[64]; - char memTmp[64]; - char ipTmp[64]; - OSUtils::ztsnprintf(nwidTmp, sizeof(nwidTmp), "%.16llx", nwid_i); - OSUtils::ztsnprintf(memTmp, sizeof(memTmp), "%.10llx", i->first.second); - - if (! get(nwid_i, jtmp1, i->first.second, jtmp2)) { - continue; // skip non existent networks/members - } - - std::string networkId(nwidTmp); - std::string memberId(memTmp); - - try { - pqxx::row r = w2.exec_params1( - "SELECT id, network_id FROM ztc_member WHERE network_id = $1 AND id = $2", networkId, memberId); - } - catch (pqxx::unexpected_rows& e) { - continue; - } - - int64_t ts = i->second.lastSeen; - std::string ipAddr = i->second.physicalAddress.toIpString(ipTmp); - std::string timestamp = std::to_string(ts); - std::string osArch = i->second.osArch; - std::vector osArchSplit = split(osArch, '/'); - std::string os = "unknown"; - std::string arch = "unknown"; - if (osArchSplit.size() == 2) { - os = osArchSplit[0]; - arch = osArchSplit[1]; - } - - std::stringstream memberUpdate; - memberUpdate - << "INSERT INTO ztc_member_status (network_id, member_id, address, last_updated, os, arch) VALUES " - << "('" << networkId << "', '" << memberId << "', "; - if (ipAddr.empty()) { - memberUpdate << "NULL, "; - } - else { - memberUpdate << "'" << ipAddr << "', "; - } - memberUpdate << "TO_TIMESTAMP(" << timestamp << "::double precision/1000), " - << "'" << os << "', " - << "'" << arch << "'" - << ") " - << " ON CONFLICT (network_id, member_id) DO UPDATE SET address = EXCLUDED.address, " - "last_updated = EXCLUDED.last_updated, " - << "os = EXCLUDED.os, arch = EXCLUDED.arch"; - - pipe.insert(memberUpdate.str()); - Metrics::pgsql_node_checkin++; - } - while (! pipe.empty()) { - pipe.retrieve(); - } - - pipe.complete(); - w.commit(); - fprintf(stderr, "%s: Updated online status of %d members\n", _myAddressStr.c_str(), updateCount); -#endif - } - catch (std::exception& e) { - fprintf(stderr, "%s: error in onlinenotification thread: %s\n", _myAddressStr.c_str(), e.what()); - } - _pool->unborrow(c2); - _pool->unborrow(c); - - ConnectionPoolStats stats = _pool->get_stats(); - fprintf( - stderr, "%s pool stats: in use size: %llu, available size: %llu, total: %llu\n", _myAddressStr.c_str(), - stats.borrowed_size, stats.pool_size, (stats.borrowed_size + stats.pool_size)); - - span->End(); - - std::this_thread::sleep_for(std::chrono::seconds(10)); - } - fprintf(stderr, "%s: Fell out of run loop in onlineNotificationThread\n", _myAddressStr.c_str()); - if (_run == 1) { - fprintf( - stderr, "ERROR: %s onlineNotificationThread should still be running! Exiting Controller.\n", - _myAddressStr.c_str()); - exit(6); - } -} - -void CV1::onlineNotification_Redis() -{ - _connected = 1; - - char buf[11] = { 0 }; - std::string controllerId = std::string(_myAddress.toString(buf)); - - while (_run == 1) { - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv1"); - auto span = tracer->StartSpan("cv1::onlineNotification_Redis"); - auto scope = tracer->WithActiveSpan(span); - - fprintf(stderr, "onlineNotification tick\n"); - auto start = std::chrono::high_resolution_clock::now(); - uint64_t count = 0; - - std::unordered_map, NodeOnlineRecord, _PairHasher> lastOnline; - { - std::lock_guard l(_lastOnline_l); - lastOnline.swap(_lastOnline); - } - try { - if (! lastOnline.empty()) { - if (_rc->clusterMode) { - auto tx = _cluster->transaction(controllerId, true, false); - count = _doRedisUpdate(tx, controllerId, lastOnline); - } - else { - auto tx = _redis->transaction(true, false); - count = _doRedisUpdate(tx, controllerId, lastOnline); - } - } - } - catch (sw::redis::Error& e) { - fprintf(stderr, "Error in online notification thread (redis): %s\n", e.what()); - } - - auto end = std::chrono::high_resolution_clock::now(); - auto dur = std::chrono::duration_cast(end - start); - auto total = dur.count(); - - fprintf(stderr, "onlineNotification ran in %llu ms\n", total); - span->End(); - - std::this_thread::sleep_for(std::chrono::seconds(5)); - } -} - -uint64_t CV1::_doRedisUpdate( - sw::redis::Transaction& tx, - std::string& controllerId, - std::unordered_map, NodeOnlineRecord, _PairHasher>& lastOnline) -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv1"); - auto span = tracer->StartSpan("cv1::_doRedisUpdate"); - auto scope = tracer->WithActiveSpan(span); - - nlohmann::json jtmp1, jtmp2; - uint64_t count = 0; - for (auto i = lastOnline.begin(); i != lastOnline.end(); ++i) { - uint64_t nwid_i = i->first.first; - uint64_t memberid_i = i->first.second; - char nwidTmp[64]; - char memTmp[64]; - char ipTmp[64]; - OSUtils::ztsnprintf(nwidTmp, sizeof(nwidTmp), "%.16llx", nwid_i); - OSUtils::ztsnprintf(memTmp, sizeof(memTmp), "%.10llx", memberid_i); - - if (! get(nwid_i, jtmp1, memberid_i, jtmp2)) { - continue; // skip non existent members/networks - } - - std::string networkId(nwidTmp); - std::string memberId(memTmp); - - int64_t ts = i->second.lastSeen; - std::string ipAddr = i->second.physicalAddress.toIpString(ipTmp); - std::string timestamp = std::to_string(ts); - std::string osArch = i->second.osArch; - std::vector osArchSplit = split(osArch, '/'); - std::string os = "unknown"; - std::string arch = "unknown"; - if (osArchSplit.size() == 2) { - os = osArchSplit[0]; - arch = osArchSplit[1]; - } - - std::unordered_map record = { { "id", memberId }, - { "address", ipAddr }, - { "last_updated", std::to_string(ts) }, - { "os", os }, - { "arch", arch } }; - tx.zadd("nodes-online:{" + controllerId + "}", memberId, ts) - .zadd("nodes-online2:{" + controllerId + "}", networkId + "-" + memberId, ts) - .zadd("network-nodes-online:{" + controllerId + "}:" + networkId, memberId, ts) - .zadd("active-networks:{" + controllerId + "}", networkId, ts) - .sadd("network-nodes-all:{" + controllerId + "}:" + networkId, memberId) - .hmset("member:{" + controllerId + "}:" + networkId + ":" + memberId, record.begin(), record.end()); - ++count; - Metrics::redis_node_checkin++; - } - - // expire records from all-nodes and network-nodes member list - uint64_t expireOld = OSUtils::now() - 300000; - - tx.zremrangebyscore( - "nodes-online:{" + controllerId + "}", - sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); - tx.zremrangebyscore( - "nodes-online2:{" + controllerId + "}", - sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); - tx.zremrangebyscore( - "active-networks:{" + controllerId + "}", - sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); - { - std::shared_lock l(_networks_l); - for (const auto& it : _networks) { - uint64_t nwid_i = it.first; - char nwidTmp[64]; - OSUtils::ztsnprintf(nwidTmp, sizeof(nwidTmp), "%.16llx", nwid_i); - tx.zremrangebyscore( - "network-nodes-online:{" + controllerId + "}:" + nwidTmp, - sw::redis::RightBoundedInterval(expireOld, sw::redis::BoundType::LEFT_OPEN)); - } - } - tx.exec(); - fprintf(stderr, "%s: Updated online status of %d members\n", _myAddressStr.c_str(), count); - - return count; -} - -#endif // ZT_CONTROLLER_USE_LIBPQ diff --git a/nonfree/controller/CV1.hpp b/nonfree/controller/CV1.hpp deleted file mode 100644 index 2552be3588..0000000000 --- a/nonfree/controller/CV1.hpp +++ /dev/null @@ -1,143 +0,0 @@ -/* (c) ZeroTier, Inc. - * See LICENSE.txt in nonfree/ - */ - -#include "DB.hpp" - -#ifdef ZT_CONTROLLER_USE_LIBPQ - -#ifndef ZT_CONTROLLER_CV1_HPP -#define ZT_CONTROLLER_CV1_HPP - -#define ZT_CENTRAL_CONTROLLER_COMMIT_THREADS 4 - -#include "../../node/Metrics.hpp" -#include "ConnectionPool.hpp" -#include "PostgreSQL.hpp" - -#include -#include -#include - -namespace rustybits { -struct SmeeClient; -} - -namespace ZeroTier { - -struct RedisConfig; - -/** - * A controller database driver that talks to PostgreSQL - * - * This is for use with ZeroTier Central. Others are free to build and use it - * but be aware that we might change it at any time. - */ -class CV1 : public DB { - friend class MemberNotificationReceiver; - friend class NetworkNotificationReceiver; - - public: - CV1(const Identity& myId, const char* path, int listenPort, RedisConfig* rc); - virtual ~CV1(); - - virtual bool waitForReady(); - virtual bool isReady(); - virtual bool save(nlohmann::json& record, bool notifyListeners); - virtual void eraseNetwork(const uint64_t networkId); - virtual void eraseMember(const uint64_t networkId, const uint64_t memberId); - virtual void nodeIsOnline(const uint64_t networkId, const uint64_t memberId, const InetAddress& physicalAddress); - virtual void nodeIsOnline( - const uint64_t networkId, - const uint64_t memberId, - const InetAddress& physicalAddress, - const char* osArch); - virtual AuthInfo getSSOAuthInfo(const nlohmann::json& member, const std::string& redirectURL); - - virtual bool ready() - { - return _ready == 2; - } - - virtual void _memberChanged(nlohmann::json& old, nlohmann::json& memberConfig, bool notifyListeners) - { - DB::_memberChanged(old, memberConfig, notifyListeners); - } - - virtual void _networkChanged(nlohmann::json& old, nlohmann::json& networkConfig, bool notifyListeners) - { - DB::_networkChanged(old, networkConfig, notifyListeners); - } - - protected: - struct _PairHasher { - inline std::size_t operator()(const std::pair& p) const - { - return (std::size_t)(p.first ^ p.second); - } - }; - - private: - void initializeNetworks(); - void initializeMembers(); - void heartbeat(); - void membersDbWatcher(); - void _membersWatcher_Postgres(); - void networksDbWatcher(); - void _networksWatcher_Postgres(); - - void _membersWatcher_Redis(); - void _networksWatcher_Redis(); - - void commitThread(); - void onlineNotificationThread(); - void onlineNotification_Postgres(); - void onlineNotification_Redis(); - uint64_t _doRedisUpdate( - sw::redis::Transaction& tx, - std::string& controllerId, - std::unordered_map, NodeOnlineRecord, _PairHasher>& lastOnline); - - void configureSmee(); - void notifyNewMember(const std::string& networkID, const std::string& memberID); - - enum OverrideMode { ALLOW_PGBOUNCER_OVERRIDE = 0, NO_OVERRIDE = 1 }; - - std::shared_ptr > _pool; - - const Identity _myId; - const Address _myAddress; - std::string _myAddressStr; - std::string _connString; - - BlockingQueue > _commitQueue; - - std::thread _heartbeatThread; - std::thread _membersDbWatcher; - std::thread _networksDbWatcher; - std::thread _commitThread[ZT_CENTRAL_CONTROLLER_COMMIT_THREADS]; - std::thread _onlineNotificationThread; - - std::unordered_map, NodeOnlineRecord, _PairHasher> _lastOnline; - - mutable std::mutex _lastOnline_l; - mutable std::mutex _readyLock; - std::atomic _ready, _connected, _run; - mutable volatile bool _waitNoticePrinted; - - int _listenPort; - uint8_t _ssoPsk[48]; - - RedisConfig* _rc; - std::shared_ptr _redis; - std::shared_ptr _cluster; - bool _redisMemberStatus; - - rustybits::SmeeClient* _smee; -}; - -} // namespace ZeroTier - -#endif // ZT_CONTROLLER_CV1_HPP - -#endif // ZT_CONTROLLER_USE_LIBPQ diff --git a/nonfree/controller/CV2.cpp b/nonfree/controller/CV2.cpp deleted file mode 100644 index 8e2d6cdf97..0000000000 --- a/nonfree/controller/CV2.cpp +++ /dev/null @@ -1,1264 +0,0 @@ -/* (c) ZeroTier, Inc. - * See LICENSE.txt in nonfree/ - */ - -#ifdef ZT_CONTROLLER_USE_LIBPQ - -#include "CV2.hpp" - -#include "../../node/Constants.hpp" -#include "../../node/SHA512.hpp" -#include "../../version.h" -#include "CtlUtil.hpp" -#include "EmbeddedNetworkController.hpp" -#include "opentelemetry/trace/provider.h" - -#include -#include -#include -#include -#include -#include - -using json = nlohmann::json; - -namespace { - -} - -using namespace ZeroTier; - -CV2::CV2(const Identity& myId, const char* path, int listenPort) - : DB() - , _pool() - , _myId(myId) - , _myAddress(myId.address()) - , _ready(0) - , _connected(1) - , _run(1) - , _waitNoticePrinted(false) - , _listenPort(listenPort) -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv2"); - auto span = tracer->StartSpan("cv2::CV2"); - auto scope = tracer->WithActiveSpan(span); - - rustybits::init_async_runtime(); - - fprintf(stderr, "CV2::CV2\n"); - char myAddress[64]; - _myAddressStr = myId.address().toString(myAddress); - - _connString = std::string(path); - - auto f = std::make_shared(_connString); - _pool = - std::make_shared >(15, 5, std::static_pointer_cast(f)); - - memset(_ssoPsk, 0, sizeof(_ssoPsk)); - char* const ssoPskHex = getenv("ZT_SSO_PSK"); -#ifdef ZT_TRACE - fprintf(stderr, "ZT_SSO_PSK: %s\n", ssoPskHex); -#endif - if (ssoPskHex) { - // SECURITY: note that ssoPskHex will always be null-terminated if libc actually - // returns something non-NULL. If the hex encodes something shorter than 48 bytes, - // it will be padded at the end with zeroes. If longer, it'll be truncated. - Utils::unhex(ssoPskHex, _ssoPsk, sizeof(_ssoPsk)); - } - - _readyLock.lock(); - - fprintf( - stderr, "[%s] NOTICE: %.10llx controller PostgreSQL waiting for initial data download..." ZT_EOL_S, - ::_timestr(), (unsigned long long)_myAddress.toInt()); - _waitNoticePrinted = true; - - initializeNetworks(); - initializeMembers(); - - _heartbeatThread = std::thread(&CV2::heartbeat, this); - _membersDbWatcher = std::thread(&CV2::membersDbWatcher, this); - _networksDbWatcher = std::thread(&CV2::networksDbWatcher, this); - for (int i = 0; i < ZT_CENTRAL_CONTROLLER_COMMIT_THREADS; ++i) { - _commitThread[i] = std::thread(&CV2::commitThread, this); - } - _onlineNotificationThread = std::thread(&CV2::onlineNotificationThread, this); -} - -CV2::~CV2() -{ - rustybits::shutdown_async_runtime(); - - _run = 0; - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - - _heartbeatThread.join(); - _membersDbWatcher.join(); - _networksDbWatcher.join(); - _commitQueue.stop(); - for (int i = 0; i < ZT_CENTRAL_CONTROLLER_COMMIT_THREADS; ++i) { - _commitThread[i].join(); - } - _onlineNotificationThread.join(); -} - -bool CV2::waitForReady() -{ - while (_ready < 2) { - _readyLock.lock(); - _readyLock.unlock(); - } - return true; -} - -bool CV2::isReady() -{ - return (_ready == 2) && _connected; -} - -void CV2::_memberChanged(nlohmann::json& old, nlohmann::json& memberConfig, bool notifyListeners) -{ - DB::_memberChanged(old, memberConfig, notifyListeners); -} - -void CV2::_networkChanged(nlohmann::json& old, nlohmann::json& networkConfig, bool notifyListeners) -{ - DB::_networkChanged(old, networkConfig, notifyListeners); -} - -bool CV2::save(nlohmann::json& record, bool notifyListeners) -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv2"); - auto span = tracer->StartSpan("cv2::save"); - auto scope = tracer->WithActiveSpan(span); - - bool modified = false; - try { - if (! record.is_object()) { - fprintf(stderr, "record is not an object?!?\n"); - return false; - } - const std::string objtype = record["objtype"]; - if (objtype == "network") { - auto nspan = tracer->StartSpan("cv2::save::network"); - auto nscope = tracer->WithActiveSpan(nspan); - - // fprintf(stderr, "network save\n"); - const uint64_t nwid = OSUtils::jsonIntHex(record["id"], 0ULL); - if (nwid) { - nlohmann::json old; - get(nwid, old); - if ((! old.is_object()) || (! _compareRecords(old, record))) { - record["revision"] = OSUtils::jsonInt(record["revision"], 0ULL) + 1ULL; - _commitQueue.post(std::pair(record, notifyListeners)); - modified = true; - } - } - } - else if (objtype == "member") { - auto mspan = tracer->StartSpan("cv2::save::member"); - auto mscope = tracer->WithActiveSpan(mspan); - - std::string networkId = record["nwid"]; - std::string memberId = record["id"]; - const uint64_t nwid = OSUtils::jsonIntHex(record["nwid"], 0ULL); - const uint64_t id = OSUtils::jsonIntHex(record["id"], 0ULL); - // fprintf(stderr, "member save %s-%s\n", networkId.c_str(), memberId.c_str()); - if ((id) && (nwid)) { - nlohmann::json network, old; - get(nwid, network, id, old); - if ((! old.is_object()) || (! _compareRecords(old, record))) { - // fprintf(stderr, "commit queue post\n"); - record["revision"] = OSUtils::jsonInt(record["revision"], 0ULL) + 1ULL; - _commitQueue.post(std::pair(record, notifyListeners)); - modified = true; - } - else { - // fprintf(stderr, "no change\n"); - } - } - } - else { - fprintf(stderr, "uhh waaat\n"); - } - } - catch (std::exception& e) { - fprintf(stderr, "Error on PostgreSQL::save: %s\n", e.what()); - } - catch (...) { - fprintf(stderr, "Unknown error on PostgreSQL::save\n"); - } - return modified; -} - -void CV2::eraseNetwork(const uint64_t networkId) -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv2"); - auto span = tracer->StartSpan("cv2::eraseNetwork"); - auto scope = tracer->WithActiveSpan(span); - char networkIdStr[17]; - std::string nwid = Utils::hex(networkId, networkIdStr); - span->SetAttribute("network_id", nwid); - - fprintf(stderr, "CV2::eraseNetwork\n"); - waitForReady(); - std::pair tmp; - tmp.first["id"] = nwid; - tmp.first["objtype"] = "_delete_network"; - tmp.second = true; - _commitQueue.post(tmp); - // nlohmann::json nullJson; - //_networkChanged(tmp.first, nullJson, isReady()); -} - -void CV2::eraseMember(const uint64_t networkId, const uint64_t memberId) -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv2"); - auto span = tracer->StartSpan("cv2::eraseMember"); - auto scope = tracer->WithActiveSpan(span); - char networkIdStr[17]; - char memberIdStr[11]; - span->SetAttribute("network_id", Utils::hex(networkId, networkIdStr)); - span->SetAttribute("member_id", Utils::hex10(memberId, memberIdStr)); - - fprintf(stderr, "PostgreSQL::eraseMember\n"); - char tmp2[24]; - waitForReady(); - std::pair tmp, nw; - Utils::hex(networkId, tmp2); - tmp.first["nwid"] = tmp2; - Utils::hex(memberId, tmp2); - tmp.first["id"] = tmp2; - tmp.first["objtype"] = "_delete_member"; - tmp.second = true; - _commitQueue.post(tmp); - // nlohmann::json nullJson; - //_memberChanged(tmp.first, nullJson, isReady()); -} - -void CV2::nodeIsOnline( - const uint64_t networkId, - const uint64_t memberId, - const InetAddress& physicalAddress, - const char* osArch) -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv2"); - auto span = tracer->StartSpan("cv2::nodeIsOnline"); - auto scope = tracer->WithActiveSpan(span); - char networkIdStr[17]; - char memberIdStr[11]; - char ipAddressStr[INET6_ADDRSTRLEN]; - span->SetAttribute("network_id", Utils::hex(networkId, networkIdStr)); - span->SetAttribute("member_id", Utils::hex10(memberId, memberIdStr)); - span->SetAttribute("physical_address", ipAddressStr); - span->SetAttribute("os_arch", osArch); - - std::lock_guard l(_lastOnline_l); - NodeOnlineRecord& i = _lastOnline[std::pair(networkId, memberId)]; - i.lastSeen = OSUtils::now(); - if (physicalAddress) { - i.physicalAddress = physicalAddress; - } - i.osArch = std::string(osArch); -} - -void CV2::nodeIsOnline(const uint64_t networkId, const uint64_t memberId, const InetAddress& physicalAddress) -{ - this->nodeIsOnline(networkId, memberId, physicalAddress, "unknown/unknown"); -} - -AuthInfo CV2::getSSOAuthInfo(const nlohmann::json& member, const std::string& redirectURL) -{ - // TODO: Redo this for CV2 - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv2"); - auto span = tracer->StartSpan("cv2::getSSOAuthInfo"); - auto scope = tracer->WithActiveSpan(span); - - Metrics::db_get_sso_info++; - // NONCE is just a random character string. no semantic meaning - // state = HMAC SHA384 of Nonce based on shared sso key - // - // need nonce timeout in database? make sure it's used within X time - // X is 5 minutes for now. Make configurable later? - // - // how do we tell when a nonce is used? if auth_expiration_time is set - std::string networkId = member["nwid"]; - std::string memberId = member["id"]; - - char authenticationURL[4096] = { 0 }; - AuthInfo info; - info.enabled = true; - - // if (memberId == "a10dccea52" && networkId == "8056c2e21c24673d") { - // fprintf(stderr, "invalid authinfo for grant's machine\n"); - // info.version=1; - // return info; - // } - // fprintf(stderr, "PostgreSQL::updateMemberOnLoad: %s-%s\n", networkId.c_str(), memberId.c_str()); - std::shared_ptr c; - try { - // c = _pool->borrow(); - // pqxx::work w(*c->c); - - // char nonceBytes[16] = {0}; - // std::string nonce = ""; - - // // check if the member exists first. - // pqxx::row count = w.exec_params1("SELECT count(id) FROM ztc_member WHERE id = $1 AND network_id = $2 AND - // deleted = false", memberId, networkId); if (count[0].as() == 1) { - // // get active nonce, if exists. - // pqxx::result r = w.exec_params("SELECT nonce FROM ztc_sso_expiry " - // "WHERE network_id = $1 AND member_id = $2 " - // "AND ((NOW() AT TIME ZONE 'UTC') <= authentication_expiry_time) AND ((NOW() AT TIME ZONE 'UTC') - // <= nonce_expiration)", networkId, memberId); - - // if (r.size() == 0) { - // // no active nonce. - // // find an unused nonce, if one exists. - // pqxx::result r = w.exec_params("SELECT nonce FROM ztc_sso_expiry " - // "WHERE network_id = $1 AND member_id = $2 " - // "AND authentication_expiry_time IS NULL AND ((NOW() AT TIME ZONE 'UTC') <= - // nonce_expiration)", networkId, memberId); - - // if (r.size() == 1) { - // // we have an existing nonce. Use it - // nonce = r.at(0)[0].as(); - // Utils::unhex(nonce.c_str(), nonceBytes, sizeof(nonceBytes)); - // } else if (r.empty()) { - // // create a nonce - // Utils::getSecureRandom(nonceBytes, 16); - // char nonceBuf[64] = {0}; - // Utils::hex(nonceBytes, sizeof(nonceBytes), nonceBuf); - // nonce = std::string(nonceBuf); - - // pqxx::result ir = w.exec_params0("INSERT INTO ztc_sso_expiry " - // "(nonce, nonce_expiration, network_id, member_id) VALUES " - // "($1, TO_TIMESTAMP($2::double precision/1000), $3, $4)", - // nonce, OSUtils::now() + 300000, networkId, memberId); - - // w.commit(); - // } else { - // // > 1 ?!? Thats an error! - // fprintf(stderr, "> 1 unused nonce!\n"); - // exit(6); - // } - // } else if (r.size() == 1) { - // nonce = r.at(0)[0].as(); - // Utils::unhex(nonce.c_str(), nonceBytes, sizeof(nonceBytes)); - // } else { - // // more than 1 nonce in use? Uhhh... - // fprintf(stderr, "> 1 nonce in use for network member?!?\n"); - // exit(7); - // } - - // r = w.exec_params( - // "SELECT oc.client_id, oc.authorization_endpoint, oc.issuer, oc.provider, oc.sso_impl_version " - // "FROM ztc_network AS n " - // "INNER JOIN ztc_org o " - // " ON o.owner_id = n.owner_id " - // "LEFT OUTER JOIN ztc_network_oidc_config noc " - // " ON noc.network_id = n.id " - // "LEFT OUTER JOIN ztc_oidc_config oc " - // " ON noc.client_id = oc.client_id AND oc.org_id = o.org_id " - // "WHERE n.id = $1 AND n.sso_enabled = true", networkId); - - // std::string client_id = ""; - // std::string authorization_endpoint = ""; - // std::string issuer = ""; - // std::string provider = ""; - // uint64_t sso_version = 0; - - // if (r.size() == 1) { - // client_id = r.at(0)[0].as>().value_or(""); - // authorization_endpoint = r.at(0)[1].as>().value_or(""); - // issuer = r.at(0)[2].as>().value_or(""); - // provider = r.at(0)[3].as>().value_or(""); - // sso_version = r.at(0)[4].as>().value_or(1); - // } else if (r.size() > 1) { - // fprintf(stderr, "ERROR: More than one auth endpoint for an organization?!?!? NetworkID: %s\n", - // networkId.c_str()); } else { fprintf(stderr, "No client or auth endpoint?!?\n"); - // } - - // info.version = sso_version; - - // // no catch all else because we don't actually care if no records exist here. just continue as - // normal. if ((!client_id.empty())&&(!authorization_endpoint.empty())) { - - // uint8_t state[48]; - // HMACSHA384(_ssoPsk, nonceBytes, sizeof(nonceBytes), state); - // char state_hex[256]; - // Utils::hex(state, 48, state_hex); - - // if (info.version == 0) { - // char url[2048] = {0}; - // OSUtils::ztsnprintf(url, sizeof(authenticationURL), - // "%s?response_type=id_token&response_mode=form_post&scope=openid+email+profile&redirect_uri=%s&nonce=%s&state=%s&client_id=%s", - // authorization_endpoint.c_str(), - // url_encode(redirectURL).c_str(), - // nonce.c_str(), - // state_hex, - // client_id.c_str()); - // info.authenticationURL = std::string(url); - // } else if (info.version == 1) { - // info.ssoClientID = client_id; - // info.issuerURL = issuer; - // info.ssoProvider = provider; - // info.ssoNonce = nonce; - // info.ssoState = std::string(state_hex) + "_" +networkId; - // info.centralAuthURL = redirectURL; - // #ifdef ZT_DEBUG - // fprintf( - // stderr, - // "ssoClientID: %s\nissuerURL: %s\nssoNonce: %s\nssoState: %s\ncentralAuthURL: - // %s\nprovider: %s\n", info.ssoClientID.c_str(), info.issuerURL.c_str(), info.ssoNonce.c_str(), - // info.ssoState.c_str(), - // info.centralAuthURL.c_str(), - // provider.c_str()); - // #endif - // } - // } else { - // fprintf(stderr, "client_id: %s\nauthorization_endpoint: %s\n", client_id.c_str(), - // authorization_endpoint.c_str()); - // } - // } - - // _pool->unborrow(c); - } - catch (std::exception& e) { - fprintf(stderr, "ERROR: Error updating member on load for network %s: %s\n", networkId.c_str(), e.what()); - span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - } - - return info; // std::string(authenticationURL); -} - -void CV2::initializeNetworks() -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv2"); - auto span = tracer->StartSpan("cv2::initializeNetworks"); - auto scope = tracer->WithActiveSpan(span); - - fprintf(stderr, "Initializing networks...\n"); - - try { - char qbuf[2048]; - sprintf( - qbuf, - "SELECT id, name, configuration , (EXTRACT(EPOCH FROM creation_time AT TIME ZONE 'UTC')*1000)::bigint, " - "(EXTRACT(EPOCH FROM last_modified AT TIME ZONE 'UTC')*1000)::bigint, revision " - "FROM networks_ctl WHERE controller_id = '%s'", - _myAddressStr.c_str()); - - auto c = _pool->borrow(); - pqxx::work w(*c->c); - - fprintf(stderr, "Load networks from psql...\n"); - auto stream = pqxx::stream_from::query(w, qbuf); - std::tuple< - std::string // network ID - , - std::optional // name - , - std::string // configuration - , - std::optional // creation_time - , - std::optional // last_modified - , - std::optional // revision - > - row; - uint64_t count = 0; - uint64_t total = 0; - while (stream >> row) { - auto start = std::chrono::high_resolution_clock::now(); - - json empty; - json config; - - initNetwork(config); - - std::string nwid = std::get<0>(row); - std::string name = std::get<1>(row).value_or(""); - json cfgtmp = json::parse(std::get<2>(row)); - std::optional created_at = std::get<3>(row); - std::optional last_modified = std::get<4>(row); - std::optional revision = std::get<5>(row); - - config["id"] = nwid; - config["name"] = name; - config["creationTime"] = created_at.value_or(0); - config["lastModified"] = last_modified.value_or(0); - config["revision"] = revision.value_or(0); - config["capabilities"] = cfgtmp["capabilities"].is_array() ? cfgtmp["capabilities"] : json::array(); - config["enableBroadcast"] = - cfgtmp["enableBroadcast"].is_boolean() ? cfgtmp["enableBroadcast"].get() : false; - config["mtu"] = cfgtmp["mtu"].is_number() ? cfgtmp["mtu"].get() : 2800; - config["multicastLimit"] = - cfgtmp["multicastLimit"].is_number() ? cfgtmp["multicastLimit"].get() : 64; - config["private"] = cfgtmp["private"].is_boolean() ? cfgtmp["private"].get() : true; - config["remoteTraceLevel"] = - cfgtmp["remoteTraceLevel"].is_number() ? cfgtmp["remoteTraceLevel"].get() : 0; - config["remoteTraceTarget"] = - cfgtmp["remoteTraceTarget"].is_string() ? cfgtmp["remoteTraceTarget"].get() : ""; - config["revision"] = revision.value_or(0); - config["rules"] = cfgtmp["rules"].is_array() ? cfgtmp["rules"] : json::array(); - config["tags"] = cfgtmp["tags"].is_array() ? cfgtmp["tags"] : json::array(); - if (cfgtmp["v4AssignMode"].is_object()) { - config["v4AssignMode"] = cfgtmp["v4AssignMode"]; - } - else { - config["v4AssignMode"] = json::object(); - config["v4AssignMode"]["zt"] = true; - } - if (cfgtmp["v6AssignMode"].is_object()) { - config["v6AssignMode"] = cfgtmp["v6AssignMode"]; - } - else { - config["v6AssignMode"] = json::object(); - config["v6AssignMode"]["zt"] = true; - config["v6AssignMode"]["6plane"] = true; - config["v6AssignMode"]["rfc4193"] = false; - } - config["ssoEnabled"] = cfgtmp["ssoEnabled"].is_boolean() ? cfgtmp["ssoEnabled"].get() : false; - config["objtype"] = "network"; - config["routes"] = cfgtmp["routes"].is_array() ? cfgtmp["routes"] : json::array(); - config["clientId"] = cfgtmp["clientId"].is_string() ? cfgtmp["clientId"].get() : ""; - config["authorizationEndpoint"] = cfgtmp["authorizationEndpoint"].is_string() - ? cfgtmp["authorizationEndpoint"].get() - : nullptr; - config["provider"] = cfgtmp["ssoProvider"].is_string() ? cfgtmp["ssoProvider"].get() : ""; - if (! cfgtmp["dns"].is_object()) { - cfgtmp["dns"] = json::object(); - cfgtmp["dns"]["domain"] = ""; - cfgtmp["dns"]["servers"] = json::array(); - } - else { - config["dns"] = cfgtmp["dns"]; - } - config["ipAssignmentPools"] = - cfgtmp["ipAssignmentPools"].is_array() ? cfgtmp["ipAssignmentPools"] : json::array(); - - Metrics::network_count++; - - _networkChanged(empty, config, false); - - auto end = std::chrono::high_resolution_clock::now(); - auto dur = std::chrono::duration_cast(end - start); - ; - total += dur.count(); - ++count; - if (count > 0 && count % 10000 == 0) { - fprintf(stderr, "Averaging %lu us per network\n", (total / count)); - } - } - - w.commit(); - _pool->unborrow(c); - fprintf(stderr, "done.\n"); - - if (++this->_ready == 2) { - if (_waitNoticePrinted) { - fprintf( - stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), - (unsigned long long)_myAddress.toInt()); - } - _readyLock.unlock(); - } - fprintf(stderr, "network init done\n"); - } - catch (std::exception& e) { - fprintf(stderr, "ERROR: Error initializing networks: %s\n", e.what()); - span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - std::this_thread::sleep_for(std::chrono::milliseconds(5000)); - exit(-1); - } -} - -void CV2::initializeMembers() -{ - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv2"); - auto span = tracer->StartSpan("cv2::initializeMembers"); - auto scope = tracer->WithActiveSpan(span); - - std::string memberId; - std::string networkId; - try { - char qbuf[2048]; - sprintf( - qbuf, - "SELECT nm.device_id, nm.network_id, nm.authorized, nm.active_bridge, nm.ip_assignments, " - "nm.no_auto_assign_ips, " - "nm.sso_exempt, (EXTRACT(EPOCH FROM nm.authentication_expiry_time AT TIME ZONE 'UTC')*1000)::bigint, " - "(EXTRACT(EPOCH FROM nm.creation_time AT TIME ZONE 'UTC')*1000)::bigint, nm.identity, " - "(EXTRACT(EPOCH FROM nm.last_authorized_time AT TIME ZONE 'UTC')*1000)::bigint, " - "(EXTRACT(EPOCH FROM nm.last_deauthorized_time AT TIME ZONE 'UTC')*1000)::bigint, " - "nm.remote_trace_level, nm.remote_trace_target, nm.revision, nm.capabilities, nm.tags " - "FROM network_memberships_ctl nm " - "INNER JOIN networks_ctl n " - " ON nm.network_id = n.id " - "WHERE n.controller_id = '%s'", - _myAddressStr.c_str()); - - auto c = _pool->borrow(); - pqxx::work w(*c->c); - fprintf(stderr, "Load members from psql...\n"); - auto stream = pqxx::stream_from::query(w, qbuf); - std::tuple< - std::string // device ID - , - std::string // network ID - , - bool // authorized - , - std::optional // active_bridge - , - std::optional // ip_assignments - , - std::optional // no_auto_assign_ips - , - std::optional // sso_exempt - , - std::optional // authentication_expiry_time - , - std::optional // creation_time - , - std::optional // identity - , - std::optional // last_authorized_time - , - std::optional // last_deauthorized_time - , - std::optional // remote_trace_level - , - std::optional // remote_trace_target - , - std::optional // revision - , - std::optional // capabilities - , - std::optional // tags - > - row; - - uint64_t count = 0; - uint64_t total = 0; - while (stream >> row) { - auto start = std::chrono::high_resolution_clock::now(); - json empty; - json config; - - initMember(config); - - memberId = std::get<0>(row); - networkId = std::get<1>(row); - bool authorized = std::get<2>(row); - std::optional active_bridge = std::get<3>(row); - std::string ip_assignments = std::get<4>(row).value_or(""); - std::optional no_auto_assign_ips = std::get<5>(row); - std::optional sso_exempt = std::get<6>(row); - std::optional authentication_expiry_time = std::get<7>(row); - std::optional creation_time = std::get<8>(row); - std::optional identity = std::get<9>(row); - std::optional last_authorized_time = std::get<10>(row); - std::optional last_deauthorized_time = std::get<11>(row); - std::optional remote_trace_level = std::get<12>(row); - std::optional remote_trace_target = std::get<13>(row); - std::optional revision = std::get<14>(row); - std::optional capabilities = std::get<15>(row); - std::optional tags = std::get<16>(row); - - config["objtype"] = "member"; - config["id"] = memberId; - config["address"] = identity.value_or(""); - config["nwid"] = networkId; - config["authorized"] = authorized; - config["activeBridge"] = active_bridge.value_or(false); - config["ipAssignments"] = json::array(); - if (ip_assignments != "{}") { - std::string tmp = ip_assignments.substr(1, ip_assignments.length() - 2); - std::vector addrs = split(tmp, ','); - for (auto it = addrs.begin(); it != addrs.end(); ++it) { - config["ipAssignments"].push_back(*it); - } - } - config["capabilities"] = json::parse(capabilities.value_or("[]")); - config["creationTime"] = creation_time.value_or(0); - config["lastAuthorizedTime"] = last_authorized_time.value_or(0); - config["lastDeauthorizedTime"] = last_deauthorized_time.value_or(0); - config["noAutoAssignIPs"] = no_auto_assign_ips.value_or(false); - config["remoteTraceLevel"] = remote_trace_level.value_or(0); - config["remoteTraceTarget"] = remote_trace_target.value_or(nullptr); - config["revision"] = revision.value_or(0); - config["ssoExempt"] = sso_exempt.value_or(false); - config["authenticationExpiryTime"] = authentication_expiry_time.value_or(0); - config["tags"] = json::parse(tags.value_or("[]")); - - Metrics::member_count++; - - _memberChanged(empty, config, false); - - memberId = ""; - networkId = ""; - - auto end = std::chrono::high_resolution_clock::now(); - auto dur = std::chrono::duration_cast(end - start); - total += dur.count(); - ++count; - if (count > 0 && count % 10000 == 0) { - fprintf(stderr, "Averaging %lu us per member\n", (total / count)); - } - } - if (count > 0) { - fprintf(stderr, "Took %lu us per member to load\n", (total / count)); - } - - stream.complete(); - w.commit(); - _pool->unborrow(c); - fprintf(stderr, "done.\n"); - - if (++this->_ready == 2) { - if (_waitNoticePrinted) { - fprintf( - stderr, "[%s] NOTICE: %.10llx controller PostgreSQL data download complete." ZT_EOL_S, _timestr(), - (unsigned long long)_myAddress.toInt()); - } - _readyLock.unlock(); - } - fprintf(stderr, "member init done\n"); - } - catch (std::exception& e) { - fprintf(stderr, "ERROR: Error initializing member: %s-%s %s\n", networkId.c_str(), memberId.c_str(), e.what()); - span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - exit(-1); - } -} - -void CV2::heartbeat() -{ - char publicId[1024]; - char hostnameTmp[1024]; - _myId.toString(false, publicId); - if (gethostname(hostnameTmp, sizeof(hostnameTmp)) != 0) { - hostnameTmp[0] = (char)0; - } - else { - for (int i = 0; i < (int)sizeof(hostnameTmp); ++i) { - if ((hostnameTmp[i] == '.') || (hostnameTmp[i] == 0)) { - hostnameTmp[i] = (char)0; - break; - } - } - } - const char* controllerId = _myAddressStr.c_str(); - const char* publicIdentity = publicId; - const char* hostname = hostnameTmp; - - while (_run == 1) { - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv2"); - auto span = tracer->StartSpan("cv2::heartbeat"); - auto scope = tracer->WithActiveSpan(span); - - auto c = _pool->borrow(); - int64_t ts = OSUtils::now(); - - if (c->c) { - std::string major = std::to_string(ZEROTIER_ONE_VERSION_MAJOR); - std::string minor = std::to_string(ZEROTIER_ONE_VERSION_MINOR); - std::string rev = std::to_string(ZEROTIER_ONE_VERSION_REVISION); - std::string version = major + "." + minor + "." + rev; - std::string versionStr = "v" + version; - - try { - pqxx::work w { *c->c }; - w.exec_params0( - "INSERT INTO controllers_ctl (id, hostname, last_heartbeat, public_identity, version) VALUES " - "($1, $2, TO_TIMESTAMP($3::double precision/1000), $4, $5) " - "ON CONFLICT (id) DO UPDATE SET hostname = EXCLUDED.hostname, last_heartbeat = " - "EXCLUDED.last_heartbeat, " - "public_identity = EXCLUDED.public_identity, version = EXCLUDED.version", - controllerId, hostname, ts, publicIdentity, versionStr); - w.commit(); - } - catch (std::exception& e) { - fprintf(stderr, "ERROR: Error in heartbeat: %s\n", e.what()); - span->SetStatus(opentelemetry::trace::StatusCode::kError, e.what()); - continue; - } - catch (...) { - fprintf(stderr, "ERROR: Unknown error in heartbeat\n"); - span->SetStatus(opentelemetry::trace::StatusCode::kError, "Unknown error in heartbeat"); - continue; - } - } - - _pool->unborrow(c); - span->End(); - - std::this_thread::sleep_for(std::chrono::seconds(1)); - } - fprintf(stderr, "Exited heartbeat thread\n"); -} - -void CV2::membersDbWatcher() -{ - auto c = _pool->borrow(); - - std::string stream = "member_" + _myAddressStr; - - fprintf(stderr, "Listening to member stream: %s\n", stream.c_str()); - MemberNotificationReceiver m(this, *c->c, stream); - - while (_run == 1) { - c->c->await_notification(5, 0); - } - - _pool->unborrow(c); - - fprintf(stderr, "Exited membersDbWatcher\n"); -} - -void CV2::networksDbWatcher() -{ - std::string stream = "network_" + _myAddressStr; - - fprintf(stderr, "Listening to member stream: %s\n", stream.c_str()); - - auto c = _pool->borrow(); - - NetworkNotificationReceiver n(this, *c->c, stream); - - while (_run == 1) { - c->c->await_notification(5, 0); - } - - _pool->unborrow(c); - fprintf(stderr, "Exited networksDbWatcher\n"); -} - -void CV2::commitThread() -{ - fprintf(stderr, "%s: commitThread start\n", _myAddressStr.c_str()); - std::pair qitem; - while (_commitQueue.get(qitem) && (_run == 1)) { - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv2"); - auto span = tracer->StartSpan("cv2::commitThread"); - auto scope = tracer->WithActiveSpan(span); - - // fprintf(stderr, "commitThread tick\n"); - if (! qitem.first.is_object()) { - fprintf(stderr, "not an object\n"); - continue; - } - - std::shared_ptr c; - try { - c = _pool->borrow(); - } - catch (std::exception& e) { - fprintf(stderr, "ERROR: %s\n", e.what()); - continue; - } - - if (! c) { - fprintf(stderr, "Error getting database connection\n"); - continue; - } - - Metrics::pgsql_commit_ticks++; - try { - nlohmann::json& config = (qitem.first); - const std::string objtype = config["objtype"]; - if (objtype == "member") { - auto mspan = tracer->StartSpan("cv2::commitThread::member"); - auto mscope = tracer->WithActiveSpan(span); - - // fprintf(stderr, "%s: commitThread: member\n", _myAddressStr.c_str()); - std::string memberId; - std::string networkId; - try { - pqxx::work w(*c->c); - - memberId = config["id"]; - networkId = config["nwid"]; - - std::string target = "NULL"; - if (! config["remoteTraceTarget"].is_null()) { - target = config["remoteTraceTarget"]; - } - - pqxx::row nwrow = w.exec_params1("SELECT COUNT(id) FROM networks_ctl WHERE id = $1", networkId); - int nwcount = nwrow[0].as(); - - if (nwcount != 1) { - fprintf(stderr, "network %s does not exist. skipping member upsert\n", networkId.c_str()); - w.abort(); - _pool->unborrow(c); - continue; - } - - // only needed for hooks, and no hooks for now - // pqxx::row mrow = w.exec_params1("SELECT COUNT(id) FROM device_networks WHERE device_id = $1 AND - // network_id = $2", memberId, networkId); int membercount = mrow[0].as(); bool isNewMember = - // (membercount == 0); - - pqxx::result res = w.exec_params0( - "INSERT INTO network_memberships_ctl (device_id, network_id, authorized, active_bridge, " - "ip_assignments, " - "no_auto_assign_ips, sso_exempt, authentication_expiry_time, capabilities, creation_time, " - "identity, last_authorized_time, last_deauthorized_time, " - "remote_trace_level, remote_trace_target, revision, tags, version_major, version_minor, " - "version_revision, version_protocol) " - "VALUES ($1, $2, $3, $4, $5, $6, $7, TO_TIMESTAMP($8::double precision/1000), $9, " - "TO_TIMESTAMP($10::double precision/1000), $11, TO_TIMESTAMP($12::double precision/1000), " - "TO_TIMESTAMP($13::double precision/1000), $14, $15, $16, $17, $18, $19, $20, $21) " - "ON CONFLICT (device_id, network_id) DO UPDATE SET " - "authorized = EXCLUDED.authorized, active_bridge = EXCLUDED.active_bridge, " - "ip_assignments = EXCLUDED.ip_assignments, no_auto_assign_ips = EXCLUDED.no_auto_assign_ips, " - "sso_exempt = EXCLUDED.sso_exempt, authentication_expiry_time = " - "EXCLUDED.authentication_expiry_time, " - "capabilities = EXCLUDED.capabilities, creation_time = EXCLUDED.creation_time, " - "identity = EXCLUDED.identity, last_authorized_time = EXCLUDED.last_authorized_time, " - "last_deauthorized_time = EXCLUDED.last_deauthorized_time, " - "remote_trace_level = EXCLUDED.remote_trace_level, remote_trace_target = " - "EXCLUDED.remote_trace_target, " - "revision = EXCLUDED.revision, tags = EXCLUDED.tags, version_major = EXCLUDED.version_major, " - "version_minor = EXCLUDED.version_minor, version_revision = EXCLUDED.version_revision, " - "version_protocol = EXCLUDED.version_protocol", - memberId, networkId, (bool)config["authorized"], (bool)config["activeBridge"], - config["ipAssignments"].get >(), (bool)config["noAutoAssignIps"], - (bool)config["ssoExempt"], (uint64_t)config["authenticationExpiryTime"], - OSUtils::jsonDump(config["capabilities"], -1), (uint64_t)config["creationTime"], - OSUtils::jsonString(config["identity"], ""), (uint64_t)config["lastAuthorizedTime"], - (uint64_t)config["lastDeauthorizedTime"], (int)config["remoteTraceLevel"], target, - (uint64_t)config["revision"], OSUtils::jsonDump(config["tags"], -1), (int)config["vMajor"], - (int)config["vMinor"], (int)config["vRev"], (int)config["vProto"]); - - w.commit(); - - // No hooks for now - // if (_smee != NULL && isNewMember) { - // pqxx::row row = w.exec_params1( - // "SELECT " - // " count(h.hook_id) " - // "FROM " - // " ztc_hook h " - // " INNER JOIN ztc_org o ON o.org_id = h.org_id " - // " INNER JOIN ztc_network n ON n.owner_id = o.owner_id " - // " WHERE " - // "n.id = $1 ", - // networkId - // ); - // int64_t hookCount = row[0].as(); - // if (hookCount > 0) { - // notifyNewMember(networkId, memberId); - // } - // } - - const uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); - const uint64_t memberidInt = OSUtils::jsonIntHex(config["id"], 0ULL); - if (nwidInt && memberidInt) { - nlohmann::json nwOrig; - nlohmann::json memOrig; - - nlohmann::json memNew(config); - - get(nwidInt, nwOrig, memberidInt, memOrig); - - _memberChanged(memOrig, memNew, qitem.second); - } - else { - fprintf( - stderr, "%s: Can't notify of change. Error parsing nwid or memberid: %llu-%llu\n", - _myAddressStr.c_str(), (unsigned long long)nwidInt, (unsigned long long)memberidInt); - } - } - catch (pqxx::data_exception& e) { - std::string cfgDump = OSUtils::jsonDump(config, 2); - fprintf(stderr, "Member save %s-%s: %s\n", networkId.c_str(), memberId.c_str(), cfgDump.c_str()); - - const pqxx::sql_error* s = dynamic_cast(&e); - fprintf(stderr, "%s ERROR: Error updating member: %s\n", _myAddressStr.c_str(), e.what()); - if (s) { - fprintf(stderr, "%s ERROR: SQL error: %s\n", _myAddressStr.c_str(), s->query().c_str()); - } - mspan->SetStatus(opentelemetry::trace::StatusCode::kError, "pqxx::data_exception"); - mspan->SetAttribute("error", e.what()); - mspan->SetAttribute("config", cfgDump); - } - catch (std::exception& e) { - std::string cfgDump = OSUtils::jsonDump(config, 2); - fprintf( - stderr, "%s ERROR: Error updating member %s-%s: %s\njsonDump: %s\n", _myAddressStr.c_str(), - networkId.c_str(), memberId.c_str(), e.what(), cfgDump.c_str()); - mspan->SetStatus(opentelemetry::trace::StatusCode::kError, "std::exception"); - mspan->SetAttribute("error", e.what()); - mspan->SetAttribute("config", cfgDump); - } - } - else if (objtype == "network") { - auto nspan = tracer->StartSpan("cv2::commitThread::network"); - auto nscope = tracer->WithActiveSpan(span); - - try { - // fprintf(stderr, "%s: commitThread: network\n", _myAddressStr.c_str()); - pqxx::work w(*c->c); - - std::string id = config["id"]; - - // network must already exist - pqxx::result res = w.exec_params0( - "INSERT INTO networks_ctl (id, name, configuration, controller_id, revision) " - "VALUES ($1, $2, $3, $4, $5) " - "ON CONFLICT (id) DO UPDATE SET " - "name = EXCLUDED.name, configuration = EXCLUDED.configuration, revision = EXCLUDED.revision+1", - id, OSUtils::jsonString(config["name"], ""), OSUtils::jsonDump(config, -1), _myAddressStr, - ((uint64_t)config["revision"])); - - w.commit(); - - const uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); - if (nwidInt) { - nlohmann::json nwOrig; - nlohmann::json nwNew(config); - - get(nwidInt, nwOrig); - - _networkChanged(nwOrig, nwNew, qitem.second); - } - else { - fprintf( - stderr, "%s: Can't notify network changed: %llu\n", _myAddressStr.c_str(), - (unsigned long long)nwidInt); - } - } - catch (pqxx::data_exception& e) { - const pqxx::sql_error* s = dynamic_cast(&e); - fprintf(stderr, "%s ERROR: Error updating network: %s\n", _myAddressStr.c_str(), e.what()); - if (s) { - fprintf(stderr, "%s ERROR: SQL error: %s\n", _myAddressStr.c_str(), s->query().c_str()); - } - nspan->SetStatus(opentelemetry::trace::StatusCode::kError, "pqxx::data_exception"); - nspan->SetAttribute("error", e.what()); - nspan->SetAttribute("config", OSUtils::jsonDump(config, 2)); - } - catch (std::exception& e) { - fprintf(stderr, "%s ERROR: Error updating network: %s\n", _myAddressStr.c_str(), e.what()); - nspan->SetStatus(opentelemetry::trace::StatusCode::kError, "std::exception"); - nspan->SetAttribute("error", e.what()); - nspan->SetAttribute("config", OSUtils::jsonDump(config, 2)); - } - } - else if (objtype == "_delete_network") { - auto dspan = tracer->StartSpan("cv2::commitThread::delete_network"); - auto dscope = tracer->WithActiveSpan(span); - - // fprintf(stderr, "%s: commitThread: delete network\n", _myAddressStr.c_str()); - try { - pqxx::work w(*c->c); - std::string networkId = config["id"]; - fprintf(stderr, "Deleting network %s\n", networkId.c_str()); - w.exec_params0("DELETE FROM network_memberships_ctl WHERE network_id = $1", networkId); - w.exec_params0("DELETE FROM networks_ctl WHERE id = $1", networkId); - - w.commit(); - - uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); - json oldConfig; - get(nwidInt, oldConfig); - json empty; - _networkChanged(oldConfig, empty, qitem.second); - } - catch (std::exception& e) { - fprintf(stderr, "%s ERROR: Error deleting network: %s\n", _myAddressStr.c_str(), e.what()); - dspan->SetStatus(opentelemetry::trace::StatusCode::kError, "std::exception"); - dspan->SetAttribute("error", e.what()); - dspan->SetAttribute("config", OSUtils::jsonDump(config, 2)); - } - } - else if (objtype == "_delete_member") { - auto dspan = tracer->StartSpan("cv2::commitThread::delete_member"); - auto dscope = tracer->WithActiveSpan(span); - - // fprintf(stderr, "%s commitThread: delete member\n", _myAddressStr.c_str()); - try { - pqxx::work w(*c->c); - - std::string memberId = config["id"]; - std::string networkId = config["nwid"]; - - pqxx::result res = w.exec_params0( - "DELETE FROM network_memberships_ctl WHERE device_id = $1 AND network_id = $2", memberId, - networkId); - - w.commit(); - - uint64_t nwidInt = OSUtils::jsonIntHex(config["nwid"], 0ULL); - uint64_t memberidInt = OSUtils::jsonIntHex(config["id"], 0ULL); - - nlohmann::json networkConfig; - nlohmann::json oldConfig; - - get(nwidInt, networkConfig, memberidInt, oldConfig); - json empty; - _memberChanged(oldConfig, empty, qitem.second); - } - catch (std::exception& e) { - fprintf(stderr, "%s ERROR: Error deleting member: %s\n", _myAddressStr.c_str(), e.what()); - dspan->SetStatus(opentelemetry::trace::StatusCode::kError, "std::exception"); - dspan->SetAttribute("error", e.what()); - dspan->SetAttribute("config", OSUtils::jsonDump(config, 2)); - } - } - else { - fprintf(stderr, "%s ERROR: unknown objtype\n", _myAddressStr.c_str()); - } - } - catch (std::exception& e) { - fprintf(stderr, "%s ERROR: Error getting objtype: %s\n", _myAddressStr.c_str(), e.what()); - span->SetStatus(opentelemetry::trace::StatusCode::kError, "std::exception"); - span->SetAttribute("error", e.what()); - } - _pool->unborrow(c); - c.reset(); - } - - fprintf(stderr, "%s commitThread finished\n", _myAddressStr.c_str()); -} - -void CV2::onlineNotificationThread() -{ - waitForReady(); - - _connected = 1; - - nlohmann::json jtmp1, jtmp2; - while (_run == 1) { - auto provider = opentelemetry::trace::Provider::GetTracerProvider(); - auto tracer = provider->GetTracer("cv2"); - auto span = tracer->StartSpan("cv2::onlineNotificationThread"); - auto scope = tracer->WithActiveSpan(span); - - auto c = _pool->borrow(); - auto c2 = _pool->borrow(); - - try { - fprintf(stderr, "%s onlineNotificationThread\n", _myAddressStr.c_str()); - - std::unordered_map, NodeOnlineRecord, _PairHasher> lastOnline; - { - std::lock_guard l(_lastOnline_l); - lastOnline.swap(_lastOnline); - } - - pqxx::work w(*c->c); - pqxx::work w2(*c2->c); - - bool firstRun = true; - bool memberAdded = false; - uint64_t updateCount = 0; - - pqxx::pipeline pipe(w); - - for (auto i = lastOnline.begin(); i != lastOnline.end(); ++i) { - updateCount++; - - uint64_t nwid_i = i->first.first; - char nwidTmp[64]; - char memTmp[64]; - char ipTmp[64]; - - OSUtils::ztsnprintf(nwidTmp, sizeof(nwidTmp), "%.16llx", nwid_i); - OSUtils::ztsnprintf(memTmp, sizeof(memTmp), "%.10llx", i->first.second); - - if (! get(nwid_i, jtmp1, i->first.second, jtmp2)) { - continue; // skip non existent networks/members - } - - std::string networkId(nwidTmp); - std::string memberId(memTmp); - - try { - pqxx::row r = w2.exec_params1( - "SELECT device_id, network_id FROM network_memberships_ctl WHERE network_id = $1 AND device_id " - "= $2", - networkId, memberId); - } - catch (pqxx::unexpected_rows& e) { - continue; - } - - int64_t ts = i->second.lastSeen; - std::string ipAddr = i->second.physicalAddress.toIpString(ipTmp); - std::string timestamp = std::to_string(ts); - std::string osArch = i->second.osArch; - std::vector osArchSplit = split(osArch, '/'); - std::string os = osArchSplit[0]; - std::string arch = osArchSplit[1]; - - if (ipAddr.empty()) { - ipAddr = "relayed"; - } - - json record = { - { ipAddr, ts }, - }; - - std::string device_network_insert = - "INSERT INTO network_memberships_ctl (device_id, network_id, last_seen, os, arch) " - "VALUES ('" - + w2.esc(memberId) + "', '" + w2.esc(networkId) + "', '" + w2.esc(record.dump()) - + "'::JSONB, " - "'" - + w2.esc(os) + "', '" + w2.esc(arch) - + "') " - "ON CONFLICT (device_id, network_id) DO UPDATE SET os = EXCLUDED.os, arch = EXCLUDED.arch, " - "last_seen = network_memberships_ctl.last_seen || EXCLUDED.last_seen"; - pipe.insert(device_network_insert); - - Metrics::pgsql_node_checkin++; - } - - pipe.complete(); - ; - w2.commit(); - w.commit(); - fprintf(stderr, "%s: Updated online status of %lu members\n", _myAddressStr.c_str(), updateCount); - } - catch (std::exception& e) { - fprintf(stderr, "%s ERROR: Error in onlineNotificationThread: %s\n", _myAddressStr.c_str(), e.what()); - span->SetStatus(opentelemetry::trace::StatusCode::kError, "std::exception"); - span->SetAttribute("error", e.what()); - } - catch (...) { - fprintf(stderr, "%s ERROR: Unknown error in onlineNotificationThread\n", _myAddressStr.c_str()); - span->SetStatus(opentelemetry::trace::StatusCode::kError, "unknown"); - } - _pool->unborrow(c2); - _pool->unborrow(c); - span->End(); - - std::this_thread::sleep_for(std::chrono::seconds(10)); - } - - fprintf(stderr, "%s: Fell out of run loop in onlineNotificationThread\n", _myAddressStr.c_str()); - if (_run == 1) { - fprintf( - stderr, "ERROR: %s onlineNotificationThread should still be running! Exiting Controller.\n", - _myAddressStr.c_str()); - exit(6); - } -} -#endif // ZT_CONTROLLER_USE_LIBPQ diff --git a/nonfree/controller/CV2.hpp b/nonfree/controller/CV2.hpp deleted file mode 100644 index 5257ed0372..0000000000 --- a/nonfree/controller/CV2.hpp +++ /dev/null @@ -1,100 +0,0 @@ -/* (c) ZeroTier, Inc. - * See LICENSE.txt in nonfree/ - */ - -#include "DB.hpp" - -#ifdef ZT_CONTROLLER_USE_LIBPQ - -#ifndef ZT_CONTROLLER_CV2_HPP -#define ZT_CONTROLLER_CV2_HPP - -#define ZT_CENTRAL_CONTROLLER_COMMIT_THREADS 4 - -#include "../../node/Metrics.hpp" -#include "ConnectionPool.hpp" -#include "PostgreSQL.hpp" - -#include -#include -#include - -namespace ZeroTier { -class CV2 : public DB { - friend class MemberNotificationReceiver; - friend class NetworkNotificationReceiver; - - public: - CV2(const Identity& myId, const char* path, int listenPort); - virtual ~CV2(); - - virtual bool waitForReady(); - virtual bool isReady(); - virtual bool save(nlohmann::json& record, bool notifyListeners); - virtual void eraseNetwork(const uint64_t networkId); - virtual void eraseMember(const uint64_t networkId, const uint64_t memberId); - virtual void nodeIsOnline(const uint64_t networkId, const uint64_t memberId, const InetAddress& physicalAddress); - virtual void nodeIsOnline(const uint64_t networkId, const uint64_t memberId, const InetAddress& physicalAddress, const char* osArch); - virtual AuthInfo getSSOAuthInfo(const nlohmann::json& member, const std::string& redirectURL); - - virtual bool ready() - { - return _ready == 2; - } - - virtual void _memberChanged(nlohmann::json& old, nlohmann::json& memberConfig, bool notifyListeners); - - virtual void _networkChanged(nlohmann::json& old, nlohmann::json& networkConfig, bool notifyListeners); - - protected: - struct _PairHasher { - inline std::size_t operator()(const std::pair& p) const - { - return (std::size_t)(p.first ^ p.second); - } - }; - - private: - void initializeNetworks(); - void initializeMembers(); - void heartbeat(); - void membersDbWatcher(); - void networksDbWatcher(); - - void commitThread(); - void onlineNotificationThread(); - - // void notifyNewMember(const std::string &networkID, const std::string &memberID); - - enum OverrideMode { ALLOW_PGBOUNCER_OVERRIDE = 0, NO_OVERRIDE = 1 }; - - std::shared_ptr > _pool; - - const Identity _myId; - const Address _myAddress; - std::string _myAddressStr; - std::string _connString; - - BlockingQueue > _commitQueue; - - std::thread _heartbeatThread; - std::thread _membersDbWatcher; - std::thread _networksDbWatcher; - std::thread _commitThread[ZT_CENTRAL_CONTROLLER_COMMIT_THREADS]; - std::thread _onlineNotificationThread; - - std::unordered_map, NodeOnlineRecord, _PairHasher> _lastOnline; - - mutable std::mutex _lastOnline_l; - mutable std::mutex _readyLock; - std::atomic _ready, _connected, _run; - mutable volatile bool _waitNoticePrinted; - - int _listenPort; - uint8_t _ssoPsk[48]; -}; - -} // namespace ZeroTier - -#endif // ZT_CONTROLLER_CV2_HPP -#endif // ZT_CONTROLLER_USE_LIBPQ diff --git a/nonfree/controller/EmbeddedNetworkController.cpp b/nonfree/controller/EmbeddedNetworkController.cpp index f0213d27a8..45279955f8 100644 --- a/nonfree/controller/EmbeddedNetworkController.cpp +++ b/nonfree/controller/EmbeddedNetworkController.cpp @@ -24,8 +24,6 @@ #include #include #ifdef ZT_CONTROLLER_USE_LIBPQ -#include "CV1.hpp" -#include "CV2.hpp" #include "CentralDB.hpp" #ifdef ZT1_CENTRAL_CONTROLLER #include "ControllerConfig.hpp" @@ -687,22 +685,7 @@ void EmbeddedNetworkController::init(const Identity& signingId, Sender* sender) _db.addDB(std::shared_ptr(new CentralDB(_signingId, connString.c_str(), _listenPort, lm, sm, _cc))); #else -#ifdef ZT_CONTROLLER_USE_LIBPQ - if ((_path.length() > 9) && (_path.substr(0, 9) == "postgres:")) { - fprintf(stderr, "CV1\n"); - _db.addDB(std::shared_ptr(new CV1(_signingId, _path.substr(9).c_str(), _listenPort, _rc))); - } - else if ((_path.length() > 4) && (_path.substr(0, 4) == "cv2:")) { - fprintf(stderr, "CV2\n"); - _db.addDB(std::shared_ptr(new CV2(_signingId, _path.substr(4).c_str(), _listenPort))); - } - else { - fprintf(stderr, "FileDB\n"); -#endif - _db.addDB(std::shared_ptr(new FileDB(_path.c_str()))); -#ifdef ZT_CONTROLLER_USE_LIBPQ - } -#endif + _db.addDB(std::shared_ptr(new FileDB(_path.c_str()))); #endif // ZT1_CENTRAL_CONTROLLER _db.waitForReady(); diff --git a/objects-nonfree.mk b/objects-nonfree.mk index cd25cce110..c55c06bba2 100644 --- a/objects-nonfree.mk +++ b/objects-nonfree.mk @@ -3,6 +3,4 @@ CONTROLLER_OBJS=\ nonfree/controller/DBMirrorSet.o \ nonfree/controller/DB.o \ nonfree/controller/FileDB.o \ - nonfree/controller/CtlUtil.o \ - nonfree/controller/CV1.o \ - nonfree/controller/CV2.o + nonfree/controller/CtlUtil.o diff --git a/rustybits/Cargo.lock b/rustybits/Cargo.lock index 96d14ec26f..65ba050679 100644 --- a/rustybits/Cargo.lock +++ b/rustybits/Cargo.lock @@ -11,12 +11,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "allocator-api2" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" - [[package]] name = "android_system_properties" version = "0.1.5" @@ -105,60 +99,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" -[[package]] -name = "axum" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31b698c5f9a010f6573133b09e0de5408834d0c82f8d7475a89fc1867a71cd90" -dependencies = [ - "axum-core", - "bytes", - "futures-util", - "http 1.4.0", - "http-body 1.0.1", - "http-body-util", - "itoa", - "matchit", - "memchr", - "mime", - "percent-encoding", - "pin-project-lite", - "serde_core", - "sync_wrapper 1.0.2", - "tower", - "tower-layer", - "tower-service", -] - -[[package]] -name = "axum-core" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c78f31d7b1291f7ee735c1c6780ccde7785daae9a9206026862dab7d8792d1" -dependencies = [ - "bytes", - "futures-core", - "http 1.4.0", - "http-body 1.0.1", - "http-body-util", - "mime", - "pin-project-lite", - "sync_wrapper 1.0.2", - "tower-layer", - "tower-service", -] - -[[package]] -name = "backoff" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62ddb9cb1ec0a098ad4bbf9344d0713fa193ae1a80af55febcff2627b6a00c1" -dependencies = [ - "getrandom 0.2.17", - "instant", - "rand 0.8.6", -] - [[package]] name = "base16ct" version = "0.2.0" @@ -327,7 +267,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-link 0.2.1", + "windows-link", ] [[package]] @@ -369,15 +309,6 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" -[[package]] -name = "convert_case" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "core-foundation" version = "0.9.4" @@ -413,30 +344,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-queue" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" - [[package]] name = "crypto-bigint" version = "0.5.5" @@ -444,7 +351,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", - "rand_core 0.6.4", + "rand_core", "subtle", "zeroize", ] @@ -486,38 +393,14 @@ dependencies = [ "syn", ] -[[package]] -name = "darling" -version = "0.20.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" -dependencies = [ - "darling_core 0.20.11", - "darling_macro 0.20.11", -] - [[package]] name = "darling" version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d" dependencies = [ - "darling_core 0.23.0", - "darling_macro 0.23.0", -] - -[[package]] -name = "darling_core" -version = "0.20.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn", + "darling_core", + "darling_macro", ] [[package]] @@ -533,42 +416,17 @@ dependencies = [ "syn", ] -[[package]] -name = "darling_macro" -version = "0.20.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" -dependencies = [ - "darling_core 0.20.11", - "quote", - "syn", -] - [[package]] name = "darling_macro" version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" dependencies = [ - "darling_core 0.23.0", + "darling_core", "quote", "syn", ] -[[package]] -name = "dashmap" -version = "6.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6361d5c062261c78a176addb82d4c821ae42bed6089de0e12603cd25de2059c" -dependencies = [ - "cfg-if", - "crossbeam-utils", - "hashbrown 0.14.5", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "der" version = "0.7.10" @@ -590,60 +448,6 @@ dependencies = [ "serde_core", ] -[[package]] -name = "derive_builder" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" -dependencies = [ - "derive_builder_macro", -] - -[[package]] -name = "derive_builder_core" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" -dependencies = [ - "darling 0.20.11", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "derive_builder_macro" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" -dependencies = [ - "derive_builder_core", - "syn", -] - -[[package]] -name = "derive_more" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134" -dependencies = [ - "derive_more-impl", -] - -[[package]] -name = "derive_more-impl" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn", - "unicode-xid", -] - [[package]] name = "digest" version = "0.10.7" @@ -678,12 +482,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "downcast" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" - [[package]] name = "dyn-clone" version = "1.0.20" @@ -749,7 +547,7 @@ dependencies = [ "hkdf", "pem-rfc7468", "pkcs8", - "rand_core 0.6.4", + "rand_core", "sec1", "subtle", "zeroize", @@ -764,55 +562,12 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "enum-iterator" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4549325971814bda7a44061bf3fe7e487d447cba01e4220a4b454d630d7a016" -dependencies = [ - "enum-iterator-derive", -] - -[[package]] -name = "enum-iterator-derive" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685adfa4d6f3d765a26bc5dbc936577de9abf756c1feeb3089b01dd395034842" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "enum_dispatch" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa18ce2bc66555b3218614519ac839ddb759a7d6720732f979ef8d13be147ecd" -dependencies = [ - "once_cell", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "equivalent" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" -[[package]] -name = "erased-serde" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2add8a07dd6a8d93ff627029c51de145e12686fbc36ecb298ac22e74cf02dec" -dependencies = [ - "serde", - "serde_core", - "typeid", -] - [[package]] name = "errno" version = "0.3.14" @@ -846,7 +601,7 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" dependencies = [ - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -872,12 +627,6 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" -[[package]] -name = "fixedbitset" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" - [[package]] name = "fnv" version = "1.0.7" @@ -890,12 +639,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" -[[package]] -name = "foldhash" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" - [[package]] name = "foreign-types" version = "0.3.2" @@ -920,15 +663,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "fragile" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8878864ba14bb86e818a412bfd6f18f9eabd4ec0f008a28e8f7eb61db532fcf9" -dependencies = [ - "futures-core", -] - [[package]] name = "futures" version = "0.3.32" @@ -988,17 +722,6 @@ dependencies = [ "syn", ] -[[package]] -name = "futures-retry" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fde5a672a61f96552aa5ed9fd9c81c3fbdae4be9b1e205d6eaf17c83705adc0f" -dependencies = [ - "futures", - "pin-project-lite", - "tokio", -] - [[package]] name = "futures-sink" version = "0.3.32" @@ -1011,12 +734,6 @@ version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" -[[package]] -name = "futures-timer" -version = "3.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af43fadb8a98512d547e37b4e92e0ced13e205c061b87b4623eff01d918d6968" - [[package]] name = "futures-util" version = "0.3.32" @@ -1045,16 +762,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "gethostname" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" -dependencies = [ - "rustix", - "windows-link 0.2.1", -] - [[package]] name = "getrandom" version = "0.2.17" @@ -1068,20 +775,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "getrandom" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" -dependencies = [ - "cfg-if", - "js-sys", - "libc", - "r-efi 5.3.0", - "wasip2", - "wasm-bindgen", -] - [[package]] name = "getrandom" version = "0.4.2" @@ -1090,34 +783,11 @@ checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" dependencies = [ "cfg-if", "libc", - "r-efi 6.0.0", + "r-efi", "wasip2", "wasip3", ] -[[package]] -name = "governor" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9efcab3c1958580ff1f25a2a41be1668f7603d849bb63af523b208a3cc1223b8" -dependencies = [ - "cfg-if", - "dashmap", - "futures-sink", - "futures-timer", - "futures-util", - "getrandom 0.3.4", - "hashbrown 0.16.1", - "nonzero_ext", - "parking_lot", - "portable-atomic", - "quanta", - "rand 0.9.4", - "smallvec", - "spinning_top", - "web-time", -] - [[package]] name = "group" version = "0.13.0" @@ -1125,7 +795,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", - "rand_core 0.6.4", + "rand_core", "subtle", ] @@ -1148,55 +818,19 @@ dependencies = [ "tracing", ] -[[package]] -name = "h2" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "171fefbc92fe4a4de27e0698d6a5b392d6a0e333506bc49133760b3bcf948733" -dependencies = [ - "atomic-waker", - "bytes", - "fnv", - "futures-core", - "futures-sink", - "http 1.4.0", - "indexmap 2.14.0", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - [[package]] name = "hashbrown" version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" dependencies = [ - "foldhash 0.1.5", -] - -[[package]] -name = "hashbrown" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" -dependencies = [ - "allocator-api2", - "equivalent", - "foldhash 0.2.0", + "foldhash", ] [[package]] @@ -1321,7 +955,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2 0.3.27", + "h2", "http 0.2.12", "http-body 0.4.6", "httparse", @@ -1345,7 +979,6 @@ dependencies = [ "bytes", "futures-channel", "futures-core", - "h2 0.4.14", "http 1.4.0", "http-body 1.0.1", "httparse", @@ -1388,19 +1021,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "hyper-timeout" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" -dependencies = [ - "hyper 1.9.0", - "hyper-util", - "pin-project-lite", - "tokio", - "tower-service", -] - [[package]] name = "hyper-tls" version = "0.5.0" @@ -1461,7 +1081,7 @@ dependencies = [ "js-sys", "log", "wasm-bindgen", - "windows-core 0.62.2", + "windows-core", ] [[package]] @@ -1612,26 +1232,8 @@ dependencies = [ ] [[package]] -name = "instant" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "inventory" -version = "0.3.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4f0c30c76f2f4ccee3fe55a2435f691ca00c0e4bd87abe4f4a851b1d4dac39b" -dependencies = [ - "rustversion", -] - -[[package]] -name = "ipnet" -version = "2.12.0" +name = "ipnet" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" @@ -1650,15 +1252,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.18" @@ -1730,45 +1323,12 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0" -[[package]] -name = "lock_api" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" -dependencies = [ - "scopeguard", -] - [[package]] name = "log" version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" -[[package]] -name = "lru" -version = "0.16.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f66e8d5d03f609abc3a39e6f08e4164ebf1447a732906d39eb9b99b7919ef39" -dependencies = [ - "hashbrown 0.16.1", -] - -[[package]] -name = "matchers" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" -dependencies = [ - "regex-automata", -] - -[[package]] -name = "matchit" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" - [[package]] name = "memchr" version = "2.8.0" @@ -1792,38 +1352,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "mockall" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39a6bfcc6c8c7eed5ee98b9c3e33adc726054389233e201c95dab2d41a3839d2" -dependencies = [ - "cfg-if", - "downcast", - "fragile", - "mockall_derive", - "predicates", - "predicates-tree", -] - -[[package]] -name = "mockall_derive" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25ca3004c2efe9011bd4e461bd8256445052b9615405b4f7ea43fc8ca5c20898" -dependencies = [ - "cfg-if", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "multimap" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" - [[package]] name = "native-tls" version = "0.2.18" @@ -1841,30 +1369,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "nonzero_ext" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bf9645c8b145698bb0b18a4637dcacbc421ea49bef2317e4fd8065a387cf21" - -[[package]] -name = "ntapi" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3b335231dfd352ffb0f8017f3b6027a4917f7df785ea2143d8af2adc66980ae" -dependencies = [ - "winapi", -] - -[[package]] -name = "nu-ansi-term" -version = "0.50.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" -dependencies = [ - "windows-sys 0.61.2", -] - [[package]] name = "num-bigint-dig" version = "0.8.6" @@ -1876,7 +1380,7 @@ dependencies = [ "num-integer", "num-iter", "num-traits", - "rand 0.8.6", + "rand", "smallvec", "zeroize", ] @@ -1927,7 +1431,7 @@ dependencies = [ "chrono", "getrandom 0.2.17", "http 0.2.12", - "rand 0.8.6", + "rand", "reqwest", "serde", "serde_json", @@ -1937,25 +1441,6 @@ dependencies = [ "url", ] -[[package]] -name = "objc2-core-foundation" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" -dependencies = [ - "bitflags 2.11.1", -] - -[[package]] -name = "objc2-io-kit" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15" -dependencies = [ - "libc", - "objc2-core-foundation", -] - [[package]] name = "once_cell" version = "1.21.4" @@ -1980,12 +1465,12 @@ dependencies = [ "ed25519-dalek", "hmac", "http 0.2.12", - "itertools 0.10.5", + "itertools", "log", "oauth2", "p256", "p384", - "rand 0.8.6", + "rand", "rsa", "serde", "serde-value", @@ -2043,20 +1528,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "opentelemetry" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf416e4cb72756655126f7dd7bb0af49c674f4c1b9903e80c009e0c37e552e6" -dependencies = [ - "futures-core", - "futures-sink", - "js-sys", - "pin-project-lite", - "thiserror 2.0.18", - "tracing", -] - [[package]] name = "ordered-float" version = "2.10.1" @@ -2090,29 +1561,6 @@ dependencies = [ "sha2", ] -[[package]] -name = "parking_lot" -version = "0.12.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall 0.5.18", - "smallvec", - "windows-link 0.2.1", -] - [[package]] name = "parse-display" version = "0.9.1" @@ -2153,56 +1601,6 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" -[[package]] -name = "petgraph" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" -dependencies = [ - "fixedbitset", - "indexmap 2.14.0", -] - -[[package]] -name = "petgraph" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" -dependencies = [ - "fixedbitset", - "hashbrown 0.15.5", - "indexmap 2.14.0", -] - -[[package]] -name = "pid" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7c931ef9756cd5e3fa3d395bfe09df4dfa6f0612c6ca8f6b12927d17ca34e36" -dependencies = [ - "num-traits", -] - -[[package]] -name = "pin-project" -version = "1.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "pin-project-lite" version = "0.2.17" @@ -2236,21 +1634,6 @@ version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" -[[package]] -name = "portable-atomic" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" - -[[package]] -name = "portable-atomic-util" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2a106d1259c23fac8e543272398ae0e3c0b8d33c88ed73d0cc71b0f1d902618" -dependencies = [ - "portable-atomic", -] - [[package]] name = "potential_utf" version = "0.1.5" @@ -2275,32 +1658,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "predicates" -version = "3.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ada8f2932f28a27ee7b70dd6c1c39ea0675c55a36879ab92f3a715eaa1e63cfe" -dependencies = [ - "anstyle", - "predicates-core", -] - -[[package]] -name = "predicates-core" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cad38746f3166b4031b1a0d39ad9f954dd291e7854fcc0eed52ee41a0b50d144" - -[[package]] -name = "predicates-tree" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0de1b847b39c8131db0467e9df1ff60e6d0562ab8e9a16e568ad0fdb372e2f2" -dependencies = [ - "predicates-core", - "termtree", -] - [[package]] name = "prettyplease" version = "0.2.37" @@ -2329,170 +1686,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "prost" -version = "0.13.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5" -dependencies = [ - "bytes", - "prost-derive 0.13.5", -] - -[[package]] -name = "prost" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2ea70524a2f82d518bce41317d0fae74151505651af45faf1ffbd6fd33f0568" -dependencies = [ - "bytes", - "prost-derive 0.14.3", -] - -[[package]] -name = "prost-build" -version = "0.13.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be769465445e8c1474e9c5dac2018218498557af32d9ed057325ec9a41ae81bf" -dependencies = [ - "heck", - "itertools 0.14.0", - "log", - "multimap", - "once_cell", - "petgraph 0.7.1", - "prettyplease", - "prost 0.13.5", - "prost-types 0.13.5", - "regex", - "syn", - "tempfile", -] - -[[package]] -name = "prost-build" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343d3bd7056eda839b03204e68deff7d1b13aba7af2b2fd16890697274262ee7" -dependencies = [ - "heck", - "itertools 0.14.0", - "log", - "multimap", - "petgraph 0.8.3", - "prettyplease", - "prost 0.14.3", - "prost-types 0.14.3", - "regex", - "syn", - "tempfile", -] - -[[package]] -name = "prost-derive" -version = "0.13.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" -dependencies = [ - "anyhow", - "itertools 0.14.0", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "prost-derive" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27c6023962132f4b30eb4c172c91ce92d933da334c59c23cddee82358ddafb0b" -dependencies = [ - "anyhow", - "itertools 0.14.0", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "prost-types" -version = "0.13.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52c2c1bf36ddb1a1c396b3601a3cec27c2462e45f07c386894ec3ccf5332bd16" -dependencies = [ - "prost 0.13.5", -] - -[[package]] -name = "prost-types" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8991c4cbdb8bc5b11f0b074ffe286c30e523de90fee5ba8132f1399f23cb3dd7" -dependencies = [ - "prost 0.14.3", -] - -[[package]] -name = "prost-wkt" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497e1e938f0c09ef9cabe1d49437b4016e03e8f82fbbe5d1c62a9b61b9decae1" -dependencies = [ - "chrono", - "inventory", - "prost 0.13.5", - "serde", - "serde_derive", - "serde_json", - "typetag", -] - -[[package]] -name = "prost-wkt-build" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b8bf115b70a7aa5af1fd5d6e9418492e9ccb6e4785e858c938e28d132a884b" -dependencies = [ - "heck", - "prost 0.13.5", - "prost-build 0.13.5", - "prost-types 0.13.5", - "quote", -] - -[[package]] -name = "prost-wkt-types" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8cdde6df0a98311c839392ca2f2f0bcecd545f86a62b4e3c6a49c336e970fe5" -dependencies = [ - "chrono", - "prost 0.13.5", - "prost-build 0.13.5", - "prost-types 0.13.5", - "prost-wkt", - "prost-wkt-build", - "regex", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "quanta" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3ab5a9d756f0d97bdc89019bd2e4ea098cf9cde50ee7564dde6b81ccc8f06c7" -dependencies = [ - "crossbeam-utils", - "libc", - "once_cell", - "raw-cpuid", - "wasi", - "web-sys", - "winapi", -] - [[package]] name = "quote" version = "1.0.45" @@ -2502,12 +1695,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "r-efi" -version = "5.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" - [[package]] name = "r-efi" version = "6.0.0" @@ -2521,18 +1708,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a" dependencies = [ "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - -[[package]] -name = "rand" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea" -dependencies = [ - "rand_chacha 0.9.0", - "rand_core 0.9.5", + "rand_chacha", + "rand_core", ] [[package]] @@ -2542,17 +1719,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" -dependencies = [ - "ppv-lite86", - "rand_core 0.9.5", + "rand_core", ] [[package]] @@ -2564,24 +1731,6 @@ dependencies = [ "getrandom 0.2.17", ] -[[package]] -name = "rand_core" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" -dependencies = [ - "getrandom 0.3.4", -] - -[[package]] -name = "raw-cpuid" -version = "11.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "498cd0dc59d73224351ee52a95fee0f1a617a2eae0e7d9d720cc622c73a54186" -dependencies = [ - "bitflags 2.11.1", -] - [[package]] name = "redox_syscall" version = "0.3.5" @@ -2591,15 +1740,6 @@ dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "redox_syscall" -version = "0.5.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" -dependencies = [ - "bitflags 2.11.1", -] - [[package]] name = "ref-cast" version = "1.0.25" @@ -2660,7 +1800,7 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2 0.3.27", + "h2", "http 0.2.12", "http-body 0.4.6", "hyper 0.14.32", @@ -2677,7 +1817,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 0.1.2", + "sync_wrapper", "system-configuration", "tokio", "tokio-native-tls", @@ -2713,17 +1853,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "ringbuf" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe47b720588c8702e34b5979cb3271a8b1842c7cb6f57408efa70c779363488c" -dependencies = [ - "crossbeam-utils", - "portable-atomic", - "portable-atomic-util", -] - [[package]] name = "rsa" version = "0.9.10" @@ -2737,7 +1866,7 @@ dependencies = [ "num-traits", "pkcs1", "pkcs8", - "rand_core 0.6.4", + "rand_core", "signature", "spki", "subtle", @@ -2753,32 +1882,6 @@ dependencies = [ "semver", ] -[[package]] -name = "rustfsm" -version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" -dependencies = [ - "rustfsm_procmacro", - "rustfsm_trait", -] - -[[package]] -name = "rustfsm_procmacro" -version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" -dependencies = [ - "derive_more", - "proc-macro2", - "quote", - "rustfsm_trait", - "syn", -] - -[[package]] -name = "rustfsm_trait" -version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" - [[package]] name = "rustix" version = "1.1.4" @@ -2798,7 +1901,6 @@ version = "0.23.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef86cd5876211988985292b91c96a8f2d298df24e75989a43a3c73f2d4d8168b" dependencies = [ - "log", "once_cell", "ring", "rustls-pki-types", @@ -2872,21 +1974,12 @@ dependencies = [ "cbindgen", "jwt", "openidconnect", - "prost-build 0.14.3", "reqwest", - "serde", - "serde_json", - "temporal-client", - "temporal-sdk", - "temporal-sdk-core-protos", "testcontainers", "testcontainers-modules", "thiserror 1.0.69", "time", - "tokio", - "tokio-util", "url", - "uuid", ] [[package]] @@ -2928,12 +2021,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "sec1" version = "0.7.3" @@ -3108,7 +2195,7 @@ version = "3.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b90c488738ecb4fb0262f41f43bc40efc5868d9fb744319ddf5f5317f417bfac" dependencies = [ - "darling 0.23.0", + "darling", "proc-macro2", "quote", "syn", @@ -3125,31 +2212,12 @@ dependencies = [ "digest", ] -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", -] - [[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" -[[package]] -name = "signal-hook-registry" -version = "1.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" -dependencies = [ - "errno", - "libc", -] - [[package]] name = "signature" version = "2.2.0" @@ -3157,30 +2225,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest", - "rand_core 0.6.4", + "rand_core", ] -[[package]] -name = "siphasher" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ee5873ec9cce0195efcb7a4e9507a04cd49aec9c83d0389df45b1ef7ba2e649" - [[package]] name = "slab" version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" -[[package]] -name = "slotmap" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdd58c3c93c3d278ca835519292445cb4b0d4dc59ccfdf7ceadaab3f8aeb4038" -dependencies = [ - "version_check", -] - [[package]] name = "smallvec" version = "1.15.1" @@ -3211,16 +2264,7 @@ dependencies = [ name = "spin" version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - -[[package]] -name = "spinning_top" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96d2d1d716fb500937168cc09353ffdc7a012be8475ac7308e1bdf0e3923300" -dependencies = [ - "lock_api", -] +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "spki" @@ -3290,12 +2334,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" -[[package]] -name = "sync_wrapper" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" - [[package]] name = "synstructure" version = "0.13.2" @@ -3307,20 +2345,6 @@ dependencies = [ "syn", ] -[[package]] -name = "sysinfo" -version = "0.37.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16607d5caffd1c07ce073528f9ed972d88db15dd44023fa57142963be3feb11f" -dependencies = [ - "libc", - "memchr", - "ntapi", - "objc2-core-foundation", - "objc2-io-kit", - "windows", -] - [[package]] name = "system-configuration" version = "0.5.1" @@ -3355,156 +2379,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "temporal-client" -version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" -dependencies = [ - "anyhow", - "async-trait", - "backoff", - "base64 0.22.1", - "bytes", - "derive_builder", - "derive_more", - "futures-retry", - "futures-util", - "http 1.4.0", - "http-body-util", - "hyper 1.9.0", - "hyper-util", - "opentelemetry", - "parking_lot", - "slotmap", - "temporal-sdk-core-api", - "temporal-sdk-core-protos", - "thiserror 2.0.18", - "tokio", - "tonic", - "tower", - "tracing", - "url", - "uuid", -] - -[[package]] -name = "temporal-sdk" -version = "0.1.0-alpha.1" -source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" -dependencies = [ - "anyhow", - "async-trait", - "derive_more", - "futures-util", - "parking_lot", - "prost-wkt-types", - "serde", - "temporal-client", - "temporal-sdk-core", - "temporal-sdk-core-api", - "temporal-sdk-core-protos", - "tokio", - "tokio-stream", - "tokio-util", - "tracing", -] - -[[package]] -name = "temporal-sdk-core" -version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" -dependencies = [ - "anyhow", - "async-trait", - "crossbeam-channel", - "crossbeam-queue", - "crossbeam-utils", - "dashmap", - "derive_builder", - "derive_more", - "enum-iterator", - "enum_dispatch", - "futures-channel", - "futures-util", - "gethostname", - "governor", - "itertools 0.14.0", - "lru", - "mockall", - "parking_lot", - "pid", - "pin-project", - "prost 0.13.5", - "prost-wkt-types", - "rand 0.9.4", - "ringbuf", - "rustfsm", - "serde", - "serde_json", - "siphasher", - "slotmap", - "sysinfo", - "temporal-client", - "temporal-sdk-core-api", - "temporal-sdk-core-protos", - "thiserror 2.0.18", - "tokio", - "tokio-stream", - "tokio-util", - "tonic", - "tracing", - "tracing-subscriber", - "url", - "uuid", -] - -[[package]] -name = "temporal-sdk-core-api" -version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" -dependencies = [ - "async-trait", - "derive_builder", - "derive_more", - "opentelemetry", - "prost 0.13.5", - "serde_json", - "temporal-sdk-core-protos", - "thiserror 2.0.18", - "tonic", - "tracing", - "tracing-core", - "url", -] - -[[package]] -name = "temporal-sdk-core-protos" -version = "0.1.0" -source = "git+https://github.com/temporalio/sdk-core?rev=4614dcb8f4ffd2cb244eb0a19d7485c896e3459e#4614dcb8f4ffd2cb244eb0a19d7485c896e3459e" -dependencies = [ - "anyhow", - "base64 0.22.1", - "derive_more", - "prost 0.13.5", - "prost-build 0.13.5", - "prost-wkt", - "prost-wkt-build", - "prost-wkt-types", - "rand 0.9.4", - "serde", - "serde_json", - "thiserror 2.0.18", - "tonic", - "tonic-build", - "uuid", -] - -[[package]] -name = "termtree" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" - [[package]] name = "testcontainers" version = "0.24.0" @@ -3583,15 +2457,6 @@ dependencies = [ "syn", ] -[[package]] -name = "thread_local" -version = "1.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" -dependencies = [ - "cfg-if", -] - [[package]] name = "time" version = "0.3.47" @@ -3657,9 +2522,7 @@ dependencies = [ "bytes", "libc", "mio", - "parking_lot", "pin-project-lite", - "signal-hook-registry", "socket2 0.6.3", "tokio-macros", "windows-sys 0.61.2", @@ -3716,7 +2579,7 @@ dependencies = [ "filetime", "futures-core", "libc", - "redox_syscall 0.3.5", + "redox_syscall", "tokio", "tokio-stream", "xattr", @@ -3776,76 +2639,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" -[[package]] -name = "tonic" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e581ba15a835f4d9ea06c55ab1bd4dce26fc53752c69a04aac00703bfb49ba9" -dependencies = [ - "async-trait", - "axum", - "base64 0.22.1", - "bytes", - "h2 0.4.14", - "http 1.4.0", - "http-body 1.0.1", - "http-body-util", - "hyper 1.9.0", - "hyper-timeout", - "hyper-util", - "percent-encoding", - "pin-project", - "prost 0.13.5", - "rustls-native-certs", - "socket2 0.5.10", - "tokio", - "tokio-rustls", - "tokio-stream", - "tower", - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "tonic-build" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac6f67be712d12f0b41328db3137e0d0757645d8904b4cb7d51cd9c2279e847" -dependencies = [ - "prettyplease", - "proc-macro2", - "prost-build 0.13.5", - "prost-types 0.13.5", - "quote", - "syn", -] - -[[package]] -name = "tower" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" -dependencies = [ - "futures-core", - "futures-util", - "indexmap 2.14.0", - "pin-project-lite", - "slab", - "sync_wrapper 1.0.2", - "tokio", - "tokio-util", - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "tower-layer" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" - [[package]] name = "tower-service" version = "0.3.3" @@ -3859,21 +2652,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" dependencies = [ "pin-project-lite", - "tracing-attributes", "tracing-core", ] -[[package]] -name = "tracing-attributes" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "tracing-core" version = "0.1.36" @@ -3881,24 +2662,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" dependencies = [ "once_cell", - "valuable", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" -dependencies = [ - "matchers", - "nu-ansi-term", - "once_cell", - "parking_lot", - "regex-automata", - "sharded-slab", - "thread_local", - "tracing", - "tracing-core", ] [[package]] @@ -3907,54 +2670,18 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" -[[package]] -name = "typeid" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" - [[package]] name = "typenum" version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40ce102ab67701b8526c123c1bab5cbe42d7040ccfd0f64af1a385808d2f43de" -[[package]] -name = "typetag" -version = "0.2.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5a897b12c6c1151ad0b138b8db50252dc301f93bc3b027db05eec82aeed298c" -dependencies = [ - "erased-serde", - "inventory", - "once_cell", - "serde", - "typetag-impl", -] - -[[package]] -name = "typetag-impl" -version = "0.2.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf808357c6ed7e13ba0f3277ec8d8f21b2d501274895104263985330c726c1c5" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "unicode-ident" version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" -[[package]] -name = "unicode-segmentation" -version = "1.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9629274872b2bfaf8d66f5f15725007f635594914870f65218920345aa11aa8c" - [[package]] name = "unicode-xid" version = "0.2.6" @@ -3992,23 +2719,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" -[[package]] -name = "uuid" -version = "1.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd74a9687298c6858e9b88ec8935ec45d22e8fd5e6394fa1bd4e99a87789c76" -dependencies = [ - "getrandom 0.4.2", - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "valuable" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" - [[package]] name = "vcpkg" version = "0.2.15" @@ -4153,16 +2863,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "web-time" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - [[package]] name = "winapi" version = "0.3.9" @@ -4185,41 +2885,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows" -version = "0.61.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" -dependencies = [ - "windows-collections", - "windows-core 0.61.2", - "windows-future", - "windows-link 0.1.3", - "windows-numerics", -] - -[[package]] -name = "windows-collections" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" -dependencies = [ - "windows-core 0.61.2", -] - -[[package]] -name = "windows-core" -version = "0.61.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" -dependencies = [ - "windows-implement", - "windows-interface", - "windows-link 0.1.3", - "windows-result 0.3.4", - "windows-strings 0.4.2", -] - [[package]] name = "windows-core" version = "0.62.2" @@ -4228,20 +2893,9 @@ checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" dependencies = [ "windows-implement", "windows-interface", - "windows-link 0.2.1", - "windows-result 0.4.1", - "windows-strings 0.5.1", -] - -[[package]] -name = "windows-future" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" -dependencies = [ - "windows-core 0.61.2", - "windows-link 0.1.3", - "windows-threading", + "windows-link", + "windows-result", + "windows-strings", ] [[package]] @@ -4266,53 +2920,19 @@ dependencies = [ "syn", ] -[[package]] -name = "windows-link" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" - [[package]] name = "windows-link" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" -[[package]] -name = "windows-numerics" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" -dependencies = [ - "windows-core 0.61.2", - "windows-link 0.1.3", -] - -[[package]] -name = "windows-result" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" -dependencies = [ - "windows-link 0.1.3", -] - [[package]] name = "windows-result" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" dependencies = [ - "windows-link 0.2.1", -] - -[[package]] -name = "windows-strings" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" -dependencies = [ - "windows-link 0.1.3", + "windows-link", ] [[package]] @@ -4321,7 +2941,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" dependencies = [ - "windows-link 0.2.1", + "windows-link", ] [[package]] @@ -4366,7 +2986,7 @@ version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ - "windows-link 0.2.1", + "windows-link", ] [[package]] @@ -4406,7 +3026,7 @@ version = "0.53.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" dependencies = [ - "windows-link 0.2.1", + "windows-link", "windows_aarch64_gnullvm 0.53.1", "windows_aarch64_msvc 0.53.1", "windows_i686_gnu 0.53.1", @@ -4417,15 +3037,6 @@ dependencies = [ "windows_x86_64_msvc 0.53.1", ] -[[package]] -name = "windows-threading" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6" -dependencies = [ - "windows-link 0.1.3", -] - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" diff --git a/rustybits/Cargo.toml b/rustybits/Cargo.toml index abcd5afdd5..eb754d2b45 100644 --- a/rustybits/Cargo.toml +++ b/rustybits/Cargo.toml @@ -9,29 +9,8 @@ crate-type = ["staticlib", "rlib"] [features] default = ["zeroidc"] zeroidc = [] -ztcontroller = [ - "dep:serde", - "dep:serde_json", - "dep:temporal-sdk", - "dep:temporal-client", - "dep:temporal-sdk-core-protos", - "dep:tokio", - "dep:tokio-util", -] [dependencies] -serde = { version = "1", features = ["derive"], optional = true } -serde_json = { version = "1", optional = true } -temporal-sdk = { git = "https://github.com/temporalio/sdk-core", rev = "4614dcb8f4ffd2cb244eb0a19d7485c896e3459e", optional = true } -temporal-client = { git = "https://github.com/temporalio/sdk-core", rev = "4614dcb8f4ffd2cb244eb0a19d7485c896e3459e", features = ["telemetry"], optional = true } -temporal-sdk-core-protos = { git = "https://github.com/temporalio/sdk-core", rev = "4614dcb8f4ffd2cb244eb0a19d7485c896e3459e", optional = true} -tokio = { version = "1.43", features = [ - "full", - "rt", - "macros", -], optional = true } -tokio-util = { version = "0.7", optional = true } -uuid = { version = "1.4", features = ["v4"] } openidconnect = { version = "3.4", default-features = false, features = [ "reqwest", "native-tls", @@ -53,7 +32,6 @@ testcontainers-modules = { version = "0.12.1", features = [ [build-dependencies] cbindgen = "0.29" -prost-build = "0.14" [profile.release] strip = "debuginfo" diff --git a/rustybits/src/ext.rs b/rustybits/src/ext.rs index 32687bcaf9..09ed463e6e 100644 --- a/rustybits/src/ext.rs +++ b/rustybits/src/ext.rs @@ -8,47 +8,8 @@ use std::ffi::{CStr, CString}; use std::os::raw::c_char; -#[cfg(feature = "ztcontroller")] -use tokio::runtime; use url::Url; -#[cfg(feature = "ztcontroller")] -static mut RT: Option = None; - -#[cfg(feature = "ztcontroller")] -static START: std::sync::Once = std::sync::Once::new(); -#[cfg(feature = "ztcontroller")] -static SHUTDOWN: std::sync::Once = std::sync::Once::new(); - -#[cfg(feature = "ztcontroller")] -#[no_mangle] -pub unsafe extern "C" fn init_async_runtime() { - START.call_once(|| { - let rt = runtime::Builder::new_multi_thread() - .worker_threads(4) - .thread_name("rust-async-worker") - .enable_all() - .build() - .expect("Failed to create tokio runtime"); - - unsafe { RT = Some(rt) }; - }); -} - -#[cfg(feature = "ztcontroller")] -#[no_mangle] -#[allow(static_mut_refs)] -pub unsafe extern "C" fn shutdown_async_runtime() { - SHUTDOWN.call_once(|| { - // Shutdown the tokio runtime - unsafe { - if let Some(rt) = RT.take() { - rt.shutdown_timeout(std::time::Duration::from_secs(5)); - } - } - }); -} - #[cfg(feature = "zeroidc")] use crate::zeroidc::ZeroIDC; @@ -407,85 +368,3 @@ pub unsafe extern "C" fn zeroidc_kick_refresh_thread(idc: *mut ZeroIDC) { idc.kick_refresh_thread(); } - -#[cfg(feature = "ztcontroller")] -use crate::smeeclient::NetworkJoinedParams; -#[cfg(feature = "ztcontroller")] -use crate::smeeclient::SmeeClient; - -#[cfg(feature = "ztcontroller")] -#[no_mangle] -pub unsafe extern "C" fn smee_client_new( - temporal_url: *const c_char, - namespace: *const c_char, - task_queue: *const c_char, -) -> *mut SmeeClient { - let url = unsafe { - assert!(!temporal_url.is_null()); - CStr::from_ptr(temporal_url).to_str().unwrap() - }; - - let ns = unsafe { - assert!(!namespace.is_null()); - CStr::from_ptr(namespace).to_str().unwrap() - }; - - let tq = unsafe { - assert!(!task_queue.is_null()); - CStr::from_ptr(task_queue).to_str().unwrap() - }; - - match SmeeClient::new(url, ns, tq) { - Ok(c) => Box::into_raw(Box::new(c)), - Err(e) => { - println!("error creating smee client instance: {}", e); - std::ptr::null_mut() - } - } -} - -#[cfg(feature = "ztcontroller")] -#[no_mangle] -pub unsafe extern "C" fn smee_client_delete(ptr: *mut SmeeClient) { - if ptr.is_null() { - return; - } - let smee = unsafe { - assert!(!ptr.is_null()); - Box::from_raw(&mut *ptr) - }; - drop(smee); -} - -#[cfg(feature = "ztcontroller")] -#[no_mangle] -pub unsafe extern "C" fn smee_client_notify_network_joined( - smee_instance: *mut SmeeClient, - network_id: *const c_char, - member_id: *const c_char, -) -> bool { - let nwid = unsafe { - assert!(!network_id.is_null()); - CStr::from_ptr(network_id).to_str().unwrap() - }; - - let mem_id = unsafe { - assert!(!member_id.is_null()); - CStr::from_ptr(member_id).to_str().unwrap() - }; - - let smee = unsafe { - assert!(!smee_instance.is_null()); - &mut *smee_instance - }; - - let params = NetworkJoinedParams::new(nwid, mem_id); - - match smee.notify_network_joined(params) { - Ok(()) => true, - Err(e) => { - println!("error notifying network joined: {0}", e); - false - } - } -} diff --git a/rustybits/src/lib.rs b/rustybits/src/lib.rs index a11b77299c..e503343ef6 100644 --- a/rustybits/src/lib.rs +++ b/rustybits/src/lib.rs @@ -1,5 +1,3 @@ pub mod ext; -#[cfg(feature = "ztcontroller")] -pub mod smeeclient; #[cfg(feature = "zeroidc")] pub mod zeroidc; diff --git a/rustybits/src/smeeclient/mod.rs b/rustybits/src/smeeclient/mod.rs deleted file mode 100644 index 203444b60d..0000000000 --- a/rustybits/src/smeeclient/mod.rs +++ /dev/null @@ -1,98 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * (c) ZeroTier, Inc. - * https://www.zerotier.com/ - */ -use serde::{Deserialize, Serialize}; -use std::str::FromStr; -use temporal_client::{Client, ClientOptionsBuilder, RetryClient, WorkflowClientTrait, WorkflowOptions}; -use temporal_sdk_core_protos::{ - coresdk::AsJsonPayloadExt, - temporal::api::enums::v1::{WorkflowIdConflictPolicy, WorkflowIdReusePolicy}, -}; -use tokio::runtime::Handle; -use url::Url; -use uuid::Uuid; - -const CLIENT_NAME: &str = "SmeeClient-Rust"; -const CLIENT_VERSION: &str = "0.1"; -const NETWORK_JOINED_WORKFLOW: &str = "NetworkJoinedWorkflow"; - -#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] -pub struct NetworkJoinedParams { - #[serde(rename = "NetworkID")] - pub network_id: String, - - #[serde(rename = "MemberID")] - pub member_id: String, -} - -impl NetworkJoinedParams { - pub fn new(network_id: &str, member_id: &str) -> Self { - Self { - network_id: network_id.to_string(), - member_id: member_id.to_string(), - } - } -} - -pub struct SmeeClient { - client: RetryClient, - task_queue: String, -} - -impl SmeeClient { - pub fn new(temporal_url: &str, namespace: &str, task_queue: &str) -> Result> { - let rt = Handle::current(); - let c = ClientOptionsBuilder::default() - .target_url(Url::from_str(temporal_url).unwrap()) - .client_name(CLIENT_NAME) - .client_version(CLIENT_VERSION) - .build()?; - - let con = rt.block_on(async { c.connect(namespace.to_string(), None).await })?; - - Ok(Self { client: con, task_queue: task_queue.to_string() }) - } - - pub fn notify_network_joined(&self, params: NetworkJoinedParams) -> Result<(), Box> { - println!("notifying network joined"); - let options = WorkflowOptions { - id_reuse_policy: WorkflowIdReusePolicy::RejectDuplicate, - id_conflict_policy: WorkflowIdConflictPolicy::Fail, - execution_timeout: None, - completion_callbacks: Default::default(), - links: Default::default(), - priority: None, - run_timeout: None, - task_timeout: None, - cron_schedule: None, - search_attributes: None, - enable_eager_workflow_start: false, - retry_policy: Some(Default::default()), - }; - - let payload = vec![params.as_json_payload()?]; - - let workflow_id = Uuid::new_v4(); - - let rt = Handle::current(); - rt.block_on(async { - println!("calilng start_workflow"); - self.client - .start_workflow( - payload, - self.task_queue.clone(), - workflow_id.hyphenated().to_string(), - String::from(NETWORK_JOINED_WORKFLOW), - None, - options, - ) - .await - })?; - - Ok(()) - } -} diff --git a/rustybits/zeroidc.vcxproj b/rustybits/zeroidc.vcxproj index a4318fba52..be1efd0ef8 100644 --- a/rustybits/zeroidc.vcxproj +++ b/rustybits/zeroidc.vcxproj @@ -139,7 +139,7 @@ - + diff --git a/rustybits/zeroidc.vcxproj.filters b/rustybits/zeroidc.vcxproj.filters index 432c20f816..e2313077e8 100644 --- a/rustybits/zeroidc.vcxproj.filters +++ b/rustybits/zeroidc.vcxproj.filters @@ -23,7 +23,7 @@ - + Header Files diff --git a/windows/ZeroTierOne/ZeroTierOne.vcxproj b/windows/ZeroTierOne/ZeroTierOne.vcxproj index 2046974cb3..e02ff99c46 100644 --- a/windows/ZeroTierOne/ZeroTierOne.vcxproj +++ b/windows/ZeroTierOne/ZeroTierOne.vcxproj @@ -96,8 +96,6 @@ - - @@ -224,8 +222,6 @@ - - diff --git a/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters b/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters index 8c30bf323a..977a065d7d 100644 --- a/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters +++ b/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters @@ -285,12 +285,6 @@ Source Files\nonfree\controller - - Source Files\nonfree\controller - - - Source Files\nonfree\controller - Source Files\nonfree\controller @@ -557,12 +551,6 @@ Header Files\nonfree\controller - - Header Files\nonfree\controller - - - Header Files\nonfree\controller - Header Files\nonfree\controller From 378dd2736119bbe778fbd96178337b2eeaa84a08 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 12 Jun 2026 16:34:26 -0700 Subject: [PATCH 213/245] main controller cmake file cleanup --- CMakeLists.txt | 189 ++++++++++++++++++++++++++++++------------------- 1 file changed, 117 insertions(+), 72 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index da26af2d2b..fbfa08735a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,52 +1,90 @@ # CMake build script for libzerotiercore.a -cmake_minimum_required (VERSION 3.13) -project (zerotier-one LANGUAGES CXX C) +cmake_minimum_required(VERSION 3.15) +project(zerotier-one LANGUAGES CXX C) +# --------------------------------------------------------------------------- +# Options +# --------------------------------------------------------------------------- option(ZT1_CENTRAL_CONTROLLER "Build with ZeroTier Central Controller support" OFF) -option(ADDRESS_SANITIZER "Build with Address Sanitizer enabled (only for x86_64/arm64)" OFF -) -set (PROJ_DIR ${PROJECT_SOURCE_DIR}) +option(ADDRESS_SANITIZER "Build with Address Sanitizer enabled (only for x86_64/arm64)" OFF) + +set(PROJ_DIR ${PROJECT_SOURCE_DIR}) +# --------------------------------------------------------------------------- +# CPU architecture detection and architecture-specific flags +# --------------------------------------------------------------------------- execute_process(COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE CPU_ARCHITECTURE) set(CPU_ARCHITECTURE ${CPU_ARCHITECTURE} CACHE STRING "Target CPU architecture (detected automatically)") message(STATUS "Detected CPU architecture: ${CPU_ARCHITECTURE}") if(CPU_ARCHITECTURE STREQUAL "x86_64") add_definitions( - -DZT_ARCHITECTURE=2 - -DZT_USE_X64_ASM_SALSA=1 - -DZT_USE_X64_ASM_ED25519=1 - -DZT_SSO_SUPPORTED=1 - -DZT_USE_X64_ASM_SALSA2012=1 + -DZT_ARCHITECTURE=2 + -DZT_USE_X64_ASM_SALSA=1 + -DZT_USE_X64_ASM_ED25519=1 + -DZT_SSO_SUPPORTED=1 + -DZT_USE_X64_ASM_SALSA2012=1 -DZT_USE_FAST_X64_ED25519=1 ) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack") - - if(ADDRESS_SANITIZER) - add_compile_options(-fsanitize=address) - add_link_options(-fsanitize=address) - endif() elseif(CPU_ARCHITECTURE STREQUAL "aarch64" OR CPU_ARCHITECTURE STREQUAL "arm64") - add_definitions(-DZT_ARCHITECTURE=4 -DZT_ARCH_ARM_HAS_NEON=1 -DZT_SSO_SUPPORTED=1 -DZT_AES_NEON=1) + add_definitions( + -DZT_ARCHITECTURE=4 + -DZT_ARCH_ARM_HAS_NEON=1 + -DZT_SSO_SUPPORTED=1 + -DZT_AES_NEON=1 + ) add_compile_options(-march=armv8-a+crypto -mtune=generic -mstrict-align) - - if(ADDRESS_SANITIZER) - add_compile_options(-fsanitize=address) - add_link_options(-fsanitize=address) - endif() endif() -include(FetchContent) -include(ExternalProject) +# Address Sanitizer is only supported on x86_64/arm64. +if(ADDRESS_SANITIZER AND (CPU_ARCHITECTURE STREQUAL "x86_64" + OR CPU_ARCHITECTURE STREQUAL "aarch64" + OR CPU_ARCHITECTURE STREQUAL "arm64")) + add_compile_options(-fsanitize=address) + add_link_options(-fsanitize=address) +endif() + +# --------------------------------------------------------------------------- +# C++ language standard +# --------------------------------------------------------------------------- +if(ZT1_CENTRAL_CONTROLLER) + set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to" FORCE) + set(CMAKE_CXX_STANDARD_REQUIRED True CACHE BOOL "C++ standard required" FORCE) + set(CMAKE_CXX_EXTENSIONS ON CACHE BOOL "Enable compiler-specific extensions" FORCE) +else() + set(CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard to conform to") + set(CMAKE_CXX_STANDARD_REQUIRED True CACHE BOOL "C++ standard required") + set(CMAKE_CXX_EXTENSIONS ON CACHE BOOL "Enable compiler-specific extensions") +endif() +# --------------------------------------------------------------------------- +# Global compile definitions +# --------------------------------------------------------------------------- add_definitions(-DCMAKE_BUILD) +if(ZT1_CENTRAL_CONTROLLER) + add_definitions( + -DZT_NONFREE_CONTROLLER=1 + -DZT_CONTROLLER_USE_LIBPQ=1 + -DZT1_CENTRAL_CONTROLLER=1 + -DZT_OPENTELEMETRY_ENABLED=1 + -DZT_NO_PEER_METRICS=1 + ) +endif() + +# --------------------------------------------------------------------------- +# Dependencies +# --------------------------------------------------------------------------- +include(FetchContent) +include(ExternalProject) + find_package(OpenSSL REQUIRED) find_package(nlohmann_json REQUIRED) find_package(inja REQUIRED) -set(CMAKE_THREDAD_PREFER_PTHREAD TRUE CACHE INTERNAL "Use pthreads" FORCE) +# Threads (prefer pthreads) set(THREADS_PREFER_PTHREAD_FLAG TRUE CACHE INTERNAL "Use pthreads" FORCE) find_package(Threads REQUIRED) if(CMAKE_USE_PTHREADS_INIT) @@ -54,63 +92,63 @@ if(CMAKE_USE_PTHREADS_INIT) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") endif() +# OpenTelemetry: the controller build needs the full SDK + exporters; everyone +# else only needs the API. if(ZT1_CENTRAL_CONTROLLER) find_package(PostgreSQL REQUIRED) - find_package(opentelemetry-cpp REQUIRED COMPONENTS api sdk exporters_otlp_grpc exporters_otlp_http exporters_prometheus ) + find_package(opentelemetry-cpp REQUIRED COMPONENTS api sdk exporters_otlp_grpc exporters_otlp_http exporters_prometheus) find_package(google_cloud_cpp_bigtable REQUIRED) find_package(google_cloud_cpp_pubsub REQUIRED) else() find_package(opentelemetry-cpp REQUIRED COMPONENTS api) endif() -if(ZT1_CENTRAL_CONTROLLER) - set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to" FORCE) - set(CMAKE_CXX_STANDARD_REQUIRED True CACHE BOOL "C++ standard required" FORCE) - set(CMAKE_CXX_EXTENSIONS ON CACHE BOOL "Enable compiler-specific extensions" FORCE) - add_definitions(-DZT_NONFREE_CONTROLLER=1 -DZT_CONTROLLER_USE_LIBPQ=1 -DZT1_CENTRAL_CONTROLLER=1 -DZT_OPENTELEMETRY_ENABLED=1 -DZT_NO_PEER_METRICS=1) -else() - set(CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard to conform to") - set(CMAKE_CXX_STANDARD_REQUIRED True CACHE BOOL "C++ standard required") - set(CMAKE_CXX_EXTENSIONS ON CACHE BOOL "Enable compiler-specific extensions") -endif() +# Dependencies not provided by conda. +include(cmake/cpp-httplib.cmake) +include(cmake/redis-plus-plus.cmake) +include(cmake/miniupnpc.cmake) -# rustybits build command (unquoted so it expands as separate shell arguments) -set(RUST_BUILD_COMMAND cargo build --release) +# --------------------------------------------------------------------------- +# rustybits (built via cargo, linked as a static library) +# --------------------------------------------------------------------------- +set(RUSTYBITS_LIB ${PROJ_DIR}/rustybits/target/release/librustybits.a) +set(RUSTYBITS_INCLUDE_DIR ${PROJ_DIR}/rustybits/target) -# build rustybits ExternalProject_Add( rustybits_build DOWNLOAD_COMMAND "" CONFIGURE_COMMAND "" - # PREFIX ${PROJ_DIR}/rustybits - BUILD_COMMAND cd ${PROJ_DIR}/rustybits && ${RUST_BUILD_COMMAND} + BUILD_COMMAND cd ${PROJ_DIR}/rustybits && cargo build --release INSTALL_COMMAND "" - BUILD_BYPRODUCTS ${PROJ_DIR}/rustybits/target/release/librustybits.a ${PROJ_DIR}/rustybits/target/rustybits.h - ) -set(RUSTYBITS_LIB ${PROJ_DIR}/rustybits/target/release/librustybits.a) -set(RUSTYBITS_INCLUDE_DIR ${PROJ_DIR}/rustybits/target) + BUILD_BYPRODUCTS ${RUSTYBITS_LIB} ${RUSTYBITS_INCLUDE_DIR}/rustybits.h +) + add_library(rustybits STATIC IMPORTED GLOBAL) set_property(TARGET rustybits PROPERTY IMPORTED_LOCATION ${RUSTYBITS_LIB}) add_dependencies(rustybits rustybits_build) +# Make `make clean` also clean rustybits. CMake's clean target can only delete +# files (it can't run `cargo clean`), but removing the target dir is exactly +# what `cargo clean` does. +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${PROJ_DIR}/rustybits/target) - -# Get & build dependencies not in conda -include (cmake/cpp-httplib.cmake) -include (cmake/redis-plus-plus.cmake) -include (cmake/miniupnpc.cmake) - +# --------------------------------------------------------------------------- +# Subdirectories +# --------------------------------------------------------------------------- add_subdirectory(ext) add_subdirectory(node) add_subdirectory(osdep) add_subdirectory(service) add_subdirectory(nonfree) +# --------------------------------------------------------------------------- +# Link libraries +# --------------------------------------------------------------------------- set(LINKED_LIBRARIES prometheus-cpp-lite zerotier-service zerotier-osdep - zerotier-core + zerotier-core zerotier-controller Threads::Threads nlohmann_json::nlohmann_json @@ -118,50 +156,57 @@ set(LINKED_LIBRARIES rustybits OpenSSL::Crypto OpenSSL::SSL - Threads::Threads ) +# Controller-only OpenTelemetry exporters. if(ZT1_CENTRAL_CONTROLLER) - list(APPEND LINKED_LIBRARIES + list(APPEND LINKED_LIBRARIES opentelemetry-cpp::sdk opentelemetry-cpp::trace opentelemetry-cpp::proto_grpc opentelemetry-cpp::otlp_grpc_client opentelemetry-cpp::otlp_grpc_exporter opentelemetry-cpp::otlp_grpc_log_record_exporter - opentelemetry-cpp::otlp_grpc_metrics_exporter + opentelemetry-cpp::otlp_grpc_metrics_exporter opentelemetry-cpp::otlp_http_exporter - opentelemetry-cpp::otlp_http_log_record_exporter - opentelemetry-cpp::otlp_http_metric_exporter + opentelemetry-cpp::otlp_http_log_record_exporter + opentelemetry-cpp::otlp_http_metric_exporter opentelemetry-cpp::prometheus_exporter - ) + ) endif() -if (APPLE) +# Apple system frameworks. +if(APPLE) find_library(COREFOUNDATION_LIBRARY CoreFoundation) find_library(SECURITY_LIBRARY Security) find_library(SYSTEM_CONFIGURATION_LIBRARY SystemConfiguration) - find_library(CARBON Carbon) + find_library(CARBON_LIBRARY Carbon) find_library(CORESERVICES_LIBRARY CoreServices) - list(APPEND LINKED_LIBRARIES ${COREFOUNDATION_LIBRARY} ${SECURITY_LIBRARY} ${CARBON_LIBRARY} ${SYSTEM_CONFIGURATION_LIBRARY} ${CORESERVICES_LIBRARY}) + list(APPEND LINKED_LIBRARIES + ${COREFOUNDATION_LIBRARY} + ${SECURITY_LIBRARY} + ${CARBON_LIBRARY} + ${SYSTEM_CONFIGURATION_LIBRARY} + ${CORESERVICES_LIBRARY} + ) endif() -add_executable(zerotier-one - one.cpp - ext/http-parser/http_parser.c) - -target_link_libraries(zerotier-one - ${LINKED_LIBRARIES} +# --------------------------------------------------------------------------- +# Targets +# --------------------------------------------------------------------------- +add_executable(zerotier-one + one.cpp + ext/http-parser/http_parser.c ) +target_link_libraries(zerotier-one ${LINKED_LIBRARIES}) -add_executable(zerotier-selftest - selftest.cpp +add_executable(zerotier-selftest + selftest.cpp ) - -target_link_libraries(zerotier-selftest +target_link_libraries(zerotier-selftest zerotier-core zerotier-osdep Threads::Threads - nlohmann_json::nlohmann_json + nlohmann_json::nlohmann_json prometheus-cpp-lite - Threads::Threads) +) From 052ea5563612eaedb95233a6f1e61684cacd9328 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 12 Jun 2026 17:15:30 -0700 Subject: [PATCH 214/245] bring CMake in line with make-linux/mac/bsd --- CMakeLists.txt | 280 +++++++++++++++++++++++++++++++++++++++----- node/CMakeLists.txt | 33 +++++- 2 files changed, 276 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fbfa08735a..471465ea78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,56 +8,213 @@ project(zerotier-one LANGUAGES CXX C) # --------------------------------------------------------------------------- option(ZT1_CENTRAL_CONTROLLER "Build with ZeroTier Central Controller support" OFF) option(ADDRESS_SANITIZER "Build with Address Sanitizer enabled (only for x86_64/arm64)" OFF) +option(EXT_OSDEP "Build with external osdep feature" OFF) +option(ZT_IA32 "Force a 32-bit (i386) build on x86 hosts mismarked as i386" OFF) + +# Feature toggles mirrored from make-linux.mk's ZT_* switches. +option(ZT_TRACE "Enable tracing (-DZT_TRACE)" OFF) +option(ZT_RULES_ENGINE_DEBUGGING "Enable rules-engine debugging" OFF) +option(ZT_DEBUG_TRACE "Enable debug tracing" OFF) +option(ZT_USE_TEST_TAP "Build with the test tap device" OFF) +option(ZT_VAULT_SUPPORT "Enable HashiCorp Vault support (links libcurl)" OFF) +option(ZT_STATIC "Link the executables statically" OFF) +option(ZT_QNAP "Build for QNAP (embedded)" OFF) +option(ZT_UBIQUITI "Build for Ubiquiti (embedded)" OFF) +option(ZT_SYNOLOGY "Build for Synology (embedded)" OFF) set(PROJ_DIR ${PROJECT_SOURCE_DIR}) +# make builds release by default and switches to debug flags under ZT_DEBUG=1; +# mirror that with CMAKE_BUILD_TYPE, defaulting to Release when unset. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel) +endif() + # --------------------------------------------------------------------------- # CPU architecture detection and architecture-specific flags +# +# Translated from make-linux.mk. CMAKE_SYSTEM_PROCESSOR is CMake's canonical +# target-processor variable: it reflects the host for native builds and is set +# by the toolchain file when cross-compiling. ZT_ARCHITECTURE mirrors the +# numeric arch codes used by the Makefile and is exported to the binary as +# ZT_BUILD_ARCHITECTURE (read by one.cpp via version.h). +# +# Note: node/Constants.hpp already auto-defines ZT_NO_TYPE_PUNNING for every +# non-x86 architecture, and AES.hpp auto-defines ZT_AES_NEON whenever ARM +# crypto extensions are present (-march=armv8-a+crypto). The explicit -D flags +# below are therefore belt-and-suspenders that keep this a faithful mirror of +# make-linux.mk. # --------------------------------------------------------------------------- -execute_process(COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE CPU_ARCHITECTURE) -set(CPU_ARCHITECTURE ${CPU_ARCHITECTURE} CACHE STRING "Target CPU architecture (detected automatically)") -message(STATUS "Detected CPU architecture: ${CPU_ARCHITECTURE}") +string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" CPU_ARCHITECTURE) +message(STATUS "Target CPU (CMAKE_SYSTEM_PROCESSOR): ${CMAKE_SYSTEM_PROCESSOR}") -if(CPU_ARCHITECTURE STREQUAL "x86_64") - add_definitions( - -DZT_ARCHITECTURE=2 - -DZT_USE_X64_ASM_SALSA=1 - -DZT_USE_X64_ASM_ED25519=1 - -DZT_SSO_SUPPORTED=1 - -DZT_USE_X64_ASM_SALSA2012=1 - -DZT_USE_FAST_X64_ED25519=1 - ) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack") +# ZeroTier architecture code (see node/Constants.hpp); 999 = unknown. +set(ZT_ARCHITECTURE 999) +# Crypto-assembly gates, also consumed by node/CMakeLists.txt to select sources. +set(ZT_USE_X64_ASM_SALSA FALSE) +set(ZT_USE_X64_ASM_ED25519 FALSE) +set(ZT_USE_ARM32_NEON_ASM_CRYPTO FALSE) +set(ZT_SSO_SUPPORTED FALSE) + +if(CPU_ARCHITECTURE STREQUAL "x86_64" OR CPU_ARCHITECTURE STREQUAL "amd64") + set(ZT_ARCHITECTURE 2) + set(ZT_USE_X64_ASM_SALSA TRUE) + set(ZT_USE_X64_ASM_ED25519 TRUE) + set(ZT_SSO_SUPPORTED TRUE) + add_compile_options(-msse -msse2) +elseif(CPU_ARCHITECTURE STREQUAL "e2k" OR CPU_ARCHITECTURE STREQUAL "e2k64") + # Elbrus 2000: x86-compatible arch code, but no x86 crypto assembly. + set(ZT_ARCHITECTURE 2) +elseif(CPU_ARCHITECTURE STREQUAL "i386" OR CPU_ARCHITECTURE STREQUAL "i486" + OR CPU_ARCHITECTURE STREQUAL "i586" OR CPU_ARCHITECTURE STREQUAL "i686") + set(ZT_ARCHITECTURE 1) + set(ZT_SSO_SUPPORTED TRUE) elseif(CPU_ARCHITECTURE STREQUAL "aarch64" OR CPU_ARCHITECTURE STREQUAL "arm64") - add_definitions( - -DZT_ARCHITECTURE=4 - -DZT_ARCH_ARM_HAS_NEON=1 - -DZT_SSO_SUPPORTED=1 - -DZT_AES_NEON=1 - ) + set(ZT_ARCHITECTURE 4) + set(ZT_SSO_SUPPORTED TRUE) + add_definitions(-DZT_NO_TYPE_PUNNING -DZT_ARCH_ARM_HAS_NEON) add_compile_options(-march=armv8-a+crypto -mtune=generic -mstrict-align) +elseif(CPU_ARCHITECTURE MATCHES "^(arm|armel|armhf|armv6|armv6l|armv6k|armv6kz|armv6zk|armv7|armv7l|armv7hl|armv7ve)$") + set(ZT_ARCHITECTURE 3) + set(ZT_USE_ARM32_NEON_ASM_CRYPTO TRUE) + add_definitions(-DZT_NO_TYPE_PUNNING) + if(CPU_ARCHITECTURE STREQUAL "armhf") + set(ZT_SSO_SUPPORTED TRUE) + endif() +elseif(CPU_ARCHITECTURE STREQUAL "powerpc64le") + set(ZT_ARCHITECTURE 8) + add_definitions(-DZT_NO_TYPE_PUNNING) +elseif(CPU_ARCHITECTURE STREQUAL "powerpc") + set(ZT_ARCHITECTURE 8) + add_definitions(-DZT_NO_TYPE_PUNNING -DZT_NO_CAPABILITIES) +elseif(CPU_ARCHITECTURE STREQUAL "ppc64le" OR CPU_ARCHITECTURE STREQUAL "ppc64el") + set(ZT_ARCHITECTURE 8) +elseif(CPU_ARCHITECTURE STREQUAL "mips" OR CPU_ARCHITECTURE STREQUAL "mipsel") + set(ZT_ARCHITECTURE 5) + add_definitions(-DZT_NO_TYPE_PUNNING) +elseif(CPU_ARCHITECTURE STREQUAL "mips64" OR CPU_ARCHITECTURE STREQUAL "mips64el") + set(ZT_ARCHITECTURE 6) + add_definitions(-DZT_NO_TYPE_PUNNING) +elseif(CPU_ARCHITECTURE STREQUAL "s390x") + set(ZT_ARCHITECTURE 16) +elseif(CPU_ARCHITECTURE STREQUAL "riscv64") + set(ZT_ARCHITECTURE 0) +elseif(CPU_ARCHITECTURE STREQUAL "loongarch64") + set(ZT_ARCHITECTURE 17) + add_definitions(-DZT_NO_TYPE_PUNNING) +endif() + +# Embedded platform markers (make-linux.mk); these also disable SSO. +if(ZT_QNAP) + add_definitions(-D__QNAP__) + set(ZT_EMBEDDED TRUE) +endif() +if(ZT_UBIQUITI) + add_definitions(-D__UBIQUITI__) + set(ZT_EMBEDDED TRUE) +endif() +if(ZT_SYNOLOGY) + add_definitions(-D__SYNOLOGY__) + set(ZT_EMBEDDED TRUE) +endif() + +# SSO is unavailable for external-osdep and embedded builds (make-linux.mk). +if(EXT_OSDEP OR ZT_EMBEDDED) + set(ZT_SSO_SUPPORTED FALSE) +endif() + +# Fail if the architecture could not be determined. +if(ZT_ARCHITECTURE EQUAL 999) + message(FATAL_ERROR + "Unsupported/undetected CPU architecture '${CMAKE_SYSTEM_PROCESSOR}'. " + "Add a case for it above (mirror make-linux.mk).") +endif() +message(STATUS "ZeroTier architecture code (ZT_BUILD_ARCHITECTURE): ${ZT_ARCHITECTURE}") + +# Intel 32-bit override: some images mismark x86_64 as i386. Force 32-bit and +# disable x86-64 crypto assembly. +if(ZT_IA32) + add_compile_options(-m32) + add_link_options(-m32) + set(ZT_USE_X64_ASM_SALSA FALSE) + set(ZT_USE_X64_ASM_ED25519 FALSE) +endif() + +# "ARM32 hell": conservative per-board flags. Mirrors make-linux.mk, which +# branches on the Debian architecture (host-based dpkg probe, as in the +# Makefile) and the EXT_OSDEP feature. NEON crypto assembly ends up disabled +# on arm32 except in the EXT_OSDEP path. +if(ZT_ARCHITECTURE EQUAL 3) + execute_process( + COMMAND dpkg --print-architecture + OUTPUT_VARIABLE ZT_DPKG_ARCH + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) + if(ZT_DPKG_ARCH STREQUAL "armel") + add_compile_options(-march=armv5t -mfloat-abi=soft -msoft-float -mno-unaligned-access -marm) + set(ZT_USE_ARM32_NEON_ASM_CRYPTO FALSE) + elseif(NOT EXT_OSDEP) + add_compile_options(-mfloat-abi=hard -march=armv6zk -marm -mfpu=vfp -mno-unaligned-access -mtp=cp15 -mcpu=arm1176jzf-s) + add_compile_options($<$:-fexceptions>) + set(ZT_USE_ARM32_NEON_ASM_CRYPTO FALSE) + else() + add_definitions(-DZT_NO_PEER_METRICS) + endif() +endif() + +# Single sign-on (OIDC) support. +if(ZT_SSO_SUPPORTED) + add_definitions(-DZT_SSO_SUPPORTED=1) +endif() + +# Faster crypto assembly. These -D gates pair with the source selection in +# node/CMakeLists.txt, which reads the ZT_USE_*_ASM_* variables set above. +if(ZT_USE_X64_ASM_SALSA) + add_definitions(-DZT_USE_X64_ASM_SALSA2012) +endif() +if(ZT_USE_X64_ASM_ED25519) + add_definitions(-DZT_USE_FAST_X64_ED25519) +endif() +if(ZT_USE_ARM32_NEON_ASM_CRYPTO) + add_definitions(-DZT_USE_ARM32_NEON_ASM_SALSA2012) endif() -# Address Sanitizer is only supported on x86_64/arm64. -if(ADDRESS_SANITIZER AND (CPU_ARCHITECTURE STREQUAL "x86_64" - OR CPU_ARCHITECTURE STREQUAL "aarch64" - OR CPU_ARCHITECTURE STREQUAL "arm64")) +# Build platform code reported into the binary (read by one.cpp via version.h). +# Codes match the other build systems: make-linux.mk = 1, Windows .vcxproj = 2, +# make-mac.mk = 3, root Makefile FreeBSD = 7 / OpenBSD = 9. NetBSD has no +# assigned code anywhere, so it falls back to version.h's default of 0. +if(APPLE) + set(ZT_BUILD_PLATFORM 3) +elseif(WIN32) + set(ZT_BUILD_PLATFORM 2) +elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + set(ZT_BUILD_PLATFORM 7) +elseif(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") + set(ZT_BUILD_PLATFORM 9) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(ZT_BUILD_PLATFORM 1) +else() + set(ZT_BUILD_PLATFORM 0) +endif() +add_definitions(-DZT_BUILD_PLATFORM=${ZT_BUILD_PLATFORM} -DZT_BUILD_ARCHITECTURE=${ZT_ARCHITECTURE}) + +# Address Sanitizer (only meaningful on x86_64/arm64). +if(ADDRESS_SANITIZER AND (ZT_ARCHITECTURE EQUAL 2 OR ZT_ARCHITECTURE EQUAL 4)) add_compile_options(-fsanitize=address) add_link_options(-fsanitize=address) endif() # --------------------------------------------------------------------------- # C++ language standard +# +# make-linux.mk compiles everything as C++17 (controller and daemon alike), so +# we do the same. Extensions stay ON, which yields -std=gnu++17 -- a superset of +# the Makefile's -std=c++17, so anything that builds under make also builds here. # --------------------------------------------------------------------------- -if(ZT1_CENTRAL_CONTROLLER) - set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to" FORCE) - set(CMAKE_CXX_STANDARD_REQUIRED True CACHE BOOL "C++ standard required" FORCE) - set(CMAKE_CXX_EXTENSIONS ON CACHE BOOL "Enable compiler-specific extensions" FORCE) -else() - set(CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard to conform to") - set(CMAKE_CXX_STANDARD_REQUIRED True CACHE BOOL "C++ standard required") - set(CMAKE_CXX_EXTENSIONS ON CACHE BOOL "Enable compiler-specific extensions") -endif() +set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to" FORCE) +set(CMAKE_CXX_STANDARD_REQUIRED True CACHE BOOL "C++ standard required" FORCE) +set(CMAKE_CXX_EXTENSIONS ON CACHE BOOL "Enable compiler-specific extensions" FORCE) # --------------------------------------------------------------------------- # Global compile definitions @@ -74,6 +231,59 @@ if(ZT1_CENTRAL_CONTROLLER) ) endif() +# --------------------------------------------------------------------------- +# Compiler and linker flags (translated from make-linux.mk) +# +# CMAKE_BUILD_TYPE supplies -O3 -DNDEBUG for Release and -g for Debug; the lines +# below add the remaining flags make uses so the two builds match. make applies +# these to ZeroTier's own objects only; here they are global, so bundled +# third-party targets see them too (harmless -- we set no -Werror). +# --------------------------------------------------------------------------- + +# Warnings + position independence: every configuration, matching make. +add_compile_options(-Wall -Wno-deprecated -fPIC -fPIE) + +# Release adds a stack protector; debug uses -O1 globally (with -O2 for the hot +# crypto sources, set per-file in node/CMakeLists.txt). +add_compile_options($<$>:-fstack-protector>) +add_compile_options($<$:-O1>) + +# make's debug build also defines these (ZT_DEBUG implies ZT_TRACE). +add_compile_definitions($<$:ZT_DEBUG> $<$:ZT_TRACE>) + +# Stop libstdc++ from pulling in its mt/pool/extptr/debug allocators (no-op on +# macOS/libc++). +add_definitions(-D_MT_ALLOCATOR_H -D_POOL_ALLOCATOR_H -D_EXTPTR_ALLOCATOR_H -D_DEBUG_ALLOCATOR_H) + +# GNU-ld hardening (not understood by the macOS linker). make applies +# -Wl,-z,noexecstack to every build and -pie -Wl,-z,relro,-z,now to release, and +# disables self-update on Linux/BSD (left to package management). +if(NOT APPLE) + string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,-z,noexecstack") + string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE " -pie -Wl,-z,relro,-z,now") + add_compile_definitions(ZT_SOFTWARE_UPDATE_DEFAULT="disable") +endif() + +# Optional feature toggles (mirror make-linux.mk's ZT_* switches). +if(ZT_TRACE) + add_definitions(-DZT_TRACE) +endif() +if(ZT_RULES_ENGINE_DEBUGGING) + add_definitions(-DZT_RULES_ENGINE_DEBUGGING) +endif() +if(ZT_DEBUG_TRACE) + add_definitions(-DZT_DEBUG_TRACE) +endif() +if(ZT_USE_TEST_TAP) + add_definitions(-DZT_USE_TEST_TAP) +endif() +if(ZT_VAULT_SUPPORT) + add_definitions(-DZT_VAULT_SUPPORT=1) +endif() +if(ZT_STATIC) + string(APPEND CMAKE_EXE_LINKER_FLAGS " -static") +endif() + # --------------------------------------------------------------------------- # Dependencies # --------------------------------------------------------------------------- @@ -175,6 +385,12 @@ if(ZT1_CENTRAL_CONTROLLER) ) endif() +# HashiCorp Vault support links libcurl (make-linux.mk). +if(ZT_VAULT_SUPPORT) + find_package(CURL REQUIRED) + list(APPEND LINKED_LIBRARIES CURL::libcurl) +endif() + # Apple system frameworks. if(APPLE) find_library(COREFOUNDATION_LIBRARY CoreFoundation) diff --git a/node/CMakeLists.txt b/node/CMakeLists.txt index b74935e1cd..e239f4df07 100644 --- a/node/CMakeLists.txt +++ b/node/CMakeLists.txt @@ -5,12 +5,21 @@ project(zerotier-core LANGUAGES CXX ASM) file (GLOB core_src_glob ${PROJ_DIR}/node/*.cpp) file (GLOB core_hdr_glob ${PROJ_DIR}/node/*.hpp) -if(${CPU_ARCHITECTURE} STREQUAL "x86_64") - set(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp -z noexecstack") +# Crypto assembly sources are selected by the ZT_USE_*_ASM_* gates set in the +# top-level CMakeLists.txt (which derives them from the target architecture). +if(ZT_USE_X64_ASM_SALSA OR ZT_USE_X64_ASM_ED25519 OR ZT_USE_ARM32_NEON_ASM_CRYPTO) + set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -x assembler-with-cpp -z noexecstack") +endif() + +if(ZT_USE_X64_ASM_SALSA) set(ASM_SALSA_DIR ${CMAKE_SOURCE_DIR}/ext/x64-salsa2012-asm) + list(APPEND core_src_glob ${ASM_SALSA_DIR}/salsa2012.s) + list(APPEND core_hdr_glob ${ASM_SALSA_DIR}/salsa2012.h) +endif() + +if(ZT_USE_X64_ASM_ED25519) set(ASM_ED25519_DIR ${CMAKE_SOURCE_DIR}/ext/ed25519-amd64-asm) list(APPEND core_src_glob - ${ASM_SALSA_DIR}/salsa2012.s #${ASM_ED25519_DIR}/batch.c ${ASM_ED25519_DIR}/choose_t.s ${ASM_ED25519_DIR}/consts.s @@ -69,17 +78,31 @@ if(${CPU_ARCHITECTURE} STREQUAL "x86_64") ${ASM_ED25519_DIR}/ull4_mul.s ) list(APPEND core_hdr_glob - ${ASM_SALSA_DIR}/salsa2012.h ${ASM_ED25519_DIR}/fe25519.h ${ASM_ED25519_DIR}/ge25519.h ${ASM_ED25519_DIR}/hram.h ${ASM_ED25519_DIR}/index_heap.h ${ASM_ED25519_DIR}/sc25519.h) set_property(SOURCE ${ASM_ED25519_DIR}/fe25519_freeze.s PROPERTY COMPILE_FLAGS "-z noexecstack") -elseif(${CPU_ARCHITECTURE} STREQUAL "aarch64") +endif() +if(ZT_USE_ARM32_NEON_ASM_CRYPTO) + set(ASM_ARM32_DIR ${CMAKE_SOURCE_DIR}/ext/arm32-neon-salsa2012-asm) + list(APPEND core_src_glob ${ASM_ARM32_DIR}/salsa2012.s) + list(APPEND core_hdr_glob ${ASM_ARM32_DIR}/salsa2012.h) endif() +# Optimize the hot crypto sources at -O2 even in debug builds; make-linux.mk +# does this because C25519 in particular is unusably slow at -O0/-O1. (No effect +# in release, where everything is already -O3.) +set_property( + SOURCE + ${PROJ_DIR}/node/Salsa20.cpp + ${PROJ_DIR}/node/SHA512.cpp + ${PROJ_DIR}/node/C25519.cpp + ${PROJ_DIR}/node/Poly1305.cpp + APPEND PROPERTY COMPILE_OPTIONS $<$:-O2>) + add_library(zerotier-core STATIC ${core_src_glob} ${core_hdr_glob}) target_include_directories(zerotier-core From e09e7b5c9b8a16689017e4597b2c5882feba33d3 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 12 Jun 2026 17:41:45 -0700 Subject: [PATCH 215/245] Fix PIC/PIE flags --- CMakeLists.txt | 10 ++++++++-- cmake/redis-plus-plus.cmake | 5 +++-- nonfree/controller/CMakeLists.txt | 7 ++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 471465ea78..1cda80a85a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -240,8 +240,14 @@ endif() # third-party targets see them too (harmless -- we set no -Werror). # --------------------------------------------------------------------------- -# Warnings + position independence: every configuration, matching make. -add_compile_options(-Wall -Wno-deprecated -fPIC -fPIE) +# Warnings: every configuration, matching make. +add_compile_options(-Wall -Wno-deprecated) + +# Position independence: PIC for all libraries, PIE for the executables (paired +# with -pie below). Equivalent to make's -fPIC -fPIE hardening, applied the +# idiomatic CMake way so -fPIE does NOT leak into bundled shared libraries +# (e.g. redis++), which fails to link on aarch64. +set(CMAKE_POSITION_INDEPENDENT_CODE ON) # Release adds a stack protector; debug uses -O1 globally (with -O2 for the hot # crypto sources, set per-file in node/CMakeLists.txt). diff --git a/cmake/redis-plus-plus.cmake b/cmake/redis-plus-plus.cmake index 7fa99ea733..7b13edd09a 100644 --- a/cmake/redis-plus-plus.cmake +++ b/cmake/redis-plus-plus.cmake @@ -7,13 +7,14 @@ FetchContent_Declare( GIT_SHALLOW ON ) set(REDIS_PLUS_PLUS_BUILD_STATIC ON CACHE INTERNAL "Build static library" FORCE) -set(REDIS_PLUS_PLUS_BUILD_SHARED ON CACHE INTERNAL "Build shared library" FORCE) +# We only link redis++::redis++_static, so skip the unused shared library. +set(REDIS_PLUS_PLUS_BUILD_SHARED OFF CACHE INTERNAL "Build shared library" FORCE) set(REDIS_PLUS_PLUS_BUILD_TEST OFF CACHE INTERNAL "Build tests" FORCE) set(REDIS_PLUS_PLUS_BUILD_STATIC_WITH_PIC ON CACHE INTERNAL "Build static library with PIC" FORCE) set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Build shared libraries" FORCE) FetchContent_MakeAvailable(redis-plus-plus) if(NOT TARGET redis++::redis++_static) - message(FATAL_ERROR "A required redis-plus-plus target (redis++::redis++) was not imported") + message(FATAL_ERROR "A required redis-plus-plus target (redis++::redis++_static) was not imported") endif() message(STATUS "redis-plus-plus imported") diff --git a/nonfree/controller/CMakeLists.txt b/nonfree/controller/CMakeLists.txt index 5fdf424662..72ae44a367 100644 --- a/nonfree/controller/CMakeLists.txt +++ b/nonfree/controller/CMakeLists.txt @@ -91,7 +91,12 @@ endif() target_include_directories(zerotier-controller PRIVATE ${INCLUDE_DIRS}) -add_dependencies(zerotier-controller redis++::redis++) +# redis++ is only used by the central controller; depend on the static target +# (the only one we build). target_link_libraries below already orders the build, +# so this is belt-and-suspenders. +if (ZT1_CENTRAL_CONTROLLER) + add_dependencies(zerotier-controller redis++::redis++_static) +endif() target_link_libraries(zerotier-controller ${LINK_LIBS} From 0e637a1de65fd23440c995280ae5c5feb658b685 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 15 Jun 2026 12:59:32 -0700 Subject: [PATCH 216/245] More linux/mac cmake cleanup * Brewfile for homebrew dependencies on macos * Pull & build google-cloud-cpp/otel via bootstrap script rather than keeping it all in the ext/ subfolder. * Update controller CI build with new steps --- .dockerignore | 10 + .github/workflows/central-controller.yaml | 16 +- .gitignore | 5 + Brewfile | 28 + CMakeLists.txt | 40 +- cmake/inja.cmake | 18 + cmake/redis-plus-plus.cmake | 10 +- conda_env_build.yml | 20 - conda_env_run.yml | 14 - ext/central-controller-docker/Dockerfile | 79 +- .../Dockerfile.builder | 34 - .../Dockerfile.conda | 25 - .../Dockerfile.conda_builder | 10 - ext/central-controller-docker/Dockerfile.new | 25 - .../Dockerfile.run_base | 19 - ext/central-controller-docker/Makefile | 16 - ext/central-controller-docker/main-new.sh | 226 - ext/central-controller-docker/main.sh | 133 +- ext/opentelemetry-cpp-1.21.0/.bazelignore | 3 - ext/opentelemetry-cpp-1.21.0/.bazelrc | 41 - ext/opentelemetry-cpp-1.21.0/.bazelversion | 1 - ext/opentelemetry-cpp-1.21.0/.clang-format | 73 - ext/opentelemetry-cpp-1.21.0/.clang-tidy | 42 - ext/opentelemetry-cpp-1.21.0/.cmake-format.py | 7 - .../.copyright-ignore | 52 - .../.devcontainer/Dockerfile.conan | 55 - .../.devcontainer/Dockerfile.dev | 58 - .../.devcontainer/README.md | 65 - .../.devcontainer/customize_container.sh | 39 - .../.devcontainer/devcontainer.json | 35 - ext/opentelemetry-cpp-1.21.0/.gitattributes | 47 - .../.github/.codecov.yaml | 50 - .../.github/CODEOWNERS | 8 - .../.github/ISSUE_TEMPLATE/bug_report.md | 19 - .../.github/ISSUE_TEMPLATE/feature_request.md | 19 - .../.github/dependabot.yml | 13 - .../.github/pull_request_template.md | 11 - .../.github/repository-settings.md | 38 - .../.github/workflows/benchmark.yml | 82 - .../.github/workflows/ci.yml | 1247 ---- .../.github/workflows/clang-tidy.yaml | 89 - .../.github/workflows/cmake_install.yml | 372 -- .../.github/workflows/codeql-analysis.yml | 48 - .../.github/workflows/cppcheck.yml | 77 - .../.github/workflows/dependencies_image.yml | 54 - .../.github/workflows/fossa.yml | 25 - .../.github/workflows/iwyu.yml | 92 - .../.github/workflows/ossf-scorecard.yml | 52 - .../workflows/project_management_comment.yml | 28 - .../project_management_issue_open.yml | 29 - .../.github/workflows/stale.yml | 21 - ext/opentelemetry-cpp-1.21.0/.gitignore | 84 - ext/opentelemetry-cpp-1.21.0/.gitmodules | 39 - ext/opentelemetry-cpp-1.21.0/.iwyu.imp | 31 - .../.markdownlint.json | 8 - .../.markdownlintignore | 3 - ext/opentelemetry-cpp-1.21.0/CHANGELOG.md | 2816 --------- ext/opentelemetry-cpp-1.21.0/CMakeLists.txt | 927 --- .../CMakeSettings.json | 126 - .../CODE_OF_CONDUCT.md | 3 - ext/opentelemetry-cpp-1.21.0/CONTRIBUTING.md | 322 -- ext/opentelemetry-cpp-1.21.0/DEPRECATED.md | 139 - ext/opentelemetry-cpp-1.21.0/INSTALL.md | 452 -- ext/opentelemetry-cpp-1.21.0/LICENSE | 201 - ext/opentelemetry-cpp-1.21.0/MODULE.bazel | 25 - ext/opentelemetry-cpp-1.21.0/README.md | 127 - ext/opentelemetry-cpp-1.21.0/RELEASING.md | 96 - ext/opentelemetry-cpp-1.21.0/Versioning.md | 107 - ext/opentelemetry-cpp-1.21.0/WORKSPACE | 23 - ext/opentelemetry-cpp-1.21.0/WORKSPACE.bzlmod | 4 - ext/opentelemetry-cpp-1.21.0/api/BUILD | 81 - .../api/CMakeLists.txt | 140 - .../include/opentelemetry/baggage/baggage.h | 299 - .../opentelemetry/baggage/baggage_context.h | 36 - .../baggage/propagation/baggage_propagator.h | 60 - .../opentelemetry/common/attribute_value.h | 82 - .../opentelemetry/common/key_value_iterable.h | 64 - .../common/key_value_iterable_view.h | 146 - .../opentelemetry/common/kv_properties.h | 272 - .../api/include/opentelemetry/common/macros.h | 523 -- .../opentelemetry/common/spin_lock_mutex.h | 133 - .../opentelemetry/common/string_util.h | 42 - .../include/opentelemetry/common/timestamp.h | 206 - .../api/include/opentelemetry/config.h | 19 - .../include/opentelemetry/context/context.h | 171 - .../opentelemetry/context/context_value.h | 35 - .../propagation/composite_propagator.h | 93 - .../context/propagation/global_propagator.h | 57 - .../context/propagation/noop_propagator.h | 40 - .../context/propagation/text_map_propagator.h | 59 - .../opentelemetry/context/runtime_context.h | 340 -- .../opentelemetry/detail/preprocessor.h | 25 - .../api/include/opentelemetry/logs/event_id.h | 37 - .../include/opentelemetry/logs/event_logger.h | 82 - .../logs/event_logger_provider.h | 37 - .../include/opentelemetry/logs/log_record.h | 92 - .../api/include/opentelemetry/logs/logger.h | 492 -- .../opentelemetry/logs/logger_provider.h | 71 - .../opentelemetry/logs/logger_type_traits.h | 204 - .../api/include/opentelemetry/logs/noop.h | 131 - .../api/include/opentelemetry/logs/provider.h | 100 - .../api/include/opentelemetry/logs/severity.h | 67 - .../opentelemetry/metrics/async_instruments.h | 33 - .../api/include/opentelemetry/metrics/meter.h | 174 - .../opentelemetry/metrics/meter_provider.h | 148 - .../api/include/opentelemetry/metrics/noop.h | 271 - .../opentelemetry/metrics/observer_result.h | 54 - .../include/opentelemetry/metrics/provider.h | 60 - .../opentelemetry/metrics/sync_instruments.h | 328 -- .../include/opentelemetry/nostd/detail/all.h | 21 - .../opentelemetry/nostd/detail/decay.h | 16 - .../nostd/detail/dependent_type.h | 20 - .../opentelemetry/nostd/detail/functional.h | 66 - .../opentelemetry/nostd/detail/invoke.h | 163 - .../opentelemetry/nostd/detail/trait.h | 75 - .../nostd/detail/type_pack_element.h | 53 - .../opentelemetry/nostd/detail/valueless.h | 14 - .../nostd/detail/variant_alternative.h | 40 - .../opentelemetry/nostd/detail/variant_fwd.h | 14 - .../opentelemetry/nostd/detail/variant_size.h | 33 - .../include/opentelemetry/nostd/detail/void.h | 28 - .../opentelemetry/nostd/function_ref.h | 94 - .../nostd/internal/absl/.clang-format | 3 - .../nostd/internal/absl/README.md | 4 - .../nostd/internal/absl/base/attributes.h | 621 -- .../nostd/internal/absl/base/config.h | 671 --- .../internal/absl/base/internal/identity.h | 37 - .../absl/base/internal/inline_variable.h | 107 - .../internal/absl/base/internal/invoke.h | 188 - .../nostd/internal/absl/base/macros.h | 220 - .../nostd/internal/absl/base/optimization.h | 181 - .../nostd/internal/absl/base/options.h | 216 - .../nostd/internal/absl/base/policy_checks.h | 115 - .../nostd/internal/absl/base/port.h | 26 - .../nostd/internal/absl/meta/type_traits.h | 779 --- .../internal/absl/types/bad_variant_access.h | 94 - .../internal/absl/types/internal/variant.h | 1649 ------ .../nostd/internal/absl/types/variant.h | 866 --- .../nostd/internal/absl/utility/utility.h | 350 -- .../include/opentelemetry/nostd/shared_ptr.h | 210 - .../api/include/opentelemetry/nostd/span.h | 274 - .../include/opentelemetry/nostd/string_view.h | 226 - .../include/opentelemetry/nostd/type_traits.h | 172 - .../include/opentelemetry/nostd/unique_ptr.h | 180 - .../api/include/opentelemetry/nostd/utility.h | 160 - .../api/include/opentelemetry/nostd/variant.h | 85 - .../plugin/detail/dynamic_library_handle.h | 20 - .../plugin/detail/dynamic_load_unix.h | 73 - .../plugin/detail/dynamic_load_windows.h | 96 - .../opentelemetry/plugin/detail/loader_info.h | 24 - .../plugin/detail/tracer_handle.h | 27 - .../opentelemetry/plugin/detail/utility.h | 36 - .../opentelemetry/plugin/dynamic_load.h | 30 - .../include/opentelemetry/plugin/factory.h | 65 - .../api/include/opentelemetry/plugin/hook.h | 51 - .../api/include/opentelemetry/plugin/tracer.h | 133 - .../opentelemetry/semconv/azure_metrics.h | 97 - .../opentelemetry/semconv/cicd_metrics.h | 213 - .../opentelemetry/semconv/client_attributes.h | 41 - .../opentelemetry/semconv/code_attributes.h | 81 - .../opentelemetry/semconv/container_metrics.h | 266 - .../opentelemetry/semconv/cpu_metrics.h | 141 - .../opentelemetry/semconv/db_attributes.h | 349 -- .../opentelemetry/semconv/db_metrics.h | 53 - .../opentelemetry/semconv/dns_metrics.h | 49 - .../opentelemetry/semconv/error_attributes.h | 57 - .../semconv/exception_attributes.h | 50 - .../opentelemetry/semconv/faas_metrics.h | 287 - .../opentelemetry/semconv/gen_ai_metrics.h | 157 - .../opentelemetry/semconv/http_attributes.h | 164 - .../opentelemetry/semconv/http_metrics.h | 77 - .../opentelemetry/semconv/hw_metrics.h | 344 -- .../semconv/incubating/app_attributes.h | 76 - .../semconv/incubating/artifact_attributes.h | 79 - .../semconv/incubating/aws_attributes.h | 425 -- .../semconv/incubating/az_attributes.h | 37 - .../semconv/incubating/azure_attributes.h | 110 - .../semconv/incubating/azure_metrics.h | 97 - .../semconv/incubating/browser_attributes.h | 65 - .../semconv/incubating/cassandra_attributes.h | 116 - .../semconv/incubating/cicd_attributes.h | 258 - .../semconv/incubating/cicd_metrics.h | 213 - .../semconv/incubating/client_attributes.h | 41 - .../semconv/incubating/cloud_attributes.h | 287 - .../incubating/cloudevents_attributes.h | 58 - .../incubating/cloudfoundry_attributes.h | 133 - .../semconv/incubating/code_attributes.h | 126 - .../semconv/incubating/container_attributes.h | 159 - .../semconv/incubating/container_metrics.h | 266 - .../semconv/incubating/cpu_attributes.h | 78 - .../semconv/incubating/cpu_metrics.h | 141 - .../semconv/incubating/cpython_attributes.h | 48 - .../semconv/incubating/cpython_metrics.h | 154 - .../semconv/incubating/db_attributes.h | 1212 ---- .../semconv/incubating/db_metrics.h | 861 --- .../incubating/deployment_attributes.h | 77 - .../incubating/destination_attributes.h | 37 - .../semconv/incubating/device_attributes.h | 72 - .../semconv/incubating/disk_attributes.h | 43 - .../semconv/incubating/dns_attributes.h | 34 - .../semconv/incubating/dns_metrics.h | 49 - .../incubating/elasticsearch_attributes.h | 29 - .../semconv/incubating/enduser_attributes.h | 57 - .../semconv/incubating/error_attributes.h | 69 - .../semconv/incubating/event_attributes.h | 32 - .../semconv/incubating/exception_attributes.h | 50 - .../semconv/incubating/faas_attributes.h | 231 - .../semconv/incubating/faas_metrics.h | 287 - .../incubating/feature_flag_attributes.h | 209 - .../semconv/incubating/file_attributes.h | 143 - .../semconv/incubating/gcp_attributes.h | 221 - .../semconv/incubating/gen_ai_attributes.h | 494 -- .../semconv/incubating/gen_ai_metrics.h | 157 - .../semconv/incubating/geo_attributes.h | 102 - .../semconv/incubating/graphql_attributes.h | 60 - .../semconv/incubating/heroku_attributes.h | 39 - .../semconv/incubating/host_attributes.h | 159 - .../semconv/incubating/http_attributes.h | 375 -- .../semconv/incubating/http_metrics.h | 346 -- .../semconv/incubating/hw_attributes.h | 148 - .../semconv/incubating/hw_metrics.h | 345 -- .../semconv/incubating/k8s_attributes.h | 443 -- .../semconv/incubating/k8s_metrics.h | 1723 ------ .../semconv/incubating/linux_attributes.h | 43 - .../semconv/incubating/log_attributes.h | 82 - .../semconv/incubating/message_attributes.h | 76 - .../semconv/incubating/messaging_attributes.h | 522 -- .../semconv/incubating/messaging_metrics.h | 413 -- .../semconv/incubating/net_attributes.h | 208 - .../semconv/incubating/network_attributes.h | 379 -- .../semconv/incubating/oci_attributes.h | 36 - .../incubating/opentracing_attributes.h | 45 - .../semconv/incubating/os_attributes.h | 110 - .../semconv/incubating/otel_attributes.h | 202 - .../semconv/incubating/otel_metrics.h | 976 ---- .../semconv/incubating/other_attributes.h | 47 - .../semconv/incubating/peer_attributes.h | 31 - .../semconv/incubating/pool_attributes.h | 33 - .../semconv/incubating/process_attributes.h | 297 - .../semconv/incubating/process_metrics.h | 458 -- .../semconv/incubating/profile_attributes.h | 98 - .../semconv/incubating/rpc_attributes.h | 368 -- .../semconv/incubating/rpc_metrics.h | 310 - .../incubating/security_rule_attributes.h | 69 - .../semconv/incubating/server_attributes.h | 41 - .../semconv/incubating/service_attributes.h | 84 - .../semconv/incubating/session_attributes.h | 34 - .../semconv/incubating/source_attributes.h | 37 - .../semconv/incubating/system_attributes.h | 383 -- .../semconv/incubating/system_metrics.h | 1338 ----- .../semconv/incubating/telemetry_attributes.h | 125 - .../semconv/incubating/test_attributes.h | 93 - .../semconv/incubating/thread_attributes.h | 34 - .../semconv/incubating/tls_attributes.h | 222 - .../semconv/incubating/url_attributes.h | 173 - .../incubating/user_agent_attributes.h | 92 - .../semconv/incubating/user_attributes.h | 57 - .../semconv/incubating/vcs_attributes.h | 348 -- .../semconv/incubating/vcs_metrics.h | 435 -- .../semconv/incubating/webengine_attributes.h | 39 - .../opentelemetry/semconv/k8s_metrics.h | 1735 ------ .../opentelemetry/semconv/messaging_metrics.h | 414 -- .../semconv/network_attributes.h | 119 - .../opentelemetry/semconv/otel_attributes.h | 59 - .../opentelemetry/semconv/otel_metrics.h | 337 -- .../opentelemetry/semconv/process_metrics.h | 458 -- .../opentelemetry/semconv/rpc_metrics.h | 310 - .../opentelemetry/semconv/schema_url.h | 24 - .../opentelemetry/semconv/server_attributes.h | 41 - .../semconv/service_attributes.h | 41 - .../opentelemetry/semconv/system_metrics.h | 1339 ----- .../semconv/telemetry_attributes.h | 111 - .../opentelemetry/semconv/url_attributes.h | 102 - .../semconv/user_agent_attributes.h | 30 - .../opentelemetry/semconv/vcs_metrics.h | 435 -- .../include/opentelemetry/std/shared_ptr.h | 22 - .../api/include/opentelemetry/std/span.h | 71 - .../include/opentelemetry/std/string_view.h | 21 - .../include/opentelemetry/std/type_traits.h | 10 - .../include/opentelemetry/std/unique_ptr.h | 22 - .../api/include/opentelemetry/std/utility.h | 71 - .../api/include/opentelemetry/std/variant.h | 230 - .../api/include/opentelemetry/trace/context.h | 44 - .../opentelemetry/trace/default_span.h | 77 - .../api/include/opentelemetry/trace/noop.h | 159 - .../trace/propagation/b3_propagator.h | 198 - .../trace/propagation/detail/hex.h | 83 - .../trace/propagation/detail/string.h | 63 - .../trace/propagation/http_trace_context.h | 201 - .../opentelemetry/trace/propagation/jaeger.h | 127 - .../include/opentelemetry/trace/provider.h | 60 - .../api/include/opentelemetry/trace/scope.h | 42 - .../trace/semantic_conventions.h | 5111 ---------------- .../api/include/opentelemetry/trace/span.h | 259 - .../opentelemetry/trace/span_context.h | 98 - .../trace/span_context_kv_iterable.h | 54 - .../trace/span_context_kv_iterable_view.h | 119 - .../api/include/opentelemetry/trace/span_id.h | 67 - .../opentelemetry/trace/span_metadata.h | 45 - .../opentelemetry/trace/span_startoptions.h | 71 - .../include/opentelemetry/trace/trace_flags.h | 66 - .../include/opentelemetry/trace/trace_id.h | 72 - .../include/opentelemetry/trace/trace_state.h | 323 -- .../api/include/opentelemetry/trace/tracer.h | 244 - .../opentelemetry/trace/tracer_provider.h | 127 - .../api/include/opentelemetry/version.h | 29 - .../api/test/CMakeLists.txt | 16 - .../api/test/baggage/BUILD | 30 - .../api/test/baggage/CMakeLists.txt | 21 - .../api/test/baggage/baggage_benchmark.cc | 122 - .../api/test/baggage/baggage_test.cc | 222 - .../api/test/baggage/propagation/BUILD | 19 - .../test/baggage/propagation/CMakeLists.txt | 12 - .../propagation/baggage_propagator_test.cc | 123 - .../api/test/common/BUILD | 45 - .../api/test/common/CMakeLists.txt | 20 - .../api/test/common/kv_properties_test.cc | 238 - .../api/test/common/spinlock_benchmark.cc | 169 - .../api/test/common/string_util_test.cc | 51 - .../api/test/context/BUILD | 34 - .../api/test/context/CMakeLists.txt | 16 - .../api/test/context/context_test.cc | 154 - .../api/test/context/propagation/BUILD | 19 - .../test/context/propagation/CMakeLists.txt | 12 - .../propagation/composite_propagator_test.cc | 152 - .../api/test/context/runtime_context_test.cc | 149 - .../api/test/core/BUILD | 32 - .../api/test/core/CMakeLists.txt | 20 - .../api/test/core/timestamp_test.cc | 70 - .../api/test/core/version_test.cc | 18 - .../api/test/logs/BUILD | 36 - .../api/test/logs/CMakeLists.txt | 18 - .../api/test/logs/logger_benchmark.cc | 253 - .../api/test/logs/logger_test.cc | 237 - .../api/test/logs/provider_test.cc | 118 - .../api/test/metrics/BUILD | 34 - .../api/test/metrics/CMakeLists.txt | 12 - .../api/test/metrics/meter_provider_test.cc | 36 - .../test/metrics/noop_sync_instrument_test.cc | 54 - .../api/test/nostd/BUILD | 107 - .../api/test/nostd/CMakeLists.txt | 22 - .../api/test/nostd/function_ref_test.cc | 38 - .../api/test/nostd/shared_ptr_test.cc | 191 - .../api/test/nostd/span_test.cc | 175 - .../api/test/nostd/string_view_test.cc | 128 - .../api/test/nostd/unique_ptr_test.cc | 171 - .../api/test/nostd/utility_test.cc | 57 - .../api/test/nostd/variant_test.cc | 117 - .../api/test/plugin/BUILD | 20 - .../api/test/plugin/CMakeLists.txt | 13 - .../api/test/plugin/dynamic_load_test.cc | 16 - .../api/test/singleton/BUILD | 201 - .../api/test/singleton/CMakeLists.txt | 55 - .../api/test/singleton/component_a.cc | 39 - .../api/test/singleton/component_a.h | 4 - .../api/test/singleton/component_b.cc | 39 - .../api/test/singleton/component_b.h | 4 - .../api/test/singleton/component_c.cc | 41 - .../api/test/singleton/component_c.h | 15 - .../api/test/singleton/component_d.cc | 41 - .../api/test/singleton/component_d.h | 21 - .../api/test/singleton/component_e.cc | 41 - .../api/test/singleton/component_e.h | 15 - .../api/test/singleton/component_f.cc | 41 - .../api/test/singleton/component_f.h | 21 - .../api/test/singleton/component_g.cc | 45 - .../api/test/singleton/component_h.cc | 51 - .../api/test/singleton/singleton_test.cc | 463 -- .../api/test/trace/BUILD | 204 - .../api/test/trace/CMakeLists.txt | 34 - .../api/test/trace/default_span_test.cc | 24 - .../trace/key_value_iterable_view_test.cc | 76 - .../api/test/trace/noop_test.cc | 110 - .../api/test/trace/propagation/BUILD | 55 - .../api/test/trace/propagation/CMakeLists.txt | 15 - .../trace/propagation/b3_propagation_test.cc | 221 - .../api/test/trace/propagation/detail/BUILD | 36 - .../trace/propagation/detail/CMakeLists.txt | 12 - .../test/trace/propagation/detail/hex_test.cc | 42 - .../trace/propagation/detail/string_test.cc | 64 - .../propagation/http_text_format_test.cc | 248 - .../propagation/jaeger_propagation_test.cc | 207 - .../api/test/trace/propagation/util.h | 14 - .../api/test/trace/provider_test.cc | 50 - .../api/test/trace/scope_test.cc | 56 - .../api/test/trace/span_benchmark.cc | 137 - .../api/test/trace/span_context_test.cc | 56 - .../api/test/trace/span_id_benchmark.cc | 56 - .../api/test/trace/span_id_test.cc | 57 - .../api/test/trace/trace_flags_test.cc | 43 - .../api/test/trace/trace_id_test.cc | 58 - .../api/test/trace/trace_state_test.cc | 200 - .../api/test/trace/tracer_test.cc | 43 - ext/opentelemetry-cpp-1.21.0/bazel/BUILD | 9 - ext/opentelemetry-cpp-1.21.0/bazel/curl.BUILD | 59 - ext/opentelemetry-cpp-1.21.0/bazel/curl.bzl | 190 - .../bazel/extra_deps.bzl | 13 - .../bazel/nlohmann_json.BUILD | 17 - .../bazel/opentelemetry_proto.BUILD | 152 - .../bazel/otel_cc_benchmark.bzl | 52 - .../bazel/repository.bzl | 186 - ext/opentelemetry-cpp-1.21.0/bazel/zlib.BUILD | 74 - .../buildscripts/pre-commit | 82 - .../buildscripts/pre-merge-commit | 1 - .../buildscripts/pre_release.sh | 75 - .../semantic-convention/generate.sh | 120 - .../templates/registry/schema_url-h.j2 | 48 - .../registry/semantic_attributes-h.j2 | 132 - .../templates/registry/semantic_metrics-h.j2 | 228 - .../templates/registry/weaver.yaml | 156 - ext/opentelemetry-cpp-1.21.0/ci/README.md | 32 - ext/opentelemetry-cpp-1.21.0/ci/do_ci.ps1 | 562 -- ext/opentelemetry-cpp-1.21.0/ci/do_ci.sh | 688 --- ext/opentelemetry-cpp-1.21.0/ci/docfx.cmd | 21 - ext/opentelemetry-cpp-1.21.0/ci/docfx.json | 31 - .../ci/fix-abseil-cpp-issue-1536.patch | 23 - .../ci/install_abseil.sh | 73 - .../ci/install_bazelisk.sh | 11 - .../ci/install_format_tools.sh | 27 - .../ci/install_gcc48.sh | 9 - .../ci/install_osx_bazelisk.sh | 9 - .../ci/install_protobuf.sh | 76 - .../ci/install_windows_bazelisk.ps1 | 11 - .../ci/install_windows_protobuf.ps1 | 9 - .../ci/ports/protobuf/CONTROL | 8 - .../ci/ports/protobuf/fix-android-log.patch | 28 - .../ci/ports/protobuf/fix-static-build.patch | 13 - .../ci/ports/protobuf/fix-uwp.patch | 12 - .../ci/ports/protobuf/portfile.cmake | 127 - ext/opentelemetry-cpp-1.21.0/ci/run_docker.sh | 17 - .../ci/setup_ci_environment.sh | 16 - .../ci/setup_cmake.ps1 | 48 - .../ci/setup_cmake.sh | 48 - .../ci/setup_cmake_macos.sh | 51 - .../ci/setup_gcc10.sh | 10 - .../ci/setup_googletest.sh | 56 - ext/opentelemetry-cpp-1.21.0/ci/setup_grpc.sh | 154 - .../ci/setup_windows_ci_environment.ps1 | 31 - ext/opentelemetry-cpp-1.21.0/ci/toc.yml | 2 - .../ci/valgrind-suppressions | 15 - .../ci/verify_packages.sh | 12 - .../cmake/ParseOsRelease.cmake | 25 - .../find-package-support-functions.cmake | 145 - .../cmake/nlohmann-json.cmake | 94 - ...entelemetry-build-external-component.cmake | 49 - .../cmake/opentelemetry-proto.cmake | 397 -- .../cmake/otel-install-functions.cmake | 506 -- .../cmake/package.cmake | 74 - .../cmake/patch-imported-config.cmake | 144 - .../cmake/pkgconfig.cmake | 55 - .../templates/component-definitions.cmake.in | 28 - .../cmake/templates/config.pc.in | 15 - .../opentelemetry-cpp-config.cmake.in | 228 - ...thirdparty-dependency-definitions.cmake.in | 20 - .../cmake/thirdparty-dependency-config.cmake | 46 - .../cmake/tools.cmake | 222 - .../docker/.gitignore | 1 - .../docker/Dockerfile | 35 - .../docker/Dockerfile.alpine.base | 18 - .../docker/Dockerfile.centos | 50 - .../docker/Dockerfile.debian.deps | 37 - ext/opentelemetry-cpp-1.21.0/docker/README.md | 20 - ext/opentelemetry-cpp-1.21.0/docker/build.sh | 74 - .../docker/grpc/CMakeLists.txt | 87 - .../docker/grpc/Dockerfile | 24 - .../docker/ubuntuLatest/Dockerfile | 41 - .../docs/abi-compatibility.md | 62 - .../docs/abi-policy.md | 60 - .../docs/abi-version-policy.md | 529 -- .../docs/build-as-dll.md | 11 - .../docs/building-with-stdlib.md | 207 - .../docs/building-with-vcpkg.md | 119 - .../docs/building-with-vs2019.md | 190 - .../docs/cpp-ostream-exporter-design.md | 259 - .../docs/cpp-sdk-factory-design.md | 210 - .../docs/dependencies.md | 101 - .../docs/deprecation-process.md | 433 -- .../docs/google-test.md | 375 -- .../docs/library-distribution.md | 128 - .../docs/maintaining-dependencies.md | 638 -- .../docs/public/Doxyfile | 2479 -------- .../docs/public/GettingHelp.rst | 17 - .../docs/public/Makefile | 27 - .../public/_static/opentelemetry_logo.png | Bin 14927 -> 0 bytes .../docs/public/_templates/sidebar/brand.html | 8 - .../docs/public/api/GettingStarted.rst | 104 - .../docs/public/api/Overview.rst | 26 - .../docs/public/api/api.rst | 8 - .../docs/public/conf.py | 90 - .../docs/public/index.rst | 57 - .../docs/public/performance/benchmarks.rst | 6 - .../docs/public/requirements.txt | 3 - .../docs/public/resources/footer.html | 14 - .../docs/public/resources/header.html | 56 - .../docs/public/resources/stylesheet.css | 1600 ------ .../docs/public/sdk/GettingStarted.rst | 209 - .../docs/public/sdk/sdk.rst | 7 - .../docs/requirements.md | 23 - .../docs/testing-with-ssl.md | 351 -- .../docs/using-clang-format.md | 53 - .../examples/CMakeLists.txt | 33 - .../examples/batch/BUILD | 16 - .../examples/batch/CMakeLists.txt | 7 - .../examples/batch/main.cc | 112 - .../examples/common/CMakeLists.txt | 7 - .../examples/common/foo_library/BUILD | 19 - .../common/foo_library/CMakeLists.txt | 15 - .../common/foo_library/foo_library.cc | 40 - .../examples/common/foo_library/foo_library.h | 6 - .../examples/common/logs_foo_library/BUILD | 19 - .../common/logs_foo_library/CMakeLists.txt | 16 - .../common/logs_foo_library/foo_library.cc | 41 - .../common/logs_foo_library/foo_library.h | 6 - .../examples/common/metrics_foo_library/BUILD | 20 - .../common/metrics_foo_library/CMakeLists.txt | 16 - .../common/metrics_foo_library/foo_library.cc | 195 - .../common/metrics_foo_library/foo_library.h | 21 - .../examples/etw_threads/BUILD | 18 - .../examples/etw_threads/CMakeLists.txt | 10 - .../examples/etw_threads/README.md | 32 - .../examples/etw_threads/main.cc | 154 - .../examples/grpc/BUILD | 66 - .../examples/grpc/CMakeLists.txt | 49 - .../examples/grpc/README.md | 107 - .../examples/grpc/client.cc | 139 - .../examples/grpc/protos/messages.proto | 18 - .../examples/grpc/server.cc | 140 - .../examples/grpc/tracer_common.h | 109 - .../examples/http/BUILD | 42 - .../examples/http/CMakeLists.txt | 15 - .../examples/http/README.md | 112 - .../examples/http/client.cc | 99 - .../examples/http/server.cc | 100 - .../examples/http/server.h | 53 - .../examples/http/tracer_common.h | 98 - .../examples/logs_simple/BUILD | 19 - .../examples/logs_simple/CMakeLists.txt | 18 - .../examples/logs_simple/README.md | 16 - .../examples/logs_simple/main.cc | 91 - .../examples/metrics_simple/BUILD | 17 - .../examples/metrics_simple/CMakeLists.txt | 18 - .../examples/metrics_simple/README.md | 117 - .../metrics_simple/metrics_ostream.cc | 226 - .../examples/multi_processor/BUILD | 20 - .../examples/multi_processor/CMakeLists.txt | 9 - .../examples/multi_processor/README.md | 15 - .../examples/multi_processor/main.cc | 112 - .../examples/multithreaded/BUILD | 15 - .../examples/multithreaded/CMakeLists.txt | 7 - .../examples/multithreaded/main.cc | 87 - .../examples/otlp/BUILD | 192 - .../examples/otlp/CMakeLists.txt | 179 - .../examples/otlp/README.md | 69 - .../examples/otlp/file_log_main.cc | 129 - .../examples/otlp/file_main.cc | 76 - .../examples/otlp/file_metric_main.cc | 126 - .../examples/otlp/grpc_log_main.cc | 121 - .../examples/otlp/grpc_main.cc | 74 - .../examples/otlp/grpc_metric_main.cc | 165 - .../examples/otlp/http_instrumented_main.cc | 360 -- .../examples/otlp/http_log_main.cc | 168 - .../examples/otlp/http_main.cc | 105 - .../examples/otlp/http_metric_main.cc | 160 - .../config.dev.yaml | 30 - .../examples/plugin/CMakeLists.txt | 8 - .../examples/plugin/load/BUILD | 15 - .../examples/plugin/load/CMakeLists.txt | 6 - .../examples/plugin/load/main.cc | 44 - .../examples/plugin/plugin/BUILD | 15 - .../examples/plugin/plugin/CMakeLists.txt | 5 - .../examples/plugin/plugin/factory_impl.cc | 55 - .../examples/plugin/plugin/tracer.cc | 98 - .../examples/plugin/plugin/tracer.h | 36 - .../examples/prometheus/BUILD | 17 - .../examples/prometheus/CMakeLists.txt | 7 - .../examples/prometheus/README.md | 180 - .../examples/prometheus/main.cc | 139 - .../examples/prometheus/prometheus.yml | 11 - .../examples/prometheus/run.sh | 6 - .../examples/simple/BUILD | 18 - .../examples/simple/CMakeLists.txt | 16 - .../examples/simple/README.md | 12 - .../examples/simple/main.cc | 57 - .../examples/zipkin/CMakeLists.txt | 7 - .../examples/zipkin/README.md | 32 - .../examples/zipkin/main.cc | 66 - .../exporters/CMakeLists.txt | 27 - .../exporters/elasticsearch/BUILD | 47 - .../exporters/elasticsearch/CMakeLists.txt | 49 - .../elasticsearch/es_log_record_exporter.h | 142 - .../elasticsearch/es_log_recordable.h | 127 - .../src/es_log_record_exporter.cc | 484 -- .../elasticsearch/src/es_log_recordable.cc | 208 - .../test/es_log_record_exporter_test.cc | 128 - .../exporters/etw/BUILD | 72 - .../exporters/etw/CMakeLists.txt | 91 - .../exporters/etw/README.md | 16 - .../opentelemetry/exporters/etw/LICENSE | 23 - .../exporters/etw/TraceLoggingDynamic.h | 3458 ----------- .../opentelemetry/exporters/etw/etw_config.h | 244 - .../opentelemetry/exporters/etw/etw_fields.h | 146 - .../opentelemetry/exporters/etw/etw_logger.h | 432 -- .../exporters/etw/etw_logger_exporter.h | 27 - .../exporters/etw/etw_properties.h | 459 -- .../exporters/etw/etw_provider.h | 635 -- .../exporters/etw/etw_random_id_generator.h | 49 - .../exporters/etw/etw_tail_sampler.h | 40 - .../exporters/etw/etw_traceloggingdynamic.h | 18 - .../opentelemetry/exporters/etw/etw_tracer.h | 1193 ---- .../exporters/etw/etw_tracer_exporter.h | 28 - .../opentelemetry/exporters/etw/utils.h | 431 -- .../opentelemetry/exporters/etw/uuid.h | 412 -- .../exporters/etw/test/etw_logger_test.cc | 198 - .../exporters/etw/test/etw_perf_test.cc | 192 - .../exporters/etw/test/etw_provider_test.cc | 64 - .../exporters/etw/test/etw_tracer_test.cc | 571 -- .../exporters/memory/BUILD | 141 - .../exporters/memory/CMakeLists.txt | 92 - .../exporters/memory/in_memory_data.h | 62 - .../exporters/memory/in_memory_metric_data.h | 68 - .../in_memory_metric_exporter_factory.h | 38 - .../exporters/memory/in_memory_span_data.h | 33 - .../memory/in_memory_span_exporter.h | 106 - .../memory/in_memory_span_exporter_factory.h | 46 - .../memory/src/in_memory_metric_data.cc | 71 - .../src/in_memory_metric_exporter_factory.cc | 101 - .../src/in_memory_span_exporter_factory.cc | 33 - .../memory/test/in_memory_metric_data_test.cc | 63 - .../test/in_memory_metric_exporter_test.cc | 64 - .../memory/test/in_memory_span_data_test.cc | 29 - .../test/in_memory_span_exporter_test.cc | 33 - .../exporters/ostream/BUILD | 112 - .../exporters/ostream/CMakeLists.txt | 90 - .../exporters/ostream/common_utils.h | 131 - .../exporters/ostream/log_record_exporter.h | 76 - .../ostream/log_record_exporter_factory.h | 37 - .../exporters/ostream/metric_exporter.h | 87 - .../ostream/metric_exporter_factory.h | 43 - .../exporters/ostream/span_exporter.h | 85 - .../exporters/ostream/span_exporter_factory.h | 37 - .../ostream/src/log_record_exporter.cc | 180 - .../src/log_record_exporter_factory.cc | 30 - .../exporters/ostream/src/metric_exporter.cc | 322 -- .../ostream/src/metric_exporter_factory.cc | 36 - .../exporters/ostream/src/span_exporter.cc | 200 - .../ostream/src/span_exporter_factory.cc | 29 - .../exporters/ostream/test/ostream_capture.h | 60 - .../ostream/test/ostream_log_test.cc | 538 -- .../ostream/test/ostream_metric_test.cc | 413 -- .../ostream/test/ostream_span_test.cc | 412 -- .../exporters/otlp/BUILD | 781 --- .../exporters/otlp/CMakeLists.txt | 623 -- .../exporters/otlp/README.md | 137 - .../exporters/otlp/otlp_environment.h | 173 - .../exporters/otlp/otlp_file_client.h | 92 - .../exporters/otlp/otlp_file_client_options.h | 108 - .../otlp/otlp_file_client_runtime_options.h | 31 - .../exporters/otlp/otlp_file_exporter.h | 88 - .../otlp/otlp_file_exporter_factory.h | 46 - .../otlp/otlp_file_exporter_options.h | 30 - .../otlp/otlp_file_exporter_runtime_options.h | 27 - .../otlp/otlp_file_log_record_exporter.h | 89 - .../otlp_file_log_record_exporter_factory.h | 46 - .../otlp_file_log_record_exporter_options.h | 30 - ...file_log_record_exporter_runtime_options.h | 27 - .../otlp/otlp_file_metric_exporter.h | 84 - .../otlp/otlp_file_metric_exporter_factory.h | 46 - .../otlp/otlp_file_metric_exporter_options.h | 33 - ...tlp_file_metric_exporter_runtime_options.h | 27 - .../exporters/otlp/otlp_grpc_client.h | 215 - .../exporters/otlp/otlp_grpc_client_factory.h | 37 - .../exporters/otlp/otlp_grpc_client_options.h | 81 - .../exporters/otlp/otlp_grpc_exporter.h | 134 - .../otlp/otlp_grpc_exporter_factory.h | 47 - .../otlp/otlp_grpc_exporter_options.h | 32 - .../otlp/otlp_grpc_log_record_exporter.h | 135 - .../otlp_grpc_log_record_exporter_factory.h | 45 - .../otlp_grpc_log_record_exporter_options.h | 31 - .../otlp/otlp_grpc_metric_exporter.h | 123 - .../otlp/otlp_grpc_metric_exporter_factory.h | 47 - .../otlp/otlp_grpc_metric_exporter_options.h | 36 - .../exporters/otlp/otlp_grpc_utils.h | 25 - .../opentelemetry/exporters/otlp/otlp_http.h | 33 - .../exporters/otlp/otlp_http_client.h | 321 -- .../exporters/otlp/otlp_http_exporter.h | 96 - .../otlp/otlp_http_exporter_factory.h | 46 - .../otlp/otlp_http_exporter_options.h | 121 - .../otlp/otlp_http_exporter_runtime_options.h | 31 - .../otlp/otlp_http_log_record_exporter.h | 97 - .../otlp_http_log_record_exporter_factory.h | 46 - .../otlp_http_log_record_exporter_options.h | 121 - ...http_log_record_exporter_runtime_options.h | 31 - .../otlp/otlp_http_metric_exporter.h | 91 - .../otlp/otlp_http_metric_exporter_factory.h | 46 - .../otlp/otlp_http_metric_exporter_options.h | 124 - ...tlp_http_metric_exporter_runtime_options.h | 31 - .../exporters/otlp/otlp_log_recordable.h | 129 - .../exporters/otlp/otlp_metric_utils.h | 89 - .../otlp/otlp_populate_attribute_utils.h | 77 - .../otlp/otlp_preferred_temporality.h | 23 - .../exporters/otlp/otlp_recordable.h | 91 - .../exporters/otlp/otlp_recordable_utils.h | 60 - .../exporters/otlp/protobuf_include_prefix.h | 66 - .../exporters/otlp/protobuf_include_suffix.h | 16 - .../exporters/otlp/src/otlp_environment.cc | 1329 ----- .../exporters/otlp/src/otlp_file_client.cc | 1704 ------ .../exporters/otlp/src/otlp_file_exporter.cc | 114 - .../otlp/src/otlp_file_exporter_factory.cc | 40 - .../otlp/src/otlp_file_exporter_options.cc | 34 - .../otlp/src/otlp_file_log_record_exporter.cc | 116 - .../otlp_file_log_record_exporter_factory.cc | 42 - .../otlp_file_log_record_exporter_options.cc | 34 - .../otlp/src/otlp_file_metric_exporter.cc | 122 - .../src/otlp_file_metric_exporter_factory.cc | 41 - .../src/otlp_file_metric_exporter_options.cc | 35 - .../exporters/otlp/src/otlp_grpc_client.cc | 774 --- .../otlp/src/otlp_grpc_client_factory.cc | 27 - .../exporters/otlp/src/otlp_grpc_exporter.cc | 213 - .../otlp/src/otlp_grpc_exporter_factory.cc | 41 - .../otlp/src/otlp_grpc_exporter_options.cc | 50 - .../otlp/src/otlp_grpc_log_record_exporter.cc | 221 - .../otlp_grpc_log_record_exporter_factory.cc | 42 - .../otlp_grpc_log_record_exporter_options.cc | 48 - .../otlp/src/otlp_grpc_metric_exporter.cc | 219 - .../src/otlp_grpc_metric_exporter_factory.cc | 42 - .../src/otlp_grpc_metric_exporter_options.cc | 49 - .../exporters/otlp/src/otlp_grpc_utils.cc | 62 - .../exporters/otlp/src/otlp_http.cc | 26 - .../exporters/otlp/src/otlp_http_client.cc | 1057 ---- .../exporters/otlp/src/otlp_http_exporter.cc | 218 - .../otlp/src/otlp_http_exporter_factory.cc | 39 - .../otlp/src/otlp_http_exporter_options.cc | 50 - .../otlp/src/otlp_http_log_record_exporter.cc | 218 - .../otlp_http_log_record_exporter_factory.cc | 41 - .../otlp_http_log_record_exporter_options.cc | 50 - .../otlp/src/otlp_http_metric_exporter.cc | 227 - .../src/otlp_http_metric_exporter_factory.cc | 40 - .../src/otlp_http_metric_exporter_options.cc | 52 - .../exporters/otlp/src/otlp_log_recordable.cc | 256 - .../exporters/otlp/src/otlp_metric_utils.cc | 412 -- .../otlp/src/otlp_populate_attribute_utils.cc | 330 -- .../exporters/otlp/src/otlp_recordable.cc | 233 - .../otlp/src/otlp_recordable_utils.cc | 187 - .../otlp/test/otlp_file_client_test.cc | 557 -- .../test/otlp_file_exporter_factory_test.cc | 46 - .../otlp/test/otlp_file_exporter_test.cc | 195 - ...p_file_log_record_exporter_factory_test.cc | 46 - .../otlp_file_log_record_exporter_test.cc | 190 - .../otlp_file_metric_exporter_factory_test.cc | 46 - .../test/otlp_file_metric_exporter_test.cc | 416 -- .../otlp/test/otlp_grpc_exporter_benchmark.cc | 279 - .../test/otlp_grpc_exporter_factory_test.cc | 70 - .../otlp/test/otlp_grpc_exporter_test.cc | 567 -- ...p_grpc_log_record_exporter_factory_test.cc | 72 - .../otlp_grpc_log_record_exporter_test.cc | 524 -- .../otlp_grpc_metric_exporter_factory_test.cc | 72 - .../test/otlp_grpc_metric_exporter_test.cc | 306 - .../otlp/test/otlp_grpc_target_test.cc | 37 - .../test/otlp_http_exporter_factory_test.cc | 48 - .../otlp/test/otlp_http_exporter_test.cc | 797 --- ...p_http_log_record_exporter_factory_test.cc | 48 - .../otlp_http_log_record_exporter_test.cc | 814 --- .../otlp_http_metric_exporter_factory_test.cc | 48 - .../test/otlp_http_metric_exporter_test.cc | 1140 ---- .../otlp/test/otlp_log_recordable_test.cc | 234 - .../test/otlp_metrics_serialization_test.cc | 460 -- .../otlp/test/otlp_recordable_test.cc | 510 -- .../exporters/prometheus/BUILD | 128 - .../exporters/prometheus/CMakeLists.txt | 54 - .../exporters/prometheus/collector.h | 56 - .../exporters/prometheus/exporter.h | 66 - .../exporters/prometheus/exporter_factory.h | 34 - .../exporters/prometheus/exporter_options.h | 41 - .../exporters/prometheus/exporter_utils.h | 230 - .../exporters/prometheus/src/collector.cc | 69 - .../exporters/prometheus/src/exporter.cc | 73 - .../prometheus/src/exporter_factory.cc | 28 - .../prometheus/src/exporter_options.cc | 82 - .../prometheus/src/exporter_utils.cc | 855 --- .../exporters/prometheus/test/CMakeLists.txt | 14 - .../prometheus/test/collector_test.cc | 86 - .../prometheus/test/exporter_test.cc | 77 - .../prometheus/test/exporter_utils_test.cc | 540 -- .../prometheus/test/prometheus_test_helper.h | 235 - .../exporters/zipkin/BUILD | 70 - .../exporters/zipkin/CMakeLists.txt | 68 - .../exporters/zipkin/README.md | 56 - .../exporters/zipkin/recordable.h | 75 - .../exporters/zipkin/zipkin_exporter.h | 96 - .../zipkin/zipkin_exporter_factory.h | 38 - .../zipkin/zipkin_exporter_options.h | 50 - .../exporters/zipkin/src/recordable.cc | 281 - .../exporters/zipkin/src/zipkin_exporter.cc | 151 - .../zipkin/src/zipkin_exporter_factory.cc | 33 - .../zipkin/test/zipkin_exporter_test.cc | 228 - .../zipkin/test/zipkin_recordable_test.cc | 304 - ext/opentelemetry-cpp-1.21.0/ext/BUILD | 10 - .../ext/CMakeLists.txt | 30 - .../ext/http/client/curl/http_client_curl.h | 383 -- .../http/client/curl/http_operation_curl.h | 353 -- .../ext/http/client/http_client.h | 421 -- .../ext/http/client/http_client_factory.h | 29 - .../ext/http/common/url_parser.h | 239 - .../ext/http/server/file_http_server.h | 148 - .../ext/http/server/http_server.h | 889 --- .../ext/http/server/socket_tools.h | 851 --- .../ext/src/CMakeLists.txt | 10 - .../ext/src/dll/CMakeLists.txt | 192 - .../ext/src/dll/dllmain.cc | 19 - .../ext/src/dll/input.src | 83 - .../ext/src/dll/make_def.ps1 | 8 - .../ext/src/dll/opentelemetry_cpp.src | 135 - .../ext/src/http/client/curl/BUILD | 31 - .../ext/src/http/client/curl/CMakeLists.txt | 71 - .../src/http/client/curl/http_client_curl.cc | 912 --- .../client/curl/http_client_factory_curl.cc | 27 - .../http/client/curl/http_operation_curl.cc | 1434 ----- .../ext/test/CMakeLists.txt | 7 - .../ext/test/http/BUILD | 17 - .../ext/test/http/CMakeLists.txt | 42 - .../ext/test/http/curl_http_test.cc | 821 --- .../ext/test/http/url_parser_test.cc | 139 - .../w3c_tracecontext_http_test_server/BUILD | 26 - .../CMakeLists.txt | 13 - .../Dockerfile | 11 - .../README.md | 55 - .../w3c_tracecontext_http_test_server/main.cc | 254 - .../functional/CMakeLists.txt | 6 - .../functional/cert/ca_csr.json | 12 - .../functional/cert/ca_csr_b.json | 12 - .../functional/cert/client_csr.json | 12 - .../functional/cert/client_csr_b.json | 12 - .../functional/cert/garbage.pem | 1 - .../functional/cert/generate_cert.sh | 38 - .../functional/cert/server_csr.json | 12 - .../functional/cert/server_csr_b.json | 12 - .../functional/otlp/CMakeLists.txt | 14 - .../functional/otlp/Dockerfile | 8 - .../functional/otlp/func_grpc_main.cc | 822 --- .../functional/otlp/func_http_main.cc | 1881 ------ .../functional/otlp/otel-config-http.yaml | 33 - .../otlp/otel-config-https-mtls.yaml | 40 - .../functional/otlp/otel-config-https.yaml | 40 - .../otlp/otel-docker-config-http.yaml | 32 - .../otlp/otel-docker-config-https-mtls.yaml | 39 - .../otlp/otel-docker-config-https.yaml | 39 - .../functional/otlp/run_test.sh | 185 - .../functional/otlp/run_test_mode.sh | 80 - .../install/conan/conanfile_latest.txt | 40 - .../install/conan/conanfile_stable.txt | 40 - .../install/test/cmake/CMakeLists.txt | 141 - .../cmake/component_tests/api/CMakeLists.txt | 17 - .../exporters_elasticsearch/CMakeLists.txt | 23 - .../exporters_etw/CMakeLists.txt | 20 - .../exporters_in_memory/CMakeLists.txt | 20 - .../exporters_ostream/CMakeLists.txt | 22 - .../exporters_otlp_common/CMakeLists.txt | 23 - .../exporters_otlp_file/CMakeLists.txt | 27 - .../exporters_otlp_grpc/CMakeLists.txt | 30 - .../exporters_otlp_http/CMakeLists.txt | 27 - .../exporters_prometheus/CMakeLists.txt | 22 - .../exporters_zipkin/CMakeLists.txt | 22 - .../component_tests/ext_common/CMakeLists.txt | 16 - .../component_tests/ext_dll/CMakeLists.txt | 19 - .../ext_http_curl/CMakeLists.txt | 21 - .../cmake/component_tests/sdk/CMakeLists.txt | 30 - .../shims_opentracing/CMakeLists.txt | 22 - .../cmake/fetch_content_test/CMakeLists.txt | 83 - .../test/cmake/package_test/CMakeLists.txt | 78 - .../missing_components/CMakeLists.txt | 45 - .../usage_tests/no_components/CMakeLists.txt | 37 - .../unsorted_components/CMakeLists.txt | 46 - .../unsupported_components/CMakeLists.txt | 23 - .../install/test/src/test_api.cc | 91 - .../test/src/test_exporters_elasticsearch.cc | 20 - .../install/test/src/test_exporters_etw.cc | 65 - .../test/src/test_exporters_in_memory.cc | 25 - .../test/src/test_exporters_ostream.cc | 26 - .../test/src/test_exporters_otlp_common.cc | 161 - .../test/src/test_exporters_otlp_file.cc | 34 - .../test/src/test_exporters_otlp_grpc.cc | 42 - .../test/src/test_exporters_otlp_http.cc | 34 - .../test/src/test_exporters_prometheus.cc | 14 - .../install/test/src/test_exporters_zipkin.cc | 14 - .../install/test/src/test_ext_common.cc | 12 - .../install/test/src/test_ext_dll.cc | 116 - .../install/test/src/test_ext_http_curl.cc | 13 - .../install/test/src/test_sdk.cc | 262 - .../test/src/test_shims_opentracing.cc | 23 - .../opentracing-shim/BUILD | 106 - .../opentracing-shim/CMakeLists.txt | 65 - .../opentracing-shim/README.md | 53 - .../opentracingshim/propagation.h | 94 - .../opentracingshim/shim_utils.h | 191 - .../opentracingshim/span_context_shim.h | 73 - .../opentelemetry/opentracingshim/span_shim.h | 69 - .../opentracingshim/tracer_shim.h | 91 - .../opentracing-shim/src/shim_utils.cc | 104 - .../opentracing-shim/src/span_context_shim.cc | 60 - .../opentracing-shim/src/span_shim.cc | 186 - .../opentracing-shim/src/tracer_shim.cc | 203 - .../opentracing-shim/test/propagation_test.cc | 120 - .../opentracing-shim/test/shim_mocks.h | 261 - .../opentracing-shim/test/shim_utils_test.cc | 308 - .../test/span_context_shim_test.cc | 117 - .../opentracing-shim/test/span_shim_test.cc | 250 - .../opentracing-shim/test/tracer_shim_test.cc | 344 -- ext/opentelemetry-cpp-1.21.0/sdk/BUILD | 10 - .../sdk/CMakeLists.txt | 38 - .../sdk/common/atomic_shared_ptr.h | 63 - .../sdk/common/atomic_unique_ptr.h | 86 - .../sdk/common/attribute_utils.h | 303 - .../sdk/common/attributemap_hash.h | 82 - .../include/opentelemetry/sdk/common/base64.h | 35 - .../sdk/common/circular_buffer.h | 197 - .../sdk/common/circular_buffer_range.h | 92 - .../opentelemetry/sdk/common/disabled.h | 18 - .../sdk/common/empty_attributes.h | 36 - .../opentelemetry/sdk/common/env_variables.h | 73 - .../opentelemetry/sdk/common/exporter_utils.h | 34 - .../sdk/common/global_log_handler.h | 214 - .../sdk/common/thread_instrumentation.h | 92 - .../instrumentation_library.h | 21 - .../instrumentation_scope.h | 182 - .../instrumentationscope/scope_configurator.h | 145 - .../sdk/logs/batch_log_record_processor.h | 179 - .../logs/batch_log_record_processor_factory.h | 44 - .../logs/batch_log_record_processor_options.h | 41 - ...tch_log_record_processor_runtime_options.h | 30 - .../opentelemetry/sdk/logs/event_logger.h | 52 - .../sdk/logs/event_logger_provider.h | 38 - .../sdk/logs/event_logger_provider_factory.h | 35 - .../include/opentelemetry/sdk/logs/exporter.h | 68 - .../include/opentelemetry/sdk/logs/logger.h | 76 - .../opentelemetry/sdk/logs/logger_config.h | 58 - .../opentelemetry/sdk/logs/logger_context.h | 100 - .../sdk/logs/logger_context_factory.h | 62 - .../opentelemetry/sdk/logs/logger_provider.h | 130 - .../sdk/logs/logger_provider_factory.h | 78 - .../sdk/logs/multi_log_record_processor.h | 65 - .../logs/multi_log_record_processor_factory.h | 31 - .../opentelemetry/sdk/logs/multi_recordable.h | 113 - .../opentelemetry/sdk/logs/processor.h | 63 - .../include/opentelemetry/sdk/logs/provider.h | 33 - .../sdk/logs/read_write_log_record.h | 209 - .../sdk/logs/readable_log_record.h | 145 - .../opentelemetry/sdk/logs/recordable.h | 50 - .../sdk/logs/simple_log_record_processor.h | 58 - .../simple_log_record_processor_factory.h | 32 - .../sdk/metrics/aggregation/aggregation.h | 56 - .../metrics/aggregation/aggregation_config.h | 38 - .../base2_exponential_histogram_aggregation.h | 60 - .../base2_exponential_histogram_indexer.h | 46 - .../metrics/aggregation/default_aggregation.h | 203 - .../metrics/aggregation/drop_aggregation.h | 51 - .../aggregation/histogram_aggregation.h | 128 - .../aggregation/lastvalue_aggregation.h | 66 - .../sdk/metrics/aggregation/sum_aggregation.h | 67 - .../sdk/metrics/async_instruments.h | 45 - .../sdk/metrics/data/circular_buffer.h | 159 - .../sdk/metrics/data/exemplar_data.h | 84 - .../sdk/metrics/data/metric_data.h | 45 - .../sdk/metrics/data/point_data.h | 165 - ...gned_histogram_bucket_exemplar_reservoir.h | 96 - .../sdk/metrics/exemplar/filter_type.h | 46 - .../exemplar/fixed_size_exemplar_reservoir.h | 108 - .../metrics/exemplar/no_exemplar_reservoir.h | 67 - .../sdk/metrics/exemplar/reservoir.h | 90 - .../sdk/metrics/exemplar/reservoir_cell.h | 164 - .../exemplar/reservoir_cell_selector.h | 51 - .../sdk/metrics/exemplar/reservoir_utils.h | 62 - .../simple_fixed_size_exemplar_reservoir.h | 108 - .../sdk/metrics/export/metric_filter.h | 112 - .../sdk/metrics/export/metric_producer.h | 114 - .../export/periodic_exporting_metric_reader.h | 71 - ...periodic_exporting_metric_reader_factory.h | 34 - ...periodic_exporting_metric_reader_options.h | 35 - ..._exporting_metric_reader_runtime_options.h | 30 - .../metrics/instrument_metadata_validator.h | 35 - .../opentelemetry/sdk/metrics/instruments.h | 232 - .../include/opentelemetry/sdk/metrics/meter.h | 187 - .../opentelemetry/sdk/metrics/meter_config.h | 57 - .../opentelemetry/sdk/metrics/meter_context.h | 199 - .../sdk/metrics/meter_context_factory.h | 63 - .../sdk/metrics/meter_provider.h | 142 - .../sdk/metrics/meter_provider_factory.h | 44 - .../opentelemetry/sdk/metrics/metric_reader.h | 75 - .../sdk/metrics/observer_result.h | 54 - .../opentelemetry/sdk/metrics/provider.h | 33 - .../sdk/metrics/push_metric_exporter.h | 60 - .../sdk/metrics/state/async_metric_storage.h | 151 - .../sdk/metrics/state/attributes_hashmap.h | 239 - .../state/filtered_ordered_attribute_map.h | 94 - .../sdk/metrics/state/metric_collector.h | 72 - .../sdk/metrics/state/metric_storage.h | 135 - .../sdk/metrics/state/multi_metric_storage.h | 109 - .../sdk/metrics/state/observable_registry.h | 49 - .../sdk/metrics/state/sync_metric_storage.h | 189 - .../metrics/state/temporal_metric_storage.h | 62 - .../sdk/metrics/sync_instruments.h | 179 - .../sdk/metrics/view/attributes_processor.h | 106 - .../sdk/metrics/view/instrument_selector.h | 43 - .../view/instrument_selector_factory.h | 30 - .../sdk/metrics/view/meter_selector.h | 48 - .../sdk/metrics/view/meter_selector_factory.h | 28 - .../sdk/metrics/view/predicate.h | 79 - .../sdk/metrics/view/predicate_factory.h | 48 - .../opentelemetry/sdk/metrics/view/view.h | 72 - .../sdk/metrics/view/view_factory.h | 56 - .../sdk/metrics/view/view_registry.h | 112 - .../sdk/metrics/view/view_registry_factory.h | 23 - .../opentelemetry/sdk/resource/resource.h | 83 - .../sdk/resource/resource_detector.h | 44 - .../sdk/resource/semantic_conventions.h | 5114 ----------------- .../sdk/trace/batch_span_processor.h | 180 - .../sdk/trace/batch_span_processor_factory.h | 43 - .../sdk/trace/batch_span_processor_options.h | 40 - .../batch_span_processor_runtime_options.h | 29 - .../opentelemetry/sdk/trace/exporter.h | 68 - .../opentelemetry/sdk/trace/id_generator.h | 41 - .../sdk/trace/multi_recordable.h | 168 - .../sdk/trace/multi_span_processor.h | 188 - .../opentelemetry/sdk/trace/processor.h | 78 - .../opentelemetry/sdk/trace/provider.h | 31 - .../sdk/trace/random_id_generator.h | 29 - .../sdk/trace/random_id_generator_factory.h | 31 - .../opentelemetry/sdk/trace/recordable.h | 191 - .../include/opentelemetry/sdk/trace/sampler.h | 108 - .../sdk/trace/samplers/always_off.h | 53 - .../sdk/trace/samplers/always_off_factory.h | 31 - .../sdk/trace/samplers/always_on.h | 62 - .../sdk/trace/samplers/always_on_factory.h | 31 - .../opentelemetry/sdk/trace/samplers/parent.h | 54 - .../sdk/trace/samplers/parent_factory.h | 31 - .../sdk/trace/samplers/trace_id_ratio.h | 60 - .../trace/samplers/trace_id_ratio_factory.h | 31 - .../sdk/trace/simple_processor.h | 102 - .../sdk/trace/simple_processor_factory.h | 32 - .../opentelemetry/sdk/trace/span_data.h | 328 -- .../include/opentelemetry/sdk/trace/tracer.h | 115 - .../opentelemetry/sdk/trace/tracer_config.h | 57 - .../opentelemetry/sdk/trace/tracer_context.h | 122 - .../sdk/trace/tracer_context_factory.h | 71 - .../opentelemetry/sdk/trace/tracer_provider.h | 131 - .../sdk/trace/tracer_provider_factory.h | 93 - .../opentelemetry/sdk/version/version.h | 25 - .../sdk/include/opentelemetry/sdk_config.h | 6 - .../sdk/src/CMakeLists.txt | 9 - .../sdk/src/common/BUILD | 69 - .../sdk/src/common/CMakeLists.txt | 30 - .../sdk/src/common/base64.cc | 331 -- .../sdk/src/common/disabled.cc | 32 - .../sdk/src/common/env_variables.cc | 278 - .../src/common/fast_random_number_generator.h | 82 - .../sdk/src/common/global_log_handler.cc | 134 - .../sdk/src/common/platform/BUILD | 23 - .../sdk/src/common/platform/fork.h | 24 - .../sdk/src/common/platform/fork_unix.cc | 23 - .../sdk/src/common/platform/fork_windows.cc | 23 - .../sdk/src/common/random.cc | 87 - .../sdk/src/common/random.h | 43 - .../sdk/src/logs/BUILD | 17 - .../sdk/src/logs/CMakeLists.txt | 42 - .../src/logs/batch_log_record_processor.cc | 399 -- .../batch_log_record_processor_factory.cc | 41 - .../sdk/src/logs/event_logger.cc | 63 - .../sdk/src/logs/event_logger_provider.cc | 34 - .../src/logs/event_logger_provider_factory.cc | 21 - .../sdk/src/logs/exporter.cc | 24 - .../sdk/src/logs/logger.cc | 139 - .../sdk/src/logs/logger_config.cc | 41 - .../sdk/src/logs/logger_context.cc | 68 - .../sdk/src/logs/logger_context_factory.cc | 53 - .../sdk/src/logs/logger_provider.cc | 144 - .../sdk/src/logs/logger_provider_factory.cc | 89 - .../src/logs/multi_log_record_processor.cc | 155 - .../multi_log_record_processor_factory.cc | 29 - .../sdk/src/logs/multi_recordable.cc | 195 - .../sdk/src/logs/provider.cc | 31 - .../sdk/src/logs/read_write_log_record.cc | 213 - .../sdk/src/logs/readable_log_record.cc | 55 - .../src/logs/simple_log_record_processor.cc | 83 - .../simple_log_record_processor_factory.cc | 28 - .../sdk/src/metrics/BUILD | 18 - .../sdk/src/metrics/CMakeLists.txt | 51 - ...base2_exponential_histogram_aggregation.cc | 491 -- .../base2_exponential_histogram_indexer.cc | 71 - .../aggregation/histogram_aggregation.cc | 192 - .../aggregation/lastvalue_aggregation.cc | 145 - .../metrics/aggregation/sum_aggregation.cc | 135 - .../sdk/src/metrics/async_instruments.cc | 58 - .../sdk/src/metrics/data/circular_buffer.cc | 193 - .../sdk/src/metrics/exemplar/reservoir.cc | 47 - .../periodic_exporting_metric_reader.cc | 300 - ...eriodic_exporting_metric_reader_factory.cc | 41 - .../metrics/instrument_metadata_validator.cc | 87 - .../sdk/src/metrics/meter.cc | 734 --- .../sdk/src/metrics/meter_config.cc | 40 - .../sdk/src/metrics/meter_context.cc | 226 - .../sdk/src/metrics/meter_context_factory.cc | 57 - .../sdk/src/metrics/meter_provider.cc | 168 - .../sdk/src/metrics/meter_provider_factory.cc | 68 - .../sdk/src/metrics/metric_reader.cc | 91 - .../sdk/src/metrics/provider.cc | 30 - .../state/filtered_ordered_attribute_map.cc | 49 - .../sdk/src/metrics/state/metric_collector.cc | 146 - .../src/metrics/state/observable_registry.cc | 109 - .../src/metrics/state/sync_metric_storage.cc | 47 - .../metrics/state/temporal_metric_storage.cc | 188 - .../sdk/src/metrics/sync_instruments.cc | 574 -- .../view/instrument_selector_factory.cc | 26 - .../metrics/view/meter_selector_factory.cc | 24 - .../sdk/src/metrics/view/view_factory.cc | 75 - .../src/metrics/view/view_registry_factory.cc | 22 - .../sdk/src/resource/BUILD | 15 - .../sdk/src/resource/CMakeLists.txt | 20 - .../sdk/src/resource/resource.cc | 83 - .../sdk/src/resource/resource_detector.cc | 73 - .../sdk/src/trace/BUILD | 19 - .../sdk/src/trace/CMakeLists.txt | 42 - .../sdk/src/trace/batch_span_processor.cc | 390 -- .../src/trace/batch_span_processor_factory.cc | 41 - .../sdk/src/trace/exporter.cc | 23 - .../sdk/src/trace/provider.cc | 30 - .../sdk/src/trace/random_id_generator.cc | 35 - .../src/trace/random_id_generator_factory.cc | 22 - .../src/trace/samplers/always_off_factory.cc | 22 - .../src/trace/samplers/always_on_factory.cc | 22 - .../sdk/src/trace/samplers/parent.cc | 59 - .../sdk/src/trace/samplers/parent_factory.cc | 26 - .../sdk/src/trace/samplers/trace_id_ratio.cc | 108 - .../trace/samplers/trace_id_ratio_factory.cc | 22 - .../sdk/src/trace/simple_processor_factory.cc | 27 - .../sdk/src/trace/span.cc | 232 - .../sdk/src/trace/span.h | 87 - .../sdk/src/trace/tracer.cc | 191 - .../sdk/src/trace/tracer_config.cc | 41 - .../sdk/src/trace/tracer_context.cc | 84 - .../sdk/src/trace/tracer_context_factory.cc | 79 - .../sdk/src/trace/tracer_provider.cc | 149 - .../sdk/src/trace/tracer_provider_factory.cc | 141 - .../sdk/src/version/CMakeLists.txt | 21 - .../sdk/src/version/version.cc | 24 - .../sdk/test/CMakeLists.txt | 9 - .../sdk/test/common/BUILD | 213 - .../sdk/test/common/CMakeLists.txt | 55 - .../sdk/test/common/atomic_unique_ptr_test.cc | 44 - .../sdk/test/common/attribute_utils_test.cc | 193 - .../common/attributemap_hash_benchmark.cc | 24 - .../sdk/test/common/attributemap_hash_test.cc | 33 - .../sdk/test/common/base64_benchmark.cc | 49 - .../sdk/test/common/base64_test.cc | 92 - .../test/common/baseline_circular_buffer.h | 88 - .../test/common/circular_buffer_benchmark.cc | 138 - .../test/common/circular_buffer_range_test.cc | 59 - .../sdk/test/common/circular_buffer_test.cc | 171 - .../sdk/test/common/empty_attributes_test.cc | 19 - .../sdk/test/common/env_var_test.cc | 352 -- .../fast_random_number_generator_test.cc | 25 - ...obal_log_handle_singleton_lifetime_test.cc | 107 - .../sdk/test/common/global_log_handle_test.cc | 76 - .../sdk/test/common/random_benchmark.cc | 33 - .../sdk/test/common/random_fork_test.cc | 53 - .../sdk/test/common/random_test.cc | 68 - .../sdk/test/instrumentationscope/BUILD | 15 - .../test/instrumentationscope/CMakeLists.txt | 14 - .../instrumentationscope_test.cc | 307 - .../sdk/test/logs/BUILD | 110 - .../sdk/test/logs/CMakeLists.txt | 21 - .../logs/batch_log_record_processor_test.cc | 356 -- .../sdk/test/logs/log_record_test.cc | 321 -- .../sdk/test/logs/logger_config_test.cc | 95 - .../sdk/test/logs/logger_provider_sdk_test.cc | 267 - .../sdk/test/logs/logger_provider_set_test.cc | 92 - .../sdk/test/logs/logger_sdk_test.cc | 546 -- .../logs/simple_log_record_processor_test.cc | 253 - .../sdk/test/metrics/BUILD | 162 - .../sdk/test/metrics/CMakeLists.txt | 83 - .../sdk/test/metrics/aggregation_test.cc | 453 -- .../test/metrics/async_instruments_test.cc | 40 - .../test/metrics/async_metric_storage_test.cc | 321 -- .../metrics/attributes_hashmap_benchmark.cc | 63 - .../test/metrics/attributes_hashmap_test.cc | 160 - .../metrics/attributes_processor_benchmark.cc | 30 - .../test/metrics/attributes_processor_test.cc | 53 - ...exponential_histogram_indexer_benchmark.cc | 66 - ...ase2_exponential_histogram_indexer_test.cc | 180 - .../test/metrics/cardinality_limit_test.cc | 157 - .../metrics/circular_buffer_counter_test.cc | 151 - .../sdk/test/metrics/common.cc | 70 - .../sdk/test/metrics/common.h | 63 - .../sdk/test/metrics/exemplar/BUILD | 53 - .../sdk/test/metrics/exemplar/CMakeLists.txt | 15 - ...istogram_bucket_exemplar_reservoir_test.cc | 56 - .../exemplar/always_sample_filter_test.cc | 18 - .../exemplar/no_exemplar_reservoir_test.cc | 22 - .../metrics/exemplar/reservoir_cell_test.cc | 76 - .../exemplar/with_trace_sample_filter_test.cc | 17 - .../histogram_aggregation_benchmark.cc | 165 - .../metrics/histogram_aggregation_test.cc | 130 - .../sdk/test/metrics/histogram_test.cc | 385 -- .../metrics/instrument_descriptor_test.cc | 163 - .../instrument_metadata_validator_test.cc | 82 - .../test/metrics/measurements_benchmark.cc | 102 - .../sdk/test/metrics/meter_config_test.cc | 95 - .../test/metrics/meter_provider_sdk_test.cc | 313 - .../test/metrics/meter_provider_set_test.cc | 69 - .../sdk/test/metrics/meter_test.cc | 853 --- .../sdk/test/metrics/metric_collector_test.cc | 403 -- .../sdk/test/metrics/metric_reader_test.cc | 34 - .../sdk/test/metrics/metric_test_stress.cc | 172 - .../test/metrics/multi_metric_storage_test.cc | 68 - .../test/metrics/observable_registry_test.cc | 74 - .../sdk/test/metrics/observer_result_test.cc | 40 - .../periodic_exporting_metric_reader_test.cc | 112 - .../test/metrics/sum_aggregation_benchmark.cc | 91 - .../sdk/test/metrics/sum_aggregation_test.cc | 307 - .../sdk/test/metrics/sync_instruments_test.cc | 186 - .../sync_metric_storage_counter_test.cc | 326 -- .../metrics/sync_metric_storage_gauge_test.cc | 196 - .../sync_metric_storage_histogram_test.cc | 542 -- ...ync_metric_storage_up_down_counter_test.cc | 341 -- .../sdk/test/metrics/view_registry_test.cc | 94 - .../sdk/test/resource/BUILD | 15 - .../sdk/test/resource/CMakeLists.txt | 12 - .../sdk/test/resource/resource_test.cc | 294 - .../sdk/test/trace/BUILD | 190 - .../sdk/test/trace/CMakeLists.txt | 38 - .../sdk/test/trace/always_off_sampler_test.cc | 54 - .../sdk/test/trace/always_on_sampler_test.cc | 71 - .../test/trace/batch_span_processor_test.cc | 366 -- .../sdk/test/trace/parent_sampler_test.cc | 88 - .../sdk/test/trace/sampler_benchmark.cc | 181 - .../sdk/test/trace/simple_processor_test.cc | 144 - .../sdk/test/trace/span_data_test.cc | 151 - .../test/trace/trace_id_ratio_sampler_test.cc | 269 - .../sdk/test/trace/tracer_config_test.cc | 95 - .../test/trace/tracer_provider_set_test.cc | 82 - .../sdk/test/trace/tracer_provider_test.cc | 334 -- .../sdk/test/trace/tracer_test.cc | 1334 ----- .../test_common/BUILD | 10 - .../test_common/CMakeLists.txt | 16 - .../http/client/http_client_test_factory.h | 26 - .../http/client/nosend/http_client_nosend.h | 203 - .../test_common/src/CMakeLists.txt | 6 - .../test_common/src/http/client/nosend/BUILD | 23 - .../src/http/client/nosend/CMakeLists.txt | 15 - .../http/client/nosend/http_client_nosend.cc | 108 - .../client/nosend/http_client_test_factory.cc | 13 - .../third_party/BUILD | 6 - .../third_party_release | 25 - ext/opentelemetry-cpp-1.21.0/tools/WORKSPACE | 7 - .../tools/build-bazel.cmd | 9 - .../tools/build-benchmark.cmd | 38 - .../tools/build-benchmark.sh | 30 - .../tools/build-clang-12.cmd | 10 - .../tools/build-clang.cmd | 10 - .../tools/build-docker.cmd | 72 - .../tools/build-gtest.sh | 41 - .../tools/build-nuget.cmd | 14 - .../tools/build-nuget.ps1 | 76 - .../tools/build-vcpkg.sh | 32 - .../tools/build-vs2015.cmd | 36 - .../tools/build-vs2017.cmd | 20 - .../tools/build-vs2019.cmd | 16 - .../tools/build-vs2022.cmd | 16 - ext/opentelemetry-cpp-1.21.0/tools/build.cmd | 177 - ext/opentelemetry-cpp-1.21.0/tools/build.sh | 192 - .../tools/check_copyright.sh | 97 - .../tools/download.cmd | 6 - .../tools/download.ps1 | 7 - ext/opentelemetry-cpp-1.21.0/tools/format.sh | 64 - ext/opentelemetry-cpp-1.21.0/tools/git-cl.cmd | 23 - ext/opentelemetry-cpp-1.21.0/tools/git-cl.sh | 20 - .../tools/install-vs-addons.cmd | 42 - ext/opentelemetry-cpp-1.21.0/tools/install.sh | 18 - .../tools/install_llvm-win32.ps1 | 11 - .../tools/install_llvm-win64.ps1 | 11 - .../tools/nuget/OpenTelemetry.Cpp.Dev.nuspec | 24 - .../tools/nuget/README.md | 42 - .../tools/nuget/opentelemetry-icon-color.png | Bin 47847 -> 0 bytes .../tools/ports/benchmark/CONTROL | 5 - .../tools/ports/benchmark/portfile.cmake | 46 - .../tools/ports/benchmark/version.patch | 34 - .../tools/ports/opentelemetry/CONTROL | 10 - .../tools/ports/opentelemetry/TODO.md | 7 - .../ports/opentelemetry/get_repo_name.sh | 6 - .../tools/ports/opentelemetry/portfile.cmake | 75 - .../opentelemetry/response_file_linux.txt | 9 - .../ports/opentelemetry/response_file_mac.txt | 9 - .../fix-default-proto-file-path.patch | 20 - .../ports/protobuf/fix-static-build.patch | 13 - .../tools/ports/protobuf/port_def.patch | 14 - .../tools/ports/protobuf/portfile.cmake | 127 - .../protobuf-targets-vcpkg-protoc.cmake | 8 - .../ports/protobuf/vcpkg-cmake-wrapper.cmake | 16 - .../tools/ports/protobuf/vcpkg.json | 21 - .../tools/setup-buildtools-mac.sh | 38 - .../tools/setup-buildtools.cmd | 76 - .../tools/setup-buildtools.sh | 60 - .../tools/setup-cfssl.sh | 13 - .../tools/setup-cmake.sh | 64 - .../tools/setup-devenv.cmd | 9 - .../tools/setup-devenv.sh | 32 - .../tools/setup-ninja.sh | 9 - .../tools/setup-protobuf.sh | 10 - ext/opentelemetry-cpp-1.21.0/tools/vcvars.cmd | 200 - make-linux.mk | 39 +- make-mac.mk | 42 +- nonfree/controller/CMakeLists.txt | 7 +- .../controller/README_CENTRAL_CONTROLLER.md | 51 +- scripts/bootstrap-deps.sh | 136 + 1312 files changed, 486 insertions(+), 185699 deletions(-) create mode 100644 Brewfile create mode 100644 cmake/inja.cmake delete mode 100644 conda_env_build.yml delete mode 100644 conda_env_run.yml delete mode 100644 ext/central-controller-docker/Dockerfile.builder delete mode 100644 ext/central-controller-docker/Dockerfile.conda delete mode 100644 ext/central-controller-docker/Dockerfile.conda_builder delete mode 100644 ext/central-controller-docker/Dockerfile.new delete mode 100644 ext/central-controller-docker/Dockerfile.run_base delete mode 100644 ext/central-controller-docker/Makefile delete mode 100755 ext/central-controller-docker/main-new.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/.bazelignore delete mode 100644 ext/opentelemetry-cpp-1.21.0/.bazelrc delete mode 100644 ext/opentelemetry-cpp-1.21.0/.bazelversion delete mode 100644 ext/opentelemetry-cpp-1.21.0/.clang-format delete mode 100644 ext/opentelemetry-cpp-1.21.0/.clang-tidy delete mode 100644 ext/opentelemetry-cpp-1.21.0/.cmake-format.py delete mode 100644 ext/opentelemetry-cpp-1.21.0/.copyright-ignore delete mode 100644 ext/opentelemetry-cpp-1.21.0/.devcontainer/Dockerfile.conan delete mode 100644 ext/opentelemetry-cpp-1.21.0/.devcontainer/Dockerfile.dev delete mode 100644 ext/opentelemetry-cpp-1.21.0/.devcontainer/README.md delete mode 100755 ext/opentelemetry-cpp-1.21.0/.devcontainer/customize_container.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/.devcontainer/devcontainer.json delete mode 100644 ext/opentelemetry-cpp-1.21.0/.gitattributes delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/.codecov.yaml delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/CODEOWNERS delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/ISSUE_TEMPLATE/feature_request.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/dependabot.yml delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/pull_request_template.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/repository-settings.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/workflows/benchmark.yml delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/workflows/ci.yml delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/workflows/clang-tidy.yaml delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/workflows/cmake_install.yml delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/workflows/codeql-analysis.yml delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/workflows/cppcheck.yml delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/workflows/dependencies_image.yml delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/workflows/fossa.yml delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/workflows/iwyu.yml delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/workflows/ossf-scorecard.yml delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/workflows/project_management_comment.yml delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/workflows/project_management_issue_open.yml delete mode 100644 ext/opentelemetry-cpp-1.21.0/.github/workflows/stale.yml delete mode 100644 ext/opentelemetry-cpp-1.21.0/.gitignore delete mode 100644 ext/opentelemetry-cpp-1.21.0/.gitmodules delete mode 100644 ext/opentelemetry-cpp-1.21.0/.iwyu.imp delete mode 100644 ext/opentelemetry-cpp-1.21.0/.markdownlint.json delete mode 100644 ext/opentelemetry-cpp-1.21.0/.markdownlintignore delete mode 100644 ext/opentelemetry-cpp-1.21.0/CHANGELOG.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/CMakeSettings.json delete mode 100644 ext/opentelemetry-cpp-1.21.0/CODE_OF_CONDUCT.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/CONTRIBUTING.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/DEPRECATED.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/INSTALL.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/LICENSE delete mode 100644 ext/opentelemetry-cpp-1.21.0/MODULE.bazel delete mode 100644 ext/opentelemetry-cpp-1.21.0/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/RELEASING.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/Versioning.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/WORKSPACE delete mode 100644 ext/opentelemetry-cpp-1.21.0/WORKSPACE.bzlmod delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/baggage/baggage.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/baggage/baggage_context.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/baggage/propagation/baggage_propagator.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/attribute_value.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/key_value_iterable.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/key_value_iterable_view.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/kv_properties.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/macros.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/spin_lock_mutex.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/string_util.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/timestamp.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/config.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/context.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/context_value.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/propagation/composite_propagator.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/propagation/global_propagator.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/propagation/noop_propagator.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/propagation/text_map_propagator.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/runtime_context.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/detail/preprocessor.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/event_id.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/event_logger.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/event_logger_provider.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/log_record.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/logger.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/logger_provider.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/logger_type_traits.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/noop.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/provider.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/severity.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/async_instruments.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/meter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/meter_provider.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/noop.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/observer_result.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/provider.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/sync_instruments.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/all.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/decay.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/dependent_type.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/functional.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/invoke.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/trait.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/type_pack_element.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/valueless.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/variant_alternative.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/variant_fwd.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/variant_size.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/void.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/function_ref.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/.clang-format delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/config.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/internal/identity.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/internal/inline_variable.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/internal/invoke.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/macros.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/optimization.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/policy_checks.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/port.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/meta/type_traits.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/types/bad_variant_access.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/types/internal/variant.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/types/variant.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/utility/utility.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/shared_ptr.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/span.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/string_view.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/type_traits.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/unique_ptr.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/utility.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/variant.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/plugin/detail/dynamic_library_handle.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/plugin/detail/dynamic_load_unix.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/plugin/detail/dynamic_load_windows.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/plugin/detail/loader_info.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/plugin/detail/tracer_handle.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/plugin/detail/utility.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/plugin/dynamic_load.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/plugin/factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/plugin/hook.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/plugin/tracer.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/azure_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/cicd_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/client_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/code_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/container_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/cpu_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/db_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/db_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/dns_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/error_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/exception_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/faas_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/gen_ai_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/http_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/http_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/hw_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/app_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/artifact_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/aws_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/az_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/azure_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/azure_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/browser_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/cassandra_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/cicd_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/cicd_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/client_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/cloud_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/cloudevents_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/cloudfoundry_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/code_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/container_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/container_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/cpu_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/cpu_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/cpython_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/cpython_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/db_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/db_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/deployment_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/destination_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/device_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/disk_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/dns_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/dns_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/elasticsearch_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/enduser_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/error_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/event_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/exception_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/faas_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/faas_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/feature_flag_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/file_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/gcp_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/gen_ai_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/geo_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/graphql_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/heroku_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/host_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/http_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/http_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/hw_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/hw_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/k8s_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/k8s_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/linux_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/log_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/message_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/messaging_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/messaging_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/net_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/network_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/oci_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/opentracing_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/os_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/otel_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/otel_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/other_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/peer_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/pool_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/process_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/process_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/profile_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/rpc_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/rpc_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/security_rule_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/server_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/service_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/session_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/source_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/system_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/system_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/telemetry_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/test_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/thread_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/tls_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/url_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/user_agent_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/user_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/vcs_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/vcs_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/incubating/webengine_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/k8s_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/messaging_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/network_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/otel_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/otel_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/process_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/rpc_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/schema_url.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/server_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/service_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/system_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/telemetry_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/url_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/user_agent_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/semconv/vcs_metrics.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/std/shared_ptr.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/std/span.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/std/string_view.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/std/type_traits.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/std/unique_ptr.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/std/utility.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/std/variant.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/context.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/default_span.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/noop.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/propagation/b3_propagator.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/propagation/detail/hex.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/propagation/detail/string.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/propagation/http_trace_context.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/propagation/jaeger.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/provider.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/scope.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/semantic_conventions.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/span.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/span_context.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/span_context_kv_iterable.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/span_context_kv_iterable_view.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/span_id.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/span_metadata.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/span_startoptions.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/trace_flags.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/trace_id.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/trace_state.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/tracer.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/trace/tracer_provider.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/version.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/baggage/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/baggage/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/baggage/baggage_benchmark.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/baggage/baggage_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/baggage/propagation/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/baggage/propagation/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/baggage/propagation/baggage_propagator_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/common/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/common/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/common/kv_properties_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/common/spinlock_benchmark.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/common/string_util_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/context/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/context/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/context/context_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/context/propagation/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/context/propagation/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/context/propagation/composite_propagator_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/context/runtime_context_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/core/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/core/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/core/timestamp_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/core/version_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/logs/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/logs/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/logs/logger_benchmark.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/logs/logger_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/logs/provider_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/metrics/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/metrics/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/metrics/meter_provider_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/metrics/noop_sync_instrument_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/nostd/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/nostd/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/nostd/function_ref_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/nostd/shared_ptr_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/nostd/span_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/nostd/string_view_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/nostd/unique_ptr_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/nostd/utility_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/nostd/variant_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/plugin/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/plugin/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/plugin/dynamic_load_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/singleton/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/singleton/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/singleton/component_a.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/singleton/component_a.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/singleton/component_b.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/singleton/component_b.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/singleton/component_c.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/singleton/component_c.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/singleton/component_d.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/singleton/component_d.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/singleton/component_e.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/singleton/component_e.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/singleton/component_f.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/singleton/component_f.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/singleton/component_g.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/singleton/component_h.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/singleton/singleton_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/default_span_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/key_value_iterable_view_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/noop_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/propagation/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/propagation/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/propagation/b3_propagation_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/propagation/detail/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/propagation/detail/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/propagation/detail/hex_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/propagation/detail/string_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/propagation/http_text_format_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/propagation/jaeger_propagation_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/propagation/util.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/provider_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/scope_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/span_benchmark.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/span_context_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/span_id_benchmark.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/span_id_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/trace_flags_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/trace_id_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/trace_state_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/api/test/trace/tracer_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/bazel/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/bazel/curl.BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/bazel/curl.bzl delete mode 100644 ext/opentelemetry-cpp-1.21.0/bazel/extra_deps.bzl delete mode 100644 ext/opentelemetry-cpp-1.21.0/bazel/nlohmann_json.BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/bazel/opentelemetry_proto.BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/bazel/otel_cc_benchmark.bzl delete mode 100644 ext/opentelemetry-cpp-1.21.0/bazel/repository.bzl delete mode 100644 ext/opentelemetry-cpp-1.21.0/bazel/zlib.BUILD delete mode 100755 ext/opentelemetry-cpp-1.21.0/buildscripts/pre-commit delete mode 120000 ext/opentelemetry-cpp-1.21.0/buildscripts/pre-merge-commit delete mode 100755 ext/opentelemetry-cpp-1.21.0/buildscripts/pre_release.sh delete mode 100755 ext/opentelemetry-cpp-1.21.0/buildscripts/semantic-convention/generate.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/buildscripts/semantic-convention/templates/registry/schema_url-h.j2 delete mode 100644 ext/opentelemetry-cpp-1.21.0/buildscripts/semantic-convention/templates/registry/semantic_attributes-h.j2 delete mode 100644 ext/opentelemetry-cpp-1.21.0/buildscripts/semantic-convention/templates/registry/semantic_metrics-h.j2 delete mode 100644 ext/opentelemetry-cpp-1.21.0/buildscripts/semantic-convention/templates/registry/weaver.yaml delete mode 100644 ext/opentelemetry-cpp-1.21.0/ci/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/ci/do_ci.ps1 delete mode 100755 ext/opentelemetry-cpp-1.21.0/ci/do_ci.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/ci/docfx.cmd delete mode 100644 ext/opentelemetry-cpp-1.21.0/ci/docfx.json delete mode 100644 ext/opentelemetry-cpp-1.21.0/ci/fix-abseil-cpp-issue-1536.patch delete mode 100755 ext/opentelemetry-cpp-1.21.0/ci/install_abseil.sh delete mode 100755 ext/opentelemetry-cpp-1.21.0/ci/install_bazelisk.sh delete mode 100755 ext/opentelemetry-cpp-1.21.0/ci/install_format_tools.sh delete mode 100755 ext/opentelemetry-cpp-1.21.0/ci/install_gcc48.sh delete mode 100755 ext/opentelemetry-cpp-1.21.0/ci/install_osx_bazelisk.sh delete mode 100755 ext/opentelemetry-cpp-1.21.0/ci/install_protobuf.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/ci/install_windows_bazelisk.ps1 delete mode 100644 ext/opentelemetry-cpp-1.21.0/ci/install_windows_protobuf.ps1 delete mode 100644 ext/opentelemetry-cpp-1.21.0/ci/ports/protobuf/CONTROL delete mode 100644 ext/opentelemetry-cpp-1.21.0/ci/ports/protobuf/fix-android-log.patch delete mode 100644 ext/opentelemetry-cpp-1.21.0/ci/ports/protobuf/fix-static-build.patch delete mode 100644 ext/opentelemetry-cpp-1.21.0/ci/ports/protobuf/fix-uwp.patch delete mode 100644 ext/opentelemetry-cpp-1.21.0/ci/ports/protobuf/portfile.cmake delete mode 100755 ext/opentelemetry-cpp-1.21.0/ci/run_docker.sh delete mode 100755 ext/opentelemetry-cpp-1.21.0/ci/setup_ci_environment.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/ci/setup_cmake.ps1 delete mode 100755 ext/opentelemetry-cpp-1.21.0/ci/setup_cmake.sh delete mode 100755 ext/opentelemetry-cpp-1.21.0/ci/setup_cmake_macos.sh delete mode 100755 ext/opentelemetry-cpp-1.21.0/ci/setup_gcc10.sh delete mode 100755 ext/opentelemetry-cpp-1.21.0/ci/setup_googletest.sh delete mode 100755 ext/opentelemetry-cpp-1.21.0/ci/setup_grpc.sh delete mode 100755 ext/opentelemetry-cpp-1.21.0/ci/setup_windows_ci_environment.ps1 delete mode 100644 ext/opentelemetry-cpp-1.21.0/ci/toc.yml delete mode 100644 ext/opentelemetry-cpp-1.21.0/ci/valgrind-suppressions delete mode 100755 ext/opentelemetry-cpp-1.21.0/ci/verify_packages.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/cmake/ParseOsRelease.cmake delete mode 100644 ext/opentelemetry-cpp-1.21.0/cmake/find-package-support-functions.cmake delete mode 100644 ext/opentelemetry-cpp-1.21.0/cmake/nlohmann-json.cmake delete mode 100644 ext/opentelemetry-cpp-1.21.0/cmake/opentelemetry-build-external-component.cmake delete mode 100644 ext/opentelemetry-cpp-1.21.0/cmake/opentelemetry-proto.cmake delete mode 100644 ext/opentelemetry-cpp-1.21.0/cmake/otel-install-functions.cmake delete mode 100644 ext/opentelemetry-cpp-1.21.0/cmake/package.cmake delete mode 100644 ext/opentelemetry-cpp-1.21.0/cmake/patch-imported-config.cmake delete mode 100644 ext/opentelemetry-cpp-1.21.0/cmake/pkgconfig.cmake delete mode 100644 ext/opentelemetry-cpp-1.21.0/cmake/templates/component-definitions.cmake.in delete mode 100644 ext/opentelemetry-cpp-1.21.0/cmake/templates/config.pc.in delete mode 100644 ext/opentelemetry-cpp-1.21.0/cmake/templates/opentelemetry-cpp-config.cmake.in delete mode 100644 ext/opentelemetry-cpp-1.21.0/cmake/templates/thirdparty-dependency-definitions.cmake.in delete mode 100644 ext/opentelemetry-cpp-1.21.0/cmake/thirdparty-dependency-config.cmake delete mode 100644 ext/opentelemetry-cpp-1.21.0/cmake/tools.cmake delete mode 100644 ext/opentelemetry-cpp-1.21.0/docker/.gitignore delete mode 100644 ext/opentelemetry-cpp-1.21.0/docker/Dockerfile delete mode 100644 ext/opentelemetry-cpp-1.21.0/docker/Dockerfile.alpine.base delete mode 100644 ext/opentelemetry-cpp-1.21.0/docker/Dockerfile.centos delete mode 100644 ext/opentelemetry-cpp-1.21.0/docker/Dockerfile.debian.deps delete mode 100644 ext/opentelemetry-cpp-1.21.0/docker/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/docker/build.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/docker/grpc/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/docker/grpc/Dockerfile delete mode 100644 ext/opentelemetry-cpp-1.21.0/docker/ubuntuLatest/Dockerfile delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/abi-compatibility.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/abi-policy.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/abi-version-policy.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/build-as-dll.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/building-with-stdlib.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/building-with-vcpkg.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/building-with-vs2019.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/cpp-ostream-exporter-design.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/cpp-sdk-factory-design.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/dependencies.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/deprecation-process.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/google-test.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/library-distribution.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/maintaining-dependencies.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/public/Doxyfile delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/public/GettingHelp.rst delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/public/Makefile delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/public/_static/opentelemetry_logo.png delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/public/_templates/sidebar/brand.html delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/public/api/GettingStarted.rst delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/public/api/Overview.rst delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/public/api/api.rst delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/public/conf.py delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/public/index.rst delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/public/performance/benchmarks.rst delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/public/requirements.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/public/resources/footer.html delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/public/resources/header.html delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/public/resources/stylesheet.css delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/public/sdk/GettingStarted.rst delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/public/sdk/sdk.rst delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/requirements.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/testing-with-ssl.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/docs/using-clang-format.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/batch/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/batch/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/batch/main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/common/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/common/foo_library/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/common/foo_library/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/common/foo_library/foo_library.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/common/foo_library/foo_library.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/common/logs_foo_library/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/common/logs_foo_library/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/common/logs_foo_library/foo_library.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/common/logs_foo_library/foo_library.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/common/metrics_foo_library/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/common/metrics_foo_library/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/common/metrics_foo_library/foo_library.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/common/metrics_foo_library/foo_library.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/etw_threads/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/etw_threads/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/etw_threads/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/etw_threads/main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/grpc/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/grpc/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/grpc/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/grpc/client.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/grpc/protos/messages.proto delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/grpc/server.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/grpc/tracer_common.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/http/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/http/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/http/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/http/client.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/http/server.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/http/server.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/http/tracer_common.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/logs_simple/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/logs_simple/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/logs_simple/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/logs_simple/main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/metrics_simple/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/metrics_simple/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/metrics_simple/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/metrics_simple/metrics_ostream.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/multi_processor/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/multi_processor/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/multi_processor/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/multi_processor/main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/multithreaded/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/multithreaded/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/multithreaded/main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/otlp/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/otlp/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/otlp/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/otlp/file_log_main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/otlp/file_main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/otlp/file_metric_main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/otlp/grpc_log_main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/otlp/grpc_main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/otlp/grpc_metric_main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/otlp/http_instrumented_main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/otlp/http_log_main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/otlp/http_main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/otlp/http_metric_main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/otlp/opentelemetry-collector-config/config.dev.yaml delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/plugin/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/plugin/load/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/plugin/load/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/plugin/load/main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/plugin/plugin/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/plugin/plugin/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/plugin/plugin/factory_impl.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/plugin/plugin/tracer.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/plugin/plugin/tracer.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/prometheus/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/prometheus/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/prometheus/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/prometheus/main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/prometheus/prometheus.yml delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/prometheus/run.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/simple/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/simple/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/simple/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/simple/main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/zipkin/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/zipkin/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/examples/zipkin/main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/elasticsearch/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/elasticsearch/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_record_exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/elasticsearch/src/es_log_record_exporter.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/elasticsearch/src/es_log_recordable.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/elasticsearch/test/es_log_record_exporter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/include/opentelemetry/exporters/etw/LICENSE delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/include/opentelemetry/exporters/etw/TraceLoggingDynamic.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/include/opentelemetry/exporters/etw/etw_config.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/include/opentelemetry/exporters/etw/etw_fields.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/include/opentelemetry/exporters/etw/etw_logger.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/include/opentelemetry/exporters/etw/etw_logger_exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/include/opentelemetry/exporters/etw/etw_properties.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/include/opentelemetry/exporters/etw/etw_provider.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/include/opentelemetry/exporters/etw/etw_random_id_generator.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/include/opentelemetry/exporters/etw/etw_tail_sampler.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/include/opentelemetry/exporters/etw/etw_traceloggingdynamic.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer_exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/include/opentelemetry/exporters/etw/utils.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/include/opentelemetry/exporters/etw/uuid.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/test/etw_logger_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/test/etw_perf_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/test/etw_provider_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/etw/test/etw_tracer_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/memory/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/memory/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/memory/include/opentelemetry/exporters/memory/in_memory_data.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_data.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/memory/include/opentelemetry/exporters/memory/in_memory_metric_exporter_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_data.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/memory/src/in_memory_metric_data.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/memory/src/in_memory_metric_exporter_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/memory/src/in_memory_span_exporter_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/memory/test/in_memory_metric_data_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/memory/test/in_memory_metric_exporter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/memory/test/in_memory_span_data_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/memory/test/in_memory_span_exporter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/ostream/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/ostream/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/ostream/include/opentelemetry/exporters/ostream/common_utils.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/ostream/include/opentelemetry/exporters/ostream/metric_exporter_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/ostream/src/log_record_exporter.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/ostream/src/log_record_exporter_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/ostream/src/metric_exporter.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/ostream/src/metric_exporter_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/ostream/src/span_exporter.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/ostream/src/span_exporter_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/ostream/test/ostream_capture.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/ostream/test/ostream_log_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/ostream/test/ostream_metric_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/ostream/test/ostream_span_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_environment.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_client.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_client_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_client_runtime_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_exporter_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_exporter_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_exporter_runtime_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_log_record_exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_log_record_exporter_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_log_record_exporter_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_log_record_exporter_runtime_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_metric_exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_metric_exporter_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_metric_exporter_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_file_metric_exporter_runtime_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_utils.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter_runtime_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_runtime_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_metric_exporter_runtime_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_log_recordable.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_metric_utils.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_populate_attribute_utils.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_preferred_temporality.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_recordable.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_recordable_utils.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/protobuf_include_prefix.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/include/opentelemetry/exporters/otlp/protobuf_include_suffix.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_environment.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_file_client.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_file_exporter.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_file_exporter_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_file_exporter_options.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_file_log_record_exporter.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_file_log_record_exporter_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_file_log_record_exporter_options.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_file_metric_exporter.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_file_metric_exporter_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_file_metric_exporter_options.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_grpc_client.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_grpc_client_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_grpc_exporter.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_grpc_exporter_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_grpc_exporter_options.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_grpc_log_record_exporter.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_grpc_log_record_exporter_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_grpc_log_record_exporter_options.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_grpc_metric_exporter.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_grpc_metric_exporter_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_grpc_metric_exporter_options.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_grpc_utils.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_http.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_http_client.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_http_exporter.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_http_exporter_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_http_exporter_options.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_http_log_record_exporter.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_http_log_record_exporter_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_http_log_record_exporter_options.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_http_metric_exporter.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_http_metric_exporter_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_http_metric_exporter_options.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_log_recordable.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_metric_utils.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_populate_attribute_utils.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_recordable.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/src/otlp_recordable_utils.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_file_client_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_file_exporter_factory_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_file_exporter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_file_log_record_exporter_factory_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_file_log_record_exporter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_file_metric_exporter_factory_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_file_metric_exporter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_grpc_exporter_benchmark.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_grpc_exporter_factory_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_grpc_exporter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_grpc_log_record_exporter_factory_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_grpc_metric_exporter_factory_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_grpc_metric_exporter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_grpc_target_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_http_exporter_factory_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_http_exporter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_http_log_record_exporter_factory_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_http_log_record_exporter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_http_metric_exporter_factory_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_http_metric_exporter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_log_recordable_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_metrics_serialization_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/otlp/test/otlp_recordable_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/prometheus/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/prometheus/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/prometheus/include/opentelemetry/exporters/prometheus/collector.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/prometheus/include/opentelemetry/exporters/prometheus/exporter_utils.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/prometheus/src/collector.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/prometheus/src/exporter.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/prometheus/src/exporter_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/prometheus/src/exporter_options.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/prometheus/src/exporter_utils.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/prometheus/test/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/prometheus/test/collector_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/prometheus/test/exporter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/prometheus/test/exporter_utils_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/prometheus/test/prometheus_test_helper.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/zipkin/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/zipkin/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/zipkin/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/zipkin/include/opentelemetry/exporters/zipkin/recordable.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/zipkin/src/recordable.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/zipkin/src/zipkin_exporter.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/zipkin/src/zipkin_exporter_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/zipkin/test/zipkin_exporter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/exporters/zipkin/test/zipkin_recordable_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/include/opentelemetry/ext/http/client/curl/http_client_curl.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/include/opentelemetry/ext/http/client/http_client.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/include/opentelemetry/ext/http/client/http_client_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/include/opentelemetry/ext/http/common/url_parser.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/include/opentelemetry/ext/http/server/file_http_server.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/include/opentelemetry/ext/http/server/http_server.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/include/opentelemetry/ext/http/server/socket_tools.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/src/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/src/dll/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/src/dll/dllmain.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/src/dll/input.src delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/src/dll/make_def.ps1 delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/src/dll/opentelemetry_cpp.src delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/src/http/client/curl/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/src/http/client/curl/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/src/http/client/curl/http_client_curl.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/src/http/client/curl/http_client_factory_curl.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/src/http/client/curl/http_operation_curl.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/test/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/test/http/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/test/http/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/test/http/curl_http_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/test/http/url_parser_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/test/w3c_tracecontext_http_test_server/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/test/w3c_tracecontext_http_test_server/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/test/w3c_tracecontext_http_test_server/Dockerfile delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/test/w3c_tracecontext_http_test_server/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/ext/test/w3c_tracecontext_http_test_server/main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/functional/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/functional/cert/ca_csr.json delete mode 100644 ext/opentelemetry-cpp-1.21.0/functional/cert/ca_csr_b.json delete mode 100644 ext/opentelemetry-cpp-1.21.0/functional/cert/client_csr.json delete mode 100644 ext/opentelemetry-cpp-1.21.0/functional/cert/client_csr_b.json delete mode 100644 ext/opentelemetry-cpp-1.21.0/functional/cert/garbage.pem delete mode 100755 ext/opentelemetry-cpp-1.21.0/functional/cert/generate_cert.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/functional/cert/server_csr.json delete mode 100644 ext/opentelemetry-cpp-1.21.0/functional/cert/server_csr_b.json delete mode 100644 ext/opentelemetry-cpp-1.21.0/functional/otlp/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/functional/otlp/Dockerfile delete mode 100644 ext/opentelemetry-cpp-1.21.0/functional/otlp/func_grpc_main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/functional/otlp/func_http_main.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/functional/otlp/otel-config-http.yaml delete mode 100644 ext/opentelemetry-cpp-1.21.0/functional/otlp/otel-config-https-mtls.yaml delete mode 100644 ext/opentelemetry-cpp-1.21.0/functional/otlp/otel-config-https.yaml delete mode 100644 ext/opentelemetry-cpp-1.21.0/functional/otlp/otel-docker-config-http.yaml delete mode 100644 ext/opentelemetry-cpp-1.21.0/functional/otlp/otel-docker-config-https-mtls.yaml delete mode 100644 ext/opentelemetry-cpp-1.21.0/functional/otlp/otel-docker-config-https.yaml delete mode 100755 ext/opentelemetry-cpp-1.21.0/functional/otlp/run_test.sh delete mode 100755 ext/opentelemetry-cpp-1.21.0/functional/otlp/run_test_mode.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/conan/conanfile_latest.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/conan/conanfile_stable.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/component_tests/api/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/component_tests/exporters_elasticsearch/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/component_tests/exporters_etw/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/component_tests/exporters_in_memory/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/component_tests/exporters_ostream/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/component_tests/exporters_otlp_common/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/component_tests/exporters_otlp_file/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/component_tests/exporters_otlp_grpc/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/component_tests/exporters_otlp_http/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/component_tests/exporters_prometheus/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/component_tests/exporters_zipkin/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/component_tests/ext_common/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/component_tests/ext_dll/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/component_tests/ext_http_curl/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/component_tests/sdk/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/component_tests/shims_opentracing/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/fetch_content_test/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/package_test/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/usage_tests/missing_components/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/usage_tests/no_components/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/usage_tests/unsorted_components/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/cmake/usage_tests/unsupported_components/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/src/test_api.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/src/test_exporters_elasticsearch.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/src/test_exporters_etw.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/src/test_exporters_in_memory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/src/test_exporters_ostream.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/src/test_exporters_otlp_common.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/src/test_exporters_otlp_file.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/src/test_exporters_otlp_grpc.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/src/test_exporters_otlp_http.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/src/test_exporters_prometheus.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/src/test_exporters_zipkin.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/src/test_ext_common.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/src/test_ext_dll.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/src/test_ext_http_curl.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/src/test_sdk.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/install/test/src/test_shims_opentracing.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/opentracing-shim/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/opentracing-shim/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/opentracing-shim/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/opentracing-shim/include/opentelemetry/opentracingshim/propagation.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/opentracing-shim/include/opentelemetry/opentracingshim/shim_utils.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/opentracing-shim/include/opentelemetry/opentracingshim/span_context_shim.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/opentracing-shim/include/opentelemetry/opentracingshim/span_shim.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/opentracing-shim/include/opentelemetry/opentracingshim/tracer_shim.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/opentracing-shim/src/shim_utils.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/opentracing-shim/src/span_context_shim.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/opentracing-shim/src/span_shim.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/opentracing-shim/src/tracer_shim.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/opentracing-shim/test/propagation_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/opentracing-shim/test/shim_mocks.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/opentracing-shim/test/shim_utils_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/opentracing-shim/test/span_context_shim_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/opentracing-shim/test/span_shim_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/opentracing-shim/test/tracer_shim_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/common/atomic_shared_ptr.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/common/atomic_unique_ptr.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/common/attribute_utils.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/common/attributemap_hash.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/common/base64.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/common/circular_buffer.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/common/circular_buffer_range.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/common/disabled.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/common/empty_attributes.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/common/env_variables.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/common/exporter_utils.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/common/global_log_handler.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/common/thread_instrumentation.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/instrumentationlibrary/instrumentation_library.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/instrumentationscope/instrumentation_scope.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/instrumentationscope/scope_configurator.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor_runtime_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/event_logger.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/event_logger_provider.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/event_logger_provider_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/logger.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/logger_config.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/logger_context.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/logger_context_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/logger_provider.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/logger_provider_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/multi_recordable.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/processor.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/provider.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/read_write_log_record.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/readable_log_record.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/recordable.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/aggregation/aggregation.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/aggregation/aggregation_config.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/aggregation/base2_exponential_histogram_aggregation.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/aggregation/base2_exponential_histogram_indexer.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/aggregation/default_aggregation.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/aggregation/drop_aggregation.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/aggregation/histogram_aggregation.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/aggregation/lastvalue_aggregation.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/aggregation/sum_aggregation.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/async_instruments.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/data/circular_buffer.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/data/exemplar_data.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/data/metric_data.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/data/point_data.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/exemplar/aligned_histogram_bucket_exemplar_reservoir.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/exemplar/filter_type.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/exemplar/fixed_size_exemplar_reservoir.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/exemplar/no_exemplar_reservoir.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir_cell.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir_cell_selector.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir_utils.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/exemplar/simple_fixed_size_exemplar_reservoir.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/export/metric_filter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/export/metric_producer.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_runtime_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/instrument_metadata_validator.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/instruments.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/meter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/meter_config.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/meter_context.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/meter_context_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/meter_provider.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/meter_provider_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/metric_reader.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/observer_result.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/provider.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/push_metric_exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/state/async_metric_storage.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/state/attributes_hashmap.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/state/filtered_ordered_attribute_map.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/state/metric_collector.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/state/metric_storage.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/state/multi_metric_storage.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/state/observable_registry.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/state/sync_metric_storage.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/state/temporal_metric_storage.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/sync_instruments.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/view/attributes_processor.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/view/instrument_selector_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/view/meter_selector.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/view/meter_selector_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/view/predicate.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/view/predicate_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/view/view.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/view/view_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/view/view_registry.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/metrics/view/view_registry_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/resource/resource.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/resource/resource_detector.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/batch_span_processor_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/batch_span_processor_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/batch_span_processor_runtime_options.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/exporter.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/id_generator.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/multi_recordable.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/multi_span_processor.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/processor.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/provider.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/random_id_generator.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/random_id_generator_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/recordable.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/sampler.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/samplers/always_off.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/samplers/always_off_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/samplers/always_on.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/samplers/always_on_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/samplers/parent.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/samplers/parent_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/samplers/trace_id_ratio_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/simple_processor.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/simple_processor_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/span_data.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/tracer.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/tracer_config.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/tracer_context.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/tracer_context_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/tracer_provider.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/trace/tracer_provider_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk/version/version.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/include/opentelemetry/sdk_config.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/common/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/common/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/common/base64.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/common/disabled.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/common/env_variables.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/common/fast_random_number_generator.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/common/global_log_handler.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/common/platform/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/common/platform/fork.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/common/platform/fork_unix.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/common/platform/fork_windows.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/common/random.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/common/random.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/batch_log_record_processor.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/batch_log_record_processor_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/event_logger.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/event_logger_provider.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/event_logger_provider_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/exporter.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/logger.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/logger_config.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/logger_context.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/logger_context_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/logger_provider.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/logger_provider_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/multi_log_record_processor.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/multi_log_record_processor_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/multi_recordable.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/provider.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/read_write_log_record.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/readable_log_record.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/simple_log_record_processor.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/logs/simple_log_record_processor_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/aggregation/base2_exponential_histogram_aggregation.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/aggregation/base2_exponential_histogram_indexer.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/aggregation/histogram_aggregation.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/aggregation/lastvalue_aggregation.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/aggregation/sum_aggregation.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/async_instruments.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/data/circular_buffer.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/exemplar/reservoir.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/export/periodic_exporting_metric_reader.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/export/periodic_exporting_metric_reader_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/instrument_metadata_validator.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/meter.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/meter_config.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/meter_context.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/meter_context_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/meter_provider.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/meter_provider_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/metric_reader.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/provider.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/state/filtered_ordered_attribute_map.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/state/metric_collector.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/state/observable_registry.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/state/sync_metric_storage.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/state/temporal_metric_storage.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/sync_instruments.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/view/instrument_selector_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/view/meter_selector_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/view/view_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/metrics/view/view_registry_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/resource/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/resource/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/resource/resource.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/resource/resource_detector.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/batch_span_processor.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/batch_span_processor_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/exporter.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/provider.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/random_id_generator.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/random_id_generator_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/samplers/always_off_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/samplers/always_on_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/samplers/parent.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/samplers/parent_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/samplers/trace_id_ratio.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/samplers/trace_id_ratio_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/simple_processor_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/span.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/span.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/tracer.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/tracer_config.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/tracer_context.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/tracer_context_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/tracer_provider.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/trace/tracer_provider_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/version/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/src/version/version.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/atomic_unique_ptr_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/attribute_utils_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/attributemap_hash_benchmark.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/attributemap_hash_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/base64_benchmark.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/base64_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/baseline_circular_buffer.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/circular_buffer_benchmark.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/circular_buffer_range_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/circular_buffer_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/empty_attributes_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/env_var_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/fast_random_number_generator_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/global_log_handle_singleton_lifetime_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/global_log_handle_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/random_benchmark.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/random_fork_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/common/random_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/instrumentationscope/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/instrumentationscope/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/instrumentationscope/instrumentationscope_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/logs/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/logs/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/logs/batch_log_record_processor_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/logs/log_record_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/logs/logger_config_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/logs/logger_provider_sdk_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/logs/logger_provider_set_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/logs/logger_sdk_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/logs/simple_log_record_processor_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/aggregation_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/async_instruments_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/async_metric_storage_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/attributes_hashmap_benchmark.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/attributes_hashmap_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/attributes_processor_benchmark.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/attributes_processor_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/base2_exponential_histogram_indexer_benchmark.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/base2_exponential_histogram_indexer_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/cardinality_limit_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/circular_buffer_counter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/common.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/common.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/exemplar/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/exemplar/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/exemplar/aligned_histogram_bucket_exemplar_reservoir_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/exemplar/always_sample_filter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/exemplar/no_exemplar_reservoir_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/exemplar/reservoir_cell_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/exemplar/with_trace_sample_filter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/histogram_aggregation_benchmark.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/histogram_aggregation_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/histogram_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/instrument_descriptor_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/instrument_metadata_validator_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/measurements_benchmark.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/meter_config_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/meter_provider_sdk_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/meter_provider_set_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/meter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/metric_collector_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/metric_reader_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/metric_test_stress.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/multi_metric_storage_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/observable_registry_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/observer_result_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/periodic_exporting_metric_reader_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/sum_aggregation_benchmark.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/sum_aggregation_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/sync_instruments_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/sync_metric_storage_counter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/sync_metric_storage_gauge_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/sync_metric_storage_histogram_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/sync_metric_storage_up_down_counter_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/metrics/view_registry_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/resource/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/resource/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/resource/resource_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/trace/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/trace/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/trace/always_off_sampler_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/trace/always_on_sampler_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/trace/batch_span_processor_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/trace/parent_sampler_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/trace/sampler_benchmark.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/trace/simple_processor_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/trace/span_data_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/trace/trace_id_ratio_sampler_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/trace/tracer_config_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/trace/tracer_provider_set_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/trace/tracer_provider_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/sdk/test/trace/tracer_test.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/test_common/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/test_common/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/test_common/include/opentelemetry/test_common/ext/http/client/http_client_test_factory.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/test_common/include/opentelemetry/test_common/ext/http/client/nosend/http_client_nosend.h delete mode 100644 ext/opentelemetry-cpp-1.21.0/test_common/src/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/test_common/src/http/client/nosend/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/test_common/src/http/client/nosend/CMakeLists.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/test_common/src/http/client/nosend/http_client_nosend.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/test_common/src/http/client/nosend/http_client_test_factory.cc delete mode 100644 ext/opentelemetry-cpp-1.21.0/third_party/BUILD delete mode 100644 ext/opentelemetry-cpp-1.21.0/third_party_release delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/WORKSPACE delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/build-bazel.cmd delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/build-benchmark.cmd delete mode 100755 ext/opentelemetry-cpp-1.21.0/tools/build-benchmark.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/build-clang-12.cmd delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/build-clang.cmd delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/build-docker.cmd delete mode 100755 ext/opentelemetry-cpp-1.21.0/tools/build-gtest.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/build-nuget.cmd delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/build-nuget.ps1 delete mode 100755 ext/opentelemetry-cpp-1.21.0/tools/build-vcpkg.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/build-vs2015.cmd delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/build-vs2017.cmd delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/build-vs2019.cmd delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/build-vs2022.cmd delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/build.cmd delete mode 100755 ext/opentelemetry-cpp-1.21.0/tools/build.sh delete mode 100755 ext/opentelemetry-cpp-1.21.0/tools/check_copyright.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/download.cmd delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/download.ps1 delete mode 100755 ext/opentelemetry-cpp-1.21.0/tools/format.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/git-cl.cmd delete mode 100755 ext/opentelemetry-cpp-1.21.0/tools/git-cl.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/install-vs-addons.cmd delete mode 100755 ext/opentelemetry-cpp-1.21.0/tools/install.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/install_llvm-win32.ps1 delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/install_llvm-win64.ps1 delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/nuget/OpenTelemetry.Cpp.Dev.nuspec delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/nuget/README.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/nuget/opentelemetry-icon-color.png delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/ports/benchmark/CONTROL delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/ports/benchmark/portfile.cmake delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/ports/benchmark/version.patch delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/ports/opentelemetry/CONTROL delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/ports/opentelemetry/TODO.md delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/ports/opentelemetry/get_repo_name.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/ports/opentelemetry/portfile.cmake delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/ports/opentelemetry/response_file_linux.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/ports/opentelemetry/response_file_mac.txt delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/ports/protobuf/fix-default-proto-file-path.patch delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/ports/protobuf/fix-static-build.patch delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/ports/protobuf/port_def.patch delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/ports/protobuf/portfile.cmake delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/ports/protobuf/protobuf-targets-vcpkg-protoc.cmake delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/ports/protobuf/vcpkg-cmake-wrapper.cmake delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/ports/protobuf/vcpkg.json delete mode 100755 ext/opentelemetry-cpp-1.21.0/tools/setup-buildtools-mac.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/setup-buildtools.cmd delete mode 100755 ext/opentelemetry-cpp-1.21.0/tools/setup-buildtools.sh delete mode 100755 ext/opentelemetry-cpp-1.21.0/tools/setup-cfssl.sh delete mode 100755 ext/opentelemetry-cpp-1.21.0/tools/setup-cmake.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/setup-devenv.cmd delete mode 100755 ext/opentelemetry-cpp-1.21.0/tools/setup-devenv.sh delete mode 100755 ext/opentelemetry-cpp-1.21.0/tools/setup-ninja.sh delete mode 100755 ext/opentelemetry-cpp-1.21.0/tools/setup-protobuf.sh delete mode 100644 ext/opentelemetry-cpp-1.21.0/tools/vcvars.cmd create mode 100755 scripts/bootstrap-deps.sh diff --git a/.dockerignore b/.dockerignore index 4acef401cf..10b50a97db 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,12 @@ .git/ workspace/ +# Local from-source dependency builds (scripts/bootstrap-deps.sh) and CMake output; +# never ship these into an image -- they are host-specific and large. +.deps/ +.deps-build/ +build/ +build-*/ +out/ +# Dockerfiles are supplied via -f; keeping them out of the context means editing +# them does not invalidate the COPY layers (and the heavy build cache). +ext/central-controller-docker/Dockerfile* diff --git a/.github/workflows/central-controller.yaml b/.github/workflows/central-controller.yaml index 209cc0522f..fc20a7a15d 100644 --- a/.github/workflows/central-controller.yaml +++ b/.github/workflows/central-controller.yaml @@ -39,9 +39,23 @@ jobs: calculatedSha=$(git rev-parse --short ${{ github.sha }}) echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build & Push Docker Image + # Registry layer cache (mode=max) so the expensive builder stage -- which + # builds opentelemetry-cpp + google-cloud-cpp from source -- is reused across + # runs and fresh runners. The cache invalidates automatically when the + # bootstrap inputs change. Cache is per-arch (the deps layer is arch-specific). run: | - docker build -t us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} -f ext/central-controller-docker/Dockerfile.new --provenance false . --push + CACHE=us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller-buildcache:${{ runner.arch }} + docker buildx build \ + -t us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/ztcentral-controller:${{ env.COMMIT_SHORT_SHA }}-${{ steps.branch.outputs.branch_name }}-${{ runner.arch }} \ + -f ext/central-controller-docker/Dockerfile \ + --cache-from type=registry,ref=$CACHE \ + --cache-to type=registry,ref=$CACHE,mode=max \ + --provenance false \ + --push . multi-arch-docker: runs-on: gha-runner-x64 diff --git a/.gitignore b/.gitignore index b8fd5c0479..dd562076dd 100755 --- a/.gitignore +++ b/.gitignore @@ -145,4 +145,9 @@ __pycache__ snap/.snapcraft build/ +# Local dependency bootstrap output (scripts/bootstrap-deps.sh): the install +# prefix and the build/clone scratch dir. Large + host-specific; never commit. +.deps/ +.deps-build/ + .claude/*.local.* diff --git a/Brewfile b/Brewfile new file mode 100644 index 0000000000..e8ac2e5d49 --- /dev/null +++ b/Brewfile @@ -0,0 +1,28 @@ +# Central Controller build dependencies for macOS development. +# +# brew bundle # install the deps below +# ZT_CONTROLLER_DEPS=1 scripts/bootstrap-deps.sh # build the two pinned controller deps (full OTel + google-cloud-cpp) +# +# The two version-sensitive C++ libraries (opentelemetry-cpp, google-cloud-cpp) +# are NOT taken from Homebrew -- they are pinned and built from source by +# scripts/bootstrap-deps.sh so every dev/CI machine uses the same versions +# (the role conda previously filled). Everything below is stable enough to take +# from Homebrew. + +brew "cmake" +brew "ninja" +brew "pkg-config" +brew "rustup-init" # then: rustup-init -y && rustup default stable + +brew "libpqxx" +brew "libpq" # keg-only; add $(brew --prefix libpq) to CMAKE_PREFIX_PATH so find_package(PostgreSQL) resolves +brew "hiredis" +brew "jemalloc" +brew "nlohmann-json" +brew "openssl@3" +brew "abseil" +brew "protobuf" +brew "grpc" +brew "googletest" # google-cloud-cpp requires GTest/GMock at configure (builds its *_mocks libs) +brew "curl" +brew "inja" diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cda80a85a..76b5c56ddf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -298,7 +298,8 @@ include(ExternalProject) find_package(OpenSSL REQUIRED) find_package(nlohmann_json REQUIRED) -find_package(inja REQUIRED) +# inja: found if installed (Homebrew), otherwise fetched (Debian has no package). +include(cmake/inja.cmake) # Threads (prefer pthreads) set(THREADS_PREFER_PTHREAD_FLAG TRUE CACHE INTERNAL "Use pthreads" FORCE) @@ -312,11 +313,39 @@ endif() # else only needs the API. if(ZT1_CENTRAL_CONTROLLER) find_package(PostgreSQL REQUIRED) - find_package(opentelemetry-cpp REQUIRED COMPONENTS api sdk exporters_otlp_grpc exporters_otlp_http exporters_prometheus) - find_package(google_cloud_cpp_bigtable REQUIRED) - find_package(google_cloud_cpp_pubsub REQUIRED) + # opentelemetry-cpp + google-cloud-cpp come from scripts/bootstrap-deps.sh. Find + # them non-fatally so we can emit an actionable error (vs CMake's default) if the + # prefix wasn't provided. A wrong-mode prefix (api-only OTel) also lands here, + # since the missing sdk/exporter components leave opentelemetry-cpp_FOUND false. + find_package(opentelemetry-cpp QUIET COMPONENTS api sdk exporters_otlp_grpc exporters_otlp_http) + find_package(google_cloud_cpp_bigtable QUIET) + find_package(google_cloud_cpp_pubsub QUIET) + if(NOT opentelemetry-cpp_FOUND OR NOT google_cloud_cpp_bigtable_FOUND OR NOT google_cloud_cpp_pubsub_FOUND) + message(FATAL_ERROR [=[ +Controller dependencies (opentelemetry-cpp and/or google-cloud-cpp) were not found on +CMAKE_PREFIX_PATH. Build them, then re-run CMake pointing at the prefix: + + ZT_CONTROLLER_DEPS=1 scripts/bootstrap-deps.sh # builds OTel + google-cloud-cpp into ./.deps + cmake -DZT1_CENTRAL_CONTROLLER=1 -DCMAKE_PREFIX_PATH="" -S . -B build + +bootstrap-deps.sh prints the exact -DCMAKE_PREFIX_PATH to use when it finishes. +See nonfree/controller/README_CENTRAL_CONTROLLER.md. +]=]) + endif() else() - find_package(opentelemetry-cpp REQUIRED COMPONENTS api) + # Daemon/non-controller: only the OTel API (header-only), from the same bootstrap prefix. + find_package(opentelemetry-cpp QUIET COMPONENTS api) + if(NOT opentelemetry-cpp_FOUND) + message(FATAL_ERROR [=[ +opentelemetry-cpp (API) was not found on CMAKE_PREFIX_PATH. Build the header-only OTel +API, then re-run CMake pointing at the prefix: + + scripts/bootstrap-deps.sh # quick, header-only (this is the default) + cmake -DCMAKE_PREFIX_PATH="" -S . -B build + +bootstrap-deps.sh prints the exact -DCMAKE_PREFIX_PATH to use when it finishes. +]=]) + endif() endif() # Dependencies not provided by conda. @@ -387,7 +416,6 @@ if(ZT1_CENTRAL_CONTROLLER) opentelemetry-cpp::otlp_http_exporter opentelemetry-cpp::otlp_http_log_record_exporter opentelemetry-cpp::otlp_http_metric_exporter - opentelemetry-cpp::prometheus_exporter ) endif() diff --git a/cmake/inja.cmake b/cmake/inja.cmake new file mode 100644 index 0000000000..227863fdda --- /dev/null +++ b/cmake/inja.cmake @@ -0,0 +1,18 @@ +# inja -- header-only C++ templating engine used by service/OneService.cpp +# (`#include `). Homebrew ships no usable CMake config and Debian +# has no package, so we vendor the headers via FetchContent. We populate the +# source only and skip inja's own CMakeLists (its build/test/json machinery) by +# pointing SOURCE_SUBDIR at a non-existent directory. inja consumes +# nlohmann::json, which the build already provides via find_package(nlohmann_json) +# and links into the targets that use inja; we only need inja's headers on the +# include path here (header-only, no link), matching the previous conda setup. +include(FetchContent) +FetchContent_Declare(inja + GIT_REPOSITORY https://github.com/pantor/inja.git + GIT_TAG v3.4.0 + GIT_SHALLOW ON + SOURCE_SUBDIR _skip_inja_cmakelists_) # populate only; no add_subdirectory +FetchContent_MakeAvailable(inja) + +# inja ships an amalgamated header under single_include/inja/inja.hpp. +include_directories("${inja_SOURCE_DIR}/single_include") diff --git a/cmake/redis-plus-plus.cmake b/cmake/redis-plus-plus.cmake index 7b13edd09a..eadc08ccae 100644 --- a/cmake/redis-plus-plus.cmake +++ b/cmake/redis-plus-plus.cmake @@ -17,4 +17,12 @@ FetchContent_MakeAvailable(redis-plus-plus) if(NOT TARGET redis++::redis++_static) message(FATAL_ERROR "A required redis-plus-plus target (redis++::redis++_static) was not imported") endif() -message(STATUS "redis-plus-plus imported") + +# redis++'s static library calls into hiredis but does not propagate that +# dependency to consumers, so the final link fails with undefined hiredis +# symbols (redisAppendCommand, redisFree, freeReplyObject, ...). Attach hiredis +# to the static target's interface. find_library (not find_package(hiredis)) +# because Debian's libhiredis-dev ships no CMake config. +find_library(HIREDIS_LIB hiredis REQUIRED) +target_link_libraries(redis++_static INTERFACE ${HIREDIS_LIB}) +message(STATUS "redis-plus-plus imported (hiredis: ${HIREDIS_LIB})") diff --git a/conda_env_build.yml b/conda_env_build.yml deleted file mode 100644 index 9a51cb7b7e..0000000000 --- a/conda_env_build.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: central_controller -channels: - - conda-forge -dependencies: - - conda-forge::cmake=3.27.4 - - conda-forge::git - - conda-forge::cxx-compiler - - conda-forge::c-compiler - - conda-forge::make - - conda-forge::pkg-config - - conda-forge::libpqxx=7.10.1 - - conda-forge::libopentelemetry-cpp=1.21.0 - - conda-forge::libopentelemetry-cpp-headers=1.21.0 - - conda-forge::google-cloud-cpp=2.38.0 - - conda-forge::libgoogle-cloud=2.38.0 - - conda-forge::rust=1.89.0 - - conda-forge::inja=3.3.0 - - conda-forge::libhiredis=1.3.0 - - conda-forge::nlohmann_json=3.12.0 - - conda-forge::jemalloc=5.3.0 diff --git a/conda_env_run.yml b/conda_env_run.yml deleted file mode 100644 index 3ad8b606f2..0000000000 --- a/conda_env_run.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: central_controller -channels: - - conda-forge -dependencies: - - conda-forge::pkg-config - - conda-forge::libpqxx=7.10.1 - - conda-forge::libopentelemetry-cpp=1.21.0 - - conda-forge::google-cloud-cpp=2.38.0 - - conda-forge::libgoogle-cloud=2.38.0 - - conda-forge::inja=3.3.0 - - conda-forge::libhiredis=1.3.0 - - conda-forge::nlohmann_json=3.12.0 - - conda-forge::jemalloc=5.3.0 - - conda-forge::postgresql=17.6 diff --git a/ext/central-controller-docker/Dockerfile b/ext/central-controller-docker/Dockerfile index c739b03956..67041dc2a7 100644 --- a/ext/central-controller-docker/Dockerfile +++ b/ext/central-controller-docker/Dockerfile @@ -1,21 +1,68 @@ -# Dockerfile for ZeroTier Central Controllers -FROM registry.zerotier.com/zerotier/ctlbuild:2025-07-14 AS builder -ADD . /ZeroTierOne -RUN export PATH=$PATH:~/.cargo/bin && cd ZeroTierOne && make clean && make central-controller -j8 +# Central Controller -- conda-free, CMake-based, Debian trixie. Multi-stage: +# builder : apt deps + scripts/bootstrap-deps.sh (OTel 1.27 + google-cloud-cpp +# 2.38 from source) + CMake build of zerotier-one +# go_base : golang-migrate +# runtime : slim trixie with exactly the runtime libs the binary needs +# +# Build (context = repo root, see .dockerignore): +# docker build -f ext/central-controller-docker/Dockerfile -t ztctl . +FROM debian:trixie AS builder -FROM golang:1.24.1-bookworm AS go_base -RUN GONOSUMDB=* GOFLAGS='-p=1' go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + build-essential cmake ninja-build git pkg-config ca-certificates curl \ + libpqxx-dev libpq-dev libhiredis-dev libjemalloc-dev nlohmann-json3-dev \ + libabsl-dev libprotobuf-dev protobuf-compiler protobuf-compiler-grpc libgrpc++-dev \ + libgtest-dev libgmock-dev libssl-dev libcurl4-openssl-dev \ + && rm -rf /var/lib/apt/lists/* -FROM registry.zerotier.com/zerotier/ctlrun:2025-07-14 AS run_base -COPY --from=builder /ZeroTierOne/zerotier-one /usr/local/bin/zerotier-one -COPY --from=builder /ZeroTierOne/ext/opentelemetry-cpp-1.21.0/localinstall/lib/*.so /usr/local/lib64/ -COPY --from=go_base /go/bin/migrate /usr/local/bin/migrate -COPY ext/central-controller-docker/migrations /migrations +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ + | sh -s -- -y --default-toolchain 1.89.0 --profile minimal +ENV PATH="/root/.cargo/bin:${PATH}" + +WORKDIR /ZeroTierOne + +# Pinned from-source deps -> /opt/zt-deps, against apt's abseil/protobuf/grpc. +# ZT_CONTROLLER_DEPS=1 builds the full controller set (OTel SDK + OTLP exporters + +# google-cloud-cpp); without it the script only builds the header-only OTel API. +# Copy only the bootstrap script first so this expensive layer stays cached across +# changes to the rest of the tree. +COPY scripts/bootstrap-deps.sh scripts/bootstrap-deps.sh +RUN ZT_CONTROLLER_DEPS=1 bash scripts/bootstrap-deps.sh /opt/zt-deps + +COPY . . +RUN cmake -DCMAKE_BUILD_TYPE=Release -DZT1_CENTRAL_CONTROLLER=1 \ + -DCMAKE_PREFIX_PATH=/opt/zt-deps -S . -B build-cmake -G Ninja \ + && cmake --build build-cmake -j"$(nproc)" -RUN chmod a+x /usr/local/bin/zerotier-one -RUN echo "/usr/local/lib64" > /etc/ld.so.conf.d/usr-local-lib64.conf && ldconfig +# Compute the exact runtime apt packages the binary links (robust against the +# trixie t64 package renames). The two non-apt OTel proto .so's are copied +# explicitly in the runtime stage, so dpkg-S misses there are expected. +# readlink -f resolves the usrmerge /lib -> /usr/lib symlinks so dpkg -S can +# attribute each .so to its package (and naturally picks up the trixie t64 names). +RUN ldd build-cmake/zerotier-one | awk '/=> \//{print $3}' | xargs -r readlink -f \ + | xargs -r dpkg -S 2>/dev/null | cut -d: -f1 | tr ',' '\n' | sort -u > /opt/runtime-pkgs.txt \ + && echo "--- runtime packages ---" && cat /opt/runtime-pkgs.txt -ADD ext/central-controller-docker/main.sh / -RUN chmod a+x /main.sh +# --------------------------------------------------------------------------- +FROM golang:1.24-bookworm AS go_base +RUN GOFLAGS='-p=1' go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest + +# --------------------------------------------------------------------------- +FROM debian:trixie AS runtime +COPY --from=builder /opt/runtime-pkgs.txt /opt/runtime-pkgs.txt +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + $(cat /opt/runtime-pkgs.txt) \ + libjemalloc2 postgresql-client netcat-openbsd ca-certificates \ + && rm -rf /var/lib/apt/lists/* /opt/runtime-pkgs.txt + +COPY --from=builder /ZeroTierOne/build-cmake/zerotier-one /usr/local/bin/zerotier-one +# The only dynamically-linked from-source libs (OTel/gcloud are otherwise static). +COPY --from=builder /opt/zt-deps/lib/libopentelemetry_proto.so /opt/zt-deps/lib/libopentelemetry_proto_grpc.so /usr/local/lib/ +RUN echo /usr/local/lib > /etc/ld.so.conf.d/zerotier.conf && ldconfig + +COPY --from=go_base /go/bin/migrate /usr/local/bin/migrate +COPY ext/central-controller-docker/migrations /migrations +COPY ext/central-controller-docker/main.sh /main.sh +RUN chmod +x /usr/local/bin/zerotier-one /usr/local/bin/migrate /main.sh -ENTRYPOINT /main.sh +ENTRYPOINT ["/main.sh"] diff --git a/ext/central-controller-docker/Dockerfile.builder b/ext/central-controller-docker/Dockerfile.builder deleted file mode 100644 index 6e10db887f..0000000000 --- a/ext/central-controller-docker/Dockerfile.builder +++ /dev/null @@ -1,34 +0,0 @@ -# Dockerfile for building ZeroTier Central Controllers -FROM debian:bookworm - -RUN apt update && apt upgrade -y -RUN apt -y install \ - build-essential \ - pkg-config \ - bash \ - clang \ - libjemalloc2 \ - libjemalloc-dev \ - libpq5 \ - libpq-dev \ - openssl \ - libssl-dev \ - postgresql-client \ - postgresql-client-common \ - curl \ - libcurl4-openssl-dev \ - google-perftools \ - libgoogle-perftools-dev \ - protobuf-compiler \ - protobuf-compiler-grpc \ - protobuf-c-compiler \ - grpc-proto \ - libgrpc++1.51 \ - libgrpc++-dev \ - libgrpc-dev \ - libgrpc29 \ - cmake \ - git - - -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y diff --git a/ext/central-controller-docker/Dockerfile.conda b/ext/central-controller-docker/Dockerfile.conda deleted file mode 100644 index 7d1bbc64cc..0000000000 --- a/ext/central-controller-docker/Dockerfile.conda +++ /dev/null @@ -1,25 +0,0 @@ -FROM golang:bookworm AS go_base -RUN go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest - - -FROM continuumio/miniconda3:25.3.1-1 - -LABEL maintainer="ZeroTier Inc." - -ADD environment.yml /environment.yml -RUN conda env create -f /environment.yml && \ - conda clean -a -y -SHELL ["conda", "run", "--no-capture-output", "-n", "central_controller", "/bin/bash", "-c"] - -COPY --from=go_base /go/bin/migrate /usr/local/bin/migrate -COPY ext/central-controller-docker/migrations /migrations -ADD build/zerotier-one /usr/local/bin/zerotier-one -RUN chmod a+x /usr/local/bin/zerotier-one -RUN echo "/opt/conda/envs/central_controller/lib" > /etc/ld.so.conf.d/conda-central-controller.conf && \ - echo "/opt/conda/envs/central_controller/`uname -m`-conda-linux-gnu/lib" > /etc/ld.so.conf.d/conda-central-controller-x64.conf && \ - ldconfig - -ADD ext/central-controller-docker/main-new.sh /main.sh -RUN chmod a+x /main.sh - -ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "central_controller", "/bin/bash", "-c", "/main.sh"] diff --git a/ext/central-controller-docker/Dockerfile.conda_builder b/ext/central-controller-docker/Dockerfile.conda_builder deleted file mode 100644 index 42be3ab8bc..0000000000 --- a/ext/central-controller-docker/Dockerfile.conda_builder +++ /dev/null @@ -1,10 +0,0 @@ -FROM continuumio/miniconda3:25.3.1-1 - -LABEL maintainer="ZeroTier Inc." - -ADD conda_env_build.yml /environment.yml -RUN conda env create -f /environment.yml && \ - conda clean -a -y - -SHELL ["conda", "run", "--no-capture-output", "-n", "central_controller", "/bin/bash", "-c"] -ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "central_controller", "/bin/bash"] \ No newline at end of file diff --git a/ext/central-controller-docker/Dockerfile.new b/ext/central-controller-docker/Dockerfile.new deleted file mode 100644 index 18245494cc..0000000000 --- a/ext/central-controller-docker/Dockerfile.new +++ /dev/null @@ -1,25 +0,0 @@ -FROM us-central1-docker.pkg.dev/zerotier-421eb9/docker-images/controller_conda_builder:latest AS controller_conda_builder -ADD . /ZeroTierOne -WORKDIR /ZeroTierOne -SHELL ["conda", "run", "--no-capture-output", "-n", "central_controller", "/bin/bash", "-c"] -RUN cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DZT1_CENTRAL_CONTROLLER=1 && cmake --build build/ --target all -j4 --verbose - -FROM golang:bookworm AS go_base -RUN go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest - -FROM continuumio/miniconda3:25.3.1-1 -LABEL maintainer="ZeroTier Inc." -ADD conda_env_run.yml /environment.yml -RUN conda env create -f /environment.yml && \ - conda clean -a -y -SHELL ["conda", "run", "--no-capture-output", "-n", "central_controller", "/bin/bash", "-c"] -COPY --from=go_base /go/bin/migrate /usr/local/bin/migrate -COPY --from=controller_conda_builder /ZeroTierOne/build/zerotier-one /usr/local/bin/zerotier-one -COPY ext/central-controller-docker/migrations /migrations -RUN chmod a+x /usr/local/bin/zerotier-one -# RUN echo "/opt/conda/envs/central_controller/lib" > /etc/ld.so.conf.d/conda-central-controller.conf && \ -# echo "/opt/conda/envs/central_controller/`uname -m`-conda-linux-gnu/lib" > /etc/ld.so.conf.d/conda-central-controller-x64.conf && \ -# ldconfig -ADD ext/central-controller-docker/main-new.sh /main.sh -RUN chmod a+x /main.sh -ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "central_controller", "/bin/bash", "-c", "/main.sh"] \ No newline at end of file diff --git a/ext/central-controller-docker/Dockerfile.run_base b/ext/central-controller-docker/Dockerfile.run_base deleted file mode 100644 index fb5d0e2d56..0000000000 --- a/ext/central-controller-docker/Dockerfile.run_base +++ /dev/null @@ -1,19 +0,0 @@ -FROM debian:bookworm - - - -RUN apt update && apt upgrade -y -RUN apt -y install \ - netcat-traditional \ - postgresql-client \ - postgresql-client-common \ - libjemalloc2 \ - libpq5 \ - curl \ - binutils \ - perf-tools-unstable \ - google-perftools \ - gnupg \ - libgrpc++1.51 \ - libgrpc29 - diff --git a/ext/central-controller-docker/Makefile b/ext/central-controller-docker/Makefile deleted file mode 100644 index 2318d29033..0000000000 --- a/ext/central-controller-docker/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -registry = registry.zerotier.com/zerotier - -all: controller-builder controller-runbase - -buildx: - @echo "docker buildx create" - # docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - docker run --privileged --rm tonistiigi/binfmt --install all - @echo docker buildx create --name multiarch --driver docker-container --use - @echo docker buildx inspect --bootstrap - -controller-builder: buildx - docker buildx build --no-cache --platform linux/amd64,linux/arm64 -t $(registry)/ctlbuild:$(shell date +"%Y-%m-%d") -f Dockerfile.builder . --push - -controller-runbase: buildx - docker buildx build --no-cache --platform linux/amd64,linux/arm64 -t $(registry)/ctlrun:$(shell date +"%Y-%m-%d") -f Dockerfile.run_base . --push diff --git a/ext/central-controller-docker/main-new.sh b/ext/central-controller-docker/main-new.sh deleted file mode 100755 index 73d1b495e0..0000000000 --- a/ext/central-controller-docker/main-new.sh +++ /dev/null @@ -1,226 +0,0 @@ -#!/bin/bash - -# conda init -# conda activate central_controller - -if [ -z "$ZT_DB_HOST" ]; then - echo '*** FAILED: ZT_DB_HOST environment variable not defined' - exit 1 -fi -if [ -z "$ZT_DB_PORT" ]; then - echo '*** FAILED: ZT_DB_PORT environment variable not defined' - exit 1 -fi -if [ -z "$ZT_DB_NAME" ]; then - echo '*** FAILED: ZT_DB_NAME environment variable not defined' - exit 1 -fi -if [ -z "$ZT_DB_USER" ]; then - echo '*** FAILED: ZT_DB_USER environment variable not defined' - exit 1 -fi -if [ -z "$ZT_DB_PASSWORD" ]; then - echo '*** FAILED: ZT_DB_PASSWORD environment variable not defined' - exit 1 -fi - -REDIS="" -if [ "$ZT_USE_REDIS" == "true" ]; then - if [ -z "$ZT_REDIS_HOST" ]; then - echo '*** FAILED: ZT_REDIS_HOST environment variable not defined' - exit 1 - fi - - if [ -z "$ZT_REDIS_PORT" ]; then - echo '*** FAILED: ZT_REDIS_PORT enivronment variable not defined' - exit 1 - fi - - if [ -z "$ZT_REDIS_CLUSTER_MODE" ]; then - echo '*** FAILED: ZT_REDIS_CLUSTER_MODE environment variable not defined' - exit 1 - fi - - REDIS=", \"redis\": { - \"hostname\": \"${ZT_REDIS_HOST}\", - \"port\": ${ZT_REDIS_PORT}, - \"clusterMode\": ${ZT_REDIS_CLUSTER_MODE}, - \"password\": \"${ZT_REDIS_PASSWORD}\" - } - " -else - REDIS=", \"redis\": null" -fi - -mkdir -p /var/lib/zerotier-one - -pushd /var/lib/zerotier-one -if [ -d "$ZT_IDENTITY_PATH" ]; then - echo '*** Using existing ZT identity from path $ZT_IDENTITY_PATH' - - ln -s $ZT_IDENTITY_PATH/identity.public identity.public - ln -s $ZT_IDENTITY_PATH/identity.secret identity.secret - if [ -L "$ZT_IDENTITY_PATH/authtoken.secret" ] && [ -e "$ZT_IDENTITY_PATH/authtoken.secret" ]; then - ln -s $ZT_IDENTITY_PATH/authtoken.secret authtoken.secret - ln -s $ZT_IDENTITY_PATH/authtoken.secret metricstoken.secret - fi -fi -popd - -DEFAULT_PORT=9993 -DEFAULT_LB_MODE=false - -APP_NAME="controller-$(cat /var/lib/zerotier-one/identity.public | cut -d ':' -f 1)" - -BIGTABLE_CONF="" -if [ "$ZT_USE_BIGTABLE" == "true" ]; then - if [ -z "$ZT_BIGTABLE_PROJECT" ] || [ -z "$ZT_BIGTABLE_INSTANCE" ] || [ -z "$ZT_BIGTABLE_TABLE" ]; then - echo '*** FAILED: ZT_BIGTABLE_PROJECT, ZT_BIGTABLE_INSTANCE, and ZT_BIGTABLE_TABLE environment variables must all be defined to use Bigtable as a controller backend' - exit 1 - fi - - BIGTABLE_CONF=", \"bigtable\": { - \"project_id\": \"${ZT_BIGTABLE_PROJECT}\", - \"instance_id\": \"${ZT_BIGTABLE_INSTANCE}\", - \"table_id\": \"${ZT_BIGTABLE_TABLE}\" - } - " -fi - - -PUBSUB_CONF="" -if [ "$ZT_USE_PUBSUB" == "true" ]; then - if [ -z "$ZT_PUBSUB_PROJECT" ]; then - echo '*** FAILED: ZT_PUBSUB_PROJECT environment variable must be defined to use PubSub as a controller backend' - exit 1 - fi - - if [ -z "$ZT_PUBSUB_MEMBER_CHANGE_RECV_TOPIC" ] || [ -z "$ZT_PUBSUB_MEMBER_CHANGE_SEND_TOPIC" ] || [ -z "$ZT_PUBSUB_NETWORK_CHANGE_RECV_TOPIC" ] || [ -z "$ZT_PUBSUB_NETWORK_CHANGE_SEND_TOPIC" ]; then - echo '*** FAILED: ZT_PUBSUB_MEMBER_CHANGE_RECV_TOPIC, ZT_PUBSUB_MEMBER_CHANGE_SEND_TOPIC, ZT_PUBSUB_NETWORK_CHANGE_RECV_TOPIC, and ZT_PUBSUB_NETWORK_CHANGE_SEND_TOPIC environment variables must all be defined to use PubSub as a controller backend' - exit 1 - fi - - PUBSUB_CONF=", \"pubsub\": { - \"project_id\": \"${ZT_PUBSUB_PROJECT}\", - \"member_change_recv_topic\": \"${ZT_PUBSUB_MEMBER_CHANGE_RECV_TOPIC}\", - \"member_change_send_topic\": \"${ZT_PUBSUB_MEMBER_CHANGE_SEND_TOPIC}\", - \"network_change_recv_topic\": \"${ZT_PUBSUB_NETWORK_CHANGE_RECV_TOPIC}\", - \"network_change_send_topic\": \"${ZT_PUBSUB_NETWORK_CHANGE_SEND_TOPIC}\", - \"sso_nonce_publish_topic\": \"${ZT_PUBSUB_SSO_NONCE_PUBLISH_TOPIC}\", - \"sso_auth_subscribe_topic\": \"${ZT_PUBSUB_SSO_AUTH_SUBSCRIBE_TOPIC}\" - } -" -fi - -# Backwards compatibility: if the per-frontend URLs aren't set but the legacy -# ZT_SSO_REDIRECT_URL and ZT_ASSIGNED_CENTRAL_VERSION are both populated, map -# the legacy URL into the new format keyed by the assigned Central version. -if [ -z "$ZT_SSO_REDIRECT_URL_CV1" ] && [ -z "$ZT_SSO_REDIRECT_URL_CV2" ]; then - if [ -n "$ZT_SSO_REDIRECT_URL" ] && [ -n "$ZT_ASSIGNED_CENTRAL_VERSION" ]; then - case "$ZT_ASSIGNED_CENTRAL_VERSION" in - cv1) - ZT_SSO_REDIRECT_URL_CV1="$ZT_SSO_REDIRECT_URL" - ;; - cv2) - ZT_SSO_REDIRECT_URL_CV2="$ZT_SSO_REDIRECT_URL" - ;; - all) - echo '*** FAILED: controllers assigned to "all" must define ZT_SSO_REDIRECT_URL_CV1 and ZT_SSO_REDIRECT_URL_CV2; the legacy ZT_SSO_REDIRECT_URL cannot serve both Central versions' - exit 1 - ;; - esac - fi -fi - -# Per-frontend Central SSO redirect URLs. SSO-enabled networks are routed to the -# SSO endpoint of the Central version ("cv1" or "cv2") they belong to. -SSO_REDIRECT_URLS_CONF="" -if [ -n "$ZT_SSO_REDIRECT_URL_CV1" ] || [ -n "$ZT_SSO_REDIRECT_URL_CV2" ]; then - SSO_REDIRECT_URLS="" - if [ -n "$ZT_SSO_REDIRECT_URL_CV1" ]; then - SSO_REDIRECT_URLS="\"cv1\": \"${ZT_SSO_REDIRECT_URL_CV1}\"" - fi - if [ -n "$ZT_SSO_REDIRECT_URL_CV2" ]; then - if [ -n "$SSO_REDIRECT_URLS" ]; then - SSO_REDIRECT_URLS="${SSO_REDIRECT_URLS}, - " - fi - SSO_REDIRECT_URLS="${SSO_REDIRECT_URLS}\"cv2\": \"${ZT_SSO_REDIRECT_URL_CV2}\"" - fi - SSO_REDIRECT_URLS_CONF=", \"ssoRedirectURLs\": { - ${SSO_REDIRECT_URLS} - } -" -fi - -echo "{ - \"settings\": { - \"controllerDbPath\": \"postgres:host=${ZT_DB_HOST} port=${ZT_DB_PORT} dbname=${ZT_DB_NAME} user=${ZT_DB_USER} password=${ZT_DB_PASSWORD} application_name=${APP_NAME} sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}\", - \"portMappingEnabled\": true, - \"softwareUpdate\": \"disable\", - \"interfacePrefixBlacklist\": [ - \"inot\", - \"nat64\" - ], - \"lowBandwidthMode\": ${ZT_LB_MODE:-$DEFAULT_LB_MODE}, - \"ssoRedirectURL\": \"${ZT_SSO_REDIRECT_URL}\", - \"allowManagementFrom\": [\"127.0.0.1\", \"::1\", \"10.0.0.0/8\"], - \"otel\": { - \"exporterEndpoint\": \"${ZT_EXPORTER_ENDPOINT}\", - \"exporterSampleRate\": ${ZT_EXPORTER_SAMPLE_RATE:-0} - } - ${REDIS} - }, - \"controller\": { - \"listenMode\": \"${ZT_LISTEN_MODE:-pgsql}\", - \"statusMode\": \"${ZT_STATUS_MODE:-pgsql}\", - \"assignedCentralVersion\": \"${ZT_ASSIGNED_CENTRAL_VERSION:-all}\", - \"ssoEnabled\": ${ZT_SSO_ENABLED:-false} - ${SSO_REDIRECT_URLS_CONF} - ${REDIS} - ${BIGTABLE_CONF} - ${PUBSUB_CONF} - } -} -" > /var/lib/zerotier-one/local.conf - -if [ -n "$DB_SERVER_CA" ]; then - echo "secret list" - chmod 600 /secrets/db/*.pem - ls -l /secrets/db/ - until pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT} -d "sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}"; do - echo "Waiting for PostgreSQL..."; - sleep 2; - done -else - until pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT}; do - echo "Waiting for PostgreSQL..."; - sleep 2; - done -fi - - -echo "Migrating database (if needed)..." -if [ -n "$DB_SERVER_CA" ]; then - /usr/local/bin/migrate -source file:///migrations -database "postgres://$ZT_DB_USER:$ZT_DB_PASSWORD@$ZT_DB_HOST:$ZT_DB_PORT/$ZT_DB_NAME?x-migrations-table=controller_migrations&sslmode=verify-full&sslrootcert=$DB_SERVER_CA&sslcert=$DB_CLIENT_CERT&sslkey=$DB_CLIENT_KEY" up -else - /usr/local/bin/migrate -source file:///migrations -database "postgres://$ZT_DB_USER:$ZT_DB_PASSWORD@$ZT_DB_HOST:$ZT_DB_PORT/$ZT_DB_NAME?x-migrations-table=controller_migrations&sslmode=disable" up -fi - -if [ -n "$ZT_TEMPORAL_HOST" ] && [ -n "$ZT_TEMPORAL_PORT" ]; then - echo "waiting for temporal..." - while ! nc -z ${ZT_TEMPORAL_HOST} ${ZT_TEMPORAL_PORT}; do - echo "waiting..."; - sleep 1; - done - echo "Temporal is up" -fi - -cat /var/lib/zerotier-one/local.conf - -export GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes -export LIBC_FATAL_STDERR_=1 -export GLIBCXX_FORCE_NEW=1 -export GLIBCPP_FORCE_NEW=1 -export LD_PRELOAD="/opt/conda/envs/central_controller/lib/libjemalloc.so.2" -exec /usr/local/bin/zerotier-one -p${ZT_CONTROLLER_PORT:-$DEFAULT_PORT} /var/lib/zerotier-one diff --git a/ext/central-controller-docker/main.sh b/ext/central-controller-docker/main.sh index b1c4b4cbc8..88023a70f4 100755 --- a/ext/central-controller-docker/main.sh +++ b/ext/central-controller-docker/main.sh @@ -20,9 +20,6 @@ if [ -z "$ZT_DB_PASSWORD" ]; then echo '*** FAILED: ZT_DB_PASSWORD environment variable not defined' exit 1 fi -if [ -z "$ZT_DB_TYPE" ]; then - ZT_DB_TYPE="postgres" -fi REDIS="" if [ "$ZT_USE_REDIS" == "true" ]; then @@ -41,7 +38,7 @@ if [ "$ZT_USE_REDIS" == "true" ]; then exit 1 fi - REDIS="\"redis\": { + REDIS=", \"redis\": { \"hostname\": \"${ZT_REDIS_HOST}\", \"port\": ${ZT_REDIS_PORT}, \"clusterMode\": ${ZT_REDIS_CLUSTER_MODE}, @@ -49,7 +46,7 @@ if [ "$ZT_USE_REDIS" == "true" ]; then } " else - REDIS="\"redis\": null" + REDIS=", \"redis\": null" fi mkdir -p /var/lib/zerotier-one @@ -60,8 +57,9 @@ if [ -d "$ZT_IDENTITY_PATH" ]; then ln -s $ZT_IDENTITY_PATH/identity.public identity.public ln -s $ZT_IDENTITY_PATH/identity.secret identity.secret - if [ -f "$ZT_IDENTITY_PATH/authtoken.secret" ]; then + if [ -L "$ZT_IDENTITY_PATH/authtoken.secret" ] && [ -e "$ZT_IDENTITY_PATH/authtoken.secret" ]; then ln -s $ZT_IDENTITY_PATH/authtoken.secret authtoken.secret + ln -s $ZT_IDENTITY_PATH/authtoken.secret metricstoken.secret fi fi popd @@ -71,9 +69,90 @@ DEFAULT_LB_MODE=false APP_NAME="controller-$(cat /var/lib/zerotier-one/identity.public | cut -d ':' -f 1)" +BIGTABLE_CONF="" +if [ "$ZT_USE_BIGTABLE" == "true" ]; then + if [ -z "$ZT_BIGTABLE_PROJECT" ] || [ -z "$ZT_BIGTABLE_INSTANCE" ] || [ -z "$ZT_BIGTABLE_TABLE" ]; then + echo '*** FAILED: ZT_BIGTABLE_PROJECT, ZT_BIGTABLE_INSTANCE, and ZT_BIGTABLE_TABLE environment variables must all be defined to use Bigtable as a controller backend' + exit 1 + fi + + BIGTABLE_CONF=", \"bigtable\": { + \"project_id\": \"${ZT_BIGTABLE_PROJECT}\", + \"instance_id\": \"${ZT_BIGTABLE_INSTANCE}\", + \"table_id\": \"${ZT_BIGTABLE_TABLE}\" + } + " +fi + + +PUBSUB_CONF="" +if [ "$ZT_USE_PUBSUB" == "true" ]; then + if [ -z "$ZT_PUBSUB_PROJECT" ]; then + echo '*** FAILED: ZT_PUBSUB_PROJECT environment variable must be defined to use PubSub as a controller backend' + exit 1 + fi + + if [ -z "$ZT_PUBSUB_MEMBER_CHANGE_RECV_TOPIC" ] || [ -z "$ZT_PUBSUB_MEMBER_CHANGE_SEND_TOPIC" ] || [ -z "$ZT_PUBSUB_NETWORK_CHANGE_RECV_TOPIC" ] || [ -z "$ZT_PUBSUB_NETWORK_CHANGE_SEND_TOPIC" ]; then + echo '*** FAILED: ZT_PUBSUB_MEMBER_CHANGE_RECV_TOPIC, ZT_PUBSUB_MEMBER_CHANGE_SEND_TOPIC, ZT_PUBSUB_NETWORK_CHANGE_RECV_TOPIC, and ZT_PUBSUB_NETWORK_CHANGE_SEND_TOPIC environment variables must all be defined to use PubSub as a controller backend' + exit 1 + fi + + PUBSUB_CONF=", \"pubsub\": { + \"project_id\": \"${ZT_PUBSUB_PROJECT}\", + \"member_change_recv_topic\": \"${ZT_PUBSUB_MEMBER_CHANGE_RECV_TOPIC}\", + \"member_change_send_topic\": \"${ZT_PUBSUB_MEMBER_CHANGE_SEND_TOPIC}\", + \"network_change_recv_topic\": \"${ZT_PUBSUB_NETWORK_CHANGE_RECV_TOPIC}\", + \"network_change_send_topic\": \"${ZT_PUBSUB_NETWORK_CHANGE_SEND_TOPIC}\", + \"sso_nonce_publish_topic\": \"${ZT_PUBSUB_SSO_NONCE_PUBLISH_TOPIC}\", + \"sso_auth_subscribe_topic\": \"${ZT_PUBSUB_SSO_AUTH_SUBSCRIBE_TOPIC}\" + } +" +fi + +# Backwards compatibility: if the per-frontend URLs aren't set but the legacy +# ZT_SSO_REDIRECT_URL and ZT_ASSIGNED_CENTRAL_VERSION are both populated, map +# the legacy URL into the new format keyed by the assigned Central version. +if [ -z "$ZT_SSO_REDIRECT_URL_CV1" ] && [ -z "$ZT_SSO_REDIRECT_URL_CV2" ]; then + if [ -n "$ZT_SSO_REDIRECT_URL" ] && [ -n "$ZT_ASSIGNED_CENTRAL_VERSION" ]; then + case "$ZT_ASSIGNED_CENTRAL_VERSION" in + cv1) + ZT_SSO_REDIRECT_URL_CV1="$ZT_SSO_REDIRECT_URL" + ;; + cv2) + ZT_SSO_REDIRECT_URL_CV2="$ZT_SSO_REDIRECT_URL" + ;; + all) + echo '*** FAILED: controllers assigned to "all" must define ZT_SSO_REDIRECT_URL_CV1 and ZT_SSO_REDIRECT_URL_CV2; the legacy ZT_SSO_REDIRECT_URL cannot serve both Central versions' + exit 1 + ;; + esac + fi +fi + +# Per-frontend Central SSO redirect URLs. SSO-enabled networks are routed to the +# SSO endpoint of the Central version ("cv1" or "cv2") they belong to. +SSO_REDIRECT_URLS_CONF="" +if [ -n "$ZT_SSO_REDIRECT_URL_CV1" ] || [ -n "$ZT_SSO_REDIRECT_URL_CV2" ]; then + SSO_REDIRECT_URLS="" + if [ -n "$ZT_SSO_REDIRECT_URL_CV1" ]; then + SSO_REDIRECT_URLS="\"cv1\": \"${ZT_SSO_REDIRECT_URL_CV1}\"" + fi + if [ -n "$ZT_SSO_REDIRECT_URL_CV2" ]; then + if [ -n "$SSO_REDIRECT_URLS" ]; then + SSO_REDIRECT_URLS="${SSO_REDIRECT_URLS}, + " + fi + SSO_REDIRECT_URLS="${SSO_REDIRECT_URLS}\"cv2\": \"${ZT_SSO_REDIRECT_URL_CV2}\"" + fi + SSO_REDIRECT_URLS_CONF=", \"ssoRedirectURLs\": { + ${SSO_REDIRECT_URLS} + } +" +fi + echo "{ \"settings\": { - \"controllerDbPath\": \"${ZT_DB_TYPE}:host=${ZT_DB_HOST} port=${ZT_DB_PORT} dbname=${ZT_DB_NAME} user=${ZT_DB_USER} password=${ZT_DB_PASSWORD} application_name=${APP_NAME} sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}\", + \"controllerDbPath\": \"postgres:host=${ZT_DB_HOST} port=${ZT_DB_PORT} dbname=${ZT_DB_NAME} user=${ZT_DB_USER} password=${ZT_DB_PASSWORD} application_name=${APP_NAME} sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}\", \"portMappingEnabled\": true, \"softwareUpdate\": \"disable\", \"interfacePrefixBlacklist\": [ @@ -86,8 +165,18 @@ echo "{ \"otel\": { \"exporterEndpoint\": \"${ZT_EXPORTER_ENDPOINT}\", \"exporterSampleRate\": ${ZT_EXPORTER_SAMPLE_RATE:-0} - }, + } ${REDIS} + }, + \"controller\": { + \"listenMode\": \"${ZT_LISTEN_MODE:-pgsql}\", + \"statusMode\": \"${ZT_STATUS_MODE:-pgsql}\", + \"assignedCentralVersion\": \"${ZT_ASSIGNED_CENTRAL_VERSION:-all}\", + \"ssoEnabled\": ${ZT_SSO_ENABLED:-false} + ${SSO_REDIRECT_URLS_CONF} + ${REDIS} + ${BIGTABLE_CONF} + ${PUBSUB_CONF} } } " > /var/lib/zerotier-one/local.conf @@ -96,24 +185,23 @@ if [ -n "$DB_SERVER_CA" ]; then echo "secret list" chmod 600 /secrets/db/*.pem ls -l /secrets/db/ - until /usr/bin/pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT} -d "sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}"; do + until pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT} -d "sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}"; do echo "Waiting for PostgreSQL..."; sleep 2; done else - until /usr/bin/pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT}; do + until pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT}; do echo "Waiting for PostgreSQL..."; sleep 2; done fi -if [ "$ZT_DB_TYPE" == "cv2" ]; then - echo "Migrating database (if needed)..." - if [ -n "$DB_SERVER_CA" ]; then - /usr/local/bin/migrate -source file:///migrations -database "postgres://$ZT_DB_USER:$ZT_DB_PASSWORD@$ZT_DB_HOST:$ZT_DB_PORT/$ZT_DB_NAME?x-migrations-table=controller_migrations&sslmode=verify-full&sslrootcert=$DB_SERVER_CA&sslcert=$DB_CLIENT_CERT&sslkey=$DB_CLIENT_KEY" up - else - /usr/local/bin/migrate -source file:///migrations -database "postgres://$ZT_DB_USER:$ZT_DB_PASSWORD@$ZT_DB_HOST:$ZT_DB_PORT/$ZT_DB_NAME?x-migrations-table=controller_migrations&sslmode=disable" up - fi + +echo "Migrating database (if needed)..." +if [ -n "$DB_SERVER_CA" ]; then + /usr/local/bin/migrate -source file:///migrations -database "postgres://$ZT_DB_USER:$ZT_DB_PASSWORD@$ZT_DB_HOST:$ZT_DB_PORT/$ZT_DB_NAME?x-migrations-table=controller_migrations&sslmode=verify-full&sslrootcert=$DB_SERVER_CA&sslcert=$DB_CLIENT_CERT&sslkey=$DB_CLIENT_KEY" up +else + /usr/local/bin/migrate -source file:///migrations -database "postgres://$ZT_DB_USER:$ZT_DB_PASSWORD@$ZT_DB_HOST:$ZT_DB_PORT/$ZT_DB_NAME?x-migrations-table=controller_migrations&sslmode=disable" up fi if [ -n "$ZT_TEMPORAL_HOST" ] && [ -n "$ZT_TEMPORAL_PORT" ]; then @@ -125,7 +213,16 @@ if [ -n "$ZT_TEMPORAL_HOST" ] && [ -n "$ZT_TEMPORAL_PORT" ]; then echo "Temporal is up" fi +cat /var/lib/zerotier-one/local.conf + +export GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes +export LIBC_FATAL_STDERR_=1 export GLIBCXX_FORCE_NEW=1 export GLIBCPP_FORCE_NEW=1 -export LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libjemalloc.so.2" +# Preload jemalloc, located arch-agnostically (libjemalloc2 installs it under the +# multiarch dir, e.g. /usr/lib//libjemalloc.so.2). Skip if not present. +JEMALLOC="$(ldconfig -p 2>/dev/null | awk '/libjemalloc\.so\.2/ {print $NF; exit}')" +if [ -n "$JEMALLOC" ]; then + export LD_PRELOAD="$JEMALLOC" +fi exec /usr/local/bin/zerotier-one -p${ZT_CONTROLLER_PORT:-$DEFAULT_PORT} /var/lib/zerotier-one diff --git a/ext/opentelemetry-cpp-1.21.0/.bazelignore b/ext/opentelemetry-cpp-1.21.0/.bazelignore deleted file mode 100644 index 56306fc4b9..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.bazelignore +++ /dev/null @@ -1,3 +0,0 @@ -third_party -tools -out diff --git a/ext/opentelemetry-cpp-1.21.0/.bazelrc b/ext/opentelemetry-cpp-1.21.0/.bazelrc deleted file mode 100644 index 57cd0a2fa0..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.bazelrc +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -# bazel configurations for running tests under sanitizers. -# Based on https://github.com/bazelment/trunk/blob/master/tools/bazel.rc - -# Enable automatic configs based on platform -common --enable_platform_specific_config - -# Make globs that don't match anything fail -common --incompatible_disallow_empty_glob - -# Needed by gRPC to build on some platforms. -build --copt -DGRPC_BAZEL_BUILD - -# Workaround abseil libraries missing symbols -build:windows --dynamic_mode=off - -# Set minimum supported C++ version -build:macos --host_cxxopt=-std=c++14 --cxxopt=-std=c++14 -build:linux --host_cxxopt=-std=c++14 --cxxopt=-std=c++14 -build:windows --host_cxxopt=/std:c++14 --cxxopt=/std:c++14 - -# --config=asan : Address Sanitizer. -common:asan --copt -DADDRESS_SANITIZER -common:asan --copt -fsanitize=address,bool,float-cast-overflow,integer-divide-by-zero,null,return,returns-nonnull-attribute,shift-exponent,signed-integer-overflow,unreachable,vla-bound -common:asan --copt -fsanitize-address-use-after-scope -common:asan --copt -fno-sanitize-recover=all -common:asan --linkopt -fsanitize=address,bool,float-cast-overflow,integer-divide-by-zero,null,return,returns-nonnull-attribute,shift-exponent,signed-integer-overflow,unreachable,vla-bound -common:asan --linkopt -fsanitize-address-use-after-scope -common:asan --linkopt -fno-sanitize-recover=all -common:asan --cc_output_directory_tag=asan - -# --config=tsan : Thread Sanitizer. -common:tsan --copt -fsanitize=thread -common:tsan --copt -DTHREAD_SANITIZER -common:tsan --linkopt -fsanitize=thread -common:tsan --cc_output_directory_tag=tsan -# This is needed to address false positive problem with abseil.The same setting as gRPC -# https://github.com/google/sanitizers/issues/953 -common:tsan --test_env=TSAN_OPTIONS=report_atomic_races=0 diff --git a/ext/opentelemetry-cpp-1.21.0/.bazelversion b/ext/opentelemetry-cpp-1.21.0/.bazelversion deleted file mode 100644 index 21c8c7b46b..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.bazelversion +++ /dev/null @@ -1 +0,0 @@ -7.1.1 diff --git a/ext/opentelemetry-cpp-1.21.0/.clang-format b/ext/opentelemetry-cpp-1.21.0/.clang-format deleted file mode 100644 index 1b5d0d488f..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.clang-format +++ /dev/null @@ -1,73 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -# See Clang docs: http://clang.llvm.org/docs/ClangFormatStyleOptions.html -BasedOnStyle: Chromium - -# Allow double brackets such as std::vector>. -Standard: Cpp11 - -# Indent 2 spaces at a time. -IndentWidth: 2 - -# Keep lines under 100 columns long. -ColumnLimit: 100 - -# Always break before braces -BreakBeforeBraces: Custom -BraceWrapping: -# TODO(lujc) wait for clang-format-9 support in Chromium tools -# AfterCaseLabel: true - AfterClass: true - AfterControlStatement: true - AfterEnum: true - AfterFunction: true - AfterNamespace: true - AfterStruct: true - AfterUnion: true - BeforeCatch: true - BeforeElse: true - IndentBraces: false - SplitEmptyFunction: false - SplitEmptyRecord: false - SplitEmptyNamespace: false - - # Keeps extern "C" blocks unindented. - AfterExternBlock: false - -# Indent case labels. -IndentCaseLabels: true - -# Right-align pointers and references -PointerAlignment: Right - -# ANGLE likes to align things as much as possible. -AlignOperands: true -AlignConsecutiveAssignments: true - -# Use 2 space negative offset for access modifiers -AccessModifierOffset: -2 - -# TODO(jmadill): Decide if we want this on. Doesn't have an "all or none" mode. -AllowShortCaseLabelsOnASingleLine: false - -# Useful for spacing out functions in classes -KeepEmptyLinesAtTheStartOfBlocks: true - -# Indent nested PP directives. -IndentPPDirectives: AfterHash - -# Include blocks style -IncludeBlocks: Preserve - -AttributeMacros: - - OPENTELEMETRY_UNLIKELY - - OPENTELEMETRY_LIKELY - - OPENTELEMETRY_MAYBE_UNUSED - - OPENTELEMETRY_DEPRECATED - - OPENTELEMETRY_API_SINGLETON - - OPENTELEMETRY_LOCAL_SYMBOL - - OPENTELEMETRY_EXPORT - - OPENTELEMETRY_SANITIZER_NO_MEMORY - - OPENTELEMETRY_SANITIZER_NO_THREAD - - OPENTELEMETRY_SANITIZER_NO_ADDRESS \ No newline at end of file diff --git a/ext/opentelemetry-cpp-1.21.0/.clang-tidy b/ext/opentelemetry-cpp-1.21.0/.clang-tidy deleted file mode 100644 index db61b810c9..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.clang-tidy +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -Checks: > - -*, - performance-*, - portability-*, - abseil-*, - -abseil-string-find-str-contains, - bugprone-*, - -bugprone-easily-swappable-parameters, - -bugprone-implicit-widening-of-multiplication-result, - -bugprone-inc-dec-in-conditions, - -bugprone-narrowing-conversions, - -bugprone-unchecked-optional-access, - -bugprone-unhandled-exception-at-new, - -bugprone-unused-local-non-trivial-variable, - google-*, - -google-build-using-namespace, - -google-default-arguments, - -google-explicit-constructor, - -google-readability-avoid-underscore-in-googletest-name, - -google-readability-braces-around-statements, - -google-readability-namespace-comments, - -google-readability-todo, - -google-runtime-references, - misc-*, - -misc-const-correctness, - -misc-include-cleaner, - -misc-non-private-member-variables-in-classes, - -misc-unused-alias-decls, - -misc-use-anonymous-namespace, - cppcoreguidelines-*, - -cppcoreguidelines-owning-memory, - -cppcoreguidelines-avoid-do-while, - -cppcoreguidelines-avoid-c-arrays, - -cppcoreguidelines-avoid-magic-numbers, - -cppcoreguidelines-init-variables, - -cppcoreguidelines-macro-usage, - -cppcoreguidelines-non-private-member-variables-in-classes, - -cppcoreguidelines-avoid-non-const-global-variables, - -cppcoreguidelines-pro-* \ No newline at end of file diff --git a/ext/opentelemetry-cpp-1.21.0/.cmake-format.py b/ext/opentelemetry-cpp-1.21.0/.cmake-format.py deleted file mode 100644 index d232ac8ebb..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.cmake-format.py +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -# If comment markup is enabled, don't reflow the first comment block in -# eachlistfile. Use this to preserve formatting of your -# copyright/licensestatements. -first_comment_is_literal = True diff --git a/ext/opentelemetry-cpp-1.21.0/.copyright-ignore b/ext/opentelemetry-cpp-1.21.0/.copyright-ignore deleted file mode 100644 index 81c51bcd50..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.copyright-ignore +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -# Ignore the following directories - -./.git/* -./.github/* -./third_party/benchmark/* -./third_party/boost/* -./third_party/googletest/* -./third_party/ms-gsl/* -./third_party/nlohmann-json/* -./third_party/opentelemetry-proto/* -./third_party/prometheus-cpp/* -./tools/vcpkg/* -./tools/ports/* - -# Third party code - -./api/include/opentelemetry/nostd/internal/absl/* -./exporters/jaeger/thrift-gen/* -./exporters/etw/include/opentelemetry/exporters/etw/TraceLoggingDynamic.h - -# Doc - -./docs/* - -## Ignore the following files patterns - -*.md -*.rst -*.png -*.log -*.patch -*.json -*.nuspec -*.pem - -# Packaging -*/CONTROL - -# LICENSE files -*/LICENSE - -# Ignore the following misc files - -./.bazelignore -./.bazelversion -./docker/.gitignore -.markdownlintignore -./ci/toc.yml -./ci/valgrind-suppressions diff --git a/ext/opentelemetry-cpp-1.21.0/.devcontainer/Dockerfile.conan b/ext/opentelemetry-cpp-1.21.0/.devcontainer/Dockerfile.conan deleted file mode 100644 index 05f6ae27fa..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.devcontainer/Dockerfile.conan +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 -FROM ubuntu:24.04@sha256:1e622c5f073b4f6bfad6632f2616c7f59ef256e96fe78bf6a595d1dc4376ac02 - -RUN apt update && apt install -y \ - build-essential \ - ca-certificates \ - wget \ - cmake \ - git \ - sudo \ - nano \ - pkg-config \ - ninja-build \ - clang-format \ - clang-tidy \ - autoconf \ - automake \ - libtool \ - python3-pip - -RUN pip install "conan==2.15.1" --break-system-packages - -ARG USER_UID=1000 -ARG USER_GID=1000 -ARG USER_NAME=devuser -ENV USER_NAME=devuser -ENV USER_UID=${USER_UID} -ENV USER_GID=${USER_GID} -ENV INSTALL_PACKAGES= -ENV IS_CONTAINER_BUILD=true - -COPY ./.devcontainer/customize_container.sh /tmp/opentelemetry_cpp/devcontainer/customize_container.sh -RUN /tmp/opentelemetry_cpp/devcontainer/customize_container.sh -USER devuser - -RUN conan profile detect --force - -ARG CONAN_FILE=conanfile_stable.txt -ARG CONAN_BUILD_TYPE=Debug -ARG CXX_STANDARD=17 -WORKDIR /home/devuser/conan -COPY ./install/conan/ . - -RUN conan install ./${CONAN_FILE} --build=missing -s build_type=${CONAN_BUILD_TYPE} -ENV CMAKE_TOOLCHAIN_FILE=/home/devuser/conan/build/${CONAN_BUILD_TYPE}/generators/conan_toolchain.cmake -ENV CXX_STANDARD=${CXX_STANDARD} -ENV BUILD_TYPE=${CONAN_BUILD_TYPE} -ENV CONAN_FILE=${CONAN_FILE} - -WORKDIR /workspaces/opentelemetry-cpp - -ENTRYPOINT [] - -CMD ["/bin/bash"] diff --git a/ext/opentelemetry-cpp-1.21.0/.devcontainer/Dockerfile.dev b/ext/opentelemetry-cpp-1.21.0/.devcontainer/Dockerfile.dev deleted file mode 100644 index c0eea6d326..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.devcontainer/Dockerfile.dev +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -FROM otel/cpp_format_tools - -ARG USER_UID=1000 -ARG USER_GID=1000 -ARG INSTALL_PACKAGES= - -ARG CXX_STANDARD=17 -ARG CMAKE_VERSION=3.31.6 -ARG ABSEIL_CPP_VERSION=20230125.3 -ARG PROTOBUF_VERSION=23.3 -ARG GRPC_VERSION=v1.55.0 - -ENV CXX_STANDARD=${CXX_STANDARD} -ENV CMAKE_VERSION=${CMAKE_VERSION} -ENV ABSEIL_CPP_VERSION=${ABSEIL_CPP_VERSION} -ENV PROTOBUF_VERSION=${PROTOBUF_VERSION} -ENV GRPC_VERSION=${GRPC_VERSION} - -COPY ci /opt/ci - -RUN apt update && apt install -y wget \ - ninja-build \ - libcurl4-openssl-dev \ - clang-tidy \ - shellcheck - -RUN cd /opt/ci && bash setup_cmake.sh -RUN cd /opt/ci && bash setup_ci_environment.sh -RUN cd /opt && bash ci/setup_googletest.sh \ - && bash ci/install_abseil.sh \ - && bash ci/install_protobuf.sh \ - && bash ci/setup_grpc.sh -r $GRPC_VERSION -s $CXX_STANDARD -p protobuf -p abseil-cpp - -ADD https://github.com/bazelbuild/bazelisk/releases/download/v1.22.1/bazelisk-linux-amd64 /usr/local/bin - -RUN git config --global core.autocrlf input \ - && chmod +x /usr/local/bin/bazelisk-linux-amd64 - -ENV INSTALL_PACKAGES=${INSTALL_PACKAGES} -ENV USER_NAME=devuser -ENV USER_UID=${USER_UID} -ENV USER_GID=${USER_GID} -ENV IS_CONTAINER_BUILD=true - -COPY ./.devcontainer/customize_container.sh /tmp/opentelemetry_cpp/devcontainer/customize_container.sh -RUN /tmp/opentelemetry_cpp/devcontainer/customize_container.sh -RUN apt install -y npm && npm install -g markdownlint-cli@0.44.0 - -USER devuser - -WORKDIR /workspaces/opentelemetry-cpp - -ENTRYPOINT [] - -CMD ["/bin/bash"] \ No newline at end of file diff --git a/ext/opentelemetry-cpp-1.21.0/.devcontainer/README.md b/ext/opentelemetry-cpp-1.21.0/.devcontainer/README.md deleted file mode 100644 index bea6f8c4d5..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.devcontainer/README.md +++ /dev/null @@ -1,65 +0,0 @@ -# Customizing Your Dev Container - -Customize your dev container using build arguments (for direct Docker builds) or -environment variables (for evaluation in `devcontainer.json`). - -* **CMake version:** - The version of cmake to install. (Default: 3.31.6) - * Docker ARG: - `CMAKE_VERSION` - * Host Environment Variable: - `OTEL_CPP_DEVCONTAINER_CMAKE_VERSION` - -* **CXX standard:** - This is the C++ standard to build from (eg: 17, 20, ...). (Default: 17) - * Docker ARG: - `CXX_STANDARD` - * Host Environment Variable: - `OTEL_CPP_DEVCONTAINER_CXX_STANDARD` - -* **abseil-cpp version:** - This is the version of abseil-cpp that will be used to build protobuf, gRPC, - and opentelemetry-cpp. - * Docker ARG: - `ABSEIL_CPP_VERSION` - * Host Environment Variable: - `OTEL_CPP_DEVCONTAINER_ABSEIL_CPP_VERSION` - -* **Protobuf version:** - * Docker ARG: - `PROTOBUF_VERSION` - * Host Environment Variable: - `OTEL_CPP_DEVCONTAINER_PROTOBUF_VERSION` - -* **gRPC version:** - * Docker ARG: - `GRPC_VERSION` - * Host Environment Variable: - `OTEL_CPP_DEVCONTAINER_GRPC_VERSION` - -* **User ID (UID):** - User ID (Default: `1000`) - * Docker ARG: - `USER_UID` - * Host Environment Variable: - `OTEL_CPP_DEVCONTAINER_USER_UID` - -* **Group ID (GID):** - User group ID (Default: `1000`) - * Docker ARG: - `USER_GID` - * Host Environment Variable: - `OTEL_CPP_DEVCONTAINER_USER_GID` - -* **Install Packages:** - These are the additional packages that will be installed via `apt install` in the devcontainer. This is a space separated list. - * Docker ARG: - `INSTALL_PACKAGES` (Default: ``) - * Host Environment Variable: - `OTEL_CPP_DEVCONTAINER_INSTALL_PACKAGES` (Default: ``) - -## Examples - -* `docker build --build-arg CXX_STANDARD="20" --build-arg INSTALL_PACKAGES="nano gitk"...` -* `export OTEL_CPP_DEVCONTAINER_CXX_STANDARD=20` -* `export OTEL_CPP_DEVCONTAINER_INSTALL_PACKAGES="nano gitk"` diff --git a/ext/opentelemetry-cpp-1.21.0/.devcontainer/customize_container.sh b/ext/opentelemetry-cpp-1.21.0/.devcontainer/customize_container.sh deleted file mode 100755 index ba9614e671..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.devcontainer/customize_container.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -set -eu - -if [[ $IS_CONTAINER_BUILD != "true" ]]; then - echo "This script should only run inside a Docker container." - exit 1 -fi - -if [[ -n "$INSTALL_PACKAGES" ]]; then - packages=($INSTALL_PACKAGES) - for package in "${packages[@]}"; do - apt install -y "$package" - done -fi - -if [[ $(id "$USER_NAME" 2>/dev/null) ]]; then - echo "User '$USER_NAME' already exists. Removing it." - userdel -rf "$USER_NAME" -elif [[ $(id -u "$USER_UID" 2>/dev/null) ]]; then - OTHER_USER=$(getent passwd "$USER_UID" | cut -d: -f1) - echo "User '$OTHER_USER' exists with UID $USER_UID. Removing it." - userdel -rf "$OTHER_USER" -fi - -if [[ ! $(getent group "$USER_GID" 2>/dev/null) ]]; then - echo "Group '$USER_GID' does not exist. Adding it." - groupadd -g "$USER_GID" "$USER_NAME" -fi - -useradd -m -u "$USER_UID" -g "$USER_GID" -s /bin/bash "$USER_NAME" -echo "Created user '$USER_NAME' (UID: $USER_UID, GID: $USER_GID)." - -echo "$USER_NAME ALL=(ALL) NOPASSWD:ALL" | tee /etc/sudoers.d/"$USER_NAME" - -echo "User and group setup complete." diff --git a/ext/opentelemetry-cpp-1.21.0/.devcontainer/devcontainer.json b/ext/opentelemetry-cpp-1.21.0/.devcontainer/devcontainer.json deleted file mode 100644 index 8087122423..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.devcontainer/devcontainer.json +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 -// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: -// https://github.com/microsoft/vscode-dev-containers/tree/v0.162.0/containers/javascript-node -{ - "name": "opentelemetry-cpp", - "build": { - "context": "..", - "dockerfile": "Dockerfile.dev", - "args": { - "USER_UID": "${localEnv:OTEL_CPP_DEVCONTAINER_USER_UID:1000}", - "USER_GID": "${localEnv:OTEL_CPP_DEVCONTAINER_USER_GID:1000}", - "INSTALL_PACKAGES": "${localEnv:OTEL_CPP_DEVCONTAINER_INSTALL_PACKAGES:}", - "CMAKE_VERSION": "${localEnv:OTEL_CPP_DEVCONTAINER_CMAKE_VERSION:3.31.6}", - "CXX_STANDARD": "${localEnv:OTEL_CPP_DEVCONTAINER_CXX_STANDARD:17}", - "GRPC_VERSION": "${localEnv:OTEL_CPP_DEVCONTAINER_GRPC_VERSION:v1.55.0}", - "PROTOBUF_VERSION": "${localEnv:OTEL_CPP_DEVCONTAINER_PROTOBUF_VERSION:23.3}", - "ABSEIL_CPP_VERSION":"${localEnv:OTEL_CPP_DEVCONTAINER_ABSEIL_CPP_VERSION:20230125.3}" - } - }, - "customizations": { - "vscode": { - "extensions": [ - "ms-vscode.cpptools", - "ms-azuretools.vscode-docker", - "ms-vscode.cpptools-extension-pack" - ], - "settings": { - "terminal.integrated.shell.linux": "/bin/bash", - } - } - }, - - "remoteUser": "devuser" -} diff --git a/ext/opentelemetry-cpp-1.21.0/.gitattributes b/ext/opentelemetry-cpp-1.21.0/.gitattributes deleted file mode 100644 index ca2467b474..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.gitattributes +++ /dev/null @@ -1,47 +0,0 @@ -##### Source code ##### - -## C++ and C source files -*.c text eol=lf diff=cpp -*.h text eol=lf diff=cpp -*.cc text eol=lf diff=cpp -*.cpp text eol=lf diff=cpp -*.cxx text eol=lf diff=cpp -*.hpp text eol=lf diff=cpp - -## Python scripts -*.py text eol=lf diff=python - -## Perl scripts/libraries/modules -*.perl text eol=lf diff=perl -*.pl text eol=lf diff=perl -*.pm text eol=lf diff=perl - -## Shell scripts -*.sh text eol=lf -*.bash text eol=lf - -## Windows batch and PowerShell scripts -*.bat text eol=crlf -*.cmd text eol=crlf -*.ps1 text eol=crlf - -##### Other file types ##### - -## Text files and documentation -*.txt text -README* text -INSTALL* text -LICENSE* text - -## Non-text documentation -*.html text diff=html -*.pdf binary -*.rtf binary - -## git files -.gitignore text eol=lf -.gitattributes text eol=lf - -## bazel files -WORKSPACE text eol=lf -BUILD text eol=lf diff --git a/ext/opentelemetry-cpp-1.21.0/.github/.codecov.yaml b/ext/opentelemetry-cpp-1.21.0/.github/.codecov.yaml deleted file mode 100644 index 1b9921ac4c..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/.codecov.yaml +++ /dev/null @@ -1,50 +0,0 @@ -codecov: - require_ci_to_pass: false - max_report_age: off - -coverage: - precision: 2 - round: up - range: "80...100" - status: - project: - default: - informational: true - target: auto - threshold: 10% - patch: false - -parsers: - gcov: - branch_detection: - conditional: yes - loop: yes - method: no - macro: no - -comment: - layout: "reach,diff,flags,tree" - behavior: default - require_changes: false - -# Relative file path fixing. -# CI file paths must match Git file paths. -# This fix removes the "/home/runner/" prefix -# to coverage report file paths. -fixes: - - "/home/runner/::" - -ignore: - - "docs/**/*" - - "docker/**/*" - - "examples/**/*" - - "bazel/**/*" - - "cmake/**/*" - - "buildscripts/**/*" - - "third_party/**/*" - - "test_common/**/*" - - "tools/**/*" - - ".vscode/**/*" - - ".github/**/*" - - "**/test/**/*" - - "**.md" \ No newline at end of file diff --git a/ext/opentelemetry-cpp-1.21.0/.github/CODEOWNERS b/ext/opentelemetry-cpp-1.21.0/.github/CODEOWNERS deleted file mode 100644 index 7a40cd0b0e..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/CODEOWNERS +++ /dev/null @@ -1,8 +0,0 @@ -# Code owners file. -# This file controls who is tagged for review for any given pull request. - -# For ETW exporter -exporters/etw/* @reyang @maxgolov @lalitb @ThomsonTan @open-telemetry/cpp-approvers - -# For anything not explicitly taken by someone else: -* @open-telemetry/cpp-approvers diff --git a/ext/opentelemetry-cpp-1.21.0/.github/ISSUE_TEMPLATE/bug_report.md b/ext/opentelemetry-cpp-1.21.0/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index e0bb4cca27..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -name: Bug Report -about: Create a report to help us improve -labels: bug ---- - -**Describe your environment** Describe any aspect of your environment relevant to the problem, including your platform, build system, version numbers of installed dependencies, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main branch. - -**Steps to reproduce** -Describe exactly how to reproduce the error. Include a code sample if applicable. - -**What is the expected behavior?** -What did you expect to see? - -**What is the actual behavior?** -What did you see instead? - -**Additional context** -Add any other context about the problem here. diff --git a/ext/opentelemetry-cpp-1.21.0/.github/ISSUE_TEMPLATE/feature_request.md b/ext/opentelemetry-cpp-1.21.0/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 973549ab2d..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -name: Feature Request -about: Suggest an idea for this project -labels: feature-request ---- - -Before opening a feature request against this repo, consider whether the feature should/could be implemented in the [other OpenTelemetry client libraries](https://github.com/open-telemetry/). If so, please [open an issue on opentelemetry-specification](https://github.com/open-telemetry/opentelemetry-specification/issues/new) first. - -**Is your feature request related to a problem?** -If so, provide a concise description of the problem. - -**Describe the solution you'd like** -What do you want to happen instead? What is the expected behavior? - -**Describe alternatives you've considered** -Which alternative solutions or features have you considered? - -**Additional context** -Add any other context about the feature request here. diff --git a/ext/opentelemetry-cpp-1.21.0/.github/dependabot.yml b/ext/opentelemetry-cpp-1.21.0/.github/dependabot.yml deleted file mode 100644 index 5cfb4cb898..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/dependabot.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "daily" - labels: - - "GHA" - - - package-ecosystem: "devcontainers" - directory: "/" - schedule: - interval: daily diff --git a/ext/opentelemetry-cpp-1.21.0/.github/pull_request_template.md b/ext/opentelemetry-cpp-1.21.0/.github/pull_request_template.md deleted file mode 100644 index e547603239..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/pull_request_template.md +++ /dev/null @@ -1,11 +0,0 @@ -Fixes # (issue) - -## Changes - -Please provide a brief description of the changes here. - -For significant contributions please make sure you have completed the following items: - -* [ ] `CHANGELOG.md` updated for non-trivial changes -* [ ] Unit tests have been added -* [ ] Changes in public API reviewed \ No newline at end of file diff --git a/ext/opentelemetry-cpp-1.21.0/.github/repository-settings.md b/ext/opentelemetry-cpp-1.21.0/.github/repository-settings.md deleted file mode 100644 index fa86d02cfc..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/repository-settings.md +++ /dev/null @@ -1,38 +0,0 @@ -# Process - -This file documents local admin changes for opentelemetry-cpp, -per the community process: https://github.com/open-telemetry/community/blob/main/docs/how-to-configure-new-repository.md - -Please note that the EasyCLA check **MUST** stay **REQUIRED**, -it should never be disabled or bypassed, at the risk of tainting the repository. - -# Guidelines - -The best is to open a PR first that describes the change, -so it can be discussed during review (maybe it is not needed, -maybe there is an alternate solution, ...). - -The PR must add a log entry in this file, detailing: - -* the date the change is implemented -* what is changed exactly (which setting) -* a short rationale - -Admin changes are then applied only when the PR is merged. - -If for some reason a change is implemented in emergency, -before a PR can be discussed and merged, -a PR should still be prepared and pushed after the fact to -describe the settings changed. - -# Log of local changes - -## 2023-11-03 - -Created log file `.github/repository-settings.md`, since admin permissions are now granted to maintainers. - -See https://github.com/open-telemetry/community/issues/1727 - -No setting changed. - - diff --git a/ext/opentelemetry-cpp-1.21.0/.github/workflows/benchmark.yml b/ext/opentelemetry-cpp-1.21.0/.github/workflows/benchmark.yml deleted file mode 100644 index eaad6b280f..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/workflows/benchmark.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: OpenTelemetry-cpp benchmarks -on: - push: - branches: - - main - -permissions: - contents: write - deployments: write - -jobs: - benchmark: - name: Run OpenTelemetry-cpp benchmarks - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Mount Bazel Cache - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 - env: - cache-name: bazel_cache - with: - path: /home/runner/.cache/bazel - key: bazel_benchmark - - name: setup - run: | - sudo ./ci/setup_ci_environment.sh - sudo ./ci/install_bazelisk.sh - - name: Run benchmark - id: run_benchmarks - run: | - ./ci/do_ci.sh bazel.benchmark - mkdir -p benchmarks - mv api-benchmark_result.json benchmarks - mv sdk-benchmark_result.json benchmarks - mv exporters-benchmark_result.json benchmarks - - uses: actions/upload-artifact@6027e3dd177782cd8ab9af838c04fd81a07f1d47 # main March 2025 - with: - name: benchmark_results - path: benchmarks - store_benchmark: - needs: benchmark - strategy: - matrix: - components: ["api", "sdk", "exporters"] - name: Store benchmark result - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # main March 2025 - with: - name: benchmark_results - path: benchmarks - - name: Print json files - id: print_json - run: | - cat benchmarks/* - - name: Push benchmark result - uses: benchmark-action/github-action-benchmark@d48d326b4ca9ba73ca0cd0d59f108f9e02a381c7 # v1.20.4 - with: - name: OpenTelemetry-cpp ${{ matrix.components }} Benchmark - tool: 'googlecpp' - output-file-path: benchmarks/${{ matrix.components }}-benchmark_result.json - github-token: ${{ secrets.GITHUB_TOKEN }} - auto-push: true - # Show alert with commit comment on detecting possible performance regression - alert-threshold: '200%' - comment-on-alert: true - fail-on-alert: false - gh-pages-branch: gh-pages - benchmark-data-dir-path: benchmarks diff --git a/ext/opentelemetry-cpp-1.21.0/.github/workflows/ci.yml b/ext/opentelemetry-cpp-1.21.0/.github/workflows/ci.yml deleted file mode 100644 index bc585fc26e..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/workflows/ci.yml +++ /dev/null @@ -1,1247 +0,0 @@ -name: CI - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -permissions: - contents: read - -jobs: - -# Commented 2024-11-06, lack of workers in github causes CI failures -# arm64_test: -# name: CMake test arm64 (with modern protobuf,grpc and abseil) -# runs-on: actuated-arm64-4cpu-16gb -# steps: -# - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 -# with: -# submodules: 'recursive' -# - name: setup -# env: -# PROTOBUF_VERSION: '23.3' -# ABSEIL_CPP_VERSION: '20230125.3' -# CXX_STANDARD: '14' -# CC: /usr/bin/gcc-10 -# CXX: /usr/bin/g++-10 -# run: | -# sudo -E ./ci/setup_gcc10.sh -# sudo -E ./ci/setup_ci_environment.sh -# sudo -E ./ci/setup_cmake.sh -# sudo -E ./ci/setup_googletest.sh -# sudo -E ./ci/install_abseil.sh -# sudo -E ./ci/install_protobuf.sh - - cmake_test: - name: CMake test (prometheus, elasticsearch, zipkin) - runs-on: ubuntu-22.04 - env: - CXX_STANDARD: '17' - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: run cmake tests - run: | - ./ci/do_ci.sh cmake.test - - cmake_fetch_content_test: - name: CMake FetchContent usage with opentelemetry-cpp - runs-on: ubuntu-24.04 - env: - CXX_STANDARD: '17' - BUILD_TYPE: 'Debug' - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: Install abseil, protobuf, and grpc with apt - run: | - sudo -E apt-get update - sudo -E apt-get install -y libabsl-dev libprotobuf-dev libgrpc++-dev protobuf-compiler protobuf-compiler-grpc - - name: run fetch content cmake test - run: | - ./ci/do_ci.sh cmake.fetch_content.test - - cmake_gcc_maintainer_sync_test: - name: CMake gcc 14 (maintainer mode, sync) - runs-on: ubuntu-24.04 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - env: - CC: /usr/bin/gcc-14 - CXX: /usr/bin/g++-14 - PROTOBUF_VERSION: 21.12 - run: | - sudo apt remove needrestart #refer: https://github.com/actions/runner-images/issues/9937 - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - sudo -E ./ci/install_protobuf.sh - - name: setup grpc - run: | - sudo ./ci/setup_grpc.sh - - name: run cmake gcc (maintainer mode, sync) - env: - CC: /usr/bin/gcc-14 - CXX: /usr/bin/g++-14 - run: | - ./ci/do_ci.sh cmake.maintainer.sync.test - - name: generate test cert - env: - CFSSL_VERSION: 1.6.3 - run: | - sudo -E ./tools/setup-cfssl.sh - (cd ./functional/cert; ./generate_cert.sh) - - name: run func test - run: | - (cd ./functional/otlp; ./run_test.sh) - - cmake_gcc_maintainer_async_test: - name: CMake gcc 14 (maintainer mode, async) - runs-on: ubuntu-24.04 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - env: - CC: /usr/bin/gcc-14 - CXX: /usr/bin/g++-14 - PROTOBUF_VERSION: 21.12 - run: | - sudo apt remove needrestart #refer: https://github.com/actions/runner-images/issues/9937 - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - sudo -E ./ci/install_protobuf.sh - - name: setup grpc - run: | - sudo ./ci/setup_grpc.sh - - name: run cmake gcc (maintainer mode, async) - env: - CC: /usr/bin/gcc-14 - CXX: /usr/bin/g++-14 - run: | - ./ci/do_ci.sh cmake.maintainer.async.test - - name: generate test cert - env: - CFSSL_VERSION: 1.6.3 - run: | - sudo -E ./tools/setup-cfssl.sh - (cd ./functional/cert; ./generate_cert.sh) - - name: run func test - run: | - (cd ./functional/otlp; ./run_test.sh) - - cmake_clang_maintainer_sync_test: - name: CMake clang 18 (maintainer mode, sync) - runs-on: ubuntu-24.04 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - env: - CC: /usr/bin/clang-18 - CXX: /usr/bin/clang++-18 - PROTOBUF_VERSION: 21.12 - run: | - sudo apt remove needrestart #refer: https://github.com/actions/runner-images/issues/9937 - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - sudo -E ./ci/install_protobuf.sh - - name: setup grpc - run: | - sudo ./ci/setup_grpc.sh - - name: run cmake clang (maintainer mode, sync) - env: - CC: /usr/bin/clang-18 - CXX: /usr/bin/clang++-18 - run: | - ./ci/do_ci.sh cmake.maintainer.sync.test - - name: generate test cert - env: - CFSSL_VERSION: 1.6.3 - run: | - sudo -E ./tools/setup-cfssl.sh - (cd ./functional/cert; ./generate_cert.sh) - - name: run func test - run: | - (cd ./functional/otlp; ./run_test.sh) - - cmake_clang_maintainer_async_test: - name: CMake clang 18 (maintainer mode, async) - runs-on: ubuntu-24.04 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - env: - CC: /usr/bin/clang-18 - CXX: /usr/bin/clang++-18 - PROTOBUF_VERSION: 21.12 - run: | - sudo apt remove needrestart #refer: https://github.com/actions/runner-images/issues/9937 - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - sudo -E ./ci/install_protobuf.sh - - name: setup grpc - run: | - sudo ./ci/setup_grpc.sh - - name: run cmake clang (maintainer mode, async) - env: - CC: /usr/bin/clang-18 - CXX: /usr/bin/clang++-18 - run: | - ./ci/do_ci.sh cmake.maintainer.async.test - - name: generate test cert - env: - CFSSL_VERSION: 1.6.3 - run: | - sudo -E ./tools/setup-cfssl.sh - (cd ./functional/cert; ./generate_cert.sh) - - name: run func test - run: | - (cd ./functional/otlp; ./run_test.sh) - - cmake_clang_maintainer_abiv2_test: - name: CMake clang 18 (maintainer mode, abiv2) - runs-on: ubuntu-24.04 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - env: - CC: /usr/bin/clang-18 - CXX: /usr/bin/clang++-18 - PROTOBUF_VERSION: 21.12 - run: | - sudo apt remove needrestart #refer: https://github.com/actions/runner-images/issues/9937 - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - sudo -E ./ci/install_protobuf.sh - - name: setup grpc - run: | - sudo ./ci/setup_grpc.sh - - name: run cmake clang (maintainer mode, abiv2) - env: - CC: /usr/bin/clang-18 - CXX: /usr/bin/clang++-18 - run: | - ./ci/do_ci.sh cmake.maintainer.abiv2.test - - name: generate test cert - env: - CFSSL_VERSION: 1.6.3 - run: | - sudo -E ./tools/setup-cfssl.sh - (cd ./functional/cert; ./generate_cert.sh) - - name: run func test - run: | - (cd ./functional/otlp; ./run_test.sh) - - cmake_msvc_maintainer_test: - name: CMake msvc (maintainer mode) - runs-on: windows-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - run: | - ./ci/setup_cmake.ps1 - ./ci/setup_windows_ci_environment.ps1 - - name: run tests - run: ./ci/do_ci.ps1 cmake.maintainer.test - - cmake_msvc_maintainer_test_stl_cxx20: - name: CMake msvc (maintainer mode) with C++20 - runs-on: windows-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - run: | - ./ci/setup_cmake.ps1 - ./ci/setup_windows_ci_environment.ps1 - - name: run tests - env: - CXX_STANDARD: '20' - run: ./ci/do_ci.ps1 cmake.maintainer.cxx20.stl.test - - cmake_msvc_maintainer_abiv2_test: - name: CMake msvc (maintainer mode, abiv2) - runs-on: windows-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - run: | - ./ci/setup_cmake.ps1 - ./ci/setup_windows_ci_environment.ps1 - - name: run tests - env: - CXX_STANDARD: '20' - run: ./ci/do_ci.ps1 cmake.maintainer.abiv2.test - - cmake_with_async_export_test: - name: CMake test (without otlp-exporter and with async export) - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - env: - CC: /usr/bin/gcc-12 - CXX: /usr/bin/g++-12 - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: run cmake tests (without otlp-exporter) - env: - CC: /usr/bin/gcc-12 - CXX: /usr/bin/g++-12 - run: | - ./ci/do_ci.sh cmake.with_async_export.test - - cmake_opentracing_shim_test: - name: CMake test (with opentracing-shim) - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: run cmake tests (enable opentracing-shim) - run: ./ci/do_ci.sh cmake.opentracing_shim.test - - cmake_test_cxx14_gcc: - name: CMake C++14 test(GCC) - runs-on: ubuntu-22.04 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: run tests (enable stl) - env: - CXX_STANDARD: '14' - run: ./ci/do_ci.sh cmake.c++14.stl.test - - cmake_test_cxx17_gcc: - name: CMake C++17 test(GCC) - runs-on: ubuntu-22.04 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: run tests (enable stl) - env: - CXX_STANDARD: '17' - run: ./ci/do_ci.sh cmake.c++17.stl.test - - cmake_test_cxx20_gcc: - name: CMake C++20 test(GCC) - runs-on: ubuntu-22.04 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: run tests - env: - CXX_STANDARD: '20' - run: ./ci/do_ci.sh cmake.c++20.test - - name: run tests (enable stl) - env: - CXX_STANDARD: '20' - run: ./ci/do_ci.sh cmake.c++20.stl.test - - cmake_test_cxx20_clang: - name: CMake C++20 test(Clang with libc++) - runs-on: ubuntu-22.04 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - env: - CC: /usr/bin/clang - CXX: /usr/bin/clang++ - CXXFLAGS: "-stdlib=libc++" - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: run tests - env: - CC: /usr/bin/clang - CXX: /usr/bin/clang++ - CXXFLAGS: "-stdlib=libc++" - CXX_STANDARD: '20' - run: ./ci/do_ci.sh cmake.c++20.test - - name: run tests (enable stl) - env: - CC: /usr/bin/clang - CXX: /usr/bin/clang++ - CXXFLAGS: "-stdlib=libc++" - CXX_STANDARD: '20' - run: ./ci/do_ci.sh cmake.c++20.stl.test - - cmake_test_cxx23_gcc: - name: CMake C++23 test(GCC) - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: run tests - env: - CXX_STANDARD: '23' - run: ./ci/do_ci.sh cmake.c++23.test - - name: run tests (enable stl) - env: - CXX_STANDARD: '23' - run: ./ci/do_ci.sh cmake.c++23.stl.test - - cmake_test_cxx23_clang: - name: CMake C++23 test(Clang with libc++) - runs-on: ubuntu-22.04 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - env: - CC: /usr/bin/clang - CXX: /usr/bin/clang++ - CXXFLAGS: "-stdlib=libc++" - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: run tests - env: - CC: /usr/bin/clang - CXX: /usr/bin/clang++ - CXXFLAGS: "-stdlib=libc++" - CXX_STANDARD: '23' - run: ./ci/do_ci.sh cmake.c++23.test - - name: run tests (enable stl) - env: - CC: /usr/bin/clang - CXX: /usr/bin/clang++ - CXXFLAGS: "-stdlib=libc++" - CXX_STANDARD: '23' - run: ./ci/do_ci.sh cmake.c++23.stl.test - - cmake_otprotocol_test: - name: CMake test (with otlp-exporter) - runs-on: ubuntu-22.04 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: run otlp exporter tests - run: | - sudo ./ci/setup_grpc.sh - ./ci/do_ci.sh cmake.exporter.otprotocol.test - - name: generate test cert - env: - CFSSL_VERSION: 1.6.3 - run: | - sudo -E ./tools/setup-cfssl.sh - (cd ./functional/cert; ./generate_cert.sh) - - name: run func test - run: | - (cd ./functional/otlp; ./run_test.sh) - - cmake_modern_protobuf_grpc_with_abseil_test: - name: CMake test (with modern protobuf,grpc and abseil) - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - env: - PROTOBUF_VERSION: '23.3' - ABSEIL_CPP_VERSION: '20230125.3' - CXX_STANDARD: '14' - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - sudo -E ./ci/install_abseil.sh - sudo -E ./ci/install_protobuf.sh - - name: run otlp exporter tests - env: - CXX_STANDARD: '14' - run: | - sudo -E ./ci/setup_grpc.sh -m -p protobuf -p abseil-cpp - ./ci/do_ci.sh cmake.exporter.otprotocol.test - - cmake_do_not_install_test: - name: CMake do not install test (with otlp-exporter) - runs-on: ubuntu-22.04 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: run otlp exporter tests - run: | - sudo ./ci/setup_grpc.sh - ./ci/do_ci.sh cmake.do_not_install.test - - cmake_otprotocol_shared_libs_with_static_grpc_test: - name: CMake test (build shared libraries with otlp-exporter and static gRPC) - runs-on: ubuntu-22.04 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: run otlp exporter tests - run: | - sudo ./ci/setup_grpc.sh -T - ./ci/do_ci.sh cmake.exporter.otprotocol.shared_libs.with_static_grpc.test - - plugin_test: - name: Plugin -> CMake - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - env: - CC: /usr/bin/gcc-12 - CXX: /usr/bin/g++-12 - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: run tests - env: - CC: /usr/bin/gcc-12 - CXX: /usr/bin/g++-12 - run: ./ci/do_ci.sh cmake.test_example_plugin - - bazel_test: - name: Bazel - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Mount Bazel Cache - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 - env: - cache-name: bazel_cache - with: - path: /home/runner/.cache/bazel - key: bazel_test - - name: setup - run: | - sudo ./ci/setup_ci_environment.sh - sudo ./ci/setup_cmake.sh - sudo ./ci/install_bazelisk.sh - - name: run tests - run: ./ci/do_ci.sh bazel.test - - bazel_no_bzlmod_test: - name: Bazel without bzlmod - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Mount Bazel Cache - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 - env: - cache-name: bazel_cache - with: - path: /home/runner/.cache/bazel - key: bazel_test - - name: setup - run: | - sudo ./ci/setup_ci_environment.sh - sudo ./ci/setup_cmake.sh - sudo ./ci/install_bazelisk.sh - - name: run tests - run: ./ci/do_ci.sh bazel.no_bzlmod.test - - bazel_test_async: - name: Bazel with async export - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Mount Bazel Cache - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 - env: - cache-name: bazel_cache - with: - path: /home/runner/.cache/bazel - key: bazel_test - - name: setup - run: | - sudo ./ci/setup_ci_environment.sh - sudo ./ci/setup_cmake.sh - sudo ./ci/install_bazelisk.sh - - name: run tests - run: ./ci/do_ci.sh bazel.with_async_export.test - - bazel_valgrind: - name: Bazel valgrind - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Mount Bazel Cache - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 - env: - cache-name: bazel_cache - with: - path: /home/runner/.cache/bazel - key: bazel_valgrind - - name: setup - run: | - sudo ./ci/setup_ci_environment.sh - sudo ./ci/setup_cmake.sh - sudo ./ci/install_bazelisk.sh - - name: run tests - run: ./ci/do_ci.sh bazel.valgrind - - bazel_noexcept: - name: Bazel noexcept - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Mount Bazel Cache - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 - env: - cache-name: bazel_cache - with: - path: /home/runner/.cache/bazel - key: bazel_noexcept - - name: setup - run: | - sudo ./ci/setup_ci_environment.sh - sudo ./ci/setup_cmake.sh - sudo ./ci/install_bazelisk.sh - - name: run tests - run: ./ci/do_ci.sh bazel.noexcept - - bazel_nortti: - name: Bazel nortti - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Mount Bazel Cache - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 - env: - cache-name: bazel_cache - with: - path: /home/runner/.cache/bazel - key: bazel_nortti - - name: setup - run: | - sudo ./ci/setup_ci_environment.sh - sudo ./ci/setup_cmake.sh - sudo ./ci/install_bazelisk.sh - - name: run tests - run: ./ci/do_ci.sh bazel.nortti - - bazel_asan: - name: Bazel asan config - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Mount Bazel Cache - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 - env: - cache-name: bazel_cache - with: - path: /home/runner/.cache/bazel - key: bazel_asan - - name: setup - run: | - sudo ./ci/setup_ci_environment.sh - sudo ./ci/setup_cmake.sh - sudo ./ci/install_bazelisk.sh - - name: run tests - run: ./ci/do_ci.sh bazel.asan - - bazel_tsan: - name: Bazel tsan config - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Mount Bazel Cache - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 - env: - cache-name: bazel_cache - with: - path: /home/runner/.cache/bazel - key: bazel_tsan - - name: setup - run: | - sudo ./ci/setup_ci_environment.sh - sudo ./ci/setup_cmake.sh - sudo ./ci/install_bazelisk.sh - - name: run tests - run: ./ci/do_ci.sh bazel.tsan - - bazel_osx: - name: Bazel on MacOS - runs-on: macos-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Mount Bazel Cache - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 - env: - cache-name: bazel_cache - with: - path: /Users/runner/.cache/bazel - key: bazel_osx - - name: run tests - run: ./ci/do_ci.sh bazel.macos.test - - benchmark: - name: Benchmark - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Mount Bazel Cache - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 - env: - cache-name: bazel_cache - with: - path: /home/runner/.cache/bazel - key: bazel_benchmark - - name: setup - run: | - sudo ./ci/setup_ci_environment.sh - sudo ./ci/install_bazelisk.sh - - name: run tests - run: | - env BENCHMARK_DIR=/benchmark - ./ci/do_ci.sh benchmark - - name: Upload benchmark results - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - with: - name: benchmark_reports - path: /home/runner/benchmark - - format: - name: Format - runs-on: ubuntu-24.04 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: setup - run: sudo apt remove needrestart && sudo ./ci/install_format_tools.sh #refer: https://github.com/actions/runner-images/issues/9937 - - name: run tests - run: ./ci/do_ci.sh format - - copyright: - name: Copyright - runs-on: ubuntu-22.04 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: check copyright - run: ./tools/check_copyright.sh - - windows: - name: CMake -> exporter proto - runs-on: windows-2019 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - run: | - ./ci/setup_cmake.ps1 - ./ci/setup_windows_ci_environment.ps1 - ./ci/install_windows_protobuf.ps1 - - name: run cmake test - run: ./ci/do_ci.ps1 cmake.test - - name: run otprotocol test - run: ./ci/do_ci.ps1 cmake.exporter.otprotocol.test - - windows-build-dll: - name: CMake -> exporter proto (Build as DLL) - runs-on: windows-2019 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - run: | - ./ci/setup_cmake.ps1 - ./ci/setup_windows_ci_environment.ps1 - ./ci/install_windows_protobuf.ps1 - - name: run cmake test (DLL build) - run: ./ci/do_ci.ps1 cmake.dll.test - - name: run cmake cxx20 test (DLL build) - run: ./ci/do_ci.ps1 cmake.dll.cxx20.test - - name: run otprotocol test (DLL build) - run: ./ci/do_ci.ps1 cmake.exporter.otprotocol.dll.test - - windows_with_async_export: - name: CMake (With async export) -> exporter proto - runs-on: windows-2019 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - run: | - ./ci/setup_cmake.ps1 - ./ci/setup_windows_ci_environment.ps1 - ./ci/install_windows_protobuf.ps1 - - name: run cmake test - run: ./ci/do_ci.ps1 cmake.with_async_export.test - - name: run otprotocol test - run: ./ci/do_ci.ps1 cmake.exporter.otprotocol.with_async_export.test - - windows_bazel: - name: Bazel Windows - runs-on: windows-2019 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - run: | - ./ci/install_windows_bazelisk.ps1 - - name: run tests - run: ./ci/do_ci.ps1 bazel.build - - windows_plugin_test: - name: Plugin -> CMake Windows - runs-on: windows-2019 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - run: | - ./ci/setup_cmake.ps1 - ./ci/setup_windows_ci_environment.ps1 - - name: run tests - run: ./ci/do_ci.ps1 cmake.test_example_plugin - - code_coverage: - name: Code coverage - runs-on: ubuntu-22.04 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - env: - CC: /usr/bin/gcc-10 - CXX: /usr/bin/g++-10 - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: run tests and generate report - env: - CC: /usr/bin/gcc-10 - CXX: /usr/bin/g++-10 - run: ./ci/do_ci.sh code.coverage - - name: upload report - uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3 - with: - files: /home/runner/build/coverage.info - - markdown-lint: - runs-on: ubuntu-latest - - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - name: check out code - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - name: install markdownlint-cli - run: sudo npm install -g markdownlint-cli@0.44.0 - - - name: run markdownlint - run: markdownlint . - - shellcheck: - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - name: check out code - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: install shellcheck - run: sudo apt install --assume-yes shellcheck - - name: run shellcheck - run: find . -name \*.sh | xargs shellcheck --severity=error - - misspell: - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - name: check out code - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: install misspell - run: | - curl -L -o ./install-misspell.sh https://git.io/misspell - sh ./install-misspell.sh - - name: run misspell - run: ./bin/misspell -error . - - docfx_check: - name: DocFX check - runs-on: windows-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - name: install docfx - run: choco install docfx -y --version=2.58.5 - - name: run ./ci/docfx.cmd - shell: cmd - run: ./ci/docfx.cmd - - w3c_trace_context_compliance_v1: - name: W3C Distributed Tracing Validation V1 - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - name: Checkout open-telemetry/opentelemetry-cpp - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: setup - env: - CC: /usr/bin/gcc-12 - CXX: /usr/bin/g++-12 - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: run w3c trace-context test server (background) - env: - CXX_STANDARD: '14' - run: | - ./ci/do_ci.sh cmake.w3c.trace-context.build-server - cd $HOME/build/ext/test/w3c_tracecontext_http_test_server - ./w3c_tracecontext_http_test_server & - - name: Checkout w3c/trace-context repo - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - repository: w3c/trace-context - path: trace-context - - name: install dependencies - run: | - sudo apt update && sudo apt install python3-pip - sudo pip3 install aiohttp==3.11.18 - - name: run w3c trace-context test suite - env: - SPEC_LEVEL: 1 - run: - | - python ${GITHUB_WORKSPACE}/trace-context/test/test.py http://localhost:30000/test TraceContextTest AdvancedTest - curl http://localhost:30000/stop diff --git a/ext/opentelemetry-cpp-1.21.0/.github/workflows/clang-tidy.yaml b/ext/opentelemetry-cpp-1.21.0/.github/workflows/clang-tidy.yaml deleted file mode 100644 index aec027f64b..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/workflows/clang-tidy.yaml +++ /dev/null @@ -1,89 +0,0 @@ -name: clang-tidy - -on: - push: - branches: [main] - pull_request: - branches: [main] - -permissions: - contents: read - -jobs: - clang-tidy: - runs-on: ubuntu-24.04 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: recursive - - - name: Setup Environment - env: - PROTOBUF_VERSION: '23.3' - ABSEIL_CPP_VERSION: '20230125.3' - CXX_STANDARD: '14' - run: | - sudo apt update -y - sudo apt install -y --no-install-recommends --no-install-suggests \ - build-essential \ - iwyu \ - cmake \ - libssl-dev \ - libcurl4-openssl-dev \ - libprotobuf-dev \ - protobuf-compiler \ - libgmock-dev \ - libgtest-dev \ - libbenchmark-dev - - if ! command -v clang-tidy &> /dev/null; then - echo "clang-tidy could not be found" - exit 1 - fi - echo "Using clang-tidy version: $(clang-tidy --version)" - echo "clang-tidy installed at: $(which clang-tidy)" - - - - name: Prepare CMake - env: - CC: clang - CXX: clang++ - run: | - echo "Running cmake..." - cmake -B build \ - -DCMAKE_CXX_STANDARD=14 \ - -DWITH_STL=CXX14 \ - -DWITH_OTLP_HTTP=ON \ - -DWITH_OTLP_FILE=ON \ - -DWITH_PROMETHEUS=ON \ - -DWITH_ZIPKIN=ON \ - -DWITH_ELASTICSEARCH=ON \ - -DWITH_OTLP_HTTP_COMPRESSION=ON \ - -DWITH_EXAMPLES=ON \ - -DWITH_EXAMPLES_HTTP=ON \ - -DBUILD_W3CTRACECONTEXT_TEST=ON \ - -DWITH_METRICS_EXEMPLAR_PREVIEW=ON \ - -DWITH_ASYNC_EXPORT_PREVIEW=ON \ - -DCMAKE_EXPORT_COMPILE_COMMANDS=ON - - - name: Run clang-tidy - run: | - cmake --build build --target opentelemetry_proto - jq -r .[].file build/compile_commands.json | grep -vE '/(generated|third_party)/' | xargs -P $(nproc) -n 1 clang-tidy --quiet -p build 2>&1 | tee -a clang-tidy.log - - - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - with: - name: Logs (clang-tidy) - path: ./clang-tidy.log - - - name: Count warnings - run: | - COUNT=$(grep -c "warning:" clang-tidy.log) - echo "clang-tidy reported ${COUNT} warning(s)" - -# TODO: include WITH_OTLP_GRPC flags. diff --git a/ext/opentelemetry-cpp-1.21.0/.github/workflows/cmake_install.yml b/ext/opentelemetry-cpp-1.21.0/.github/workflows/cmake_install.yml deleted file mode 100644 index c62d7def82..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/workflows/cmake_install.yml +++ /dev/null @@ -1,372 +0,0 @@ -name: CMake Install Tests - -on: - workflow_dispatch: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -permissions: - contents: read - -jobs: - windows_2022_vcpkg_submodule: - name: Windows 2022 vcpkg submodule versions cxx17 (static libs - dll) - runs-on: windows-2022 - env: - # Set to the latest version of cmake 3.x - CMAKE_VERSION: '3.31.6' - # cxx17 is the default for windows-2022 - CXX_STANDARD: '17' - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Build dependencies with vcpkg submodule - run: | - ./ci/setup_cmake.ps1 - ./ci/setup_windows_ci_environment.ps1 - - name: Run Tests - run: ./ci/do_ci.ps1 cmake.install.test - - name: Run DLL Tests - run: ./ci/do_ci.ps1 cmake.dll.install.test - - windows_2019_vcpkg_submodule_min_cmake: - name: Windows 2019 vcpkg submodule versions minimum cmake cxx14 (static libs) - runs-on: windows-2019 - env: - # cmake 3.15 is the minimum for windows builds (See https://github.com/open-telemetry/opentelemetry-cpp/pull/3349#discussion_r2030319430) - CMAKE_VERSION: '3.15.0' - # cxx14 is the default for windows-2019 - CXX_STANDARD: '14' - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Build dependencies with vcpkg submodule - run: | - ./ci/setup_cmake.ps1 - ./ci/setup_windows_ci_environment.ps1 - - name: Run Tests - run: ./ci/do_ci.ps1 cmake.install.test - - ubuntu_2404_system_packages: - name: Ubuntu 24.04 apt packages cxx17 (static libs - shared libs) - runs-on: ubuntu-24.04 - env: - INSTALL_TEST_DIR: '/home/runner/install_test' - # CMake 3.28 is apt package version for Ubuntu 24.04 - CMAKE_VERSION: '3.28.3' - # cxx17 is the default for Ubuntu 24.04 - CXX_STANDARD: '17' - BUILD_TYPE: 'Debug' - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Install libcurl, zlib, nlohmann-json with apt - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: Install abseil, protobuf, and grpc with apt - run: | - sudo -E apt-get update - sudo -E apt-get install -y libabsl-dev libprotobuf-dev libgrpc++-dev protobuf-compiler protobuf-compiler-grpc - - name: Run Tests (static libs) - env: - BUILD_SHARED_LIBS: 'OFF' - run: ./ci/do_ci.sh cmake.install.test - - name: Run Tests (shared libs) - env: - BUILD_SHARED_LIBS: 'ON' - run: ./ci/do_ci.sh cmake.install.test - - ubuntu_2404_latest: - name: Ubuntu 24.04 latest versions cxx20 (static libs) - runs-on: ubuntu-24.04 - env: - INSTALL_TEST_DIR: '/home/runner/install_test' - # Set to the latest version of cmake 3.x - CMAKE_VERSION: '3.31.6' - # Set to the latest cxx standard supported by opentelemetry-cpp - CXX_STANDARD: '20' - # Versions below set to the latest version available - # The abseil and protobuf versions are taken from - # the grpc submodules at the GRPC_VERSION tag - GOOGLETEST_VERSION: '1.16.0' - ABSEIL_CPP_VERSION: '20240722.1' - PROTOBUF_VERSION: '29.0' - GRPC_VERSION: 'v1.71.0' - BUILD_TYPE: 'Debug' - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Install gtest, libcurl, zlib, nlohmann-json with apt - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: Build abseil, protobuf, and grpc with ci scripts - run: | - sudo -E ./ci/install_abseil.sh - sudo -E ./ci/install_protobuf.sh - sudo -E ./ci/setup_grpc.sh -r $GRPC_VERSION -s $CXX_STANDARD -p protobuf -p abseil-cpp - - name: Run Tests (static libs) - env: - BUILD_SHARED_LIBS: 'OFF' - run: ./ci/do_ci.sh cmake.install.test - - ubuntu_2204_stable: - name: Ubuntu 22.04 stable versions cxx17 (static libs - shared libs) - runs-on: ubuntu-22.04 - env: - INSTALL_TEST_DIR: '/home/runner/install_test' - # CMake 3.22 is the apt package version for Ubuntu 22.04 - CMAKE_VERSION: '3.22.0' - CXX_STANDARD: '17' - # These are stable versions tested in the main ci workflow - # and defaults in the devcontainer - GOOGLETEST_VERSION: '1.14.0' - ABSEIL_CPP_VERSION: '20230125.3' - PROTOBUF_VERSION: '23.3' - GRPC_VERSION: 'v1.55.0' - BUILD_TYPE: 'Debug' - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Install gtest, libcurl, zlib, nlohmann-json with apt - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: Build abseil, protobuf, and grpc with ci scripts - run: | - sudo -E ./ci/install_abseil.sh - sudo -E ./ci/install_protobuf.sh - sudo -E ./ci/setup_grpc.sh -r $GRPC_VERSION -s $CXX_STANDARD -p protobuf -p abseil-cpp - - name: Run Tests (static libs) - env: - BUILD_SHARED_LIBS: 'OFF' - run: ./ci/do_ci.sh cmake.install.test - - name: Run Tests (shared libs) - env: - BUILD_SHARED_LIBS: 'ON' - run: ./ci/do_ci.sh cmake.install.test - - ubuntu_2204_minimum: - name: Ubuntu 22.04 minimum versions cxx14 (static libs - shared libs) - runs-on: ubuntu-22.04 - env: - INSTALL_TEST_DIR: '/home/runner/install_test' - # Set to the current minimum version of cmake - CMAKE_VERSION: '3.14.0' - # cxx14 is the default for Ubuntu 22.04 - CXX_STANDARD: '14' - # This is the apt package version of googletest for Ubuntu 22.04 - GOOGLETEST_VERSION: '1.11.0' - # These are minimum versions tested in the main ci workflow - ABSEIL_CPP_VERSION: '20220623.2' - PROTOBUF_VERSION: '21.12' - GRPC_VERSION: 'v1.49.2' - BUILD_TYPE: 'Debug' - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Install gtest, libcurl, zlib, nlohmann-json with apt - run: | - sudo -E ./ci/setup_ci_environment.sh - sudo -E ./ci/setup_cmake.sh - sudo -E ./ci/setup_googletest.sh - - name: Build abseil, protobuf, and grpc with ci scripts - run: | - sudo -E ./ci/install_abseil.sh - sudo -E ./ci/install_protobuf.sh - sudo -E ./ci/setup_grpc.sh -r $GRPC_VERSION -s $CXX_STANDARD -p protobuf -p abseil-cpp - - name: Run Tests (static libs) - env: - BUILD_SHARED_LIBS: 'OFF' - run: ./ci/do_ci.sh cmake.install.test - - name: Run Tests (shared libs) - env: - BUILD_SHARED_LIBS: 'ON' - run: ./ci/do_ci.sh cmake.install.test - - ubuntu_2404_conan_stable: - name: Ubuntu 24.04 conan stable versions cxx17 (static libs - shared libs - opentracing shim) - runs-on: ubuntu-24.04 - env: - INSTALL_TEST_DIR: '/home/runner/install_test' - # CMake 3.28 is apt package version for Ubuntu 24.04 - CMAKE_VERSION: '3.28.3' - CXX_STANDARD: '17' - CMAKE_TOOLCHAIN_FILE: /home/runner/conan/build/Debug/generators/conan_toolchain.cmake - BUILD_TYPE: 'Debug' - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Install Conan - run: | - python3 -m pip install pip==25.0.1 - pip install "conan==2.15.1" - conan profile detect --force - - name: Install or build all dependencies with Conan - run: | - sudo -E ./ci/setup_cmake.sh - conan install install/conan/conanfile_stable.txt --build=missing -of /home/runner/conan -s build_type=${BUILD_TYPE} -s compiler.cppstd=${CXX_STANDARD} - - name: Run Tests (static libs) - env: - BUILD_SHARED_LIBS: 'OFF' - run: ./ci/do_ci.sh cmake.install.test - - name: Run Tests (shared libs) - env: - BUILD_SHARED_LIBS: 'ON' - run: ./ci/do_ci.sh cmake.install.test - - name: verify pkgconfig packages - run: | - export PKG_CONFIG_PATH=$INSTALL_TEST_DIR/lib/pkgconfig:$PKG_CONFIG_PATH - ./ci/verify_packages.sh - - name: Run OpenTracing Shim Test - run: ./ci/do_ci.sh cmake.opentracing_shim.install.test - - ubuntu_2404_conan_latest: - name: Ubuntu 24.04 conan latest versions cxx17 (static libs) - runs-on: ubuntu-24.04 - env: - INSTALL_TEST_DIR: '/home/runner/install_test' - # Set to the latest version of cmake 3.x - CMAKE_VERSION: '3.31.6' - CXX_STANDARD: '17' - CMAKE_TOOLCHAIN_FILE: /home/runner/conan/build/Debug/generators/conan_toolchain.cmake - BUILD_TYPE: 'Debug' - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Install Conan - run: | - python3 -m pip install pip==25.0.1 - pip install "conan==2.15.1" - conan profile detect --force - - name: Install or build all dependencies with Conan - run: | - sudo -E ./ci/setup_cmake.sh - conan install install/conan/conanfile_latest.txt --build=missing -of /home/runner/conan -s build_type=${BUILD_TYPE} -s compiler.cppstd=${CXX_STANDARD} - - name: Run Tests (static libs) - env: - BUILD_SHARED_LIBS: 'OFF' - run: ./ci/do_ci.sh cmake.install.test - - name: verify pkgconfig packages - run: | - export PKG_CONFIG_PATH=$INSTALL_TEST_DIR/lib/pkgconfig:$PKG_CONFIG_PATH - ./ci/verify_packages.sh - - macos_14_conan_stable: - name: macOS 14 conan stable versions cxx17 (static libs) - runs-on: macos-14 - env: - INSTALL_TEST_DIR: '/Users/runner/install_test' - CMAKE_VERSION: '3.28.3' - CXX_STANDARD: '17' - CMAKE_TOOLCHAIN_FILE: '/Users/runner/conan/build/Debug/generators/conan_toolchain.cmake' - BUILD_TYPE: 'Debug' - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Install Conan and tools - run: | - brew install conan autoconf automake libtool coreutils - ./ci/setup_cmake_macos.sh - conan profile detect --force - - name: Install or build all dependencies with Conan - run: conan install install/conan/conanfile_stable.txt --build=missing -of /Users/runner/conan -s build_type=${BUILD_TYPE} -s compiler.cppstd=${CXX_STANDARD} - - name: Run Tests (static libs) - env: - BUILD_SHARED_LIBS: 'OFF' - run: ./ci/do_ci.sh cmake.install.test - - macos_14_brew_packages: - name: macOS 14 brew latest versions cxx17 (static libs) - runs-on: macos-14 - env: - INSTALL_TEST_DIR: '/Users/runner/install_test' - # Set to the latest version of cmake 3.x - CMAKE_VERSION: '3.31.6' - CXX_STANDARD: '17' - BUILD_TYPE: 'Debug' - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Install Dependencies with Homebrew - run: | - ./ci/setup_cmake_macos.sh - brew install coreutils - brew install googletest - brew install google-benchmark - brew install zlib - brew install abseil - brew install protobuf - brew install grpc - brew install nlohmann-json - brew install prometheus-cpp - - name: Run Tests (static libs) - env: - BUILD_SHARED_LIBS: 'OFF' - run: ./ci/do_ci.sh cmake.install.test \ No newline at end of file diff --git a/ext/opentelemetry-cpp-1.21.0/.github/workflows/codeql-analysis.yml b/ext/opentelemetry-cpp-1.21.0/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 9d2fe02d71..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: "CodeQL" - -on: - push: - branches: [main] - pull_request: - # The branches below must be a subset of the branches above - branches: [main] - -permissions: - contents: read - -jobs: - CodeQL-Build: - permissions: - actions: read # for github/codeql-action/init to get workflow details - contents: read # for actions/checkout to fetch code - security-events: write # for github/codeql-action/autobuild to send a status report - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - name: Checkout repository - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - name: Remove Third_party Modules from Code Scan - run: | - rm -rf third_party - - name: Setup - env: - CC: /usr/bin/gcc-12 - CXX: /usr/bin/g++-12 - GOOGLETEST_VERSION: 1.12.1 - run: | - sudo -E ./ci/setup_googletest.sh - sudo -E ./ci/setup_ci_environment.sh - - name: Initialize CodeQL - uses: github/codeql-action/init@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18 - with: - languages: cpp - - name: Autobuild - uses: github/codeql-action/autobuild@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18 - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18 diff --git a/ext/opentelemetry-cpp-1.21.0/.github/workflows/cppcheck.yml b/ext/opentelemetry-cpp-1.21.0/.github/workflows/cppcheck.yml deleted file mode 100644 index 53057354bc..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/workflows/cppcheck.yml +++ /dev/null @@ -1,77 +0,0 @@ - -name: cppcheck - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -permissions: - contents: read - -jobs: - cppcheck: - runs-on: ubuntu-24.04 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - - name: Set up dependencies - run: | - sudo apt update -y - sudo apt install -y cppcheck - - - name: Run cppcheck - run: | - cppcheck --version | tee cppcheck.log - cppcheck \ - --force \ - --enable=warning,performance,portability \ - --inline-suppr \ - --suppress=unknownMacro:exporters/etw/include/opentelemetry/exporters/etw/TraceLoggingDynamic.h \ - --language=c++ \ - --std=c++14 \ - -I api/include \ - -I exporters/elasticsearch/include \ - -I exporters/etw/include \ - -I exporters/memory/include \ - -I exporters/ostream/include \ - -I exporters/otlp/include \ - -I exporters/prometheus/include \ - -I exporters/zipkin/include \ - -I ext/include \ - -I opentracing-shim/include \ - -I sdk/include \ - -i build \ - -i test \ - -i third_party \ - -j $(nproc) \ - . 2>&1 | tee --append cppcheck.log - - - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - if: success() || failure() - with: - name: Logs (cppcheck) - path: ./cppcheck.log - - - name: Count warnings - run: | - set +e - readonly WARNING_COUNT=`grep -c -E "\[.+\]" cppcheck.log` - echo "cppcheck reported ${WARNING_COUNT} warning(s)" - # Acceptable limit, to decrease over time down to 0 - readonly WARNING_LIMIT=10 - # FAIL the build if WARNING_COUNT > WARNING_LIMIT - if [ $WARNING_COUNT -gt $WARNING_LIMIT ] ; then - exit 1 - # WARN in annotations if WARNING_COUNT > 0 - elif [ $WARNING_COUNT -gt 0 ] ; then - echo "::warning::cppcheck reported ${WARNING_COUNT} warning(s)" - fi diff --git a/ext/opentelemetry-cpp-1.21.0/.github/workflows/dependencies_image.yml b/ext/opentelemetry-cpp-1.21.0/.github/workflows/dependencies_image.yml deleted file mode 100644 index 3163dd8ca3..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/workflows/dependencies_image.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: 'OpenTelemetry-cpp dependencies image' -on: - schedule: - - cron: "0 3 * * 6" - -permissions: - contents: read - -jobs: - docker_image: - name: Docker Image - runs-on: ubuntu-latest - timeout-minutes: 300 - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - - name: checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - name: Set up QEMU - uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 - - - name: Build Image - uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 - with: - builder: ${{ steps.buildx.outputs.name }} - context: ci/ - file: ./docker/Dockerfile - build-args: BASE_IMAGE=ubuntu:latest - platforms: linux/amd64 - # platforms: linux/amd64,linux/arm64 - push: false - tags: otel-cpp-deps - load: true - - - name: Save Image - run: | - docker images - docker save -o /opt/otel-cpp-deps-debian.tar otel-cpp-deps - - - name: Upload Image - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - with: - name: otel-cpp-deps - path: /opt/otel-cpp-deps-debian.tar - retention-days: 14 diff --git a/ext/opentelemetry-cpp-1.21.0/.github/workflows/fossa.yml b/ext/opentelemetry-cpp-1.21.0/.github/workflows/fossa.yml deleted file mode 100644 index 8b90aa1671..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/workflows/fossa.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: FOSSA scanning - -on: - push: - branches: - - main - -permissions: - contents: read - -jobs: - fossa: - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - uses: fossas/fossa-action@3ebcea1862c6ffbd5cf1b4d0bd6b3fe7bd6f2cac # v1.7.0 - with: - api-key: ${{secrets.FOSSA_API_KEY}} - team: OpenTelemetry diff --git a/ext/opentelemetry-cpp-1.21.0/.github/workflows/iwyu.yml b/ext/opentelemetry-cpp-1.21.0/.github/workflows/iwyu.yml deleted file mode 100644 index 42881ec6b6..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/workflows/iwyu.yml +++ /dev/null @@ -1,92 +0,0 @@ - -name: include-what-you-use - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -permissions: - contents: read - -jobs: - iwyu: - runs-on: ubuntu-latest - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - submodules: 'recursive' - - - name: setup dependencies - run: | - sudo apt update -y - sudo apt install -y --no-install-recommends --no-install-suggests \ - build-essential \ - iwyu \ - ninja-build \ - libssl-dev \ - libcurl4-openssl-dev \ - libprotobuf-dev \ - protobuf-compiler \ - libgmock-dev \ - libgtest-dev \ - libbenchmark-dev - sudo ./ci/setup_cmake.sh - - - - name: setup grpc - run: | - sudo ./ci/setup_grpc.sh - - - name: Prepare CMake - run: | - TOPDIR=`pwd` - mkdir build && cd build - CC="clang" CXX="clang++" cmake \ - -DCMAKE_CXX_STANDARD=14 \ - -DWITH_STL=CXX14 \ - -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-w;-Xiwyu;--mapping_file=${TOPDIR}/.iwyu.imp;" \ - -DBUILD_TESTING=ON \ - -DBUILD_W3CTRACECONTEXT_TEST=ON \ - -DWITH_OTLP_GRPC=ON \ - -DWITH_OTLP_HTTP=ON \ - -DWITH_OTLP_FILE=ON \ - -DWITH_OPENTRACING=ON \ - -DWITH_OTLP_HTTP_COMPRESSION=ON \ - -DWITH_THREAD_INSTRUMENTATION=ON \ - -DWITH_ZIPKIN=ON \ - -DWITH_PROMETHEUS=ON \ - .. - - - name: iwyu_tool - run: | - cd build - make -k 2>&1 | tee -a iwyu.log - - - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - if: success() || failure() - with: - name: Logs (include-what-you-use) - path: ./build/*.log - - - name: count warnings - run: | - set +e - cd build - readonly WARNING_COUNT=`grep -c "include-what-you-use reported diagnostics:" iwyu.log` - echo "include-what-you-use reported ${WARNING_COUNT} warning(s)" - # Acceptable limit, to decrease over time down to 0 - readonly WARNING_LIMIT=0 - # FAIL the build if WARNING_COUNT > WARNING_LIMIT - if [ $WARNING_COUNT -gt $WARNING_LIMIT ] ; then - exit 1 - # WARN in annotations if WARNING_COUNT > 0 - elif [ $WARNING_COUNT -gt 0 ] ; then - echo "::warning::include-what-you-use reported ${WARNING_COUNT} warning(s)" - fi diff --git a/ext/opentelemetry-cpp-1.21.0/.github/workflows/ossf-scorecard.yml b/ext/opentelemetry-cpp-1.21.0/.github/workflows/ossf-scorecard.yml deleted file mode 100644 index 4ecbe8bf8c..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/workflows/ossf-scorecard.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: OSSF Scorecard - -on: - push: - branches: - - main - schedule: - - cron: "56 23 * * 6" # once a week - workflow_dispatch: - -permissions: read-all - -jobs: - analysis: - runs-on: ubuntu-latest - permissions: - # Needed for Code scanning upload - security-events: write - # Needed for GitHub OIDC token if publish_results is true - id-token: write - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - persist-credentials: false - - - uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1 - with: - results_file: results.sarif - results_format: sarif - publish_results: true - - # Upload the results as artifacts (optional). Commenting out will disable - # uploads of run results in SARIF format to the repository Actions tab. - # https://docs.github.com/en/actions/advanced-guides/storing-workflow-data-as-artifacts - - name: "Upload artifact" - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - with: - name: SARIF file - path: results.sarif - retention-days: 5 - - # Upload the results to GitHub's code scanning dashboard (optional). - # Commenting out will disable upload of results to your repo's Code Scanning dashboard - - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18 - with: - sarif_file: results.sarif diff --git a/ext/opentelemetry-cpp-1.21.0/.github/workflows/project_management_comment.yml b/ext/opentelemetry-cpp-1.21.0/.github/workflows/project_management_comment.yml deleted file mode 100644 index 6e64cf0aac..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/workflows/project_management_comment.yml +++ /dev/null @@ -1,28 +0,0 @@ - -name: Add comment -on: - issues: - types: - - labeled -permissions: - contents: read - -jobs: - add-comment: - if: github.event.label.name == 'help wanted' - runs-on: ubuntu-latest - permissions: - issues: write - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - name: Add comment - uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 - with: - issue-number: ${{ github.event.issue.number }} - body: | - This issue is available for anyone to work on. **Make sure to reference this issue in your pull request.** - :sparkles: Thank you for your contribution! :sparkles: diff --git a/ext/opentelemetry-cpp-1.21.0/.github/workflows/project_management_issue_open.yml b/ext/opentelemetry-cpp-1.21.0/.github/workflows/project_management_issue_open.yml deleted file mode 100644 index 14750d1a67..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/workflows/project_management_issue_open.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: OpenTelemetry-cpp project -on: - issues: - types: - - reopened - - opened -permissions: - contents: read - -jobs: - label_issues: - runs-on: ubuntu-latest - permissions: - issues: write - steps: - - name: Harden the runner (Audit all outbound calls) - uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 - with: - egress-policy: audit - - - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 - with: - script: | - github.rest.issues.addLabels({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - labels: ["needs-triage"] - }) diff --git a/ext/opentelemetry-cpp-1.21.0/.github/workflows/stale.yml b/ext/opentelemetry-cpp-1.21.0/.github/workflows/stale.yml deleted file mode 100644 index 931403638d..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.github/workflows/stale.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: "Mark stale issues" -on: - schedule: - - cron: "30 1 * * *" - -permissions: - contents: read - -jobs: - stale: - permissions: - issues: write # for actions/stale to close stale issues - pull-requests: write # for actions/stale to close stale PRs - runs-on: ubuntu-latest - steps: - - uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0 - with: - stale-issue-message: "This issue was marked as stale due to lack of activity." - days-before-issue-stale: 60 - days-before-close: -1 - exempt-issue-labels: "do-not-stale" diff --git a/ext/opentelemetry-cpp-1.21.0/.gitignore b/ext/opentelemetry-cpp-1.21.0/.gitignore deleted file mode 100644 index 580df5ac31..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.gitignore +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -# Ref. https://github.com/github/gitignore/blob/master/C%2B%2B.gitignore -# Prerequisites -*.d - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll -*.pdb - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app - -# Bazel files -MODULE.bazel.lock -/bazel-* - -# Mac -.DS_Store - -# Output directories -/out -/out.* -# Indicator that the tools were deployed -.buildtools - -# Temporary Bazel directories -/bazel-* -/plugin -/build - -tags -.cache/clangd/* - -# Temporary dir used when generating semconv -buildscripts/semantic-convention/tmp-semconv/ - -# Generated cert keys in functional tests -functional/cert/ca.csr -functional/cert/ca.pem -functional/cert/ca-key.pem -functional/cert/client_cert.csr -functional/cert/client_cert.pem -functional/cert/client_cert-key.pem -functional/cert/server_cert.csr -functional/cert/server_cert.pem -functional/cert/server_cert-key.pem -functional/cert/ca_b.csr -functional/cert/ca_b.pem -functional/cert/ca_b-key.pem -functional/cert/client_cert_b.csr -functional/cert/client_cert_b.pem -functional/cert/client_cert_b-key.pem -functional/cert/server_cert_b.csr -functional/cert/server_cert_b.pem -functional/cert/server_cert_b-key.pem -functional/cert/unreadable.pem - -localinstall \ No newline at end of file diff --git a/ext/opentelemetry-cpp-1.21.0/.gitmodules b/ext/opentelemetry-cpp-1.21.0/.gitmodules deleted file mode 100644 index 88a78e5f94..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.gitmodules +++ /dev/null @@ -1,39 +0,0 @@ -[submodule "third_party/prometheus-cpp"] -path = third_party/prometheus-cpp -url = https://github.com/jupp0r/prometheus-cpp -branch = master - -[submodule "tools/vcpkg"] -path = tools/vcpkg -url = https://github.com/Microsoft/vcpkg -branch = master - -[submodule "third_party/ms-gsl"] -path = third_party/ms-gsl -url = https://github.com/microsoft/GSL -branch = main - -[submodule "third_party/googletest"] -path = third_party/googletest -url = https://github.com/google/googletest -branch = main - -[submodule "third_party/benchmark"] -path = third_party/benchmark -url = https://github.com/google/benchmark -branch = main - -[submodule "third_party/opentelemetry-proto"] -path = third_party/opentelemetry-proto -url = https://github.com/open-telemetry/opentelemetry-proto -branch = main - -[submodule "third_party/nlohmann-json"] -path = third_party/nlohmann-json -url = https://github.com/nlohmann/json -branch = master - -[submodule "third_party/opentracing-cpp"] -path = third_party/opentracing-cpp -url = https://github.com/opentracing/opentracing-cpp.git -branch = master diff --git a/ext/opentelemetry-cpp-1.21.0/.iwyu.imp b/ext/opentelemetry-cpp-1.21.0/.iwyu.imp deleted file mode 100644 index 123e72f32d..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.iwyu.imp +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -# include-what-you-use mapping file - -[ - # Work around for C++ STL - { "include": ["", "private", "", "public"] }, - { "include": ["", "private", "", "public"] }, - { "include": ["", "private", "", "public"] }, - { "include": ["", "private", "", "public"] }, - { "include": ["", "private", "", "public"] }, - - # Local opentelemetry-cpp style - - # We prefer to include for simplicity - { "include": ["", "private", "", "public"] }, - { "include": ["", "private", "", "public"] }, - { "include": ["", "private", "", "public"] }, - { "include": ["", "private", "", "public"] }, - { "include": ["", "private", "", "public"] }, - { "include": ["", "private", "", "public"] }, - - # We prefer to include for simplicity - { "include": ["", "private", "", "public"] }, - { "include": ["", "private", "", "public"] }, - - # We prefer to include for simplicity - { "include": ["", "private", "", "public"] }, -] - diff --git a/ext/opentelemetry-cpp-1.21.0/.markdownlint.json b/ext/opentelemetry-cpp-1.21.0/.markdownlint.json deleted file mode 100644 index 48c2ae2a3f..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.markdownlint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "default": true, - "MD013": - { - "code_blocks": false, - "tables": false - } -} diff --git a/ext/opentelemetry-cpp-1.21.0/.markdownlintignore b/ext/opentelemetry-cpp-1.21.0/.markdownlintignore deleted file mode 100644 index f0cec48dba..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/.markdownlintignore +++ /dev/null @@ -1,3 +0,0 @@ -third_party/** -tools/** -examples/otlp/README.md diff --git a/ext/opentelemetry-cpp-1.21.0/CHANGELOG.md b/ext/opentelemetry-cpp-1.21.0/CHANGELOG.md deleted file mode 100644 index 30c94679ed..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/CHANGELOG.md +++ /dev/null @@ -1,2816 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## Guideline to update the version - -Increment the: - -* MAJOR version when you make incompatible API/ABI changes, -* MINOR version when you add functionality in a backwards compatible manner, and -* PATCH version when you make backwards compatible bug fixes. - -## [Unreleased] - -## [1.21 2025-05-28] - -* [BUILD] Remove WITH_ABSEIL - [#3318](https://github.com/open-telemetry/opentelemetry-cpp/pull/3318) - -* [INSTALL] Add CMake components to the opentelemetry-cpp package - [#3320](https://github.com/open-telemetry/opentelemetry-cpp/pull/3220) - -* [CI] Harden GitHub Actions - [#3338](https://github.com/open-telemetry/opentelemetry-cpp/pull/3338) - -* [StepSecurity] Harden GibHub Actions, part 2 - [#3340](https://github.com/open-telemetry/opentelemetry-cpp/pull/3340) - -* Bump github/codeql-action from 3.28.12 to 3.28.13 - [#3341](https://github.com/open-telemetry/opentelemetry-cpp/pull/3341) - -* [DEVCONTAINER] expose cmake version setting as docker arg and environment variable - [#3347](https://github.com/open-telemetry/opentelemetry-cpp/pull/3347) - -* [CI] disable bzip2 in conan builds - [#3352](https://github.com/open-telemetry/opentelemetry-cpp/pull/3352) - -* [SEMANTIC CONVENTIONS] Upgrade semantic conventions to 1.32.0 - [#3351](https://github.com/open-telemetry/opentelemetry-cpp/pull/3351) - -* Bump github/codeql-action from 3.28.13 to 3.28.15 - [#3353](https://github.com/open-telemetry/opentelemetry-cpp/pull/3353) - -* [CMAKE] bump cmake minimum required version to 3.14 - [#3349](https://github.com/open-telemetry/opentelemetry-cpp/pull/3349) - -* Bump codecov/codecov-action from 5.4.0 to 5.4.2 - [#3362](https://github.com/open-telemetry/opentelemetry-cpp/pull/3362) - -* [DOC] Fix documentation tags in logger API - [#3371](https://github.com/open-telemetry/opentelemetry-cpp/pull/3371) - -* [CI] fix artifacts download/upload - [#3369](https://github.com/open-telemetry/opentelemetry-cpp/pull/3369) - -* [API] Add Enabled method to Tracer - [#3357](https://github.com/open-telemetry/opentelemetry-cpp/pull/3357) - -* [BUILD] Fixes warnings of ciso646 in C++17 - [#3360](https://github.com/open-telemetry/opentelemetry-cpp/pull/3360) - -* Bump github/codeql-action from 3.28.15 to 3.28.16 - [#3377](https://github.com/open-telemetry/opentelemetry-cpp/pull/3377) - -* Bump step-security/harden-runner from 2.11.1 to 2.12.0 - [#3373](https://github.com/open-telemetry/opentelemetry-cpp/pull/3373) - -* Bump docker/build-push-action from 6.15.0 to 6.16.0 - [#3382](https://github.com/open-telemetry/opentelemetry-cpp/pull/3382) - -* Bump actions/download-artifact from 4.2.1 to 4.3.0 - [#3381](https://github.com/open-telemetry/opentelemetry-cpp/pull/3381) - -* [CI] Harden Github actions - pinned-dependencies (part -1) - [#3380](https://github.com/open-telemetry/opentelemetry-cpp/pull/3380) - -* [StepSecurity] ci: Harden GitHub Actions - [#3378](https://github.com/open-telemetry/opentelemetry-cpp/pull/3378) - -* [SDK] Base2 exponential histogram aggregation - [#3346](https://github.com/open-telemetry/opentelemetry-cpp/pull/3346) - -* [StepSecurity] ci: Harden GitHub Actions - [#3379](https://github.com/open-telemetry/opentelemetry-cpp/pull/3379) - -* [BUILD] Fixes glibc++ 5 checking - [#3355](https://github.com/open-telemetry/opentelemetry-cpp/pull/3355) - -* [TEST] Add stress test for histogram metric for multiple threads validation - [#3388](https://github.com/open-telemetry/opentelemetry-cpp/pull/3388) - -* Bump github/codeql-action from 3.28.16 to 3.28.17 - [#3389](https://github.com/open-telemetry/opentelemetry-cpp/pull/3389) - -* [SDK] Optimize PeriodicExportingMetricReader Thread Usage - [#3383](https://github.com/open-telemetry/opentelemetry-cpp/pull/3383) - -* [Metrics SDK] Use nostd::function_ref in AttributesHashMap - [#3393](https://github.com/open-telemetry/opentelemetry-cpp/pull/3393) - -* [SDK] support aggregation of identical instruments - [#3358](https://github.com/open-telemetry/opentelemetry-cpp/pull/3358) - -* [BUILD] Fixes unused var - [#3397](https://github.com/open-telemetry/opentelemetry-cpp/pull/3397) - -* [INSTALL] Unify cmake install functions and dynamically set component dependencies - [#3368](https://github.com/open-telemetry/opentelemetry-cpp/pull/3368) - -* [BUILD] Upgrade nlohmann_json to 3.12.0 - [#3406](https://github.com/open-telemetry/opentelemetry-cpp/pull/3406) - -* [BUILD] Upgrade opentelemetry-proto to 1.6.0 - [#3407](https://github.com/open-telemetry/opentelemetry-cpp/pull/3407) - -* [CMAKE] add generated protobuf headers to the opentelemetry_proto target - [#3400](https://github.com/open-telemetry/opentelemetry-cpp/pull/3400) - -* [MERGE] Fix accidental rollback of nlohmann-json submodule - [#3415](https://github.com/open-telemetry/opentelemetry-cpp/pull/3415) - -* Bump fossas/fossa-action from 1.6.0 to 1.7.0 - [#3414](https://github.com/open-telemetry/opentelemetry-cpp/pull/3414) - -* Bump docker/build-push-action from 6.16.0 to 6.17.0 - [#3420](https://github.com/open-telemetry/opentelemetry-cpp/pull/3420) - -* Bump codecov/codecov-action from 5.4.2 to 5.4.3 - [#3419](https://github.com/open-telemetry/opentelemetry-cpp/pull/3419) - -* [SEMANTIC CONVENTIONS] Upgrade semantic conventions to 1.33 - [#3416](https://github.com/open-telemetry/opentelemetry-cpp/pull/3416) - -* [DOCS] update the INSTALL guide on cmake components - [#3422](https://github.com/open-telemetry/opentelemetry-cpp/pull/3422) - -* Bump github/codeql-action from 3.28.17 to 3.28.18 - [#3423](https://github.com/open-telemetry/opentelemetry-cpp/pull/3423) - -* [CMAKE] update cmake files in examples directory - [#3421](https://github.com/open-telemetry/opentelemetry-cpp/pull/3421) - -* [SDK] Fix Base2ExponentialHistogramAggregation Merge with empty buckets - [#3425](https://github.com/open-telemetry/opentelemetry-cpp/pull/3425) - -* [SDK] Fix MetricProducer interface - [#3413](https://github.com/open-telemetry/opentelemetry-cpp/pull/3413) - -* [CMAKE] remove global include_directories usage and rely on target properties - [#3426](https://github.com/open-telemetry/opentelemetry-cpp/pull/3426) - -* [BUILD] remove unused WITH_CURL build flag - [#3429](https://github.com/open-telemetry/opentelemetry-cpp/pull/3429) - -* [SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.34.0 - [#3428](https://github.com/open-telemetry/opentelemetry-cpp/pull/3428) - -* [EXPORTER] ostream log exporter, fix memory ownership issues - [#3417](https://github.com/open-telemetry/opentelemetry-cpp/pull/3417) - -* [TEST] add all components to the cmake fetch content test - [#3433](https://github.com/open-telemetry/opentelemetry-cpp/pull/3433) - -* [BUILD] Error out when building DLL without MSVC - [#3438](https://github.com/open-telemetry/opentelemetry-cpp/pull/3438) - -* [BUILD] Add missing CMake keyword for target_link_libraries - [#3442](https://github.com/open-telemetry/opentelemetry-cpp/pull/3442) - -* [CMAKE] Remove third-party version mismatch warning - [#3432](https://github.com/open-telemetry/opentelemetry-cpp/pull/3432) - -* Bump docker/build-push-action from 6.17.0 to 6.18.0 - [#3446](https://github.com/open-telemetry/opentelemetry-cpp/pull/3446) - -* [SEMANTIC CONVENTIONS] Fix comment style to preserve markup. - [#3444](https://github.com/open-telemetry/opentelemetry-cpp/pull/3444) - -* [EXPORTER] support unix sockets in grpc client - [#3410](https://github.com/open-telemetry/opentelemetry-cpp/pull/3410) - -* [BUILD] Propagate INTERFACE_COMPILE_DEFINITIONS from API through common_foo_library - [#3440](https://github.com/open-telemetry/opentelemetry-cpp/pull/3440) - -New Features: - -* [SDK] Base2 exponential histogram aggregation - [#3346](https://github.com/open-telemetry/opentelemetry-cpp/pull/3346) - - * Add base2 exponential histogram aggregation. Includes a new aggregation type, - ostream exporter, and otlp/grpc exporter. Updated histogram aggregation and - benchmark tests. - -Important changes: - -* [EXPORTER] ostream log exporter, fixed memory ownership issues - [#3417](https://github.com/open-telemetry/opentelemetry-cpp/pull/3417) - - * In the SDK, the following classes implementation has changed: - - * opentelemetry::sdk::logs::ReadableLogRecord - * opentelemetry::sdk::logs::ReadWriteLogRecord - - * An application implementing a custom log record exporter, - that reuses these classes from the opentelemetry-cpp SDK, - will need code adjustments, in particular for methods: - - * GetBody() - * GetAttributes() - - * Applications not using these SDK classes directly are not affected. - -* [BUILD] Remove WITH_ABSEIL - [#3318](https://github.com/open-telemetry/opentelemetry-cpp/pull/3318) - - * The build option `WITH_ABSEIL` is no longer used, and opentelemetry-cpp - will no longer use any release of abseil provided externally, - for its own use. - - * Instead, opentelemetry-cpp will only use an internal abseil version. - - * This change resolves long standing binary integrity issues, - that occurred in the past when mixing several versions of abseil - in the build. - -## [1.20 2025-04-01] - -* [BUILD] Update opentelemetry-proto version - [#3254](https://github.com/open-telemetry/opentelemetry-cpp/pull/3254) - -* [BUILD] Build break with CURL 7.29.0 - [#3255](https://github.com/open-telemetry/opentelemetry-cpp/pull/3255) - -* [SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.30.0 - [#3258](https://github.com/open-telemetry/opentelemetry-cpp/pull/3258) - -* [SDK] Add tracer scope configurator - [#3137](https://github.com/open-telemetry/opentelemetry-cpp/pull/3137) - -* [DOC] Add document and example for sharing gRPC Client - [#3260](https://github.com/open-telemetry/opentelemetry-cpp/pull/3260) - -* [SDK] Fix BatchLogRecordProcessor to instrument shutdown - [#3262](https://github.com/open-telemetry/opentelemetry-cpp/pull/3262) - -* [SDK] Support OTEL_SDK_DISABLED environment variable - [#3245](https://github.com/open-telemetry/opentelemetry-cpp/pull/3245) - -* [CI] OTLP in Windows builds - [#3263](https://github.com/open-telemetry/opentelemetry-cpp/pull/3263) - -* [BUILD] Fixes compatibility of type_traits - [#3274](https://github.com/open-telemetry/opentelemetry-cpp/pull/3274) - -* [BUILD] Fix compilation with Regex being disabled - [#3276](https://github.com/open-telemetry/opentelemetry-cpp/pull/3276) - -* [EXPORTER] Support exporting event_name using OTLP Exporter - [#3277](https://github.com/open-telemetry/opentelemetry-cpp/pull/3277) - -* [CI] Add FOSSA scanning workflow - [#3279](https://github.com/open-telemetry/opentelemetry-cpp/pull/3279) - -* [BUILD] Adding typecast without whom c++latest build fails - [#3281](https://github.com/open-telemetry/opentelemetry-cpp/pull/3281) - -* [ADMIN] Add FOSSA badges - [#3280](https://github.com/open-telemetry/opentelemetry-cpp/pull/3280) - -* [BUILD] Fix compiling problems with abiv2 and MSVC - [#3284](https://github.com/open-telemetry/opentelemetry-cpp/pull/3284) - -* [BUILD] Enable old behavior of CMP0092 - [#3269](https://github.com/open-telemetry/opentelemetry-cpp/pull/3269) - -* [SDK] Add meter scope configurator - [#3268](https://github.com/open-telemetry/opentelemetry-cpp/pull/3268) - -* [DEVCONTAINER] Support customization and run as non-root user - [#3270](https://github.com/open-telemetry/opentelemetry-cpp/pull/3270) - -* [ETW] Add configuration to export 64-bit integer as timestamp - [#3286](https://github.com/open-telemetry/opentelemetry-cpp/pull/3286) - -* [API] Deprecate event logger - [#3285](https://github.com/open-telemetry/opentelemetry-cpp/pull/3285) - -* [BUILD] Add link directory to support curl 8.12 - [#3272](https://github.com/open-telemetry/opentelemetry-cpp/pull/3272) - -* [API] Change the param-pack unpacking order to start from left to right - [#3296](https://github.com/open-telemetry/opentelemetry-cpp/pull/3296) - -* [SDK] Implement spec: MetricFilter - [#3235](https://github.com/open-telemetry/opentelemetry-cpp/pull/3235) - -* [SEMANTIC CONVENTIONS] Upgrade semantic conventions to 1.31.0 - [#3297](https://github.com/open-telemetry/opentelemetry-cpp/pull/3297) - -* [SDK] Add logger scope configurator - [#3282](https://github.com/open-telemetry/opentelemetry-cpp/pull/3282) - -* [EXAMPLE] fix buffer overrun in the gRPC sample project - [#3304](https://github.com/open-telemetry/opentelemetry-cpp/pull/3304) - -* [CI] Bump fossas/fossa-action from 1.5.0 to 1.6.0 - [#3305](https://github.com/open-telemetry/opentelemetry-cpp/pull/3305) - -* [TEST] fix segfault in singleton test with cmake on macos-latest - [#3316](https://github.com/open-telemetry/opentelemetry-cpp/pull/3316) - -* [TEST] fix test failure with elasticsearch exporter on cxx20 - [#3308](https://github.com/open-telemetry/opentelemetry-cpp/pull/3308) - -* [TEST] otlp grpc exporter retry test fix - [#3311](https://github.com/open-telemetry/opentelemetry-cpp/pull/3311) - -* [SDK] Use OPENTELEMETRY_EXPORT and static local variables - [#3314](https://github.com/open-telemetry/opentelemetry-cpp/pull/3314) - -* [BUILD] Fix elasticsearch exporter json compatibility - [#3313](https://github.com/open-telemetry/opentelemetry-cpp/pull/3313) - -* [BUILD] Fix missing exported definition for OTLP file exporter and forceflush - [#3319](https://github.com/open-telemetry/opentelemetry-cpp/pull/3319) - -* [BUILD] Remove gRPC header including in OtlpGrpcClientFactory - [#3321](https://github.com/open-telemetry/opentelemetry-cpp/pull/3321) - -* [ADMIN] Add Pranav Sharma in cpp-approvers - [#3323](https://github.com/open-telemetry/opentelemetry-cpp/pull/3323) - -* [DEVCONTAINER] fix grpc install - [#3325](https://github.com/open-telemetry/opentelemetry-cpp/pull/3325) - -* [ADMIN] Add dbarker to approvers - [#3331](https://github.com/open-telemetry/opentelemetry-cpp/pull/3331) - -* [CI] Upgrade CI to ubuntu 22.04 - [#3330](https://github.com/open-telemetry/opentelemetry-cpp/pull/3330) - -* [CI] Add ossf-scorecard scanning workflow - [#3332](https://github.com/open-telemetry/opentelemetry-cpp/pull/3332) - -* [CI] pin cmake in ci and devcontainer - [#3336](https://github.com/open-telemetry/opentelemetry-cpp/pull/3336) - -* [METRICS SDK] Fix hash collision in MetricAttributes - [#3322](https://github.com/open-telemetry/opentelemetry-cpp/pull/3322) - -Important changes: - -* [SDK] Support OTEL_SDK_DISABLED environment variable - [#3245](https://github.com/open-telemetry/opentelemetry-cpp/pull/3245) - - * The SDK now exposes the following new methods: - - * opentelemetry::sdk::trace::Provider::SetTracerProvider() - * opentelemetry::sdk::metrics::Provider::SetMeterProvider() - * opentelemetry::sdk::logs::Provider::SetLoggerProvider() - - * These methods do support the `OTEL_SDK_DISABLED` environment variable, - unlike the corresponding existing API Provider classes. - - * Applications are encouraged to migrate from the API to the SDK - `Provider` classes, to benefit from this feature. - - * All the example code has been updated to reflect the new usage. - -## [1.19 2025-01-22] - -* [PROMETHEUS_EXPORTER] Fix default for emitting otel_scope attributes - [#3171](https://github.com/open-telemetry/opentelemetry-cpp/pull/3171) - -* [Code health] Include what you use cleanup, part 5 - [#3140](https://github.com/open-telemetry/opentelemetry-cpp/pull/3140) - -* [BUILD] Upgrade cmake - [#3167](https://github.com/open-telemetry/opentelemetry-cpp/pull/3167) - -* [SHIM] Fix string_view mappings between OT and OTel - [#3181](https://github.com/open-telemetry/opentelemetry-cpp/pull/3181) - -* [EXPORTER] Refactor ElasticSearchRecordable - [#3164](https://github.com/open-telemetry/opentelemetry-cpp/pull/3164) - -* [SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.29.0 - [#3182](https://github.com/open-telemetry/opentelemetry-cpp/pull/3182) - -* [BUILD] Fix cross-compilation with protoc - [#3186](https://github.com/open-telemetry/opentelemetry-cpp/pull/3186) - -* [Code health] Perform cppcheck cleanup - [#3150](https://github.com/open-telemetry/opentelemetry-cpp/pull/3150) - -* [EXPORTER] add instrumentation scope attributes - to otlp proto messages for traces and metrics - [#3185](https://github.com/open-telemetry/opentelemetry-cpp/pull/3185) - -* [SDK] Tracer provider shutdown blocks in-definitively - [#3191](https://github.com/open-telemetry/opentelemetry-cpp/pull/3191) - -* [SEMANTIC CONVENTIONS] Upgrade to weaver 0.11.0 - [#3194](https://github.com/open-telemetry/opentelemetry-cpp/pull/3194) - -* [DOC] Update existing maintaining dependencies doc - [#3195](https://github.com/open-telemetry/opentelemetry-cpp/pull/3195) - -* [TEST] Change is_called_ and got_response_ to use atomic - [#3204](https://github.com/open-telemetry/opentelemetry-cpp/pull/3204) - -* [SEMANTIC CONVENTIONS] update links to openmetrics to reference the v1.0.0 release - [#3205](https://github.com/open-telemetry/opentelemetry-cpp/pull/3205) - -* [CI] Fix CI on ubuntu-latest - [#3207](https://github.com/open-telemetry/opentelemetry-cpp/pull/3207) - -* [BUILD] Build break using protoc 3.14 - [#3211](https://github.com/open-telemetry/opentelemetry-cpp/pull/3211) - -* [TEST] Build the singleton test on windows - [#3183](https://github.com/open-telemetry/opentelemetry-cpp/pull/3183) - -* [BUILD] Add cxx feature detections - [#3203](https://github.com/open-telemetry/opentelemetry-cpp/pull/3203) - -* [SDK] Do not frequently create and destroy http client threads - [#3198](https://github.com/open-telemetry/opentelemetry-cpp/pull/3198) - -* [EXPORTER] Optimize OTLP HTTP compression - [#3178](https://github.com/open-telemetry/opentelemetry-cpp/pull/3178) - -* [SDK] Fix include instrumentation scope attributes in equal method - [#3214](https://github.com/open-telemetry/opentelemetry-cpp/pull/3214) - -* Upgrade to opentelemetry-proto 1.5.0 - [#3210](https://github.com/open-telemetry/opentelemetry-cpp/pull/3210) - -* [TEST] Added support for SELINUX in functional tests - [#3212](https://github.com/open-telemetry/opentelemetry-cpp/pull/3212) - -* [EDITORIAL] fix changelog entry for PR 3185 - [#3217](https://github.com/open-telemetry/opentelemetry-cpp/pull/3217) - -* [TEST] Functional tests for OTLP/gRPC with mutual TLS - [#3227](https://github.com/open-telemetry/opentelemetry-cpp/pull/3227) - -* [SEMCONV] Metrics are incorrectly prefixed with 'metric' - [#3228](https://github.com/open-telemetry/opentelemetry-cpp/pull/3228) - -* [BUILD] Add OTLP/file exporter for dll and examples - [#3231](https://github.com/open-telemetry/opentelemetry-cpp/pull/3231) - -* [Code Health] Include what you use, part 6 - [#3216](https://github.com/open-telemetry/opentelemetry-cpp/pull/3216) - -* [CI] Spurious test failures - [#3233](https://github.com/open-telemetry/opentelemetry-cpp/pull/3233) - -* [BUILD] Fix error ‘uint8_t’ does not name a type with gcc-15 - [#3240](https://github.com/open-telemetry/opentelemetry-cpp/pull/3240) - -* [EXPORTER] fix throw in OtlpGrpcMetricExporter with shared grpc client - [#3243](https://github.com/open-telemetry/opentelemetry-cpp/pull/3243) - -* [SDK] Better control of threads executed by opentelemetry-cpp - [#3175](https://github.com/open-telemetry/opentelemetry-cpp/pull/3175) - -* [Code Health] Include what you use, part 7 - [#3238](https://github.com/open-telemetry/opentelemetry-cpp/pull/3238) - -* [SDK] Fix lifetime of GlobalLogHandler - [#3221](https://github.com/open-telemetry/opentelemetry-cpp/pull/3221) - -* [MAINTAINER] Add devcontainer - [#3123](https://github.com/open-telemetry/opentelemetry-cpp/pull/3123) - -* [SDK] enable deriving from ResourceDetector to create a Resource - [#3247](https://github.com/open-telemetry/opentelemetry-cpp/pull/3247) - -* [EXPORTER] Support handling retry-able errors for OTLP/HTTP - [#3223](https://github.com/open-telemetry/opentelemetry-cpp/pull/3223) - -* [CI] Add GRPC in maintainer CI - [#3248](https://github.com/open-telemetry/opentelemetry-cpp/pull/3248) - -* [EXPORTER] Support handling retry-able errors for OTLP/gRPC - [#3219](https://github.com/open-telemetry/opentelemetry-cpp/pull/3219) - -* [SDK] Optimize Metric Processing for Single Collector with Delta Temporality - [#3236](https://github.com/open-telemetry/opentelemetry-cpp/pull/3236) - -New features: - -* [SDK] Better control of threads executed by opentelemetry-cpp - [#3175](https://github.com/open-telemetry/opentelemetry-cpp/pull/3175) - - * This feature provides a way for applications, - when configuring the SDK and exporters, - to participate in the execution path - of internal opentelemetry-cpp threads. - - * The opentelemetry-cpp library provides the following: - - * a new ThreadInstrumentation interface, - * new runtime options structures, to optionally configure the SDK: - * BatchSpanProcessorRuntimeOptions - * PeriodicExportingMetricReaderRuntimeOptions - * BatchLogRecordProcessorRuntimeOptions - * new runtime options structures, - to optionally configure the OTLP HTTP exporters: - * OtlpHttpExporterRuntimeOptions - * OtlpHttpMetricExporterRuntimeOptions - * OtlpHttpLogRecordExporterRuntimeOptions - * new ThreadInstrumentation parameters, - to optionally configure the CURL HttpClient - * new runtime options structures, - to optionally configure the OTLP FILE exporters: - * OtlpFileExporterRuntimeOptions - * OtlpFileMetricExporterRuntimeOptions - * OtlpFileLogRecordExporterRuntimeOptions - * new runtime options structure, - to optionally configure the OTLP FILE client: - * OtlpFileClientRuntimeOptions - - * Using the optional runtime options structures, - an application can subclass the ThreadInstrumentation interface, - and be notified of specific events of interest during the execution - of an internal opentelemetry-cpp thread. - - * This allows an application to call, for example: - - * pthread_setaffinity_np(), for better performances, - * setns(), to control the network namespace used by HTTP CURL connections - * pthread_setname_np(), for better observability from the operating system - * many more specific apis, as needed - - * See the documentation for ThreadInstrumentation for details. - - * A new example program, example_otlp_instrumented_http, - shows how to use the feature, - and add application logic in the thread execution code path. - - * Note that this feature is experimental, - protected by a WITH_THREAD_INSTRUMENTATION_PREVIEW - flag in CMake. Various runtime options structures, - as well as the thread instrumentation interface, - may change without notice before this feature is declared stable. - -* [EXPORTER] Support handling retry-able errors for OTLP/HTTP - [#3223](https://github.com/open-telemetry/opentelemetry-cpp/pull/3223) - - * This feature is experimental, - protected by a WITH_OTLP_RETRY_PREVIEW - flag in CMake. - -* [EXPORTER] Support handling retry-able errors for OTLP/gRPC - [#3219](https://github.com/open-telemetry/opentelemetry-cpp/pull/3219) - - * This feature is experimental, - protected by a WITH_OTLP_RETRY_PREVIEW - flag in CMake. - -## [1.18 2024-11-25] - -* [EXPORTER] Fix crash in ElasticsearchLogRecordExporter - [#3082](https://github.com/open-telemetry/opentelemetry-cpp/pull/3082) - -* [BUILD] Avoid buggy warning with gcc <= 8 - [#3087](https://github.com/open-telemetry/opentelemetry-cpp/pull/3087) - -* [API] Jaeger Propagator should not be deprecated - [#3086](https://github.com/open-telemetry/opentelemetry-cpp/pull/3086) - -* Update bzlmod version - [#3093](https://github.com/open-telemetry/opentelemetry-cpp/pull/3093) - -* [BUILD] Remove std::make_unique - [#3098](https://github.com/open-telemetry/opentelemetry-cpp/pull/3098) - -* [BUILD] Fix compiling problems for gcc 4.8 - [#3100](https://github.com/open-telemetry/opentelemetry-cpp/pull/3100) - -* [TEST] Fix linking order and gmock linking - [#3106](https://github.com/open-telemetry/opentelemetry-cpp/pull/3106) - -* [EXPORTER] Add config options to prometheus exporter - [#3104](https://github.com/open-telemetry/opentelemetry-cpp/pull/3104) - -* [BUILD] Add a CMake option to disable shared libs - [#3095](https://github.com/open-telemetry/opentelemetry-cpp/pull/3095) - -* [EXPORTER] Remove out of date ETW exporter doc - [#3103](https://github.com/open-telemetry/opentelemetry-cpp/pull/3103) - -* [EXPORTER] Add logging for async gRPC errors - [#3108](https://github.com/open-telemetry/opentelemetry-cpp/pull/3108) - -* [BUILD] Remove aligned_storage from nostd - [#3112](https://github.com/open-telemetry/opentelemetry-cpp/pull/3112) - -* [EXPORTER] Elastic Search exporter follow ECS guidelines - [#3107](https://github.com/open-telemetry/opentelemetry-cpp/pull/3107) - -* [INSTALL] Resolve dependencies in opentelemetry-cpp-config.cmake - [#3094](https://github.com/open-telemetry/opentelemetry-cpp/pull/3094) - -* [API] Add synchronous gauge - [#3029](https://github.com/open-telemetry/opentelemetry-cpp/pull/3029) - -* [BUILD] allow building with -DWITH_OTLP_HTTP_COMPRESSION=OFF without zlib - [#3120](https://github.com/open-telemetry/opentelemetry-cpp/pull/3120) - -* [CI] Comment the arm64 CI - [#3125](https://github.com/open-telemetry/opentelemetry-cpp/pull/3125) - -* [API] Comply with W3C Trace Context - [#3115](https://github.com/open-telemetry/opentelemetry-cpp/pull/3115) - -* [EXPORTER] bump prometheus to v1.3.0 - [#3122](https://github.com/open-telemetry/opentelemetry-cpp/pull/3122) - -* [EXPORTER] Log SSL Connection Information - [#3113](https://github.com/open-telemetry/opentelemetry-cpp/pull/3113) - -* [BUILD] Improve how to handle yield() in ARM - [#3129](https://github.com/open-telemetry/opentelemetry-cpp/pull/3129) - -* [BUILD] Fix -Wmissing-template-arg-list-after-template-kw warning - [#3133](https://github.com/open-telemetry/opentelemetry-cpp/pull/3133) - -* [EXPORTER]: Elasticsearch exporter put log resource in root instead of under 'resources' - [#3131](https://github.com/open-telemetry/opentelemetry-cpp/pull/3131) - -* [TEST] Rename w3c_tracecontext_test to w3c_tracecontext_http_test_server - [#3132](https://github.com/open-telemetry/opentelemetry-cpp/pull/3132) - -* [BUILD] Patches for building on AIX - [#3127](https://github.com/open-telemetry/opentelemetry-cpp/pull/3127) - -* [SEMANTIC CONVENTIONS] Migration to weaver - [#3105](https://github.com/open-telemetry/opentelemetry-cpp/pull/3105) - -* [SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.28.0 - [#3139](https://github.com/open-telemetry/opentelemetry-cpp/pull/3139) - -* [EXPORTER] handling of invalid ports in UrlParser - [#3142](https://github.com/open-telemetry/opentelemetry-cpp/pull/3142) - -* [CI] speed up clang-tidy workflow - [#3148](https://github.com/open-telemetry/opentelemetry-cpp/pull/3148) - -* [EXPORTER] Allow to share gRPC clients between OTLP exporters - [#3041](https://github.com/open-telemetry/opentelemetry-cpp/pull/3041) - -* Bump codecov/codecov-action from 4 to 5 - [#3143](https://github.com/open-telemetry/opentelemetry-cpp/pull/3143) - -* [CI] Add cppcheck in the build - [#3151](https://github.com/open-telemetry/opentelemetry-cpp/pull/3151) - -* [BUILD] Fix error message - [#3152](https://github.com/open-telemetry/opentelemetry-cpp/pull/3152) - -* [EXPORTER] fix clang-tidy warnings in UrlParser - [#3146](https://github.com/open-telemetry/opentelemetry-cpp/pull/3146) - -* [EXPORTER] Upgrade to opentelemetry-proto 1.4.0 - [#3157](https://github.com/open-telemetry/opentelemetry-cpp/pull/3157) - -* [TEST] refactor UrlParser tests to use value-paramterized tests - [#3153](https://github.com/open-telemetry/opentelemetry-cpp/pull/3153) - -* [TEST] add a test for ElasticSearchRecordable - [#3154](https://github.com/open-telemetry/opentelemetry-cpp/pull/3154) - -* [BUILD] Fix missing dependency on protoc compiler - [#3159](https://github.com/open-telemetry/opentelemetry-cpp/pull/3159) - -* [bazel] Update prometheus-cpp in MODULE.bazel - [#3162](https://github.com/open-telemetry/opentelemetry-cpp/pull/3162) - -* [bazel] Enable --incompatible_disallow_empty_glob - [#2642](https://github.com/open-telemetry/opentelemetry-cpp/pull/2642) - -* [INSTALL] Fix cmake/opentelemetry-cpp-config.cmake.in - [#3165](https://github.com/open-telemetry/opentelemetry-cpp/pull/3165) - -* [BUILD] Do not set OTELCPP_PROTO_PATH in the CMake cache - [#3160](https://github.com/open-telemetry/opentelemetry-cpp/pull/3160) - -* [BUILD] Fix build for esp32 - [#3155](https://github.com/open-telemetry/opentelemetry-cpp/pull/3155) - -* [bazel] Update opentelemetry-proto in MODULE.bazel - [#3163](https://github.com/open-telemetry/opentelemetry-cpp/pull/3163) - -Important changes: - -* [API] Jaeger Propagator should not be deprecated - [#3086](https://github.com/open-telemetry/opentelemetry-cpp/pull/3086) - - * Deprecation of the Jaeger propagator, as announced on 2023-01-31 - in version 1.8.2, is now reverted. - * This deprecation turned out to be not justified, - as the Jaeger propagator can be used without the (now removed) - Jaeger exporter. - -* [EXPORTER] Change log resources location for ElasticsearchLogRecordExporter - [#3119](https://github.com/open-telemetry/opentelemetry-cpp/pull/3131) - - * Moved from `root/resources` to `root` - -* [SEMANTIC CONVENTIONS] Migration to weaver - [#3105](https://github.com/open-telemetry/opentelemetry-cpp/pull/3105) - - * `semantic_convention.h` header files are deprecated, - replaced by `semconv/xxx_attributes.h` header files, - for each `xxx` semantic attribute group. - * See file DEPRECATED.md for details. - -Deprecations: - -* This release contains deprecations, see file DEPRECATED.md for details. - -## [1.17 2024-10-07] - -* [CI] Add a clang-tidy build - [#3001](https://github.com/open-telemetry/opentelemetry-cpp/pull/3001) - -* [BUILD] Upgrade to opentelemetry-proto 1.3.2 - [#2991](https://github.com/open-telemetry/opentelemetry-cpp/pull/2991) - -* [REMOVAL] Remove build option `WITH_DEPRECATED_SDK_FACTORY` - [#2717](https://github.com/open-telemetry/opentelemetry-cpp/pull/2717) - -* [EXPORTER] ForceFlush before canceling the running requests on shutdown - [#2727](https://github.com/open-telemetry/opentelemetry-cpp/pull/2727) - -* [SDK] Fix crash in PeriodicExportingMetricReader - [#2983](https://github.com/open-telemetry/opentelemetry-cpp/pull/2983) - -* [SDK] Fix memory leak in TlsRandomNumberGenerator() constructor - [#2661](https://github.com/open-telemetry/opentelemetry-cpp/pull/2661) - -* [EXPORTER] Ignore exception when create thread in OTLP file exporter - [#3012](https://github.com/open-telemetry/opentelemetry-cpp/pull/3012) - -* [BUILD] Update the version in MODULE.bazel - [#3015](https://github.com/open-telemetry/opentelemetry-cpp/pull/3015) - -* [BUILD] Fix build without vcpkg on Windows when gRPC is disabled - [#3016](https://github.com/open-telemetry/opentelemetry-cpp/pull/3016) - -* [BUILD] Add abi_version_no bazel flag - [#3020](https://github.com/open-telemetry/opentelemetry-cpp/pull/3020) - -* [Code health] Expand iwyu coverage to include unit tests - [#3022](https://github.com/open-telemetry/opentelemetry-cpp/pull/3022) - -* [BUILD] Version opentelemetry_proto/proto_grpc shared libraries - [#2992](https://github.com/open-telemetry/opentelemetry-cpp/pull/2992) - -* [SEMANTIC CONVENTIONS] Upgrade semantic conventions to 1.27.0 - [#3023](https://github.com/open-telemetry/opentelemetry-cpp/pull/3023) - -* [SDK] Support empty histogram buckets - [#3027](https://github.com/open-telemetry/opentelemetry-cpp/pull/3027) - -* [TEST] Fix sync problems in OTLP File exporter tests - [#3031](https://github.com/open-telemetry/opentelemetry-cpp/pull/3031) - -* [SDK] PeriodicExportingMetricReader: future is never set, blocks until timeout - [#3030](https://github.com/open-telemetry/opentelemetry-cpp/pull/3030) - -* [Code Health] Clang Tidy cleanup, Part 2 - [#3038](https://github.com/open-telemetry/opentelemetry-cpp/pull/3038) - -* [Code Health] include-what-you-use cleanup, part 3 - [#3004](https://github.com/open-telemetry/opentelemetry-cpp/pull/3004) - -* [SDK] Fix overflow in timeout logic - [#3046](https://github.com/open-telemetry/opentelemetry-cpp/pull/3046) - -* [TEST] Add missing tests to Bazel build - [#3045](https://github.com/open-telemetry/opentelemetry-cpp/pull/3045) - -* [TEST] update collector tests with debug exporter - [#3050](https://github.com/open-telemetry/opentelemetry-cpp/pull/3050) - -* [EXAMPLE] update collector example with debug exporter - [#3049](https://github.com/open-telemetry/opentelemetry-cpp/pull/3049) - -* [TEST] update references to logging exporter - [#3053](https://github.com/open-telemetry/opentelemetry-cpp/pull/3053) - -* [EXAMPLE] Clean the tracer initialization in OStream example - [#3051](https://github.com/open-telemetry/opentelemetry-cpp/pull/3051) - -* [EXPORTER] Fix the format of SpanLink for ETW - [#3054](https://github.com/open-telemetry/opentelemetry-cpp/pull/3054) - -* [EXPORTER] Add in-memory metric exporter - [#3043](https://github.com/open-telemetry/opentelemetry-cpp/pull/3043) - -* [Code Health] include-what-you-use cleanup, part 4 - [#3040](https://github.com/open-telemetry/opentelemetry-cpp/pull/3040) - -* [BUILD] add loongarch info - [#3052](https://github.com/open-telemetry/opentelemetry-cpp/pull/3052) - -* [CI] Update otel-collector version - [#3067](https://github.com/open-telemetry/opentelemetry-cpp/pull/3067) - -* [SDK] Update MetricProducer interface to match spec - [#3044](https://github.com/open-telemetry/opentelemetry-cpp/pull/3044) - -* [EXPORTER] Fix URL in ES exporter, fix ipv6 supporting for http client - [#3081](https://github.com/open-telemetry/opentelemetry-cpp/pull/3081) - -* [EXPORTER] Add HttpHeaders in ElasticsearchLogRecordExporter - [#3083](https://github.com/open-telemetry/opentelemetry-cpp/pull/3083) - -Breaking changes: - -* [REMOVAL] Remove build option `WITH_DEPRECATED_SDK_FACTORY` - [#2717](https://github.com/open-telemetry/opentelemetry-cpp/pull/2717) - - * As announced in opentelemetry-cpp previous release 1.16.0, - CMake option `WITH_DEPRECATED_SDK_FACTORY` was temporary, - and to be removed by the next release. - * This option is now removed. - * Code configuring the SDK must be adjusted, as previously described: - - * [API/SDK] Provider cleanup - [#2664](https://github.com/open-telemetry/opentelemetry-cpp/pull/2664) - - * Before this fix: - * SDK factory methods such as: - * opentelemetry::sdk::trace::TracerProviderFactory::Create() - * opentelemetry::sdk::metrics::MeterProviderFactory::Create() - * opentelemetry::sdk::logs::LoggerProviderFactory::Create() - * opentelemetry::sdk::logs::EventLoggerProviderFactory::Create() - - returned an API object (opentelemetry::trace::TracerProvider) - to the caller. - - * After this fix, these methods return an SDK level object - (opentelemetry::sdk::trace::TracerProvider) to the caller. - * Returning an SDK object is necessary for the application to - cleanup and invoke SDK level methods, such as ForceFlush(), - on a provider. - * The application code that configures the SDK, by calling - the various provider factories, may need adjustment. - * All the examples have been updated, and in particular no - longer perform static_cast do convert an API object to an SDK object. - Please refer to examples for guidance on how to adjust. - -## [1.16.1 2024-07-17] - -* [BUILD] Add bazel missing BUILD file - [#2720](https://github.com/open-telemetry/opentelemetry-cpp/pull/2720) - -* [SDK] Added reserve for spans array in BatchSpanProcessor. - [#2724](https://github.com/open-telemetry/opentelemetry-cpp/pull/2724) - -* [DOC] Update "Using triplets" section in building-with-vcpkg documentation. - [#2726](https://github.com/open-telemetry/opentelemetry-cpp/pull/2726) - -* [DOC] Remove comment for unused LoggerProvider initialization params - [#2972](https://github.com/open-telemetry/opentelemetry-cpp/pull/2972) - -* [SECURITY] Remove OTLP HTTP support for TLS 1.0 and TLS 1.1, - require TLS 1.2 or better - [#2722](https://github.com/open-telemetry/opentelemetry-cpp/pull/2722) - -* [TEST] Fix opentelemetry-collector bind address - [#2989](https://github.com/open-telemetry/opentelemetry-cpp/pull/2989) - -* [EXPORTER] Fix references in AttributeValueVisitor - [#2985](https://github.com/open-telemetry/opentelemetry-cpp/pull/2985) - -* [Code health] include-what-you-use cleanup, part 2 - [#2704](https://github.com/open-telemetry/opentelemetry-cpp/pull/2704) - -* [Code Health] clang-tidy cleanup, part 1 - [#2990](https://github.com/open-telemetry/opentelemetry-cpp/pull/2990) - -* [CI] Build failures with ABSEIL 20240116 and CMAKE 3.30 - [#3002](https://github.com/open-telemetry/opentelemetry-cpp/pull/3002) - -* [CI] Enable bzlmod - [#2995](https://github.com/open-telemetry/opentelemetry-cpp/pull/2995) - -* [Metrics SDK] Fix hash calculation for nostd::string - [#2999](https://github.com/open-telemetry/opentelemetry-cpp/pull/2999) - -Breaking changes: - -* [SECURITY] Remove OTLP HTTP support for TLS 1.0 and TLS 1.1, - require TLS 1.2 or better - [#2722](https://github.com/open-telemetry/opentelemetry-cpp/pull/2722) - * The OTLP HTTP exporter no longer accept options like: - * min_TLS = 1.0 - * min_TLS = 1.1 - * max_TLS = 1.0 - * max_TLS = 1.1 - * When connecting to an OTLP HTTP endpoint, using `https`, - the connection will require TLS 1.2 by default, - unless min_TLS is set to 1.3 - * Plain `http` connections (insecure) are not affected. - -## [1.16.0] 2024-06-21 - -* [BUILD] Upgrade bazel abseil from 20220623.1 to 20230802.2 - [#2650](https://github.com/open-telemetry/opentelemetry-cpp/pull/2650) -* [BUILD] Use nostd::enable_if_t instead of std::enable_if_t - [#2648](https://github.com/open-telemetry/opentelemetry-cpp/pull/2648) -* [EXEMPLAR] Update ExemplarFilter and ExemplarReservoir for spec - [#2372](https://github.com/open-telemetry/opentelemetry-cpp/pull/2372) -* [BUILD] Link CoreFoundation on apple systems - [#2655](https://github.com/open-telemetry/opentelemetry-cpp/pull/2655) -* [SDK] Avoid missing conditional variable update and simplify atomic bool - [#2553](https://github.com/open-telemetry/opentelemetry-cpp/pull/2553) -* [BUILD] Build break in OLTP_FILE tests - [#2659](https://github.com/open-telemetry/opentelemetry-cpp/pull/2659) -* [EXPORTER] General cleanup for is_shutdown flags in exporters. - [#2663](https://github.com/open-telemetry/opentelemetry-cpp/pull/2663) -* [CI] Upgrade Maintainers CI to ubuntu-24.04 - [#2670](https://github.com/open-telemetry/opentelemetry-cpp/pull/2670) -* [BUILD] Upgrade to opentelemetry-proto 1.3.1 - [#2669](https://github.com/open-telemetry/opentelemetry-cpp/pull/2669) -* [API] Return NoopLogRecord from NoopLogger - [#2668](https://github.com/open-telemetry/opentelemetry-cpp/pull/2668) -* [BUILD] Remove the hard-coded separator in tracestate - [#2672](https://github.com/open-telemetry/opentelemetry-cpp/pull/2672) -* [SDK] Fix forceflush may wait for ever - [#2584](https://github.com/open-telemetry/opentelemetry-cpp/pull/2584) -* [API] DO not allow unsafe Logger::EmitLogRecord - [#2673](https://github.com/open-telemetry/opentelemetry-cpp/pull/2673) -* [BUILD] Read default proto version from third_party_release - [#2677](https://github.com/open-telemetry/opentelemetry-cpp/pull/2677) -* [CI] include-what-you-use - [#2629](https://github.com/open-telemetry/opentelemetry-cpp/pull/2629) -* [CI] Upgrade to clang-format 18 - [#2684](https://github.com/open-telemetry/opentelemetry-cpp/pull/2684) -* [CI] Fix CI failures on Ubuntu 24.04 - [#2686](https://github.com/open-telemetry/opentelemetry-cpp/pull/2686) -* [SEMANTIC CONVENTIONS] Upgrade to version 1.26.0 - [#2687](https://github.com/open-telemetry/opentelemetry-cpp/pull/2687) -* [API/SDK] Provider cleanup - [#2664](https://github.com/open-telemetry/opentelemetry-cpp/pull/2664) -* [ETW] Add table name mapping for Logs other than the default Log table - [#2691](https://github.com/open-telemetry/opentelemetry-cpp/pull/2691) -* [CI] Remove benchmark overlay for vcpkg - [#2695](https://github.com/open-telemetry/opentelemetry-cpp/pull/2695) -* [BUILD] Remove the incorrect set of CMAKE_MSVC_RUNTIME_LIBRARY for vcpkg - [#2696](https://github.com/open-telemetry/opentelemetry-cpp/pull/2696) -* [BUILD] CMakeLists.txt: Enable CMAKE_MSVC_RUNTIME_LIBRARY support - [#2652](https://github.com/open-telemetry/opentelemetry-cpp/pull/2652) -* [EXPORTER] OTLP file: use thread-safe file/io - [#2675](https://github.com/open-telemetry/opentelemetry-cpp/pull/2675) -* [bazel] Bump version and deps - [#2679](https://github.com/open-telemetry/opentelemetry-cpp/pull/2679) -* [BUILD] Add support for bzlmod - [#2608](https://github.com/open-telemetry/opentelemetry-cpp/pull/2608) -* [BUILD] Fix Import Abseil-cpp - [#2701](https://github.com/open-telemetry/opentelemetry-cpp/pull/2701) -* [Code health] include-what-you-use cleanup - [#2692](https://github.com/open-telemetry/opentelemetry-cpp/pull/2692) -* [BUILD] Restore Bazel flag removed from public API - [#2702](https://github.com/open-telemetry/opentelemetry-cpp/pull/2702) -* [DOC] Fix typo tace_id -> trace_id in logger.h - [#2703](https://github.com/open-telemetry/opentelemetry-cpp/pull/2703) -* Bump docker/build-push-action from 5 to 6 - [#2705](https://github.com/open-telemetry/opentelemetry-cpp/pull/2705) -* [CI] Enable ARM64 build in CI - [#2699](https://github.com/open-telemetry/opentelemetry-cpp/pull/2699) -* [Code health] Remove Unicode Text from Source files - [#2707](https://github.com/open-telemetry/opentelemetry-cpp/pull/2707) -* [BUILD] Add option WITH_OTLP_GRPC_SSL_MTLS_PREVIEW - [#2714](https://github.com/open-telemetry/opentelemetry-cpp/pull/2714) -* [EXPORTER] All 2xx return codes should be considered successful. - [#2712](https://github.com/open-telemetry/opentelemetry-cpp/pull/2712) - -Important changes: - -* [API/SDK] Provider cleanup - [#2664](https://github.com/open-telemetry/opentelemetry-cpp/pull/2664) - * Before this fix: - * The API class `opentelemetry::trace::Tracer` exposed methods such - as `ForceFlush()`, `ForceFlushWithMicroseconds()`, `Close()` - and `CloseWithMicroseconds()`. - * These methods are meant to be used when configuring the SDK, - and should not be part of the API. Exposing them was an oversight. - * Two of these methods are virtual, and therefore part of the ABI. - * After this fix: - * In `OPENTELEMETRY_ABI_VERSION_NO 1`, nothing is changed, - because removing this code would break the ABI. - * In `OPENTELEMETRY_ABI_VERSION_NO 2`, these methods are moved - from the API to the SDK. This is a breaking change for ABI version 2, - which is still experimental. - * In all cases, instrumenting an application should not - invoke flush or close on a tracer, do not use these methods. - -Breaking changes: - -* [API/SDK] Provider cleanup - [#2664](https://github.com/open-telemetry/opentelemetry-cpp/pull/2664) - * Before this fix: - * SDK factory methods such as: - * opentelemetry::sdk::trace::TracerProviderFactory::Create() - * opentelemetry::sdk::metrics::MeterProviderFactory::Create() - * opentelemetry::sdk::logs::LoggerProviderFactory::Create() - * opentelemetry::sdk::logs::EventLoggerProviderFactory::Create() - returned an API object (opentelemetry::trace::TracerProvider) - to the caller. - * After this fix, these methods return an SDK level object - (opentelemetry::sdk::trace::TracerProvider) to the caller. - * Returning an SDK object is necessary for the application to - cleanup and invoke SDK level methods, such as ForceFlush(), - on a provider. - * The application code that configures the SDK, by calling - the various provider factories, may need adjustment. - * All the examples have been updated, and in particular no - longer perform static_cast do convert an API object to an SDK object. - Please refer to examples for guidance on how to adjust. - * If adjusting application code is impractical, - an alternate and temporary solution is to build with option - WITH_DEPRECATED_SDK_FACTORY=ON in CMake. - * Option WITH_DEPRECATED_SDK_FACTORY=ON will allow to build code - without application changes, posponing changes for later. - * WITH_DEPRECATED_SDK_FACTORY=ON is temporary, only to provide - an easier migration path. Expect this flag to be removed, - as early as by the next release. - -Notes on experimental features: - -* [#2372](https://github.com/open-telemetry/opentelemetry-cpp/issues/2372) - introduced `MeterProvider::SetExemplar()` which accepts en - `ExemplarFilterType` enumeration with `kAlwaysOff`, `kAlwaysOn` and - `kTraceBased`. - -## [1.15.0] 2024-04-21 - -* [EXPORTER] Change OTLP HTTP content_type default to binary - [#2564](https://github.com/open-telemetry/opentelemetry-cpp/pull/2564) -* [DOC] Fix OTLP documentation: Default endpoint is wrong for OTLP/HTTP - [#2560](https://github.com/open-telemetry/opentelemetry-cpp/pull/2560) -* [BUILD] Fix old style cast warning - [#2567](https://github.com/open-telemetry/opentelemetry-cpp/pull/2567) -* [EXPORTER] Gzip compression support for OTLP/HTTP and OTLP/gRPC exporter - [#2530](https://github.com/open-telemetry/opentelemetry-cpp/pull/2530) -* [BUILD] update vcpkg submodule to 2024.02.14 - [#2575](https://github.com/open-telemetry/opentelemetry-cpp/pull/2575) -* [SDK] Support for OTEL_SERVICE_NAME - [#2577](https://github.com/open-telemetry/opentelemetry-cpp/pull/2577) -* [EXPORTER] Support URL-encoded values for `OTEL_EXPORTER_OTLP_HEADERS` - [#2579](https://github.com/open-telemetry/opentelemetry-cpp/pull/2579) -* [BUILD] CMake cleanup for message() - [#2582](https://github.com/open-telemetry/opentelemetry-cpp/pull/2582) -* [BUILD] Bump CMake minimum required version to 3.9 - [#2581](https://github.com/open-telemetry/opentelemetry-cpp/pull/2581) -* [BUILD] Provide LIKELY / UNLIKELY macros - [#2580](https://github.com/open-telemetry/opentelemetry-cpp/pull/2580) -* [EXPORTER] OTLP: Fix missing ResourceMetrics SchemaURL - [#2587](https://github.com/open-telemetry/opentelemetry-cpp/pull/2587) -* [ETW] cleanup include path - [#2594](https://github.com/open-telemetry/opentelemetry-cpp/pull/2594) -* Upgrade to googletest 1.14.0 - [#2596](https://github.com/open-telemetry/opentelemetry-cpp/pull/2596) -* Upgrade to nlohmann_json 3.11.3 - [#2595](https://github.com/open-telemetry/opentelemetry-cpp/pull/2595) -* [BAZEL] Move -std=c++14 to .bazelrc - [#2600](https://github.com/open-telemetry/opentelemetry-cpp/pull/2600) -* [BAZEL] Fix -std=c++14 warning on Windows - [#2601](https://github.com/open-telemetry/opentelemetry-cpp/pull/2601) -* Upgrade to benchmark 1.8.3 - [#2597](https://github.com/open-telemetry/opentelemetry-cpp/pull/2597) -* Upgrade to prometheus 1.2.4 - [#2598](https://github.com/open-telemetry/opentelemetry-cpp/pull/2598) -* [DOC] Fix typo: Asynchronouse -> Asynchronous in meter.h - [#2604](https://github.com/open-telemetry/opentelemetry-cpp/pull/2604) -* [BUILD] Do not link prometheus-cpp::util when it doesn't exist - [#2606](https://github.com/open-telemetry/opentelemetry-cpp/pull/2606) -* [SDK] Remove unused variable - [#2609](https://github.com/open-telemetry/opentelemetry-cpp/pull/2609) -* [METRICS SDK] Remove extra OfferMeasurement call - in SyncMetricsStorage::OfferMeasurement - [#2610](https://github.com/open-telemetry/opentelemetry-cpp/pull/2610) -* [MISC] Use set -e on all shell scripts and pass shellcheck --severity=error - [#2616](https://github.com/open-telemetry/opentelemetry-cpp/pull/2616) -* [CI] Add shellcheck --severity=error as a CI step - [#2618](https://github.com/open-telemetry/opentelemetry-cpp/pull/2618) -* [CI] Upgrade to abseil 20240116.1 (CMake only) - [#2599](https://github.com/open-telemetry/opentelemetry-cpp/pull/2599) -* [CI] Benchmark, provide units with --benchmark_min_time - [#2621](https://github.com/open-telemetry/opentelemetry-cpp/pull/2621) -* [EXPORTER] OTLP file exporter - [#2540](https://github.com/open-telemetry/opentelemetry-cpp/pull/2540) -* [CI] Use platform CMake - [#2627](https://github.com/open-telemetry/opentelemetry-cpp/pull/2627) -* [PROTO] Upgrade to opentelemetry-proto 1.2.0 - [#2631](https://github.com/open-telemetry/opentelemetry-cpp/pull/2631) -* [SDK] DefaultLogHandler to print errors to std::cerr, add LogLevel::None - [#2622](https://github.com/open-telemetry/opentelemetry-cpp/pull/2622) -* [SEMANTIC CONVENTIONS] Upgrade to semantic convention 1.25.0 - [#2633](https://github.com/open-telemetry/opentelemetry-cpp/pull/2633) -* [DOC] Add readme and examples for OTLP FILE exporters. - [#2638](https://github.com/open-telemetry/opentelemetry-cpp/pull/2638) -* [SEMANTIC CONVENTIONS] Rework on semantic conventions 1.25.0 - [#2640](https://github.com/open-telemetry/opentelemetry-cpp/pull/2640) -* [DOC] Update INSTALL.md - [#2592](https://github.com/open-telemetry/opentelemetry-cpp/pull/2592) - -Important changes: - -* [EXPORTER] Gzip compression support for OTLP/HTTP and OTLP/gRPC exporter - [#2530](https://github.com/open-telemetry/opentelemetry-cpp/pull/2530) - * In the `OtlpHttpExporterOptions` and `OtlpGrpcExporterOptions`, a new - field called compression has been introduced. This field can be set - to "gzipâ€� to enable gzip compression. - * The CMake option `WITH_OTLP_HTTP_COMPRESSION` is introduced to enable - gzip compression support for the OTLP HTTP Exporter and includes a - dependency on zlib. -* [SDK] Change OTLP HTTP content_type default to binary - [#2558](https://github.com/open-telemetry/opentelemetry-cpp/pull/2558) -* [CI] Use platform CMake - [#2627](https://github.com/open-telemetry/opentelemetry-cpp/pull/2627) - * The `CI` in github no longer install a different version of `cmake`. - * It now always use the `cmake` provided by the platform. - * As part of this change, the script `ci/setup_cmake.sh` was renamed - to `ci/setup_googletest.sh`, for clarity, now that this script - only installs googletest. -* [SDK] DefaultLogHandler to print to std::cerr, add LogLevel::None - [#2622](https://github.com/open-telemetry/opentelemetry-cpp/pull/2622) - * Change DefaultLogHandler output - * Before, the default internal logger, DefaultLogHandler, - used to print to std::cout. - * Now, DefaultLogHandler prints errors and warnings to std::cerr, - as expected, while printing info and debug messages to std::cout. - * Applications that expected to find the opentelemetry-cpp internal - error log in std::cout may need adjustments, either by looking - at std::cerr instead, or by using a custom log handler. - * Additional LogLevel::None - * LogLevel::None is a new supported log level, which does not print - any message. - * Custom log handlers may need to implement a new case, to avoid - compiler warnings. - * Numbering of log levels like OTEL_INTERNAL_LOG_LEVEL_ERROR - has changed, which requires to rebuild, as the SDK ABI differs. - -## [1.14.2] 2024-02-27 - -* [SDK] Fix observable attributes drop - [#2557](https://github.com/open-telemetry/opentelemetry-cpp/pull/2557) - -## [1.14.1] 2024-02-23 - -* [SDK] Restore Recordable API compatibility with versions < 1.14.0 - [#2547](https://github.com/open-telemetry/opentelemetry-cpp/pull/2547) -* [DOC] Add missing CHANGELOG. - [#2549](https://github.com/open-telemetry/opentelemetry-cpp/pull/2549) -* [EXPORTER] Error when grpc endpoint is empty - [#2507](https://github.com/open-telemetry/opentelemetry-cpp/pull/2507) -* [DOC] Fix typo in benchmarks.rst - [#2542](https://github.com/open-telemetry/opentelemetry-cpp/pull/2542) - -Important changes: - -* [SDK] Restore Recordable API compatibility with versions < 1.14.0 - [#2547](https://github.com/open-telemetry/opentelemetry-cpp/pull/2547) - * For third party _extending_ the SDK, release 1.14.0 introduced - an API breaking change compared to 1.13.0 - * This fix restores API (but not ABI) compatibility of - release 1.14.1 with release 1.13.0. - * This allows to build a third party exporter with no source code changes, - for both releases 1.14.1 and 1.13.0. - -## [1.14.0] 2024-02-16 - -* [BUILD] Add DLL build CI pipeline with CXX20 - [#2465](https://github.com/open-telemetry/opentelemetry-cpp/pull/2465) -* [EXPORTER] Set `is_monotonic` flag for Observable Counters - [#2478](https://github.com/open-telemetry/opentelemetry-cpp/pull/2478) -* [PROTO] Upgrade to opentelemetry-proto v1.1.0 - [#2488](https://github.com/open-telemetry/opentelemetry-cpp/pull/2488) -* [BUILD] Introduce CXX 20 CI pipeline for MSVC/Windows - [#2450](https://github.com/open-telemetry/opentelemetry-cpp/pull/2450) -* [API] Propagation: fix for hex conversion to binary for odd hex strings - [#2533](https://github.com/open-telemetry/opentelemetry-cpp/pull/2533) -* [DOC] Fix calendar link - [#2532](https://github.com/open-telemetry/opentelemetry-cpp/pull/2532) -* [ETW EXPORTER] Remove namespace using in ETW exporter which affects global - namespace - [#2531](https://github.com/open-telemetry/opentelemetry-cpp/pull/2531) -* [BUILD] Don't invoke vcpkg from this repo with CMAKE_TOOLCHAIN_FILE set - [#2527](https://github.com/open-telemetry/opentelemetry-cpp/pull/2527) -* [EXPORTER] Async exporting for otlp grpc - [#2407](https://github.com/open-telemetry/opentelemetry-cpp/pull/2407) -* [METRICS SDK] Fix attribute filtering for synchronous instruments. - [#2472](https://github.com/open-telemetry/opentelemetry-cpp/pull/2472) -* [BUILD] Better handling of OPENTELEMETRY_STL_VERSION under Bazel. - [#2503](https://github.com/open-telemetry/opentelemetry-cpp/pull/2503) -* [DOC] Fixes CI markdown error MD055 - Table pipe style - [#2517](https://github.com/open-telemetry/opentelemetry-cpp/pull/2517) -* [API] Propagators: do not overwrite the active span with a default invalid - span [#2511](https://github.com/open-telemetry/opentelemetry-cpp/pull/2511) -* [BUILD] Updated the recorded vcpkg submodule version - [#2513](https://github.com/open-telemetry/opentelemetry-cpp/pull/2513) -* [BUILD] Remove unnecessary usage/includes of nostd/type_traits - [#2509](https://github.com/open-telemetry/opentelemetry-cpp/pull/2509) -* [SEMANTIC CONVENTIONS] Upgrade to version 1.24.0 - [#2461](https://github.com/open-telemetry/opentelemetry-cpp/pull/2461) -* [EXAMPLES] Improve readme of Metrics example - [#2510](https://github.com/open-telemetry/opentelemetry-cpp/pull/2510) -* [BUILD] Clang-15 warning about `__has_trivial_destructor` - [#2502](https://github.com/open-telemetry/opentelemetry-cpp/pull/2502) -* [BUILD] Fix multiple assignment operators for SpinLockMutex - [#2501](https://github.com/open-telemetry/opentelemetry-cpp/pull/2501) -* [BUILD] Alternative way of exporting symbols (generating .def file) - [#2476](https://github.com/open-telemetry/opentelemetry-cpp/pull/2476) -* [CI] Make cmake.c++20*.test actually use C++20 and add cmake.c++23*.test - [#2496](https://github.com/open-telemetry/opentelemetry-cpp/pull/2496) -* [DOCUMENTATION] Add api reference documentation for logs - [#2497](https://github.com/open-telemetry/opentelemetry-cpp/pull/2497) -* [BUILD] Fix variable shadow - [#2498](https://github.com/open-telemetry/opentelemetry-cpp/pull/2498) -* [BUILD] Fix checks on __cplusplus under MSVC, do not assume /Zc - [#2493](https://github.com/open-telemetry/opentelemetry-cpp/pull/2493) -* [EXAMPLES] Use logs API instead of logs bridge API in the example - [#2494](https://github.com/open-telemetry/opentelemetry-cpp/pull/2494) -* [EXPORTER] Fix forward protocol encoding for ETW exporter - [#2473](https://github.com/open-telemetry/opentelemetry-cpp/pull/2473) -* [BUILD] Skip patch alias target - [#2457](https://github.com/open-telemetry/opentelemetry-cpp/pull/2457) -* [EXPORTER] Rename populate_otel_scope to without_otel_scope - [#2479](https://github.com/open-telemetry/opentelemetry-cpp/pull/2479) -* [EXPORTER SDK] Additional fixes after NOMINMAX removal on Windows - [#2475](https://github.com/open-telemetry/opentelemetry-cpp/pull/2475) -* [EXPORTER] Do not use regex in `CleanUpString` because some implementations of - STL may crash. - [#2464](https://github.com/open-telemetry/opentelemetry-cpp/pull/2464) -* [EXPORTER] Fix Aggregation type detection in OTLP Exporter - [#2467](https://github.com/open-telemetry/opentelemetry-cpp/pull/2467) -* [EXPORTER] Add option to disable Prometheus otel_scope_name and - otel_scope_version attributes - [#2451](https://github.com/open-telemetry/opentelemetry-cpp/pull/2451) -* [SEMANTIC CONVENTIONS] Code generation script fails on SELINUX - [#2455](https://github.com/open-telemetry/opentelemetry-cpp/pull/2455) -* [BUILD] Fix removing of NOMINMAX on Windows - [#2449](https://github.com/open-telemetry/opentelemetry-cpp/pull/2449) -* [BUILD] Accept path list in OPENTELEMETRY_EXTERNAL_COMPONENT_PATH - [#2439](https://github.com/open-telemetry/opentelemetry-cpp/pull/2439) -* [BUILD] Remove gmock from GTEST_BOTH_LIBRARIES - [#2437](https://github.com/open-telemetry/opentelemetry-cpp/pull/2437) -* [REMOVAL] Remove option WITH_OTLP_HTTP_SSL_PREVIEW - [#2435](https://github.com/open-telemetry/opentelemetry-cpp/pull/2435) - -Important changes: - -Breaking changes: - -* [REMOVAL] Remove option WITH_OTLP_HTTP_SSL_PREVIEW - [#2435](https://github.com/open-telemetry/opentelemetry-cpp/pull/2435) - * CMake options `WITH_OTLP_HTTP_SSL_PREVIEW` and - `WITH_OTLP_HTTP_SSL_TLS_PREVIEW` are removed. Building opentelemetry-cpp - without SSL support is no longer possible. - -* [PROTO] Upgrade to opentelemetry-proto v1.1.0 - [#2488](https://github.com/open-telemetry/opentelemetry-cpp/pull/2488) - * Class `opentelemetry::sdk::trace::Recordable` has a new virtual method, - `SetTraceFlags()`. - * This is an incompatible change for the SDK Recordable API and ABI. - * Applications _configuring_ the SDK are not affected. - * Third parties providing SDK _extensions_ are affected, - and must provide a `SetTraceFlags()` implementation, - starting with opentelemetry-cpp 1.14.0. - -## [1.13.0] 2023-12-06 - -* [BUILD] Remove WITH_REMOVE_METER_PREVIEW, use WITH_ABI_VERSION_2 instead - [#2370](https://github.com/open-telemetry/opentelemetry-cpp/pull/2370) -* [SDK] Metrics ObservableRegistry Cleanup - [#2376](https://github.com/open-telemetry/opentelemetry-cpp/pull/2376) -* [BUILD] Make WITH_OTLP_HTTP_SSL_PREVIEW mainstream - [#2378](https://github.com/open-telemetry/opentelemetry-cpp/pull/2378) -* [SDK] Creating DoubleUpDownCounter with no matching view - [#2379](https://github.com/open-telemetry/opentelemetry-cpp/pull/2379) -* [API] Add InstrumentationScope attributes in TracerProvider::GetTracer() - [#2371](https://github.com/open-telemetry/opentelemetry-cpp/pull/2371) -* [BUILD] DLL export interface for Metrics - [#2344](https://github.com/open-telemetry/opentelemetry-cpp/pull/2344) -* [BUILD] enum CanonicalCode names too generic... conflict with old C defines - [#2385](https://github.com/open-telemetry/opentelemetry-cpp/pull/2385) -* [BUILD] Fix cpack broken package version - [#2386](https://github.com/open-telemetry/opentelemetry-cpp/pull/2386) -* [API] Add a new AddLink() operation to Span - [#2380](https://github.com/open-telemetry/opentelemetry-cpp/pull/2380) -* [opentracing-shim] Add check for sampled context - [#2390](https://github.com/open-telemetry/opentelemetry-cpp/pull/2390) -* [BUILD] Fix exported definitions when building DLL with STL - [#2387](https://github.com/open-telemetry/opentelemetry-cpp/pull/2387) -* [BUILD] Add missing includes to runtime_context_test - [#2395](https://github.com/open-telemetry/opentelemetry-cpp/pull/2395) -* [ADMIN] Add file .github/repository-settings.md - [#2392](https://github.com/open-telemetry/opentelemetry-cpp/pull/2392) -* [SDK] Fix GetLogger with empty library name - [#2398](https://github.com/open-telemetry/opentelemetry-cpp/pull/2398) -* [TEST] Fix compiling problem and removed -DENABLE_TEST - [#2401](https://github.com/open-telemetry/opentelemetry-cpp/pull/2401) -* [BUILD] Check windows options are not passed to non-Windows build - [#2399](https://github.com/open-telemetry/opentelemetry-cpp/pull/2399) -* [EXPORTER] Rework OTLP/HTTP and OTLP/GRPC exporter options - [#2388](https://github.com/open-telemetry/opentelemetry-cpp/pull/2388) -* [Build] Update vcpkg to latest release - [#2412](https://github.com/open-telemetry/opentelemetry-cpp/pull/2412) -* [SDK] Cardinality limits for metrics streams - (Sync Instruments + Delta Temporality) - [#2255](https://github.com/open-telemetry/opentelemetry-cpp/pull/2255) -* [EXPORTER] Prometheus: Add unit to names, convert to word - [#2213](https://github.com/open-telemetry/opentelemetry-cpp/pull/2213) -* [Metrics] Make context optional for histogram instruments in Metrics SDK - [#2416](https://github.com/open-telemetry/opentelemetry-cpp/pull/2416) -* [BUILD] Fix references to trace namespace to be fully qualified - [#2422](https://github.com/open-telemetry/opentelemetry-cpp/pull/2422) -* [BUILD] Bump third_party/googletest to same version as bazel - [#2421](https://github.com/open-telemetry/opentelemetry-cpp/pull/2421) -* [BUILD] Remove defining NOMINMAX from api - [#2420](https://github.com/open-telemetry/opentelemetry-cpp/pull/2420) -* [BUILD] 'uint8_t' not declared in this scope with gcc 13.2.1 - [#2423](https://github.com/open-telemetry/opentelemetry-cpp/pull/2423) -* [BUILD] Improve the handling of OPENTELEMETRY_HAVE_WORKING_REGEX - [#2430](https://github.com/open-telemetry/opentelemetry-cpp/pull/2430) -* [SEMANTIC CONVENTION] Upgrade to semconv 1.23.1 - [#2428](https://github.com/open-telemetry/opentelemetry-cpp/pull/2428) -* [BUILD] Use fully qualified references to trace/common namespace - [#2424](https://github.com/open-telemetry/opentelemetry-cpp/pull/2424) -* [API] Create root span with active span - [#2427](https://github.com/open-telemetry/opentelemetry-cpp/pull/2427) -* [REMOVAL] Remove ZPAGES - [#2433](https://github.com/open-telemetry/opentelemetry-cpp/pull/2433) - -Important changes: - -* [API] Add InstrumentationScope attributes in TracerProvider::GetTracer() - [#2371](https://github.com/open-telemetry/opentelemetry-cpp/pull/2371) - * TracerProvider::GetTracer() now accepts InstrumentationScope attributes. - * Because this is an `ABI` breaking change, the fix is only available - with the `CMake` option `WITH_ABI_VERSION_2=ON`. - * When building with `CMake` option `WITH_ABI_VERSION_1=ON` (by default) - the `ABI` is unchanged, and the fix is not available. - -* [API] Add a new AddLink() operation to Span - [#2380](https://github.com/open-telemetry/opentelemetry-cpp/pull/2380) - * New `API` Span::AddLink() adds a single link to a span. - * New `API` Span::AddLinks() adds multiple links to a span. - * Because this is an `ABI` breaking change, the fix is only available - with the `CMake` option `WITH_ABI_VERSION_2=ON`. - * When building with `CMake` option `WITH_ABI_VERSION_1=ON` (by default) - the `ABI` is unchanged, and the fix is not available. - -* [BUILD] Make WITH_OTLP_HTTP_SSL_PREVIEW mainstream - [#2378](https://github.com/open-telemetry/opentelemetry-cpp/pull/2378) - * The experimental `CMake` option `WITH_OTLP_HTTP_SSL_PREVIEW` - is now promoted to stable. The default is changed to `ON`. - * The experimental `CMake` option `WITH_OTLP_HTTP_SSL_TLS_PREVIEW` - is now promoted to stable. The default is changed to `ON`. - * These build options are scheduled to be removed by the next release, - building without SSL/TLS will no longer be possible. - -* [EXPORTER] Rework OTLP/HTTP and OTLP/GRPC exporter options - [#2388](https://github.com/open-telemetry/opentelemetry-cpp/pull/2388) - * `OtlpGrpcMetricExporterOptions` used to honor `_TRACES_` - environment variables, instead of `_METRICS_` environment variables. - * The implementation of `OtlpGrpcMetricExporterOptions` is now fixed. - * Please check configuration variables, - to make sure `_METRICS_` variables are set as expected. - -Breaking changes: - -* [BUILD] Remove WITH_REMOVE_METER_PREVIEW, use WITH_ABI_VERSION_2 instead - [#2370](https://github.com/open-telemetry/opentelemetry-cpp/pull/2370) - * The experimental `CMake` option `WITH_REMOVE_METER_PREVIEW` is removed, - use option `WITH_ABI_VERSION_2` instead. - -* [BUILD] enum CanonicalCode names too generic... conflict with old C defines - [#2385](https://github.com/open-telemetry/opentelemetry-cpp/pull/2385) - * Header file `opentelemetry/trace/canonical_code.h` is unused, - and is now removed. - * This header should not be included directly in an application. - If this is the case, please remove any remaining include directives. - -* [BUILD] Fix exported definitions when building DLL with STL - [#2387](https://github.com/open-telemetry/opentelemetry-cpp/pull/2387) - * The MeterSelector, MeterSelectorFactory, InstrumentSelector, - and InstrumentSelectorFactory APIs now use const std::string& - instead of nostd::string_view for name, version and schema to - maintain a single export definition for DLL. - -* [EXPORTER] Rework OTLP/HTTP and OTLP/GRPC exporter options - [#2388](https://github.com/open-telemetry/opentelemetry-cpp/pull/2388) - * `OtlpGrpcLogRecordExporter` incorrectly used `OtlpGrpcExporterOptions`, - which are options for traces and not logs. - * This created a bug: the `OtlpGrpcLogRecordExporter` honors `_TRACES_` - environment variables, instead of `_LOGS_` environment variables. - * `OtlpGrpcLogRecordExporter` is changed to use - `OtlpGrpcLogRecordExporterOptions` instead, fixing the bug. - * User code that initializes the SDK with a GRPC Log exporter, - and uses exporter options, should adjust to replace - `OtlpGrpcExporterOptions` with `OtlpGrpcLogRecordExporterOptions`. - * Please check configuration variables, - to make sure `_LOGS_` variables are set as expected. - -* [REMOVAL] Remove ZPAGES - [#2433](https://github.com/open-telemetry/opentelemetry-cpp/pull/2433) - * As announced in release 1.12.0, - the deprecated ZPAGES exporter is now removed. - -## [1.12.0] 2023-10-16 - -* [BUILD] Support `pkg-config` - [#2269](https://github.com/open-telemetry/opentelemetry-cpp/pull/2269) -* [CI] Do not automatically close stale issues - [#2277](https://github.com/open-telemetry/opentelemetry-cpp/pull/2277) -* [CI] Benchmark workflow fails, C++14 required to build grpc - [#2278](https://github.com/open-telemetry/opentelemetry-cpp/pull/2278) -* [SDK] Increase metric name maximum length from 63 to 255 characters - [#2284](https://github.com/open-telemetry/opentelemetry-cpp/pull/2284) -* [SEMANTIC CONVENTION] Deprecated semconv (in the spec) - not deprecated (in C++) - [#2285](https://github.com/open-telemetry/opentelemetry-cpp/pull/2285) -* [SDK] Remove unused member variables from SyncMetricStorage - [#2294](https://github.com/open-telemetry/opentelemetry-cpp/pull/2294) -* [DEPRECATION] Deprecate ZPAGES - [#2291](https://github.com/open-telemetry/opentelemetry-cpp/pull/2291) -* [API] Deliver ABI breaking changes - [#2222](https://github.com/open-telemetry/opentelemetry-cpp/pull/2222) -* [SDK] Allow metric instrument names to contain / characters - [#2310](https://github.com/open-telemetry/opentelemetry-cpp/pull/2310) -* [SDK] Fix Observable Counters/UpDownCounters - [#2298](https://github.com/open-telemetry/opentelemetry-cpp/pull/2298) -* [SDK] Add exemplar reservoir to async metric storage - [#2319](https://github.com/open-telemetry/opentelemetry-cpp/pull/2319) -* [TEST] Fix lifetime issues in prometheus test utils - [#2322](https://github.com/open-telemetry/opentelemetry-cpp/pull/2322) -* [EXPORTER] Prometheus: Remove explicit timestamps from metric points - [#2324](https://github.com/open-telemetry/opentelemetry-cpp/pull/2324) -* [EXPORTER] Prometheus: Handle attribute key collisions from sanitation - [#2326](https://github.com/open-telemetry/opentelemetry-cpp/pull/2326) -* [EXPORTER] Prometheus cleanup, test with TranslateToPrometheus - [#2329](https://github.com/open-telemetry/opentelemetry-cpp/pull/2329) -* [SDK] Fix log message in Meter::RegisterSyncMetricStorage - [#2325](https://github.com/open-telemetry/opentelemetry-cpp/pull/2325) -* [DOC] Simplify the project status section - [#2332](https://github.com/open-telemetry/opentelemetry-cpp/pull/2332) -* [EXPORTER] Prometheus: Sanitize labels according to spec - [#2330](https://github.com/open-telemetry/opentelemetry-cpp/pull/2330) -* [SDK] Fix deadlock when shuting down http client - [#2337](https://github.com/open-telemetry/opentelemetry-cpp/pull/2337) -* [Exporter] Group spans by resource and instrumentation scope - in OTLP export requests - [#2335](https://github.com/open-telemetry/opentelemetry-cpp/pull/2335) -* [BUILD] Need fine-grained HAVE_CPP_STDLIB - [#2304](https://github.com/open-telemetry/opentelemetry-cpp/pull/2304) -* [API] Add InstrumentationScope attributes in MeterProvider::GetMeter() - [#2224](https://github.com/open-telemetry/opentelemetry-cpp/pull/2224) -* [REMOVAL] Drop C++11 support - [#2342](https://github.com/open-telemetry/opentelemetry-cpp/pull/2342) -* [EXPORTER] prometheus: add otel_scope_name and otel_scope_version labels - [#2293](https://github.com/open-telemetry/opentelemetry-cpp/pull/2293) -* [EXPORTER] Export resource for prometheus - [#2301](https://github.com/open-telemetry/opentelemetry-cpp/pull/2301) -* [BUILD] error: read-only reference ‘value’ used as ‘asm’ output - [#2354](https://github.com/open-telemetry/opentelemetry-cpp/pull/2354) -* [BUILD] Build break with external CMake nlohman_json package - [#2353](https://github.com/open-telemetry/opentelemetry-cpp/pull/2353) -* [BUILD] Upgrade libcurl to version 8.4.0 - [#2358](https://github.com/open-telemetry/opentelemetry-cpp/pull/2358) -* [BUILD] Fix opentracing-shim when added in super project - [#2356](https://github.com/open-telemetry/opentelemetry-cpp/pull/2356) -* [BUILD] Fix protoc searching with non-imported protobuf::protoc target - [#2362](https://github.com/open-telemetry/opentelemetry-cpp/pull/2362) -* [BUILD] Support to use different cmake package CONFIG of dependencies - [#2263](https://github.com/open-telemetry/opentelemetry-cpp/pull/2263) -* [SEMANTIC CONVENTION] Upgrade to semconv 1.22.0 - [#2368](https://github.com/open-telemetry/opentelemetry-cpp/pull/2368) - -Important changes: - -* [API] Add InstrumentationScope attributes in MeterProvider::GetMeter() - [#2224](https://github.com/open-telemetry/opentelemetry-cpp/pull/2224) - * MeterProvider::GetMeter() now accepts InstrumentationScope attributes. - * Because this is an `ABI` breaking change, the fix is only available - with the `CMake` option `WITH_ABI_VERSION_2=ON`. - * When building with `CMake` option `WITH_ABI_VERSION_1=ON` (by default) - the `ABI` is unchanged, and the fix is not available. - -Breaking changes: - -* [BUILD] Need fine-grained HAVE_CPP_STDLIB - [#2304](https://github.com/open-telemetry/opentelemetry-cpp/pull/2304) - * In `CMAKE`, the boolean option `WITH_STL` as changed to an option - that accepts the values `OFF`, `ON`, `CXX11`, `CXX14`, `CXX17`, - `CXX20` and `CXX23`. - * Applications makefiles that did not set WITH_STL need to use - `WITH_STL=OFF` instead (this is the default). - * Applications makefiles that did set WITH_STL need to use - `WITH_STL=ON` instead, or may choose to pick a specific value. - * In the `API` header files, the preprocessor symbol `HAVE_CPP_STDLIB` - is no longer used. - * Applications that did set `HAVE_CPP_STDLIB` before, need to set - `OPENTELEMETRY_STL_VERSION=` instead, to build with a - specific STL version (2011, 2014, 2017, 2020, 2023). - * The opentelemetry-cpp makefile no longer sets - CMAKE_CXX_STANDARD by itself. - Instead, the CMAKE_CXX_STANDARD and/or compiler options -stdc++ used - by the caller are honored. - * Applications that set neither CMAKE_CXX_STANDARD nor -stdc++ - options may need to provide a C++ standard in their makefiles. - -* [REMOVAL] Drop C++11 support - [#2342](https://github.com/open-telemetry/opentelemetry-cpp/pull/2342) - * Building with C++11 is no longer supported. - -Deprecations: - -* [DEPRECATION] Deprecate ZPAGES - [#2291](https://github.com/open-telemetry/opentelemetry-cpp/pull/2291) - -## [1.11.0] 2023-08-21 - -* [BUILD] Fix more cases for symbol name for 32-bit win32 DLL build - [#2264](https://github.com/open-telemetry/opentelemetry-cpp/pull/2264) -* [BUILD] added public link of `opentelemetry_proto_grpc` against gRPC lib (only - if gRPC library is shared) - [#2268](https://github.com/open-telemetry/opentelemetry-cpp/pull/2268) -* [CI] use ubuntu-latest for tsan CI - [#2267](https://github.com/open-telemetry/opentelemetry-cpp/pull/2267) -* [SDK] Fixing an apparent logging macro bug - [#2265](https://github.com/open-telemetry/opentelemetry-cpp/pull/2265) -* [BUILD] Support protobuf 3.22 or upper - [#2163](https://github.com/open-telemetry/opentelemetry-cpp/pull/2163) -* [BUILD] Remove extra includes - [#2252](https://github.com/open-telemetry/opentelemetry-cpp/pull/2252) -* [LOGS API SDK] Mark logs signal as stable API/SDK - [#2229](https://github.com/open-telemetry/opentelemetry-cpp/pull/2229) -* [SEMANTIC CONVENTIONS] Upgrade to 1.21.0 - [#2248](https://github.com/open-telemetry/opentelemetry-cpp/pull/2248) -* [SDK] Valgrind errors on std::atomic variables - [#2244](https://github.com/open-telemetry/opentelemetry-cpp/pull/2244) -* [BUILD] Fix compile with clang 16 and libc++ - [#2242](https://github.com/open-telemetry/opentelemetry-cpp/pull/2242) -* [Metrics SDK] Add unit to Instrument selection criteria - [#2236](https://github.com/open-telemetry/opentelemetry-cpp/pull/2236) -* [SDK] Add OStreamLogRecordExporterFactory - [#2240](https://github.com/open-telemetry/opentelemetry-cpp/pull/2240) -* [SDK] Add support for LowMemory metrics temporality - [#2234](https://github.com/open-telemetry/opentelemetry-cpp/pull/2234) -* [CI] Misc build scripts cleanup - [#2232](https://github.com/open-telemetry/opentelemetry-cpp/pull/2232) -* [CI] Upgrade GoogleTest version from 1.12.1 to 1.13.0 - [#2114](https://github.com/open-telemetry/opentelemetry-cpp/pull/2114) -* [BUILD] include cstdint - [#2230](https://github.com/open-telemetry/opentelemetry-cpp/pull/2230) -* [EXPORTER] Support protobuf 3.22 or upper - [#2163](https://github.com/open-telemetry/opentelemetry-cpp/pull/2163) -* [SDK] Mark logs signal as stable API/SDK - [#2229](https://github.com/open-telemetry/opentelemetry-cpp/pull/2229) - -Breaking changes: - -* [SDK] Add unit to Instrument selection criteria - [#2236](https://github.com/open-telemetry/opentelemetry-cpp/pull/2236) - * The `View` constructor and `ViewFactory::Create` method now takes a - `unit` criteria as optional third argument. - * Please adjust SDK configuration code accordingly. - -## [1.10.0] 2023-07-11 - -* [REMOVAL] Remove the jaeger exporter - [#2031](https://github.com/open-telemetry/opentelemetry-cpp/pull/2031) - -* [CI] Add a C++11 build - [#2152](https://github.com/open-telemetry/opentelemetry-cpp/pull/2152) - -* [CI] Add Include what you use - [#2214](https://github.com/open-telemetry/opentelemetry-cpp/pull/2214) - -* [CI] opentelemetry-cpp project CI - [#2071](https://github.com/open-telemetry/opentelemetry-cpp/pull/2071) - -* [CI] Do not tag pull_request with the "need-triage" label - [#2228](https://github.com/open-telemetry/opentelemetry-cpp/pull/2228) - -* [BUILD] Fixing CMake to build GTest on Windows - [#1887](https://github.com/open-telemetry/opentelemetry-cpp/pull/1887) - -* [BUILD] Remove option WITH_OTLP - [#2161](https://github.com/open-telemetry/opentelemetry-cpp/pull/2161) - -* [BUILD] Link to opentelemetry_logs even without OTLP - [#2177](https://github.com/open-telemetry/opentelemetry-cpp/pull/2177) - -* [BUILD] Avoid dependency on protobuf from the OTLP HTTP metrics exporter header - [#2179](https://github.com/open-telemetry/opentelemetry-cpp/pull/2179) - -* [BUILD] Add ctime header to metrics_exporter.cc - [#2187](https://github.com/open-telemetry/opentelemetry-cpp/pull/2187) - -* [BUILD] Fix the exported symbol name for 32-bit win32 DLL - [#2190](https://github.com/open-telemetry/opentelemetry-cpp/pull/2190) - -* [BUILD] Upgrade to opentelemetry-proto 0.20.0 - [#2195](https://github.com/open-telemetry/opentelemetry-cpp/pull/2195) - -* [BUILD] SDK Header files cleanup, use forward declarations - [#2182](https://github.com/open-telemetry/opentelemetry-cpp/pull/2182) - -* [BUILD] Enable building otel-cpp extensions from main repo - [#1937](https://github.com/open-telemetry/opentelemetry-cpp/pull/1937) - -* [BUILD] Fix if check on environment variable and add CMake variable - [#2207](https://github.com/open-telemetry/opentelemetry-cpp/pull/2207) - -* [BUILD] Add `OPENTELEMETRY_CPP_FOUND` into cmake CONFIG file - [#2215](https://github.com/open-telemetry/opentelemetry-cpp/pull/2215) - -* [BUILD] Upgrade opentelemetry-proto to 1.0.0 - [#2216](https://github.com/open-telemetry/opentelemetry-cpp/pull/2216) - -* [BUILD] Include nostd/string_view which is used in severity.h - [#2219](https://github.com/open-telemetry/opentelemetry-cpp/pull/2219) - -* [TEST] Expand api singleton test to cover explicit dlopen() - [#2164](https://github.com/open-telemetry/opentelemetry-cpp/pull/2164) - -* [API] Remove include_trace_context - [#2194](https://github.com/open-telemetry/opentelemetry-cpp/pull/2194) - -* [API] Remove Meters - [#2205](https://github.com/open-telemetry/opentelemetry-cpp/pull/2205) - -* [SDK] Add AdaptingCircularBufferCounter for exponential histograms - [#2158](https://github.com/open-telemetry/opentelemetry-cpp/pull/2158) - -* [SDK] Add base2 exponential histogram indexer - [#2173](https://github.com/open-telemetry/opentelemetry-cpp/pull/2173) - -* [SDK] Simplify SDK version - [#2180](https://github.com/open-telemetry/opentelemetry-cpp/pull/2180) - -* [SDK] Add benchmark for base2 exponential histogram indexer - [#2181](https://github.com/open-telemetry/opentelemetry-cpp/pull/2181) - -* [SDK] Provide builders to avoid exposing Metrics SDK internals - [#2189](https://github.com/open-telemetry/opentelemetry-cpp/pull/2189) - -* [SDK] MeterProvider should own MeterContext, not share it - [#2218](https://github.com/open-telemetry/opentelemetry-cpp/pull/2218) - -* [SDK] TracerProvider should own TracerContext, not share it - [#2221](https://github.com/open-telemetry/opentelemetry-cpp/pull/2221) - -* [EXPORTER] Change OTLP Json field name to camelCase - [#2162](https://github.com/open-telemetry/opentelemetry-cpp/pull/2162) - -* [EXPORTER] Support empty arrays in `OtlpRecordable` attributes - [#2166](https://github.com/open-telemetry/opentelemetry-cpp/pull/2166) - -* [EXPORTER] set is_monotonic only for instrument type kCounter - [#2171](https://github.com/open-telemetry/opentelemetry-cpp/pull/2171) - -* [EXPORTER] Fixed HTTP CURL for 32bits platforms - [#2178](https://github.com/open-telemetry/opentelemetry-cpp/pull/2178) - -* [EXPORTER] Fix OTLP HTTP exporting in sync mode - [#2193](https://github.com/open-telemetry/opentelemetry-cpp/pull/2193) - -* [EXPORTER] Prometheus exporter sanitizes invalid characters - [#1934](https://github.com/open-telemetry/opentelemetry-cpp/pull/1934) - -* [EXPORTER] Prometheus: Error on ingesting samples - with different value but same timestamp - [#2200](https://github.com/open-telemetry/opentelemetry-cpp/pull/2200) - -* [EXPORTER] OTLP GRPC mTLS support - [#2120](https://github.com/open-telemetry/opentelemetry-cpp/pull/2120) - -* [DOC] Small fix for Histogram documentation - [#2156](https://github.com/open-telemetry/opentelemetry-cpp/pull/2156) - -* [DOC] Move Reiley Yang to emeritus - [#2198](https://github.com/open-telemetry/opentelemetry-cpp/pull/2198) - -Important changes: - -* [API] Remove Meters - [#2205](https://github.com/open-telemetry/opentelemetry-cpp/pull/2205) - * The CMake option `WITH_REMOVE_METER_PREVIEW` was added. - * This option is experimental, and may change in the future. - * Enabling it is an ABI breaking change. - -Breaking changes: - -* [REMOVAL] Remove the jaeger exporter - [#2031](https://github.com/open-telemetry/opentelemetry-cpp/pull/2031) - * The CMake `WITH_JAEGER` option has been removed - * Please remove usage of `WITH_JAEGER` from user scripts and makefiles. - -* [SDK] MeterProvider should own MeterContext, not share it - [#2218](https://github.com/open-telemetry/opentelemetry-cpp/pull/2218) - * The `MeterProvider` constructor now takes a `unique_ptr` on - `MeterContext`, instead of a `shared_ptr`. - * Please adjust SDK configuration code accordingly. - -* [SDK] TracerProvider should own TracerContext, not share it - [#2221](https://github.com/open-telemetry/opentelemetry-cpp/pull/2221) - * The `TracerProvider` constructor now takes a `unique_ptr` on - `TracerContext`, instead of a `shared_ptr`. - * The `LoggerProvider` constructor now takes a `unique_ptr` on - `LoggerContext`, instead of a `shared_ptr`. - * Please adjust SDK configuration code accordingly. - -## [1.9.1] 2023-05-26 - -* [DEPRECATION] Drop C++11 support - [#2146](https://github.com/open-telemetry/opentelemetry-cpp/pull/2146) - -* [CI] Upgrade Bazel and Bazelisk version - [#2118](https://github.com/open-telemetry/opentelemetry-cpp/pull/2118) -* [CI] Upgrade Google Benchmark version from 1.6.0 to 1.7.1 - [#2116](https://github.com/open-telemetry/opentelemetry-cpp/pull/2116) -* [CI] Upgrade Nlohmann JSON library version from 3.10.5 to 3.11.2 - [#2115](https://github.com/open-telemetry/opentelemetry-cpp/pull/2115) - -* [BUILD] Missed include - [#2143](https://github.com/open-telemetry/opentelemetry-cpp/pull/2143) -* [BUILD] Add opentelemetry_proto_grpc and allow build shared - opentelemetry_proto and opentelemetry_proto_grpc on non-Windows platform. - [#2097](https://github.com/open-telemetry/opentelemetry-cpp/pull/2097) -* [BUILD] Warning cleanup, single character wrapped by std::string - [#2137](https://github.com/open-telemetry/opentelemetry-cpp/pull/2137) -* [BUILD] Add missing target dependencies - [#2128](https://github.com/open-telemetry/opentelemetry-cpp/pull/2128) -* [BUILD] Fix if JSON library already added another CMake target - [#2126](https://github.com/open-telemetry/opentelemetry-cpp/pull/2126) -* [BUILD] shared libraries with version suffix, along with the symbolic link - [#2109](https://github.com/open-telemetry/opentelemetry-cpp/pull/2109) -* [BUILD] Show warning message if WITH_OTLP is enabled - [#2112](https://github.com/open-telemetry/opentelemetry-cpp/pull/2112) -* [BUILD] Add missing STL header. - [#2107](https://github.com/open-telemetry/opentelemetry-cpp/pull/2107) -* [BUILD] Build break with old curl, macro CURL_VERSION_BITS unknown - [#2102](https://github.com/open-telemetry/opentelemetry-cpp/pull/2102) -* [BUILD] Transitive dependency issue with the otlp http exporter - [#2154](https://github.com/open-telemetry/opentelemetry-cpp/pull/2154) - -* [TEST] Add unit test for log body implicit conversions. - [#2136](https://github.com/open-telemetry/opentelemetry-cpp/pull/2136) -* [TEST] Add event id to logger benchmark method - [#2133](https://github.com/open-telemetry/opentelemetry-cpp/pull/2133) - -* [API] Fix inclusion header files and use forward declaration - [#2124](https://github.com/open-telemetry/opentelemetry-cpp/pull/2124) -* [API] Add user facing Logging API and Benchmarks - [#2094](https://github.com/open-telemetry/opentelemetry-cpp/pull/2094) - -* [SDK] SDK support for the new OTel log - [#2123](https://github.com/open-telemetry/opentelemetry-cpp/pull/2123) - -* [EXPORTER] Fixed HTTP session cleanup on shutdown - [#2111](https://github.com/open-telemetry/opentelemetry-cpp/pull/2111) -* [EXPORTER] Delegate all API calls of gRPC into - opentelemetry_exporter_otlp_grpc_client, - and make it contains all symbols needed. - [#2005](https://github.com/open-telemetry/opentelemetry-cpp/pull/2005) - -* [DOC] Add Marc as maintainer. - [#2027](https://github.com/open-telemetry/opentelemetry-cpp/pull/2027) - -Breaking changes: - -* Add opentelemetry_proto_grpc and move gRPC sources into it. - [#2097](https://github.com/open-telemetry/opentelemetry-cpp/pull/2097) - * There will be no breaking changes for users who only use OTLP exporters and - do not directly use opentelemetry-cpp::proto. However, it is important to - note that `opentelemetry-cpp::proto` no longer contains generated gRPC codes - , and all components that depend on these gRPC codes should also link to - `opentelemetry-cpp::proto_grpc`. - -Deprecations: - -* The Jaeger Exporter is deprecated, see [DEPRECATED](./DEPRECATED.md) for details. -* C++11 support is to end, C++14 will be supported instead, - see [DEPRECATED](./DEPRECATED.md) for details. - -## [1.9.0] 2023-04-12 - -* [CI] Make build environment parallel (Windows) - [#2080](https://github.com/open-telemetry/opentelemetry-cpp/pull/2080) -* [CI] Make build environment parallel (Linux) - [#2076](https://github.com/open-telemetry/opentelemetry-cpp/pull/2076) -* [CI] Remove separate run of metrics ostream example - [#2030](https://github.com/open-telemetry/opentelemetry-cpp/pull/2030) - -* [BUILD] Include directory path added for Zipkin exporter example - [#2069](https://github.com/open-telemetry/opentelemetry-cpp/pull/2069) -* [BUILD] Ignore more warning in generated protobuf files - [#2067](https://github.com/open-telemetry/opentelemetry-cpp/pull/2067) -* [BUILD] Clean warnings in ETW exporters - [#2063](https://github.com/open-telemetry/opentelemetry-cpp/pull/2063) -* [BUILD] Fix default value of OPENTELEMETRY_INSTALL_default - [#2062](https://github.com/open-telemetry/opentelemetry-cpp/pull/2062) - -* [SEMANTIC CONVENTIONS] Upgrade to version 1.20.0 - [#2088](https://github.com/open-telemetry/opentelemetry-cpp/pull/2088) -* [SEMANTIC CONVENTIONS] Upgrade to version 1.19.0 - [#2017](https://github.com/open-telemetry/opentelemetry-cpp/pull/2017) - -* [API] Checking indices before dereference in string utils - [#2040](https://github.com/open-telemetry/opentelemetry-cpp/pull/2040) -* [API] Export factory class of log provider - [#2041](https://github.com/open-telemetry/opentelemetry-cpp/pull/2041) - -* [SDK] Implement Forceflush for Periodic Metric Reader - [#2064](https://github.com/open-telemetry/opentelemetry-cpp/pull/2064) -* [SDK] Add `ForceFlush` for all `LogRecordExporter` and `SpanExporter` - [#2000](https://github.com/open-telemetry/opentelemetry-cpp/pull/2000) -* [SDK] Fix schema URL precedence bug in `Resource::Merge` - [#2036](https://github.com/open-telemetry/opentelemetry-cpp/pull/2036) -* [SDK] Use sdk_start_ts for MetricData start_ts for instruments having - cumulative aggregation temporality. - [#2086](https://github.com/open-telemetry/opentelemetry-cpp/pull/2086) - -* [EXPORTER] Add OTLP HTTP SSL support - [#1793](https://github.com/open-telemetry/opentelemetry-cpp/pull/1793) -* [EXPORTER] GRPC endpoint scheme should take precedence over OTEL_EXPORTER_OTLP_TRACES_INSECURE - [#2060](https://github.com/open-telemetry/opentelemetry-cpp/pull/2060) - -* [EXAMPLES] Remove unused 'alerting' section from prometheus.yml in examples - [#2055](https://github.com/open-telemetry/opentelemetry-cpp/pull/2055) -* [EXAMPLES] Fix view names in Prometheus example - [#2034](https://github.com/open-telemetry/opentelemetry-cpp/pull/2034) - -* [DOC] Fix some docs typo - [#2057](https://github.com/open-telemetry/opentelemetry-cpp/pull/2057) -* [DOC] Update OpenTracing shim README.md - [#2028](https://github.com/open-telemetry/opentelemetry-cpp/pull/2028) -* [DOC] INSTALL doc clarifications - [#2078](https://github.com/open-telemetry/opentelemetry-cpp/pull/2078) - -Important changes: - -* [EXPORTER] GRPC endpoint scheme should take precedence over OTEL_EXPORTER_OTLP_TRACES_INSECURE - [#2060](https://github.com/open-telemetry/opentelemetry-cpp/pull/2060) - * The logic to decide whether or not an OTLP GRPC exporter uses SSL has - changed to comply with the specification: - * Before this change, the following settings were evaluated, in order: - * OTEL_EXPORTER_OTLP_TRACES_INSECURE (starting with 1.8.3) - * OTEL_EXPORTER_OTLP_INSECURE (starting with 1.8.3) - * OTEL_EXPORTER_OTLP_TRACES_SSL_ENABLE - * OTEL_EXPORTER_OTLP_SSL_ENABLE - * With this change, the following settings are evaluated, in order: - * The GRPC endpoint scheme, if provided: - * "https" imply with SSL, - * "http" imply without ssl. - * OTEL_EXPORTER_OTLP_TRACES_INSECURE - * OTEL_EXPORTER_OTLP_INSECURE - * OTEL_EXPORTER_OTLP_TRACES_SSL_ENABLE - * OTEL_EXPORTER_OTLP_SSL_ENABLE - * As a result, a behavior change for GRPC SSL is possible, - because the endpoint scheme now takes precedence. - Please verify configuration settings for the GRPC endpoint. -* [SDK] Add `ForceFlush` for all `LogRecordExporter` and `SpanExporter` - [#2000](https://github.com/open-telemetry/opentelemetry-cpp/pull/2000) - * `LogRecordExporter` and `SpanExporter` add a new virtual function - `ForceFlush`, and if users implement any customized `LogRecordExporter` and - `SpanExporter`, they should also implement this function. - There should be no impact if users only use factory to create exporters. - -Deprecations: - -* The Jaeger Exporter is deprecated, see [DEPRECATED](./DEPRECATED.md) for details. - -## [1.8.3] 2023-03-06 - -* Provide version major/minor/patch macros - [#2014](https://github.com/open-telemetry/opentelemetry-cpp/pull/2014) -* [BUILD] Add `OPENTELEMETRY_INSTALL` to allow user to skip install targets. - [#2022](https://github.com/open-telemetry/opentelemetry-cpp/pull/2022) -* [SDK] Rename the global SDK version variables to avoid naming clash - [#2011](https://github.com/open-telemetry/opentelemetry-cpp/pull/2011) -* [BUILD] Fix typo in CMakeLists.txt - [#2010](https://github.com/open-telemetry/opentelemetry-cpp/pull/2010) -* [EXPORTER] fix Prometheus test iterator iterator increment - [#2006](https://github.com/open-telemetry/opentelemetry-cpp/pull/2006) -* [SDK]Add attributes for InstrumentationScope - [#2004](https://github.com/open-telemetry/opentelemetry-cpp/pull/2004) -* [METRICS SDK] Performance improvement in measurement processing - [#1993](https://github.com/open-telemetry/opentelemetry-cpp/pull/1993) -* [EXAMPLE] Add example for logs ostream exporter - [#1992](https://github.com/open-telemetry/opentelemetry-cpp/pull/1992) -* [ETW Exporter] Support serialize span/log attributes into JSON - [#1991](https://github.com/open-telemetry/opentelemetry-cpp/pull/1991) -* [ETW Exporter]Do not overwrite ParentId when setting attribute on Span - [#1989](https://github.com/open-telemetry/opentelemetry-cpp/pull/1989) -* Upgrade prometheus-cpp to v1.1.0 - [#1954](https://github.com/open-telemetry/opentelemetry-cpp/pull/1954) -* Convert Prometheus Exporter to Pull MetricReader - [#1953](https://github.com/open-telemetry/opentelemetry-cpp/pull/1953) -* [DOCS] Add alpine packages to INSTALL.md - [#1957](https://github.com/open-telemetry/opentelemetry-cpp/pull/1957) -* [METRICS SDK] Add benchmark tests for Sum Aggregation. - [#1948](https://github.com/open-telemetry/opentelemetry-cpp/pull/1948) -* [BUILD] Build OpenTelemetry SDK and exporters into DLL - [#1932](https://github.com/open-telemetry/opentelemetry-cpp/pull/1932) -* [CI] Enforce copyright check in CI - [#1965](https://github.com/open-telemetry/opentelemetry-cpp/pull/1965) -* [BUILD] Fix typo GENENV -> GETENV - [#1972](https://github.com/open-telemetry/opentelemetry-cpp/pull/1972) -* [SEMANTIC CONVENTIONS] Upgrade to version 1.18.0 - [#1974](https://github.com/open-telemetry/opentelemetry-cpp/pull/1974) -* [EXT] Fix thread-safety when shutdown. - [#1977](https://github.com/open-telemetry/opentelemetry-cpp/pull/1977) -* [SDK] Fix missing ObservedTimestamp. - [#1985](https://github.com/open-telemetry/opentelemetry-cpp/pull/1985) -* [METRICS SDK] fix variable names - [#1987](https://github.com/open-telemetry/opentelemetry-cpp/pull/1987) -* [EXPORTER] Fix Prometheus server crash on listening to already used port - [#1986](https://github.com/open-telemetry/opentelemetry-cpp/pull/1986) -* [EXPORTER] Boolean environment variables not parsed per the spec - [#1982](https://github.com/open-telemetry/opentelemetry-cpp/pull/1982) -* [EXPORTER] Opentracing shim - [#1909](https://github.com/open-telemetry/opentelemetry-cpp/pull/1909) - -## [1.8.2] 2023-01-31 - -* Remove redundant macro check in nostd::shared_ptr [#1939](https://github.com/open-telemetry/opentelemetry-cpp/pull/1939) -* Fix typo in packages.cmake causing incorrect nuget package versions [#1936](https://github.com/open-telemetry/opentelemetry-cpp/pull/1936) -* [METRICS] Custom Aggregation support [#1899](https://github.com/open-telemetry/opentelemetry-cpp/pull/1899) -* Small fix in INSTALL.md for enabling building package. [#1930](https://github.com/open-telemetry/opentelemetry-cpp/pull/1930) -* [METRICS] Fix warning for misconfiguration of PeriodicExportingMetricReader [#1929](https://github.com/open-telemetry/opentelemetry-cpp/pull/1929) -* Make macros.h available for all source files via version.h [#1918](https://github.com/open-telemetry/opentelemetry-cpp/pull/1918) -* [METRICS] Histogram Aggregation: Fix bucket detection logic, - performance improvements, and benchmark tests [#1869](https://github.com/open-telemetry/opentelemetry-cpp/pull/1869) -* Remove unused namespace alias for nostd [#1914](https://github.com/open-telemetry/opentelemetry-cpp/pull/1914) -* [METRICS] Update meter.h [#1907](https://github.com/open-telemetry/opentelemetry-cpp/pull/1907) -* sdk::resource::Resource::Merge should be const [#1905](https://github.com/open-telemetry/opentelemetry-cpp/pull/1905) -* [METRICS] Collect and Export metric data before - PeriodicMetricReader shutdown. [#1860](https://github.com/open-telemetry/opentelemetry-cpp/pull/1860) -* [ETW EXPORTER] Add Virtual destructor for TailSampler, Update Maintainer - mode warnings for MSVC [#1897](https://github.com/open-telemetry/opentelemetry-cpp/pull/1897) -* Fix #1867 Orderly shutdown in examples [#1868](https://github.com/open-telemetry/opentelemetry-cpp/pull/1868) -* [METRICS] minor metrics handling optimizations [#1890](https://github.com/open-telemetry/opentelemetry-cpp/pull/1890) -* fix SpinLockMutex for Intel Compiler [#1885](https://github.com/open-telemetry/opentelemetry-cpp/pull/1885) -* [LOGS] Change BatchLogRecordProcessorFactory::Create to static method [#1876](https://github.com/open-telemetry/opentelemetry-cpp/pull/1876) -* Enable generating deb, rpm, NuGet, tgz, zip package through cmake build [#1662](https://github.com/open-telemetry/opentelemetry-cpp/pull/1662) -* Updated clone command in INSTALL.md [#1818](https://github.com/open-telemetry/opentelemetry-cpp/pull/1818) -* Small cleanup to remove old metrics design docs [#1855](https://github.com/open-telemetry/opentelemetry-cpp/pull/1855) -* [BUILD] Fix build error with older version of VS2017 compiler. [1857](https://github.com/open-telemetry/opentelemetry-cpp/pull/1857) -* [EXPORTERS] Enable setting Span endtime for ETW exporter [#1846](https://github.com/open-telemetry/opentelemetry-cpp/pull/1846) -* [REMOVAL] Remove deprecated experimental semantic conventions [#1743](https://github.com/open-telemetry/opentelemetry-cpp/pull/1743) -* [EXPORTERS] Fix console debug logs for otlp exporters. [#1848](https://github.com/open-telemetry/opentelemetry-cpp/pull/1848) -* [LOGS] Add `include_trace_context` and `EventLogger` [#1884](https://github.com/open-telemetry/opentelemetry-cpp/pull/1884) -* [METRICS] Change BatchLogRecordProcessorFactory::Create to static method -* [BUILD] Fix OTELCPP_MAINTAINER_MODE [#1844](https://github.com/open-telemetry/opentelemetry-cpp/pull/1844) -* [BUILD] Fix compatibility when using clang and libc++, upgrade GTest and - cmake when using C++20 [#1852](https://github.com/open-telemetry/opentelemetry-cpp/pull/1852) -* [SEMANTIC CONVENTIONS] Upgrade to version 1.16.0 - [#1854](https://github.com/open-telemetry/opentelemetry-cpp/pull/1854) -* [SDK] BatchSpanProcessor now logs a warning when dropping a span because the - queue is full - [1871](https://github.com/open-telemetry/opentelemetry-cpp/pull/1871) -* [BUILD] Migrate from @bazel_tools//platforms to [Bazel Platforms](https://github.com/bazelbuild/platforms) - to enable Bazel 6.0.0 compatibility [#1873](https://github.com/open-telemetry/opentelemetry-cpp/pull/1873) -* [BUILD] Cleanup CMake makefiles for nlohmann_json - [#1912](https://github.com/open-telemetry/opentelemetry-cpp/pull/1912) -* [BUILD] Cleanup CMake makefiles for CURL usage - [#1916](https://github.com/open-telemetry/opentelemetry-cpp/pull/1916) -* [SEMANTIC CONVENTIONS] Upgrade to version 1.17.0 - [#1927](https://github.com/open-telemetry/opentelemetry-cpp/pull/1927) -* [MAINTAINER DOC] Define and document a deprecation process, - [DEPRECATION] Deprecate the Jaeger exporter, - implemented by [#1923](https://github.com/open-telemetry/opentelemetry-cpp/pull/1923) -* [BUILD] OTLP HTTP Exporter has build warnings in maintainer mode - [#1943](https://github.com/open-telemetry/opentelemetry-cpp/pull/1943) - -Deprecations: - -* [MAINTAINER DOC] Define and document a deprecation process, - [#1923](https://github.com/open-telemetry/opentelemetry-cpp/pull/1923) - * A new file, [DEPRECATED](./DEPRECATED.md) list all the code currently - deprecated. - * A new [deprecation process](./docs/deprecation-process.md) details the plan to - deprecate and later remove code. -* [DEPRECATION] Deprecate the Jaeger exporter - [#1923](https://github.com/open-telemetry/opentelemetry-cpp/pull/1923) - * The Jaeger Exporter is deprecated, see [DEPRECATED](./DEPRECATED.md) for details. - -Important changes: - -* [BUILD] Cleanup CMake makefiles for CURL usage - [#1916](https://github.com/open-telemetry/opentelemetry-cpp/pull/1916) - * CMake option `WITH_OTLP_HTTP` - * Before this change, the CMake option `WITH_OTLP_HTTP` was unpredictable, - sometime set to ON and sometime set to OFF by default, - depending on whether a CURL package was found or not. - The option `WITH_OTLP_HTTP` was sometime not displayed in the ccmake - UI, making it impossible to even discover there is an option of that name. - * With this change, CMake option `WITH_OTLP_HTTP` is always OFF by - default. WITH_OTLP_HTTP MUST be set to ON explicitly to build the - OTLP HTTP exporter. The option is always visible in the ccmake UI. - * CMake option `BUILD_W3CTRACECONTEXT_TEST` - * Before this change, the W3C trace context tests were built, or - not, in an unpredictable way, depending on the presence, or not, of a - CURL package. In particular, the build could ignore the W3C trace - context tests even when BUILD_W3CTRACECONTEXT_TEST=ON. - * With this change, option BUILD_W3CTRACECONTEXT_TEST is honored. - * HTTP client/server examples - * Before this change, the HTTP client/server examples were built, or - not, in an unpredictable way, depending on the presence, or not, of a - CURL package. - * With this change, a new option `WITH_EXAMPLES_HTTP` is used to - build the HTTP client/server examples. - -## [1.8.1] 2022-12-04 - -* [ETW Exporter] Tail based sampling support [#1780](https://github.com/open-telemetry/opentelemetry-cpp/pull/1780) -* [EXPORTERS] fix typo [affecting otlp exported histogram metrics max uint] [#1827](https://github.com/open-telemetry/opentelemetry-cpp/pull/1827) -* [EXPORTERS] fix enum-compare-switch warning [#1833](https://github.com/open-telemetry/opentelemetry-cpp/pull/1833) -* [METRICS] Change default temporality as "Cumulative" for OTLP metrics -exporters [#1828](https://github.com/open-telemetry/opentelemetry-cpp/pull/1828) -* [BUILD] Moved otlp_grpc_utils.cc to opentelemetry_exporter_otlp_grpc_client. -[#1829](https://github.com/open-telemetry/opentelemetry-cpp/pull/1829) -* Fix type mismatch when move nostd::shared_ptr [#1815](https://github.com/open-telemetry/opentelemetry-cpp/pull/1815) -* [BUILD] Fix Prometheus target name [#1820](https://github.com/open-telemetry/opentelemetry-cpp/pull/1820) -* Clean unused docker files [#1817](https://github.com/open-telemetry/opentelemetry-cpp/pull/1817) -* [BUILD] Fix default bazel build [#1816](https://github.com/open-telemetry/opentelemetry-cpp/pull/1816) -* [BUILD] move client::nosend under test_common [#1811](https://github.com/open-telemetry/opentelemetry-cpp/pull/1811) -* [BUILD] Fix opentelemetry-proto file exists check [#1824](https://github.com/open-telemetry/opentelemetry-cpp/pull/1824) - -## [1.8.0] 2022-11-27 - -* [DOC] Update Metrics status in README.md [#1722](https://github.com/open-telemetry/opentelemetry-cpp/pull/1722) -* [DOC] Remove misleading comments about ABI compatibility for nostd::span [#1731](https://github.com/open-telemetry/opentelemetry-cpp/pull/1731) -* [BUILD] Bump abseil-cpp for cmake CI [#1807](https://github.com/open-telemetry/opentelemetry-cpp/pull/1807) -* [Exporter] Add status code to OTLP grpc trace log [#1792](https://github.com/open-telemetry/opentelemetry-cpp/pull/1792) -* [Exporter] add fix for prometheus exporter build [#1795](https://github.com/open-telemetry/opentelemetry-cpp/pull/1795) -* [BUILD] Add option WITH_BENCHMARK to disable building benchmarks [#1794](https://github.com/open-telemetry/opentelemetry-cpp/pull/1794) -* [BUILD] Fix CI benchmark [#1799](https://github.com/open-telemetry/opentelemetry-cpp/pull/1799) -* [BUILD] bump to gRPC v1.48.1 for bazel CIs [#1786](https://github.com/open-telemetry/opentelemetry-cpp/pull/1786) -* [BUILD] Fix CI build [#1798](https://github.com/open-telemetry/opentelemetry-cpp/pull/1798) -* [BUILD] Fix clang-format in CI [#1796](https://github.com/open-telemetry/opentelemetry-cpp/pull/1796) -* Fix session lock of OtlpHttpClient [#1760](https://github.com/open-telemetry/opentelemetry-cpp/pull/1760) -* [Metrics SDK] Add MeterContext::ForEachMeter() method to process callbacks on - Meter in thread-safe manner [#1783](https://github.com/open-telemetry/opentelemetry-cpp/pull/1783) -* [DOC] Document that clang-format version 10.0 is used. [#1782](https://github.com/open-telemetry/opentelemetry-cpp/pull/1782) -* [BUILD] Upgrade bazel build to use abseil-cpp-20220623.1 [#1779](https://github.com/open-telemetry/opentelemetry-cpp/pull/1779) -* Fix GlobalLogHandler singleton creation order [#1767](https://github.com/open-telemetry/opentelemetry-cpp/pull/1767) -* [Metrics SDK] Change Prometheus CMake target name [#1765](https://github.com/open-telemetry/opentelemetry-cpp/pull/1765) -* [DOC] Cleanup INSTALL.md [#1757](https://github.com/open-telemetry/opentelemetry-cpp/pull/1757) -* [DOC] Format config options in OTLP exporter readme [#1748](https://github.com/open-telemetry/opentelemetry-cpp/pull/1748) -* [DOC] Cleanup ENABLE_METRICS_PREVIEW [#1745](https://github.com/open-telemetry/opentelemetry-cpp/pull/1745) -* [Build] Multiple CURL packages leads to invalid build (#1738) [#1739](https://github.com/open-telemetry/opentelemetry-cpp/pull/1739) -* [Metrics SDK] Cleanup ENABLE_METRICS_PREVIEW [#1735](https://github.com/open-telemetry/opentelemetry-cpp/pull/1735) -* [Logs SDK] LogProcessor, LogExporter class name [#1736](https://github.com/open-telemetry/opentelemetry-cpp/pull/1736) -* [Metrics SDK] Cleanup of old _metric api/sdk [#1734](https://github.com/open-telemetry/opentelemetry-cpp/pull/1734) -* [ETW Exporter] Fix span timestamp(s) precision to nanoseconds [#1726](https://github.com/open-telemetry/opentelemetry-cpp/pull/1726) -* [LOGS SDK] Rename LogProcessor and LogExporter to LogRecordProcessor and LogRecordExporter - [#1727](https://github.com/open-telemetry/opentelemetry-cpp/pull/1727) -* [METRICS SDK] - Remove old metrics from Github CI - [#1733](https://github.com/open-telemetry/opentelemetry-cpp/pull/1733) -* [BUILD] Add CMake OTELCPP_PROTO_PATH [#1730](https://github.com/open-telemetry/opentelemetry-cpp/pull/1730) -* [SEMANTIC CONVENTIONS] Upgrade to version 1.15.0 - [#1761](https://github.com/open-telemetry/opentelemetry-cpp/pull/1761) -* [LOGS SDK] New LogRecord and logs::Recordable implementations. - [#1766](https://github.com/open-telemetry/opentelemetry-cpp/pull/1766) - -Deprecation notes: - -* [Deprecation] Deprecate experimental semantic conventions - [#1744](https://github.com/open-telemetry/opentelemetry-cpp/pull/1744) - * The file - `api/include/opentelemetry/trace/experimental_semantic_conventions.h` - is deprecated, and will be removed in a future release. - Use file - `api/include/opentelemetry/trace/semantic_conventions.h` - instead. - - * The file - `sdk/include/opentelemetry/sdk/resource/experimental_semantic_conventions.h` - is deprecated, and will be removed in a future release. - Use file - `sdk/include/opentelemetry/sdk/resource/semantic_conventions.h` - instead. - - * The function, declared in the global namespace - `uint32_t hashCode(const char *str, uint32_t h = 0)` - is deprecated, and will be removed in a future release. - No replacement will be provided. - Note that function `opentelemetry::utils::hashCode`, - declared in the ETW exporter, is not affected by this deprecation. - -Breaking changes: - -* [SEMANTIC CONVENTIONS] Upgrade to version 1.15.0 - [#1761](https://github.com/open-telemetry/opentelemetry-cpp/pull/1761) - * Naming of semantic conventions has changed from uppercase constants, - like `SemanticConventions::SERVICE_NAME`, - to camel case, like `SemanticConventions::kServiceName`. - This is necessary to avoid collisions with macros in general, - which breaks the build on some platforms. - * Semantic conventions are flagged as experimental, - which is why this change is done in this release. - -## [1.7.0] 2022-10-28 - -* [METRICS SDK] Validate Instrument meta data (name, unit, description) [#1713](https://github.com/open-telemetry/opentelemetry-cpp/pull/1713) -* [DOCS] Document libthrift 0.12.0 doesn't work with Jaeger exporter [#1714](https://github.com/open-telemetry/opentelemetry-cpp/pull/1714) -* [Metrics SDK] Add Monotonic Property to Sum Aggregation, and -unit tests for Up Down Counter [#1675](https://github.com/open-telemetry/opentelemetry-cpp/pull/1675) -* [Metrics SDK] Move Metrics Exemplar processing behind feature flag [#1710](https://github.com/open-telemetry/opentelemetry-cpp/pull/1710) -* [Metrics API/SDK] Change Meter API/SDK to return nostd::unique_ptr - for Sync Instruments [#1707](https://github.com/open-telemetry/opentelemetry-cpp/pull/1707) -which includes breaking change in the Metrics api and sdk. -* [BUILD] Add e2e test to asan & tsan CI [#1670](https://github.com/open-telemetry/opentelemetry-cpp/pull/1670) -* [BUILD] Add otlp-grpc example bazel [#1708](https://github.com/open-telemetry/opentelemetry-cpp/pull/1708) -* [TRACE SDK] Fix debug log of OTLP HTTP exporter and ES log exporter [#1703](https://github.com/open-telemetry/opentelemetry-cpp/pull/1703) -* [METRICS SDK] Fix a potential precision loss on integer in -ReservoirCellIndexFor [#1696](https://github.com/open-telemetry/opentelemetry-cpp/pull/1696) -* [METRICS SDK] Fix Histogram crash [#1685](https://github.com/open-telemetry/opentelemetry-cpp/pull/1685) -* [METRICS SDK] Fix:1676 Segfault when short export period is used for metrics [#1682](https://github.com/open-telemetry/opentelemetry-cpp/pull/1682) -* [METRICS SDK] Add timeout support to MeterContext::ForceFlush [#1673](https://github.com/open-telemetry/opentelemetry-cpp/pull/1673) -* [DOCS] - Minor updates to OStream Metrics exporter documentation [#1679](https://github.com/open-telemetry/opentelemetry-cpp/pull/1679) -* [DOCS] Fix:#1575 API Documentation for Metrics SDK and API [#1678](https://github.com/open-telemetry/opentelemetry-cpp/pull/1678) -* [BUILD] Fixed compiler warnings [#1677](https://github.com/open-telemetry/opentelemetry-cpp/pull/1677) -* [METRICS SDK] Fix threading issue between Meter::RegisterSyncMetricStorage - and Meter::Collect [#1666](https://github.com/open-telemetry/opentelemetry-cpp/pull/1666) -* [METRICS SDK] Fix data race on MeterContext::meters_ [#1668](https://github.com/open-telemetry/opentelemetry-cpp/pull/1668) -* [METRICS SDK] Fix observable Gauge metrics generation [#1651](https://github.com/open-telemetry/opentelemetry-cpp/pull/1651) -* [BUILD] Detect ARCH=sparc in CMake [#1660](https://github.com/open-telemetry/opentelemetry-cpp/pull/1660) -* [SDK] Add user agent for OTLP http/grpc client [#1657](https://github.com/open-telemetry/opentelemetry-cpp/pull/1657) -* [BUILD] Fix clang and gcc warnings [#1658](https://github.com/open-telemetry/opentelemetry-cpp/pull/1658) -* [Metrics SDK] Add Metrics ExemplarFilter and ExemplarReservoir [#1584](https://github.com/open-telemetry/opentelemetry-cpp/pull/1584) -* [LOGS SDK] Rename OnReceive to OnEmit [#1652](https://github.com/open-telemetry/opentelemetry-cpp/pull/1652) -* [METRICS SDK] Fix Observable Gauge does not reflect updated values, -and send the old value always [#1641](https://github.com/open-telemetry/opentelemetry-cpp/pull/1641) -* [Metrics SDK] Change boundary type to double for Explicit Bucket Histogram Aggregation, -and change default bucket range [#1626](https://github.com/open-telemetry/opentelemetry-cpp/pull/1626) -* [METRICS SDK] Fix occasional Segfault with LongCounter instrument [#1638](https://github.com/open-telemetry/opentelemetry-cpp/pull/1638) -* [BUILD] Bump vcpk to 2022.08.15 [#1633](https://github.com/open-telemetry/opentelemetry-cpp/pull/1633) -* [BUILD] Bump gRPC to v1.48.1 for CMake Linux CI [#1608](https://github.com/open-telemetry/opentelemetry-cpp/pull/1608) -* [Metrics] Switch to explicit 64 bit integers [#1686](https://github.com/open-telemetry/opentelemetry-cpp/pull/1686) - which includes breaking change in the Metrics api and sdk. -* [Metrics SDK] Add support for Pull Metric Exporter [#1701](https://github.com/open-telemetry/opentelemetry-cpp/pull/1701) - which includes breaking change in the Metrics api. -* [BUILD] Add CMake OTELCPP_MAINTAINER_MODE [#1650](https://github.com/open-telemetry/opentelemetry-cpp/pull/1650) -* [SEMANTIC CONVENTIONS] Upgrade to version 1.14.0 [#1697](https://github.com/open-telemetry/opentelemetry-cpp/pull/1697) - -Notes: - -Metrics API/SDK GA release includes PRs [#1686](https://github.com/open-telemetry/opentelemetry-cpp/pull/1686), -[#1701](https://github.com/open-telemetry/opentelemetry-cpp/pull/1701), and -[#1707](https://github.com/open-telemetry/opentelemetry-cpp/pull/1707) -with breaking changes in the Metrics API and SDK. - -## [1.6.1] 2022-09-22 - -* [BUILD] Upgrade opentelemetry-proto to v0.19.0 [#1579](https://github.com/open-telemetry/opentelemetry-cpp/pull/1579) -* [METRICS EXPORTER] Add `OtlpGrpcMetricExporterFactory` and `OtlpHttpMetricExporterFactory`. - [#1606](https://github.com/open-telemetry/opentelemetry-cpp/pull/1606) -* [SEMANTIC CONVENTIONS] Upgrade to version 1.13.0 [#1624](https://github.com/open-telemetry/opentelemetry-cpp/pull/1624) -* [BUILD] Fixes span creation benchmark issue. [#1622](https://github.com/open-telemetry/opentelemetry-cpp/pull/1622) -* [BUILD] Fix more build warnings (#1616) [#1620](https://github.com/open-telemetry/opentelemetry-cpp/pull/1620) -* [SDK gRPC]: Fix out-of-bounds access of string_view in GrpcClientCarrier in - the example - [#1619](https://github.com/open-telemetry/opentelemetry-cpp/pull/1619) -* [EXPORTER ETW] Add Trace flags in SpanContext [#1618](https://github.com/open-telemetry/opentelemetry-cpp/pull/1618) -* [SDK] resource sdk: Update Resource::Merge function docs [#1615](https://github.com/open-telemetry/opentelemetry-cpp/pull/1615) -* [BUILD] Fix build warnings [#1613](https://github.com/open-telemetry/opentelemetry-cpp/pull/1613) -* [API BUILD] Fix header only api singletons (#1520) [#1604](https://github.com/open-telemetry/opentelemetry-cpp/pull/1604) -* [METRICS SDK] Fix default value of - `OtlpHttpMetricExporterOptions::aggregation_temporality`. - [#1601](https://github.com/open-telemetry/opentelemetry-cpp/pull/1601) -* [METRICS EXAMPLE] Example for OTLP gRPC exporter for Metrics. [#1598](https://github.com/open-telemetry/opentelemetry-cpp/pull/1598) -* [SDK] Fix `LoggerContext::Shutdown` and tsan of `OtlpHttpClient` [#1592](https://github.com/open-telemetry/opentelemetry-cpp/pull/1592) -* [METRICS SDK] Fix 1585 - Multiple cumulative metric collections without - measurement recording. - [#1586](https://github.com/open-telemetry/opentelemetry-cpp/pull/1586) -* [BUILD] metrics warnings [#1583](https://github.com/open-telemetry/opentelemetry-cpp/pull/1583) -* [METRICS SDK] Fix ObservableInstrument::RemoveCallback [#1582](https://github.com/open-telemetry/opentelemetry-cpp/pull/1582) -* [SDK] Add error log when getting a http error code [#1581](https://github.com/open-telemetry/opentelemetry-cpp/pull/1581) -* [EXPORTER] ETW Exporter - Add support for Sampler and ID Generator [#1547](https://github.com/open-telemetry/opentelemetry-cpp/pull/1547) - -Notes: - -While [OpenTelemetry semantic -convention](https://github.com/open-telemetry/opentelemetry-specification/tree/main/semantic_conventions) -is still in experimental state, PR -[#1624](https://github.com/open-telemetry/opentelemetry-cpp/pull/1624) upgraded -it from 1.12.0 to 1.13.0 which **MAY** break the instrumentation library. Please -update the semantic convention in instrumentation library is needed. - -## [1.6.0] 2022-08-15 - -* [METRICS SDK] Calling Observable Instruments callback during metrics - collection - [#1554](https://github.com/open-telemetry/opentelemetry-cpp/pull/1554) -* [METRICS CI] Add CI jobs for new and deprecated metrics [#1531](https://github.com/open-telemetry/opentelemetry-cpp/pull/1531) -* [METRICS BUILD] Fix metrics asan and tsan CI [#1562](https://github.com/open-telemetry/opentelemetry-cpp/pull/1562) -* [METRICS SDK] remove throw check from metrics with noexcept [#1560](https://github.com/open-telemetry/opentelemetry-cpp/pull/1560) -* [METRICS SDK] fix metrics race condition [#1552](https://github.com/open-telemetry/opentelemetry-cpp/pull/1552) -* [METRICS SDK] Fix metrics context circular reference [#1535](https://github.com/open-telemetry/opentelemetry-cpp/pull/1535) -* [METRICS EXPORTER] Improve scope/instrument names in metrics ostream exporter [#1544](https://github.com/open-telemetry/opentelemetry-cpp/pull/1544) -* [METRICS BUILD] fix IWYU error in instruments.h [#1555](https://github.com/open-telemetry/opentelemetry-cpp/pull/1555) -* [EXPORTER] Prometheus exporter support Gauge Type [#1553](https://github.com/open-telemetry/opentelemetry-cpp/pull/1553) -* [METRICS SDK] Fix default Metric view name [#1515](https://github.com/open-telemetry/opentelemetry-cpp/pull/1515) -* [SDK] Fix infinitely waiting when shutdown with more than one running http - sessions. - [#1549](https://github.com/open-telemetry/opentelemetry-cpp/pull/1549) -* [METRICS SDK] Fix OTLP gRPC Metrics env variables [#1543](https://github.com/open-telemetry/opentelemetry-cpp/pull/1543) -* [METRICS SDK] Metric aggregation temporality controls [#1541](https://github.com/open-telemetry/opentelemetry-cpp/pull/1541) -* [METRICS SDK] Histogram min/max support [#1540](https://github.com/open-telemetry/opentelemetry-cpp/pull/1540) -* [METRICS EXPORTER] ostream exporter should print out resource attributes [#1523](https://github.com/open-telemetry/opentelemetry-cpp/pull/1523) -* [METRICS SDK] Support multiple async callbacks [#1495](https://github.com/open-telemetry/opentelemetry-cpp/pull/1495) -* [BUILD] Fix code scanning alert [#1530](https://github.com/open-telemetry/opentelemetry-cpp/pull/1530) -* [BUILD] Fix several compiling/linking errors [#1539](https://github.com/open-telemetry/opentelemetry-cpp/pull/1539) -* [TRACE SDK] Add SpanData getter for Span Recordable [#1508](https://github.com/open-telemetry/opentelemetry-cpp/pull/1508) -* [LOG SDK] Fix log sdk builder (#1486) [#1524](https://github.com/open-telemetry/opentelemetry-cpp/pull/1524) -* [METRICS SDK] Add configuration options for Aggregation creation [#1513](https://github.com/open-telemetry/opentelemetry-cpp/pull/1513) -* [METRICS TEST] Fix metrics unit test memory leack [#1533](https://github.com/open-telemetry/opentelemetry-cpp/pull/1533) -* [LOG SDK] Add log sdk builders (#1486) [#1524](https://github.com/open-telemetry/opentelemetry-cpp/pull/1524) - -## [1.5.0] 2022-07-29 - -* [EXPORTER BUILD] Add resources to dep list of prometheus exporter test [#1527](https://github.com/open-telemetry/opentelemetry-cpp/pull/1527) -* [BUILD] Don't require applications using jaeger exporter to know about libcurl - [#1518](https://github.com/open-telemetry/opentelemetry-cpp/pull/1518) -* [EXPORTER] Inline print_value() in ostream exporter [#1512](https://github.com/open-telemetry/opentelemetry-cpp/pull/1512) -* [SDK] fix: urlPaser will incorrect parsing url like `http://abc.com/xxx@xxx/a/b` - [#1511](https://github.com/open-telemetry/opentelemetry-cpp/pull/1511) -* [SDK] Rename `InstrumentationLibrary` to `InstrumentationScope` [#1507](https://github.com/open-telemetry/opentelemetry-cpp/pull/1507) -* [BUILD] Try to build nlohmann-json only it's depended. [#1505](https://github.com/open-telemetry/opentelemetry-cpp/pull/1505) -* [EXPORTER BUILD] Link opentelemetry_api to ETW exporter test [#1503](https://github.com/open-telemetry/opentelemetry-cpp/pull/1503) -* [SDK] Add automatically semantic conventions from the spec (#873) [#1497](https://github.com/open-telemetry/opentelemetry-cpp/pull/1497) -* [SDK] Use template class for in-memory data. [#1496](https://github.com/open-telemetry/opentelemetry-cpp/pull/1496) -* [SDK] fix compiler warnings [#1499](https://github.com/open-telemetry/opentelemetry-cpp/pull/1499) -* [TRACE SDK] Add trace sdk builders (#1393) [#1471](https://github.com/open-telemetry/opentelemetry-cpp/pull/1471) -* [METRICS BUILD] Enable bazel build for metrics proto files [#1489](https://github.com/open-telemetry/opentelemetry-cpp/pull/1489) -* [METRICS EXPORTER] Add metrics OTLP/HTTP exporter [#1487](https://github.com/open-telemetry/opentelemetry-cpp/pull/1487) -* [EXPORTER] fix otlp grpc exporter naming [#1488](https://github.com/open-telemetry/opentelemetry-cpp/pull/1488) -* [BUILD] Remove `--config Debug` when installing. [#1480](https://github.com/open-telemetry/opentelemetry-cpp/pull/1480) -* [EXPORTER] Fix endpoint in otlp grpc exporter [#1474](https://github.com/open-telemetry/opentelemetry-cpp/pull/1474) -* [EXAMPLE] Fix memory ownership of InMemorySpanExporter (#1473) [#1471](https://github.com/open-telemetry/opentelemetry-cpp/pull/1471) -* [EXPORTER TESTS] Prometheus unit test [#1461](https://github.com/open-telemetry/opentelemetry-cpp/pull/1461) -* [DOCS] Update docs to use relative code links. [#1447](https://github.com/open-telemetry/opentelemetry-cpp/pull/1447) -* [SDK] Remove reference to deprecated InstrumentationLibrary in OTLP [#1469](https://github.com/open-telemetry/opentelemetry-cpp/pull/1469) -* [SDK] Fix trace kIsSampled flag set incorrectly [#1465](https://github.com/open-telemetry/opentelemetry-cpp/pull/1465) -* [METRICS EXPORTER] OTLP gRPC Metrics Exporter [#1454](https://github.com/open-telemetry/opentelemetry-cpp/pull/1454) -* [EXPORTER] fix prometheus exporter failure type [#1460](https://github.com/open-telemetry/opentelemetry-cpp/pull/1460) -* [SDK] Fix build warnings about missing aggregates. [#1368](https://github.com/open-telemetry/opentelemetry-cpp/pull/1368) -* [EXT] `curl::HttpClient` use `curl_multi_handle` instead of creating a thread - for every request and it's able to reuse connections now. ([#1317](https://github.com/open-telemetry/opentelemetry-cpp/pull/1317)) -* [SEMANTIC CONVENTIONS] Upgrade to version 1.12.0 [#873](https://github.com/open-telemetry/opentelemetry-cpp/pull/873) - -## [1.4.1] 2022-06-19 - -* [METRICS SDK] Fix variables inizialization [#1430](https://github.com/open-telemetry/opentelemetry-cpp/pull/1430) -* [DOCS] Fixed broken link to OpenTelemetry.io (#1445) [#1446](https://github.com/open-telemetry/opentelemetry-cpp/pull/1446) -* [BUILD] Upgrade nlohmann_json to 3.10.5 (#1438) [#1441](https://github.com/open-telemetry/opentelemetry-cpp/pull/1441) -* [METRICS SDK] fix histogram [#1440](https://github.com/open-telemetry/opentelemetry-cpp/pull/1440) -* [DOCS] Fix GettingStarted documentation for Jaeger HTTP exporter (#1347) [#1439](https://github.com/open-telemetry/opentelemetry-cpp/pull/1439) -* [BUILD] install sdk-config.h [#1419](https://github.com/open-telemetry/opentelemetry-cpp/pull/1419) -* [EXAMPLE] Log current timestamp instead of epoch time [#1434](https://github.com/open-telemetry/opentelemetry-cpp/pull/1434) -* [METRICS SDK] Add attributes/dimensions to metrics ostream exporter [#1400](https://github.com/open-telemetry/opentelemetry-cpp/pull/1400) -* [SDK] Fix global log handle symbols when using dlopen [#1420](https://github.com/open-telemetry/opentelemetry-cpp/pull/1420) -* [METRICS] Only record non-negative / finite / Non-NAN histogram values([#1427](https://github.com/open-telemetry/opentelemetry-cpp/pull/1427)) -* [ETW EXPORTER] Fix ETW log exporter header inclusion [#1426](https://github.com/open-telemetry/opentelemetry-cpp/pull/1426) -* [ETW EXPORTER] Copy string_view passed to ETW exporter in PropertyVariant [#1425](https://github.com/open-telemetry/opentelemetry-cpp/pull/1425) -* [METRICS API/SDK] Pass state to async callback function. [#1408](https://github.com/open-telemetry/opentelemetry-cpp/pull/1408) -* [BUILD] fix nlohmann_json's (third party) include dir [#1415](https://github.com/open-telemetry/opentelemetry-cpp/pull/1415) -* [SDK] fix: WaitOnSocket select error when sockfd above FD_SETSIZE [#1410](https://github.com/open-telemetry/opentelemetry-cpp/pull/1410) -* [SDK] fix OTEL_INTERNAL_LOG_INFO [#1407](https://github.com/open-telemetry/opentelemetry-cpp/pull/1407) -* [DOCS] Document Getting Started with Prometheus and Grafana [#1396](https://github.com/open-telemetry/opentelemetry-cpp/pull/1396) - -## [1.4.0] 2022-05-17 - -* [API SDK] Upgrade proto to v0.17.0, update log data model ([#1383](https://github.com/open-telemetry/opentelemetry-cpp/pull/1383)) -* [BUILD] Alpine image ([#1382](https://github.com/open-telemetry/opentelemetry-cpp/pull/1382)) -* [LOGS SDK] Get span_id from context when Logger::Log received invalid span_id - ([#1398](https://github.com/open-telemetry/opentelemetry-cpp/pull/1398)) -* [METRICS SDK] Connect async storage with async instruments ([#1388](https://github.com/open-telemetry/opentelemetry-cpp/pull/1388)) -* [DOCS] Getting started document using ostream exporter ([#1394](https://github.com/open-telemetry/opentelemetry-cpp/pull/1394)) -* [BUILD] Fix missing link to nlohmann_json ([#1390](https://github.com/open-telemetry/opentelemetry-cpp/pull/1390)) -* [SDK] Fix sharing resource in batched exported spans ([#1386](https://github.com/open-telemetry/opentelemetry-cpp/pull/1386)) -* [PROTOCOL \& LOGS] Upgrade proto to v0.17.0, update log data model ([#1383](https://github.com/open-telemetry/opentelemetry-cpp/pull/1383)) -* [METRICS SDK] Remove un-necessary files. ([#1379](https://github.com/open-telemetry/opentelemetry-cpp/pull/1379)) -* [EXPORTER] Prometheus exporter meters and instrument name ([#1378](https://github.com/open-telemetry/opentelemetry-cpp/pull/1378)) -* [API] Add noexcept/const qualifier at missing places for Trace API. ([#1374](https://github.com/open-telemetry/opentelemetry-cpp/pull/1374)) -* [SDK] Fix empty tracestate header propagation ([#1373](https://github.com/open-telemetry/opentelemetry-cpp/pull/1373)) -* [METRICS SDK] Reuse temporal metric storage for sync storage ([#1369](https://github.com/open-telemetry/opentelemetry-cpp/pull/1369)) -* [SDK] Fix baggage propagation for empty/invalid baggage context ([#1367](https://github.com/open-telemetry/opentelemetry-cpp/pull/1367)) -* [BUILD] Export opentelemetry_otlp_recordable ([#1365](https://github.com/open-telemetry/opentelemetry-cpp/pull/1365)) -* [TESTS] Disable test on prometheus-cpp which not need ([#1363](https://github.com/open-telemetry/opentelemetry-cpp/pull/1363)) -* [METRICS] Fix class member initialization order ([#1360](https://github.com/open-telemetry/opentelemetry-cpp/pull/1360)) -* [METRICS SDK] Simplify SDK Configuration: Use View with default aggregation if - no matching View is configured - ([#1358](https://github.com/open-telemetry/opentelemetry-cpp/pull/1358)) -* [BUILD] Add missing include guard ([#1357](https://github.com/open-telemetry/opentelemetry-cpp/pull/1357)) -* [ETW EXPORTER] Fix scalar delete against array ([#1356](https://github.com/open-telemetry/opentelemetry-cpp/pull/1356)) -* [ETW EXPORTER] Conditional include for codecvt header ([#1355](https://github.com/open-telemetry/opentelemetry-cpp/pull/1355)) -* [BUILD] Use latest TraceLoggingDynamic.h ([#1354](https://github.com/open-telemetry/opentelemetry-cpp/pull/1354)) -* [SDK] Add explicit type cast in baggage UrlDecode ([#1353](https://github.com/open-telemetry/opentelemetry-cpp/pull/1353)) -* [METRICS SDK] Remove exporter registration to meter provider ([#1350](https://github.com/open-telemetry/opentelemetry-cpp/pull/1350)) -* [METRICS SDK] Fix output time in metrics OStream exporter ([#1346](https://github.com/open-telemetry/opentelemetry-cpp/pull/1346)) -* [BUILD] ostream metrics cmake ([#1344](https://github.com/open-telemetry/opentelemetry-cpp/pull/1344)) -* [BUILD] Link `opentelemetry_ext` with `opentelemetry_api` ([#1336](https://github.com/open-telemetry/opentelemetry-cpp/pull/1336)) -* [METRICS SDK] Enable metric collection for Async Instruments - Delta and - Cumulative - ([#1334](https://github.com/open-telemetry/opentelemetry-cpp/pull/1334)) -* [BUILD] Dependencies image as artifact ([#1333](https://github.com/open-telemetry/opentelemetry-cpp/pull/1333)) -* [EXAMPLE] Prometheus example ([#1332](https://github.com/open-telemetry/opentelemetry-cpp/pull/1332)) -* [METRICS EXPORTER] Prometheus exporter ([#1331](https://github.com/open-telemetry/opentelemetry-cpp/pull/1331)) -* [METRICS] Metrics histogram example ([#1330](https://github.com/open-telemetry/opentelemetry-cpp/pull/1330)) -* [TESTS] Replace deprecated googletest API ([#1327](https://github.com/open-telemetry/opentelemetry-cpp/pull/1327)) -* [BUILD] Fix Ninja path ([#1326](https://github.com/open-telemetry/opentelemetry-cpp/pull/1326)) -* [API] Update yield logic for ARM processor ([#1325](https://github.com/open-telemetry/opentelemetry-cpp/pull/1325)) -* [BUILD] Fix metrics compiler warnings ([#1328](https://github.com/open-telemetry/opentelemetry-cpp/pull/1328)) -* [METRICS SDK] Implement Merge and Diff operation for Histogram Aggregation ([#1303](https://github.com/open-telemetry/opentelemetry-cpp/pull/1303)) - -Notes: - -While opentelemetry-cpp Logs are still in experimental stage, -[#1383](https://github.com/open-telemetry/opentelemetry-cpp/pull/1383) updated -opentelemetry-proto to 0.17.0, which includes some breaking change in the -protocol, like -[this](https://github.com/open-telemetry/opentelemetry-proto/pull/373). This -makes `name` parameter for our log API unnecessary. However, this parameter is -marked deprecated instead of being removed in this release, and it will be -removed in future release. - -## [1.3.0] 2022-04-11 - -* [ETW EXPORTER] ETW provider handle cleanup ([#1322](https://github.com/open-telemetry/opentelemetry-cpp/pull/1322)) -* [BUILD] Move public definitions into `opentelemetry_api`. ([#1314](https://github.com/open-telemetry/opentelemetry-cpp/pull/1314)) -* [METRICS] OStream example ([#1312](https://github.com/open-telemetry/opentelemetry-cpp/pull/1312)) -* [BUILD] Rename `http_client_curl` to `opentelemetry_http_client_curl` ([#1301](https://github.com/open-telemetry/opentelemetry-cpp/pull/1301)) -* [METRICS SDK] Add InstrumentationInfo and Resource to the metrics data to be - exported. - ([#1299](https://github.com/open-telemetry/opentelemetry-cpp/pull/1299)) -* [TESTS] Add building test without RTTI ([#1294](https://github.com/open-telemetry/opentelemetry-cpp/pull/1294)) -* [METRICS SDK] Implement periodic exporting metric reader ([#1286](https://github.com/open-telemetry/opentelemetry-cpp/pull/1286)) -* [SDK] Bugfix: span SetAttribute crash ([#1283](https://github.com/open-telemetry/opentelemetry-cpp/pull/1283)) -* [BUG] Remove implicitly deleted default constructor ([#1267](https://github.com/open-telemetry/opentelemetry-cpp/pull/1267)) -* [METRICS SDK] Synchronous Metric collection (Delta , Cumulative) ([#1265](https://github.com/open-telemetry/opentelemetry-cpp/pull/1265)) -* [METRICS SDK] Metrics exemplar round 1 ([#1264](https://github.com/open-telemetry/opentelemetry-cpp/pull/1264)) -* [EXPORTER] Fix: use CURLOPT_TIMEOUT_MS to config OtlpHttpExporter's timeout - instead of CURLOPT_TIMEOUT - ([#1261](https://github.com/open-telemetry/opentelemetry-cpp/pull/1261)) -* [EXPORTER] Jaeger Exporter - Populate Span Links ([#1251](https://github.com/open-telemetry/opentelemetry-cpp/pull/1251)) -* [SDK] Reorder the destructor of members in LoggerProvider and TracerProvider ([#1245](https://github.com/open-telemetry/opentelemetry-cpp/pull/1245)) -* [METRICS SDK] Enable metric collection from MetricReader ([#1241](https://github.com/open-telemetry/opentelemetry-cpp/pull/1241)) -* [METRICS SDK] Asynchronous Aggregation storage ([#1232](https://github.com/open-telemetry/opentelemetry-cpp/pull/1232)) -* [METRICS SDK] Synchronous Instruments - Aggregation Storage(s) creation for - configured views - ([#1219](https://github.com/open-telemetry/opentelemetry-cpp/pull/1219)) -* [BUILD] Added s390x arch into CMake build. ([#1216](https://github.com/open-telemetry/opentelemetry-cpp/pull/1216)) -* [API] Allow extension of the lifetime of ContextStorage. ([#1214](https://github.com/open-telemetry/opentelemetry-cpp/pull/1214)) -* [METRICS SDK] Add Aggregation storage ([#1213](https://github.com/open-telemetry/opentelemetry-cpp/pull/1213)) -* [TESTS] Fix ostream_log_test Mac ([#1208](https://github.com/open-telemetry/opentelemetry-cpp/pull/1208)) -* [BUILD] Update grpc to v1.43.2 to support VS2022/MSVC 19.30 and bazel 5.0 ([#1207](https://github.com/open-telemetry/opentelemetry-cpp/pull/1207)) -* [DOCS] Benchmark documentation ([#1205](https://github.com/open-telemetry/opentelemetry-cpp/pull/1205)) -* [DOCS] Fix errors in SDK documentation ([#1201](https://github.com/open-telemetry/opentelemetry-cpp/pull/1201)) -* [METRICS EXPORTER] Ostream metric exporter ([#1196](https://github.com/open-telemetry/opentelemetry-cpp/pull/1196)) -* [Metrics SDK] Filtering metrics attributes ([#1191](https://github.com/open-telemetry/opentelemetry-cpp/pull/1191)) -* [Metrics SDK] Sync and Async Instruments SDK ([#1184](https://github.com/open-telemetry/opentelemetry-cpp/pull/1184)) -* [Metrics SDK] Add Aggregation as part of metrics SDK. ([#1178](https://github.com/open-telemetry/opentelemetry-cpp/pull/1178)) -* [BUILD] Cmake: thrift requires boost headers, include them as - Boost_INCLUDE_DIRS - ([#1100](https://github.com/open-telemetry/opentelemetry-cpp/pull/1100)) - -Notes: - -[#1301](https://github.com/open-telemetry/opentelemetry-cpp/pull/1301) added -`opentelemetry_` as prefix to http_client_curl library for resolving potential -naming conflict, this could break existing cmake build if http_client_curl is -listed as explicit dependency in user's cmake file. - -## [1.2.0] 2022-01-31 - -* [CI] Continuous benchmark tests as part of the CI ([#1174](https://github.com/open-telemetry/opentelemetry-cpp/pull/1174)) -* [API] Allow to use external abseil for bazel targets ([#1172](https://github.com/open-telemetry/opentelemetry-cpp/pull/1172)) -* [EXPORTER] Importing gsl::span if std::span is not available ([#1167](https://github.com/open-telemetry/opentelemetry-cpp/pull/1167)) -* [EXPORTER] Synchronized calls to Exporter::Export & Shutdown ([#1164](https://github.com/open-telemetry/opentelemetry-cpp/pull/1164)) -* [EXPORTER] OTLP http exporter block thread ([#1163](https://github.com/open-telemetry/opentelemetry-cpp/pull/1163)) -* [TESTS] Jaeger: ThriftSender unit test ([#1162](https://github.com/open-telemetry/opentelemetry-cpp/pull/1162)) -* [EXPORTER] InMemorySpanExporter shutdown fix ([#1161](https://github.com/open-telemetry/opentelemetry-cpp/pull/1161)) -* [EXPORTER] Fix leak in Jaeger exporter ([#1160](https://github.com/open-telemetry/opentelemetry-cpp/pull/1160)) -* [TESTS] ZipkinExporter unit-tests ([#1155](https://github.com/open-telemetry/opentelemetry-cpp/pull/1155)) -* [SDK] Logger: propagating resources through LoggerProvider ([#1154](https://github.com/open-telemetry/opentelemetry-cpp/pull/1154)) -* [SDK] Logger: support for instrumentation library ([#1149](https://github.com/open-telemetry/opentelemetry-cpp/pull/1149)) -* [SDK] Add log level for internal log of sdk ([#1147](https://github.com/open-telemetry/opentelemetry-cpp/pull/1147)) -* [METRICS] Metrics SDK: View API ([#1110](https://github.com/open-telemetry/opentelemetry-cpp/pull/1110)) - -Notes on experimental features: - -[#1149](https://github.com/open-telemetry/opentelemetry-cpp/pull/1149) and -[#1154](https://github.com/open-telemetry/opentelemetry-cpp/pull/1154) from -above CHANGELOG introduced API changes which are not backward compatible with -previous logs, please update API package to this release if -`ENABLE_LOGS_PREVIEW` is turned on (it is turned off by default). - -## [1.1.1] 2021-12-20 - -* [SDK] Rename OTEL_CPP_GET_ATTR macro, and define it using fully qualified attr - function - ([#1140](https://github.com/open-telemetry/opentelemetry-cpp/pull/1140)) -* [SDK] Default resource attributes and attributes in OTEL_RESOURCE_ATTRIBUTES - are missing when using Otlp*LogExporter - ([#1082](https://github.com/open-telemetry/opentelemetry-cpp/pull/1082)) -* [METRICS] Add Meter and MeterProvider in the SDK - ([#1078](https://github.com/open-telemetry/opentelemetry-cpp/pull/1078)) -* [EXPORTER] ZipkinExporter shutdown - ([#1153](https://github.com/open-telemetry/opentelemetry-cpp/pull/1153)) -* [EXPORTER] Jaeger exporter shutdown - ([#1150](https://github.com/open-telemetry/opentelemetry-cpp/pull/1150)) -* [EXPORTER] Bugfix: `jaeger::TUDPTransport::write` crash when `getaddrinfo` - returns error - ([#1116](https://github.com/open-telemetry/opentelemetry-cpp/pull/1116)) -* [EXPORTER] Bugfix: Jaeger exporter: extend supported attributes types - ([#1106](https://github.com/open-telemetry/opentelemetry-cpp/pull/1106)) -* [EXPORTER] Fix otlp generates null span ids - ([#1113](https://github.com/open-telemetry/opentelemetry-cpp/pull/1113)) -* [EXPORTER] Jaeger bazel (Linux only) - ([#1077](https://github.com/open-telemetry/opentelemetry-cpp/pull/1077)) -* [DOCS] Add note on DLL support - ([#1137](https://github.com/open-telemetry/opentelemetry-cpp/pull/1137)) -* [DOCS] Improve the instructions for Bazel build - ([#1136](https://github.com/open-telemetry/opentelemetry-cpp/pull/1136)) -* [DOCS] Document dependencies - ([#1119](https://github.com/open-telemetry/opentelemetry-cpp/pull/1119)) -* [DOCS] Dockerfile for quick demo/troubleshooting purpose - ([#905](https://github.com/open-telemetry/opentelemetry-cpp/pull/905)) -* [TESTS] Fix data race in BM_ThreadYieldSpinLockThrashing - ([#1099](https://github.com/open-telemetry/opentelemetry-cpp/pull/1099)) -* [EXAMPLE] Otlp gRPC log example - ([#1083](https://github.com/open-telemetry/opentelemetry-cpp/pull/1083)) -* [BUILD] C++20 not Building with VS2019 - ([#1144](https://github.com/open-telemetry/opentelemetry-cpp/pull/1144)) -* [BUILD] Mark tags to bazel - targets([#1075](https://github.com/open-telemetry/opentelemetry-cpp/pull/1075)) - -## [1.1.0] 2021-11-19 - -* [BUILD] build release tarball when nlohmann-json not installed - ([#1074](https://github.com/open-telemetry/opentelemetry-cpp/pull/1074)) -* [SDK] Bugfix: regex is neither working on GCC 4.9.x - ([#1069](https://github.com/open-telemetry/opentelemetry-cpp/pull/1069)) -* [SDK] Improvement: span_id should not break strict aliasing. - ([#1068](https://github.com/open-telemetry/opentelemetry-cpp/pull/1068)) -* [EXAMPLE] OTLP HTTP log example - ([#1062](https://github.com/open-telemetry/opentelemetry-cpp/pull/1062)) -* [SDK] OTLP gRPC log export should fail after shutdown - ([#1064](https://github.com/open-telemetry/opentelemetry-cpp/pull/1064)) -* [BUILD] Building otlp exporter from the release tarball - ([#1056](https://github.com/open-telemetry/opentelemetry-cpp/pull/1056)) -* [METRICS] Move old metrics implementation to different directory, and rename - targets to \_deprecated - ([#1053](https://github.com/open-telemetry/opentelemetry-cpp/pull/1053)) -* [EXPORTER] Add OTLP/gRPC Log Exporter - ([#1048](https://github.com/open-telemetry/opentelemetry-cpp/pull/1048)) -* [EXPORTER] Prometheus Exporter - ([#1031](https://github.com/open-telemetry/opentelemetry-cpp/pull/1031)) -* [EXPORTER] Add OTLP/HTTP Log Exporter - ([#1030](https://github.com/open-telemetry/opentelemetry-cpp/pull/1030)) -* [SDK] fix: issue 368- consistent namespace scope resolution - ([#1008](https://github.com/open-telemetry/opentelemetry-cpp/pull/1008)) - -## [1.0.1] 2021-10-21 - -* [EXPORTER] Exports span attributes to ETW - ([#1021](https://github.com/open-telemetry/opentelemetry-cpp/pull/1021)) -* [BUILD] cmake: add FindThrift.cmake find module method for thrift - ([#1020](https://github.com/open-telemetry/opentelemetry-cpp/pull/1020)) -* [BUILD] Fix nlohmann_json package dependency - ([#1017](https://github.com/open-telemetry/opentelemetry-cpp/pull/1017)) -* [EXPORTER] Change OTLP/HTTP default port from 4317 to 4318 - ([#1018](https://github.com/open-telemetry/opentelemetry-cpp/pull/1018)) -* [EXPORTER] ETW Log Exporter - ([#1006](https://github.com/open-telemetry/opentelemetry-cpp/pull/1006)) -* [API] Adding new Logger:log() method - ([#1005](https://github.com/open-telemetry/opentelemetry-cpp/pull/1005)) -* [EXPORTER] Remove scheme from OTLP endpoint before passing to gRPC - ([#988](https://github.com/open-telemetry/opentelemetry-cpp/pull/988)) -* [BUILD] Update opentelemetry-proto for bazel build to 0.9.0 - ([#984](https://github.com/open-telemetry/opentelemetry-cpp/pull/984)) -* [BUILD] Cross compling grpc_cpp_plugin not found bug - ([#982](https://github.com/open-telemetry/opentelemetry-cpp/pull/982)) -* [EXPORTER] Support environment variables for both `OtlpGrpcExporter` and - `OtlpHttpExporter` - ([#983](https://github.com/open-telemetry/opentelemetry-cpp/pull/983)) -* [API/SDK] Add schema_url support to both Resource and InstrumentationLibrary - ([#979](https://github.com/open-telemetry/opentelemetry-cpp/pull/979)) -* [BUILD] Fix build issue where _memcpy_ was not declared in scope - ([#985](https://github.com/open-telemetry/opentelemetry-cpp/issues/985)) - -## [1.0.0] 2021-09-16 - -### API - -* Document DefaultSpan, remove DefaultTracer - ([#959](https://github.com/open-telemetry/opentelemetry-cpp/pull/959)) -* Separate baggage<->Context api from Baggage Propagator - ([#963](https://github.com/open-telemetry/opentelemetry-cpp/pull/963)) -* Remove unused public API to_span_ptr - ([#964](https://github.com/open-telemetry/opentelemetry-cpp/pull/964)) -* :collision: Make span context management public - ([#967](https://github.com/open-telemetry/opentelemetry-cpp/pull/967)) -* Support determining parent span from Context while creating new Span - ([#969](https://github.com/open-telemetry/opentelemetry-cpp/pull/969)) -* :collision: Traces: Add note on experimental semantic convention - implementation, prefix semantics headers with experimental tag - ([#970](https://github.com/open-telemetry/opentelemetry-cpp/pull/970)) -* Increment OPENTELEMETRY_ABI_VERSION_NO to 1 - ([#980](https://github.com/open-telemetry/opentelemetry-cpp/pull/980)) - -### SDK - -* Clean up `GetEnvironmentVariable` and remove unused variable under `NO_GETENV` - ([#976](https://github.com/open-telemetry/opentelemetry-cpp/pull/976)) -* :collision: Resources: Add note on experimental semantic convention - implementation, prefix semantics headers with experimental tag - ([#970](https://github.com/open-telemetry/opentelemetry-cpp/pull/970)) - -### OTLP Exporter - -* :bug: Ignore status description if status code is not Error - ([#962](https://github.com/open-telemetry/opentelemetry-cpp/pull/962)) -* :collision: Make Otlp exporter configuration environment variables - specs-compliant - ([#974](https://github.com/open-telemetry/opentelemetry-cpp/pull/974)) - -### Zipkin Exporter - -* :bug: Don't set parentId in case parentId is empty - ([#943](https://github.com/open-telemetry/opentelemetry-cpp/pull/943)) -* :rocket: Extend zipkin exporter with ability to provide headers - ([#951](https://github.com/open-telemetry/opentelemetry-cpp/pull/951)) - -### DOCS - -* :book: Add getting-started documentation for SDK: - ([#942](https://github.com/open-telemetry/opentelemetry-cpp/pull/942)) -* :book: Remove unnecessary spaces and spelling of gRPC in README - ([#965](https://github.com/open-telemetry/opentelemetry-cpp/pull/965)) - -### BUILD - -* Disable bazel build for gcc 4.8, upgrade versions for grpc(v1.39.1) and - bazel(4.2.0), document bazel support - ([#953](https://github.com/open-telemetry/opentelemetry-cpp/pull/953)) -* Move CMake config template to cmake folder - ([#958](https://github.com/open-telemetry/opentelemetry-cpp/pull/958)) -* Enable CMake to search the new package variable `_ROOT` - ([#975](https://github.com/open-telemetry/opentelemetry-cpp/pull/975)) -* :bug: Do not override CMAKE_CXX_STANDARD - ([#977](https://github.com/open-telemetry/opentelemetry-cpp/pull/977)) - -### :construction: Experiemental Features (Will change in future) - -* Semantic Conventions for traces - As the specs is still experimental, the - implementation will change in future. -* Semantic Convention for resource - As the specs is still experimental, the - implementation will change in future. -* Logs and Metrics API & SDK - These are not compliant, and are behind feature - flag. Not recommended to use for now. - -## [1.0.0-rc4] 2021-08-04 - -* [EXPORTER] `BREAKING CHANGE` Fix default HTTP port for OTLP HTTP Exporter - ([#939](https://github.com/open-telemetry/opentelemetry-cpp/pull/939)) -* [API] Fix timeout calculation for Tracer::Flush() and Tracer::Close() - ([#937](https://github.com/open-telemetry/opentelemetry-cpp/pull/937)) -* [API] Fix for Stack::Resize that new_capacity is not assigned to capacity_ - ([#934](https://github.com/open-telemetry/opentelemetry-cpp/pull/934)) -* [SDK] Fix race condition in circular buffer simulation test - ([#931](https://github.com/open-telemetry/opentelemetry-cpp/pull/931)) -* [EXPORTER] Fix error logging in Jaeger Exporter - ([#930](https://github.com/open-telemetry/opentelemetry-cpp/pull/930)) -* [BUILD] Use latest grpc version (v1.39.0) for cmake build of otlp exporter - ([#927](https://github.com/open-telemetry/opentelemetry-cpp/pull/927)) -* [EXPORTER] Add Jaeger Thrift HTTP exporter - ([#926](https://github.com/open-telemetry/opentelemetry-cpp/pull/926)) -* [SDK] Move env-var read logic to common dir, and optional reading of env-var - ([#924](https://github.com/open-telemetry/opentelemetry-cpp/pull/924)) -* [EXPORTER] Remove recordable header from CMake install rules for exporters - ([#923](https://github.com/open-telemetry/opentelemetry-cpp/pull/923)) -* [EXPORTER] `BREAKING CHANGE` Rename Recordable to JaegerRecordable in Jaeger - exporter - ([#919](https://github.com/open-telemetry/opentelemetry-cpp/pull/919)) -* [EXPORTER] `BREAKING CHANGE` Rename Jaeger exporter target - ([#918](https://github.com/open-telemetry/opentelemetry-cpp/pull/918)) -* [EXPORTER] Add Zipkin exporter example - ([#917](https://github.com/open-telemetry/opentelemetry-cpp/pull/917)) -* [EXPORTER] Bazel build for Zipkin exorter - ([#916](https://github.com/open-telemetry/opentelemetry-cpp/pull/916)) -* [BUILD] Allow to use local GSL - ([#915](https://github.com/open-telemetry/opentelemetry-cpp/pull/915)) -* [DOCS] Document vcpkg toolchain configuration - ([#913](https://github.com/open-telemetry/opentelemetry-cpp/pull/913)) -* [SDK] Fix for resource deletion after tracer provider shutdown - ([#911](https://github.com/open-telemetry/opentelemetry-cpp/pull/911)) -* [BUILD] Add bazel build for grpc example - ([#910](https://github.com/open-telemetry/opentelemetry-cpp/pull/910)) -* [EXPORTER] Add resource and instrumentation library support for - OStreamSpanExporter - ([#906](https://github.com/open-telemetry/opentelemetry-cpp/pull/906)) -* [API] Adding semantic-convention attributes for trace - ([#868](https://github.com/open-telemetry/opentelemetry-cpp/pull/868)) - -## [1.0.0-rc3] 2021-07-12 - -* [DOCS] Add doxygen reference docs for SDK - ([#902](https://github.com/open-telemetry/opentelemetry-cpp/pull/902)) -* [EXPORTER] Jaeger Exporter - Populate resource attributes into process tags in - Jaeger ([#897](https://github.com/open-telemetry/opentelemetry-cpp/pull/897)) -* [EXPORTER] Zipkin Exporter - Report Event timestamp into microseconds - ([#896](https://github.com/open-telemetry/opentelemetry-cpp/pull/896)) -* [EXPORTER] Jaeger Exporter - Handle span events - ([#895](https://github.com/open-telemetry/opentelemetry-cpp/pull/895)) -* [DOCS] Fix API docs for Scope object - ([#894](https://github.com/open-telemetry/opentelemetry-cpp/pull/894)) -* [BUILD] Fix Linking error for libcurl on some macOS environments - ([#893](https://github.com/open-telemetry/opentelemetry-cpp/pull/893)) -* [API] Context cleanup from Runtime Storage - ([#885](https://github.com/open-telemetry/opentelemetry-cpp/pull/885)) -* [DOCS] Document strategy to avoid conflict between two different versions of - Abseil ([#883](https://github.com/open-telemetry/opentelemetry-cpp/pull/883/)) -* [EXPORTER] ETW Exporter - Document example for ETW Exporter - ([#882](https://github.com/open-telemetry/opentelemetry-cpp/pull/882)) -* [SDK] Create Span with Valid spanId and traceId irrespective of Sampling - decision - ([#879](https://github.com/open-telemetry/opentelemetry-cpp/pull/879)) -* [EXPORTER] Jaeger Exporter - Rename bswap macros to avoid clash on some - systems ([#876](https://github.com/open-telemetry/opentelemetry-cpp/pull/876)) -* [API] Add Semantics Conventions attributes for Resources - ([#872](https://github.com/open-telemetry/opentelemetry-cpp/pull/872)) -* [BUILD] Use nlohmann-json from submodules if not already installed - ([#870](https://github.com/open-telemetry/opentelemetry-cpp/pull/870)) - -## [1.0.0-rc2] 2021-06-18 - -* [EXPORTER] Jaeger Exporter - Support for Instrumentation Library - ([#864](https://github.com/open-telemetry/opentelemetry-cpp/pull/864)) -* [TESTS] Adding benchmark tests for baggage api - ([#861](https://github.com/open-telemetry/opentelemetry-cpp/pull/861)) -* [BUILD] Fix for GCC9/C++20 Support for using STL for modern C++ features - ([#860](https://github.com/open-telemetry/opentelemetry-cpp/pull/860)) -* [TESTS] Adding benchmark tests for span create api - ([#856](https://github.com/open-telemetry/opentelemetry-cpp/pull/856)) -* [BUILD] Fix for using Abseil library for modern C++ features - ([#850](https://github.com/open-telemetry/opentelemetry-cpp/pull/850)) -* [BUILD] Fix issues with win32/x86 compilation - ([#847](https://github.com/open-telemetry/opentelemetry-cpp/pull/847)) -* [DOCS] Document OSS dependencies and their licenses - ([#844](https://github.com/open-telemetry/opentelemetry-cpp/pull/844)) -* [BUILD] Various fixes to build with Visual Studio 2015 - ([#840](https://github.com/open-telemetry/opentelemetry-cpp/pull/840)) -* [INSTRUMENTATION] HTTPClient: Change support for full URL argument - ([#833](https://github.com/open-telemetry/opentelemetry-cpp/pull/833)) -* [EXPORTER] Jaeger Exporter - fix endianness of Jaeger IDs for transmission - ([#832](https://github.com/open-telemetry/opentelemetry-cpp/pull/832)) -* [INSTRUMENTATION] fix protobuf compilation warning in gRPC example - ([#830](https://github.com/open-telemetry/opentelemetry-cpp/pull/830)) -* [EXPORTER] `BREAKING CHANGE` - Add OTLP/HTTP+JSON Protocol exporter; Rename - `OtlpExporter` to `OtlpGrpcExporter` - ([#810](https://github.com/open-telemetry/opentelemetry-cpp/pull/810)) - -## [1.0.0-rc1] 2021-06-04 - -* [BUILD] Enable Jaeger exporter build in Windows - ([#815](https://github.com/open-telemetry/opentelemetry-cpp/pull/815)) -* [DOCS] Versioning doc update to clarify release and versioning policy - ([#811](https://github.com/open-telemetry/opentelemetry-cpp/pull/811)) -* [LOGS] Move Logging implementation under feature-flag - ([#807](https://github.com/open-telemetry/opentelemetry-cpp/pull/807)) -* [BUILD] Filter metric headers files from `opentelemetry-api` and - `opentelemetry-sdk` targets if metrics feature-flag is disabled - ([#806](https://github.com/open-telemetry/opentelemetry-cpp/pull/806)) -* [BUILD] Fix install rule for ostream exporter, Jaeger, ETW, ElasticSearch - ([#805](Fix install rule for header files of ostream exporter)) -* [API/SDK] Switch from mpark::variant to absl::variant as default - ([#771](https://github.com/open-telemetry/opentelemetry-cpp/pull/771)) -* [API/SDK] Support `const char *` as acceptable data type for attributes and - resources - ([#771](https://github.com/open-telemetry/opentelemetry-cpp/pull/771)) -* [EXAMPLE] gRPC instrumentation example with context propagation - ([#729](https://github.com/open-telemetry/opentelemetry-cpp/pull/729)) - -## [0.7.0] 2021-05-26 - -* [METRICS] Move metrics api/sdk under preview feature flag - ([#745](https://github.com/open-telemetry/opentelemetry-cpp/pull/745)) -* [DOCS] Add instructions to build using Bazel - ([#747](https://github.com/open-telemetry/opentelemetry-cpp/pull/747)) -* [DOCS] Update copyright headers - ([#754](https://github.com/open-telemetry/opentelemetry-cpp/pull/754)) -* [EXPORTER] Populate resource to OTLP proto data - ([#758](https://github.com/open-telemetry/opentelemetry-cpp/pull/758)) -* [CI] Add CodeQL security scan CI workflow - ([#770](https://github.com/open-telemetry/opentelemetry-cpp/pull/770)) -* [BUILD] Enable building API only CMake Project - ([#778](https://github.com/open-telemetry/opentelemetry-cpp/pull/778)) -* [SDK] Fix for sampling of root span - ([#784](https://github.com/open-telemetry/opentelemetry-cpp/pull/784)) -* [CI] Add Jaeger exporter to CMake CI build - ([#786](https://github.com/open-telemetry/opentelemetry-cpp/pull/786)) -* [API] `BREAKING CHANGE` - Tracer::WithActiveSpan() to return Scope object - intead of unique_ptr - ([#788](https://github.com/open-telemetry/opentelemetry-cpp/pull/788)) -* [DOCS] Add docs for nested spans and context propagation in readthedocs - ([#792](https://github.com/open-telemetry/opentelemetry-cpp/pull/792)) -* [CI] Output verbose error for failed unit-test in CI - ([#796](https://github.com/open-telemetry/opentelemetry-cpp/pull/796)) - -## [0.6.0] 2021-05-11 - -* [EXPORTER] Add Jaeger exporter - ([#534](https://github.com/open-telemetry/opentelemetry-cpp/pull/534)) -* [SDK] Support multiple processors - ([#692](https://github.com/open-telemetry/opentelemetry-cpp/pull/692)) -* [SDK] Add instrumentation library and multiple tracer support - ([#693](https://github.com/open-telemetry/opentelemetry-cpp/pull/693)) -* [SDK] Resource integration with Exporters - ([#706](https://github.com/open-telemetry/opentelemetry-cpp/pull/706)) -* [EXAMPLE] Enhance existing http example with propagation - ([#727](https://github.com/open-telemetry/opentelemetry-cpp/pull/727)) - -## [0.5.0] 2021-04-26 - -* [SDK] Support custom span-id and trace-id generator - ([#681](https://github.com/open-telemetry/opentelemetry-cpp/pull/681)) -* [SDK] Add SpanContext (and TraceState) to Recordable - ([#667](https://github.com/open-telemetry/opentelemetry-cpp/pull/667)) -* [SDK] Global Propagator - ([#668](https://github.com/open-telemetry/opentelemetry-cpp/pull/668)) -* [SDK] Create SharedContext for updating span pipeline - ([#650](https://github.com/open-telemetry/opentelemetry-cpp/pull/650)) -* [API] Baggage implementation - ([#676](https://github.com/open-telemetry/opentelemetry-cpp/pull/676)) -* [API] Move class from opentelemetry::core namespace to opentelemetry::common - namespace - ([#686](https://github.com/open-telemetry/opentelemetry-cpp/pull/686)) - -## [0.4.0] 2021-04-12 - -* [EXPORTER] ETW Exporter enhancements - ([#519](https://github.com/open-telemetry/opentelemetry-cpp/pull/519)) -* [EXPORTER] Read Zipkin endpoint from environment variable. - ([#624](https://github.com/open-telemetry/opentelemetry-cpp/pull/624)) -* [EXPORTER] Split Zpages webserver hosting from Exporter - ([#626](https://github.com/open-telemetry/opentelemetry-cpp/pull/626)) -* [EXPORTER] ETW Exporter Usage Instructions - ([#628](https://github.com/open-telemetry/opentelemetry-cpp/pull/628)) -* [INSTRUMENTATION] HTTP Client/Server Instrumentation example - ([#632](https://github.com/open-telemetry/opentelemetry-cpp/pull/632)) -* [EXPORTER] Enable tls authentication for otlp grpc exporter ([#635](Enable tls - authentication for otlp grpc exporter)) -* [API] Refactoring trace_state to reuse common functionality in baggage - ([#638](https://github.com/open-telemetry/opentelemetry-cpp/pull/638/files)) - -## [0.3.0] 2021-03-19 - -* [EXPORTER] Added Zipkin Exporter. - ([#471](https://github.com/open-telemetry/opentelemetry-cpp/pull/471)) -* [API] Added Jaeger propagator. - ([#599](https://github.com/open-telemetry/opentelemetry-cpp/pull/599)) -* [PROPAGATOR] Added Composite Propagator - ([#597](https://github.com/open-telemetry/opentelemetry-cpp/pull/597)) -* [API] Propagate traceflag from parent - ([#603](https://github.com/open-telemetry/opentelemetry-cpp/pull/603)) -* [DOCS] Add sphinx support for api doc generation - ([595](https://github.com/open-telemetry/opentelemetry-cpp/pull/595)) -* [SDK] Add service.name if missing in Resource - ([#616](https://github.com/open-telemetry/opentelemetry-cpp/pull/616)) - -## [0.2.0] 2021-03-02 - -* [SDK] Added `ForceFlush` to `TracerProvider`. - ([#588](https://github.com/open-telemetry/opentelemetry-cpp/pull/588)). -* [SDK] Added Resource API. - ([#502](https://github.com/open-telemetry/opentelemetry-cpp/pull/502)) -* [API] Modified TraceState support for w3c trace context as per specs. -* [SDK] TraceState implementation as per spec - ([#551](https://github.com/open-telemetry/opentelemetry-cpp/pull/551)) -* [API] Added B3 Propagator. - ([#523](https://github.com/open-telemetry/opentelemetry-cpp/pull/523)) -* [Exporter] Added ETW Exporter. - ([#376](https://github.com/open-telemetry/opentelemetry-cpp/pull/376)) -* [CI] Enable cache for Bazel for faster builds. - ([#505](https://github.com/open-telemetry/opentelemetry-cpp/pull/505)) - -## [0.0.1] 2020-12-16 - -### Added - -* Trace API and SDK experimental -* OTLP Exporter - -### Changed - -### Removed diff --git a/ext/opentelemetry-cpp-1.21.0/CMakeLists.txt b/ext/opentelemetry-cpp-1.21.0/CMakeLists.txt deleted file mode 100644 index 4e65f0493a..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/CMakeLists.txt +++ /dev/null @@ -1,927 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.14) - -# See https://cmake.org/cmake/help/latest/policy/CMP0074.html required by -# certain version of zlib which CURL depends on. -if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12") - cmake_policy(SET CMP0074 NEW) -endif() - -# Allow to use normal variable for option() -if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13") - cmake_policy(SET CMP0077 NEW) -endif() - -# Prefer CMAKE_MSVC_RUNTIME_LIBRARY if possible -if(POLICY CMP0091) - cmake_policy(SET CMP0091 NEW) -endif() - -if(POLICY CMP0092) - # https://cmake.org/cmake/help/latest/policy/CMP0092.html#policy:CMP0092 Make - # sure the /W3 is not removed from CMAKE_CXX_FLAGS since CMake 3.15 - cmake_policy(SET CMP0092 OLD) -endif() - -# MSVC RTTI flag /GR should not be not added to CMAKE_CXX_FLAGS by default. @see -# https://cmake.org/cmake/help/latest/policy/CMP0117.html -if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20.0") - cmake_policy(SET CMP0117 NEW) -endif() - -project(opentelemetry-cpp) - -# Mark variables as used so cmake doesn't complain about them -mark_as_advanced(CMAKE_TOOLCHAIN_FILE) - -# Note: CMAKE_FIND_PACKAGE_PREFER_CONFIG requires cmake 3.15. Prefer cmake -# CONFIG search mode to find dependencies. This is important to properly find -# protobuf versions 3.22.0 and above due to the abseil-cpp dependency. -set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE) - -# Don't use customized cmake modules if vcpkg is used to resolve dependence. -if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) - list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/") -endif() - -if(EXISTS "${CMAKE_SOURCE_DIR}/third_party_release") - file(STRINGS "${CMAKE_SOURCE_DIR}/third_party_release" third_party_tags) - foreach(third_party ${third_party_tags}) - string(REGEX REPLACE "^[ ]+" "" third_party ${third_party}) - string(REGEX MATCH "^[^=]+" third_party_name ${third_party}) - string(REPLACE "${third_party_name}=" "" third_party_tag ${third_party}) - set(${third_party_name} "${third_party_tag}") - endforeach() -endif() - -if(DEFINED ENV{ARCH}) - # Architecture may be specified via ARCH environment variable - set(ARCH $ENV{ARCH}) -else() - # Autodetection logic that populates ARCH variable - if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*") - # Windows may report AMD64 even if target is 32-bit - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(ARCH x64) - elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) - set(ARCH x86) - endif() - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*") - # Windows may report x86 even if target is 64-bit - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(ARCH x64) - elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) - set(ARCH x86) - endif() - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "powerpc") - # AIX will report the processor as 'powerpc' even if building in 64-bit mode - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(ARCH ppc64) - else() - set(ARCH ppc32) - endif() - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES - "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)") - set(ARCH arm64) - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)") - set(ARCH arm) - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64le") - set(ARCH ppc64le) - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64") - set(ARCH ppc64) - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(mips.*|MIPS.*)") - set(ARCH mips) - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(riscv.*|RISCV.*)") - set(ARCH riscv) - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(s390x.*|S390X.*)") - set(ARCH s390x) - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(sparc.*|SPARC.*)") - set(ARCH sparc) - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(loongarch.*|LOONGARCH.*)") - set(ARCH loongarch) - else() - message( - FATAL_ERROR - "opentelemetry-cpp: unrecognized target processor ${CMAKE_SYSTEM_PROCESSOR} configuration!" - ) - endif() -endif() -message(STATUS "Building for architecture ARCH=${ARCH}") - -# Autodetect vcpkg toolchain -if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) - set(CMAKE_TOOLCHAIN_FILE - "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" - CACHE STRING "") -endif() - -if(VCPKG_CHAINLOAD_TOOLCHAIN_FILE) - include("${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}") -endif() - -option(WITH_ABI_VERSION_1 "ABI version 1" ON) -option(WITH_ABI_VERSION_2 "EXPERIMENTAL: ABI version 2 preview" OFF) - -file(READ "${CMAKE_CURRENT_LIST_DIR}/api/include/opentelemetry/version.h" - OPENTELEMETRY_CPP_HEADER_VERSION_H) - -# -# We do not want to have WITH_ABI_VERSION = "1" or "2", and instead prefer two -# distinct flags, WITH_ABI_VERSION_1 and WITH_ABI_VERSION_2. -# -# This allows: -# -# * to have a specific option description for each ABI -# * to mark experimental/stable/deprecated on flags, for clarity -# * to search for exact abi usage move easily, discouraging: -# -# * cmake -DWITH_ABI_VERSION=${ARG} -# -# While not supported, having distinct WITH_ABI_VERSION_1 and WITH_ABI_VERSION_2 -# flags also opens the possibility to support multiple ABI concurrently, should -# that become necessary. -# -if(WITH_ABI_VERSION_1 AND WITH_ABI_VERSION_2) - # - # Only one ABI is supported in a build. - # - message( - FATAL_ERROR "Set either WITH_ABI_VERSION_1 or WITH_ABI_VERSION_2, not both") -endif() - -if(WITH_ABI_VERSION_2) - set(OPENTELEMETRY_ABI_VERSION_NO "2") -elseif(WITH_ABI_VERSION_1) - set(OPENTELEMETRY_ABI_VERSION_NO "1") -else() - if(OPENTELEMETRY_CPP_HEADER_VERSION_H MATCHES - "OPENTELEMETRY_ABI_VERSION_NO[ \t\r\n]+\"?([0-9]+)\"?") - math(EXPR OPENTELEMETRY_ABI_VERSION_NO ${CMAKE_MATCH_1}) - else() - message( - FATAL_ERROR - "OPENTELEMETRY_ABI_VERSION_NO not found on ${CMAKE_CURRENT_LIST_DIR}/api/include/opentelemetry/version.h" - ) - endif() -endif() - -message(STATUS "OPENTELEMETRY_ABI_VERSION_NO=${OPENTELEMETRY_ABI_VERSION_NO}") - -if(OPENTELEMETRY_CPP_HEADER_VERSION_H MATCHES - "OPENTELEMETRY_VERSION[ \t\r\n]+\"?([^\"]+)\"?") - set(OPENTELEMETRY_VERSION ${CMAKE_MATCH_1}) -else() - message( - FATAL_ERROR - "OPENTELEMETRY_VERSION not found on ${CMAKE_CURRENT_LIST_DIR}/api/include/opentelemetry/version.h" - ) -endif() - -message(STATUS "OPENTELEMETRY_VERSION=${OPENTELEMETRY_VERSION}") - -option(WITH_NO_DEPRECATED_CODE "Do not include deprecated code" OFF) - -set(WITH_STL - "OFF" - CACHE STRING "Which version of the Standard Library for C++ to use") - -option(WITH_GSL - "Whether to use Guidelines Support Library for C++ latest features" OFF) - -set(OPENTELEMETRY_INSTALL_default ON) -if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - set(OPENTELEMETRY_INSTALL_default OFF) -endif() -option(OPENTELEMETRY_INSTALL "Whether to install opentelemetry targets" - ${OPENTELEMETRY_INSTALL_default}) - -include("${PROJECT_SOURCE_DIR}/cmake/tools.cmake") - -if(NOT WITH_STL STREQUAL "OFF") - # These definitions are needed for test projects that do not link against - # opentelemetry-api library directly. We ensure that variant implementation - # (absl::variant or std::variant) in variant unit test code is consistent with - # the global project build definitions. Optimize for speed to reduce the hops - if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - if(CMAKE_BUILD_TYPE MATCHES Debug) - # Turn off optimizations for DEBUG - set(MSVC_CXX_OPT_FLAG "/Od") - else() - string(REGEX MATCH "\/O" result ${CMAKE_CXX_FLAGS}) - if(NOT ${result} MATCHES "\/O") - set(MSVC_CXX_OPT_FLAG "/O2") - endif() - endif() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MSVC_CXX_OPT_FLAG}") - endif() -endif() - -option(WITH_OTLP_RETRY_PREVIEW - "Whether to enable experimental retry functionality" OFF) - -option(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW - "Whether to enable mTLS support fro gRPC" OFF) - -option(WITH_OTLP_GRPC "Whether to include the OTLP gRPC exporter in the SDK" - OFF) - -option(WITH_OTLP_HTTP "Whether to include the OTLP http exporter in the SDK" - OFF) - -option(WITH_OTLP_FILE "Whether to include the OTLP file exporter in the SDK" - OFF) - -option( - WITH_OTLP_HTTP_COMPRESSION - "Whether to include gzip compression for the OTLP http exporter in the SDK" - OFF) - -option(WITH_CURL_LOGGING "Whether to enable select CURL verbosity in OTel logs" - OFF) - -option(WITH_ZIPKIN "Whether to include the Zipkin exporter in the SDK" OFF) - -option(WITH_PROMETHEUS "Whether to include the Prometheus Client in the SDK" - OFF) - -option(WITH_ELASTICSEARCH - "Whether to include the Elasticsearch Client in the SDK" OFF) - -option(WITH_NO_GETENV "Whether the platform supports environment variables" OFF) - -option(BUILD_TESTING "Whether to enable tests" ON) - -option(WITH_BENCHMARK "Whether to build benchmark program" ON) - -option(BUILD_W3CTRACECONTEXT_TEST "Whether to build w3c trace context" OFF) - -option(OTELCPP_MAINTAINER_MODE "Build in maintainer mode (-Wall -Werror)" OFF) - -option(WITH_OPENTRACING "Whether to include the Opentracing shim" OFF) - -option(OTELCPP_VERSIONED_LIBS "Whether to generate the versioned shared libs" - OFF) - -# -# This option is experimental, subject to change in the spec: -# -# * https://github.com/open-telemetry/opentelemetry-specification/issues/2232 -# -option(WITH_REMOVE_METER_PREVIEW - "EXPERIMENTAL, ABI BREAKING: Allow to remove a meter" OFF) - -if(OTELCPP_VERSIONED_LIBS AND NOT BUILD_SHARED_LIBS) - message(FATAL_ERROR "OTELCPP_VERSIONED_LIBS=ON requires BUILD_SHARED_LIBS=ON") -endif() - -if(WIN32) - option(WITH_ETW "Whether to include the ETW Exporter in the SDK" ON) -else() - if(DEFINED (WITH_ETW)) - message(FATAL_ERROR "WITH_ETW is only supported on Windows") - endif() -endif(WIN32) - -# Do not convert deprecated message to error -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") - add_compile_options(-Wno-error=deprecated-declarations) -endif() - -option( - WITH_API_ONLY - "Only build the API (use as a header-only library). Overrides WITH_EXAMPLES and all options to enable exporters" - OFF) -option(WITH_EXAMPLES "Whether to build examples" ON) - -# This requires CURL, OFF by default. -option( - WITH_EXAMPLES_HTTP - "Whether to build http client/server examples. Requires WITH_EXAMPLES and CURL" - OFF) - -option(WITH_FUNC_TESTS "Whether to build functional tests" ON) - -option(WITH_ASYNC_EXPORT_PREVIEW "Whether to enable async export" OFF) - -# Exemplar specs status is experimental, so behind feature flag by default -option(WITH_METRICS_EXEMPLAR_PREVIEW - "Whether to enable exemplar within metrics" OFF) - -# Experimental, so behind feature flag by default -option(WITH_THREAD_INSTRUMENTATION_PREVIEW - "Whether to enable thread instrumentation" OFF) - -option(OPENTELEMETRY_SKIP_DYNAMIC_LOADING_TESTS - "Whether to build test libraries that are always linked as shared libs" - OFF) - -# -# Verify options dependencies -# - -if(WITH_EXAMPLES_HTTP AND NOT WITH_EXAMPLES) - message(FATAL_ERROR "WITH_EXAMPLES_HTTP=ON requires WITH_EXAMPLES=ON") -endif() - -find_package(Threads) - -function(install_windows_deps) - # Bootstrap vcpkg from CMake and auto-install deps in case if we are missing - # deps on Windows. Respect the target architecture variable. - set(VCPKG_TARGET_ARCHITECTURE - ${ARCH} - PARENT_SCOPE) - message(STATUS "Installing build tools and dependencies...") - set(ENV{ARCH} ${ARCH}) - execute_process( - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/setup-buildtools.cmd) - set(CMAKE_TOOLCHAIN_FILE - ${CMAKE_CURRENT_SOURCE_DIR}/tools/vcpkg/scripts/buildsystems/vcpkg.cmake - CACHE FILEPATH "") - message( - STATUS - "Make sure that vcpkg.cmake is set as the CMAKE_TOOLCHAIN_FILE at the START of the cmake build process! - Can be command-line arg (cmake -DCMAKE_TOOLCHAIN_FILE=...) or set in your editor of choice." - ) - -endfunction() - -function(set_target_version target_name) - if(OTELCPP_VERSIONED_LIBS) - set_target_properties( - ${target_name} PROPERTIES VERSION ${OPENTELEMETRY_VERSION} - SOVERSION ${OPENTELEMETRY_ABI_VERSION_NO}) - endif() -endfunction() - -if(MSVC) - # Options for Visual C++ compiler: /Zc:__cplusplus - report an updated value - # for recent C++ language standards. Without this option MSVC returns the - # value of __cplusplus="199711L" - if(MSVC_VERSION GREATER 1900) - # __cplusplus flag is not supported by Visual Studio 2015 - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") - endif() -endif() - -# include GNUInstallDirs before include cmake/opentelemetry-proto.cmake because -# opentelemetry-proto installs targets to the location variables defined in -# GNUInstallDirs. -include(GNUInstallDirs) - -if(WITH_PROMETHEUS) - find_package(prometheus-cpp CONFIG QUIET) - if(NOT prometheus-cpp_FOUND) - message(STATUS "Trying to use local prometheus-cpp from submodule") - if(EXISTS ${PROJECT_SOURCE_DIR}/third_party/prometheus-cpp/.git) - set(SAVED_ENABLE_TESTING ${ENABLE_TESTING}) - set(SAVED_CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY}) - set(SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE - ${CMAKE_CXX_INCLUDE_WHAT_YOU_USE}) - set(ENABLE_TESTING OFF) - set(CMAKE_CXX_CLANG_TIDY "") - set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "") - add_subdirectory(third_party/prometheus-cpp) - set(ENABLE_TESTING ${SAVED_ENABLE_TESTING}) - set(CMAKE_CXX_CLANG_TIDY ${SAVED_CMAKE_CXX_CLANG_TIDY}) - set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE - ${SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE}) - - # Get the version of the prometheus-cpp submodule - find_package(Git QUIET) - if(Git_FOUND) - execute_process( - COMMAND ${GIT_EXECUTABLE} describe --tags --always - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/third_party/prometheus-cpp - OUTPUT_VARIABLE prometheus-cpp_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REGEX REPLACE "^v" "" prometheus-cpp_VERSION - "${prometheus-cpp_VERSION}") - endif() - - message( - STATUS - "Using local prometheus-cpp from submodule. Version = ${prometheus-cpp_VERSION}" - ) - else() - message( - FATAL_ERROR - "\nprometheus-cpp package was not found. Please either provide it manually or clone with submodules. " - "To initialize, fetch and checkout any nested submodules, you can use the following command:\n" - "git submodule update --init --recursive") - endif() - else() - message(STATUS "Using external prometheus-cpp") - endif() -endif() - -if(WITH_OTLP_GRPC - OR WITH_OTLP_HTTP - OR WITH_OTLP_FILE) - - # Including the CMakeFindDependencyMacro resolves an error from - # gRPCConfig.cmake on some grpc versions. See - # https://github.com/grpc/grpc/pull/33361 for more details. - include(CMakeFindDependencyMacro) - - # Protobuf 3.22+ depends on abseil-cpp and must be found using the cmake - # find_package CONFIG search mode. The following attempts to find Protobuf - # using the CONFIG mode first, and if not found, falls back to the MODULE - # mode. See https://gitlab.kitware.com/cmake/cmake/-/issues/24321 for more - # details. - find_package(Protobuf CONFIG) - if(NOT Protobuf_FOUND) - find_package(Protobuf MODULE) - if(Protobuf_FOUND AND Protobuf_VERSION VERSION_GREATER_EQUAL "3.22.0") - message( - WARNING - "Found Protobuf version ${Protobuf_VERSION} using MODULE mode. " - "Linking errors may occur. Protobuf 3.22+ depends on abseil-cpp " - "and should be found using the CONFIG mode.") - endif() - endif() - - if(WITH_OTLP_GRPC) - find_package(gRPC CONFIG) - endif() - if((NOT Protobuf_FOUND) OR (WITH_OTLP_GRPC AND NOT gRPC_FOUND)) - if(WIN32 AND (NOT DEFINED CMAKE_TOOLCHAIN_FILE)) - install_windows_deps() - endif() - - if(WIN32 AND (NOT DEFINED CMAKE_TOOLCHAIN_FILE)) - message(FATAL_ERROR "Windows dependency installation failed!") - endif() - if(WIN32) - include(${CMAKE_TOOLCHAIN_FILE}) - endif() - - if(NOT Protobuf_FOUND) - find_package(Protobuf CONFIG REQUIRED) - endif() - if(NOT gRPC_FOUND AND WITH_OTLP_GRPC) - find_package(gRPC CONFIG) - endif() - if(WIN32) - # Always use x64 protoc.exe - if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}") - set(Protobuf_PROTOC_EXECUTABLE - ${CMAKE_CURRENT_SOURCE_DIR}/tools/vcpkg/packages/protobuf_x64-windows/tools/protobuf/protoc.exe - ) - endif() - endif() - endif() - # Latest Protobuf imported targets and without legacy module support - if(TARGET protobuf::protoc) - if(CMAKE_CROSSCOMPILING AND Protobuf_PROTOC_EXECUTABLE) - set(PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE}) - else() - project_build_tools_get_imported_location(PROTOBUF_PROTOC_EXECUTABLE - protobuf::protoc) - # If protobuf::protoc is not a imported target, then we use the target - # directly for fallback - if(NOT PROTOBUF_PROTOC_EXECUTABLE) - set(PROTOBUF_PROTOC_EXECUTABLE protobuf::protoc) - endif() - endif() - elseif(Protobuf_PROTOC_EXECUTABLE) - # Some versions of FindProtobuf.cmake uses mixed case instead of uppercase - set(PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE}) - endif() - include(CMakeDependentOption) - - message(STATUS "PROTOBUF_PROTOC_EXECUTABLE=${PROTOBUF_PROTOC_EXECUTABLE}") - set(SAVED_CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY}) - set(CMAKE_CXX_CLANG_TIDY "") - include(cmake/opentelemetry-proto.cmake) - set(CMAKE_CXX_CLANG_TIDY ${SAVED_CMAKE_CXX_CLANG_TIDY}) -endif() - -# -# Do we need HTTP CLIENT CURL ? -# - -if(WITH_OTLP_HTTP - OR WITH_ELASTICSEARCH - OR WITH_ZIPKIN - OR BUILD_W3CTRACECONTEXT_TEST - OR WITH_EXAMPLES_HTTP) - set(WITH_HTTP_CLIENT_CURL ON) -else() - set(WITH_HTTP_CLIENT_CURL OFF) -endif() - -# -# Do we need CURL ? -# - -if((NOT WITH_API_ONLY) AND WITH_HTTP_CLIENT_CURL) - # No specific version required. - find_package(CURL REQUIRED) - # Set the CURL_VERSION from the legacy CURL_VERSION_STRING Required for CMake - # versions below 4.0 - if(NOT DEFINED CURL_VERSION AND DEFINED CURL_VERSION_STRING) - set(CURL_VERSION ${CURL_VERSION_STRING}) - endif() -endif() - -# -# Do we need ZLIB ? -# - -if((NOT WITH_API_ONLY) - AND WITH_HTTP_CLIENT_CURL - AND WITH_OTLP_HTTP_COMPRESSION) - # No specific version required. - find_package(ZLIB REQUIRED) - # Set the ZLIB_VERSION from the legacy ZLIB_VERSION_STRING Required for CMake - # versions below 3.26 - if(NOT DEFINED ZLIB_VERSION AND DEFINED ZLIB_VERSION_STRING) - set(ZLIB_VERSION ${ZLIB_VERSION_STRING}) - endif() -endif() - -# -# Do we need NLOHMANN_JSON ? -# - -if(WITH_ELASTICSEARCH - OR WITH_ZIPKIN - OR WITH_OTLP_HTTP - OR WITH_OTLP_FILE - OR BUILD_W3CTRACECONTEXT_TEST - OR WITH_ETW) - set(USE_NLOHMANN_JSON ON) -else() - set(USE_NLOHMANN_JSON OFF) -endif() - -if((NOT WITH_API_ONLY) AND USE_NLOHMANN_JSON) - include(cmake/nlohmann-json.cmake) -endif() - -if(OTELCPP_MAINTAINER_MODE) - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - message(STATUS "Building with gcc in maintainer mode.") - - add_compile_options(-Wall) - add_compile_options(-Werror) - add_compile_options(-Wextra) - - # Tested with GCC 9.4 on github. - if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.4) - message(STATUS "Building with additional warnings for gcc.") - - # Relaxed warnings - - # Enforced warnings - - # C++ options only - add_compile_options($<$,CXX>:-Wextra-semi>) - add_compile_options( - $<$,CXX>:-Woverloaded-virtual>) - add_compile_options( - $<$,CXX>:-Wsuggest-override>) - add_compile_options( - $<$,CXX>:-Wold-style-cast>) - - # C and C++ - add_compile_options(-Wcast-qual) - add_compile_options(-Wformat-security) - add_compile_options(-Wlogical-op) - add_compile_options(-Wmissing-include-dirs) - add_compile_options(-Wstringop-truncation) - add_compile_options(-Wundef) - add_compile_options(-Wvla) - endif() - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - message(STATUS "Building with clang in maintainer mode.") - - add_compile_options(-Wall) - add_compile_options(-Werror) - add_compile_options(-Wextra) - - # Tested with Clang 11.0 on github. - if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0) - message(STATUS "Building with additional warnings for clang.") - - # Relaxed warnings - add_compile_options(-Wno-error=unused-private-field) - - # Enforced warnings - add_compile_options(-Wcast-qual) - add_compile_options(-Wconditional-uninitialized) - add_compile_options(-Wextra-semi) - add_compile_options(-Wformat-security) - add_compile_options(-Wheader-hygiene) - add_compile_options(-Winconsistent-missing-destructor-override) - add_compile_options(-Winconsistent-missing-override) - add_compile_options(-Wnewline-eof) - add_compile_options(-Wnon-virtual-dtor) - add_compile_options(-Woverloaded-virtual) - add_compile_options(-Wrange-loop-analysis) - add_compile_options(-Wundef) - add_compile_options(-Wundefined-reinterpret-cast) - add_compile_options(-Wvla) - add_compile_options(-Wold-style-cast) - endif() - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - message(STATUS "Building with msvc in maintainer mode.") - - add_compile_options(/WX) - add_compile_options(/W4) - - # Relaxed warnings - add_compile_options(/wd4100) - add_compile_options(/wd4125) - add_compile_options(/wd4566) - add_compile_options(/wd4127) - add_compile_options(/wd4512) - add_compile_options(/wd4267) - add_compile_options(/wd4996) - - # Enforced warnings - add_compile_options(/we4265) # 'class': class has virtual functions, but - # destructor is not virtual - add_compile_options(/we5204) # A class with virtual functions has - # non-virtual trivial destructor. - - elseif() - message(FATAL_ERROR "Building with unknown compiler in maintainer mode.") - endif() -endif(OTELCPP_MAINTAINER_MODE) - -list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}") - -include(CTest) -if(BUILD_TESTING) - if(EXISTS ${CMAKE_BINARY_DIR}/lib/libgtest.a) - # Prefer GTest from build tree. GTest is not always working with - # CMAKE_PREFIX_PATH - set(GTEST_INCLUDE_DIRS - ${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest/googletest/include - ${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest/googlemock/include) - if(TARGET gtest) - set(GTEST_BOTH_LIBRARIES gtest gtest_main) - else() - set(GTEST_BOTH_LIBRARIES ${CMAKE_BINARY_DIR}/lib/libgtest.a - ${CMAKE_BINARY_DIR}/lib/libgtest_main.a) - endif() - elseif(WIN32) - # Make sure we are always bootsrapped with vcpkg on Windows - find_package(GTest) - if(NOT (GTEST_FOUND OR GTest_FOUND)) - if(DEFINED CMAKE_TOOLCHAIN_FILE) - message( - FATAL_ERROR - "Pleaes install GTest with the CMAKE_TOOLCHAIN_FILE at ${CMAKE_TOOLCHAIN_FILE}" - ) - else() - install_windows_deps() - include(${CMAKE_TOOLCHAIN_FILE}) - find_package(GTest REQUIRED) - endif() - endif() - else() - # Prefer GTest installed by OS distro, brew or vcpkg package manager - find_package(GTest REQUIRED) - endif() - if(NOT GTEST_BOTH_LIBRARIES) - # New GTest package names - if(TARGET GTest::gtest) - set(GTEST_BOTH_LIBRARIES GTest::gtest GTest::gtest_main) - elseif(TARGET GTest::GTest) - set(GTEST_BOTH_LIBRARIES GTest::GTest GTest::Main) - endif() - endif() - if(GTEST_INCLUDE_DIRS) - include_directories(SYSTEM ${GTEST_INCLUDE_DIRS}) - endif() - message(STATUS "GTEST_INCLUDE_DIRS = ${GTEST_INCLUDE_DIRS}") - message(STATUS "GTEST_BOTH_LIBRARIES = ${GTEST_BOTH_LIBRARIES}") - - # Try to find gmock - if(NOT GMOCK_LIB AND TARGET GTest::gmock) - set(GMOCK_LIB GTest::gmock) - elseif(MSVC) - # Explicitly specify that we consume GTest from shared library. The rest of - # code logic below determines whether we link Release or Debug flavor of the - # library. These flavors have different prefix on Windows, gmock and gmockd - # respectively. - add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY=1) - if(GMOCK_LIB) - # unset GMOCK_LIB to force find_library to redo the lookup, as the cached - # entry could cause linking to incorrect flavor of gmock and leading to - # runtime error. - unset(GMOCK_LIB CACHE) - endif() - endif() - if(NOT GMOCK_LIB) - if(MSVC AND CMAKE_BUILD_TYPE STREQUAL "Debug") - find_library(GMOCK_LIB gmockd PATH_SUFFIXES lib) - else() - find_library(GMOCK_LIB gmock PATH_SUFFIXES lib) - endif() - # Reset GMOCK_LIB if it was not found, or some target may link - # GMOCK_LIB-NOTFOUND - if(NOT GMOCK_LIB) - unset(GMOCK_LIB) - unset(GMOCK_LIB CACHE) - endif() - endif() - - enable_testing() - if(WITH_BENCHMARK) - # Benchmark respects the CMAKE_PREFIX_PATH - find_package(benchmark CONFIG REQUIRED) - endif() -endif() - -# Record build config and versions -message(STATUS "---------------------------------------------") -message(STATUS "build settings") -message(STATUS "---------------------------------------------") -message(STATUS "OpenTelemetry: ${OPENTELEMETRY_VERSION}") -message(STATUS "OpenTelemetry ABI: ${OPENTELEMETRY_ABI_VERSION_NO}") -message(STATUS "ARCH: ${ARCH}") -message(STATUS "CXX: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}") -message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") -message(STATUS "CXXFLAGS: ${CMAKE_CXX_FLAGS}") -message(STATUS "CMAKE_CXX_STANDARD: ${CMAKE_CXX_STANDARD}") -message(STATUS "CMAKE_TOOLCHAIN_FILE: ${CMAKE_TOOLCHAIN_FILE}") -message(STATUS "BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") - -message(STATUS "---------------------------------------------") -message(STATUS "opentelemetry-cpp build options") -message(STATUS "---------------------------------------------") -message(STATUS "WITH_API_ONLY: ${WITH_API_ONLY}") -message(STATUS "WITH_NO_DEPRECATED_CODE: ${WITH_NO_DEPRECATED_CODE}") -message(STATUS "WITH_ABI_VERSION_1: ${WITH_ABI_VERSION_1}") -message(STATUS "WITH_ABI_VERSION_2: ${WITH_ABI_VERSION_2}") -message(STATUS "OTELCPP_VERSIONED_LIBS: ${OTELCPP_VERSIONED_LIBS}") -message(STATUS "OTELCPP_MAINTAINER_MODE: ${OTELCPP_MAINTAINER_MODE}") -message(STATUS "WITH_STL: ${WITH_STL}") -message(STATUS "WITH_GSL: ${WITH_GSL}") -message(STATUS "WITH_NO_GETENV: ${WITH_NO_GETENV}") - -message(STATUS "---------------------------------------------") -message(STATUS "opentelemetry-cpp cmake component options") -message(STATUS "---------------------------------------------") -message(STATUS "WITH_OTLP_GRPC: ${WITH_OTLP_GRPC}") -message(STATUS "WITH_OTLP_HTTP: ${WITH_OTLP_HTTP}") -message(STATUS "WITH_OTLP_FILE: ${WITH_OTLP_FILE}") -message(STATUS "WITH_HTTP_CLIENT_CURL: ${WITH_HTTP_CLIENT_CURL}") -message(STATUS "WITH_ZIPKIN: ${WITH_ZIPKIN}") -message(STATUS "WITH_PROMETHEUS: ${WITH_PROMETHEUS}") -message(STATUS "WITH_ELASTICSEARCH: ${WITH_ELASTICSEARCH}") -message(STATUS "WITH_OPENTRACING: ${WITH_OPENTRACING}") -message(STATUS "WITH_ETW: ${WITH_ETW}") -message(STATUS "OPENTELEMETRY_BUILD_DLL: ${OPENTELEMETRY_BUILD_DLL}") - -message(STATUS "---------------------------------------------") -message(STATUS "feature preview options") -message(STATUS "---------------------------------------------") -message(STATUS "WITH_ASYNC_EXPORT_PREVIEW: ${WITH_ASYNC_EXPORT_PREVIEW}") -message( - STATUS - "WITH_THREAD_INSTRUMENTATION_PREVIEW: ${WITH_THREAD_INSTRUMENTATION_PREVIEW}" -) -message( - STATUS "WITH_METRICS_EXEMPLAR_PREVIEW: ${WITH_METRICS_EXEMPLAR_PREVIEW}") -message(STATUS "WITH_REMOVE_METER_PREVIEW: ${WITH_REMOVE_METER_PREVIEW}") -message( - STATUS "WITH_OTLP_GRPC_SSL_MTLS_PREVIEW: ${WITH_OTLP_GRPC_SSL_MTLS_PREVIEW}") -message(STATUS "WITH_OTLP_RETRY_PREVIEW: ${WITH_OTLP_RETRY_PREVIEW}") -message(STATUS "---------------------------------------------") -message(STATUS "third-party options") -message(STATUS "---------------------------------------------") -message(STATUS "WITH_NLOHMANN_JSON: ${USE_NLOHMANN_JSON}") -message(STATUS "WITH_CURL_LOGGING: ${WITH_CURL_LOGGING}") -message(STATUS "WITH_OTLP_HTTP_COMPRESSION: ${WITH_OTLP_HTTP_COMPRESSION}") -message(STATUS "---------------------------------------------") -message(STATUS "examples and test options") -message(STATUS "---------------------------------------------") -message(STATUS "WITH_BENCHMARK: ${WITH_BENCHMARK}") -message(STATUS "WITH_EXAMPLES: ${WITH_EXAMPLES}") -message(STATUS "WITH_EXAMPLES_HTTP: ${WITH_EXAMPLES_HTTP}") -message(STATUS "WITH_FUNC_TESTS: ${WITH_FUNC_TESTS}") -message(STATUS "BUILD_W3CTRACECONTEXT_TEST: ${BUILD_W3CTRACECONTEXT_TEST}") -message(STATUS "BUILD_TESTING: ${BUILD_TESTING}") -message(STATUS "---------------------------------------------") -message(STATUS "versions") -message(STATUS "---------------------------------------------") -message(STATUS "CMake: ${CMAKE_VERSION}") -message(STATUS "GTest: ${GTest_VERSION}") -message(STATUS "benchmark: ${benchmark_VERSION}") -if(WITH_GSL) - message(STATUS "GSL: ${GSL_VERSION}") -endif() -if(absl_FOUND) - message(STATUS "Abseil: ${absl_VERSION}") -endif() -if(Protobuf_FOUND) - message(STATUS "Protobuf: ${Protobuf_VERSION}") -endif() -if(gRPC_FOUND) - message(STATUS "gRPC: ${gRPC_VERSION}") -endif() -if(CURL_FOUND) - message(STATUS "CURL: ${CURL_VERSION}") -endif() -if(ZLIB_FOUND) - message(STATUS "ZLIB: ${ZLIB_VERSION}") -endif() -if(USE_NLOHMANN_JSON) - message(STATUS "nlohmann-json: ${nlohmann_json_VERSION}") -endif() -if(prometheus-cpp_FOUND) - message(STATUS "prometheus-cpp: ${prometheus-cpp_VERSION}") -endif() -message(STATUS "---------------------------------------------") - -include("${PROJECT_SOURCE_DIR}/cmake/otel-install-functions.cmake") - -include(CMakePackageConfigHelpers) - -if(DEFINED OPENTELEMETRY_BUILD_DLL) - if(NOT WIN32) - message(FATAL_ERROR "Build DLL is only supported on Windows!") - endif() - if(NOT MSVC) - message(WARNING "Build DLL is supposed to work with MSVC!") - endif() - if(WITH_STL) - message( - WARNING "Build DLL with C++ STL could cause binary incompatibility!") - endif() - add_definitions(-DOPENTELEMETRY_BUILD_EXPORT_DLL) -endif() - -add_subdirectory(api) - -if(WITH_OPENTRACING) - find_package(OpenTracing CONFIG QUIET) - if(NOT OpenTracing_FOUND) - set(OPENTRACING_DIR "third_party/opentracing-cpp") - message(STATUS "Trying to use local ${OPENTRACING_DIR} from submodule") - if(EXISTS "${PROJECT_SOURCE_DIR}/${OPENTRACING_DIR}/.git") - set(SAVED_BUILD_TESTING ${BUILD_TESTING}) - set(BUILD_TESTING OFF) - set(SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE - ${CMAKE_CXX_INCLUDE_WHAT_YOU_USE}) - set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "") - add_subdirectory(${OPENTRACING_DIR}) - set(BUILD_TESTING ${SAVED_BUILD_TESTING}) - set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE - ${SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE}) - else() - message( - FATAL_ERROR - "\nopentracing-cpp package was not found. Please either provide it manually or clone with submodules. " - "To initialize, fetch and checkout any nested submodules, you can use the following command:\n" - "git submodule update --init --recursive") - endif() - else() - message(STATUS "Using external opentracing-cpp") - endif() - add_subdirectory(opentracing-shim) -endif() - -if(NOT WITH_API_ONLY) - set(BUILD_TESTING ${BUILD_TESTING}) - - add_subdirectory(sdk) - add_subdirectory(ext) - add_subdirectory(exporters) - - if(BUILD_TESTING) - add_subdirectory(test_common) - endif() - if(WITH_EXAMPLES) - add_subdirectory(examples) - endif() - if(WITH_FUNC_TESTS) - add_subdirectory(functional) - endif() -endif() - -include(cmake/opentelemetry-build-external-component.cmake) -include(cmake/patch-imported-config.cmake) - -if(OPENTELEMETRY_INSTALL) - # Install the cmake config and version files - otel_install_cmake_config() - - # Install the components and associated files - otel_install_components() - - # Install the thirdparty dependency definition file - otel_install_thirdparty_definitions() - - if(BUILD_PACKAGE) - include(cmake/package.cmake) - include(CPack) - endif() -endif() diff --git a/ext/opentelemetry-cpp-1.21.0/CMakeSettings.json b/ext/opentelemetry-cpp-1.21.0/CMakeSettings.json deleted file mode 100644 index 02d068a3a1..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/CMakeSettings.json +++ /dev/null @@ -1,126 +0,0 @@ -{ - "configurations": [ - { - "name": "nostd-x64-Debug", - "generator": "Ninja", - "configurationType": "Debug", - "inheritEnvironments": [ - "msvc_x64_x64" - ], - "buildRoot": "${projectDir}\\out\\vs2019\\${name}", - "installRoot": "${projectDir}\\out\\vs2019\\${name}\\install", - "cmakeCommandArgs": "", - "buildCommandArgs": "", - "ctestCommandArgs": "", - "variables": [ - { - "name": "WITH_OTLP_GRPC", - "value": "True", - "type": "BOOL" - }, - { - "name": "WITH_EXAMPLES", - "value": "true", - "type": "BOOL" - } - ] - }, - { - "name": "nostd-x64-Release", - "generator": "Ninja", - "configurationType": "Release", - "inheritEnvironments": [ - "msvc_x64_x64" - ], - "buildRoot": "${projectDir}\\out\\vs2019\\${name}", - "installRoot": "${projectDir}\\out\\vs2019\\${name}\\install", - "cmakeCommandArgs": "", - "buildCommandArgs": "", - "ctestCommandArgs": "", - "cmakeToolchain": "", - "variables": [ - { - "name": "WITH_OTLP_GRPC", - "value": "True", - "type": "BOOL" - }, - { - "name": "WITH_EXAMPLES", - "value": "true", - "type": "BOOL" - } - ] - }, - { - "name": "stdlib-x64-Debug", - "generator": "Ninja", - "configurationType": "Debug", - "inheritEnvironments": [ - "msvc_x64_x64" - ], - "buildRoot": "${projectDir}\\out\\vs2019\\${name}", - "installRoot": "${projectDir}\\out\\vs2019\\${name}\\install", - "cmakeCommandArgs": "", - "buildCommandArgs": "", - "ctestCommandArgs": "", - "variables": [ - { - "name": "WITH_STL", - "value": "True", - "type": "BOOL" - }, - { - "name": "WITH_OTLP_GRPC", - "value": "True", - "type": "BOOL" - }, - { - "name": "WITH_EXAMPLES", - "value": "true", - "type": "BOOL" - }, - { - "name": "WITH_PROMETHEUS", - "value": "True", - "type": "BOOL" - } - ] - }, - { - "name": "stdlib-x64-Release", - "generator": "Ninja", - "configurationType": "Release", - "inheritEnvironments": [ - "msvc_x64_x64" - ], - "buildRoot": "${projectDir}\\out\\vs2019\\${name}", - "installRoot": "${projectDir}\\out\\vs2019\\${name}\\install", - "cmakeCommandArgs": "", - "buildCommandArgs": "", - "ctestCommandArgs": "", - "cmakeToolchain": "", - "variables": [ - { - "name": "WITH_STL", - "value": "True", - "type": "BOOL" - }, - { - "name": "WITH_OTLP_GRPC", - "value": "True", - "type": "BOOL" - }, - { - "name": "WITH_EXAMPLES", - "value": "true", - "type": "BOOL" - }, - { - "name": "WITH_PROMETHEUS", - "value": "True", - "type": "BOOL" - } - ] - } - ] -} diff --git a/ext/opentelemetry-cpp-1.21.0/CODE_OF_CONDUCT.md b/ext/opentelemetry-cpp-1.21.0/CODE_OF_CONDUCT.md deleted file mode 100644 index fee94ae58b..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,3 +0,0 @@ -# OpenTelemetry Community Code of Conduct - -OpenTelemetry follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md). diff --git a/ext/opentelemetry-cpp-1.21.0/CONTRIBUTING.md b/ext/opentelemetry-cpp-1.21.0/CONTRIBUTING.md deleted file mode 100644 index fda99e0978..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/CONTRIBUTING.md +++ /dev/null @@ -1,322 +0,0 @@ -# Contributing to opentelemetry-cpp - -The OpenTelemetry C/C++ special interest group (SIG) meets regularly. See the -OpenTelemetry [community](https://github.com/open-telemetry/community#cc-sdk) -repo for information on this and other language SIGs. - -See the [public meeting -notes](https://docs.google.com/document/d/1i1E4-_y4uJ083lCutKGDhkpi3n4_e774SBLi9hPLocw/edit) -for a summary description of past meetings. To request edit access, join the -meeting or get in touch on -[Slack](https://cloud-native.slack.com/archives/C01N3AT62SJ). - -See the [community membership -document](https://github.com/open-telemetry/community/blob/main/community-membership.md) -on how to become a -[**Member**](https://github.com/open-telemetry/community/blob/main/community-membership.md#member), -[**Approver**](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver) -and -[**Maintainer**](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer). - -## Development - -OpenTelemetry C++ uses the [Google naming -convention](https://google.github.io/styleguide/cppguide.html#Naming). - -Code is formatted automatically and enforced by CI. - -### Build and Run Code Examples - -Note: these instructions apply to examples configured with Bazel, see -example-specific documentation for other build automation tools. - -Install the latest bazel version by following the steps listed -[here](https://docs.bazel.build/versions/master/install.html). - -Select an example of interest from the [examples -folder](https://github.com/open-telemetry/opentelemetry-cpp/tree/main/examples). -Inside each example directory is a `BUILD` file containing instructions for -Bazel. Find the binary name of your example by inspecting the contents of this -`BUILD` file. - -Build the example from the root of the opentelemetry-cpp directory using Bazel. -Replace `` with the identifier found in the previous step: - -```sh -bazel build //examples/: -``` - -Run the resulting executable to see telemetry from the application as it calls -the instrumented library: - -```sh -bazel-bin/examples// -``` - -For instance, building and running the `simple` example can be done as follows: - -```sh -bazel build //examples/simple:example_simple -bazel-bin/examples/simple/example_simple -``` - -### DevContainer Setup for Project - -This guide provides instructions on how to set up and use the development -container (`devcontainer`) environment to streamline testing and development -for this project. With the DevContainer, you can work in a consistent environment -configured with all the necessary dependencies and tools. - -#### Prerequisites - -Before getting started, ensure you have the following installed: - -* **Docker**: DevContainers require Docker for containerization. -* **Visual Studio Code (VSCode)** with the **Remote - Containers** extension. - -#### Getting Started - -* **Open the Project in DevContainer**: - - Open the project in VSCode. When prompted to "Reopen in Container," select - this option. If you’re not prompted, you can manually open the container by - selecting **Remote-Containers: Reopen in Container** from the command palette - (`F1` or `Ctrl+Shift+P`). - -* **Container Setup**: - - The DevContainer environment will automatically build based on the configuration - files provided (e.g., `.devcontainer/devcontainer.json`). This setup will install - required dependencies, tools, and environment variables needed for the project. - -* **Container Customization**: - See `.devcontainer/README.md` for devcontainer configuration options. - -#### Available Commands - -Once inside the DevContainer, you can use the following commands to run tests -and CI workflows. - -##### 1. Run Tests with Bazelisk - -To run tests with Bazelisk using specific compilation options, use: - -```bash -bazelisk-linux-amd64 test --copt=-DENABLE_LOGS_PREVIEW ---test_output=errors --cache_test_results=no --copt=-DENABLE_TEST //exporters/otlp/... -``` - -###### Command Breakdown - -* `--copt=-DENABLE_LOGS_PREVIEW`: Enables preview logs. -* `--test_output=errors`: Shows only the errors in the test output. -* `--cache_test_results=no`: Forces Bazel to re-run tests without caching. -* `--copt=-DENABLE_TEST`: Enables testing capabilities for the target code. -* `//exporters/otlp/...`: Specifies the test target path. - -##### 2. Run CI Script - -You can also run the CI script provided to perform testing with the -following command as an -example: - -```bash -bash ci/do_ci.sh cmake.exporter.otprotocol.test -``` - -This command initiates the CI pipeline, executing tests specifically for the -**cmake.exporter.otprotocol** module. - -#### Troubleshooting - -If you encounter issues: - -* **Rebuild the DevContainer**: From the command palette, run - **Remote-Containers: Rebuild Container** to reinitialize the environment. -* **Check Bazelisk and CI Script Logs**: Inspect logs for any configuration or - dependency issues. - -#### Additional Notes - -* You can adjust compiler options (`--copt`) as needed to test additional flags - or enable/disable specific features. -* The test results will be displayed in the terminal within the DevContainer for - easy debugging. - -#### Resources - -* **Bazelisk Documentation**: [https://github.com/bazelbuild/bazelisk](https://github.com/bazelbuild/bazelisk) -* **VSCode DevContainer Documentation**: [https://code.visualstudio.com/docs/remote/containers](https://code.visualstudio.com/docs/remote/containers) - -### Docker Development Image - -The `.devcontainer/Dockerfile.dev` -dockerfile can be built directly with the following command. - -```sh - docker build -t opentelemetry-cpp-dev -f ./.devcontainer/Dockerfile.dev . -``` - -You can customize the image using build arguments - to match permissions with the host user. - -```sh - docker build -t opentelemetry-cpp-dev \ - --build-arg USER_UID="$(id -u)" \ - --build-arg USER_GID="$(id -g)" \ - -f ./.devcontainer/Dockerfile.dev . - -``` - -Run an interactive bash session binding your host - opentelemetry-cpp directory to the container's workspace: - -```sh -docker run -it -v "$PWD:/workspaces/opentelemetry-cpp" opentelemetry-cpp-dev bash -``` - -## Pull Requests - -### How to Send Pull Requests - -Everyone is welcome to contribute code to `opentelemetry-cpp` via GitHub pull -requests (PRs). - -To create a new PR, fork the project in GitHub and clone the upstream repo: - -```sh -git clone --recursive https://github.com/open-telemetry/opentelemetry-cpp.git -``` - -Add your fork as a remote: - -```sh -git remote add fork https://github.com/YOUR_GITHUB_USERNAME/opentelemetry-cpp.git -``` - -If you haven't, make sure you are loading the submodules required to build -OpenTelemetry - -```sh -git submodule init -git submodule update -``` - -The source code is automatically formatted using clang-format. - -The output can vary between versions, so make sure to install `clang-format` -version `10.0`, and have `clang-format-10` in your execution path, -so that the helper script `tools/format.sh` can find it. - -Check out a new branch, make modifications and push the branch to your fork: - -```sh -git checkout -b feature -# edit files -tools/format.sh -git commit -git push fork feature -``` - -If you made changes to the Markdown documents (`*.md` files), install the latest -[`markdownlint-cli`](https://github.com/igorshubovych/markdownlint-cli) and run: - -```sh -markdownlint . -``` - -If you modified shell scripts (`*.sh` files), install `shellcheck` and run: - -```sh -shellcheck --severity=error .sh -``` - -Open a pull request against the main `opentelemetry-cpp` repo. - -To run tests locally, please read the [CI instructions](ci/README.md). - -### How to Receive Comments - -* If the PR is not ready for review, please put `[WIP]` in the title, tag it as - `work-in-progress`, or mark it as - [`draft`](https://github.blog/2019-02-14-introducing-draft-pull-requests/). -* Make sure [CLA](https://identity.linuxfoundation.org/projects/cncf) is signed - and CI is clear. -* For non-trivial changes, please update the [CHANGELOG](./CHANGELOG.md). - -### How to Get PRs Merged - -A PR is considered to be **ready to merge** when: - -* It has received two approvals with at least one approval from - [Approver](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver) - / - [Maintainer](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer) - (at different company). -* A pull request opened by an Approver / Maintainer can be merged with only one - approval from Approver / Maintainer (at different company). -* Major feedback items/points are resolved. -* It has been open for review for at least one working day. This gives people - reasonable time to review. -* Trivial changes (typo, cosmetic, doc, etc.) don't have to wait for one day. -* Urgent fixes can take exceptions as long as it has been actively communicated. - -Any Maintainer can merge the PR once it is **ready to merge**. Maintainer can -make conscious judgement to merge pull requests which have not strictly met -above mentioned requirements. - -If a PR has been stuck (e.g. there are lots of debates and people couldn't agree -on each other), the owner should try to get people aligned by: - -* Consolidating the perspectives and putting a summary in the PR. It is - recommended to add a link into the PR description, which points to a comment - with a summary in the PR conversation -* Stepping back to see if it makes sense to narrow down the scope of the PR or - split it up. - -If none of the above worked and the PR has been stuck for more than 2 weeks, the -owner should bring it to the OpenTelemetry C++ SIG meeting. See -[README.md](README.md#contributing) for the meeting link. - -## Design Choices - -As with other OpenTelemetry clients, opentelemetry-cpp follows the -[opentelemetry-specification](https://github.com/open-telemetry/opentelemetry-specification). - -It's especially valuable to read through the [library -guidelines](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/library-guidelines.md). - -## Useful Resources - -Hi! If you’re looking at this document, these resources will provide you the -knowledge to get started as a newcomer to the OpenTelemetry project. They will -help you understand the OpenTelemetry Project, its components, and specifically -the C++ repository. - -### Reading Resources - -* Medium - [article](https://medium.com/opentelemetry/how-to-start-contributing-to-opentelemetry-b23991ad91f4) - (October 2019) on how to start contributing to the OpenTelemetry project. -* Medium - [article](https://medium.com/opentelemetry/opentelemetry-beyond-getting-started-5ac43cd0fe26) - (January 2020) describing the overarching goals and use cases for - OpenTelemetry. - -### Relevant Documentation - -* [OpenTelemetry - Specification](https://github.com/open-telemetry/opentelemetry-specification) -* The OpenTelemetry Specification describes the requirements and expectations - of for all OpenTelemetry implementations. - -* Read through the OpenTelemetry C++ documentation -* The - [API](https://opentelemetry-cpp.readthedocs.io/en/latest/api/api.html) - and - [SDK](https://opentelemetry-cpp.readthedocs.io/en/latest/sdk/sdk.html) - documentation provides a lot of information on what the classes and their - functions are used for. - -Please contribute! You’re welcome to add more information if you come across any -helpful resources. diff --git a/ext/opentelemetry-cpp-1.21.0/DEPRECATED.md b/ext/opentelemetry-cpp-1.21.0/DEPRECATED.md deleted file mode 100644 index ec97f420fe..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/DEPRECATED.md +++ /dev/null @@ -1,139 +0,0 @@ -# Deprecated - -This document lists all the items currently deprecated in opentelemetry-cpp. - -Deprecated items will be removed in the future. - -## Guidelines - -### Maintainer guidelines - -See the [deprecation-process](./docs/deprecation-process.md) - -## [TEMPLATE] - -### New Deprecation Title (Template) - -#### Announcement (Template) - -#### Motivation (Template) - -#### Scope (Template) - -#### Mitigation (Template) - -#### Planned removal (Template) - -## [Platforms] - -N/A - -## [Compilers] - -N/A - -## [Third party dependencies] - -N/A - -## [Build tools] - -N/A - -## [Build scripts] - -N/A - -## [opentelemetry-cpp API] - -N/A - -## [opentelemetry-cpp SDK] - -N/A - -## [opentelemetry-cpp Exporter] - -N/A - -## [Documentation] - -N/A - -## Semantic conventions - -### Header files "semantic_conventions.h" - -#### Announcement (semantic_conventions.h) - -Deprecation is announced as part of the migration to weaver: - -* `Version:` release following opentelemetry-cpp 1.17.0 -* `Date:` Nov 9, 2024 -* `PR:` [PR 3105](https://github.com/open-telemetry/opentelemetry-cpp/pull/3105) - -#### Motivation (semantic_conventions.h) - -The header files for semantic conventions are generated automatically. -The tooling to generate these files is changing: - -* before, the build-tool repository was used -* now, the weaver repository is used - -Changes in tooling allows to generate code that is better organized, -with dedicated header files per group of semantic conventions, -instead of a single header file for everything. - -#### Scope (semantic_conventions.h) - -The following files: - -* `api/include/opentelemetry/trace/semantic_conventions.h` -* `sdk/include/opentelemetry/sdk/resource/semantic_conventions.h` - -are now deprecated. - -They correspond to semantic conventions v1.27.0, -and will no longer be maintained up to date. - -These files will be removed in the future. - -#### Mitigation (semantic_conventions.h) - -Two things have changed: - -* the header file to use -* the symbol name to use. - -Before, the semantic convention for `url.full` was: - -* declared in file `semantic_conventions.h` -* declared as symbol `SemanticConventions::kUrlFull` - -Now, the `url.full` convention, which is part or the `url` group, is: - -* declared in file `semconv/url_attributes.h` -* declared as symbol `semconv::url::kUrlFull` - -Application code that uses semantic conventions must be adjusted -accordingly. - -In addition, semantic conventions that are not marked as stable -are generated in a different header file, placed under directory -`incubating`, to better separate stable and non stable code. - -For example, file `semconv/incubating/url_attributes.h` -defines `semconv::url::kUrlDomain`, -which is not marked as stable in semconv v1.27.0 - -#### Planned removal (semantic_conventions.h) - -The following files: - -* `api/include/opentelemetry/trace/semantic_conventions.h` -* `sdk/include/opentelemetry/sdk/resource/semantic_conventions.h` - -will be removed. - -The removal date is planned for July 1, 2025. -This allows more than six months for applications to adjust. diff --git a/ext/opentelemetry-cpp-1.21.0/INSTALL.md b/ext/opentelemetry-cpp-1.21.0/INSTALL.md deleted file mode 100644 index 296a61c44b..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/INSTALL.md +++ /dev/null @@ -1,452 +0,0 @@ -# Building opentelemetry-cpp - -[CMake](https://cmake.org/) and [Bazel](https://bazel.build) are the official -build systems for opentelemetry-cpp. - -## Dependencies - -You can link OpenTelemetry C++ SDK with libraries provided in -[dependencies.md](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/dependencies.md) -(complete list of libraries with versions used in our CI can be found -[here](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/third_party_release)). - -## Build instructions using CMake - -### Prerequisites for CMake build - -- A supported platform (e.g. Windows, macOS or Linux). Refer to [Platforms - Supported](./README.md#supported-development-platforms) for more information. -- A compatible C++ compiler supporting at least C++14. Major compilers are - supported. Refer to [Supported Compilers](./README.md#supported-c-versions) - for more information. -- [Git](https://git-scm.com/) for fetching opentelemetry-cpp source code from - repository. To install Git, consult the [Set up - Git](https://help.github.com/articles/set-up-git/) guide on GitHub. -- [CMake](https://cmake.org/) for building opentelemetry-cpp API, SDK with their - unittests. The minimum CMake version is 3.14. - CMake 3.15+ is recommended on Windows due to known CI test failures with 3.14. - To install CMake, - consult the [Installing CMake](https://cmake.org/install/) guide. -- [GoogleTest](https://github.com/google/googletest) framework to build and run - the unittests. Refer to - [third_party_release](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/third_party_release#L5) - for version of GoogleTest used in CI. To install GoogleTest, consult the - [GoogleTest Build - Instructions](https://github.com/google/googletest/blob/master/googletest/README.md#generic-build-instructions). -- [Google Benchmark](https://github.com/google/benchmark) framework to build and - run benchmark tests. Refer to - [third_party_release](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/third_party_release#L4) - for version of Benchmark used in CI. To install Benchmark, consult the - [GoogleBenchmark Build - Instructions](https://github.com/google/benchmark#installation). -- Apart from above core requirements, the Exporters and Propagators have their - build dependencies. - -### Building dependencies for the OTLP exporters - -The opentelemetry-cpp OTLP exporters depend on Protobuf and gRPC - (in the case of the otlp grpc exporters). -Protobuf (since version 3.22.0) and gRPC depend on Abseil. -For cmake builds, it is best practice to build and install Abseil -, Protobuf, and gPRC as independent packages - -configuring cmake for Protobuf and gRPC to build against - the installed packages instead of using their submodule option. - -If building and installing Protobuf and gRPC manually with cmake the - recommended approach is: - -1. Choose the desired tag version of grpc. Find the compatible versions of abseil - and protobuf by inspecting the submodules of grpc at that tag. -2. Build and install the required version of abseil -3. Build and install the required version of protobuf - - Set the cmake option of Protobuf to build against the installed - package of Abseil (`protobuf_ABSL_PROVIDER=package`) -4. Build and install the required version of grpc - - Set the cmake option of grpc to build against the installed packages - of Abseil and Protobuf (cmake options - `gRPC_ABSL_PROVIDER=package` and `gRPC_PROTOBUF_PROVIDER=package`) - -### Building as standalone CMake Project - -1. Getting the opentelemetry-cpp source with its submodules: - - ```console - # Change to the directory where you want to create the code repository - $ cd ~ - $ mkdir source && cd source && git clone --recurse-submodules https://github.com/open-telemetry/opentelemetry-cpp - Cloning into 'opentelemetry-cpp'... - ... - Resolving deltas: 100% (3225/3225), done. - $ - ``` - -2. Navigate to the repository cloned above, and create the `CMake` build - configuration. - - ```console - $ cd opentelemetry-cpp - $ mkdir build && cd build && cmake .. - -- The C compiler identification is GNU 9.3.0 - -- The CXX compiler identification is GNU 9.3.0 - ... - -- Configuring done - -- Generating done - -- Build files have been written to: /home//source/opentelemetry-cpp/build - $ - ``` - - Some of the available cmake build variables we can use during cmake - configuration: - - - `-DCMAKE_POSITION_INDEPENDENT_CODE=ON` : Please note that with default - configuration, the code is compiled without `-fpic` option, so it is not - suitable for inclusion in shared libraries. To enable the code for - inclusion in shared libraries, this variable is used. - - `-DBUILD_SHARED_LIBS=ON` : To build shared libraries for the targets. - Please refer to note [below](#building-shared-libs-for-windows) for - Windows DLL support. - - `-DWITH_OTLP_GRPC=ON` : To enable building OTLP GRPC exporter. - - `-DWITH_OTLP_HTTP=ON` : To enable building OTLP HTTP exporter. - - `-DWITH_PROMETHEUS=ON` : To enable building prometheus exporter. - - `-DOPENTELEMETRY_INSTALL=ON`: To install `otel-cpp` library needed - for external code linking. - -3. Once the build configuration is created, build the CMake targets - this - includes building SDKs and unittests for API and SDK. Note that since API is - header only library, no separate build is triggered for it. - - ```console - $ cmake --build . --target all - Scanning dependencies of target timestamp_test - [ 0%] Building CXX object api/test/core/CMakeFiles/timestamp_test.dir/timestamp_test.cc.o - [ 1%] Linking CXX executable timestamp_test - ... - Scanning dependencies of target w3c_tracecontext_test - [ 99%] Building CXX object ext/test/w3c_tracecontext_test/CMakeFiles/w3c_tracecontext_test.dir/main.cc.o - [100%] Linking CXX executable w3c_tracecontext_test - [100%] Built target w3c_tracecontext_test - $ - ``` - -4. Once CMake tests are built, run them with `ctest` command - - ```console - $ ctest - Test project /tmp/opentelemetry-cpp/build - Start 1: trace.SystemTimestampTest.Construction - ... - Start 380: ext.http.urlparser.UrlParserTests.BasicTests - ... - 100% tests passed, 0 tests failed out of 380 - $ - ``` - -5. Optionally install the header files for API, and generated targets and header - files for SDK at custom/default install location. - - ```console - $ cmake --install . --prefix // - -- Installing: //lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config.cmake - -- Installing: //lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config-version.cmake - ... - $ - ``` - -### Incorporating into an external CMake Project - -There are two approaches to incoporate `opentelemetry-cpp` into - an external CMake project: - -1. Build and install `opentelemetry-cpp` then use `find_package` - to import its targets - - ```cmake - # Find all installed components and link all imported targets - find_package(opentelemetry-cpp CONFIG REQUIRED) - ... - target_include_directories(foo PRIVATE ${OPENTELEMETRY_CPP_INCLUDE_DIRS}) - target_link_libraries(foo PRIVATE ${OPENTELEMETRY_CPP_LIBRARIES}) - ``` - - ```cmake - # Find a specific component and link its imported target(s) - find_package(opentelemetry-cpp CONFIG REQUIRED COMPONENTS api) - ... - target_link_libraries(foo PRIVATE opentelemetry-cpp::api) - ``` - -2. Use CMake's [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html) - module to fetch and build `opentelemetry-cpp` then make its targets available - - ```cmake - # Fetch from an existing clone and build - include(FetchContent) - FetchContent_Declare(opentelemetry-cpp SOURCE_DIR "") - FetchContent_MakeAvailable(opentelemetry-cpp) - ... - target_link_libraries(foo PRIVATE opentelemetry-cpp::api) - ``` - - ```cmake - # Clone and build opentelemetry-cpp from a git tag - include(FetchContent) - FetchContent_Declare( - opentelemetry-cpp - GIT_REPOSITORY https://github.com/open-telemetry/opentelemetry-cpp.git - GIT_TAG v1.20.0) - FetchContent_MakeAvailable(opentelemetry-cpp) - ... - target_link_libraries(foo PRIVATE opentelemetry-cpp::api) - ``` - -In both cases the project's built or imported CMake targets will be - available in the `opentelemetry-cpp` namespace (ie: `opentelemetry-cpp::api`) - -#### Using opentelemetry-cpp package components - -> **Note:** `opentelemetry-cpp` CMake package components were introduced in `v1.21.0` - -The `opentelemetry-cpp` package supports using the `COMPONENTS` argument to -`find_package`. The following example illustrates using this feature to include -and link the `api` header only target to an instrumented `foo_lib` while only including -and linking the `sdk` and `otlp_grpc_exporter` targets to the `foo_app`. - -```cmake -# foo_lib/CMakeLists.txt -find_package(opentelemetry-cpp CONFIG REQUIRED COMPONENTS api) -add_library(foo_lib foo.cpp) -target_link_libraries(foo_lib PRIVATE opentelemetry-cpp::api) -``` - -```cmake -# foo_app/CMakeLists.txt -find_package(opentelemetry-cpp CONFIG REQUIRED COMPONENTS api sdk exporters_otlp_grpc) -add_executable(foo_app main.cpp) -target_link_libraries(foo_app PRIVATE foo_lib opentelemetry-cpp::api opentelemetry-cpp::trace opentelemetry-cpp::otlp_grpc_exporter ) -``` - -The following table provides the mapping between components and targets. Components -and targets available in the installation depends on the opentelemetry-cpp package -build configuration. - -> **Note:** components `exporters_elasticsearch` and `exporters_etw` - may be moved out of the core package and to `opentelemetry-cpp-contrib` - in a future release - -| Component | Targets | -|----------------------------|--------------------------------------------------------------------------------------------------| -| **api** | opentelemetry-cpp::api | -| **sdk** | opentelemetry-cpp::sdk | -| | opentelemetry-cpp::version | -| | opentelemetry-cpp::common | -| | opentelemetry-cpp::resources | -| | opentelemetry-cpp::trace | -| | opentelemetry-cpp::metrics | -| | opentelemetry-cpp::logs | -| **ext_common** | opentelemetry-cpp::ext | -| **ext_http_curl** | opentelemetry-cpp::http_client_curl | -| **ext_dll** | opentelemetry-cpp::opentelemetry_cpp | -| **exporters_in_memory** | opentelemetry-cpp::in_memory_span_exporter | -| | opentelemetry-cpp::in_memory_metric_exporter | -| **exporters_ostream** | opentelemetry-cpp::ostream_log_record_exporter | -| | opentelemetry-cpp::ostream_metrics_exporter | -| | opentelemetry-cpp::ostream_span_exporter | -| **exporters_otlp_common** | opentelemetry-cpp::proto | -| | opentelemetry-cpp::otlp_recordable | -| **exporters_otlp_file** | opentelemetry-cpp::otlp_file_client | -| | opentelemetry-cpp::otlp_file_exporter | -| | opentelemetry-cpp::otlp_file_log_record_exporter | -| | opentelemetry-cpp::otlp_file_metric_exporter | -| **exporters_otlp_grpc** | opentelemetry-cpp::proto_grpc | -| | opentelemetry-cpp::otlp_grpc_client | -| | opentelemetry-cpp::otlp_grpc_exporter | -| | opentelemetry-cpp::otlp_grpc_log_record_exporter | -| | opentelemetry-cpp::otlp_grpc_metrics_exporter | -| **exporters_otlp_http** | opentelemetry-cpp::otlp_http_client | -| | opentelemetry-cpp::otlp_http_exporter | -| | opentelemetry-cpp::otlp_http_log_record_exporter | -| | opentelemetry-cpp::otlp_http_metric_exporter | -| **exporters_prometheus** | opentelemetry-cpp::prometheus_exporter | -| **exporters_elasticsearch**| opentelemetry-cpp::elasticsearch_log_record_exporter | -| **exporters_etw** | opentelemetry-cpp::etw_exporter | -| **exporters_zipkin** | opentelemetry-cpp::zipkin_trace_exporter | -| **shims_opentracing** | opentelemetry-cpp::opentracing_shim | - -## Build instructions using Bazel - -NOTE: Experimental, and not supported for all the components. Make sure the -[GoogleTest](https://github.com/google/googletest) installation may fail if -there is a different version of googletest already installed in system-defined -path. - -### Prerequisites for Bazel build - -- A supported platform (e.g. Windows, macOS or Linux). Refer to [Platforms -Supported](./README.md#supported-development-platforms) for more information. -- A compatible C++ compiler supporting at least C++14. Major compilers are -supported. Refer to [Supported Compilers](./README.md#supported-c-versions) for -more information. -- [Git](https://git-scm.com/) for fetching opentelemetry-cpp source code from -repository. To install Git, consult the [Set up -Git](https://help.github.com/articles/set-up-git/) guide on GitHub. -- [Bazel](https://www.bazel.build/) for building opentelemetry-cpp API, SDK with -their unittests. We use 3.7.2 in our build system. - -To install Bazel, consult the [Installing -Bazel](https://docs.bazel.build/versions/3.7.0/install.html) guide. - -### Building as standalone Bazel Project - -1. Getting the opentelemetry-cpp source: - - ```console - # Change to the directory where you want to create the code repository - $ cd ~ - $ mkdir source && cd source - $ git clone https://github.com/open-telemetry/opentelemetry-cpp - Cloning into 'opentelemetry-cpp'... - ... - Resolving deltas: 100% (3225/3225), done. - $ - ``` - -2. Navigate to the repository cloned above, download the dependencies and build - the source code: - - ```console - $ cd opentelemetry-cpp - $ bazel build //... - bazel build -- //... -//exporters/otlp/... -//exporters/prometheus/... - Extracting Bazel installation... - Starting local Bazel server and connecting to it... - INFO: Analyzed 121 targets (98 packages loaded, 3815 targets configured). - INFO: Found 121 targets... - INFO: From Compiling sdk/src/trace/tracer_context.cc: - ... - - ``` - -3. Once Bazel tests are built, run them with `bazel test //...` command - - ```console - $ bazel test //... - .. - $ - ``` - -4. The build artifacts will be located under `bazel-bin` - -### Incorporating into an existing Bazel Project - -- WORKSPACE file: - -```console -http_archive( - name = "io_opentelemetry_cpp", - sha256 = "", - strip_prefix = "opentelemetry-cpp-1.0.1", - urls = [ - "https://github.com/open-telemetry/opentelemetry-cpp/archive/refs/tags/v1.0.1.tar.gz" - ], -) - -# Load OpenTelemetry dependencies after load. -load("@io_opentelemetry_cpp//bazel:repository.bzl", "opentelemetry_cpp_deps") - -opentelemetry_cpp_deps() - -# (required after v1.8.0) Load extra dependencies required for OpenTelemetry -load("@io_opentelemetry_cpp//bazel:extra_deps.bzl", "opentelemetry_extra_deps") - -opentelemetry_extra_deps() - -# Load gRPC dependencies after load. -load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") - -grpc_deps() - -# Load extra gRPC dependencies due to https://github.com/grpc/grpc/issues/20511 -load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") - -grpc_extra_deps() - -``` - -- Component level BUILD file: - -```console -cc_library( - name = "" - ... - deps = [ - "@io_opentelemetry_cpp//api", - "@io_opentelemetry_cpp//exporters/otlp:otlp_exporter", - "@io_opentelemetry_cpp//sdk/src/trace", - ... - ], - ... -) -``` - -## Building shared libs for Windows - -Windows DLL build is supported under **preview**. Please check the -[doc](./docs/build-as-dll.md) for more details. - -## Generating binary packages - -OpenTelemetry C++ supports generating platform specific binary packages from CMake -configuration. The packages generated through this mayn't be production ready, -and user may have to customize it further before using it as distribution. - -- Linux : deb, rpm, tgz -- MacOS : tgz -- Windows : NuGet, zip - -This requires platform specific package generators already installed. The package -generation can subsequently be enabled by using BUILD_PACKAGE option during cmake -configuration - - ```console - $ cd opentelemetry-cpp - $ mkdir build && cd build && cmake -DBUILD_PACKAGE=ON .. - - -- Package name: opentelemetry-cpp-1.8.1-ubuntu-20.04-x86_64.deb - -- Configuring done - -- Generating done - ... - $ - ``` - -Once build is complete as specified in [standalone build section](#building-as-standalone-cmake-project), -the package can be generated as below. - - ```console - $ cpack -C debug - CPack: Create package using DEB - ... - CPack: - package: /home//opentelemetry-cpp/build/opentelemetry-cpp-1.8.1-ubuntu-20.04-x86_64.deb generated. - $ - ``` - -## Using Package Managers - -If you are using [Conan](https://www.conan.io/) to manage your dependencies, add -[`opentelemetry-cpp/x.y.z`](https://conan.io/center/opentelemetry-cpp) to your -`conanfile`'s requires, where `x.y.z` is the release version you want to use. -Please file issues [here](https://github.com/conan-io/conan-center-index/issues) -if you experience problems with the packages. - -If you are using [vcpkg](https://github.com/Microsoft/vcpkg/) on your project -for external dependencies, then you can install the [opentelemetry-cpp -package](https://github.com/microsoft/vcpkg/tree/master/ports/opentelemetry-cpp) -with `vcpkg install opentelemetry-cpp` and follow the then displayed -descriptions. Please see the vcpkg project for any issues regarding the -packaging. - -If you are using [alpine linux](https://www.alpinelinux.org/) you can install -the [opentelemetry-cpp packages](https://pkgs.alpinelinux.org/packages?name=opentelemetry-cpp-*) -with `apk add -X http://dl-cdn.alpinelinux.org/alpine/edge/testing opentelemetry-cpp-dev`. - -Please note, these packages are not officially provided and maintained by -OpenTelemetry C++ project, and are just listed here to consolidate all such -efforts for ease of developers. diff --git a/ext/opentelemetry-cpp-1.21.0/LICENSE b/ext/opentelemetry-cpp-1.21.0/LICENSE deleted file mode 100644 index 261eeb9e9f..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/ext/opentelemetry-cpp-1.21.0/MODULE.bazel b/ext/opentelemetry-cpp-1.21.0/MODULE.bazel deleted file mode 100644 index 59d8440906..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/MODULE.bazel +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -module( - name = "opentelemetry-cpp", - version = "1.21.0", - compatibility_level = 0, - repo_name = "io_opentelemetry_cpp", -) - -bazel_dep(name = "abseil-cpp", version = "20240116.1", repo_name = "com_google_absl") -bazel_dep(name = "bazel_skylib", version = "1.5.0") -bazel_dep(name = "curl", version = "8.8.0") -bazel_dep(name = "grpc", version = "1.63.1.bcr.1", repo_name = "com_github_grpc_grpc") -bazel_dep(name = "nlohmann_json", version = "3.12.0", repo_name = "github_nlohmann_json") -bazel_dep(name = "opentelemetry-proto", version = "1.6.0", repo_name = "com_github_opentelemetry_proto") -bazel_dep(name = "opentracing-cpp", version = "1.6.0", repo_name = "com_github_opentracing") -bazel_dep(name = "platforms", version = "0.0.8") -bazel_dep(name = "prometheus-cpp", version = "1.3.0", repo_name = "com_github_jupp0r_prometheus_cpp") -bazel_dep(name = "protobuf", version = "26.0", repo_name = "com_google_protobuf") -bazel_dep(name = "rules_proto", version = "5.3.0-21.7") -bazel_dep(name = "zlib", version = "1.3.1.bcr.1") - -bazel_dep(name = "google_benchmark", version = "1.8.3", dev_dependency = True, repo_name = "com_github_google_benchmark") -bazel_dep(name = "googletest", version = "1.14.0.bcr.1", dev_dependency = True, repo_name = "com_google_googletest") diff --git a/ext/opentelemetry-cpp-1.21.0/README.md b/ext/opentelemetry-cpp-1.21.0/README.md deleted file mode 100644 index 01645aa8c2..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/README.md +++ /dev/null @@ -1,127 +0,0 @@ -# OpenTelemetry C++ - -[![Slack](https://img.shields.io/badge/slack-@cncf/otel/cpp-brightgreen.svg?logo=slack)](https://cloud-native.slack.com/archives/C01N3AT62SJ) -[![codecov.io](https://codecov.io/gh/open-telemetry/opentelemetry-cpp/branch/main/graphs/badge.svg?)](https://codecov.io/gh/open-telemetry/opentelemetry-cpp/) -[![Build -Status](https://github.com/open-telemetry/opentelemetry-cpp/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/open-telemetry/opentelemetry-cpp/actions) -[![Release](https://img.shields.io/github/v/release/open-telemetry/opentelemetry-cpp?include_prereleases&style=)](https://github.com/open-telemetry/opentelemetry-cpp/releases/) -[![FOSSA License Status](https://app.fossa.com/api/projects/custom%2B162%2Fgithub.com%2Fopen-telemetry%2Fopentelemetry-cpp.svg?type=shield&issueType=license)](https://app.fossa.com/projects/custom%2B162%2Fgithub.com%2Fopen-telemetry%2Fopentelemetry-cpp?ref=badge_shield&issueType=license) -[![FOSSA Security Status](https://app.fossa.com/api/projects/custom%2B162%2Fgithub.com%2Fopen-telemetry%2Fopentelemetry-cpp.svg?type=shield&issueType=security)](https://app.fossa.com/projects/custom%2B162%2Fgithub.com%2Fopen-telemetry%2Fopentelemetry-cpp?ref=badge_shield&issueType=security) - -The C++ [OpenTelemetry](https://opentelemetry.io/) client. - -## Project Status - -**Stable** across all 3 signals i.e. `Logs`, `Metrics`, and `Traces`. - -See [Spec Compliance -Matrix](https://github.com/open-telemetry/opentelemetry-specification/blob/main/spec-compliance-matrix.md) -to understand which portions of the specification has been implemented in this -repo. - -## Supported C++ Versions - -Code shipped from this repository generally supports the following versions of -C++ standards: - -* ISO/IEC 14882:2014 (C++14) -* ISO/IEC 14882:2017 (C++17) -* ISO/IEC 14882:2020 (C++20) - -Any exceptions to this are noted in the individual `README.md` files. - -Please note that supporting the [C Programming -Language](https://en.wikipedia.org/wiki/C_(programming_language)) is not a goal -of the current project. - -## Supported Development Platforms - - Our CI pipeline builds and tests on following `x86-64` platforms: - -| Platform | Build type | -|---------------------------------------------------------------------|---------------| -| ubuntu-22.04 (GCC 10, GCC 12, Clang 14) | CMake, Bazel | -| ubuntu-20.04 (GCC 9.4.0 - default compiler) | CMake, Bazel | -| ubuntu-20.04 (GCC 9.4.0 with -std=c++14/17/20 flags) | CMake, Bazel | -| macOS 12.7 (Xcode 14.2) | Bazel | -| Windows Server 2019 (Visual Studio Enterprise 2019) | CMake, Bazel | -| Windows Server 2022 (Visual Studio Enterprise 2022) | CMake | - -In general, the code shipped from this repository should build on all platforms -having C++ compiler with [supported C++ standards](#supported-c-versions). - -## Dependencies - -Please refer to [Dependencies.md](docs/dependencies.md) for OSS Dependencies and -license requirements. - -## Installation - -Please refer to [INSTALL.md](./INSTALL.md). - -## Getting Started - -As an application owner or the library author, you can find the getting started -guide and reference documentation on -[opentelemetry-cpp.readthedocs.io](https://opentelemetry-cpp.readthedocs.io/en/latest/) - -The `examples/simple` directory contains a minimal program demonstrating how to -instrument a small library using a simple `processor` and console `exporter`, -along with build files for CMake and Bazel. - -## Contributing - -See [CONTRIBUTING.md](CONTRIBUTING.md) - -We meet weekly, and the time of the meeting alternates between Monday at 13:00 -PT and Wednesday at 9:00 PT. The meeting is subject to change depending on -contributors' availability. Check the [OpenTelemetry community -calendar](https://github.com/open-telemetry/community#calendar) -for specific dates and Zoom meeting links. - -Meeting notes are available as a public [Google -doc](https://docs.google.com/document/d/1i1E4-_y4uJ083lCutKGDhkpi3n4_e774SBLi9hPLocw/edit?usp=sharing). -For edit access, get in touch on -[Slack](https://cloud-native.slack.com/archives/C01N3AT62SJ). - -[Maintainers](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer) -([@open-telemetry/cpp-maintainers](https://github.com/orgs/open-telemetry/teams/cpp-maintainers)): - -* [Ehsan Saei](https://github.com/esigo) -* [Lalit Kumar Bhasin](https://github.com/lalitb), Microsoft -* [Marc Alff](https://github.com/marcalff), Oracle -* [Tom Tan](https://github.com/ThomsonTan), Microsoft - -[Approvers](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver) -([@open-telemetry/cpp-approvers](https://github.com/orgs/open-telemetry/teams/cpp-approvers)): - -* [Doug Barker](https://github.com/dbarker) -* [Josh Suereth](https://github.com/jsuereth), Google -* [Pranav Sharma](https://github.com/psx95), Google -* [WenTao Ou](https://github.com/owent), Tencent - -[Emeritus -Maintainer/Approver/Triager](https://github.com/open-telemetry/community/blob/main/community-membership.md#emeritus-maintainerapprovertriager): - -* [Alolita Sharma](https://github.com/alolita) -* [Emil Mikulic](https://github.com/g-easy) -* [Jodee Varney](https://github.com/jodeev) -* [Johannes Tax](https://github.com/pyohannes) -* [Max Golovanov](https://github.com/maxgolov) -* [Reiley Yang](https://github.com/reyang) -* [Ryan Burn](https://github.com/rnburn) - -### Thanks to all the people who have contributed - -[![contributors](https://contributors-img.web.app/image?repo=open-telemetry/opentelemetry-cpp)](https://github.com/open-telemetry/opentelemetry-cpp/graphs/contributors) - -## Release Schedule - -See the [release -notes](https://github.com/open-telemetry/opentelemetry-cpp/releases) for -existing releases. - -See the [project -milestones](https://github.com/open-telemetry/opentelemetry-cpp/milestones) for -details on upcoming releases. The dates and features described in issues and -milestones are estimates, and subject to change. diff --git a/ext/opentelemetry-cpp-1.21.0/RELEASING.md b/ext/opentelemetry-cpp-1.21.0/RELEASING.md deleted file mode 100644 index 852332e820..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/RELEASING.md +++ /dev/null @@ -1,96 +0,0 @@ -# Release Process - -## Pre Release - -1: Upgrade to latest [dependencies](docs/maintaining-dependencies.md) -if required. - -2: Make sure all relevant changes for this release are included under -`Unreleased` section in `CHANGELOG.md` and are in language that non-contributors -to the project can understand. - -3: Run the pre-release script. It creates a branch `pre_release_` and -updates `CHANGELOG.md` with the ``: - -```sh -./buildscripts/pre_release.sh -t -``` - -4: Verify that CHANGELOG.md is updated properly: - -```sh -git diff main -``` - -5: Push the changes to upstream and create a Pull Request on GitHub. Be sure to -include the curated changes from the [Changelog](./CHANGELOG.md) in the -description. - -## Tag - -Once the above Pull Request has been approved and merged it is time to tag the -merged commit. - -***IMPORTANT***: It is critical you use the same tag that you used in the -Pre-Release step! Failure to do so will leave things in a broken state. - -1: Note down the commit hash of the master branch after above PR request is -merged: `` - -```sh -git show -s --format=%H -``` - -2: Create a github tag on this commit hash: - -```sh -git tag -a "" -s -m "Version " "" -``` - -3: Push tag to upstream remote - -```sh -git push upstream -``` - -## Versioning - -Once tag is created, it's time to use that tag for Runtime Versioning - -1: Create a new brach for updating version information in -`./sdk/src/version.cc`. - -```sh -git checkout -b update_version_${tag} master -``` - -2: Run the pre-commit script to update the version: - -```sh -./buildscripts/pre-commit -``` - -3: Check if any changes made since last release broke ABI compatibility. If yes, -update `OPENTELEMETRY_ABI_VERSION_NO` in -[version.h](api/include/opentelemetry/version.h). - -4: Push the changes to upstream and create a Pull Request on GitHub. - -5: Once changes are merged, move the tag created earlier to the new commit hash -from step 4. - -```sh -git tag -f -git push --tags --force -``` - -## Release - -Finally create a Release for the new `` on GitHub. The release body -should include all the release notes from the Changelog for this release. - -## Post Release - -Update the OpenTelemetry.io document -[here](https://github.com/open-telemetry/opentelemetry.io/tree/main/content/en/docs/instrumentation/cpp) -by sending a Pull Request. diff --git a/ext/opentelemetry-cpp-1.21.0/Versioning.md b/ext/opentelemetry-cpp-1.21.0/Versioning.md deleted file mode 100644 index b6cbe490e2..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/Versioning.md +++ /dev/null @@ -1,107 +0,0 @@ -# Versioning - -This document describes the versioning policy for this repository. - -## Goals - -### API and SDK Compatibility - -Once the API for a given signal (spans, logs, metrics, baggage) has been -officially released, that API module will function with any SDK that has the -same MAJOR version and equal or greater MINOR or PATCH version. For example, -application compiled with API v1.1 is compatible with SDK v1.1.2, v1.2.0, etc. - -For example, libraries that are instrumented with `opentelemetry 1.0.1` will -function in applications using `opentelemetry 1.11.33` or `opentelemetry 1.3.4`, -buy may not work in applications using `opentelemetry 2.0.0`. - -### ABI Stability - -Refer to the [ABI Policy](./docs/abi-policy.md) for more details. To summarise: - -* The API is header only, and uses ABI compliant interfaces. However, ABI - stability is not guaranteed for SDK. -* In case of ABI breaking changes, a new `inline namespace` version will be - introduced, and the existing linked applications can continue using the older - version unless they relink with newer version. - -## Release Policy - -* Release versions will follow [SemVer 2.0](https://semver.org/). -* Only a single source package containing the API, SDK, and exporters which are - required by the specification would be released. All these components are - always versioned and released together. For example, any changes in one of the - exporter would result in version update of the entire source package even - though there is no changes in API, SDK and other exporters. -* Experimental releases: New (unstable) telemetry signals and features will be - introduced behind feature flag protected by a preprocessor macro. - - ```cpp - #ifdef FEATURE_FLAG - - #endif - ``` - - As we deliver the package in source form, and the user is responsible to build - it for their platform, the user must be aware of these feature flags - (documented in the [CHANGELOG.md](CHANGELOG.md) file). The user must enable - them explicitly through their build system (CMake, Bazel or others) to use any - preview features. - - The guidelines in creating feature flag would be: - - * Naming: - * `ENABLE__PREVIEW` : For experimental release of signal api/sdks - eg, `METRICS_PREVIEW`, `LOGS_PREVIEW`, - * `ENABLE___PREVIEW` : For experimental release for - any feature within stable signal. For example, `TRACING_JAEGER_PREVIEW` to - release the experimental Jaeger exporter for tracing. - * Cleanup: It is good practice to keep feature-flags as shortlived as - possible. And, also important to keep the number of them low. They should be - used such that it is easy to remove/cleanup them once the experimental - feature is stable. - -* New signals will be stabilized via a **minor version bump**, and are not - allowed to break existing stable interfaces. Feature flags will be removed - once we have a stable implementation for the signal. - -* As an exception, small experimental features in otherwise stable - signals/components mayn't necessarily be released under feature flag. These - would be flagged as experimental by adding a `NOTE` in it's header file - - either at the beginning of file, or as the comment for the experimental API - methods. Also, if the complete header is experimental, it would be prefixed as - `experimental_`. As an example, the semantic conventions for trace signal is - experimental at the time of the writing and is within - `experimental_semantic_conventions.h` - -* Code under the "*::detail" namespace implements internal details, and is NOT - part of public interface. Also, any API not documented in the [public - documentation](https://opentelemetry-cpp.readthedocs.io/en/latest/) is NOT - part of the public interface. - -* GitHub releases will be made for all released versions. - -## Example Versioning Lifecycle - -Purely for illustration purposes, not intended to represent actual releases: - -* v0.0.1 release: - * Contains experimental API and SDK of trace (without feature flag) - * No API and SDK of logging and metrics available -* v1.0.0-rc1 release: - * Pre-release, no API/ABI guarantees, but more stable than alpha/beta. - * Contains pre-release API and SDK of trace, baggage and resource - * experimental metrics and logging API/SDK behind feature flag -* v1.0.0: ( with traces ) - * Contains stable API and SDK of trace, baggage and resource - * experimental metrics and logging API/SDK behind feature flag -* v1.5.0 release (with metrics) - * Contains stable API and SDK of metrics, trace, baggage, resource. - * experimental logging API/SDK behind feature flag -* v1.10.0 release (with logging) - * Contains stable API and SDK of logging, metrics, trace, baggage, resource. - -### Before moving to version 1.0.0 - -* Major version zero (0.y.z) is for initial development. Anything MAY change at - any time. The public API SHOULD NOT be considered stable. diff --git a/ext/opentelemetry-cpp-1.21.0/WORKSPACE b/ext/opentelemetry-cpp-1.21.0/WORKSPACE deleted file mode 100644 index a52788ece2..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/WORKSPACE +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -workspace(name = "io_opentelemetry_cpp") - -# Load our direct dependencies. -load("//bazel:repository.bzl", "opentelemetry_cpp_deps") - -opentelemetry_cpp_deps() - -load("//bazel:extra_deps.bzl", "opentelemetry_extra_deps") - -opentelemetry_extra_deps() - -# Load gRPC dependencies after load. -load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") - -grpc_deps() - -# Load extra gRPC dependencies due to https://github.com/grpc/grpc/issues/20511 -load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") - -grpc_extra_deps() diff --git a/ext/opentelemetry-cpp-1.21.0/WORKSPACE.bzlmod b/ext/opentelemetry-cpp-1.21.0/WORKSPACE.bzlmod deleted file mode 100644 index 0db1b04622..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/WORKSPACE.bzlmod +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -# Disables the default WORKSPACE when using bzlmod diff --git a/ext/opentelemetry-cpp-1.21.0/api/BUILD b/ext/opentelemetry-cpp-1.21.0/api/BUILD deleted file mode 100644 index fb31393569..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/BUILD +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "int_flag", "string_flag") - -package(default_visibility = ["//visibility:public"]) - -CPP_STDLIBS = [ - "none", - "best", - "2014", - "2017", - "2020", - "2023", -] - -string_flag( - name = "with_cxx_stdlib", - build_setting_default = "best", - values = CPP_STDLIBS, -) - -cc_library( - name = "api", - hdrs = glob(["include/**/*.h"]), - defines = select({ - ":set_cxx_stdlib_none": [], - ### automatic selection - ":set_cxx_stdlib_best": ["OPENTELEMETRY_STL_VERSION=(__cplusplus/100)"], - # See https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus - ":set_cxx_stdlib_best_and_msvc": ["OPENTELEMETRY_STL_VERSION=(_MSVC_LANG/100)"], - ### manual selection - ":set_cxx_stdlib_2014": ["OPENTELEMETRY_STL_VERSION=2014"], - ":set_cxx_stdlib_2017": ["OPENTELEMETRY_STL_VERSION=2017"], - ":set_cxx_stdlib_2020": ["OPENTELEMETRY_STL_VERSION=2020"], - ":set_cxx_stdlib_2023": ["OPENTELEMETRY_STL_VERSION=2023"], - "//conditions:default": [], - }) + select({ - ":abi_version_no_1": ["OPENTELEMETRY_ABI_VERSION_NO=1"], - ":abi_version_no_2": ["OPENTELEMETRY_ABI_VERSION_NO=2"], - }), - strip_include_prefix = "include", - tags = ["api"], - deps = [ - "@com_google_absl//absl/base", - "@com_google_absl//absl/strings", - "@com_google_absl//absl/types:variant", - ], -) - -[config_setting( - name = "set_cxx_stdlib_%s" % v, - flag_values = {":with_cxx_stdlib": v}, -) for v in CPP_STDLIBS] - -config_setting( - name = "set_cxx_stdlib_best_and_msvc", - constraint_values = ["@bazel_tools//tools/cpp:msvc"], - flag_values = {":with_cxx_stdlib": "best"}, -) - -bool_flag( - name = "with_abseil", - build_setting_default = False, - deprecation = "The value of this flag is ignored. Bazel builds always depend on Abseil for its pre-adopted `std::` types. You should remove this flag from your build command.", -) - -int_flag( - name = "abi_version_no", - build_setting_default = 1, -) - -config_setting( - name = "abi_version_no_1", - flag_values = {":abi_version_no": "1"}, -) - -config_setting( - name = "abi_version_no_2", - flag_values = {":abi_version_no": "2"}, -) diff --git a/ext/opentelemetry-cpp-1.21.0/api/CMakeLists.txt b/ext/opentelemetry-cpp-1.21.0/api/CMakeLists.txt deleted file mode 100644 index 0707464b36..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/CMakeLists.txt +++ /dev/null @@ -1,140 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -add_library(opentelemetry_api INTERFACE) -target_include_directories( - opentelemetry_api - INTERFACE "$" - "$") - -set_target_properties(opentelemetry_api PROPERTIES EXPORT_NAME api) - -otel_add_component( - COMPONENT - api - TARGETS - opentelemetry_api - FILES_DIRECTORY - "include/opentelemetry" - FILES_DESTINATION - "include" - FILES_MATCHING - PATTERN - "*.h") - -if(OPENTELEMETRY_INSTALL) - unset(TARGET_DEPS) -endif() - -if(BUILD_TESTING) - add_subdirectory(test) -endif() - -if(WITH_NO_DEPRECATED_CODE) - target_compile_definitions(opentelemetry_api - INTERFACE OPENTELEMETRY_NO_DEPRECATED_CODE) -endif() - -if(WITH_STL STREQUAL "OFF") - message(STATUS "Building WITH_STL=OFF") -elseif(WITH_STL STREQUAL "CXX11") - message(STATUS "Building WITH_STL=CXX11") - target_compile_definitions(opentelemetry_api - INTERFACE OPENTELEMETRY_STL_VERSION=2011) -elseif(WITH_STL STREQUAL "CXX14") - message(STATUS "Building WITH_STL=CXX14") - target_compile_definitions(opentelemetry_api - INTERFACE OPENTELEMETRY_STL_VERSION=2014) -elseif(WITH_STL STREQUAL "CXX17") - message(STATUS "Building WITH_STL=CXX17") - target_compile_definitions(opentelemetry_api - INTERFACE OPENTELEMETRY_STL_VERSION=2017) -elseif(WITH_STL STREQUAL "CXX20") - message(STATUS "Building WITH_STL=CXX20") - target_compile_definitions(opentelemetry_api - INTERFACE OPENTELEMETRY_STL_VERSION=2020) -elseif(WITH_STL STREQUAL "CXX23") - message(STATUS "Building WITH_STL=CXX23") - target_compile_definitions(opentelemetry_api - INTERFACE OPENTELEMETRY_STL_VERSION=2023) -elseif(WITH_STL STREQUAL "ON") - message(STATUS "Building WITH_STL=ON") - # "ON" corresponds to "CXX23" at this time. - target_compile_definitions(opentelemetry_api - INTERFACE OPENTELEMETRY_STL_VERSION=2023) -else() - message( - FATAL_ERROR "WITH_STL must be ON, OFF, CXX11, CXX14, CXX17, CXX20 or CXX23") -endif() - -if(WITH_GSL) - target_compile_definitions(opentelemetry_api INTERFACE HAVE_GSL) - - # Guidelines Support Library path. Used if we are not on not get C++20. - # - find_package(Microsoft.GSL QUIET) - if(TARGET Microsoft.GSL::GSL) - target_link_libraries(opentelemetry_api INTERFACE Microsoft.GSL::GSL) - list(APPEND TARGET_DEPS "gsl") - else() - set(GSL_DIR third_party/ms-gsl) - target_include_directories( - opentelemetry_api INTERFACE "$") - endif() -endif() - -if(WITH_NO_GETENV) - target_compile_definitions(opentelemetry_api INTERFACE NO_GETENV) -endif() - -if(WIN32) - if(WITH_ETW) - target_compile_definitions(opentelemetry_api INTERFACE HAVE_MSGPACK) - endif() -endif() - -if(WITH_ASYNC_EXPORT_PREVIEW) - target_compile_definitions(opentelemetry_api INTERFACE ENABLE_ASYNC_EXPORT) -endif() - -target_compile_definitions( - opentelemetry_api - INTERFACE OPENTELEMETRY_ABI_VERSION_NO=${OPENTELEMETRY_ABI_VERSION_NO}) - -if(WITH_OTLP_RETRY_PREVIEW) - target_compile_definitions(opentelemetry_api - INTERFACE ENABLE_OTLP_RETRY_PREVIEW) -endif() - -if(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW) - target_compile_definitions(opentelemetry_api - INTERFACE ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW) -endif() - -if(WITH_METRICS_EXEMPLAR_PREVIEW) - target_compile_definitions(opentelemetry_api - INTERFACE ENABLE_METRICS_EXEMPLAR_PREVIEW) -endif() - -if(WITH_THREAD_INSTRUMENTATION_PREVIEW) - target_compile_definitions(opentelemetry_api - INTERFACE ENABLE_THREAD_INSTRUMENTATION_PREVIEW) -endif() - -if(WITH_OTLP_HTTP_COMPRESSION) - target_compile_definitions(opentelemetry_api - INTERFACE ENABLE_OTLP_COMPRESSION_PREVIEW) -endif() - -if(APPLE) - target_link_libraries(opentelemetry_api INTERFACE "-framework CoreFoundation") -endif() - -include(${PROJECT_SOURCE_DIR}/cmake/pkgconfig.cmake) - -if(OPENTELEMETRY_INSTALL) - opentelemetry_add_pkgconfig( - api "OpenTelemetry API" - "A header-only library to support instrumentation with OpenTelemetry." - "${TARGET_DEPS}") -endif() diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/baggage/baggage.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/baggage/baggage.h deleted file mode 100644 index 6c799cda27..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/baggage/baggage.h +++ /dev/null @@ -1,299 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include - -#include "opentelemetry/common/kv_properties.h" -#include "opentelemetry/common/macros.h" -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE - -namespace baggage -{ - -class OPENTELEMETRY_EXPORT Baggage -{ -public: - static constexpr size_t kMaxKeyValuePairs = 180; - static constexpr size_t kMaxKeyValueSize = 4096; - static constexpr size_t kMaxSize = 8192; - static constexpr char kKeyValueSeparator = '='; - static constexpr char kMembersSeparator = ','; - static constexpr char kMetadataSeparator = ';'; - - Baggage() noexcept : kv_properties_(new common::KeyValueProperties()) {} - Baggage(size_t size) noexcept : kv_properties_(new common::KeyValueProperties(size)) {} - - template - Baggage(const T &keys_and_values) noexcept - : kv_properties_(new common::KeyValueProperties(keys_and_values)) - {} - - OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr GetDefault() - { - static nostd::shared_ptr baggage{new Baggage()}; - return baggage; - } - - /* Get value for key in the baggage - @returns true if key is found, false otherwise - */ - bool GetValue(nostd::string_view key, std::string &value) const noexcept - { - return kv_properties_->GetValue(key, value); - } - - /* Returns shared_ptr of new baggage object which contains new key-value pair. If key or value is - invalid, copy of current baggage is returned - */ - nostd::shared_ptr Set(const nostd::string_view &key, - const nostd::string_view &value) noexcept - { - - nostd::shared_ptr baggage(new Baggage(kv_properties_->Size() + 1)); - const bool valid_kv = IsValidKey(key) && IsValidValue(value); - - if (valid_kv) - { - baggage->kv_properties_->AddEntry(key, value); - } - - // add rest of the fields. - kv_properties_->GetAllEntries( - [&baggage, &key, &valid_kv](nostd::string_view e_key, nostd::string_view e_value) { - // if key or value was not valid, add all the entries. Add only remaining entries - // otherwise. - if (!valid_kv || key != e_key) - { - baggage->kv_properties_->AddEntry(e_key, e_value); - } - - return true; - }); - - return baggage; - } - - // @return all key-values entries by repeatedly invoking the function reference passed as argument - // for each entry - bool GetAllEntries( - nostd::function_ref callback) const noexcept - { - return kv_properties_->GetAllEntries(callback); - } - - // delete key from the baggage if it exists. Returns shared_ptr of new baggage object. - // if key does not exist, copy of current baggage is returned. - // Validity of key is not checked as invalid keys should never be populated in baggage in the - // first place. - nostd::shared_ptr Delete(nostd::string_view key) noexcept - { - // keeping size of baggage same as key might not be found in it - nostd::shared_ptr baggage(new Baggage(kv_properties_->Size())); - kv_properties_->GetAllEntries( - [&baggage, &key](nostd::string_view e_key, nostd::string_view e_value) { - if (key != e_key) - baggage->kv_properties_->AddEntry(e_key, e_value); - return true; - }); - return baggage; - } - - // Returns shared_ptr of baggage after extracting key-value pairs from header - static nostd::shared_ptr FromHeader(nostd::string_view header) noexcept - { - if (header.size() > kMaxSize) - { - // header size exceeds maximum threshold, return empty baggage - return GetDefault(); - } - - common::KeyValueStringTokenizer kv_str_tokenizer(header); - size_t cnt = kv_str_tokenizer.NumTokens(); // upper bound on number of kv pairs - if (cnt > kMaxKeyValuePairs) - { - cnt = kMaxKeyValuePairs; - } - - nostd::shared_ptr baggage(new Baggage(cnt)); - bool kv_valid; - nostd::string_view key, value; - - while (kv_str_tokenizer.next(kv_valid, key, value) && baggage->kv_properties_->Size() < cnt) - { - if (!kv_valid || (key.size() + value.size() > kMaxKeyValueSize)) - { - // if kv pair is not valid, skip it - continue; - } - - // NOTE : metadata is kept as part of value only as it does not have any semantic meaning. - // but, we need to extract it (else Decode on value will return error) - nostd::string_view metadata; - auto metadata_separator = value.find(kMetadataSeparator); - if (metadata_separator != std::string::npos) - { - metadata = value.substr(metadata_separator); - value = value.substr(0, metadata_separator); - } - - bool err = 0; - auto key_str = UrlDecode(common::StringUtil::Trim(key), err); - auto value_str = UrlDecode(common::StringUtil::Trim(value), err); - - if (err == false && IsValidKey(key_str) && IsValidValue(value_str)) - { - if (!metadata.empty()) - { - value_str.append(metadata.data(), metadata.size()); - } - baggage->kv_properties_->AddEntry(key_str, value_str); - } - } - - return baggage; - } - - // Creates string from baggage object. - std::string ToHeader() const noexcept - { - std::string header_s; - bool first = true; - kv_properties_->GetAllEntries([&](nostd::string_view key, nostd::string_view value) { - if (!first) - { - header_s.push_back(kMembersSeparator); - } - else - { - first = false; - } - header_s.append(UrlEncode(key)); - header_s.push_back(kKeyValueSeparator); - - // extracting metadata from value. We do not encode metadata - auto metadata_separator = value.find(kMetadataSeparator); - if (metadata_separator != std::string::npos) - { - header_s.append(UrlEncode(value.substr(0, metadata_separator))); - auto metadata = value.substr(metadata_separator); - header_s.append(std::string(metadata.data(), metadata.size())); - } - else - { - header_s.append(UrlEncode(value)); - } - return true; - }); - return header_s; - } - -private: - static bool IsPrintableString(nostd::string_view str) - { - for (const auto ch : str) - { - if (ch < ' ' || ch > '~') - { - return false; - } - } - - return true; - } - - static bool IsValidKey(nostd::string_view key) { return key.size() && IsPrintableString(key); } - - static bool IsValidValue(nostd::string_view value) { return IsPrintableString(value); } - - // Uri encode key value pairs before injecting into header - // Implementation inspired from : https://golang.org/src/net/url/url.go?s=7851:7884#L264 - static std::string UrlEncode(nostd::string_view str) - { - auto to_hex = [](char c) -> char { - static const char *hex = "0123456789ABCDEF"; - return hex[c & 15]; - }; - - std::string ret; - - for (auto c : str) - { - if (std::isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') - { - ret.push_back(c); - } - else if (c == ' ') - { - ret.push_back('+'); - } - else - { - ret.push_back('%'); - ret.push_back(to_hex(c >> 4)); - ret.push_back(to_hex(c & 15)); - } - } - - return ret; - } - - // Uri decode key value pairs after extracting from header - static std::string UrlDecode(nostd::string_view str, bool &err) - { - auto IsHex = [](char c) { - return std::isdigit(c) || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'); - }; - - auto from_hex = [](char c) -> char { - // c - '0' produces integer type which could trigger error/warning when casting to char, - // but the cast is safe here. - return static_cast(std::isdigit(c) ? c - '0' : std::toupper(c) - 'A' + 10); - }; - - std::string ret; - - for (size_t i = 0; i < str.size(); i++) - { - if (str[i] == '%') - { - if (i + 2 >= str.size() || !IsHex(str[i + 1]) || !IsHex(str[i + 2])) - { - err = 1; - return ""; - } - ret.push_back(from_hex(str[i + 1]) << 4 | from_hex(str[i + 2])); - i += 2; - } - else if (str[i] == '+') - { - ret.push_back(' '); - } - else if (std::isalnum(str[i]) || str[i] == '-' || str[i] == '_' || str[i] == '.' || - str[i] == '~') - { - ret.push_back(str[i]); - } - else - { - err = 1; - return ""; - } - } - - return ret; - } - -private: - // Store entries in a C-style array to avoid using std::array or std::vector. - nostd::unique_ptr kv_properties_; -}; - -} // namespace baggage - -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/baggage/baggage_context.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/baggage/baggage_context.h deleted file mode 100644 index a0016353ba..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/baggage/baggage_context.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/baggage/baggage.h" -#include "opentelemetry/context/context.h" -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE - -namespace baggage -{ - -static const std::string kBaggageHeader = "baggage"; - -inline nostd::shared_ptr GetBaggage(const context::Context &context) noexcept -{ - context::ContextValue context_value = context.GetValue(kBaggageHeader); - if (nostd::holds_alternative>(context_value)) - { - return nostd::get>(context_value); - } - static nostd::shared_ptr empty_baggage{new Baggage()}; - return empty_baggage; -} - -inline context::Context SetBaggage(context::Context &context, - const nostd::shared_ptr &baggage) noexcept -{ - return context.SetValue(kBaggageHeader, baggage); -} - -} // namespace baggage -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/baggage/propagation/baggage_propagator.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/baggage/propagation/baggage_propagator.h deleted file mode 100644 index d75409ed60..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/baggage/propagation/baggage_propagator.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include -#include - -#include "opentelemetry/baggage/baggage.h" -#include "opentelemetry/baggage/baggage_context.h" -#include "opentelemetry/context/context.h" -#include "opentelemetry/context/propagation/text_map_propagator.h" -#include "opentelemetry/nostd/function_ref.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace baggage -{ -namespace propagation -{ - -class BaggagePropagator : public context::propagation::TextMapPropagator -{ -public: - void Inject(context::propagation::TextMapCarrier &carrier, - const context::Context &context) noexcept override - { - auto baggage = baggage::GetBaggage(context); - auto header = baggage->ToHeader(); - if (header.size()) - { - carrier.Set(kBaggageHeader, header); - } - } - - context::Context Extract(const context::propagation::TextMapCarrier &carrier, - context::Context &context) noexcept override - { - nostd::string_view baggage_str = carrier.Get(baggage::kBaggageHeader); - auto baggage = baggage::Baggage::FromHeader(baggage_str); - - if (baggage->ToHeader().size()) - { - return baggage::SetBaggage(context, baggage); - } - else - { - return context; - } - } - - bool Fields(nostd::function_ref callback) const noexcept override - { - return callback(kBaggageHeader); - } -}; -} // namespace propagation -} // namespace baggage -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/attribute_value.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/attribute_value.h deleted file mode 100644 index af4cc83d42..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/attribute_value.h +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include - -#include "opentelemetry/nostd/span.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/variant.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace common -{ -/// OpenTelemetry signals can be enriched by adding attributes. The -/// \c AttributeValue type is defined as a variant of all attribute value -/// types the OpenTelemetry C++ API supports. -/// -/// The following attribute value types are supported by the OpenTelemetry -/// specification: -/// - Primitive types: string, boolean, double precision floating point -/// (IEEE 754-1985) or signed 64 bit integer. -/// - Homogenous arrays of primitive type values. -/// -/// \warning -/// \parblock The OpenTelemetry C++ API currently supports several attribute -/// value types that are not covered by the OpenTelemetry specification: -/// - \c uint64_t -/// - \c nostd::span -/// - \c nostd::span -/// -/// Those types are reserved for future use and currently should not be -/// used. There are no guarantees around how those values are handled by -/// exporters. -/// \endparblock -using AttributeValue = - nostd::variant, - nostd::span, - nostd::span, - nostd::span, - nostd::span, - nostd::span, - // Not currently supported by the specification, but reserved for future use. - // Added to provide support for all primitive C++ types. - uint64_t, - // Not currently supported by the specification, but reserved for future use. - // Added to provide support for all primitive C++ types. - nostd::span, - // Not currently supported by the specification, but reserved for future use. - // See https://github.com/open-telemetry/opentelemetry-specification/issues/780 - nostd::span>; - -enum AttributeType -{ - kTypeBool, - kTypeInt, - kTypeInt64, - kTypeUInt, - kTypeDouble, - kTypeCString, - kTypeString, - kTypeSpanBool, - kTypeSpanInt, - kTypeSpanInt64, - kTypeSpanUInt, - kTypeSpanDouble, - kTypeSpanString, - kTypeUInt64, - kTypeSpanUInt64, - kTypeSpanByte -}; - -} // namespace common -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/key_value_iterable.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/key_value_iterable.h deleted file mode 100644 index 9d43e1571b..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/key_value_iterable.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/nostd/function_ref.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace common -{ -/** - * Supports internal iteration over a collection of key-value pairs. - */ -class KeyValueIterable -{ -public: - virtual ~KeyValueIterable() = default; - - /** - * Iterate over key-value pairs - * @param callback a callback to invoke for each key-value. If the callback returns false, - * the iteration is aborted. - * @return true if every key-value pair was iterated over - */ - virtual bool ForEachKeyValue(nostd::function_ref - callback) const noexcept = 0; - - /** - * @return the number of key-value pairs - */ - virtual size_t size() const noexcept = 0; -}; - -/** - * Supports internal iteration over a collection of key-value pairs. - */ -class NoopKeyValueIterable : public KeyValueIterable -{ -public: - ~NoopKeyValueIterable() override = default; - - /** - * Iterate over key-value pairs - * @param callback a callback to invoke for each key-value. If the callback returns false, - * the iteration is aborted. - * @return true if every key-value pair was iterated over - */ - bool ForEachKeyValue( - nostd::function_ref) const noexcept override - { - return true; - } - - /** - * @return the number of key-value pairs - */ - size_t size() const noexcept override { return 0; } -}; - -} // namespace common -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/key_value_iterable_view.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/key_value_iterable_view.h deleted file mode 100644 index e22fb6f06f..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/key_value_iterable_view.h +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include -#include -#include -#include -#include -#include - -#include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/common/key_value_iterable.h" -#include "opentelemetry/nostd/function_ref.h" -#include "opentelemetry/nostd/span.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/type_traits.h" -#include "opentelemetry/nostd/utility.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace common -{ -// NOTE - code within `detail` namespace implements internal details, and not part -// of the public interface. -namespace detail -{ -inline void take_key_value(nostd::string_view, common::AttributeValue) {} - -template -auto is_key_value_iterable_impl(T iterable) - -> decltype(take_key_value(std::begin(iterable)->first, std::begin(iterable)->second), - nostd::size(iterable), - std::true_type{}); - -std::false_type is_key_value_iterable_impl(...); - -template -struct is_key_value_iterable -{ - static const bool value = decltype(detail::is_key_value_iterable_impl(std::declval()))::value; -}; -} // namespace detail - -/** - * @brief Container for key-value pairs that can transform every value in it to one of types - * listed in common::AttributeValue. It may contain value types that are not directly map'able - * to primitive value types. In that case the `ForEachKeyValue` method acts as a transform to - * convert the value type to one listed under AtributeValue (bool, int32_t, int64_t, uint32_t, - * uint64_t, double, nostd::string_view, or arrays of primite types). For example, if UUID, - * GUID, or UTF-16 string type is passed as one of values stored inside this container, the - * container itself may provide a custom implementation of `ForEachKeyValue` to transform the - * 'non-standard' type to one of the standard types. - */ -template -class KeyValueIterableView final : public KeyValueIterable -{ - -public: - explicit KeyValueIterableView(const T &container) noexcept : container_{&container} {} - - // KeyValueIterable - bool ForEachKeyValue(nostd::function_ref - callback) const noexcept override - { - auto iter = std::begin(*container_); - auto last = std::end(*container_); - for (; iter != last; ++iter) - { - if (!callback(iter->first, iter->second)) - { - return false; - } - } - return true; - } - - size_t size() const noexcept override { return nostd::size(*container_); } - -private: - const T *container_; -}; - -template ::value> * = nullptr> -KeyValueIterableView MakeKeyValueIterableView(const T &container) noexcept -{ - return KeyValueIterableView(container); -} - -/** - * Utility function to help to make a attribute view from initializer_list - * - * @param attributes - * @return nostd::span> - */ -inline static nostd::span> -MakeAttributes(std::initializer_list> - attributes) noexcept -{ - return nostd::span>{ - attributes.begin(), attributes.end()}; -} - -/** - * Utility function to help to make a attribute view from a span - * - * @param attributes - * @return nostd::span> - */ -inline static nostd::span> -MakeAttributes( - nostd::span> attributes) noexcept -{ - return attributes; -} - -/** - * Utility function to help to make a attribute view from a KeyValueIterable - * - * @param attributes - * @return common::KeyValueIterable - */ -inline static const common::KeyValueIterable &MakeAttributes( - const common::KeyValueIterable &attributes) noexcept -{ - return attributes; -} - -/** - * Utility function to help to make a attribute view from a key-value iterable object - * - * @param attributes - * @return nostd::span> - */ -template < - class ArgumentType, - nostd::enable_if_t::value> * = nullptr> -inline static common::KeyValueIterableView MakeAttributes( - const ArgumentType &arg) noexcept -{ - return common::KeyValueIterableView(arg); -} - -} // namespace common -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/kv_properties.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/kv_properties.h deleted file mode 100644 index b5accab403..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/kv_properties.h +++ /dev/null @@ -1,272 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/common/string_util.h" -#include "opentelemetry/nostd/function_ref.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/unique_ptr.h" -#include "opentelemetry/version.h" - -#include -#include -#include - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace common -{ - -// Constructor parameter for KeyValueStringTokenizer -struct KeyValueStringTokenizerOptions -{ - char member_separator = ','; - char key_value_separator = '='; - bool ignore_empty_members = true; -}; - -// Tokenizer for key-value headers -class KeyValueStringTokenizer -{ -public: - KeyValueStringTokenizer( - nostd::string_view str, - const KeyValueStringTokenizerOptions &opts = KeyValueStringTokenizerOptions()) noexcept - : str_(str), opts_(opts), index_(0) - {} - - static nostd::string_view GetDefaultKeyOrValue() - { - static std::string default_str = ""; - return default_str; - } - - // Returns next key value in the string header - // @param valid_kv : if the found kv pair is valid or not - // @param key : key in kv pair - // @param key : value in kv pair - // @returns true if next kv pair was found, false otherwise. - bool next(bool &valid_kv, nostd::string_view &key, nostd::string_view &value) noexcept - { - valid_kv = true; - while (index_ < str_.size()) - { - bool is_empty_pair = false; - size_t end = str_.find(opts_.member_separator, index_); - if (end == std::string::npos) - { - end = str_.size() - 1; - } - else if (end == index_) // empty pair. do not update end - { - is_empty_pair = true; - } - else - { - end--; - } - - auto list_member = StringUtil::Trim(str_, index_, end); - if (list_member.size() == 0 || is_empty_pair) - { - // empty list member - index_ = end + 2 - is_empty_pair; - if (opts_.ignore_empty_members) - { - continue; - } - - valid_kv = true; - key = GetDefaultKeyOrValue(); - value = GetDefaultKeyOrValue(); - return true; - } - - auto key_end_pos = list_member.find(opts_.key_value_separator); - if (key_end_pos == std::string::npos) - { - // invalid member - valid_kv = false; - } - else - { - key = list_member.substr(0, key_end_pos); - value = list_member.substr(key_end_pos + 1); - } - - index_ = end + 2; - - return true; - } - - // no more entries remaining - return false; - } - - // Returns total number of tokens in header string - size_t NumTokens() const noexcept - { - size_t cnt = 0, begin = 0; - while (begin < str_.size()) - { - ++cnt; - size_t end = str_.find(opts_.member_separator, begin); - if (end == std::string::npos) - { - break; - } - - begin = end + 1; - } - - return cnt; - } - - // Resets the iterator - void reset() noexcept { index_ = 0; } - -private: - nostd::string_view str_; - KeyValueStringTokenizerOptions opts_; - size_t index_; -}; - -// Class to store fixed size array of key-value pairs of string type -class KeyValueProperties -{ - // Class to store key-value pairs of string types -public: - class Entry - { - public: - Entry() : key_(nullptr), value_(nullptr) {} - - // Copy constructor - Entry(const Entry ©) - { - key_ = CopyStringToPointer(copy.key_.get()); - value_ = CopyStringToPointer(copy.value_.get()); - } - - // Copy assignment operator - Entry &operator=(Entry &other) - { - key_ = CopyStringToPointer(other.key_.get()); - value_ = CopyStringToPointer(other.value_.get()); - return *this; - } - - // Move contructor and assignment operator - Entry(Entry &&other) = default; - Entry &operator=(Entry &&other) = default; - - // Creates an Entry for a given key-value pair. - Entry(nostd::string_view key, nostd::string_view value) - { - key_ = CopyStringToPointer(key); - value_ = CopyStringToPointer(value); - } - - // Gets the key associated with this entry. - nostd::string_view GetKey() const noexcept { return key_.get(); } - - // Gets the value associated with this entry. - nostd::string_view GetValue() const noexcept { return value_.get(); } - - // Sets the value for this entry. This overrides the previous value. - void SetValue(nostd::string_view value) noexcept { value_ = CopyStringToPointer(value); } - - private: - // Store key and value as raw char pointers to avoid using std::string. - nostd::unique_ptr key_; - nostd::unique_ptr value_; - - // Copies string into a buffer and returns a unique_ptr to the buffer. - // This is a workaround for the fact that memcpy doesn't accept a const destination. - nostd::unique_ptr CopyStringToPointer(nostd::string_view str) - { - char *temp = new char[str.size() + 1]; - memcpy(temp, str.data(), str.size()); - temp[str.size()] = '\0'; - return nostd::unique_ptr(temp); - } - }; - - // Maintain the number of entries in entries_. - size_t num_entries_; - - // Max size of allocated array - size_t max_num_entries_; - - // Store entries in a C-style array to avoid using std::array or std::vector. - nostd::unique_ptr entries_; - -public: - // Create Key-value list of given size - // @param size : Size of list. - KeyValueProperties(size_t size) noexcept - : num_entries_(0), max_num_entries_(size), entries_(new Entry[size]) - {} - - // Create Empty Key-Value list - KeyValueProperties() noexcept : num_entries_(0), max_num_entries_(0), entries_(nullptr) {} - - template ::value>::type> - KeyValueProperties(const T &keys_and_values) noexcept - : num_entries_(0), - max_num_entries_(keys_and_values.size()), - entries_(new Entry[max_num_entries_]) - { - for (auto &e : keys_and_values) - { - Entry entry(e.first, e.second); - (entries_.get())[num_entries_++] = std::move(entry); - } - } - - // Adds new kv pair into kv properties - void AddEntry(nostd::string_view key, nostd::string_view value) noexcept - { - if (num_entries_ < max_num_entries_) - { - Entry entry(key, value); - (entries_.get())[num_entries_++] = std::move(entry); - } - } - - // Returns all kv pair entries - bool GetAllEntries( - nostd::function_ref callback) const noexcept - { - for (size_t i = 0; i < num_entries_; i++) - { - auto &entry = (entries_.get())[i]; - if (!callback(entry.GetKey(), entry.GetValue())) - { - return false; - } - } - return true; - } - - // Return value for key if exists, return false otherwise - bool GetValue(nostd::string_view key, std::string &value) const noexcept - { - for (size_t i = 0; i < num_entries_; i++) - { - auto &entry = (entries_.get())[i]; - if (entry.GetKey() == key) - { - const auto &entry_value = entry.GetValue(); - value = std::string(entry_value.data(), entry_value.size()); - return true; - } - } - return false; - } - - size_t Size() const noexcept { return num_entries_; } -}; -} // namespace common -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/macros.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/macros.h deleted file mode 100644 index 71d12a57bf..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/macros.h +++ /dev/null @@ -1,523 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -/* - OPENTELEMETRY_HAVE_BUILTIN&OPENTELEMETRY_HAVE_FEATURE - - Checks whether the compiler supports a Clang Feature Checking Macro, and if - so, checks whether it supports the provided builtin function "x" where x - is one of the functions noted in - https://clang.llvm.org/docs/LanguageExtensions.html - - Note: Use this macro to avoid an extra level of #ifdef __has_builtin check. - http://releases.llvm.org/3.3/tools/clang/docs/LanguageExtensions.html -*/ -#if !defined(OPENTELEMETRY_HAVE_BUILTIN) -# ifdef __has_builtin -# define OPENTELEMETRY_HAVE_BUILTIN(x) __has_builtin(x) -# else -# define OPENTELEMETRY_HAVE_BUILTIN(x) 0 -# endif -#endif - -#if !defined(OPENTELEMETRY_HAVE_FEATURE) -# ifdef __has_feature -# define OPENTELEMETRY_HAVE_FEATURE(f) __has_feature(f) -# else -# define OPENTELEMETRY_HAVE_FEATURE(f) 0 -# endif -#endif - -/* - has feature - - OPENTELEMETRY_HAVE_ATTRIBUTE - - A function-like feature checking macro that is a wrapper around - `__has_attribute`, which is defined by GCC 5+ and Clang and evaluates to a - nonzero constant integer if the attribute is supported or 0 if not. - - It evaluates to zero if `__has_attribute` is not defined by the compiler. - - GCC: https://gcc.gnu.org/gcc-5/changes.html - Clang: https://clang.llvm.org/docs/LanguageExtensions.html -*/ -#if !defined(OPENTELEMETRY_HAVE_ATTRIBUTE) -# ifdef __has_attribute -# define OPENTELEMETRY_HAVE_ATTRIBUTE(x) __has_attribute(x) -# else -# define OPENTELEMETRY_HAVE_ATTRIBUTE(x) 0 -# endif -#endif - -/* - OPENTELEMETRY_HAVE_CPP_ATTRIBUTE - - A function-like feature checking macro that accepts C++11 style attributes. - It's a wrapper around `__has_cpp_attribute`, defined by ISO C++ SD-6 - (https://en.cppreference.com/w/cpp/experimental/feature_test). If we don't - find `__has_cpp_attribute`, will evaluate to 0. -*/ -#if !defined(OPENTELEMETRY_HAVE_CPP_ATTRIBUTE) -# if defined(__cplusplus) && defined(__has_cpp_attribute) -// NOTE: requiring __cplusplus above should not be necessary, but -// works around https://bugs.llvm.org/show_bug.cgi?id=23435. -# define OPENTELEMETRY_HAVE_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) -# else -# define OPENTELEMETRY_HAVE_CPP_ATTRIBUTE(x) 0 -# endif -#endif - -/* - Expected usage pattern: - - if OPENTELEMETRY_LIKELY_CONDITION (ptr != nullptr) - { - do_something_likely(); - } else { - do_something_unlikely(); - } - - This pattern works with gcc/clang and __builtin_expect(), - as well as with C++20. - It is unclear if __builtin_expect() will be deprecated - in favor of C++20 [[likely]] or not. - - OPENTELEMETRY_LIKELY_CONDITION is preferred over OPENTELEMETRY_LIKELY, - to be revisited when C++20 is required. -*/ - -#if !defined(OPENTELEMETRY_LIKELY_CONDITION) && defined(__cplusplus) -// Only use likely with C++20 -# if __cplusplus >= 202002L -// GCC 9 has likely attribute but do not support declare it at the beginning of statement -# if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9) -# if __has_cpp_attribute(likely) -# define OPENTELEMETRY_LIKELY_CONDITION(C) (C) [[likely]] -# endif -# endif -# endif -#endif -#if !defined(OPENTELEMETRY_LIKELY_CONDITION) && (defined(__clang__) || defined(__GNUC__)) -// Only use if supported by the compiler -# define OPENTELEMETRY_LIKELY_CONDITION(C) (__builtin_expect(!!(C), true)) -#endif -#ifndef OPENTELEMETRY_LIKELY_CONDITION -// Do not use likely annotations -# define OPENTELEMETRY_LIKELY_CONDITION(C) (C) -#endif - -#if !defined(OPENTELEMETRY_UNLIKELY_CONDITION) && defined(__cplusplus) -// Only use unlikely with C++20 -# if __cplusplus >= 202002L -// GCC 9 has unlikely attribute but do not support declare it at the beginning of statement -# if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9) -# if __has_cpp_attribute(unlikely) -# define OPENTELEMETRY_UNLIKELY_CONDITION(C) (C) [[unlikely]] -# endif -# endif -# endif -#endif -#if !defined(OPENTELEMETRY_UNLIKELY_CONDITION) && (defined(__clang__) || defined(__GNUC__)) -// Only use if supported by the compiler -# define OPENTELEMETRY_UNLIKELY_CONDITION(C) (__builtin_expect(!!(C), false)) -#endif -#ifndef OPENTELEMETRY_UNLIKELY_CONDITION -// Do not use unlikely annotations -# define OPENTELEMETRY_UNLIKELY_CONDITION(C) (C) -#endif - -/* - Expected usage pattern: - - if (ptr != nullptr) - OPENTELEMETRY_LIKELY - { - do_something_likely(); - } else { - do_something_unlikely(); - } - - This pattern works starting with C++20. - See https://en.cppreference.com/w/cpp/language/attributes/likely - - Please use OPENTELEMETRY_LIKELY_CONDITION instead for now. -*/ - -#if !defined(OPENTELEMETRY_LIKELY) && defined(__cplusplus) -// Only use likely with C++20 -# if __cplusplus >= 202002L -// GCC 9 has likely attribute but do not support declare it at the beginning of statement -# if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9) -# if __has_cpp_attribute(likely) -# define OPENTELEMETRY_LIKELY [[likely]] -# endif -# endif -# endif -#endif - -#ifndef OPENTELEMETRY_LIKELY -# define OPENTELEMETRY_LIKELY -#endif - -#if !defined(OPENTELEMETRY_UNLIKELY) && defined(__cplusplus) -// Only use unlikely with C++20 -# if __cplusplus >= 202002L -// GCC 9 has unlikely attribute but do not support declare it at the beginning of statement -# if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9) -# if __has_cpp_attribute(unlikely) -# define OPENTELEMETRY_UNLIKELY [[unlikely]] -# endif -# endif -# endif -#endif - -#ifndef OPENTELEMETRY_UNLIKELY -# define OPENTELEMETRY_UNLIKELY -#endif - -/// \brief Declare variable as maybe unused -/// usage: -/// OPENTELEMETRY_MAYBE_UNUSED int a; -/// class OPENTELEMETRY_MAYBE_UNUSED a; -/// OPENTELEMETRY_MAYBE_UNUSED int a(); -/// -#if defined(__cplusplus) && __cplusplus >= 201703L -# define OPENTELEMETRY_MAYBE_UNUSED [[maybe_unused]] -#elif defined(__clang__) -# define OPENTELEMETRY_MAYBE_UNUSED __attribute__((unused)) -#elif defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) -# define OPENTELEMETRY_MAYBE_UNUSED __attribute__((unused)) -#elif (defined(_MSC_VER) && _MSC_VER >= 1910) && (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) -# define OPENTELEMETRY_MAYBE_UNUSED [[maybe_unused]] -#else -# define OPENTELEMETRY_MAYBE_UNUSED -#endif - -#ifndef OPENTELEMETRY_RTTI_ENABLED -# if defined(__clang__) -# if __has_feature(cxx_rtti) -# define OPENTELEMETRY_RTTI_ENABLED -# endif -# elif defined(__GNUG__) -# if defined(__GXX_RTTI) -# define OPENTELEMETRY_RTTI_ENABLED -# endif -# elif defined(_MSC_VER) -# if defined(_CPPRTTI) -# define OPENTELEMETRY_RTTI_ENABLED -# endif -# endif -#endif - -#if defined(__cplusplus) && __cplusplus >= 201402L -# define OPENTELEMETRY_DEPRECATED [[deprecated]] -#elif defined(__clang__) -# define OPENTELEMETRY_DEPRECATED __attribute__((deprecated)) -#elif defined(__GNUC__) -# define OPENTELEMETRY_DEPRECATED __attribute__((deprecated)) -#elif defined(_MSC_VER) -# if _MSC_VER >= 1910 && defined(_MSVC_LANG) && _MSVC_LANG >= 201703L -# define OPENTELEMETRY_DEPRECATED [[deprecated]] -# else -# define OPENTELEMETRY_DEPRECATED __declspec(deprecated) -# endif -#else -# define OPENTELEMETRY_DEPRECATED -#endif - -#if defined(__cplusplus) && __cplusplus >= 201402L -# define OPENTELEMETRY_DEPRECATED_MESSAGE(msg) [[deprecated(msg)]] -#elif defined(__clang__) -# define OPENTELEMETRY_DEPRECATED_MESSAGE(msg) __attribute__((deprecated(msg))) -#elif defined(__GNUC__) -# define OPENTELEMETRY_DEPRECATED_MESSAGE(msg) __attribute__((deprecated(msg))) -#elif defined(_MSC_VER) -# if _MSC_VER >= 1910 && defined(_MSVC_LANG) && _MSVC_LANG >= 201703L -# define OPENTELEMETRY_DEPRECATED_MESSAGE(msg) [[deprecated(msg)]] -# else -# define OPENTELEMETRY_DEPRECATED_MESSAGE(msg) __declspec(deprecated(msg)) -# endif -#else -# define OPENTELEMETRY_DEPRECATED_MESSAGE(msg) -#endif - -// Regex support -#if (__GNUC__ == 4 && (__GNUC_MINOR__ == 8 || __GNUC_MINOR__ == 9)) -# define OPENTELEMETRY_HAVE_WORKING_REGEX 0 -#else -# define OPENTELEMETRY_HAVE_WORKING_REGEX 1 -#endif - -/* clang-format off */ - -/** - @page HEADER_ONLY_SINGLETON Header only singleton. - - @section ELF_SINGLETON - - For clang and gcc, the desired coding pattern is as follows. - - @verbatim - class Foo - { - // (a) - __attribute__((visibility("default"))) - // (b) - T& get_singleton() - { - // (c) - static T singleton; - return singleton; - } - }; - @endverbatim - - (a) is needed when the code is build with - @code -fvisibility="hidden" @endcode - to ensure that all instances of (b) are visible to the linker. - - What is duplicated in the binary is @em code, in (b). - - The linker will make sure only one instance - of all the (b) methods is used. - - (c) is a singleton implemented inside a method. - - This is very desirable, because: - - - the C++ compiler guarantees that construction - of the variable (c) is thread safe. - - - constructors for (c) singletons are executed in code path order, - or not at all if the singleton is never used. - - @section OTHER_SINGLETON - - For other platforms, header only singletons are not supported at this -point. - - @section CODING_PATTERN - - The coding pattern to use in the source code is as follows - - @verbatim - class Foo - { - OPENTELEMETRY_API_SINGLETON - T& get_singleton() - { - static T singleton; - return singleton; - } - }; - @endverbatim -*/ - -/* clang-format on */ - -#if defined(__clang__) - -# define OPENTELEMETRY_API_SINGLETON __attribute__((visibility("default"))) -# define OPENTELEMETRY_LOCAL_SYMBOL __attribute__((visibility("hidden"))) - -#elif defined(__GNUC__) - -# define OPENTELEMETRY_API_SINGLETON __attribute__((visibility("default"))) -# define OPENTELEMETRY_LOCAL_SYMBOL __attribute__((visibility("hidden"))) - -#else - -/* Add support for other compilers here. */ - -# define OPENTELEMETRY_API_SINGLETON -# define OPENTELEMETRY_LOCAL_SYMBOL - -#endif - -// -// Atomic wrappers based on compiler intrinsics for memory read/write. -// The tailing number is read/write length in bits. -// -// N.B. Compiler intrinsic is used because the usage of C++ standard library is restricted in the -// OpenTelemetry C++ API. -// -#if defined(__GNUC__) - -# define OPENTELEMETRY_ATOMIC_READ_8(ptr) __atomic_load_n(ptr, __ATOMIC_SEQ_CST) -# define OPENTELEMETRY_ATOMIC_WRITE_8(ptr, value) __atomic_store_n(ptr, value, __ATOMIC_SEQ_CST) - -#elif defined(_MSC_VER) - -# include - -# define OPENTELEMETRY_ATOMIC_READ_8(ptr) \ - static_cast(_InterlockedCompareExchange8(reinterpret_cast(ptr), 0, 0)) -# define OPENTELEMETRY_ATOMIC_WRITE_8(ptr, value) \ - _InterlockedExchange8(reinterpret_cast(ptr), static_cast(value)) - -#else -# error port atomics read/write for the current platform -#endif - -/* clang-format on */ -// -// The if/elif order matters here. If both OPENTELEMETRY_BUILD_IMPORT_DLL and -// OPENTELEMETRY_BUILD_EXPORT_DLL are defined, the former takes precedence. -// -// TODO: consider define OPENTELEMETRY_EXPORT for cygwin/gcc, see below link. -// https://gcc.gnu.org/wiki/Visibility#How_to_use_the_new_C.2B-.2B-_visibility_support -// -#if defined(_MSC_VER) && defined(OPENTELEMETRY_BUILD_IMPORT_DLL) - -# define OPENTELEMETRY_EXPORT __declspec(dllimport) - -#elif defined(_MSC_VER) && defined(OPENTELEMETRY_BUILD_EXPORT_DLL) - -# define OPENTELEMETRY_EXPORT __declspec(dllexport) - -#else - -// -// build OpenTelemetry as static library or not on Windows. -// -# define OPENTELEMETRY_EXPORT - -#endif - -// OPENTELEMETRY_HAVE_EXCEPTIONS -// -// Checks whether the compiler both supports and enables exceptions. Many -// compilers support a "no exceptions" mode that disables exceptions. -// -// Generally, when OPENTELEMETRY_HAVE_EXCEPTIONS is not defined: -// -// * Code using `throw` and `try` may not compile. -// * The `noexcept` specifier will still compile and behave as normal. -// * The `noexcept` operator may still return `false`. -// -// For further details, consult the compiler's documentation. -#ifndef OPENTELEMETRY_HAVE_EXCEPTIONS -# if defined(__clang__) && ((__clang_major__ * 100) + __clang_minor__) < 306 -// Clang < 3.6 -// http://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html#the-exceptions-macro -# if defined(__EXCEPTIONS) && OPENTELEMETRY_HAVE_FEATURE(cxx_exceptions) -# define OPENTELEMETRY_HAVE_EXCEPTIONS 1 -# endif // defined(__EXCEPTIONS) && OPENTELEMETRY_HAVE_FEATURE(cxx_exceptions) -# elif OPENTELEMETRY_HAVE_FEATURE(cxx_exceptions) -# define OPENTELEMETRY_HAVE_EXCEPTIONS 1 -// Handle remaining special cases and default to exceptions being supported. -# elif !(defined(__GNUC__) && !defined(__EXCEPTIONS) && !defined(__cpp_exceptions)) && \ - !(defined(_MSC_VER) && !defined(_CPPUNWIND)) -# define OPENTELEMETRY_HAVE_EXCEPTIONS 1 -# endif -#endif -#ifndef OPENTELEMETRY_HAVE_EXCEPTIONS -# define OPENTELEMETRY_HAVE_EXCEPTIONS 0 -#endif - -/* - OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND indicates that a resource owned by a function - parameter or implicit object parameter is retained by the return value of the - annotated function (or, for a parameter of a constructor, in the value of the - constructed object). This attribute causes warnings to be produced if a - temporary object does not live long enough. - - When applied to a reference parameter, the referenced object is assumed to be - retained by the return value of the function. When applied to a non-reference - parameter (for example, a pointer or a class type), all temporaries - referenced by the parameter are assumed to be retained by the return value of - the function. - - See also the upstream documentation: - https://clang.llvm.org/docs/AttributeReference.html#lifetimebound -*/ -#ifndef OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND -# if OPENTELEMETRY_HAVE_CPP_ATTRIBUTE(clang::lifetimebound) -# define OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND [[clang::lifetimebound]] -# elif OPENTELEMETRY_HAVE_ATTRIBUTE(lifetimebound) -# define OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND __attribute__((lifetimebound)) -# else -# define OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND -# endif -#endif - -// OPENTELEMETRY_HAVE_MEMORY_SANITIZER -// -// MemorySanitizer (MSan) is a detector of uninitialized reads. It consists of -// a compiler instrumentation module and a run-time library. -#ifndef OPENTELEMETRY_HAVE_MEMORY_SANITIZER -# if !defined(__native_client__) && OPENTELEMETRY_HAVE_FEATURE(memory_sanitizer) -# define OPENTELEMETRY_HAVE_MEMORY_SANITIZER 1 -# else -# define OPENTELEMETRY_HAVE_MEMORY_SANITIZER 0 -# endif -#endif - -#if OPENTELEMETRY_HAVE_MEMORY_SANITIZER && OPENTELEMETRY_HAVE_ATTRIBUTE(no_sanitize_memory) -# define OPENTELEMETRY_SANITIZER_NO_MEMORY \ - __attribute__((no_sanitize_memory)) // __attribute__((no_sanitize("memory"))) -#else -# define OPENTELEMETRY_SANITIZER_NO_MEMORY -#endif - -// OPENTELEMETRY_HAVE_THREAD_SANITIZER -// -// ThreadSanitizer (TSan) is a fast data race detector. -#ifndef OPENTELEMETRY_HAVE_THREAD_SANITIZER -# if defined(__SANITIZE_THREAD__) -# define OPENTELEMETRY_HAVE_THREAD_SANITIZER 1 -# elif OPENTELEMETRY_HAVE_FEATURE(thread_sanitizer) -# define OPENTELEMETRY_HAVE_THREAD_SANITIZER 1 -# else -# define OPENTELEMETRY_HAVE_THREAD_SANITIZER 0 -# endif -#endif - -#if OPENTELEMETRY_HAVE_THREAD_SANITIZER && OPENTELEMETRY_HAVE_ATTRIBUTE(no_sanitize_thread) -# define OPENTELEMETRY_SANITIZER_NO_THREAD \ - __attribute__((no_sanitize_thread)) // __attribute__((no_sanitize("thread"))) -#else -# define OPENTELEMETRY_SANITIZER_NO_THREAD -#endif - -// OPENTELEMETRY_HAVE_ADDRESS_SANITIZER -// -// AddressSanitizer (ASan) is a fast memory error detector. -#ifndef OPENTELEMETRY_HAVE_ADDRESS_SANITIZER -# if defined(__SANITIZE_ADDRESS__) -# define OPENTELEMETRY_HAVE_ADDRESS_SANITIZER 1 -# elif OPENTELEMETRY_HAVE_FEATURE(address_sanitizer) -# define OPENTELEMETRY_HAVE_ADDRESS_SANITIZER 1 -# else -# define OPENTELEMETRY_HAVE_ADDRESS_SANITIZER 0 -# endif -#endif - -// OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER -// -// Hardware-Assisted AddressSanitizer (or HWASAN) is even faster than asan -// memory error detector which can use CPU features like ARM TBI, Intel LAM or -// AMD UAI. -#ifndef OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER -# if defined(__SANITIZE_HWADDRESS__) -# define OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER 1 -# elif OPENTELEMETRY_HAVE_FEATURE(hwaddress_sanitizer) -# define OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER 1 -# else -# define OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER 0 -# endif -#endif - -#if OPENTELEMETRY_HAVE_ADDRESS_SANITIZER && OPENTELEMETRY_HAVE_ATTRIBUTE(no_sanitize_address) -# define OPENTELEMETRY_SANITIZER_NO_ADDRESS \ - __attribute__((no_sanitize_address)) // __attribute__((no_sanitize("address"))) -#elif OPENTELEMETRY_HAVE_ADDRESS_SANITIZER && defined(_MSC_VER) && _MSC_VER >= 1928 -# define OPENTELEMETRY_SANITIZER_NO_ADDRESS __declspec(no_sanitize_address) -#elif OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER && OPENTELEMETRY_HAVE_ATTRIBUTE(no_sanitize) -# define OPENTELEMETRY_SANITIZER_NO_ADDRESS __attribute__((no_sanitize("hwaddress"))) -#else -# define OPENTELEMETRY_SANITIZER_NO_ADDRESS -#endif diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/spin_lock_mutex.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/spin_lock_mutex.h deleted file mode 100644 index 7031fa4d23..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/spin_lock_mutex.h +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include -#include -#include - -#include "opentelemetry/version.h" - -#if defined(_MSC_VER) -# define _WINSOCKAPI_ // stops including winsock.h -# include -#elif defined(__i386__) || defined(__x86_64__) -# if defined(__clang__) -# include -# elif defined(__INTEL_COMPILER) -# include -# endif -#endif - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace common -{ - -constexpr int SPINLOCK_FAST_ITERATIONS = 100; -constexpr int SPINLOCK_SLEEP_MS = 1; - -/** - * A Mutex which uses atomic flags and spin-locks instead of halting threads. - * - * This mutex uses an incremental back-off strategy with the following phases: - * 1. A tight spin-lock loop (pending: using hardware PAUSE/YIELD instructions) - * 2. A loop where the current thread yields control after checking the lock. - * 3. Issuing a thread-sleep call before starting back in phase 1. - * - * This is meant to give a good balance of perofrmance and CPU consumption in - * practice. - * - * This mutex uses an incremental back-off strategy with the following phases: - * 1. A tight spin-lock loop (pending: using hardware PAUSE/YIELD instructions) - * 2. A loop where the current thread yields control after checking the lock. - * 3. Issuing a thread-sleep call before starting back in phase 1. - * - * This is meant to give a good balance of perofrmance and CPU consumption in - * practice. - * - * This class implements the `BasicLockable` specification: - * https://en.cppreference.com/w/cpp/named_req/BasicLockable - */ -class SpinLockMutex -{ -public: - SpinLockMutex() noexcept {} - ~SpinLockMutex() noexcept = default; - SpinLockMutex(const SpinLockMutex &) = delete; - SpinLockMutex &operator=(const SpinLockMutex &) = delete; - - static inline void fast_yield() noexcept - { -// Issue a Pause/Yield instruction while spinning. -#if defined(_MSC_VER) - YieldProcessor(); -#elif defined(__i386__) || defined(__x86_64__) -# if defined(__clang__) || defined(__INTEL_COMPILER) - _mm_pause(); -# else - __builtin_ia32_pause(); -# endif -#elif defined(__armel__) || defined(__ARMEL__) - asm volatile("nop" ::: "memory"); -#elif defined(__arm__) || defined(__aarch64__) // arm big endian / arm64 - __asm__ __volatile__("yield" ::: "memory"); -#else - // TODO: Issue PAGE/YIELD on other architectures. -#endif - } - - /** - * Attempts to lock the mutex. Return immediately with `true` (success) or `false` (failure). - */ - bool try_lock() noexcept - { - return !flag_.load(std::memory_order_relaxed) && - !flag_.exchange(true, std::memory_order_acquire); - } - - /** - * Blocks until a lock can be obtained for the current thread. - * - * This mutex will spin the current CPU waiting for the lock to be available. This can have - * decent performance in scenarios where there is low lock contention and lock-holders achieve - * their work quickly. It degrades in scenarios where locked tasks take a long time. - */ - void lock() noexcept - { - for (;;) - { - // Try once - if (!flag_.exchange(true, std::memory_order_acquire)) - { - return; - } - // Spin-Fast (goal ~10ns) - for (std::size_t i = 0; i < SPINLOCK_FAST_ITERATIONS; ++i) - { - if (try_lock()) - { - return; - } - fast_yield(); - } - // Yield then try again (goal ~100ns) - std::this_thread::yield(); - if (try_lock()) - { - return; - } - // Sleep and then start the whole process again. (goal ~1000ns) - std::this_thread::sleep_for(std::chrono::milliseconds(SPINLOCK_SLEEP_MS)); - } - return; - } - /** Releases the lock held by the execution agent. Throws no exceptions. */ - void unlock() noexcept { flag_.store(false, std::memory_order_release); } - -private: - std::atomic flag_{false}; -}; - -} // namespace common -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/string_util.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/string_util.h deleted file mode 100644 index 273a65272b..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/string_util.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace common -{ - -class StringUtil -{ -public: - static nostd::string_view Trim(nostd::string_view str, size_t left, size_t right) noexcept - { - while (left <= right && isspace(str[left])) - { - left++; - } - while (left <= right && isspace(str[right])) - { - right--; - } - return str.substr(left, 1 + right - left); - } - - static nostd::string_view Trim(nostd::string_view str) noexcept - { - if (str.empty()) - { - return str; - } - - return Trim(str, 0, str.size() - 1); - } -}; - -} // namespace common - -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/timestamp.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/timestamp.h deleted file mode 100644 index f7c79b8b57..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/common/timestamp.h +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include -#include - -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace common -{ -/** - * @brief A timepoint relative to the system clock epoch. - * - * This is used for marking the beginning and end of an operation. - */ -class SystemTimestamp -{ -public: - /** - * @brief Initializes a system timestamp pointing to the start of the epoch. - */ - SystemTimestamp() noexcept : nanos_since_epoch_{0} {} - - /** - * @brief Initializes a system timestamp from a duration. - * - * @param time_since_epoch Time elapsed since the beginning of the epoch. - */ - template - explicit SystemTimestamp(const std::chrono::duration &time_since_epoch) noexcept - : nanos_since_epoch_{static_cast( - std::chrono::duration_cast(time_since_epoch).count())} - {} - - /** - * @brief Initializes a system timestamp based on a point in time. - * - * @param time_point A point in time. - */ - /*implicit*/ SystemTimestamp(const std::chrono::system_clock::time_point &time_point) noexcept - : SystemTimestamp{time_point.time_since_epoch()} - {} - - /** - * @brief Returns a time point for the time stamp. - * - * @return A time point corresponding to the time stamp. - */ - operator std::chrono::system_clock::time_point() const noexcept - { - return std::chrono::system_clock::time_point{ - std::chrono::duration_cast( - std::chrono::nanoseconds{nanos_since_epoch_})}; - } - - /** - * @brief Returns the nanoseconds since the beginning of the epoch. - * - * @return Elapsed nanoseconds since the beginning of the epoch for this timestamp. - */ - std::chrono::nanoseconds time_since_epoch() const noexcept - { - return std::chrono::nanoseconds{nanos_since_epoch_}; - } - - /** - * @brief Compare two steady time stamps. - * - * @return true if the two time stamps are equal. - */ - bool operator==(const SystemTimestamp &other) const noexcept - { - return nanos_since_epoch_ == other.nanos_since_epoch_; - } - - /** - * @brief Compare two steady time stamps for inequality. - * - * @return true if the two time stamps are not equal. - */ - bool operator!=(const SystemTimestamp &other) const noexcept - { - return nanos_since_epoch_ != other.nanos_since_epoch_; - } - -private: - int64_t nanos_since_epoch_; -}; - -/** - * @brief A timepoint relative to the monotonic clock epoch - * - * This is used for calculating the duration of an operation. - */ -class SteadyTimestamp -{ -public: - /** - * @brief Initializes a monotonic timestamp pointing to the start of the epoch. - */ - SteadyTimestamp() noexcept : nanos_since_epoch_{0} {} - - /** - * @brief Initializes a monotonic timestamp from a duration. - * - * @param time_since_epoch Time elapsed since the beginning of the epoch. - */ - template - explicit SteadyTimestamp(const std::chrono::duration &time_since_epoch) noexcept - : nanos_since_epoch_{static_cast( - std::chrono::duration_cast(time_since_epoch).count())} - {} - - /** - * @brief Initializes a monotonic timestamp based on a point in time. - * - * @param time_point A point in time. - */ - /*implicit*/ SteadyTimestamp(const std::chrono::steady_clock::time_point &time_point) noexcept - : SteadyTimestamp{time_point.time_since_epoch()} - {} - - /** - * @brief Returns a time point for the time stamp. - * - * @return A time point corresponding to the time stamp. - */ - operator std::chrono::steady_clock::time_point() const noexcept - { - return std::chrono::steady_clock::time_point{ - std::chrono::duration_cast( - std::chrono::nanoseconds{nanos_since_epoch_})}; - } - - /** - * @brief Returns the nanoseconds since the beginning of the epoch. - * - * @return Elapsed nanoseconds since the beginning of the epoch for this timestamp. - */ - std::chrono::nanoseconds time_since_epoch() const noexcept - { - return std::chrono::nanoseconds{nanos_since_epoch_}; - } - - /** - * @brief Compare two steady time stamps. - * - * @return true if the two time stamps are equal. - */ - bool operator==(const SteadyTimestamp &other) const noexcept - { - return nanos_since_epoch_ == other.nanos_since_epoch_; - } - - /** - * @brief Compare two steady time stamps for inequality. - * - * @return true if the two time stamps are not equal. - */ - bool operator!=(const SteadyTimestamp &other) const noexcept - { - return nanos_since_epoch_ != other.nanos_since_epoch_; - } - -private: - int64_t nanos_since_epoch_; -}; - -class DurationUtil -{ -public: - template - static std::chrono::duration AdjustWaitForTimeout( - std::chrono::duration timeout, - std::chrono::duration indefinite_value) noexcept - { - // Do not call now() when this duration is max value, now() may have a expensive cost. - if (timeout == (std::chrono::duration::max)()) - { - return indefinite_value; - } - - // std::future::wait_for, std::this_thread::sleep_for, and std::condition_variable::wait_for - // may use steady_clock or system_clock.We need make sure now() + timeout do not overflow. - auto max_timeout = std::chrono::duration_cast>( - (std::chrono::steady_clock::time_point::max)() - std::chrono::steady_clock::now()); - if (timeout >= max_timeout) - { - return indefinite_value; - } - max_timeout = std::chrono::duration_cast>( - (std::chrono::system_clock::time_point::max)() - std::chrono::system_clock::now()); - if (timeout >= max_timeout) - { - return indefinite_value; - } - - return timeout; - } -}; - -} // namespace common -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/config.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/config.h deleted file mode 100644 index cb52f3b5dc..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/config.h +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include // IWYU pragma: keep - -#if defined(OPENTELEMETRY_ABI_VERSION_NO) && OPENTELEMETRY_ABI_VERSION_NO >= 2 -# error \ - "opentelemetry/config.h is removed in ABI version 2 and later. Please use opentelemetry/version.h instead." -#else -# if defined(__clang__) || defined(__GNUC__) -# pragma GCC warning \ - "opentelemetry/config.h is deprecated. Please use opentelemetry/version.h instead." -# elif defined(_MSC_VER) -# pragma message( \ - "[WARNING]: opentelemetry/config.h is deprecated. Please use opentelemetry/version.h instead.") -# endif -#endif diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/context.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/context.h deleted file mode 100644 index 924036efad..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/context.h +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include -#include - -#include "opentelemetry/context/context_value.h" -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/variant.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace context -{ - -// The context class provides a context identifier. Is built as a linked list -// of DataList nodes and each context holds a shared_ptr to a place within -// the list that determines which keys and values it has access to. All that -// come before and none that come after. -class Context -{ - -public: - Context() = default; - // Creates a context object from a map of keys and identifiers, this will - // hold a shared_ptr to the head of the DataList linked list - template - Context(const T &keys_and_values) noexcept - : head_{nostd::shared_ptr{new DataList(keys_and_values)}} - {} - - // Creates a context object from a key and value, this will - // hold a shared_ptr to the head of the DataList linked list - Context(nostd::string_view key, ContextValue value) noexcept - : head_{nostd::shared_ptr{new DataList(key, value)}} - {} - - // Accepts a new iterable and then returns a new context that - // contains the new key and value data. It attaches the - // exisiting list to the end of the new list. - template - Context SetValues(T &values) noexcept - { - Context context = Context(values); - nostd::shared_ptr last = context.head_; - while (last->next_ != nullptr) - { - last = last->next_; - } - last->next_ = head_; - return context; - } - - // Accepts a new iterable and then returns a new context that - // contains the new key and value data. It attaches the - // exisiting list to the end of the new list. - Context SetValue(nostd::string_view key, ContextValue value) noexcept - { - Context context = Context(key, value); - context.head_->next_ = head_; - return context; - } - - // Returns the value associated with the passed in key. - context::ContextValue GetValue(const nostd::string_view key) const noexcept - { - for (DataList *data = head_.get(); data != nullptr; data = data->next_.get()) - { - if (key.size() == data->key_length_) - { - if (std::memcmp(key.data(), data->key_, data->key_length_) == 0) - { - return data->value_; - } - } - } - return ContextValue{}; - } - - // Checks for key and returns true if found - bool HasKey(const nostd::string_view key) const noexcept - { - return !nostd::holds_alternative(GetValue(key)); - } - - bool operator==(const Context &other) const noexcept { return (head_ == other.head_); } - -private: - // A linked list to contain the keys and values of this context node - struct DataList - { - char *key_ = nullptr; - - nostd::shared_ptr next_{nullptr}; - - size_t key_length_ = 0UL; - - ContextValue value_; - - DataList() = default; - - // Builds a data list off of a key and value iterable and returns the head - template - DataList(const T &keys_and_vals) - { - bool first = true; - auto *node = this; - for (auto &iter : keys_and_vals) - { - if (first) - { - *node = DataList(iter.first, iter.second); - first = false; - } - else - { - node->next_ = nostd::shared_ptr(new DataList(iter.first, iter.second)); - node = node->next_.get(); - } - } - } - - // Builds a data list with just a key and value, so it will just be the head - // and returns that head. - DataList(nostd::string_view key, const ContextValue &value) - { - key_ = new char[key.size()]; - key_length_ = key.size(); - std::memcpy(key_, key.data(), key.size() * sizeof(char)); - next_ = nostd::shared_ptr{nullptr}; - value_ = value; - } - - DataList(const DataList &other) - : key_(new char[other.key_length_]), - next_(other.next_), - key_length_(other.key_length_), - value_(other.value_) - { - std::memcpy(key_, other.key_, other.key_length_ * sizeof(char)); - } - - DataList &operator=(DataList &&other) noexcept - { - key_length_ = other.key_length_; - value_ = std::move(other.value_); - next_ = std::move(other.next_); - - key_ = other.key_; - other.key_ = nullptr; - - return *this; - } - - ~DataList() - { - if (key_ != nullptr) - { - delete[] key_; - } - } - }; - - // Head of the list which holds the keys and values of this context - nostd::shared_ptr head_; -}; -} // namespace context -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/context_value.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/context_value.h deleted file mode 100644 index 27bd40fb05..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/context_value.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include - -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/variant.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace baggage -{ -class Baggage; -} // namespace baggage - -namespace trace -{ -class Span; -class SpanContext; -} // namespace trace - -namespace context -{ -using ContextValue = nostd::variant, - nostd::shared_ptr, - nostd::shared_ptr>; -} // namespace context -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/propagation/composite_propagator.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/propagation/composite_propagator.h deleted file mode 100644 index f7afe23bfd..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/propagation/composite_propagator.h +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include -#include - -#include "opentelemetry/context/propagation/text_map_propagator.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace context -{ -namespace propagation -{ - -class CompositePropagator : public TextMapPropagator -{ -public: - CompositePropagator(std::vector> propagators) - : propagators_(std::move(propagators)) - {} - - /** - * Run each of the configured propagators with the given context and carrier. - * Propagators are run in the order they are configured, so if multiple - * propagators write the same carrier key, the propagator later in the list - * will "win". - * - * @param carrier Carrier into which context will be injected - * @param context Context to inject - * - */ - - void Inject(TextMapCarrier &carrier, const context::Context &context) noexcept override - { - for (auto &p : propagators_) - { - p->Inject(carrier, context); - } - } - - /** - * Run each of the configured propagators with the given context and carrier. - * Propagators are run in the order they are configured, so if multiple - * propagators write the same context key, the propagator later in the list - * will "win". - * - * @param carrier Carrier from which to extract context - * @param context Context to add values to - */ - context::Context Extract(const TextMapCarrier &carrier, - context::Context &context) noexcept override - { - auto first = true; - context::Context tmp_context; - for (auto &p : propagators_) - { - if (first) - { - tmp_context = p->Extract(carrier, context); - first = false; - } - else - { - tmp_context = p->Extract(carrier, tmp_context); - } - } - return propagators_.size() ? tmp_context : context; - } - - /** - * Invoke callback with fields set to carrier by `inject` method for all the - * configured propagators - * Returns true if all invocation return true - */ - bool Fields(nostd::function_ref callback) const noexcept override - { - bool status = true; - for (auto &p : propagators_) - { - status = status && p->Fields(callback); - } - return status; - } - -private: - std::vector> propagators_; -}; -} // namespace propagation -} // namespace context -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/propagation/global_propagator.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/propagation/global_propagator.h deleted file mode 100644 index 85293202f6..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/propagation/global_propagator.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include - -#include "opentelemetry/context/propagation/noop_propagator.h" - -#include "opentelemetry/common/macros.h" -#include "opentelemetry/common/spin_lock_mutex.h" -#include "opentelemetry/nostd/shared_ptr.h" - -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace context -{ -namespace propagation -{ - -class TextMapPropagator; - -/* Stores the singleton TextMapPropagator */ - -class OPENTELEMETRY_EXPORT GlobalTextMapPropagator -{ -public: - static nostd::shared_ptr GetGlobalPropagator() noexcept - { - std::lock_guard guard(GetLock()); - return nostd::shared_ptr(GetPropagator()); - } - - static void SetGlobalPropagator(const nostd::shared_ptr &prop) noexcept - { - std::lock_guard guard(GetLock()); - GetPropagator() = prop; - } - -private: - OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr &GetPropagator() noexcept - { - static nostd::shared_ptr propagator(new NoOpPropagator()); - return propagator; - } - - OPENTELEMETRY_API_SINGLETON static common::SpinLockMutex &GetLock() noexcept - { - static common::SpinLockMutex lock; - return lock; - } -}; - -} // namespace propagation -} // namespace context -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/propagation/noop_propagator.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/propagation/noop_propagator.h deleted file mode 100644 index 4e1b30c17f..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/propagation/noop_propagator.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/context/propagation/text_map_propagator.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace context -{ -namespace propagation -{ - -/** - * No-op implementation TextMapPropagator - */ -class NoOpPropagator : public TextMapPropagator -{ -public: - /** Noop extract function does nothing and returns the input context */ - context::Context Extract(const TextMapCarrier & /*carrier*/, - context::Context &context) noexcept override - { - return context; - } - - /** Noop inject function does nothing */ - void Inject(TextMapCarrier & /*carrier*/, - const context::Context & /* context */) noexcept override - {} - - bool Fields(nostd::function_ref /* callback */) const noexcept override - { - return true; - } -}; -} // namespace propagation -} // namespace context -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/propagation/text_map_propagator.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/propagation/text_map_propagator.h deleted file mode 100644 index 21bc293616..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/propagation/text_map_propagator.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/context/context.h" -#include "opentelemetry/nostd/function_ref.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace context -{ -namespace propagation -{ - -// TextMapCarrier is the storage medium used by TextMapPropagator. -class TextMapCarrier -{ -public: - // returns the value associated with the passed key. - virtual nostd::string_view Get(nostd::string_view key) const noexcept = 0; - - // stores the key-value pair. - virtual void Set(nostd::string_view key, nostd::string_view value) noexcept = 0; - - /* list of all the keys in the carrier. - By default, it returns true without invoking callback */ - virtual bool Keys(nostd::function_ref /* callback */) const noexcept - { - return true; - } - virtual ~TextMapCarrier() = default; -}; - -// The TextMapPropagator class provides an interface that enables extracting and injecting -// context into carriers that travel in-band across process boundaries. HTTP frameworks and clients -// can integrate with TextMapPropagator by providing the object containing the -// headers, and a getter and setter function for the extraction and -// injection of values, respectively. - -class TextMapPropagator -{ -public: - // Returns the context that is stored in the carrier with the TextMapCarrier as extractor. - virtual context::Context Extract(const TextMapCarrier &carrier, - context::Context &context) noexcept = 0; - - // Sets the context for carrier with self defined rules. - virtual void Inject(TextMapCarrier &carrier, const context::Context &context) noexcept = 0; - - // Gets the fields set in the carrier by the `inject` method - virtual bool Fields(nostd::function_ref callback) const noexcept = 0; - - virtual ~TextMapPropagator() = default; -}; -} // namespace propagation -} // namespace context -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/runtime_context.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/runtime_context.h deleted file mode 100644 index e3f88254cb..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/context/runtime_context.h +++ /dev/null @@ -1,340 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include -#include - -#include "opentelemetry/common/macros.h" -#include "opentelemetry/context/context.h" -#include "opentelemetry/context/context_value.h" -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/unique_ptr.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace context -{ -// The Token object provides is returned when attaching objects to the -// RuntimeContext object and is associated with a context object, and -// can be provided to the RuntimeContext Detach method to remove the -// associated context from the RuntimeContext. -class Token -{ -public: - bool operator==(const Context &other) const noexcept { return context_ == other; } - - ~Token() noexcept; - -private: - friend class RuntimeContextStorage; - - // A constructor that sets the token's Context object to the - // one that was passed in. - Token(const Context &context) : context_(context) {} - - const Context context_; -}; - -/** - * RuntimeContextStorage is used by RuntimeContext to store Context frames. - * - * Custom context management strategies can be implemented by deriving from - * this class and passing an initialized RuntimeContextStorage object to - * RuntimeContext::SetRuntimeContextStorage. - */ -class OPENTELEMETRY_EXPORT RuntimeContextStorage -{ -public: - /** - * Return the current context. - * @return the current context - */ - virtual Context GetCurrent() noexcept = 0; - - /** - * Set the current context. - * @param the new current context - * @return a token for the new current context. This never returns a nullptr. - */ - virtual nostd::unique_ptr Attach(const Context &context) noexcept = 0; - - /** - * Detach the context related to the given token. - * @param token a token related to a context - * @return true if the context could be detached - */ - virtual bool Detach(Token &token) noexcept = 0; - - virtual ~RuntimeContextStorage() {} - -protected: - nostd::unique_ptr CreateToken(const Context &context) noexcept - { - return nostd::unique_ptr(new Token(context)); - } -}; - -/** - * Construct and return the default RuntimeContextStorage - * @return a ThreadLocalContextStorage - */ -static RuntimeContextStorage *GetDefaultStorage() noexcept; - -// Provides a wrapper for propagating the context object globally. -// -// By default, a thread-local runtime context storage is used. -class OPENTELEMETRY_EXPORT RuntimeContext -{ -public: - // Return the current context. - static Context GetCurrent() noexcept { return GetRuntimeContextStorage()->GetCurrent(); } - - // Sets the current 'Context' object. Returns a token - // that can be used to reset to the previous Context. - static nostd::unique_ptr Attach(const Context &context) noexcept - { - return GetRuntimeContextStorage()->Attach(context); - } - - // Resets the context to a previous value stored in the - // passed in token. Returns true if successful, false otherwise - static bool Detach(Token &token) noexcept { return GetRuntimeContextStorage()->Detach(token); } - - // Sets the Key and Value into the passed in context or if a context is not - // passed in, the RuntimeContext. - // Should be used to SetValues to the current RuntimeContext, is essentially - // equivalent to RuntimeContext::GetCurrent().SetValue(key,value). Keep in - // mind that the current RuntimeContext will not be changed, and the new - // context will be returned. - static Context SetValue(nostd::string_view key, - const ContextValue &value, - Context *context = nullptr) noexcept - { - Context temp_context; - if (context == nullptr) - { - temp_context = GetCurrent(); - } - else - { - temp_context = *context; - } - return temp_context.SetValue(key, value); - } - - // Returns the value associated with the passed in key and either the - // passed in context* or the runtime context if a context is not passed in. - // Should be used to get values from the current RuntimeContext, is - // essentially equivalent to RuntimeContext::GetCurrent().GetValue(key). - static ContextValue GetValue(nostd::string_view key, Context *context = nullptr) noexcept - { - Context temp_context; - if (context == nullptr) - { - temp_context = GetCurrent(); - } - else - { - temp_context = *context; - } - return temp_context.GetValue(key); - } - - /** - * Provide a custom runtime context storage. - * - * This provides a possibility to override the default thread-local runtime - * context storage. This has to be set before any spans are created by the - * application, otherwise the behavior is undefined. - * - * @param storage a custom runtime context storage - */ - static void SetRuntimeContextStorage( - const nostd::shared_ptr &storage) noexcept - { - GetStorage() = storage; - } - - /** - * Provide a pointer to const runtime context storage. - * - * The returned pointer can only be used for extending the lifetime of the runtime context - * storage. - * - */ - static nostd::shared_ptr GetConstRuntimeContextStorage() noexcept - { - return GetRuntimeContextStorage(); - } - -private: - static nostd::shared_ptr GetRuntimeContextStorage() noexcept - { - return GetStorage(); - } - - OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr &GetStorage() noexcept - { - static nostd::shared_ptr context(GetDefaultStorage()); - return context; - } -}; - -inline Token::~Token() noexcept -{ - context::RuntimeContext::Detach(*this); -} - -// The ThreadLocalContextStorage class is a derived class from -// RuntimeContextStorage and provides a wrapper for propagating context through -// cpp thread locally. This file must be included to use the RuntimeContext -// class if another implementation has not been registered. -class ThreadLocalContextStorage : public RuntimeContextStorage -{ -public: - ThreadLocalContextStorage() noexcept = default; - - // Return the current context. - Context GetCurrent() noexcept override { return GetStack().Top(); } - - // Resets the context to the value previous to the passed in token. This will - // also detach all child contexts of the passed in token. - // Returns true if successful, false otherwise. - bool Detach(Token &token) noexcept override - { - // In most cases, the context to be detached is on the top of the stack. - if (token == GetStack().Top()) - { - GetStack().Pop(); - return true; - } - - if (!GetStack().Contains(token)) - { - return false; - } - - while (!(token == GetStack().Top())) - { - GetStack().Pop(); - } - - GetStack().Pop(); - - return true; - } - - // Sets the current 'Context' object. Returns a token - // that can be used to reset to the previous Context. - nostd::unique_ptr Attach(const Context &context) noexcept override - { - GetStack().Push(context); - return CreateToken(context); - } - -private: - // A nested class to store the attached contexts in a stack. - class Stack - { - friend class ThreadLocalContextStorage; - - Stack() noexcept : size_(0), capacity_(0), base_(nullptr) {} - - // Pops the top Context off the stack. - void Pop() noexcept - { - if (size_ == 0) - { - return; - } - // Store empty Context before decrementing `size`, to ensure - // the shared_ptr object (if stored in prev context object ) are released. - // The stack is not resized, and the unused memory would be reutilised - // for subsequent context storage. - base_[size_ - 1] = Context(); - size_ -= 1; - } - - bool Contains(const Token &token) const noexcept - { - for (size_t pos = size_; pos > 0; --pos) - { - if (token == base_[pos - 1]) - { - return true; - } - } - - return false; - } - - // Returns the Context at the top of the stack. - Context Top() const noexcept - { - if (size_ == 0) - { - return Context(); - } - return base_[size_ - 1]; - } - - // Pushes the passed in context pointer to the top of the stack - // and resizes if necessary. - void Push(const Context &context) noexcept - { - size_++; - if (size_ > capacity_) - { - Resize(size_ * 2); - } - base_[size_ - 1] = context; - } - - // Reallocates the storage array to the pass in new capacity size. - void Resize(size_t new_capacity) noexcept - { - size_t old_size = size_ - 1; - if (new_capacity == 0) - { - new_capacity = 2; - } - Context *temp = new Context[new_capacity]; - if (base_ != nullptr) - { - // vs2015 does not like this construct considering it unsafe: - // - std::copy(base_, base_ + old_size, temp); - // Ref. - // https://stackoverflow.com/questions/12270224/xutility2227-warning-c4996-std-copy-impl - for (size_t i = 0; i < (std::min)(old_size, new_capacity); i++) - { - temp[i] = base_[i]; - } - delete[] base_; - } - base_ = temp; - capacity_ = new_capacity; - } - - ~Stack() noexcept { delete[] base_; } - - size_t size_; - size_t capacity_; - Context *base_; - }; - - OPENTELEMETRY_API_SINGLETON Stack &GetStack() - { - static thread_local Stack stack_ = Stack(); - return stack_; - } -}; - -static RuntimeContextStorage *GetDefaultStorage() noexcept -{ - return new ThreadLocalContextStorage(); -} -} // namespace context -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/detail/preprocessor.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/detail/preprocessor.h deleted file mode 100644 index acdf02eb08..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/detail/preprocessor.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// NOTE - code within detail namespace implements internal details, and not part -// of the public interface. - -#pragma once - -#define OPENTELEMETRY_STRINGIFY(S) OPENTELEMETRY_STRINGIFY_(S) -#define OPENTELEMETRY_STRINGIFY_(S) #S - -#define OPENTELEMETRY_CONCAT(A, B) OPENTELEMETRY_CONCAT_(A, B) -#define OPENTELEMETRY_CONCAT_(A, B) A##B - -// Import the C++20 feature-test macros -#ifdef __has_include -# if __has_include() -# include -# endif -#elif defined(_MSC_VER) && ((defined(__cplusplus) && __cplusplus >= 202002L) || \ - (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)) -# if _MSC_VER >= 1922 -# include -# endif -#endif diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/event_id.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/event_id.h deleted file mode 100644 index 65306ef793..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/event_id.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include - -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/unique_ptr.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace logs -{ - -/** - * EventId class which acts the Id of the event with an optional name. - */ -class EventId -{ -public: - EventId(int64_t id, nostd::string_view name) noexcept - : id_{id}, name_{nostd::unique_ptr{new char[name.length() + 1]}} - { - std::copy(name.begin(), name.end(), name_.get()); - name_.get()[name.length()] = 0; - } - - EventId(int64_t id) noexcept : id_{id}, name_{nullptr} {} - -public: - int64_t id_; - nostd::unique_ptr name_; -}; - -} // namespace logs -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/event_logger.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/event_logger.h deleted file mode 100644 index bcc1035625..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/event_logger.h +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/logs/log_record.h" -#include "opentelemetry/logs/logger.h" -#include "opentelemetry/logs/logger_type_traits.h" -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/unique_ptr.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace logs -{ -#if OPENTELEMETRY_ABI_VERSION_NO < 2 -/** - * Handles event log record creation. - **/ -class OPENTELEMETRY_DEPRECATED EventLogger -{ -public: - virtual ~EventLogger() = default; - - /* Returns the name of the logger */ - virtual const nostd::string_view GetName() noexcept = 0; - - /* Returns the delegate logger of this event logger */ - virtual nostd::shared_ptr GetDelegateLogger() noexcept = 0; - - /** - * Emit a event Log Record object - * - * @param event_name Event name - * @param log_record Log record - */ - virtual void EmitEvent(nostd::string_view event_name, - nostd::unique_ptr &&log_record) noexcept = 0; - - /** - * Emit a event Log Record object with arguments - * - * @param event_name Event name - * @tparam args Arguments which can be used to set data of log record by type. - * Severity -> severity, severity_text - * string_view -> body - * AttributeValue -> body - * SpanContext -> span_id,tace_id and trace_flags - * SpanId -> span_id - * TraceId -> tace_id - * TraceFlags -> trace_flags - * SystemTimestamp -> timestamp - * system_clock::time_point -> timestamp - * KeyValueIterable -> attributes - * Key value iterable container -> attributes - * span> -> attributes(return type of MakeAttributes) - */ - template - void EmitEvent(nostd::string_view event_name, ArgumentType &&...args) - { - nostd::shared_ptr delegate_logger = GetDelegateLogger(); - if (!delegate_logger) - { - return; - } - nostd::unique_ptr log_record = delegate_logger->CreateLogRecord(); - - IgnoreTraitResult(detail::LogRecordSetterTrait::type>::Set( - log_record.get(), std::forward(args))...); - - EmitEvent(event_name, std::move(log_record)); - } - -private: - template - void IgnoreTraitResult(ValueType &&...) - {} -}; -#endif -} // namespace logs -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/event_logger_provider.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/event_logger_provider.h deleted file mode 100644 index 9eea0ca23b..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/event_logger_provider.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace logs -{ - -class EventLogger; -class Logger; - -#if OPENTELEMETRY_ABI_VERSION_NO < 2 -/** - * Creates new EventLogger instances. - */ -class OPENTELEMETRY_DEPRECATED EventLoggerProvider -{ -public: - virtual ~EventLoggerProvider() = default; - - /** - * Creates a named EventLogger instance. - * - */ - - virtual nostd::shared_ptr CreateEventLogger( - nostd::shared_ptr delegate_logger, - nostd::string_view event_domain) noexcept = 0; -}; -#endif -} // namespace logs -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/log_record.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/log_record.h deleted file mode 100644 index 81dec568e5..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/log_record.h +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/common/timestamp.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace trace -{ -class SpanId; -class TraceId; -class TraceFlags; -} // namespace trace - -namespace logs -{ - -enum class Severity : uint8_t; - -/** - * Maintains a representation of a log in a format that can be processed by a recorder. - * - * This class is thread-compatible. - */ -class LogRecord -{ -public: - virtual ~LogRecord() = default; - - /** - * Set the timestamp for this log. - * @param timestamp the timestamp to set - */ - virtual void SetTimestamp(common::SystemTimestamp timestamp) noexcept = 0; - - /** - * Set the observed timestamp for this log. - * @param timestamp the timestamp to set - */ - virtual void SetObservedTimestamp(common::SystemTimestamp timestamp) noexcept = 0; - - /** - * Set the severity for this log. - * @param severity the severity of the event - */ - virtual void SetSeverity(logs::Severity severity) noexcept = 0; - - /** - * Set body field for this log. - * @param message the body to set - */ - virtual void SetBody(const common::AttributeValue &message) noexcept = 0; - - /** - * Set an attribute of a log. - * @param key the name of the attribute - * @param value the attribute value - */ - virtual void SetAttribute(nostd::string_view key, - const common::AttributeValue &value) noexcept = 0; - - /** - * Set the Event Id. - * @param id The event id to set - * @param name Optional event name to set - */ - // TODO: mark this as pure virtual once all exporters have been updated - virtual void SetEventId(int64_t id, nostd::string_view name = {}) noexcept = 0; - - /** - * Set the trace id for this log. - * @param trace_id the trace id to set - */ - virtual void SetTraceId(const trace::TraceId &trace_id) noexcept = 0; - - /** - * Set the span id for this log. - * @param span_id the span id to set - */ - virtual void SetSpanId(const trace::SpanId &span_id) noexcept = 0; - - /** - * Inject trace_flags for this log. - * @param trace_flags the trace flags to set - */ - virtual void SetTraceFlags(const trace::TraceFlags &trace_flags) noexcept = 0; -}; -} // namespace logs -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/logger.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/logger.h deleted file mode 100644 index 52f403b0ac..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/logger.h +++ /dev/null @@ -1,492 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/logs/logger_type_traits.h" -#include "opentelemetry/logs/severity.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/unique_ptr.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace common -{ -class KeyValueIterable; -} // namespace common - -namespace logs -{ - -class EventId; -class LogRecord; - -/** - * Handles log record creation. - **/ -class Logger -{ -public: - virtual ~Logger() = default; - - /* Returns the name of the logger */ - virtual const nostd::string_view GetName() noexcept = 0; - - /** - * Create a Log Record object - * - * @return nostd::unique_ptr - */ - virtual nostd::unique_ptr CreateLogRecord() noexcept = 0; - - /** - * Emit a Log Record object - * - * @param log_record Log record - */ - virtual void EmitLogRecord(nostd::unique_ptr &&log_record) noexcept = 0; - - /** - * Emit a Log Record object with arguments - * - * @param log_record Log record - * @param args Arguments which can be used to set data of log record by type. - * Severity -> severity, severity_text - * string_view -> body - * AttributeValue -> body - * SpanContext -> span_id,trace_id and trace_flags - * SpanId -> span_id - * TraceId -> trace_id - * TraceFlags -> trace_flags - * SystemTimestamp -> timestamp - * system_clock::time_point -> timestamp - * KeyValueIterable -> attributes - * Key value iterable container -> attributes - * span> -> attributes(return type of MakeAttributes) - */ - template - void EmitLogRecord(nostd::unique_ptr &&log_record, ArgumentType &&...args) - { - if (!log_record) - { - return; - } - - // - // Keep the parameter pack unpacking order from left to right because left - // ones are usually more important like severity and event_id than the - // attributes. The left to right unpack order could pass the more important - // data to processors to avoid caching and memory allocating. - // -#if __cplusplus <= 201402L - // C++14 does not support fold expressions for parameter pack expansion. - int dummy[] = {(detail::LogRecordSetterTrait::type>::Set( - log_record.get(), std::forward(args)), - 0)...}; - IgnoreTraitResult(dummy); -#else - IgnoreTraitResult((detail::LogRecordSetterTrait::type>::Set( - log_record.get(), std::forward(args)), - ...)); -#endif - - EmitLogRecord(std::move(log_record)); - } - - /** - * Emit a Log Record object with arguments - * - * @param args Arguments which can be used to set data of log record by type. - * Severity -> severity, severity_text - * string_view -> body - * AttributeValue -> body - * SpanContext -> span_id,trace_id and trace_flags - * SpanId -> span_id - * TraceId -> trace_id - * TraceFlags -> trace_flags - * SystemTimestamp -> timestamp - * system_clock::time_point -> timestamp - * KeyValueIterable -> attributes - * Key value iterable container -> attributes - * span> -> attributes(return type of MakeAttributes) - */ - template - void EmitLogRecord(ArgumentType &&...args) - { - nostd::unique_ptr log_record = CreateLogRecord(); - - EmitLogRecord(std::move(log_record), std::forward(args)...); - } - - /** - * Writes a log with a severity of trace. - * @param args Arguments which can be used to set data of log record by type. - * string_view -> body - * AttributeValue -> body - * SpanContext -> span_id,trace_id and trace_flags - * SpanId -> span_id - * TraceId -> trace_id - * TraceFlags -> trace_flags - * SystemTimestamp -> timestamp - * system_clock::time_point -> timestamp - * KeyValueIterable -> attributes - * Key value iterable container -> attributes - * span> -> attributes(return type of MakeAttributes) - */ - template - void Trace(ArgumentType &&...args) noexcept - { - static_assert( - !detail::LogRecordHasType::type...>::value, - "Severity is already set."); - this->EmitLogRecord(Severity::kTrace, std::forward(args)...); - } - - /** - * Writes a log with a severity of debug. - * @param args Arguments which can be used to set data of log record by type. - * string_view -> body - * AttributeValue -> body - * SpanContext -> span_id,trace_id and trace_flags - * SpanId -> span_id - * TraceId -> trace_id - * TraceFlags -> trace_flags - * SystemTimestamp -> timestamp - * system_clock::time_point -> timestamp - * KeyValueIterable -> attributes - * Key value iterable container -> attributes - * span> -> attributes(return type of MakeAttributes) - */ - template - void Debug(ArgumentType &&...args) noexcept - { - static_assert( - !detail::LogRecordHasType::type...>::value, - "Severity is already set."); - this->EmitLogRecord(Severity::kDebug, std::forward(args)...); - } - - /** - * Writes a log with a severity of info. - * @param args Arguments which can be used to set data of log record by type. - * string_view -> body - * AttributeValue -> body - * SpanContext -> span_id,trace_id and trace_flags - * SpanId -> span_id - * TraceId -> trace_id - * TraceFlags -> trace_flags - * SystemTimestamp -> timestamp - * system_clock::time_point -> timestamp - * KeyValueIterable -> attributes - * Key value iterable container -> attributes - * span> -> attributes(return type of MakeAttributes) - */ - template - void Info(ArgumentType &&...args) noexcept - { - static_assert( - !detail::LogRecordHasType::type...>::value, - "Severity is already set."); - this->EmitLogRecord(Severity::kInfo, std::forward(args)...); - } - - /** - * Writes a log with a severity of warn. - * @param args Arguments which can be used to set data of log record by type. - * string_view -> body - * AttributeValue -> body - * SpanContext -> span_id,trace_id and trace_flags - * SpanId -> span_id - * TraceId -> trace_id - * TraceFlags -> trace_flags - * SystemTimestamp -> timestamp - * system_clock::time_point -> timestamp - * KeyValueIterable -> attributes - * Key value iterable container -> attributes - * span> -> attributes(return type of MakeAttributes) - */ - template - void Warn(ArgumentType &&...args) noexcept - { - static_assert( - !detail::LogRecordHasType::type...>::value, - "Severity is already set."); - this->EmitLogRecord(Severity::kWarn, std::forward(args)...); - } - - /** - * Writes a log with a severity of error. - * @param args Arguments which can be used to set data of log record by type. - * string_view -> body - * AttributeValue -> body - * SpanContext -> span_id,trace_id and trace_flags - * SpanId -> span_id - * TraceId -> trace_id - * TraceFlags -> trace_flags - * SystemTimestamp -> timestamp - * system_clock::time_point -> timestamp - * KeyValueIterable -> attributes - * Key value iterable container -> attributes - * span> -> attributes(return type of MakeAttributes) - */ - template - void Error(ArgumentType &&...args) noexcept - { - static_assert( - !detail::LogRecordHasType::type...>::value, - "Severity is already set."); - this->EmitLogRecord(Severity::kError, std::forward(args)...); - } - - /** - * Writes a log with a severity of fatal. - * @param args Arguments which can be used to set data of log record by type. - * string_view -> body - * AttributeValue -> body - * SpanContext -> span_id,trace_id and trace_flags - * SpanId -> span_id - * TraceId -> trace_id - * TraceFlags -> trace_flags - * SystemTimestamp -> timestamp - * system_clock::time_point -> timestamp - * KeyValueIterable -> attributes - * Key value iterable container -> attributes - * span> -> attributes(return type of MakeAttributes) - */ - template - void Fatal(ArgumentType &&...args) noexcept - { - static_assert( - !detail::LogRecordHasType::type...>::value, - "Severity is already set."); - this->EmitLogRecord(Severity::kFatal, std::forward(args)...); - } - - // - // OpenTelemetry C++ user-facing Logs API - // - - inline bool Enabled(Severity severity, const EventId &event_id) const noexcept - { - if OPENTELEMETRY_LIKELY_CONDITION (!Enabled(severity)) - { - return false; - } - return EnabledImplementation(severity, event_id); - } - - inline bool Enabled(Severity severity, int64_t event_id) const noexcept - { - if OPENTELEMETRY_LIKELY_CONDITION (!Enabled(severity)) - { - return false; - } - return EnabledImplementation(severity, event_id); - } - - inline bool Enabled(Severity severity) const noexcept - { - return static_cast(severity) >= OPENTELEMETRY_ATOMIC_READ_8(&minimum_severity_); - } - - /** - * Log an event - * - * @severity severity of the log - * @event_id event identifier of the log - * @format an utf-8 string following https://messagetemplates.org/ - * @attributes key value pairs of the log - */ - virtual void Log(Severity severity, - const EventId &event_id, - nostd::string_view format, - const common::KeyValueIterable &attributes) noexcept - { - this->EmitLogRecord(severity, event_id, format, attributes); - } - - virtual void Log(Severity severity, - int64_t event_id, - nostd::string_view format, - const common::KeyValueIterable &attributes) noexcept - { - this->EmitLogRecord(severity, EventId{event_id}, format, attributes); - } - - virtual void Log(Severity severity, - nostd::string_view format, - const common::KeyValueIterable &attributes) noexcept - { - this->EmitLogRecord(severity, format, attributes); - } - - virtual void Log(Severity severity, nostd::string_view message) noexcept - { - this->EmitLogRecord(severity, message); - } - - // Convenient wrappers based on virtual methods Log(). - // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-severitynumber - - inline void Trace(const EventId &event_id, - nostd::string_view format, - const common::KeyValueIterable &attributes) noexcept - { - this->Log(Severity::kTrace, event_id, format, attributes); - } - - inline void Trace(int64_t event_id, - nostd::string_view format, - const common::KeyValueIterable &attributes) noexcept - { - this->Log(Severity::kTrace, EventId{event_id}, format, attributes); - } - - inline void Trace(nostd::string_view format, const common::KeyValueIterable &attributes) noexcept - { - this->Log(Severity::kTrace, format, attributes); - } - - inline void Trace(nostd::string_view message) noexcept { this->Log(Severity::kTrace, message); } - - inline void Debug(const EventId &event_id, - nostd::string_view format, - const common::KeyValueIterable &attributes) noexcept - { - this->Log(Severity::kDebug, event_id, format, attributes); - } - - inline void Debug(int64_t event_id, - nostd::string_view format, - const common::KeyValueIterable &attributes) noexcept - { - this->Log(Severity::kDebug, EventId{event_id}, format, attributes); - } - - inline void Debug(nostd::string_view format, const common::KeyValueIterable &attributes) noexcept - { - this->Log(Severity::kDebug, format, attributes); - } - - inline void Debug(nostd::string_view message) noexcept { this->Log(Severity::kDebug, message); } - - inline void Info(const EventId &event_id, - nostd::string_view format, - const common::KeyValueIterable &attributes) noexcept - { - this->Log(Severity::kInfo, event_id, format, attributes); - } - - inline void Info(int64_t event_id, - nostd::string_view format, - const common::KeyValueIterable &attributes) noexcept - { - this->Log(Severity::kInfo, EventId{event_id}, format, attributes); - } - - inline void Info(nostd::string_view format, const common::KeyValueIterable &attributes) noexcept - { - this->Log(Severity::kInfo, format, attributes); - } - - inline void Info(nostd::string_view message) noexcept { this->Log(Severity::kInfo, message); } - - inline void Warn(const EventId &event_id, - nostd::string_view format, - const common::KeyValueIterable &attributes) noexcept - { - this->Log(Severity::kWarn, event_id, format, attributes); - } - - inline void Warn(int64_t event_id, - nostd::string_view format, - const common::KeyValueIterable &attributes) noexcept - { - this->Log(Severity::kWarn, EventId{event_id}, format, attributes); - } - - inline void Warn(nostd::string_view format, const common::KeyValueIterable &attributes) noexcept - { - this->Log(Severity::kWarn, format, attributes); - } - - inline void Warn(nostd::string_view message) noexcept { this->Log(Severity::kWarn, message); } - - inline void Error(const EventId &event_id, - nostd::string_view format, - const common::KeyValueIterable &attributes) noexcept - { - this->Log(Severity::kError, event_id, format, attributes); - } - - inline void Error(int64_t event_id, - nostd::string_view format, - const common::KeyValueIterable &attributes) noexcept - { - this->Log(Severity::kError, EventId{event_id}, format, attributes); - } - - inline void Error(nostd::string_view format, const common::KeyValueIterable &attributes) noexcept - { - this->Log(Severity::kError, format, attributes); - } - - inline void Error(nostd::string_view message) noexcept { this->Log(Severity::kError, message); } - - inline void Fatal(const EventId &event_id, - nostd::string_view format, - const common::KeyValueIterable &attributes) noexcept - { - this->Log(Severity::kFatal, event_id, format, attributes); - } - - inline void Fatal(int64_t event_id, - nostd::string_view format, - const common::KeyValueIterable &attributes) noexcept - { - this->Log(Severity::kFatal, EventId{event_id}, format, attributes); - } - - inline void Fatal(nostd::string_view format, const common::KeyValueIterable &attributes) noexcept - { - this->Log(Severity::kFatal, format, attributes); - } - - inline void Fatal(nostd::string_view message) noexcept { this->Log(Severity::kFatal, message); } - - // - // End of OpenTelemetry C++ user-facing Log API. - // - -protected: - // TODO: discuss with community about naming for internal methods. - virtual bool EnabledImplementation(Severity /*severity*/, - const EventId & /*event_id*/) const noexcept - { - return false; - } - - virtual bool EnabledImplementation(Severity /*severity*/, int64_t /*event_id*/) const noexcept - { - return false; - } - - void SetMinimumSeverity(uint8_t severity_or_max) noexcept - { - OPENTELEMETRY_ATOMIC_WRITE_8(&minimum_severity_, severity_or_max); - } - -private: - template - void IgnoreTraitResult(ValueType &&...) - {} - - // - // minimum_severity_ can be updated concurrently by multiple threads/cores, so race condition on - // read/write should be handled. And std::atomic can not be used here because it is not ABI - // compatible for OpenTelemetry C++ API. - // - mutable uint8_t minimum_severity_{kMaxSeverity}; -}; -} // namespace logs -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/logger_provider.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/logger_provider.h deleted file mode 100644 index ab1493c5cd..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/logger_provider.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/common/key_value_iterable.h" -#include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/span.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/type_traits.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace logs -{ - -class Logger; - -/** - * Creates new Logger instances. - */ -class OPENTELEMETRY_EXPORT LoggerProvider -{ -public: - virtual ~LoggerProvider() = default; - - /** - * Gets or creates a named Logger instance. - * - * Optionally a version can be passed to create a named and versioned Logger - * instance. - * - * Optionally a configuration file name can be passed to create a configuration for - * the Logger instance. - * - */ - - virtual nostd::shared_ptr GetLogger( - nostd::string_view logger_name, - nostd::string_view library_name = "", - nostd::string_view library_version = "", - nostd::string_view schema_url = "", - const common::KeyValueIterable &attributes = common::NoopKeyValueIterable()) = 0; - - nostd::shared_ptr GetLogger( - nostd::string_view logger_name, - nostd::string_view library_name, - nostd::string_view library_version, - nostd::string_view schema_url, - std::initializer_list> attributes) - { - return GetLogger(logger_name, library_name, library_version, schema_url, - nostd::span>{ - attributes.begin(), attributes.end()}); - } - - template ::value> * = nullptr> - nostd::shared_ptr GetLogger(nostd::string_view logger_name, - nostd::string_view library_name, - nostd::string_view library_version, - nostd::string_view schema_url, - const T &attributes) - { - return GetLogger(logger_name, library_name, library_version, schema_url, - common::KeyValueIterableView(attributes)); - } -}; -} // namespace logs -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/logger_type_traits.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/logger_type_traits.h deleted file mode 100644 index d88a6ffbdc..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/logger_type_traits.h +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include -#include -#include - -#include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/common/key_value_iterable.h" -#include "opentelemetry/common/timestamp.h" -#include "opentelemetry/logs/event_id.h" -#include "opentelemetry/logs/log_record.h" -#include "opentelemetry/logs/severity.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/type_traits.h" -#include "opentelemetry/trace/span_context.h" -#include "opentelemetry/trace/span_id.h" -#include "opentelemetry/trace/trace_flags.h" -#include "opentelemetry/trace/trace_id.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace logs -{ -namespace detail -{ -template -struct LogRecordSetterTrait; - -template <> -struct LogRecordSetterTrait -{ - template - inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept - { - log_record->SetSeverity(std::forward(arg)); - - return log_record; - } -}; - -template <> -struct LogRecordSetterTrait -{ - template - inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept - { - log_record->SetEventId(arg.id_, nostd::string_view{arg.name_.get()}); - - return log_record; - } -}; - -template <> -struct LogRecordSetterTrait -{ - template - inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept - { - log_record->SetSpanId(arg.span_id()); - log_record->SetTraceId(arg.trace_id()); - log_record->SetTraceFlags(arg.trace_flags()); - - return log_record; - } -}; - -template <> -struct LogRecordSetterTrait -{ - template - inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept - { - log_record->SetSpanId(std::forward(arg)); - - return log_record; - } -}; - -template <> -struct LogRecordSetterTrait -{ - template - inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept - { - log_record->SetTraceId(std::forward(arg)); - - return log_record; - } -}; - -template <> -struct LogRecordSetterTrait -{ - template - inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept - { - log_record->SetTraceFlags(std::forward(arg)); - - return log_record; - } -}; - -template <> -struct LogRecordSetterTrait -{ - template - inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept - { - log_record->SetTimestamp(std::forward(arg)); - - return log_record; - } -}; - -template <> -struct LogRecordSetterTrait -{ - template - inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept - { - log_record->SetTimestamp(common::SystemTimestamp(std::forward(arg))); - - return log_record; - } -}; - -template <> -struct LogRecordSetterTrait -{ - template - inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept - { - arg.ForEachKeyValue( - [&log_record](nostd::string_view key, common::AttributeValue value) noexcept { - log_record->SetAttribute(key, value); - return true; - }); - - return log_record; - } -}; - -template -struct LogRecordSetterTrait -{ - static_assert(!std::is_same, ValueType>::value && - !std::is_same, ValueType>::value, - "unique_ptr is not allowed, please use std::move()"); - - template ::value || - std::is_convertible::value, - void> * = nullptr> - inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept - { - log_record->SetBody(std::forward(arg)); - - return log_record; - } - - template ::value, bool> - * = nullptr> - inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept - { - return LogRecordSetterTrait::Set(log_record, - std::forward(arg)); - } - - template ::value, int> * = - nullptr> - inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept - { - for (auto &argv : arg) - { - log_record->SetAttribute(argv.first, argv.second); - } - - return log_record; - } -}; - -template -struct LogRecordHasType; - -template -struct LogRecordHasType : public std::false_type -{}; - -template -struct LogRecordHasType - : public std::conditional::value, - std::true_type, - LogRecordHasType>::type -{}; - -} // namespace detail - -} // namespace logs -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/noop.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/noop.h deleted file mode 100644 index 24312f061c..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/noop.h +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -// Please refer to provider.h for documentation on how to obtain a Logger object. -// -// This file is part of the internal implementation of OpenTelemetry. Nothing in this file should be -// used directly. Please refer to logger.h for documentation on these interfaces. - -#include "opentelemetry/logs/event_logger.h" -#include "opentelemetry/logs/event_logger_provider.h" -#include "opentelemetry/logs/logger.h" -#include "opentelemetry/logs/logger_provider.h" -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/unique_ptr.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace common -{ -class KeyValueIterable; -} // namespace common - -namespace logs -{ -/** - * No-op implementation of Logger. This class should not be used directly. It should only be - * instantiated using a LoggerProvider's GetLogger() call. - */ -class NoopLogger final : public Logger -{ -public: - const nostd::string_view GetName() noexcept override { return "noop logger"; } - - nostd::unique_ptr CreateLogRecord() noexcept override - { - /* - * Do not return memory shared between threads, - * a `new` + `delete` for each noop record can not be avoided, - * due to the semantic of unique_ptr. - */ - return nostd::unique_ptr(new NoopLogRecord()); - } - - using Logger::EmitLogRecord; - - void EmitLogRecord(nostd::unique_ptr &&) noexcept override {} - -private: - class NoopLogRecord : public LogRecord - { - public: - NoopLogRecord() = default; - ~NoopLogRecord() override = default; - - void SetTimestamp(common::SystemTimestamp /* timestamp */) noexcept override {} - void SetObservedTimestamp(common::SystemTimestamp /* timestamp */) noexcept override {} - void SetSeverity(logs::Severity /* severity */) noexcept override {} - void SetBody(const common::AttributeValue & /* message */) noexcept override {} - void SetAttribute(nostd::string_view /* key */, - const common::AttributeValue & /* value */) noexcept override - {} - void SetEventId(int64_t /* id */, nostd::string_view /* name */) noexcept override {} - void SetTraceId(const trace::TraceId & /* trace_id */) noexcept override {} - void SetSpanId(const trace::SpanId & /* span_id */) noexcept override {} - void SetTraceFlags(const trace::TraceFlags & /* trace_flags */) noexcept override {} - }; -}; - -/** - * No-op implementation of a LoggerProvider. - */ -class NoopLoggerProvider final : public LoggerProvider -{ -public: - NoopLoggerProvider() : logger_{nostd::shared_ptr(new NoopLogger())} {} - - nostd::shared_ptr GetLogger(nostd::string_view /* logger_name */, - nostd::string_view /* library_name */, - nostd::string_view /* library_version */, - nostd::string_view /* schema_url */, - const common::KeyValueIterable & /* attributes */) override - { - return logger_; - } - -private: - nostd::shared_ptr logger_; -}; - -#if OPENTELEMETRY_ABI_VERSION_NO < 2 -class NoopEventLogger final : public EventLogger -{ -public: - NoopEventLogger() : logger_{nostd::shared_ptr(new NoopLogger())} {} - - const nostd::string_view GetName() noexcept override { return "noop event logger"; } - - nostd::shared_ptr GetDelegateLogger() noexcept override { return logger_; } - - void EmitEvent(nostd::string_view, nostd::unique_ptr &&) noexcept override {} - -private: - nostd::shared_ptr logger_; -}; - -/** - * No-op implementation of a EventLoggerProvider. - */ -class NoopEventLoggerProvider final : public EventLoggerProvider -{ -public: - NoopEventLoggerProvider() : event_logger_{nostd::shared_ptr(new NoopEventLogger())} - {} - - nostd::shared_ptr CreateEventLogger( - nostd::shared_ptr /*delegate_logger*/, - nostd::string_view /*event_domain*/) noexcept override - { - return event_logger_; - } - -private: - nostd::shared_ptr event_logger_; -}; -#endif - -} // namespace logs -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/provider.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/provider.h deleted file mode 100644 index 0c1b4deea8..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/provider.h +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include - -#include "opentelemetry/common/macros.h" -#include "opentelemetry/common/spin_lock_mutex.h" -#include "opentelemetry/logs/noop.h" -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace logs -{ - -#if OPENTELEMETRY_ABI_VERSION_NO < 2 -class EventLoggerProvider; -#endif -class LoggerProvider; - -/** - * Stores the singleton global LoggerProvider. - */ -class OPENTELEMETRY_EXPORT Provider -{ -public: - /** - * Returns the singleton LoggerProvider. - * - * By default, a no-op LoggerProvider is returned. This will never return a - * nullptr LoggerProvider. - */ - static nostd::shared_ptr GetLoggerProvider() noexcept - { - std::lock_guard guard(GetLock()); - return nostd::shared_ptr(GetProvider()); - } - - /** - * Changes the singleton LoggerProvider. - */ - static void SetLoggerProvider(const nostd::shared_ptr &tp) noexcept - { - std::lock_guard guard(GetLock()); - GetProvider() = tp; - } - -#if OPENTELEMETRY_ABI_VERSION_NO < 2 - /** - * Returns the singleton EventLoggerProvider. - * - * By default, a no-op EventLoggerProvider is returned. This will never return a - * nullptr EventLoggerProvider. - */ - OPENTELEMETRY_DEPRECATED static nostd::shared_ptr - GetEventLoggerProvider() noexcept - { - std::lock_guard guard(GetLock()); - return nostd::shared_ptr(GetEventProvider()); - } - - /** - * Changes the singleton EventLoggerProvider. - */ - OPENTELEMETRY_DEPRECATED static void SetEventLoggerProvider( - const nostd::shared_ptr &tp) noexcept - { - std::lock_guard guard(GetLock()); - GetEventProvider() = tp; - } -#endif - -private: - OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr &GetProvider() noexcept - { - static nostd::shared_ptr provider(new NoopLoggerProvider); - return provider; - } - -#if OPENTELEMETRY_ABI_VERSION_NO < 2 - OPENTELEMETRY_DEPRECATED - OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr & - GetEventProvider() noexcept - { - static nostd::shared_ptr provider(new NoopEventLoggerProvider); - return provider; - } -#endif - - OPENTELEMETRY_API_SINGLETON static common::SpinLockMutex &GetLock() noexcept - { - static common::SpinLockMutex lock; - return lock; - } -}; - -} // namespace logs -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/severity.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/severity.h deleted file mode 100644 index f4d961615f..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/logs/severity.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include - -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace logs -{ - -/** - * Severity Levels assigned to log events, based on Log Data Model, - * with the addition of kInvalid (mapped to a severity number of 0). - * - * See - * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-severitynumber - */ -enum class Severity : uint8_t -{ - kInvalid = 0, - kTrace = 1, - kTrace2 = 2, - kTrace3 = 3, - kTrace4 = 4, - kDebug = 5, - kDebug2 = 6, - kDebug3 = 7, - kDebug4 = 8, - kInfo = 9, - kInfo2 = 10, - kInfo3 = 11, - kInfo4 = 12, - kWarn = 13, - kWarn2 = 14, - kWarn3 = 15, - kWarn4 = 16, - kError = 17, - kError2 = 18, - kError3 = 19, - kError4 = 20, - kFatal = 21, - kFatal2 = 22, - kFatal3 = 23, - kFatal4 = 24 -}; - -const uint8_t kMaxSeverity = 255; - -/** - * Mapping of the severity enum above, to a severity text string (in all caps). - * This severity text can be printed out by exporters. Capital letters follow the - * spec naming convention. - * - * Included to follow the specification's recommendation to print both - * severity number and text in each log record. - */ -const nostd::string_view SeverityNumToText[25] = { - "INVALID", "TRACE", "TRACE2", "TRACE3", "TRACE4", "DEBUG", "DEBUG2", "DEBUG3", "DEBUG4", - "INFO", "INFO2", "INFO3", "INFO4", "WARN", "WARN2", "WARN3", "WARN4", "ERROR", - "ERROR2", "ERROR3", "ERROR4", "FATAL", "FATAL2", "FATAL3", "FATAL4"}; - -} // namespace logs -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/async_instruments.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/async_instruments.h deleted file mode 100644 index f73eb2f51b..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/async_instruments.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/metrics/observer_result.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace metrics -{ - -using ObservableCallbackPtr = void (*)(ObserverResult, void *); - -class ObservableInstrument -{ -public: - ObservableInstrument() = default; - virtual ~ObservableInstrument() = default; - - /** - * Sets up a function that will be called whenever a metric collection is initiated. - */ - virtual void AddCallback(ObservableCallbackPtr, void *state) noexcept = 0; - - /** - * Remove a function that was configured to be called whenever a metric collection is initiated. - */ - virtual void RemoveCallback(ObservableCallbackPtr, void *state) noexcept = 0; -}; - -} // namespace metrics -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/meter.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/meter.h deleted file mode 100644 index 59cfb87822..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/meter.h +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/unique_ptr.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace metrics -{ - -template -class Counter; - -template -class Histogram; - -template -class UpDownCounter; - -template -class Gauge; - -class ObservableInstrument; - -/** - * Handles instrument creation and provides a facility for batch recording. - * - * This class provides methods to create new metric instruments, record a - * batch of values to a specified set of instruments, and collect - * measurements from all instruments. - * - */ -class Meter -{ -public: - virtual ~Meter() = default; - - /** - * Creates a Counter with the passed characteristics and returns a unique_ptr to that Counter. - * - * @param name the name of the new Counter. - * @param description a brief description of what the Counter is used for. - * @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html. - * @return a shared pointer to the created Counter. - */ - - virtual nostd::unique_ptr> CreateUInt64Counter( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept = 0; - - virtual nostd::unique_ptr> CreateDoubleCounter( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept = 0; - - /** - * Creates a Asynchronous (Observable) counter with the passed characteristics and returns a - * shared_ptr to that Observable Counter - * - * @param name the name of the new Observable Counter. - * @param description a brief description of what the Observable Counter is used for. - * @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html. - */ - virtual nostd::shared_ptr CreateInt64ObservableCounter( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept = 0; - - virtual nostd::shared_ptr CreateDoubleObservableCounter( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept = 0; - - /** - * Creates a Histogram with the passed characteristics and returns a unique_ptr to that Histogram. - * - * @param name the name of the new Histogram. - * @param description a brief description of what the Histogram is used for. - * @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html. - * @return a shared pointer to the created Histogram. - */ - virtual nostd::unique_ptr> CreateUInt64Histogram( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept = 0; - - virtual nostd::unique_ptr> CreateDoubleHistogram( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept = 0; - -#if OPENTELEMETRY_ABI_VERSION_NO >= 2 - /** - * Creates a Gauge with the passed characteristics and returns a unique_ptr to that Gauge. - * - * @param name the name of the new Gauge. - * @param description a brief description of what the Gauge is used for. - * @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html. - * @return a unique pointer to the created Gauge. - */ - - virtual nostd::unique_ptr> CreateInt64Gauge( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept = 0; - - virtual nostd::unique_ptr> CreateDoubleGauge( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept = 0; -#endif - - /** - * Creates a Asynchronous (Observable) Gauge with the passed characteristics and returns a - * shared_ptr to that Observable Gauge - * - * @param name the name of the new Observable Gauge. - * @param description a brief description of what the Observable Gauge is used for. - * @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html. - */ - virtual nostd::shared_ptr CreateInt64ObservableGauge( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept = 0; - - virtual nostd::shared_ptr CreateDoubleObservableGauge( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept = 0; - - /** - * Creates an UpDownCounter with the passed characteristics and returns a unique_ptr to that - * UpDownCounter. - * - * @param name the name of the new UpDownCounter. - * @param description a brief description of what the UpDownCounter is used for. - * @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html. - * @return a shared pointer to the created UpDownCounter. - */ - virtual nostd::unique_ptr> CreateInt64UpDownCounter( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept = 0; - - virtual nostd::unique_ptr> CreateDoubleUpDownCounter( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept = 0; - - /** - * Creates a Asynchronous (Observable) UpDownCounter with the passed characteristics and returns - * a shared_ptr to that Observable UpDownCounter - * - * @param name the name of the new Observable UpDownCounter. - * @param description a brief description of what the Observable UpDownCounter is used for. - * @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html. - */ - virtual nostd::shared_ptr CreateInt64ObservableUpDownCounter( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept = 0; - - virtual nostd::shared_ptr CreateDoubleObservableUpDownCounter( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept = 0; -}; -} // namespace metrics -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/meter_provider.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/meter_provider.h deleted file mode 100644 index fca960bb8e..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/meter_provider.h +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/common/key_value_iterable.h" -#include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/type_traits.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace metrics -{ - -class Meter; - -/** - * Creates new Meter instances. - */ -class MeterProvider -{ -public: - virtual ~MeterProvider() = default; - -#if OPENTELEMETRY_ABI_VERSION_NO >= 2 - - /** - * Gets or creates a named Meter instance (ABI). - * - * @since ABI_VERSION 2 - * - * @param[in] name Meter instrumentation scope - * @param[in] version Instrumentation scope version - * @param[in] schema_url Instrumentation scope schema URL - * @param[in] attributes Instrumentation scope attributes (optional, may be nullptr) - */ - virtual nostd::shared_ptr GetMeter( - nostd::string_view name, - nostd::string_view version, - nostd::string_view schema_url, - const common::KeyValueIterable *attributes) noexcept = 0; - - /** - * Gets or creates a named Meter instance (API helper). - * - * @since ABI_VERSION 2 - * - * @param[in] name Meter instrumentation scope - * @param[in] version Instrumentation scope version, optional - * @param[in] schema_url Instrumentation scope schema URL, optional - */ - nostd::shared_ptr GetMeter(nostd::string_view name, - nostd::string_view version = "", - nostd::string_view schema_url = "") - { - return GetMeter(name, version, schema_url, nullptr); - } - - /** - * Gets or creates a named Meter instance (API helper). - * - * @since ABI_VERSION 2 - * - * @param[in] name Meter instrumentation scope - * @param[in] version Instrumentation scope version - * @param[in] schema_url Instrumentation scope schema URL - * @param[in] attributes Instrumentation scope attributes - */ - nostd::shared_ptr GetMeter( - nostd::string_view name, - nostd::string_view version, - nostd::string_view schema_url, - std::initializer_list> attributes) - { - /* Build a container from std::initializer_list. */ - nostd::span> attributes_span{ - attributes.begin(), attributes.end()}; - - /* Build a view on the container. */ - common::KeyValueIterableView< - nostd::span>> - iterable_attributes{attributes_span}; - - /* Add attributes using the view. */ - return GetMeter(name, version, schema_url, &iterable_attributes); - } - - /** - * Gets or creates a named Meter instance (API helper). - * - * @since ABI_VERSION 2 - * - * @param[in] name Meter instrumentation scope - * @param[in] version Instrumentation scope version - * @param[in] schema_url Instrumentation scope schema URL - * @param[in] attributes Instrumentation scope attributes container - */ - template ::value> * = nullptr> - nostd::shared_ptr GetMeter(nostd::string_view name, - nostd::string_view version, - nostd::string_view schema_url, - const T &attributes) - { - /* Build a view on the container. */ - common::KeyValueIterableView iterable_attributes(attributes); - - /* Add attributes using the view. */ - return GetMeter(name, version, schema_url, &iterable_attributes); - } - -#else - /** - * Gets or creates a named Meter instance (ABI) - * - * @since ABI_VERSION 1 - * - * @param[in] name Meter instrumentation scope - * @param[in] version Instrumentation scope version, optional - * @param[in] schema_url Instrumentation scope schema URL, optional - */ - virtual nostd::shared_ptr GetMeter(nostd::string_view name, - nostd::string_view version = "", - nostd::string_view schema_url = "") noexcept = 0; -#endif - -#if OPENTELEMETRY_ABI_VERSION_NO >= 2 - /** - * Remove a named Meter instance (ABI). - * - * This API is experimental, see - * https://github.com/open-telemetry/opentelemetry-specification/issues/2232 - * - * @since ABI_VERSION 2 - * - * @param[in] name Meter instrumentation scope - * @param[in] version Instrumentation scope version, optional - * @param[in] schema_url Instrumentation scope schema URL, optional - */ - virtual void RemoveMeter(nostd::string_view name, - nostd::string_view version = "", - nostd::string_view schema_url = "") noexcept = 0; -#endif -}; -} // namespace metrics -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/noop.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/noop.h deleted file mode 100644 index 1d508b9387..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/noop.h +++ /dev/null @@ -1,271 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/metrics/async_instruments.h" -#include "opentelemetry/metrics/meter.h" -#include "opentelemetry/metrics/meter_provider.h" -#include "opentelemetry/metrics/observer_result.h" -#include "opentelemetry/metrics/sync_instruments.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace metrics -{ - -template -class NoopCounter : public Counter -{ -public: - NoopCounter(nostd::string_view /* name */, - nostd::string_view /* description */, - nostd::string_view /* unit */) noexcept - {} - void Add(T /* value */) noexcept override {} - void Add(T /* value */, const context::Context & /* context */) noexcept override {} - void Add(T /* value */, const common::KeyValueIterable & /* attributes */) noexcept override {} - void Add(T /* value */, - const common::KeyValueIterable & /* attributes */, - const context::Context & /* context */) noexcept override - {} -}; - -template -class NoopHistogram : public Histogram -{ -public: - NoopHistogram(nostd::string_view /* name */, - nostd::string_view /* description */, - nostd::string_view /* unit */) noexcept - {} - void Record(T /* value */, const context::Context & /* context */) noexcept override {} - void Record(T /* value */, - const common::KeyValueIterable & /* attributes */, - const context::Context & /* context */) noexcept override - {} -#if OPENTELEMETRY_ABI_VERSION_NO >= 2 - void Record(T /*value*/, - const opentelemetry::common::KeyValueIterable & /*attributes*/) noexcept override - {} - - void Record(T /*value*/) noexcept override {} -#endif -}; - -template -class NoopUpDownCounter : public UpDownCounter -{ -public: - NoopUpDownCounter(nostd::string_view /* name */, - nostd::string_view /* description */, - nostd::string_view /* unit */) noexcept - {} - ~NoopUpDownCounter() override = default; - void Add(T /* value */) noexcept override {} - void Add(T /* value */, const context::Context & /* context */) noexcept override {} - void Add(T /* value */, const common::KeyValueIterable & /* attributes */) noexcept override {} - void Add(T /* value */, - const common::KeyValueIterable & /* attributes */, - const context::Context & /* context */) noexcept override - {} -}; - -#if OPENTELEMETRY_ABI_VERSION_NO >= 2 -template -class NoopGauge : public Gauge -{ -public: - NoopGauge(nostd::string_view /* name */, - nostd::string_view /* description */, - nostd::string_view /* unit */) noexcept - {} - ~NoopGauge() override = default; - void Record(T /* value */) noexcept override {} - void Record(T /* value */, const context::Context & /* context */) noexcept override {} - void Record(T /* value */, const common::KeyValueIterable & /* attributes */) noexcept override {} - void Record(T /* value */, - const common::KeyValueIterable & /* attributes */, - const context::Context & /* context */) noexcept override - {} -}; -#endif - -class NoopObservableInstrument : public ObservableInstrument -{ -public: - NoopObservableInstrument(nostd::string_view /* name */, - nostd::string_view /* description */, - nostd::string_view /* unit */) noexcept - {} - - void AddCallback(ObservableCallbackPtr, void * /* state */) noexcept override {} - void RemoveCallback(ObservableCallbackPtr, void * /* state */) noexcept override {} -}; - -/** - * No-op implementation of Meter. - */ -class NoopMeter final : public Meter -{ -public: - nostd::unique_ptr> CreateUInt64Counter( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept override - { - return nostd::unique_ptr>{new NoopCounter(name, description, unit)}; - } - - nostd::unique_ptr> CreateDoubleCounter( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept override - { - return nostd::unique_ptr>{new NoopCounter(name, description, unit)}; - } - - nostd::shared_ptr CreateInt64ObservableCounter( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept override - { - return nostd::shared_ptr( - new NoopObservableInstrument(name, description, unit)); - } - - nostd::shared_ptr CreateDoubleObservableCounter( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept override - { - return nostd::shared_ptr( - new NoopObservableInstrument(name, description, unit)); - } - - nostd::unique_ptr> CreateUInt64Histogram( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept override - { - return nostd::unique_ptr>{ - new NoopHistogram(name, description, unit)}; - } - - nostd::unique_ptr> CreateDoubleHistogram( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept override - { - return nostd::unique_ptr>{new NoopHistogram(name, description, unit)}; - } - -#if OPENTELEMETRY_ABI_VERSION_NO >= 2 - nostd::unique_ptr> CreateInt64Gauge(nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept override - { - return nostd::unique_ptr>{new NoopGauge(name, description, unit)}; - } - - nostd::unique_ptr> CreateDoubleGauge(nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept override - { - return nostd::unique_ptr>{new NoopGauge(name, description, unit)}; - } -#endif - - nostd::shared_ptr CreateInt64ObservableGauge( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept override - { - return nostd::shared_ptr( - new NoopObservableInstrument(name, description, unit)); - } - - nostd::shared_ptr CreateDoubleObservableGauge( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept override - { - return nostd::shared_ptr( - new NoopObservableInstrument(name, description, unit)); - } - - nostd::unique_ptr> CreateInt64UpDownCounter( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept override - { - return nostd::unique_ptr>{ - new NoopUpDownCounter(name, description, unit)}; - } - - nostd::unique_ptr> CreateDoubleUpDownCounter( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept override - { - return nostd::unique_ptr>{ - new NoopUpDownCounter(name, description, unit)}; - } - - nostd::shared_ptr CreateInt64ObservableUpDownCounter( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept override - { - return nostd::shared_ptr( - new NoopObservableInstrument(name, description, unit)); - } - - nostd::shared_ptr CreateDoubleObservableUpDownCounter( - nostd::string_view name, - nostd::string_view description = "", - nostd::string_view unit = "") noexcept override - { - return nostd::shared_ptr( - new NoopObservableInstrument(name, description, unit)); - } -}; - -/** - * No-op implementation of a MeterProvider. - */ -class NoopMeterProvider final : public MeterProvider -{ -public: - NoopMeterProvider() : meter_{nostd::shared_ptr(new NoopMeter)} {} - -#if OPENTELEMETRY_ABI_VERSION_NO >= 2 - nostd::shared_ptr GetMeter( - nostd::string_view /* name */, - nostd::string_view /* version */, - nostd::string_view /* schema_url */, - const common::KeyValueIterable * /* attributes */) noexcept override - { - return meter_; - } -#else - nostd::shared_ptr GetMeter(nostd::string_view /* name */, - nostd::string_view /* version */, - nostd::string_view /* schema_url */) noexcept override - { - return meter_; - } -#endif - -#if OPENTELEMETRY_ABI_VERSION_NO >= 2 - void RemoveMeter(nostd::string_view /* name */, - nostd::string_view /* version */, - nostd::string_view /* schema_url */) noexcept override - {} -#endif - -private: - nostd::shared_ptr meter_; -}; -} // namespace metrics -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/observer_result.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/observer_result.h deleted file mode 100644 index 56c42bc20e..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/observer_result.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/nostd/span.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/type_traits.h" -#include "opentelemetry/nostd/variant.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace metrics -{ - -/** - * ObserverResultT class is necessary for the callback recording asynchronous - * instrument use. - */ -template -class ObserverResultT -{ - -public: - virtual ~ObserverResultT() = default; - - virtual void Observe(T value) noexcept = 0; - - virtual void Observe(T value, const common::KeyValueIterable &attributes) noexcept = 0; - - template ::value> * = nullptr> - void Observe(T value, const U &attributes) noexcept - { - this->Observe(value, common::KeyValueIterableView{attributes}); - } - - void Observe(T value, - std::initializer_list> - attributes) noexcept - { - this->Observe(value, nostd::span>{ - attributes.begin(), attributes.end()}); - } -}; - -using ObserverResult = nostd::variant>, - nostd::shared_ptr>>; - -} // namespace metrics -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/provider.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/provider.h deleted file mode 100644 index 20a606a772..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/provider.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include - -#include "opentelemetry/common/spin_lock_mutex.h" -#include "opentelemetry/metrics/meter_provider.h" -#include "opentelemetry/metrics/noop.h" -#include "opentelemetry/nostd/shared_ptr.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace metrics -{ - -/** - * Stores the singleton global MeterProvider. - */ -class Provider -{ -public: - /** - * Returns the singleton MeterProvider. - * - * By default, a no-op MeterProvider is returned. This will never return a - * nullptr MeterProvider. - */ - static nostd::shared_ptr GetMeterProvider() noexcept - { - std::lock_guard guard(GetLock()); - return nostd::shared_ptr(GetProvider()); - } - - /** - * Changes the singleton MeterProvider. - */ - static void SetMeterProvider(const nostd::shared_ptr &tp) noexcept - { - std::lock_guard guard(GetLock()); - GetProvider() = tp; - } - -private: - OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr &GetProvider() noexcept - { - static nostd::shared_ptr provider(new NoopMeterProvider); - return provider; - } - - OPENTELEMETRY_API_SINGLETON static common::SpinLockMutex &GetLock() noexcept - { - static common::SpinLockMutex lock; - return lock; - } -}; - -} // namespace metrics -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/sync_instruments.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/sync_instruments.h deleted file mode 100644 index 9eaec3352f..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/metrics/sync_instruments.h +++ /dev/null @@ -1,328 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/context/context.h" -#include "opentelemetry/nostd/span.h" -#include "opentelemetry/nostd/string_view.h" -#include "opentelemetry/nostd/type_traits.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace metrics -{ - -class SynchronousInstrument -{ -public: - SynchronousInstrument() = default; - virtual ~SynchronousInstrument() = default; -}; - -/* A Counter instrument that adds values. */ -template -class Counter : public SynchronousInstrument -{ - -public: - /** - * Record a value - * - * @param value The increment amount. MUST be non-negative. - */ - virtual void Add(T value) noexcept = 0; - - /** - * Record a value - * - * @param value The increment amount. MUST be non-negative. - * @param context The explicit context to associate with this measurement. - */ - virtual void Add(T value, const context::Context &context) noexcept = 0; - - /** - * Record a value with a set of attributes. - * - * @param value The increment amount. MUST be non-negative. - * @param attributes A set of attributes to associate with the value. - */ - - virtual void Add(T value, const common::KeyValueIterable &attributes) noexcept = 0; - - /** - * Record a value with a set of attributes. - * - * @param value The increment amount. MUST be non-negative. - * @param attributes A set of attributes to associate with the value. - * @param context The explicit context to associate with this measurement. - */ - virtual void Add(T value, - const common::KeyValueIterable &attributes, - const context::Context &context) noexcept = 0; - - template ::value> * = nullptr> - void Add(T value, const U &attributes) noexcept - { - this->Add(value, common::KeyValueIterableView{attributes}); - } - - template ::value> * = nullptr> - void Add(T value, const U &attributes, const context::Context &context) noexcept - { - this->Add(value, common::KeyValueIterableView{attributes}, context); - } - - void Add(T value, - std::initializer_list> - attributes) noexcept - { - this->Add(value, nostd::span>{ - attributes.begin(), attributes.end()}); - } - - void Add(T value, - std::initializer_list> attributes, - const context::Context &context) noexcept - { - this->Add(value, - nostd::span>{ - attributes.begin(), attributes.end()}, - context); - } -}; - -/** A histogram instrument that records values. */ - -template -class Histogram : public SynchronousInstrument -{ -public: -#if OPENTELEMETRY_ABI_VERSION_NO >= 2 - /** - * @since ABI_VERSION 2 - * Records a value. - * - * @param value The measurement value. MUST be non-negative. - */ - virtual void Record(T value) noexcept = 0; - - /** - * @since ABI_VERSION 2 - * Records a value with a set of attributes. - * - * @param value The measurement value. MUST be non-negative. - * @param attribute A set of attributes to associate with the value. - */ - virtual void Record(T value, const common::KeyValueIterable &attribute) noexcept = 0; - - template ::value> * = nullptr> - void Record(T value, const U &attributes) noexcept - { - this->Record(value, common::KeyValueIterableView{attributes}); - } - - void Record(T value, - std::initializer_list> - attributes) noexcept - { - this->Record(value, nostd::span>{ - attributes.begin(), attributes.end()}); - } -#endif - - /** - * Records a value. - * - * @param value The measurement value. MUST be non-negative. - * @param context The explicit context to associate with this measurement. - */ - virtual void Record(T value, const context::Context &context) noexcept = 0; - - /** - * Records a value with a set of attributes. - * - * @param value The measurement value. MUST be non-negative. - * @param attributes A set of attributes to associate with the value.. - * @param context The explicit context to associate with this measurement. - */ - virtual void Record(T value, - const common::KeyValueIterable &attributes, - const context::Context &context) noexcept = 0; - - template ::value> * = nullptr> - void Record(T value, const U &attributes, const context::Context &context) noexcept - { - this->Record(value, common::KeyValueIterableView{attributes}, context); - } - - void Record( - T value, - std::initializer_list> attributes, - const context::Context &context) noexcept - { - this->Record(value, - nostd::span>{ - attributes.begin(), attributes.end()}, - context); - } -}; - -/** An up-down-counter instrument that adds or reduce values. */ - -template -class UpDownCounter : public SynchronousInstrument -{ -public: - /** - * Record a value. - * - * @param value The increment amount. May be positive, negative or zero. - */ - virtual void Add(T value) noexcept = 0; - - /** - * Record a value. - * - * @param value The increment amount. May be positive, negative or zero. - * @param context The explicit context to associate with this measurement. - */ - virtual void Add(T value, const context::Context &context) noexcept = 0; - - /** - * Record a value with a set of attributes. - * - * @param value The increment amount. May be positive, negative or zero. - * @param attributes A set of attributes to associate with the count. - */ - virtual void Add(T value, const common::KeyValueIterable &attributes) noexcept = 0; - - /** - * Record a value with a set of attributes. - * - * @param value The increment amount. May be positive, negative or zero. - * @param attributes A set of attributes to associate with the count. - * @param context The explicit context to associate with this measurement. - */ - virtual void Add(T value, - const common::KeyValueIterable &attributes, - const context::Context &context) noexcept = 0; - - template ::value> * = nullptr> - void Add(T value, const U &attributes) noexcept - { - this->Add(value, common::KeyValueIterableView{attributes}); - } - - template ::value> * = nullptr> - void Add(T value, const U &attributes, const context::Context &context) noexcept - { - this->Add(value, common::KeyValueIterableView{attributes}, context); - } - - void Add(T value, - std::initializer_list> - attributes) noexcept - { - this->Add(value, nostd::span>{ - attributes.begin(), attributes.end()}); - } - - void Add(T value, - std::initializer_list> attributes, - const context::Context &context) noexcept - { - this->Add(value, - nostd::span>{ - attributes.begin(), attributes.end()}, - context); - } -}; - -#if OPENTELEMETRY_ABI_VERSION_NO >= 2 -/* A Gauge instrument that records values. */ -template -class Gauge : public SynchronousInstrument -{ - -public: - /** - * Record a value - * - * @param value The measurement value. May be positive, negative or zero. - */ - virtual void Record(T value) noexcept = 0; - - /** - * Record a value - * - * @param value The measurement value. May be positive, negative or zero. - * @param context The explicit context to associate with this measurement. - */ - virtual void Record(T value, const context::Context &context) noexcept = 0; - - /** - * Record a value with a set of attributes. - * - * @param value The measurement value. May be positive, negative or zero. - * @param attributes A set of attributes to associate with the value. - */ - - virtual void Record(T value, const common::KeyValueIterable &attributes) noexcept = 0; - - /** - * Record a value with a set of attributes. - * - * @param value The measurement value. May be positive, negative or zero. - * @param attributes A set of attributes to associate with the value. - * @param context The explicit context to associate with this measurement. - */ - virtual void Record(T value, - const common::KeyValueIterable &attributes, - const context::Context &context) noexcept = 0; - - template ::value> * = nullptr> - void Record(T value, const U &attributes) noexcept - { - this->Record(value, common::KeyValueIterableView{attributes}); - } - - template ::value> * = nullptr> - void Record(T value, const U &attributes, const context::Context &context) noexcept - { - this->Record(value, common::KeyValueIterableView{attributes}, context); - } - - void Record(T value, - std::initializer_list> - attributes) noexcept - { - this->Record(value, nostd::span>{ - attributes.begin(), attributes.end()}); - } - - void Record( - T value, - std::initializer_list> attributes, - const context::Context &context) noexcept - { - this->Record(value, - nostd::span>{ - attributes.begin(), attributes.end()}, - context); - } -}; -#endif - -} // namespace metrics -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/all.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/all.h deleted file mode 100644 index deaf3ac6f2..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/all.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include - -#include "opentelemetry/nostd/utility.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace nostd -{ -namespace detail -{ -template -using all = std::is_same, integer_sequence>; - -} // namespace detail -} // namespace nostd -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/decay.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/decay.h deleted file mode 100644 index a6cb111243..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/decay.h +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include - -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace nostd -{ -template -using decay_t = typename std::decay::type; -} // namespace nostd -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/dependent_type.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/dependent_type.h deleted file mode 100644 index 5bba09ff88..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/dependent_type.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include - -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace nostd -{ -namespace detail -{ -template -struct dependent_type : T -{}; -} // namespace detail -} // namespace nostd -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/functional.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/functional.h deleted file mode 100644 index 0da58dd186..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/functional.h +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include - -#include "opentelemetry/version.h" - -#define OPENTELEMETRY_RETURN(...) \ - noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) \ - { \ - return __VA_ARGS__; \ - } - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace nostd -{ -namespace detail -{ -struct equal_to -{ - template - inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const - OPENTELEMETRY_RETURN(std::forward(lhs) == std::forward(rhs)) -}; - -struct not_equal_to -{ - template - inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const - OPENTELEMETRY_RETURN(std::forward(lhs) != std::forward(rhs)) -}; - -struct less -{ - template - inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const - OPENTELEMETRY_RETURN(std::forward(lhs) < std::forward(rhs)) -}; - -struct greater -{ - template - inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const - OPENTELEMETRY_RETURN(std::forward(lhs) > std::forward(rhs)) -}; - -struct less_equal -{ - template - inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const - OPENTELEMETRY_RETURN(std::forward(lhs) <= std::forward(rhs)) -}; - -struct greater_equal -{ - template - inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const - OPENTELEMETRY_RETURN(std::forward(lhs) >= std::forward(rhs)) -}; -} // namespace detail -} // namespace nostd -OPENTELEMETRY_END_NAMESPACE - -#undef OPENTELEMETRY_RETURN diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/invoke.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/invoke.h deleted file mode 100644 index 55a943ed12..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/invoke.h +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include -#include - -#include "opentelemetry/nostd/detail/decay.h" -#include "opentelemetry/nostd/detail/void.h" -#include "opentelemetry/version.h" - -#define OPENTELEMETRY_RETURN(...) \ - noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) \ - { \ - return __VA_ARGS__; \ - } - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace nostd -{ -namespace detail -{ - -template -struct is_reference_wrapper : std::false_type -{}; - -template -struct is_reference_wrapper> : std::true_type -{}; - -template -struct Invoke; - -template <> -struct Invoke -{ - template - inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&...args) - OPENTELEMETRY_RETURN((std::forward(arg).*pmf)(std::forward(args)...)) -}; - -template <> -struct Invoke -{ - template - inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&...args) - OPENTELEMETRY_RETURN((std::forward(arg).get().*pmf)(std::forward(args)...)) -}; - -template <> -struct Invoke -{ - template - inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&...args) - OPENTELEMETRY_RETURN(((*std::forward(arg)).*pmf)(std::forward(args)...)) -}; - -template <> -struct Invoke -{ - template - inline static constexpr auto invoke(R T::*pmo, Arg &&arg) - OPENTELEMETRY_RETURN(std::forward(arg).*pmo) -}; - -template <> -struct Invoke -{ - template - inline static constexpr auto invoke(R T::*pmo, Arg &&arg) - OPENTELEMETRY_RETURN(std::forward(arg).get().*pmo) -}; - -template <> -struct Invoke -{ - template - inline static constexpr auto invoke(R T::*pmo, Arg &&arg) - OPENTELEMETRY_RETURN((*std::forward(arg)).*pmo) -}; - -template -inline constexpr auto invoke_impl(R T::*f, Arg &&arg, Args &&...args) OPENTELEMETRY_RETURN( - Invoke::value, - (std::is_base_of>::value ? 0 - : is_reference_wrapper>::value ? 1 - : 2)>::invoke(f, - std::forward(arg), - std::forward(args)...)) - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable : 4100) -#endif - template - inline constexpr auto invoke_impl(F &&f, Args &&...args) - OPENTELEMETRY_RETURN(std::forward(f)(std::forward(args)...)) -#ifdef _MSC_VER -# pragma warning(pop) -#endif -} // namespace detail - -/* clang-format off */ -template -inline constexpr auto invoke(F &&f, Args &&... args) - OPENTELEMETRY_RETURN(detail::invoke_impl(std::forward(f), std::forward(args)...)) - -namespace detail -/* clang-format on */ -{ - - template - struct invoke_result - {}; - - template - struct invoke_result(), std::declval()...))>, - F, Args...> - { - using type = decltype(nostd::invoke(std::declval(), std::declval()...)); - }; - -} // namespace detail - -template -using invoke_result = detail::invoke_result; - -template -using invoke_result_t = typename invoke_result::type; - -namespace detail -{ - -template -struct is_invocable : std::false_type -{}; - -template -struct is_invocable>, F, Args...> : std::true_type -{}; - -template -struct is_invocable_r : std::false_type -{}; - -template -struct is_invocable_r>, R, F, Args...> - : std::is_convertible, R> -{}; - -} // namespace detail - -template -using is_invocable = detail::is_invocable; - -template -using is_invocable_r = detail::is_invocable_r; -} // namespace nostd -OPENTELEMETRY_END_NAMESPACE - -#undef OPENTELEMETRY_RETURN diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/trait.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/trait.h deleted file mode 100644 index 8f76fdec8b..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/trait.h +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include - -#include "opentelemetry/nostd/type_traits.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace nostd -{ -namespace detail -{ -enum class Trait -{ - TriviallyAvailable, - Available, - Unavailable -}; - -template - class IsTriviallyAvailable, - template - class IsAvailable> -inline constexpr Trait trait() -{ - return IsTriviallyAvailable::value ? Trait::TriviallyAvailable - : IsAvailable::value ? Trait::Available - : Trait::Unavailable; -} - -inline constexpr Trait common_trait_impl(Trait result) -{ - return result; -} - -template -inline constexpr Trait common_trait_impl(Trait result, Trait t, Traits... ts) -{ - return static_cast(t) > static_cast(result) ? common_trait_impl(t, ts...) - : common_trait_impl(result, ts...); -} - -template -inline constexpr Trait common_trait(Traits... ts) -{ - return common_trait_impl(Trait::TriviallyAvailable, ts...); -} - -template -struct traits -{ - static constexpr Trait copy_constructible_trait = - common_trait(trait()...); - - static constexpr Trait move_constructible_trait = - common_trait(trait()...); - - static constexpr Trait copy_assignable_trait = - common_trait(copy_constructible_trait, - trait()...); - - static constexpr Trait move_assignable_trait = - common_trait(move_constructible_trait, - trait()...); - - static constexpr Trait destructible_trait = - common_trait(trait()...); -}; -} // namespace detail -} // namespace nostd -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/type_pack_element.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/type_pack_element.h deleted file mode 100644 index 280d24e94a..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/type_pack_element.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include -#include - -#include "opentelemetry/nostd/utility.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace nostd -{ -namespace detail -{ -template -using size_constant = std::integral_constant; - -template -struct indexed_type : size_constant -{ - using type = T; -}; - -template -struct type_pack_element_impl -{ -private: - template - struct set; - - template - struct set> : indexed_type... - {}; - - template - inline static std::enable_if impl(indexed_type); - - inline static std::enable_if impl(...); - -public: - using type = decltype(impl(set>{})); -}; - -template -using type_pack_element = typename type_pack_element_impl::type; - -template -using type_pack_element_t = typename type_pack_element::type; -} // namespace detail -} // namespace nostd -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/valueless.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/valueless.h deleted file mode 100644 index 3b2ca7f7cf..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/valueless.h +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace nostd -{ -struct valueless_t -{}; -} // namespace nostd -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/variant_alternative.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/variant_alternative.h deleted file mode 100644 index cc0da9c8c1..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/variant_alternative.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include - -#include "opentelemetry/nostd/detail/type_pack_element.h" -#include "opentelemetry/nostd/detail/variant_fwd.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace nostd -{ -template -struct variant_alternative; - -template -using variant_alternative_t = typename variant_alternative::type; - -template -struct variant_alternative : std::add_const> -{}; - -template -struct variant_alternative : std::add_volatile> -{}; - -template -struct variant_alternative : std::add_cv> -{}; - -template -struct variant_alternative> -{ - static_assert(I < sizeof...(Ts), "index out of bounds in `std::variant_alternative<>`"); - using type = detail::type_pack_element_t; -}; -} // namespace nostd -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/variant_fwd.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/variant_fwd.h deleted file mode 100644 index 6bae9659ec..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/variant_fwd.h +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace nostd -{ -template -class variant; -} // namespace nostd -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/variant_size.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/variant_size.h deleted file mode 100644 index d8986a222b..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/variant_size.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include - -#include "opentelemetry/nostd/detail/variant_fwd.h" -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace nostd -{ -template -struct variant_size; - -template -struct variant_size : variant_size -{}; - -template -struct variant_size : variant_size -{}; - -template -struct variant_size : variant_size -{}; - -template -struct variant_size> : std::integral_constant -{}; -} // namespace nostd -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/void.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/void.h deleted file mode 100644 index 1b4c3b4f7d..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/detail/void.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace nostd -{ -namespace detail -{ -template -struct voider -{ - using type = void; -}; -} // namespace detail - -/** - * Back port of std::void_t - * - * Note: voider workaround is required for gcc-4.8 to make SFINAE work - */ -template -using void_t = typename detail::voider::type; -} // namespace nostd -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/function_ref.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/function_ref.h deleted file mode 100644 index 6f0c2dd330..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/function_ref.h +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -#pragma once - -#include -#include // IWYU pragma: keep -#include -#include - -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -namespace nostd -{ -template -class function_ref; // IWYU pragma: keep - -/** - * Non-owning function reference that can be used as a more performant - * replacement for std::function when ownership sematics aren't needed. - * - * See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0792r0.html - * - * Based off of https://stackoverflow.com/a/39087660/4447365 - */ -template -class function_ref -{ - void *callable_ = nullptr; - R (*invoker_)(void *, Args...) = nullptr; - - template - using FunctionPointer = decltype(std::addressof(std::declval())); - - template - void BindTo(F &f) noexcept - { - callable_ = static_cast(std::addressof(f)); - invoker_ = [](void *callable, Args... args) -> R { - return (*static_cast>(callable))(std::forward(args)...); - }; - } - - template - void BindTo(R_in (*f)(Args_in...)) noexcept - { - using F = decltype(f); - if (f == nullptr) - { - return BindTo(nullptr); - } - callable_ = reinterpret_cast(f); - invoker_ = [](void *callable, Args... args) -> R { - return (F(callable))(std::forward(args)...); - }; - } - - void BindTo(std::nullptr_t) noexcept - { - callable_ = nullptr; - invoker_ = nullptr; - } - -public: - template < - class F, - typename std::enable_if::type>::value, - int>::type = 0, - typename std::enable_if< -#if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && (_MSVC_LANG > 201402)) - // std::result_of deprecated in C++17, removed in C++20 - std::is_convertible::type, R>::value, -#else - // std::result_of since C++11 - std::is_convertible::type, R>::value, -#endif - int>::type = 0> - function_ref(F &&f) - { - BindTo(f); // not forward - } - - function_ref(std::nullptr_t) {} - - function_ref(const function_ref &) noexcept = default; - function_ref(function_ref &&) noexcept = default; - - R operator()(Args... args) const { return invoker_(callable_, std::forward(args)...); } - - explicit operator bool() const { return invoker_; } -}; -} // namespace nostd -OPENTELEMETRY_END_NAMESPACE diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/.clang-format b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/.clang-format deleted file mode 100644 index 001170f7ee..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/.clang-format +++ /dev/null @@ -1,3 +0,0 @@ -# Disable formatting for Google Abseil library snapshot -DisableFormat: true -SortIncludes: false diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/README.md b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/README.md deleted file mode 100644 index 5dd661971f..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Notes on Abseil Variant implementation - -This is a snapshot of Abseil Variant -`absl::OTABSL_OPTION_NAMESPACE_NAME::variant` from Abseil `v2020-03-03#8`. diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/attributes.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/attributes.h deleted file mode 100644 index 72901a84c5..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/attributes.h +++ /dev/null @@ -1,621 +0,0 @@ -// Copyright 2017 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// This header file defines macros for declaring attributes for functions, -// types, and variables. -// -// These macros are used within Abseil and allow the compiler to optimize, where -// applicable, certain function calls. -// -// This file is used for both C and C++! -// -// Most macros here are exposing GCC or Clang features, and are stubbed out for -// other compilers. -// -// GCC attributes documentation: -// https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Function-Attributes.html -// https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Variable-Attributes.html -// https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Type-Attributes.html -// -// Most attributes in this file are already supported by GCC 4.7. However, some -// of them are not supported in older version of Clang. Thus, we check -// `__has_attribute()` first. If the check fails, we check if we are on GCC and -// assume the attribute exists on GCC (which is verified on GCC 4.7). -// -// ----------------------------------------------------------------------------- -// Sanitizer Attributes -// ----------------------------------------------------------------------------- -// -// Sanitizer-related attributes are not "defined" in this file (and indeed -// are not defined as such in any file). To utilize the following -// sanitizer-related attributes within your builds, define the following macros -// within your build using a `-D` flag, along with the given value for -// `-fsanitize`: -// -// * `ADDRESS_SANITIZER` + `-fsanitize=address` (Clang, GCC 4.8) -// * `MEMORY_SANITIZER` + `-fsanitize=memory` (Clang-only) -// * `THREAD_SANITIZER + `-fsanitize=thread` (Clang, GCC 4.8+) -// * `UNDEFINED_BEHAVIOR_SANITIZER` + `-fsanitize=undefined` (Clang, GCC 4.9+) -// * `CONTROL_FLOW_INTEGRITY` + -fsanitize=cfi (Clang-only) -// -// Example: -// -// // Enable branches in the Abseil code that are tagged for ASan: -// $ bazel build --copt=-DADDRESS_SANITIZER --copt=-fsanitize=address -// --linkopt=-fsanitize=address *target* -// -// Since these macro names are only supported by GCC and Clang, we only check -// for `__GNUC__` (GCC or Clang) and the above macros. -#ifndef OTABSL_BASE_ATTRIBUTES_H_ -#define OTABSL_BASE_ATTRIBUTES_H_ - -// OTABSL_HAVE_ATTRIBUTE -// -// A function-like feature checking macro that is a wrapper around -// `__has_attribute`, which is defined by GCC 5+ and Clang and evaluates to a -// nonzero constant integer if the attribute is supported or 0 if not. -// -// It evaluates to zero if `__has_attribute` is not defined by the compiler. -// -// GCC: https://gcc.gnu.org/gcc-5/changes.html -// Clang: https://clang.llvm.org/docs/LanguageExtensions.html -#ifdef __has_attribute -#define OTABSL_HAVE_ATTRIBUTE(x) __has_attribute(x) -#else -#define OTABSL_HAVE_ATTRIBUTE(x) 0 -#endif - -// OTABSL_HAVE_CPP_ATTRIBUTE -// -// A function-like feature checking macro that accepts C++11 style attributes. -// It's a wrapper around `__has_cpp_attribute`, defined by ISO C++ SD-6 -// (https://en.cppreference.com/w/cpp/experimental/feature_test). If we don't -// find `__has_cpp_attribute`, will evaluate to 0. -#if defined(__cplusplus) && defined(__has_cpp_attribute) -// NOTE: requiring __cplusplus above should not be necessary, but -// works around https://bugs.llvm.org/show_bug.cgi?id=23435. -#define OTABSL_HAVE_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) -#else -#define OTABSL_HAVE_CPP_ATTRIBUTE(x) 0 -#endif - -// ----------------------------------------------------------------------------- -// Function Attributes -// ----------------------------------------------------------------------------- -// -// GCC: https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html -// Clang: https://clang.llvm.org/docs/AttributeReference.html - -// OTABSL_PRINTF_ATTRIBUTE -// OTABSL_SCANF_ATTRIBUTE -// -// Tells the compiler to perform `printf` format string checking if the -// compiler supports it; see the 'format' attribute in -// . -// -// Note: As the GCC manual states, "[s]ince non-static C++ methods -// have an implicit 'this' argument, the arguments of such methods -// should be counted from two, not one." -#if OTABSL_HAVE_ATTRIBUTE(format) || (defined(__GNUC__) && !defined(__clang__)) -#define OTABSL_PRINTF_ATTRIBUTE(string_index, first_to_check) \ - __attribute__((__format__(__printf__, string_index, first_to_check))) -#define OTABSL_SCANF_ATTRIBUTE(string_index, first_to_check) \ - __attribute__((__format__(__scanf__, string_index, first_to_check))) -#else -#define OTABSL_PRINTF_ATTRIBUTE(string_index, first_to_check) -#define OTABSL_SCANF_ATTRIBUTE(string_index, first_to_check) -#endif - -// OTABSL_ATTRIBUTE_ALWAYS_INLINE -// OTABSL_ATTRIBUTE_NOINLINE -// -// Forces functions to either inline or not inline. Introduced in gcc 3.1. -#if OTABSL_HAVE_ATTRIBUTE(always_inline) || \ - (defined(__GNUC__) && !defined(__clang__)) -#define OTABSL_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline)) -#define OTABSL_HAVE_ATTRIBUTE_ALWAYS_INLINE 1 -#else -#define OTABSL_ATTRIBUTE_ALWAYS_INLINE -#endif - -#if OTABSL_HAVE_ATTRIBUTE(noinline) || (defined(__GNUC__) && !defined(__clang__)) -#define OTABSL_ATTRIBUTE_NOINLINE __attribute__((noinline)) -#define OTABSL_HAVE_ATTRIBUTE_NOINLINE 1 -#else -#define OTABSL_ATTRIBUTE_NOINLINE -#endif - -// OTABSL_ATTRIBUTE_NO_TAIL_CALL -// -// Prevents the compiler from optimizing away stack frames for functions which -// end in a call to another function. -#if OTABSL_HAVE_ATTRIBUTE(disable_tail_calls) -#define OTABSL_HAVE_ATTRIBUTE_NO_TAIL_CALL 1 -#define OTABSL_ATTRIBUTE_NO_TAIL_CALL __attribute__((disable_tail_calls)) -#elif defined(__GNUC__) && !defined(__clang__) -#define OTABSL_HAVE_ATTRIBUTE_NO_TAIL_CALL 1 -#define OTABSL_ATTRIBUTE_NO_TAIL_CALL \ - __attribute__((optimize("no-optimize-sibling-calls"))) -#else -#define OTABSL_ATTRIBUTE_NO_TAIL_CALL -#define OTABSL_HAVE_ATTRIBUTE_NO_TAIL_CALL 0 -#endif - -// OTABSL_ATTRIBUTE_WEAK -// -// Tags a function as weak for the purposes of compilation and linking. -// Weak attributes currently do not work properly in LLVM's Windows backend, -// so disable them there. See https://bugs.llvm.org/show_bug.cgi?id=37598 -// for further information. -// The MinGW compiler doesn't complain about the weak attribute until the link -// step, presumably because Windows doesn't use ELF binaries. -#if (OTABSL_HAVE_ATTRIBUTE(weak) || \ - (defined(__GNUC__) && !defined(__clang__))) && \ - !(defined(__llvm__) && defined(_WIN32)) && !defined(__MINGW32__) -#undef OTABSL_ATTRIBUTE_WEAK -#define OTABSL_ATTRIBUTE_WEAK __attribute__((weak)) -#define OTABSL_HAVE_ATTRIBUTE_WEAK 1 -#else -#define OTABSL_ATTRIBUTE_WEAK -#define OTABSL_HAVE_ATTRIBUTE_WEAK 0 -#endif - -// OTABSL_ATTRIBUTE_NONNULL -// -// Tells the compiler either (a) that a particular function parameter -// should be a non-null pointer, or (b) that all pointer arguments should -// be non-null. -// -// Note: As the GCC manual states, "[s]ince non-static C++ methods -// have an implicit 'this' argument, the arguments of such methods -// should be counted from two, not one." -// -// Args are indexed starting at 1. -// -// For non-static class member functions, the implicit `this` argument -// is arg 1, and the first explicit argument is arg 2. For static class member -// functions, there is no implicit `this`, and the first explicit argument is -// arg 1. -// -// Example: -// -// /* arg_a cannot be null, but arg_b can */ -// void Function(void* arg_a, void* arg_b) OTABSL_ATTRIBUTE_NONNULL(1); -// -// class C { -// /* arg_a cannot be null, but arg_b can */ -// void Method(void* arg_a, void* arg_b) OTABSL_ATTRIBUTE_NONNULL(2); -// -// /* arg_a cannot be null, but arg_b can */ -// static void StaticMethod(void* arg_a, void* arg_b) -// OTABSL_ATTRIBUTE_NONNULL(1); -// }; -// -// If no arguments are provided, then all pointer arguments should be non-null. -// -// /* No pointer arguments may be null. */ -// void Function(void* arg_a, void* arg_b, int arg_c) OTABSL_ATTRIBUTE_NONNULL(); -// -// NOTE: The GCC nonnull attribute actually accepts a list of arguments, but -// OTABSL_ATTRIBUTE_NONNULL does not. -#if OTABSL_HAVE_ATTRIBUTE(nonnull) || (defined(__GNUC__) && !defined(__clang__)) -#define OTABSL_ATTRIBUTE_NONNULL(arg_index) __attribute__((nonnull(arg_index))) -#else -#define OTABSL_ATTRIBUTE_NONNULL(...) -#endif - -// OTABSL_ATTRIBUTE_NORETURN -// -// Tells the compiler that a given function never returns. -#if OTABSL_HAVE_ATTRIBUTE(noreturn) || (defined(__GNUC__) && !defined(__clang__)) -#define OTABSL_ATTRIBUTE_NORETURN __attribute__((noreturn)) -#elif defined(_MSC_VER) -#define OTABSL_ATTRIBUTE_NORETURN __declspec(noreturn) -#else -#define OTABSL_ATTRIBUTE_NORETURN -#endif - -// OTABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS -// -// Tells the AddressSanitizer (or other memory testing tools) to ignore a given -// function. Useful for cases when a function reads random locations on stack, -// calls _exit from a cloned subprocess, deliberately accesses buffer -// out of bounds or does other scary things with memory. -// NOTE: GCC supports AddressSanitizer(asan) since 4.8. -// https://gcc.gnu.org/gcc-4.8/changes.html -#if defined(__GNUC__) -#define OTABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address)) -#else -#define OTABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS -#endif - -// OTABSL_ATTRIBUTE_NO_SANITIZE_MEMORY -// -// Tells the MemorySanitizer to relax the handling of a given function. All -// "Use of uninitialized value" warnings from such functions will be suppressed, -// and all values loaded from memory will be considered fully initialized. -// This attribute is similar to the ADDRESS_SANITIZER attribute above, but deals -// with initialized-ness rather than addressability issues. -// NOTE: MemorySanitizer(msan) is supported by Clang but not GCC. -#if defined(__clang__) -#define OTABSL_ATTRIBUTE_NO_SANITIZE_MEMORY __attribute__((no_sanitize_memory)) -#else -#define OTABSL_ATTRIBUTE_NO_SANITIZE_MEMORY -#endif - -// OTABSL_ATTRIBUTE_NO_SANITIZE_THREAD -// -// Tells the ThreadSanitizer to not instrument a given function. -// NOTE: GCC supports ThreadSanitizer(tsan) since 4.8. -// https://gcc.gnu.org/gcc-4.8/changes.html -#if defined(__GNUC__) -#define OTABSL_ATTRIBUTE_NO_SANITIZE_THREAD __attribute__((no_sanitize_thread)) -#else -#define OTABSL_ATTRIBUTE_NO_SANITIZE_THREAD -#endif - -// OTABSL_ATTRIBUTE_NO_SANITIZE_UNDEFINED -// -// Tells the UndefinedSanitizer to ignore a given function. Useful for cases -// where certain behavior (eg. division by zero) is being used intentionally. -// NOTE: GCC supports UndefinedBehaviorSanitizer(ubsan) since 4.9. -// https://gcc.gnu.org/gcc-4.9/changes.html -#if defined(__GNUC__) && \ - (defined(UNDEFINED_BEHAVIOR_SANITIZER) || defined(ADDRESS_SANITIZER)) -#define OTABSL_ATTRIBUTE_NO_SANITIZE_UNDEFINED \ - __attribute__((no_sanitize("undefined"))) -#else -#define OTABSL_ATTRIBUTE_NO_SANITIZE_UNDEFINED -#endif - -// OTABSL_ATTRIBUTE_NO_SANITIZE_CFI -// -// Tells the ControlFlowIntegrity sanitizer to not instrument a given function. -// See https://clang.llvm.org/docs/ControlFlowIntegrity.html for details. -#if defined(__GNUC__) && defined(CONTROL_FLOW_INTEGRITY) -#define OTABSL_ATTRIBUTE_NO_SANITIZE_CFI __attribute__((no_sanitize("cfi"))) -#else -#define OTABSL_ATTRIBUTE_NO_SANITIZE_CFI -#endif - -// OTABSL_ATTRIBUTE_NO_SANITIZE_SAFESTACK -// -// Tells the SafeStack to not instrument a given function. -// See https://clang.llvm.org/docs/SafeStack.html for details. -#if defined(__GNUC__) && defined(SAFESTACK_SANITIZER) -#define OTABSL_ATTRIBUTE_NO_SANITIZE_SAFESTACK \ - __attribute__((no_sanitize("safe-stack"))) -#else -#define OTABSL_ATTRIBUTE_NO_SANITIZE_SAFESTACK -#endif - -// OTABSL_ATTRIBUTE_RETURNS_NONNULL -// -// Tells the compiler that a particular function never returns a null pointer. -#if OTABSL_HAVE_ATTRIBUTE(returns_nonnull) || \ - (defined(__GNUC__) && \ - (__GNUC__ > 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) && \ - !defined(__clang__)) -#define OTABSL_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull)) -#else -#define OTABSL_ATTRIBUTE_RETURNS_NONNULL -#endif - -// OTABSL_HAVE_ATTRIBUTE_SECTION -// -// Indicates whether labeled sections are supported. Weak symbol support is -// a prerequisite. Labeled sections are not supported on Darwin/iOS. -#ifdef OTABSL_HAVE_ATTRIBUTE_SECTION -#error OTABSL_HAVE_ATTRIBUTE_SECTION cannot be directly set -#elif (OTABSL_HAVE_ATTRIBUTE(section) || \ - (defined(__GNUC__) && !defined(__clang__))) && \ - !defined(__APPLE__) && OTABSL_HAVE_ATTRIBUTE_WEAK -#define OTABSL_HAVE_ATTRIBUTE_SECTION 1 - -// OTABSL_ATTRIBUTE_SECTION -// -// Tells the compiler/linker to put a given function into a section and define -// `__start_ ## name` and `__stop_ ## name` symbols to bracket the section. -// This functionality is supported by GNU linker. Any function annotated with -// `OTABSL_ATTRIBUTE_SECTION` must not be inlined, or it will be placed into -// whatever section its caller is placed into. -// -#ifndef OTABSL_ATTRIBUTE_SECTION -#define OTABSL_ATTRIBUTE_SECTION(name) \ - __attribute__((section(#name))) __attribute__((noinline)) -#endif - - -// OTABSL_ATTRIBUTE_SECTION_VARIABLE -// -// Tells the compiler/linker to put a given variable into a section and define -// `__start_ ## name` and `__stop_ ## name` symbols to bracket the section. -// This functionality is supported by GNU linker. -#ifndef OTABSL_ATTRIBUTE_SECTION_VARIABLE -#define OTABSL_ATTRIBUTE_SECTION_VARIABLE(name) __attribute__((section(#name))) -#endif - -// OTABSL_DECLARE_ATTRIBUTE_SECTION_VARS -// -// A weak section declaration to be used as a global declaration -// for OTABSL_ATTRIBUTE_SECTION_START|STOP(name) to compile and link -// even without functions with OTABSL_ATTRIBUTE_SECTION(name). -// OTABSL_DEFINE_ATTRIBUTE_SECTION should be in the exactly one file; it's -// a no-op on ELF but not on Mach-O. -// -#ifndef OTABSL_DECLARE_ATTRIBUTE_SECTION_VARS -#define OTABSL_DECLARE_ATTRIBUTE_SECTION_VARS(name) \ - extern char __start_##name[] OTABSL_ATTRIBUTE_WEAK; \ - extern char __stop_##name[] OTABSL_ATTRIBUTE_WEAK -#endif -#ifndef OTABSL_DEFINE_ATTRIBUTE_SECTION_VARS -#define OTABSL_INIT_ATTRIBUTE_SECTION_VARS(name) -#define OTABSL_DEFINE_ATTRIBUTE_SECTION_VARS(name) -#endif - -// OTABSL_ATTRIBUTE_SECTION_START -// -// Returns `void*` pointers to start/end of a section of code with -// functions having OTABSL_ATTRIBUTE_SECTION(name). -// Returns 0 if no such functions exist. -// One must OTABSL_DECLARE_ATTRIBUTE_SECTION_VARS(name) for this to compile and -// link. -// -#define OTABSL_ATTRIBUTE_SECTION_START(name) \ - (reinterpret_cast(__start_##name)) -#define OTABSL_ATTRIBUTE_SECTION_STOP(name) \ - (reinterpret_cast(__stop_##name)) - -#else // !OTABSL_HAVE_ATTRIBUTE_SECTION - -#define OTABSL_HAVE_ATTRIBUTE_SECTION 0 - -// provide dummy definitions -#define OTABSL_ATTRIBUTE_SECTION(name) -#define OTABSL_ATTRIBUTE_SECTION_VARIABLE(name) -#define OTABSL_INIT_ATTRIBUTE_SECTION_VARS(name) -#define OTABSL_DEFINE_ATTRIBUTE_SECTION_VARS(name) -#define OTABSL_DECLARE_ATTRIBUTE_SECTION_VARS(name) -#define OTABSL_ATTRIBUTE_SECTION_START(name) (reinterpret_cast(0)) -#define OTABSL_ATTRIBUTE_SECTION_STOP(name) (reinterpret_cast(0)) - -#endif // OTABSL_ATTRIBUTE_SECTION - -// OTABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC -// -// Support for aligning the stack on 32-bit x86. -#if OTABSL_HAVE_ATTRIBUTE(force_align_arg_pointer) || \ - (defined(__GNUC__) && !defined(__clang__)) -#if defined(__i386__) -#define OTABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC \ - __attribute__((force_align_arg_pointer)) -#define OTABSL_REQUIRE_STACK_ALIGN_TRAMPOLINE (0) -#elif defined(__x86_64__) -#define OTABSL_REQUIRE_STACK_ALIGN_TRAMPOLINE (1) -#define OTABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC -#else // !__i386__ && !__x86_64 -#define OTABSL_REQUIRE_STACK_ALIGN_TRAMPOLINE (0) -#define OTABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC -#endif // __i386__ -#else -#define OTABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC -#define OTABSL_REQUIRE_STACK_ALIGN_TRAMPOLINE (0) -#endif - -// OTABSL_MUST_USE_RESULT -// -// Tells the compiler to warn about unused results. -// -// When annotating a function, it must appear as the first part of the -// declaration or definition. The compiler will warn if the return value from -// such a function is unused: -// -// OTABSL_MUST_USE_RESULT Sprocket* AllocateSprocket(); -// AllocateSprocket(); // Triggers a warning. -// -// When annotating a class, it is equivalent to annotating every function which -// returns an instance. -// -// class OTABSL_MUST_USE_RESULT Sprocket {}; -// Sprocket(); // Triggers a warning. -// -// Sprocket MakeSprocket(); -// MakeSprocket(); // Triggers a warning. -// -// Note that references and pointers are not instances: -// -// Sprocket* SprocketPointer(); -// SprocketPointer(); // Does *not* trigger a warning. -// -// OTABSL_MUST_USE_RESULT allows using cast-to-void to suppress the unused result -// warning. For that, warn_unused_result is used only for clang but not for gcc. -// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425 -// -// Note: past advice was to place the macro after the argument list. -#if OTABSL_HAVE_ATTRIBUTE(nodiscard) -#define OTABSL_MUST_USE_RESULT [[nodiscard]] -#elif defined(__clang__) && OTABSL_HAVE_ATTRIBUTE(warn_unused_result) -#define OTABSL_MUST_USE_RESULT __attribute__((warn_unused_result)) -#else -#define OTABSL_MUST_USE_RESULT -#endif - -// OTABSL_ATTRIBUTE_HOT, OTABSL_ATTRIBUTE_COLD -// -// Tells GCC that a function is hot or cold. GCC can use this information to -// improve static analysis, i.e. a conditional branch to a cold function -// is likely to be not-taken. -// This annotation is used for function declarations. -// -// Example: -// -// int foo() OTABSL_ATTRIBUTE_HOT; -#if OTABSL_HAVE_ATTRIBUTE(hot) || (defined(__GNUC__) && !defined(__clang__)) -#define OTABSL_ATTRIBUTE_HOT __attribute__((hot)) -#else -#define OTABSL_ATTRIBUTE_HOT -#endif - -#if OTABSL_HAVE_ATTRIBUTE(cold) || (defined(__GNUC__) && !defined(__clang__)) -#define OTABSL_ATTRIBUTE_COLD __attribute__((cold)) -#else -#define OTABSL_ATTRIBUTE_COLD -#endif - -// OTABSL_XRAY_ALWAYS_INSTRUMENT, OTABSL_XRAY_NEVER_INSTRUMENT, OTABSL_XRAY_LOG_ARGS -// -// We define the OTABSL_XRAY_ALWAYS_INSTRUMENT and OTABSL_XRAY_NEVER_INSTRUMENT -// macro used as an attribute to mark functions that must always or never be -// instrumented by XRay. Currently, this is only supported in Clang/LLVM. -// -// For reference on the LLVM XRay instrumentation, see -// http://llvm.org/docs/XRay.html. -// -// A function with the XRAY_ALWAYS_INSTRUMENT macro attribute in its declaration -// will always get the XRay instrumentation sleds. These sleds may introduce -// some binary size and runtime overhead and must be used sparingly. -// -// These attributes only take effect when the following conditions are met: -// -// * The file/target is built in at least C++11 mode, with a Clang compiler -// that supports XRay attributes. -// * The file/target is built with the -fxray-instrument flag set for the -// Clang/LLVM compiler. -// * The function is defined in the translation unit (the compiler honors the -// attribute in either the definition or the declaration, and must match). -// -// There are cases when, even when building with XRay instrumentation, users -// might want to control specifically which functions are instrumented for a -// particular build using special-case lists provided to the compiler. These -// special case lists are provided to Clang via the -// -fxray-always-instrument=... and -fxray-never-instrument=... flags. The -// attributes in source take precedence over these special-case lists. -// -// To disable the XRay attributes at build-time, users may define -// OTABSL_NO_XRAY_ATTRIBUTES. Do NOT define OTABSL_NO_XRAY_ATTRIBUTES on specific -// packages/targets, as this may lead to conflicting definitions of functions at -// link-time. -// -#if OTABSL_HAVE_CPP_ATTRIBUTE(clang::xray_always_instrument) && \ - !defined(OTABSL_NO_XRAY_ATTRIBUTES) -#define OTABSL_XRAY_ALWAYS_INSTRUMENT [[clang::xray_always_instrument]] -#define OTABSL_XRAY_NEVER_INSTRUMENT [[clang::xray_never_instrument]] -#if OTABSL_HAVE_CPP_ATTRIBUTE(clang::xray_log_args) -#define OTABSL_XRAY_LOG_ARGS(N) \ - [[clang::xray_always_instrument, clang::xray_log_args(N)]] -#else -#define OTABSL_XRAY_LOG_ARGS(N) [[clang::xray_always_instrument]] -#endif -#else -#define OTABSL_XRAY_ALWAYS_INSTRUMENT -#define OTABSL_XRAY_NEVER_INSTRUMENT -#define OTABSL_XRAY_LOG_ARGS(N) -#endif - -// OTABSL_ATTRIBUTE_REINITIALIZES -// -// Indicates that a member function reinitializes the entire object to a known -// state, independent of the previous state of the object. -// -// The clang-tidy check bugprone-use-after-move allows member functions marked -// with this attribute to be called on objects that have been moved from; -// without the attribute, this would result in a use-after-move warning. -#if OTABSL_HAVE_CPP_ATTRIBUTE(clang::reinitializes) -#define OTABSL_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]] -#else -#define OTABSL_ATTRIBUTE_REINITIALIZES -#endif - -// ----------------------------------------------------------------------------- -// Variable Attributes -// ----------------------------------------------------------------------------- - -// OTABSL_ATTRIBUTE_UNUSED -// -// Prevents the compiler from complaining about variables that appear unused. -#if OTABSL_HAVE_ATTRIBUTE(unused) || (defined(__GNUC__) && !defined(__clang__)) -#undef OTABSL_ATTRIBUTE_UNUSED -#define OTABSL_ATTRIBUTE_UNUSED __attribute__((__unused__)) -#else -#define OTABSL_ATTRIBUTE_UNUSED -#endif - -// OTABSL_ATTRIBUTE_INITIAL_EXEC -// -// Tells the compiler to use "initial-exec" mode for a thread-local variable. -// See http://people.redhat.com/drepper/tls.pdf for the gory details. -#if OTABSL_HAVE_ATTRIBUTE(tls_model) || (defined(__GNUC__) && !defined(__clang__)) -#define OTABSL_ATTRIBUTE_INITIAL_EXEC __attribute__((tls_model("initial-exec"))) -#else -#define OTABSL_ATTRIBUTE_INITIAL_EXEC -#endif - -// OTABSL_ATTRIBUTE_PACKED -// -// Instructs the compiler not to use natural alignment for a tagged data -// structure, but instead to reduce its alignment to 1. This attribute can -// either be applied to members of a structure or to a structure in its -// entirety. Applying this attribute (judiciously) to a structure in its -// entirety to optimize the memory footprint of very commonly-used structs is -// fine. Do not apply this attribute to a structure in its entirety if the -// purpose is to control the offsets of the members in the structure. Instead, -// apply this attribute only to structure members that need it. -// -// When applying OTABSL_ATTRIBUTE_PACKED only to specific structure members the -// natural alignment of structure members not annotated is preserved. Aligned -// member accesses are faster than non-aligned member accesses even if the -// targeted microprocessor supports non-aligned accesses. -#if OTABSL_HAVE_ATTRIBUTE(packed) || (defined(__GNUC__) && !defined(__clang__)) -#define OTABSL_ATTRIBUTE_PACKED __attribute__((__packed__)) -#else -#define OTABSL_ATTRIBUTE_PACKED -#endif - -// OTABSL_ATTRIBUTE_FUNC_ALIGN -// -// Tells the compiler to align the function start at least to certain -// alignment boundary -#if OTABSL_HAVE_ATTRIBUTE(aligned) || (defined(__GNUC__) && !defined(__clang__)) -#define OTABSL_ATTRIBUTE_FUNC_ALIGN(bytes) __attribute__((aligned(bytes))) -#else -#define OTABSL_ATTRIBUTE_FUNC_ALIGN(bytes) -#endif - -// OTABSL_CONST_INIT -// -// A variable declaration annotated with the `OTABSL_CONST_INIT` attribute will -// not compile (on supported platforms) unless the variable has a constant -// initializer. This is useful for variables with static and thread storage -// duration, because it guarantees that they will not suffer from the so-called -// "static init order fiasco". Prefer to put this attribute on the most visible -// declaration of the variable, if there's more than one, because code that -// accesses the variable can then use the attribute for optimization. -// -// Example: -// -// class MyClass { -// public: -// OTABSL_CONST_INIT static MyType my_var; -// }; -// -// MyType MyClass::my_var = MakeMyType(...); -// -// Note that this attribute is redundant if the variable is declared constexpr. -#if OTABSL_HAVE_CPP_ATTRIBUTE(clang::require_constant_initialization) -#define OTABSL_CONST_INIT [[clang::require_constant_initialization]] -#else -#define OTABSL_CONST_INIT -#endif // OTABSL_HAVE_CPP_ATTRIBUTE(clang::require_constant_initialization) - -#endif // OTABSL_BASE_ATTRIBUTES_H_ diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/config.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/config.h deleted file mode 100644 index e0836b9b3f..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/config.h +++ /dev/null @@ -1,671 +0,0 @@ -// -// Copyright 2017 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ----------------------------------------------------------------------------- -// File: config.h -// ----------------------------------------------------------------------------- -// -// This header file defines a set of macros for checking the presence of -// important compiler and platform features. Such macros can be used to -// produce portable code by parameterizing compilation based on the presence or -// lack of a given feature. -// -// We define a "feature" as some interface we wish to program to: for example, -// a library function or system call. A value of `1` indicates support for -// that feature; any other value indicates the feature support is undefined. -// -// Example: -// -// Suppose a programmer wants to write a program that uses the 'mmap()' system -// call. The Abseil macro for that feature (`OTABSL_HAVE_MMAP`) allows you to -// selectively include the `mmap.h` header and bracket code using that feature -// in the macro: -// -// #include "absl/base/config.h" -// -// #ifdef OTABSL_HAVE_MMAP -// #include "sys/mman.h" -// #endif //OTABSL_HAVE_MMAP -// -// ... -// #ifdef OTABSL_HAVE_MMAP -// void *ptr = mmap(...); -// ... -// #endif // OTABSL_HAVE_MMAP - -#ifndef OTABSL_BASE_CONFIG_H_ -#define OTABSL_BASE_CONFIG_H_ - -// Included for the __GLIBC__ macro (or similar macros on other systems). -#include - -#ifdef __cplusplus -// Included for __GLIBCXX__, _LIBCPP_VERSION -#include -#endif // __cplusplus - -#if defined(__APPLE__) -// Included for TARGET_OS_IPHONE, __IPHONE_OS_VERSION_MIN_REQUIRED, -// __IPHONE_8_0. -#include -#include -#endif - -#include "options.h" -#include "policy_checks.h" - -// Helper macro to convert a CPP variable to a string literal. -#define OTABSL_INTERNAL_DO_TOKEN_STR(x) #x -#define OTABSL_INTERNAL_TOKEN_STR(x) OTABSL_INTERNAL_DO_TOKEN_STR(x) - -// ----------------------------------------------------------------------------- -// Abseil namespace annotations -// ----------------------------------------------------------------------------- - -// OTABSL_NAMESPACE_BEGIN/OTABSL_NAMESPACE_END -// -// An annotation placed at the beginning/end of each `namespace absl` scope. -// This is used to inject an inline namespace. -// -// The proper way to write Abseil code in the `absl` namespace is: -// -// namespace absl { -// OTABSL_NAMESPACE_BEGIN -// -// void Foo(); // absl::OTABSL_OPTION_NAMESPACE_NAME::Foo(). -// -// OTABSL_NAMESPACE_END -// } // namespace absl -// -// Users of Abseil should not use these macros, because users of Abseil should -// not write `namespace absl {` in their own code for any reason. (Abseil does -// not support forward declarations of its own types, nor does it support -// user-provided specialization of Abseil templates. Code that violates these -// rules may be broken without warning.) -#if !defined(OTABSL_OPTION_NAMESPACE_NAME) -#error options.h is misconfigured. -#endif - -// Check that OTABSL_OPTION_NAMESPACE_NAME is neither "head" nor "" -#if defined(__cplusplus) - -#define OTABSL_INTERNAL_INLINE_NAMESPACE_STR \ - OTABSL_INTERNAL_TOKEN_STR(OTABSL_OPTION_NAMESPACE_NAME) - -static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != '\0', - "options.h misconfigured: OTABSL_OPTION_NAMESPACE_NAME must " - "not be empty."); -static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || - OTABSL_INTERNAL_INLINE_NAMESPACE_STR[1] != 'e' || - OTABSL_INTERNAL_INLINE_NAMESPACE_STR[2] != 'a' || - OTABSL_INTERNAL_INLINE_NAMESPACE_STR[3] != 'd' || - OTABSL_INTERNAL_INLINE_NAMESPACE_STR[4] != '\0', - "options.h misconfigured: OTABSL_OPTION_NAMESPACE_NAME must " - "be changed to a new, unique identifier name."); - -#endif - - -#define OTABSL_NAMESPACE_BEGIN namespace OTABSL_OPTION_NAMESPACE_NAME { -#define OTABSL_NAMESPACE_END } - -// ----------------------------------------------------------------------------- -// Compiler Feature Checks -// ----------------------------------------------------------------------------- - -// OTABSL_HAVE_BUILTIN() -// -// Checks whether the compiler supports a Clang Feature Checking Macro, and if -// so, checks whether it supports the provided builtin function "x" where x -// is one of the functions noted in -// https://clang.llvm.org/docs/LanguageExtensions.html -// -// Note: Use this macro to avoid an extra level of #ifdef __has_builtin check. -// http://releases.llvm.org/3.3/tools/clang/docs/LanguageExtensions.html -#ifdef __has_builtin -#define OTABSL_HAVE_BUILTIN(x) __has_builtin(x) -#else -#define OTABSL_HAVE_BUILTIN(x) 0 -#endif - -#if defined(__is_identifier) -#define OTABSL_INTERNAL_HAS_KEYWORD(x) !(__is_identifier(x)) -#else -#define OTABSL_INTERNAL_HAS_KEYWORD(x) 0 -#endif - -// OTABSL_HAVE_TLS is defined to 1 when __thread should be supported. -// We assume __thread is supported on Linux when compiled with Clang or compiled -// against libstdc++ with _GLIBCXX_HAVE_TLS defined. -#ifdef OTABSL_HAVE_TLS -#error OTABSL_HAVE_TLS cannot be directly set -#elif defined(__linux__) && (defined(__clang__) || defined(_GLIBCXX_HAVE_TLS)) -#define OTABSL_HAVE_TLS 1 -#endif - -// OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE -// -// Checks whether `std::is_trivially_destructible` is supported. -// -// Notes: All supported compilers using libc++ support this feature, as does -// gcc >= 4.8.1 using libstdc++, and Visual Studio. -#ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE -#error OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE cannot be directly set -#elif defined(_LIBCPP_VERSION) || \ - (defined(__clang__) && __clang_major__ >= 15) || \ - (!defined(__clang__) && defined(__GNUC__) && defined(__GLIBCXX__) && \ - (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) || \ - defined(_MSC_VER) -#define OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE 1 -#endif - -// OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE -// -// Checks whether `std::is_trivially_default_constructible` and -// `std::is_trivially_copy_constructible` are supported. - -// OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE -// -// Checks whether `std::is_trivially_copy_assignable` is supported. - -// Notes: Clang with libc++ supports these features, as does gcc >= 5.1 with -// either libc++ or libstdc++, and Visual Studio (but not NVCC). -#if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) -#error OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE cannot be directly set -#elif defined(OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE) -#error OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE cannot directly set -#elif (defined(__clang__) && defined(_LIBCPP_VERSION)) || \ - (defined(__clang__) && __clang_major__ >= 15) || \ - (!defined(__clang__) && defined(__GNUC__) && \ - (__GNUC__ > 7 || (__GNUC__ == 7 && __GNUC_MINOR__ >= 4)) && \ - (defined(_LIBCPP_VERSION) || defined(__GLIBCXX__))) || \ - (defined(_MSC_VER) && !defined(__NVCC__)) -#define OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE 1 -#define OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE 1 -#endif - -// OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE -// -// Checks whether `std::is_trivially_copyable` is supported. -// -// Notes: Clang 15+ with libc++ supports these features, GCC hasn't been tested. -#if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE) -#error OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE cannot be directly set -#elif defined(__clang__) && (__clang_major__ >= 15) -#define OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE 1 -#endif - -// OTABSL_HAVE_SOURCE_LOCATION_CURRENT -// -// Indicates whether `absl::OTABSL_OPTION_NAMESPACE_NAME::SourceLocation::current()` will return useful -// information in some contexts. -#ifndef OTABSL_HAVE_SOURCE_LOCATION_CURRENT -#if OTABSL_INTERNAL_HAS_KEYWORD(__builtin_LINE) && \ - OTABSL_INTERNAL_HAS_KEYWORD(__builtin_FILE) -#define OTABSL_HAVE_SOURCE_LOCATION_CURRENT 1 -#endif -#endif - -// OTABSL_HAVE_THREAD_LOCAL -// -// Checks whether C++11's `thread_local` storage duration specifier is -// supported. -#ifdef OTABSL_HAVE_THREAD_LOCAL -#error OTABSL_HAVE_THREAD_LOCAL cannot be directly set -#elif defined(__APPLE__) -// Notes: -// * Xcode's clang did not support `thread_local` until version 8, and -// even then not for all iOS < 9.0. -// * Xcode 9.3 started disallowing `thread_local` for 32-bit iOS simulator -// targeting iOS 9.x. -// * Xcode 10 moves the deployment target check for iOS < 9.0 to link time -// making __has_feature unreliable there. -// -// Otherwise, `__has_feature` is only supported by Clang so it has be inside -// `defined(__APPLE__)` check. -#if __has_feature(cxx_thread_local) && \ - !(TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0) -#define OTABSL_HAVE_THREAD_LOCAL 1 -#endif -#else // !defined(__APPLE__) -#define OTABSL_HAVE_THREAD_LOCAL 1 -#endif - -// There are platforms for which TLS should not be used even though the compiler -// makes it seem like it's supported (Android NDK < r12b for example). -// This is primarily because of linker problems and toolchain misconfiguration: -// Abseil does not intend to support this indefinitely. Currently, the newest -// toolchain that we intend to support that requires this behavior is the -// r11 NDK - allowing for a 5 year support window on that means this option -// is likely to be removed around June of 2021. -// TLS isn't supported until NDK r12b per -// https://developer.android.com/ndk/downloads/revision_history.html -// Since NDK r16, `__NDK_MAJOR__` and `__NDK_MINOR__` are defined in -// . For NDK < r16, users should define these macros, -// e.g. `-D__NDK_MAJOR__=11 -D__NKD_MINOR__=0` for NDK r11. -#if defined(__ANDROID__) && defined(__clang__) -#if __has_include() -#include -#endif // __has_include() -#if defined(__ANDROID__) && defined(__clang__) && defined(__NDK_MAJOR__) && \ - defined(__NDK_MINOR__) && \ - ((__NDK_MAJOR__ < 12) || ((__NDK_MAJOR__ == 12) && (__NDK_MINOR__ < 1))) -#undef OTABSL_HAVE_TLS -#undef OTABSL_HAVE_THREAD_LOCAL -#endif -#endif // defined(__ANDROID__) && defined(__clang__) - -// Emscripten doesn't yet support `thread_local` or `__thread`. -// https://github.com/emscripten-core/emscripten/issues/3502 -#if defined(__EMSCRIPTEN__) -#undef OTABSL_HAVE_TLS -#undef OTABSL_HAVE_THREAD_LOCAL -#endif // defined(__EMSCRIPTEN__) - -// OTABSL_HAVE_INTRINSIC_INT128 -// -// Checks whether the __int128 compiler extension for a 128-bit integral type is -// supported. -// -// Note: __SIZEOF_INT128__ is defined by Clang and GCC when __int128 is -// supported, but we avoid using it in certain cases: -// * On Clang: -// * Building using Clang for Windows, where the Clang runtime library has -// 128-bit support only on LP64 architectures, but Windows is LLP64. -// * On Nvidia's nvcc: -// * nvcc also defines __GNUC__ and __SIZEOF_INT128__, but not all versions -// actually support __int128. -#ifdef OTABSL_HAVE_INTRINSIC_INT128 -#error OTABSL_HAVE_INTRINSIC_INT128 cannot be directly set -#elif defined(__SIZEOF_INT128__) -#if (defined(__clang__) && !defined(_WIN32)) || \ - (defined(__CUDACC__) && __CUDACC_VER_MAJOR__ >= 9) || \ - (defined(__GNUC__) && !defined(__clang__) && !defined(__CUDACC__)) -#define OTABSL_HAVE_INTRINSIC_INT128 1 -#elif defined(__CUDACC__) -// __CUDACC_VER__ is a full version number before CUDA 9, and is defined to a -// string explaining that it has been removed starting with CUDA 9. We use -// nested #ifs because there is no short-circuiting in the preprocessor. -// NOTE: `__CUDACC__` could be undefined while `__CUDACC_VER__` is defined. -#if __CUDACC_VER__ >= 70000 -#define OTABSL_HAVE_INTRINSIC_INT128 1 -#endif // __CUDACC_VER__ >= 70000 -#endif // defined(__CUDACC__) -#endif // OTABSL_HAVE_INTRINSIC_INT128 - -// OTABSL_HAVE_EXCEPTIONS -// -// Checks whether the compiler both supports and enables exceptions. Many -// compilers support a "no exceptions" mode that disables exceptions. -// -// Generally, when OTABSL_HAVE_EXCEPTIONS is not defined: -// -// * Code using `throw` and `try` may not compile. -// * The `noexcept` specifier will still compile and behave as normal. -// * The `noexcept` operator may still return `false`. -// -// For further details, consult the compiler's documentation. -#ifdef OTABSL_HAVE_EXCEPTIONS -#error OTABSL_HAVE_EXCEPTIONS cannot be directly set. - -#elif defined(__clang__) - -#if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 6) -// Clang >= 3.6 -#if __has_feature(cxx_exceptions) -#define OTABSL_HAVE_EXCEPTIONS 1 -#endif // __has_feature(cxx_exceptions) -#else -// Clang < 3.6 -// http://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html#the-exceptions-macro -#if defined(__EXCEPTIONS) && __has_feature(cxx_exceptions) -#define OTABSL_HAVE_EXCEPTIONS 1 -#endif // defined(__EXCEPTIONS) && __has_feature(cxx_exceptions) -#endif // __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 6) - -// Handle remaining special cases and default to exceptions being supported. -#elif !(defined(__GNUC__) && (__GNUC__ < 5) && !defined(__EXCEPTIONS)) && \ - !(defined(__GNUC__) && (__GNUC__ >= 5) && !defined(__cpp_exceptions)) && \ - !(defined(_MSC_VER) && !defined(_CPPUNWIND)) -#define OTABSL_HAVE_EXCEPTIONS 1 -#endif - -// ----------------------------------------------------------------------------- -// Platform Feature Checks -// ----------------------------------------------------------------------------- - -// Currently supported operating systems and associated preprocessor -// symbols: -// -// Linux and Linux-derived __linux__ -// Android __ANDROID__ (implies __linux__) -// Linux (non-Android) __linux__ && !__ANDROID__ -// Darwin (macOS and iOS) __APPLE__ -// Akaros (http://akaros.org) __ros__ -// Windows _WIN32 -// NaCL __native_client__ -// AsmJS __asmjs__ -// WebAssembly __wasm__ -// Fuchsia __Fuchsia__ -// -// Note that since Android defines both __ANDROID__ and __linux__, one -// may probe for either Linux or Android by simply testing for __linux__. - -// OTABSL_HAVE_MMAP -// -// Checks whether the platform has an mmap(2) implementation as defined in -// POSIX.1-2001. -#ifdef OTABSL_HAVE_MMAP -#error OTABSL_HAVE_MMAP cannot be directly set -#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ - defined(__ros__) || defined(__native_client__) || defined(__asmjs__) || \ - defined(__wasm__) || defined(__Fuchsia__) || defined(__sun) || \ - defined(__ASYLO__) -#define OTABSL_HAVE_MMAP 1 -#endif - -// OTABSL_HAVE_PTHREAD_GETSCHEDPARAM -// -// Checks whether the platform implements the pthread_(get|set)schedparam(3) -// functions as defined in POSIX.1-2001. -#ifdef OTABSL_HAVE_PTHREAD_GETSCHEDPARAM -#error OTABSL_HAVE_PTHREAD_GETSCHEDPARAM cannot be directly set -#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ - defined(__ros__) -#define OTABSL_HAVE_PTHREAD_GETSCHEDPARAM 1 -#endif - -// OTABSL_HAVE_SCHED_YIELD -// -// Checks whether the platform implements sched_yield(2) as defined in -// POSIX.1-2001. -#ifdef OTABSL_HAVE_SCHED_YIELD -#error OTABSL_HAVE_SCHED_YIELD cannot be directly set -#elif defined(__linux__) || defined(__ros__) || defined(__native_client__) -#define OTABSL_HAVE_SCHED_YIELD 1 -#endif - -// OTABSL_HAVE_SEMAPHORE_H -// -// Checks whether the platform supports the header and sem_init(3) -// family of functions as standardized in POSIX.1-2001. -// -// Note: While Apple provides for both iOS and macOS, it is -// explicitly deprecated and will cause build failures if enabled for those -// platforms. We side-step the issue by not defining it here for Apple -// platforms. -#ifdef OTABSL_HAVE_SEMAPHORE_H -#error OTABSL_HAVE_SEMAPHORE_H cannot be directly set -#elif defined(__linux__) || defined(__ros__) -#define OTABSL_HAVE_SEMAPHORE_H 1 -#endif - -// OTABSL_HAVE_ALARM -// -// Checks whether the platform supports the header and alarm(2) -// function as standardized in POSIX.1-2001. -#ifdef OTABSL_HAVE_ALARM -#error OTABSL_HAVE_ALARM cannot be directly set -#elif defined(__GOOGLE_GRTE_VERSION__) -// feature tests for Google's GRTE -#define OTABSL_HAVE_ALARM 1 -#elif defined(__GLIBC__) -// feature test for glibc -#define OTABSL_HAVE_ALARM 1 -#elif defined(_MSC_VER) -// feature tests for Microsoft's library -#elif defined(__MINGW32__) -// mingw32 doesn't provide alarm(2): -// https://osdn.net/projects/mingw/scm/git/mingw-org-wsl/blobs/5.2-trunk/mingwrt/include/unistd.h -// mingw-w64 provides a no-op implementation: -// https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-crt/misc/alarm.c -#elif defined(__EMSCRIPTEN__) -// emscripten doesn't support signals -#elif defined(__Fuchsia__) -// Signals don't exist on fuchsia. -#elif defined(__native_client__) -#else -// other standard libraries -#define OTABSL_HAVE_ALARM 1 -#endif - -// OTABSL_IS_LITTLE_ENDIAN -// OTABSL_IS_BIG_ENDIAN -// -// Checks the endianness of the platform. -// -// Notes: uses the built in endian macros provided by GCC (since 4.6) and -// Clang (since 3.2); see -// https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html. -// Otherwise, if _WIN32, assume little endian. Otherwise, bail with an error. -#if defined(OTABSL_IS_BIG_ENDIAN) -#error "OTABSL_IS_BIG_ENDIAN cannot be directly set." -#endif -#if defined(OTABSL_IS_LITTLE_ENDIAN) -#error "OTABSL_IS_LITTLE_ENDIAN cannot be directly set." -#endif - -#if (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \ - __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) -#define OTABSL_IS_LITTLE_ENDIAN 1 -#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \ - __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -#define OTABSL_IS_BIG_ENDIAN 1 -#elif defined(_WIN32) -#define OTABSL_IS_LITTLE_ENDIAN 1 -#else -#error "absl endian detection needs to be set up for your compiler" -#endif - -// macOS 10.13 and iOS 10.11 don't let you use , , or -// even though the headers exist and are publicly noted to work. See -// https://github.com/abseil/abseil-cpp/issues/207 and -// https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes -// libc++ spells out the availability requirements in the file -// llvm-project/libcxx/include/__config via the #define -// _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS. -#if defined(__APPLE__) && defined(_LIBCPP_VERSION) && \ - ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ - __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101400) || \ - (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \ - __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 120000) || \ - (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \ - __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 120000) || \ - (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && \ - __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 50000)) -#define OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 1 -#else -#define OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 0 -#endif - -// OTABSL_HAVE_STD_ANY -// -// Checks whether C++17 std::any is available by checking whether exists. -#ifdef OTABSL_HAVE_STD_ANY -#error "OTABSL_HAVE_STD_ANY cannot be directly set." -#endif - -#ifdef __has_include -#if __has_include() && __cplusplus >= 201703L && \ - !OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE -#define OTABSL_HAVE_STD_ANY 1 -#endif -#endif - -// OTABSL_HAVE_STD_OPTIONAL -// -// Checks whether C++17 std::optional is available. -#ifdef OTABSL_HAVE_STD_OPTIONAL -#error "OTABSL_HAVE_STD_OPTIONAL cannot be directly set." -#endif - -#ifdef __has_include -#if __has_include() && __cplusplus >= 201703L && \ - !OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE -#define OTABSL_HAVE_STD_OPTIONAL 1 -#endif -#endif - -// OTABSL_HAVE_STD_VARIANT -// -// Checks whether C++17 std::variant is available. -#ifdef OTABSL_HAVE_STD_VARIANT -#error "OTABSL_HAVE_STD_VARIANT cannot be directly set." -#endif - -#ifdef __has_include -#if __has_include() && __cplusplus >= 201703L && \ - !OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE -#define OTABSL_HAVE_STD_VARIANT 1 -#endif -#endif - -// OTABSL_HAVE_STD_STRING_VIEW -// -// Checks whether C++17 std::string_view is available. -#ifdef OTABSL_HAVE_STD_STRING_VIEW -#error "OTABSL_HAVE_STD_STRING_VIEW cannot be directly set." -#endif - -#ifdef __has_include -#if __has_include() && __cplusplus >= 201703L -#define OTABSL_HAVE_STD_STRING_VIEW 1 -#endif -#endif - -// For MSVC, `__has_include` is supported in VS 2017 15.3, which is later than -// the support for , , , . So we use -// _MSC_VER to check whether we have VS 2017 RTM (when , , -// , is implemented) or higher. Also, `__cplusplus` is -// not correctly set by MSVC, so we use `_MSVC_LANG` to check the language -// version. -// TODO(zhangxy): fix tests before enabling aliasing for `std::any`. -#if defined(_MSC_VER) && _MSC_VER >= 1910 && \ - ((defined(_MSVC_LANG) && _MSVC_LANG > 201402) || __cplusplus > 201402) -// #define OTABSL_HAVE_STD_ANY 1 -#define OTABSL_HAVE_STD_OPTIONAL 1 -#define OTABSL_HAVE_STD_VARIANT 1 -#define OTABSL_HAVE_STD_STRING_VIEW 1 -#endif - -// OTABSL_USES_STD_ANY -// -// Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::any is an alias for std::any. -#if !defined(OTABSL_OPTION_USE_STD_ANY) -#error options.h is misconfigured. -#elif OTABSL_OPTION_USE_STD_ANY == 0 || \ - (OTABSL_OPTION_USE_STD_ANY == 2 && !defined(OTABSL_HAVE_STD_ANY)) -#undef OTABSL_USES_STD_ANY -#elif OTABSL_OPTION_USE_STD_ANY == 1 || \ - (OTABSL_OPTION_USE_STD_ANY == 2 && defined(OTABSL_HAVE_STD_ANY)) -#define OTABSL_USES_STD_ANY 1 -#else -#error options.h is misconfigured. -#endif - -// OTABSL_USES_STD_OPTIONAL -// -// Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::optional is an alias for std::optional. -#if !defined(OTABSL_OPTION_USE_STD_OPTIONAL) -#error options.h is misconfigured. -#elif OTABSL_OPTION_USE_STD_OPTIONAL == 0 || \ - (OTABSL_OPTION_USE_STD_OPTIONAL == 2 && !defined(OTABSL_HAVE_STD_OPTIONAL)) -#undef OTABSL_USES_STD_OPTIONAL -#elif OTABSL_OPTION_USE_STD_OPTIONAL == 1 || \ - (OTABSL_OPTION_USE_STD_OPTIONAL == 2 && defined(OTABSL_HAVE_STD_OPTIONAL)) -#define OTABSL_USES_STD_OPTIONAL 1 -#else -#error options.h is misconfigured. -#endif - -// OTABSL_USES_STD_VARIANT -// -// Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::variant is an alias for std::variant. -#if !defined(OTABSL_OPTION_USE_STD_VARIANT) -#error options.h is misconfigured. -#elif OTABSL_OPTION_USE_STD_VARIANT == 0 || \ - (OTABSL_OPTION_USE_STD_VARIANT == 2 && !defined(OTABSL_HAVE_STD_VARIANT)) -#undef OTABSL_USES_STD_VARIANT -#elif OTABSL_OPTION_USE_STD_VARIANT == 1 || \ - (OTABSL_OPTION_USE_STD_VARIANT == 2 && defined(OTABSL_HAVE_STD_VARIANT)) -#define OTABSL_USES_STD_VARIANT 1 -#else -#error options.h is misconfigured. -#endif - -// OTABSL_USES_STD_STRING_VIEW -// -// Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::string_view is an alias for std::string_view. -#if !defined(OTABSL_OPTION_USE_STD_STRING_VIEW) -#error options.h is misconfigured. -#elif OTABSL_OPTION_USE_STD_STRING_VIEW == 0 || \ - (OTABSL_OPTION_USE_STD_STRING_VIEW == 2 && \ - !defined(OTABSL_HAVE_STD_STRING_VIEW)) -#undef OTABSL_USES_STD_STRING_VIEW -#elif OTABSL_OPTION_USE_STD_STRING_VIEW == 1 || \ - (OTABSL_OPTION_USE_STD_STRING_VIEW == 2 && \ - defined(OTABSL_HAVE_STD_STRING_VIEW)) -#define OTABSL_USES_STD_STRING_VIEW 1 -#else -#error options.h is misconfigured. -#endif - -// In debug mode, MSVC 2017's std::variant throws a EXCEPTION_ACCESS_VIOLATION -// SEH exception from emplace for variant when constructing the -// struct can throw. This defeats some of variant_test and -// variant_exception_safety_test. -#if defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_DEBUG) -#define OTABSL_INTERNAL_MSVC_2017_DBG_MODE -#endif - -// OTABSL_INTERNAL_MANGLED_NS -// OTABSL_INTERNAL_MANGLED_BACKREFERENCE -// -// Internal macros for building up mangled names in our internal fork of CCTZ. -// This implementation detail is only needed and provided for the MSVC build. -// -// These macros both expand to string literals. OTABSL_INTERNAL_MANGLED_NS is -// the mangled spelling of the `absl` namespace, and -// OTABSL_INTERNAL_MANGLED_BACKREFERENCE is a back-reference integer representing -// the proper count to skip past the CCTZ fork namespace names. (This number -// is one larger when there is an inline namespace name to skip.) -#if defined(_MSC_VER) -#define OTABSL_INTERNAL_MANGLED_NS \ - OTABSL_INTERNAL_TOKEN_STR(OTABSL_OPTION_NAMESPACE_NAME) "@absl" -#define OTABSL_INTERNAL_MANGLED_BACKREFERENCE "6" -#endif - -#undef OTABSL_INTERNAL_HAS_KEYWORD - -// OTABSL_DLL -// -// When building Abseil as a DLL, this macro expands to `__declspec(dllexport)` -// so we can annotate symbols appropriately as being exported. When used in -// headers consuming a DLL, this macro expands to `__declspec(dllimport)` so -// that consumers know the symbol is defined inside the DLL. In all other cases, -// the macro expands to nothing. -#if defined(_MSC_VER) -#if defined(OTABSL_BUILD_DLL) -#define OTABSL_DLL __declspec(dllexport) -#elif 1 -#define OTABSL_DLL __declspec(dllimport) -#else -#define OTABSL_DLL -#endif -#else -#define OTABSL_DLL -#endif // defined(_MSC_VER) - -#endif // OTABSL_BASE_CONFIG_H_ diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/internal/identity.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/internal/identity.h deleted file mode 100644 index 4afba31796..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/internal/identity.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2017 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#ifndef OTABSL_BASE_INTERNAL_IDENTITY_H_ -#define OTABSL_BASE_INTERNAL_IDENTITY_H_ - -#include "../config.h" - -namespace absl { -OTABSL_NAMESPACE_BEGIN -namespace internal { - -template -struct identity { - typedef T type; -}; - -template -using identity_t = typename identity::type; - -} // namespace internal -OTABSL_NAMESPACE_END -} // namespace absl - -#endif // OTABSL_BASE_INTERNAL_IDENTITY_H_ diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/internal/inline_variable.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/internal/inline_variable.h deleted file mode 100644 index dd66e9f223..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/internal/inline_variable.h +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2017 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef OTABSL_BASE_INTERNAL_INLINE_VARIABLE_EMULATION_H_ -#define OTABSL_BASE_INTERNAL_INLINE_VARIABLE_EMULATION_H_ - -#include - -#include "identity.h" - -// File: -// This file define a macro that allows the creation of or emulation of C++17 -// inline variables based on whether or not the feature is supported. - -//////////////////////////////////////////////////////////////////////////////// -// Macro: OTABSL_INTERNAL_INLINE_CONSTEXPR(type, name, init) -// -// Description: -// Expands to the equivalent of an inline constexpr instance of the specified -// `type` and `name`, initialized to the value `init`. If the compiler being -// used is detected as supporting actual inline variables as a language -// feature, then the macro expands to an actual inline variable definition. -// -// Requires: -// `type` is a type that is usable in an extern variable declaration. -// -// Requires: `name` is a valid identifier -// -// Requires: -// `init` is an expression that can be used in the following definition: -// constexpr type name = init; -// -// Usage: -// -// // Equivalent to: `inline constexpr size_t variant_npos = -1;` -// OTABSL_INTERNAL_INLINE_CONSTEXPR(size_t, variant_npos, -1); -// -// Differences in implementation: -// For a direct, language-level inline variable, decltype(name) will be the -// type that was specified along with const qualification, whereas for -// emulated inline variables, decltype(name) may be different (in practice -// it will likely be a reference type). -//////////////////////////////////////////////////////////////////////////////// - -#ifdef __cpp_inline_variables - -// Clang's -Wmissing-variable-declarations option erroneously warned that -// inline constexpr objects need to be pre-declared. This has now been fixed, -// but we will need to support this workaround for people building with older -// versions of clang. -// -// Bug: https://bugs.llvm.org/show_bug.cgi?id=35862 -// -// Note: -// identity_t is used here so that the const and name are in the -// appropriate place for pointer types, reference types, function pointer -// types, etc.. -#if defined(__clang__) -#define OTABSL_INTERNAL_EXTERN_DECL(type, name) \ - extern const ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t name; -#else // Otherwise, just define the macro to do nothing. -#define OTABSL_INTERNAL_EXTERN_DECL(type, name) -#endif // defined(__clang__) - -// See above comment at top of file for details. -#define OTABSL_INTERNAL_INLINE_CONSTEXPR(type, name, init) \ - OTABSL_INTERNAL_EXTERN_DECL(type, name) \ - inline constexpr ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t name = init - -#else - -// See above comment at top of file for details. -// -// Note: -// identity_t is used here so that the const and name are in the -// appropriate place for pointer types, reference types, function pointer -// types, etc.. -#define OTABSL_INTERNAL_INLINE_CONSTEXPR(var_type, name, init) \ - template \ - struct AbslInternalInlineVariableHolder##name { \ - static constexpr ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t kInstance = init; \ - }; \ - \ - template \ - constexpr ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t \ - AbslInternalInlineVariableHolder##name::kInstance; \ - \ - static constexpr const ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t& \ - name = /* NOLINT */ \ - AbslInternalInlineVariableHolder##name<>::kInstance; \ - static_assert(sizeof(void (*)(decltype(name))) != 0, \ - "Silence unused variable warnings.") - -#endif // __cpp_inline_variables - -#endif // OTABSL_BASE_INTERNAL_INLINE_VARIABLE_EMULATION_H_ diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/internal/invoke.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/internal/invoke.h deleted file mode 100644 index c37f43cfc8..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/internal/invoke.h +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright 2017 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::Invoke(f, args...) is an implementation of -// INVOKE(f, args...) from section [func.require] of the C++ standard. -// -// [func.require] -// Define INVOKE (f, t1, t2, ..., tN) as follows: -// 1. (t1.*f)(t2, ..., tN) when f is a pointer to a member function of a class T -// and t1 is an object of type T or a reference to an object of type T or a -// reference to an object of a type derived from T; -// 2. ((*t1).*f)(t2, ..., tN) when f is a pointer to a member function of a -// class T and t1 is not one of the types described in the previous item; -// 3. t1.*f when N == 1 and f is a pointer to member data of a class T and t1 is -// an object of type T or a reference to an object of type T or a reference -// to an object of a type derived from T; -// 4. (*t1).*f when N == 1 and f is a pointer to member data of a class T and t1 -// is not one of the types described in the previous item; -// 5. f(t1, t2, ..., tN) in all other cases. -// -// The implementation is SFINAE-friendly: substitution failure within Invoke() -// isn't an error. - -#ifndef OTABSL_BASE_INTERNAL_INVOKE_H_ -#define OTABSL_BASE_INTERNAL_INVOKE_H_ - -#include -#include -#include - -#include "../../meta/type_traits.h" - -// The following code is internal implementation detail. See the comment at the -// top of this file for the API documentation. - -namespace absl { -OTABSL_NAMESPACE_BEGIN -namespace base_internal { - -// The five classes below each implement one of the clauses from the definition -// of INVOKE. The inner class template Accept checks whether the -// clause is applicable; static function template Invoke(f, args...) does the -// invocation. -// -// By separating the clause selection logic from invocation we make sure that -// Invoke() does exactly what the standard says. - -template -struct StrippedAccept { - template - struct Accept : Derived::template AcceptImpl::type>::type...> {}; -}; - -// (t1.*f)(t2, ..., tN) when f is a pointer to a member function of a class T -// and t1 is an object of type T or a reference to an object of type T or a -// reference to an object of a type derived from T. -struct MemFunAndRef : StrippedAccept { - template - struct AcceptImpl : std::false_type {}; - - template - struct AcceptImpl - : std::integral_constant::value && - absl::OTABSL_OPTION_NAMESPACE_NAME::is_function::value> { - }; - - template - static decltype((std::declval().* - std::declval())(std::declval()...)) - Invoke(MemFun&& mem_fun, Obj&& obj, Args&&... args) { - return (std::forward(obj).* - std::forward(mem_fun))(std::forward(args)...); - } -}; - -// ((*t1).*f)(t2, ..., tN) when f is a pointer to a member function of a -// class T and t1 is not one of the types described in the previous item. -struct MemFunAndPtr : StrippedAccept { - template - struct AcceptImpl : std::false_type {}; - - template - struct AcceptImpl - : std::integral_constant::value && - absl::OTABSL_OPTION_NAMESPACE_NAME::is_function::value> { - }; - - template - static decltype(((*std::declval()).* - std::declval())(std::declval()...)) - Invoke(MemFun&& mem_fun, Ptr&& ptr, Args&&... args) { - return ((*std::forward(ptr)).* - std::forward(mem_fun))(std::forward(args)...); - } -}; - -// t1.*f when N == 1 and f is a pointer to member data of a class T and t1 is -// an object of type T or a reference to an object of type T or a reference -// to an object of a type derived from T. -struct DataMemAndRef : StrippedAccept { - template - struct AcceptImpl : std::false_type {}; - - template - struct AcceptImpl - : std::integral_constant::value && - !absl::OTABSL_OPTION_NAMESPACE_NAME::is_function::value> {}; - - template - static decltype(std::declval().*std::declval()) Invoke( - DataMem&& data_mem, Ref&& ref) { - return std::forward(ref).*std::forward(data_mem); - } -}; - -// (*t1).*f when N == 1 and f is a pointer to member data of a class T and t1 -// is not one of the types described in the previous item. -struct DataMemAndPtr : StrippedAccept { - template - struct AcceptImpl : std::false_type {}; - - template - struct AcceptImpl - : std::integral_constant::value && - !absl::OTABSL_OPTION_NAMESPACE_NAME::is_function::value> {}; - - template - static decltype((*std::declval()).*std::declval()) Invoke( - DataMem&& data_mem, Ptr&& ptr) { - return (*std::forward(ptr)).*std::forward(data_mem); - } -}; - -// f(t1, t2, ..., tN) in all other cases. -struct Callable { - // Callable doesn't have Accept because it's the last clause that gets picked - // when none of the previous clauses are applicable. - template - static decltype(std::declval()(std::declval()...)) Invoke( - F&& f, Args&&... args) { - return std::forward(f)(std::forward(args)...); - } -}; - -// Resolves to the first matching clause. -template -struct Invoker { - typedef typename std::conditional< - MemFunAndRef::Accept::value, MemFunAndRef, - typename std::conditional< - MemFunAndPtr::Accept::value, MemFunAndPtr, - typename std::conditional< - DataMemAndRef::Accept::value, DataMemAndRef, - typename std::conditional::value, - DataMemAndPtr, Callable>::type>::type>:: - type>::type type; -}; - -// The result type of Invoke. -template -using InvokeT = decltype(Invoker::type::Invoke( - std::declval(), std::declval()...)); - -// Invoke(f, args...) is an implementation of INVOKE(f, args...) from section -// [func.require] of the C++ standard. -template -InvokeT Invoke(F&& f, Args&&... args) { - return Invoker::type::Invoke(std::forward(f), - std::forward(args)...); -} - -} // namespace base_internal -OTABSL_NAMESPACE_END -} // namespace absl - -#endif // OTABSL_BASE_INTERNAL_INVOKE_H_ diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/macros.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/macros.h deleted file mode 100644 index 707c375ed1..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/macros.h +++ /dev/null @@ -1,220 +0,0 @@ -// -// Copyright 2017 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ----------------------------------------------------------------------------- -// File: macros.h -// ----------------------------------------------------------------------------- -// -// This header file defines the set of language macros used within Abseil code. -// For the set of macros used to determine supported compilers and platforms, -// see absl/base/config.h instead. -// -// This code is compiled directly on many platforms, including client -// platforms like Windows, Mac, and embedded systems. Before making -// any changes here, make sure that you're not breaking any platforms. - -#ifndef OTABSL_BASE_MACROS_H_ -#define OTABSL_BASE_MACROS_H_ - -#include -#include - -#include "attributes.h" -#include "optimization.h" -#include "port.h" - -// OTABSL_ARRAYSIZE() -// -// Returns the number of elements in an array as a compile-time constant, which -// can be used in defining new arrays. If you use this macro on a pointer by -// mistake, you will get a compile-time error. -#define OTABSL_ARRAYSIZE(array) \ - (sizeof(::absl::OTABSL_OPTION_NAMESPACE_NAME::macros_internal::ArraySizeHelper(array))) - -namespace absl { -OTABSL_NAMESPACE_BEGIN -namespace macros_internal { -// Note: this internal template function declaration is used by OTABSL_ARRAYSIZE. -// The function doesn't need a definition, as we only use its type. -template -auto ArraySizeHelper(const T (&array)[N]) -> char (&)[N]; -} // namespace macros_internal -OTABSL_NAMESPACE_END -} // namespace absl - -// kLinkerInitialized -// -// An enum used only as a constructor argument to indicate that a variable has -// static storage duration, and that the constructor should do nothing to its -// state. Use of this macro indicates to the reader that it is legal to -// declare a static instance of the class, provided the constructor is given -// the absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::kLinkerInitialized argument. -// -// Normally, it is unsafe to declare a static variable that has a constructor or -// a destructor because invocation order is undefined. However, if the type can -// be zero-initialized (which the loader does for static variables) into a valid -// state and the type's destructor does not affect storage, then a constructor -// for static initialization can be declared. -// -// Example: -// // Declaration -// explicit MyClass(absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal:LinkerInitialized x) {} -// -// // Invocation -// static MyClass my_global(absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::kLinkerInitialized); -namespace absl { -OTABSL_NAMESPACE_BEGIN -namespace base_internal { -enum LinkerInitialized { - kLinkerInitialized = 0, -}; -} // namespace base_internal -OTABSL_NAMESPACE_END -} // namespace absl - -// OTABSL_FALLTHROUGH_INTENDED -// -// Annotates implicit fall-through between switch labels, allowing a case to -// indicate intentional fallthrough and turn off warnings about any lack of a -// `break` statement. The OTABSL_FALLTHROUGH_INTENDED macro should be followed by -// a semicolon and can be used in most places where `break` can, provided that -// no statements exist between it and the next switch label. -// -// Example: -// -// switch (x) { -// case 40: -// case 41: -// if (truth_is_out_there) { -// ++x; -// OTABSL_FALLTHROUGH_INTENDED; // Use instead of/along with annotations -// // in comments -// } else { -// return x; -// } -// case 42: -// ... -// -// Notes: when compiled with clang in C++11 mode, the OTABSL_FALLTHROUGH_INTENDED -// macro is expanded to the [[clang::fallthrough]] attribute, which is analysed -// when performing switch labels fall-through diagnostic -// (`-Wimplicit-fallthrough`). See clang documentation on language extensions -// for details: -// https://clang.llvm.org/docs/AttributeReference.html#fallthrough-clang-fallthrough -// -// When used with unsupported compilers, the OTABSL_FALLTHROUGH_INTENDED macro -// has no effect on diagnostics. In any case this macro has no effect on runtime -// behavior and performance of code. -#ifdef OTABSL_FALLTHROUGH_INTENDED -#error "OTABSL_FALLTHROUGH_INTENDED should not be defined." -#endif - -// TODO(zhangxy): Use c++17 standard [[fallthrough]] macro, when supported. -#if defined(__clang__) && defined(__has_warning) -#if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough") -#define OTABSL_FALLTHROUGH_INTENDED [[clang::fallthrough]] -#endif -#elif defined(__GNUC__) && __GNUC__ >= 7 -#define OTABSL_FALLTHROUGH_INTENDED [[gnu::fallthrough]] -#endif - -#ifndef OTABSL_FALLTHROUGH_INTENDED -#define OTABSL_FALLTHROUGH_INTENDED \ - do { \ - } while (0) -#endif - -// OTABSL_DEPRECATED() -// -// Marks a deprecated class, struct, enum, function, method and variable -// declarations. The macro argument is used as a custom diagnostic message (e.g. -// suggestion of a better alternative). -// -// Examples: -// -// class OTABSL_DEPRECATED("Use Bar instead") Foo {...}; -// -// OTABSL_DEPRECATED("Use Baz() instead") void Bar() {...} -// -// template -// OTABSL_DEPRECATED("Use DoThat() instead") -// void DoThis(); -// -// Every usage of a deprecated entity will trigger a warning when compiled with -// clang's `-Wdeprecated-declarations` option. This option is turned off by -// default, but the warnings will be reported by clang-tidy. -#if defined(__clang__) && __cplusplus >= 201103L -#define OTABSL_DEPRECATED(message) __attribute__((deprecated(message))) -#endif - -#ifndef OTABSL_DEPRECATED -#define OTABSL_DEPRECATED(message) -#endif - -// OTABSL_BAD_CALL_IF() -// -// Used on a function overload to trap bad calls: any call that matches the -// overload will cause a compile-time error. This macro uses a clang-specific -// "enable_if" attribute, as described at -// https://clang.llvm.org/docs/AttributeReference.html#enable-if -// -// Overloads which use this macro should be bracketed by -// `#ifdef OTABSL_BAD_CALL_IF`. -// -// Example: -// -// int isdigit(int c); -// #ifdef OTABSL_BAD_CALL_IF -// int isdigit(int c) -// OTABSL_BAD_CALL_IF(c <= -1 || c > 255, -// "'c' must have the value of an unsigned char or EOF"); -// #endif // OTABSL_BAD_CALL_IF -#if OTABSL_HAVE_ATTRIBUTE(enable_if) -#define OTABSL_BAD_CALL_IF(expr, msg) \ - __attribute__((enable_if(expr, "Bad call trap"), unavailable(msg))) -#endif - -// OTABSL_ASSERT() -// -// In C++11, `assert` can't be used portably within constexpr functions. -// OTABSL_ASSERT functions as a runtime assert but works in C++11 constexpr -// functions. Example: -// -// constexpr double Divide(double a, double b) { -// return OTABSL_ASSERT(b != 0), a / b; -// } -// -// This macro is inspired by -// https://akrzemi1.wordpress.com/2017/05/18/asserts-in-constexpr-functions/ -#if defined(NDEBUG) -#define OTABSL_ASSERT(expr) \ - (false ? static_cast(expr) : static_cast(0)) -#else -#define OTABSL_ASSERT(expr) \ - (OTABSL_PREDICT_TRUE((expr)) ? static_cast(0) \ - : [] { assert(false && #expr); }()) // NOLINT -#endif - -#ifdef OTABSL_HAVE_EXCEPTIONS -#define OTABSL_INTERNAL_TRY try -#define OTABSL_INTERNAL_CATCH_ANY catch (...) -#define OTABSL_INTERNAL_RETHROW do { throw; } while (false) -#else // OTABSL_HAVE_EXCEPTIONS -#define OTABSL_INTERNAL_TRY if (true) -#define OTABSL_INTERNAL_CATCH_ANY else if (false) -#define OTABSL_INTERNAL_RETHROW do {} while (false) -#endif // OTABSL_HAVE_EXCEPTIONS - -#endif // OTABSL_BASE_MACROS_H_ diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/optimization.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/optimization.h deleted file mode 100644 index 69713654a6..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/optimization.h +++ /dev/null @@ -1,181 +0,0 @@ -// -// Copyright 2017 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ----------------------------------------------------------------------------- -// File: optimization.h -// ----------------------------------------------------------------------------- -// -// This header file defines portable macros for performance optimization. - -#ifndef OTABSL_BASE_OPTIMIZATION_H_ -#define OTABSL_BASE_OPTIMIZATION_H_ - -#include "config.h" - -// OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION -// -// Instructs the compiler to avoid optimizing tail-call recursion. Use of this -// macro is useful when you wish to preserve the existing function order within -// a stack trace for logging, debugging, or profiling purposes. -// -// Example: -// -// int f() { -// int result = g(); -// OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION(); -// return result; -// } -#if defined(__pnacl__) -#define OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION() if (volatile int x = 0) { (void)x; } -#elif defined(__clang__) -// Clang will not tail call given inline volatile assembly. -#define OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION() __asm__ __volatile__("") -#elif defined(__GNUC__) -// GCC will not tail call given inline volatile assembly. -#define OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION() __asm__ __volatile__("") -#elif defined(_MSC_VER) -#include -// The __nop() intrinsic blocks the optimisation. -#define OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION() __nop() -#else -#define OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION() if (volatile int x = 0) { (void)x; } -#endif - -// OTABSL_CACHELINE_SIZE -// -// Explicitly defines the size of the L1 cache for purposes of alignment. -// Setting the cacheline size allows you to specify that certain objects be -// aligned on a cacheline boundary with `OTABSL_CACHELINE_ALIGNED` declarations. -// (See below.) -// -// NOTE: this macro should be replaced with the following C++17 features, when -// those are generally available: -// -// * `std::hardware_constructive_interference_size` -// * `std::hardware_destructive_interference_size` -// -// See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0154r1.html -// for more information. -#if defined(__GNUC__) -// Cache line alignment -#if defined(__i386__) || defined(__x86_64__) -#define OTABSL_CACHELINE_SIZE 64 -#elif defined(__powerpc64__) -#define OTABSL_CACHELINE_SIZE 128 -#elif defined(__aarch64__) -// We would need to read special register ctr_el0 to find out L1 dcache size. -// This value is a good estimate based on a real aarch64 machine. -#define OTABSL_CACHELINE_SIZE 64 -#elif defined(__arm__) -// Cache line sizes for ARM: These values are not strictly correct since -// cache line sizes depend on implementations, not architectures. There -// are even implementations with cache line sizes configurable at boot -// time. -#if defined(__ARM_ARCH_5T__) -#define OTABSL_CACHELINE_SIZE 32 -#elif defined(__ARM_ARCH_7A__) -#define OTABSL_CACHELINE_SIZE 64 -#endif -#endif - -#ifndef OTABSL_CACHELINE_SIZE -// A reasonable default guess. Note that overestimates tend to waste more -// space, while underestimates tend to waste more time. -#define OTABSL_CACHELINE_SIZE 64 -#endif - -// OTABSL_CACHELINE_ALIGNED -// -// Indicates that the declared object be cache aligned using -// `OTABSL_CACHELINE_SIZE` (see above). Cacheline aligning objects allows you to -// load a set of related objects in the L1 cache for performance improvements. -// Cacheline aligning objects properly allows constructive memory sharing and -// prevents destructive (or "false") memory sharing. -// -// NOTE: this macro should be replaced with usage of `alignas()` using -// `std::hardware_constructive_interference_size` and/or -// `std::hardware_destructive_interference_size` when available within C++17. -// -// See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0154r1.html -// for more information. -// -// On some compilers, `OTABSL_CACHELINE_ALIGNED` expands to an `__attribute__` -// or `__declspec` attribute. For compilers where this is not known to work, -// the macro expands to nothing. -// -// No further guarantees are made here. The result of applying the macro -// to variables and types is always implementation-defined. -// -// WARNING: It is easy to use this attribute incorrectly, even to the point -// of causing bugs that are difficult to diagnose, crash, etc. It does not -// of itself guarantee that objects are aligned to a cache line. -// -// NOTE: Some compilers are picky about the locations of annotations such as -// this attribute, so prefer to put it at the beginning of your declaration. -// For example, -// -// OTABSL_CACHELINE_ALIGNED static Foo* foo = ... -// -// class OTABSL_CACHELINE_ALIGNED Bar { ... -// -// Recommendations: -// -// 1) Consult compiler documentation; this comment is not kept in sync as -// toolchains evolve. -// 2) Verify your use has the intended effect. This often requires inspecting -// the generated machine code. -// 3) Prefer applying this attribute to individual variables. Avoid -// applying it to types. This tends to localize the effect. -#define OTABSL_CACHELINE_ALIGNED __attribute__((aligned(OTABSL_CACHELINE_SIZE))) -#elif defined(_MSC_VER) -#define OTABSL_CACHELINE_SIZE 64 -#define OTABSL_CACHELINE_ALIGNED __declspec(align(OTABSL_CACHELINE_SIZE)) -#else -#define OTABSL_CACHELINE_SIZE 64 -#define OTABSL_CACHELINE_ALIGNED -#endif - -// OTABSL_PREDICT_TRUE, OTABSL_PREDICT_FALSE -// -// Enables the compiler to prioritize compilation using static analysis for -// likely paths within a boolean branch. -// -// Example: -// -// if (OTABSL_PREDICT_TRUE(expression)) { -// return result; // Faster if more likely -// } else { -// return 0; -// } -// -// Compilers can use the information that a certain branch is not likely to be -// taken (for instance, a CHECK failure) to optimize for the common case in -// the absence of better information (ie. compiling gcc with `-fprofile-arcs`). -// -// Recommendation: Modern CPUs dynamically predict branch execution paths, -// typically with accuracy greater than 97%. As a result, annotating every -// branch in a codebase is likely counterproductive; however, annotating -// specific branches that are both hot and consistently mispredicted is likely -// to yield performance improvements. -#if OTABSL_HAVE_BUILTIN(__builtin_expect) || \ - (defined(__GNUC__) && !defined(__clang__)) -#define OTABSL_PREDICT_FALSE(x) (__builtin_expect(x, 0)) -#define OTABSL_PREDICT_TRUE(x) (__builtin_expect(false || (x), true)) -#else -#define OTABSL_PREDICT_FALSE(x) (x) -#define OTABSL_PREDICT_TRUE(x) (x) -#endif - -#endif // OTABSL_BASE_OPTIMIZATION_H_ diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/options.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/options.h deleted file mode 100644 index c4b00a3d38..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/options.h +++ /dev/null @@ -1,216 +0,0 @@ -#ifndef OTABSL_BASE_OPTIONS_H_ -#define OTABSL_BASE_OPTIONS_H_ - -// Copyright 2019 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ----------------------------------------------------------------------------- -// File: options.h -// ----------------------------------------------------------------------------- -// -// This file contains Abseil configuration options for setting specific -// implementations instead of letting Abseil determine which implementation to -// use at compile-time. Setting these options may be useful for package or build -// managers who wish to guarantee ABI stability within binary builds (which are -// otherwise difficult to enforce). -// -// *** IMPORTANT NOTICE FOR PACKAGE MANAGERS: It is important that -// maintainers of package managers who wish to package Abseil read and -// understand this file! *** -// -// Abseil contains a number of possible configuration endpoints, based on -// parameters such as the detected platform, language version, or command-line -// flags used to invoke the underlying binary. As is the case with all -// libraries, binaries which contain Abseil code must ensure that separate -// packages use the same compiled copy of Abseil to avoid a diamond dependency -// problem, which can occur if two packages built with different Abseil -// configuration settings are linked together. Diamond dependency problems in -// C++ may manifest as violations to the One Definition Rule (ODR) (resulting in -// linker errors), or undefined behavior (resulting in crashes). -// -// Diamond dependency problems can be avoided if all packages utilize the same -// exact version of Abseil. Building from source code with the same compilation -// parameters is the easiest way to avoid such dependency problems. However, for -// package managers who cannot control such compilation parameters, we are -// providing the file to allow you to inject ABI (Application Binary Interface) -// stability across builds. Settings options in this file will neither change -// API nor ABI, providing a stable copy of Abseil between packages. -// -// Care must be taken to keep options within these configurations isolated -// from any other dynamic settings, such as command-line flags which could alter -// these options. This file is provided specifically to help build and package -// managers provide a stable copy of Abseil within their libraries and binaries; -// other developers should not have need to alter the contents of this file. -// -// ----------------------------------------------------------------------------- -// Usage -// ----------------------------------------------------------------------------- -// -// For any particular package release, set the appropriate definitions within -// this file to whatever value makes the most sense for your package(s). Note -// that, by default, most of these options, at the moment, affect the -// implementation of types; future options may affect other implementation -// details. -// -// NOTE: the defaults within this file all assume that Abseil can select the -// proper Abseil implementation at compile-time, which will not be sufficient -// to guarantee ABI stability to package managers. - -// Include a standard library header to allow configuration based on the -// standard library in use. -// Using C++20 feature-test macros when possible, otherwise fall back to -// ciso646/iso646.h.There are warnings when including ciso646 in C++17 mode -#ifdef __has_include -# if __has_include() -# include -# endif -#elif defined(_MSC_VER) && \ - ((defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)) -# if _MSC_VER >= 1922 -# include -# endif -#else -# if defined(__GNUC__) && !defined(__clang__) && !defined(__apple_build_version__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wcpp" -# elif defined(__clang__) || defined(__apple_build_version__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wcpp" -# endif -# include -# if defined(__GNUC__) && !defined(__clang__) && !defined(__apple_build_version__) -# pragma GCC diagnostic pop -# elif defined(__clang__) || defined(__apple_build_version__) -# pragma clang diagnostic pop -# endif -#endif - -// ----------------------------------------------------------------------------- -// Type Compatibility Options -// ----------------------------------------------------------------------------- -// -// OTABSL_OPTION_USE_STD_ANY -// -// This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::any is implemented as an alias to -// std::any, or as an independent implementation. -// -// A value of 0 means to use Abseil's implementation. This requires only C++11 -// support, and is expected to work on every toolchain we support. -// -// A value of 1 means to use an alias to std::any. This requires that all code -// using Abseil is built in C++17 mode or later. -// -// A value of 2 means to detect the C++ version being used to compile Abseil, -// and use an alias only if a working std::any is available. This option is -// useful when you are building your entire program, including all of its -// dependencies, from source. It should not be used otherwise -- for example, -// if you are distributing Abseil in a binary package manager -- since in -// mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::any will name a different type, with a different mangled name -// and binary layout, depending on the compiler flags passed by the end user. -// For more info, see https://abseil.io/about/design/dropin-types. -// -// User code should not inspect this macro. To check in the preprocessor if -// absl::OTABSL_OPTION_NAMESPACE_NAME::any is a typedef of std::any, use the feature macro OTABSL_USES_STD_ANY. - -#define OTABSL_OPTION_USE_STD_ANY 0 - - -// OTABSL_OPTION_USE_STD_OPTIONAL -// -// This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::optional is implemented as an alias to -// std::optional, or as an independent implementation. -// -// A value of 0 means to use Abseil's implementation. This requires only C++11 -// support, and is expected to work on every toolchain we support. -// -// A value of 1 means to use an alias to std::optional. This requires that all -// code using Abseil is built in C++17 mode or later. -// -// A value of 2 means to detect the C++ version being used to compile Abseil, -// and use an alias only if a working std::optional is available. This option -// is useful when you are building your program from source. It should not be -// used otherwise -- for example, if you are distributing Abseil in a binary -// package manager -- since in mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::optional will name a different -// type, with a different mangled name and binary layout, depending on the -// compiler flags passed by the end user. For more info, see -// https://abseil.io/about/design/dropin-types. - -// User code should not inspect this macro. To check in the preprocessor if -// absl::OTABSL_OPTION_NAMESPACE_NAME::optional is a typedef of std::optional, use the feature macro -// OTABSL_USES_STD_OPTIONAL. - -#define OTABSL_OPTION_USE_STD_OPTIONAL 0 - - -// OTABSL_OPTION_USE_STD_STRING_VIEW -// -// This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::string_view is implemented as an alias to -// std::string_view, or as an independent implementation. -// -// A value of 0 means to use Abseil's implementation. This requires only C++11 -// support, and is expected to work on every toolchain we support. -// -// A value of 1 means to use an alias to std::string_view. This requires that -// all code using Abseil is built in C++17 mode or later. -// -// A value of 2 means to detect the C++ version being used to compile Abseil, -// and use an alias only if a working std::string_view is available. This -// option is useful when you are building your program from source. It should -// not be used otherwise -- for example, if you are distributing Abseil in a -// binary package manager -- since in mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::string_view will name a -// different type, with a different mangled name and binary layout, depending on -// the compiler flags passed by the end user. For more info, see -// https://abseil.io/about/design/dropin-types. -// -// User code should not inspect this macro. To check in the preprocessor if -// absl::OTABSL_OPTION_NAMESPACE_NAME::string_view is a typedef of std::string_view, use the feature macro -// OTABSL_USES_STD_STRING_VIEW. - -#define OTABSL_OPTION_USE_STD_STRING_VIEW 0 - -// OTABSL_OPTION_USE_STD_VARIANT -// -// This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::variant is implemented as an alias to -// std::variant, or as an independent implementation. -// -// A value of 0 means to use Abseil's implementation. This requires only C++11 -// support, and is expected to work on every toolchain we support. -// -// A value of 1 means to use an alias to std::variant. This requires that all -// code using Abseil is built in C++17 mode or later. -// -// A value of 2 means to detect the C++ version being used to compile Abseil, -// and use an alias only if a working std::variant is available. This option -// is useful when you are building your program from source. It should not be -// used otherwise -- for example, if you are distributing Abseil in a binary -// package manager -- since in mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::variant will name a different -// type, with a different mangled name and binary layout, depending on the -// compiler flags passed by the end user. For more info, see -// https://abseil.io/about/design/dropin-types. -// -// User code should not inspect this macro. To check in the preprocessor if -// absl::OTABSL_OPTION_NAMESPACE_NAME::variant is a typedef of std::variant, use the feature macro -// OTABSL_USES_STD_VARIANT. - -#define OTABSL_OPTION_USE_STD_VARIANT 0 - - -// OTABSL_OPTION_NAMESPACE_NAME -// -// All codes in otabsl are under OTABSL_OPTION_NAMESPACE_NAME, we do not use inline namespace to avoid -// conlict with external Abseil. - -#define OTABSL_OPTION_NAMESPACE_NAME otel_v1 - -#endif // OTABSL_BASE_OPTIONS_H_ diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/policy_checks.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/policy_checks.h deleted file mode 100644 index f86c264fc4..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/policy_checks.h +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2017 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ----------------------------------------------------------------------------- -// File: policy_checks.h -// ----------------------------------------------------------------------------- -// -// This header enforces a minimum set of policies at build time, such as the -// supported compiler and library versions. Unsupported configurations are -// reported with `#error`. This enforcement is best effort, so successfully -// compiling this header does not guarantee a supported configuration. - -#ifndef OTABSL_BASE_POLICY_CHECKS_H_ -#define OTABSL_BASE_POLICY_CHECKS_H_ - -// Included for the __GLIBC_PREREQ macro used below. -#include - -// Included for the _STLPORT_VERSION macro used below. -#if defined(__cplusplus) -#include -#endif - -// ----------------------------------------------------------------------------- -// Operating System Check -// ----------------------------------------------------------------------------- - -#if defined(__CYGWIN__) -#error "Cygwin is not supported." -#endif - -// ----------------------------------------------------------------------------- -// Compiler Check -// ----------------------------------------------------------------------------- - -#if 0 /* FIXME: MG */ -// We support MSVC++ 14.0 update 2 and later. -// This minimum will go up. -#if defined(_MSC_FULL_VER) && _MSC_FULL_VER < 190023918 && !defined(__clang__) -#error "This package requires Visual Studio 2015 Update 2 or higher." -#endif -#endif - -// We support gcc 4.7 and later. -// This minimum will go up. -#if defined(__GNUC__) && !defined(__clang__) -#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7) -#error "This package requires gcc 4.7 or higher." -#endif -#endif - -// We support Apple Xcode clang 4.2.1 (version 421.11.65) and later. -// This corresponds to Apple Xcode version 4.5. -// This minimum will go up. -#if defined(__apple_build_version__) && __apple_build_version__ < 4211165 -#error "This package requires __apple_build_version__ of 4211165 or higher." -#endif - -// ----------------------------------------------------------------------------- -// C++ Version Check -// ----------------------------------------------------------------------------- - -// Enforce C++11 as the minimum. -#if defined(_MSVC_LANG) -#if _MSVC_LANG < 201103L -#error "C++ versions less than C++11 are not supported." -#endif // _MSVC_LANG < 201103L -#elif defined(__cplusplus) -#if __cplusplus < 201103L -#error "C++ versions less than C++11 are not supported." -#endif // __cplusplus < 201103L -#endif - -// ----------------------------------------------------------------------------- -// Standard Library Check -// ----------------------------------------------------------------------------- - -#if defined(_STLPORT_VERSION) -#error "STLPort is not supported." -#endif - -// ----------------------------------------------------------------------------- -// `char` Size Check -// ----------------------------------------------------------------------------- - -// Abseil currently assumes CHAR_BIT == 8. If you would like to use Abseil on a -// platform where this is not the case, please provide us with the details about -// your platform so we can consider relaxing this requirement. -#if CHAR_BIT != 8 -#error "Abseil assumes CHAR_BIT == 8." -#endif - -// ----------------------------------------------------------------------------- -// `int` Size Check -// ----------------------------------------------------------------------------- - -// Abseil currently assumes that an int is 4 bytes. If you would like to use -// Abseil on a platform where this is not the case, please provide us with the -// details about your platform so we can consider relaxing this requirement. -#if INT_MAX < 2147483647 -#error "Abseil assumes that int is at least 4 bytes. " -#endif - -#endif // OTABSL_BASE_POLICY_CHECKS_H_ diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/port.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/port.h deleted file mode 100644 index aaba551b59..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/base/port.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// This files is a forwarding header for other headers containing various -// portability macros and functions. -// This file is used for both C and C++! - -#ifndef OTABSL_BASE_PORT_H_ -#define OTABSL_BASE_PORT_H_ - -#include "attributes.h" -#include "config.h" -#include "optimization.h" - -#endif // OTABSL_BASE_PORT_H_ diff --git a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/meta/type_traits.h b/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/meta/type_traits.h deleted file mode 100644 index dbd0348871..0000000000 --- a/ext/opentelemetry-cpp-1.21.0/api/include/opentelemetry/nostd/internal/absl/meta/type_traits.h +++ /dev/null @@ -1,779 +0,0 @@ -// -// Copyright 2017 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// ----------------------------------------------------------------------------- -// type_traits.h -// ----------------------------------------------------------------------------- -// -// This file contains C++11-compatible versions of standard API -// functions for determining the characteristics of types. Such traits can -// support type inference, classification, and transformation, as well as -// make it easier to write templates based on generic type behavior. -// -// See https://en.cppreference.com/w/cpp/header/type_traits -// -// WARNING: use of many of the constructs in this header will count as "complex -// template metaprogramming", so before proceeding, please carefully consider -// https://google.github.io/styleguide/cppguide.html#Template_metaprogramming -// -// WARNING: using template metaprogramming to detect or depend on API -// features is brittle and not guaranteed. Neither the standard library nor -// Abseil provides any guarantee that APIs are stable in the face of template -// metaprogramming. Use with caution. -#ifndef OTABSL_META_TYPE_TRAITS_H_ -#define OTABSL_META_TYPE_TRAITS_H_ - -#include -#include -#include - -#include "../base/config.h" - -// MSVC constructibility traits do not detect destructor properties and so our -// implementations should not use them as a source-of-truth. -#if defined(_MSC_VER) && !defined(__clang__) && !defined(__GNUC__) -#define OTABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION 1 -#endif - -namespace absl { -OTABSL_NAMESPACE_BEGIN - -// Defined and documented later on in this file. -template -struct is_trivially_destructible; - -// Defined and documented later on in this file. -template -struct is_trivially_move_assignable; - -namespace type_traits_internal { - -// Silence MSVC warnings about the destructor being defined as deleted. -#if defined(_MSC_VER) && !defined(__GNUC__) -#pragma warning(push) -#pragma warning(disable : 4624) -#endif // defined(_MSC_VER) && !defined(__GNUC__) - -template -union SingleMemberUnion { - T t; -}; - -// Restore the state of the destructor warning that was silenced above. -#if defined(_MSC_VER) && !defined(__GNUC__) -#pragma warning(pop) -#endif // defined(_MSC_VER) && !defined(__GNUC__) - -template -struct IsTriviallyMoveConstructibleObject - : std::integral_constant< - bool, std::is_move_constructible< - type_traits_internal::SingleMemberUnion>::value && - absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_destructible::value> {}; - -template -struct IsTriviallyCopyConstructibleObject - : std::integral_constant< - bool, std::is_copy_constructible< - type_traits_internal::SingleMemberUnion>::value && - absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_destructible::value> {}; - -template -struct IsTriviallyMoveAssignableReference : std::false_type {}; - -template -struct IsTriviallyMoveAssignableReference - : absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_move_assignable::type {}; - -template -struct IsTriviallyMoveAssignableReference - : absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_move_assignable::type {}; - -template -struct VoidTImpl { - using type = void; -}; - -//////////////////////////////// -// Library Fundamentals V2 TS // -//////////////////////////////// - -// NOTE: The `is_detected` family of templates here differ from the library -// fundamentals specification in that for library fundamentals, `Op` is -// evaluated as soon as the type `is_detected` undergoes -// substitution, regardless of whether or not the `::value` is accessed. That -// is inconsistent with all other standard traits and prevents lazy evaluation -// in larger contexts (such as if the `is_detected` check is a trailing argument -// of a `conjunction`. This implementation opts to instead be lazy in the same -// way that the standard traits are (this "defect" of the detection idiom -// specifications has been reported). - -template class Op, class... Args> -struct is_detected_impl { - using type = std::false_type; -}; - -template