From 50236dbb5523cf04bab7ec5b77c86f9fe7f60d58 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Apr 2023 17:32:20 +0000 Subject: [PATCH 1/3] Bump h2 from 0.3.9 to 0.3.17 Bumps [h2](https://github.com/hyperium/h2) from 0.3.9 to 0.3.17. - [Release notes](https://github.com/hyperium/h2/releases) - [Changelog](https://github.com/hyperium/h2/blob/master/CHANGELOG.md) - [Commits](https://github.com/hyperium/h2/compare/v0.3.9...v0.3.17) --- updated-dependencies: - dependency-name: h2 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Cargo.lock | 60 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 03d8c51..5a694b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ dependencies = [ "memchr", "pin-project-lite", "tokio", - "tokio-util", + "tokio-util 0.6.9", ] [[package]] @@ -138,7 +138,7 @@ dependencies = [ "log", "pin-project-lite", "tokio-rustls", - "tokio-util", + "tokio-util 0.6.9", "webpki-roots", ] @@ -771,9 +771,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.9" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f072413d126e57991455e0a922b31e4c8ba7c2ffbebf6b78b4f8521397d65cd" +checksum = "66b91535aa35fea1523ad1b86cb6b53c28e0ae566ba4a460f4457e936cad7c6f" dependencies = [ "bytes", "fnv", @@ -784,7 +784,7 @@ dependencies = [ "indexmap", "slab", "tokio", - "tokio-util", + "tokio-util 0.7.2", "tracing", ] @@ -1272,11 +1272,11 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro2" -version = "1.0.34" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f84e92c0f7c9d58328b85a78557813e4bd845130db68d7184635344399423b1" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] @@ -1634,13 +1634,13 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "syn" -version = "1.0.82" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] @@ -1780,6 +1780,20 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-util" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f988a1a1adc2fb21f9c12aa96441da33a1728193ae0b95d2be22dbd17fcb4e5c" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + [[package]] name = "tracing" version = "0.1.29" @@ -1788,9 +1802,21 @@ checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" dependencies = [ "cfg-if 1.0.0", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tracing-core" version = "0.1.21" @@ -1818,6 +1844,12 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" +[[package]] +name = "unicode-ident" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" + [[package]] name = "unicode-normalization" version = "0.1.19" @@ -1833,12 +1865,6 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" -[[package]] -name = "unicode-xid" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" - [[package]] name = "untrusted" version = "0.7.1" From be52984d1d5fc580e7dced2f3505c4df8a9dd635 Mon Sep 17 00:00:00 2001 From: owent Date: Thu, 18 May 2023 00:48:09 +0800 Subject: [PATCH 2/3] Update dependencies. Signed-off-by: owent --- .github/workflows/build-on-linux.yml | 177 +++++ .github/workflows/build-on-macos.yml | 76 +++ .github/workflows/build-on-windows.yml | 79 +++ .github/workflows/main.yml | 266 -------- CHANGELOG.md | 11 + Cargo.lock | 901 ++++++++++++++----------- Cargo.toml | 53 +- LICENSE | 2 +- LICENSE-MIT | 2 +- etc/conf.json | 2 +- src/app.rs | 186 ++--- src/handles/robot.rs | 5 +- src/logger/mod.rs | 6 +- src/main.rs | 9 +- src/wxwork_robot/command.rs | 26 +- src/wxwork_robot/command_runtime.rs | 10 +- src/wxwork_robot/error.rs | 2 - src/wxwork_robot/message.rs | 401 ++++++----- src/wxwork_robot/mod.rs | 6 +- src/wxwork_robot/project.rs | 44 +- 20 files changed, 1243 insertions(+), 1021 deletions(-) create mode 100644 .github/workflows/build-on-linux.yml create mode 100644 .github/workflows/build-on-macos.yml create mode 100644 .github/workflows/build-on-windows.yml delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/build-on-linux.yml b/.github/workflows/build-on-linux.yml new file mode 100644 index 0000000..6177bc6 --- /dev/null +++ b/.github/workflows/build-on-linux.yml @@ -0,0 +1,177 @@ +name: "Build On Linux" + +on: # @see https://help.github.com/en/articles/events-that-trigger-workflows#webhook-events + push: + branches: # Array of patterns that match refs/heads + - main # Push events on master branch + tags: + - "*" + pull_request: + branches: + - main + +jobs: + format_and_lint: + name: "Format and lint" + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Cache cargo modules + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-format_and_lint-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Install rust toolchain for host + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: x86_64-unknown-linux-gnu + override: true + default: true + components: "rustfmt, clippy, cargo, rust-docs" + - name: Format and lint + shell: bash + run: | + cargo fmt --all -- --check + cargo clippy + build: # job id, can be any string + # Job name is Build And Publish + name: Build + # This job runs on Linux + strategy: + matrix: + os: [ubuntu-latest] + rust: [stable] + target: [ + x86_64-unknown-linux-gnu, + x86_64-unknown-linux-musl, + aarch64-unknown-linux-gnu, + aarch64-unknown-linux-musl, + arm-unknown-linux-gnueabi, + armv7-unknown-linux-gnueabihf, + armv7-unknown-linux-musleabihf, + arm-unknown-linux-musleabihf, + arm-unknown-linux-musleabi, + #mips-unknown-linux-gnu, + #mipsel-unknown-linux-gnu, + #mips64-unknown-linux-gnuabi64, + #mips64el-unknown-linux-gnuabi64, + #mips-unknown-linux-musl, + #mipsel-unknown-linux-musl, + #powerpc-unknown-linux-gnu, + #powerpc64-unknown-linux-gnu, + #powerpc64le-unknown-linux-gnu, + i686-unknown-linux-gnu, + i686-unknown-linux-musl, + aarch64-linux-android, + armv7-linux-androideabi, + x86_64-linux-android, + #x86_64-unknown-netbsd, + #x86_64-unknown-freebsd, + #x86_64-sun-solaris, + ] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Cache cargo modules + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Install rust toolchain for host + uses: actions-rs/toolchain@v1 + if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} + with: + toolchain: ${{ matrix.rust }} + target: ${{ matrix.target }} + override: true + default: true + components: "rustfmt, clippy, cargo, rust-docs" + - name: Install rust toolchain for cross + uses: actions-rs/toolchain@v1 + if: ${{ matrix.target != 'x86_64-unknown-linux-gnu' }} + with: + toolchain: ${{ matrix.rust }} + target: x86_64-unknown-linux-gnu + override: true + default: true + components: "rustfmt, clippy, cargo, rust-docs" + - name: Install Cross + shell: bash + if: ${{ matrix.target != 'x86_64-unknown-linux-gnu' }} + run: | + cargo install cross --git https://github.com/cross-rs/cross + cargo install xargo + - name: Cargo Release build + uses: actions-rs/cargo@v1 + if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} + with: + use-cross: false + command: build + args: --target ${{ matrix.target }} --release --jobs 2 --verbose + - name: Run tests + uses: actions-rs/cargo@v1 + if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} + with: + command: test + args: --release --verbose --target ${{ matrix.target }} --bin wxwork_robotd + - name: Cross Release build + uses: actions-rs/cargo@v1 + # shell: bash + if: ${{ matrix.target != 'x86_64-unknown-linux-gnu' }} + # run: cross --target ${{ matrix.target }} --release --jobs 2 --verbose + with: + use-cross: true + command: build + args: --target ${{ matrix.target }} --release --jobs 2 --verbose + - name: Prepare package + shell: bash + if: ${{ github.ref_type == 'tag' }} + run: | + if [[ -e "target/${{ matrix.target }}/release/etc" ]]; then + rm -rf "target/${{ matrix.target }}/release/etc"; + fi + if [[ -e "target/${{ matrix.target }}/release/tools" ]]; then + rm -rf "target/${{ matrix.target }}/release/tools"; + fi + mkdir -p "target/${{ matrix.target }}/release" + cp -rf etc tools "target/${{ matrix.target }}/release"/ + cd "target/${{ matrix.target }}/release/" + mkdir -p bin; + if [[ -e wxwork_robotd ]]; then + cp -f wxwork_robotd bin/wxwork_robotd; + else + cp -f wxwork_robotd* bin/; + fi + tar -zcvf ${{ matrix.target }}.tar.gz etc bin tools; + cd "$GITHUB_WORKSPACE" ; + - uses: xresloader/upload-to-github-release@main + if: ${{ github.ref_type == 'tag' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + file: "target/${{ matrix.target }}/release/${{ matrix.target }}.tar.gz" + tags: true + draft: false + prerelease: false + overwrite: true + - name: Update docker + shell: bash + if: ${{ github.ref_type == 'tag' && matrix.target == 'x86_64-unknown-linux-musl' }} + run: | + cd "target/${{ matrix.target }}/release/" + which docker || true; + cp -f ../../../Dockerfile ./ ; + TAG_NAME="$(echo "${{ github.ref }}" | awk 'match($0, /refs\/tags\/(.+)/, tag_name) {print tag_name[1]}')"; + echo "${{ secrets.DOCKER_TOKEN }}" | docker login -u "owt5008137" --password-stdin docker.io + docker build --force-rm --tag docker.io/owt5008137/wxwork_robotd:latest -f Dockerfile . ; + docker tag docker.io/owt5008137/wxwork_robotd:latest docker.io/owt5008137/wxwork_robotd:$TAG_NAME ; + docker push docker.io/owt5008137/wxwork_robotd:latest ; + docker push docker.io/owt5008137/wxwork_robotd:$TAG_NAME ; + cd "$GITHUB_WORKSPACE" ; diff --git a/.github/workflows/build-on-macos.yml b/.github/workflows/build-on-macos.yml new file mode 100644 index 0000000..396eb2a --- /dev/null +++ b/.github/workflows/build-on-macos.yml @@ -0,0 +1,76 @@ +name: "Build On macOS" + +on: [push] + +jobs: + build: # job id, can be any string + # Job name is Build And Publish + name: Build + # This job runs on Linux + strategy: + matrix: + os: [macOS-latest] + rust: [stable] + target: [x86_64-apple-darwin] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Cache cargo modules + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + target: ${{ matrix.target }} + default: true + override: true + components: "rustfmt, clippy, cargo, rust-docs" + - name: Cargo Release build + uses: actions-rs/cargo@v1 + if: ${{ matrix.target != 'x86_64-pc-windows-gnu' }} + with: + use-cross: false + command: build + args: --target ${{ matrix.target }} --release --jobs 2 --verbose + - name: Run tests + uses: actions-rs/cargo@v1 + with: + command: test + args: --release --verbose --target ${{ matrix.target }} --bin wxwork_robotd + - name: Prepare package + shell: bash + if: ${{ contains(github.ref, 'refs/tags/') }} + run: | + if [[ -e "target/${{ matrix.target }}/release/etc" ]]; then + rm -rf "target/${{ matrix.target }}/release/etc"; + fi + if [[ -e "target/${{ matrix.target }}/release/tools" ]]; then + rm -rf "target/${{ matrix.target }}/release/tools"; + fi + mkdir -p "target/${{ matrix.target }}/release" + cp -rf etc tools "target/${{ matrix.target }}/release"/ + cd "target/${{ matrix.target }}/release/" + mkdir -p bin; + if [[ -e wxwork_robotd ]]; then + cp -f wxwork_robotd bin/wxwork_robotd; + else + cp -f wxwork_robotd* bin/; + fi + tar -zcvf ${{ matrix.target }}.tar.gz etc bin tools; + cd "$GITHUB_WORKSPACE" ; + - uses: xresloader/upload-to-github-release@master + if: ${{ contains(github.ref, 'refs/tags/') }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + file: "target/${{ matrix.target }}/release/${{ matrix.target }}.tar.gz" + tags: true + draft: false + prerelease: false + overwrite: true diff --git a/.github/workflows/build-on-windows.yml b/.github/workflows/build-on-windows.yml new file mode 100644 index 0000000..c34d470 --- /dev/null +++ b/.github/workflows/build-on-windows.yml @@ -0,0 +1,79 @@ +name: "Build On Windows" + +on: [push] + +jobs: + build: # job id, can be any string + # Job name is Build And Publish + name: Build + # This job runs on Linux + strategy: + matrix: + os: [windows-latest] + rust: [stable] + target: [x86_64-pc-windows-msvc, i686-pc-windows-msvc] + # x86_64-pc-windows-gnu, i686-pc-windows-gnu, + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Cache cargo modules + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + target: ${{ matrix.target }} + default: true + override: true + components: "rustfmt, clippy, cargo, rust-docs" + - name: Cargo Release build + uses: actions-rs/cargo@v1 + if: ${{ matrix.target != 'x86_64-pc-windows-gnu' }} + with: + use-cross: false + command: build + args: --target ${{ matrix.target }} --release --jobs 2 --verbose + - name: Run tests + uses: actions-rs/cargo@v1 + with: + command: test + args: --release --verbose --target ${{ matrix.target }} --bin wxwork_robotd + - name: Prepare package + shell: pwsh + if: ${{ contains(github.ref, 'refs/tags/') }} + run: | + cd "$ENV:GITHUB_WORKSPACE/target/${{ matrix.target }}/release/" + + if ( Test-Path "tools" ) { Remove-Item -Recurse -Force "tools" } + + if ( Test-Path "etc" ) { Remove-Item -Recurse -Force "etc" } + + New-Item -Force -ItemType Directory "bin" + + Copy-Item -Force -Recurse "../../../tools" "./" + + Copy-Item -Force -Recurse "../../../etc" "./" + + Copy-Item -Force "wxwork_robotd.exe" "bin/" + + if ( Test-Path "${{ matrix.target }}.zip" ) { Remove-Item -Force "${{ matrix.target }}.zip" } + + Compress-Archive -DestinationPath "${{ matrix.target }}.zip" -Path etc,bin,tools + + cd "$ENV:GITHUB_WORKSPACE" + - uses: xresloader/upload-to-github-release@master + if: ${{ contains(github.ref, 'refs/tags/') }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + file: "target/${{ matrix.target }}/release/${{ matrix.target }}.zip" + tags: true + draft: false + prerelease: false + overwrite: true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 950e38c..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,266 +0,0 @@ -name: "Build and release" - -on: # @see https://help.github.com/en/articles/events-that-trigger-workflows#webhook-events - push: - branches: # Array of patterns that match refs/heads - - main - tags: - - "*" - pull_request: - branches: - - main - -jobs: - linux_build: # job id, can be any string - # Job name is Build And Publish - name: Linux Build - # This job runs on Linux - strategy: - matrix: - os: [ubuntu-latest] - rust: [stable] - target: - - x86_64-unknown-linux-gnu - - aarch64-unknown-linux-gnu - - arm-unknown-linux-gnueabi - - armv7-unknown-linux-gnueabihf - - i686-unknown-linux-gnu - #- mips-unknown-linux-gnu - #- mipsel-unknown-linux-gnu - #- mips64-unknown-linux-gnuabi64 - #- mips64el-unknown-linux-gnuabi64 - #- powerpc-unknown-linux-gnu - #- powerpc64-unknown-linux-gnu - #- powerpc64le-unknown-linux-gnu - - aarch64-unknown-linux-musl - - arm-unknown-linux-musleabihf - - arm-unknown-linux-musleabi - - armv7-unknown-linux-musleabihf - - i686-unknown-linux-musl - #- mips-unknown-linux-musl - #- mipsel-unknown-linux-musl - - x86_64-unknown-linux-musl - - aarch64-linux-android - - arm-linux-androideabi - - armv7-linux-androideabi - - i686-linux-android - - x86_64-linux-android - # - x86_64-unknown-netbsd - # - x86_64-unknown-freebsd - # - x86_64-sun-solaris - # see https://github.com/rust-embedded/cross - # Github action is run under a docker pod but cross need docker service - runs-on: ${{ matrix.os }} - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.rust }} - target: ${{ matrix.target }} - override: true - default: true - components: "rustfmt, clippy, cargo, rust-docs" - - name: Format and lint - if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} - shell: bash - run: | - cargo fmt --all -- --check - cargo clippy - - name: Cargo Release build - uses: actions-rs/cargo@v1 - if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} - with: - use-cross: false - command: build - args: --target ${{ matrix.target }} --release --all-features - - name: Cross Release build - uses: actions-rs/cargo@v1 - if: ${{ matrix.target != 'x86_64-unknown-linux-gnu' }} - with: - use-cross: true - command: build - args: --target ${{ matrix.target }} --release --all-features - - name: Debug build & test - uses: actions-rs/cargo@v1 - if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }} - with: - command: test - args: --all-features - env: - RUSTFLAGS: "-C link-dead-code" - - name: Cache prebuilt and cargo - uses: actions/cache@v2 - with: - path: | - ~/prebuilt - ~/.cargo - !~/prebuilt/exclude - key: ${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }} - - name: Package - shell: bash - run: | - if [[ -e "target/${{ matrix.target }}/release/etc" ]]; then - rm -rf "target/${{ matrix.target }}/release/etc"; - fi - if [[ -e "target/${{ matrix.target }}/release/tools" ]]; then - rm -rf "target/${{ matrix.target }}/release/tools"; - fi - mkdir -p "target/${{ matrix.target }}/release" - cp -rf etc tools "target/${{ matrix.target }}/release"/ - cd "target/${{ matrix.target }}/release/" - mkdir -p bin; - if [[ -e wxwork_robotd ]]; then - cp -f wxwork_robotd bin/wxwork_robotd; - else - cp -f wxwork_robotd* bin/; - fi - tar -zcvf ${{ matrix.target }}.tar.gz etc bin tools; - cp -f ../../../Dockerfile ./; - if [[ "${{ matrix.target }}" == "x86_64-unknown-linux-musl" ]] && [[ "xtag" == "x$GITHUB_REF_TYPE" ]]; then - TAG_NAME="$GITHUB_REF_TYPE"; - echo "Trigger by tag -> $TAG_NAME"; - which docker || true; - echo "${{ secrets.DOCKER_TOKEN }}" | docker login -u "owt5008137" --password-stdin docker.io - docker build --build-arg=GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} --force-rm --tag docker.io/owt5008137/wxwork_robotd:latest -f Dockerfile . - docker tag docker.io/owt5008137/wxwork_robotd:latest docker.io/owt5008137/wxwork_robotd:$TAG_NAME - docker push docker.io/owt5008137/wxwork_robotd:latest - docker push docker.io/owt5008137/wxwork_robotd:$TAG_NAME - else - echo "Trigger by $GITHUB_REF_TYPE -> $GITHUB_REF_NAME"; - fi - cd ../../..; - mv -f "target/${{ matrix.target }}/release/${{ matrix.target }}.tar.gz" ./; - - uses: xresloader/upload-to-github-release@v1 - if: ${{ github.ref_type == 'tag' }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - file: "*.tar.gz" - tags: true - draft: true - overwrite: true - macos_build: # job id, can be any string - # Job name is Build And Publish - name: macOS Build - # This job runs on Linux - strategy: - matrix: - os: [macOS-latest] - rust: [stable] - target: [x86_64-apple-darwin] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.rust }} - target: ${{ matrix.target }} - override: true - default: true - components: "rustfmt, clippy, cargo, rust-docs" - - name: Cargo Release build - uses: actions-rs/cargo@v1 - with: - use-cross: false - command: build - args: --target ${{ matrix.target }} --release --all-features - - name: Package - shell: bash - run: | - if [[ -e "target/${{ matrix.target }}/release/etc" ]]; then - rm -rf "target/${{ matrix.target }}/release/etc"; - fi - if [[ -e "target/${{ matrix.target }}/release/tools" ]]; then - rm -rf "target/${{ matrix.target }}/release/tools"; - fi - mkdir -p "target/${{ matrix.target }}/release" - cp -rf etc tools "target/${{ matrix.target }}/release"/ ; - cd "target/${{ matrix.target }}/release/"; - mkdir -p bin; - if [[ -e wxwork_robotd ]]; then - cp -f wxwork_robotd bin/wxwork_robotd; - else - cp -f wxwork_robotd* bin/; - fi - tar -zcvf ${{ matrix.target }}.tar.gz etc bin tools; - cd ../../..; - mv -f "target/${{ matrix.target }}/release/${{ matrix.target }}.tar.gz" ./; - - name: Run tests - run: | - cargo test --release --verbose --target ${{ matrix.target }} - - uses: xresloader/upload-to-github-release@v1 - if: ${{ github.ref_type == 'tag' }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - file: "*.tar.gz" - tags: true - draft: true - overwrite: true - windows_build: # job id, can be any string - # Job name is Build And Publish - name: Windows Build - # This job runs on Linux - strategy: - matrix: - os: [windows-latest] - rust: [stable] - target: [x86_64-pc-windows-msvc, i686-pc-windows-msvc] - #, x86_64-pc-windows-gnu - runs-on: ${{ matrix.os }} - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.rust }} - target: ${{ matrix.target }} - override: true - default: true - components: "rustfmt, clippy, cargo, rust-docs" - - name: Cargo Release build - uses: actions-rs/cargo@v1 - if: ${{ matrix.target != 'x86_64-pc-windows-gnu' }} - with: - use-cross: false - command: build - args: --target ${{ matrix.target }} --release --all-features - - name: Cross Release build - uses: actions-rs/cargo@v1 - if: ${{ matrix.target == 'x86_64-pc-windows-gnu' }} - with: - use-cross: false - command: build - args: --target ${{ matrix.target }} --release --all-features - - name: Package - shell: pwsh - run: | - Copy-Item -Force -Recurse etc "./target/${{ matrix.target }}/release/" - Copy-Item -Force -Recurse tools "./target/${{ matrix.target }}/release/" - cd "./target/${{ matrix.target }}/release/" - mkdir bin - Copy-Item -Force wxwork_robotd.exe bin/ - if ( Test-Path "${{ matrix.target }}.zip" ) { Remove-Item -Force "${{ matrix.target }}.zip" } - Compress-Archive -DestinationPath "${{ matrix.target }}.zip" -Path etc,bin,tools - Get-ChildItem - Get-ChildItem -Recurse etc,bin,tools - Copy-Item -Force "${{ matrix.target }}.zip" ../../../ - cd ../../../ - - name: Run tests - shell: pwsh - run: | - cargo test --release --verbose --target ${{ matrix.target }} - - uses: xresloader/upload-to-github-release@v1 - if: ${{ github.ref_type == 'tag' }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - file: "*.zip" - tags: true - draft: true - overwrite: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 647725b..fa1974c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,17 @@ CHANGELOG ============ +v0.10.0 +---------- + +1. 升级 clap 到 ^4.2.0 +2. 升级 awc 到 ^3.1.0 +3. 升级 rustls 到 >0.21.0 +4. 升级 quick-xml 到 >=0.28.0 +5. 升级 block-modes 到 >=0.9.0 +6. 升级 aes 到 >=0.8.2 +7. 升级 cipher 到 >=0.4.0 + v0.9.1 ---------- diff --git a/Cargo.lock b/Cargo.lock index 5a694b8..098a068 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,57 +4,58 @@ version = 3 [[package]] name = "actix-codec" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13895df506faee81e423febbae3a33b27fca71831b96bb3d60adf16ebcfea952" +checksum = "617a8268e3537fe1d8c9ead925fca49ef6400927ee7bc26750e90ecee14ce4b8" dependencies = [ "bitflags", "bytes", "futures-core", "futures-sink", - "log", "memchr", "pin-project-lite", "tokio", - "tokio-util 0.6.9", + "tokio-util", + "tracing", ] [[package]] name = "actix-http" -version = "3.0.0-beta.16" +version = "3.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6294c508c1413346857838356f53f45dbfd257ea31dca19470d9ce78750a7d37" +checksum = "c2079246596c18b4a33e274ae10c0e50613f4d32a4198e09c7b93771013fed74" dependencies = [ "actix-codec", "actix-rt", "actix-service", "actix-tls", "actix-utils", - "ahash", + "ahash 0.8.3", "base64", "bitflags", - "brotli2", + "brotli", "bytes", "bytestring", "derive_more", "encoding_rs", "flate2", "futures-core", - "futures-task", "h2", "http", "httparse", "httpdate", - "itoa 0.4.8", + "itoa 1.0.1", "language-tags", "local-channel", - "log", "mime", "percent-encoding", "pin-project-lite", "rand", - "sha-1 0.9.8", + "sha1", "smallvec", + "tokio", + "tokio-util", + "tracing", "zstd", ] @@ -65,50 +66,48 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "actix-router" -version = "0.5.0-beta.3" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd9f117b910fbcce6e9f45092ffd4ff017785a346d09e2d4fd049f4e20384f4" +checksum = "d66ff4d247d2b160861fa2866457e85706833527840e4133f8f49aa423a38799" dependencies = [ "bytestring", - "firestorm", "http", - "log", "regex", "serde", + "tracing", ] [[package]] name = "actix-rt" -version = "2.5.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05c2f80ce8d0c990941c7a7a931f69fd0701b76d521f8d36298edf59cd3fbf1f" +checksum = "15265b6b8e2347670eb363c47fc8c75208b4a4994b27192f345fcbe707804f3e" dependencies = [ - "actix-macros", "futures-core", "tokio", ] [[package]] name = "actix-server" -version = "2.0.0-rc.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78c9b22794b8af1c2e02434873ef858f2a7db40dbbf861ce77a04cd81ac6b767" +checksum = "3e8613a75dd50cc45f473cee3c34d59ed677c0f7b44480ce3b8247d7dc519327" dependencies = [ "actix-rt", "actix-service", "actix-utils", "futures-core", "futures-util", - "log", - "mio 0.8.0", + "mio 0.8.6", "num_cpus", "socket2", "tokio", + "tracing", ] [[package]] @@ -124,21 +123,20 @@ dependencies = [ [[package]] name = "actix-tls" -version = "3.0.0-rc.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcebfd4a6255a2a75b7b87c1a3a723c57f08293ca9a7fade692e94515585f7a6" +checksum = "9fde0cf292f7cdc7f070803cb9a0d45c018441321a78b1042ffbbb81ec333297" dependencies = [ "actix-codec", "actix-rt", "actix-service", "actix-utils", - "derive_more", "futures-core", "http", "log", "pin-project-lite", "tokio-rustls", - "tokio-util 0.6.9", + "tokio-util", "webpki-roots", ] @@ -154,9 +152,9 @@ dependencies = [ [[package]] name = "actix-web" -version = "4.0.0-beta.15" +version = "4.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4609cf57246040316642d4dc4c03d7f3d4a083a892122829dbd9e6ec8db7cd67" +checksum = "cd3cb42f9566ab176e1ef0b8b3a896529062b4efc6be0123046095914c4c1c96" dependencies = [ "actix-codec", "actix-http", @@ -168,20 +166,21 @@ dependencies = [ "actix-tls", "actix-utils", "actix-web-codegen", - "ahash", + "ahash 0.7.6", "bytes", + "bytestring", "cfg-if 1.0.0", "cookie", "derive_more", "encoding_rs", "futures-core", "futures-util", - "itoa 0.4.8", + "http", + "itoa 1.0.1", "language-tags", "log", "mime", "once_cell", - "paste", "pin-project-lite", "regex", "serde", @@ -195,14 +194,14 @@ dependencies = [ [[package]] name = "actix-web-codegen" -version = "0.5.0-beta.6" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a90b7f6c2fde9a1fe3df4da758c2c3c9d620dfa3eae4da0b6925dc0a13444a" +checksum = "2262160a7ae29e3415554a3f1fc04c764b1540c116aa524683208078b7a75bc9" dependencies = [ "actix-router", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -213,14 +212,13 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aes" -version = "0.7.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241" dependencies = [ "cfg-if 1.0.0", "cipher", "cpufeatures", - "opaque-debug 0.3.0", ] [[package]] @@ -234,6 +232,18 @@ dependencies = [ "version_check", ] +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if 1.0.0", + "getrandom", + "once_cell", + "version_check", +] + [[package]] name = "aho-corasick" version = "0.7.18" @@ -244,36 +254,80 @@ dependencies = [ ] [[package]] -name = "ansi_term" -version = "0.12.1" +name = "alloc-no-stdlib" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" + +[[package]] +name = "alloc-stdlib" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" dependencies = [ - "winapi 0.3.9", + "alloc-no-stdlib", ] [[package]] -name = "atty" -version = "0.2.14" +name = "anstream" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" dependencies = [ - "hermit-abi", - "libc", - "winapi 0.3.9", + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", ] [[package]] -name = "autocfg" +name = "anstyle" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" + +[[package]] +name = "anstyle-parse" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +dependencies = [ + "anstyle", + "windows-sys 0.48.0", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "awc" -version = "3.0.0-beta.14" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c7f4bbe98c31efbf5182545d1b0a423df909ee27281c66f3c9aaeb58120cf8b" +checksum = "87ef547a81796eb2dfe9b345aba34c2e08391a0502493711395b36dd64052b69" dependencies = [ "actix-codec", "actix-http", @@ -281,7 +335,7 @@ dependencies = [ "actix-service", "actix-tls", "actix-utils", - "ahash", + "ahash 0.7.6", "base64", "bytes", "cfg-if 1.0.0", @@ -291,30 +345,24 @@ dependencies = [ "futures-util", "h2", "http", - "itoa 0.4.8", + "itoa 1.0.1", "log", "mime", "percent-encoding", "pin-project-lite", "rand", - "rustls", + "rustls 0.20.2", "serde", "serde_json", "serde_urlencoded", "tokio", ] -[[package]] -name = "base-x" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" - [[package]] name = "base64" -version = "0.13.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" [[package]] name = "bitflags" @@ -334,15 +382,6 @@ dependencies = [ "generic-array 0.12.4", ] -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array 0.14.4", -] - [[package]] name = "block-buffer" version = "0.10.0" @@ -352,16 +391,6 @@ dependencies = [ "generic-array 0.14.4", ] -[[package]] -name = "block-modes" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cb03d1bed155d89dce0f845b7899b18a9a163e148fd004e1c28421a783e2d8e" -dependencies = [ - "block-padding 0.2.1", - "cipher", -] - [[package]] name = "block-padding" version = "0.1.5" @@ -373,28 +402,32 @@ dependencies = [ [[package]] name = "block-padding" -version = "0.2.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" +checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93" +dependencies = [ + "generic-array 0.14.4", +] [[package]] -name = "brotli-sys" -version = "0.3.2" +name = "brotli" +version = "3.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4445dea95f4c2b41cde57cc9fee236ae4dbae88d8fcbdb4750fc1bb5d86aaecd" +checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68" dependencies = [ - "cc", - "libc", + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", ] [[package]] -name = "brotli2" -version = "0.3.2" +name = "brotli-decompressor" +version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cb036c3eade309815c15ddbacec5b22c4d1f3983a774ab2eac2e3e9ea85568e" +checksum = "4b6561fd3f895a11e8f72af2cb7d22e08366bebc2b6b57f7744c4bda27034744" dependencies = [ - "brotli-sys", - "libc", + "alloc-no-stdlib", + "alloc-stdlib", ] [[package]] @@ -430,6 +463,15 @@ dependencies = [ "bytes", ] +[[package]] +name = "cbc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6" +dependencies = [ + "cipher", +] + [[package]] name = "cc" version = "1.0.72" @@ -466,32 +508,48 @@ dependencies = [ [[package]] name = "cipher" -version = "0.3.0" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ - "generic-array 0.14.4", + "crypto-common", + "inout", ] [[package]] name = "clap" -version = "2.34.0" +version = "4.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +checksum = "34d21f9bf1b425d2968943631ec91202fe5e837264063503708b83013f8fc938" dependencies = [ - "ansi_term", - "atty", + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914c8c79fb560f238ef6429439a30023c862f7a28e688c58f7203f12b29970bd" +dependencies = [ + "anstream", + "anstyle", "bitflags", + "clap_lex", + "once_cell", "strsim", - "textwrap", - "unicode-width", ] [[package]] -name = "const_fn" -version = "0.4.8" +name = "clap_lex" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" + +[[package]] +name = "colorchoice" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f92cfa0fd5690b3cf8c1ef2cabbd9b7ef22fa53cf5e1f92b05103f6d5d1cf6e7" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "convert_case" @@ -501,12 +559,12 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "cookie" -version = "0.15.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f1c7727e460397e56abc4bddc1d49e07a1ad78fc98eb2e1c8f032a58a2f80d" +checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" dependencies = [ "percent-encoding", - "time 0.2.27", + "time 0.3.5", "version_check", ] @@ -530,11 +588,12 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.1.1" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683d6b536309245c849479fba3da410962a43ed8e51c26b729208ec0ac2798d0" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array 0.14.4", + "typenum", ] [[package]] @@ -546,8 +605,8 @@ dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version 0.4.0", - "syn", + "rustc_version", + "syn 1.0.109", ] [[package]] @@ -561,37 +620,42 @@ dependencies = [ [[package]] name = "digest" -version = "0.9.0" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ - "generic-array 0.14.4", + "block-buffer 0.10.0", + "crypto-common", ] [[package]] -name = "digest" -version = "0.10.1" +name = "encoding_rs" +version = "0.8.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b697d66081d42af4fba142d56918a3cb21dc8eb63372c6b85d14f44fb9c5979b" +checksum = "7896dc8abb250ffdda33912550faa54c88ec8b998dec0b2c55ab224921ce11df" dependencies = [ - "block-buffer 0.10.0", - "crypto-common", - "generic-array 0.14.4", + "cfg-if 1.0.0", ] [[package]] -name = "discard" -version = "1.0.4" +name = "errno" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys 0.48.0", +] [[package]] -name = "encoding_rs" -version = "0.8.30" +name = "errno-dragonfly" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dc8abb250ffdda33912550faa54c88ec8b998dec0b2c55ab224921ce11df" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" dependencies = [ - "cfg-if 1.0.0", + "cc", + "libc", ] [[package]] @@ -600,12 +664,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" -[[package]] -name = "firestorm" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31586bda1b136406162e381a3185a506cdfc1631708dd40cba2f6628d8634499" - [[package]] name = "flate2" version = "1.0.22" @@ -706,7 +764,7 @@ checksum = "6dbd947adfffb0efc70599b3ddcf7b5597bb5fa9e245eb99f62b3a5f7bb8bd3c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -760,9 +818,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.3" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if 1.0.0", "libc", @@ -784,7 +842,7 @@ dependencies = [ "indexmap", "slab", "tokio", - "tokio-util 0.7.2", + "tokio-util", "tracing", ] @@ -817,6 +875,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + [[package]] name = "hex" version = "0.4.3" @@ -825,13 +889,13 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "http" -version = "0.2.5" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ "bytes", "fnv", - "itoa 0.4.8", + "itoa 1.0.1", ] [[package]] @@ -868,12 +932,24 @@ dependencies = [ ] [[package]] -name = "instant" -version = "0.1.12" +name = "inout" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" dependencies = [ - "cfg-if 1.0.0", + "block-padding 0.3.3", + "generic-array 0.14.4", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" +dependencies = [ + "hermit-abi 0.3.1", + "libc", + "windows-sys 0.48.0", ] [[package]] @@ -885,6 +961,18 @@ dependencies = [ "libc", ] +[[package]] +name = "is-terminal" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix", + "windows-sys 0.48.0", +] + [[package]] name = "itoa" version = "0.4.8" @@ -939,9 +1027,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.112" +version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" + +[[package]] +name = "linux-raw-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f" [[package]] name = "local-channel" @@ -963,10 +1057,11 @@ checksum = "902eb695eb0591864543cbfbf6d742510642a605a61fc5e97fe6ceb5a30ac4fb" [[package]] name = "lock_api" -version = "0.4.5" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" dependencies = [ + "autocfg", "scopeguard", ] @@ -997,7 +1092,7 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6a38fc55c8bbc10058782919516f88826e70320db6d206aebc49611d24216ae" dependencies = [ - "digest 0.10.1", + "digest 0.10.6", ] [[package]] @@ -1035,7 +1130,7 @@ dependencies = [ "kernel32-sys", "libc", "log", - "miow 0.2.2", + "miow", "net2", "slab", "winapi 0.2.8", @@ -1043,28 +1138,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.7.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" -dependencies = [ - "libc", - "log", - "miow 0.3.7", - "ntapi", - "winapi 0.3.9", -] - -[[package]] -name = "mio" -version = "0.8.0" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba272f85fa0b41fc91872be579b3bbe0f56b792aa361a380eb669469f68dafb2" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", - "miow 0.3.7", - "ntapi", - "winapi 0.3.9", + "wasi", + "windows-sys 0.45.0", ] [[package]] @@ -1090,15 +1171,6 @@ dependencies = [ "ws2_32-sys", ] -[[package]] -name = "miow" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "net2" version = "0.2.37" @@ -1110,15 +1182,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "ntapi" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "num-integer" version = "0.1.44" @@ -1144,15 +1207,15 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", ] [[package]] name = "once_cell" -version = "1.9.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "opaque-debug" @@ -1160,35 +1223,27 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - [[package]] name = "parking_lot" -version = "0.11.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ - "instant", "lock_api", "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.8.5" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if 1.0.0", - "instant", "libc", "redox_syscall", "smallvec", - "winapi 0.3.9", + "windows-sys 0.45.0", ] [[package]] @@ -1232,7 +1287,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1243,7 +1298,7 @@ checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" dependencies = [ "maplit", "pest", - "sha-1 0.8.2", + "sha-1", ] [[package]] @@ -1259,16 +1314,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] -name = "ppv-lite86" -version = "0.2.15" +name = "pkg-config" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] -name = "proc-macro-hack" -version = "0.5.19" +name = "ppv-lite86" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" +checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" [[package]] name = "proc-macro2" @@ -1287,18 +1342,18 @@ checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" [[package]] name = "quick-xml" -version = "0.22.0" +version = "0.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8533f14c8382aaad0d592c812ac3b826162128b65662331e1127b45c3d18536b" +checksum = "0ce5e73202a820a31f8a0ee32ada5e21029c81fd9e3ebf668a40832e4219d9d1" dependencies = [ "memchr", ] [[package]] name = "quote" -version = "1.0.10" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" +checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" dependencies = [ "proc-macro2", ] @@ -1386,20 +1441,25 @@ dependencies = [ [[package]] name = "rustc_version" -version = "0.2.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 0.9.0", + "semver", ] [[package]] -name = "rustc_version" -version = "0.4.0" +name = "rustix" +version = "0.37.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" dependencies = [ - "semver 1.0.4", + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1414,6 +1474,28 @@ dependencies = [ "webpki", ] +[[package]] +name = "rustls" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c911ba11bc8433e811ce56fde130ccf32f5127cab0e0194e9c68c5a5b671791e" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct", +] + +[[package]] +name = "rustls-webpki" +version = "0.100.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6207cd5ed3d8dca7816f8f3725513a34609c0c765bf652b8c3cb4cfd87db46b" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "ryu" version = "1.0.9" @@ -1436,27 +1518,12 @@ dependencies = [ "untrusted", ] -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - [[package]] name = "semver" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "serde" version = "1.0.132" @@ -1474,7 +1541,7 @@ checksum = "ecc0db5cb2556c0e558887d9bbdcf6ac4471e83ff66cf696e5419024d1606276" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1509,28 +1576,20 @@ dependencies = [ "block-buffer 0.7.3", "digest 0.8.1", "fake-simd", - "opaque-debug 0.2.3", + "opaque-debug", ] [[package]] -name = "sha-1" -version = "0.9.8" +name = "sha1" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" dependencies = [ - "block-buffer 0.9.0", "cfg-if 1.0.0", "cpufeatures", - "digest 0.9.0", - "opaque-debug 0.3.0", + "digest 0.10.6", ] -[[package]] -name = "sha1" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" - [[package]] name = "signal-hook-registry" version = "1.4.0" @@ -1554,9 +1613,9 @@ checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" [[package]] name = "socket2" -version = "0.4.2" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" dependencies = [ "libc", "winapi 0.3.9", @@ -1568,69 +1627,11 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" -[[package]] -name = "standback" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" -dependencies = [ - "version_check", -] - -[[package]] -name = "stdweb" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" -dependencies = [ - "discard", - "rustc_version 0.2.3", - "stdweb-derive", - "stdweb-internal-macros", - "stdweb-internal-runtime", - "wasm-bindgen", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" -dependencies = [ - "proc-macro2", - "quote", - "serde", - "serde_derive", - "syn", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" -dependencies = [ - "base-x", - "proc-macro2", - "quote", - "serde", - "serde_derive", - "serde_json", - "sha1", - "syn", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" - [[package]] name = "strsim" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" @@ -1644,12 +1645,14 @@ dependencies = [ ] [[package]] -name = "textwrap" -version = "0.11.0" +name = "syn" +version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01" dependencies = [ - "unicode-width", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] @@ -1662,21 +1665,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "time" -version = "0.2.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242" -dependencies = [ - "const_fn", - "libc", - "standback", - "stdweb", - "time-macros", - "version_check", - "winapi 0.3.9", -] - [[package]] name = "time" version = "0.3.5" @@ -1685,30 +1673,14 @@ checksum = "41effe7cfa8af36f439fac33861b66b049edc6f9a32331e2312660529c1c24ad" dependencies = [ "itoa 0.4.8", "libc", + "time-macros", ] [[package]] name = "time-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" -dependencies = [ - "proc-macro-hack", - "time-macros-impl", -] - -[[package]] -name = "time-macros-impl" -version = "0.1.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "standback", - "syn", -] +checksum = "25eb0ca3468fc0acc11828786797f6ef9aa1555e4a211a60d64cc8e4d1be47d6" [[package]] name = "tinyvec" @@ -1727,32 +1699,32 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.15.0" +version = "1.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838" +checksum = "0aa32867d44e6f2ce3385e89dceb990188b8bb0fb25b0cf576647a6f98ac5105" dependencies = [ + "autocfg", "bytes", "libc", - "memchr", - "mio 0.7.14", + "mio 0.8.6", "num_cpus", - "once_cell", "parking_lot", "pin-project-lite", "signal-hook-registry", + "socket2", "tokio-macros", - "winapi 0.3.9", + "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "1.7.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.16", ] [[package]] @@ -1761,25 +1733,11 @@ version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a27d5f2b839802bd8267fa19b0530f5a08b9c08cd417976be2a65d130fe1c11b" dependencies = [ - "rustls", + "rustls 0.20.2", "tokio", "webpki", ] -[[package]] -name = "tokio-util" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e99e1983e5d376cd8eb4b66604d2e99e79f5bd988c3055891dcd8c9e2604cc0" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "log", - "pin-project-lite", - "tokio", -] - [[package]] name = "tokio-util" version = "0.7.2" @@ -1796,11 +1754,12 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.29" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" +checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160" dependencies = [ "cfg-if 1.0.0", + "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1814,16 +1773,16 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "tracing-core" -version = "0.1.21" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ - "lazy_static", + "once_cell", ] [[package]] @@ -1859,12 +1818,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-width" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" - [[package]] name = "untrusted" version = "0.7.1" @@ -1883,17 +1836,23 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "version_check" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" @@ -1916,7 +1875,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-shared", ] @@ -1938,7 +1897,7 @@ checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2012,6 +1971,138 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.0", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -2024,14 +2115,14 @@ dependencies = [ [[package]] name = "wxwork_robotd" -version = "0.9.1" +version = "0.10.0" dependencies = [ "actix-web", "aes", "awc", - "block-modes", "byteorder", "bytes", + "cbc", "chrono", "cipher", "clap", @@ -2045,27 +2136,26 @@ dependencies = [ "quick-xml", "regex", "ring", - "rustls", + "rustls 0.21.1", "serde", - "serde_derive", "serde_json", "tokio", ] [[package]] name = "zstd" -version = "0.9.0+zstd.1.5.0" +version = "0.12.3+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07749a5dc2cb6b36661290245e350f15ec3bbb304e493db54a1d354480522ccd" +checksum = "76eea132fb024e0e13fd9c2f5d5d595d8a967aa72382ac2f9d39fcc95afd0806" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "4.1.1+zstd.1.5.0" +version = "6.0.5+zstd.1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c91c90f2c593b003603e5e0493c837088df4469da25aafff8bce42ba48caf079" +checksum = "d56d9e60b4b1758206c238a10165fbcae3ca37b01744e394c463463f6529d23b" dependencies = [ "libc", "zstd-sys", @@ -2073,10 +2163,11 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "1.6.1+zstd.1.5.0" +version = "2.0.8+zstd.1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "615120c7a2431d16cf1cf979e7fc31ba7a5b5e5707b29c8a99e5dbf8a8392a33" +checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" dependencies = [ "cc", "libc", + "pkg-config", ] diff --git a/Cargo.toml b/Cargo.toml index 9c3cd3e..4fd3358 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,26 +1,33 @@ [package] authors = ["owent "] -categories = ["network-programming", "web-programming::http-server", "web-programming::http-client", "development-tools"] +categories = [ + "network-programming", + "web-programming::http-server", + "web-programming::http-client", + "development-tools", +] description = "Robot service for WXWork" -documentation = "https://github.com/owt5008137/wxwork_robotd" -edition = "2018" +documentation = "https://github.com/owent/wxwork_robotd" +edition = "2021" homepage = "https://crates.io/crates/wxwork_robotd" -include = ["src/**/*.rs", "Cargo.toml", "Cross.toml", "README.md", "tools/__init__.py", "tools/qyapi_wx_send_robot.py"] +include = [ + "src/**/*.rs", + "Cargo.toml", + "Cross.toml", + "README.md", + "tools/__init__.py", + "tools/qyapi_wx_send_robot.py", +] keywords = ["wxwork", "wework", "robot", "weixin", "wechat"] license = "MIT OR Apache-2.0" name = "wxwork_robotd" readme = "README.md" -repository = "https://github.com/owt5008137/wxwork_robotd" -version = "0.9.1" +repository = "https://github.com/owent/wxwork_robotd" +version = "0.10.0" + [[bin]] name = "wxwork_robotd" -[build-dependencies] -[build-dependencies.clap] -default-features = false -features = ["suggestions", "color"] -version = "^2.33.0" - [dependencies] byteorder = "^1.3.2" bytes = "^1.1.0" @@ -32,30 +39,28 @@ lazy_static = "^1.2.0" log = ">=0.4.3" mio-uds = "^0.6.7" ring = ">=0.16.0" -rustls = ">=0.20.0" -quick-xml = ">=0.22.0" +rustls = ">=0.21.0" +quick-xml = ">=0.28.0" regex = "^1.5.5" -serde = "^1.0.80" -serde_derive = "^1.0.80" +serde = { version = "1.0", features = ["derive"] } serde_json = "^1.0.33" -block-modes = ">=0.8.0" -aes = ">=0.7.5" +aes = ">=0.8.2" +cbc = ">=0.1.2" md-5 = ">=0.10.0" -cipher = ">=0.3.0" +cipher = { version = ">=0.4.0", features = ["alloc"] } # https://github.com/RustCrypto [dependencies.actix-web] features = ["rustls"] -version = "^4.0.0-beta.15" +version = "^4.3.0" [dependencies.awc] features = ["rustls"] -version = "^3.0.0-beta.14" +version = "^3.1.0" [dependencies.clap] -default-features = false -features = ["suggestions", "color"] -version = "^2.34.0" +features = ["std", "suggestions", "color", "cargo", "help"] +version = "^4.2.0" [dependencies.tokio] features = ["full"] diff --git a/LICENSE b/LICENSE index d365ed4..64ad6a1 100644 --- a/LICENSE +++ b/LICENSE @@ -187,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2022 owent + Copyright 2023 owent Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/LICENSE-MIT b/LICENSE-MIT index 474e65a..dbefd15 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,4 +1,4 @@ -Copyright (c) 2022 owent +Copyright (c) 2023 owent Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated diff --git a/etc/conf.json b/etc/conf.json index ee4449c..f8979fc 100644 --- a/etc/conf.json +++ b/etc/conf.json @@ -1,6 +1,6 @@ { "listen": [":::12019", "0.0.0.0:12019"], - "taskTimeout": 4000, + "task_timeout": 4000, "workers": 8, "backlog": 256, "keep_alive": 5, diff --git a/src/app.rs b/src/app.rs index dc96088..294d1b0 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,13 +1,14 @@ -extern crate clap; -use clap::{App, Arg, ArgMatches}; use std::fs::{create_dir_all, OpenOptions}; use std::io::Write; use std::net::ToSocketAddrs; use std::path::Path; use std::process; use std::rc::Rc; +use std::str::FromStr; use std::sync::Arc; +use crate::clap::{Arg, ArgAction, ArgMatches}; + use super::wxwork_robot::command::{WxWorkCommandList, WxWorkCommandMatch, WxWorkCommandPtr}; use super::wxwork_robot::project::WxWorkProject; use super::wxwork_robot::{build_project_set_shared, WxWorkProjectSet, WxWorkProjectSetShared}; @@ -18,7 +19,7 @@ pub struct AppConfigure { pub hosts: Option>, pub workers: usize, pub backlog: u32, - pub keep_alive: usize, + pub keep_alive: u64, pub client_timeout: u64, pub client_shutdown: u64, pub max_connection_per_worker: usize, @@ -77,6 +78,50 @@ static mut APP_ENV_INFO_STORE: AppEnvironmentInfo = AppEnvironmentInfo { }, }; +fn unwraper_flag(matches: &ArgMatches, name: S) -> bool +where + S: AsRef, +{ + if let Ok(Some(x)) = matches.try_get_one::(name.as_ref()) { + return *x; + } + + false +} + +pub trait OptionValueWrapper { + fn pick(input: &str) -> Option; +} + +impl OptionValueWrapper for T +where + T: FromStr, +{ + fn pick(input: &str) -> Option { + if let Ok(v) = input.parse::() { + Some(v) + } else { + None + } + } +} + +fn unwraper_option(matches: &ArgMatches, name: S) -> Option +where + T: OptionValueWrapper, + S: AsRef, +{ + if let Ok(Some(x)) = matches.try_get_raw(name.as_ref()) { + for val in x { + if let Some(str_val) = val.to_str() { + return T::pick(str_val); + } + } + } + + None +} + /// Build a clap application parameterized by usage strings. pub fn app() -> AppEnvironment { unsafe { @@ -85,130 +130,111 @@ pub fn app() -> AppEnvironment { } } - let app = App::new(crate_name!()) + let matches = command!(); + + let app = matches .author(crate_authors!()) .version(crate_version!()) .about(crate_description!()) - .max_term_width(100) + .max_term_width(120) .arg( - Arg::with_name("version") - .short("v") + Arg::new("version") + .short('v') .long("version") + .action(ArgAction::SetTrue) .help("Show version"), ) .arg( - Arg::with_name("debug") - .short("d") + Arg::new("debug") + .short('d') .long("debug") + .action(ArgAction::SetTrue) .help("Show debug log"), ) .arg( - Arg::with_name("prefix") - .short("P") + Arg::new("prefix") + .short('P') .long("prefix") .value_name("PREFIX") .help("Set a url prefix for current service") - .takes_value(true) .default_value("/"), ) .arg( - Arg::with_name("configure") - .short("c") + Arg::new("configure") + .short('c') .long("conf") .value_name("CONFIGURE") .help("Set configure file") - .required(true) - .takes_value(true), + .required(true), ) .arg( - Arg::with_name("log") - .short("l") + Arg::new("log") + .short('l') .long("log") .value_name("LOG PATH") - .help("Set log path") - .takes_value(true), + .help("Set log path"), ) .arg( - Arg::with_name("log-rotate") + Arg::new("log-rotate") .long("log-rotate") .value_name("LOG ROTATE") .help("Set log rotate") - .takes_value(true) .default_value("8"), ) .arg( - Arg::with_name("log-rotate-size") + Arg::new("log-rotate-size") .long("log-rotate-size") .value_name("LOG ROTATE SIZE") - .help("Set log rotate size in bytes") - .takes_value(true), + .help("Set log rotate size in bytes"), ) .arg( - Arg::with_name("pid-file") + Arg::new("pid-file") .long("pid-file") .value_name("PID FILE") - .help("Set path of pid file") - .takes_value(true), + .help("Set path of pid file"), ); let matches: ArgMatches = app.get_matches(); - if matches.is_present("version") { + if unwraper_flag(&matches, "version") { println!("{}", crate_version!()); process::exit(0); } unsafe { - if matches.is_present("debug") { + if unwraper_flag(&matches, "debug") { APP_ENV_INFO_STORE.debug = true; } - if let Some(mut x) = matches.values_of("configure") { - if let Some(val) = x.next() { - APP_ENV_INFO_STORE.configure = Some(String::from(val)); - } + if let Some(val) = unwraper_option(&matches, "configure") { + APP_ENV_INFO_STORE.configure = Some(val); } - if let Some(mut x) = matches.values_of("prefix") { - if let Some(val) = x.next() { - let mut val_str = String::from(val); - if !val_str.starts_with('/') { - val_str.insert(0, '/'); - } - if !val_str.ends_with('/') { - val_str.push('/'); - } - APP_ENV_INFO_STORE.prefix = Some(val_str); + if let Some(mut val_str) = unwraper_option::(&matches, "prefix") { + if !val_str.starts_with('/') { + val_str.insert(0, '/'); } + if !val_str.ends_with('/') { + val_str.push('/'); + } + APP_ENV_INFO_STORE.prefix = Some(val_str); } - if let Some(mut x) = matches.values_of("log") { - if let Some(val) = x.next() { - APP_ENV_INFO_STORE.log = Some(String::from(val)); - } + if let Some(val) = unwraper_option(&matches, "log") { + APP_ENV_INFO_STORE.log = Some(val); } else { APP_ENV_INFO_STORE.log = Some(format!("{}.log", crate_name!())); } - if let Some(mut x) = matches.values_of("log-rotate") { - if let Some(val) = x.next() { - if let Ok(rotate) = val.parse::() { - APP_ENV_INFO_STORE.log_rotate = rotate; - } - } + if let Some(rotate) = unwraper_option(&matches, "log-rotate") { + APP_ENV_INFO_STORE.log_rotate = rotate; } - if let Some(mut x) = matches.values_of("log-rotate-size") { - if let Some(val) = x.next() { - if let Ok(rotate) = val.parse::() { - APP_ENV_INFO_STORE.log_rotate_size = rotate; - } - } + if let Some(rotate_size) = unwraper_option(&matches, "log-rotate-size") { + APP_ENV_INFO_STORE.log_rotate_size = rotate_size; } - if let Some(mut x) = matches.values_of("pid-file") { - if let Some(val) = x.next() { - APP_ENV_INFO_STORE.pid_file = Some(String::from(val)); - } + if let Some(val) = unwraper_option(&matches, "pid-file") { + APP_ENV_INFO_STORE.pid_file = Some(val); } else { APP_ENV_INFO_STORE.pid_file = Some(format!("{}.pid", crate_name!())); } @@ -388,11 +414,7 @@ impl AppEnvironment { pub fn get_projects(&self) -> Option { let ret: Option; unsafe { - ret = if let Some(ref x) = APP_ENV_INFO_STORE.projects { - Some(x.clone()) - } else { - None - }; + ret = APP_ENV_INFO_STORE.projects.as_ref().cloned(); } ret @@ -401,7 +423,7 @@ impl AppEnvironment { pub fn set_projects(&self, val: WxWorkProjectSetShared) { { if let Ok(x) = val.lock() { - let ref_x: &WxWorkProjectSet = &*x; + let ref_x: &WxWorkProjectSet = &x; for (k, _) in ref_x.projs.iter() { info!("load project \"{}\" success", k); } @@ -424,7 +446,7 @@ impl AppEnvironment { pub fn get_project(&self, name: &str) -> Option> { if let Some(projs) = self.get_projects() { if let Ok(x) = projs.lock() { - if let Some(found_proj) = (*x).projs.get(name) { + if let Some(found_proj) = x.projs.get(name) { return Some(found_proj.clone()); } } @@ -440,7 +462,7 @@ impl AppEnvironment { ) -> Option<(WxWorkCommandPtr, WxWorkCommandMatch)> { if let Some(projs) = self.get_projects() { if let Ok(x) = projs.lock() { - return WxWorkProject::try_capture_commands(&(*x).cmds, message, allow_hidden); + return WxWorkProject::try_capture_commands(&x.cmds, message, allow_hidden); } } @@ -454,7 +476,7 @@ impl AppEnvironment { ) -> Option<(WxWorkCommandPtr, WxWorkCommandMatch)> { if let Some(projs) = self.get_projects() { if let Ok(x) = projs.lock() { - return WxWorkProject::try_capture_commands(&(*x).events, message, allow_hidden); + return WxWorkProject::try_capture_commands(&x.events, message, allow_hidden); } } @@ -467,7 +489,7 @@ impl AppEnvironment { pub fn get_global_command_list(&self) -> Rc { if let Some(projs) = self.get_projects() { if let Ok(x) = projs.lock() { - return (*x).cmds.clone(); + return x.cmds.clone(); } } @@ -512,7 +534,15 @@ impl AppEnvironment { return; }; - if let Some(x) = kvs.get("taskTimeout") { + if let Some(x) = kvs.get("task_timeout") { + if let Some(v) = x.as_u64() { + if v > 0 { + unsafe { + APP_ENV_INFO_STORE.conf.task_timeout = v; + } + } + } + } else if let Some(x) = kvs.get("taskTimeout") { if let Some(v) = x.as_u64() { if v > 0 { unsafe { @@ -546,7 +576,7 @@ impl AppEnvironment { if let Some(v) = x.as_u64() { if v > 0 { unsafe { - APP_ENV_INFO_STORE.conf.keep_alive = v as usize; + APP_ENV_INFO_STORE.conf.keep_alive = v; } } } @@ -556,7 +586,7 @@ impl AppEnvironment { if let Some(v) = x.as_u64() { if v > 0 { unsafe { - APP_ENV_INFO_STORE.conf.client_timeout = v as u64; + APP_ENV_INFO_STORE.conf.client_timeout = v; } } } @@ -566,7 +596,7 @@ impl AppEnvironment { if let Some(v) = x.as_u64() { if v > 0 { unsafe { - APP_ENV_INFO_STORE.conf.client_shutdown = v as u64; + APP_ENV_INFO_STORE.conf.client_shutdown = v; } } } diff --git a/src/handles/robot.rs b/src/handles/robot.rs index 080ae51..0278a99 100644 --- a/src/handles/robot.rs +++ b/src/handles/robot.rs @@ -1,5 +1,6 @@ -use actix_web::{web, FromRequest, HttpRequest, HttpResponse}; -use serde::Deserialize; +use crate::actix_web::{web, FromRequest, HttpRequest, HttpResponse}; +use crate::serde::Deserialize; + use std::sync::Arc; use super::super::app::AppEnvironment; diff --git a/src/logger/mod.rs b/src/logger/mod.rs index 6dbf2ad..f6ec1f2 100644 --- a/src/logger/mod.rs +++ b/src/logger/mod.rs @@ -126,7 +126,7 @@ impl Log for FileRotateLogger { let content = if record.file().is_some() && record.line().is_some() { format!( "{} {:<5} [{}:{}@{}] {}\n", - now.format("%Y-%m-%d %H:%M:%S").to_string(), + now.format("%Y-%m-%d %H:%M:%S"), record.level().to_string(), record.file().unwrap(), record.line().unwrap(), @@ -136,7 +136,7 @@ impl Log for FileRotateLogger { } else { format!( "{} {:<5} [{}] {}\n", - now.format("%Y-%m-%d %H:%M:%S").to_string(), + now.format("%Y-%m-%d %H:%M:%S"), record.level().to_string(), record.module_path().unwrap_or_default(), record.args(), @@ -177,7 +177,7 @@ impl Log for FileRotateLogger { } fn get_log_path(file_path: &str, rotate_num: i32) -> String { - return format!("{}.{}", file_path, rotate_num); + format!("{}.{}", file_path, rotate_num) } static mut SHARED_FILE_ROTATE_LOG: FileRotateLoggerWrapper = FileRotateLoggerWrapper::Nil; diff --git a/src/main.rs b/src/main.rs index 202a6d1..c192c2c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,7 +22,7 @@ extern crate serde; #[macro_use] extern crate serde_json; extern crate aes; -extern crate block_modes; +extern crate cbc; extern crate cipher; extern crate md5; extern crate regex; @@ -40,6 +40,7 @@ extern crate tokio; use actix_web::{middleware::Logger, web, App, HttpServer}; use std::io; use std::net::TcpListener; +use std::time::Duration; pub mod app; pub mod handles; @@ -104,9 +105,9 @@ async fn main() -> io::Result<()> { .backlog(app_env.conf.backlog) .max_connections(app_env.conf.max_connection_per_worker) .max_connection_rate(app_env.conf.max_concurrent_rate_per_worker) - .keep_alive(app_env.conf.keep_alive) - .client_timeout(app_env.conf.client_timeout) - .client_shutdown(app_env.conf.client_shutdown); + .keep_alive(Duration::from_secs(app_env.conf.keep_alive)) + .client_request_timeout(Duration::from_millis(app_env.conf.client_timeout)) + .client_disconnect_timeout(Duration::from_millis(app_env.conf.client_shutdown)); // server = server.client_timeout(app_env.conf.task_timeout); let mut listened_count = 0; diff --git a/src/wxwork_robot/command.rs b/src/wxwork_robot/command.rs index 0bebd78..56d7126 100644 --- a/src/wxwork_robot/command.rs +++ b/src/wxwork_robot/command.rs @@ -76,8 +76,8 @@ pub type WxWorkCommandPtr = Arc; pub type WxWorkCommandList = Vec; pub fn read_string_from_json_object(json: &serde_json::Value, name: &str) -> Option { - if let Some(ref x) = json.as_object() { - if let Some(ref v) = x.get(name) { + if let Some(x) = json.as_object() { + if let Some(v) = x.get(name) { if let Some(r) = v.as_str() { return Some(String::from(r)); } @@ -91,8 +91,8 @@ pub fn read_object_from_json_object<'a>( json: &'a serde_json::Value, name: &str, ) -> Option<&'a serde_json::map::Map> { - if let Some(ref x) = json.as_object() { - if let Some(ref v) = x.get(name) { + if let Some(x) = json.as_object() { + if let Some(v) = x.get(name) { if let Some(r) = v.as_object() { return Some(r); } @@ -103,7 +103,7 @@ pub fn read_object_from_json_object<'a>( } pub fn read_bool_from_json_object(json: &serde_json::Value, name: &str) -> Option { - if let Some(ref x) = json.as_object() { + if let Some(x) = json.as_object() { if let Some(v) = x.get(name) { return match v { serde_json::Value::Null => None, @@ -142,8 +142,8 @@ pub fn read_array_from_json_object<'a>( json: &'a serde_json::Value, name: &str, ) -> Option<&'a Vec> { - if let Some(ref x) = json.as_object() { - if let Some(ref v) = x.get(name) { + if let Some(x) = json.as_object() { + if let Some(v) = x.get(name) { if let Some(r) = v.as_array() { return Some(r); } @@ -154,7 +154,7 @@ pub fn read_array_from_json_object<'a>( } pub fn read_i64_from_json_object(json: &serde_json::Value, name: &str) -> Option { - if let Some(ref x) = json.as_object() { + if let Some(x) = json.as_object() { if let Some(v) = x.get(name) { return match v { serde_json::Value::Null => None, @@ -495,12 +495,10 @@ impl WxWorkCommand { json["WXWORK_ROBOT_CMD"] = serde_json::Value::String(String::from(caps.get(0).unwrap().as_str())); - for cap_name in self.rule.capture_names() { - if let Some(key) = cap_name { - if let Some(m) = caps.name(key) { - json[format!("WXWORK_ROBOT_CMD_{}", key).as_str().to_uppercase()] = - serde_json::Value::String(String::from(m.as_str())); - } + for key in self.rule.capture_names().flatten() { + if let Some(m) = caps.name(key) { + json[format!("WXWORK_ROBOT_CMD_{}", key).as_str().to_uppercase()] = + serde_json::Value::String(String::from(m.as_str())); } } diff --git a/src/wxwork_robot/command_runtime.rs b/src/wxwork_robot/command_runtime.rs index e624005..1ef6ae8 100644 --- a/src/wxwork_robot/command_runtime.rs +++ b/src/wxwork_robot/command_runtime.rs @@ -92,16 +92,16 @@ async fn run_help(runtime: Arc) -> HttpResponse { } let mut cmd_index = 1; - for ref cmd in runtime.proj.cmds.as_ref() { - if let Some(desc) = command::get_command_description(&cmd) { + for cmd in runtime.proj.cmds.as_ref() { + if let Some(desc) = command::get_command_description(cmd) { output += format!("> {}. {}\r\n", cmd_index, desc).as_str(); cmd_index += 1; } } let app_env = app::app(); - for ref cmd in app_env.get_global_command_list().as_ref() { - if let Some(desc) = command::get_command_description(&cmd) { + for cmd in app_env.get_global_command_list().as_ref() { + if let Some(desc) = command::get_command_description(cmd) { output += format!("> {}. {}\r\n", cmd_index, desc).as_str(); cmd_index += 1; } @@ -264,7 +264,7 @@ async fn run_http(runtime: Arc) -> HttpResponse { } }; - let data_str = if let Ok(x) = String::from_utf8((&rsp_data).to_vec()) { + let data_str = if let Ok(x) = String::from_utf8(rsp_data.to_vec()) { x } else { hex::encode(&rsp_data) diff --git a/src/wxwork_robot/error.rs b/src/wxwork_robot/error.rs index 6e638e5..07f1462 100644 --- a/src/wxwork_robot/error.rs +++ b/src/wxwork_robot/error.rs @@ -5,7 +5,6 @@ pub enum Error { StringErr(String), ActixWebErr(actix_web::Error), Base64Err(base64::DecodeError), - CryptoErr(block_modes::BlockModeError), } impl From for actix_web::Error { @@ -13,7 +12,6 @@ impl From for actix_web::Error { match e { Error::ActixWebErr(x) => x, Error::StringErr(x) => actix_web::error::ErrorForbidden(x), - Error::CryptoErr(x) => actix_web::error::ErrorForbidden(format!("{:?}", x)), Error::Base64Err(x) => actix_web::error::ErrorForbidden(format!("{:?}", x)), } } diff --git a/src/wxwork_robot/message.rs b/src/wxwork_robot/message.rs index 9dd9a50..1bb0feb 100644 --- a/src/wxwork_robot/message.rs +++ b/src/wxwork_robot/message.rs @@ -1,15 +1,19 @@ -use actix_web::web; -use md5::{Digest, Md5}; +use quick_xml::events::BytesCData; + +use crate::actix_web::web; +use crate::md5::{Digest, Md5}; // use hex; -use quick_xml::events::{BytesEnd, BytesStart, BytesText, Event}; -use quick_xml::Reader; -use quick_xml::Writer; -use std::io::Cursor; +use crate::quick_xml::events::{BytesEnd, BytesStart, BytesText, Event}; +use crate::quick_xml::name::QName; +use crate::quick_xml::Reader; +use crate::quick_xml::Writer; -use actix_web::HttpResponse; +use crate::actix_web::HttpResponse; -use regex::{Regex, RegexBuilder}; +use crate::regex::{Regex, RegexBuilder}; + +use std::io::Cursor; use super::base64; @@ -75,29 +79,27 @@ pub fn get_msg_encrypt_from_bytes(bytes: web::Bytes) -> Option { reader.trim_text(true); let mut is_msg_field = false; let mut ret = None; - let mut buf = Vec::new(); + loop { - match reader.read_event(&mut buf) { + match reader.read_event() { Ok(Event::Start(ref e)) => { - if let b"Encrypt" = e.name() { + if let QName(b"Encrypt") = e.name() { is_msg_field = true; } } Ok(Event::End(ref e)) => { - if let b"Encrypt" = e.name() { + if let QName(b"Encrypt") = e.name() { is_msg_field = false; } } Ok(Event::CData(data)) => { if is_msg_field { - if let Ok(x) = data.unescaped() { - match String::from_utf8(Vec::from(x)) { - Ok(s) => { - ret = Some(s); - } - Err(e) => { - error!("decode Encrypt as utf8 failed, {:?}", e); - } + match String::from_utf8(Vec::from(data.into_inner())) { + Ok(s) => { + ret = Some(s); + } + Err(e) => { + error!("decode Encrypt as utf8 failed, {:?}", e); } } } @@ -106,12 +108,12 @@ pub fn get_msg_encrypt_from_bytes(bytes: web::Bytes) -> Option { Ok(Event::Eof) => break, _ => (), } - buf.clear(); } ret } +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] enum WxWorkMsgField { None, WebHookUrl, @@ -159,12 +161,85 @@ pub fn get_msg_from_str(input: &str) -> Option { let mut reader = Reader::from_str(input); reader.trim_text(true); - let mut buf = Vec::new(); + let mut setter_fn = |data_str, field_mode| match field_mode { + WxWorkMsgField::WebHookUrl => { + web_hook_url = data_str; + debug!("Parse data for WebhookUrl"); + } + WxWorkMsgField::FromUserId => { + from_user_id = data_str; + debug!("Parse data for From.UserId"); + } + WxWorkMsgField::FromName => { + from_name = data_str; + debug!("Parse data for From.Name"); + } + WxWorkMsgField::FromAlias => { + from_alias = data_str; + debug!("Parse data for From.Alias"); + } + WxWorkMsgField::MsgType => { + msg_type = data_str; + debug!("Parse data for MsgType"); + } + WxWorkMsgField::Content => { + content = data_str; + debug!("Parse data for Content"); + } + WxWorkMsgField::ImageUrl => { + image_url = data_str; + debug!("Parse data for ImageUrl"); + } + WxWorkMsgField::MsgId => { + msg_id = data_str; + debug!("Parse data for MsgId"); + } + WxWorkMsgField::GetChatInfoUrl => { + get_chat_info_url = data_str; + debug!("Parse data for GetChatInfoUrl"); + } + WxWorkMsgField::PostId => { + post_id = data_str; + debug!("Parse data for PostId"); + } + WxWorkMsgField::ChatId => { + chat_id = data_str; + debug!("Parse data for ChatId"); + } + WxWorkMsgField::ChatType => { + chat_type = data_str; + debug!("Parse data for ChatType"); + } + WxWorkMsgField::AppVersion => { + app_version = data_str; + debug!("Parse data for AppVersion"); + } + WxWorkMsgField::EventType => { + event_type = data_str; + debug!("Parse data for EventType"); + } + WxWorkMsgField::ActionCallbackId => { + action_callbackid = data_str; + debug!("Parse data for ActionCallbackId"); + } + WxWorkMsgField::ActionName => { + action_name = data_str; + debug!("Parse data for ActionName"); + } + WxWorkMsgField::ActionValue => { + action_value = data_str; + debug!("Parse data for ActionValue"); + } + _ => { + debug!("Ignore data {}", data_str); + } + }; + loop { - match reader.read_event(&mut buf) { + match reader.read_event() { Ok(Event::Start(ref e)) => { let tag_name = e.name(); - match tag_name { + match tag_name.into_inner() { b"WebhookUrl" => { field_mode = WxWorkMsgField::WebHookUrl; debug!("Parse get ready for WebhookUrl"); @@ -268,7 +343,7 @@ pub fn get_msg_from_str(input: &str) -> Option { } } } - Ok(Event::End(ref e)) => match e.name() { + Ok(Event::End(ref e)) => match e.name().into_inner() { b"WebhookUrl" => { if let WxWorkMsgField::WebHookUrl = field_mode { field_mode = WxWorkMsgField::None; @@ -405,21 +480,17 @@ pub fn get_msg_from_str(input: &str) -> Option { ); } }, - Ok(Event::CData(data)) | Ok(Event::Text(data)) => { + Ok(Event::CData(data)) => { if let WxWorkMsgField::None = field_mode { continue; } - let data_str_opt = if let Ok(x) = data.unescaped() { - match String::from_utf8(Vec::from(x)) { - Ok(s) => Some(s), - Err(e) => { - error!("decode Encrypt as utf8 failed, {:?}", e); - None - } + let data_str_opt = match String::from_utf8(Vec::from(data.into_inner())) { + Ok(s) => Some(s), + Err(e) => { + error!("decode Encrypt as utf8 failed, {:?}", e); + None } - } else { - None }; let data_str = if let Some(x) = data_str_opt { @@ -428,85 +499,34 @@ pub fn get_msg_from_str(input: &str) -> Option { continue; }; - match field_mode { - WxWorkMsgField::WebHookUrl => { - web_hook_url = data_str; - debug!("Parse data for WebhookUrl"); - } - WxWorkMsgField::FromUserId => { - from_user_id = data_str; - debug!("Parse data for From.UserId"); - } - WxWorkMsgField::FromName => { - from_name = data_str; - debug!("Parse data for From.Name"); - } - WxWorkMsgField::FromAlias => { - from_alias = data_str; - debug!("Parse data for From.Alias"); - } - WxWorkMsgField::MsgType => { - msg_type = data_str; - debug!("Parse data for MsgType"); - } - WxWorkMsgField::Content => { - content = data_str; - debug!("Parse data for Content"); - } - WxWorkMsgField::ImageUrl => { - image_url = data_str; - debug!("Parse data for ImageUrl"); - } - WxWorkMsgField::MsgId => { - msg_id = data_str; - debug!("Parse data for MsgId"); - } - WxWorkMsgField::GetChatInfoUrl => { - get_chat_info_url = data_str; - debug!("Parse data for GetChatInfoUrl"); - } - WxWorkMsgField::PostId => { - post_id = data_str; - debug!("Parse data for PostId"); - } - WxWorkMsgField::ChatId => { - chat_id = data_str; - debug!("Parse data for ChatId"); - } - WxWorkMsgField::ChatType => { - chat_type = data_str; - debug!("Parse data for ChatType"); - } - WxWorkMsgField::AppVersion => { - app_version = data_str; - debug!("Parse data for AppVersion"); - } - WxWorkMsgField::EventType => { - event_type = data_str; - debug!("Parse data for EventType"); - } - WxWorkMsgField::ActionCallbackId => { - action_callbackid = data_str; - debug!("Parse data for ActionCallbackId"); - } - WxWorkMsgField::ActionName => { - action_name = data_str; - debug!("Parse data for ActionName"); - } - WxWorkMsgField::ActionValue => { - action_value = data_str; - debug!("Parse data for ActionValue"); - } - _ => { - debug!("Ignore data {}", data_str); - } + setter_fn(data_str, field_mode); + } + Ok(Event::Text(data)) => { + if let WxWorkMsgField::None = field_mode { + continue; } + + let data_str_opt = match String::from_utf8(Vec::from(data.into_inner())) { + Ok(s) => Some(s), + Err(e) => { + error!("decode Encrypt as utf8 failed, {:?}", e); + None + } + }; + + let data_str = if let Some(x) = data_str_opt { + x + } else { + continue; + }; + + setter_fn(data_str, field_mode); } + Err(e) => error!("Error at position {}: {:?}", reader.buffer_position(), e), Ok(Event::Eof) => break, _ => {} } - buf.clear(); } let web_hook_key = if let Some(caps) = PICK_WEBHOOK_KEY_RULE.captures(web_hook_url.as_str()) { @@ -556,71 +576,70 @@ pub fn pack_text_message(msg: WxWorkMessageTextRsp) -> Result { let mut writer = Writer::new(Cursor::new(Vec::new())); if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"xml"))) + .write_event(Event::Start(BytesStart::new("xml"))) .is_ok() { if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"MsgType"))) + .write_event(Event::Start(BytesStart::new("MsgType"))) .is_ok() { - let _ = writer.write_event(Event::Text(BytesText::from_plain_str("text"))); - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"MsgType"))); + let _ = writer.write_event(Event::Text(BytesText::new("text"))); + let _ = writer.write_event(Event::End(BytesEnd::new("MsgType"))); } if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"Text"))) + .write_event(Event::Start(BytesStart::new("Text"))) .is_ok() { if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"Content"))) + .write_event(Event::Start(BytesStart::new("Content"))) .is_ok() { - let _ = writer.write_event(Event::CData(BytesText::from_plain_str( - msg.content.as_str(), + let _ = writer.write_event(Event::CData(BytesCData::new( + quick_xml::escape::escape(msg.content.as_str()), ))); - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"Content"))); + let _ = writer.write_event(Event::End(BytesEnd::new("Content"))); } if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"MentionedList"))) + .write_event(Event::Start(BytesStart::new("MentionedList"))) .is_ok() { for v in msg.mentioned_list { if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"Item"))) + .write_event(Event::Start(BytesStart::new("Item"))) .is_ok() { - let _ = - writer.write_event(Event::CData(BytesText::from_plain_str(v.as_str()))); - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"Item"))); + let _ = writer.write_event(Event::CData(BytesCData::new( + quick_xml::escape::escape(v.as_str()), + ))); + let _ = writer.write_event(Event::End(BytesEnd::new("Item"))); } } - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"MentionedList"))); + let _ = writer.write_event(Event::End(BytesEnd::new("MentionedList"))); } if writer - .write_event(Event::Start(BytesStart::borrowed_name( - b"MentionedMobileList", - ))) + .write_event(Event::Start(BytesStart::new("MentionedMobileList"))) .is_ok() { for v in msg.mentioned_mobile_list { if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"Item"))) + .write_event(Event::Start(BytesStart::new("Item"))) .is_ok() { - let _ = writer.write_event(Event::CData(BytesText::from_plain_str( - v.to_string().as_str(), + let _ = writer.write_event(Event::CData(BytesCData::new( + quick_xml::escape::escape(v.to_string().as_str()), ))); - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"Item"))); + let _ = writer.write_event(Event::End(BytesEnd::new("Item"))); } } - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"MentionedMobileList"))); + let _ = writer.write_event(Event::End(BytesEnd::new("MentionedMobileList"))); } - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"Text"))); + let _ = writer.write_event(Event::End(BytesEnd::new("Text"))); } - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"xml"))); + let _ = writer.write_event(Event::End(BytesEnd::new("xml"))); } match String::from_utf8(writer.into_inner().into_inner()) { @@ -634,35 +653,35 @@ pub fn pack_markdown_message(msg: WxWorkMessageMarkdownRsp) -> Result Result let mut writer = Writer::new(Cursor::new(Vec::new())); if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"xml"))) + .write_event(Event::Start(BytesStart::new("xml"))) .is_ok() { if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"MsgType"))) + .write_event(Event::Start(BytesStart::new("MsgType"))) .is_ok() { - let _ = writer.write_event(Event::CData(BytesText::from_plain_str("image"))); - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"MsgType"))); + let _ = writer.write_event(Event::CData(BytesCData::new(quick_xml::escape::escape( + "image", + )))); + let _ = writer.write_event(Event::End(BytesEnd::new("MsgType"))); } if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"Image"))) + .write_event(Event::Start(BytesStart::new("Image"))) .is_ok() { if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"Base64"))) + .write_event(Event::Start(BytesStart::new("Base64"))) .is_ok() { // BytesText::from_escaped_str - let _ = writer.write_event(Event::CData(BytesText::from_escaped_str( - match base64::STANDARD.encode(&msg.content) { - Ok(x) => x, - Err(e) => e.message, - }, - ))); - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"Base64"))); + let _ = + writer.write_event(Event::CData(BytesCData::new(quick_xml::escape::escape( + match base64::STANDARD.encode(&msg.content) { + Ok(x) => x, + Err(e) => e.message, + } + .as_str(), + )))); + let _ = writer.write_event(Event::End(BytesEnd::new("Base64"))); } let mut hasher = Md5::new(); hasher.update(&msg.content); if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"Md5"))) + .write_event(Event::Start(BytesStart::new("Md5"))) .is_ok() { // BytesText::from_escaped_str - let _ = writer.write_event(Event::CData(BytesText::from_escaped_str( - hex::encode(hasher.finalize().as_slice()).as_str(), + let _ = writer.write_event(Event::CData(BytesCData::new( + quick_xml::escape::escape(hex::encode(hasher.finalize().as_slice()).as_str()), ))); - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"Md5"))); + let _ = writer.write_event(Event::End(BytesEnd::new("Md5"))); } - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"Image"))); + let _ = writer.write_event(Event::End(BytesEnd::new("Image"))); } - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"xml"))); + let _ = writer.write_event(Event::End(BytesEnd::new("xml"))); } match String::from_utf8(writer.into_inner().into_inner()) { @@ -739,44 +762,48 @@ pub fn pack_message_response( let mut writer = Writer::new(Cursor::new(Vec::new())); if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"xml"))) + .write_event(Event::Start(BytesStart::new("xml"))) .is_ok() { if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"Encrypt"))) + .write_event(Event::Start(BytesStart::new("Encrypt"))) .is_ok() { - let _ = writer.write_event(Event::CData(BytesText::from_plain_str(encrypt.as_str()))); - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"Encrypt"))); + let _ = writer.write_event(Event::CData(BytesCData::new(quick_xml::escape::escape( + encrypt.as_str(), + )))); + let _ = writer.write_event(Event::End(BytesEnd::new("Encrypt"))); } if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"MsgSignature"))) + .write_event(Event::Start(BytesStart::new("MsgSignature"))) .is_ok() { - let _ = writer.write_event(Event::CData(BytesText::from_plain_str( + let _ = writer.write_event(Event::CData(BytesCData::new(quick_xml::escape::escape( msg_signature.as_str(), - ))); - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"MsgSignature"))); + )))); + let _ = writer.write_event(Event::End(BytesEnd::new("MsgSignature"))); } if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"TimeStamp"))) + .write_event(Event::Start(BytesStart::new("TimeStamp"))) .is_ok() { - let _ = writer.write_event(Event::Text(BytesText::from_plain_str(timestamp.as_str()))); - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"TimeStamp"))); + let _ = writer.write_event(Event::Text(BytesText::new(timestamp.as_str()))); + let _ = writer.write_event(Event::End(BytesEnd::new("TimeStamp"))); } if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"Nonce"))) + .write_event(Event::Start(BytesStart::new("Nonce"))) .is_ok() { - let _ = writer.write_event(Event::CData(BytesText::from_plain_str(nonce.as_str()))); - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"Nonce"))); + let _ = writer.write_event(Event::CData(BytesCData::new(quick_xml::escape::escape( + nonce.as_str(), + )))); + let _ = writer.write_event(Event::End(BytesEnd::new("Nonce"))); } - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"xml"))); + let _ = writer.write_event(Event::End(BytesEnd::new("xml"))); } match String::from_utf8(writer.into_inner().into_inner()) { @@ -796,25 +823,27 @@ pub fn get_robot_response_access_deny_content(msg: &str) -> String { let mut writer = Writer::new(Cursor::new(Vec::new())); if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"xml"))) + .write_event(Event::Start(BytesStart::new("xml"))) .is_ok() { if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"message"))) + .write_event(Event::Start(BytesStart::new("message"))) .is_ok() { - let _ = writer.write_event(Event::CData(BytesText::from_plain_str(msg))); - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"message"))); + let _ = writer.write_event(Event::CData(BytesCData::new(quick_xml::escape::escape( + msg, + )))); + let _ = writer.write_event(Event::End(BytesEnd::new("message"))); } if writer - .write_event(Event::Start(BytesStart::borrowed_name(b"code"))) + .write_event(Event::Start(BytesStart::new("code"))) .is_ok() { - let _ = writer.write_event(Event::Text(BytesText::from_plain_str("Access Deny"))); - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"code"))); + let _ = writer.write_event(Event::Text(BytesText::new("Access Deny"))); + let _ = writer.write_event(Event::End(BytesEnd::new("code"))); } - let _ = writer.write_event(Event::End(BytesEnd::borrowed(b"xml"))); + let _ = writer.write_event(Event::End(BytesEnd::new("xml"))); } match String::from_utf8(writer.into_inner().into_inner()) { diff --git a/src/wxwork_robot/mod.rs b/src/wxwork_robot/mod.rs index 573419e..bda3bb2 100644 --- a/src/wxwork_robot/mod.rs +++ b/src/wxwork_robot/mod.rs @@ -61,9 +61,5 @@ pub fn build_project_set(json: &serde_json::Value) -> Option { } pub fn build_project_set_shared(json: &serde_json::Value) -> Option { - if let Some(x) = build_project_set(json) { - Some(Arc::new(Mutex::new(x))) - } else { - None - } + build_project_set(json).map(|x| Arc::new(Mutex::new(x))) } diff --git a/src/wxwork_robot/project.rs b/src/wxwork_robot/project.rs index e3e6d66..fd3b377 100644 --- a/src/wxwork_robot/project.rs +++ b/src/wxwork_robot/project.rs @@ -1,9 +1,8 @@ use actix_web::HttpResponse; -use aes::Aes256; +use aes::cipher::{block_padding::NoPadding, BlockDecryptMut, BlockEncryptMut, KeyIvInit}; // use cipher::{BlockCipher, NewBlockCipher}; -use block_modes::block_padding::NoPadding; -use block_modes::{BlockMode, Cbc}; use byteorder::{BigEndian, ByteOrder}; + // use openssl::symm::{Cipher, Crypter, Mode}; use ring::rand::SecureRandom; @@ -16,7 +15,8 @@ use std::time::SystemTime; use super::{base64, command, message}; -type Aes256CbcNoPadding = Cbc; +type Aes128CbcEncoder = cbc::Encryptor; +type Aes128CbcDecoder = cbc::Decryptor; // #[derive(Clone)] struct WxWorkProjectCipherInfo { @@ -204,7 +204,7 @@ impl WxWorkProject { } else { Vec::new() }; - let _ = match Aes256CbcNoPadding::new_from_slices(&aes_key_bin, &cipher_iv) { + let _ = match Aes128CbcDecoder::new_from_slices(&aes_key_bin, &cipher_iv) { Ok(x) => x, Err(e) => { let err_msg = format!( @@ -345,13 +345,12 @@ impl WxWorkProject { // 去掉rand_msg头部的16个随机字节和4个字节的msg_len,截取msg_len长度的部分即为msg,剩下的为尾部的receiveid // 网络字节序 - let decrypter; // let block_size: usize; - match self.cipher_info.lock() { + let decrypter = match self.cipher_info.lock() { Ok(c) => { let ci = &*c; - decrypter = match Aes256CbcNoPadding::new_from_slices(&ci.key, &ci.iv) { + match Aes128CbcDecoder::new_from_slices(&ci.key, &ci.iv) { Ok(x) => x, Err(e) => { let ret = format!( @@ -362,7 +361,7 @@ impl WxWorkProject { error!("{}", ret); return Err(ret); } - }; + } } Err(e) => { let ret = format!( @@ -373,9 +372,9 @@ impl WxWorkProject { error!("{}", ret); return Err(ret); } - } + }; - match decrypter.decrypt_vec(&input) { + match decrypter.decrypt_padded_vec_mut::(input) { Ok(x) => Ok(x), Err(e) => { let ret = format!("project \"{}\" try to decrypt failed, {:?}", self.name(), e); @@ -465,7 +464,7 @@ impl WxWorkProject { let err_msg = format!( "project \"{}\" decode {} data length invalid", self.name(), - hex::encode(&dec_bin_unpadding) + hex::encode(dec_bin_unpadding) ); error!("{}", err_msg); return Err(err_msg); @@ -477,7 +476,7 @@ impl WxWorkProject { "project \"{}\" decode message length {} , but bin data {} has only length {}", self.name(), msg_len, - hex::encode(&dec_bin_unpadding), + hex::encode(dec_bin_unpadding), dec_bin_unpadding.len() ); error!("{}", err_msg); @@ -543,14 +542,12 @@ impl WxWorkProject { padded_plaintext.extend_from_slice(input); let padded_input = self.pkcs7_encode(&padded_plaintext); - - let encrypter; // let block_size: usize; - match self.cipher_info.lock() { + let encrypter = match self.cipher_info.lock() { Ok(c) => { let ci = &*c; - encrypter = match Aes256CbcNoPadding::new_from_slices(&ci.key, &ci.iv) { + match Aes128CbcEncoder::new_from_slices(&ci.key, &ci.iv) { Ok(x) => x, Err(e) => { let ret = format!( @@ -561,7 +558,7 @@ impl WxWorkProject { error!("{}", ret); return Err(ret); } - }; + } } Err(e) => { let ret = format!( @@ -572,16 +569,15 @@ impl WxWorkProject { error!("{}", ret); return Err(ret); } - } + }; - let ret = encrypter.encrypt_vec(&padded_input); - Ok(ret) + Ok(encrypter.encrypt_padded_vec_mut::(&padded_input)) } pub fn encrypt_msg_raw_base64(&self, input: &[u8]) -> Result { // msg_encrypt = Base64_Encode(AES_Encrypt(rand_msg)) let random_str = self.alloc_random_str(); - match self.encrypt_msg_raw(&input, &random_str) { + match self.encrypt_msg_raw(input, &random_str) { Ok(x) => match base64::STANDARD.encode(&x) { Ok(v) => { debug!( @@ -627,7 +623,7 @@ impl WxWorkProject { // Ok(x) => hex::encode(x.as_ref()), // Err(e) => format!("Sha1 for {} failed, {:?}", cat_str, e), // } - hex::encode(&hash_res.as_ref()) + hex::encode(hash_res.as_ref()) } pub fn check_msg_signature( @@ -637,7 +633,7 @@ impl WxWorkProject { nonce: &str, msg_encrypt: &str, ) -> bool { - let real_signature = self.make_msg_signature(×tamp, &nonce, &msg_encrypt); + let real_signature = self.make_msg_signature(timestamp, nonce, msg_encrypt); debug!("project \"{}\" try to check msg signature: excepted_signature={}, timestamp={}, nonce={}, msg_encrypt={}, real_signature={}", self.name(), excepted_signature, timestamp, nonce, msg_encrypt, real_signature); if real_signature.as_str() == excepted_signature { true From 7be82bc230addd19adf4c5467f2ae50412feeba9 Mon Sep 17 00:00:00 2001 From: owent Date: Thu, 18 May 2023 00:56:47 +0800 Subject: [PATCH 3/3] Use the default version flag Signed-off-by: owent --- src/app.rs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/app.rs b/src/app.rs index 294d1b0..1fb3c14 100644 --- a/src/app.rs +++ b/src/app.rs @@ -137,13 +137,6 @@ pub fn app() -> AppEnvironment { .version(crate_version!()) .about(crate_description!()) .max_term_width(120) - .arg( - Arg::new("version") - .short('v') - .long("version") - .action(ArgAction::SetTrue) - .help("Show version"), - ) .arg( Arg::new("debug") .short('d') @@ -195,10 +188,6 @@ pub fn app() -> AppEnvironment { ); let matches: ArgMatches = app.get_matches(); - if unwraper_flag(&matches, "version") { - println!("{}", crate_version!()); - process::exit(0); - } unsafe { if unwraper_flag(&matches, "debug") {