diff options
Diffstat
| -rw-r--r-- | .dockerignore | 9 | +0 −9 |
| -rw-r--r-- | .editorconfig | 26 | +0 −26 |
| -rw-r--r-- | .github/workflows/build.yml | 290 | +79 −211 |
| -rw-r--r-- | .github/workflows/cla.yml | 30 | +30 −0 |
| -rw-r--r-- | .github/workflows/legal.yml | 35 | +0 −35 |
| -rw-r--r-- | .gitignore | 10 | +3 −7 |
| -rw-r--r-- | .mailmap | 7 | +0 −7 |
| -rw-r--r-- | CLA.md | 111 | +69 −42 |
| -rw-r--r-- | CODEOWNERS | 4 | +0 −4 |
| -rw-r--r-- | Cargo.lock | 2732 | +2289 −443 |
| -rw-r--r-- | Cargo.toml | 57 | +17 −40 |
| -rw-r--r-- | Dockerfile | 29 | +0 −29 |
| -rw-r--r-- | LICENSES/CC-BY-3.0.txt | 319 | +0 −319 |
| -rw-r--r-- | LICENSES/CC-BY-4.0.txt | 156 | +0 −156 |
| -rw-r--r-- | Makefile | 25 | +25 −0 |
| -rw-r--r-- | README.md | 99 | +32 −67 |
| -rw-r--r-- | REUSE.toml | 35 | +5 −30 |
| -rw-r--r-- | charts/tesor/Chart.yaml | 10 | +0 −10 |
| -rw-r--r-- | charts/tesor/templates/_helpers.tpl | 37 | +0 −37 |
| -rw-r--r-- | charts/tesor/templates/configmap.yaml | 46 | +0 −46 |
| -rw-r--r-- | charts/tesor/templates/deployment.yaml | 97 | +0 −97 |
| -rw-r--r-- | charts/tesor/templates/httproute.yaml | 26 | +0 −26 |
| -rw-r--r-- | charts/tesor/templates/pvc.yaml | 22 | +0 −22 |
| -rw-r--r-- | charts/tesor/templates/service.yaml | 19 | +0 −19 |
| -rw-r--r-- | charts/tesor/values.yaml | 78 | +0 −78 |
| -rw-r--r-- | crates/base/Cargo.toml | 20 | +0 −20 |
| -rw-r--r-- | crates/base/src/lib.rs | 31 | +0 −31 |
| -rw-r--r-- | crates/base/src/serde.rs | 108 | +0 −108 |
| -rw-r--r-- | crates/repos/Cargo.toml | 30 | +0 −30 |
| -rw-r--r-- | crates/repos/src/go.rs | 518 | +0 −518 |
| -rw-r--r-- | crates/repos/src/lib.rs | 679 | +0 −679 |
| -rw-r--r-- | crates/repos/src/zig.rs | 519 | +0 −519 |
| -rw-r--r-- | crates/tesor/Cargo.toml | 62 | +0 −62 |
| -rw-r--r-- | crates/tesor/build.rs | 30 | +0 −30 |
| -rw-r--r-- | crates/tesor/src/assets/apple-touch-icon.png | bin | 715 -> 0 bytes |
| -rw-r--r-- | crates/tesor/src/assets/favicon-192.png | bin | 715 -> 0 bytes |
| -rw-r--r-- | crates/tesor/src/assets/favicon-512.png | bin | 2329 -> 0 bytes |
| -rw-r--r-- | crates/tesor/src/assets/favicon.ico | bin | 32038 -> 0 bytes |
| -rw-r--r-- | crates/tesor/src/assets/favicon.svg | 4 | +0 −4 |
| -rw-r--r-- | crates/tesor/src/assets/manifest.webmanifest | 8 | +0 −8 |
| -rw-r--r-- | crates/tesor/src/assets/robots.txt | 5 | +0 −5 |
| -rw-r--r-- | crates/tesor/src/controller_web.rs | 486 | +0 −486 |
| -rw-r--r-- | deny.toml | 7 | +2 −5 |
| -rw-r--r-- | mise.lock | 73 | +0 −73 |
| -rw-r--r-- | mise.toml | 65 | +0 −65 |
| -rw-r--r-- | nfpm.yaml | 26 | +13 −13 |
| -rw-r--r-- | pkg/logo.svg | 25 | +0 −25 |
| -rw-r--r-- | pkg/scripts/postinstall.sh | 6 | +3 −3 |
| -rw-r--r-- | pkg/scripts/preinstall.sh | 15 | +8 −7 |
| -rw-r--r-- | pkg/scripts/preremove.sh | 8 | +4 −4 |
| -rw-r--r-- | pkg/zorian.service (renamed from pkg/tesor.service) | 12 | +6 −6 |
| -rw-r--r-- | pkg/zorian.toml (renamed from pkg/tesor.toml) | 22 | +11 −11 |
| -rw-r--r-- | src/assets/base.css (renamed from crates/tesor/src/assets/base.css) | 71 | +14 −57 |
| -rw-r--r-- | src/assets/jetbrainsmono/JetBrainsMono-Italic[wght].woff2 (renamed from crates/tesor/src/assets/jetbrainsmono/JetBrainsMono-Italic[wght].woff2) | bin | 122452 -> 122452 bytes |
| -rw-r--r-- | src/assets/jetbrainsmono/JetBrainsMono[wght].woff2 (renamed from crates/tesor/src/assets/jetbrainsmono/JetBrainsMono[wght].woff2) | bin | 113700 -> 113700 bytes |
| -rw-r--r-- | src/backends/go.rs | 700 | +700 −0 |
| -rw-r--r-- | src/backends/mod.rs | 283 | +283 −0 |
| -rw-r--r-- | src/backends/zig.rs | 495 | +495 −0 |
| -rw-r--r-- | src/config.rs (renamed from crates/tesor/src/config.rs) | 317 | +16 −301 |
| -rw-r--r-- | src/controller_backend.rs (renamed from crates/tesor/src/controller_backend.rs) | 58 | +29 −29 |
| -rw-r--r-- | src/controller_web.rs | 363 | +363 −0 |
| -rw-r--r-- | src/main.rs (renamed from crates/tesor/src/main.rs) | 102 | +68 −34 |
| -rw-r--r-- | src/proxy.rs (renamed from crates/tesor/src/proxy.rs) | 27 | +5 −22 |
| -rw-r--r-- | src/storage.rs (renamed from crates/tesor/src/storage.rs) | 442 | +28 −414 |
| -rw-r--r-- | src/telemetry.rs (renamed from crates/tesor/src/telemetry.rs) | 6 | +3 −3 |
| -rw-r--r-- | src/utils.rs | 61 | +61 −0 |
| -rw-r--r-- | tests/smoke/Cargo.toml | 18 | +0 −18 |
| -rwxr-xr-x | tests/smoke/run-local.sh | 75 | +0 −75 |
| -rw-r--r-- | tests/smoke/src/main.rs | 403 | +0 −403 |
69 files changed, 4661 insertions, 5828 deletions
diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 --- a/.dockerignore +++ /dev/null @@ -1,9 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -.git -.github -.tesor-state -dist -target -*.lcov diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 --- a/.editorconfig +++ /dev/null @@ -1,26 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -root = true - -[*] -charset = utf-8 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true -indent_style = space -indent_size = 4 - -[*.md] -# double whitespace at end of line -# denotes a line break in Markdown -trim_trailing_whitespace = false - -[*.rs] -max_line_length = 100 - -[*.yml] -indent_size = 2 - -[{Makefile,*.mk}] -indent_style = tab diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4078821..e57e505 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov +# SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> # SPDX-License-Identifier: AGPL-3.0-or-later name: Build @@ -10,16 +10,9 @@ on: pull_request: branches: [main] -permissions: - contents: read - -concurrency: - group: tesor-build-${{ github.ref }} - cancel-in-progress: true - env: CARGO_TERM_COLOR: always - RELEASE_TAG: nightly + RELEASE_TAG: dev jobs: lint: @@ -28,23 +21,20 @@ jobs: steps: - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - - uses: jdx/mise-action@5228313ee0372e111a38da051671ca30fc5a96db # v3 - with: - version: 2026.7.5 - experimental: true - install: false - - name: Install dependencies - run: mise bootstrap --locked --yes --update + - uses: dtolnay/rust-toolchain@4be9e76fd7c4901c61fb841f559994984270fce7 # stable - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 - - name: formatting - run: cargo fmt --all --check + - name: Check licenses + uses: fsfe/reuse-action@676e2d560c9a403aa252096d99fcab3e1132b0f5 # v6.0.0 - - name: shellcheck - run: shellcheck pkg/scripts/*.sh tests/smoke/*.sh + - name: Check dependencies + uses: EmbarkStudios/cargo-deny-action@3fd3802e88374d3fe9159b834c7714ec57d6c979 # 0.19.0 - - name: clippy - run: cargo clippy --workspace --all-targets --all-features --release --locked -- -D warnings + - name: Check formatting + run: cargo fmt --all --check + + - name: Run clippy + run: cargo clippy --all-targets --all-features -- -D warnings build: name: Build (${{ matrix.arch }}) @@ -61,106 +51,60 @@ jobs: steps: - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - - uses: jdx/mise-action@5228313ee0372e111a38da051671ca30fc5a96db # v3 - with: - version: 2026.7.5 - experimental: true - install: false - - name: Install dependencies - run: mise bootstrap --locked --yes --update + - uses: dtolnay/rust-toolchain@4be9e76fd7c4901c61fb841f559994984270fce7 # stable - uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 - - run: cargo clippy --workspace --locked --all-targets --all-features --release -- -D warnings + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec #v6.3.0 + with: + passphrase: ${{ secrets.GPG_PASSPHRASE }} + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + + - run: cargo build --release - run: cargo test --all-features --release --locked - - run: cargo build --package tesor --bin tesor --release --locked + + - name: Install nfpm + run: | + echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list + sudo apt update && sudo apt install nfpm - name: Build packages run: | - PKG_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "tesor") | .version') - if [[ "$GITHUB_REF" == refs/tags/v* ]]; then - VERSION="${GITHUB_REF_NAME#v}" - if [[ "$VERSION" != "$PKG_VERSION" ]]; then - echo "Tag version $VERSION does not match Cargo.toml version $PKG_VERSION" >&2 - exit 1 - fi - else - VERSION="$PKG_VERSION~nightly.$(git log -1 --format=%ct)" - fi + export SIGNING_PRIVATE_KEY="/tmp/private.asc" + printf '%s' "$GPG_PRIVATE_KEY" > $SIGNING_PRIVATE_KEY + chmod 600 $SIGNING_PRIVATE_KEY + + PKG_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version') + export VERSION="${PKG_VERSION}~dev.$(git log -1 --format=%ct)" + export ARCH=${{ matrix.arch }} - mise run package -- \ - --version "$VERSION" \ - --arch "${{ matrix.arch }}" \ - --output dist \ - deb rpm + mkdir -p dist/ + for pkg in deb rpm; do + nfpm package --packager $pkg --target dist/ + done env: GPG_KEY_ID: ${{ vars.GPG_KEY_ID }} GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} - GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - - - name: Generate coverage (lcov) - run: cargo llvm-cov --all-features --workspace --lcov --output-path coverage.lcov - - - name: Upload coverage artifact - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 - with: - name: coverage-lcov-${{ matrix.arch }} - path: coverage.lcov + NFPM_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: name: packages-${{ matrix.arch }} path: dist/* - - uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 - with: - name: binary-${{ matrix.arch }} - path: target/release/tesor - - smoke: - name: Smoke tests - runs-on: ubuntu-24.04 - needs: [build] - steps: - - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - - - uses: jdx/mise-action@5228313ee0372e111a38da051671ca30fc5a96db # v3 - with: - version: 2026.7.5 - experimental: true - install: false - - name: Install dependencies - run: mise bootstrap --locked --yes --update - - - uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 - with: - name: binary-amd64 - path: target/release/ - - - name: Run smoke tests against local instance - run: | - chmod +x target/release/tesor - ./tests/smoke/run-local.sh - publish: - name: Publish nightly build + name: Publish dev build runs-on: ubuntu-latest - needs: [build, smoke] - concurrency: - group: package-publish-tesor-nightly - cancel-in-progress: false + needs: [build] if: github.ref == 'refs/heads/main' permissions: contents: write steps: - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - - - uses: jdx/mise-action@5228313ee0372e111a38da051671ca30fc5a96db # v3 - with: - version: 2026.7.5 - experimental: true - install: false - - name: Install dependencies - run: mise bootstrap --locked --yes --update + - name: Install tools + run: | + sudo apt-get update + sudo apt-get install -y aptly rclone createrepo-c - uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 with: @@ -168,8 +112,19 @@ jobs: path: dist merge-multiple: true + # Configure GPG keys + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec #v6.3.0 + with: + passphrase: ${{ secrets.GPG_PASSPHRASE }} + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + - name: Export GPG public key + run: printf '%s' "$GPG_PUBLIC_KEY" > dist/public.gpg + env: + GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} + # Update Github Release - - name: Update 'nightly' tag + - name: Update 'dev' tag run: | git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" @@ -196,117 +151,30 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Publish package repositories - run: | - mise run publish -- \ - --service tesor \ - --channel nightly \ - --input dist \ - deb rpm - env: - GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} - GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - GPG_KEY_ID: ${{ vars.GPG_KEY_ID }} - PACKAGE_KEY_VERSION: ${{ vars.PACKAGE_KEY_VERSION }} - S3_BUCKET: ${{ vars.S3_BUCKET }} - S3_ENDPOINT: ${{ vars.S3_ENDPOINT }} - S3_PUBLIC_URL: ${{ vars.S3_PUBLIC_URL }} - S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }} - S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }} - - oci: - name: OCI artifacts - needs: [smoke] - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - - - uses: jdx/mise-action@5228313ee0372e111a38da051671ca30fc5a96db # v3 - with: - version: 2026.7.5 - experimental: true - install: false - - - uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 - with: - pattern: binary-* - path: .container - - - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4 - - - name: Determine artifact version - id: artifact - shell: bash + # Update APT/RPM repos on s3 + - name: Create APT repository run: | - base_version=$(python3 -c 'import tomllib; print(tomllib.load(open("Cargo.toml", "rb"))["workspace"]["package"]["version"])') - if [[ "$GITHUB_REF" == refs/heads/main ]]; then - version="$base_version-nightly.$(git log -1 --format=%ct)" - elif [[ "$GITHUB_REF" == refs/tags/v* ]]; then - version="${GITHUB_REF_NAME#v}" - if [[ "$version" != "$base_version" ]]; then - echo "Tag version $version does not match Cargo.toml version $base_version" >&2 - exit 1 - fi - else - version="$base_version-pr.$GITHUB_RUN_NUMBER" - fi - echo "version=$version" >> "$GITHUB_OUTPUT" - - - name: Log in to GHCR - if: github.event_name != 'pull_request' - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Log Helm in to GHCR - if: github.event_name != 'pull_request' - env: - GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }} + aptly repo create -distribution=dev -component=main zorian + aptly repo add zorian dist/*.deb + aptly publish repo -architectures=amd64,arm64 -gpg-key="${{vars.GPG_KEY_ID}}" zorian + - name: Create RPM repository run: | - printf '%s' "$GHCR_TOKEN" | mise x helm@4.1.1 -- \ - helm registry login ghcr.io --username "$GITHUB_ACTOR" --password-stdin - - - name: Build and publish OCI artifacts - shell: bash + mkdir -p rpm-repo + cp dist/*.rpm rpm-repo/ + createrepo_c rpm-repo/ + gpg --default-key="${{vars.GPG_KEY_ID}}" --detach-sign --armor rpm-repo/repodata/repomd.xml + - name: Upload RPM to S3 run: | - version="${{ steps.artifact.outputs.version }}" - image="ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/tesor" - tags=( - --tag "$image:sha-$GITHUB_SHA" - --tag "$image:$version" - ) - labels=( - --label "org.opencontainers.image.revision=$GITHUB_SHA" - --label "org.opencontainers.image.source=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" - --label "org.opencontainers.image.version=$version" - ) - image_output=() - chart_output=() - - if [[ "$GITHUB_REF" == refs/heads/main ]]; then - tags+=(--tag "$image:nightly") - elif [[ "$GITHUB_REF" == refs/tags/v* ]]; then - tags+=(--tag "$image:latest") - fi - if [[ "${{ github.event_name }}" != pull_request ]]; then - image_output+=(--push) - chart_output+=(--push "oci://ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/charts") - fi - - mise run container -- \ - --context . \ - --file Dockerfile \ - --platform linux/amd64,linux/arm64 \ - --cache-scope tesor \ - "${tags[@]}" "${labels[@]}" "${image_output[@]}" - - mise run chart -- \ - --chart charts/tesor \ - --version "$version" \ - --app-version "$version" \ - "${chart_output[@]}" + mkdir -p ~/.config/rclone + cat > ~/.config/rclone/rclone.conf << EOF + [hetzner] + type = s3 + provider = Other + acl = public-read + endpoint = ${{vars.S3_ENDPOINT}} + access_key_id = ${{secrets.S3_ACCESS_KEY_ID}} + secret_access_key = ${{secrets.S3_SECRET_ACCESS_KEY}} + EOF + + rclone sync rpm-repo/ "hetzner:${{vars.S3_BUCKET}}/rpm/" --progress + rclone sync ~/.aptly/public/ "hetzner:${{vars.S3_BUCKET}}/apt/" --progress diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml new file mode 100644 --- /dev/null +++ b/.github/workflows/cla.yml @@ -0,0 +1,30 @@ +# SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> +# SPDX-License-Identifier: AGPL-3.0-or-later + +name: "CLA Assistant" + +on: + issue_comment: + types: [created] + pull_request_target: + types: [opened, closed, synchronize] + +jobs: + CLAAssistant: + runs-on: ubuntu-latest + permissions: + actions: write + contents: write + statuses: write + pull-requests: write + steps: + - name: "CLA Assistant" + if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' + uses: contributor-assistant/github-action@ca4a40a7d1004f18d9960b404b97e5f30a505a08 # v2.6.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + branch: "main" + allowlist: mrdimidium + path-to-signatures: "LICENSES/cla.json" + path-to-document: "https://github.com/mrdimidium/Zorian/blob/main/CLA.md" diff --git a/.github/workflows/legal.yml b/.github/workflows/legal.yml deleted file mode 100644 --- a/.github/workflows/legal.yml +++ /dev/null @@ -1,35 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -name: Legal - -on: - push: - branches: [main] - tags: ["v*"] - pull_request: - branches: [main] - -permissions: - contents: read - -jobs: - legal: - name: Legal checks - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - with: - fetch-depth: 0 - - - uses: jdx/mise-action@5228313ee0372e111a38da051671ca30fc5a96db # v3 - with: - version: 2026.7.5 - experimental: true - install: false - - - name: Check contribution sign-off - run: mise run signoff - - - name: Check licensing policy - run: mise run licenses diff --git a/.gitignore b/.gitignore index 2c7fb07..0575fa6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,6 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov +# SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> # SPDX-License-Identifier: AGPL-3.0-or-later -/dist /target -mise.local.toml -mise.*.local.toml - -/.container -/.tesor-state +/dist +/.zorian-state diff --git a/.mailmap b/.mailmap deleted file mode 100644 --- a/.mailmap +++ /dev/null @@ -1,7 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later -# -# Add new entries in alphabetical order - -Nikolay Govorov <me@govorov.online> -Nikolay Govorov <mr@dimidiumlabs.io> diff --git a/CLA.md b/CLA.md index c0418c8..03ff421 100644 --- a/CLA.md +++ b/CLA.md @@ -1,45 +1,43 @@ -# Tesor Individual Contributor License Agreement +# Zorian Grant and Contributor License Agreement -Version 1.0 +> This agreement is based on the Harmony Combined Contributor Agreement +> Version 1.0 licensed under a [Creative Commons Attribution 3.0 Unported License](http://creativecommons.org/licenses/by/3.0/). -> This agreement is based on the Harmony Individual Contributor License -> Agreement Version 1.0 licensed under a -> [Creative Commons Attribution 3.0 Unported License](https://creativecommons.org/licenses/by/3.0/). - -Thank you for your interest in contributing to Tesor (the "Project"). In this -Agreement, "We" and "Us" mean Nikolay Govorov. - -This contributor agreement ("Agreement") documents the rights granted by -contributors to Us. To make this document effective, You must personally add -the following trailers to every commit You Submit: - -```text -CLA-Version: 1.0 -Signed-off-by: Your Name <your.email@example.com> -``` - -The name and email address in `Signed-off-by` must identify You and match the -commit author. By Submitting a commit containing these trailers, You -electronically sign and accept this Agreement. No other person or automated -system may add the `Signed-off-by` trailer on Your behalf. This is a legally -binding document, so please read it carefully before agreeing to it. +Thank you for your interest in contributing to Zorian ("We" or "Us"). In order +to clarify the intellectual property license granted with Contributions from any +person or entity, We must have a Contributor License Agreement ("CLA") on file +that has been signed, accepted or otherwise agreed to by each contributor, +indicating agreement to the license terms below. This license is for your +protection as a contributor as well as the protection of the Us and our users; +it does not change your rights to use your own Contributions for any other +purpose. ## 1. Definitions -"You" means the individual who Submits a Contribution to Us. +"You" (Individual) means the individual who Submits a Contribution to Us. + +"You" (Entity) means any Legal Entity on behalf of whom a Contribution has been +received by Us. "Legal Entity" means an entity which is not a natural person. +"Affiliates" means other Legal Entities that control, are controlled by, or +under common control with that Legal Entity. For the purposes of this +definition, "control" means (i) the power, direct or indirect, to cause the +direction or management of such Legal Entity, whether by contract or otherwise, +(ii) ownership of fifty percent (50%) or more of the outstanding shares or +securities which vote to elect the management or other persons who direct such +Legal Entity or (iii) beneficial ownership of such entity. "Contribution" means any work of authorship that is Submitted by You to Us in -which You own or assert ownership of the Copyright. If You do not own the -Copyright in the entire work of authorship, please follow the instructions in -Section 3(d). +which You own or assert ownership of the Copyright. "Copyright" means all rights protecting works of authorship owned or controlled -by You, including copyright, moral and neighboring rights, as appropriate, for -the full term of their existence including any extensions by You. +by You [or Your Affiliates], including copyright, moral and neighboring rights, +as appropriate, for the full term of their existence including any extensions by +You. "Material" means the work of authorship which is made available by Us to third -parties as part of the Project. After You Submit the Contribution, it may be -included in the Material. +parties. When this Agreement covers more than one software project, the Material +means the work of authorship to which the Contribution was Submitted. After You +Submit the Contribution, it may be included in the Material. "Submit" means any form of electronic, verbal, or written communication sent to Us or our representatives, including but not limited to electronic mailing @@ -71,10 +69,40 @@ modify, display, perform and distribute the Contribution as part of the Material; provided that this license is conditioned upon compliance with Section 2.3. +### 2.1 Copyright Assignment + +(a) At the time the Contribution is Submitted, You assign to Us all right, +title, and interest worldwide in all Copyright covering the Contribution; +provided that this transfer is conditioned upon compliance with Section 2.3. + +(b) To the extent that any of the rights in Section 2.1(a) cannot be assigned by +You to Us, You grant to Us a perpetual, worldwide, exclusive, royalty-free, +transferable, irrevocable license under such non-assigned rights, with rights to +sublicense through multiple tiers of sublicensees, to practice such non-assigned +rights, including, but not limited to, the right to reproduce, modify, display, +perform and distribute the Contribution; provided that this license is +conditioned upon compliance with Section 2.3. + +(c) To the extent that any of the rights in Section 2.1(a) can neither be +assigned nor licensed by You to Us, You irrevocably waive and agree never to +assert such rights against Us, any of our successors in interest, or any of our +licensees, either direct or indirect; provided that this agreement not to assert +is conditioned upon compliance with Section 2.3. + +(d) Upon such transfer of rights to Us, to the maximum extent possible, We +immediately grant to You a perpetual, worldwide, non-exclusive, royalty-free, +transferable, irrevocable license under such rights covering the Contribution, +with rights to sublicense through multiple tiers of sublicensees, to reproduce, +modify, display, perform, and distribute the Contribution. The intention of the +parties is that this license will be as broad as possible and to provide You +with rights as similar as possible to the owner of the rights that You +transferred. This license back is limited to the Contribution and does not +provide any rights to the Material. + ### 2.2 Patent License For patent claims including, without limitation, method, process, and apparatus -claims which You own, control or have the right to grant, +claims which You [or Your Affiliates] own, control or have the right to grant, now or in the future, You grant to Us a perpetual, worldwide, non-exclusive, transferable, royalty-free, irrevocable patent license, with the right to sublicense these rights to multiple tiers of sublicensees, to make, have made, @@ -106,7 +134,7 @@ the Material and may decide to include any Contribution We consider appropriate. ### 2.6 Reservation of Rights -Any rights not expressly licensed under this section are expressly +Any rights not expressly [assigned or] licensed under this section are expressly reserved by You. ## 3. Agreement @@ -115,32 +143,31 @@ You confirm that: (a) You have the legal authority to enter into this Agreement. -(b) You own the Copyright and patent claims covering the +(b) You [or Your Affiliates] own the Copyright and patent claims covering the Contribution which are required to grant the rights under Section 2. -(c) The grant of rights under Section 2 does not violate any grant +(c) (Individual) The grant of rights under Section 2 does not violate any grant of rights which You have made to third parties, including Your employer. If You are an employee, You have had Your employer approve this Agreement or sign the Entity version of this document. If You are less than eighteen years old, please have Your parents or guardian sign the Agreement. -(d) If You do not own the Copyright in the entire work of authorship Submitted, -You have clearly identified the third-party work, its source, and its license in -the Submission. +(c) (Entity) The grant of rights under Section 2 does not violate any grant of +rights which You or Your Affiliates have made to third parties. ## 4. Disclaimer EXCEPT FOR THE EXPRESS WARRANTIES IN SECTION 3, THE CONTRIBUTION IS PROVIDED "AS IS". MORE PARTICULARLY, ALL EXPRESS OR IMPLIED WARRANTIES INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY DISCLAIMED BY YOU TO US. -TO THE EXTENT THAT ANY SUCH WARRANTIES CANNOT BE DISCLAIMED, SUCH WARRANTY +PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY DISCLAIMED BY YOU TO US [AND BY US TO +YOU]. TO THE EXTENT THAT ANY SUCH WARRANTIES CANNOT BE DISCLAIMED, SUCH WARRANTY IS LIMITED IN DURATION TO THE MINIMUM PERIOD PERMITTED BY LAW. ## 5. Consequential Damage Waiver -TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT WILL YOU BE -LIABLE FOR ANY LOSS OF PROFITS, LOSS OF ANTICIPATED SAVINGS, LOSS OF DATA, +TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT WILL YOU [OR US] +BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF ANTICIPATED SAVINGS, LOSS OF DATA, INDIRECT, SPECIAL, INCIDENTAL, CONSEQUENTIAL AND EXEMPLARY DAMAGES ARISING OUT OF THIS AGREEMENT REGARDLESS OF THE LEGAL OR EQUITABLE THEORY (CONTRACT, TORT OR OTHERWISE) UPON WHICH THE CLAIM IS BASED. diff --git a/CODEOWNERS b/CODEOWNERS deleted file mode 100644 --- a/CODEOWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -* @mrdimidium diff --git a/Cargo.lock b/Cargo.lock index d2e2df0..9dda733 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -48,25 +48,75 @@ dependencies = [ ] [[package]] +name = "anstream" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + +[[package]] name = "anyhow" -version = "1.0.102" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" [[package]] name = "arc-swap" -version = "1.8.2" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9f3647c145568cec02c42054e07bdf9a5a698e15b466fb2341bfc393cd24aa5" +checksum = "51d03449bb8ca2cc2ef70869af31463d1ae5ccc8fa3e334b307203fbf815207e" dependencies = [ "rustversion", ] [[package]] name = "async-compression" -version = "0.4.41" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f9ee0f6e02ffd7ad5816e9464499fba7b3effd01123b515c41d1697c43dad1" +checksum = "d10e4f991a553474232bc0a31799f6d24b034a84c0971d80d2e2f78b2e576e40" dependencies = [ "compression-codecs", "compression-core", @@ -126,6 +176,7 @@ dependencies = [ "matchit", "memchr", "mime", + "multer", "percent-encoding", "pin-project-lite", "serde_core", @@ -160,6 +211,27 @@ dependencies = [ ] [[package]] +name = "axum-extra" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fef252edff26ddba56bbcdf2ee3307b8129acb86f5749b68990c168a6fcc9c76" +dependencies = [ + "axum", + "axum-core", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] name = "axum-macros" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -193,14 +265,6 @@ dependencies = [ ] [[package]] -name = "base" -version = "0.0.0" -dependencies = [ - "serde", - "serde_json", -] - -[[package]] name = "base64" version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -229,14 +293,26 @@ checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" [[package]] name = "bitflags" -version = "2.11.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" dependencies = [ "serde_core", ] [[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] name = "block-buffer" version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -246,6 +322,15 @@ dependencies = [ ] [[package]] +name = "borsh" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1da5ab77c1437701eeff7c88d968729e7766172279eab0676857b3d63af7a6f" +dependencies = [ + "cfg_aliases", +] + +[[package]] name = "brotli" version = "8.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -267,10 +352,21 @@ dependencies = [ ] [[package]] +name = "bstr" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63044e1ae8e69f3b5a92c736ca6269b8d12fa7efe39bf34ddb06d102cf0e2cab" +dependencies = [ + "memchr", + "regex-automata", + "serde", +] + +[[package]] name = "bumpalo" -version = "3.20.2" +version = "3.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" +checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" [[package]] name = "byteorder" @@ -280,9 +376,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.11.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" +checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" [[package]] name = "bytesize" @@ -294,10 +390,75 @@ dependencies = [ ] [[package]] +name = "camino" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e629a66d692cb9ff1a1c664e41771b3dcaf961985a9774c0eb0bd1b51cf60a48" +dependencies = [ + "serde_core", +] + +[[package]] +name = "cargo-deny" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e0218cb20d184dbbd8304a3c78d7167188e61a96ab4ae3c598c2947dab61d43" +dependencies = [ + "anyhow", + "bitvec", + "camino", + "cfg-expr", + "clap", + "codespan", + "codespan-reporting", + "crossbeam", + "fern", + "gix", + "globset", + "goblin", + "home", + "krates", + "log", + "memchr", + "nu-ansi-term", + "parking_lot", + "rayon", + "regex", + "reqwest 0.13.1", + "ring", + "rustls", + "rustsec", + "semver", + "serde", + "serde_json", + "smallvec", + "spdx", + "strum", + "tame-index", + "time", + "toml-span", + "twox-hash", + "url", + "walkdir", +] + +[[package]] +name = "cargo-lock" +version = "11.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf53e0ebbbc6e45357b199f3b213f3eb330792c8b370e548499f5685470ecb11" +dependencies = [ + "semver", + "serde", + "toml", + "url", +] + +[[package]] name = "cc" -version = "1.2.57" +version = "1.2.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a0dd1ca384932ff3641c8718a02769f1698e7563dc6974ffd03346116310423" +checksum = "755d2fce177175ffca841e9a06afdb2c4ab0f593d53b4dee48147dfaade85932" dependencies = [ "find-msvc-tools", "jobserver", @@ -306,16 +467,38 @@ dependencies = [ ] [[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + +[[package]] +name = "cfg-expr" +version = "0.20.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21be0e1ce6cdb2ee7fff840f922fb04ead349e5cfb1e750b769132d44ce04720" +dependencies = [ + "smallvec", + "target-lexicon", +] + +[[package]] name = "cfg-if" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] name = "chrono" -version = "0.4.44" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0" +checksum = "fac4744fb15ae8337dc853fee7fb3f4e48c0fbaa23d0afe49c447b4fab126118" dependencies = [ "iana-time-zone", "js-sys", @@ -326,10 +509,93 @@ dependencies = [ ] [[package]] +name = "clap" +version = "4.5.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6e6ff9dcd79cff5cd969a17a545d79e84ab086e444102a591e288a8aa3ce394" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa42cf4d2b7a41bc8f663a7cab4031ebafa1bf3875705bfaf8466dc60ab52c00" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e64b0cc0439b12df2fa678eae89a1c56a529fd067a9115f7827f1fffd22b32" + +[[package]] +name = "clru" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbd0f76e066e64fdc5631e3bb46381254deab9ef1158292f27c8c57e3bf3fe59" + +[[package]] +name = "codespan" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583f52b0658b321b25fd6b209b6c76cf058f433071297de64e5980c3d9aad937" +dependencies = [ + "codespan-reporting", + "serde", +] + +[[package]] +name = "codespan-reporting" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681" +dependencies = [ + "serde", + "termcolor", + "unicode-width", +] + +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + +[[package]] +name = "combine" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] name = "compression-codecs" -version = "0.4.37" +version = "0.4.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb7b51a7d9c967fc26773061ba86150f19c50c0d65c887cb1fbe295fd16619b7" +checksum = "00828ba6fd27b45a448e57dbfe84f1029d4c9f26b368157e9a448a5f49a2ec2a" dependencies = [ "brotli", "compression-core", @@ -362,6 +628,16 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" @@ -410,6 +686,47 @@ dependencies = [ ] [[package]] +name = "crossbeam" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] name = "crossbeam-queue" version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -435,6 +752,15 @@ dependencies = [ ] [[package]] +name = "cvss" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fb220d3ce1b565af39cee5b89e47fd8dd1dab162900ee4363c8ee4169ee8a2" +dependencies = [ + "serde", +] + +[[package]] name = "dashmap" version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -460,6 +786,15 @@ dependencies = [ ] [[package]] +name = "deranged" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587" +dependencies = [ + "powerfmt", +] + +[[package]] name = "digest" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -489,6 +824,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" [[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + +[[package]] name = "either" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -498,6 +839,15 @@ dependencies = [ ] [[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] name = "equivalent" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -510,7 +860,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -536,22 +886,59 @@ dependencies = [ ] [[package]] +name = "faster-hex" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7223ae2d2f179b803433d9c830478527e92b8117eab39460edae7f1614d9fb73" +dependencies = [ + "heapless", + "serde", +] + +[[package]] name = "fastrand" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] +name = "fern" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4316185f709b23713e41e3195f90edef7fb00c3ed4adc79769cf09cc762a3b29" +dependencies = [ + "log", +] + +[[package]] +name = "filetime" +version = "0.2.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc0505cd1b6fa6580283f6bdf70a73fcf4aba1184038c90902b92b3dd0df63ed" +dependencies = [ + "cfg-if", + "libc", + "libredox", + "windows-sys 0.60.2", +] + +[[package]] name = "find-msvc-tools" -version = "0.1.9" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" +checksum = "8591b0bcc8a98a64310a2fae1bb3e9b8564dd10e381e6e28010fde8e8e8568db" + +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" [[package]] name = "flate2" -version = "1.1.9" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c" +checksum = "b375d6465b98090a5f25b1c7703f3859783755aa9a80433b36e0379a3ec2f369" dependencies = [ "crc32fast", "miniz_oxide", @@ -622,19 +1009,40 @@ dependencies = [ [[package]] name = "fs-err" -version = "3.3.0" +version = "3.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73fde052dbfc920003cfd2c8e2c6e6d4cc7c1091538c3a24226cec0665ab08c0" +checksum = "baf68cef89750956493a66a10f512b9e58d9db21f2a573c079c0bdf1207a54a7" dependencies = [ "autocfg", "tokio", ] [[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] name = "futures-channel" -version = "0.3.32" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -642,15 +1050,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.32" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.32" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -670,15 +1078,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.32" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.32" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", @@ -687,15 +1095,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.32" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.32" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-timer" @@ -705,10 +1113,11 @@ checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" [[package]] name = "futures-util" -version = "0.3.32" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ + "futures-channel", "futures-core", "futures-io", "futures-macro", @@ -716,6 +1125,7 @@ dependencies = [ "futures-task", "memchr", "pin-project-lite", + "pin-utils", "slab", ] @@ -749,22 +1159,793 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "r-efi 5.3.0", + "r-efi", "wasip2", "wasm-bindgen", ] [[package]] -name = "getrandom" -version = "0.4.2" +name = "gix" +version = "0.77.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d8284d86a2f5c0987fbf7219a128815cc04af5a18f5fd7eec6a76d83c2b78cc" +dependencies = [ + "gix-actor", + "gix-attributes", + "gix-command", + "gix-commitgraph", + "gix-config", + "gix-credentials", + "gix-date", + "gix-diff", + "gix-discover", + "gix-features", + "gix-filter", + "gix-fs", + "gix-glob", + "gix-hash", + "gix-hashtable", + "gix-ignore", + "gix-index", + "gix-lock", + "gix-negotiate", + "gix-object", + "gix-odb", + "gix-pack", + "gix-path", + "gix-pathspec", + "gix-prompt", + "gix-protocol", + "gix-ref", + "gix-refspec", + "gix-revision", + "gix-revwalk", + "gix-sec", + "gix-shallow", + "gix-submodule", + "gix-tempfile", + "gix-trace", + "gix-transport", + "gix-traverse", + "gix-url", + "gix-utils", + "gix-validate", + "gix-worktree", + "gix-worktree-state", + "parking_lot", + "signal-hook 0.3.18", + "smallvec", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-actor" +version = "0.37.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +checksum = "c345528d405eab51d20f505f5fe1a4680973953694e0292c6bbe97827daa55c4" dependencies = [ - "cfg-if", + "bstr", + "gix-date", + "gix-utils", + "itoa", + "thiserror 2.0.17", + "winnow", +] + +[[package]] +name = "gix-attributes" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f47dabf8a50f1558c3a55d978440c7c4f22f87ac897bef03b4edbc96f6115966" +dependencies = [ + "bstr", + "gix-glob", + "gix-path", + "gix-quote", + "gix-trace", + "kstring", + "smallvec", + "thiserror 2.0.17", + "unicode-bom", +] + +[[package]] +name = "gix-bitmap" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e150161b8a75b5860521cb876b506879a3376d3adc857ec7a9d35e7c6a5e531" +dependencies = [ + "thiserror 2.0.17", +] + +[[package]] +name = "gix-chunk" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c356b3825677cb6ff579551bb8311a81821e184453cbd105e2fc5311b288eeb" +dependencies = [ + "thiserror 2.0.17", +] + +[[package]] +name = "gix-command" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46f9c425730a654835351e6da8c3c69ba1804f8b8d4e96d027254151138d5c64" +dependencies = [ + "bstr", + "gix-path", + "gix-quote", + "gix-trace", + "shell-words", +] + +[[package]] +name = "gix-commitgraph" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efdcba8048045baf15225daf949d597c3e6183d130245e22a7fbd27084abe63a" +dependencies = [ + "bstr", + "gix-chunk", + "gix-hash", + "memmap2", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-config" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b58e2ff8eef96b71f2c5e260f02ca0475caff374027c5cc5a29bda69fac67404" +dependencies = [ + "bstr", + "gix-config-value", + "gix-features", + "gix-glob", + "gix-path", + "gix-ref", + "gix-sec", + "memchr", + "smallvec", + "thiserror 2.0.17", + "unicode-bom", + "winnow", +] + +[[package]] +name = "gix-config-value" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2409cffa4fe8b303847d5b6ba8df9da9ba65d302fc5ee474ea0cac5afde79840" +dependencies = [ + "bitflags", + "bstr", + "gix-path", "libc", - "r-efi 6.0.0", - "wasip2", - "wasip3", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-credentials" +version = "0.34.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "316a12842fb761a7a6e9ae963d7bae9f0f4c433f242282df91192ef084b1891c" +dependencies = [ + "bstr", + "gix-command", + "gix-config-value", + "gix-date", + "gix-path", + "gix-prompt", + "gix-sec", + "gix-trace", + "gix-url", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-date" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe4a31bab8159e233094fa70d2e5fd3ec6f19e593f67e6ae01281daa48f8d8e7" +dependencies = [ + "bstr", + "itoa", + "jiff", + "smallvec", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-diff" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3506936e63ce14cd54b5f28ed06c8e43b92ef9f41c2238cc0bc271a9259b4e90" +dependencies = [ + "bstr", + "gix-hash", + "gix-object", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-discover" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ce096dc132533802a09d6fd5d4008858f2038341dfe2e69e0d0239edb359de" +dependencies = [ + "bstr", + "dunce", + "gix-fs", + "gix-hash", + "gix-path", + "gix-ref", + "gix-sec", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-features" +version = "0.45.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56aad357ae016449434705033df644ac6253dfcf1281aad3af3af9e907560d1" +dependencies = [ + "bytes", + "crc32fast", + "gix-path", + "gix-trace", + "gix-utils", + "libc", + "once_cell", + "prodash", + "thiserror 2.0.17", + "walkdir", + "zlib-rs", +] + +[[package]] +name = "gix-filter" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10c02464962482570c1f94ad451a608c4391514f803e8074662d02c5629a25dc" +dependencies = [ + "bstr", + "encoding_rs", + "gix-attributes", + "gix-command", + "gix-hash", + "gix-object", + "gix-packetline", + "gix-path", + "gix-quote", + "gix-trace", + "gix-utils", + "smallvec", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-fs" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "785b9c499e46bc78d7b81c148c21b3fca18655379ee729a856ed19ce50d359ec" +dependencies = [ + "bstr", + "fastrand", + "gix-features", + "gix-path", + "gix-utils", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-glob" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8546300aee4c65c5862c22a3e321124a69b654a61a8b60de546a9284812b7e2" +dependencies = [ + "bitflags", + "bstr", + "gix-features", + "gix-path", +] + +[[package]] +name = "gix-hash" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e153930f42ccdab8a3306b1027cd524879f6a8996cd0c474d18b0e56cae7714d" +dependencies = [ + "faster-hex", + "gix-features", + "sha1-checked", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-hashtable" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "222f7428636020bef272a87ed833ea48bf5fb3193f99852ae16fbb5a602bd2f0" +dependencies = [ + "gix-hash", + "hashbrown 0.16.1", + "parking_lot", +] + +[[package]] +name = "gix-ignore" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfa727fdf54fd9fb53fa3fbb1a5c17172d3073e8e336bf155f3cac3e25b81b21" +dependencies = [ + "bstr", + "gix-glob", + "gix-path", + "gix-trace", + "unicode-bom", +] + +[[package]] +name = "gix-index" +version = "0.45.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ea6d3e9e11647ba49f441dea0782494cc6d2875ff43fa4ad9094e6957f42051" +dependencies = [ + "bitflags", + "bstr", + "filetime", + "fnv", + "gix-bitmap", + "gix-features", + "gix-fs", + "gix-hash", + "gix-lock", + "gix-object", + "gix-traverse", + "gix-utils", + "gix-validate", + "hashbrown 0.16.1", + "itoa", + "libc", + "memmap2", + "rustix", + "smallvec", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-lock" +version = "20.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115268ae5e3b3b7bc7fc77260eecee05acca458e45318ca45d35467fa81a3ac5" +dependencies = [ + "gix-tempfile", + "gix-utils", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-negotiate" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cee7e32e6198e356caef0e4b8321bc2f9b2afeb76f870c0bf9aa05fe53edb6" +dependencies = [ + "bitflags", + "gix-commitgraph", + "gix-date", + "gix-hash", + "gix-object", + "gix-revwalk", + "smallvec", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-object" +version = "0.54.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "363d6a879c52e4890180e0ffa7d8c9a364fd0b7e807caa368e860b80e8d0bc81" +dependencies = [ + "bstr", + "gix-actor", + "gix-date", + "gix-features", + "gix-hash", + "gix-hashtable", + "gix-path", + "gix-utils", + "gix-validate", + "itoa", + "smallvec", + "thiserror 2.0.17", + "winnow", +] + +[[package]] +name = "gix-odb" +version = "0.74.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "165a907df369a12ed4330faf8baf7ae597aadb08cfacb4ed8649f93d90bcc0c5" +dependencies = [ + "arc-swap", + "gix-date", + "gix-features", + "gix-fs", + "gix-hash", + "gix-hashtable", + "gix-object", + "gix-pack", + "gix-path", + "gix-quote", + "parking_lot", + "tempfile", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-pack" +version = "0.64.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b04a73d5ab07ea0faae55e2c0ae6f24e36e365ac8ce140394dee3a2c89cd4366" +dependencies = [ + "clru", + "gix-chunk", + "gix-features", + "gix-hash", + "gix-hashtable", + "gix-object", + "gix-path", + "gix-tempfile", + "memmap2", + "parking_lot", + "smallvec", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-packetline" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fad0ffb982a289888087a165d3e849cbac724f2aa5431236b050dd2cb9c7de31" +dependencies = [ + "bstr", + "faster-hex", + "gix-trace", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-path" +version = "0.10.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cb06c3e4f8eed6e24fd915fa93145e28a511f4ea0e768bae16673e05ed3f366" +dependencies = [ + "bstr", + "gix-trace", + "gix-validate", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-pathspec" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed9e0c881933c37a7ef45288d6c5779c4a7b3ad240b4c37657e1d9829eb90085" +dependencies = [ + "bitflags", + "bstr", + "gix-attributes", + "gix-config-value", + "gix-glob", + "gix-path", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-prompt" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "974b142ea650fb0050a301958f49c8cc68929c36f686e9606a381ce39da34fd9" +dependencies = [ + "gix-command", + "gix-config-value", + "parking_lot", + "rustix", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-protocol" +version = "0.55.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02c5dfd068789442c5709e702ef42d851765f2c09a11bf0a13749d24363f4d07" +dependencies = [ + "bstr", + "gix-credentials", + "gix-date", + "gix-features", + "gix-hash", + "gix-lock", + "gix-negotiate", + "gix-object", + "gix-ref", + "gix-refspec", + "gix-revwalk", + "gix-shallow", + "gix-trace", + "gix-transport", + "gix-utils", + "maybe-async", + "thiserror 2.0.17", + "winnow", +] + +[[package]] +name = "gix-quote" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e912ec04b7b1566a85ad486db0cab6b9955e3e32bcd3c3a734542ab3af084c5b" +dependencies = [ + "bstr", + "gix-utils", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-ref" +version = "0.57.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccb33aa97006e37e9e83fde233569a66b02ed16fd4b0406cdf35834b06cf8a63" +dependencies = [ + "gix-actor", + "gix-features", + "gix-fs", + "gix-hash", + "gix-lock", + "gix-object", + "gix-path", + "gix-tempfile", + "gix-utils", + "gix-validate", + "memmap2", + "thiserror 2.0.17", + "winnow", +] + +[[package]] +name = "gix-refspec" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcbba6ae5389f4021f73a2d62a4195aace7db1e8bb684b25521d3d685f57da02" +dependencies = [ + "bstr", + "gix-glob", + "gix-hash", + "gix-revision", + "gix-validate", + "smallvec", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-revision" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91898c83b18c635696f7355d171cfa74a52f38022ff89581f567768935ebc4c8" +dependencies = [ + "bstr", + "gix-commitgraph", + "gix-date", + "gix-hash", + "gix-object", + "gix-revwalk", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-revwalk" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d063699278485016863d0d2bb0db7609fd2e8ba9a89379717bf06fd96949eb2" +dependencies = [ + "gix-commitgraph", + "gix-date", + "gix-hash", + "gix-hashtable", + "gix-object", + "smallvec", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-sec" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea9962ed6d9114f7f100efe038752f41283c225bb507a2888903ac593dffa6be" +dependencies = [ + "bitflags", + "gix-path", + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "gix-shallow" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c1c467fb9f7ec1d33613c2ea5482de514bcb84b8222a793cdc4c71955832356" +dependencies = [ + "bstr", + "gix-hash", + "gix-lock", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-submodule" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efee2a61198413d80de10028aa507344537827d776ade781760130721bec2419" +dependencies = [ + "bstr", + "gix-config", + "gix-path", + "gix-pathspec", + "gix-refspec", + "gix-url", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-tempfile" +version = "20.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad89218e74850f42d364ed3877c7291f0474c8533502df91bb877ecc5cb0dd40" +dependencies = [ + "gix-fs", + "libc", + "parking_lot", + "signal-hook 0.4.1", + "signal-hook-registry", + "tempfile", +] + +[[package]] +name = "gix-trace" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e42a4c2583357721ba2d887916e78df504980f22f1182df06997ce197b89504" + +[[package]] +name = "gix-transport" +version = "0.52.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4d4ed02a2ebe771a26111896ecda0b98b58ed35e1d9c0ccf07251c1abb4918d" +dependencies = [ + "base64", + "bstr", + "gix-command", + "gix-credentials", + "gix-features", + "gix-packetline", + "gix-quote", + "gix-sec", + "gix-url", + "reqwest 0.13.1", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-traverse" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d052b83d1d1744be95ac6448ac02f95f370a8f6720e466be9ce57146e39f5280" +dependencies = [ + "bitflags", + "gix-commitgraph", + "gix-date", + "gix-hash", + "gix-hashtable", + "gix-object", + "gix-revwalk", + "smallvec", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-url" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff1996dfb9430b3699d89224c674169c1ae355eacc52bf30a03c0b8bffe73d9" +dependencies = [ + "bstr", + "gix-features", + "gix-path", + "percent-encoding", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-utils" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "befcdbdfb1238d2854591f760a48711bed85e72d80a10e8f2f93f656746ef7c5" +dependencies = [ + "fastrand", + "unicode-normalization", +] + +[[package]] +name = "gix-validate" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b1e63a5b516e970a594f870ed4571a8fdcb8a344e7bd407a20db8bd61dbfde4" +dependencies = [ + "bstr", + "thiserror 2.0.17", +] + +[[package]] +name = "gix-worktree" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cfb7ce8cdbfe06117d335d1ad329351468d20331e0aafd108ceb647c1326aca" +dependencies = [ + "bstr", + "gix-attributes", + "gix-features", + "gix-fs", + "gix-glob", + "gix-hash", + "gix-ignore", + "gix-index", + "gix-object", + "gix-path", + "gix-validate", +] + +[[package]] +name = "gix-worktree-state" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f34c19e29e0a359b97faaf92fdd053d4cc33aa0e69cabb30f0e120effe4ff3b" +dependencies = [ + "bstr", + "gix-features", + "gix-filter", + "gix-fs", + "gix-index", + "gix-object", + "gix-path", + "gix-worktree", + "io-close", + "thiserror 2.0.17", +] + +[[package]] +name = "globset" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52dfc19153a48bde0cbd630453615c8151bce3a5adfac7a0aebfbf0a1e1f57e3" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "goblin" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4db6758c546e6f81f265638c980e5e84dfbda80cfd8e89e02f83454c8e8124bd" +dependencies = [ + "log", + "plain", + "scroll", ] [[package]] @@ -792,9 +1973,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.16" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9f37a958b41b3b19ee2707c06439c0e9e547e847223eb791ecb0cb821c65e27" +checksum = "2f44da3a8150a6703ed5d34e164b875fd14c2cdab9af1252a9a1020bde2bdc54" dependencies = [ "atomic-waker", "bytes", @@ -810,6 +1991,15 @@ dependencies = [ ] [[package]] +name = "hash32" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" +dependencies = [ + "byteorder", +] + +[[package]] name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -847,6 +2037,26 @@ dependencies = [ ] [[package]] +name = "hdrhistogram" +version = "7.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "765c9198f173dd59ce26ff9f95ef0aafd0a0fe01fb9d72841bc5066a4c06511d" +dependencies = [ + "byteorder", + "num-traits", +] + +[[package]] +name = "heapless" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" +dependencies = [ + "hash32", + "stable_deref_trait", +] + +[[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -919,6 +2129,12 @@ dependencies = [ ] [[package]] +name = "http-range-header" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9171a2ea8a68358193d15dd5d70c1c10a2afc3e7e4c5bc92bc9f025cebd7359c" + +[[package]] name = "httparse" version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -950,7 +2166,23 @@ dependencies = [ "pin-utils", "smallvec", "tokio", - "want", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", ] [[package]] @@ -984,13 +2216,14 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.20" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" +checksum = "727805d60e7938b76b826a6ef209eb70eaa1812794f9424d4a4e2d740662df5f" dependencies = [ "base64", "bytes", "futures-channel", + "futures-core", "futures-util", "http", "http-body", @@ -1000,16 +2233,19 @@ dependencies = [ "percent-encoding", "pin-project-lite", "socket2", + "system-configuration", "tokio", + "tower-layer", "tower-service", "tracing", + "windows-registry", ] [[package]] name = "iana-time-zone" -version = "0.1.65" +version = "0.1.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -1111,12 +2347,6 @@ dependencies = [ ] [[package]] -name = "id-arena" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" - -[[package]] name = "idna" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1145,15 +2375,23 @@ checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" dependencies = [ "equivalent", "hashbrown 0.16.1", - "serde", - "serde_core", +] + +[[package]] +name = "io-close" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cadcf447f06744f8ce713d2d6239bb5bde2c357a452397a9ed90c625da390bc" +dependencies = [ + "libc", + "winapi", ] [[package]] name = "ipnet" -version = "2.12.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" [[package]] name = "iri-string" @@ -1166,6 +2404,12 @@ dependencies = [ ] [[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] name = "itertools" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1176,9 +2420,72 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.18" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "jiff" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e67e8da4c49d6d9909fe03361f9b620f58898859f5c7aded68351e85e71ecf50" +dependencies = [ + "jiff-static", + "jiff-tzdb-platform", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", + "windows-sys 0.61.2", +] + +[[package]] +name = "jiff-static" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0c84ee7f197eca9a86c6fd6cb771e55eb991632f15f2bc3ca6ec838929e6e78" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "jiff-tzdb" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68971ebff725b9e2ca27a601c5eb38a4c5d64422c4cbab0c535f248087eda5c2" + +[[package]] +name = "jiff-tzdb-platform" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "875a5a69ac2bab1a891711cf5eccbec1ce0341ea805560dcd90b7a2e925132e8" +dependencies = [ + "jiff-tzdb", +] + +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys", + "log", + "thiserror 1.0.69", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "jobserver" @@ -1192,15 +2499,38 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.91" +version = "0.3.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c" +checksum = "8c942ebf8e95485ca0d52d97da7c5a2c387d0e7f0ba4c35e93bfcaee045955b3" dependencies = [ "once_cell", "wasm-bindgen", ] [[package]] +name = "krates" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c432bb7d7a968a338f6c7cbd8782f38ffd87a793ff06c3a20257f45e1d003f6d" +dependencies = [ + "camino", + "cfg-expr", + "petgraph", + "semver", + "serde", + "serde_json", +] + +[[package]] +name = "kstring" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "558bf9508a558512042d3095138b1f7b8fe90c5467d94f9f1da28b3731c5dbd1" +dependencies = [ + "static_assertions", +] + +[[package]] name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1210,33 +2540,26 @@ dependencies = [ ] [[package]] -name = "leb128fmt" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" - -[[package]] name = "libc" -version = "0.2.183" +version = "0.2.180" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" +checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" [[package]] name = "libm" -version = "0.2.16" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" +checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" [[package]] name = "libredox" -version = "0.1.14" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1744e39d1d6a9948f4f388969627434e31128196de472883b39f148769bfe30a" +checksum = "3d0b95e02c851351f877147b7deea7b1afb1df71b63aa5f8270716e0c5720616" dependencies = [ "bitflags", "libc", - "plain", - "redox_syscall 0.7.3", + "redox_syscall 0.7.0", ] [[package]] @@ -1252,9 +2575,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.12.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" +checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" [[package]] name = "litemap" @@ -1317,6 +2640,17 @@ dependencies = [ ] [[package]] +name = "maybe-async" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cf92c10c7e361d6b99666ec1c6f9805b0bea2c3bd8c78dc6fe98ac5bd78db11" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] name = "md-5" version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1328,9 +2662,18 @@ dependencies = [ [[package]] name = "memchr" -version = "2.8.0" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" + +[[package]] +name = "memmap2" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" +checksum = "744133e4a0e0a658e1374cf3bf8e415c4052a15a111acd372764c55b4177d490" +dependencies = [ + "libc", +] [[package]] name = "mime" @@ -1339,6 +2682,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + +[[package]] name = "miniz_oxide" version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1360,18 +2713,35 @@ dependencies = [ ] [[package]] +name = "multer" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83e87776546dc87511aa5ee218730c92b666d7264ab6ed41f9d215af9cd5224b" +dependencies = [ + "bytes", + "encoding_rs", + "futures-util", + "http", + "httparse", + "memchr", + "mime", + "spin", + "version_check", +] + +[[package]] name = "native-tls" -version = "0.2.18" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" +checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" dependencies = [ "libc", "log", "openssl", - "openssl-probe", + "openssl-probe 0.1.6", "openssl-sys", "schannel", - "security-framework", + "security-framework 2.11.1", "security-framework-sys", "tempfile", ] @@ -1414,6 +2784,12 @@ dependencies = [ ] [[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] name = "num-integer" version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1445,15 +2821,21 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.21.4" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[package]] name = "openssl" -version = "0.10.76" +version = "0.10.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "951c002c75e16ea2c65b8c7e4d3d51d5530d8dfa7d060b4776828c88cfb18ecf" +checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" dependencies = [ "bitflags", "cfg-if", @@ -1477,15 +2859,21 @@ dependencies = [ [[package]] name = "openssl-probe" -version = "0.2.1" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" + +[[package]] +name = "openssl-probe" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f50d9b3dabb09ecd771ad0aa242ca6894994c130308ca3d7684634df8037391" [[package]] name = "openssl-sys" -version = "0.9.112" +version = "0.9.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d55af3b3e226502be1526dfdba67ab0e9c96fc293004e79576b2b9edb0dbdb" +checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321" dependencies = [ "cc", "libc", @@ -1503,7 +2891,7 @@ dependencies = [ "futures-sink", "js-sys", "pin-project-lite", - "thiserror 2.0.18", + "thiserror 2.0.17", "tracing", ] @@ -1534,9 +2922,9 @@ dependencies = [ [[package]] name = "opentelemetry-otlp" -version = "0.31.1" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f69cd6acbb9af919df949cd1ec9e5e7fdc2ef15d234b6b795aaa525cc02f71f" +checksum = "7a2366db2dca4d2ad033cad11e6ee42844fd727007af5ad04a1730f4cb8163bf" dependencies = [ "http", "opentelemetry", @@ -1545,7 +2933,7 @@ dependencies = [ "opentelemetry_sdk", "prost", "reqwest 0.12.28", - "thiserror 2.0.18", + "thiserror 2.0.17", "tokio", "tonic", "tracing", @@ -1582,7 +2970,7 @@ dependencies = [ "opentelemetry", "percent-encoding", "rand 0.9.2", - "thiserror 2.0.18", + "thiserror 2.0.17", "tokio", "tokio-stream", ] @@ -1632,19 +3020,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] +name = "petgraph" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" +dependencies = [ + "fixedbitset", + "hashbrown 0.15.5", + "indexmap", +] + +[[package]] name = "pin-project" -version = "1.1.11" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1749c7ed4bcaf4c3d0a3efc28538844fb29bcdd7d2b67b2be7e20ba861ff517" +checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.11" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b20ed30f105399776b9c883e68e536ef602a16ae6f596d2c473591d6ad64c6" +checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" dependencies = [ "proc-macro2", "quote", @@ -1653,9 +3052,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.17" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -1697,10 +3096,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" [[package]] +name = "platforms" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f21de1852251c849a53467e0ce8b97cca9d11fd4efa3930145c5d5f02f24447" +dependencies = [ + "serde", +] + +[[package]] name = "portable-atomic" -version = "1.13.1" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" +checksum = "f89776e4d69bb58bc6993e99ffa1d11f228b839984854c7daeb5d37f87cbe950" + +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] [[package]] name = "potential_utf" @@ -1712,6 +3129,12 @@ dependencies = [ ] [[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] name = "ppv-lite86" version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1721,20 +3144,10 @@ dependencies = [ ] [[package]] -name = "prettyplease" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" -dependencies = [ - "proc-macro2", - "syn", -] - -[[package]] name = "proc-macro2" -version = "1.0.106" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7" dependencies = [ "unicode-ident", ] @@ -1752,10 +3165,19 @@ dependencies = [ ] [[package]] +name = "prodash" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6efc566849d3d9d737c5cb06cc50e48950ebe3d3f9d70631490fff3a07b139" +dependencies = [ + "parking_lot", +] + +[[package]] name = "proptest" -version = "1.10.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37566cb3fdacef14c0737f9546df7cfeadbfbc9fef10991038bf5015d0c80532" +checksum = "bee689443a2bd0a16ab0348b52ee43e3b2d1b1f931c8aa5c9f8de4c86fbe8c40" dependencies = [ "bit-set", "bit-vec", @@ -1816,9 +3238,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.45" +version = "1.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a" dependencies = [ "proc-macro2", ] @@ -1830,10 +3252,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" [[package]] -name = "r-efi" -version = "6.0.0" +name = "radium" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" [[package]] name = "rand" @@ -1913,6 +3335,26 @@ dependencies = [ ] [[package]] +name = "rayon" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368f01d005bf8fd9b1206fb6fa653e6c4a81ceb1466406b81792d87c5677a58f" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] name = "redox_syscall" version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1923,48 +3365,43 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.7.3" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce70a74e890531977d37e532c34d45e9055d2409ed08ddba14529471ed0be16" +checksum = "49f3fe0889e69e2ae9e41f4d6c4c0181701d00e4697b356fb1f74173a5e0ee27" dependencies = [ "bitflags", ] [[package]] -name = "regex-automata" -version = "0.4.14" +name = "regex" +version = "1.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" dependencies = [ "aho-corasick", "memchr", + "regex-automata", "regex-syntax", ] [[package]] -name = "regex-syntax" -version = "0.8.10" +name = "regex-automata" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" - -[[package]] -name = "repos" -version = "0.0.0" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" dependencies = [ - "async-trait", - "base", - "bytes", - "proptest", - "semver", - "serde", - "serde_json", - "strum", - "thiserror 2.0.18", - "tracing", - "url", + "aho-corasick", + "memchr", + "regex-syntax", ] [[package]] +name = "regex-syntax" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" + +[[package]] name = "reqwest" version = "0.12.28" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2000,30 +3437,34 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.13.2" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab3f43e3283ab1488b624b44b0e988d0acea0b3214e694730a055cb6b2efa801" +checksum = "04e9018c9d814e5f30cc16a0f03271aeab3571e609612d9fe78c1aa8d11c2f62" dependencies = [ "base64", "bytes", + "encoding_rs", "futures-channel", "futures-core", "futures-util", + "h2", "http", "http-body", "http-body-util", "hyper", - "hyper-tls", + "hyper-rustls", "hyper-util", "js-sys", "log", - "native-tls", + "mime", "percent-encoding", "pin-project-lite", + "rustls", "rustls-pki-types", + "rustls-platform-verifier", "sync_wrapper", "tokio", - "tokio-native-tls", + "tokio-rustls", "tower", "tower-http", "tower-service", @@ -2048,43 +3489,83 @@ dependencies = [ ] [[package]] -name = "rsa" -version = "0.9.10" +name = "rsa" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8573f03f5883dcaebdfcf4725caa1ecb9c15b2ef50c43a07b816e06799bb12d" +dependencies = [ + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core 0.6.4", + "signature", + "spki", + "subtle", + "zeroize", +] + +[[package]] +name = "rust-embed" +version = "8.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04113cb9355a377d83f06ef1f0a45b8ab8cd7d8b1288160717d66df5c7988d27" +dependencies = [ + "rust-embed-impl", + "rust-embed-utils", + "walkdir", +] + +[[package]] +name = "rust-embed-impl" +version = "8.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0902e4c7c8e997159ab384e6d0fc91c221375f6894346ae107f47dd0f3ccaa" +dependencies = [ + "proc-macro2", + "quote", + "rust-embed-utils", + "syn", + "walkdir", +] + +[[package]] +name = "rust-embed-utils" +version = "8.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8573f03f5883dcaebdfcf4725caa1ecb9c15b2ef50c43a07b816e06799bb12d" +checksum = "5bcdef0be6fe7f6fa333b1073c949729274b05f123a0ad7efcb8efd878e5c3b1" dependencies = [ - "const-oid", - "digest", - "num-bigint-dig", - "num-integer", - "num-traits", - "pkcs1", - "pkcs8", - "rand_core 0.6.4", - "signature", - "spki", - "subtle", - "zeroize", + "sha2", + "walkdir", ] [[package]] +name = "rustc-stable-hash" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "781442f29170c5c93b7185ad559492601acdc71d5bb0706f5868094f45cfcd08" + +[[package]] name = "rustix" -version = "1.1.4" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34" dependencies = [ "bitflags", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] name = "rustls" -version = "0.23.37" +version = "0.23.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "758025cb5fccfd3bc2fd74708fd4682be41d99e5dff73c377c0646c6012c73a4" +checksum = "c665f33d38cea657d9614f766881e4d510e0eda4239891eea56b4cadcf01801b" dependencies = [ "log", "once_cell", @@ -2101,10 +3582,10 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "612460d5f7bea540c490b2b6395d8e34a953e52b491accd6c86c8164c5932a63" dependencies = [ - "openssl-probe", + "openssl-probe 0.2.0", "rustls-pki-types", "schannel", - "security-framework", + "security-framework 3.5.1", ] [[package]] @@ -2117,10 +3598,37 @@ dependencies = [ ] [[package]] +name = "rustls-platform-verifier" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d99feebc72bae7ab76ba994bb5e121b8d83d910ca40b36e0921f53becc41784" +dependencies = [ + "core-foundation 0.10.1", + "core-foundation-sys", + "jni", + "log", + "once_cell", + "rustls", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki", + "security-framework 3.5.1", + "security-framework-sys", + "webpki-root-certs", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" + +[[package]] name = "rustls-webpki" -version = "0.103.13" +version = "0.103.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" +checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53" dependencies = [ "ring", "rustls-pki-types", @@ -2128,6 +3636,23 @@ dependencies = [ ] [[package]] +name = "rustsec" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1648a26dcf2251d444d7c405ed4e227ac08552cdfb31bfc0145266fbec4138c" +dependencies = [ + "cargo-lock", + "cvss", + "fs-err", + "platforms", + "semver", + "serde", + "thiserror 2.0.17", + "toml", + "url", +] + +[[package]] name = "rustversion" version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2147,15 +3672,24 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.23" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984" + +[[package]] +name = "same-file" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] [[package]] name = "schannel" -version = "0.1.29" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" +checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" dependencies = [ "windows-sys 0.61.2", ] @@ -2167,6 +3701,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] +name = "scroll" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1257cd4248b4132760d6524d6dda4e053bc648c9070b960929bf50cfb1e7add" +dependencies = [ + "scroll_derive", +] + +[[package]] +name = "scroll_derive" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed76efe62313ab6610570951494bdaa81568026e0318eaa55f167de70eeea67d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] name = "sd-notify" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2177,12 +3731,25 @@ dependencies = [ [[package]] name = "security-framework" -version = "3.7.0" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags", + "core-foundation 0.9.4", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework" +version = "3.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +checksum = "b3297343eaf830f66ede390ea39da1d462b6b0c1b000f420d0a83f898bbbe6ef" dependencies = [ "bitflags", - "core-foundation", + "core-foundation 0.10.1", "core-foundation-sys", "libc", "security-framework-sys", @@ -2190,9 +3757,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.17.0" +version = "2.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +checksum = "cc1f0cbffaac4852523ce30d8bd3c5cdc873501d96ff467ca09b6767bb8cd5c0" dependencies = [ "core-foundation-sys", "libc", @@ -2203,6 +3770,10 @@ name = "semver" version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" +dependencies = [ + "serde", + "serde_core", +] [[package]] name = "serde" @@ -2291,6 +3862,16 @@ dependencies = [ ] [[package]] +name = "sha1-checked" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89f599ac0c323ebb1c6082821a54962b839832b03984598375bff3975b804423" +dependencies = [ + "digest", + "sha1", +] + +[[package]] name = "sha1_smol" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2317,12 +3898,38 @@ dependencies = [ ] [[package]] +name = "shell-words" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc6fe69c597f9c37bfeeeeeb33da3530379845f10be461a66d16d03eca2ded77" + +[[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] +name = "signal-hook" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a37d01603c37b5466f808de79f845c7116049b0579adb70a6b7d47c1fa3a952" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] name = "signal-hook-registry" version = "1.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2350,9 +3957,9 @@ checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2" [[package]] name = "slab" -version = "0.4.12" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" +checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" [[package]] name = "smallvec" @@ -2364,22 +3971,36 @@ dependencies = [ ] [[package]] -name = "smoke" -version = "0.1.0" +name = "smol_str" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f7a918bd2a9951d18ee6e48f076843e8e73a9a5d22cf05bcd4b7a81bdd04e17" dependencies = [ - "hex", - "reqwest 0.13.2", - "sha2", + "borsh", + "serde_core", ] [[package]] name = "socket2" -version = "0.6.3" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" +checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.60.2", +] + +[[package]] +name = "spdx" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afd765179d12cdd06192e02b1d8c6b0d46bd26de9bf16ce04c881428ca2cc7ed" +dependencies = [ + "rayon", + "regex", + "smallvec", + "unicode-normalization", + "zstd", ] [[package]] @@ -2451,7 +4072,7 @@ dependencies = [ "serde_json", "sha2", "smallvec", - "thiserror 2.0.18", + "thiserror 2.0.17", "tokio", "tokio-stream", "tracing", @@ -2534,7 +4155,7 @@ dependencies = [ "smallvec", "sqlx-core", "stringprep", - "thiserror 2.0.18", + "thiserror 2.0.17", "tracing", "whoami", ] @@ -2572,7 +4193,7 @@ dependencies = [ "smallvec", "sqlx-core", "stringprep", - "thiserror 2.0.18", + "thiserror 2.0.17", "tracing", "whoami", ] @@ -2597,7 +4218,7 @@ dependencies = [ "serde", "serde_urlencoded", "sqlx-core", - "thiserror 2.0.18", + "thiserror 2.0.17", "tracing", "url", ] @@ -2609,6 +4230,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] name = "stringprep" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2620,6 +4247,12 @@ dependencies = [ ] [[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] name = "strum" version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2648,9 +4281,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.117" +version = "2.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" dependencies = [ "proc-macro2", "quote", @@ -2678,61 +4311,85 @@ dependencies = [ ] [[package]] -name = "tempfile" -version = "3.27.0" +name = "system-configuration" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ - "fastrand", - "getrandom 0.4.2", - "once_cell", - "rustix", - "windows-sys 0.52.0", + "bitflags", + "core-foundation 0.9.4", + "system-configuration-sys", ] [[package]] -name = "tesor" -version = "0.1.0" +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tame-index" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "502c6b412fa8aa4d46f6fee23bba6cab4d260e459226c23a5f936c5f172039ec" dependencies = [ - "async-trait", - "axum", - "axum-server", - "base", "bytes", - "bytesize", - "chrono", - "crc32fast", - "hex", - "http-body-util", - "hyper", - "hyper-tls", - "hyper-util", - "maud", - "opentelemetry", - "opentelemetry-appender-tracing", - "opentelemetry-otlp", - "opentelemetry-semantic-conventions", - "opentelemetry_sdk", - "repos", - "rustls", - "sd-notify", + "camino", + "crossbeam-channel", + "home", + "http", + "libc", + "memchr", + "rayon", + "reqwest 0.13.1", + "rustc-stable-hash", + "semver", "serde", "serde_json", - "sqlx", - "tempfile", - "thiserror 2.0.18", + "sha2", + "smol_str", + "thiserror 2.0.17", "tokio", - "tokio-util", - "toml", - "tonic", - "tower", - "tower-http", - "tower_governor", - "tracing", - "tracing-opentelemetry", - "tracing-subscriber", - "url", - "uuid", + "toml-span", + "twox-hash", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "target-lexicon" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df7f62577c25e07834649fc3b39fafdc597c0a3527dc1c60129201ccfcbaa50c" + +[[package]] +name = "tempfile" +version = "3.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c" +dependencies = [ + "fastrand", + "getrandom 0.3.4", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", ] [[package]] @@ -2746,11 +4403,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.18" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" dependencies = [ - "thiserror-impl 2.0.18", + "thiserror-impl 2.0.17", ] [[package]] @@ -2766,9 +4423,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.18" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", @@ -2785,6 +4442,37 @@ dependencies = [ ] [[package]] +name = "time" +version = "0.3.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9e442fc33d7fdb45aa9bfeb312c095964abdf596f7567261062b2a7107aaabd" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b36ee98fd31ec7426d599183e8fe26932a8dc1fb76ddb6214d05493377d34ca" + +[[package]] +name = "time-macros" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e552d1249bf61ac2a52db88179fd0673def1e1ad8243a00d9ec9ed71fee3dd" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] name = "tinystr" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2796,9 +4484,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.11.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e61e67053d25a4e82c844e8424039d9745781b3fc4f32b8d55ed50f5f667ef3" +checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa" dependencies = [ "tinyvec_macros", ] @@ -2811,13 +4499,14 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.50.0" +version = "1.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d" +checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86" dependencies = [ "bytes", "libc", "mio", + "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", @@ -2827,9 +4516,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.6.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c55a2eff8b69ce66c84f85e1da1c233edc36ceb85a2058d11b0d6a3c7e7569c" +checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" dependencies = [ "proc-macro2", "quote", @@ -2882,9 +4571,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.9.12+spec-1.1.0" +version = "0.9.11+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf92845e79fc2e2def6a5d828f0801e29a2f8acc037becc5ab08595c7d5e9863" +checksum = "f3afc9a848309fe1aaffaed6e1546a7a14de1f935dc9d89d32afd9a44bab7c46" dependencies = [ "indexmap", "serde_core", @@ -2892,7 +4581,17 @@ dependencies = [ "toml_datetime", "toml_parser", "toml_writer", - "winnow 0.7.15", + "winnow", +] + +[[package]] +name = "toml-span" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6532e5b62b652073bff0e2050ef57e4697a853be118d6c57c32b59fffdeaab" +dependencies = [ + "codespan-reporting", + "smallvec", ] [[package]] @@ -2906,24 +4605,24 @@ dependencies = [ [[package]] name = "toml_parser" -version = "1.0.10+spec-1.1.0" +version = "1.0.6+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7df25b4befd31c4816df190124375d5a20c6b6921e2cad937316de3fccd63420" +checksum = "a3198b4b0a8e11f09dd03e133c0280504d0801269e9afa46362ffde1cbeebf44" dependencies = [ - "winnow 1.0.0", + "winnow", ] [[package]] name = "toml_writer" -version = "1.0.7+spec-1.1.0" +version = "1.0.6+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f17aaa1c6e3dc22b1da4b6bba97d066e354c7945cac2f7852d4e4e7ca7a6b56d" +checksum = "ab16f14aed21ee8bfd8ec22513f7287cd4a91aa92e44edfe2c17ddd004e92607" [[package]] name = "tonic" -version = "0.14.5" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fec7c61a0695dc1887c1b53952990f3ad2e3a31453e1f49f10e75424943a93ec" +checksum = "eb7613188ce9f7df5bfe185db26c5814347d110db17920415cf2fbcad85e7203" dependencies = [ "async-trait", "axum", @@ -2952,9 +4651,9 @@ dependencies = [ [[package]] name = "tonic-prost" -version = "0.14.5" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55376a0bbaa4975a3f10d009ad763d8f4108f067c7c2e74f3001fb49778d309" +checksum = "d6c55a2d6a14174563de34409c9f92ff981d006f56da9c6ecd40d9d4a31500b0" dependencies = [ "bytes", "prost", @@ -2969,6 +4668,7 @@ checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" dependencies = [ "futures-core", "futures-util", + "hdrhistogram", "indexmap", "pin-project-lite", "slab", @@ -2987,6 +4687,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" dependencies = [ "async-compression", + "base64", "bitflags", "bytes", "futures-core", @@ -2994,7 +4695,12 @@ dependencies = [ "http", "http-body", "http-body-util", + "http-range-header", + "httpdate", "iri-string", + "mime", + "mime_guess", + "percent-encoding", "pin-project-lite", "tokio", "tokio-util", @@ -3028,7 +4734,7 @@ dependencies = [ "governor", "http", "pin-project", - "thiserror 2.0.18", + "thiserror 2.0.17", "tonic", "tower", "tracing", @@ -3106,9 +4812,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.23" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" +checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" dependencies = [ "matchers", "nu-ansi-term", @@ -3132,6 +4838,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] +name = "twox-hash" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ea3136b675547379c4bd395ca6b938e5ad3c3d20fad76e7fe85f9e0d011419c" + +[[package]] name = "typenum" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3144,16 +4856,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] +name = "unicase" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142" + +[[package]] name = "unicode-bidi" version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" [[package]] +name = "unicode-bom" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eec5d1121208364f6793f7d2e222bf75a915c19557537745b195b253dd64217" + +[[package]] name = "unicode-ident" -version = "1.0.24" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" [[package]] name = "unicode-normalization" @@ -3171,10 +4895,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d" [[package]] -name = "unicode-xid" -version = "0.2.6" +name = "unicode-width" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" [[package]] name = "untrusted" @@ -3202,12 +4926,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" [[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] name = "uuid" -version = "1.22.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a68d3c8f01c0cfa54a75291d83601161799e4a89a39e0929f4b0354d88757a37" +checksum = "e2e054861b4bd027cd373e18e8d8d8e6548085000e41290d95ce0c373a654b4a" dependencies = [ - "getrandom 0.4.2", + "getrandom 0.3.4", "js-sys", "sha1_smol", "wasm-bindgen", @@ -3241,6 +4971,16 @@ dependencies = [ ] [[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] name = "want" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3265,15 +5005,6 @@ dependencies = [ ] [[package]] -name = "wasip3" -version = "0.4.0+wasi-0.3.0-rc-2026-01-06" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" -dependencies = [ - "wit-bindgen", -] - -[[package]] name = "wasite" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3281,9 +5012,9 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" [[package]] name = "wasm-bindgen" -version = "0.2.114" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e" +checksum = "64024a30ec1e37399cf85a7ffefebdb72205ca1c972291c51512360d90bd8566" dependencies = [ "cfg-if", "once_cell", @@ -3294,9 +5025,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.64" +version = "0.4.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9c5522b3a28661442748e09d40924dfb9ca614b21c00d3fd135720e48b67db8" +checksum = "70a6e77fd0ae8029c9ea0063f87c46fde723e7d887703d74ad2616d792e51e6f" dependencies = [ "cfg-if", "futures-util", @@ -3308,9 +5039,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.114" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6" +checksum = "008b239d9c740232e71bd39e8ef6429d27097518b6b30bdf9086833bd5b6d608" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3318,9 +5049,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.114" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3" +checksum = "5256bae2d58f54820e6490f9839c49780dff84c65aeab9e772f15d5f0e913a55" dependencies = [ "bumpalo", "proc-macro2", @@ -3331,52 +5062,18 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.114" +version = "0.2.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16" +checksum = "1f01b580c9ac74c8d8f0c0e4afb04eeef2acf145458e52c03845ee9cd23e3d12" dependencies = [ "unicode-ident", ] [[package]] -name = "wasm-encoder" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" -dependencies = [ - "leb128fmt", - "wasmparser", -] - -[[package]] -name = "wasm-metadata" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" -dependencies = [ - "anyhow", - "indexmap", - "wasm-encoder", - "wasmparser", -] - -[[package]] -name = "wasmparser" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" -dependencies = [ - "bitflags", - "hashbrown 0.15.5", - "indexmap", - "semver", -] - -[[package]] name = "web-sys" -version = "0.3.91" +version = "0.3.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854ba17bb104abfb26ba36da9729addc7ce7f06f5c0f90f3c391f8461cca21f9" +checksum = "312e32e551d92129218ea9a2452120f4aabc03529ef03e4d0d82fb2780608598" dependencies = [ "js-sys", "wasm-bindgen", @@ -3393,6 +5090,15 @@ dependencies = [ ] [[package]] +name = "webpki-root-certs" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36a29fc0408b113f68cf32637857ab740edfafdf460c326cd2afaa2d84cc05dc" +dependencies = [ + "rustls-pki-types", +] + +[[package]] name = "whoami" version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3419,6 +5125,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3466,6 +5181,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] +name = "windows-registry" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" +dependencies = [ + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] name = "windows-result" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3485,6 +5211,15 @@ dependencies = [ [[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" @@ -3503,6 +5238,15 @@ dependencies = [ [[package]] name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.5", +] + +[[package]] +name = "windows-sys" version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" @@ -3512,6 +5256,21 @@ dependencies = [ [[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.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" @@ -3534,7 +5293,7 @@ dependencies = [ "windows_aarch64_gnullvm 0.52.6", "windows_aarch64_msvc 0.52.6", "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm", + "windows_i686_gnullvm 0.52.6", "windows_i686_msvc 0.52.6", "windows_x86_64_gnu 0.52.6", "windows_x86_64_gnullvm 0.52.6", @@ -3542,6 +5301,29 @@ dependencies = [ ] [[package]] +name = "windows-targets" +version = "0.53.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", +] + +[[package]] +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.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3554,6 +5336,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3566,6 +5360,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3578,12 +5384,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] +name = "windows_i686_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + +[[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3596,6 +5420,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] +name = "windows_i686_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3608,6 +5444,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] +name = "windows_x86_64_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3620,124 +5468,66 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" +name = "windows_x86_64_gnullvm" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" [[package]] name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - -[[package]] -name = "winnow" -version = "0.7.15" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] -name = "winnow" -version = "1.0.0" +name = "windows_x86_64_msvc" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a90e88e4667264a994d34e6d1ab2d26d398dcdca8b7f52bec8668957517fc7d8" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] -name = "wit-bindgen" -version = "0.51.0" +name = "windows_x86_64_msvc" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" -dependencies = [ - "wit-bindgen-rust-macro", -] +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] -name = "wit-bindgen-core" -version = "0.51.0" +name = "windows_x86_64_msvc" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" -dependencies = [ - "anyhow", - "heck", - "wit-parser", -] +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" [[package]] -name = "wit-bindgen-rust" -version = "0.51.0" +name = "winnow" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829" dependencies = [ - "anyhow", - "heck", - "indexmap", - "prettyplease", - "syn", - "wasm-metadata", - "wit-bindgen-core", - "wit-component", + "memchr", ] [[package]] -name = "wit-bindgen-rust-macro" +name = "wit-bindgen" version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" -dependencies = [ - "anyhow", - "prettyplease", - "proc-macro2", - "quote", - "syn", - "wit-bindgen-core", - "wit-bindgen-rust", -] +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" [[package]] -name = "wit-component" -version = "0.244.0" +name = "writeable" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" -dependencies = [ - "anyhow", - "bitflags", - "indexmap", - "log", - "serde", - "serde_derive", - "serde_json", - "wasm-encoder", - "wasm-metadata", - "wasmparser", - "wit-parser", -] +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" [[package]] -name = "wit-parser" -version = "0.244.0" +name = "wyz" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" dependencies = [ - "anyhow", - "id-arena", - "indexmap", - "log", - "semver", - "serde", - "serde_derive", - "serde_json", - "unicode-xid", - "wasmparser", + "tap", ] [[package]] -name = "writeable" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" - -[[package]] name = "yoke" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3762,18 +5552,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.47" +version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbb2a062be311f2ba113ce66f697a4dc589f85e78a4aea276200804cea0ed87" +checksum = "668f5168d10b9ee831de31933dc111a459c97ec93225beb307aed970d1372dfd" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.47" +version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e8bc7269b54418e7aeeef514aa68f8690b8c0489a06b0136e5f57c4c5ccab89" +checksum = "2c7962b26b0a8685668b671ee4b54d007a67d4eaf05fda79ac0ecf41e32270f1" dependencies = [ "proc-macro2", "quote", @@ -3841,10 +5631,66 @@ dependencies = [ ] [[package]] +name = "zlib-rs" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40990edd51aae2c2b6907af74ffb635029d5788228222c4bb811e9351c0caad3" + +[[package]] name = "zmij" -version = "1.0.21" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" +checksum = "bd8f3f50b848df28f887acb68e41201b5aea6bc8a8dacc00fb40635ff9a72fea" + +[[package]] +name = "zorian" +version = "0.1.0" +dependencies = [ + "async-trait", + "axum", + "axum-extra", + "axum-server", + "bytes", + "bytesize", + "cargo-deny", + "chrono", + "crc32fast", + "futures", + "hex", + "http-body-util", + "hyper", + "hyper-tls", + "hyper-util", + "maud", + "mime_guess", + "opentelemetry", + "opentelemetry-appender-tracing", + "opentelemetry-otlp", + "opentelemetry-semantic-conventions", + "opentelemetry_sdk", + "proptest", + "rust-embed", + "rustls", + "sd-notify", + "semver", + "serde", + "serde_json", + "sqlx", + "tempfile", + "thiserror 2.0.17", + "tokio", + "tokio-util", + "toml", + "tonic", + "tower", + "tower-http", + "tower_governor", + "tracing", + "tracing-opentelemetry", + "tracing-subscriber", + "url", + "uuid", +] [[package]] name = "zstd" diff --git a/Cargo.toml b/Cargo.toml index 19cca99..17571ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,38 +1,31 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -[workspace] -members = ["crates/*", "tests/smoke"] -resolver = "3" - -[workspace.package] +[package] +name = "zorian" publish = false edition = "2024" version = "0.1.0" license = "AGPL-3.0-or-later" authors = ["Nikolay Govorov <me@govorov.online>"] homepage = "https://pkg.earth" -repository = "https://git.dimidiumlabs.io/tesor" +repository = "https://github.com/mrdimidium/Zorian" -[workspace.dependencies] -# local dependencies -base = { path = "crates/base" } -repos = { path = "crates/repos" } - -# external +[dependencies] async-trait = "0.1" -axum = { version = "0.8", features = ["http2", "macros"] } +axum = { version = "0.8", features = ["http2", "macros", "multipart"] } +axum-extra = "0.12" axum-server = { version = "0.8", features = ["tls-rustls-no-provider"] } bytes = "1.11" bytesize = { version = "2.3", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] } crc32fast = "1.5" +futures = "0.3" hex = "0.4" http-body-util = "0.1" hyper = "1.8" hyper-tls = "0.6" -hyper-util = { version = "0.1", features = ["client-legacy", "http1", "http2", "tokio"] } +hyper-util = { version = "0.1", features = ["full"] } maud = { version = "0.27", features = ["axum"] } +mime_guess = "2.0" +rust-embed = "8.11" rustls = { version = "0.23", default-features = false, features = [ "ring", "std", @@ -49,30 +42,13 @@ sqlx = { version = "0.8", features = [ "chrono", "json", ] } -strum = { version = "0.27", features = ["derive"] } thiserror = "2.0" -tokio = { version = "1.49", features = [ - "rt-multi-thread", - "macros", - "time", - "signal", - "fs", - "io-util", -] } +tokio = { version = "1.49", features = ["full"] } tokio-util = "0.7" toml = "0.9" tonic = "0.14" -tower = { version = "0.5", features = ["util"] } -tower-http = { version = "0.6", features = [ - "trace", - "compression-full", - "limit", - "timeout", - "request-id", - "set-header", - "follow-redirect", - "util", -] } +tower = { version = "0.5", features = ["full"] } +tower-http = { version = "0.6", features = ["full"] } tower_governor = { version = "0.8", features = ["axum", "tracing"] } url = { version = "2.5", features = ["serde"] } uuid = { version = "1.19", features = ["v4", "v5"] } @@ -100,9 +76,10 @@ tracing = "0.1" tracing-opentelemetry = "0.32" tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] } -# platform-specific -sd-notify = "0.4" +[target.'cfg(target_os = "linux")'.dependencies] +sd-notify = { version = "0.4" } -# dev +[dev-dependencies] +cargo-deny = "0.19" proptest = "1.6" tempfile = "3.24" diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 --- a/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -# syntax=docker/dockerfile:1.7@sha256:a57df69d0ea827fb7266491f2813635de6f17269be881f696fbfdf2d83dda33e -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -ARG ALPINE_VERSION=3.23.5 -ARG ALPINE_DIGEST=sha256:fd791d74b68913cbb027c6546007b3f0d3bc45125f797758156952bc2d6daf40 -ARG DISTROLESS_DIGEST=sha256:a77defd6fedbb3392b175ba8ea3d1c22be963c1597c248c3ba987ddd80bfb512 - -FROM --platform=$BUILDPLATFORM docker.io/library/alpine:${ALPINE_VERSION}@${ALPINE_DIGEST} AS rootfs -RUN install -d -m 0750 /rootfs/var/lib/tesor - -FROM gcr.io/distroless/cc-debian13:nonroot@${DISTROLESS_DIGEST} - -ARG TARGETARCH - -LABEL org.opencontainers.image.source="https://git.dimidiumlabs.io/tesor" \ - org.opencontainers.image.licenses="AGPL-3.0-or-later" - -COPY --chown=root:root --chmod=0755 .container/binary-${TARGETARCH}/tesor /usr/local/bin/tesor -COPY --from=rootfs --chown=10000:10000 /rootfs/var/lib/tesor /var/lib/tesor -COPY --chown=root:root pkg/tesor.toml /etc/tesor.toml -COPY --chown=root:root LICENSE README.md /usr/share/doc/tesor/ - -USER 10000:10000 -EXPOSE 2000 -VOLUME ["/var/lib/tesor"] - -ENTRYPOINT ["/usr/local/bin/tesor"] -CMD ["--config=/etc/tesor.toml"] diff --git a/LICENSES/CC-BY-3.0.txt b/LICENSES/CC-BY-3.0.txt deleted file mode 100644 --- a/LICENSES/CC-BY-3.0.txt +++ /dev/null @@ -1,319 +0,0 @@ -Creative Commons Legal Code - -Attribution 3.0 Unported - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR - DAMAGES RESULTING FROM ITS USE. - -License - -THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE -COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY -COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS -AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. - -BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE -TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY -BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS -CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND -CONDITIONS. - -1. Definitions - - a. "Adaptation" means a work based upon the Work, or upon the Work and - other pre-existing works, such as a translation, adaptation, - derivative work, arrangement of music or other alterations of a - literary or artistic work, or phonogram or performance and includes - cinematographic adaptations or any other form in which the Work may be - recast, transformed, or adapted including in any form recognizably - derived from the original, except that a work that constitutes a - Collection will not be considered an Adaptation for the purpose of - this License. For the avoidance of doubt, where the Work is a musical - work, performance or phonogram, the synchronization of the Work in - timed-relation with a moving image ("synching") will be considered an - Adaptation for the purpose of this License. - b. "Collection" means a collection of literary or artistic works, such as - encyclopedias and anthologies, or performances, phonograms or - broadcasts, or other works or subject matter other than works listed - in Section 1(f) below, which, by reason of the selection and - arrangement of their contents, constitute intellectual creations, in - which the Work is included in its entirety in unmodified form along - with one or more other contributions, each constituting separate and - independent works in themselves, which together are assembled into a - collective whole. A work that constitutes a Collection will not be - considered an Adaptation (as defined above) for the purposes of this - License. - c. "Distribute" means to make available to the public the original and - copies of the Work or Adaptation, as appropriate, through sale or - other transfer of ownership. - d. "Licensor" means the individual, individuals, entity or entities that - offer(s) the Work under the terms of this License. - e. "Original Author" means, in the case of a literary or artistic work, - the individual, individuals, entity or entities who created the Work - or if no individual or entity can be identified, the publisher; and in - addition (i) in the case of a performance the actors, singers, - musicians, dancers, and other persons who act, sing, deliver, declaim, - play in, interpret or otherwise perform literary or artistic works or - expressions of folklore; (ii) in the case of a phonogram the producer - being the person or legal entity who first fixes the sounds of a - performance or other sounds; and, (iii) in the case of broadcasts, the - organization that transmits the broadcast. - f. "Work" means the literary and/or artistic work offered under the terms - of this License including without limitation any production in the - literary, scientific and artistic domain, whatever may be the mode or - form of its expression including digital form, such as a book, - pamphlet and other writing; a lecture, address, sermon or other work - of the same nature; a dramatic or dramatico-musical work; a - choreographic work or entertainment in dumb show; a musical - composition with or without words; a cinematographic work to which are - assimilated works expressed by a process analogous to cinematography; - a work of drawing, painting, architecture, sculpture, engraving or - lithography; a photographic work to which are assimilated works - expressed by a process analogous to photography; a work of applied - art; an illustration, map, plan, sketch or three-dimensional work - relative to geography, topography, architecture or science; a - performance; a broadcast; a phonogram; a compilation of data to the - extent it is protected as a copyrightable work; or a work performed by - a variety or circus performer to the extent it is not otherwise - considered a literary or artistic work. - g. "You" means an individual or entity exercising rights under this - License who has not previously violated the terms of this License with - respect to the Work, or who has received express permission from the - Licensor to exercise rights under this License despite a previous - violation. - h. "Publicly Perform" means to perform public recitations of the Work and - to communicate to the public those public recitations, by any means or - process, including by wire or wireless means or public digital - performances; to make available to the public Works in such a way that - members of the public may access these Works from a place and at a - place individually chosen by them; to perform the Work to the public - by any means or process and the communication to the public of the - performances of the Work, including by public digital performance; to - broadcast and rebroadcast the Work by any means including signs, - sounds or images. - i. "Reproduce" means to make copies of the Work by any means including - without limitation by sound or visual recordings and the right of - fixation and reproducing fixations of the Work, including storage of a - protected performance or phonogram in digital form or other electronic - medium. - -2. Fair Dealing Rights. Nothing in this License is intended to reduce, -limit, or restrict any uses free from copyright or rights arising from -limitations or exceptions that are provided for in connection with the -copyright protection under copyright law or other applicable laws. - -3. License Grant. Subject to the terms and conditions of this License, -Licensor hereby grants You a worldwide, royalty-free, non-exclusive, -perpetual (for the duration of the applicable copyright) license to -exercise the rights in the Work as stated below: - - a. to Reproduce the Work, to incorporate the Work into one or more - Collections, and to Reproduce the Work as incorporated in the - Collections; - b. to create and Reproduce Adaptations provided that any such Adaptation, - including any translation in any medium, takes reasonable steps to - clearly label, demarcate or otherwise identify that changes were made - to the original Work. For example, a translation could be marked "The - original work was translated from English to Spanish," or a - modification could indicate "The original work has been modified."; - c. to Distribute and Publicly Perform the Work including as incorporated - in Collections; and, - d. to Distribute and Publicly Perform Adaptations. - e. For the avoidance of doubt: - - i. Non-waivable Compulsory License Schemes. In those jurisdictions in - which the right to collect royalties through any statutory or - compulsory licensing scheme cannot be waived, the Licensor - reserves the exclusive right to collect such royalties for any - exercise by You of the rights granted under this License; - ii. Waivable Compulsory License Schemes. In those jurisdictions in - which the right to collect royalties through any statutory or - compulsory licensing scheme can be waived, the Licensor waives the - exclusive right to collect such royalties for any exercise by You - of the rights granted under this License; and, - iii. Voluntary License Schemes. The Licensor waives the right to - collect royalties, whether individually or, in the event that the - Licensor is a member of a collecting society that administers - voluntary licensing schemes, via that society, from any exercise - by You of the rights granted under this License. - -The above rights may be exercised in all media and formats whether now -known or hereafter devised. The above rights include the right to make -such modifications as are technically necessary to exercise the rights in -other media and formats. Subject to Section 8(f), all rights not expressly -granted by Licensor are hereby reserved. - -4. Restrictions. The license granted in Section 3 above is expressly made -subject to and limited by the following restrictions: - - a. You may Distribute or Publicly Perform the Work only under the terms - of this License. You must include a copy of, or the Uniform Resource - Identifier (URI) for, this License with every copy of the Work You - Distribute or Publicly Perform. You may not offer or impose any terms - on the Work that restrict the terms of this License or the ability of - the recipient of the Work to exercise the rights granted to that - recipient under the terms of the License. You may not sublicense the - Work. You must keep intact all notices that refer to this License and - to the disclaimer of warranties with every copy of the Work You - Distribute or Publicly Perform. When You Distribute or Publicly - Perform the Work, You may not impose any effective technological - measures on the Work that restrict the ability of a recipient of the - Work from You to exercise the rights granted to that recipient under - the terms of the License. This Section 4(a) applies to the Work as - incorporated in a Collection, but this does not require the Collection - apart from the Work itself to be made subject to the terms of this - License. If You create a Collection, upon notice from any Licensor You - must, to the extent practicable, remove from the Collection any credit - as required by Section 4(b), as requested. If You create an - Adaptation, upon notice from any Licensor You must, to the extent - practicable, remove from the Adaptation any credit as required by - Section 4(b), as requested. - b. If You Distribute, or Publicly Perform the Work or any Adaptations or - Collections, You must, unless a request has been made pursuant to - Section 4(a), keep intact all copyright notices for the Work and - provide, reasonable to the medium or means You are utilizing: (i) the - name of the Original Author (or pseudonym, if applicable) if supplied, - and/or if the Original Author and/or Licensor designate another party - or parties (e.g., a sponsor institute, publishing entity, journal) for - attribution ("Attribution Parties") in Licensor's copyright notice, - terms of service or by other reasonable means, the name of such party - or parties; (ii) the title of the Work if supplied; (iii) to the - extent reasonably practicable, the URI, if any, that Licensor - specifies to be associated with the Work, unless such URI does not - refer to the copyright notice or licensing information for the Work; - and (iv) , consistent with Section 3(b), in the case of an Adaptation, - a credit identifying the use of the Work in the Adaptation (e.g., - "French translation of the Work by Original Author," or "Screenplay - based on original Work by Original Author"). The credit required by - this Section 4 (b) may be implemented in any reasonable manner; - provided, however, that in the case of a Adaptation or Collection, at - a minimum such credit will appear, if a credit for all contributing - authors of the Adaptation or Collection appears, then as part of these - credits and in a manner at least as prominent as the credits for the - other contributing authors. For the avoidance of doubt, You may only - use the credit required by this Section for the purpose of attribution - in the manner set out above and, by exercising Your rights under this - License, You may not implicitly or explicitly assert or imply any - connection with, sponsorship or endorsement by the Original Author, - Licensor and/or Attribution Parties, as appropriate, of You or Your - use of the Work, without the separate, express prior written - permission of the Original Author, Licensor and/or Attribution - Parties. - c. Except as otherwise agreed in writing by the Licensor or as may be - otherwise permitted by applicable law, if You Reproduce, Distribute or - Publicly Perform the Work either by itself or as part of any - Adaptations or Collections, You must not distort, mutilate, modify or - take other derogatory action in relation to the Work which would be - prejudicial to the Original Author's honor or reputation. Licensor - agrees that in those jurisdictions (e.g. Japan), in which any exercise - of the right granted in Section 3(b) of this License (the right to - make Adaptations) would be deemed to be a distortion, mutilation, - modification or other derogatory action prejudicial to the Original - Author's honor and reputation, the Licensor will waive or not assert, - as appropriate, this Section, to the fullest extent permitted by the - applicable national law, to enable You to reasonably exercise Your - right under Section 3(b) of this License (right to make Adaptations) - but not otherwise. - -5. Representations, Warranties and Disclaimer - -UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR -OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY -KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, -INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, -FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF -LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, -WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION -OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. - -6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE -LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR -ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES -ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS -BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -7. Termination - - a. This License and the rights granted hereunder will terminate - automatically upon any breach by You of the terms of this License. - Individuals or entities who have received Adaptations or Collections - from You under this License, however, will not have their licenses - terminated provided such individuals or entities remain in full - compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will - survive any termination of this License. - b. Subject to the above terms and conditions, the license granted here is - perpetual (for the duration of the applicable copyright in the Work). - Notwithstanding the above, Licensor reserves the right to release the - Work under different license terms or to stop distributing the Work at - any time; provided, however that any such election will not serve to - withdraw this License (or any other license that has been, or is - required to be, granted under the terms of this License), and this - License will continue in full force and effect unless terminated as - stated above. - -8. Miscellaneous - - a. Each time You Distribute or Publicly Perform the Work or a Collection, - the Licensor offers to the recipient a license to the Work on the same - terms and conditions as the license granted to You under this License. - b. Each time You Distribute or Publicly Perform an Adaptation, Licensor - offers to the recipient a license to the original Work on the same - terms and conditions as the license granted to You under this License. - c. If any provision of this License is invalid or unenforceable under - applicable law, it shall not affect the validity or enforceability of - the remainder of the terms of this License, and without further action - by the parties to this agreement, such provision shall be reformed to - the minimum extent necessary to make such provision valid and - enforceable. - d. No term or provision of this License shall be deemed waived and no - breach consented to unless such waiver or consent shall be in writing - and signed by the party to be charged with such waiver or consent. - e. This License constitutes the entire agreement between the parties with - respect to the Work licensed here. There are no understandings, - agreements or representations with respect to the Work not specified - here. Licensor shall not be bound by any additional provisions that - may appear in any communication from You. This License may not be - modified without the mutual written agreement of the Licensor and You. - f. The rights granted under, and the subject matter referenced, in this - License were drafted utilizing the terminology of the Berne Convention - for the Protection of Literary and Artistic Works (as amended on - September 28, 1979), the Rome Convention of 1961, the WIPO Copyright - Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 - and the Universal Copyright Convention (as revised on July 24, 1971). - These rights and subject matter take effect in the relevant - jurisdiction in which the License terms are sought to be enforced - according to the corresponding provisions of the implementation of - those treaty provisions in the applicable national law. If the - standard suite of rights granted under applicable copyright law - includes additional rights not granted under this License, such - additional rights are deemed to be included in the License; this - License is not intended to restrict the license of any rights under - applicable law. - - -Creative Commons Notice - - Creative Commons is not a party to this License, and makes no warranty - whatsoever in connection with the Work. Creative Commons will not be - liable to You or any party on any legal theory for any damages - whatsoever, including without limitation any general, special, - incidental or consequential damages arising in connection to this - license. Notwithstanding the foregoing two (2) sentences, if Creative - Commons has expressly identified itself as the Licensor hereunder, it - shall have all rights and obligations of Licensor. - - Except for the limited purpose of indicating to the public that the - Work is licensed under the CCPL, Creative Commons does not authorize - the use by either party of the trademark "Creative Commons" or any - related trademark or logo of Creative Commons without the prior - written consent of Creative Commons. Any permitted use will be in - compliance with Creative Commons' then-current trademark usage - guidelines, as may be published on its website or otherwise made - available upon request from time to time. For the avoidance of doubt, - this trademark restriction does not form part of this License. - - Creative Commons may be contacted at https://creativecommons.org/. diff --git a/LICENSES/CC-BY-4.0.txt b/LICENSES/CC-BY-4.0.txt deleted file mode 100644 --- a/LICENSES/CC-BY-4.0.txt +++ /dev/null @@ -1,156 +0,0 @@ -Creative Commons Attribution 4.0 International - - Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. - -Using Creative Commons Public Licenses - -Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. - -Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors. - -Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public. - -Creative Commons Attribution 4.0 International Public License - -By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. - -Section 1 – Definitions. - - a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. - - b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. - - c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. - - d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. - - e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. - - f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. - - g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. - - h. Licensor means the individual(s) or entity(ies) granting rights under this Public License. - - i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. - - j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. - - k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. - -Section 2 – Scope. - - a. License grant. - - 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: - - A. reproduce and Share the Licensed Material, in whole or in part; and - - B. produce, reproduce, and Share Adapted Material. - - 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. - - 3. Term. The term of this Public License is specified in Section 6(a). - - 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. - - 5. Downstream recipients. - - A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. - - B. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. - - 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). - -b. Other rights. - - 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. - - 2. Patent and trademark rights are not licensed under this Public License. - - 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties. - -Section 3 – License Conditions. - -Your exercise of the Licensed Rights is expressly made subject to the following conditions. - - a. Attribution. - - 1. If You Share the Licensed Material (including in modified form), You must: - - A. retain the following if it is supplied by the Licensor with the Licensed Material: - - i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); - - ii. a copyright notice; - - iii. a notice that refers to this Public License; - - iv. a notice that refers to the disclaimer of warranties; - - v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; - - B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and - - C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. - - 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. - - 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. - - 4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License. - -Section 4 – Sui Generis Database Rights. - -Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: - - a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database; - - b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and - - c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. -For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. - -Section 5 – Disclaimer of Warranties and Limitation of Liability. - - a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You. - - b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You. - - c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. - -Section 6 – Term and Termination. - - a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. - - b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: - - 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or - - 2. upon express reinstatement by the Licensor. - - c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. - - d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. - - e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. - -Section 7 – Other Terms and Conditions. - - a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. - - b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. - -Section 8 – Interpretation. - - a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. - - b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. - - c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. - - d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. - -Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. - -Creative Commons may be contacted at creativecommons.org. diff --git a/Makefile b/Makefile new file mode 100644 --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +# SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> +# SPDX-License-Identifier: AGPL-3.0-or-later + +all: fmt clippy test deps licenses + +.PHONY: licenses +licenses: + reuse lint + +.PHONY: fmt +fmt: + cargo fmt --all --check + +.PHONY: deps +deps: + cargo deny check + +.PHONY: clippy +clippy: + cargo clippy --all-targets --all-features -- -D warnings + +.PHONY: test +test: + cargo build --release + cargo test --all-features --release --locked diff --git a/README.md b/README.md index 2c51ae4..3e75d70 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Tesor — tiny packages caching proxy +# Zorian — tiny packages caching proxy Soon humanity will go to Mars and in order for the colonists to be able to program, we will need a local mirror of packages. @@ -13,89 +13,54 @@ is **not** intended for production use. ```bash sudo apt install curl gnupg -curl -fsSL https://pkg.dimidiumlabs.io/packages.gpg | sudo gpg --dearmor -o /usr/share/keyrings/dimidiumlabs.gpg -echo "deb [signed-by=/usr/share/keyrings/dimidiumlabs.gpg] https://pkg.dimidiumlabs.io/tesor/apt/ nightly main" | sudo tee /etc/apt/sources.list.d/tesor.list -sudo apt update && sudo apt install tesor +curl -fsSL https://github.com/mrdimidium/Zorian/releases/download/dev/public.gpg | sudo gpg --dearmor -o /usr/share/keyrings/zorian.gpg +echo "deb [signed-by=/usr/share/keyrings/zorian.gpg] https://zorian.hel1.your-objectstorage.com/apt/ dev main" | sudo tee /etc/apt/sources.list.d/zorian.list +sudo apt update && sudo apt install zorian -sudo systemctl enable --now tesor +sudo systemctl enable --now zorian ``` -**Fedora/RHEL:** +**Fedora/RedHat:** ```bash -# DNF5 (Fedora 41+, RHEL 10+) -sudo dnf config-manager addrepo --from-repofile=https://pkg.dimidiumlabs.io/tesor/rpm/nightly/tesor-nightly.repo +sudo rpm --import https://github.com/mrdimidium/Zorian/releases/download/dev/public.gpg +sudo dnf config-manager --add-repo https://zorian.hel1.your-objectstorage.com/rpm/ +sudo dnf install zorian -# DNF4 (Fedora 40 and older, RHEL 8/9) -sudo curl -o /etc/yum.repos.d/tesor-nightly.repo https://pkg.dimidiumlabs.io/tesor/rpm/nightly/tesor-nightly.repo - -sudo dnf install tesor -sudo systemctl enable --now tesor -``` - -**openSUSE:** - -```bash -sudo rpm --import https://pkg.dimidiumlabs.io/packages.gpg -sudo zypper addrepo https://pkg.dimidiumlabs.io/tesor/rpm/nightly/ tesor-nightly -sudo zypper refresh -sudo zypper install tesor - -sudo systemctl enable --now tesor +sudo systemctl enable --now zorian ``` ## Build from source -1. Clone repo: `git clone https://git.dimidiumlabs.io/tesor.git && cd tesor` -1. Provision the toolchain and system build dependencies: `mise bootstrap` -1. Build from source: `mise exec -- cargo build --release` +1. Install build dependencies: + - Fedora/RedHat: `sudo dnf install gcc openssl-devel pkg-config` + - Debian/Ubuntu: `sudo apt install build-essential libssl-dev pkg-config` +1. Clone repo: `git clone https://github.com/mrdimidium/Zorian.git && cd Zorian` +1. Build from source: `cargo build --release` 1. Install manually ```bash - sudo groupadd --system tesor - sudo useradd --system --gid tesor --no-create-home --shell /usr/sbin/nologin tesor - sudo install -m 700 -o tesor ./pkg/tesor.toml /etc/ - sudo install -m 755 -o root ./pkg/tesor.service /usr/lib/systemd/system - sudo install -m 755 -o root target/release/tesor /usr/local/bin/ + sudo groupadd --system zorian + sudo useradd --system --gid zorian --no-create-home --shell /usr/sbin/nologin zorian + sudo install -m 700 -o zorian ./pkg/zorian.toml /etc/ + sudo install -m 755 -o root ./pkg/zorian.service /usr/lib/systemd/system + sudo install -m 755 -o root target/release/zorian /usr/local/bin/ ``` -1. start systemd service: `sudo systemctl enable --now tesor` - -## Contributing - -We welcome your contributions, including code, bug reports, ideas, and success -stories. - -If you are making a contribution for the first time or from a new email, please -add yourself to the `.mailmap`. - -### Signoff - -To include your code, we ask that you read and agree to the [CLA](./CLA.md). To -sign, add a `CLA-Version: 1.0` and a `Signed-off-by` trailer to every commit -(`git commit -s --trailer "CLA-Version: 1.0"`). Each commit in a pull request -must carry a valid `Signed-off-by` line matching the commit author. Please use -your real name. We cannot include code from anonymous contributors. - -AI agents MUST NOT add Signed-off-by tags. Only humans can legally certify the -Contributor License Agreement. - -### AI policy - -You may use AI agents when writing code and documentation. AI is not allowed for -media including images, videos, fonts at all. You must fully read, understand, -and cleanup any code generated by the agent. We ask that you disclose the -agent's use and indicate the tool, model, and extent of contribution. +1. start systemd service: `sudo systemctl enable --now zorian` -Contributions should include an Assisted-by tag in the following format: -`Assisted-by: AGENT_NAME:MODEL_VERSION [TOOL1] [TOOL2]`, for example: -`Assisted-by: Claude:claude-4.6-opus coccinelle sparse` +## License -Remember, AI agents should make software better, not worse. +Copyright (C) 2026 Nikolay Govorov -## Licensing +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU Affero General Public License as published by the Free +Software Foundation, either version 3 of the License, or (at your option) any +later version. -Tesor source code is licensed under AGPL-3.0-or-later. Documentation is -licensed under CC-BY-4.0. +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. -The bundled JetBrains Mono font files are licensed under OFL-1.1. +You should have received a copy of the GNU Affero General Public License along +with this program. If not, see <https://www.gnu.org/licenses/>. diff --git a/REUSE.toml b/REUSE.toml index ca825f7..ec848e2 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -1,44 +1,19 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - version = 1 [[annotations]] path = [ + "CLA.md", + "README.md", "Cargo.toml", "Cargo.lock", - "mise.lock", - - "pkg/*.svg", - "charts/tesor/templates/*", - - "crates/tesor/src/assets/*.svg", - "crates/tesor/src/assets/*.ico", - "crates/tesor/src/assets/*.png", - "crates/tesor/src/assets/robots.txt", - "crates/tesor/src/assets/manifest.webmanifest", ] -SPDX-FileCopyrightText = "2026 Nikolay Govorov" +SPDX-FileCopyrightText = "2026 Nikolay Govorov <me@govorov.online>" SPDX-License-Identifier = "AGPL-3.0-or-later" [[annotations]] path = [ - "README.md", -] -SPDX-FileCopyrightText = "2026 Nikolay Govorov" -SPDX-License-Identifier = "CC-BY-4.0" - -[[annotations]] -path = [ - "CLA.md", -] -SPDX-FileCopyrightText = "2026 Nikolay Govorov" -SPDX-License-Identifier = "CC-BY-3.0" - -[[annotations]] -path = [ - "crates/tesor/src/assets/jetbrainsmono/OFL.txt", - "crates/tesor/src/assets/jetbrainsmono/*.woff2", + "src/assets/jetbrainsmono/OFL.txt", + "src/assets/jetbrainsmono/*.woff2", ] SPDX-FileCopyrightText = "Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)" SPDX-License-Identifier = "OFL-1.1" diff --git a/charts/tesor/Chart.yaml b/charts/tesor/Chart.yaml deleted file mode 100644 --- a/charts/tesor/Chart.yaml +++ /dev/null @@ -1,10 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -apiVersion: v2 -type: application -version: 0.1.0 - -name: tesor -home: https://git.dimidiumlabs.io/tesor -description: Tiny package caching proxy diff --git a/charts/tesor/templates/_helpers.tpl b/charts/tesor/templates/_helpers.tpl deleted file mode 100644 --- a/charts/tesor/templates/_helpers.tpl +++ /dev/null @@ -1,37 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -{{- define "tesor.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{- define "tesor.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name (include "tesor.name" .) | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} - -{{- define "tesor.labels" -}} -helm.sh/chart: {{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" }} -app.kubernetes.io/name: {{ include "tesor.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end -}} - -{{- define "tesor.selectorLabels" -}} -app.kubernetes.io/name: {{ include "tesor.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end -}} - -{{- define "tesor.image" -}} -{{- if .Values.image.digest -}} -{{- printf "%s@%s" .Values.image.repository .Values.image.digest -}} -{{- else -}} -{{- printf "%s:%s" .Values.image.repository (default .Chart.AppVersion .Values.image.tag) -}} -{{- end -}} -{{- end -}} - -# vim: set filetype=helm: diff --git a/charts/tesor/templates/configmap.yaml b/charts/tesor/templates/configmap.yaml deleted file mode 100644 --- a/charts/tesor/templates/configmap.yaml +++ /dev/null @@ -1,46 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -{{- if not .Values.config.existingConfigMap }} -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ include "tesor.fullname" . }} - labels: - {{- include "tesor.labels" . | nindent 4 }} -data: - tesor.toml: | - appname = {{ .Values.config.appname | quote }} - dirname = "/var/lib/tesor" - - [server] - max_body_size = {{ .Values.config.server.maxBodySize | quote }} - max_concurrent_requests = {{ .Values.config.server.maxConcurrentRequests }} - - rate_limit_period = {{ .Values.config.server.rateLimitPeriod }} - rate_limit_burst_size = {{ .Values.config.server.rateLimitBurstSize }} - - request_timeout = {{ .Values.config.server.requestTimeout }} - shutdown_timeout = {{ .Values.config.server.shutdownTimeout }} - - [[listen]] - addr = "0.0.0.0:2000" - hostnames = {{ .Values.config.hostnames | toJson }} - - {{- range $name, $backend := .Values.config.backends }} - [backends.{{ $name }}] - enabled = {{ $backend.enabled }} - refresh_interval = {{ $backend.refreshInterval }} - - {{- end }} - [telemetry.stdout] - enabled = {{ .Values.config.log.enabled }} - log_level = {{ .Values.config.log.level | quote }} - log_format = {{ .Values.config.log.format | quote }} - {{- with .Values.config.extra }} - -{{ . | indent 4 }} - {{- end }} -{{- end }} - -# vim: set filetype=helm: diff --git a/charts/tesor/templates/deployment.yaml b/charts/tesor/templates/deployment.yaml deleted file mode 100644 --- a/charts/tesor/templates/deployment.yaml +++ /dev/null @@ -1,97 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "tesor.fullname" . }} - labels: - {{- include "tesor.labels" . | nindent 4 }} -spec: - replicas: {{ .Values.replicaCount }} - strategy: - type: Recreate - selector: - matchLabels: - {{- include "tesor.selectorLabels" . | nindent 6 }} - template: - metadata: - annotations: - {{- if not .Values.config.existingConfigMap }} - checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} - {{- end }} - {{- with .Values.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} - labels: - {{- include "tesor.selectorLabels" . | nindent 8 }} - {{- with .Values.podLabels }} - {{- toYaml . | nindent 8 }} - {{- end }} - spec: - automountServiceAccountToken: false - terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - containers: - - name: tesor - image: {{ include "tesor.image" . | quote }} - imagePullPolicy: {{ .Values.image.pullPolicy }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - args: ["--config=/etc/tesor/tesor.toml"] - ports: - - name: http - containerPort: 2000 - protocol: TCP - startupProbe: - tcpSocket: - port: http - failureThreshold: 60 - periodSeconds: 5 - readinessProbe: - tcpSocket: - port: http - periodSeconds: 10 - livenessProbe: - tcpSocket: - port: http - periodSeconds: 20 - resources: - {{- toYaml .Values.resources | nindent 12 }} - volumeMounts: - - name: config - mountPath: /etc/tesor/tesor.toml - subPath: tesor.toml - readOnly: true - - name: state - mountPath: /var/lib/tesor - volumes: - - name: config - configMap: - name: {{ default (include "tesor.fullname" .) .Values.config.existingConfigMap }} - - name: state - {{- if .Values.persistence.enabled }} - persistentVolumeClaim: - claimName: {{ default (include "tesor.fullname" .) .Values.persistence.existingClaim }} - {{- else }} - emptyDir: {} - {{- end }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} - -# vim: set filetype=helm: diff --git a/charts/tesor/templates/httproute.yaml b/charts/tesor/templates/httproute.yaml deleted file mode 100644 --- a/charts/tesor/templates/httproute.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -{{- if .Values.route.enabled }} -apiVersion: gateway.networking.k8s.io/v1 -kind: HTTPRoute -metadata: - name: {{ include "tesor.fullname" . }} - labels: - {{- include "tesor.labels" . | nindent 4 }} -spec: - {{- with .Values.route.parentRefs }} - parentRefs: - {{- toYaml . | nindent 4 }} - {{- end }} - {{- with .Values.route.hostnames }} - hostnames: - {{- toYaml . | nindent 4 }} - {{- end }} - rules: - - backendRefs: - - name: {{ include "tesor.fullname" . }} - port: {{ .Values.service.port }} -{{- end }} - -# vim: set filetype=helm: diff --git a/charts/tesor/templates/pvc.yaml b/charts/tesor/templates/pvc.yaml deleted file mode 100644 --- a/charts/tesor/templates/pvc.yaml +++ /dev/null @@ -1,22 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }} -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: {{ include "tesor.fullname" . }} - labels: - {{- include "tesor.labels" . | nindent 4 }} -spec: - accessModes: - {{- toYaml .Values.persistence.accessModes | nindent 4 }} - resources: - requests: - storage: {{ .Values.persistence.size }} - {{- with .Values.persistence.storageClass }} - storageClassName: {{ . | quote }} - {{- end }} -{{- end }} - -# vim: set filetype=helm: diff --git a/charts/tesor/templates/service.yaml b/charts/tesor/templates/service.yaml deleted file mode 100644 --- a/charts/tesor/templates/service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -apiVersion: v1 -kind: Service -metadata: - name: {{ include "tesor.fullname" . }} - labels: - {{- include "tesor.labels" . | nindent 4 }} -spec: - selector: - {{- include "tesor.selectorLabels" . | nindent 4 }} - ports: - - name: http - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - -# vim: set filetype=helm: diff --git a/charts/tesor/values.yaml b/charts/tesor/values.yaml deleted file mode 100644 --- a/charts/tesor/values.yaml +++ /dev/null @@ -1,78 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -replicaCount: 1 - -image: - repository: ghcr.io/dimidiumlabs/tesor - tag: "" - digest: "" - pullPolicy: IfNotPresent - -imagePullSecrets: [] -nameOverride: "" -fullnameOverride: "" - -podAnnotations: {} -podLabels: {} - -podSecurityContext: - runAsNonRoot: true - - runAsUser: 10000 - runAsGroup: 10000 - - fsGroup: 10000 - fsGroupChangePolicy: OnRootMismatch - -securityContext: - allowPrivilegeEscalation: false - capabilities: - drop: [ALL] - readOnlyRootFilesystem: true - -service: - port: 2000 - -config: - existingConfigMap: "" - appname: tesor - hostnames: [] - server: - shutdownTimeout: 60 - requestTimeout: 30 - maxBodySize: 64 MiB - maxConcurrentRequests: 512 - rateLimitPeriod: 10 - rateLimitBurstSize: 50 - backends: - go: - enabled: true - refreshInterval: 3600 - zig: - enabled: true - refreshInterval: 3600 - log: - enabled: true - level: info - format: json - extra: "" - -persistence: - enabled: true - existingClaim: "" - accessModes: [ReadWriteOnce] - size: 20Gi - storageClass: "" - -route: - enabled: false - hostnames: [] - parentRefs: [] - -resources: {} -nodeSelector: {} -tolerations: [] -affinity: {} - -terminationGracePeriodSeconds: 70 diff --git a/crates/base/Cargo.toml b/crates/base/Cargo.toml deleted file mode 100644 --- a/crates/base/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -[package] -name = "base" -version = "0.0.0" -description = "Shared types and utilities" - -authors.workspace = true -edition.workspace = true -license.workspace = true -publish.workspace = true -homepage.workspace = true -repository.workspace = true - -[dependencies] -serde.workspace = true - -[dev-dependencies] -serde_json.workspace = true diff --git a/crates/base/src/lib.rs b/crates/base/src/lib.rs deleted file mode 100644 --- a/crates/base/src/lib.rs +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Nikolay Govorov -// SPDX-License-Identifier: AGPL-3.0-or-later - -pub mod serde; - -#[derive(Debug, Clone, Copy)] -pub enum ContentType { - TextPlain, - OctetStream, - ImageXIcon, - ImagePng, - ImageSvgXml, - TextCss, - FontWoff2, - ApplicationManifestJson, -} - -impl ContentType { - pub fn as_str(&self) -> &'static str { - match self { - Self::TextPlain => "text/plain", - Self::OctetStream => "application/octet-stream", - Self::ImageXIcon => "image/x-icon", - Self::ImagePng => "image/png", - Self::ImageSvgXml => "image/svg+xml", - Self::TextCss => "text/css", - Self::FontWoff2 => "font/woff2", - Self::ApplicationManifestJson => "application/manifest+json", - } - } -} diff --git a/crates/base/src/serde.rs b/crates/base/src/serde.rs deleted file mode 100644 --- a/crates/base/src/serde.rs +++ /dev/null @@ -1,108 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Nikolay Govorov -// SPDX-License-Identifier: AGPL-3.0-or-later - -use std::net::SocketAddr; -use std::time::Duration; - -use ::serde::de::Deserialize; - -/// Deserializes a duration from seconds (u64). -pub fn deserialize_duration<'de, D>(deserializer: D) -> Result<Duration, D::Error> -where - D: ::serde::Deserializer<'de>, -{ - let secs = u64::deserialize(deserializer)?; - Ok(Duration::from_secs(secs)) -} - -/// Deserializes a SocketAddr from a string. -pub fn deserialize_listener_addr<'de, D>(deserializer: D) -> Result<SocketAddr, D::Error> -where - D: ::serde::Deserializer<'de>, -{ - let raw = String::deserialize(deserializer)?; - let raw = raw.trim(); - - // Hostnames are not supported, but localhost shorthands are useful - if let Some(port) = raw.strip_prefix("localhost:") { - return port - .parse::<u16>() - .map(|port| SocketAddr::new(std::net::Ipv4Addr::LOCALHOST.into(), port)) - .map_err(|err| ::serde::de::Error::custom(format!("invalid port in '{raw}': {err}"))); - } - - raw.parse::<SocketAddr>() - .map_err(|err| ::serde::de::Error::custom(format!("invalid address '{raw}': {err}"))) -} - -#[cfg(test)] -mod deserialize_duration_tests { - use super::*; - use ::serde::Deserialize; - - #[derive(Debug, Deserialize)] - struct DurationWrapper { - #[serde(deserialize_with = "deserialize_duration")] - value: Duration, - } - - #[test] - fn test_deserialize_duration() { - let value: DurationWrapper = serde_json::from_str(r#"{"value": 5}"#).unwrap(); - assert_eq!(value.value, Duration::from_secs(5)); - } - - #[test] - fn test_deserialize_duration_invalid_type() { - let err = serde_json::from_str::<DurationWrapper>(r#"{"value": "5"}"#).unwrap_err(); - assert!(err.to_string().contains("invalid type")); - } -} - -#[cfg(test)] -mod deserialize_listener_addr_tests { - use super::*; - use ::serde::Deserialize; - - #[derive(Debug, Deserialize)] - struct AddrWrapper { - #[serde(deserialize_with = "deserialize_listener_addr")] - value: SocketAddr, - } - - #[test] - fn test_deserialize_listener_addr_localhost() { - let value: AddrWrapper = serde_json::from_str(r#"{"value": "localhost:1234"}"#).unwrap(); - assert_eq!(value.value, "127.0.0.1:1234".parse().unwrap()); - } - - #[test] - fn test_deserialize_listener_addr_trim() { - let value: AddrWrapper = serde_json::from_str(r#"{"value": " localhost:4321 "}"#).unwrap(); - assert_eq!(value.value, "127.0.0.1:4321".parse().unwrap()); - } - - #[test] - fn test_deserialize_listener_addr_ip() { - let value: AddrWrapper = serde_json::from_str(r#"{"value": "127.0.0.1:80"}"#).unwrap(); - assert_eq!(value.value, "127.0.0.1:80".parse().unwrap()); - } - - #[test] - fn test_deserialize_listener_addr_invalid() { - let err = serde_json::from_str::<AddrWrapper>(r#"{"value": "bad"}"#).unwrap_err(); - assert!(err.to_string().contains("invalid address")); - } - - #[test] - fn test_deserialize_listener_addr_localhost_invalid_port() { - let err = serde_json::from_str::<AddrWrapper>(r#"{"value": "localhost:bad"}"#).unwrap_err(); - assert!(err.to_string().contains("invalid port")); - } - - #[test] - fn test_deserialize_listener_addr_invalid_type() { - let err = serde_json::from_str::<AddrWrapper>(r#"{"value": 1234}"#).unwrap_err(); - assert!(err.to_string().contains("invalid type")); - } -} diff --git a/crates/repos/Cargo.toml b/crates/repos/Cargo.toml deleted file mode 100644 --- a/crates/repos/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -[package] -name = "repos" -version = "0.0.0" -description = "A collection of adapters to external repositories" - -authors.workspace = true -edition.workspace = true -license.workspace = true -publish.workspace = true -homepage.workspace = true -repository.workspace = true - -[dependencies] -base.workspace = true - -async-trait.workspace = true -bytes.workspace = true -semver.workspace = true -serde.workspace = true -serde_json.workspace = true -strum.workspace = true -thiserror.workspace = true -tracing.workspace = true -url.workspace = true - -[dev-dependencies] -proptest.workspace = true diff --git a/crates/repos/src/go.rs b/crates/repos/src/go.rs deleted file mode 100644 --- a/crates/repos/src/go.rs +++ /dev/null @@ -1,518 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Nikolay Govorov -// SPDX-License-Identifier: AGPL-3.0-or-later - -use std::time::Duration; - -use serde::{Deserialize, Serialize}; -use url::Url; - -use super::*; - -#[derive(Debug, Clone, Deserialize)] -#[serde(default)] -pub struct GoConfig { - pub enabled: bool, - pub upstream: Url, - pub refresh_interval: u64, -} - -impl Default for GoConfig { - fn default() -> Self { - Self { - enabled: true, - upstream: Url::parse("https://go.dev/dl/").unwrap(), - refresh_interval: 60 * 60, - } - } -} - -impl BackendConfig for GoConfig { - fn enabled(&self) -> bool { - self.enabled - } - fn refresh_interval(&self) -> Duration { - Duration::from_secs(self.refresh_interval) - } -} - -/// Typed metadata for Go files -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct GoFileMeta { - pub kind: FileKind, -} - -/// Typed metadata for Go releases -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct GoReleaseMeta { - pub stable: bool, -} - -/// Upstream API file format (only used for parsing JSON from go.dev) -#[derive(Deserialize)] -struct UpstreamFile { - filename: String, - os: Option<String>, - arch: Option<String>, - sha256: String, - size: u64, - kind: FileKind, -} - -/// Upstream API release format (only used for parsing JSON from go.dev) -#[derive(Deserialize)] -struct UpstreamRelease { - version: String, - stable: bool, - files: Vec<UpstreamFile>, -} - -/// Go backend specification -pub struct GoSpec; - -#[async_trait::async_trait] -impl BackendSpec for GoSpec { - const ID: &'static str = "go"; - - type Config = GoConfig; - type ReleaseMeta = GoReleaseMeta; - type FileMeta = GoFileMeta; - type Filename<'a> = GoFilename<'a>; - - async fn fetch_index( - config: &Self::Config, - network: &dyn BackendNetwork, - ) -> Result<Vec<(RawRelease, Vec<RawReleaseFile>)>, BackendError> { - let mut url = config.upstream.clone(); - url.query_pairs_mut() - .append_pair("mode", "json") - .append_pair("include", "all"); - - let bytes = network.http_get(&url).await?; - let upstream: Vec<UpstreamRelease> = - serde_json::from_slice(&bytes).map_err(|e| BackendError::Upstream(e.to_string()))?; - - let mut releases = Vec::with_capacity(upstream.len()); - for u in upstream { - let sort_key = match GoVersion::parse(&u.version) { - Ok(v) => v.sort_key(), - Err(_) => { - tracing::error!(version = u.version, "invalid go version, skipping"); - continue; - } - }; - - let release: Release<GoReleaseMeta> = Release { - backend: Self::ID.to_string(), - version: u.version.clone(), - sort_key, - meta: GoReleaseMeta { stable: u.stable }, - }; - - let files: Vec<RawReleaseFile> = u - .files - .iter() - .map(|f| { - let file: ReleaseFile<GoFileMeta> = ReleaseFile { - backend: Self::ID.to_string(), - version: u.version.clone(), - filename: f.filename.clone(), - checksum: f.sha256.clone(), - size: f.size as i64, - os: f.os.as_ref().and_then(|s| s.parse().ok()), - arch: f.arch.as_ref().and_then(|s| s.parse().ok()), - meta: GoFileMeta { kind: f.kind }, - }; - file.to_raw() - }) - .collect(); - - releases.push((release.to_raw(), files)); - } - - Ok(releases) - } -} - -/// Type alias for Go backend -pub type GoBackend = Backend<GoSpec>; - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -enum ReleaseType { - Stable, - ReleaseCandidate(u64), - Beta(u64), -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GoVersion { - major: u64, - minor: u64, - patch: Option<u64>, - release_type: ReleaseType, -} - -impl GoVersion { - /// Parses version string like "go1", "go1.22.3", "go1.23rc1", or "go1.9.2rc2". - fn parse(s: &str) -> Result<Self, BackendError> { - let s = s.strip_prefix("go").ok_or(BackendError::NotFound)?; - let parts: Vec<&str> = s.split('.').collect(); - let (version, consumed) = Self::from_parts(&parts)?; - if consumed != parts.len() { - return Err(BackendError::NotFound); - } - Ok(version) - } - - /// Parses version from dot-separated parts, returns (version, parts_consumed). - fn from_parts(parts: &[&str]) -> Result<(Self, usize), BackendError> { - let major = parts - .first() - .ok_or(BackendError::NotFound)? - .parse() - .map_err(|_| BackendError::NotFound)?; - - let Some(minor_str) = parts.get(1) else { - return Ok(( - Self { - major, - minor: 0, - patch: None, - release_type: ReleaseType::Stable, - }, - 1, - )); - }; - let (minor, minor_release) = Self::parse_minor_with_release(minor_str)?; - - let Some(patch_str) = parts.get(2) else { - return Ok(( - Self { - major, - minor, - patch: None, - release_type: minor_release, - }, - 2, - )); - }; - if let Ok((p, patch_release)) = Self::parse_version_part(patch_str) { - Ok(( - Self { - major, - minor, - patch: Some(p), - release_type: patch_release.unwrap_or(minor_release), - }, - 3, - )) - } else { - Ok(( - Self { - major, - minor, - patch: None, - release_type: minor_release, - }, - 2, - )) - } - } - - fn sort_key(&self) -> i64 { - let vtype = match self.release_type { - ReleaseType::Beta(n) => super::VersionType::Beta(n), - ReleaseType::ReleaseCandidate(n) => super::VersionType::Rc(n), - ReleaseType::Stable => super::VersionType::Stable, - }; - super::stable_version(self.major, self.minor, self.patch.unwrap_or(0), vtype) - } - - /// Parses a version part (number with optional rc/beta suffix). - /// "25" -> (25, None) - /// "2rc2" -> (2, Some(ReleaseCandidate(2))) - /// "1beta1" -> (1, Some(Beta(1))) - fn parse_version_part(s: &str) -> Result<(u64, Option<ReleaseType>), BackendError> { - if let Some(idx) = s.find("rc") { - let num = s[..idx] - .parse::<u64>() - .map_err(|_| BackendError::NotFound)?; - let rc_num = s[idx + 2..] - .parse::<u64>() - .map_err(|_| BackendError::NotFound)?; - return Ok((num, Some(ReleaseType::ReleaseCandidate(rc_num)))); - } - if let Some(idx) = s.find("beta") { - let num = s[..idx] - .parse::<u64>() - .map_err(|_| BackendError::NotFound)?; - let beta_num = s[idx + 4..] - .parse::<u64>() - .map_err(|_| BackendError::NotFound)?; - return Ok((num, Some(ReleaseType::Beta(beta_num)))); - } - let num = s.parse::<u64>().map_err(|_| BackendError::NotFound)?; - Ok((num, None)) - } - - /// Parses minor version with possible release type suffix. - /// "25" -> (25, Stable) - /// "26rc2" -> (26, ReleaseCandidate(2)) - /// "26beta1" -> (26, Beta(1)) - fn parse_minor_with_release(s: &str) -> Result<(u64, ReleaseType), BackendError> { - let (num, release) = GoVersion::parse_version_part(s)?; - Ok((num, release.unwrap_or(ReleaseType::Stable))) - } -} - -#[cfg(test)] -mod tests_go_version { - use super::*; - - #[test] - fn test_parse_go1() { - let v = GoVersion::parse("go1").unwrap(); - assert_eq!(v.major, 1); - assert_eq!(v.minor, 0); - assert_eq!(v.patch, None); - assert!(matches!(v.release_type, ReleaseType::Stable)); - } - - #[test] - fn test_parse_patch_rc() { - let v = GoVersion::parse("go1.9.2rc2").unwrap(); - assert_eq!(v.major, 1); - assert_eq!(v.minor, 9); - assert_eq!(v.patch, Some(2)); - assert!(matches!(v.release_type, ReleaseType::ReleaseCandidate(2))); - } - - #[test] - fn test_no_collision_go19_and_go192rc2() { - let v1 = GoVersion::parse("go1.9").unwrap(); - let v2 = GoVersion::parse("go1.9.2rc2").unwrap(); - assert_ne!(v1.sort_key(), v2.sort_key()); - // go1.9 (stable) should sort before go1.9.2rc2 - assert!(v1.sort_key() < v2.sort_key()); - } -} - -/// Describes a single file stored at `dl.google.com/go/`. -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GoFilename<'a> { - filename: &'a str, - version: GoVersion, - os: Option<&'a str>, - arch: Option<&'a str>, - kind: FileKind, - archive: Archive, - sha256: bool, -} - -impl<'a> BackendFilename<'a, GoConfig> for GoFilename<'a> { - fn parse(filename: &'a str) -> Result<Self, BackendError> { - let mut buffer = filename; - let mut sha256 = false; - let archive; - - // Strip "go" prefix - buffer = buffer.strip_prefix("go").ok_or(BackendError::NotFound)?; - - // Check for .sha256 suffix - if let Some(it) = buffer.strip_suffix(".sha256") { - buffer = it; - sha256 = true; - } - - // Determine archive type - if let Some(it) = buffer.strip_suffix(".tar.gz") { - buffer = it; - archive = Archive::TarGz; - } else if let Some(it) = buffer.strip_suffix(".zip") { - buffer = it; - archive = Archive::Zip; - } else if let Some(it) = buffer.strip_suffix(".msi") { - buffer = it; - archive = Archive::Msi; - } else if let Some(it) = buffer.strip_suffix(".pkg") { - buffer = it; - archive = Archive::Pkg; - } else { - return Err(BackendError::NotFound); - } - - if buffer.is_empty() { - return Err(BackendError::NotFound); - } - - // Split by dots: "1.25.6.linux-amd64" -> ["1", "25", "6", "linux-amd64"] - let parts: Vec<&str> = buffer.split('.').collect(); - if parts.len() < 3 { - return Err(BackendError::NotFound); - } - - // Parse version, get how many parts were consumed - let (version, consumed) = GoVersion::from_parts(&parts)?; - - // Remainder must exist and be either "src" or "os-arch" - let remainder = parts.get(consumed).ok_or(BackendError::NotFound)?; - let (os, arch, kind) = if *remainder == "src" { - (None, None, FileKind::Source) - } else if let Some((os, arch)) = remainder.split_once('-') { - let kind = match archive { - Archive::Msi | Archive::Pkg => FileKind::Installer, - _ => FileKind::Archive, - }; - (Some(os), Some(arch), kind) - } else { - return Err(BackendError::NotFound); - }; - - Ok(GoFilename { - filename, - version, - os, - arch, - kind, - archive, - sha256, - }) - } - - fn upstream_url(&self, config: &GoConfig, source: &str) -> Result<Url, BackendError> { - let mut url = config.upstream.clone(); - url.path_segments_mut() - .map_err(|()| BackendError::Internal("cannot build upstream URL".into()))? - .pop_if_empty() - .push(self.filename); - url.query_pairs_mut().append_pair("source", source); - Ok(url) - } - - fn is_sha256(&self) -> bool { - self.sha256 - } -} - -#[cfg(test)] -mod tests_go_filename { - use super::*; - - #[test] - fn test_parse_stable_binary() { - let t = GoFilename::parse("go1.25.6.linux-amd64.tar.gz").unwrap(); - assert_eq!(t.version.major, 1); - assert_eq!(t.version.minor, 25); - assert_eq!(t.version.patch, Some(6)); - assert!(matches!(t.version.release_type, ReleaseType::Stable)); - assert_eq!(t.os, Some("linux")); - assert_eq!(t.arch, Some("amd64")); - assert!(matches!(t.kind, FileKind::Archive)); - assert_eq!(t.archive, Archive::TarGz); - assert!(!t.sha256); - } - - #[test] - fn test_parse_first_minor_release() { - let t = GoFilename::parse("go1.25.linux-amd64.tar.gz").unwrap(); - assert_eq!(t.version.major, 1); - assert_eq!(t.version.minor, 25); - assert_eq!(t.version.patch, None); - assert!(matches!(t.version.release_type, ReleaseType::Stable)); - } - - #[test] - fn test_parse_rc() { - let t = GoFilename::parse("go1.26rc2.linux-amd64.tar.gz").unwrap(); - assert_eq!(t.version.major, 1); - assert_eq!(t.version.minor, 26); - assert_eq!(t.version.patch, None); - assert!(matches!( - t.version.release_type, - ReleaseType::ReleaseCandidate(2) - )); - } - - #[test] - fn test_parse_beta() { - let t = GoFilename::parse("go1.26beta1.darwin-arm64.tar.gz").unwrap(); - assert_eq!(t.version.major, 1); - assert_eq!(t.version.minor, 26); - assert!(matches!(t.version.release_type, ReleaseType::Beta(1))); - } - - #[test] - fn test_parse_source() { - let t = GoFilename::parse("go1.25.6.src.tar.gz").unwrap(); - assert!(matches!(t.kind, FileKind::Source)); - assert_eq!(t.os, None); - assert_eq!(t.arch, None); - assert_eq!(t.version.patch, Some(6)); - } - - #[test] - fn test_parse_windows_zip() { - let t = GoFilename::parse("go1.25.6.windows-amd64.zip").unwrap(); - assert_eq!(t.archive, Archive::Zip); - assert_eq!(t.os, Some("windows")); - assert_eq!(t.arch, Some("amd64")); - assert!(matches!(t.kind, FileKind::Archive)); - } - - #[test] - fn test_parse_msi() { - let t = GoFilename::parse("go1.25.6.windows-amd64.msi").unwrap(); - assert_eq!(t.archive, Archive::Msi); - assert!(matches!(t.kind, FileKind::Installer)); - } - - #[test] - fn test_parse_pkg() { - let t = GoFilename::parse("go1.25.6.darwin-arm64.pkg").unwrap(); - assert_eq!(t.archive, Archive::Pkg); - assert!(matches!(t.kind, FileKind::Installer)); - } - - #[test] - fn test_parse_sha256() { - let t = GoFilename::parse("go1.25.6.linux-amd64.tar.gz.sha256").unwrap(); - assert!(t.sha256); - assert_eq!(t.archive, Archive::TarGz); - assert_eq!(t.version.patch, Some(6)); - } - - #[test] - fn test_upstream_url() { - let t = GoFilename::parse("go1.25.6.linux-amd64.tar.gz").unwrap(); - let config = GoConfig { - upstream: Url::parse("https://dl.google.com/go/").unwrap(), - ..Default::default() - }; - let url = t.upstream_url(&config, "tesor:test").unwrap(); - assert_eq!( - url.as_str(), - "https://dl.google.com/go/go1.25.6.linux-amd64.tar.gz?source=tesor%3Atest" - ); - } - - #[test] - fn test_parse_patch_rc() { - let t = GoFilename::parse("go1.9.2rc2.linux-amd64.tar.gz").unwrap(); - assert_eq!(t.version.major, 1); - assert_eq!(t.version.minor, 9); - assert_eq!(t.version.patch, Some(2)); - assert!(matches!( - t.version.release_type, - ReleaseType::ReleaseCandidate(2) - )); - } - - #[test] - fn test_invalid_prefix() { - assert!(GoFilename::parse("rust1.25.6.linux-amd64.tar.gz").is_err()); - } - - #[test] - fn test_invalid_extension() { - assert!(GoFilename::parse("go1.25.6.linux-amd64.tar.bz2").is_err()); - } -} diff --git a/crates/repos/src/lib.rs b/crates/repos/src/lib.rs deleted file mode 100644 --- a/crates/repos/src/lib.rs +++ /dev/null @@ -1,679 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Nikolay Govorov -// SPDX-License-Identifier: AGPL-3.0-or-later - -pub mod go; -pub mod zig; - -use std::collections::HashMap; -use std::sync::Arc; -use std::time::Duration; - -use async_trait::async_trait; -use bytes::Bytes; -use serde::{Deserialize, Serialize, de::DeserializeOwned}; -use thiserror::Error; -use url::Url; - -pub use base::ContentType; -pub use go::{GoBackend, GoConfig}; -pub use zig::{ZigBackend, ZigConfig}; - -/// Backend operation error. -#[derive(Debug, Clone, Error)] -pub enum BackendError { - /// Resource not found - #[error("not found")] - NotFound, - - /// Upstream network error - #[error("network: {0}")] - Network(String), - - /// Internal storage error - #[error("storage: {0}")] - Storage(String), - - /// Malformed data from upstream - #[error("upstream: {0}")] - Upstream(String), - - /// Internal logic error - #[error("internal: {0}")] - Internal(String), -} - -/// Operating system -#[derive( - Debug, - Clone, - Copy, - PartialEq, - Eq, - Serialize, - Deserialize, - strum::Display, - strum::EnumString, - strum::AsRefStr, -)] -#[serde(rename_all = "lowercase")] -#[strum(serialize_all = "lowercase")] -pub enum Os { - Linux, - Windows, - Darwin, - #[serde(alias = "macos")] - Macos, - Freebsd, - Netbsd, - Openbsd, - Illumos, - Plan9, - Aix, - Solaris, - Dragonfly, - Android, - Ios, - Js, - Wasip1, - Wasi, -} - -/// CPU architecture -#[derive( - Debug, - Clone, - Copy, - PartialEq, - Eq, - Serialize, - Deserialize, - strum::Display, - strum::EnumString, - strum::AsRefStr, -)] -#[serde(rename_all = "lowercase")] -#[strum(serialize_all = "lowercase")] -pub enum Arch { - Amd64, - #[serde(alias = "x86_64")] - X86_64, - Arm64, - #[serde(alias = "aarch64")] - Aarch64, - #[serde(rename = "386")] - #[strum(serialize = "386")] - I386, - Arm, - Armv6l, - Armv7a, - Loong64, - Mips, - Mips64, - Mips64le, - Mipsle, - Ppc64, - Ppc64le, - Riscv64, - S390x, - Wasm32, - Powerpc, - Powerpc64, - Powerpc64le, -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum Archive { - TarGz, - TarXz, - Zip, - Msi, - Pkg, -} - -#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(rename_all = "lowercase")] -pub enum FileKind { - Source, - Bootstrap, - Archive, - Installer, -} - -/// Version type for ordering. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum VersionType { - Stable, - Rc(u64), - Beta(u64), - Dev(u64), -} - -/// Result of resolving a file request. -pub enum ResolvedFile { - /// Proxy request to upstream URL - Upstream { mime: ContentType, url: Url }, - /// Return content directly - Content { - mime: ContentType, - data: bytes::Bytes, - }, -} - -/// Release entry with typed metadata -#[derive(Debug, Clone)] -pub struct Release<M> { - pub backend: String, - pub version: String, - pub sort_key: i64, - pub meta: M, -} - -/// Type alias for storage (untyped meta) -pub type RawRelease = Release<Option<serde_json::Value>>; - -impl<M: Serialize> Release<M> { - pub fn to_raw(&self) -> RawRelease { - Release { - backend: self.backend.clone(), - version: self.version.clone(), - sort_key: self.sort_key, - meta: Some(serde_json::to_value(&self.meta).expect("meta serialization")), - } - } -} - -impl RawRelease { - pub fn try_into_typed<M: DeserializeOwned>(self) -> Result<Release<M>, BackendError> { - let meta = self - .meta - .ok_or_else(|| BackendError::Internal("missing release meta".into()))?; - let meta = serde_json::from_value(meta) - .map_err(|e| BackendError::Internal(format!("release meta: {e}")))?; - Ok(Release { - backend: self.backend, - version: self.version, - sort_key: self.sort_key, - meta, - }) - } -} - -/// Release file entry with typed metadata -#[derive(Debug, Clone)] -pub struct ReleaseFile<M> { - pub backend: String, - pub version: String, - pub filename: String, - pub checksum: String, - pub size: i64, - pub os: Option<Os>, - pub arch: Option<Arch>, - pub meta: M, -} - -/// Type alias for storage (untyped meta) -pub type RawReleaseFile = ReleaseFile<Option<serde_json::Value>>; - -impl<M: Serialize> ReleaseFile<M> { - pub fn to_raw(&self) -> RawReleaseFile { - ReleaseFile { - backend: self.backend.clone(), - version: self.version.clone(), - filename: self.filename.clone(), - checksum: self.checksum.clone(), - size: self.size, - os: self.os, - arch: self.arch, - meta: Some(serde_json::to_value(&self.meta).expect("meta serialization")), - } - } -} - -impl RawReleaseFile { - pub fn try_into_typed<M: DeserializeOwned>(self) -> Result<ReleaseFile<M>, BackendError> { - let meta = self - .meta - .ok_or_else(|| BackendError::Internal("missing file meta".into()))?; - let meta = serde_json::from_value(meta) - .map_err(|e| BackendError::Internal(format!("file meta: {e}")))?; - Ok(ReleaseFile { - backend: self.backend, - version: self.version, - filename: self.filename, - checksum: self.checksum, - size: self.size, - os: self.os, - arch: self.arch, - meta, - }) - } -} - -/// Release view for display (version + metadata + files) -#[derive(Debug, Clone)] -pub struct ReleaseView<M, F> { - pub version: String, - pub meta: M, - pub files: Vec<F>, -} - -/// Trait for backend configuration with common fields. -pub trait BackendConfig { - fn enabled(&self) -> bool; - fn refresh_interval(&self) -> Duration; -} - -/// Trait for parsing filenames and handling checksums/signatures. -pub trait BackendFilename<'a, C>: Sized { - /// Backend-specific signature suffix (e.g., ".minisig"). - /// SHA256 is handled automatically by the base. - const SIGNATURE_SUFFIX: Option<&'static str> = None; - - fn parse(filename: &'a str) -> Result<Self, BackendError>; - - fn upstream_url(&self, config: &C, source: &str) -> Result<Url, BackendError>; - - /// Is this a .sha256 checksum file? - fn is_sha256(&self) -> bool; - - /// Is this a signature file (minisig, gpg)? - fn is_signature(&self) -> bool { - false - } - - /// Can bypass index check? (for dev builds) - fn can_bypass_index(&self) -> bool { - false - } - - /// Get signature content from file meta (not sha256) - fn signature_content(&self, _file: &RawReleaseFile) -> Option<Bytes> { - None - } -} - -/// Storage interface for backend version/file index -#[async_trait] -pub trait BackendStorage: Send + Sync { - /// Query versions by backend, ordered by sort_key. - async fn query_releases(&self, backend: &str) -> Result<Vec<RawRelease>, BackendError>; - - /// Insert or update releases with their files in a single transaction. - async fn insert_releases( - &self, - releases: &[(RawRelease, Vec<RawReleaseFile>)], - ) -> Result<(), BackendError>; - - /// Query files by backend with optional filters. - async fn query_files( - &self, - backend: &str, - version: Option<&str>, - filename: Option<&str>, - meta_null_field: Option<&str>, - ) -> Result<Vec<RawReleaseFile>, BackendError>; - - /// Update file metadata (e.g. after fetching a signature). - async fn update_file_meta(&self, file: &RawReleaseFile) -> Result<bool, BackendError>; -} - -/// Delegate provides I/O primitives to backends. -#[async_trait] -pub trait BackendNetwork: Send + Sync { - /// HTTP GET request - async fn http_get(&self, url: &Url) -> Result<Bytes, BackendError>; -} - -/// Trait for backend-specific types and methods. -#[async_trait] -pub trait BackendSpec: Send + Sync + 'static { - /// Fixed unique identifier for storage - const ID: &'static str; - - /// Meta field where signature is stored (for query_files with meta_null_field) - /// None = signatures not supported by this backend - const SIGNATURE_META_FIELD: Option<&'static str> = None; - - type Config: BackendConfig + Send + Sync; - type Filename<'a>: BackendFilename<'a, Self::Config> + Send; - - type FileMeta: DeserializeOwned; - type ReleaseMeta: DeserializeOwned; - - /// Fetch release index from upstream and convert to storage format - async fn fetch_index( - config: &Self::Config, - network: &dyn BackendNetwork, - ) -> Result<Vec<(RawRelease, Vec<RawReleaseFile>)>, BackendError>; - - /// Fetch signature for a file and return updated file - async fn fetch_signature( - _file: &RawReleaseFile, - _config: &Self::Config, - _source: &str, - _network: &dyn BackendNetwork, - ) -> Result<RawReleaseFile, BackendError> { - unimplemented!("fetch_signature unimplemented"); // default: not supported - } -} - -/// Generic backend implementation -pub struct Backend<S: BackendSpec> { - pub config: S::Config, - pub source: String, - pub storage: Arc<dyn BackendStorage>, - pub network: Arc<dyn BackendNetwork>, -} - -impl<S: BackendSpec> Backend<S> { - pub fn new( - config: S::Config, - source: String, - storage: Arc<dyn BackendStorage>, - network: Arc<dyn BackendNetwork>, - ) -> Self { - Self { - config, - source, - storage, - network, - } - } - - pub fn enabled(&self) -> bool { - self.config.enabled() - } - - pub fn refresh_interval(&self) -> Duration { - self.config.refresh_interval() - } - - /// Fetch index from upstream and store in DB - pub async fn refresh(&self) -> Result<(), BackendError> { - let releases = S::fetch_index(&self.config, &*self.network).await?; - - self.storage.insert_releases(&releases).await?; - - // Fetch signatures if supported - if let Some(field) = S::SIGNATURE_META_FIELD { - let files = self - .storage - .query_files(S::ID, None, None, Some(field)) - .await?; - - for file in files { - match S::fetch_signature(&file, &self.config, &self.source, &*self.network).await { - Ok(updated) => { - if let Err(e) = self.storage.update_file_meta(&updated).await { - tracing::debug!( - filename = file.filename, - "failed to store signature: {e}" - ); - } - } - Err(e) => { - tracing::debug!(filename = file.filename, "failed to fetch signature: {e}"); - } - } - } - } - - Ok(()) - } - - /// Load releases from DB - pub async fn get_releases( - &self, - ) -> Result<Vec<ReleaseView<S::ReleaseMeta, ReleaseFile<S::FileMeta>>>, BackendError> { - let raw_releases = self.storage.query_releases(S::ID).await?; - let raw_files = self.storage.query_files(S::ID, None, None, None).await?; - - let mut files_by_version: HashMap<String, Vec<ReleaseFile<S::FileMeta>>> = HashMap::new(); - for raw_file in raw_files { - if let Ok(file) = raw_file.try_into_typed::<S::FileMeta>() { - files_by_version - .entry(file.version.clone()) - .or_default() - .push(file); - } - } - - let releases = raw_releases - .into_iter() - .filter_map(|raw| { - let typed: Release<S::ReleaseMeta> = raw.try_into_typed().ok()?; - let files = files_by_version.remove(&typed.version).unwrap_or_default(); - Some(ReleaseView { - version: typed.version, - meta: typed.meta, - files, - }) - }) - .collect(); - - Ok(releases) - } - - /// Resolves filename to upstream URL or direct content - pub async fn resolve_file(&self, filename: &str) -> Result<ResolvedFile, BackendError> { - let parsed = S::Filename::parse(filename)?; - - let is_checksum_or_sig = parsed.is_sha256() || parsed.is_signature(); - let mime = if is_checksum_or_sig { - ContentType::TextPlain - } else { - ContentType::OctetStream - }; - - let url = parsed.upstream_url(&self.config, &self.source)?; - - // Strip suffix to get base filename - let base = filename - .strip_suffix(".sha256") - .or_else(|| { - <S::Filename<'_> as BackendFilename<'_, S::Config>>::SIGNATURE_SUFFIX - .and_then(|s| filename.strip_suffix(s)) - }) - .unwrap_or(filename); - - let files = self - .storage - .query_files(S::ID, None, Some(base), None) - .await?; - - let Some(file) = files.into_iter().next() else { - return if parsed.can_bypass_index() { - Ok(ResolvedFile::Upstream { url, mime }) - } else { - Err(BackendError::NotFound) - }; - }; - - // SHA256 — universal, always in file.checksum - if parsed.is_sha256() { - return Ok(ResolvedFile::Content { - mime, - data: file.checksum.clone().into(), - }); - } - - // Signature — backend supports it, may or may not be indexed - if parsed.is_signature() { - if let Some(data) = parsed.signature_content(&file) { - return Ok(ResolvedFile::Content { mime, data }); - } - // Not indexed yet, proxy to upstream - return Ok(ResolvedFile::Upstream { url, mime }); - } - - Ok(ResolvedFile::Upstream { url, mime }) - } -} - -/// Computes numeric sort key for correct version ordering. -/// -/// Formula: major × 10^12 + minor × 10^9 + patch × 10^6 + type × 10^4 + num -/// Where type: dev=10, beta=25, rc=50, stable=99 -/// -/// Examples: -/// - 1.21.3 stable → 1_021_003_990_000 -/// - 1.22.0 beta(1) → 1_022_000_250_001 -/// - 1.22.0 rc(2) → 1_022_000_500_002 -/// - 0.13.0 dev(1234) → 0_013_000_101_234 -pub fn stable_version(major: u64, minor: u64, patch: u64, vtype: VersionType) -> i64 { - let (type_val, num) = match vtype { - VersionType::Stable => (99, 0), - VersionType::Rc(n) => (50, n), - VersionType::Beta(n) => (25, n), - VersionType::Dev(n) => (10, n), - }; - - (major as i64) * 1_000_000_000_000 - + (minor as i64) * 1_000_000_000 - + (patch as i64) * 1_000_000 - + (type_val as i64) * 10_000 - + (num as i64) -} - -#[cfg(test)] -mod tests { - use super::*; - use std::collections::HashSet; - - use proptest::prelude::*; - - #[test] - fn test_stable_version_ordering() { - // dev < beta < rc < stable - let dev = stable_version(1, 0, 0, VersionType::Dev(1)); - let beta = stable_version(1, 0, 0, VersionType::Beta(1)); - let rc = stable_version(1, 0, 0, VersionType::Rc(1)); - let stable = stable_version(1, 0, 0, VersionType::Stable); - - assert!(dev < beta); - assert!(beta < rc); - assert!(rc < stable); - } - - #[test] - fn test_stable_version_patch_ordering() { - let v1_0_0 = stable_version(1, 0, 0, VersionType::Stable); - let v1_0_1 = stable_version(1, 0, 1, VersionType::Stable); - let v1_1_0 = stable_version(1, 1, 0, VersionType::Stable); - let v2_0_0 = stable_version(2, 0, 0, VersionType::Stable); - - assert!(v1_0_0 < v1_0_1); - assert!(v1_0_1 < v1_1_0); - assert!(v1_1_0 < v2_0_0); - } - - #[test] - fn test_stable_version_rc_before_stable() { - // 1.22.0-rc1 < 1.22.0-rc2 < 1.22.0 - let rc1 = stable_version(1, 22, 0, VersionType::Rc(1)); - let rc2 = stable_version(1, 22, 0, VersionType::Rc(2)); - let stable = stable_version(1, 22, 0, VersionType::Stable); - - assert!(rc1 < rc2); - assert!(rc2 < stable); - } - - #[test] - fn test_stable_version_no_collisions() { - let mut keys = HashSet::new(); - - // Test a range of realistic versions - for major in 0..3 { - for minor in 0..30 { - for patch in 0..20 { - let key = stable_version(major, minor, patch, VersionType::Stable); - assert!(keys.insert(key), "collision at {major}.{minor}.{patch}"); - } - // Also test pre-release versions - for n in 1..10 { - let rc = stable_version(major, minor, 0, VersionType::Rc(n)); - assert!(keys.insert(rc), "collision at {major}.{minor}.0-rc{n}"); - - let beta = stable_version(major, minor, 0, VersionType::Beta(n)); - assert!(keys.insert(beta), "collision at {major}.{minor}.0-beta{n}"); - - let dev = stable_version(major, minor, 0, VersionType::Dev(n)); - assert!(keys.insert(dev), "collision at {major}.{minor}.0-dev{n}"); - } - } - } - } - - #[test] - fn test_stable_version_expected_values() { - // Verify the documented examples - assert_eq!( - stable_version(1, 21, 3, VersionType::Stable), - 1_021_003_990_000 - ); - assert_eq!( - stable_version(1, 22, 0, VersionType::Beta(1)), - 1_022_000_250_001 - ); - assert_eq!( - stable_version(1, 22, 0, VersionType::Rc(2)), - 1_022_000_500_002 - ); - assert_eq!( - stable_version(0, 13, 0, VersionType::Dev(1234)), - 13_000_101_234 - ); - } - - fn version_type_strategy() -> impl Strategy<Value = VersionType> { - prop_oneof![ - Just(VersionType::Stable), - (1..100u64).prop_map(VersionType::Rc), - (1..100u64).prop_map(VersionType::Beta), - (1..9999u64).prop_map(VersionType::Dev), - ] - } - - fn to_semver(major: u64, minor: u64, patch: u64, vtype: VersionType) -> semver::Version { - let pre = match vtype { - VersionType::Stable => semver::Prerelease::EMPTY, - VersionType::Rc(n) => semver::Prerelease::new(&format!("rc.{n}")).unwrap(), - VersionType::Beta(n) => semver::Prerelease::new(&format!("beta.{n}")).unwrap(), - VersionType::Dev(n) => semver::Prerelease::new(&format!("dev.{n}")).unwrap(), - }; - semver::Version { - major, - minor, - patch, - pre, - build: semver::BuildMetadata::EMPTY, - } - } - - proptest! { - #[test] - fn fuzz_stable_version_matches_semver( - major1 in 0..100u64, - minor1 in 0..1000u64, - patch1 in 0..1000u64, - vtype1 in version_type_strategy(), - major2 in 0..100u64, - minor2 in 0..1000u64, - patch2 in 0..1000u64, - vtype2 in version_type_strategy(), - ) { - let key1 = stable_version(major1, minor1, patch1, vtype1); - let key2 = stable_version(major2, minor2, patch2, vtype2); - - let sem1 = to_semver(major1, minor1, patch1, vtype1); - let sem2 = to_semver(major2, minor2, patch2, vtype2); - - let key_cmp = key1.cmp(&key2); - let sem_cmp = sem1.cmp(&sem2); - - prop_assert_eq!(key_cmp, sem_cmp, - "Mismatch: {} vs {}: stable_version gives {:?}, semver gives {:?}", - sem1, sem2, key_cmp, sem_cmp); - } - } -} diff --git a/crates/repos/src/zig.rs b/crates/repos/src/zig.rs deleted file mode 100644 --- a/crates/repos/src/zig.rs +++ /dev/null @@ -1,519 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Nikolay Govorov -// SPDX-License-Identifier: AGPL-3.0-or-later - -use std::collections::HashMap; -use std::time::Duration; - -use semver::Version as SemVersion; -use serde::de::{self, Visitor}; -use serde::{Deserialize, Serialize}; -use url::Url; - -use bytes::Bytes; - -use super::*; - -#[derive(Debug, Clone, Deserialize)] -#[serde(default)] -pub struct ZigConfig { - pub enabled: bool, - pub upstream: Url, - pub refresh_interval: u64, -} - -impl Default for ZigConfig { - fn default() -> Self { - Self { - enabled: true, - upstream: Url::parse("https://ziglang.org").unwrap(), - refresh_interval: 60 * 60, - } - } -} - -impl BackendConfig for ZigConfig { - fn enabled(&self) -> bool { - self.enabled - } - fn refresh_interval(&self) -> Duration { - Duration::from_secs(self.refresh_interval) - } -} - -/// Deserializes a u64 from either a number or a string. -fn deserialize_size<'de, D>(deserializer: D) -> Result<u64, D::Error> -where - D: serde::Deserializer<'de>, -{ - struct SizeVisitor; - impl<'de> Visitor<'de> for SizeVisitor { - type Value = u64; - - fn expecting(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str("a number or string") - } - - fn visit_u64<E: de::Error>(self, v: u64) -> Result<Self::Value, E> { - Ok(v) - } - - fn visit_str<E: de::Error>(self, v: &str) -> Result<Self::Value, E> { - v.parse().map_err(de::Error::custom) - } - } - - deserializer.deserialize_any(SizeVisitor) -} - -/// Typed metadata for Zig files -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct ZigFileMeta { - pub target: String, - - #[serde(default, skip_serializing_if = "Option::is_none")] - pub minisig: Option<String>, -} - -/// Typed metadata for Zig releases (stored in DB) -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct ZigReleaseMeta { - pub date: Option<String>, - pub docs: Option<String>, - #[serde(alias = "stdDocs")] - pub std_docs: Option<String>, - pub notes: Option<String>, -} - -/// Upstream API tarball format (only used for parsing JSON from ziglang.org) -#[derive(Deserialize)] -struct UpstreamFile { - #[serde(alias = "tarball")] - filename: String, - shasum: String, - #[serde(deserialize_with = "deserialize_size")] - size: u64, -} - -/// Upstream API release format (only used for parsing JSON from ziglang.org) -#[derive(Deserialize)] -#[allow(dead_code)] -struct UpstreamRelease { - #[serde(flatten)] - meta: ZigReleaseMeta, - /// Present only in the "master" entry - version: Option<String>, - src: Option<UpstreamFile>, - bootstrap: Option<UpstreamFile>, - #[serde(flatten)] - targets: HashMap<String, UpstreamFile>, -} - -/// Zig file with metadata -pub type ZigFile = ReleaseFile<ZigFileMeta>; - -impl ZigFile { - fn from_upstream( - version: &str, - target: &str, - tarball: &UpstreamFile, - ) -> Option<RawReleaseFile> { - let url = Url::parse(&tarball.filename).ok()?; - let filename = url - .path_segments() - .and_then(|mut s| s.next_back()) - .filter(|s| !s.is_empty())?; - - let parsed = ZigFilename::parse(filename).ok()?; - - let file: ReleaseFile<ZigFileMeta> = ReleaseFile { - backend: ZigSpec::ID.to_string(), - version: version.to_string(), - filename: filename.to_string(), - checksum: tarball.shasum.clone(), - size: tarball.size as i64, - os: parsed.os.and_then(|s| s.parse().ok()), - arch: parsed.arch.and_then(|s| s.parse().ok()), - meta: ZigFileMeta { - minisig: None, - target: target.to_string(), - }, - }; - Some(file.to_raw()) - } -} - -/// Zig backend specification -pub struct ZigSpec; - -#[async_trait::async_trait] -impl BackendSpec for ZigSpec { - const ID: &'static str = "zig"; - const SIGNATURE_META_FIELD: Option<&'static str> = Some("minisig"); - - type Config = ZigConfig; - type ReleaseMeta = ZigReleaseMeta; - type FileMeta = ZigFileMeta; - type Filename<'a> = ZigFilename<'a>; - - async fn fetch_index( - config: &Self::Config, - network: &dyn BackendNetwork, - ) -> Result<Vec<(RawRelease, Vec<RawReleaseFile>)>, BackendError> { - let mut url = config.upstream.clone(); - url.path_segments_mut() - .map_err(|_| BackendError::Internal("cannot-be-a-base URL".into()))? - .pop_if_empty() - .extend(["download", "index.json"]); - - let bytes = network.http_get(&url).await?; - let map: HashMap<String, UpstreamRelease> = - serde_json::from_slice(&bytes).map_err(|e| BackendError::Upstream(e.to_string()))?; - - let mut releases = Vec::with_capacity(map.len()); - for (version_str, upstream) in map { - let sort_key = match ZigVersion::parse(&version_str) { - Ok(v) => v.sort_key(), - Err(e) => { - tracing::error!(version = version_str, "invalid zig version, skipping: {e}"); - continue; - } - }; - - let release: Release<ZigReleaseMeta> = Release { - backend: Self::ID.to_string(), - version: version_str.to_string(), - sort_key, - meta: upstream.meta.clone(), - }; - - let mut files = Vec::new(); - - if let Some(ref tarball) = upstream.src - && let Some(f) = ZigFile::from_upstream(&version_str, "src", tarball) - { - files.push(f); - } - if let Some(ref tarball) = upstream.bootstrap - && let Some(f) = ZigFile::from_upstream(&version_str, "bootstrap", tarball) - { - files.push(f); - } - for (target, tarball) in &upstream.targets { - if let Some(f) = ZigFile::from_upstream(&version_str, target, tarball) { - files.push(f); - } - } - - releases.push((release.to_raw(), files)); - } - - Ok(releases) - } - - async fn fetch_signature( - file: &RawReleaseFile, - config: &Self::Config, - source: &str, - network: &dyn BackendNetwork, - ) -> Result<RawReleaseFile, BackendError> { - let minisig_filename = format!("{}.minisig", file.filename); - let parsed = ZigFilename::parse(&minisig_filename) - .map_err(|_| BackendError::Internal(format!("invalid filename: {}", file.filename)))?; - - let url = parsed - .upstream_url(config, source) - .map_err(|_| BackendError::Internal("cannot build URL".into()))?; - - let bytes = network.http_get(&url).await?; - let minisig = - String::from_utf8(bytes.to_vec()).map_err(|e| BackendError::Upstream(e.to_string()))?; - - let mut typed: ReleaseFile<ZigFileMeta> = file.clone().try_into_typed()?; - typed.meta.minisig = Some(minisig); - - tracing::debug!(filename = file.filename, "cached minisig"); - Ok(typed.to_raw()) - } -} - -/// Type alias for Zig backend -pub type ZigBackend = Backend<ZigSpec>; - -/// Wrapper for sort key computation. -pub enum ZigVersion { - Master, - Semver(SemVersion), -} - -impl ZigVersion { - fn parse(s: &str) -> Result<Self, BackendError> { - if s == "master" { - return Ok(Self::Master); - } - SemVersion::parse(s) - .map(Self::Semver) - .map_err(|_| BackendError::Upstream(format!("invalid zig version: {s}"))) - } - - fn sort_key(&self) -> i64 { - match self { - Self::Master => i64::MAX, - Self::Semver(v) => { - let vtype = if v.pre.is_empty() { - VersionType::Stable - } else if v.pre.as_str().starts_with("dev.") { - let num = v.pre.as_str()[4..].parse().unwrap_or(0); - VersionType::Dev(num) - } else { - VersionType::Stable - }; - - stable_version(v.major, v.minor, v.patch, vtype) - } - } - } -} - -/// Describes a single file stored at `ziglang.org/download/`. -/// -/// The tarball naming has changed several times. When parsing, -/// we standardize the files, but for the reverse operation -/// (getting a string from a tarball), we preserve the original path. -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct ZigFilename<'a> { - filename: &'a str, - os: Option<&'a str>, - arch: Option<&'a str>, - kind: FileKind, - minisig: bool, - archive: Archive, - version: SemVersion, - development: bool, -} - -impl<'a> BackendFilename<'a, ZigConfig> for ZigFilename<'a> { - const SIGNATURE_SUFFIX: Option<&'static str> = Some(".minisig"); - - /// Builds the upstream URL for this tarball. - fn parse(filename: &'a str) -> Result<Self, BackendError> { - let mut buffer = filename; - let mut minisig = false; - let archive; - - // (?:|-bootstrap|-[a-zA-Z0-9_]+-[a-zA-Z0-9_]+)-( - // \d+\.\d+\.\d+(?:-dev\.\d+\+[0-9a-f]+)? - // )\.(?:tar\.xz|zip)(?:\.minisig)? - buffer = buffer.strip_prefix("zig-").ok_or(BackendError::NotFound)?; - - // (?:|bootstrap|[a-zA-Z0-9_]+-[a-zA-Z0-9_]+)-( - // \d+\.\d+\.\d+(?:-dev\.\d+\+[0-9a-f]+)? - // )\.(?:tar\.xz|zip) - if let Some(it) = buffer.strip_suffix(".minisig") { - buffer = it; - minisig = true; - } - - // (?:|bootstrap|[a-zA-Z0-9_]+-[a-zA-Z0-9_]+)-( - // \d+\.\d+\.\d+(?:-dev\.\d+\+[0-9a-f]+)? - // ) - if let Some(it) = buffer.strip_suffix(".zip") { - buffer = it; - archive = Archive::Zip; - } else if let Some(it) = buffer.strip_suffix(".tar.xz") { - buffer = it; - archive = Archive::TarXz; - } else { - return Err(BackendError::NotFound); - } - - if buffer.is_empty() { - return Err(BackendError::NotFound); - } - - let mut it = buffer.rsplit('-'); - let last = it.next().ok_or(BackendError::NotFound)?; - - let development = last.starts_with("dev"); - - let version = if !development { - SemVersion::parse(last).map_err(|_| BackendError::NotFound)? - } else { - let semver = it.next().ok_or(BackendError::NotFound)?; - let devver = last; - let version_str = format!("{}-{}", semver, devver); - SemVersion::parse(&version_str).map_err(|_| BackendError::NotFound)? - }; - - let (os, arch, kind) = if let Some(payload) = it.next() { - if payload == "bootstrap" { - (None, None, FileKind::Bootstrap) - } else { - // Filename format changed over time: - // - <= 0.2.0: used zig-win64 for windows and zig-linux-x86_64 for linux ¯\_(ツ)_/¯ - // - 0.2.0 to 0.14.0: zig-OS-ARCH-VERSION (e.g. zig-linux-x86_64-0.13.0) - // - > 0.14.0: zig-ARCH-OS-VERSION (e.g. zig-x86_64-linux-0.15.0) - let (os, arch) = if version <= SemVersion::new(0, 2, 0) && payload == "win64" { - ("windows", "x86_64") - } else if version <= SemVersion::new(0, 14, 0) { - (it.next().ok_or(BackendError::NotFound)?, payload) - } else { - (payload, it.next().ok_or(BackendError::NotFound)?) - }; - (Some(os), Some(arch), FileKind::Archive) - } - } else { - (None, None, FileKind::Source) - }; - - if it.next().is_some() { - return Err(BackendError::NotFound); - } - - Ok(ZigFilename { - filename, - os, - arch, - kind, - minisig, - archive, - version, - development, - }) - } - - fn upstream_url(&self, config: &ZigConfig, source: &str) -> Result<Url, BackendError> { - let mut url = config.upstream.clone(); - - { - let mut segments = url - .path_segments_mut() - .map_err(|()| BackendError::Internal("cannot build upstream URL".into()))?; - segments.pop_if_empty(); - if self.development { - segments.push("builds"); - } else { - segments.push("download").push(&self.version.to_string()); - } - segments.push(self.filename); - } - - url.query_pairs_mut().append_pair("source", source); - Ok(url) - } - - fn is_sha256(&self) -> bool { - false // Zig uses minisig, not sha256 - } - - fn is_signature(&self) -> bool { - self.minisig - } - - fn can_bypass_index(&self) -> bool { - self.development - } - - fn signature_content(&self, file: &RawReleaseFile) -> Option<Bytes> { - if !self.minisig { - return None; - } - let typed: ReleaseFile<ZigFileMeta> = file.clone().try_into_typed().ok()?; - typed.meta.minisig.map(|s| s.into_bytes().into()) - } -} - -#[cfg(test)] -mod tests_zig_filename { - use super::*; - - #[test] - fn parse_old_combined_platform() { - // <= 0.2.0: zig-PLATFORM-VERSION (only Windows used this format) - let file = ZigFilename::parse("zig-win64-0.1.1.zip").unwrap(); - assert_eq!(file.os, Some("windows")); - assert_eq!(file.arch, Some("x86_64")); - assert_eq!(file.version, SemVersion::new(0, 1, 1)); - assert_eq!(file.archive, Archive::Zip); - assert_eq!(file.kind, FileKind::Archive); - - let file = ZigFilename::parse("zig-win64-0.2.0.zip").unwrap(); - assert_eq!(file.os, Some("windows")); - assert_eq!(file.arch, Some("x86_64")); - assert_eq!(file.version, SemVersion::new(0, 2, 0)); - } - - #[test] - fn parse_middle_os_arch_format() { - // 0.2.0 to 0.14.0: zig-OS-ARCH-VERSION - let file = ZigFilename::parse("zig-linux-x86_64-0.13.0.tar.xz").unwrap(); - assert_eq!(file.os, Some("linux")); - assert_eq!(file.arch, Some("x86_64")); - assert_eq!(file.version, SemVersion::new(0, 13, 0)); - assert_eq!(file.archive, Archive::TarXz); - - let file = ZigFilename::parse("zig-windows-x86_64-0.10.0.zip").unwrap(); - assert_eq!(file.os, Some("windows")); - assert_eq!(file.arch, Some("x86_64")); - } - - #[test] - fn parse_new_arch_os_format() { - // > 0.14.0: zig-ARCH-OS-VERSION - let file = ZigFilename::parse("zig-x86_64-linux-0.15.0.tar.xz").unwrap(); - assert_eq!(file.os, Some("linux")); - assert_eq!(file.arch, Some("x86_64")); - assert_eq!(file.version, SemVersion::new(0, 15, 0)); - - let file = ZigFilename::parse("zig-aarch64-macos-0.15.0.tar.xz").unwrap(); - assert_eq!(file.os, Some("macos")); - assert_eq!(file.arch, Some("aarch64")); - } - - #[test] - fn parse_dev_version() { - let file = ZigFilename::parse("zig-x86_64-linux-0.14.0-dev.123+abc123.tar.xz").unwrap(); - assert!(file.development); - assert_eq!(file.version.major, 0); - assert_eq!(file.version.minor, 14); - assert_eq!(file.version.patch, 0); - } - - #[test] - fn parse_source_tarball() { - let file = ZigFilename::parse("zig-0.13.0.tar.xz").unwrap(); - assert_eq!(file.os, None); - assert_eq!(file.arch, None); - assert_eq!(file.kind, FileKind::Source); - } - - #[test] - fn parse_bootstrap() { - let file = ZigFilename::parse("zig-bootstrap-0.13.0.tar.xz").unwrap(); - assert_eq!(file.kind, FileKind::Bootstrap); - } - - #[test] - fn parse_minisig() { - let file = ZigFilename::parse("zig-win64-0.1.1.zip.minisig").unwrap(); - assert!(file.minisig); - assert_eq!(file.os, Some("windows")); - assert_eq!(file.arch, Some("x86_64")); - - let file = ZigFilename::parse("zig-x86_64-linux-0.15.0.tar.xz.minisig").unwrap(); - assert!(file.minisig); - assert_eq!(file.os, Some("linux")); - } - - #[test] - fn parse_boundary_version() { - // 0.14.0 should use OS-ARCH format - let file = ZigFilename::parse("zig-linux-x86_64-0.14.0.tar.xz").unwrap(); - assert_eq!(file.os, Some("linux")); - assert_eq!(file.arch, Some("x86_64")); - - // 0.14.1 should use ARCH-OS format - let file = ZigFilename::parse("zig-x86_64-linux-0.14.1.tar.xz").unwrap(); - assert_eq!(file.os, Some("linux")); - assert_eq!(file.arch, Some("x86_64")); - } -} diff --git a/crates/tesor/Cargo.toml b/crates/tesor/Cargo.toml deleted file mode 100644 --- a/crates/tesor/Cargo.toml +++ /dev/null @@ -1,62 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -[package] -name = "tesor" -description = "tesor web-server and daemon" -version.workspace = true - -authors.workspace = true -edition.workspace = true -license.workspace = true -publish.workspace = true -homepage.workspace = true -repository.workspace = true - -[dependencies] -base.workspace = true -repos.workspace = true - -async-trait.workspace = true -axum.workspace = true -axum-server.workspace = true -bytes.workspace = true -bytesize.workspace = true -chrono.workspace = true -crc32fast.workspace = true -hex.workspace = true -http-body-util.workspace = true -hyper.workspace = true -hyper-tls.workspace = true -hyper-util.workspace = true -maud.workspace = true -rustls.workspace = true -serde.workspace = true -serde_json.workspace = true -sqlx.workspace = true -thiserror.workspace = true -tokio.workspace = true -tokio-util.workspace = true -toml.workspace = true -tonic.workspace = true -tower.workspace = true -tower-http.workspace = true -tower_governor.workspace = true -tracing.workspace = true -tracing-opentelemetry.workspace = true -tracing-subscriber.workspace = true -url.workspace = true -uuid.workspace = true - -# telemetry -opentelemetry.workspace = true -opentelemetry-appender-tracing.workspace = true -opentelemetry-otlp.workspace = true -opentelemetry-semantic-conventions.workspace = true -opentelemetry_sdk.workspace = true - -[target.'cfg(target_os = "linux")'.dependencies] -sd-notify.workspace = true - -[dev-dependencies] -tempfile.workspace = true diff --git a/crates/tesor/build.rs b/crates/tesor/build.rs deleted file mode 100644 --- a/crates/tesor/build.rs +++ /dev/null @@ -1,30 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Nikolay Govorov -// SPDX-License-Identifier: AGPL-3.0-or-later - -fn main() { - println!("cargo::rerun-if-changed=../../Cargo.lock"); - println!("cargo::rerun-if-changed=../../mise.toml"); - println!("cargo::rerun-if-changed=../../mise.lock"); - - let out_dir = std::env::var("OUT_DIR").unwrap(); - let target = std::env::var("TARGET").unwrap(); - let output = format!("{out_dir}/licenses.json"); - - let status = std::process::Command::new("mise") - .current_dir(env!("CARGO_MANIFEST_DIR")) - .args([ - "run", - "licenses-json", - "--", - "--manifest-path", - "Cargo.toml", - "--output", - &output, - "--target", - &target, - ]) - .status() - .expect("failed to run licenses-json task"); - - assert!(status.success(), "failed to generate licenses.json"); -} diff --git a/crates/tesor/src/assets/apple-touch-icon.png b/crates/tesor/src/assets/apple-touch-icon.png deleted file mode 100644 --- a/crates/tesor/src/assets/apple-touch-icon.png +++ /dev/null Binary files differ diff --git a/crates/tesor/src/assets/favicon-192.png b/crates/tesor/src/assets/favicon-192.png deleted file mode 100644 --- a/crates/tesor/src/assets/favicon-192.png +++ /dev/null Binary files differ diff --git a/crates/tesor/src/assets/favicon-512.png b/crates/tesor/src/assets/favicon-512.png deleted file mode 100644 --- a/crates/tesor/src/assets/favicon-512.png +++ /dev/null Binary files differ diff --git a/crates/tesor/src/assets/favicon.ico b/crates/tesor/src/assets/favicon.ico deleted file mode 100644 --- a/crates/tesor/src/assets/favicon.ico +++ /dev/null Binary files differ diff --git a/crates/tesor/src/assets/favicon.svg b/crates/tesor/src/assets/favicon.svg deleted file mode 100644 --- a/crates/tesor/src/assets/favicon.svg +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg xmlns="http://www.w3.org/2000/svg" fill="#f7a41d" viewBox="-150 -150 800 800"> - <path d="M100 0v100H0v400h500V100H400V0H100m0 200h100v100H100zm200 0h100v100H300z"/> -</svg> diff --git a/crates/tesor/src/assets/manifest.webmanifest b/crates/tesor/src/assets/manifest.webmanifest deleted file mode 100644 --- a/crates/tesor/src/assets/manifest.webmanifest +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "tesor", - "icons": [ - { "src": "/icon-192.png", "type": "image/png", "sizes": "192x192" }, - { "src": "/icon-512.png", "type": "image/png", "sizes": "512x512" }, - { "src": "/icon-512.png", "type": "image/png", "sizes": "512x512", "purpose": "maskable" } - ] -} diff --git a/crates/tesor/src/assets/robots.txt b/crates/tesor/src/assets/robots.txt deleted file mode 100644 --- a/crates/tesor/src/assets/robots.txt +++ /dev/null @@ -1,5 +0,0 @@ -User-Agent: * -Disallow: /zig/ - -User-Agent: * -Disallow: /go/ diff --git a/crates/tesor/src/controller_web.rs b/crates/tesor/src/controller_web.rs deleted file mode 100644 --- a/crates/tesor/src/controller_web.rs +++ /dev/null @@ -1,486 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Nikolay Govorov -// SPDX-License-Identifier: AGPL-3.0-or-later - -use std::future::Future; -use std::pin::Pin; -use std::sync::{Arc, LazyLock}; -use std::task::{Context, Poll}; - -use axum::body::Body; -use axum::http::{HeaderValue, Method, Request, Response, StatusCode, header}; -use axum::{extract, routing}; -use maud::{Markup, html}; -use serde::Deserialize; -use tower::{Layer, Service}; -use tracing::error; - -use base::ContentType; -use repos::{GoBackend, ZigBackend}; - -fn get_asset(path: &str) -> Option<(&'static [u8], ContentType)> { - Some(match path { - "base.css" => (include_bytes!("assets/base.css"), ContentType::TextCss), - "favicon.svg" => ( - include_bytes!("assets/favicon.svg"), - ContentType::ImageSvgXml, - ), - "favicon.ico" => ( - include_bytes!("assets/favicon.ico"), - ContentType::ImageXIcon, - ), - "favicon-192.png" | "apple-touch-icon.png" => ( - include_bytes!("assets/favicon-192.png"), - ContentType::ImagePng, - ), - "favicon-512.png" => ( - include_bytes!("assets/favicon-512.png"), - ContentType::ImagePng, - ), - "manifest.webmanifest" => ( - include_bytes!("assets/manifest.webmanifest"), - ContentType::ApplicationManifestJson, - ), - "jetbrainsmono/JetBrainsMono[wght].woff2" => ( - include_bytes!("assets/jetbrainsmono/JetBrainsMono[wght].woff2"), - ContentType::FontWoff2, - ), - "jetbrainsmono/JetBrainsMono-Italic[wght].woff2" => ( - include_bytes!("assets/jetbrainsmono/JetBrainsMono-Italic[wght].woff2"), - ContentType::FontWoff2, - ), - "robots.txt" => (include_bytes!("assets/robots.txt"), ContentType::TextPlain), - _ => return None, - }) -} - -const CSP: &str = "default-src 'self'; base-uri 'none'; img-src 'self'; font-src 'self'; style-src 'self'; script-src 'self'; object-src 'none'; frame-ancestors 'none'"; - -#[derive(Deserialize)] -struct LicenseList { - overview: Vec<LicenseOverview>, - licenses: Vec<LicenseEntry>, -} - -#[derive(Deserialize)] -struct LicenseOverview { - id: String, - name: String, - count: usize, -} - -#[derive(Deserialize)] -struct LicenseEntry { - id: String, - name: String, - text: String, - first_of_kind: bool, - used_by: Vec<LicenseUsedBy>, -} - -#[derive(Deserialize)] -struct LicenseUsedBy { - #[serde(rename = "crate")] - crate_: LicenseCrate, -} - -#[derive(Deserialize)] -#[allow(dead_code)] -struct LicenseCrate { - name: String, - version: String, - repository: Option<String>, -} - -static LICENSES: LazyLock<LicenseList> = LazyLock::new(|| { - let json = include_str!(concat!(env!("OUT_DIR"), "/licenses.json")); - serde_json::from_str(json).expect("failed to parse licenses.json") -}); - -/// Handles html pages rendering and static files -pub struct WebController { - zig: Option<Arc<ZigBackend>>, - go: Option<Arc<GoBackend>>, -} - -impl WebController { - pub fn new(zig: Option<Arc<ZigBackend>>, go: Option<Arc<GoBackend>>) -> Self { - Self { zig, go } - } -} - -impl WebController { - pub fn router(self: Arc<Self>) -> axum::Router { - axum::Router::new() - .route("/", axum::routing::get(Self::index)) - .route("/{*path}", routing::get(Self::assets)) - .route("/about/licenses", axum::routing::get(Self::licenses)) - .layer(CacheLayer) - .layer(tower_http::set_header::SetResponseHeaderLayer::overriding( - header::CONTENT_SECURITY_POLICY, - HeaderValue::from_static(CSP), - )) - .with_state(self.clone()) - } - - async fn assets(extract::Path(path): extract::Path<String>) -> Response<Body> { - let Some((data, content_type)) = get_asset(&path) else { - return Response::builder() - .status(StatusCode::NOT_FOUND) - .body(Body::empty()) - .unwrap(); - }; - - let mut builder = Response::builder() - .status(StatusCode::OK) - .header(header::CONTENT_TYPE, content_type.as_str()); - - if matches!(content_type, ContentType::FontWoff2) { - builder = builder.header(header::CACHE_CONTROL, "public, max-age=31536000, immutable"); - } - - builder.body(Body::from(data)).unwrap() - } - - async fn index(extract::State(ctrl): extract::State<Arc<Self>>) -> Markup { - let zig_versions = if let Some(ref backend) = ctrl.zig { - match backend.get_releases().await { - Ok(v) => v, - Err(e) => { - error!("failed to get zig versions: {e}"); - Vec::new() - } - } - } else { - Vec::new() - }; - - let go_versions = if let Some(ref backend) = ctrl.go { - match backend.get_releases().await { - Ok(v) => v, - Err(e) => { - error!("failed to get go versions: {e}"); - Vec::new() - } - } - } else { - Vec::new() - }; - - WebController::layout( - "Tesor — tiny & opinionated packages mirror", - html! { - h1 { "Tesor — tiny & opinionated packages mirror." } - - p { - r#"This site provides a caching proxy for downloading Zig and Go installation files. - It reduces load on upstream servers and makes your infrastructure more reliable by adding redundancy."# - } - - p { - "Tesor is open source software licensed under " a href="https://www.gnu.org/licenses/agpl-3.0.html" { "AGPL-3.0" } ". " - "Source code is available on " a href="https://git.dimidiumlabs.io/tesor" { "Dimidium Labs Git" } ". " - "A list of dependency licenses " a href="/about/licenses" { "is available" } "." - } - - h2 { "Usage" } - - p { - "Replace official download URLs with " code { "https://pkg.earth/{tool}/{filename}" } ". " - "Files are cached automatically after the first download." - } - - h3 id="zig" { - a href="#zig" { "Zig" } - } - - @if !zig_versions.is_empty() { - details { - summary { "Available versions (" (zig_versions.len()) ")" } - - p { "You can take actual minisig public key at " a href="https://ziglang.org/download/" { "ziglang.org/download" } "." } - table { - thead { - tr { - th { "Version" } - th { "Date" } - th { "Docs" } - th { "Targets" } - } - } - tbody { - @for v in zig_versions.iter().rev() { - tr { - td { (v.version) } - td { (v.meta.date.as_deref().unwrap_or("-")) } - td { - @if let Some(ref url) = v.meta.docs { - a href=(url) { "docs" } - } - " " - @if let Some(ref url) = v.meta.std_docs { - a href=(url) { "std" } - } - " " - @if let Some(ref url) = v.meta.notes { - a href=(url) { "notes" } - } - } - td { - @for file in &v.files { - a href=(format!("/zig/{}", file.filename)) { (&file.meta.target) } - " " - } - } - } - } - } - } - } - } - - p { - "Read more about community mirrors in the " a href="https://ziglang.org/download/community-mirrors/" { "blog post" } ". " - "Information on how to deploy your own mirror is available " a href="https://github.com/ziglang/www.ziglang.org/blob/main/MIRRORS.md" { "in the documentation" } "." - } - - p { - "For simplicity, you can use tools like " a href="https://github.com/prantlf/zigup" { "prantlf/zigup" } - " and " a href="https://github.com/mlugg/setup-zig" { "mlugg/setup-zig" } "." - } - - p { - "To install manually:" - ol { - li { "download zig dist file:" br; code { "wget https://pkg.earth/zig/zig-x86_64-linux-0.15.1.tar.xz" } ";" } - li { "download zig minisig file:" br; code { "wget https://pkg.earth/zig/zig-x86_64-linux-0.15.1.tar.xz.minisig" } ";" } - li { "check archive integrity:" br; code { "minisign -Vm zig-x86_64-linux-0.15.1.tar.xz -P RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U" } ";" } - li { "unpack archive:" br; code { "tar -xf 'zig-x86_64-linux-0.15.1.tar.xz'" } ";" } - li { "check installed zig:" br; code { "./zig-x86_64-linux-0.15.1/zig --version" } ";" } - } - } - - h3 id="go" { a href="#go" { "Go" } } - - @if !go_versions.is_empty() { - details { - summary { "Available versions (" (go_versions.len()) ")" } - - p { "You can find available versions at " a href="https://go.dev/dl/" { "go.dev/dl" } "." } - table { - thead { - tr { - th { "Version" } - th { "Stable" } - th { "Files" } - } - } - tbody { - @for v in go_versions.iter().rev() { - tr { - td { (v.version) } - td { @if v.meta.stable { "✓" } @else { "" } } - td { - @for file in &v.files { - a href=(format!("/go/{}", file.filename)) { (file.filename) } - " " - } - } - } - } - } - } - } - } - - p { "To install manually:" } - - ol { - li { "download go dist file:" br; code { "wget https://pkg.earth/go/go1.23.0.linux-amd64.tar.gz" } ";" } - li { "download go sha256 file:" br; code { "wget https://pkg.earth/go/go1.23.0.linux-amd64.tar.gz.sha256" } ";" } - li { "check archive integrity:" br; code { "sha256sum -c go1.23.0.linux-amd64.tar.gz.sha256" } ";" } - li { "unpack archive:" br; code { "tar -xzf go1.23.0.linux-amd64.tar.gz" } ";" } - li { "check installed go:" br; code { "./go/bin/go version" } ";" } - } - - h2 { "Privacy policy" } - - p { "This mirror is a non-profit project available on a voluntary basis. The author has no plans to fund it." } - - p { r#"Since the mirror is hosted on hardware, we collect access logs to combat bots and brute-force attacks. - The logs are used for security purposes and load planning, are not shared with third parties, - and are deleted after 30 days."# } - - p { "Third-party analytics systems are not used, same as client-side trackers." } - }, - ) - } - - async fn licenses() -> Markup { - let data = &*LICENSES; - - WebController::layout( - "Third Party Licenses", - html! { - h1 { "Licenses" } - - h2 { "Tesor" } - - p { - "Tesor is licensed under the " b { "GNU Affero General Public License v3.0 (AGPL-3.0)" } ". " - "This means you are free to use, modify, and distribute the software. " - "If you run a modified version of Tesor as a network service, " - "you must make the source code of your modifications available to its users. " - "The software is provided as-is, without warranty of any kind." - } - - p { - "Source code is available on " - a href="https://git.dimidiumlabs.io/tesor" { "Dimidium Labs Git" } - ". The full license text is included below." - } - - pre .license-text { (include_str!("../../../LICENSE")) } - - h2 { "Third party licenses" } - - ul { - @for ov in &data.overview { - li { a href=(format!("#{}", ov.id)) { (&ov.name) } " (" (ov.count) ")" } - } - } - - @for (i, lic) in data.licenses.iter().enumerate() { - @if lic.first_of_kind { - h3 id=(&lic.id) { (&lic.name) } - } - - section.license { - h4 id=(format!("{}-{}", lic.id, i)) { (&lic.name) } - - p { "Used by:" } - - ul .license-used-by { - @for usage in &lic.used_by { - li { - a href=( - usage.crate_.repository.as_deref() - .unwrap_or(&format!("https://crates.io/crates/{}", usage.crate_.name)) - ) { - (&usage.crate_.name) "@" (&usage.crate_.version) - } - } - } - } - - pre .license-text { (&lic.text) } - } - } - }, - ) - } - - fn layout(title: &str, content: Markup) -> Markup { - html! { - (maud::DOCTYPE) - - html lang="en" { - head { - meta charset="UTF-8"; - meta http-equiv="X-UA-Compatible" content="ie=edge"; - meta name="viewport" content="width=device-width,initial-scale=1"; - - title { (title) } - link rel="stylesheet" href="/base.css"; - - link rel="manifest" href="/manifest.webmanifest"; - link rel="icon" href="/favicon.ico" sizes="32x32"; - link rel="icon" href="/favicon.svg" type="image/svg+xml"; - link rel="apple-touch-icon" href="/apple-touch-icon.png"; - } - - body { - article { (content) } - } - } - } - } -} - -#[derive(Clone)] -struct CacheLayer; - -impl<S> Layer<S> for CacheLayer { - type Service = CacheService<S>; - fn layer(&self, inner: S) -> Self::Service { - CacheService { inner } - } -} - -#[derive(Clone)] -struct CacheService<S> { - inner: S, -} - -impl<S> Service<Request<Body>> for CacheService<S> -where - S: Service<Request<Body>, Response = Response<Body>> + Clone + Send + 'static, - S::Future: Send + 'static, - S::Error: Send + 'static, -{ - type Response = Response<Body>; - type Error = S::Error; - type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>; - - fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { - self.inner.poll_ready(cx) - } - - fn call(&mut self, req: Request<Body>) -> Self::Future { - let method = req.method().clone(); - let if_none_match = req.headers().get(header::IF_NONE_MATCH).cloned(); - - let mut inner = self.inner.clone(); - Box::pin(async move { - let resp = inner.call(req).await?; - - if !resp.status().is_success() { - return Ok(resp); - } - - let (parts, body) = resp.into_parts(); - let bytes = axum::body::to_bytes(body, usize::MAX).await.unwrap(); - - let mut hasher = crc32fast::Hasher::new(); - hasher.update(&bytes); - let etag = format!("\"{}\"", hex::encode(hasher.finalize().to_be_bytes())); - let etag_header = HeaderValue::from_str(&etag).unwrap(); - let cache_control = parts - .headers - .get(header::CACHE_CONTROL) - .cloned() - .unwrap_or(HeaderValue::from_static("no-cache")); - - if (method == Method::GET || method == Method::HEAD) - && if_none_match - .as_ref() - .is_some_and(|v| v.as_bytes() == etag.as_bytes()) - { - let mut resp = Response::builder() - .status(StatusCode::NOT_MODIFIED) - .body(Body::empty()) - .unwrap(); - resp.headers_mut().insert(header::ETAG, etag_header); - resp.headers_mut() - .insert(header::CACHE_CONTROL, cache_control); - return Ok(resp); - } - - let mut resp = Response::from_parts(parts, Body::from(bytes)); - resp.headers_mut().insert(header::ETAG, etag_header); - resp.headers_mut() - .entry(header::CACHE_CONTROL) - .or_insert(HeaderValue::from_static("no-cache")); - Ok(resp) - }) - } -} diff --git a/deny.toml b/deny.toml index 3cd37da..03a665b 100644 --- a/deny.toml +++ b/deny.toml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov +# SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> # SPDX-License-Identifier: AGPL-3.0-or-later [licenses] @@ -22,10 +22,7 @@ allow = [ ] exceptions = [ # The project itself is distributed under the AGPL, but avoid it in dependencies - { crate = "base", allow = ["AGPL-3.0-or-later"] }, - { crate = "repos", allow = ["AGPL-3.0-or-later"] }, - { crate = "smoke", allow = ["AGPL-3.0-or-later"] }, - { crate = "tesor", allow = ["AGPL-3.0-or-later"] }, + { crate = "zorian", allow = ["AGPL-3.0-or-later"] }, ] unused-allowed-license = "allow" diff --git a/mise.lock b/mise.lock deleted file mode 100644 --- a/mise.lock +++ /dev/null @@ -1,73 +0,0 @@ -# @generated - this file is auto-generated by `mise lock` https://mise.jdx.dev/dev-tools/mise-lock.html - -[[tools."aqua:taiki-e/cargo-llvm-cov"]] -version = "0.8.7" -backend = "aqua:taiki-e/cargo-llvm-cov" - -[tools."aqua:taiki-e/cargo-llvm-cov"."platforms.linux-arm64"] -checksum = "sha256:b7bb2ad514166f3b19fc06874c577eefde0010e5ac571f9ae33ff45cd19a4785" -url = "https://github.com/taiki-e/cargo-llvm-cov/releases/download/v0.8.7/cargo-llvm-cov-aarch64-unknown-linux-musl.tar.gz" -url_api = "https://api.github.com/repos/taiki-e/cargo-llvm-cov/releases/assets/418861713" - -[tools."aqua:taiki-e/cargo-llvm-cov"."platforms.linux-x64"] -checksum = "sha256:967b5cc996c29d8baa52bbb4595ef1f53af35255af8e2036ddbc6468d7b523c7" -url = "https://github.com/taiki-e/cargo-llvm-cov/releases/download/v0.8.7/cargo-llvm-cov-x86_64-unknown-linux-musl.tar.gz" -url_api = "https://api.github.com/repos/taiki-e/cargo-llvm-cov/releases/assets/418861752" - -[[tools."cargo:cargo-about"]] -version = "0.8.4" -backend = "cargo:cargo-about" - -[[tools.gh]] -version = "2.96.0" -backend = "aqua:cli/cli" - -[tools.gh."platforms.linux-arm64"] -checksum = "sha256:06f86ec7103d41993b76cd78072f43595c34aaa56506d971d9860e67140bf909" -url = "https://github.com/cli/cli/releases/download/v2.96.0/gh_2.96.0_linux_arm64.tar.gz" -url_api = "https://api.github.com/repos/cli/cli/releases/assets/464728549" -provenance = "github-attestations" - -[tools.gh."platforms.linux-x64"] -checksum = "sha256:83d5c2ccad5498f58bf6368acb1ab32588cf43ab3a4b1c301bf36328b1c8bd60" -url = "https://github.com/cli/cli/releases/download/v2.96.0/gh_2.96.0_linux_amd64.tar.gz" -url_api = "https://api.github.com/repos/cli/cli/releases/assets/464728543" -provenance = "github-attestations" - -[[tools.jq]] -version = "1.8.2" -backend = "aqua:jqlang/jq" - -[tools.jq."platforms.linux-arm64"] -checksum = "sha256:8b85c817833814ddca00a144c33705546355afccf0cf39b188f3cdb48b852309" -url = "https://github.com/jqlang/jq/releases/download/jq-1.8.2/jq-linux-arm64" -url_api = "https://api.github.com/repos/jqlang/jq/releases/assets/453012756" -provenance = "github-attestations" - -[tools.jq."platforms.linux-x64"] -checksum = "sha256:b1c22172dd303f3be49e935aa56aa48a8b7a46e0bc838b4997d3bb451495870f" -url = "https://github.com/jqlang/jq/releases/download/jq-1.8.2/jq-linux-amd64" -url_api = "https://api.github.com/repos/jqlang/jq/releases/assets/453012752" -provenance = "github-attestations" - -[[tools.rust]] -version = "1.97.1" -backend = "core:rust" - -[tools.rust.options] -components = "clippy,llvm-tools-preview,rustfmt" -profile = "minimal" - -[[tools.shellcheck]] -version = "0.11.0" -backend = "aqua:koalaman/shellcheck" - -[tools.shellcheck."platforms.linux-arm64"] -checksum = "sha256:12b331c1d2db6b9eb13cfca64306b1b157a86eb69db83023e261eaa7e7c14588" -url = "https://github.com/koalaman/shellcheck/releases/download/v0.11.0/shellcheck-v0.11.0.linux.aarch64.tar.xz" -url_api = "https://api.github.com/repos/koalaman/shellcheck/releases/assets/279056934" - -[tools.shellcheck."platforms.linux-x64"] -checksum = "sha256:8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198" -url = "https://github.com/koalaman/shellcheck/releases/download/v0.11.0/shellcheck-v0.11.0.linux.x86_64.tar.xz" -url_api = "https://api.github.com/repos/koalaman/shellcheck/releases/assets/279056942" diff --git a/mise.toml b/mise.toml deleted file mode 100644 --- a/mise.toml +++ /dev/null @@ -1,65 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -min_version = "2026.7.5" - -[settings] -experimental = true - -[tools] -"aqua:taiki-e/cargo-llvm-cov" = "0.8.7" -"cargo:cargo-about" = "0.8.4" -gh = "2.96.0" -jq = "1.8.2" -rust = { version = "1.97.1", profile = "minimal", components = [ "clippy", "llvm-tools-preview", "rustfmt" ] } -shellcheck = "0.11.0" - -[bootstrap.packages] -# APT -"apt:apt-utils" = "latest" -"apt:build-essential" = "latest" -"apt:debsigs" = "latest" -"apt:createrepo-c" = "latest" -"apt:gnupg" = "latest" -"apt:libssl-dev" = "latest" -"apt:pkg-config" = "latest" -"apt:rpm" = "latest" - -# DNF -"dnf:createrepo_c" = "latest" -"dnf:gcc" = "latest" -"dnf:gnupg2" = "latest" -"dnf:openssl-devel" = "latest" -"dnf:pkgconf-pkg-config" = "latest" -"dnf:rpm" = "latest" - -[task_config] -dir = "{{cwd}}" -includes = [ - "git::https://git.dimidiumlabs.io/platform.git//tasks?ref=159ce265b95d655342c378d9aaa7dc14dbf1dfa4", -] - -[tasks.fmt] -run = "cargo fmt --all --check" - -[tasks.clippy] -run = "cargo clippy --all-targets --all-features -- -D warnings" - -[tasks.test] -run = """ -cargo build --release -cargo test --all-features --release --locked -""" - -[tasks.smoke] -run = "cargo run -p smoke" - -[tasks.smoke-local] -run = "./tests/smoke/run-local.sh" - -[tasks.coverage] -run = """ -mkdir -p target/coverage/ -cargo llvm-cov --all-features --workspace --lcov --output-path target/coverage/lcov.info -cargo llvm-cov --all-features --workspace --html --output-dir target/coverage/html -""" diff --git a/nfpm.yaml b/nfpm.yaml index 5704fcb..262bde9 100644 --- a/nfpm.yaml +++ b/nfpm.yaml @@ -1,10 +1,10 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov +# SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> # SPDX-License-Identifier: AGPL-3.0-or-later # yaml-language-server: $schema=https://nfpm.goreleaser.com/schema.json # vim: set ts=2 sw=2 tw=0 fo=cnqoj -name: tesor +name: zorian arch: ${ARCH} version: ${VERSION} license: AGPL-3.0-or-later @@ -14,34 +14,34 @@ description: Tiny packages caching proxy contents: - src: ./LICENSE - dst: /usr/share/doc/tesor/LICENSE + dst: /usr/share/doc/zorian/LICENSE - src: ./README.md - dst: /usr/share/doc/tesor/README.md + dst: /usr/share/doc/zorian/README.md - - src: target/release/tesor - dst: /usr/local/bin/tesor + - src: target/release/zorian + dst: /usr/local/bin/zorian file_info: mode: 0755 - - src: pkg/tesor.toml - dst: /etc/tesor.toml + - src: pkg/zorian.toml + dst: /etc/zorian.toml type: config|noreplace file_info: mode: 0640 owner: root - group: tesor + group: zorian - - src: pkg/tesor.service - dst: /usr/lib/systemd/system/tesor.service + - src: pkg/zorian.service + dst: /usr/lib/systemd/system/zorian.service file_info: mode: 0644 - - dst: /var/lib/tesor + - dst: /var/lib/zorian type: dir file_info: mode: 0755 owner: root - group: tesor + group: zorian scripts: diff --git a/pkg/logo.svg b/pkg/logo.svg deleted file mode 100644 --- a/pkg/logo.svg +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg viewBox="-150 -150 800 800" xmlns="http://www.w3.org/2000/svg" fill="rgb(247, 164, 29)"> - <rect x="0" y="100" width="100" height="100"></rect> - <rect x="0" y="200" width="100" height="100"></rect> - <rect x="0" y="300" width="100" height="100"></rect> - <rect x="0" y="400" width="100" height="100"></rect> - <rect x="100" y="0" width="100" height="100"></rect> - <rect x="100" y="100" width="100" height="100"></rect> - <rect x="100" y="300" width="100" height="100"></rect> - <rect x="100" y="400" width="100" height="100"></rect> - <rect x="200" y="0" width="100" height="100"></rect> - <rect x="200" y="100" width="100" height="100"></rect> - <rect x="200" y="200" width="100" height="100"></rect> - <rect x="200" y="300" width="100" height="100"></rect> - <rect x="200" y="400" width="100" height="100"></rect> - <rect x="400" y="100" width="100" height="100"></rect> - <rect x="400" y="200" width="100" height="100"></rect> - <rect x="400" y="300" width="100" height="100"></rect> - <rect x="400" y="400" width="100" height="100"></rect> - <rect x="300" y="0" width="100" height="100"></rect> - <rect x="300" y="100" width="100" height="100"></rect> - <rect x="300" y="300" width="100" height="100"></rect> - <rect x="300" y="400" width="100" height="100"></rect> -</svg> diff --git a/pkg/scripts/postinstall.sh b/pkg/scripts/postinstall.sh index 6e391fc..8a1e7cf 100644 --- a/pkg/scripts/postinstall.sh +++ b/pkg/scripts/postinstall.sh @@ -1,10 +1,10 @@ #!/bin/sh -# SPDX-FileCopyrightText: 2026 Nikolay Govorov +# SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> # SPDX-License-Identifier: AGPL-3.0-or-later set -e -if [ -x "/bin/systemctl" ] && [ -d /run/systemd/system ] && [ -f /usr/lib/systemd/system/tesor.service ]; then +if [ -x "/bin/systemctl" ] && [ -d /run/systemd/system ] && [ -f /usr/lib/systemd/system/zorian.service ]; then /bin/systemctl daemon-reload - /bin/systemctl enable tesor + /bin/systemctl enable zorian fi diff --git a/pkg/scripts/preinstall.sh b/pkg/scripts/preinstall.sh index 175eaf1..2828c95 100644 --- a/pkg/scripts/preinstall.sh +++ b/pkg/scripts/preinstall.sh @@ -1,16 +1,17 @@ #!/bin/sh -# SPDX-FileCopyrightText: 2026 Nikolay Govorov +# SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> # SPDX-License-Identifier: AGPL-3.0-or-later set -e -TESOR_USER=${TESOR_USER:-tesor} -TESOR_GROUP=${TESOR_GROUP:-${TESOR_USER}} +PROGRAM=zorian +ZORIAN_USER=${ZORIAN_USER:-zorian} +ZORIAN_GROUP=${ZORIAN_GROUP:-${ZORIAN_USER}} -if ! getent group "$TESOR_GROUP" >/dev/null; then - groupadd --system "$TESOR_GROUP" +if ! getent group $ZORIAN_GROUP >/dev/null; then + groupadd --system $ZORIAN_GROUP fi -if ! getent passwd "$TESOR_USER" >/dev/null; then - useradd --system --gid "$TESOR_GROUP" --no-create-home --shell /usr/sbin/nologin "$TESOR_USER" +if ! getent passwd $ZORIAN_USER >/dev/null; then + useradd --system --gid $ZORIAN_GROUP --no-create-home --shell /usr/sbin/nologin $ZORIAN_USER fi diff --git a/pkg/scripts/preremove.sh b/pkg/scripts/preremove.sh index 9cd6599..87c062a 100644 --- a/pkg/scripts/preremove.sh +++ b/pkg/scripts/preremove.sh @@ -1,10 +1,10 @@ #!/bin/sh -# SPDX-FileCopyrightText: 2026 Nikolay Govorov +# SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> # SPDX-License-Identifier: AGPL-3.0-or-later set -e -if [ -x "/bin/systemctl" ] && [ -d /run/systemd/system ] && [ -f /usr/lib/systemd/system/tesor.service ]; then - /bin/systemctl stop tesor.service || true - /bin/systemctl disable tesor.service || true +if [ -x "/bin/systemctl" ] && [ -d /run/systemd/system ] && [ -f /usr/lib/systemd/system/zorian.service ]; then + /bin/systemctl stop zorian.service || true + /bin/systemctl disable zorian.service || true fi diff --git a/pkg/tesor.service b/pkg/zorian.service index c2d463d..64f34b5 100644 --- a/pkg/tesor.service +++ b/pkg/zorian.service @@ -1,22 +1,22 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov +# SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> # SPDX-License-Identifier: AGPL-3.0-or-later [Unit] -Description=tesor server (tiny packages caching proxy) +Description=Zorian server (tiny packages caching proxy) Requires=network-online.target After=time-sync.target network-online.target remote-fs.target nss-lookup.target Wants=time-sync.target [Service] Type=notify -User=tesor -Group=tesor +User=zorian +Group=zorian Restart=always RestartSec=30 WatchdogSec=30 NotifyAccess=main -ExecPaths=/usr/local/bin/tesor /usr/lib -ExecStart=/usr/local/bin/tesor --config=/etc/tesor.toml +ExecPaths=/usr/local/bin/zorian /usr/lib +ExecStart=/usr/local/bin/zorian --config=/etc/zorian.toml LimitCORE=infinity LimitNOFILE=500000 AmbientCapabilities=CAP_NET_BIND_SERVICE diff --git a/pkg/tesor.toml b/pkg/zorian.toml index 7296086..0fde186 100644 --- a/pkg/tesor.toml +++ b/pkg/zorian.toml @@ -1,13 +1,13 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov +# SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> # SPDX-License-Identifier: AGPL-3.0-or-later -# tesor will dutifully indicate its user agent and protocols (for example, source for zig). +# Zorian will dutifully indicate its user agent and protocols (for example, source for zig). # Specify your name if you want your instance to be identified. -appname="tesor" +appname="zorian" # Path to the directory for storing state (indexes, caches, statistics). # Must be a writable directory. -dirname="/var/lib/tesor" +dirname="/var/lib/zorian" # Common server settings [server] @@ -25,8 +25,8 @@ addr = "0.0.0.0:2025" hostnames = ["localhost", "127.0.0.1", "::1"] # For HTTPS, set tls_cert and tls_key to PEM file paths. -# tls_crt = "/etc/tesor/cert.pem" -# tls_key = "/etc/tesor/key.pem" +# tls_crt = "/etc/zorian/cert.pem" +# tls_key = "/etc/zorian/key.pem" # Telemetry configuration # Logs to stdout (pretty or json format) @@ -47,13 +47,13 @@ log_format = "pretty" # pretty, json # log_level = "info" # # # For gRPC with TLS, specify certificates: -# # tls_ca = "/etc/tesor/otel-ca.crt" -# # tls_crt = "/etc/tesor/otel-client.crt" # for mTLS -# # tls_key = "/etc/tesor/otel-client.key" # for mTLS +# # tls_ca = "/etc/zorian/otel-ca.crt" +# # tls_crt = "/etc/zorian/otel-client.crt" # for mTLS +# # tls_key = "/etc/zorian/otel-client.key" # for mTLS # # # HTTP headers for authentication: # # [telemetry.otelcol.headers] # # Authorization = "Bearer <token>" -# Environment variable TESOR_LOG overrides log_level settings. -# Example: TESOR_LOG=debug,sqlx=warn +# Environment variable ZORIAN_LOG overrides log_level settings. +# Example: ZORIAN_LOG=debug,sqlx=warn diff --git a/crates/tesor/src/assets/base.css b/src/assets/base.css index 66503e7..d102d49 100644 --- a/crates/tesor/src/assets/base.css +++ b/src/assets/base.css @@ -1,4 +1,4 @@ -/* SPDX-FileCopyrightText: 2026 Nikolay Govorov */ +/* SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> */ /* SPDX-License-Identifier: AGPL-3.0-or-later */ @font-face { @@ -26,25 +26,6 @@ :root { line-height: 1.4; font-family: 'JetBrains Mono', monospace; - color-scheme: light dark; - - --color-text: #222; - --color-bg: #fff; - --color-border: #222; - --color-code-bg: #818b981f; - --color-license-bg: antiquewhite; - --color-link: #0969da; -} - -@media (prefers-color-scheme: dark) { - :root { - --color-text: #e0e0e0; - --color-bg: #1a1a1a; - --color-border: #555; - --color-code-bg: #ffffff12; - --color-license-bg: #2a2a2a; - --color-link: #58a6ff; - } } html { @@ -54,32 +35,29 @@ html { body { margin: 0 auto; - max-width: 80ch; + max-width: 960px; padding: 1.5em 2em; - color: var(--color-text); - background-color: var(--color-bg); } -code { - margin: 0; - padding: .2em .4em; - white-space: break-spaces; - background-color: var(--color-code-bg); +pre, code { + font-size: .75rem; + font-weight: 600; } -h1, h2, h3, h4 { - margin: 1.5rem 0 0.5rem; +h1, h2, h3, h4, h5, h6 { + margin: 1rem 0; font-weight: 700; line-height: 1.2; text-wrap: balance; } -h1 { font-size: 2.25rem; line-height: 1.1; } -h2 { font-size: 1.5rem; } -h3 { font-size: 1.15rem; } -h4 { font-size: 1rem; } +h1 { + font-size: 2.75rem; +} -h1:first-child { margin-top: 0; } +h1:first-child { + margin-top: 0; +} p, details { margin: 1em 0; @@ -92,15 +70,11 @@ table { th, td { padding: 7px 8px; - border: 2px solid var(--color-border); + border: 2px solid black; text-align: start; vertical-align: top; } -a { - color: var(--color-link); -} - h3 a { color: inherit; text-decoration: none; @@ -109,20 +83,3 @@ h3 a { h3 a:hover { text-decoration: underline; } - -.license { - margin: 1rem 0; -} - -.license-used-by { - margin-top: -10px; -} - -.license-text { - max-height: 280px; - overflow-y: scroll; - white-space: pre-wrap; - background-color: var(--color-license-bg); - border-left: 4px solid var(--color-border); - padding: 0.8em 1em; -} diff --git a/crates/tesor/src/assets/jetbrainsmono/JetBrainsMono-Italic[wght].woff2 b/src/assets/jetbrainsmono/JetBrainsMono-Italic[wght].woff2 index 98adc80..98adc80 100644 --- a/crates/tesor/src/assets/jetbrainsmono/JetBrainsMono-Italic[wght].woff2 +++ b/src/assets/jetbrainsmono/JetBrainsMono-Italic[wght].woff2 Binary files differ diff --git a/crates/tesor/src/assets/jetbrainsmono/JetBrainsMono[wght].woff2 b/src/assets/jetbrainsmono/JetBrainsMono[wght].woff2 index 4cd1413..4cd1413 100644 --- a/crates/tesor/src/assets/jetbrainsmono/JetBrainsMono[wght].woff2 +++ b/src/assets/jetbrainsmono/JetBrainsMono[wght].woff2 Binary files differ diff --git a/src/backends/go.rs b/src/backends/go.rs new file mode 100644 --- /dev/null +++ b/src/backends/go.rs @@ -0,0 +1,700 @@ +// SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> +// SPDX-License-Identifier: AGPL-3.0-or-later + +use std::sync::Arc; +use std::time::Duration; + +use serde::{Deserialize, Serialize}; +use thiserror::Error; +use url::Url; + +use super::{Archive, Backend, BackendDelegate, FileKind, IndexError, ResolveError, ResolvedFile}; +use crate::utils::deserialize_duration_secs; + +#[derive(Debug, Clone, Deserialize)] +#[serde(default)] +pub struct GoConfig { + pub enabled: bool, + pub upstream: Url, + #[serde(deserialize_with = "deserialize_duration_secs")] + pub refresh_interval: Duration, +} +impl Default for GoConfig { + fn default() -> Self { + Self { + enabled: true, + upstream: Url::parse("https://go.dev/dl/").unwrap(), + refresh_interval: Duration::from_secs(60 * 10), + } + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +enum ReleaseType { + Stable, + ReleaseCandidate(u64), + Beta(u64), +} + +#[derive(Debug, Clone, PartialEq, Eq, Error)] +#[error("invalid tarball filename")] +struct ParseError; + +#[derive(Debug, Clone, PartialEq, Eq)] +struct GoVersion { + major: u64, + minor: u64, + patch: Option<u64>, + release_type: ReleaseType, +} + +impl GoVersion { + /// Parses version string like "go1", "go1.22.3", "go1.23rc1", or "go1.9.2rc2". + fn parse(s: &str) -> Result<Self, ParseError> { + let s = s.strip_prefix("go").ok_or(ParseError)?; + let parts: Vec<&str> = s.split('.').collect(); + let (version, consumed) = Self::from_parts(&parts)?; + if consumed != parts.len() { + return Err(ParseError); + } + Ok(version) + } + + /// Parses version from dot-separated parts, returns (version, parts_consumed). + fn from_parts(parts: &[&str]) -> Result<(Self, usize), ParseError> { + let major = parts + .first() + .ok_or(ParseError)? + .parse() + .map_err(|_| ParseError)?; + + let Some(minor_str) = parts.get(1) else { + return Ok(( + Self { + major, + minor: 0, + patch: None, + release_type: ReleaseType::Stable, + }, + 1, + )); + }; + let (minor, minor_release) = Self::parse_minor_with_release(minor_str)?; + + let Some(patch_str) = parts.get(2) else { + return Ok(( + Self { + major, + minor, + patch: None, + release_type: minor_release, + }, + 2, + )); + }; + if let Ok((p, patch_release)) = Self::parse_version_part(patch_str) { + Ok(( + Self { + major, + minor, + patch: Some(p), + release_type: patch_release.unwrap_or(minor_release), + }, + 3, + )) + } else { + Ok(( + Self { + major, + minor, + patch: None, + release_type: minor_release, + }, + 2, + )) + } + } + + fn sort_key(&self) -> i64 { + let vtype = match self.release_type { + ReleaseType::Beta(n) => super::VersionType::Beta(n), + ReleaseType::ReleaseCandidate(n) => super::VersionType::Rc(n), + ReleaseType::Stable => super::VersionType::Stable, + }; + super::stable_version(self.major, self.minor, self.patch.unwrap_or(0), vtype) + } + + /// Parses a version part (number with optional rc/beta suffix). + /// "25" -> (25, None) + /// "2rc2" -> (2, Some(ReleaseCandidate(2))) + /// "1beta1" -> (1, Some(Beta(1))) + fn parse_version_part(s: &str) -> Result<(u64, Option<ReleaseType>), ParseError> { + if let Some(idx) = s.find("rc") { + let num = s[..idx].parse::<u64>().map_err(|_| ParseError)?; + let rc_num = s[idx + 2..].parse::<u64>().map_err(|_| ParseError)?; + return Ok((num, Some(ReleaseType::ReleaseCandidate(rc_num)))); + } + if let Some(idx) = s.find("beta") { + let num = s[..idx].parse::<u64>().map_err(|_| ParseError)?; + let beta_num = s[idx + 4..].parse::<u64>().map_err(|_| ParseError)?; + return Ok((num, Some(ReleaseType::Beta(beta_num)))); + } + let num = s.parse::<u64>().map_err(|_| ParseError)?; + Ok((num, None)) + } + + /// Parses minor version with possible release type suffix. + /// "25" -> (25, Stable) + /// "26rc2" -> (26, ReleaseCandidate(2)) + /// "26beta1" -> (26, Beta(1)) + fn parse_minor_with_release(s: &str) -> Result<(u64, ReleaseType), ParseError> { + let (num, release) = GoVersion::parse_version_part(s)?; + Ok((num, release.unwrap_or(ReleaseType::Stable))) + } +} + +#[cfg(test)] +mod version_tests { + use super::*; + + #[test] + fn test_parse_go1() { + let v = GoVersion::parse("go1").unwrap(); + assert_eq!(v.major, 1); + assert_eq!(v.minor, 0); + assert_eq!(v.patch, None); + assert!(matches!(v.release_type, ReleaseType::Stable)); + } + + #[test] + fn test_parse_patch_rc() { + let v = GoVersion::parse("go1.9.2rc2").unwrap(); + assert_eq!(v.major, 1); + assert_eq!(v.minor, 9); + assert_eq!(v.patch, Some(2)); + assert!(matches!(v.release_type, ReleaseType::ReleaseCandidate(2))); + } + + #[test] + fn test_no_collision_go19_and_go192rc2() { + let v1 = GoVersion::parse("go1.9").unwrap(); + let v2 = GoVersion::parse("go1.9.2rc2").unwrap(); + assert_ne!(v1.sort_key(), v2.sort_key()); + // go1.9 (stable) should sort before go1.9.2rc2 + assert!(v1.sort_key() < v2.sort_key()); + } +} + +/// Describes a single file stored at `dl.google.com/go/`. +#[derive(Debug, Clone, PartialEq, Eq)] +struct GoFile<'a> { + filename: &'a str, + version: GoVersion, + os: Option<&'a str>, + arch: Option<&'a str>, + kind: FileKind, + archive: Archive, + sha256: bool, +} + +impl<'a> GoFile<'a> { + pub fn parse(filename: &'a str) -> Result<Self, ParseError> { + let mut buffer = filename; + let mut sha256 = false; + let archive; + + // Strip "go" prefix + buffer = buffer.strip_prefix("go").ok_or(ParseError)?; + + // Check for .sha256 suffix + if let Some(it) = buffer.strip_suffix(".sha256") { + buffer = it; + sha256 = true; + } + + // Determine archive type + if let Some(it) = buffer.strip_suffix(".tar.gz") { + buffer = it; + archive = Archive::TarGz; + } else if let Some(it) = buffer.strip_suffix(".zip") { + buffer = it; + archive = Archive::Zip; + } else if let Some(it) = buffer.strip_suffix(".msi") { + buffer = it; + archive = Archive::Msi; + } else if let Some(it) = buffer.strip_suffix(".pkg") { + buffer = it; + archive = Archive::Pkg; + } else { + return Err(ParseError); + } + + if buffer.is_empty() { + return Err(ParseError); + } + + // Split by dots: "1.25.6.linux-amd64" -> ["1", "25", "6", "linux-amd64"] + let parts: Vec<&str> = buffer.split('.').collect(); + if parts.len() < 3 { + return Err(ParseError); + } + + // Parse version, get how many parts were consumed + let (version, consumed) = GoVersion::from_parts(&parts)?; + + // Remainder must exist and be either "src" or "os-arch" + let remainder = parts.get(consumed).ok_or(ParseError)?; + let (os, arch, kind) = if *remainder == "src" { + (None, None, FileKind::Source) + } else if let Some((os, arch)) = remainder.split_once('-') { + let kind = match archive { + Archive::Msi | Archive::Pkg => FileKind::Installer, + _ => FileKind::Archive, + }; + (Some(os), Some(arch), kind) + } else { + return Err(ParseError); + }; + + Ok(GoFile { + filename, + version, + os, + arch, + kind, + archive, + sha256, + }) + } + + /// Builds the upstream URL for this tarball. + pub fn upstream_url(&self, upstream: &Url, source: &str) -> Result<Url, ()> { + let mut url = upstream.clone(); + url.path_segments_mut() + .map_err(|_| ())? + .pop_if_empty() + .push(self.filename); + url.query_pairs_mut().append_pair("source", source); + Ok(url) + } +} + +#[cfg(test)] +mod file_tests { + use super::*; + + #[test] + fn test_parse_stable_binary() { + let t = GoFile::parse("go1.25.6.linux-amd64.tar.gz").unwrap(); + assert_eq!(t.version.major, 1); + assert_eq!(t.version.minor, 25); + assert_eq!(t.version.patch, Some(6)); + assert!(matches!(t.version.release_type, ReleaseType::Stable)); + assert_eq!(t.os, Some("linux")); + assert_eq!(t.arch, Some("amd64")); + assert!(matches!(t.kind, FileKind::Archive)); + assert_eq!(t.archive, Archive::TarGz); + assert!(!t.sha256); + } + + #[test] + fn test_parse_first_minor_release() { + let t = GoFile::parse("go1.25.linux-amd64.tar.gz").unwrap(); + assert_eq!(t.version.major, 1); + assert_eq!(t.version.minor, 25); + assert_eq!(t.version.patch, None); + assert!(matches!(t.version.release_type, ReleaseType::Stable)); + } + + #[test] + fn test_parse_rc() { + let t = GoFile::parse("go1.26rc2.linux-amd64.tar.gz").unwrap(); + assert_eq!(t.version.major, 1); + assert_eq!(t.version.minor, 26); + assert_eq!(t.version.patch, None); + assert!(matches!( + t.version.release_type, + ReleaseType::ReleaseCandidate(2) + )); + } + + #[test] + fn test_parse_beta() { + let t = GoFile::parse("go1.26beta1.darwin-arm64.tar.gz").unwrap(); + assert_eq!(t.version.major, 1); + assert_eq!(t.version.minor, 26); + assert!(matches!(t.version.release_type, ReleaseType::Beta(1))); + } + + #[test] + fn test_parse_source() { + let t = GoFile::parse("go1.25.6.src.tar.gz").unwrap(); + assert!(matches!(t.kind, FileKind::Source)); + assert_eq!(t.os, None); + assert_eq!(t.arch, None); + assert_eq!(t.version.patch, Some(6)); + } + + #[test] + fn test_parse_windows_zip() { + let t = GoFile::parse("go1.25.6.windows-amd64.zip").unwrap(); + assert_eq!(t.archive, Archive::Zip); + assert_eq!(t.os, Some("windows")); + assert_eq!(t.arch, Some("amd64")); + assert!(matches!(t.kind, FileKind::Archive)); + } + + #[test] + fn test_parse_msi() { + let t = GoFile::parse("go1.25.6.windows-amd64.msi").unwrap(); + assert_eq!(t.archive, Archive::Msi); + assert!(matches!(t.kind, FileKind::Installer)); + } + + #[test] + fn test_parse_pkg() { + let t = GoFile::parse("go1.25.6.darwin-arm64.pkg").unwrap(); + assert_eq!(t.archive, Archive::Pkg); + assert!(matches!(t.kind, FileKind::Installer)); + } + + #[test] + fn test_parse_sha256() { + let t = GoFile::parse("go1.25.6.linux-amd64.tar.gz.sha256").unwrap(); + assert!(t.sha256); + assert_eq!(t.archive, Archive::TarGz); + assert_eq!(t.version.patch, Some(6)); + } + + #[test] + fn test_upstream_url() { + let t = GoFile::parse("go1.25.6.linux-amd64.tar.gz").unwrap(); + let upstream = Url::parse("https://dl.google.com/go/").unwrap(); + let url = t.upstream_url(&upstream, "zorian:test").unwrap(); + assert_eq!( + url.as_str(), + "https://dl.google.com/go/go1.25.6.linux-amd64.tar.gz?source=zorian%3Atest" + ); + } + + #[test] + fn test_parse_patch_rc() { + let t = GoFile::parse("go1.9.2rc2.linux-amd64.tar.gz").unwrap(); + assert_eq!(t.version.major, 1); + assert_eq!(t.version.minor, 9); + assert_eq!(t.version.patch, Some(2)); + assert!(matches!( + t.version.release_type, + ReleaseType::ReleaseCandidate(2) + )); + } + + #[test] + fn test_invalid_prefix() { + assert!(GoFile::parse("rust1.25.6.linux-amd64.tar.gz").is_err()); + } + + #[test] + fn test_invalid_extension() { + assert!(GoFile::parse("go1.25.6.linux-amd64.tar.bz2").is_err()); + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct GoTarball { + pub filename: String, + pub os: Option<String>, + pub arch: Option<String>, + pub version: Option<String>, + pub sha256: String, + pub size: u64, + pub kind: FileKind, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct GoRelease { + pub version: String, + pub stable: bool, + pub files: Vec<GoTarball>, +} + +pub struct GoBackend { + config: GoConfig, + source: String, + delegate: Arc<dyn BackendDelegate>, +} +impl GoBackend { + pub fn new(config: GoConfig, source: String, delegate: Arc<dyn BackendDelegate>) -> Self { + Self { + config, + source, + delegate, + } + } +} +#[async_trait::async_trait] +impl Backend for GoBackend { + const ID: &'static str = "go"; + type Release = self::GoRelease; + + fn enabled(&self) -> bool { + self.config.enabled + } + + fn refresh_interval(&self) -> std::time::Duration { + self.config.refresh_interval + } + + async fn resolve_file(&self, filename: &str) -> Result<ResolvedFile, ResolveError> { + // For .sha256 files, return hash directly from the index + if let Some(base) = filename.strip_suffix(".sha256") { + let result: Result<Option<String>, _> = + sqlx::query_scalar("SELECT sha256 FROM go_files WHERE filename = ?1") + .bind(base) + .fetch_optional(self.delegate.db()) + .await; + + match result { + Ok(Some(hash)) => { + return Ok(ResolvedFile::Content { + data: hash.into(), + mime: "text/plain", + }); + } + Ok(None) => return Err(ResolveError::NotFound), + Err(e) => { + tracing::error!(filename, "failed to query sha256: {e}"); + return Err(ResolveError::Internal); + } + } + } + + // Check that file exists in index before proxying to upstream + let exists: Result<Option<i32>, _> = + sqlx::query_scalar("SELECT 1 FROM go_files WHERE filename = ?1") + .bind(filename) + .fetch_optional(self.delegate.db()) + .await; + + match exists { + Ok(None) => return Err(ResolveError::NotFound), + Err(e) => { + tracing::error!(filename, "failed to check file existence: {e}"); + return Err(ResolveError::Internal); + } + Ok(Some(_)) => {} + } + + let file = GoFile::parse(filename).map_err(|_| ResolveError::NotFound)?; + let url = file + .upstream_url(&self.config.upstream, &self.source) + .map_err(|_| ResolveError::Internal)?; + Ok(ResolvedFile::Upstream(url)) + } + + async fn migrate(&self) -> Result<(), IndexError> { + sqlx::query( + "CREATE TABLE IF NOT EXISTS go_versions ( + id INTEGER PRIMARY KEY, + version TEXT NOT NULL UNIQUE, + stable INTEGER NOT NULL + ) STRICT", + ) + .execute(self.delegate.db()) + .await + .map_err(|e| IndexError::Database(e.to_string()))?; + + sqlx::query( + "CREATE TABLE IF NOT EXISTS go_files ( + version TEXT NOT NULL, + filename TEXT NOT NULL, + os TEXT, + arch TEXT, + sha256 TEXT NOT NULL, + size INTEGER NOT NULL, + kind TEXT NOT NULL, + PRIMARY KEY (version, filename), + FOREIGN KEY (version) REFERENCES go_versions(version) + ) STRICT", + ) + .execute(self.delegate.db()) + .await + .map_err(|e| IndexError::Database(e.to_string()))?; + + Ok(()) + } + + async fn fetch_index(&self) -> Result<(), IndexError> { + let mut url = self.config.upstream.clone(); + url.query_pairs_mut() + .append_pair("mode", "json") + .append_pair("include", "all"); + let bytes = self.delegate.http_get(&url).await?; + + let versions: Vec<GoRelease> = + serde_json::from_slice(&bytes).map_err(|e| IndexError::Parse(e.to_string()))?; + + for version in versions { + if let Err(e) = self.insert_version(&version).await { + tracing::error!(version = version.version, "failed to index version: {e}"); + } + } + + Ok(()) + } + + async fn get_versions(&self) -> Result<Vec<Self::Release>, IndexError> { + use futures::{StreamExt, TryStreamExt}; + + sqlx::query_as( + " + SELECT + v.version, v.stable, + COALESCE( + json_group_array(json_object( + 'filename', f.filename, 'os', f.os, 'arch', f.arch, + 'version', f.version, 'sha256', f.sha256, 'size', f.size, 'kind', f.kind + )) FILTER (WHERE f.filename IS NOT NULL), + '[]' + ) + FROM go_versions v + LEFT JOIN go_files f ON v.version = f.version + GROUP BY v.version + ORDER BY v.id ASC + ", + ) + .fetch(self.delegate.db()) + .map(|row| { + let (version, stable, files_json): (String, bool, String) = + row.map_err(|e| IndexError::Database(e.to_string()))?; + let files = + serde_json::from_str(&files_json).map_err(|e| IndexError::Parse(e.to_string()))?; + Ok(GoRelease { + version, + stable, + files, + }) + }) + .try_collect() + .await + } +} +impl GoBackend { + async fn insert_version(&self, version: &GoRelease) -> Result<(), IndexError> { + let id = GoVersion::parse(&version.version) + .map(|v| v.sort_key()) + .map_err(|_| IndexError::Parse(format!("invalid go version: {}", version.version)))?; + + let mut tx = self + .delegate + .db() + .begin() + .await + .map_err(|e| IndexError::Database(e.to_string()))?; + + sqlx::query( + "INSERT INTO go_versions (id, version, stable) + VALUES (?1, ?2, ?3) + ON CONFLICT(version) DO UPDATE SET + id = excluded.id, + stable = excluded.stable + WHERE id IS NOT excluded.id OR stable IS NOT excluded.stable", + ) + .bind(id) + .bind(&version.version) + .bind(version.stable) + .execute(&mut *tx) + .await + .map_err(|e| IndexError::Database(e.to_string()))?; + + for file in &version.files { + Self::insert_file(&mut tx, &version.version, file).await?; + } + + tx.commit() + .await + .map_err(|e| IndexError::Database(e.to_string()))?; + Ok(()) + } + + async fn insert_file( + tx: &mut sqlx::Transaction<'_, sqlx::Sqlite>, + version: &str, + file: &GoTarball, + ) -> Result<(), IndexError> { + let kind = match file.kind { + FileKind::Source => "source", + FileKind::Archive => "archive", + FileKind::Installer => "installer", + FileKind::Bootstrap => unreachable!("go does not have bootstrap files"), + }; + + let os = file.os.as_deref().filter(|s| !s.is_empty()); + + let exists: Option<i32> = + sqlx::query_scalar("SELECT 1 FROM go_files WHERE version = ?1 AND filename = ?2") + .bind(version) + .bind(&file.filename) + .fetch_optional(&mut **tx) + .await + .map_err(|e| IndexError::Database(e.to_string()))?; + + let changed: Option<(i32,)> = sqlx::query_as( + "INSERT INTO go_files (version, filename, os, arch, sha256, size, kind) + VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7) + ON CONFLICT(version, filename) DO UPDATE SET + os = excluded.os, arch = excluded.arch, sha256 = excluded.sha256, + size = excluded.size, kind = excluded.kind + WHERE os IS NOT excluded.os OR arch IS NOT excluded.arch + OR sha256 IS NOT excluded.sha256 OR size IS NOT excluded.size + OR kind IS NOT excluded.kind + RETURNING 1", + ) + .bind(version) + .bind(&file.filename) + .bind(os) + .bind(&file.arch) + .bind(&file.sha256) + .bind(file.size as i64) + .bind(kind) + .fetch_optional(&mut **tx) + .await + .map_err(|e| IndexError::Database(e.to_string()))?; + + if exists.is_some() && changed.is_some() { + tracing::warn!(version, filename = file.filename, "go index file changed"); + } + + Ok(()) + } +} + +#[cfg(test)] +mod api_tests { + use super::*; + + #[test] + fn test_deserialize_go_release() { + let json = r#"{ + "version": "go1.22.0", + "stable": true, + "files": [ + { + "filename": "go1.22.0.windows-amd64.msi", + "os": "windows", + "arch": "amd64", + "version": "go1.22.0", + "sha256": "11a47de052db9971359e8c2f3a1667f8d56fa4c6bbec0687cf4cf2403a07628a", + "size": 63172608, + "kind": "installer" + } + ] + }"#; + + let release: GoRelease = serde_json::from_str(json).unwrap(); + assert_eq!(release.version, "go1.22.0"); + assert_eq!(release.files.len(), 1); + assert_eq!(release.files[0].filename, "go1.22.0.windows-amd64.msi"); + assert_eq!(release.files[0].size, 63172608); + } +} diff --git a/src/backends/mod.rs b/src/backends/mod.rs new file mode 100644 --- /dev/null +++ b/src/backends/mod.rs @@ -0,0 +1,283 @@ +// SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> +// SPDX-License-Identifier: AGPL-3.0-or-later + +pub mod go; +pub mod zig; + +use std::time::Duration; + +use async_trait::async_trait; +use bytes::Bytes; +use serde::{Deserialize, Serialize}; +use sqlx::{Pool, Sqlite}; +use thiserror::Error; +use url::Url; + +pub use go::{GoBackend, GoConfig}; +pub use zig::{ZigBackend, ZigConfig}; + +/// Error during index operations. +#[derive(Debug, Error)] +pub enum IndexError { + #[error("fetch error: {0}")] + Fetch(String), + + #[error("database error: {0}")] + Database(String), + + #[error("parse error: {0}")] + Parse(String), +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Archive { + TarGz, + TarXz, + Zip, + Msi, + Pkg, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum FileKind { + Source, + Bootstrap, + Archive, + Installer, +} + +/// Error during file resolution. +#[derive(Debug, Clone, Copy)] +pub enum ResolveError { + /// File not found (404) + NotFound, + /// Internal error (500) + Internal, +} + +/// Result of resolving a file request. +pub enum ResolvedFile { + /// Proxy request to upstream URL + Upstream(Url), + /// Return content directly + Content { + data: bytes::Bytes, + mime: &'static str, + }, +} + +/// Delegate provides I/O primitives to backends. +#[async_trait] +pub trait BackendDelegate: Send + Sync { + /// Get SQLite pool + fn db(&self) -> &Pool<Sqlite>; + + /// HTTP GET request + async fn http_get(&self, url: &Url) -> Result<Bytes, IndexError>; +} + +/// Trait for backend-specific logic (parsing, URL building, version indexing). +#[async_trait] +pub trait Backend: Send + Sync + 'static { + /// Fixed unique identifier for storage + const ID: &'static str; + + /// Backend-specific release representation + type Release; + + /// Whether the backend is enabled + fn enabled(&self) -> bool; + + /// Index refresh interval + fn refresh_interval(&self) -> Duration; + + /// Create tables for this backend (called at startup) + async fn migrate(&self) -> Result<(), IndexError>; + + /// Fetch index from upstream and store in DB + async fn fetch_index(&self) -> Result<(), IndexError>; + + /// Resolves filename to upstream URL or direct content. + async fn resolve_file(&self, filename: &str) -> Result<ResolvedFile, ResolveError>; + + /// Load versions from DB + async fn get_versions(&self) -> Result<Vec<Self::Release>, IndexError>; +} + +/// Version type for ordering. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum VersionType { + Stable, + Rc(u64), + Beta(u64), + Dev(u64), +} + +/// Computes numeric sort key for correct version ordering. +/// +/// Formula: major × 10^12 + minor × 10^9 + patch × 10^6 + type × 10^4 + num +/// Where type: dev=10, beta=25, rc=50, stable=99 +/// +/// Examples: +/// - 1.21.3 stable → 1_021_003_990_000 +/// - 1.22.0 beta(1) → 1_022_000_250_001 +/// - 1.22.0 rc(2) → 1_022_000_500_002 +/// - 0.13.0 dev(1234) → 0_013_000_101_234 +pub fn stable_version(major: u64, minor: u64, patch: u64, vtype: VersionType) -> i64 { + let (type_val, num) = match vtype { + VersionType::Stable => (99, 0), + VersionType::Rc(n) => (50, n), + VersionType::Beta(n) => (25, n), + VersionType::Dev(n) => (10, n), + }; + + (major as i64) * 1_000_000_000_000 + + (minor as i64) * 1_000_000_000 + + (patch as i64) * 1_000_000 + + (type_val as i64) * 10_000 + + (num as i64) +} + +#[cfg(test)] +mod tests { + use super::*; + use std::collections::HashSet; + + use proptest::prelude::*; + + #[test] + fn test_stable_version_ordering() { + // dev < beta < rc < stable + let dev = stable_version(1, 0, 0, VersionType::Dev(1)); + let beta = stable_version(1, 0, 0, VersionType::Beta(1)); + let rc = stable_version(1, 0, 0, VersionType::Rc(1)); + let stable = stable_version(1, 0, 0, VersionType::Stable); + + assert!(dev < beta); + assert!(beta < rc); + assert!(rc < stable); + } + + #[test] + fn test_stable_version_patch_ordering() { + let v1_0_0 = stable_version(1, 0, 0, VersionType::Stable); + let v1_0_1 = stable_version(1, 0, 1, VersionType::Stable); + let v1_1_0 = stable_version(1, 1, 0, VersionType::Stable); + let v2_0_0 = stable_version(2, 0, 0, VersionType::Stable); + + assert!(v1_0_0 < v1_0_1); + assert!(v1_0_1 < v1_1_0); + assert!(v1_1_0 < v2_0_0); + } + + #[test] + fn test_stable_version_rc_before_stable() { + // 1.22.0-rc1 < 1.22.0-rc2 < 1.22.0 + let rc1 = stable_version(1, 22, 0, VersionType::Rc(1)); + let rc2 = stable_version(1, 22, 0, VersionType::Rc(2)); + let stable = stable_version(1, 22, 0, VersionType::Stable); + + assert!(rc1 < rc2); + assert!(rc2 < stable); + } + + #[test] + fn test_stable_version_no_collisions() { + let mut keys = HashSet::new(); + + // Test a range of realistic versions + for major in 0..3 { + for minor in 0..30 { + for patch in 0..20 { + let key = stable_version(major, minor, patch, VersionType::Stable); + assert!(keys.insert(key), "collision at {major}.{minor}.{patch}"); + } + // Also test pre-release versions + for n in 1..10 { + let rc = stable_version(major, minor, 0, VersionType::Rc(n)); + assert!(keys.insert(rc), "collision at {major}.{minor}.0-rc{n}"); + + let beta = stable_version(major, minor, 0, VersionType::Beta(n)); + assert!(keys.insert(beta), "collision at {major}.{minor}.0-beta{n}"); + + let dev = stable_version(major, minor, 0, VersionType::Dev(n)); + assert!(keys.insert(dev), "collision at {major}.{minor}.0-dev{n}"); + } + } + } + } + + #[test] + fn test_stable_version_expected_values() { + // Verify the documented examples + assert_eq!( + stable_version(1, 21, 3, VersionType::Stable), + 1_021_003_990_000 + ); + assert_eq!( + stable_version(1, 22, 0, VersionType::Beta(1)), + 1_022_000_250_001 + ); + assert_eq!( + stable_version(1, 22, 0, VersionType::Rc(2)), + 1_022_000_500_002 + ); + assert_eq!( + stable_version(0, 13, 0, VersionType::Dev(1234)), + 13_000_101_234 + ); + } + + fn version_type_strategy() -> impl Strategy<Value = VersionType> { + prop_oneof![ + Just(VersionType::Stable), + (1..100u64).prop_map(VersionType::Rc), + (1..100u64).prop_map(VersionType::Beta), + (1..9999u64).prop_map(VersionType::Dev), + ] + } + + fn to_semver(major: u64, minor: u64, patch: u64, vtype: VersionType) -> semver::Version { + let pre = match vtype { + VersionType::Stable => semver::Prerelease::EMPTY, + VersionType::Rc(n) => semver::Prerelease::new(&format!("rc.{n}")).unwrap(), + VersionType::Beta(n) => semver::Prerelease::new(&format!("beta.{n}")).unwrap(), + VersionType::Dev(n) => semver::Prerelease::new(&format!("dev.{n}")).unwrap(), + }; + semver::Version { + major, + minor, + patch, + pre, + build: semver::BuildMetadata::EMPTY, + } + } + + proptest! { + #[test] + fn fuzz_stable_version_matches_semver( + major1 in 0..100u64, + minor1 in 0..1000u64, + patch1 in 0..1000u64, + vtype1 in version_type_strategy(), + major2 in 0..100u64, + minor2 in 0..1000u64, + patch2 in 0..1000u64, + vtype2 in version_type_strategy(), + ) { + let key1 = stable_version(major1, minor1, patch1, vtype1); + let key2 = stable_version(major2, minor2, patch2, vtype2); + + let sem1 = to_semver(major1, minor1, patch1, vtype1); + let sem2 = to_semver(major2, minor2, patch2, vtype2); + + let key_cmp = key1.cmp(&key2); + let sem_cmp = sem1.cmp(&sem2); + + prop_assert_eq!(key_cmp, sem_cmp, + "Mismatch: {} vs {}: stable_version gives {:?}, semver gives {:?}", + sem1, sem2, key_cmp, sem_cmp); + } + } +} diff --git a/src/backends/zig.rs b/src/backends/zig.rs new file mode 100644 --- /dev/null +++ b/src/backends/zig.rs @@ -0,0 +1,495 @@ +// SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> +// SPDX-License-Identifier: AGPL-3.0-or-later + +use std::collections::HashMap; +use std::sync::Arc; +use std::time::Duration; + +use semver::Version as SemVersion; +use serde::{Deserialize, Serialize}; +use thiserror::Error; +use url::Url; + +use super::{ + Archive, Backend, BackendDelegate, FileKind, IndexError, ResolveError, ResolvedFile, + VersionType, stable_version, +}; +use crate::utils::{deserialize_duration_secs, deserialize_size}; + +#[derive(Debug, Clone, Deserialize)] +#[serde(default)] +pub struct ZigConfig { + pub enabled: bool, + pub upstream: Url, + #[serde(deserialize_with = "deserialize_duration_secs")] + pub refresh_interval: Duration, +} +impl Default for ZigConfig { + fn default() -> Self { + Self { + enabled: true, + upstream: Url::parse("https://ziglang.org").unwrap(), + refresh_interval: Duration::from_secs(60 * 10), + } + } +} + +/// Wrapper for sort key computation. +enum ZigVersion { + Master, + Semver(SemVersion), +} +impl ZigVersion { + fn parse(s: &str) -> Result<Self, IndexError> { + if s == "master" { + return Ok(Self::Master); + } + SemVersion::parse(s) + .map(Self::Semver) + .map_err(|_| IndexError::Parse(format!("invalid zig version: {s}"))) + } + + fn sort_key(&self) -> i64 { + match self { + Self::Master => i64::MAX, + Self::Semver(v) => { + let vtype = if v.pre.is_empty() { + VersionType::Stable + } else if v.pre.as_str().starts_with("dev.") { + let num = v.pre.as_str()[4..].parse().unwrap_or(0); + VersionType::Dev(num) + } else { + VersionType::Stable + }; + + stable_version(v.major, v.minor, v.patch, vtype) + } + } + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Error)] +#[error("invalid tarball filename")] +struct ParseError; + +/// Describes a single file stored at `ziglang.org/download/`. +/// +/// The tarball naming has changed several times. When parsing, +/// we standardize the files, but for the reverse operation +/// (getting a string from a tarball), we preserve the original path. +#[derive(Debug, Clone, PartialEq, Eq)] +struct ZigFile<'a> { + filename: &'a str, + os: Option<&'a str>, + arch: Option<&'a str>, + kind: FileKind, + minisig: bool, + archive: Archive, + version: SemVersion, + development: bool, +} + +impl<'a> ZigFile<'a> { + pub fn parse(filename: &'a str) -> Result<Self, ParseError> { + let mut buffer = filename; + let mut minisig = false; + let archive; + + // (?:|-bootstrap|-[a-zA-Z0-9_]+-[a-zA-Z0-9_]+)-( + // \d+\.\d+\.\d+(?:-dev\.\d+\+[0-9a-f]+)? + // )\.(?:tar\.xz|zip)(?:\.minisig)? + buffer = buffer.strip_prefix("zig-").ok_or(ParseError)?; + + // (?:|bootstrap|[a-zA-Z0-9_]+-[a-zA-Z0-9_]+)-( + // \d+\.\d+\.\d+(?:-dev\.\d+\+[0-9a-f]+)? + // )\.(?:tar\.xz|zip) + if let Some(it) = buffer.strip_suffix(".minisig") { + buffer = it; + minisig = true; + } + + // (?:|bootstrap|[a-zA-Z0-9_]+-[a-zA-Z0-9_]+)-( + // \d+\.\d+\.\d+(?:-dev\.\d+\+[0-9a-f]+)? + // ) + if let Some(it) = buffer.strip_suffix(".zip") { + buffer = it; + archive = Archive::Zip; + } else if let Some(it) = buffer.strip_suffix(".tar.xz") { + buffer = it; + archive = Archive::TarXz; + } else { + return Err(ParseError); + } + + if buffer.is_empty() { + return Err(ParseError); + } + + let mut it = buffer.rsplit('-'); + let last = it.next().ok_or(ParseError)?; + + let development = last.starts_with("dev"); + + let version = if !development { + SemVersion::parse(last).map_err(|_| ParseError)? + } else { + let semver = it.next().ok_or(ParseError)?; + let devver = last; + let version_str = format!("{}-{}", semver, devver); + SemVersion::parse(&version_str).map_err(|_| ParseError)? + }; + + let (os, arch, kind) = if let Some(payload) = it.next() { + if payload == "bootstrap" { + (None, None, FileKind::Bootstrap) + } else { + // Version 0.14.0 is the last one to use the OS-ARCH format in names; newer versions use ARCH-OS. + let min_version = SemVersion::new(0, 14, 0); + let (os, arch) = if version > min_version { + (payload, it.next().ok_or(ParseError)?) + } else { + (it.next().ok_or(ParseError)?, payload) + }; + (Some(os), Some(arch), FileKind::Archive) + } + } else { + (None, None, FileKind::Source) + }; + + if it.next().is_some() { + return Err(ParseError); + } + + Ok(ZigFile { + filename, + os, + arch, + kind, + minisig, + archive, + version, + development, + }) + } + + /// Builds the upstream URL for this tarball. + pub fn upstream_url(&self, upstream: &Url, source: &str) -> Result<Url, ()> { + let mut url = upstream.clone(); + { + let mut segments = url.path_segments_mut().map_err(|_| ())?; + segments.pop_if_empty(); + if self.development { + segments.push("builds"); + } else { + segments.push("download").push(&self.version.to_string()); + } + segments.push(self.filename); + } + url.query_pairs_mut().append_pair("source", source); + Ok(url) + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct ZigTarball { + /// e.g. "zig-x86_64-linux-0.15.2.tar.xz" + /// Note: upstream API returns full URL in "tarball" field, we extract filename when storing + #[serde(alias = "tarball")] + pub filename: String, + + /// e.g. "02aa270f183da276e5b5920b1dac44a63f1a49e55050ebde3aecc9eb82f93239" + pub shasum: String, + + /// e.g. 53733924 + #[serde(deserialize_with = "deserialize_size")] + pub size: u64, +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct ZigRelease { + /// e.g. "0.15.2" (older releases don't have this field) + #[serde(default)] + pub version: String, + + /// e.g. "2025-10-11" + pub date: Option<String>, + + /// e.g. "https://ziglang.org/documentation/0.15.2/" + pub docs: Option<String>, + + /// e.g. "https://ziglang.org/documentation/0.15.2/std/" + #[serde(rename = "stdDocs")] + pub std_docs: Option<String>, + + /// e.g. "https://ziglang.org/download/0.15.2/release-notes.html" + pub notes: Option<String>, + + /// Source tarball + pub src: Option<ZigTarball>, + + /// Bootstrap tarball + pub bootstrap: Option<ZigTarball>, + + /// Platform-specific files (e.g., "x86_64-linux", "aarch64-macos") + #[serde(flatten)] + pub targets: HashMap<String, ZigTarball>, +} + +pub struct ZigBackend { + config: ZigConfig, + source: String, + delegate: Arc<dyn BackendDelegate>, +} +impl ZigBackend { + pub fn new(config: ZigConfig, source: String, delegate: Arc<dyn BackendDelegate>) -> Self { + Self { + config, + source, + delegate, + } + } +} +#[async_trait::async_trait] +impl Backend for ZigBackend { + const ID: &'static str = "zig"; + type Release = self::ZigRelease; + + fn enabled(&self) -> bool { + self.config.enabled + } + + fn refresh_interval(&self) -> std::time::Duration { + self.config.refresh_interval + } + + async fn resolve_file(&self, filename: &str) -> Result<ResolvedFile, ResolveError> { + let file = ZigFile::parse(filename).map_err(|_| ResolveError::NotFound)?; + + // For stable builds, check that file exists in index + if !file.development { + let exists: Result<Option<i32>, _> = + sqlx::query_scalar("SELECT 1 FROM zig_files WHERE filename = ?1") + .bind(filename) + .fetch_optional(self.delegate.db()) + .await; + + match exists { + Ok(None) => return Err(ResolveError::NotFound), + Err(e) => { + tracing::error!(filename, "failed to check file existence: {e}"); + return Err(ResolveError::Internal); + } + Ok(Some(_)) => {} + } + } + + let url = file + .upstream_url(&self.config.upstream, &self.source) + .map_err(|_| ResolveError::Internal)?; + Ok(ResolvedFile::Upstream(url)) + } + + async fn migrate(&self) -> Result<(), IndexError> { + sqlx::query( + "CREATE TABLE IF NOT EXISTS zig_versions ( + id INTEGER PRIMARY KEY, + version TEXT NOT NULL UNIQUE, + date TEXT, + docs TEXT, + std_docs TEXT, + notes TEXT + ) STRICT", + ) + .execute(self.delegate.db()) + .await + .map_err(|e| IndexError::Database(e.to_string()))?; + + sqlx::query( + "CREATE TABLE IF NOT EXISTS zig_files ( + version TEXT NOT NULL, + target TEXT NOT NULL, + filename TEXT NOT NULL, + shasum TEXT NOT NULL, + size INTEGER NOT NULL, + PRIMARY KEY (version, target), + FOREIGN KEY (version) REFERENCES zig_versions(version) + ) STRICT", + ) + .execute(self.delegate.db()) + .await + .map_err(|e| IndexError::Database(e.to_string()))?; + + Ok(()) + } + + async fn fetch_index(&self) -> Result<(), IndexError> { + let mut url = self.config.upstream.clone(); + url.path_segments_mut() + .map_err(|_| IndexError::Parse("cannot-be-a-base URL".into()))? + .pop_if_empty() + .extend(["download", "index.json"]); + let bytes = self.delegate.http_get(&url).await?; + + let index: HashMap<String, ZigRelease> = + serde_json::from_slice(&bytes).map_err(|e| IndexError::Parse(e.to_string()))?; + + for (version_str, version) in index { + if let Err(e) = self.insert_version(&version_str, &version).await { + tracing::error!(version = version_str, "failed to index version: {e}"); + } + } + + Ok(()) + } + + async fn get_versions(&self) -> Result<Vec<Self::Release>, IndexError> { + use futures::{StreamExt, TryStreamExt}; + + #[derive(Deserialize)] + struct FileRow { + target: String, + filename: String, + shasum: String, + size: u64, + } + + sqlx::query_as(" + SELECT + v.version, v.date, v.docs, v.std_docs, v.notes, + COALESCE( + json_group_array(json_object('target', f.target, 'filename', f.filename, 'shasum', f.shasum, 'size', f.size)) FILTER (WHERE f.version IS NOT NULL), + '[]' + ) + FROM zig_versions v + LEFT JOIN zig_files f ON v.version = f.version + GROUP BY v.version + ORDER BY v.id ASC + ") + .fetch(self.delegate.db()) + .map(|row| { + let (version, date, docs, std_docs, notes, files_json): + (String, Option<String>, Option<String>, Option<String>, Option<String>, String) = + row.map_err(|e| IndexError::Database(e.to_string()))?; + + let file_rows: Vec<FileRow> = serde_json::from_str(&files_json) + .map_err(|e| IndexError::Parse(e.to_string()))?; + + let mut src = None; + let mut bootstrap = None; + let mut targets = HashMap::new(); + + for f in file_rows { + let file = ZigTarball { filename: f.filename, shasum: f.shasum, size: f.size }; + match f.target.as_str() { + "src" => src = Some(file), + "bootstrap" => bootstrap = Some(file), + _ => { targets.insert(f.target, file); } + } + } + + Ok(ZigRelease { version, date, docs, std_docs, notes, src, bootstrap, targets }) + }) + .try_collect() + .await + } +} +impl ZigBackend { + async fn insert_version( + &self, + version_str: &str, + version: &ZigRelease, + ) -> Result<(), IndexError> { + let id = ZigVersion::parse(version_str)?.sort_key(); + + let mut tx = self + .delegate + .db() + .begin() + .await + .map_err(|e| IndexError::Database(e.to_string()))?; + + sqlx::query( + "INSERT INTO zig_versions (id, version, date, docs, std_docs, notes) + VALUES (?1, ?2, ?3, ?4, ?5, ?6) + ON CONFLICT(version) DO UPDATE SET + id = excluded.id, + date = excluded.date, docs = excluded.docs, + std_docs = excluded.std_docs, notes = excluded.notes + WHERE id IS NOT excluded.id OR date IS NOT excluded.date + OR docs IS NOT excluded.docs OR std_docs IS NOT excluded.std_docs + OR notes IS NOT excluded.notes", + ) + .bind(id) + .bind(version_str) + .bind(&version.date) + .bind(&version.docs) + .bind(&version.std_docs) + .bind(&version.notes) + .execute(&mut *tx) + .await + .map_err(|e| IndexError::Database(e.to_string()))?; + + if let Some(ref file) = version.src { + Self::insert_file(&mut tx, version_str, "src", file).await?; + } + if let Some(ref file) = version.bootstrap { + Self::insert_file(&mut tx, version_str, "bootstrap", file).await?; + } + for (target, file) in &version.targets { + Self::insert_file(&mut tx, version_str, target, file).await?; + } + + tx.commit() + .await + .map_err(|e| IndexError::Database(e.to_string()))?; + Ok(()) + } + + async fn insert_file( + tx: &mut sqlx::Transaction<'_, sqlx::Sqlite>, + version: &str, + target: &str, + file: &ZigTarball, + ) -> Result<(), IndexError> { + let url = Url::parse(&file.filename) + .map_err(|e| IndexError::Parse(format!("invalid tarball URL: {e}")))?; + let filename = url + .path_segments() + .and_then(|mut s| s.next_back()) + .filter(|s| !s.is_empty()) + .ok_or_else(|| IndexError::Parse(format!("no filename in URL: {}", file.filename)))?; + + let exists: Option<i32> = + sqlx::query_scalar("SELECT 1 FROM zig_files WHERE version = ?1 AND target = ?2") + .bind(version) + .bind(target) + .fetch_optional(&mut **tx) + .await + .map_err(|e| IndexError::Database(e.to_string()))?; + + let changed: Option<(i32,)> = sqlx::query_as( + "INSERT INTO zig_files (version, target, filename, shasum, size) + VALUES (?1, ?2, ?3, ?4, ?5) + ON CONFLICT(version, target) DO UPDATE SET + filename = excluded.filename, shasum = excluded.shasum, size = excluded.size + WHERE filename IS NOT excluded.filename + OR shasum IS NOT excluded.shasum + OR size IS NOT excluded.size + RETURNING 1", + ) + .bind(version) + .bind(target) + .bind(filename) + .bind(&file.shasum) + .bind(file.size as i64) + .fetch_optional(&mut **tx) + .await + .map_err(|e| IndexError::Database(e.to_string()))?; + + if exists.is_some() && changed.is_some() { + tracing::warn!(version, target, "zig index file changed"); + } + + Ok(()) + } +} diff --git a/crates/tesor/src/config.rs b/src/config.rs index e9e148a..c7437aa 100644 --- a/crates/tesor/src/config.rs +++ b/src/config.rs @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2026 Nikolay Govorov +// SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> // SPDX-License-Identifier: AGPL-3.0-or-later use std::collections::HashMap; @@ -10,10 +10,9 @@ use std::time::Duration; use bytesize::ByteSize; use serde::Deserialize; use thiserror::Error; -use tracing::info; -use base::serde::{deserialize_duration, deserialize_listener_addr}; -use repos::{GoConfig, ZigConfig}; +use crate::backends::{GoConfig, ZigConfig}; +use crate::utils::{deserialize_duration_secs, deserialize_listener_addr}; #[derive(Debug, Error)] pub enum ConfigError { @@ -51,11 +50,11 @@ pub enum ConfigError { #[derive(Debug, Clone, Deserialize)] pub struct ServerConfig { /// When receiving a SIGINT/SIGTERM signal, we will wait for the proposed timeout before terminating workers - #[serde(deserialize_with = "deserialize_duration")] + #[serde(deserialize_with = "deserialize_duration_secs")] pub shutdown_timeout: Duration, /// Request timeout - maximum time to process a request (protects against Slowloris) - #[serde(deserialize_with = "deserialize_duration")] + #[serde(deserialize_with = "deserialize_duration_secs")] pub request_timeout: Duration, /// Maximum request body size @@ -65,13 +64,12 @@ pub struct ServerConfig { pub max_concurrent_requests: usize, /// Rate limit: requests per second per client IP - #[serde(deserialize_with = "deserialize_duration")] + #[serde(deserialize_with = "deserialize_duration_secs")] pub rate_limit_period: Duration, /// Rate limit: burst size (max requests allowed in a burst) per client IP pub rate_limit_burst_size: u32, } - impl Default for ServerConfig { fn default() -> Self { Self { @@ -99,7 +97,6 @@ pub struct ListenerConfig { /// Path to TLS private key file (PEM format). If set, tls_crt must also be set. pub tls_key: Option<PathBuf>, } - impl Default for ListenerConfig { fn default() -> Self { Self { @@ -145,7 +142,6 @@ pub struct StdoutConfig { /// Controls the format of logs in stdout pub log_format: StdoutFormat, } - impl Default for StdoutConfig { fn default() -> Self { Self { @@ -175,7 +171,7 @@ pub struct OtelcolConfig { pub endpoint: String, /// Export timeout in seconds - #[serde(deserialize_with = "deserialize_duration")] + #[serde(deserialize_with = "deserialize_duration_secs")] pub timeout: Duration, /// Controls which logs will be sent to otlp @@ -193,7 +189,6 @@ pub struct OtelcolConfig { /// HTTP headers for authentication pub headers: HashMap<String, String>, } - impl Default for OtelcolConfig { fn default() -> Self { Self { @@ -236,39 +231,26 @@ pub struct ConfigService { telemetry: TelemetryConfig, backends: BackendsConfig, } - impl Default for ConfigService { fn default() -> Self { Self { - appname: "tesor".to_string(), - dirname: PathBuf::from("./.tesor-state"), - listen: vec![ListenerConfig::default()], + appname: "zorian".to_string(), + dirname: PathBuf::from("./.zorian-state"), server: ServerConfig::default(), + listen: vec![ListenerConfig::default()], telemetry: TelemetryConfig::default(), backends: BackendsConfig::default(), } } } - impl ConfigService { - pub fn load(config_path: Option<PathBuf>) -> Result<Self, ConfigError> { - let config = match config_path { - Some(path) => { - info!("use config file from {}", path.to_str().unwrap()); - - let content = fs::read_to_string(path)?; - toml::from_str(&content)? - } - None => { - info!("configuration file path not provided"); - Self::default() - } - }; - - config.validate() + pub fn from_file(path: &Path) -> Result<Self, ConfigError> { + let content = fs::read_to_string(path)?; + let config: Self = toml::from_str(&content)?; + Ok(config) } - fn validate(self) -> Result<Self, ConfigError> { + pub fn validate(&self) -> Result<(), ConfigError> { let mut chars = self.appname.chars(); if !chars.all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_') { return Err(ConfigError::InvalidAppname(self.appname.clone())); @@ -312,7 +294,7 @@ impl ConfigService { } } - Ok(self) + Ok(()) } pub fn appname(&self) -> &str { @@ -358,270 +340,3 @@ impl ConfigService { } } } - -#[cfg(test)] -mod tests { - use super::*; - use tempfile::TempDir; - - fn base_config(dir: PathBuf) -> ConfigService { - ConfigService { - appname: "valid-name".to_string(), - dirname: dir, - server: ServerConfig::default(), - listen: vec![ListenerConfig { - addr: "127.0.0.1:0".parse().unwrap(), - hostnames: Vec::new(), - tls_crt: None, - tls_key: None, - }], - telemetry: TelemetryConfig::default(), - backends: BackendsConfig::default(), - } - } - - fn write_temp_file(dir: &Path, name: &str) -> PathBuf { - let path = dir.join(name); - std::fs::write(&path, "x").unwrap(); - path - } - - mod defaults_tests { - use super::*; - - #[test] - fn test_for_test_config() { - let dir = TempDir::new().unwrap(); - let cfg = ConfigService::for_test(dir.path().to_path_buf()); - assert_eq!(cfg.appname(), "test"); - assert_eq!(cfg.dirname(), dir.path()); - } - - #[test] - fn test_listener_default() { - let cfg = ListenerConfig::default(); - assert!(cfg.hostnames.contains(&"localhost".to_string())); - } - } - - mod load_tests { - use super::*; - - #[test] - fn test_load_none_defaults() { - let temp = TempDir::new().unwrap(); - let state = temp.path().join(".tesor-state"); - std::fs::create_dir_all(&state).unwrap(); - let cwd = std::env::current_dir().unwrap(); - std::env::set_current_dir(temp.path()).unwrap(); - - let cfg = ConfigService::load(None).unwrap(); - assert_eq!(cfg.appname(), "tesor"); - - std::env::set_current_dir(cwd).unwrap(); - } - - #[test] - fn test_load_some_and_parse_error() { - let dir = TempDir::new().unwrap(); - let good = dir.path().join("good.toml"); - let bad = dir.path().join("bad.toml"); - let missing = dir.path().join("missing.toml"); - let state = dir.path().join("state"); - std::fs::create_dir_all(&state).unwrap(); - - std::fs::write( - &good, - format!( - "appname = \"ok\"\n\ - dirname = \"{}\"\n\ - listen = []\n\ - [server]\n\ - shutdown_timeout = 1\n\ - request_timeout = 1\n\ - max_body_size = \"1 MB\"\n\ - max_concurrent_requests = 1\n\ - rate_limit_period = 1\n\ - rate_limit_burst_size = 1\n\ - [telemetry]\n\ - [telemetry.stdout]\n\ - enabled = true\n\ - log_level = \"info\"\n\ - log_format = \"pretty\"\n\ - [backends]\n\ - [backends.go]\n\ - [backends.zig]\n", - state.display() - ), - ) - .unwrap(); - - std::fs::write(&bad, "not = [valid").unwrap(); - - let cfg = ConfigService::load(Some(good)).unwrap(); - assert_eq!(cfg.appname(), "ok"); - - let err = ConfigService::load(Some(missing)).unwrap_err(); - assert!(err.to_string().contains("failed to read")); - - let err = ConfigService::load(Some(bad)).unwrap_err(); - assert!(err.to_string().contains("failed to parse")); - } - } - - mod validation_tests { - use super::*; - - #[test] - fn test_validate_invalid_appname() { - let dir = TempDir::new().unwrap(); - let mut cfg = base_config(dir.path().to_path_buf()); - cfg.appname = "bad name!".to_string(); - let err = cfg.validate().unwrap_err(); - assert!(err.to_string().contains("appname 'bad name!'")); - } - - #[test] - fn test_validate_dir_not_found() { - let temp = TempDir::new().unwrap(); - let missing = temp.path().join("missing-dir"); - let cfg = base_config(missing); - let err = cfg.validate().unwrap_err(); - assert!(err.to_string().contains("does not exist")); - } - - #[test] - fn test_validate_not_a_directory() { - let dir = TempDir::new().unwrap(); - let file_path = dir.path().join("file"); - std::fs::write(&file_path, "x").unwrap(); - let cfg = base_config(file_path); - let err = cfg.validate().unwrap_err(); - assert!(err.to_string().contains("is not a directory")); - } - - #[cfg(unix)] - #[test] - fn test_validate_metadata_io_error() { - use std::os::unix::fs::PermissionsExt; - - let dir = TempDir::new().unwrap(); - let child = dir.path().join("child"); - std::fs::create_dir_all(&child).unwrap(); - - let mut perms = std::fs::metadata(dir.path()).unwrap().permissions(); - perms.set_mode(0o000); - std::fs::set_permissions(dir.path(), perms).unwrap(); - - let cfg = base_config(child.clone()); - let err = cfg.validate().unwrap_err(); - assert!(err.to_string().contains("failed to read")); - - let mut perms = std::fs::metadata(dir.path()).unwrap().permissions(); - perms.set_mode(0o700); - std::fs::set_permissions(dir.path(), perms).unwrap(); - } - - #[cfg(unix)] - #[test] - fn test_validate_not_writable() { - use std::os::unix::fs::PermissionsExt; - - let dir = TempDir::new().unwrap(); - let mut perms = std::fs::metadata(dir.path()).unwrap().permissions(); - perms.set_mode(0o400); - std::fs::set_permissions(dir.path(), perms).unwrap(); - - let cfg = base_config(dir.path().to_path_buf()); - let err = cfg.validate().unwrap_err(); - assert!(err.to_string().contains("not writable")); - } - - #[test] - fn test_validate_tls_key_missing() { - let dir = TempDir::new().unwrap(); - let mut cfg = base_config(dir.path().to_path_buf()); - cfg.listen = vec![ListenerConfig { - addr: "127.0.0.1:0".parse().unwrap(), - hostnames: Vec::new(), - tls_crt: Some(PathBuf::from("/tmp/does-not-matter.crt")), - tls_key: None, - }]; - let err = cfg.validate().unwrap_err(); - assert!(err.to_string().contains("tls_key is missing")); - } - - #[test] - fn test_validate_tls_crt_missing() { - let dir = TempDir::new().unwrap(); - let mut cfg = base_config(dir.path().to_path_buf()); - cfg.listen = vec![ListenerConfig { - addr: "127.0.0.1:0".parse().unwrap(), - hostnames: Vec::new(), - tls_crt: None, - tls_key: Some(PathBuf::from("/tmp/does-not-matter.key")), - }]; - let err = cfg.validate().unwrap_err(); - assert!(err.to_string().contains("tls_crt is missing")); - } - - #[test] - fn test_validate_tls_files_not_found() { - let dir = TempDir::new().unwrap(); - let mut cfg = base_config(dir.path().to_path_buf()); - cfg.listen = vec![ListenerConfig { - addr: "127.0.0.1:0".parse().unwrap(), - hostnames: Vec::new(), - tls_crt: Some(PathBuf::from("/tmp/missing.crt")), - tls_key: Some(PathBuf::from("/tmp/missing.key")), - }]; - let err = cfg.validate().unwrap_err(); - assert!(err.to_string().contains("TLS crtificate file not found")); - } - - #[test] - fn test_validate_tls_key_not_found() { - let dir = TempDir::new().unwrap(); - let mut cfg = base_config(dir.path().to_path_buf()); - let crt = write_temp_file(dir.path(), "cert.pem"); - cfg.listen = vec![ListenerConfig { - addr: "127.0.0.1:0".parse().unwrap(), - hostnames: Vec::new(), - tls_crt: Some(crt), - tls_key: Some(dir.path().join("missing.key")), - }]; - let err = cfg.validate().unwrap_err(); - assert!(err.to_string().contains("TLS key file not found")); - } - - #[test] - fn test_validate_tls_files_exist() { - let dir = TempDir::new().unwrap(); - let mut cfg = base_config(dir.path().to_path_buf()); - let crt = write_temp_file(dir.path(), "cert.pem"); - let key = write_temp_file(dir.path(), "key.pem"); - cfg.listen = vec![ListenerConfig { - addr: "127.0.0.1:0".parse().unwrap(), - hostnames: Vec::new(), - tls_crt: Some(crt), - tls_key: Some(key), - }]; - cfg.validate().unwrap(); - } - - #[test] - fn test_validate_ok_and_getters() { - let dir = TempDir::new().unwrap(); - let mut cfg = base_config(dir.path().to_path_buf()); - cfg.listen = vec![ListenerConfig::default()]; - - let cfg = cfg.validate().unwrap(); - assert_eq!(cfg.appname(), "valid-name"); - assert_eq!(cfg.dirname(), dir.path()); - let _ = cfg.server(); - let _ = cfg.listeners(); - let _ = cfg.telemetry(); - let _ = cfg.backends(); - } - } -} diff --git a/crates/tesor/src/controller_backend.rs b/src/controller_backend.rs index f97caa1..dfbfeb1 100644 --- a/crates/tesor/src/controller_backend.rs +++ b/src/controller_backend.rs @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2026 Nikolay Govorov +// SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> // SPDX-License-Identifier: AGPL-3.0-or-later use std::sync::Arc; @@ -6,20 +6,20 @@ use std::sync::Arc; use axum::{Router, body, extract, http, response, routing}; use tracing::error; +use crate::backends::{Backend, ResolveError, ResolvedFile}; use crate::proxy; use crate::storage; -use repos::{Backend, BackendError, BackendSpec, ResolvedFile}; /// Generic controller for backend HTTP handling. -pub struct BackendController<S: BackendSpec> { - backend: Arc<Backend<S>>, +pub struct BackendController<B: Backend> { + backend: Arc<B>, storage: Arc<storage::StorageService>, upstream: Arc<proxy::ProxyService>, } -impl<S: BackendSpec> BackendController<S> { +impl<B: Backend> BackendController<B> { pub fn new( - backend: Arc<Backend<S>>, + backend: Arc<B>, storage: Arc<storage::StorageService>, upstream: Arc<proxy::ProxyService>, ) -> Self { @@ -40,33 +40,32 @@ impl<S: BackendSpec> BackendController<S> { extract::State(controller): extract::State<Arc<Self>>, extract::Path(filename): extract::Path<String>, ) -> Result<response::Response, http::StatusCode> { - let (url, mime) = match controller.backend.resolve_file(&filename).await { + let url = match controller.backend.resolve_file(&filename).await { Ok(ResolvedFile::Content { data, mime }) => { - return Ok(Self::build_response(http::StatusCode::OK, data, mime)); + return Ok(Self::build_response_with_mime(data, mime)); } - Ok(ResolvedFile::Upstream { url, mime }) => (url, mime), - Err(BackendError::NotFound) => { - error!(backend = S::ID, filename, "file not found"); + Ok(ResolvedFile::Upstream(url)) => url, + Err(ResolveError::NotFound) => { + error!(backend = B::ID, filename, "file not found"); return Err(http::StatusCode::NOT_FOUND); } - Err(e) => { - error!(backend = S::ID, filename, "error resolving file: {e}"); + Err(ResolveError::Internal) => { + error!(backend = B::ID, filename, "internal error resolving file"); return Err(http::StatusCode::INTERNAL_SERVER_ERROR); } }; - match controller.storage.get(S::ID, &filename).await { + match controller.storage.get(B::ID, &filename).await { Ok(Some(entry)) => { return Ok(Self::build_response( http::StatusCode::OK, entry.file_bytes.0, - mime, )); } Ok(None) => {} Err(err) => { error!( - backend = S::ID, + backend = B::ID, filename, "failed to get file from storage: {err}" ); return Err(http::StatusCode::INTERNAL_SERVER_ERROR); @@ -78,32 +77,33 @@ impl<S: BackendSpec> BackendController<S> { .fetch(proxy::DownloadRequest { url }) .await?; - match controller.storage.put(S::ID, &filename, &entry.bytes).await { + match controller.storage.put(B::ID, &filename, &entry.bytes).await { Ok(()) => {} Err(err) => { error!( - backend = S::ID, + backend = B::ID, filename, "failed to put file to storage: {err}" ); return Err(http::StatusCode::INTERNAL_SERVER_ERROR); } } - Ok(Self::build_response( - http::StatusCode::OK, - entry.bytes, - mime, - )) + Ok(Self::build_response(http::StatusCode::OK, entry.bytes)) } - fn build_response( - status: http::StatusCode, - bytes: bytes::Bytes, - mime: repos::ContentType, - ) -> response::Response { + fn build_response(status: http::StatusCode, bytes: bytes::Bytes) -> response::Response { response::Response::builder() .status(status) - .header(http::header::CONTENT_TYPE, mime.as_str()) + .header(http::header::CONTENT_TYPE, "application/octet-stream") + .header(http::header::CONTENT_LENGTH, bytes.len()) + .body(body::Body::from(bytes)) + .unwrap() + } + + fn build_response_with_mime(bytes: bytes::Bytes, mime: &'static str) -> response::Response { + response::Response::builder() + .status(http::StatusCode::OK) + .header(http::header::CONTENT_TYPE, mime) .header(http::header::CONTENT_LENGTH, bytes.len()) .body(body::Body::from(bytes)) .unwrap() diff --git a/src/controller_web.rs b/src/controller_web.rs new file mode 100644 --- /dev/null +++ b/src/controller_web.rs @@ -0,0 +1,363 @@ +// SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> +// SPDX-License-Identifier: AGPL-3.0-or-later + +use std::future::Future; +use std::pin::Pin; +use std::sync::Arc; +use std::task::{Context, Poll}; + +use axum::body::Body; +use axum::http::{HeaderValue, Method, Request, Response, StatusCode, header}; +use axum::{extract, routing}; +use chrono::{DateTime, Utc}; +use maud::{Markup, html}; +use rust_embed::Embed; +use sqlx::types::chrono; +use tower::{Layer, Service}; +use tracing::error; + +use crate::backends::{Backend, GoBackend, ZigBackend}; + +#[derive(Embed)] +#[folder = "src/assets/"] +struct Assets; + +const CSP: &str = "default-src 'self'; base-uri 'none'; img-src 'self'; font-src 'self'; style-src 'self'; script-src 'self'; object-src 'none'; frame-ancestors 'none'"; + +/// Handles html pages rendering and static files +pub struct WebController { + zig: Option<Arc<ZigBackend>>, + go: Option<Arc<GoBackend>>, +} + +impl WebController { + pub fn new(zig: Option<Arc<ZigBackend>>, go: Option<Arc<GoBackend>>) -> Self { + Self { zig, go } + } +} + +impl WebController { + pub fn router(self: Arc<Self>) -> axum::Router { + let pages = axum::Router::new() + .route("/", axum::routing::get(Self::index)) + .layer(tower_http::set_header::SetResponseHeaderLayer::overriding( + header::CACHE_CONTROL, + HeaderValue::from_static("no-cache"), + )) + .with_state(self.clone()); + + let assets = axum::Router::new().route("/assets/{*path}", routing::get(Self::assets)); + + axum::Router::new() + .merge(pages) + .merge(assets) + .layer(LastModifiedLayer {}) + .layer(tower_http::set_header::SetResponseHeaderLayer::overriding( + header::CONTENT_SECURITY_POLICY, + HeaderValue::from_static(CSP), + )) + } + + async fn assets(extract::Path(path): extract::Path<String>) -> Response<Body> { + match Assets::get(&path) { + Some(file) => { + let mime = mime_guess::from_path(&path).first_or_octet_stream(); + let is_font = matches!( + path.rsplit('.').next(), + Some("ttf" | "otf" | "woff" | "woff2" | "eot") + ); + + let mut builder = Response::builder() + .status(StatusCode::OK) + .header(header::CONTENT_TYPE, mime.as_ref()); + + if is_font { + builder = builder + .header(header::CACHE_CONTROL, "public, max-age=31536000, immutable"); + } + + builder.body(Body::from(file.data.into_owned())).unwrap() + } + None => Response::builder() + .status(StatusCode::NOT_FOUND) + .body(Body::empty()) + .unwrap(), + } + } + + async fn index(extract::State(ctrl): extract::State<Arc<Self>>) -> Markup { + let zig_versions = if let Some(ref backend) = ctrl.zig { + match backend.get_versions().await { + Ok(v) => v, + Err(e) => { + error!("failed to get zig versions: {e}"); + Vec::new() + } + } + } else { + Vec::new() + }; + + let go_versions = if let Some(ref backend) = ctrl.go { + match backend.get_versions().await { + Ok(v) => v, + Err(e) => { + error!("failed to get go versions: {e}"); + Vec::new() + } + } + } else { + Vec::new() + }; + + html! { + (maud::DOCTYPE) + + html lang="en" { + meta charset="UTF-8"; + meta name="viewport" content="width=device-width,initial-scale=1"; + meta http-equiv="X-UA-Compatible" content="ie=edge"; + + link rel="stylesheet" href="assets/base.css"; + title { "Earth PKG — tiny & opinionated packages mirror" } + } + + body { + h1 { "Zorian — tiny & opinionated packages mirror." } + + main { + p { + r#"This site provides a caching proxy for downloading Zig and Go installation files. + It reduces load on upstream servers and makes your infrastructure more reliable by adding redundancy."# + } + + p { + "Zorian is open source software licensed under " a href="https://www.gnu.org/licenses/agpl-3.0.html" { "AGPL-3.0" } ". " + "Source code is available on " a href="https://github.com/mrdimidium/zorian" { "GitHub" } + } + + h2 { "Usage" } + + p { + "Replace official download URLs with " code { "https://pkg.earth/{tool}/{filename}" } ". " + "Files are cached automatically after the first download." + } + + h3 id="zig" { + a href="#zig" { "Zig" } + } + + @if !zig_versions.is_empty() { + details { + summary { "Available versions (" (zig_versions.len()) ")" } + + p { "You can take actual minisig public key at " a href="https://ziglang.org/download/" { "ziglang.org/download" } "." } + table { + thead { + tr { + th { "Version" } + th { "Date" } + th { "Docs" } + th { "Targets" } + } + } + tbody { + @for v in zig_versions.iter().rev() { + tr { + td { (v.version) } + td { (v.date.as_deref().unwrap_or("-")) } + td { + @if let Some(ref url) = v.docs { + a href=(url) { "docs" } + } + " " + @if let Some(ref url) = v.std_docs { + a href=(url) { "std" } + } + " " + @if let Some(ref url) = v.notes { + a href=(url) { "notes" } + } + } + td { + @if let Some(ref src) = v.src { + a href=(format!("/zig/{}", src.filename)) { code { "src" } } + " " + } + @if let Some(ref bootstrap) = v.bootstrap { + a href=(format!("/zig/{}", bootstrap.filename)) { code { "bootstrap" } } + " " + } + @for (target, tarball) in v.targets.iter() { + a href=(format!("/zig/{}", tarball.filename)) { code { (target) } } + " " + } + } + } + } + } + } + } + } + + + p { + "Read more about community mirrors in the " a href="https://ziglang.org/download/community-mirrors/" { "blog post" } ". " + "Information on how to deploy your own mirror is available " a href="https://github.com/ziglang/www.ziglang.org/blob/main/MIRRORS.md" { "in the documentation" } "." + } + + p { + "For simplicity, you can use tools like " a href="https://github.com/prantlf/zigup" { "prantlf/zigup" } + " and " a href="https://github.com/mlugg/setup-zig" { "mlugg/setup-zig" } "." + } + + p { + "To install manually:" + ol { + li { "download zig dist file:" br; code { "wget https://pkg.earth/zig/zig-x86_64-linux-0.15.1.tar.xz" } ";" } + li { "download zig minisig file:" br; code { "wget https://pkg.earth/zig/zig-x86_64-linux-0.15.1.tar.xz.minisig" } ";" } + li { "check archive integrity:" br; code { "minisign -Vm zig-x86_64-linux-0.15.1.tar.xz -P RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U" } ";" } + li { "unpack archive:" br; code { "tar -xf 'zig-x86_64-linux-0.15.1.tar.xz'" } ";" } + li { "check installed zig:" br; code { "./zig-x86_64-linux-0.15.1/zig --version" } ";" } + } + } + + h3 id="go" { a href="#go" { "Go" } } + + @if !go_versions.is_empty() { + details { + summary { "Available versions (" (go_versions.len()) ")" } + + p { "You can find available versions at " a href="https://go.dev/dl/" { "go.dev/dl" } "." } + table { + thead { + tr { + th { "Version" } + th { "Stable" } + th { "Files" } + } + } + tbody { + @for v in go_versions.iter().rev() { + tr { + td { (v.version) } + td { @if v.stable { "✓" } @else { "" } } + td { + @for file in &v.files { + a href=(format!("/go/{}", file.filename)) { code { (file.filename) } } + " " + } + } + } + } + } + } + } + } + + p { "To install manually:" } + + ol { + li { "download go dist file:" br; code { "wget https://pkg.earth/go/go1.23.0.linux-amd64.tar.gz" } ";" } + li { "download go sha256 file:" br; code { "wget https://pkg.earth/go/go1.23.0.linux-amd64.tar.gz.sha256" } ";" } + li { "check archive integrity:" br; code { "sha256sum -c go1.23.0.linux-amd64.tar.gz.sha256" } ";" } + li { "unpack archive:" br; code { "tar -xzf go1.23.0.linux-amd64.tar.gz" } ";" } + li { "check installed go:" br; code { "./go/bin/go version" } ";" } + } + + h2 { "Privacy policy" } + + p { "This mirror is a non-profit project available on a voluntary basis. The author has no plans to fund it." } + + p { r#"Since the mirror is hosted on hardware, we collect access logs to combat bots and brute-force attacks. + The logs are used for security purposes and load planning, are not shared with third parties, + and are deleted after 30 days."# } + + p { "Third-party analytics systems are not used, same as client-side trackers." } + } + } + } + } +} + +#[derive(Clone)] +pub struct LastModifiedLayer {} +impl<S> Layer<S> for LastModifiedLayer { + type Service = LastModifiedService<S>; + fn layer(&self, inner: S) -> Self::Service { + LastModifiedService { + inner, + + // Since the static file is packaged in a binary, we cache it across restarts. + // In the future, we can use the build time. + last_moidified: Utc::now(), + } + } +} + +#[derive(Clone)] +pub struct LastModifiedService<S> { + inner: S, + last_moidified: DateTime<Utc>, +} +impl<S> Service<Request<Body>> for LastModifiedService<S> +where + S: Service<Request<Body>, Response = Response<Body>> + Clone + Send + 'static, + S::Future: Send + 'static, + S::Error: Send + 'static, +{ + type Response = Response<Body>; + type Error = S::Error; + type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>; + + fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { + self.inner.poll_ready(cx) + } + + fn call(&mut self, req: Request<Body>) -> Self::Future { + let method = req.method().clone(); + let headers = req.headers().clone(); + let last_modified = self.last_moidified; + + let mut inner = self.inner.clone(); + Box::pin(async move { + let raw = last_modified + .format("%a, %d %b %Y %H:%M:%S GMT") + .to_string(); + let lmh = HeaderValue::from_str(raw.as_str()).unwrap(); + + if (method == Method::GET || method == Method::HEAD) + && headers + .get(header::IF_MODIFIED_SINCE) + .and_then(|v| v.to_str().ok()) + .and_then(parse_http_date) + .is_some_and(|ims| last_modified <= ims) + { + match Response::builder() + .status(StatusCode::NOT_MODIFIED) + .header(header::LAST_MODIFIED, lmh.clone()) + .body(Body::empty()) + { + Ok(resp) => { + return Ok(resp); + } + Err(err) => { + error!("build response: {err}") + } + } + } + + let mut resp = inner.call(req).await?; + resp.headers_mut().insert(header::LAST_MODIFIED, lmh); + Ok(resp) + }) + } +} + +/// Parse HTTP-date (IMF-fixdate per RFC 7231) or RFC 2822 +fn parse_http_date(value: &str) -> Option<DateTime<Utc>> { + // IMF-fixdate: "Tue, 14 Jan 2026 12:34:56 GMT" + DateTime::parse_from_rfc2822(value.trim()) + .map(|d| d.with_timezone(&Utc)) + .ok() +} diff --git a/crates/tesor/src/main.rs b/src/main.rs index 1029eca..bc364db 100644 --- a/crates/tesor/src/main.rs +++ b/src/main.rs @@ -1,10 +1,12 @@ -// SPDX-FileCopyrightText: 2026 Nikolay Govorov +// SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> // SPDX-License-Identifier: AGPL-3.0-or-later +mod backends; mod config; mod proxy; mod storage; mod telemetry; +mod utils; mod controller_backend; mod controller_web; @@ -29,23 +31,48 @@ use tokio::signal; use tracing::{error, info, trace}; use tracing_subscriber::registry::LookupSpan; +use crate::backends::{Backend, BackendDelegate, GoBackend, IndexError, ZigBackend}; use crate::controller_backend::BackendController; use crate::controller_web::WebController; -use repos::{Backend, BackendSpec, GoBackend, ZigBackend}; -async fn init_backend<S: BackendSpec>( - backend: Backend<S>, +/// Implementation of BackendDelegate for the application. +struct AppDelegate { + proxy: Arc<proxy::ProxyService>, + storage: Arc<storage::StorageService>, +} + +#[async_trait::async_trait] +impl BackendDelegate for AppDelegate { + async fn http_get(&self, url: &url::Url) -> Result<bytes::Bytes, IndexError> { + self.proxy + .fetch(proxy::DownloadRequest { url: url.clone() }) + .await + .map(|f| f.bytes) + .map_err(|e| IndexError::Fetch(e.to_string())) + } + + fn db(&self) -> &sqlx::Pool<sqlx::Sqlite> { + self.storage.db() + } +} + +async fn init_backend<B: Backend>( + backend: B, index_tasks: &mut tokio::task::JoinSet<()>, index_cancel: tokio_util::sync::CancellationToken, -) -> Option<Arc<Backend<S>>> { +) -> Option<Arc<B>> { if !backend.enabled() { return None; } let backend = Arc::new(backend); + if let Err(e) = backend.migrate().await { + error!(backend = B::ID, "migration failed: {e}"); + std::process::exit(1); + } let interval = backend.refresh_interval(); if !interval.is_zero() { index_tasks.spawn(run_index_refresh( - S::ID, + B::ID, backend.clone(), interval, index_cancel, @@ -54,9 +81,9 @@ async fn init_backend<S: BackendSpec>( Some(backend) } -async fn run_index_refresh<S: BackendSpec>( +async fn run_index_refresh<B: backends::Backend>( name: &'static str, - backend: Arc<Backend<S>>, + backend: Arc<B>, interval: std::time::Duration, cancel: tokio_util::sync::CancellationToken, ) { @@ -71,7 +98,7 @@ async fn run_index_refresh<S: BackendSpec>( } _ = ticker.tick() => { info!(backend = name, "refreshing index"); - match backend.refresh().await { + match backend.fetch_index().await { Ok(()) => info!(backend = name, "index refreshed"), Err(e) => error!(backend = name, "index refresh failed: {e}"), } @@ -82,7 +109,7 @@ async fn run_index_refresh<S: BackendSpec>( const VERSION: &str = env!("CARGO_PKG_VERSION"); const HELP: &str = "\ -Usage: tesor [--config=<path>] +Usage: zorian [--config=<path>] Options: --config=<path> Path to config file (optional) @@ -134,7 +161,7 @@ async fn main() { return; } if arg == "--version" || arg == "-V" { - println!("tesor {VERSION}"); + println!("zorian {VERSION}"); return; } if let Some(path) = arg.strip_prefix("--config=") { @@ -142,22 +169,39 @@ async fn main() { } } - let config = Arc::new( - config::ConfigService::load(config_path).unwrap_or_else(|e| { - eprintln!("invalid config: {e}"); - std::process::exit(1); - }), - ); + let config = Arc::new(match config_path { + Some(path) => { + info!("use config file from {}", path.to_str().unwrap()); + + config::ConfigService::from_file(&path).unwrap_or_else(|e| { + error!("{e}"); + std::process::exit(1); + }) + } + None => { + info!("configuration file path not provided"); + config::ConfigService::default() + } + }); + config.validate().unwrap_or_else(|e| { + eprintln!("invalid config: {e}"); + std::process::exit(1); + }); let mut telemetry = telemetry::TelemetryService::init(config.telemetry(), config.appname(), VERSION); let storage = Arc::new(storage::StorageService::new(config.clone()).await.unwrap()); - let network = Arc::new(proxy::ProxyService::new()); + let upstream = Arc::new(proxy::ProxyService::new()); - let source = format!("tesor:{}", config.appname()); + let source = format!("zorian:{}", config.appname()); let backends = config.backends(); + let delegate: Arc<dyn BackendDelegate> = Arc::new(AppDelegate { + proxy: upstream.clone(), + storage: storage.clone(), + }); + const REQUEST_ID_HEADER: http::HeaderName = http::HeaderName::from_static("x-request-id"); let trace_layer = tower_http::trace::TraceLayer::new_for_http() @@ -256,24 +300,14 @@ async fn main() { let index_cancel = tokio_util::sync::CancellationToken::new(); let zig_backend = init_backend( - ZigBackend::new( - backends.zig.clone(), - source.clone(), - storage.clone(), - network.clone(), - ), + ZigBackend::new(backends.zig.clone(), source.clone(), delegate.clone()), &mut index_tasks, index_cancel.clone(), ) .await; let go_backend = init_backend( - GoBackend::new( - backends.go.clone(), - source.clone(), - storage.clone(), - network.clone(), - ), + GoBackend::new(backends.go.clone(), source.clone(), delegate.clone()), &mut index_tasks, index_cancel.clone(), ) @@ -286,7 +320,7 @@ async fn main() { let ctrl = Arc::new(BackendController::new( backend.clone(), storage.clone(), - network.clone(), + upstream.clone(), )); app = app.nest("/zig", ctrl.router()); } @@ -295,7 +329,7 @@ async fn main() { let ctrl = Arc::new(BackendController::new( backend.clone(), storage.clone(), - network.clone(), + upstream.clone(), )); app = app.nest("/go", ctrl.router()); } @@ -331,7 +365,7 @@ async fn main() { )) .layer(tower_http::set_header::SetResponseHeaderLayer::overriding( http::header::SERVER, - http::HeaderValue::from_static(concat!("tesor/", env!("CARGO_PKG_VERSION"))), + http::HeaderValue::from_static(concat!("zorian/", env!("CARGO_PKG_VERSION"))), )); let mut tasks = tokio::task::JoinSet::new(); diff --git a/crates/tesor/src/proxy.rs b/src/proxy.rs index 5e98d23..e627323 100644 --- a/crates/tesor/src/proxy.rs +++ b/src/proxy.rs @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2026 Nikolay Govorov +// SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> // SPDX-License-Identifier: AGPL-3.0-or-later use bytes::Bytes; @@ -7,12 +7,8 @@ use hyper::{Request, http}; use hyper_tls::HttpsConnector; use hyper_util::client::legacy::{Client, connect::HttpConnector}; use hyper_util::rt::TokioExecutor; -use tower::ServiceExt; -use tower_http::follow_redirect::FollowRedirect; use url::Url; -use repos::{BackendError, BackendNetwork}; - #[derive(Clone)] pub struct DownloadRequest { pub url: Url, @@ -24,30 +20,27 @@ pub struct File { } pub struct ProxyService { - client: FollowRedirect<Client<HttpsConnector<HttpConnector>, Empty<Bytes>>>, + client: Client<HttpsConnector<HttpConnector>, Empty<Bytes>>, } impl ProxyService { pub fn new() -> Self { let https = HttpsConnector::new(); let client = Client::builder(TokioExecutor::new()).build(https); - Self { - client: FollowRedirect::new(client), - } + Self { client } } pub async fn fetch(&self, request: DownloadRequest) -> Result<File, http::StatusCode> { let request = Request::builder() .method(http::Method::GET) .uri(request.url.as_str()) - .header(http::header::USER_AGENT, "tesor/0.1") + .header(http::header::USER_AGENT, "zorian/0.1") .body(Empty::<Bytes>::new()) .unwrap(); let response = self .client - .clone() - .oneshot(request) + .request(request) .await .map_err(|_| http::StatusCode::GATEWAY_TIMEOUT)?; @@ -66,13 +59,3 @@ impl ProxyService { Ok(File { bytes }) } } - -#[async_trait::async_trait] -impl BackendNetwork for ProxyService { - async fn http_get(&self, url: &url::Url) -> Result<bytes::Bytes, BackendError> { - self.fetch(DownloadRequest { url: url.clone() }) - .await - .map(|f| f.bytes) - .map_err(|e| BackendError::Network(e.to_string())) - } -} diff --git a/crates/tesor/src/storage.rs b/src/storage.rs index bc751a7..ae5b056 100644 --- a/crates/tesor/src/storage.rs +++ b/src/storage.rs @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2026 Nikolay Govorov +// SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> // SPDX-License-Identifier: AGPL-3.0-or-later // This class stores uploaded files and associated metadata. @@ -35,25 +35,27 @@ use sqlx::{FromRow, Pool, Sqlite, query, query_as, query_scalar, sqlite}; use thiserror::Error; use tokio::fs; use tokio::io::AsyncWriteExt; -use tracing::{debug, error, instrument, warn}; +use tracing::{debug, instrument, warn}; use uuid::Uuid; -use crate::config::ConfigService; -use repos::{BackendError, BackendStorage, RawRelease, RawReleaseFile, Release}; +use super::config::ConfigService; const SQLITE_POOL_SIZE: u32 = 16; const INLINE_THRESHOLD: usize = 256 * 1024; // 256 KB +// You cannot change this ID, this will desynchronize the records in the database and the files on the disk. +const UUID_ROOT_NAMESPACE: Uuid = Uuid::from_bytes([ + 0x8b, 0x06, 0x3c, 0x4c, 0x6b, 0x5c, 0x4a, 0x8b, 0x92, 0x8f, 0x75, 0x8b, 0x0e, 0x63, 0xc3, 0x5d, +]); + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Id(pub Uuid); - impl std::ops::Deref for Id { type Target = Uuid; fn deref(&self) -> &Self::Target { &self.0 } } - impl sqlx::Type<Sqlite> for Id { fn type_info() -> sqlite::SqliteTypeInfo { <Vec<u8> as sqlx::Type<Sqlite>>::type_info() @@ -63,7 +65,6 @@ impl sqlx::Type<Sqlite> for Id { <Vec<u8> as sqlx::Type<Sqlite>>::compatible(ty) } } - impl<'r> sqlx::decode::Decode<'r, Sqlite> for Id { fn decode( value: sqlite::SqliteValueRef<'r>, @@ -73,7 +74,6 @@ impl<'r> sqlx::decode::Decode<'r, Sqlite> for Id { Ok(Id(uuid)) } } - impl<'q> Encode<'q, Sqlite> for Id { fn encode_by_ref( &self, @@ -86,14 +86,12 @@ impl<'q> Encode<'q, Sqlite> for Id { #[derive(Debug, Clone)] pub struct Blob(pub Bytes); - impl std::ops::Deref for Blob { type Target = Bytes; fn deref(&self) -> &Self::Target { &self.0 } } - impl sqlx::Type<Sqlite> for Blob { fn type_info() -> sqlite::SqliteTypeInfo { <Vec<u8> as sqlx::Type<Sqlite>>::type_info() // BLOB @@ -103,7 +101,6 @@ impl sqlx::Type<Sqlite> for Blob { <Vec<u8> as sqlx::Type<Sqlite>>::compatible(ty) } } - impl<'r> sqlx::decode::Decode<'r, Sqlite> for Blob { fn decode( value: sqlite::SqliteValueRef<'r>, @@ -131,10 +128,9 @@ pub enum StorageError { IoError(#[from] std::io::Error), } -/// Cached file entry (datafiles table) #[allow(unused)] #[derive(Debug, Clone, FromRow)] -pub struct Object { +pub struct File { pub id: Id, pub scope: String, pub created_at: chrono::DateTime<chrono::Utc>, @@ -145,15 +141,9 @@ pub struct Object { pub inlined: bool, } -impl Object { - // You cannot change this ID, this will desynchronize the records in the database and the files on the disk. - const UUID_ROOT_NAMESPACE: Uuid = Uuid::from_bytes([ - 0x8b, 0x06, 0x3c, 0x4c, 0x6b, 0x5c, 0x4a, 0x8b, 0x92, 0x8f, 0x75, 0x8b, 0x0e, 0x63, 0xc3, - 0x5d, - ]); - +impl File { fn uuid(scope: &str, file: &str) -> Id { - let scope_ns = Uuid::new_v5(&Object::UUID_ROOT_NAMESPACE, scope.as_bytes()); + let scope_ns = Uuid::new_v5(&UUID_ROOT_NAMESPACE, scope.as_bytes()); Id(Uuid::new_v5(&scope_ns, file.as_bytes())) } @@ -174,64 +164,6 @@ impl Object { } } -/// Builder for file query SQL -pub struct FileQuery<'a> { - backend: &'a str, - version: Option<&'a str>, - filename: Option<&'a str>, - meta_null: Option<&'a str>, -} - -impl<'a> FileQuery<'a> { - pub fn new(backend: &'a str) -> Self { - Self { - backend, - version: None, - filename: None, - meta_null: None, - } - } - - pub fn version(mut self, version: &'a str) -> Self { - self.version = Some(version); - self - } - - pub fn filename(mut self, filename: &'a str) -> Self { - self.filename = Some(filename); - self - } - - pub fn where_meta_null(mut self, field: &'a str) -> Self { - self.meta_null = Some(field); - self - } - - pub fn build_sql(&self) -> String { - let mut sql = String::from( - "SELECT backend, version, filename, checksum, size, os, arch, meta FROM files WHERE backend = ?1", - ); - let mut param_idx = 1; - - if self.version.is_some() { - param_idx += 1; - sql.push_str(&format!(" AND version = ?{}", param_idx)); - } - if self.filename.is_some() { - param_idx += 1; - sql.push_str(&format!(" AND filename = ?{}", param_idx)); - } - if let Some(field) = self.meta_null { - sql.push_str(&format!( - " AND (meta IS NULL OR json_extract(meta, '$.{}') IS NULL)", - field - )); - } - - sql - } -} - struct FileSystem { objects: PathBuf, database: PathBuf, @@ -254,7 +186,7 @@ impl FileSystem { } fn object(&self, scope: &str, file: &str) -> PathBuf { - let id = Object::uuid(scope, file); + let id = File::uuid(scope, file); let hash_hex = hex::encode(id.0.as_bytes()); self.objects_root() .join(&hash_hex[0..2]) @@ -327,6 +259,11 @@ impl StorageService { Ok(storage) } + /// Get SQLite pool for use by backends + pub fn db(&self) -> &Pool<Sqlite> { + &self.sqlite + } + /// Synchronously traverses the tree and removes temporary files. /// Must run before the application starts. async fn doctor(&self) -> Result<(), StorageError> { @@ -388,9 +325,9 @@ impl StorageService { } async fn migrations(&self) -> Result<(), StorageError> { - // Object storage table query( - "CREATE TABLE IF NOT EXISTS datafiles( + " + CREATE TABLE IF NOT EXISTS datafiles( id BLOB PRIMARY KEY CHECK (length(id) = 16), scope TEXT NOT NULL, created_at TEXT DEFAULT (datetime('now')), @@ -398,68 +335,20 @@ impl StorageService { file_size INTEGER NOT NULL, file_bytes BLOB, inlined INTEGER NOT NULL, - UNIQUE (scope, file_name) - ) STRICT", - ) - .execute(&self.sqlite) - .await?; - - // Drop old backend-specific tables (data will be re-fetched from upstream) - query("DROP TABLE IF EXISTS go_files") - .execute(&self.sqlite) - .await?; - query("DROP TABLE IF EXISTS go_versions") - .execute(&self.sqlite) - .await?; - query("DROP TABLE IF EXISTS zig_files") - .execute(&self.sqlite) - .await?; - query("DROP TABLE IF EXISTS zig_versions") - .execute(&self.sqlite) - .await?; - - // Unified versions table - query( - "CREATE TABLE IF NOT EXISTS versions ( - backend TEXT NOT NULL, - version TEXT NOT NULL, - sort_key INTEGER NOT NULL, - meta BLOB CHECK (meta IS NULL OR (json_valid(meta) AND json_type(meta) = 'object')), - PRIMARY KEY (backend, version) - ) STRICT", - ) - .execute(&self.sqlite) - .await?; - // Unified files table - query( - "CREATE TABLE IF NOT EXISTS files ( - backend TEXT NOT NULL, - version TEXT NOT NULL, - filename TEXT NOT NULL, - checksum TEXT NOT NULL, - size INTEGER NOT NULL, - os TEXT, - arch TEXT, - meta BLOB CHECK (meta IS NULL OR (json_valid(meta) AND json_type(meta) = 'object')), - PRIMARY KEY (backend, version, filename), - FOREIGN KEY (backend, version) REFERENCES versions(backend, version) - ) STRICT", + UNIQUE (scope, file_name) + ) STRICT; + ", ) .execute(&self.sqlite) .await?; - // Index for fast filename lookups - query("CREATE INDEX IF NOT EXISTS idx_files_backend_filename ON files(backend, filename)") - .execute(&self.sqlite) - .await?; - Ok(()) } #[instrument(skip(self))] - pub async fn get(&self, scope: &str, filename: &str) -> Result<Option<Object>, StorageError> { - let file: Option<Object> = + pub async fn get(&self, scope: &str, filename: &str) -> Result<Option<File>, StorageError> { + let file: Option<File> = query_as("SELECT * FROM datafiles WHERE scope = ?1 AND file_name = ?2") .bind(scope) .bind(filename) @@ -481,7 +370,7 @@ impl StorageService { Err(e) => return Err(e.into()), }; - let hash = Object::hash(scope, filename, &bytes); + let hash = File::hash(scope, filename, &bytes); if hash != file.file_bytes.to_vec() { return Err(StorageError::IntegrityError); } @@ -529,12 +418,12 @@ impl StorageService { let payload: Vec<u8> = if inlined { bytes.to_vec() } else { - Object::hash(scope, filename, bytes) + File::hash(scope, filename, bytes) }; let result = async { let mut tx = self.sqlite.begin().await?; - let id = Object::uuid(scope, filename); + let id = File::uuid(scope, filename); let result = query( " @@ -569,7 +458,7 @@ impl StorageService { Ok(()) } Err(sqlx::Error::Database(ref db_err)) if db_err.is_unique_violation() => { - let existing: Option<Object> = + let existing: Option<File> = query_as("SELECT * FROM datafiles WHERE scope = ?1 AND file_name = ?2") .bind(scope) .bind(filename) @@ -610,281 +499,6 @@ impl StorageService { result } - - /// Insert or update releases with their files in a single transaction. - pub async fn insert_releases( - &self, - releases: &[(RawRelease, Vec<RawReleaseFile>)], - ) -> Result<(), StorageError> { - for (release, files) in releases { - let mut tx = match self.sqlite.begin().await { - Ok(tx) => tx, - Err(e) => { - error!( - backend = release.backend, - version = release.version, - "failed to start transaction: {e}" - ); - return Err(e.into()); - } - }; - - let meta_json = release - .meta - .as_ref() - .map(|m| serde_json::to_vec(m).unwrap()); - - let result = async { - // Insert/update version - query( - "INSERT INTO versions (backend, version, sort_key, meta) - VALUES (?1, ?2, ?3, ?4) - ON CONFLICT(backend, version) DO UPDATE SET - sort_key = excluded.sort_key, - meta = excluded.meta - WHERE sort_key IS NOT excluded.sort_key OR meta IS NOT excluded.meta", - ) - .bind(&release.backend) - .bind(&release.version) - .bind(release.sort_key) - .bind(meta_json.as_deref()) - .execute(&mut *tx) - .await?; - - // Insert/update files - for file in files { - let changed = - Self::insert_file(&mut tx, &release.backend, &release.version, file) - .await?; - if changed { - warn!( - backend = release.backend, - version = release.version, - filename = file.filename, - "index file changed" - ); - } - } - - Ok::<(), StorageError>(()) - } - .await; - - match result { - Ok(()) => { - if let Err(e) = tx.commit().await { - error!( - backend = release.backend, - version = release.version, - "failed to commit release: {e}" - ); - } - } - Err(e) => { - error!( - backend = release.backend, - version = release.version, - "failed to store release, skipping: {e}" - ); - let _ = tx.rollback().await; - } - } - } - - Ok(()) - } - - /// Insert or update a single file within a transaction. - /// Returns `true` if an existing file was modified. - async fn insert_file( - tx: &mut sqlx::Transaction<'_, Sqlite>, - backend: &str, - version: &str, - file: &RawReleaseFile, - ) -> Result<bool, StorageError> { - let meta_json = file.meta.as_ref().map(|m| serde_json::to_vec(m).unwrap()); - let os_str = file.os.as_ref().map(AsRef::as_ref); - let arch_str = file.arch.as_ref().map(AsRef::as_ref); - - let existed: Option<(i32,)> = - query_as("SELECT 1 FROM files WHERE backend = ?1 AND version = ?2 AND filename = ?3") - .bind(backend) - .bind(version) - .bind(&file.filename) - .fetch_optional(&mut **tx) - .await?; - - let changed: Option<(i32,)> = query_as( - "INSERT INTO files (backend, version, filename, checksum, size, os, arch, meta) - VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8) - ON CONFLICT(backend, version, filename) DO UPDATE SET - checksum = excluded.checksum, - size = excluded.size, - os = excluded.os, - arch = excluded.arch - WHERE checksum IS NOT excluded.checksum - OR size IS NOT excluded.size - OR os IS NOT excluded.os - OR arch IS NOT excluded.arch - RETURNING 1", - ) - .bind(backend) - .bind(version) - .bind(&file.filename) - .bind(&file.checksum) - .bind(file.size) - .bind(os_str) - .bind(arch_str) - .bind(meta_json.as_deref()) - .fetch_optional(&mut **tx) - .await?; - - Ok(existed.is_some() && changed.is_some()) - } - - /// Execute a file query. - pub async fn query_files_filtered( - &self, - q: FileQuery<'_>, - ) -> Result<Vec<RawReleaseFile>, StorageError> { - let sql = q.build_sql(); - - let mut query = sqlx::query_as::< - _, - ( - String, - String, - String, - String, - i64, - Option<String>, - Option<String>, - Option<Vec<u8>>, - ), - >(&sql) - .bind(q.backend); - - if let Some(v) = q.version { - query = query.bind(v); - } - if let Some(f) = q.filename { - query = query.bind(f); - } - - let rows = query.fetch_all(&self.sqlite).await?; - - rows.into_iter() - .map( - |(backend, version, filename, checksum, size, os_str, arch_str, meta_bytes)| { - let meta = meta_bytes - .map(|b| serde_json::from_slice(&b)) - .transpose() - .map_err(|e| StorageError::DbError(sqlx::Error::Decode(Box::new(e))))?; - - Ok(RawReleaseFile { - backend, - version, - filename, - checksum, - size, - os: os_str.and_then(|s| s.parse().ok()), - arch: arch_str.and_then(|s| s.parse().ok()), - meta, - }) - }, - ) - .collect() - } - - /// Query all versions for a backend, ordered by sort_key. - pub async fn query_releases(&self, backend: &str) -> Result<Vec<RawRelease>, StorageError> { - let rows = query_as::<_, (String, String, i64, Option<Vec<u8>>)>( - "SELECT backend, version, sort_key, meta FROM versions WHERE backend = ?1 ORDER BY sort_key", - ) - .bind(backend) - .fetch_all(&self.sqlite) - .await?; - - rows.into_iter() - .map(|(backend, version, sort_key, meta_bytes)| { - let meta = meta_bytes - .map(|b| serde_json::from_slice(&b)) - .transpose() - .map_err(|e| StorageError::DbError(sqlx::Error::Decode(Box::new(e))))?; - - Ok(Release { - backend, - version, - sort_key, - meta, - }) - }) - .collect() - } - - /// Update file metadata (e.g. after fetching a signature). - pub async fn update_file_meta(&self, file: &RawReleaseFile) -> Result<bool, StorageError> { - let meta_json = file.meta.as_ref().map(|m| serde_json::to_vec(m).unwrap()); - - let result = query( - "UPDATE files SET meta = ?1 - WHERE backend = ?2 AND version = ?3 AND filename = ?4", - ) - .bind(meta_json.as_deref()) - .bind(&file.backend) - .bind(&file.version) - .bind(&file.filename) - .execute(&self.sqlite) - .await?; - - Ok(result.rows_affected() > 0) - } -} - -#[async_trait::async_trait] -impl BackendStorage for StorageService { - async fn insert_releases( - &self, - releases: &[(RawRelease, Vec<RawReleaseFile>)], - ) -> Result<(), BackendError> { - StorageService::insert_releases(self, releases) - .await - .map_err(|e| BackendError::Storage(e.to_string())) - } - - async fn query_releases(&self, backend: &str) -> Result<Vec<RawRelease>, BackendError> { - StorageService::query_releases(self, backend) - .await - .map_err(|e| BackendError::Storage(e.to_string())) - } - - async fn query_files( - &self, - backend: &str, - version: Option<&str>, - filename: Option<&str>, - meta_null_field: Option<&str>, - ) -> Result<Vec<RawReleaseFile>, BackendError> { - let mut q = FileQuery::new(backend); - if let Some(v) = version { - q = q.version(v); - } - if let Some(f) = filename { - q = q.filename(f); - } - if let Some(field) = meta_null_field { - q = q.where_meta_null(field); - } - self.query_files_filtered(q) - .await - .map_err(|e| BackendError::Storage(e.to_string())) - } - - async fn update_file_meta(&self, file: &RawReleaseFile) -> Result<bool, BackendError> { - StorageService::update_file_meta(self, file) - .await - .map_err(|e| BackendError::Storage(e.to_string())) - } } #[cfg(test)] diff --git a/crates/tesor/src/telemetry.rs b/src/telemetry.rs index 9036924..116a7d0 100644 --- a/crates/tesor/src/telemetry.rs +++ b/src/telemetry.rs @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2026 Nikolay Govorov +// SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> // SPDX-License-Identifier: AGPL-3.0-or-later use std::fmt::Debug; @@ -102,9 +102,9 @@ impl Drop for TelemetryService { } impl TelemetryService { pub fn init(config: &TelemetryConfig, service_name: &str, service_version: &str) -> Self { - let env_filter = match std::env::var_os("TESOR_LOG") { + let env_filter = match std::env::var_os("ZORIAN_LOG") { Some(val) => tracing_subscriber::EnvFilter::try_new(val.to_string_lossy()) - .expect("Invalid TESOR_LOG"), + .expect("Invalid ZORIAN_LOG"), None => tracing_subscriber::EnvFilter::new(Self::log_level_to_filter( config.stdout.log_level, )), diff --git a/src/utils.rs b/src/utils.rs new file mode 100644 --- /dev/null +++ b/src/utils.rs @@ -0,0 +1,61 @@ +// SPDX-FileCopyrightText: 2026 Nikolay Govorov <me@govorov.online> +// SPDX-License-Identifier: AGPL-3.0-or-later + +use std::net::SocketAddr; +use std::time::Duration; + +use serde::de::{self, Deserialize, Visitor}; + +/// Deserializes a duration from seconds (u64). +pub fn deserialize_duration_secs<'de, D>(deserializer: D) -> Result<Duration, D::Error> +where + D: serde::Deserializer<'de>, +{ + let secs = u64::deserialize(deserializer)?; + Ok(Duration::from_secs(secs)) +} + +/// Deserializes a u64 from either a number or a string. +pub fn deserialize_size<'de, D>(deserializer: D) -> Result<u64, D::Error> +where + D: serde::Deserializer<'de>, +{ + struct SizeVisitor; + impl<'de> Visitor<'de> for SizeVisitor { + type Value = u64; + + fn expecting(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str("a number or string") + } + + fn visit_u64<E: de::Error>(self, v: u64) -> Result<Self::Value, E> { + Ok(v) + } + + fn visit_str<E: de::Error>(self, v: &str) -> Result<Self::Value, E> { + v.parse().map_err(de::Error::custom) + } + } + + deserializer.deserialize_any(SizeVisitor) +} + +/// Deserializes a SocketAddr from a string. +pub fn deserialize_listener_addr<'de, D>(deserializer: D) -> Result<SocketAddr, D::Error> +where + D: serde::Deserializer<'de>, +{ + let raw = String::deserialize(deserializer)?; + let raw = raw.trim(); + + // Hostnames are not supported, but localhost shorthands are useful + if let Some(port) = raw.strip_prefix("localhost:") { + return port + .parse::<u16>() + .map(|port| SocketAddr::new(std::net::Ipv4Addr::LOCALHOST.into(), port)) + .map_err(|err| serde::de::Error::custom(format!("invalid port in '{raw}': {err}"))); + } + + raw.parse::<SocketAddr>() + .map_err(|err| serde::de::Error::custom(format!("invalid address '{raw}': {err}",))) +} diff --git a/tests/smoke/Cargo.toml b/tests/smoke/Cargo.toml deleted file mode 100644 --- a/tests/smoke/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -[package] -name = "smoke" -version.workspace = true -edition.workspace = true -license.workspace = true -publish.workspace = true - -[[bin]] -name = "smoke" -path = "src/main.rs" - -[dependencies] -hex.workspace = true -reqwest = { version = "0.13", features = ["blocking", "native-tls"], default-features = false } -sha2 = "0.10" diff --git a/tests/smoke/run-local.sh b/tests/smoke/run-local.sh deleted file mode 100755 --- a/tests/smoke/run-local.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env bash -# SPDX-FileCopyrightText: 2026 Nikolay Govorov -# SPDX-License-Identifier: AGPL-3.0-or-later - -# Starts tesor in a temporary directory, runs smoke tests, cleans up. -# Expects a prebuilt binary at target/release/tesor (run `cargo build --release` first). -# -# Usage: -# ./tests/smoke/run-local.sh # default port 2025 -# TESOR_PORT=9999 ./tests/smoke/run-local.sh - -set -euo pipefail - -BIN="target/release/tesor" -PORT="${TESOR_PORT:-2025}" -BASE_URL="http://127.0.0.1:${PORT}" - -TMPDIR="$(mktemp -d)" -LOGFILE="$TMPDIR/tesor.log" -trap 'kill "$PID" 2>/dev/null; wait "$PID" 2>/dev/null; rm -rf "$TMPDIR"' EXIT - -# Write minimal config -cat > "$TMPDIR/tesor.toml" <<EOF -appname = "smoke" -dirname = "$TMPDIR/state" - -[[listen]] -addr = "127.0.0.1:${PORT}" -hostnames = [] - -[server] -shutdown_timeout = 5 -request_timeout = 600 -max_body_size = "64 MB" -max_concurrent_requests = 64 -rate_limit_period = 1 -rate_limit_burst_size = 200 - -[telemetry.stdout] -enabled = true -log_level = "info" -log_format = "pretty" -EOF - -mkdir -p "$TMPDIR/state" - -# Start tesor -echo "Starting tesor on ${BASE_URL}..." -echo "Server log: ${LOGFILE}" -"$BIN" --config="$TMPDIR/tesor.toml" >"$LOGFILE" 2>&1 & -PID=$! - -# Wait for index to load (log shows "index refreshed" for each backend) -echo "Waiting for index to load..." -for i in $(seq 1 120); do - if grep -q "index refreshed" "$LOGFILE" 2>/dev/null; then - echo "Index loaded after ${i}s" - break - fi - if ! kill -0 "$PID" 2>/dev/null; then - echo "tesor exited unexpectedly. Server log:" - cat "$LOGFILE" - exit 1 - fi - sleep 1 -done - -if ! grep -q "index refreshed" "$LOGFILE" 2>/dev/null; then - echo "Timed out waiting for index. Server log:" - cat "$LOGFILE" - exit 1 -fi - -# Run smoke tests -TESOR_URL="${BASE_URL}" cargo run -p smoke diff --git a/tests/smoke/src/main.rs b/tests/smoke/src/main.rs deleted file mode 100644 --- a/tests/smoke/src/main.rs +++ /dev/null @@ -1,403 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Nikolay Govorov -// SPDX-License-Identifier: AGPL-3.0-or-later - -// Black-box smoke tests for Tesor. -// -// Downloads archives from Tesor and upstream, compares sha256 hashes, -// verifies that minisig signatures (Zig) and sha256 checksums (Go) match upstream. -// -// Usage: -// TESOR_URL=https://pkg.earth cargo run -p smoke - -use sha2::{Digest, Sha256}; - -const GO_FILES: &[&str] = &[ - "go1.23.0.linux-amd64.tar.gz", - "go1.23.0.darwin-arm64.tar.gz", - "go1.21.0.windows-amd64.zip", -]; - -struct ZigTestFile { - file: &'static str, - version: &'static str, -} - -const ZIG_FILES: &[ZigTestFile] = &[ - // 0.15.2 (new tarball name format, some new targets) - ZigTestFile { - file: "zig-0.15.2.tar.xz", - version: "0.15.2", - }, - ZigTestFile { - file: "zig-x86_64-windows-0.15.2.zip", - version: "0.15.2", - }, - ZigTestFile { - file: "zig-aarch64-macos-0.15.2.tar.xz", - version: "0.15.2", - }, - ZigTestFile { - file: "zig-aarch64-netbsd-0.15.2.tar.xz", - version: "0.15.2", - }, - ZigTestFile { - file: "zig-powerpc64le-freebsd-0.15.2.tar.xz", - version: "0.15.2", - }, - // Every 'zig-xxx-linux-0.14.1.tar.xz' (same order as on the website) - ZigTestFile { - file: "zig-x86_64-linux-0.14.1.tar.xz", - version: "0.14.1", - }, - ZigTestFile { - file: "zig-aarch64-linux-0.14.1.tar.xz", - version: "0.14.1", - }, - ZigTestFile { - file: "zig-armv7a-linux-0.14.1.tar.xz", - version: "0.14.1", - }, - ZigTestFile { - file: "zig-riscv64-linux-0.14.1.tar.xz", - version: "0.14.1", - }, - ZigTestFile { - file: "zig-powerpc64le-linux-0.14.1.tar.xz", - version: "0.14.1", - }, - ZigTestFile { - file: "zig-x86-linux-0.14.1.tar.xz", - version: "0.14.1", - }, - ZigTestFile { - file: "zig-loongarch64-linux-0.14.1.tar.xz", - version: "0.14.1", - }, - ZigTestFile { - file: "zig-s390x-linux-0.14.1.tar.xz", - version: "0.14.1", - }, - // 0.10.1 (last stage1 release) - ZigTestFile { - file: "zig-0.10.1.tar.xz", - version: "0.10.1", - }, - ZigTestFile { - file: "zig-bootstrap-0.10.1.tar.xz", - version: "0.10.1", - }, - ZigTestFile { - file: "zig-linux-i386-0.10.1.tar.xz", - version: "0.10.1", - }, - ZigTestFile { - file: "zig-macos-aarch64-0.10.1.tar.xz", - version: "0.10.1", - }, - ZigTestFile { - file: "zig-windows-x86_64-0.10.1.zip", - version: "0.10.1", - }, - // 0.7.1 (oldest supported patch release) - ZigTestFile { - file: "zig-0.7.1.tar.xz", - version: "0.7.1", - }, - ZigTestFile { - file: "zig-linux-x86_64-0.7.1.tar.xz", - version: "0.7.1", - }, - // 0.6.0 (oldest supported version) - ZigTestFile { - file: "zig-0.6.0.tar.xz", - version: "0.6.0", - }, - ZigTestFile { - file: "zig-linux-x86_64-0.6.0.tar.xz", - version: "0.6.0", - }, - // 0.1.1 (first release) - ZigTestFile { - file: "zig-win64-0.1.1.zip", - version: "0.1.1", - }, -]; - -struct Runner { - passed: u32, - failed: u32, - client: reqwest::blocking::Client, -} - -impl Runner { - fn new() -> Self { - Self { - passed: 0, - failed: 0, - client: reqwest::blocking::Client::builder() - .timeout(std::time::Duration::from_secs(600)) - .build() - .expect("failed to create HTTP client"), - } - } - - fn ok(&mut self, name: &str) { - self.passed += 1; - println!(" \x1b[32mok\x1b[0m {name}"); - } - - fn fail(&mut self, name: &str, reason: &str) { - self.failed += 1; - println!(" \x1b[31mFAIL\x1b[0m {name}"); - println!(" {reason}"); - } - - fn fetch_bytes(&self, url: &str) -> Result<Vec<u8>, String> { - let resp = self.client.get(url).send().map_err(|e| format!("{e}"))?; - if !resp.status().is_success() { - return Err(format!("{} for {url}", resp.status())); - } - resp.bytes().map(|b| b.to_vec()).map_err(|e| format!("{e}")) - } - - fn fetch_status(&self, url: &str) -> Result<u16, String> { - let resp = self.client.get(url).send().map_err(|e| format!("{e}"))?; - Ok(resp.status().as_u16()) - } - - fn fetch_text(&self, url: &str) -> Result<(u16, String, String), String> { - let resp = self.client.get(url).send().map_err(|e| format!("{e}"))?; - let status = resp.status().as_u16(); - let content_type = resp - .headers() - .get("content-type") - .and_then(|v| v.to_str().ok()) - .unwrap_or("") - .to_string(); - let body = resp.text().map_err(|e| format!("{e}"))?; - Ok((status, content_type, body)) - } -} - -fn sha256hex(data: &[u8]) -> String { - hex::encode(Sha256::digest(data)) -} - -fn zig_upstream_url(file: &str, version: &str) -> String { - format!("https://ziglang.org/download/{version}/{file}") -} - -fn test_web(r: &mut Runner, base_url: &str) { - println!("\n--- Web ---"); - - { - let name = "GET / returns html"; - match r.fetch_text(&format!("{base_url}/")) { - Ok((status, ct, body)) => { - if status != 200 { - r.fail(name, &format!("status {status}, expected 200")); - } else if !ct.contains("text/html") { - r.fail(name, &format!("content-type: {ct}")); - } else if !body.contains("Tesor") { - r.fail(name, "body missing \"Tesor\""); - } else { - r.ok(name); - } - } - Err(e) => r.fail(name, &e), - } - } - - { - let name = "GET /base.css returns css"; - match r.fetch_text(&format!("{base_url}/base.css")) { - Ok((status, ct, body)) => { - if status != 200 { - r.fail(name, &format!("status {status}")); - } else if !ct.contains("text/css") { - r.fail(name, &format!("content-type: {ct}")); - } else if body.is_empty() { - r.fail(name, "empty body"); - } else { - r.ok(name); - } - } - Err(e) => r.fail(name, &e), - } - } - - { - let name = "GET /favicon.ico returns icon"; - match r.fetch_status(&format!("{base_url}/favicon.ico")) { - Ok(200) => r.ok(name), - Ok(s) => r.fail(name, &format!("status {s}")), - Err(e) => r.fail(name, &e), - } - } - - { - let name = "GET /about/licenses returns html"; - match r.fetch_text(&format!("{base_url}/about/licenses")) { - Ok((status, ct, body)) => { - if status != 200 { - r.fail(name, &format!("status {status}")); - } else if !ct.contains("text/html") { - r.fail(name, &format!("content-type: {ct}")); - } else if !body.contains("AGPL") { - r.fail(name, "body missing \"AGPL\""); - } else { - r.ok(name); - } - } - Err(e) => r.fail(name, &e), - } - } - - { - let name = "GET /does-not-exist returns 404"; - match r.fetch_status(&format!("{base_url}/does-not-exist.xyz")) { - Ok(404) => r.ok(name), - Ok(s) => r.fail(name, &format!("status {s}, expected 404")), - Err(e) => r.fail(name, &e), - } - } -} - -fn test_go(r: &mut Runner, base_url: &str) { - println!("\n--- Go ---"); - - for file in GO_FILES { - // Archive: compare sha256 with upstream - { - let name = format!("go: {file} matches upstream"); - match ( - r.fetch_bytes(&format!("{base_url}/go/{file}")), - r.fetch_bytes(&format!("https://go.dev/dl/{file}")), - ) { - (Ok(tesor), Ok(upstream)) => { - let zh = sha256hex(&tesor); - let uh = sha256hex(&upstream); - if zh != uh { - r.fail(&name, &format!("tesor={zh} upstream={uh}")); - } else { - r.ok(&name); - } - } - (Err(e), _) | (_, Err(e)) => r.fail(&name, &e), - } - } - - // Checksum: compare .sha256 endpoint with computed hash - { - let name = format!("go: {file}.sha256 matches content"); - match ( - r.fetch_bytes(&format!("{base_url}/go/{file}")), - r.fetch_text(&format!("{base_url}/go/{file}.sha256")), - ) { - (Ok(archive), Ok((200, _, checksum_body))) => { - let computed = sha256hex(&archive); - let expected = checksum_body.trim(); - if computed != expected { - r.fail(&name, &format!("computed={computed} endpoint={expected}")); - } else { - r.ok(&name); - } - } - (Ok(_), Ok((s, _, _))) => { - r.fail(&name, &format!("sha256 endpoint returned {s}")); - } - (Err(e), _) | (_, Err(e)) => r.fail(&name, &e), - } - } - } - - { - let name = "go: nonexistent version returns 404"; - match r.fetch_status(&format!("{base_url}/go/go99.99.99.linux-amd64.tar.gz")) { - Ok(404) => r.ok(name), - Ok(s) => r.fail(name, &format!("status {s}, expected 404")), - Err(e) => r.fail(name, &e), - } - } -} - -fn test_zig(r: &mut Runner, base_url: &str) { - println!("\n--- Zig ---"); - - for entry in ZIG_FILES { - // Archive: compare sha256 with upstream - { - let name = format!("zig: {} matches upstream", entry.file); - match ( - r.fetch_bytes(&format!("{base_url}/zig/{}", entry.file)), - r.fetch_bytes(&zig_upstream_url(entry.file, entry.version)), - ) { - (Ok(tesor), Ok(upstream)) => { - let zh = sha256hex(&tesor); - let uh = sha256hex(&upstream); - if zh != uh { - r.fail(&name, &format!("tesor={zh} upstream={uh}")); - } else { - r.ok(&name); - } - } - (Err(e), _) | (_, Err(e)) => r.fail(&name, &e), - } - } - - // Signature: compare .minisig with upstream - { - let name = format!("zig: {}.minisig matches upstream", entry.file); - let tesor_url = format!("{base_url}/zig/{}.minisig", entry.file); - let upstream_url = format!("{}.minisig", zig_upstream_url(entry.file, entry.version)); - match (r.fetch_bytes(&tesor_url), r.fetch_bytes(&upstream_url)) { - (Ok(tesor), Ok(upstream)) => { - if tesor != upstream { - r.fail(&name, "minisig content differs from upstream"); - } else { - r.ok(&name); - } - } - (Err(e), _) | (_, Err(e)) => r.fail(&name, &e), - } - } - } - - { - let name = "zig: nonexistent version returns 404"; - match r.fetch_status(&format!("{base_url}/zig/zig-x86_64-linux-99.99.99.tar.xz")) { - Ok(404) => r.ok(name), - Ok(s) => r.fail(name, &format!("status {s}, expected 404")), - Err(e) => r.fail(name, &e), - } - } -} - -fn main() { - let base_url = match std::env::var("TESOR_URL") { - Ok(url) => url, - Err(_) => { - eprintln!("Error: TESOR_URL environment variable is not set."); - eprintln!("Usage: TESOR_URL=https://pkg.earth cargo run -p smoke"); - std::process::exit(1); - } - }; - - let base_url = base_url.trim_end_matches('/'); - println!("Smoke tests against {base_url}"); - - let mut runner = Runner::new(); - - test_web(&mut runner, base_url); - test_go(&mut runner, base_url); - test_zig(&mut runner, base_url); - - println!( - "\n--- Results: {} passed, {} failed ---", - runner.passed, runner.failed - ); - - if runner.failed > 0 { - std::process::exit(1); - } -} |
