diff --git a/.github/macos-build-entitlements.plist b/.github/macos-build-entitlements.plist
new file mode 100644
index 0000000..957352b
--- /dev/null
+++ b/.github/macos-build-entitlements.plist
@@ -0,0 +1,10 @@
+
+
+
+
+ com.apple.security.cs.allow-jit
+
+ com.apple.security.cs.allow-unsigned-executable-memory
+
+
+
\ No newline at end of file
diff --git a/.github/workflows/build-alpine-arm64.yml b/.github/workflows/build-alpine-arm64.yml
new file mode 100644
index 0000000..914a364
--- /dev/null
+++ b/.github/workflows/build-alpine-arm64.yml
@@ -0,0 +1,44 @@
+name: Build for alpine-arm64
+
+on: workflow_dispatch
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ # Checkout the code
+ - name: Checkout the code
+ uses: actions/checkout@v1
+
+ # Setup Docker for cross platform build
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v1
+
+ # Setup Docker for cross platform build
+ - name: Set up docker buildx
+ id: buildx
+ uses: docker/setup-buildx-action@v1
+
+ # Build docker image
+ - name: Run build
+ run: docker buildx build --load --platform linux/arm64 -f ./docker/Dockerfile.alpine-arm64 . -t tagocore-container
+
+ # Pull binary out of docker container
+ - name: Extract tagocore binary out of docker
+ run: docker cp $(docker create tagocore-container):/usr/src/app/__build__binary__/tagocore ./tagocore
+
+ # Set binary as executable
+ - name: Chmod
+ run: chmod +x ./tagocore
+
+ # Zip the binary
+ - name: Generate tar.gz
+ run: tar cvf - tagocore | gzip > ./tagocore-alpine-arm64.tar.gz
+
+ # Upload the zip file as an artifact
+ - name: Upload artifact
+ uses: actions/upload-artifact@v2
+ with:
+ name: mqttrelay-alpine-arm64
+ path: ../tagocore.zip
diff --git a/.github/workflows/build-alpine-x64.yml b/.github/workflows/build-alpine-x64.yml
new file mode 100644
index 0000000..2cb9952
--- /dev/null
+++ b/.github/workflows/build-alpine-x64.yml
@@ -0,0 +1,44 @@
+name: Build for alpine-x64
+
+on: workflow_dispatch
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ # Checkout the code
+ - name: Checkout the code
+ uses: actions/checkout@v1
+
+ # Setup Docker for cross platform build
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v1
+
+ # Setup Docker for cross platform build
+ - name: Set up docker buildx
+ id: buildx
+ uses: docker/setup-buildx-action@v1
+
+ # Build docker image
+ - name: Run build
+ run: docker buildx build --load --platform linux/arm64 -f ./docker/Dockerfile.alpine-arm64 . -t tagocore-container
+
+ # Pull binary out of docker container
+ - name: Extract tagocore binary out of docker
+ run: docker cp $(docker create tagocore-container):/usr/src/app/__build__binary__/tagocore ./tagocore
+
+ # Set binary as executable
+ - name: Chmod
+ run: chmod +x ./tagocore
+
+ # Zip the binary
+ - name: Generate tar.gz
+ run: tar cvf - tagocore | gzip > ./tagocore-alpine-arm64.tar.gz
+
+ # Upload the zip file as an artifact
+ - name: Upload artifact
+ uses: actions/upload-artifact@v2
+ with:
+ name: mqttrelay-alpine-arm64
+ path: ../tagocore.zip
diff --git a/.github/workflows/build-dockerhub.yml b/.github/workflows/build-dockerhub.yml
new file mode 100644
index 0000000..2a8ef8f
--- /dev/null
+++ b/.github/workflows/build-dockerhub.yml
@@ -0,0 +1,31 @@
+name: Deploy to DockerHub
+
+on:
+ workflow_dispatch:
+ inputs:
+ version:
+ description: "Version"
+ required: true
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout the code
+ uses: actions/checkout@v1
+
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v2
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v2
+
+ - name: Login to DockerHub
+ uses: docker/login-action@v2
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+ - name: Build and deploy images
+ run: bash dockerhub.sh ${{ github.event.inputs.version }}
diff --git a/.github/workflows/build-macos-x64.yml b/.github/workflows/build-macos-x64.yml
new file mode 100644
index 0000000..ac105cb
--- /dev/null
+++ b/.github/workflows/build-macos-x64.yml
@@ -0,0 +1,75 @@
+name: Build for mac-x64
+
+on: workflow_dispatch
+
+env:
+ CARGO_TERM_COLOR: always
+
+jobs:
+ build:
+ runs-on: macos-11
+
+ steps:
+ # Checkout the code
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Install Rust toolchain
+ run: |
+ rustup update --no-self-update stable
+ rustup component add --toolchain stable rustfmt
+ rustup default stable
+
+ - name: Create .env file
+ run: |
+ echo "SERVER_SSL_CA=${{ secrets.SERVER_SSL_CA }}" >> .env
+ echo "SERVER_SSL_CERT=${{ secrets.SERVER_SSL_CERT }}" >> .env
+ echo "SERVER_SSL_KEY=${{ secrets.SERVER_SSL_KEY }}" >> .env
+
+ # Build the modules
+ - name: Build
+ run: cargo build --verbose --release
+
+ # Run tests
+ - name: Run tests
+ run: cargo test --verbose
+
+ # # Sign the executable
+ # - name: Codesign binary
+ # env:
+ # MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
+ # MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
+ # MACOS_FULL_IDENTITY: ${{ secrets.MACOS_FULL_IDENTITY }}
+ # run: |
+ # echo $MACOS_CERTIFICATE | openssl base64 -d -A > certificate.p12
+ # security create-keychain -p $MACOS_CERTIFICATE_PWD build.keychain
+ # security default-keychain -s build.keychain
+ # security unlock-keychain -p $MACOS_CERTIFICATE_PWD build.keychain
+ # security import certificate.p12 -k build.keychain -P $MACOS_CERTIFICATE_PWD -T /usr/bin/codesign
+ # security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k $MACOS_CERTIFICATE_PWD build.keychain
+ # cd __build__binary__
+ # /usr/bin/codesign -f -s "$MACOS_FULL_IDENTITY" --entitlements ../.github/macos-build-entitlements.plist --options=runtime --timestamp ./mqttrelay
+ # zip ./mqttrelay.zip ./mqttrelay
+ # /usr/bin/codesign -f -s "$MACOS_FULL_IDENTITY" --options=runtime --timestamp ./mqttrelay.zip
+
+ # # Notarize app using xcrun altool
+ # - name: Notarize binary
+ # env:
+ # MACOS_DEVELOPER_EMAIL: ${{ secrets.MACOS_DEVELOPER_EMAIL }}
+ # MACOS_DEVELOPER_PWD: ${{ secrets.MACOS_DEVELOPER_PWD }}
+ # MACOS_BUNDLE_ID: ${{ secrets.MACOS_BUNDLE_ID }}
+ # MACOS_ASC_PROVIDER: ${{ secrets.MACOS_ASC_PROVIDER }}
+ # run: xcrun altool --notarize-app --primary-bundle-id "$MACOS_BUNDLE_ID" -u "$MACOS_DEVELOPER_EMAIL" -p "$MACOS_DEVELOPER_PWD" --asc-provider "$MACOS_ASC_PROVIDER" -f ./__build__binary__/mqttrelay.zip
+
+ # Zip the binary
+ - name: Generate tar.gz
+ run: |
+ cd target/release
+ tar cvf - tago-relay | gzip > ../tago-relay-mac-x64.tar.gz
+
+ # Upload the zip file as an artifact
+ - name: Upload artifact
+ uses: actions/upload-artifact@v2
+ with:
+ name: tago-relay-macos-x64
+ path: target/tago-relay-mac-x64.tar.gz
diff --git a/.github/workflows/build-win-x64.yml b/.github/workflows/build-win-x64.yml
new file mode 100644
index 0000000..5beae6f
--- /dev/null
+++ b/.github/workflows/build-win-x64.yml
@@ -0,0 +1,47 @@
+name: Build for win-x64
+on: workflow_dispatch
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ environment: PROD
+
+ steps:
+ # Checkout the code
+ - name: Checkout the code
+ uses: actions/checkout@v1
+
+ # Install dependencies
+ - name: Install dependencies
+ run: npm install
+
+ # Build the modules
+ - name: Run build
+ run: npm run build
+
+ # Manually copy the bin file of sdk to the .bin folder to use the local copy of the sdk
+ - name: Override tcore-plugin .bin file
+ run: cd ./node_modules/.bin; ln -s ../../packages/tcore-sdk/build/Bin/Bin.js tcore-plugin; chmod +x tcore-plugin; cd ../../
+
+ # Pack Plugin Store, TagoIO Integration, and Local Filesystem into a .tcore file
+ - name: Pack built-in plugins
+ run: npm run pack
+
+ # Add the packed .tcore files to the /plugins folder
+ - name: Move built-in plugins to plugins folder
+ run: npm run plugin:add
+
+ # Generate the executable
+ - name: Generate executable
+ run: ./node_modules/.bin/pkg package.json -t node16-win-x64 --public-packages "*" --no-bytecode --public --compress Brotli
+
+ # Zip the executable
+ - name: Generate zip
+ run: cd __build__binary__; zip ../tagocore.zip ./tagocore.exe
+
+ # Upload the zip file as an artifact
+ - name: Upload artifact
+ uses: actions/upload-artifact@v2
+ with:
+ name: mqttrelay-windows-x64
+ path: ../tagocore.zip
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
new file mode 100644
index 0000000..81db9a5
--- /dev/null
+++ b/.github/workflows/tests.yml
@@ -0,0 +1,55 @@
+name: Code Quality
+on: push
+
+env:
+ CARGO_TERM_COLOR: always
+ stage: prod
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ environment: PROD
+ env:
+ SERVER_SSL_CA: ${{ secrets.SERVER_SSL_CA }}
+ SERVER_SSL_CERT: ${{ secrets.SERVER_SSL_CERT }}
+ SERVER_SSL_KEY: ${{ secrets.SERVER_SSL_KEY }}
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Cache cargo
+ uses: actions/cache@v3
+ with:
+ path: |
+ ~/.cargo/registry
+ ~/.cargo/git
+ key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
+ restore-keys: |
+ ${{ runner.os }}-cargo-
+
+ - name: Install Rust toolchain and components
+ uses: actions-rs/toolchain@v1
+ with:
+ toolchain: stable
+ components: rustfmt, clippy
+
+ - name: Create empty .env file
+ run: touch .env
+
+ - name: Build
+ run: cargo build --verbose
+
+ - name: Test
+ run: cargo test --verbose
+
+ - name: Lint
+ uses: actions-rs/cargo@v1
+ with:
+ command: clippy
+ args: -- -D warnings
+
+ - name: Format Check
+ uses: actions-rs/cargo@v1
+ with:
+ command: fmt
+ args: -- --check
diff --git a/.gitignore b/.gitignore
index ea8c4bf..48cb268 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
/target
+.env
+config.toml
+*.pem
diff --git a/.rustfmt.toml b/.rustfmt.toml
new file mode 100644
index 0000000..4cac4e2
--- /dev/null
+++ b/.rustfmt.toml
@@ -0,0 +1,5 @@
+# fn_call_width = 80
+# max_width = 240
+tab_spaces = 2
+max_width = 120
+hard_tabs = false
diff --git a/Cargo.lock b/Cargo.lock
index 5e956b8..15b92a4 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -17,12 +17,216 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
+[[package]]
+name = "aho-corasick"
+version = "1.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "anstream"
+version = "0.6.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b"
+dependencies = [
+ "anstyle",
+ "anstyle-parse",
+ "anstyle-query",
+ "anstyle-wincon",
+ "colorchoice",
+ "is_terminal_polyfill",
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle"
+version = "1.0.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b"
+
+[[package]]
+name = "anstyle-parse"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4"
+dependencies = [
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle-query"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5"
+dependencies = [
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "anstyle-wincon"
+version = "3.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19"
+dependencies = [
+ "anstyle",
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "anyhow"
+version = "1.0.86"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
+
+[[package]]
+name = "arc-swap"
+version = "1.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457"
+
+[[package]]
+name = "assert-json-diff"
+version = "2.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "47e4f2b81832e72834d7518d8487a0396a28cc408186a2e8854c0f98011faf12"
+dependencies = [
+ "serde",
+ "serde_json",
+]
+
+[[package]]
+name = "async-trait"
+version = "0.1.80"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.65",
+]
+
+[[package]]
+name = "atomic-waker"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
+
[[package]]
name = "autocfg"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
+[[package]]
+name = "aws-lc-rs"
+version = "1.7.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "474d7cec9d0a1126fad1b224b767fcbf351c23b0309bb21ec210bcfd379926a5"
+dependencies = [
+ "aws-lc-sys",
+ "mirai-annotations",
+ "paste",
+ "zeroize",
+]
+
+[[package]]
+name = "aws-lc-sys"
+version = "0.17.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7505fc3cb7acbf42699a43a79dd9caa4ed9e99861dfbb837c5c0fb5a0a8d2980"
+dependencies = [
+ "bindgen",
+ "cc",
+ "cmake",
+ "dunce",
+ "fs_extra",
+ "libc",
+ "paste",
+]
+
+[[package]]
+name = "axum"
+version = "0.7.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf"
+dependencies = [
+ "async-trait",
+ "axum-core",
+ "bytes",
+ "futures-util",
+ "http 1.1.0",
+ "http-body 1.0.0",
+ "http-body-util",
+ "hyper 1.3.1",
+ "hyper-util",
+ "itoa",
+ "matchit",
+ "memchr",
+ "mime",
+ "percent-encoding",
+ "pin-project-lite",
+ "rustversion",
+ "serde",
+ "serde_json",
+ "serde_path_to_error",
+ "serde_urlencoded",
+ "sync_wrapper 1.0.1",
+ "tokio",
+ "tower",
+ "tower-layer",
+ "tower-service",
+ "tracing",
+]
+
+[[package]]
+name = "axum-core"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3"
+dependencies = [
+ "async-trait",
+ "bytes",
+ "futures-util",
+ "http 1.1.0",
+ "http-body 1.0.0",
+ "http-body-util",
+ "mime",
+ "pin-project-lite",
+ "rustversion",
+ "sync_wrapper 0.1.2",
+ "tower-layer",
+ "tower-service",
+ "tracing",
+]
+
+[[package]]
+name = "axum-server"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c1ad46c3ec4e12f4a4b6835e173ba21c25e484c9d02b49770bf006ce5367c036"
+dependencies = [
+ "arc-swap",
+ "bytes",
+ "futures-util",
+ "http 1.1.0",
+ "http-body 1.0.0",
+ "http-body-util",
+ "hyper 1.3.1",
+ "hyper-util",
+ "openssl",
+ "pin-project-lite",
+ "rustls 0.21.12",
+ "rustls-pemfile",
+ "tokio",
+ "tokio-openssl",
+ "tokio-rustls 0.24.1",
+ "tower",
+ "tower-service",
+]
+
[[package]]
name = "backtrace"
version = "0.3.71"
@@ -38,17 +242,70 @@ dependencies = [
"rustc-demangle",
]
+[[package]]
+name = "base64"
+version = "0.21.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
+
[[package]]
name = "base64"
version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
+[[package]]
+name = "bindgen"
+version = "0.69.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0"
+dependencies = [
+ "bitflags 2.5.0",
+ "cexpr",
+ "clang-sys",
+ "itertools",
+ "lazy_static",
+ "lazycell",
+ "log",
+ "prettyplease",
+ "proc-macro2",
+ "quote",
+ "regex",
+ "rustc-hash",
+ "shlex",
+ "syn 2.0.65",
+ "which",
+]
+
+[[package]]
+name = "bitflags"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+
[[package]]
name = "bitflags"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "block-buffer"
+version = "0.10.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
+dependencies = [
+ "generic-array",
+]
+
+[[package]]
+name = "bumpalo"
+version = "3.16.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
[[package]]
name = "bytes"
@@ -61,6 +318,20 @@ name = "cc"
version = "1.0.98"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f"
+dependencies = [
+ "jobserver",
+ "libc",
+ "once_cell",
+]
+
+[[package]]
+name = "cexpr"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
+dependencies = [
+ "nom",
+]
[[package]]
name = "cfg-if"
@@ -69,535 +340,2119 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
-name = "core-foundation"
-version = "0.9.4"
+name = "clang-sys"
+version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
+checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
dependencies = [
- "core-foundation-sys",
+ "glob",
"libc",
+ "libloading",
]
[[package]]
-name = "core-foundation-sys"
-version = "0.8.6"
+name = "clap"
+version = "4.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
+checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0"
+dependencies = [
+ "clap_builder",
+ "clap_derive",
+]
[[package]]
-name = "flume"
-version = "0.11.0"
+name = "clap_builder"
+version = "4.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181"
+checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4"
dependencies = [
- "futures-core",
- "futures-sink",
- "spin",
+ "anstream",
+ "anstyle",
+ "clap_lex",
+ "strsim",
]
[[package]]
-name = "futures-core"
-version = "0.3.30"
+name = "clap_derive"
+version = "4.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
+checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64"
+dependencies = [
+ "heck",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.65",
+]
[[package]]
-name = "futures-sink"
-version = "0.3.30"
+name = "clap_lex"
+version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5"
+checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce"
[[package]]
-name = "futures-task"
-version = "0.3.30"
+name = "cmake"
+version = "0.1.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004"
+checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130"
+dependencies = [
+ "cc",
+]
[[package]]
-name = "futures-util"
-version = "0.3.30"
+name = "colorchoice"
+version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
-dependencies = [
- "futures-core",
- "futures-task",
- "pin-project-lite",
- "pin-utils",
- "slab",
-]
+checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422"
[[package]]
-name = "getrandom"
-version = "0.2.15"
+name = "colored"
+version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
+checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8"
dependencies = [
- "cfg-if",
- "libc",
- "wasi",
+ "lazy_static",
+ "windows-sys 0.48.0",
]
[[package]]
-name = "gimli"
-version = "0.28.1"
+name = "config"
+version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
+checksum = "7328b20597b53c2454f0b1919720c25c7339051c02b72b7e05409e00b14132be"
+dependencies = [
+ "async-trait",
+ "convert_case",
+ "json5",
+ "lazy_static",
+ "nom",
+ "pathdiff",
+ "ron",
+ "rust-ini",
+ "serde",
+ "serde_json",
+ "toml",
+ "yaml-rust",
+]
[[package]]
-name = "hermit-abi"
-version = "0.3.9"
+name = "const-random"
+version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
+checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359"
+dependencies = [
+ "const-random-macro",
+]
[[package]]
-name = "libc"
-version = "0.2.155"
+name = "const-random-macro"
+version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
+checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e"
+dependencies = [
+ "getrandom",
+ "once_cell",
+ "tiny-keccak",
+]
[[package]]
-name = "lock_api"
-version = "0.4.12"
+name = "convert_case"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
+checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
dependencies = [
- "autocfg",
- "scopeguard",
+ "unicode-segmentation",
]
[[package]]
-name = "log"
-version = "0.4.21"
+name = "core-foundation"
+version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
+checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
[[package]]
-name = "memchr"
-version = "2.7.2"
+name = "core-foundation-sys"
+version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
+checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
[[package]]
-name = "miniz_oxide"
-version = "0.7.3"
+name = "cpufeatures"
+version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae"
+checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504"
dependencies = [
- "adler",
+ "libc",
]
[[package]]
-name = "mio"
-version = "0.8.11"
+name = "crunchy"
+version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c"
-dependencies = [
- "libc",
- "wasi",
- "windows-sys 0.48.0",
-]
+checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]]
-name = "mqtt-bridge"
-version = "0.1.0"
+name = "crypto-common"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
dependencies = [
- "rand",
- "rumqttc",
- "tokio",
+ "generic-array",
+ "typenum",
]
[[package]]
-name = "num_cpus"
-version = "1.16.0"
+name = "digest"
+version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
+checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
- "hermit-abi",
- "libc",
+ "block-buffer",
+ "crypto-common",
]
[[package]]
-name = "object"
-version = "0.32.2"
+name = "dlv-list"
+version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441"
+checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f"
dependencies = [
- "memchr",
+ "const-random",
]
[[package]]
-name = "openssl-probe"
-version = "0.1.5"
+name = "dotenvy"
+version = "0.15.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
+checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
[[package]]
-name = "parking_lot"
-version = "0.12.2"
+name = "dotenvy_macro"
+version = "0.15.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb"
+checksum = "cb0235d912a8c749f4e0c9f18ca253b4c28cfefc1d2518096016d6e3230b6424"
dependencies = [
- "lock_api",
- "parking_lot_core",
+ "dotenvy",
+ "proc-macro2",
+ "quote",
+ "syn 1.0.109",
]
[[package]]
-name = "parking_lot_core"
-version = "0.9.10"
+name = "dunce"
+version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
-dependencies = [
- "cfg-if",
- "libc",
- "redox_syscall",
+checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b"
+
+[[package]]
+name = "either"
+version = "1.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b"
+
+[[package]]
+name = "encoding_rs"
+version = "0.8.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
+name = "env_filter"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea"
+dependencies = [
+ "log",
+ "regex",
+]
+
+[[package]]
+name = "env_logger"
+version = "0.11.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9"
+dependencies = [
+ "anstream",
+ "anstyle",
+ "env_filter",
+ "humantime",
+ "log",
+]
+
+[[package]]
+name = "equivalent"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
+
+[[package]]
+name = "errno"
+version = "0.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
+dependencies = [
+ "libc",
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "fastrand"
+version = "2.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a"
+
+[[package]]
+name = "flume"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181"
+dependencies = [
+ "futures-core",
+ "futures-sink",
+ "spin",
+]
+
+[[package]]
+name = "fnv"
+version = "1.0.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
+
+[[package]]
+name = "foreign-types"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
+dependencies = [
+ "foreign-types-shared",
+]
+
+[[package]]
+name = "foreign-types-shared"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
+
+[[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 = "fs_extra"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
+
+[[package]]
+name = "futures-channel"
+version = "0.3.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78"
+dependencies = [
+ "futures-core",
+]
+
+[[package]]
+name = "futures-core"
+version = "0.3.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
+
+[[package]]
+name = "futures-sink"
+version = "0.3.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5"
+
+[[package]]
+name = "futures-task"
+version = "0.3.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004"
+
+[[package]]
+name = "futures-util"
+version = "0.3.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
+dependencies = [
+ "futures-core",
+ "futures-task",
+ "pin-project-lite",
+ "pin-utils",
+ "slab",
+]
+
+[[package]]
+name = "generic-array"
+version = "0.14.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
+dependencies = [
+ "typenum",
+ "version_check",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "wasi",
+]
+
+[[package]]
+name = "gimli"
+version = "0.28.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
+
+[[package]]
+name = "glob"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
+
+[[package]]
+name = "h2"
+version = "0.3.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8"
+dependencies = [
+ "bytes",
+ "fnv",
+ "futures-core",
+ "futures-sink",
+ "futures-util",
+ "http 0.2.12",
+ "indexmap",
+ "slab",
+ "tokio",
+ "tokio-util",
+ "tracing",
+]
+
+[[package]]
+name = "h2"
+version = "0.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab"
+dependencies = [
+ "atomic-waker",
+ "bytes",
+ "fnv",
+ "futures-core",
+ "futures-sink",
+ "http 1.1.0",
+ "indexmap",
+ "slab",
+ "tokio",
+ "tokio-util",
+ "tracing",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.13.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
+
+[[package]]
+name = "hashbrown"
+version = "0.14.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
+
+[[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.3.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
+
+[[package]]
+name = "home"
+version = "0.5.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
+dependencies = [
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "http"
+version = "0.2.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1"
+dependencies = [
+ "bytes",
+ "fnv",
+ "itoa",
+]
+
+[[package]]
+name = "http"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258"
+dependencies = [
+ "bytes",
+ "fnv",
+ "itoa",
+]
+
+[[package]]
+name = "http-body"
+version = "0.4.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2"
+dependencies = [
+ "bytes",
+ "http 0.2.12",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "http-body"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643"
+dependencies = [
+ "bytes",
+ "http 1.1.0",
+]
+
+[[package]]
+name = "http-body-util"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d"
+dependencies = [
+ "bytes",
+ "futures-core",
+ "http 1.1.0",
+ "http-body 1.0.0",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "httparse"
+version = "1.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904"
+
+[[package]]
+name = "httpdate"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
+
+[[package]]
+name = "humantime"
+version = "2.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
+
+[[package]]
+name = "hyper"
+version = "0.14.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80"
+dependencies = [
+ "bytes",
+ "futures-channel",
+ "futures-core",
+ "futures-util",
+ "h2 0.3.26",
+ "http 0.2.12",
+ "http-body 0.4.6",
+ "httparse",
+ "httpdate",
+ "itoa",
+ "pin-project-lite",
+ "tokio",
+ "tower-service",
+ "tracing",
+ "want",
+]
+
+[[package]]
+name = "hyper"
+version = "1.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d"
+dependencies = [
+ "bytes",
+ "futures-channel",
+ "futures-util",
+ "h2 0.4.5",
+ "http 1.1.0",
+ "http-body 1.0.0",
+ "httparse",
+ "httpdate",
+ "itoa",
+ "pin-project-lite",
"smallvec",
- "windows-targets 0.52.5",
+ "tokio",
+ "want",
+]
+
+[[package]]
+name = "hyper-rustls"
+version = "0.26.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c"
+dependencies = [
+ "futures-util",
+ "http 1.1.0",
+ "hyper 1.3.1",
+ "hyper-util",
+ "rustls 0.22.4",
+ "rustls-pki-types",
+ "tokio",
+ "tokio-rustls 0.25.0",
+ "tower-service",
+]
+
+[[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.3.1",
+ "hyper-util",
+ "native-tls",
+ "tokio",
+ "tokio-native-tls",
+ "tower-service",
+]
+
+[[package]]
+name = "hyper-util"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3d8d52be92d09acc2e01dddb7fde3ad983fc6489c7db4837e605bc3fca4cb63e"
+dependencies = [
+ "bytes",
+ "futures-channel",
+ "futures-util",
+ "http 1.1.0",
+ "http-body 1.0.0",
+ "hyper 1.3.1",
+ "pin-project-lite",
+ "socket2",
+ "tokio",
+ "tower",
+ "tower-service",
+ "tracing",
+]
+
+[[package]]
+name = "idna"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6"
+dependencies = [
+ "unicode-bidi",
+ "unicode-normalization",
+]
+
+[[package]]
+name = "indexmap"
+version = "2.2.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
+dependencies = [
+ "equivalent",
+ "hashbrown 0.14.5",
+]
+
+[[package]]
+name = "ipnet"
+version = "2.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3"
+
+[[package]]
+name = "is_terminal_polyfill"
+version = "1.70.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800"
+
+[[package]]
+name = "itertools"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
+dependencies = [
+ "either",
+]
+
+[[package]]
+name = "itoa"
+version = "1.0.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
+
+[[package]]
+name = "jobserver"
+version = "0.1.31"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "js-sys"
+version = "0.3.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d"
+dependencies = [
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "json5"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1"
+dependencies = [
+ "pest",
+ "pest_derive",
+ "serde",
+]
+
+[[package]]
+name = "lazy_static"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
+
+[[package]]
+name = "lazycell"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
+
+[[package]]
+name = "libc"
+version = "0.2.155"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
+
+[[package]]
+name = "libloading"
+version = "0.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
+dependencies = [
+ "cfg-if",
+ "windows-targets 0.52.5",
+]
+
+[[package]]
+name = "linked-hash-map"
+version = "0.5.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.4.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
+
+[[package]]
+name = "lock_api"
+version = "0.4.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
+dependencies = [
+ "autocfg",
+ "scopeguard",
+]
+
+[[package]]
+name = "log"
+version = "0.4.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
+
+[[package]]
+name = "matchit"
+version = "0.7.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"
+
+[[package]]
+name = "memchr"
+version = "2.7.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
+
+[[package]]
+name = "mime"
+version = "0.3.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
+
+[[package]]
+name = "minimal-lexical"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
+
+[[package]]
+name = "miniz_oxide"
+version = "0.7.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae"
+dependencies = [
+ "adler",
+]
+
+[[package]]
+name = "mio"
+version = "0.8.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c"
+dependencies = [
+ "libc",
+ "wasi",
+ "windows-sys 0.48.0",
+]
+
+[[package]]
+name = "mirai-annotations"
+version = "1.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1"
+
+[[package]]
+name = "mockito"
+version = "1.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2f6e023aa5bdf392aa06c78e4a4e6d498baab5138d0c993503350ebbc37bf1e"
+dependencies = [
+ "assert-json-diff",
+ "colored",
+ "futures-core",
+ "hyper 0.14.28",
+ "log",
+ "rand",
+ "regex",
+ "serde_json",
+ "serde_urlencoded",
+ "similar",
+ "tokio",
+]
+
+[[package]]
+name = "native-tls"
+version = "0.2.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466"
+dependencies = [
+ "libc",
+ "log",
+ "openssl",
+ "openssl-probe",
+ "openssl-sys",
+ "schannel",
+ "security-framework",
+ "security-framework-sys",
+ "tempfile",
+]
+
+[[package]]
+name = "nom"
+version = "7.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
+dependencies = [
+ "memchr",
+ "minimal-lexical",
+]
+
+[[package]]
+name = "num_cpus"
+version = "1.16.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
+dependencies = [
+ "hermit-abi",
+ "libc",
+]
+
+[[package]]
+name = "object"
+version = "0.32.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.19.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
+
+[[package]]
+name = "openssl"
+version = "0.10.64"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f"
+dependencies = [
+ "bitflags 2.5.0",
+ "cfg-if",
+ "foreign-types",
+ "libc",
+ "once_cell",
+ "openssl-macros",
+ "openssl-sys",
+]
+
+[[package]]
+name = "openssl-macros"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.65",
+]
+
+[[package]]
+name = "openssl-probe"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
+
+[[package]]
+name = "openssl-sys"
+version = "0.9.102"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2"
+dependencies = [
+ "cc",
+ "libc",
+ "pkg-config",
+ "vcpkg",
+]
+
+[[package]]
+name = "ordered-multimap"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4ed8acf08e98e744e5384c8bc63ceb0364e68a6854187221c18df61c4797690e"
+dependencies = [
+ "dlv-list",
+ "hashbrown 0.13.2",
+]
+
+[[package]]
+name = "parking_lot"
+version = "0.12.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb"
+dependencies = [
+ "lock_api",
+ "parking_lot_core",
+]
+
+[[package]]
+name = "parking_lot_core"
+version = "0.9.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "redox_syscall",
+ "smallvec",
+ "windows-targets 0.52.5",
+]
+
+[[package]]
+name = "paste"
+version = "1.0.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
+
+[[package]]
+name = "pathdiff"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
+
+[[package]]
+name = "percent-encoding"
+version = "2.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
+
+[[package]]
+name = "pest"
+version = "2.7.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8"
+dependencies = [
+ "memchr",
+ "thiserror",
+ "ucd-trie",
+]
+
+[[package]]
+name = "pest_derive"
+version = "2.7.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26293c9193fbca7b1a3bf9b79dc1e388e927e6cacaa78b4a3ab705a1d3d41459"
+dependencies = [
+ "pest",
+ "pest_generator",
+]
+
+[[package]]
+name = "pest_generator"
+version = "2.7.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ec22af7d3fb470a85dd2ca96b7c577a1eb4ef6f1683a9fe9a8c16e136c04687"
+dependencies = [
+ "pest",
+ "pest_meta",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.65",
+]
+
+[[package]]
+name = "pest_meta"
+version = "2.7.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d7a240022f37c361ec1878d646fc5b7d7c4d28d5946e1a80ad5a7a4f4ca0bdcd"
+dependencies = [
+ "once_cell",
+ "pest",
+ "sha2",
+]
+
+[[package]]
+name = "pin-project"
+version = "1.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3"
+dependencies = [
+ "pin-project-internal",
+]
+
+[[package]]
+name = "pin-project-internal"
+version = "1.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.65",
+]
+
+[[package]]
+name = "pin-project-lite"
+version = "0.2.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02"
+
+[[package]]
+name = "pin-utils"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
+
+[[package]]
+name = "pkg-config"
+version = "0.3.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
+
+[[package]]
+name = "ppv-lite86"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
+
+[[package]]
+name = "prettyplease"
+version = "0.2.20"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e"
+dependencies = [
+ "proc-macro2",
+ "syn 2.0.65",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.83"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.36"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "rand"
+version = "0.8.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
+dependencies = [
+ "libc",
+ "rand_chacha",
+ "rand_core",
+]
+
+[[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",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
+dependencies = [
+ "getrandom",
+]
+
+[[package]]
+name = "redox_syscall"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e"
+dependencies = [
+ "bitflags 2.5.0",
+]
+
+[[package]]
+name = "regex"
+version = "1.10.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-automata",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-automata"
+version = "0.4.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-syntax"
+version = "0.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
+
+[[package]]
+name = "reqwest"
+version = "0.12.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10"
+dependencies = [
+ "base64 0.22.1",
+ "bytes",
+ "encoding_rs",
+ "futures-core",
+ "futures-util",
+ "h2 0.4.5",
+ "http 1.1.0",
+ "http-body 1.0.0",
+ "http-body-util",
+ "hyper 1.3.1",
+ "hyper-rustls",
+ "hyper-tls",
+ "hyper-util",
+ "ipnet",
+ "js-sys",
+ "log",
+ "mime",
+ "native-tls",
+ "once_cell",
+ "percent-encoding",
+ "pin-project-lite",
+ "rustls 0.22.4",
+ "rustls-pemfile",
+ "rustls-pki-types",
+ "serde",
+ "serde_json",
+ "serde_urlencoded",
+ "sync_wrapper 0.1.2",
+ "system-configuration",
+ "tokio",
+ "tokio-native-tls",
+ "tokio-rustls 0.25.0",
+ "tower-service",
+ "url",
+ "wasm-bindgen",
+ "wasm-bindgen-futures",
+ "web-sys",
+ "webpki-roots",
+ "winreg",
+]
+
+[[package]]
+name = "ring"
+version = "0.17.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d"
+dependencies = [
+ "cc",
+ "cfg-if",
+ "getrandom",
+ "libc",
+ "spin",
+ "untrusted",
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "ron"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94"
+dependencies = [
+ "base64 0.21.7",
+ "bitflags 2.5.0",
+ "serde",
+ "serde_derive",
+]
+
+[[package]]
+name = "rumqttc"
+version = "0.24.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e1568e15fab2d546f940ed3a21f48bbbd1c494c90c99c4481339364a497f94a9"
+dependencies = [
+ "bytes",
+ "flume",
+ "futures-util",
+ "log",
+ "rustls-native-certs",
+ "rustls-pemfile",
+ "rustls-webpki 0.102.4",
+ "thiserror",
+ "tokio",
+ "tokio-rustls 0.25.0",
+]
+
+[[package]]
+name = "rust-ini"
+version = "0.19.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7e2a3bcec1f113553ef1c88aae6c020a369d03d55b58de9869a0908930385091"
+dependencies = [
+ "cfg-if",
+ "ordered-multimap",
+]
+
+[[package]]
+name = "rustc-demangle"
+version = "0.1.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
+
+[[package]]
+name = "rustc-hash"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
+
+[[package]]
+name = "rustix"
+version = "0.38.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
+dependencies = [
+ "bitflags 2.5.0",
+ "errno",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "rustls"
+version = "0.21.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e"
+dependencies = [
+ "log",
+ "ring",
+ "rustls-webpki 0.101.7",
+ "sct",
+]
+
+[[package]]
+name = "rustls"
+version = "0.22.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432"
+dependencies = [
+ "log",
+ "ring",
+ "rustls-pki-types",
+ "rustls-webpki 0.102.4",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "rustls"
+version = "0.23.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a218f0f6d05669de4eabfb24f31ce802035c952429d037507b4a4a39f0e60c5b"
+dependencies = [
+ "aws-lc-rs",
+ "log",
+ "once_cell",
+ "rustls-pki-types",
+ "rustls-webpki 0.102.4",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "rustls-native-certs"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792"
+dependencies = [
+ "openssl-probe",
+ "rustls-pemfile",
+ "rustls-pki-types",
+ "schannel",
+ "security-framework",
+]
+
+[[package]]
+name = "rustls-pemfile"
+version = "2.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d"
+dependencies = [
+ "base64 0.22.1",
+ "rustls-pki-types",
+]
+
+[[package]]
+name = "rustls-pki-types"
+version = "1.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d"
+
+[[package]]
+name = "rustls-webpki"
+version = "0.101.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765"
+dependencies = [
+ "ring",
+ "untrusted",
+]
+
+[[package]]
+name = "rustls-webpki"
+version = "0.102.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e"
+dependencies = [
+ "aws-lc-rs",
+ "ring",
+ "rustls-pki-types",
+ "untrusted",
+]
+
+[[package]]
+name = "rustversion"
+version = "1.0.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6"
+
+[[package]]
+name = "ryu"
+version = "1.0.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
+
+[[package]]
+name = "schannel"
+version = "0.1.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534"
+dependencies = [
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "scopeguard"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+
+[[package]]
+name = "sct"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414"
+dependencies = [
+ "ring",
+ "untrusted",
+]
+
+[[package]]
+name = "security-framework"
+version = "2.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0"
+dependencies = [
+ "bitflags 2.5.0",
+ "core-foundation",
+ "core-foundation-sys",
+ "libc",
+ "security-framework-sys",
]
[[package]]
-name = "pin-project-lite"
-version = "0.2.14"
+name = "security-framework-sys"
+version = "2.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02"
+checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
[[package]]
-name = "pin-utils"
+name = "serde"
+version = "1.0.203"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde-toml-merge"
+version = "0.3.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e75a6b6c577215161d30ba4e13fb493c435a8b4140c442e590b61b4b2a27a226"
+dependencies = [
+ "toml",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.203"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.65",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.117"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3"
+dependencies = [
+ "itoa",
+ "ryu",
+ "serde",
+]
+
+[[package]]
+name = "serde_path_to_error"
+version = "0.1.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6"
+dependencies = [
+ "itoa",
+ "serde",
+]
+
+[[package]]
+name = "serde_spanned"
+version = "0.6.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "serde_urlencoded"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
+dependencies = [
+ "form_urlencoded",
+ "itoa",
+ "ryu",
+ "serde",
+]
+
+[[package]]
+name = "sha2"
+version = "0.10.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
+dependencies = [
+ "cfg-if",
+ "cpufeatures",
+ "digest",
+]
+
+[[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.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "similar"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fa42c91313f1d05da9b26f267f931cf178d4aba455b4c4622dd7355eb80c6640"
+
+[[package]]
+name = "slab"
+version = "0.4.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "smallvec"
+version = "1.13.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
+
+[[package]]
+name = "socket2"
+version = "0.5.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c"
+dependencies = [
+ "libc",
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "spin"
+version = "0.9.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
+dependencies = [
+ "lock_api",
+]
+
+[[package]]
+name = "strsim"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
+
+[[package]]
+name = "subtle"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
+
+[[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.65"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2863d96a84c6439701d7a38f9de935ec562c8832cc55d1dde0f513b52fad106"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "sync_wrapper"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
+
+[[package]]
+name = "sync_wrapper"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394"
+
+[[package]]
+name = "system-configuration"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7"
+dependencies = [
+ "bitflags 1.3.2",
+ "core-foundation",
+ "system-configuration-sys",
+]
+
+[[package]]
+name = "system-configuration-sys"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
+
+[[package]]
+name = "tagoio-relay"
version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "axum",
+ "axum-server",
+ "clap",
+ "config",
+ "dotenvy",
+ "dotenvy_macro",
+ "env_logger",
+ "home",
+ "log",
+ "mockito",
+ "once_cell",
+ "openssl",
+ "rand",
+ "regex",
+ "reqwest",
+ "rumqttc",
+ "rustls-native-certs",
+ "serde",
+ "serde_json",
+ "tokio",
+ "tokio-rustls 0.26.0",
+ "toml-env",
+]
+
+[[package]]
+name = "tempfile"
+version = "3.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
+checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1"
+dependencies = [
+ "cfg-if",
+ "fastrand",
+ "rustix",
+ "windows-sys 0.52.0",
+]
[[package]]
-name = "ppv-lite86"
-version = "0.2.17"
+name = "thiserror"
+version = "1.0.61"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
+checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709"
+dependencies = [
+ "thiserror-impl",
+]
[[package]]
-name = "proc-macro2"
-version = "1.0.83"
+name = "thiserror-impl"
+version = "1.0.61"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.65",
+]
+
+[[package]]
+name = "tiny-keccak"
+version = "2.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237"
+dependencies = [
+ "crunchy",
+]
+
+[[package]]
+name = "tinyvec"
+version = "1.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
+dependencies = [
+ "tinyvec_macros",
+]
+
+[[package]]
+name = "tinyvec_macros"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
+
+[[package]]
+name = "tokio"
+version = "1.37.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787"
+dependencies = [
+ "backtrace",
+ "bytes",
+ "libc",
+ "mio",
+ "num_cpus",
+ "parking_lot",
+ "pin-project-lite",
+ "signal-hook-registry",
+ "socket2",
+ "tokio-macros",
+ "windows-sys 0.48.0",
+]
+
+[[package]]
+name = "tokio-macros"
+version = "2.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.65",
+]
+
+[[package]]
+name = "tokio-native-tls"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
+dependencies = [
+ "native-tls",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-openssl"
+version = "0.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ffab79df67727f6acf57f1ff743091873c24c579b1e2ce4d8f53e47ded4d63d"
+dependencies = [
+ "futures-util",
+ "openssl",
+ "openssl-sys",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-rustls"
+version = "0.24.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081"
+dependencies = [
+ "rustls 0.21.12",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-rustls"
+version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43"
+checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f"
dependencies = [
- "unicode-ident",
+ "rustls 0.22.4",
+ "rustls-pki-types",
+ "tokio",
]
[[package]]
-name = "quote"
-version = "1.0.36"
+name = "tokio-rustls"
+version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
+checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4"
dependencies = [
- "proc-macro2",
+ "rustls 0.23.9",
+ "rustls-pki-types",
+ "tokio",
]
[[package]]
-name = "rand"
-version = "0.8.5"
+name = "tokio-util"
+version = "0.7.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
+checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1"
dependencies = [
- "libc",
- "rand_chacha",
- "rand_core",
+ "bytes",
+ "futures-core",
+ "futures-sink",
+ "pin-project-lite",
+ "tokio",
]
[[package]]
-name = "rand_chacha"
-version = "0.3.1"
+name = "toml"
+version = "0.8.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
+checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba"
dependencies = [
- "ppv-lite86",
- "rand_core",
+ "serde",
+ "serde_spanned",
+ "toml_datetime",
+ "toml_edit",
]
[[package]]
-name = "rand_core"
-version = "0.6.4"
+name = "toml-env"
+version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
+checksum = "a740df0c7ded7632d527f5e4015c28c19803c9b8d6e87cc7ae72ae4d68d6f4b0"
dependencies = [
- "getrandom",
+ "serde",
+ "serde-toml-merge",
+ "thiserror",
+ "toml",
]
[[package]]
-name = "redox_syscall"
-version = "0.5.1"
+name = "toml_datetime"
+version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e"
+checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf"
dependencies = [
- "bitflags",
+ "serde",
]
[[package]]
-name = "ring"
-version = "0.17.8"
+name = "toml_edit"
+version = "0.22.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d"
+checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c"
dependencies = [
- "cc",
- "cfg-if",
- "getrandom",
- "libc",
- "spin",
- "untrusted",
- "windows-sys 0.52.0",
+ "indexmap",
+ "serde",
+ "serde_spanned",
+ "toml_datetime",
+ "winnow",
]
[[package]]
-name = "rumqttc"
-version = "0.24.0"
+name = "tower"
+version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e1568e15fab2d546f940ed3a21f48bbbd1c494c90c99c4481339364a497f94a9"
+checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
dependencies = [
- "bytes",
- "flume",
+ "futures-core",
"futures-util",
- "log",
- "rustls-native-certs",
- "rustls-pemfile",
- "rustls-webpki",
- "thiserror",
+ "pin-project",
+ "pin-project-lite",
"tokio",
- "tokio-rustls",
+ "tower-layer",
+ "tower-service",
+ "tracing",
]
[[package]]
-name = "rustc-demangle"
-version = "0.1.24"
+name = "tower-layer"
+version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
+checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0"
[[package]]
-name = "rustls"
-version = "0.22.4"
+name = "tower-service"
+version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432"
+checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52"
+
+[[package]]
+name = "tracing"
+version = "0.1.40"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef"
dependencies = [
"log",
- "ring",
- "rustls-pki-types",
- "rustls-webpki",
- "subtle",
- "zeroize",
+ "pin-project-lite",
+ "tracing-core",
]
[[package]]
-name = "rustls-native-certs"
-version = "0.7.0"
+name = "tracing-core"
+version = "0.1.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792"
+checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54"
dependencies = [
- "openssl-probe",
- "rustls-pemfile",
- "rustls-pki-types",
- "schannel",
- "security-framework",
+ "once_cell",
]
[[package]]
-name = "rustls-pemfile"
-version = "2.1.2"
+name = "try-lock"
+version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d"
-dependencies = [
- "base64",
- "rustls-pki-types",
-]
+checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
-name = "rustls-pki-types"
-version = "1.7.0"
+name = "typenum"
+version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d"
+checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]]
-name = "rustls-webpki"
-version = "0.102.4"
+name = "ucd-trie"
+version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e"
-dependencies = [
- "ring",
- "rustls-pki-types",
- "untrusted",
-]
+checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9"
[[package]]
-name = "schannel"
-version = "0.1.23"
+name = "unicode-bidi"
+version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534"
-dependencies = [
- "windows-sys 0.52.0",
-]
+checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75"
[[package]]
-name = "scopeguard"
-version = "1.2.0"
+name = "unicode-ident"
+version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
-name = "security-framework"
-version = "2.11.0"
+name = "unicode-normalization"
+version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0"
+checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5"
dependencies = [
- "bitflags",
- "core-foundation",
- "core-foundation-sys",
- "libc",
- "security-framework-sys",
+ "tinyvec",
]
[[package]]
-name = "security-framework-sys"
-version = "2.11.0"
+name = "unicode-segmentation"
+version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7"
-dependencies = [
- "core-foundation-sys",
- "libc",
-]
+checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
[[package]]
-name = "signal-hook-registry"
-version = "1.4.2"
+name = "untrusted"
+version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1"
-dependencies = [
- "libc",
-]
+checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
[[package]]
-name = "slab"
-version = "0.4.9"
+name = "url"
+version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"
+checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633"
dependencies = [
- "autocfg",
+ "form_urlencoded",
+ "idna",
+ "percent-encoding",
]
[[package]]
-name = "smallvec"
-version = "1.13.2"
+name = "utf8parse"
+version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
+checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
-name = "socket2"
-version = "0.5.7"
+name = "vcpkg"
+version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c"
-dependencies = [
- "libc",
- "windows-sys 0.52.0",
-]
+checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
-name = "spin"
-version = "0.9.8"
+name = "version_check"
+version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
+checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
+
+[[package]]
+name = "want"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e"
dependencies = [
- "lock_api",
+ "try-lock",
]
[[package]]
-name = "subtle"
-version = "2.5.0"
+name = "wasi"
+version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
+checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
-name = "syn"
-version = "2.0.65"
+name = "wasm-bindgen"
+version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d2863d96a84c6439701d7a38f9de935ec562c8832cc55d1dde0f513b52fad106"
+checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8"
dependencies = [
- "proc-macro2",
- "quote",
- "unicode-ident",
+ "cfg-if",
+ "wasm-bindgen-macro",
]
[[package]]
-name = "thiserror"
-version = "1.0.61"
+name = "wasm-bindgen-backend"
+version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709"
+checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da"
dependencies = [
- "thiserror-impl",
+ "bumpalo",
+ "log",
+ "once_cell",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.65",
+ "wasm-bindgen-shared",
]
[[package]]
-name = "thiserror-impl"
-version = "1.0.61"
+name = "wasm-bindgen-futures"
+version = "0.4.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533"
+checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0"
dependencies = [
- "proc-macro2",
- "quote",
- "syn",
+ "cfg-if",
+ "js-sys",
+ "wasm-bindgen",
+ "web-sys",
]
[[package]]
-name = "tokio"
-version = "1.37.0"
+name = "wasm-bindgen-macro"
+version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787"
+checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726"
dependencies = [
- "backtrace",
- "bytes",
- "libc",
- "mio",
- "num_cpus",
- "parking_lot",
- "pin-project-lite",
- "signal-hook-registry",
- "socket2",
- "tokio-macros",
- "windows-sys 0.48.0",
+ "quote",
+ "wasm-bindgen-macro-support",
]
[[package]]
-name = "tokio-macros"
-version = "2.2.0"
+name = "wasm-bindgen-macro-support"
+version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
+checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
dependencies = [
"proc-macro2",
"quote",
- "syn",
+ "syn 2.0.65",
+ "wasm-bindgen-backend",
+ "wasm-bindgen-shared",
]
[[package]]
-name = "tokio-rustls"
-version = "0.25.0"
+name = "wasm-bindgen-shared"
+version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f"
-dependencies = [
- "rustls",
- "rustls-pki-types",
- "tokio",
-]
+checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
[[package]]
-name = "unicode-ident"
-version = "1.0.12"
+name = "web-sys"
+version = "0.3.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
+checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef"
+dependencies = [
+ "js-sys",
+ "wasm-bindgen",
+]
[[package]]
-name = "untrusted"
-version = "0.9.0"
+name = "webpki-roots"
+version = "0.26.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
+checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009"
+dependencies = [
+ "rustls-pki-types",
+]
[[package]]
-name = "wasi"
-version = "0.11.0+wasi-snapshot-preview1"
+name = "which"
+version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
+checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
+dependencies = [
+ "either",
+ "home",
+ "once_cell",
+ "rustix",
+]
[[package]]
name = "windows-sys"
@@ -738,8 +2593,50 @@ version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
+[[package]]
+name = "winnow"
+version = "0.6.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "winreg"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5"
+dependencies = [
+ "cfg-if",
+ "windows-sys 0.48.0",
+]
+
+[[package]]
+name = "yaml-rust"
+version = "0.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
+dependencies = [
+ "linked-hash-map",
+]
+
[[package]]
name = "zeroize"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d"
+dependencies = [
+ "zeroize_derive",
+]
+
+[[package]]
+name = "zeroize_derive"
+version = "1.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.65",
+]
diff --git a/Cargo.toml b/Cargo.toml
index 696baca..0f6c7dd 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,9 +1,31 @@
[package]
-name = "mqtt-bridge"
+name = "tagoio-relay"
version = "0.1.0"
edition = "2021"
+[dev-dependencies]
+mockito = "1.4.0"
+
[dependencies]
+anyhow = "1.0.86"
+axum = "0.7.5"
+axum-server = { version = "0.6.0", features = ["tls-rustls", "tls-openssl"] }
+clap = { version = "4.5.4", features = ["derive"] }
+config = "0.14.0"
+dotenvy = "0.15.7"
+dotenvy_macro = "0.15.7"
+env_logger = "0.11.3"
+home = "0.5.9"
+log = "0.4.21"
+once_cell = "1.19.0"
+openssl = "0.10.64"
rand = "0.8.5"
-rumqttc = "0.24.0"
+regex = "1.10.4"
+reqwest = { version = "0.12.4", features = ["rustls-tls", "json"] }
+rumqttc = { version = "0.24.0" }
+rustls-native-certs = "0.7.0"
+serde = "1.0.203"
+serde_json = "1.0.117"
tokio = {version = "1.37.0", features = ["full", "rt-multi-thread"]}
+tokio-rustls = "0.26.0"
+toml-env = "1.2.0"
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..102b4e8
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,27 @@
+FROM rust:slim-bookworm as build
+ARG TAGOIO_SOURCE_FOLDER="/tago-io"
+
+RUN apt update
+RUN apt install -y protobuf-compiler libssl-dev gcc pkg-config build-essential
+
+RUN mkdir -p ${TAGOIO_SOURCE_FOLDER}
+WORKDIR ${TAGOIO_SOURCE_FOLDER}
+ADD . ${TAGOIO_SOURCE_FOLDER}
+
+RUN cargo build --release
+
+FROM debian:bookworm-slim
+ARG TAGOIO_SOURCE_FOLDER="/tago-io"
+
+RUN apt update
+RUN apt install -y build-essential netcat-traditional ca-certificates
+RUN apt-get clean && rm -rf /var/lib/apt/lists/*
+
+RUN mkdir -p ${TAGOIO_SOURCE_FOLDER}
+WORKDIR ${TAGOIO_SOURCE_FOLDER}
+COPY --from=build ${TAGOIO_SOURCE_FOLDER}/target/release/tagoio-mqtt-relay .
+
+RUN /tago-io/tagoio-mqtt-relay init
+
+ENTRYPOINT ["/tago-io/tagoio-mqtt-relay"]
+CMD ["start"]
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..f49a4e1
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,201 @@
+ 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.
\ No newline at end of file
diff --git a/README.md b/README.md
index 350d60f..a8f774b 100644
--- a/README.md
+++ b/README.md
@@ -1,24 +1,160 @@
+# TagoIO MQTT Relay
-Welcome to the **MQTT Bridge of Doom**! This is the place where we try to build a bridge between TagoIO and customer brokers without losing our sanity.
+Welcome to the TagoIO MQTT Relay! This software bridges your MQTT Broker and the TagoIO platform, allowing seamless integration and data flow. It's a fast, open-source, and scalable solution written in Rust.
-## What is this?
+## Table of Contents
-This is a Rust-powered, always-running, MQTT Bridge between TagoIO and customer brokers. π
+- [Introduction](#introduction)
+- [Features](#features)
+- [Getting Started](#getting-started)
+ - [Prerequisites](#prerequisites)
+ - [Installation](#installation)
+ - [Configuration](#configuration)
+ - [Running the Relay](#running-the-relay)
+- [Docker Setup](#docker-setup)
+- [CLI Commands](#cli-commands)
+- [Configuration File](#configuration-file)
+- [License](#license)
-## Why does it exist?
-Imagine this: TagoIO's broker is having heart attacks, and we need to save the day by building a bridge. Sounds heroic, right?
+## Introduction
-## Current Status
+The TagoIO MQTT Relay connects to your MQTT Broker on predefined topics and redirects the information to TagoIO Devices. It uses TagoIO Integration Network and Connector, alongside an Authorization Key from your TagoIO Profile.
-### Prototype Phase π οΈ
+## Features
-- **MQTT Connection:** β
-- **Asynchronous Updates:** β
-- **Sanity:** β (Still under investigation)
+- **Written in Rust**: Fast and reliable performance.
+- **Open Source**: Available on GitHub for community contributions.
+- **Scalable**: Easily handles increasing data loads.
+- **Docker Support**: Simplifies deployment and scaling.
-## The Journey So Far
+## Getting Started
-- **Hours Spent:** 10 β³
-- **Brain Cells Lost:** Countless π§ π₯
-- **Coffee Consumed:** Gallons βοΈ
-- **Rust Compiler Errors:** Infinite βΎοΈ
\ No newline at end of file
+### Prerequisites
+
+Before you begin, ensure you have:
+
+- A TagoIO account.
+- Access to an MQTT Broker (e.g., HiveMQ, EMQX).
+
+### Installation
+
+1. **Download the Binary**: Get the `tagoio-relay` binary from the [GitHub releases page](./releases/latest).
+2. **Set Permission Rights**: Give the binary executable permissions:
+ ```sh
+ chmod +x tagoio-relay
+ ```
+3. **Resolve Malicious Software Alert (macOS)**: Follow [Apple Support](https://support.apple.com) instructions if you encounter a malicious software alert.
+4. **Verify Installation**: Check if the `tagoio-relay` is working properly:
+ ```sh
+ ./tagoio-relay --help
+ ```
+
+### Configuration
+
+1. **Create a Network in TagoIO**:
+ - Navigate to Integrations in your TagoIO Profile and create a new Network.
+ - Enable Serial and write a Payload Parser:
+ ```js
+ if (Array.isArray(payload)) {
+ const payload_received = payload.find(x => x.variable === "payload");
+ serial = payload_received?.metadata.topic.split("/").pop();
+ }
+ ```
+2. **Generate Network Token**: Generate and save the Network Token.
+3. **Create a Connector**: Create a Connector for your Network.
+4. **Generate Authorization**: Navigate to Devices > Authorizations in TagoIO and generate an authorization token.
+5. **Create a Device**: Create a Device with a Serial to use later on the Broker.
+6. **Set Up an MQTT Broker**: Create or use a public MQTT Broker.
+7. **Gather Broker Details**: Obtain the Address, Port, and Credentials of your MQTT Broker.
+
+### Running the Relay
+
+1. **Initialize Config File**:
+ ```sh
+ ./tagoio-relay init
+ ```
+2. **Edit Config File**: Modify the generated `config.toml`:
+ ```toml
+ [relay]
+ network_token="Your-Network-Token"
+ authorization_token="Your-Authorization-Token"
+ tagoio_url="https://api.tago.io"
+ downlink_port="3001"
+
+ [relay.mqtt]
+ client_id="tagoio-relay"
+ tls_enabled=false
+ address="localhost"
+ port=1883
+ subscribe=["/tago/#", "/topic/+"]
+ username="my-username"
+ password="my-password"
+ ```
+3. **Start the Relay**:
+ ```sh
+ ./tagoio-relay start
+ ```
+4. **Publish Messages to Broker**: Publish messages to the Broker on your chosen topics and see them forwarded to your TagoIO device.
+
+## Docker Setup
+
+To run the TagoIO MQTT Relay using Docker, use the following command:
+
+```sh
+docker run -p 3001:3001 -it --rm --name my-test tagoio/tagorelay start --no-daemon
+```
+
+### Image Variants
+
+- **tagoio/tagocore:**: Main image for general use.
+- **tagoio/tagocore:alpine**: Based on Alpine Linux, ideal for smaller image sizes.
+- **tagoio/tagocore:bullseye**: Based on Debian 11.
+
+## CLI Commands
+
+The CLI has two main commands: `init` and `start`.
+
+### `init`
+
+Generates the `config.toml` file required for setting up the Relay.
+
+```sh
+tagoio-relay init [--config-path /path/to/config]
+```
+
+### `start`
+
+Starts the MQTT Relay service.
+
+```sh
+tagoio-relay start [--verbose info,mqtt] [--config-path /path/to/config.toml]
+```
+
+## Configuration File
+
+The `config.toml` file contains the Relay parameters. Here is a reference:
+
+```toml
+[relay]
+network_token="Your-Network-Token"
+authorization_token="Your-Authorization-Token"
+tagoio_url="https://api.tago.io"
+downlink_port="3001"
+
+[relay.mqtt]
+client_id="tagoio-relay"
+tls_enabled=false
+address="localhost"
+port=1883
+subscribe=["/tago/#", "/topic/+"]
+username="my-username"
+password="my-password"
+```
+
+## License
+
+The TagoIO MQTT Relay is licensed under the Apache License. See the [LICENSE](./LICENSE) file for more details.
+
+---
+
+Thank you for using TagoIO MQTT Relay! If you have any questions or need further assistance, feel free to reach out via [GitHub Issues](#) or our [community forum](#). π
\ No newline at end of file
diff --git a/dockerhub.sh b/dockerhub.sh
new file mode 100644
index 0000000..5f2fe17
--- /dev/null
+++ b/dockerhub.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+FULL_VERSION=$1
+
+SPLIT=(${FULL_VERSION//./ })
+MAJOR=${SPLIT[0]}
+MINOR=${SPLIT[1]}
+PATCH=${SPLIT[2]}
+
+# Alpine
+# docker buildx build --push --build-arg TAGORELAY_VERSION=${FULL_VERSION} \
+# --platform linux/arm64/v8,linux/amd64 \
+# --tag tagoio/tagorelay:alpine \
+# --tag tagoio/tagorelay:${MAJOR}.${MINOR}-alpine \
+# --tag tagoio/tagorelay:${MAJOR}.${MINOR}.${PATCH}-alpine .
+
+# Debian
+docker buildx build --push --build-arg TAGORELAY_VERSION=${FULL_VERSION} \
+ --platform linux/arm/v7,linux/arm64/v8,linux/amd64 \
+ --tag tagoio/tagorelay \
+ --tag tagoio/tagorelay:debian \
+ --tag tagoio/tagorelay:bullseye \
+ --tag tagoio/tagorelay:${MAJOR}.${MINOR}-bullseye \
+ --tag tagoio/tagorelay:${MAJOR}.${MINOR}.${PATCH}-bullseye \
+ --tag tagoio/tagorelay:${MAJOR}.${MINOR} \
+ --tag tagoio/tagorelay:${MAJOR}.${MINOR}.${PATCH} .
diff --git a/examples/docker-compose/docker-compose.yml b/examples/docker-compose/docker-compose.yml
new file mode 100644
index 0000000..6cb6c66
--- /dev/null
+++ b/examples/docker-compose/docker-compose.yml
@@ -0,0 +1,8 @@
+services:
+ my-eclipse:
+ image: tagoio/tago-relay:latest
+ restart: always
+ ports:
+ - "3001:3001"
+ volumes:
+ - ./config.toml:/root/.config/.tagoio-mqtt-relay.toml
diff --git a/src/default_config.toml b/src/default_config.toml
new file mode 100644
index 0000000..9cff33a
--- /dev/null
+++ b/src/default_config.toml
@@ -0,0 +1,17 @@
+[relay]
+network_token="Your-Network-Token" # Generate a Network Token under your TagoIO Network Settings
+authorization_token="Your-Authorization-Token" # Generate an Authorization Token under your TagoIO > Devices > Authorizations
+tagoio_url="https://api.tago.io" # Default
+downlink_port="3001" # Default is 3000
+
+[relay.mqtt]
+client_id="tagoio-relay" # Default is tagoio-relay
+tls_enabled=false
+address="localhost"
+port=1883
+subscribe=["/tago/#", "/tago/+"] # MQTT topics to subscribe to
+username="my-username"
+password="my-passowrd"
+# broker_tls_ca="" # The CA certificate. Alternative to username and password
+# broker_tls_cert="" # The client certificate.
+# broker_tls_key="" # The client key.
diff --git a/src/main.rs b/src/main.rs
index 3058949..58986ba 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,114 +1,95 @@
+mod relay;
mod schema;
mod services;
mod utils;
-use schema::BridgeConfig;
-use services::bridge::run_bridge;
-use services::tagoio::fetch_customer_settings;
-use std::collections::HashMap;
-use std::sync::{Arc, Mutex};
-use std::time::Duration;
-use tokio;
-use tokio::sync::mpsc;
-use tokio::task::JoinHandle;
-use tokio::time::sleep;
+use clap::{Parser, Subcommand};
+use schema::ConfigFile;
+use utils::init_config;
-use crate::schema::Customer;
+use once_cell::sync::Lazy;
+use std::sync::RwLock;
-// TODO: How do I setup max tasks?
-#[tokio::main]
-async fn main() {
- // Simulate fetching customer and bridge configurations
- // ? How are we going to receive updates? Pulling the Database ? or Redis ? or a hook ?
- let customers = fetch_customer_settings().await;
- let customers = Arc::new(Mutex::new(customers));
-
- let (tx, mut rx) = mpsc::channel(32);
-
- // Spawn a task to simulate receiving updates
- let tx_clone = tx.clone();
- tokio::task::spawn(async move {
- simulate_redis_updates(tx_clone).await;
- });
-
- let customers_clone = Arc::clone(&customers);
- tokio::task::spawn(async move {
- while let Some(message) = rx.recv().await {
- match message {
- UpdateMessage::UpdateCustomer(updated_customer) => {
- let mut customers = customers_clone.lock().unwrap();
- customers.insert(updated_customer.id, updated_customer);
- }
- UpdateMessage::RemoveCustomer(customer_id) => {
- let mut customers = customers_clone.lock().unwrap();
- customers.remove(&customer_id);
- }
- }
- }
- });
-
- let mut tasks = HashMap::new();
-
- loop {
- let customers = customers.lock().unwrap().clone();
-
- for (customer_id, customer) in customers.iter() {
- for bridge in &customer.bridges {
- let bridge_id = bridge.id.clone();
- println!("{}", bridge_id);
- if !tasks.contains_key(&bridge_id) {
- let bridge_clone = Arc::clone(bridge);
- let task = tokio::task::spawn(async move {
- run_bridge(bridge_clone).await;
- });
- tasks.insert(bridge_id.clone(), task);
- }
- }
- }
+// const SSL_CERTIFICATE: &str = include_str!("../certs/ca.crt");
+static CONFIG_FILE: Lazy>> = Lazy::new(|| RwLock::new(None));
- // Wait for all tasks to complete
- tasks.retain(|_, task| !task.is_finished());
-
- sleep(Duration::from_secs(5)).await;
- println!("All bridge tasks completed.");
- }
+#[derive(Parser)]
+#[command(name = "tago-relay")]
+#[command(about = "A CLI for managing the MQTT Relay service", long_about = None)]
+struct Cli {
+ #[command(subcommand)]
+ command: Commands,
}
-/**
-* Mock customer and bridge configurations
-*/
-
-enum UpdateMessage {
- UpdateCustomer(Customer),
- RemoveCustomer(u32),
+#[derive(Subcommand)]
+enum Commands {
+ #[command(
+ about = "Initialize the configuration file",
+ long_about = "Initialize the configuration file for the MQTT Relay service.\n\n\
+ This command creates a `config.toml` file containing the Relay parameters.\n\n\
+ Examples:\n\
+ - Initialize with default path:\n\
+ tago-relay init\n\
+ - Initialize with custom path:\n\
+ tago-relay init --config-path /path/to/config"
+ )]
+ Init {
+ /// Path to the configuration file
+ #[arg(short, long)]
+ config_path: Option,
+ },
+ #[command(
+ about = "Start the MQTT Relay service",
+ long_about = "Start the MQTT Relay service to create a bridge between TagoIO and customer brokers.\n\n\
+ This command starts the Relay, which is a client that will connect to the user Broker and send data to the TagoIO platform.\n\n\
+ The `config_path` option sets the path for the `config.toml` file. If not passed, it defaults to the environment variable `RELAY_CONFIG_PATH` or `$HOME/.config/tagoio-mqtt-relay.toml`.\n\n\
+ The `verbose` option accepts a string with types of logs: `info`, `error`, `mqtt`, `network`. Defaults to `info,error`.\n\n\
+ Examples:\n\
+ - Start with default configuration:\n\
+ tago-relay start\n\
+ - Start with verbose mode:\n\
+ tago-relay start --verbose info,mqtt\n\
+ - Start with custom configuration path:\n\
+ tago-relay start --config-path /path/to/config.toml"
+ )]
+ Start {
+ /// Verbose mode (-v)
+ #[arg(short, long)]
+ verbose: Option,
+
+ /// Path to the configuration file
+ #[arg(short, long)]
+ config_path: Option,
+ },
}
-async fn simulate_redis_updates(tx: mpsc::Sender) {
- loop {
- sleep(Duration::from_secs(2)).await;
-
- println!("Simulating Redis updates");
-
- // Simulate an update
- let mut bridges = Vec::new();
- for j in 1..=2 {
- let client_id = format!("client_2_{}", j);
- let bridge = BridgeConfig {
- id: format!("2_{}", j),
- address: "mqtt.tago.io".to_string(),
- version: "3.1.1".to_string(),
- tls: false,
- client_id,
- username: Some("Token".to_string()),
- password: Some("new_password".to_string()),
- certificate: None,
- };
- bridges.push(Arc::new(bridge));
- }
- let updated_customer = Customer { id: 1, bridges };
+#[tokio::main]
+async fn main() {
+ let cli = Cli::parse();
- tx.send(UpdateMessage::UpdateCustomer(updated_customer))
- .await
- .unwrap();
+ match &cli.command {
+ Commands::Init { config_path } => {
+ init_config(config_path.as_deref());
+ }
+ Commands::Start { verbose, config_path } => {
+ let log_level: String = verbose
+ .as_ref()
+ .map(|v| v.to_string())
+ .unwrap_or_else(|| "error,info".to_string());
+
+ env_logger::init_from_env(env_logger::Env::new().default_filter_or(log_level));
+
+ let config = utils::fetch_config_file(config_path.clone());
+ if let Some(config) = config {
+ *CONFIG_FILE.write().unwrap() = Some(config);
+ } else {
+ log::error!("Failed to load configuration file.");
+ std::process::exit(1);
+ }
+
+ if let Err(e) = relay::start_relay().await {
+ log::error!("Error starting relay: {}", e);
+ }
}
+ }
}
diff --git a/src/relay.rs b/src/relay.rs
new file mode 100644
index 0000000..4f0e6fe
--- /dev/null
+++ b/src/relay.rs
@@ -0,0 +1,231 @@
+use crate::{
+ services::{
+ mqttrelay::{run_mqtt_relay_connection, PublishMessage},
+ tagoio::{get_relay_list, verify_network_token},
+ },
+ CONFIG_FILE,
+};
+use anyhow::Result;
+use axum::{
+ extract::rejection::JsonRejection,
+ http::StatusCode,
+ response::{IntoResponse, Response},
+ routing::post,
+ Extension, Json, Router,
+};
+
+use axum_server::tls_openssl::OpenSSLConfig;
+use openssl::{
+ pkey::PKey,
+ ssl::{SslAcceptor, SslMethod, SslVerifyMode},
+ x509::{store::X509StoreBuilder, X509},
+};
+
+use dotenvy_macro::dotenv;
+use serde_json::json;
+use std::{collections::HashMap, error::Error, net::SocketAddr, sync::Arc, time::Duration};
+use tokio::{
+ sync::{mpsc, RwLock},
+ time::sleep,
+};
+
+/**
+ * Global constants
+ */
+const RESTART_DELAY_SECS: u64 = 120;
+
+#[cfg(debug_assertions)]
+const HOST_ADDRESS: &str = "127.0.0.1";
+
+#[cfg(not(debug_assertions))]
+const HOST_ADDRESS: &str = "::"; // ? External IPv4/IPv6 support
+
+fn create_ssl_acceptor() -> Result, openssl::error::ErrorStack> {
+ // Certificates contents are stored in the environment variables
+ let cert = dotenv!("SERVER_SSL_CERT").as_bytes();
+ let key = dotenv!("SERVER_SSL_KEY").as_bytes();
+ let ca = dotenv!("SERVER_SSL_CA").as_bytes();
+
+ let cert = X509::from_pem(cert)?;
+ let key = PKey::private_key_from_pem(key)?;
+ let ca = X509::from_pem(ca)?;
+
+ let mut acceptor = SslAcceptor::mozilla_intermediate(SslMethod::tls())?;
+ acceptor.set_private_key(&key)?;
+ acceptor.set_certificate(&cert)?;
+ // acceptor.add_client_ca(&ca)?;
+ acceptor.check_private_key()?;
+
+ // Create a new X509Store and add the CA certificate to it
+ let mut store_builder = X509StoreBuilder::new()?;
+ store_builder.add_cert(ca.clone())?;
+ let store = store_builder.build();
+
+ // Set the CA store for the acceptor
+ acceptor.set_cert_store(store);
+
+ // Add the CA certificate as a client CA
+ acceptor.add_client_ca(&ca)?;
+
+ acceptor.set_verify(SslVerifyMode::PEER | SslVerifyMode::FAIL_IF_NO_PEER_CERT);
+ Ok(Arc::new(acceptor.build()))
+}
+
+/**
+ * Start the MQTT Relay service
+ */
+pub async fn start_relay() -> Result<()> {
+ // Simulate fetching relay configurations
+ let relay_list = get_relay_list().await?;
+ let relay_list = Arc::new(RwLock::new(relay_list));
+
+ for relay in relay_list.read().await.iter() {
+ log::info!(target: "network", "Verifying network token for relay: {}", relay.id);
+ if let Err(e) = verify_network_token(relay).await {
+ log::error!(target: "network", "Failed to verify network token for relay {}: {}", relay.id, e);
+ std::process::exit(1);
+ }
+ }
+
+ let tasks = Arc::new(RwLock::new(HashMap::new()));
+
+ // Start the HTTP server
+ let app = Router::new()
+ .route("/publish", post(handle_publish))
+ .layer(Extension(tasks.clone()));
+
+ let api_port = {
+ let config_file = CONFIG_FILE.read().unwrap();
+ config_file
+ .as_ref()
+ .unwrap()
+ .downlink_port
+ .clone()
+ .unwrap_or("3000".to_string())
+ };
+
+ let test = create_ssl_acceptor().unwrap();
+ let acceptor = OpenSSLConfig::from_acceptor(test);
+
+ // let listener = match tokio::net::TcpListener::bind(format!("{}:{}", HOST_ADDRESS, api_port)).await {
+ // Ok(listener) => listener,
+ // Err(e) => {
+ // log::error!(target: "error", "Failed to bind to port {}: {}", api_port, e);
+ // std::process::exit(1);
+ // }
+ // };
+
+ let addr = SocketAddr::from((
+ HOST_ADDRESS.parse::().unwrap(),
+ api_port.parse::().unwrap(),
+ ));
+
+ tokio::spawn(async move {
+ log::info!(target: "info", "Starting Publish API on: {}", addr);
+ axum_server::bind_openssl(addr, acceptor)
+ .serve(app.into_make_service())
+ .await
+ .unwrap();
+ });
+
+ // Start the relay tasks
+ loop {
+ let relay_list = relay_list.read().await.clone();
+
+ for relay in &relay_list {
+ let relay_id = relay.id.clone();
+ if !tasks.read().await.contains_key(&relay_id) {
+ let relay_clone = Arc::clone(relay);
+ let (publish_tx, publish_rx) = mpsc::channel(32);
+ let task = tokio::task::spawn(async move {
+ run_mqtt_relay_connection(relay_clone, publish_rx).await;
+ });
+ tasks.write().await.insert(relay_id.clone(), (task, publish_tx));
+ }
+ }
+
+ tasks.write().await.retain(|_, (task, _)| !task.is_finished());
+
+ // Relay will be restarted after 120 seconds
+ sleep(Duration::from_secs(RESTART_DELAY_SECS)).await;
+ }
+}
+
+#[derive(serde::Deserialize)]
+struct PublishRequest {
+ topic: String,
+ message: String,
+ relay_id: Option,
+ qos: u8,
+ retain: bool,
+}
+
+/**
+* Handle incoming publish requests from the HTTP server
+*/
+struct JsonError(axum::http::StatusCode);
+
+impl IntoResponse for JsonError {
+ fn into_response(self) -> Response {
+ let body = Json(json!({
+ "error": self.0.canonical_reason().unwrap_or("Unknown error")
+ }));
+ (self.0, body).into_response()
+ }
+}
+
+type TaskMap = HashMap, mpsc::Sender)>;
+type SharedTaskMap = Arc>;
+
+async fn handle_publish(
+ Extension(tasks): Extension,
+ payload: Result, JsonRejection>,
+) -> Result {
+ let payload = match payload {
+ Ok(payload) => payload,
+ Err(rejection) => {
+ let (status, error_message) = match rejection {
+ JsonRejection::JsonDataError(err) => {
+ let detailed_error = format!("Invalid JSON data: {}", err.source().unwrap());
+ (StatusCode::UNPROCESSABLE_ENTITY, detailed_error)
+ }
+ JsonRejection::JsonSyntaxError(_) => (StatusCode::BAD_REQUEST, "Syntax error in JSON".to_string()),
+ JsonRejection::MissingJsonContentType(_) => (
+ StatusCode::BAD_REQUEST,
+ "Missing `Content-Type: application/json` header".to_string(),
+ ),
+ _ => (StatusCode::INTERNAL_SERVER_ERROR, "Unknown error".to_string()),
+ };
+ return Ok((status, Json(json!({ "error": error_message }))));
+ }
+ };
+
+ let tasks = tasks.read().await;
+ let relay_id = if payload.relay_id.is_none() {
+ if let Some(first_relay_id) = tasks.keys().next() {
+ first_relay_id.clone()
+ } else {
+ return Err(JsonError(axum::http::StatusCode::NOT_FOUND));
+ }
+ } else {
+ payload.relay_id.clone().unwrap()
+ };
+
+ if let Some((_, publish_tx)) = tasks.get(&relay_id) {
+ let message = PublishMessage {
+ topic: payload.topic.clone(),
+ message: payload.message.clone(),
+ qos: payload.qos,
+ retain: payload.retain,
+ };
+
+ publish_tx
+ .send(message)
+ .await
+ .map_err(|_| JsonError(axum::http::StatusCode::INTERNAL_SERVER_ERROR))?;
+
+ Ok((StatusCode::OK, Json(json!({ "status": "Message published" }))))
+ } else {
+ Err(JsonError(axum::http::StatusCode::NOT_FOUND))
+ }
+}
diff --git a/src/schema/mod.rs b/src/schema/mod.rs
index 3664d1f..bbf7894 100644
--- a/src/schema/mod.rs
+++ b/src/schema/mod.rs
@@ -1,17 +1,217 @@
-#[derive(Debug)]
-pub struct BridgeConfig {
- pub id: String,
- pub address: String,
- pub version: String,
- pub client_id: String,
- pub tls: bool,
- pub username: Option,
- pub password: Option,
- pub certificate: Option,
-}
+use regex::Regex;
#[derive(Debug, Clone)]
-pub struct Customer {
- pub id: u32,
- pub bridges: Vec>,
+#[allow(dead_code)]
+pub struct RelayConfig {
+ pub id: String,
+ pub config: ConfigFile,
+ pub profile_id: Option,
+}
+
+#[derive(serde::Serialize, serde::Deserialize, Default, Debug, Clone)]
+pub struct ConfigFile {
+ pub network_token: String,
+ pub authorization_token: String,
+ pub tagoio_url: Option, // Default is "https://api.tago.io"
+ pub downlink_port: Option, // Default is "3000"
+ pub mqtt: Mqtt,
+}
+#[derive(serde::Serialize, serde::Deserialize, Default, Debug, Clone)]
+pub struct Mqtt {
+ pub client_id: Option, // Default is "tagoio-relay"
+ pub tls_enabled: bool,
+ pub address: String,
+ pub port: u16,
+ pub subscribe: Vec, // Default is ["/tago/#", "/device/+"]
+ pub username: Option, // Default is "my-username"
+ pub password: Option, // Default is "my-password"
+ pub broker_tls_ca: Option, // Default is "certs/ca.crt"
+ pub broker_tls_cert: Option, // Default is "certs/client.crt"
+ pub broker_tls_key: Option, // Default is "certs/client.key"
+}
+
+impl RelayConfig {
+ pub fn new_with_defaults(profile_id: Option, config: ConfigFile) -> anyhow::Result {
+ // Ensure that profile_id and state are not None
+ let id = "self-hosted".to_string();
+ let profile_id = Some(profile_id.unwrap_or_else(|| "self-hosted".to_string()));
+
+ Ok(RelayConfig {
+ id,
+ config: config.with_defaults()?,
+ profile_id,
+ })
+ }
+
+ // pub fn is_running(&self) -> bool {
+ // matches!(self.state, Some(InitiatedState::Running))
+ // }
+}
+
+impl ConfigFile {
+ pub fn with_defaults(mut self) -> anyhow::Result {
+ if self.tagoio_url.is_none() {
+ self.tagoio_url = Some("https://api.tago.io".to_string());
+ }
+ if self.downlink_port.is_none() {
+ self.downlink_port = Some("3000".to_string());
+ }
+ self.mqtt = self.mqtt.with_defaults()?;
+ Ok(self)
+ }
+}
+
+impl Mqtt {
+ pub fn with_defaults(mut self) -> anyhow::Result {
+ if self.client_id.is_none() {
+ self.client_id = Some("tagoio-relay".to_string());
+ }
+ if self.address != "localhost" && !self.is_valid_address(&self.address) {
+ return Err(anyhow::anyhow!("Invalid MQTT address: {}", self.address));
+ }
+ Ok(self)
+ }
+
+ fn is_valid_address(&self, address: &str) -> bool {
+ let re = Regex::new(
+ r"^(?:(?:ws|wss|mqtt|mqtts)://)?(?:(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}|(?:\d{1,3}\.){3}\d{1,3}|localhost)$",
+ )
+ .unwrap();
+ re.is_match(address)
+ }
+}
+
+#[derive(serde::Deserialize)]
+#[allow(dead_code)]
+pub struct PublishRequest {
+ pub topic: String,
+ pub message: String,
+ pub relay_id: String,
+ pub qos: u8,
+ pub retain: bool,
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_relay_config_new_with_defaults() {
+ let config = ConfigFile {
+ network_token: "network_token".to_string(),
+ authorization_token: "authorization_token".to_string(),
+ tagoio_url: None,
+ downlink_port: None,
+ mqtt: Mqtt {
+ client_id: None,
+ tls_enabled: false,
+ address: "localhost".to_string(),
+ port: 1883,
+ subscribe: vec![],
+ username: None,
+ password: None,
+ broker_tls_ca: None,
+ broker_tls_cert: None,
+ broker_tls_key: None,
+ },
+ };
+
+ let relay_config = RelayConfig::new_with_defaults(None, config).unwrap();
+
+ assert_eq!(relay_config.id, "self-hosted");
+ assert_eq!(relay_config.profile_id.unwrap(), "self-hosted");
+ // assert_eq!(relay_config.state.unwrap(), InitiatedState::Stopped);
+ assert_eq!(relay_config.config.tagoio_url.unwrap(), "https://api.tago.io");
+ assert_eq!(relay_config.config.downlink_port.unwrap(), "3000");
+ assert_eq!(relay_config.config.mqtt.client_id.unwrap(), "tagoio-relay");
+ // assert_eq!(
+ // relay_config.config.mqtt.authentication_certificate_file.unwrap(),
+ // "certs/ca.crt"
+ // );
+ }
+
+ #[test]
+ fn test_config_file_with_defaults() {
+ let config = ConfigFile {
+ network_token: "network_token".to_string(),
+ authorization_token: "authorization_token".to_string(),
+ tagoio_url: None,
+ downlink_port: None,
+ mqtt: Mqtt {
+ client_id: None,
+ tls_enabled: false,
+ address: "localhost".to_string(),
+ port: 1883,
+ subscribe: vec![],
+ username: None,
+ password: None,
+ broker_tls_ca: None,
+ broker_tls_cert: None,
+ broker_tls_key: None,
+ },
+ };
+
+ let config_with_defaults = config.with_defaults().unwrap();
+
+ assert_eq!(config_with_defaults.tagoio_url.unwrap(), "https://api.tago.io");
+ assert_eq!(config_with_defaults.downlink_port.unwrap(), "3000");
+ assert_eq!(config_with_defaults.mqtt.client_id.unwrap(), "tagoio-relay");
+ }
+
+ #[test]
+ fn test_mqtt_with_defaults() {
+ let mqtt = Mqtt {
+ client_id: None,
+ tls_enabled: false,
+ address: "localhost".to_string(),
+ port: 1883,
+ subscribe: vec!["/tago/#".to_string(), "/device/+".to_string()],
+ username: None,
+ password: None,
+ broker_tls_ca: None,
+ broker_tls_cert: None,
+ broker_tls_key: None,
+ };
+
+ let mqtt_with_defaults = mqtt.with_defaults().unwrap();
+
+ assert_eq!(mqtt_with_defaults.client_id.unwrap(), "tagoio-relay");
+ }
+
+ #[test]
+ #[should_panic(expected = "Invalid MQTT address: invalid_address")]
+ fn test_invalid_mqtt_address() {
+ let mqtt = Mqtt {
+ client_id: None,
+ tls_enabled: false,
+ address: "invalid_address".to_string(),
+ port: 1883,
+ subscribe: vec![],
+ username: None,
+ password: None,
+ broker_tls_ca: None,
+ broker_tls_cert: None,
+ broker_tls_key: None,
+ };
+ mqtt.with_defaults().unwrap();
+ }
+
+ // #[test]
+ // fn test_is_valid_address() {
+ // let mqtt = MQTT {
+ // client_id: None,
+ // tls_enabled: false,
+ // address: "localhost".to_string(),
+ // port: 1883,
+ // subscribe: vec![],
+ // username: None,
+ // password: None,
+ // authentication_certificate_file: None,
+ // };
+
+ // assert!(mqtt.is_valid_address("localhost"));
+ // assert!(mqtt.is_valid_address("192.168.1.1"));
+ // assert!(mqtt.is_valid_address("example.com"));
+ // assert!(!mqtt.is_valid_address("invalid_address"));
+ // }
}
diff --git a/src/services/bridge.rs b/src/services/bridge.rs
deleted file mode 100644
index cf2d491..0000000
--- a/src/services/bridge.rs
+++ /dev/null
@@ -1,88 +0,0 @@
-use crate::schema::BridgeConfig;
-use rumqttc::{AsyncClient, MqttOptions, QoS, TlsConfiguration};
-use std::sync::Arc;
-use tokio::time::{sleep, Duration};
-
-pub async fn run_bridge(bridge: Arc) {
- let mut mqttoptions = MqttOptions::new(&bridge.client_id, &bridge.address, 1883);
- mqttoptions.set_keep_alive(Duration::from_secs(30));
- mqttoptions.set_max_packet_size(1024 * 1024, 1024 * 1024); // 1mb in/out
-
- if bridge.tls || bridge.address.starts_with("ssl") {
- if let Some(certificate) = &bridge.certificate {
- let certificate = std::fs::read_to_string(certificate).unwrap();
- mqttoptions.set_transport(rumqttc::Transport::tls_with_config(
- TlsConfiguration::Simple {
- ca: certificate.into_bytes(),
- alpn: None, // or Some(vec!["protocol".to_string()]) if you need ALPN
- client_auth: None, // or Some((client_cert, client_key)) if you need client authentication
- },
- ));
- }
- }
-
- // TODO: This with the TLS logic and certificate seems weird af
- if let Some(username) = &bridge.username {
- if !bridge.certificate.is_none() {
- mqttoptions.set_credentials(username, bridge.password.as_deref().unwrap_or_default());
- }
- }
-
- // TODO: Review the CAP later
- let (client, mut eventloop) = AsyncClient::new(mqttoptions, 15);
-
- client
- .subscribe("tago/my_topic", QoS::AtMostOnce)
- .await
- .unwrap();
-
- tokio::task::spawn(async move {
- client
- .publish("hello/runmqtt", QoS::AtMostOnce, false, "Hello World")
- .await
- .unwrap();
- });
-
- // Attempt to connect to the MQTT broker
- match eventloop.poll().await {
- Ok(notification) => {
- println!("Received = {:?}", notification);
- if let rumqttc::Event::Incoming(rumqttc::Packet::ConnAck(_)) = notification {
- println!(
- "Connection to MQTT broker was successful for client ID: {}",
- bridge.client_id
- );
- }
- }
- // ! seems to be unreachable actually
- Err(e) => {
- println!(
- "Failed to connect to MQTT broker for client ID: {}. Error: {:?}",
- bridge.client_id, e
- );
- return;
- }
- }
-
- // Continue processing other notifications
- while let Ok(notification) = eventloop.poll().await {
- match notification {
- rumqttc::Event::Incoming(rumqttc::Packet::Publish(publish)) => {
- println!(
- "Received message on topic {}: {:?}",
- publish.topic, publish.payload
- );
- }
- _ => {
- println!("Received = {:?}", notification);
- }
- }
- }
-
- // Simulate running task
- sleep(Duration::from_secs(1)).await;
-
- // !Reach here if timeout on connection (no control over how much time it waits for response)
- // !Reach here if connection is closed
- println!("Bridge task completed for client ID: {}", bridge.client_id);
-}
diff --git a/src/services/mod.rs b/src/services/mod.rs
index b31cc3e..5af715e 100644
--- a/src/services/mod.rs
+++ b/src/services/mod.rs
@@ -1,2 +1,2 @@
-pub mod bridge;
+pub mod mqttrelay;
pub mod tagoio;
diff --git a/src/services/mqttrelay.rs b/src/services/mqttrelay.rs
new file mode 100644
index 0000000..19da723
--- /dev/null
+++ b/src/services/mqttrelay.rs
@@ -0,0 +1,174 @@
+use crate::{schema::RelayConfig, utils::calculate_backoff};
+use rumqttc::{
+ tokio_rustls::rustls::{ClientConfig, RootCertStore},
+ AsyncClient, MqttOptions, QoS, TlsConfiguration,
+};
+use serde::Deserialize;
+use std::sync::Arc;
+use tokio::{
+ sync::{mpsc, Mutex},
+ time::{sleep, Duration},
+};
+const BACKOFF_MAX_RETRIES: u32 = 20;
+
+#[derive(Deserialize)]
+#[allow(dead_code)]
+pub struct PublishMessage {
+ pub topic: String,
+ pub message: String,
+ pub qos: u8,
+ pub retain: bool,
+}
+
+pub async fn run_mqtt_relay_connection(relay_cfg: Arc, publish_rx: mpsc::Receiver) {
+ log::info!(target: "mqtt", "Running relay task for client ID: {}", relay_cfg.id);
+
+ let publish_rx = Arc::new(Mutex::new(publish_rx));
+
+ let mqttoptions = initialize_mqtt_options(&relay_cfg);
+
+ let mut backoff_retry_attempts = 0;
+
+ loop {
+ let (client, mut eventloop) = AsyncClient::new(mqttoptions.clone(), 15);
+
+ subscribe_to_topics(&client, &relay_cfg).await;
+
+ let publish_rx_clone = Arc::clone(&publish_rx);
+ let publish_task = tokio::spawn(async move {
+ if let Err(e) = publish_messages(client, publish_rx_clone).await {
+ log::error!(target: "mqtt", "Failed to publish messages: {:?}", e);
+ }
+ });
+
+ if let Err(e) = handle_mqtt_connection(&mut eventloop).await {
+ log::error!(target: "error", "Failed to connect to MQTT broker. Error details: {:?}", e.to_string());
+ } else {
+ log::info!(target: "mqtt", "Connected to MQTT broker successfully");
+ backoff_retry_attempts = 0;
+ }
+
+ process_incoming_messages(&mut eventloop, &relay_cfg).await;
+
+ if backoff_retry_attempts >= BACKOFF_MAX_RETRIES {
+ log::error!(target: "mqtt", "Max retries reached. Exiting: {}", relay_cfg.id);
+ return;
+ }
+ let backoff_duration = calculate_backoff(backoff_retry_attempts);
+ log::info!(target: "mqtt", "Retrying in {:?}", backoff_duration);
+ publish_task.abort();
+ sleep(backoff_duration).await;
+ backoff_retry_attempts += 1;
+ }
+}
+
+fn initialize_mqtt_options(relay_cfg: &RelayConfig) -> MqttOptions {
+ let client_id = relay_cfg
+ .config
+ .mqtt
+ .client_id
+ .clone()
+ .unwrap_or("tagoio-relay".to_string());
+
+ let username = &relay_cfg.config.mqtt.username;
+ let password = &relay_cfg.config.mqtt.password;
+ let ca_file = &relay_cfg.config.mqtt.broker_tls_ca;
+ let crt_file = &relay_cfg.config.mqtt.broker_tls_cert;
+ let key_file = &relay_cfg.config.mqtt.broker_tls_key;
+
+ let mut mqttoptions = MqttOptions::new(client_id, &relay_cfg.config.mqtt.address, relay_cfg.config.mqtt.port);
+ mqttoptions.set_keep_alive(Duration::from_secs(30));
+ mqttoptions.set_max_packet_size(1024 * 1024, 1024 * 1024); // 1mb in/out
+
+ if relay_cfg.config.mqtt.tls_enabled || relay_cfg.config.mqtt.address.starts_with("ssl") {
+ let client_auth = if let (Some(crt), Some(key)) = (crt_file, key_file) {
+ Some((crt.clone().into_bytes(), key.clone().into_bytes()))
+ } else {
+ None
+ };
+
+ if let Some(certificate) = ca_file {
+ mqttoptions.set_transport(rumqttc::Transport::tls_with_config(TlsConfiguration::Simple {
+ ca: certificate.clone().into_bytes(),
+ alpn: None,
+ client_auth,
+ }));
+ } else if let Some(client_auth) = client_auth {
+ mqttoptions.set_transport(rumqttc::Transport::tls_with_config(TlsConfiguration::Simple {
+ ca: vec![],
+ alpn: None,
+ client_auth: Some(client_auth),
+ }));
+ } else {
+ // Use rustls-native-certs to load root certificates from the operating system.
+ let mut root_cert_store = RootCertStore::empty();
+ root_cert_store
+ .add_parsable_certificates(rustls_native_certs::load_native_certs().expect("could not load platform certs"));
+
+ let client_config = ClientConfig::builder()
+ .with_root_certificates(Arc::new(root_cert_store))
+ .with_no_client_auth();
+
+ mqttoptions.set_transport(rumqttc::Transport::tls_with_config(client_config.into()));
+ }
+ }
+
+ if let Some(username) = username {
+ mqttoptions.set_credentials(
+ username,
+ password.as_ref().expect("Password must be provided if username is set"),
+ );
+ }
+
+ mqttoptions
+}
+
+async fn subscribe_to_topics(client: &AsyncClient, relay_cfg: &RelayConfig) {
+ for topic in relay_cfg.config.mqtt.subscribe.iter() {
+ client.subscribe(topic, QoS::AtMostOnce).await.unwrap();
+ }
+}
+
+async fn handle_mqtt_connection(eventloop: &mut rumqttc::EventLoop) -> Result<(), rumqttc::ConnectionError> {
+ match eventloop.poll().await {
+ Ok(notification) => {
+ if let rumqttc::Event::Incoming(rumqttc::Packet::ConnAck(_)) = notification {
+ log::info!("Connection to MQTT broker was successful");
+ }
+ Ok(())
+ }
+ Err(e) => Err(e),
+ }
+}
+
+async fn publish_messages(
+ client: AsyncClient,
+ publish_rx: Arc>>,
+) -> anyhow::Result<()> {
+ while let Some(publish_message) = publish_rx.lock().await.recv().await {
+ log::info!(target: "mqtt", "[API] External published received on topic {}.", publish_message.topic);
+ if let Err(e) = client
+ .publish(
+ &publish_message.topic,
+ QoS::AtLeastOnce,
+ publish_message.retain,
+ publish_message.message.as_bytes(),
+ )
+ .await
+ {
+ log::error!(target: "mqtt", "Failed to publish message: {:?}", e);
+ }
+ }
+ Ok(())
+}
+
+async fn process_incoming_messages(eventloop: &mut rumqttc::EventLoop, relay_cfg: &RelayConfig) {
+ while let Ok(notification) = eventloop.poll().await {
+ if let rumqttc::Event::Incoming(rumqttc::Packet::Publish(publish)) = notification {
+ log::info!(target: "mqtt", "[Broker] Received message on topic {}", publish.topic);
+ if let Err(e) = crate::services::tagoio::forward_buffer_messages(relay_cfg, &publish).await {
+ log::error!(target: "mqtt", "Failed to forward message to TagoIO: {:?}", e.to_string());
+ }
+ }
+ }
+}
diff --git a/src/services/tagoio.rs b/src/services/tagoio.rs
index 58c0c40..364aa98 100644
--- a/src/services/tagoio.rs
+++ b/src/services/tagoio.rs
@@ -1,37 +1,277 @@
-use std::{collections::HashMap, sync::Arc, time::Duration};
+use std::sync::Arc;
-use tokio::{sync::mpsc, time::sleep};
+use anyhow::Error;
+use axum::http::{HeaderMap, HeaderValue};
+use reqwest::StatusCode;
+use rumqttc::{Publish, QoS};
+use serde_json;
+use std::fmt;
-use crate::schema::{BridgeConfig, Customer};
+use crate::{schema::RelayConfig, CONFIG_FILE};
/**
- * Mock customer and bridge configurations
+ * Get the list of relay configurations
+ * To be improved later to support multiple relays
*/
-pub async fn fetch_customer_settings() -> HashMap {
- let mut customers: HashMap = HashMap::new();
-
- for i in 1..=1 {
- let mut bridges = Vec::new();
- for j in 1..=2 {
- let client_id = format!("client_{}_{}", i, j);
- let bridge = BridgeConfig {
- id: format!("{}_{}", i, j),
- address: "localhost".to_string(),
- version: "3.1.1".to_string(),
- tls: false,
- client_id,
- username: Some("Token".to_string()),
- password: Some("3a162597-8724-46c0-864b-1ac220a77123".to_string()),
- certificate: None,
- };
- bridges.push(Arc::new(bridge));
- }
- customers.insert(i, Customer { id: i, bridges });
+pub async fn get_relay_list() -> Result>, Error> {
+ let config_file = CONFIG_FILE.read().unwrap();
+ if let Some(config) = &*config_file {
+ let relay = RelayConfig::new_with_defaults(None, config.clone())?;
+ let relays: Vec> = vec![Arc::new(relay)];
+
+ log::info!(target: "info", "Config file loaded successfully");
+
+ return Ok(relays);
+ }
+
+ Err(anyhow::anyhow!("Config file not found or invalid"))
+}
+
+#[derive(Debug)]
+pub struct CustomError {
+ pub status: StatusCode,
+ pub body: String,
+ pub message: String,
+}
+
+impl fmt::Display for CustomError {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(
+ f,
+ "Status: {}, Body: {}, Message: {}",
+ self.status, self.body, self.message
+ )
+ }
+}
+
+impl std::error::Error for CustomError {}
+
+/**
+ * Wrapper function to make a request to the TagoIO API
+ */
+async fn make_request(
+ method: reqwest::Method,
+ url: &str,
+ headers: HeaderMap,
+ body: Option,
+) -> Result {
+ let client = reqwest::Client::new();
+ let request = client.request(method, url).headers(headers);
+
+ let request = if let Some(body) = body {
+ request.json(&body)
+ } else {
+ request
+ };
+
+ let response = request.send().await.map_err(|e| CustomError {
+ status: StatusCode::INTERNAL_SERVER_ERROR,
+ body: String::new(),
+ message: e.to_string(),
+ })?;
+
+ let status = response.status();
+ let text = response.text().await.map_err(|e| CustomError {
+ status,
+ body: String::new(),
+ message: e.to_string(),
+ })?;
+
+ if !status.is_success() {
+ return Err(CustomError {
+ status,
+ body: text.clone(),
+ message: format!("Request failed with status: {}", status),
+ });
+ }
+ Ok(text)
+}
+
+/**
+ * Forward the buffered messages to TagoIO Network
+ */
+pub async fn forward_buffer_messages(
+ relay_cfg: &RelayConfig,
+ event: &Publish,
+) -> Result<(), Box> {
+ let endpoint = relay_cfg
+ .config
+ .tagoio_url
+ .clone()
+ .unwrap_or_else(|| "https://api.tago.io".to_string());
+
+ let query_string = format!("?authorization_token={}", relay_cfg.config.authorization_token);
+
+ let endpoint = format!("{}/integration/network/data{}", endpoint, query_string);
+
+ let mut headers = HeaderMap::new();
+ headers.insert("AUTHORIZATION", HeaderValue::from_str(&relay_cfg.config.network_token)?);
+
+ let payload_str = String::from_utf8(event.payload.to_vec())?;
+ let qos_number = match event.qos {
+ QoS::AtMostOnce => 0,
+ QoS::AtLeastOnce => 1,
+ QoS::ExactlyOnce => 2,
+ };
+
+ let body = serde_json::json!([{
+ "variable": "payload",
+ "value": payload_str,
+ "metadata": {
+ "topic": event.topic.clone(),
+ "qos": qos_number,
+ }
+ }]);
+
+ match make_request(reqwest::Method::POST, &endpoint, headers, Some(body)).await {
+ Ok(response) => response,
+ Err(e) => {
+ log::error!(target: "error", "Failed to forward buffered messages to TagoIO: {:?}", e);
+ return Err(Box::new(e));
}
- customers
- // Implement fetching customer settings from TagoIO
+ };
+
+ Ok(())
}
-pub async fn fetch_bridge_settings() {
- // Implement fetching bridge settings from TagoIO
+/**
+ * Verify that the network token is valid
+ */
+pub async fn verify_network_token(relay_cfg: &RelayConfig) -> Result<(), CustomError> {
+ let endpoint = relay_cfg
+ .config
+ .tagoio_url
+ .clone()
+ .unwrap_or_else(|| "https://api.tago.io".to_string());
+
+ let endpoint = format!("{}/info", endpoint);
+
+ let mut headers = HeaderMap::new();
+ headers.insert(
+ "Authorization",
+ HeaderValue::from_str(&relay_cfg.config.network_token).unwrap(),
+ );
+
+ let resp = make_request(reqwest::Method::GET, &endpoint, headers, None).await?;
+
+ if resp.is_empty() {
+ log::error!(target: "error", "Invalid Network Token: Check your network token and TagoIO API URL and try again");
+ return Err(CustomError {
+ status: StatusCode::UNAUTHORIZED,
+ body: String::new(),
+ message: "Invalid Network Token".to_string(),
+ });
+ }
+
+ Ok(())
+}
+/**
+ * Unit Test Section
+ */
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::schema::{ConfigFile, Mqtt};
+ use mockito::Matcher;
+ use rumqttc::{Publish, QoS};
+ use tokio;
+
+ fn get_test_relay_config(server: &mockito::Server) -> RelayConfig {
+ RelayConfig {
+ id: "test_id".to_string(),
+ config: ConfigFile {
+ network_token: "test_network_token".to_string(),
+ authorization_token: "test_authorization_token".to_string(),
+ tagoio_url: Some(server.url()),
+ downlink_port: Some("3000".to_string()),
+ mqtt: Mqtt {
+ client_id: Some("test_client_id".to_string()),
+ tls_enabled: false,
+ address: "localhost".to_string(),
+ port: 1883,
+ subscribe: vec!["/tago/#".to_string(), "/device/+".to_string()],
+ username: Some("test_username".to_string()),
+ password: Some("test_password".to_string()),
+ broker_tls_ca: None,
+ broker_tls_cert: None,
+ broker_tls_key: None,
+ },
+ },
+ profile_id: None,
+ }
+ }
+
+ #[tokio::test]
+ async fn test_forward_buffer_messages() {
+ let mut server = mockito::Server::new_async().await;
+ let relay_cfg = get_test_relay_config(&server);
+ let event = Publish::new(
+ "test/topic",
+ QoS::AtLeastOnce,
+ vec![104, 101, 108, 108, 111], // "hello" in bytes
+ );
+
+ let _m = server
+ .mock("POST", "/integration/network/data")
+ .match_query(Matcher::UrlEncoded(
+ "authorization_token".into(),
+ "test_authorization_token".into(),
+ ))
+ .match_header("AUTHORIZATION", "test_network_token")
+ .match_body(Matcher::Json(serde_json::json!([{
+ "variable": "payload",
+ "value": "hello",
+ "metadata": {
+ "topic": "test/topic",
+ "qos": 1,
+ }
+ }])))
+ .with_status(200)
+ .with_body("Success")
+ .create_async()
+ .await;
+
+ let result = forward_buffer_messages(&relay_cfg, &event).await;
+ assert!(result.is_ok());
+ }
+
+ #[tokio::test]
+ async fn test_verify_network_token() {
+ let mut server = mockito::Server::new_async().await;
+ let relay_cfg = get_test_relay_config(&server);
+ let _m = server
+ .mock("GET", "/info")
+ .match_header("AUTHORIZATION", "test_network_token")
+ .with_status(200)
+ .with_body("Valid Token") // Ensure the response body is not empty
+ .create_async()
+ .await;
+
+ let result = verify_network_token(&relay_cfg).await;
+
+ if let Err(e) = &result {
+ println!("Error: {:?}", e);
+ }
+ assert!(result.is_ok());
+ }
+
+ #[tokio::test]
+ async fn test_verify_network_token_invalid() {
+ let mut server = mockito::Server::new_async().await;
+ let relay_cfg = get_test_relay_config(&server);
+
+ let _m = server
+ .mock("GET", "/info")
+ .match_header("AUTHORIZATION", "test_network_token")
+ .with_status(401)
+ .create_async()
+ .await;
+
+ let result = verify_network_token(&relay_cfg).await;
+ assert!(result.is_err());
+ if let Err(e) = result {
+ assert_eq!(e.status, StatusCode::UNAUTHORIZED);
+ assert_eq!(e.message, "Request failed with status: 401 Unauthorized");
+ }
+ }
}
diff --git a/src/utils.rs b/src/utils.rs
index 3a987b9..06db67c 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -1,8 +1,109 @@
-// Placeholder for utility functions
-pub fn exponential_backoff() {
- // Implement exponential backoff logic
+use home::home_dir;
+use std::time::Duration;
+use toml_env::{initialize, Args, AutoMapEnvArgs};
+
+use crate::schema::ConfigFile;
+
+#[derive(serde::Serialize, serde::Deserialize, Default, Debug, Clone)]
+struct ConfigFileResponse {
+ relay: Option,
+}
+
+const DEFAULT_CONFIG: &str = include_str!("./default_config.toml");
+
+/**
+ * Get the path to the configuration file
+ */
+fn get_config_path(user_path: Option) -> std::path::PathBuf {
+ let env_config_path = if user_path.is_none() {
+ std::env::var("CONFIG_PATH").ok()
+ } else {
+ user_path
+ };
+
+ let config_path = env_config_path
+ .as_deref()
+ .map(std::path::PathBuf::from)
+ .unwrap_or_else(|| {
+ let home_dir = home_dir().expect("Failed to get home directory");
+ let config_path_str = format!("{}/.config/.tagoio-mqtt-relay.toml", home_dir.display());
+ std::path::PathBuf::from(config_path_str)
+ });
+
+ config_path
+}
+
+/**
+ * Initialize the configuration file
+ */
+pub fn init_config(user_path: Option>) {
+ let config_path = get_config_path(user_path.map(|s| s.as_ref().to_string()));
+ if config_path.exists() {
+ log::error!(target: "error", "Configuration file already exists.");
+ std::process::exit(1);
+ }
+
+ std::fs::write(&config_path, DEFAULT_CONFIG).expect("Failed to create default config file");
+
+ log::info!("Configuration file created at {}", config_path.display());
+}
+
+/**
+ * Fetch the configuration file
+ */
+pub fn fetch_config_file(user_path: Option) -> Option {
+ let config_path = get_config_path(user_path);
+ // If the config file doesn't exist, create it
+ if !config_path.exists() {
+ log::error!(target: "error", "Configuration file not found.");
+ std::process::exit(1);
+ }
+
+ let config: Option = initialize(Args {
+ auto_map_env: Some(AutoMapEnvArgs::default()),
+ // logging: Logging::StdOut,
+ config_path: Some(&config_path),
+ ..Args::default()
+ })
+ .unwrap_or_else(|err| {
+ log::error!(target: "error", "Failed to initialize configuration: {}", err);
+ std::process::exit(1);
+ });
+
+ config
+ .unwrap_or_else(|| {
+ log::error!(target: "error", "Configuration file is missing or invalid.");
+ std::process::exit(1);
+ })
+ .relay
}
-pub fn monitor_bridge_settings() {
- // Implement monitoring logic for bridge settings
+pub fn calculate_backoff(attempt: u32) -> Duration {
+ let base_delay = Duration::from_secs(5);
+ let max_delay = Duration::from_secs(60);
+ let delay = base_delay * 2u32.pow(attempt);
+ std::cmp::min(delay, max_delay)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use std::path::PathBuf;
+
+ #[test]
+ fn test_get_config_path_with_user_path() {
+ let user_path = Some(String::from("/custom/path/config.toml"));
+ let result = get_config_path(user_path);
+ assert_eq!(result, PathBuf::from("/custom/path/config.toml"));
+ }
+
+ #[test]
+ fn test_get_config_path_without_user_path() {
+ let user_path = None;
+ let result = get_config_path(user_path);
+ let home_dir = home_dir().expect("Failed to get home directory");
+ let expected_path = home_dir.join(".config/.tagoio-mqtt-relay.toml");
+
+ assert_eq!(result, expected_path);
+ }
}