Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b508a94198 | ||
|
|
4ed09e2209 | ||
|
|
e2a9d68843 | ||
|
|
c04e8f7084 | ||
|
|
323e5f7f3d | ||
|
|
7ad83ca1f6 | ||
|
|
8ef53c999a | ||
|
|
21bc7805f7 | ||
|
|
8d1d0f50de | ||
|
|
d6c6e60742 | ||
|
|
1cdd100473 | ||
|
|
80fda92231 | ||
|
|
5f6bff5dcb | ||
|
|
1a04f44bb5 | ||
|
|
d8b580a19c | ||
|
|
023e85741a | ||
|
|
2258509021 | ||
|
|
e6a296baf4 | ||
|
|
14be5cd836 | ||
|
|
6b373380f4 | ||
|
|
fc8e6d10e8 | ||
|
|
1a314778ad | ||
|
|
2e9ad57d61 | ||
|
|
b00d3ef633 | ||
|
|
ae5f939fb2 | ||
|
|
385d531461 | ||
|
|
00aab3dd6b | ||
|
|
8343bcbb54 | ||
|
|
b8d60fcc23 | ||
|
|
44ffb9557a | ||
|
|
26fbe86e90 | ||
|
|
b3f4a2d9eb | ||
|
|
d4225f38fe | ||
|
|
c386f87a0e | ||
|
|
80255f1fff | ||
|
|
3eaaeee408 | ||
|
|
f474632f4c | ||
|
|
ababa9d6b6 | ||
|
|
47a8143bce | ||
|
|
831fd0cc45 | ||
|
|
fe418d650d | ||
|
|
13404297c4 | ||
|
|
8d24d4811a | ||
|
|
7e17f063ea |
No files matched your search
@@ -0,0 +1,52 @@
|
||||
name: GitHub Actions Security
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
merge_group:
|
||||
schedule:
|
||||
- cron: "11 3 * * 1"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
actionlint:
|
||||
name: actionlint
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Run actionlint
|
||||
uses: raven-actions/actionlint@205b530c5d9fa8f44ae9ed59f341a0db994aa6f8 # v2
|
||||
|
||||
zizmor:
|
||||
name: zizmor
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
actions: read
|
||||
security-events: write
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Run zizmor
|
||||
uses: zizmorcore/zizmor-action@b1d7e1fb5de872772f31590499237e7cce841e8e # v0.5.3
|
||||
with:
|
||||
persona: regular
|
||||
@@ -1,21 +0,0 @@
|
||||
name: Build and Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Build
|
||||
run: cargo build --verbose
|
||||
- name: Run tests
|
||||
run: cargo test --verbose
|
||||
@@ -0,0 +1,115 @@
|
||||
name: Rust CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
merge_group:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
fmt:
|
||||
name: cargo fmt
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1
|
||||
with:
|
||||
components: rustfmt
|
||||
cache-key: fmt
|
||||
|
||||
- name: Check formatting
|
||||
uses: actions-rust-lang/rustfmt@4066006ec54a31931b9b1fddfd38f2fdf2d27143 # v1
|
||||
|
||||
clippy:
|
||||
name: cargo clippy
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1
|
||||
with:
|
||||
components: clippy
|
||||
cache-key: clippy
|
||||
|
||||
- name: Run clippy
|
||||
run: |
|
||||
cargo clippy \
|
||||
--workspace \
|
||||
--all-targets \
|
||||
--all-features \
|
||||
--locked \
|
||||
-- -D warnings
|
||||
|
||||
test:
|
||||
name: cargo test
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 25
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1
|
||||
with:
|
||||
cache-key: test
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cargo test \
|
||||
--workspace \
|
||||
--all-targets \
|
||||
--all-features \
|
||||
--locked
|
||||
|
||||
docs:
|
||||
name: cargo doc
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
|
||||
env:
|
||||
RUSTDOCFLAGS: "-D warnings"
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1
|
||||
with:
|
||||
cache-key: docs
|
||||
|
||||
- name: Check docs
|
||||
run: |
|
||||
cargo doc \
|
||||
--workspace \
|
||||
--all-features \
|
||||
--no-deps \
|
||||
--locked
|
||||
@@ -0,0 +1,49 @@
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
|
||||
# A sample workflow which sets up periodic OSV-Scanner scanning for vulnerabilities,
|
||||
# in addition to a PR check which fails if new vulnerabilities are introduced.
|
||||
#
|
||||
# For more examples and options, including how to ignore specific vulnerabilities,
|
||||
# see https://google.github.io/osv-scanner/github-action/
|
||||
|
||||
name: OSV-Scanner
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: ["main"]
|
||||
merge_group:
|
||||
branches: ["main"]
|
||||
schedule:
|
||||
- cron: "45 8 * * 1"
|
||||
push:
|
||||
branches: ["main"]
|
||||
|
||||
permissions:
|
||||
# Require writing security events to upload SARIF file to security tab
|
||||
security-events: write
|
||||
# Read commit contents
|
||||
contents: read
|
||||
actions: read
|
||||
|
||||
jobs:
|
||||
scan-scheduled:
|
||||
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
|
||||
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@9a498708959aeaef5ef730655706c5a1df1edbc2" # v2.3.8
|
||||
with:
|
||||
# Example of specifying custom arguments
|
||||
scan-args: |-
|
||||
-r
|
||||
--skip-git
|
||||
./
|
||||
scan-pr:
|
||||
if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
|
||||
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable-pr.yml@9a498708959aeaef5ef730655706c5a1df1edbc2" # v2.3.8
|
||||
with:
|
||||
# Example of specifying custom arguments
|
||||
scan-args: |-
|
||||
-r
|
||||
--skip-git
|
||||
./
|
||||
@@ -0,0 +1,296 @@
|
||||
# This file was autogenerated by dist: https://axodotdev.github.io/cargo-dist
|
||||
#
|
||||
# Copyright 2022-2024, axodotdev
|
||||
# SPDX-License-Identifier: MIT or Apache-2.0
|
||||
#
|
||||
# CI that:
|
||||
#
|
||||
# * checks for a Git Tag that looks like a release
|
||||
# * builds artifacts with dist (archives, installers, hashes)
|
||||
# * uploads those artifacts to temporary workflow zip
|
||||
# * on success, uploads the artifacts to a GitHub Release
|
||||
#
|
||||
# Note that the GitHub Release will be created with a generated
|
||||
# title/body based on your changelogs.
|
||||
|
||||
name: Release
|
||||
permissions:
|
||||
"contents": "write"
|
||||
|
||||
# This task will run whenever you push a git tag that looks like a version
|
||||
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
|
||||
# Various formats will be parsed into a VERSION and an optional PACKAGE_NAME, where
|
||||
# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION
|
||||
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
|
||||
#
|
||||
# If PACKAGE_NAME is specified, then the announcement will be for that
|
||||
# package (erroring out if it doesn't have the given version or isn't dist-able).
|
||||
#
|
||||
# If PACKAGE_NAME isn't specified, then the announcement will be for all
|
||||
# (dist-able) packages in the workspace with that version (this mode is
|
||||
# intended for workspaces with only one dist-able package, or with all dist-able
|
||||
# packages versioned/released in lockstep).
|
||||
#
|
||||
# If you push multiple tags at once, separate instances of this workflow will
|
||||
# spin up, creating an independent announcement for each one. However, GitHub
|
||||
# will hard limit this to 3 tags per commit, as it will assume more tags is a
|
||||
# mistake.
|
||||
#
|
||||
# If there's a prerelease-style suffix to the version, then the release(s)
|
||||
# will be marked as a prerelease.
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
tags:
|
||||
- '**[0-9]+.[0-9]+.[0-9]+*'
|
||||
|
||||
jobs:
|
||||
# Run 'dist plan' (or host) to determine what tasks we need to do
|
||||
plan:
|
||||
runs-on: "ubuntu-22.04"
|
||||
outputs:
|
||||
val: ${{ steps.plan.outputs.manifest }}
|
||||
tag: ${{ !github.event.pull_request && github.ref_name || '' }}
|
||||
tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }}
|
||||
publishing: ${{ !github.event.pull_request }}
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
submodules: recursive
|
||||
- name: Install dist
|
||||
# we specify bash to get pipefail; it guards against the `curl` command
|
||||
# failing. otherwise `sh` won't catch that `curl` returned non-0
|
||||
shell: bash
|
||||
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.31.0/cargo-dist-installer.sh | sh"
|
||||
- name: Cache dist
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: cargo-dist-cache
|
||||
path: ~/.cargo/bin/dist
|
||||
# sure would be cool if github gave us proper conditionals...
|
||||
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
|
||||
# functionality based on whether this is a pull_request, and whether it's from a fork.
|
||||
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
|
||||
# but also really annoying to build CI around when it needs secrets to work right.)
|
||||
- id: plan
|
||||
run: |
|
||||
dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
|
||||
echo "dist ran successfully"
|
||||
cat plan-dist-manifest.json
|
||||
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
|
||||
- name: "Upload dist-manifest.json"
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: artifacts-plan-dist-manifest
|
||||
path: plan-dist-manifest.json
|
||||
|
||||
# Build and packages all the platform-specific things
|
||||
build-local-artifacts:
|
||||
name: build-local-artifacts (${{ join(matrix.targets, ', ') }})
|
||||
# Let the initial task tell us to not run (currently very blunt)
|
||||
needs:
|
||||
- plan
|
||||
if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
# Target platforms/runners are computed by dist in create-release.
|
||||
# Each member of the matrix has the following arguments:
|
||||
#
|
||||
# - runner: the github runner
|
||||
# - dist-args: cli flags to pass to dist
|
||||
# - install-dist: expression to run to install dist on the runner
|
||||
#
|
||||
# Typically there will be:
|
||||
# - 1 "global" task that builds universal installers
|
||||
# - N "local" tasks that build each platform's binaries and platform-specific installers
|
||||
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
|
||||
runs-on: ${{ matrix.runner }}
|
||||
container: ${{ matrix.container && matrix.container.image || null }}
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
|
||||
steps:
|
||||
- name: enable windows longpaths
|
||||
run: |
|
||||
git config --global core.longpaths true
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
submodules: recursive
|
||||
- name: Install Rust non-interactively if not already installed
|
||||
if: ${{ matrix.container }}
|
||||
run: |
|
||||
if ! command -v cargo > /dev/null 2>&1; then
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
||||
fi
|
||||
- name: Install dist
|
||||
run: ${{ matrix.install_dist.run }}
|
||||
# Get the dist-manifest
|
||||
- name: Fetch local artifacts
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
pattern: artifacts-*
|
||||
path: target/distrib/
|
||||
merge-multiple: true
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
${{ matrix.packages_install }}
|
||||
- name: Build artifacts
|
||||
run: |
|
||||
# Actually do builds and make zips and whatnot
|
||||
dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
|
||||
echo "dist ran successfully"
|
||||
- id: cargo-dist
|
||||
name: Post-build
|
||||
# We force bash here just because github makes it really hard to get values up
|
||||
# to "real" actions without writing to env-vars, and writing to env-vars has
|
||||
# inconsistent syntax between shell and powershell.
|
||||
shell: bash
|
||||
run: |
|
||||
# Parse out what we just built and upload it to scratch storage
|
||||
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
|
||||
dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
|
||||
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||
|
||||
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
|
||||
- name: "Upload artifacts"
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: artifacts-build-local-${{ join(matrix.targets, '_') }}
|
||||
path: |
|
||||
${{ steps.cargo-dist.outputs.paths }}
|
||||
${{ env.BUILD_MANIFEST_NAME }}
|
||||
|
||||
# Build and package all the platform-agnostic(ish) things
|
||||
build-global-artifacts:
|
||||
needs:
|
||||
- plan
|
||||
- build-local-artifacts
|
||||
runs-on: "ubuntu-22.04"
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
submodules: recursive
|
||||
- name: Install cached dist
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
name: cargo-dist-cache
|
||||
path: ~/.cargo/bin/
|
||||
- run: chmod +x ~/.cargo/bin/dist
|
||||
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
|
||||
- name: Fetch local artifacts
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
pattern: artifacts-*
|
||||
path: target/distrib/
|
||||
merge-multiple: true
|
||||
- id: cargo-dist
|
||||
shell: bash
|
||||
run: |
|
||||
dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
|
||||
echo "dist ran successfully"
|
||||
|
||||
# Parse out what we just built and upload it to scratch storage
|
||||
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
|
||||
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
|
||||
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||
|
||||
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
|
||||
- name: "Upload artifacts"
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: artifacts-build-global
|
||||
path: |
|
||||
${{ steps.cargo-dist.outputs.paths }}
|
||||
${{ env.BUILD_MANIFEST_NAME }}
|
||||
# Determines if we should publish/announce
|
||||
host:
|
||||
needs:
|
||||
- plan
|
||||
- build-local-artifacts
|
||||
- build-global-artifacts
|
||||
# Only run if we're "publishing", and only if plan, local and global didn't fail (skipped is fine)
|
||||
if: ${{ always() && needs.plan.result == 'success' && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }}
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
runs-on: "ubuntu-22.04"
|
||||
outputs:
|
||||
val: ${{ steps.host.outputs.manifest }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
submodules: recursive
|
||||
- name: Install cached dist
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
name: cargo-dist-cache
|
||||
path: ~/.cargo/bin/
|
||||
- run: chmod +x ~/.cargo/bin/dist
|
||||
# Fetch artifacts from scratch-storage
|
||||
- name: Fetch artifacts
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
pattern: artifacts-*
|
||||
path: target/distrib/
|
||||
merge-multiple: true
|
||||
- id: host
|
||||
shell: bash
|
||||
run: |
|
||||
dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
|
||||
echo "artifacts uploaded and released successfully"
|
||||
cat dist-manifest.json
|
||||
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
|
||||
- name: "Upload dist-manifest.json"
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
# Overwrite the previous copy
|
||||
name: artifacts-dist-manifest
|
||||
path: dist-manifest.json
|
||||
# Create a GitHub Release while uploading all files to it
|
||||
- name: "Download GitHub Artifacts"
|
||||
uses: actions/download-artifact@v7
|
||||
with:
|
||||
pattern: artifacts-*
|
||||
path: artifacts
|
||||
merge-multiple: true
|
||||
- name: Cleanup
|
||||
run: |
|
||||
# Remove the granular manifests
|
||||
rm -f artifacts/*-dist-manifest.json
|
||||
- name: Create GitHub Release
|
||||
env:
|
||||
PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
|
||||
ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
|
||||
ANNOUNCEMENT_BODY: "${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
|
||||
RELEASE_COMMIT: "${{ github.sha }}"
|
||||
run: |
|
||||
# Write and read notes from a file to avoid quoting breaking things
|
||||
echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
|
||||
|
||||
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
|
||||
|
||||
announce:
|
||||
needs:
|
||||
- plan
|
||||
- host
|
||||
# use "always() && ..." to allow us to wait for all publish jobs while
|
||||
# still allowing individual publish jobs to skip themselves (for prereleases).
|
||||
# "host" however must run to completion, no skipping allowed!
|
||||
if: ${{ always() && needs.host.result == 'success' }}
|
||||
runs-on: "ubuntu-22.04"
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
submodules: recursive
|
||||
@@ -0,0 +1,72 @@
|
||||
name: Clippy SARIF
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
schedule:
|
||||
- cron: "17 12 * * 4"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
security-events: write
|
||||
actions: read
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
clippy-sarif:
|
||||
name: Clippy SARIF
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 25
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1
|
||||
with:
|
||||
components: clippy
|
||||
cache-key: clippy-sarif
|
||||
|
||||
- name: Install SARIF tools
|
||||
run: |
|
||||
cargo install --locked clippy-sarif sarif-fmt
|
||||
|
||||
- name: Run Clippy and generate SARIF
|
||||
id: clippy
|
||||
shell: bash
|
||||
run: |
|
||||
set +e
|
||||
|
||||
cargo clippy \
|
||||
--workspace \
|
||||
--all-targets \
|
||||
--all-features \
|
||||
--locked \
|
||||
--message-format=json \
|
||||
| clippy-sarif \
|
||||
| tee rust-clippy-results.sarif \
|
||||
| sarif-fmt
|
||||
|
||||
clippy_status=${PIPESTATUS[0]}
|
||||
echo "exit_code=${clippy_status}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
exit 0
|
||||
|
||||
- name: Upload Clippy SARIF
|
||||
uses: github/codeql-action/upload-sarif@68bde559dea0fdcac2102bfdf6230c5f70eb485e # v4
|
||||
if: always()
|
||||
with:
|
||||
sarif_file: rust-clippy-results.sarif
|
||||
category: clippy
|
||||
wait-for-processing: true
|
||||
|
||||
- name: Fail if Clippy failed
|
||||
if: steps.clippy.outputs.exit_code != '0'
|
||||
run: exit 1
|
||||
@@ -0,0 +1,27 @@
|
||||
name: Semver
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
semver:
|
||||
name: cargo-semver-checks
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Check semver compatibility
|
||||
uses: obi1kenobi/cargo-semver-checks-action@6b69fcf40e9b5fb17adeb57e4b6ecd020649a239 # v2
|
||||
with:
|
||||
feature-group: all-features
|
||||
@@ -0,0 +1,64 @@
|
||||
name: Supply chain
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
merge_group:
|
||||
schedule:
|
||||
- cron: "41 2 * * 1"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
cargo-deny:
|
||||
name: cargo-deny ${{ matrix.checks }}
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
# Advisories can appear after code was merged. Keep this visible,
|
||||
# but don't let a surprise upstream advisory nuke every unrelated PR.
|
||||
- checks: advisories
|
||||
continue-on-error: true
|
||||
|
||||
# These are policy choices in this repo. They should block PRs.
|
||||
- checks: bans licenses sources
|
||||
continue-on-error: false
|
||||
|
||||
continue-on-error: ${{ matrix.continue-on-error }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Run cargo-deny
|
||||
uses: EmbarkStudios/cargo-deny-action@6c8f9facfa5047ec02d8485b6bf52b587b7777d1 # v2
|
||||
with:
|
||||
command: check
|
||||
arguments: --all-features
|
||||
command-arguments: ${{ matrix.checks }}
|
||||
|
||||
actionlint:
|
||||
name: actionlint
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Run actionlint
|
||||
uses: raven-actions/actionlint@205b530c5d9fa8f44ae9ed59f341a0db994aa6f8 # v2
|
||||
Generated
+57
-116
@@ -38,7 +38,7 @@ version = "1.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
|
||||
dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -49,7 +49,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"once_cell_polyfill",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -60,11 +60,11 @@ checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.4"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
|
||||
checksum = "cdd35008169921d80bc60d3d0ab416eecb028c4cd653352907921d95084790be"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"hybrid-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -128,6 +128,12 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9"
|
||||
|
||||
[[package]]
|
||||
name = "cmov"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f88a43d011fc4a6876cb7344703e297c71dda42494fee094d5f7c76bf13f746"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.5"
|
||||
@@ -135,13 +141,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.7"
|
||||
name = "const-oid"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
|
||||
checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c"
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77727bb15fa921304124b128af125e7e3b968275d1b108b379190264f4423710"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"typenum",
|
||||
"hybrid-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -152,18 +163,28 @@ checksum = "e0b1fab2ae45819af2d0731d60f2afe17227ebb1a1538a236da84c93e9a60162"
|
||||
dependencies = [
|
||||
"dispatch2",
|
||||
"nix",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctutils"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d5515a3834141de9eafb9717ad39eea8247b5674e6066c404e8c4b365d2a29e"
|
||||
dependencies = [
|
||||
"cmov",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
version = "0.11.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
||||
checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"const-oid",
|
||||
"crypto-common",
|
||||
"subtle",
|
||||
"ctutils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -178,16 +199,6 @@ dependencies = [
|
||||
"objc2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
@@ -196,16 +207,25 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "hmac"
|
||||
version = "0.12.1"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
|
||||
checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f"
|
||||
dependencies = [
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hybrid-array"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9155a582abd142abc056962c29e3ce5ff2ad5469f4246b537ed42c5deba857da"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "irtt-cli"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"ctrlc",
|
||||
@@ -216,7 +236,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "irtt-client"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"irtt-proto",
|
||||
"libc",
|
||||
@@ -226,7 +246,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "irtt-proto"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"hmac",
|
||||
"md-5",
|
||||
@@ -236,7 +256,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "irtt-stats"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"irtt-client",
|
||||
]
|
||||
@@ -255,9 +275,9 @@ checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
|
||||
|
||||
[[package]]
|
||||
name = "md-5"
|
||||
version = "0.10.6"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf"
|
||||
checksum = "69b6441f590336821bb897fb28fc622898ccceb1d6cea3fde5ea86b090c4de98"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"digest",
|
||||
@@ -265,9 +285,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.31.2"
|
||||
version = "0.31.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d6d0705320c1e6ba1d912b5e37cf18071b6c2e9b7fa8215a1e8a7651966f5d3"
|
||||
checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
@@ -316,12 +336,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.5.10"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678"
|
||||
checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -385,27 +405,12 @@ version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.61.2"
|
||||
@@ -414,67 +419,3 @@ checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
+15
-3
@@ -16,6 +16,18 @@ homepage = "https://github.com/Lochnair/irtt-rs"
|
||||
readme = "README.md"
|
||||
|
||||
[workspace.dependencies]
|
||||
irtt-proto = { version = "0.1.0", path = "crates/irtt-proto" }
|
||||
irtt-client = { version = "0.1.0", path = "crates/irtt-client" }
|
||||
irtt-stats = { version = "0.1.0", path = "crates/irtt-stats" }
|
||||
irtt-proto = { version = "0.2.0", path = "crates/irtt-proto" }
|
||||
irtt-client = { version = "0.2.0", path = "crates/irtt-client" }
|
||||
irtt-stats = { version = "0.2.0", path = "crates/irtt-stats" }
|
||||
|
||||
[profile.release]
|
||||
opt-level = "z"
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
panic = "abort"
|
||||
strip = "symbols"
|
||||
|
||||
# The profile that 'dist' will build with
|
||||
[profile.dist]
|
||||
inherits = "release"
|
||||
lto = "thin"
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "irtt-cli"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
description = "Command-line IRTT-compatible client"
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
@@ -16,8 +16,8 @@ default = ["stats"]
|
||||
stats = ["dep:irtt-stats"]
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.5", features = ["derive"] }
|
||||
ctrlc = "3.4"
|
||||
clap = { version = "4.6.1", features = ["derive"] }
|
||||
ctrlc = "3.5.2"
|
||||
irtt-client.workspace = true
|
||||
irtt-proto.workspace = true
|
||||
irtt-stats = { workspace = true, optional = true }
|
||||
+37
-79
@@ -326,8 +326,8 @@ pub struct HumanEventStats {
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct HumanIpdvPair {
|
||||
pub previous_logical_seq: u64,
|
||||
pub current_logical_seq: u64,
|
||||
pub previous_seq: u32,
|
||||
pub current_seq: u32,
|
||||
pub rtt_ipdv: Duration,
|
||||
pub send_ipdv: Option<Duration>,
|
||||
pub receive_ipdv: Option<Duration>,
|
||||
@@ -352,8 +352,8 @@ impl From<irtt_stats::EventStatsUpdate> for HumanEventStats {
|
||||
impl From<irtt_stats::IpdvPairUpdate> for HumanIpdvPair {
|
||||
fn from(value: irtt_stats::IpdvPairUpdate) -> Self {
|
||||
Self {
|
||||
previous_logical_seq: value.previous_logical_seq,
|
||||
current_logical_seq: value.current_logical_seq,
|
||||
previous_seq: value.previous_seq,
|
||||
current_seq: value.current_seq,
|
||||
rtt_ipdv: value.rtt_ipdv,
|
||||
send_ipdv: value.send_ipdv,
|
||||
receive_ipdv: value.receive_ipdv,
|
||||
@@ -385,7 +385,6 @@ pub fn format_human_event_with_options(
|
||||
ClientEvent::EchoSent { .. } => String::new(),
|
||||
ClientEvent::EchoReply {
|
||||
seq,
|
||||
logical_seq,
|
||||
rtt,
|
||||
server_timing,
|
||||
one_way,
|
||||
@@ -393,17 +392,9 @@ pub fn format_human_event_with_options(
|
||||
..
|
||||
} => {
|
||||
let mut out = format!("seq={seq}");
|
||||
if options.verbose {
|
||||
write!(out, " logical_seq={logical_seq}").unwrap();
|
||||
}
|
||||
write!(out, " rtt={}", format_duration(rtt.effective)).unwrap();
|
||||
write_human_one_way(&mut out, *one_way);
|
||||
write!(
|
||||
out,
|
||||
" ipdv={}",
|
||||
format_human_ipdv(stats, Some(*logical_seq))
|
||||
)
|
||||
.unwrap();
|
||||
write!(out, " ipdv={}", format_human_ipdv(stats, *seq)).unwrap();
|
||||
if let Some(processing) = server_timing.and_then(|timing| timing.processing) {
|
||||
write!(out, " proc={}", format_duration(processing)).unwrap();
|
||||
}
|
||||
@@ -412,17 +403,14 @@ pub fn format_human_event_with_options(
|
||||
}
|
||||
out
|
||||
}
|
||||
ClientEvent::EchoLoss {
|
||||
seq, logical_seq, ..
|
||||
} => {
|
||||
format!("loss seq={seq} logical_seq={logical_seq}")
|
||||
ClientEvent::EchoLoss { seq, .. } => {
|
||||
format!("loss seq={seq}")
|
||||
}
|
||||
ClientEvent::DuplicateReply { seq, remote, .. } => {
|
||||
format!("duplicate seq={seq} remote={remote}")
|
||||
}
|
||||
ClientEvent::LateReply {
|
||||
seq,
|
||||
logical_seq,
|
||||
highest_seen,
|
||||
remote,
|
||||
rtt,
|
||||
@@ -430,19 +418,16 @@ pub fn format_human_event_with_options(
|
||||
received_stats,
|
||||
..
|
||||
} => {
|
||||
let mut out = format!(
|
||||
"late seq={seq} logical_seq={} highest_seen={highest_seen} remote={remote}",
|
||||
optional_u64(*logical_seq)
|
||||
);
|
||||
let mut out = format!("late seq={seq} highest_seen={highest_seen} remote={remote}",);
|
||||
if let Some(rtt) = rtt {
|
||||
write!(out, " rtt={}", format_duration(rtt.effective)).unwrap();
|
||||
write_human_one_way(&mut out, *one_way);
|
||||
write!(out, " ipdv={}", format_human_ipdv(stats, *logical_seq)).unwrap();
|
||||
write!(out, " ipdv={}", format_human_ipdv(stats, *seq)).unwrap();
|
||||
}
|
||||
write_human_received_stats(&mut out, *received_stats);
|
||||
out
|
||||
}
|
||||
ClientEvent::Warning { kind, message } => {
|
||||
ClientEvent::Warning { kind, message, .. } => {
|
||||
format!("warning kind={} message={message}", warning_kind(*kind))
|
||||
}
|
||||
}
|
||||
@@ -489,7 +474,6 @@ fn format_machine(event: &ClientEvent) -> String {
|
||||
ClientEvent::EchoSent { .. } => {}
|
||||
ClientEvent::EchoReply {
|
||||
seq,
|
||||
logical_seq,
|
||||
remote,
|
||||
sent_at,
|
||||
received_at,
|
||||
@@ -501,7 +485,7 @@ fn format_machine(event: &ClientEvent) -> String {
|
||||
packet_meta,
|
||||
} => {
|
||||
write_common(&mut out, "echo_reply");
|
||||
write_seq(&mut out, *seq, Some(*logical_seq));
|
||||
write_seq(&mut out, *seq);
|
||||
write_remote(&mut out, *remote);
|
||||
write_wall(&mut out, "client_send_wall_ns", sent_at.wall);
|
||||
write_wall(&mut out, "client_receive_wall_ns", received_at.wall);
|
||||
@@ -511,14 +495,9 @@ fn format_machine(event: &ClientEvent) -> String {
|
||||
write_received_stats(&mut out, *received_stats);
|
||||
write_packet_meta(&mut out, *packet_meta);
|
||||
}
|
||||
ClientEvent::EchoLoss {
|
||||
seq,
|
||||
logical_seq,
|
||||
sent_at,
|
||||
..
|
||||
} => {
|
||||
ClientEvent::EchoLoss { seq, sent_at, .. } => {
|
||||
write_common(&mut out, "loss");
|
||||
write_seq(&mut out, *seq, Some(*logical_seq));
|
||||
write_seq(&mut out, *seq);
|
||||
write_wall(&mut out, "client_send_wall_ns", sent_at.wall);
|
||||
out.push_str(" warning=loss");
|
||||
}
|
||||
@@ -529,14 +508,13 @@ fn format_machine(event: &ClientEvent) -> String {
|
||||
bytes: _,
|
||||
} => {
|
||||
write_common(&mut out, "duplicate");
|
||||
write_seq(&mut out, *seq, None);
|
||||
write_seq(&mut out, *seq);
|
||||
write_remote(&mut out, *remote);
|
||||
write_wall(&mut out, "client_receive_wall_ns", received_at.wall);
|
||||
out.push_str(" warning=duplicate");
|
||||
}
|
||||
ClientEvent::LateReply {
|
||||
seq,
|
||||
logical_seq,
|
||||
highest_seen,
|
||||
remote,
|
||||
sent_at,
|
||||
@@ -549,7 +527,7 @@ fn format_machine(event: &ClientEvent) -> String {
|
||||
packet_meta,
|
||||
} => {
|
||||
write_common(&mut out, "late");
|
||||
write_seq(&mut out, *seq, *logical_seq);
|
||||
write_seq(&mut out, *seq);
|
||||
write_remote(&mut out, *remote);
|
||||
write!(out, " highest_seen={highest_seen}").unwrap();
|
||||
if let Some(sent_at) = sent_at {
|
||||
@@ -565,8 +543,9 @@ fn format_machine(event: &ClientEvent) -> String {
|
||||
write_packet_meta(&mut out, *packet_meta);
|
||||
out.push_str(" warning=late");
|
||||
}
|
||||
ClientEvent::Warning { kind, message } => {
|
||||
ClientEvent::Warning { kind, message, at } => {
|
||||
write_common(&mut out, "warning");
|
||||
write_wall(&mut out, "at", at.wall);
|
||||
write!(
|
||||
out,
|
||||
" warning_kind={} message={}",
|
||||
@@ -593,7 +572,6 @@ fn format_simple(event: &ClientEvent) -> String {
|
||||
ClientEvent::EchoSent { .. } => String::new(),
|
||||
ClientEvent::EchoReply {
|
||||
seq,
|
||||
logical_seq,
|
||||
remote,
|
||||
rtt,
|
||||
server_timing,
|
||||
@@ -601,7 +579,7 @@ fn format_simple(event: &ClientEvent) -> String {
|
||||
..
|
||||
} => {
|
||||
let mut out = format!(
|
||||
"reply seq={seq} logical_seq={logical_seq} remote={remote} rtt_us={}",
|
||||
"reply seq={seq} remote={remote} rtt_us={}",
|
||||
duration_us(rtt.effective)
|
||||
);
|
||||
if let Some(raw) = rtt.adjusted.map(|_| rtt.raw) {
|
||||
@@ -612,32 +590,26 @@ fn format_simple(event: &ClientEvent) -> String {
|
||||
}
|
||||
out
|
||||
}
|
||||
ClientEvent::EchoLoss {
|
||||
seq, logical_seq, ..
|
||||
} => {
|
||||
format!("loss seq={seq} logical_seq={logical_seq}")
|
||||
ClientEvent::EchoLoss { seq, .. } => {
|
||||
format!("loss seq={seq}")
|
||||
}
|
||||
ClientEvent::DuplicateReply { seq, remote, .. } => {
|
||||
format!("duplicate seq={seq} remote={remote}")
|
||||
}
|
||||
ClientEvent::LateReply {
|
||||
seq,
|
||||
logical_seq,
|
||||
highest_seen,
|
||||
remote,
|
||||
rtt,
|
||||
..
|
||||
} => {
|
||||
let mut out = format!(
|
||||
"late seq={seq} logical_seq={} highest_seen={highest_seen} remote={remote}",
|
||||
optional_u64(*logical_seq)
|
||||
);
|
||||
let mut out = format!("late seq={seq} highest_seen={highest_seen} remote={remote}",);
|
||||
if let Some(rtt) = rtt {
|
||||
write!(out, " rtt_us={}", duration_us(rtt.effective)).unwrap();
|
||||
}
|
||||
out
|
||||
}
|
||||
ClientEvent::Warning { kind, message } => {
|
||||
ClientEvent::Warning { kind, message, .. } => {
|
||||
format!("warning kind={} message={message}", warning_kind(*kind))
|
||||
}
|
||||
}
|
||||
@@ -647,11 +619,8 @@ fn write_common(out: &mut String, event: &str) {
|
||||
write!(out, "event={event}").unwrap();
|
||||
}
|
||||
|
||||
fn write_seq(out: &mut String, seq: u32, logical_seq: Option<u64>) {
|
||||
fn write_seq(out: &mut String, seq: u32) {
|
||||
write!(out, " seq={seq}").unwrap();
|
||||
if let Some(logical_seq) = logical_seq {
|
||||
write!(out, " logical_seq={logical_seq}").unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
fn write_remote(out: &mut String, remote: SocketAddr) {
|
||||
@@ -762,19 +731,21 @@ fn write_human_received_stats(out: &mut String, stats: Option<ReceivedStatsSampl
|
||||
}
|
||||
}
|
||||
|
||||
fn format_human_ipdv(stats: Option<&HumanEventStats>, logical_seq: Option<u64>) -> String {
|
||||
fn format_human_ipdv(stats: Option<&HumanEventStats>, seq: u32) -> String {
|
||||
let Some(stats) = stats else {
|
||||
return "n/a".to_owned();
|
||||
};
|
||||
|
||||
let pair = logical_seq
|
||||
.and_then(|seq| {
|
||||
let pair = stats
|
||||
.ipdv_pairs
|
||||
.iter()
|
||||
.find(|pair| pair.current_seq == seq)
|
||||
.or_else(|| {
|
||||
stats
|
||||
.ipdv_pairs
|
||||
.iter()
|
||||
.find(|pair| pair.current_logical_seq == seq)
|
||||
})
|
||||
.or_else(|| stats.ipdv_pairs.last());
|
||||
.find(|pair| pair.previous_seq == seq)
|
||||
});
|
||||
|
||||
pair.map(|pair| format_duration(pair.rtt_ipdv))
|
||||
.unwrap_or_else(|| "n/a".to_owned())
|
||||
@@ -819,17 +790,12 @@ fn format_ns(ns: f64) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
fn optional_u64(value: Option<u64>) -> String {
|
||||
value
|
||||
.map(|value| value.to_string())
|
||||
.unwrap_or_else(|| "none".to_owned())
|
||||
}
|
||||
|
||||
fn warning_kind(kind: WarningKind) -> &'static str {
|
||||
match kind {
|
||||
WarningKind::MalformedOrUnrelatedPacket => "malformed_or_unrelated_packet",
|
||||
WarningKind::WrongToken => "wrong_token",
|
||||
WarningKind::UntrackedReply => "untracked_reply",
|
||||
_ => "unknown",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -877,7 +843,6 @@ mod tests {
|
||||
fn reply_event_with_meta(packet_meta: PacketMeta) -> ClientEvent {
|
||||
ClientEvent::EchoReply {
|
||||
seq: 7,
|
||||
logical_seq: 8,
|
||||
remote: test_remote(),
|
||||
sent_at: test_timestamp(Duration::from_secs(1)),
|
||||
received_at: test_timestamp(Duration::from_secs(1) + Duration::from_micros(1500)),
|
||||
@@ -913,7 +878,6 @@ mod tests {
|
||||
fn late_event_with_meta(packet_meta: PacketMeta) -> ClientEvent {
|
||||
ClientEvent::LateReply {
|
||||
seq: 4,
|
||||
logical_seq: None,
|
||||
highest_seen: 9,
|
||||
remote: test_remote(),
|
||||
sent_at: None,
|
||||
@@ -1205,6 +1169,7 @@ mod tests {
|
||||
&ClientEvent::Warning {
|
||||
kind: WarningKind::WrongToken,
|
||||
message: "bad".to_owned(),
|
||||
at: ClientTimestamp::now()
|
||||
},
|
||||
OutputMode::RttUs
|
||||
),
|
||||
@@ -1217,7 +1182,6 @@ mod tests {
|
||||
let line = format_event(&reply_event(), OutputMode::Machine).unwrap();
|
||||
assert!(line.starts_with("event=echo_reply "));
|
||||
assert!(line.contains("seq=7"));
|
||||
assert!(line.contains("logical_seq=8"));
|
||||
assert!(line.contains("remote=127.0.0.1:2112"));
|
||||
assert!(line.contains("client_send_wall_ns=1000000000"));
|
||||
assert!(line.contains("client_receive_wall_ns=1001500000"));
|
||||
@@ -1326,7 +1290,7 @@ mod tests {
|
||||
let line = format_event(&reply_event(), OutputMode::Simple).unwrap();
|
||||
assert_eq!(
|
||||
line,
|
||||
"reply seq=7 logical_seq=8 remote=127.0.0.1:2112 rtt_us=1200 raw_rtt_us=1500 server_processing_us=300"
|
||||
"reply seq=7 remote=127.0.0.1:2112 rtt_us=1200 raw_rtt_us=1500 server_processing_us=300"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1338,7 +1302,6 @@ mod tests {
|
||||
assert!(line.contains("sd=400.0µs"));
|
||||
assert!(line.contains("ipdv=n/a"));
|
||||
assert!(line.contains("proc=300.0µs"));
|
||||
assert!(!line.contains("logical_seq="));
|
||||
assert!(!line.contains("server_received="));
|
||||
assert!(!line.contains("server_window="));
|
||||
assert!(!line.contains("rtt_us="));
|
||||
@@ -1360,7 +1323,6 @@ mod tests {
|
||||
HumanOutputOptions { verbose: true },
|
||||
);
|
||||
|
||||
assert!(line.contains("logical_seq=8"));
|
||||
assert!(line.contains("server_received=9"));
|
||||
assert!(line.contains("server_window=0x7"));
|
||||
}
|
||||
@@ -1372,8 +1334,8 @@ mod tests {
|
||||
Some(HumanEventStats {
|
||||
contributed_sample: true,
|
||||
ipdv_pairs: vec![HumanIpdvPair {
|
||||
previous_logical_seq: 7,
|
||||
current_logical_seq: 8,
|
||||
previous_seq: 7,
|
||||
current_seq: 8,
|
||||
rtt_ipdv: Duration::from_micros(47),
|
||||
send_ipdv: None,
|
||||
receive_ipdv: None,
|
||||
@@ -1388,7 +1350,6 @@ mod tests {
|
||||
fn human_reply_marks_missing_one_way_delay_unavailable() {
|
||||
let ClientEvent::EchoReply {
|
||||
seq,
|
||||
logical_seq,
|
||||
remote,
|
||||
sent_at,
|
||||
received_at,
|
||||
@@ -1404,7 +1365,6 @@ mod tests {
|
||||
};
|
||||
let event = ClientEvent::EchoReply {
|
||||
seq,
|
||||
logical_seq,
|
||||
remote,
|
||||
sent_at,
|
||||
received_at,
|
||||
@@ -1427,7 +1387,6 @@ mod tests {
|
||||
let ts = test_timestamp(Duration::from_secs(1));
|
||||
let event = ClientEvent::EchoSent {
|
||||
seq: 1,
|
||||
logical_seq: 2,
|
||||
remote: test_remote(),
|
||||
scheduled_at: ts.mono,
|
||||
sent_at: ts,
|
||||
@@ -1448,7 +1407,6 @@ mod tests {
|
||||
let events = [
|
||||
ClientEvent::EchoLoss {
|
||||
seq: 1,
|
||||
logical_seq: 2,
|
||||
sent_at: ts,
|
||||
timeout_at: ts.mono + Duration::from_secs(1),
|
||||
},
|
||||
@@ -1460,7 +1418,6 @@ mod tests {
|
||||
},
|
||||
ClientEvent::LateReply {
|
||||
seq: 4,
|
||||
logical_seq: None,
|
||||
highest_seen: 9,
|
||||
remote: test_remote(),
|
||||
sent_at: None,
|
||||
@@ -1475,6 +1432,7 @@ mod tests {
|
||||
ClientEvent::Warning {
|
||||
kind: WarningKind::UntrackedReply,
|
||||
message: "untracked reply".to_owned(),
|
||||
at: ClientTimestamp::now(),
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
+17
-17
@@ -13,7 +13,11 @@ use clap::Parser;
|
||||
use irtt_cli::{
|
||||
format_event, format_human_event_with_options, CliArgs, HumanOutputOptions, OutputMode,
|
||||
};
|
||||
use irtt_client::{Client, ClientEvent, ClientTimestamp, OpenOutcome, RecvBudget};
|
||||
use irtt_client::{Client, ClientEvent, OpenOutcome, RecvBudget};
|
||||
|
||||
#[cfg(test)]
|
||||
use irtt_client::ClientTimestamp;
|
||||
|
||||
#[cfg(feature = "stats")]
|
||||
use irtt_stats::{StatsCollector, StatsConfig};
|
||||
|
||||
@@ -72,7 +76,7 @@ fn run(args: CliArgs, shutdown_requested: &AtomicBool) -> Result<(), Box<dyn std
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let open = client.open(ClientTimestamp::now())?;
|
||||
let open = client.open()?;
|
||||
output.print_event(open_event(&open))?;
|
||||
|
||||
let mut interrupted = false;
|
||||
@@ -85,7 +89,7 @@ fn run(args: CliArgs, shutdown_requested: &AtomicBool) -> Result<(), Box<dyn std
|
||||
let events = client.recv_available(RECV_BUDGET)?;
|
||||
output.print_events(&events)?;
|
||||
|
||||
let events = client.poll_timeouts(ClientTimestamp::now())?;
|
||||
let events = client.poll_timeouts()?;
|
||||
output.print_events(&events)?;
|
||||
|
||||
if is_shutdown_requested(shutdown_requested) {
|
||||
@@ -105,10 +109,10 @@ fn run(args: CliArgs, shutdown_requested: &AtomicBool) -> Result<(), Box<dyn std
|
||||
drain_final_replies(&mut client, &mut output)?;
|
||||
}
|
||||
|
||||
let events = client.poll_timeouts(ClientTimestamp::now())?;
|
||||
let events = client.poll_timeouts()?;
|
||||
output.print_events(&events)?;
|
||||
|
||||
let events = client.close(ClientTimestamp::now())?;
|
||||
let events = client.close()?;
|
||||
output.print_events(&events)?;
|
||||
output.print_summary()?;
|
||||
output.out.flush()?;
|
||||
@@ -154,7 +158,7 @@ fn drain_final_replies<W: Write>(
|
||||
printed |= !events.is_empty();
|
||||
output.print_events(&events)?;
|
||||
|
||||
let events = client.poll_timeouts(ClientTimestamp::now())?;
|
||||
let events = client.poll_timeouts()?;
|
||||
printed |= !events.is_empty();
|
||||
output.print_events(&events)?;
|
||||
|
||||
@@ -309,15 +313,14 @@ mod tests {
|
||||
SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 2112)
|
||||
}
|
||||
|
||||
fn reply_event(logical_seq: u64, rtt_us: u64) -> ClientEvent {
|
||||
let sent_at = test_timestamp(Duration::from_millis(logical_seq));
|
||||
fn reply_event(seq: u32, rtt_us: u64) -> ClientEvent {
|
||||
let sent_at = test_timestamp(Duration::from_millis(seq as u64));
|
||||
let received_at = ClientTimestamp {
|
||||
wall: sent_at.wall + Duration::from_micros(rtt_us),
|
||||
mono: sent_at.mono + Duration::from_micros(rtt_us),
|
||||
};
|
||||
ClientEvent::EchoReply {
|
||||
seq: logical_seq as u32,
|
||||
logical_seq,
|
||||
seq,
|
||||
remote: test_remote(),
|
||||
sent_at,
|
||||
received_at,
|
||||
@@ -345,7 +348,6 @@ mod tests {
|
||||
let events = [
|
||||
ClientEvent::EchoSent {
|
||||
seq: 1,
|
||||
logical_seq: 1,
|
||||
remote: test_remote(),
|
||||
scheduled_at: sent_at.mono,
|
||||
sent_at,
|
||||
@@ -355,7 +357,6 @@ mod tests {
|
||||
},
|
||||
ClientEvent::EchoReply {
|
||||
seq: 1,
|
||||
logical_seq: 1,
|
||||
remote: test_remote(),
|
||||
sent_at,
|
||||
received_at,
|
||||
@@ -438,12 +439,11 @@ mod tests {
|
||||
#[test]
|
||||
fn continuous_mode_uses_continuous_stats_config() {
|
||||
let mut collector = StatsCollector::new(stats_config(true));
|
||||
for seq in 0..5000 {
|
||||
let sent_at = test_timestamp(Duration::from_micros(seq));
|
||||
let received_at = test_timestamp(Duration::from_micros(seq + 1));
|
||||
for seq in 0..5000_u32 {
|
||||
let sent_at = test_timestamp(Duration::from_micros(seq as u64));
|
||||
let received_at = test_timestamp(Duration::from_micros(seq as u64 + 1));
|
||||
collector.process(&ClientEvent::EchoReply {
|
||||
seq: seq as u32,
|
||||
logical_seq: seq,
|
||||
seq,
|
||||
remote: test_remote(),
|
||||
sent_at,
|
||||
received_at,
|
||||
|
||||
@@ -229,7 +229,6 @@ mod tests {
|
||||
|
||||
collector.process(&ClientEvent::EchoSent {
|
||||
seq: 1,
|
||||
logical_seq: 1,
|
||||
remote: test_remote(),
|
||||
scheduled_at: sent_at.mono,
|
||||
sent_at,
|
||||
@@ -239,7 +238,6 @@ mod tests {
|
||||
});
|
||||
collector.process(&ClientEvent::EchoReply {
|
||||
seq: 1,
|
||||
logical_seq: 1,
|
||||
remote: test_remote(),
|
||||
sent_at,
|
||||
received_at,
|
||||
@@ -287,7 +285,6 @@ mod tests {
|
||||
let received_at = test_timestamp(Duration::from_secs(1) + Duration::from_micros(1500));
|
||||
collector.process(&ClientEvent::EchoReply {
|
||||
seq: 1,
|
||||
logical_seq: 1,
|
||||
remote: test_remote(),
|
||||
sent_at: test_timestamp(Duration::from_secs(1)),
|
||||
received_at,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "irtt-client"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
description = "IRTT-compatible Rust client library"
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
@@ -13,9 +13,9 @@ categories = ["network-programming"]
|
||||
|
||||
[dependencies]
|
||||
irtt-proto.workspace = true
|
||||
libc = { version = "0.2", optional = true }
|
||||
socket2 = { version = "0.5", features = ["all"] }
|
||||
thiserror = "2"
|
||||
libc = { version = "0.2.186", optional = true }
|
||||
socket2 = { version = "0.6.3", features = ["all"] }
|
||||
thiserror = "2.0.18"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
@@ -73,7 +73,7 @@ impl Client {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn open(&mut self, now: ClientTimestamp) -> Result<OpenOutcome, ClientError> {
|
||||
pub fn open(&mut self) -> Result<OpenOutcome, ClientError> {
|
||||
match self.phase {
|
||||
ClientPhase::Connected => {}
|
||||
ClientPhase::Open { .. } => return Err(ClientError::AlreadyOpen),
|
||||
@@ -81,10 +81,44 @@ impl Client {
|
||||
ClientPhase::NoTestCompleted => return Err(ClientError::AlreadyCompleted),
|
||||
}
|
||||
|
||||
let outcome = self.open_inner(now);
|
||||
let outcome = (|| -> Result<OpenOutcome, ClientError> {
|
||||
let request = OpenRequest {
|
||||
params: self.requested.clone(),
|
||||
close: self.config.run_mode == RunMode::NoTest,
|
||||
};
|
||||
|
||||
let packet = encode_open_request(&request, self.config.hmac_key.as_deref())?;
|
||||
let mut buf = [0_u8; MAX_OPEN_PACKET_SIZE];
|
||||
|
||||
for timeout in &self.config.open_timeouts {
|
||||
self.socket.set_read_timeout(Some(*timeout))?;
|
||||
self.socket.send(&packet)?;
|
||||
|
||||
match self.socket.recv(&mut buf) {
|
||||
Ok(size) => {
|
||||
let reply = irtt_proto::decode_open_reply(
|
||||
&buf[..size],
|
||||
self.config.hmac_key.as_deref(),
|
||||
)?;
|
||||
|
||||
return self.accept_open_reply(reply, ClientTimestamp::now());
|
||||
}
|
||||
Err(err)
|
||||
if matches!(
|
||||
err.kind(),
|
||||
io::ErrorKind::WouldBlock | io::ErrorKind::TimedOut
|
||||
) => {}
|
||||
Err(err) => return Err(ClientError::Socket(err)),
|
||||
}
|
||||
}
|
||||
|
||||
Err(ClientError::OpenTimeout)
|
||||
})();
|
||||
|
||||
let restore = self
|
||||
.socket
|
||||
.set_read_timeout(self.config.socket_config.recv_timeout);
|
||||
|
||||
match (outcome, restore) {
|
||||
(Ok(outcome), Ok(())) => Ok(outcome),
|
||||
(Ok(_), Err(source)) => Err(ClientError::ReadTimeoutRestore { source }),
|
||||
@@ -93,39 +127,7 @@ impl Client {
|
||||
}
|
||||
}
|
||||
|
||||
fn open_inner(&mut self, _now: ClientTimestamp) -> Result<OpenOutcome, ClientError> {
|
||||
let request = OpenRequest {
|
||||
params: self.requested.clone(),
|
||||
close: self.config.run_mode == RunMode::NoTest,
|
||||
};
|
||||
let packet = encode_open_request(&request, self.config.hmac_key.as_deref())?;
|
||||
let mut buf = [0_u8; MAX_OPEN_PACKET_SIZE];
|
||||
|
||||
for timeout in &self.config.open_timeouts {
|
||||
self.socket.set_read_timeout(Some(*timeout))?;
|
||||
self.socket.send(&packet)?;
|
||||
|
||||
match self.socket.recv(&mut buf) {
|
||||
Ok(size) => {
|
||||
let reply = irtt_proto::decode_open_reply(
|
||||
&buf[..size],
|
||||
self.config.hmac_key.as_deref(),
|
||||
)?;
|
||||
return self.accept_open_reply(reply, ClientTimestamp::now());
|
||||
}
|
||||
Err(err)
|
||||
if matches!(
|
||||
err.kind(),
|
||||
io::ErrorKind::WouldBlock | io::ErrorKind::TimedOut
|
||||
) => {}
|
||||
Err(err) => return Err(ClientError::Socket(err)),
|
||||
}
|
||||
}
|
||||
|
||||
Err(ClientError::OpenTimeout)
|
||||
}
|
||||
|
||||
pub fn close(&mut self, now: ClientTimestamp) -> Result<Vec<ClientEvent>, ClientError> {
|
||||
pub fn close(&mut self) -> Result<Vec<ClientEvent>, ClientError> {
|
||||
let token = match self.phase {
|
||||
ClientPhase::Open { token } => token,
|
||||
ClientPhase::Closed => return Err(ClientError::AlreadyClosed),
|
||||
@@ -147,7 +149,7 @@ impl Client {
|
||||
Ok(vec![ClientEvent::SessionClosed {
|
||||
remote: self.remote,
|
||||
token,
|
||||
at: now,
|
||||
at: ClientTimestamp::now(),
|
||||
}])
|
||||
}
|
||||
|
||||
@@ -208,7 +210,6 @@ impl Client {
|
||||
.expect("negotiated must exist when Open");
|
||||
|
||||
let wire_seq = session.next_wire_seq;
|
||||
let logical_seq = session.next_logical_seq;
|
||||
let scheduled_at = session.next_send_at;
|
||||
|
||||
let request = EchoRequest {
|
||||
@@ -230,7 +231,6 @@ impl Client {
|
||||
.expect("session must exist when phase is Open");
|
||||
|
||||
let pending = PendingProbe {
|
||||
logical_seq,
|
||||
wire_seq,
|
||||
sent_at,
|
||||
timeout_at: sent_at
|
||||
@@ -241,13 +241,6 @@ impl Client {
|
||||
session.pending.insert(pending)?;
|
||||
|
||||
session.next_wire_seq = session.next_wire_seq.wrapping_add(1);
|
||||
session.next_logical_seq =
|
||||
session
|
||||
.next_logical_seq
|
||||
.checked_add(1)
|
||||
.ok_or(ClientError::CounterOverflow {
|
||||
counter: "next_logical_seq",
|
||||
})?;
|
||||
session.packets_sent =
|
||||
session
|
||||
.packets_sent
|
||||
@@ -277,7 +270,6 @@ impl Client {
|
||||
|
||||
Ok(vec![ClientEvent::EchoSent {
|
||||
seq: wire_seq,
|
||||
logical_seq,
|
||||
remote: self.remote,
|
||||
scheduled_at,
|
||||
sent_at,
|
||||
@@ -317,6 +309,7 @@ impl Client {
|
||||
return Ok(vec![ClientEvent::Warning {
|
||||
kind: WarningKind::MalformedOrUnrelatedPacket,
|
||||
message: "dropped malformed or unrelated packet".to_owned(),
|
||||
at: now,
|
||||
}]);
|
||||
};
|
||||
self.process_echo_reply(reply, packet_len, now, datagram.meta)
|
||||
@@ -339,7 +332,19 @@ impl Client {
|
||||
recv_buffer_size(self.config.hmac_key.is_some(), self.negotiated.as_ref())
|
||||
}
|
||||
|
||||
pub fn poll_timeouts(&mut self, now: ClientTimestamp) -> Result<Vec<ClientEvent>, ClientError> {
|
||||
/// Polls for probes that have timed out as of the current monotonic time.
|
||||
pub fn poll_timeouts(&mut self) -> Result<Vec<ClientEvent>, ClientError> {
|
||||
self.poll_timeouts_at(Instant::now())
|
||||
}
|
||||
|
||||
/// Polls for probes that have timed out as of `now`.
|
||||
///
|
||||
/// This is useful for callers that drive `Client` from their own event loop and
|
||||
/// want timeout decisions to use the same sampled `Instant` as their scheduling
|
||||
/// logic.
|
||||
///
|
||||
/// `now` is monotonic time only; wall-clock time is not used for timeout expiry.
|
||||
pub fn poll_timeouts_at(&mut self, now: Instant) -> Result<Vec<ClientEvent>, ClientError> {
|
||||
match self.phase {
|
||||
ClientPhase::Open { .. } => {}
|
||||
ClientPhase::Closed => return Err(ClientError::AlreadyClosed),
|
||||
@@ -352,12 +357,11 @@ impl Client {
|
||||
.as_mut()
|
||||
.expect("session must exist when phase is Open");
|
||||
|
||||
let expired = session.pending.drain_expired(now.mono);
|
||||
let expired = session.pending.drain_expired(now);
|
||||
let mut events = Vec::with_capacity(expired.len());
|
||||
for probe in expired {
|
||||
events.push(ClientEvent::EchoLoss {
|
||||
seq: probe.wire_seq,
|
||||
logical_seq: probe.logical_seq,
|
||||
sent_at: probe.sent_at,
|
||||
timeout_at: probe.timeout_at,
|
||||
});
|
||||
@@ -401,6 +405,7 @@ impl Client {
|
||||
return Ok(vec![ClientEvent::Warning {
|
||||
kind: WarningKind::MalformedOrUnrelatedPacket,
|
||||
message: "dropped malformed or unrelated packet".to_owned(),
|
||||
at: now,
|
||||
}]);
|
||||
};
|
||||
self.process_echo_reply(reply, packet_len, now, meta)
|
||||
@@ -433,6 +438,7 @@ impl Client {
|
||||
"dropped reply with wrong token: expected {token:#x}, got {:#x}",
|
||||
reply.token
|
||||
),
|
||||
at: now,
|
||||
}]);
|
||||
}
|
||||
|
||||
@@ -451,13 +457,12 @@ impl Client {
|
||||
let highest_seen = session.highest_received_seq.unwrap_or(wire_seq);
|
||||
|
||||
update_highest_received(session, wire_seq);
|
||||
session.completed.insert(wire_seq, pending.logical_seq);
|
||||
session.completed.insert(wire_seq);
|
||||
|
||||
let mut events = Vec::new();
|
||||
if is_late {
|
||||
events.push(ClientEvent::LateReply {
|
||||
seq: wire_seq,
|
||||
logical_seq: Some(pending.logical_seq),
|
||||
highest_seen,
|
||||
remote: self.remote,
|
||||
sent_at: Some(pending.sent_at),
|
||||
@@ -472,7 +477,6 @@ impl Client {
|
||||
} else {
|
||||
events.push(ClientEvent::EchoReply {
|
||||
seq: wire_seq,
|
||||
logical_seq: pending.logical_seq,
|
||||
remote: self.remote,
|
||||
sent_at: pending.sent_at,
|
||||
received_at: now,
|
||||
@@ -503,11 +507,10 @@ impl Client {
|
||||
let received_stats = build_received_stats(&reply);
|
||||
let highest_seen = session.highest_received_seq.unwrap_or(wire_seq);
|
||||
update_highest_received(session, wire_seq);
|
||||
session.completed.insert(wire_seq, timed_out.logical_seq);
|
||||
session.completed.insert(wire_seq);
|
||||
|
||||
let mut events = vec![ClientEvent::LateReply {
|
||||
seq: wire_seq,
|
||||
logical_seq: Some(timed_out.logical_seq),
|
||||
highest_seen,
|
||||
remote: self.remote,
|
||||
sent_at: Some(timed_out.sent_at),
|
||||
@@ -529,7 +532,6 @@ impl Client {
|
||||
{
|
||||
Ok(vec![ClientEvent::LateReply {
|
||||
seq: wire_seq,
|
||||
logical_seq: None,
|
||||
highest_seen: session.highest_received_seq.unwrap(),
|
||||
remote: self.remote,
|
||||
sent_at: None,
|
||||
@@ -547,6 +549,7 @@ impl Client {
|
||||
message: format!(
|
||||
"dropped reply with untracked seq {wire_seq} (no pending or completed entry)"
|
||||
),
|
||||
at: now,
|
||||
}])
|
||||
}
|
||||
}
|
||||
@@ -630,7 +633,6 @@ impl Client {
|
||||
|
||||
self.session = Some(ActiveSession {
|
||||
next_wire_seq: 0,
|
||||
next_logical_seq: 0,
|
||||
highest_received_seq: None,
|
||||
packets_sent: 0,
|
||||
start_mono: now.mono,
|
||||
|
||||
@@ -11,12 +11,9 @@ fn open_fails_after_close() {
|
||||
let _ = recv_request(&socket, &tx);
|
||||
});
|
||||
let mut client = Client::connect(default_test_config(server.addr)).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
Err(ClientError::AlreadyClosed)
|
||||
));
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.close().unwrap();
|
||||
assert!(matches!(client.open(), Err(ClientError::AlreadyClosed)));
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -31,8 +28,8 @@ fn close_sends_one_close_packet_with_negotiated_token() {
|
||||
let _ = recv_request(&socket, &tx);
|
||||
});
|
||||
let mut client = Client::connect(default_test_config(server.addr)).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
let events = client.close(ClientTimestamp::now()).unwrap();
|
||||
assert_open_started(client.open().unwrap());
|
||||
let events = client.close().unwrap();
|
||||
assert_eq!(events.len(), 1);
|
||||
let packets: Vec<_> = server.rx.iter().take(2).collect();
|
||||
let close = &packets[1];
|
||||
@@ -62,8 +59,8 @@ fn send_probe_fails_after_close() {
|
||||
}
|
||||
});
|
||||
let mut client = Client::connect(default_test_config(server.addr)).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.close().unwrap();
|
||||
assert!(matches!(
|
||||
client.send_probe(),
|
||||
Err(ClientError::AlreadyClosed)
|
||||
@@ -84,14 +81,14 @@ fn close_clears_timed_out_metadata() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
|
||||
client.send_probe().unwrap();
|
||||
thread::sleep(Duration::from_millis(60));
|
||||
client.poll_timeouts(ClientTimestamp::now()).unwrap();
|
||||
client.poll_timeouts().unwrap();
|
||||
assert_eq!(client.session.as_ref().unwrap().timed_out.len(), 1);
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
assert!(client.session.is_none());
|
||||
server.join();
|
||||
}
|
||||
@@ -132,7 +129,7 @@ fn close_flagged_echo_reply_emits_reply_then_closes_without_sending_close() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.send_probe().unwrap();
|
||||
|
||||
let events = client.recv_once().unwrap();
|
||||
@@ -170,6 +167,6 @@ fn normal_echo_reply_does_not_close_session() {
|
||||
assert!(client.next_send_deadline().is_some());
|
||||
assert!(client.send_probe().is_ok());
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
@@ -26,13 +26,13 @@ fn normal_open_applies_negotiated_dscp_after_open_and_close_clears_it() {
|
||||
socket_traffic_class(&client.socket, client.remote).unwrap() & 0xfc,
|
||||
0
|
||||
);
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
assert_eq!(
|
||||
socket_traffic_class(&client.socket, client.remote).unwrap() & 0xfc,
|
||||
184
|
||||
);
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
assert_eq!(
|
||||
socket_traffic_class(&client.socket, client.remote).unwrap(),
|
||||
0
|
||||
@@ -58,7 +58,7 @@ fn normal_open_uses_negotiated_dscp_not_requested_dscp() {
|
||||
config.negotiation_policy = NegotiationPolicy::Loose;
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
|
||||
let negotiated = assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
let negotiated = assert_open_started(client.open().unwrap());
|
||||
assert_eq!(negotiated.params.dscp, 0);
|
||||
assert_eq!(
|
||||
socket_traffic_class(&client.socket, client.remote).unwrap(),
|
||||
|
||||
@@ -14,7 +14,7 @@ fn hmac_open_success() {
|
||||
});
|
||||
config.server_addr = server.addr.to_string();
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ fn hmac_open_rejects_missing_hmac() {
|
||||
config.server_addr = server.addr.to_string();
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
client.open(),
|
||||
Err(ClientError::Protocol(
|
||||
irtt_proto::ProtoError::HmacPresenceMismatch
|
||||
))
|
||||
@@ -55,7 +55,7 @@ fn hmac_open_rejects_bad_hmac() {
|
||||
config.server_addr = server.addr.to_string();
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
client.open(),
|
||||
Err(ClientError::Protocol(irtt_proto::ProtoError::BadHmac))
|
||||
));
|
||||
server.join();
|
||||
@@ -76,8 +76,8 @@ fn hmac_close_packet_includes_valid_hmac() {
|
||||
});
|
||||
config.server_addr = server.addr.to_string();
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.close().unwrap();
|
||||
let packets: Vec<_> = server.rx.iter().take(2).collect();
|
||||
let close = &packets[1];
|
||||
assert_eq!(close[3], flags::FLAG_CLOSE | FLAG_HMAC);
|
||||
@@ -125,7 +125,7 @@ fn bad_hmac_reply_is_dropped() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.send_probe().unwrap();
|
||||
thread::sleep(Duration::from_millis(30));
|
||||
let events = client.recv_once().unwrap();
|
||||
@@ -174,7 +174,7 @@ fn hmac_echo_request_reply_works() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.send_probe().unwrap();
|
||||
thread::sleep(Duration::from_millis(50));
|
||||
let events = client.recv_once().unwrap();
|
||||
|
||||
@@ -8,13 +8,10 @@ fn no_test_open_close_succeeds_on_open_reply_close() {
|
||||
let server = no_test_server(params.clone(), 0);
|
||||
config.server_addr = server.addr.to_string();
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
let negotiated = assert_no_test_completed(client.open(ClientTimestamp::now()).unwrap());
|
||||
let negotiated = assert_no_test_completed(client.open().unwrap());
|
||||
assert_eq!(negotiated.params, params);
|
||||
assert_eq!(client.negotiated.as_ref(), Some(&negotiated));
|
||||
assert!(matches!(
|
||||
client.close(ClientTimestamp::now()),
|
||||
Err(ClientError::NotOpen)
|
||||
));
|
||||
assert!(matches!(client.close(), Err(ClientError::NotOpen)));
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -26,7 +23,7 @@ fn no_test_success_validates_params() {
|
||||
let server = no_test_server(params.clone(), 0);
|
||||
config.server_addr = server.addr.to_string();
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
let negotiated = assert_no_test_completed(client.open(ClientTimestamp::now()).unwrap());
|
||||
let negotiated = assert_no_test_completed(client.open().unwrap());
|
||||
assert_eq!(negotiated.params, params);
|
||||
server.join();
|
||||
}
|
||||
@@ -40,7 +37,7 @@ fn no_test_rejects_non_close_open_reply() {
|
||||
config.server_addr = server.addr.to_string();
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
client.open(),
|
||||
Err(ClientError::UnexpectedNoTestReply)
|
||||
));
|
||||
server.join();
|
||||
@@ -55,7 +52,7 @@ fn no_test_rejects_non_zero_token_with_close_reply() {
|
||||
config.server_addr = server.addr.to_string();
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
client.open(),
|
||||
Err(ClientError::NonZeroNoTestToken { token: TOKEN })
|
||||
));
|
||||
server.join();
|
||||
@@ -71,7 +68,7 @@ fn no_test_strict_negotiation_rejects_changed_params() {
|
||||
config.server_addr = server.addr.to_string();
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
client.open(),
|
||||
Err(ClientError::NegotiationRejected { .. })
|
||||
));
|
||||
server.join();
|
||||
@@ -87,7 +84,7 @@ fn no_test_loose_negotiation_accepts_restricted_params() {
|
||||
let server = no_test_server(params.clone(), 0);
|
||||
config.server_addr = server.addr.to_string();
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
let negotiated = assert_no_test_completed(client.open(ClientTimestamp::now()).unwrap());
|
||||
let negotiated = assert_no_test_completed(client.open().unwrap());
|
||||
assert_eq!(negotiated.params, params);
|
||||
server.join();
|
||||
}
|
||||
@@ -100,7 +97,7 @@ fn send_probe_fails_after_no_test_completed() {
|
||||
let server = no_test_server(params, 0);
|
||||
config.server_addr = server.addr.to_string();
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_no_test_completed(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_no_test_completed(client.open().unwrap());
|
||||
assert!(matches!(
|
||||
client.send_probe(),
|
||||
Err(ClientError::AlreadyCompleted)
|
||||
@@ -116,10 +113,7 @@ fn open_fails_after_no_test_completed() {
|
||||
let server = no_test_server(params, 0);
|
||||
config.server_addr = server.addr.to_string();
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_no_test_completed(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
Err(ClientError::AlreadyCompleted)
|
||||
));
|
||||
assert_no_test_completed(client.open().unwrap());
|
||||
assert!(matches!(client.open(), Err(ClientError::AlreadyCompleted)));
|
||||
server.join();
|
||||
}
|
||||
@@ -18,7 +18,7 @@ fn successful_open_handshake() {
|
||||
let server = open_success_server(params.clone());
|
||||
let mut client = Client::connect(default_test_config(server.addr)).unwrap();
|
||||
|
||||
let negotiated = assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
let negotiated = assert_open_started(client.open().unwrap());
|
||||
assert_eq!(negotiated.params, params);
|
||||
assert!(matches!(client.phase, ClientPhase::Open { token: TOKEN }));
|
||||
server.join();
|
||||
@@ -30,11 +30,8 @@ fn open_fails_when_already_open() {
|
||||
let params = params_from_config(&config).unwrap();
|
||||
let server = open_success_server(params);
|
||||
let mut client = Client::connect(default_test_config(server.addr)).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
Err(ClientError::AlreadyOpen)
|
||||
));
|
||||
assert_open_started(client.open().unwrap());
|
||||
assert!(matches!(client.open(), Err(ClientError::AlreadyOpen)));
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -53,7 +50,7 @@ fn open_retries_after_first_timeout() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
let outcome = client.open(ClientTimestamp::now()).unwrap();
|
||||
let outcome = client.open().unwrap();
|
||||
assert_open_started(outcome);
|
||||
assert_eq!(server.rx.iter().take(2).count(), 2);
|
||||
server.join();
|
||||
@@ -67,10 +64,7 @@ fn open_timeout_after_all_timeouts() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
Err(ClientError::OpenTimeout)
|
||||
));
|
||||
assert!(matches!(client.open(), Err(ClientError::OpenTimeout)));
|
||||
assert_eq!(server.rx.iter().take(2).count(), 2);
|
||||
server.join();
|
||||
}
|
||||
@@ -87,10 +81,7 @@ fn open_restores_configured_read_timeout_after_timeout() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
Err(ClientError::OpenTimeout)
|
||||
));
|
||||
assert!(matches!(client.open(), Err(ClientError::OpenTimeout)));
|
||||
|
||||
let start = std::time::Instant::now();
|
||||
let mut buf = [0_u8; 1];
|
||||
@@ -108,7 +99,7 @@ fn protocol_version_mismatch_fails() {
|
||||
let server = open_success_server(params);
|
||||
let mut client = Client::connect(default_test_config(server.addr)).unwrap();
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
client.open(),
|
||||
Err(ClientError::ProtocolVersionMismatch { received: 2, .. })
|
||||
));
|
||||
server.join();
|
||||
@@ -124,9 +115,6 @@ fn server_rejection_fails_in_normal_mode() {
|
||||
socket.send_to(&reply, peer).unwrap();
|
||||
});
|
||||
let mut client = Client::connect(default_test_config(server.addr)).unwrap();
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
Err(ClientError::ServerRejected)
|
||||
));
|
||||
assert!(matches!(client.open(), Err(ClientError::ServerRejected)));
|
||||
server.join();
|
||||
}
|
||||
@@ -38,19 +38,14 @@ fn send_probe_sends_valid_echo_request() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
let events = client.send_probe().unwrap();
|
||||
assert_eq!(events.len(), 1);
|
||||
match &events[0] {
|
||||
ClientEvent::EchoSent {
|
||||
seq,
|
||||
logical_seq,
|
||||
remote,
|
||||
bytes,
|
||||
..
|
||||
seq, remote, bytes, ..
|
||||
} => {
|
||||
assert_eq!(*seq, 0);
|
||||
assert_eq!(*logical_seq, 0);
|
||||
assert_eq!(*remote, server.addr);
|
||||
assert_eq!(*bytes, echo_packet_len(false, ¶ms));
|
||||
}
|
||||
@@ -69,7 +64,7 @@ fn send_probe_sends_valid_echo_request() {
|
||||
assert_eq!(req_token, TOKEN);
|
||||
let seq = u32::from_le_bytes(echo_req[12..16].try_into().unwrap());
|
||||
assert_eq!(seq, 0);
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -89,7 +84,7 @@ fn echo_sent_reports_schedule_and_timer_error() {
|
||||
mono: Instant::now(),
|
||||
wall: SystemTime::now(),
|
||||
};
|
||||
assert_open_started(client.open(start).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
let session_start = client.session.as_ref().unwrap().start_mono;
|
||||
assert!(
|
||||
session_start >= start.mono,
|
||||
@@ -115,7 +110,7 @@ fn echo_sent_reports_schedule_and_timer_error() {
|
||||
other => panic!("expected EchoSent, got {other:?}"),
|
||||
}
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -131,7 +126,7 @@ fn send_probe_starts_seq_at_zero_and_increments() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.send_probe().unwrap();
|
||||
client.send_probe().unwrap();
|
||||
client.send_probe().unwrap();
|
||||
@@ -146,7 +141,7 @@ fn send_probe_starts_seq_at_zero_and_increments() {
|
||||
let seq = u32::from_le_bytes(pkt[12..16].try_into().unwrap());
|
||||
assert_eq!(seq, i as u32);
|
||||
}
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -172,7 +167,7 @@ fn send_probe_respects_finite_duration_exclusive_end() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
|
||||
let session = client.session.as_ref().unwrap();
|
||||
let start = session.start_mono;
|
||||
@@ -199,7 +194,7 @@ fn send_probe_respects_finite_duration_exclusive_end() {
|
||||
assert!(client.session.as_ref().unwrap().sending_done);
|
||||
assert!(client.next_send_deadline().is_none());
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -225,7 +220,7 @@ fn continuous_duration_keeps_generating_send_deadlines() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
|
||||
let start = client.session.as_ref().unwrap().start_mono;
|
||||
let interval = Duration::from_millis(500);
|
||||
@@ -240,7 +235,7 @@ fn continuous_duration_keeps_generating_send_deadlines() {
|
||||
assert!(!client.session.as_ref().unwrap().sending_done);
|
||||
}
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -262,7 +257,7 @@ fn next_send_deadline_advances_by_interval() {
|
||||
let deadline2 = client.next_send_deadline().unwrap();
|
||||
assert_eq!(deadline2, start + Duration::from_secs(2));
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -301,7 +296,7 @@ fn send_probe_reports_schedule_overflow() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.session.as_mut().unwrap().packets_sent = u64::MAX - 1;
|
||||
|
||||
assert!(matches!(
|
||||
@@ -311,30 +306,6 @@ fn send_probe_reports_schedule_overflow() {
|
||||
server.join();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn send_probe_reports_logical_sequence_counter_overflow() {
|
||||
let params = default_params();
|
||||
let server = silent_open_server(params);
|
||||
let config = ClientConfig {
|
||||
socket_config: crate::SocketConfig {
|
||||
recv_timeout: Some(Duration::from_millis(200)),
|
||||
..Default::default()
|
||||
},
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
client.session.as_mut().unwrap().next_logical_seq = u64::MAX;
|
||||
|
||||
assert!(matches!(
|
||||
client.send_probe(),
|
||||
Err(ClientError::CounterOverflow {
|
||||
counter: "next_logical_seq"
|
||||
})
|
||||
));
|
||||
server.join();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn send_probe_reports_packets_sent_counter_overflow() {
|
||||
let params = default_params();
|
||||
@@ -347,7 +318,7 @@ fn send_probe_reports_packets_sent_counter_overflow() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.session.as_mut().unwrap().packets_sent = u64::MAX;
|
||||
|
||||
assert!(matches!(
|
||||
@@ -371,7 +342,7 @@ fn recv_once_returns_empty_on_timeout() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
let events = client.recv_once().unwrap();
|
||||
assert!(events.is_empty());
|
||||
server.join();
|
||||
@@ -390,7 +361,6 @@ fn recv_once_decodes_echo_reply_and_emits_event() {
|
||||
match &events[0] {
|
||||
ClientEvent::EchoReply {
|
||||
seq,
|
||||
logical_seq,
|
||||
rtt,
|
||||
received_stats,
|
||||
server_timing,
|
||||
@@ -399,7 +369,6 @@ fn recv_once_decodes_echo_reply_and_emits_event() {
|
||||
..
|
||||
} => {
|
||||
assert_eq!(*seq, 0);
|
||||
assert_eq!(*logical_seq, 0);
|
||||
assert_eq!(*bytes, echo_packet_len(false, ¶ms));
|
||||
assert!(rtt.raw > Duration::ZERO);
|
||||
assert_eq!(rtt.effective, rtt.adjusted.unwrap_or(rtt.raw));
|
||||
@@ -431,7 +400,7 @@ fn recv_once_decodes_echo_reply_and_emits_event() {
|
||||
}
|
||||
other => panic!("expected EchoReply, got {other:?}"),
|
||||
}
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -477,7 +446,7 @@ fn recv_once_decodes_only_received_bytes_after_longer_datagram() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
|
||||
client.send_probe().unwrap();
|
||||
client.send_probe().unwrap();
|
||||
@@ -487,14 +456,8 @@ fn recv_once_decodes_only_received_bytes_after_longer_datagram() {
|
||||
let events = client.recv_once().unwrap();
|
||||
assert_eq!(events.len(), 1);
|
||||
match &events[0] {
|
||||
ClientEvent::EchoReply {
|
||||
seq,
|
||||
logical_seq,
|
||||
bytes,
|
||||
..
|
||||
} => {
|
||||
ClientEvent::EchoReply { seq, bytes, .. } => {
|
||||
assert_eq!(*seq, 1);
|
||||
assert_eq!(*logical_seq, 1);
|
||||
assert_eq!(*bytes, echo_packet_len(false, ¶ms));
|
||||
}
|
||||
other => panic!("expected EchoReply after shorter datagram, got {other:?}"),
|
||||
@@ -520,7 +483,7 @@ fn echo_reply_metadata_is_unavailable_without_ancillary() {
|
||||
other => panic!("expected EchoReply, got {other:?}"),
|
||||
}
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -550,7 +513,7 @@ fn echo_reply_metadata_propagates_observed_dscp_with_ancillary() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
|
||||
client.send_probe().unwrap();
|
||||
thread::sleep(Duration::from_millis(50));
|
||||
@@ -563,7 +526,7 @@ fn echo_reply_metadata_propagates_observed_dscp_with_ancillary() {
|
||||
metadata_unavailable_skip(
|
||||
"echo_reply_metadata_propagates_observed_dscp_with_ancillary",
|
||||
);
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
return;
|
||||
};
|
||||
@@ -574,7 +537,7 @@ fn echo_reply_metadata_propagates_observed_dscp_with_ancillary() {
|
||||
other => panic!("expected EchoReply, got {other:?}"),
|
||||
}
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -595,7 +558,7 @@ fn echo_reply_metadata_preserves_observed_zero_with_ancillary() {
|
||||
metadata_unavailable_skip(
|
||||
"echo_reply_metadata_preserves_observed_zero_with_ancillary",
|
||||
);
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
return;
|
||||
};
|
||||
@@ -606,7 +569,7 @@ fn echo_reply_metadata_preserves_observed_zero_with_ancillary() {
|
||||
other => panic!("expected EchoReply, got {other:?}"),
|
||||
}
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -627,7 +590,7 @@ fn echo_reply_metadata_propagates_kernel_rx_timestamp_with_ancillary() {
|
||||
kernel_rx_timestamp_unavailable_skip(
|
||||
"echo_reply_metadata_propagates_kernel_rx_timestamp_with_ancillary",
|
||||
);
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
return;
|
||||
};
|
||||
@@ -636,7 +599,7 @@ fn echo_reply_metadata_propagates_kernel_rx_timestamp_with_ancillary() {
|
||||
other => panic!("expected EchoReply, got {other:?}"),
|
||||
}
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -654,7 +617,7 @@ fn echo_reply_rtt_uses_client_monotonic() {
|
||||
} else {
|
||||
panic!("expected EchoReply");
|
||||
}
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -679,7 +642,7 @@ fn server_processing_subtracted_when_valid() {
|
||||
} else {
|
||||
panic!("expected EchoReply");
|
||||
}
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -724,7 +687,7 @@ fn received_stats_parsed_into_sample() {
|
||||
} else {
|
||||
panic!("expected EchoReply");
|
||||
}
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -757,7 +720,7 @@ fn wrong_token_reply_is_dropped() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.send_probe().unwrap();
|
||||
thread::sleep(Duration::from_millis(30));
|
||||
let events = client.recv_once().unwrap();
|
||||
@@ -796,7 +759,7 @@ fn duplicate_reply_emits_duplicate_event() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.send_probe().unwrap();
|
||||
thread::sleep(Duration::from_millis(50));
|
||||
|
||||
@@ -850,7 +813,7 @@ fn out_of_order_reply_emits_late_event() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.send_probe().unwrap();
|
||||
client.send_probe().unwrap();
|
||||
thread::sleep(Duration::from_millis(50));
|
||||
@@ -891,16 +854,16 @@ fn poll_timeouts_emits_echo_loss() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
|
||||
client.send_probe().unwrap();
|
||||
client.send_probe().unwrap();
|
||||
|
||||
let no_loss = client.poll_timeouts(ClientTimestamp::now()).unwrap();
|
||||
let no_loss = client.poll_timeouts().unwrap();
|
||||
assert!(no_loss.is_empty());
|
||||
|
||||
thread::sleep(Duration::from_millis(150));
|
||||
let events = client.poll_timeouts(ClientTimestamp::now()).unwrap();
|
||||
let events = client.poll_timeouts().unwrap();
|
||||
assert_eq!(events.len(), 2);
|
||||
for event in &events {
|
||||
assert!(matches!(event, ClientEvent::EchoLoss { .. }));
|
||||
@@ -921,11 +884,11 @@ fn poll_timeouts_removes_expired_pending() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
|
||||
client.send_probe().unwrap();
|
||||
thread::sleep(Duration::from_millis(150));
|
||||
client.poll_timeouts(ClientTimestamp::now()).unwrap();
|
||||
client.poll_timeouts().unwrap();
|
||||
|
||||
let session = client.session.as_ref().unwrap();
|
||||
assert_eq!(session.pending.len(), 0);
|
||||
@@ -967,11 +930,11 @@ fn late_reply_after_timeout_preserves_measurement_metadata() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
|
||||
client.send_probe().unwrap();
|
||||
thread::sleep(Duration::from_millis(60));
|
||||
let losses = client.poll_timeouts(ClientTimestamp::now()).unwrap();
|
||||
let losses = client.poll_timeouts().unwrap();
|
||||
assert!(matches!(&losses[0], ClientEvent::EchoLoss { seq: 0, .. }));
|
||||
assert_eq!(client.session.as_ref().unwrap().pending.len(), 0);
|
||||
assert_eq!(client.session.as_ref().unwrap().timed_out.len(), 1);
|
||||
@@ -980,7 +943,6 @@ fn late_reply_after_timeout_preserves_measurement_metadata() {
|
||||
match &late[0] {
|
||||
ClientEvent::LateReply {
|
||||
seq,
|
||||
logical_seq,
|
||||
sent_at,
|
||||
rtt,
|
||||
server_timing,
|
||||
@@ -990,7 +952,6 @@ fn late_reply_after_timeout_preserves_measurement_metadata() {
|
||||
..
|
||||
} => {
|
||||
assert_eq!(*seq, 0);
|
||||
assert_eq!(*logical_seq, Some(0));
|
||||
assert!(sent_at.is_some());
|
||||
assert!(rtt.is_some());
|
||||
assert!(server_timing.is_some());
|
||||
@@ -1014,7 +975,7 @@ fn late_reply_after_timeout_preserves_measurement_metadata() {
|
||||
} if *bytes == echo_packet_len(false, &default_params())
|
||||
));
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -1046,11 +1007,11 @@ fn late_reply_metadata_is_unavailable_without_ancillary() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
|
||||
client.send_probe().unwrap();
|
||||
thread::sleep(Duration::from_millis(60));
|
||||
let losses = client.poll_timeouts(ClientTimestamp::now()).unwrap();
|
||||
let losses = client.poll_timeouts().unwrap();
|
||||
assert!(matches!(&losses[0], ClientEvent::EchoLoss { seq: 0, .. }));
|
||||
|
||||
let late = client.recv_once().unwrap();
|
||||
@@ -1062,7 +1023,7 @@ fn late_reply_metadata_is_unavailable_without_ancillary() {
|
||||
other => panic!("expected LateReply, got {other:?}"),
|
||||
}
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -1095,11 +1056,11 @@ fn late_reply_metadata_propagates_observed_dscp_with_ancillary() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
|
||||
client.send_probe().unwrap();
|
||||
thread::sleep(Duration::from_millis(60));
|
||||
let losses = client.poll_timeouts(ClientTimestamp::now()).unwrap();
|
||||
let losses = client.poll_timeouts().unwrap();
|
||||
assert!(matches!(&losses[0], ClientEvent::EchoLoss { seq: 0, .. }));
|
||||
|
||||
let events = client.recv_once().unwrap();
|
||||
@@ -1110,7 +1071,7 @@ fn late_reply_metadata_propagates_observed_dscp_with_ancillary() {
|
||||
metadata_unavailable_skip(
|
||||
"late_reply_metadata_propagates_observed_dscp_with_ancillary",
|
||||
);
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
return;
|
||||
};
|
||||
@@ -1128,7 +1089,7 @@ fn late_reply_metadata_propagates_observed_dscp_with_ancillary() {
|
||||
other => panic!("expected LateReply, got {other:?}"),
|
||||
}
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -1149,7 +1110,7 @@ fn pending_map_bounded() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.send_probe().unwrap();
|
||||
client.send_probe().unwrap();
|
||||
client.send_probe().unwrap();
|
||||
@@ -1157,7 +1118,7 @@ fn pending_map_bounded() {
|
||||
client.send_probe(),
|
||||
Err(ClientError::PendingLimitExceeded { limit: 3 })
|
||||
));
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -1199,7 +1160,7 @@ fn minimal_negotiated_layout_works() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.send_probe().unwrap();
|
||||
thread::sleep(Duration::from_millis(30));
|
||||
let events = client.recv_once().unwrap();
|
||||
@@ -1253,7 +1214,7 @@ fn late_reply_with_pending_preserves_rtt() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.send_probe().unwrap();
|
||||
client.send_probe().unwrap();
|
||||
client.send_probe().unwrap();
|
||||
@@ -1296,7 +1257,7 @@ fn pending_full_does_not_send_packet() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
|
||||
client.send_probe().unwrap();
|
||||
client.send_probe().unwrap();
|
||||
@@ -1326,7 +1287,7 @@ fn pending_full_does_not_send_packet() {
|
||||
"no packet should be sent when pending is full"
|
||||
);
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -1361,7 +1322,7 @@ fn unmatched_future_reply_emits_warning_not_late() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.send_probe().unwrap();
|
||||
thread::sleep(Duration::from_millis(50));
|
||||
|
||||
@@ -1419,7 +1380,7 @@ fn unmatched_future_reply_does_not_update_highest_received_seq() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.send_probe().unwrap();
|
||||
client.send_probe().unwrap();
|
||||
thread::sleep(Duration::from_millis(50));
|
||||
@@ -1523,7 +1484,7 @@ fn matched_reply_with_reversed_monotonic_time_still_emits_event() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
|
||||
let base = Instant::now() + Duration::from_secs(1);
|
||||
let send_ts = ClientTimestamp {
|
||||
@@ -1550,7 +1511,7 @@ fn matched_reply_with_reversed_monotonic_time_still_emits_event() {
|
||||
other => panic!("expected EchoReply, got {other:?}"),
|
||||
}
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -1566,7 +1527,7 @@ fn process_received_packet_uses_supplied_receive_metadata() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
|
||||
client.send_probe_at(ClientTimestamp::now()).unwrap();
|
||||
let recv_ts = ClientTimestamp::now();
|
||||
@@ -1596,7 +1557,7 @@ fn process_received_packet_uses_supplied_receive_metadata() {
|
||||
other => panic!("expected EchoReply, got {other:?}"),
|
||||
}
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -1613,11 +1574,11 @@ fn process_received_packet_uses_supplied_receive_metadata_for_late_reply() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
|
||||
client.send_probe_at(ClientTimestamp::now()).unwrap();
|
||||
thread::sleep(Duration::from_millis(60));
|
||||
let losses = client.poll_timeouts(ClientTimestamp::now()).unwrap();
|
||||
let losses = client.poll_timeouts().unwrap();
|
||||
assert!(matches!(&losses[0], ClientEvent::EchoLoss { seq: 0, .. }));
|
||||
|
||||
let recv_ts = ClientTimestamp::now();
|
||||
@@ -1647,7 +1608,7 @@ fn process_received_packet_uses_supplied_receive_metadata_for_late_reply() {
|
||||
other => panic!("expected LateReply, got {other:?}"),
|
||||
}
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -1663,7 +1624,7 @@ fn receive_metadata_does_not_broaden_malformed_warning() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
|
||||
let events = client
|
||||
.process_received_packet(
|
||||
@@ -1678,14 +1639,14 @@ fn receive_metadata_does_not_broaden_malformed_warning() {
|
||||
|
||||
assert_eq!(events.len(), 1);
|
||||
match &events[0] {
|
||||
ClientEvent::Warning { kind, message } => {
|
||||
ClientEvent::Warning { kind, message, .. } => {
|
||||
assert_eq!(*kind, WarningKind::MalformedOrUnrelatedPacket);
|
||||
assert_eq!(message, "dropped malformed or unrelated packet");
|
||||
}
|
||||
other => panic!("expected Warning, got {other:?}"),
|
||||
}
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -1713,7 +1674,7 @@ fn recv_available_drains_burst_replies() {
|
||||
));
|
||||
}
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -1738,7 +1699,7 @@ fn recv_available_respects_packet_budget() {
|
||||
assert_eq!(second.len(), 1);
|
||||
assert!(matches!(&second[0], ClientEvent::EchoReply { seq: 1, .. }));
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -1754,11 +1715,10 @@ fn send_probe_wraps_wire_sequence_at_u32_max() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
|
||||
let session = client.session.as_mut().unwrap();
|
||||
session.next_wire_seq = u32::MAX;
|
||||
session.next_logical_seq = 41;
|
||||
|
||||
client.send_probe().unwrap();
|
||||
client.send_probe().unwrap();
|
||||
@@ -1772,7 +1732,7 @@ fn send_probe_wraps_wire_sequence_at_u32_max() {
|
||||
.collect();
|
||||
assert_eq!(seqs, vec![u32::MAX, 0]);
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -1811,10 +1771,9 @@ fn wrapped_reply_after_u32_max_is_not_late() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
let session = client.session.as_mut().unwrap();
|
||||
session.next_wire_seq = u32::MAX;
|
||||
session.next_logical_seq = 41;
|
||||
|
||||
client.send_probe().unwrap();
|
||||
client.send_probe().unwrap();
|
||||
@@ -1848,7 +1807,7 @@ fn send_probe_after_sending_done_is_noop() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
|
||||
client.session.as_mut().unwrap().sending_done = true;
|
||||
let events = client.send_probe().unwrap();
|
||||
@@ -1863,7 +1822,7 @@ fn send_probe_after_sending_done_is_noop() {
|
||||
.count();
|
||||
assert_eq!(echo_count, 0);
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -1926,7 +1885,7 @@ fn recv_buffer_uses_negotiated_packet_length() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
let buf_size = client.recv_buffer_size();
|
||||
assert!(
|
||||
buf_size > 4096,
|
||||
@@ -1934,7 +1893,7 @@ fn recv_buffer_uses_negotiated_packet_length() {
|
||||
);
|
||||
assert_eq!(buf_size, 4097);
|
||||
assert_eq!(client.recv_buffer.len(), buf_size);
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -1954,7 +1913,7 @@ fn short_echo_reply_does_not_emit_echo_reply() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.send_probe().unwrap();
|
||||
|
||||
let mut packet = echo_reply_packet(TOKEN, 0, ¶ms, &TimestampFields::default(), None);
|
||||
@@ -1970,7 +1929,7 @@ fn short_echo_reply_does_not_emit_echo_reply() {
|
||||
..
|
||||
}]
|
||||
));
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -1986,7 +1945,7 @@ fn overlong_echo_reply_does_not_emit_echo_reply() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.send_probe().unwrap();
|
||||
|
||||
let mut packet = echo_reply_packet(TOKEN, 0, ¶ms, &TimestampFields::default(), None);
|
||||
@@ -2002,7 +1961,7 @@ fn overlong_echo_reply_does_not_emit_echo_reply() {
|
||||
..
|
||||
}]
|
||||
));
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -2036,7 +1995,7 @@ fn overlong_datagram_detection_uses_extra_receive_byte() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
assert_eq!(
|
||||
client.recv_buffer.len(),
|
||||
echo_packet_len(false, ¶ms) + 1
|
||||
@@ -2051,7 +2010,7 @@ fn overlong_datagram_detection_uses_extra_receive_byte() {
|
||||
..
|
||||
}]
|
||||
));
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -2083,7 +2042,7 @@ fn exact_length_echo_reply_still_emits_echo_reply() {
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
client.send_probe().unwrap();
|
||||
|
||||
let events = client.recv_once().unwrap();
|
||||
@@ -2091,7 +2050,7 @@ fn exact_length_echo_reply_still_emits_echo_reply() {
|
||||
events.as_slice(),
|
||||
[ClientEvent::EchoReply { bytes, .. }] if *bytes == echo_packet_len(false, ¶ms)
|
||||
));
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -2113,6 +2072,6 @@ fn recv_once_at_test_helper_provides_deterministic_timestamp() {
|
||||
} else {
|
||||
panic!("expected EchoReply");
|
||||
}
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
@@ -26,7 +26,6 @@ fn sequence_ordering_handles_normal_and_wrapped_values() {
|
||||
fn highest_received_seq_updates_across_wrap() {
|
||||
let mut session = ActiveSession {
|
||||
next_wire_seq: 0,
|
||||
next_logical_seq: 0,
|
||||
highest_received_seq: Some(u32::MAX),
|
||||
packets_sent: 0,
|
||||
start_mono: Instant::now(),
|
||||
|
||||
@@ -283,7 +283,7 @@ pub(super) fn open_client_with_echo_server(params: &Params) -> (Client, FakeServ
|
||||
..default_test_config(server.addr)
|
||||
};
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert_open_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
assert_open_started(client.open().unwrap());
|
||||
(client, server)
|
||||
}
|
||||
|
||||
|
||||
@@ -29,10 +29,10 @@ fn connect_applies_configured_ipv4_ttl_before_open_and_close_preserves_it() {
|
||||
|
||||
assert_eq!(socket_ttl(&client.socket, client.remote).unwrap(), 64);
|
||||
|
||||
client.open(ClientTimestamp::now()).unwrap();
|
||||
client.open().unwrap();
|
||||
server.join();
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
assert_eq!(socket_ttl(&client.socket, client.remote).unwrap(), 64);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ use std::{io, time::Duration};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[non_exhaustive]
|
||||
pub enum ClientError {
|
||||
#[error("failed to resolve server address {addr:?}")]
|
||||
Resolve { addr: String },
|
||||
|
||||
@@ -41,7 +41,6 @@ pub enum ClientEvent {
|
||||
|
||||
EchoSent {
|
||||
seq: u32,
|
||||
logical_seq: u64,
|
||||
remote: SocketAddr,
|
||||
scheduled_at: Instant,
|
||||
sent_at: ClientTimestamp,
|
||||
@@ -52,7 +51,6 @@ pub enum ClientEvent {
|
||||
|
||||
EchoReply {
|
||||
seq: u32,
|
||||
logical_seq: u64,
|
||||
remote: SocketAddr,
|
||||
sent_at: ClientTimestamp,
|
||||
received_at: ClientTimestamp,
|
||||
@@ -66,7 +64,6 @@ pub enum ClientEvent {
|
||||
|
||||
EchoLoss {
|
||||
seq: u32,
|
||||
logical_seq: u64,
|
||||
sent_at: ClientTimestamp,
|
||||
timeout_at: std::time::Instant,
|
||||
},
|
||||
@@ -80,7 +77,6 @@ pub enum ClientEvent {
|
||||
|
||||
LateReply {
|
||||
seq: u32,
|
||||
logical_seq: Option<u64>,
|
||||
highest_seen: u32,
|
||||
remote: SocketAddr,
|
||||
sent_at: Option<ClientTimestamp>,
|
||||
@@ -96,10 +92,12 @@ pub enum ClientEvent {
|
||||
Warning {
|
||||
kind: WarningKind,
|
||||
message: String,
|
||||
at: ClientTimestamp,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum WarningKind {
|
||||
MalformedOrUnrelatedPacket,
|
||||
WrongToken,
|
||||
|
||||
@@ -279,6 +279,7 @@ mod tests {
|
||||
ClientEvent::Warning {
|
||||
kind: WarningKind::UntrackedReply,
|
||||
message: format!("event-{n}"),
|
||||
at: ClientTimestamp::now(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ use crate::{
|
||||
config::{ClientConfig, RecvBudget},
|
||||
error::ClientError,
|
||||
event::{ClientEvent, OpenOutcome},
|
||||
timing::ClientTimestamp,
|
||||
Client,
|
||||
};
|
||||
|
||||
@@ -94,7 +93,7 @@ impl ManagedClient {
|
||||
.transpose()?;
|
||||
|
||||
let mut client = Client::connect(config)?;
|
||||
let outcome = client.open(ClientTimestamp::now())?;
|
||||
let outcome = client.open()?;
|
||||
publish_open_outcome(&hub, &outcome);
|
||||
|
||||
let cancellation = CancellationToken::new();
|
||||
@@ -182,11 +181,7 @@ fn run_client(
|
||||
&mut counters,
|
||||
client.recv_available(MANAGED_RECV_BUDGET)?,
|
||||
);
|
||||
publish_events(
|
||||
&hub,
|
||||
&mut counters,
|
||||
client.poll_timeouts(ClientTimestamp::now())?,
|
||||
);
|
||||
publish_events(&hub, &mut counters, client.poll_timeouts()?);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -205,11 +200,7 @@ fn run_client(
|
||||
&mut counters,
|
||||
client.recv_available(MANAGED_RECV_BUDGET)?,
|
||||
);
|
||||
publish_events(
|
||||
&hub,
|
||||
&mut counters,
|
||||
client.poll_timeouts(ClientTimestamp::now())?,
|
||||
);
|
||||
publish_events(&hub, &mut counters, client.poll_timeouts()?);
|
||||
|
||||
if client.is_run_complete() {
|
||||
break;
|
||||
@@ -223,7 +214,7 @@ fn run_client(
|
||||
}
|
||||
|
||||
let packets_sent = client.packets_sent();
|
||||
let close_events = client.close(ClientTimestamp::now())?;
|
||||
let close_events = client.close()?;
|
||||
publish_events(&hub, &mut counters, close_events);
|
||||
|
||||
Ok(SessionOutcome {
|
||||
@@ -267,7 +258,7 @@ fn drain_final_late_replies(
|
||||
published |= !events.is_empty();
|
||||
publish_events(hub, counters, events);
|
||||
|
||||
let events = client.poll_timeouts(ClientTimestamp::now())?;
|
||||
let events = client.poll_timeouts()?;
|
||||
published |= !events.is_empty();
|
||||
publish_events(hub, counters, events);
|
||||
|
||||
@@ -603,19 +594,13 @@ mod tests {
|
||||
server.join();
|
||||
|
||||
assert_eq!(outcome.end_reason, SessionEndReason::TestComplete);
|
||||
assert!(events.iter().any(|event| matches!(
|
||||
event,
|
||||
ClientEvent::EchoLoss {
|
||||
seq: 0,
|
||||
logical_seq: 0,
|
||||
..
|
||||
}
|
||||
)));
|
||||
assert!(events
|
||||
.iter()
|
||||
.any(|event| matches!(event, ClientEvent::EchoLoss { seq: 0, .. })));
|
||||
assert!(events.iter().any(|event| matches!(
|
||||
event,
|
||||
ClientEvent::LateReply {
|
||||
seq: 0,
|
||||
logical_seq: Some(0),
|
||||
sent_at: Some(_),
|
||||
rtt: Some(_),
|
||||
..
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::{
|
||||
collections::{HashMap, VecDeque},
|
||||
collections::{HashMap, HashSet, VecDeque},
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
@@ -7,7 +7,6 @@ use crate::{error::ClientError, timing::ClientTimestamp};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct PendingProbe {
|
||||
pub logical_seq: u64,
|
||||
pub wire_seq: u32,
|
||||
pub sent_at: ClientTimestamp,
|
||||
pub timeout_at: Instant,
|
||||
@@ -59,11 +58,10 @@ impl PendingMap {
|
||||
expired.push(probe);
|
||||
}
|
||||
}
|
||||
expired.sort_by_key(|p| p.logical_seq);
|
||||
expired.sort_by_key(|p| p.sent_at.mono);
|
||||
expired
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn len(&self) -> usize {
|
||||
self.map.len()
|
||||
}
|
||||
@@ -115,7 +113,6 @@ impl TimedOutMap {
|
||||
self.insertion_order.clear();
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn len(&self) -> usize {
|
||||
self.map.len()
|
||||
}
|
||||
@@ -136,7 +133,7 @@ impl TimedOutMap {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct CompletedSet {
|
||||
set: HashMap<u32, u64>,
|
||||
set: HashSet<u32>,
|
||||
insertion_order: VecDeque<u32>,
|
||||
max_capacity: usize,
|
||||
}
|
||||
@@ -144,31 +141,32 @@ pub(crate) struct CompletedSet {
|
||||
impl CompletedSet {
|
||||
pub fn new(max_capacity: usize) -> Self {
|
||||
Self {
|
||||
set: HashMap::new(),
|
||||
set: HashSet::new(),
|
||||
insertion_order: VecDeque::new(),
|
||||
max_capacity,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert(&mut self, wire_seq: u32, logical_seq: u64) {
|
||||
if let Some(existing) = self.set.get_mut(&wire_seq) {
|
||||
*existing = logical_seq;
|
||||
pub fn insert(&mut self, seq: u32) {
|
||||
if self.set.contains(&seq) {
|
||||
return;
|
||||
}
|
||||
|
||||
if self.set.len() >= self.max_capacity {
|
||||
self.evict_oldest();
|
||||
}
|
||||
self.insertion_order.push_back(wire_seq);
|
||||
self.set.insert(wire_seq, logical_seq);
|
||||
|
||||
self.insertion_order.push_back(seq);
|
||||
self.set.insert(seq);
|
||||
}
|
||||
|
||||
pub fn contains(&self, wire_seq: u32) -> bool {
|
||||
self.set.contains_key(&wire_seq)
|
||||
pub fn contains(&self, seq: u32) -> bool {
|
||||
self.set.contains(&seq)
|
||||
}
|
||||
|
||||
fn evict_oldest(&mut self) {
|
||||
while let Some(oldest_key) = self.insertion_order.pop_front() {
|
||||
if self.set.remove(&oldest_key).is_some() {
|
||||
while let Some(oldest_seq) = self.insertion_order.pop_front() {
|
||||
if self.set.remove(&oldest_seq) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -187,9 +185,8 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
fn pending(seq: u32, logical: u64, timeout_at: Instant) -> PendingProbe {
|
||||
fn pending(seq: u32, timeout_at: Instant) -> PendingProbe {
|
||||
PendingProbe {
|
||||
logical_seq: logical,
|
||||
wire_seq: seq,
|
||||
sent_at: ts(timeout_at - Duration::from_secs(1)),
|
||||
timeout_at,
|
||||
@@ -200,7 +197,7 @@ mod tests {
|
||||
fn pending_map_insert_and_remove() {
|
||||
let mut map = PendingMap::new(10);
|
||||
let now = Instant::now();
|
||||
let probe = pending(0, 0, now + Duration::from_secs(4));
|
||||
let probe = pending(0, now + Duration::from_secs(4));
|
||||
map.insert(probe).unwrap();
|
||||
assert_eq!(map.len(), 1);
|
||||
assert!(map.remove(0).is_some());
|
||||
@@ -212,42 +209,26 @@ mod tests {
|
||||
fn pending_map_rejects_over_capacity() {
|
||||
let mut map = PendingMap::new(2);
|
||||
let now = Instant::now();
|
||||
map.insert(pending(0, 0, now + Duration::from_secs(4)))
|
||||
map.insert(pending(0, now + Duration::from_secs(4)))
|
||||
.unwrap();
|
||||
map.insert(pending(1, 1, now + Duration::from_secs(4)))
|
||||
map.insert(pending(1, now + Duration::from_secs(4)))
|
||||
.unwrap();
|
||||
assert!(matches!(
|
||||
map.insert(pending(2, 2, now + Duration::from_secs(4))),
|
||||
map.insert(pending(2, now + Duration::from_secs(4))),
|
||||
Err(ClientError::PendingLimitExceeded { limit: 2 })
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn drain_expired_returns_in_logical_order() {
|
||||
let mut map = PendingMap::new(10);
|
||||
let now = Instant::now();
|
||||
let past = now - Duration::from_secs(1);
|
||||
map.insert(pending(5, 5, past)).unwrap();
|
||||
map.insert(pending(2, 2, past)).unwrap();
|
||||
map.insert(pending(8, 8, now + Duration::from_secs(10)))
|
||||
.unwrap();
|
||||
let expired = map.drain_expired(now);
|
||||
assert_eq!(expired.len(), 2);
|
||||
assert_eq!(expired[0].wire_seq, 2);
|
||||
assert_eq!(expired[1].wire_seq, 5);
|
||||
assert_eq!(map.len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completed_set_tracks_and_evicts() {
|
||||
let mut set = CompletedSet::new(3);
|
||||
set.insert(0, 0);
|
||||
set.insert(1, 1);
|
||||
set.insert(2, 2);
|
||||
set.insert(0);
|
||||
set.insert(1);
|
||||
set.insert(2);
|
||||
assert!(set.contains(0));
|
||||
assert!(set.contains(1));
|
||||
assert!(set.contains(2));
|
||||
set.insert(3, 3);
|
||||
set.insert(3);
|
||||
assert_eq!(set.set.len(), 3);
|
||||
assert!(!set.contains(0));
|
||||
assert!(set.contains(3));
|
||||
@@ -257,9 +238,9 @@ mod tests {
|
||||
fn timed_out_map_tracks_and_evicts() {
|
||||
let mut map = TimedOutMap::new(2);
|
||||
let now = Instant::now();
|
||||
map.insert(pending(0, 0, now));
|
||||
map.insert(pending(1, 1, now));
|
||||
map.insert(pending(2, 2, now));
|
||||
map.insert(pending(0, now));
|
||||
map.insert(pending(1, now));
|
||||
map.insert(pending(2, now));
|
||||
|
||||
assert_eq!(map.len(), 2);
|
||||
assert!(map.remove(0).is_none());
|
||||
@@ -273,7 +254,7 @@ mod tests {
|
||||
let now = Instant::now();
|
||||
|
||||
for i in 0..20 {
|
||||
map.insert(pending(i, u64::from(i), now));
|
||||
map.insert(pending(i, now));
|
||||
assert!(map.remove(i).is_some());
|
||||
assert_eq!(map.len(), 0);
|
||||
assert_eq!(map.insertion_order_len(), 0);
|
||||
|
||||
@@ -15,7 +15,7 @@ pub(crate) fn configure_receive_metadata(socket: &UdpSocket, remote: SocketAddr)
|
||||
enable_kernel_rx_timestamps(socket)?;
|
||||
let socket = socket2::SockRef::from(socket);
|
||||
if remote.is_ipv4() {
|
||||
socket.set_recv_tos(true)
|
||||
socket.set_recv_tos_v4(true)
|
||||
} else {
|
||||
socket.set_recv_tclass_v6(true)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ pub(crate) enum ClientPhase {
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct ActiveSession {
|
||||
pub next_wire_seq: u32,
|
||||
pub next_logical_seq: u64,
|
||||
pub highest_received_seq: Option<u32>,
|
||||
pub packets_sent: u64,
|
||||
pub start_mono: Instant,
|
||||
|
||||
@@ -78,7 +78,7 @@ pub(crate) fn socket_ttl(socket: &UdpSocket, remote: SocketAddr) -> Result<u32,
|
||||
|
||||
fn set_socket_ttl(socket: &UdpSocket, remote: SocketAddr, ttl: u32) -> io::Result<()> {
|
||||
if remote.is_ipv4() {
|
||||
socket2::SockRef::from(socket).set_ttl(ttl)
|
||||
socket2::SockRef::from(socket).set_ttl_v4(ttl)
|
||||
} else {
|
||||
socket2::SockRef::from(socket).set_unicast_hops_v6(ttl)
|
||||
}
|
||||
@@ -87,7 +87,7 @@ fn set_socket_ttl(socket: &UdpSocket, remote: SocketAddr, ttl: u32) -> io::Resul
|
||||
#[cfg(test)]
|
||||
fn get_socket_ttl(socket: &UdpSocket, remote: SocketAddr) -> io::Result<u32> {
|
||||
if remote.is_ipv4() {
|
||||
socket2::SockRef::from(socket).ttl()
|
||||
socket2::SockRef::from(socket).ttl_v4()
|
||||
} else {
|
||||
socket2::SockRef::from(socket).unicast_hops_v6()
|
||||
}
|
||||
@@ -128,7 +128,7 @@ fn set_socket_traffic_class_io(
|
||||
target_os = "haiku",
|
||||
)))]
|
||||
fn set_ipv4_traffic_class(socket: &UdpSocket, traffic_class: u32) -> io::Result<()> {
|
||||
socket2::SockRef::from(socket).set_tos(traffic_class)
|
||||
socket2::SockRef::from(socket).set_tos_v4(traffic_class)
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
@@ -212,7 +212,7 @@ fn unsupported_traffic_class(traffic_class: u32, feature: &'static str) -> io::R
|
||||
))
|
||||
))]
|
||||
fn get_ipv4_traffic_class(socket: &UdpSocket) -> io::Result<u32> {
|
||||
socket2::SockRef::from(socket).tos()
|
||||
socket2::SockRef::from(socket).tos_v4()
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
|
||||
@@ -3,8 +3,7 @@ mod support;
|
||||
use std::time::Duration;
|
||||
|
||||
use irtt_client::{
|
||||
Client, ClientConfig, ClientError, ClientEvent, ClientTimestamp, OpenOutcome, SocketConfig,
|
||||
WarningKind,
|
||||
Client, ClientConfig, ClientError, ClientEvent, OpenOutcome, SocketConfig, WarningKind,
|
||||
};
|
||||
use irtt_proto::{echo_packet_len, ProtoError, TimestampFields};
|
||||
|
||||
@@ -74,13 +73,11 @@ fn hmac_echo_success_verifies_request_and_accepts_reply() {
|
||||
match &run.reply {
|
||||
ClientEvent::EchoReply {
|
||||
seq,
|
||||
logical_seq,
|
||||
bytes,
|
||||
server_timing,
|
||||
..
|
||||
} => {
|
||||
assert_eq!(*seq, 0);
|
||||
assert_eq!(*logical_seq, 0);
|
||||
assert_eq!(*bytes, echo_packet_len(true, ¶ms));
|
||||
assert!(server_timing.is_some());
|
||||
}
|
||||
@@ -98,10 +95,10 @@ fn hmac_close_success_sends_authenticated_close_and_closes_session() {
|
||||
config.hmac_key = Some(key);
|
||||
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
let outcome = client.open(ClientTimestamp::now()).unwrap();
|
||||
let outcome = client.open().unwrap();
|
||||
assert_started(outcome, ¶ms);
|
||||
|
||||
let events = client.close(ClientTimestamp::now()).unwrap();
|
||||
let events = client.close().unwrap();
|
||||
assert!(matches!(
|
||||
events.as_slice(),
|
||||
[ClientEvent::SessionClosed { token: TOKEN, .. }]
|
||||
@@ -131,10 +128,7 @@ fn missing_client_key_against_hmac_required_server_times_out() {
|
||||
config.hmac_key = None;
|
||||
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
Err(ClientError::OpenTimeout)
|
||||
));
|
||||
assert!(matches!(client.open(), Err(ClientError::OpenTimeout)));
|
||||
|
||||
let observations = server.observations(1);
|
||||
assert!(matches!(
|
||||
@@ -156,10 +150,7 @@ fn wrong_client_key_against_hmac_required_server_times_out() {
|
||||
config.hmac_key = Some(b"wrong-secret".to_vec());
|
||||
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
Err(ClientError::OpenTimeout)
|
||||
));
|
||||
assert!(matches!(client.open(), Err(ClientError::OpenTimeout)));
|
||||
|
||||
let observations = server.observations(1);
|
||||
assert!(matches!(
|
||||
@@ -185,7 +176,7 @@ fn bad_hmac_echo_reply_is_rejected_without_echo_reply_event() {
|
||||
};
|
||||
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
let outcome = client.open(ClientTimestamp::now()).unwrap();
|
||||
let outcome = client.open().unwrap();
|
||||
assert_started(outcome, ¶ms);
|
||||
|
||||
let sent = client.send_probe().unwrap();
|
||||
@@ -229,7 +220,7 @@ fn hmac_open_reply_with_bad_hmac_fails_with_protocol_error() {
|
||||
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
client.open(),
|
||||
Err(ClientError::Protocol(ProtoError::BadHmac))
|
||||
));
|
||||
server.join();
|
||||
@@ -247,7 +238,7 @@ fn non_hmac_client_open_does_not_set_hmac_flag() {
|
||||
config.hmac_key = None;
|
||||
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
let outcome = client.open(ClientTimestamp::now()).unwrap();
|
||||
let outcome = client.open().unwrap();
|
||||
assert_started(outcome, ¶ms);
|
||||
|
||||
let observations = server.observations(1);
|
||||
@@ -304,7 +295,7 @@ fn backend_hmac_correct_key_succeeds() {
|
||||
config.hmac_key = Some(key);
|
||||
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
let outcome = client.open(ClientTimestamp::now()).unwrap();
|
||||
let outcome = client.open().unwrap();
|
||||
assert!(matches!(outcome, OpenOutcome::Started { .. }));
|
||||
|
||||
let sent = client.send_probe().unwrap();
|
||||
@@ -314,7 +305,7 @@ fn backend_hmac_correct_key_succeeds() {
|
||||
assert_eq!(events.len(), 1);
|
||||
assert!(matches!(events[0], ClientEvent::EchoReply { .. }));
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -326,10 +317,7 @@ fn backend_hmac_wrong_key_fails() {
|
||||
config.hmac_key = Some(b"wrong-secret".to_vec());
|
||||
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
Err(ClientError::OpenTimeout)
|
||||
));
|
||||
assert!(matches!(client.open(), Err(ClientError::OpenTimeout)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -341,8 +329,5 @@ fn backend_hmac_missing_key_fails() {
|
||||
config.hmac_key = None;
|
||||
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
Err(ClientError::OpenTimeout)
|
||||
));
|
||||
assert!(matches!(client.open(), Err(ClientError::OpenTimeout)));
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
mod support;
|
||||
|
||||
use irtt_client::{Client, ClientConfig, ClientEvent, ClientTimestamp, NegotiationPolicy};
|
||||
use irtt_client::{Client, ClientConfig, ClientEvent, NegotiationPolicy};
|
||||
use irtt_proto::{echo_header_len, echo_packet_len, Params, TimestampFields};
|
||||
|
||||
use support::{config_for_params, default_params, run_one_probe, BackendPeer, ServerObservation};
|
||||
@@ -128,7 +128,7 @@ fn backend_large_packet_smoke() {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
let outcome = client.open(ClientTimestamp::now()).unwrap();
|
||||
let outcome = client.open().unwrap();
|
||||
assert!(matches!(outcome, irtt_client::OpenOutcome::Started { .. }));
|
||||
|
||||
client.send_probe().unwrap();
|
||||
@@ -136,5 +136,5 @@ fn backend_large_packet_smoke() {
|
||||
assert_eq!(events.len(), 1);
|
||||
assert!(matches!(events[0], ClientEvent::EchoReply { .. }));
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
mod support;
|
||||
|
||||
use irtt_client::ClientTimestamp;
|
||||
use std::time::Duration;
|
||||
|
||||
use irtt_client::{
|
||||
@@ -17,7 +16,6 @@ use support::{
|
||||
|
||||
struct ReplyView<'a> {
|
||||
seq: u32,
|
||||
logical_seq: u64,
|
||||
rtt: &'a RttSample,
|
||||
server_timing: Option<&'a ServerTiming>,
|
||||
one_way: Option<&'a OneWayDelaySample>,
|
||||
@@ -39,7 +37,6 @@ fn received_stats_modes_drive_negotiated_echo_and_reply_events() {
|
||||
|
||||
let reply = expect_echo_reply(&run.reply);
|
||||
assert_eq!(reply.seq, 0);
|
||||
assert_eq!(reply.logical_seq, 0);
|
||||
assert_eq!(reply.bytes, echo_packet_len(false, ¶ms));
|
||||
assert!(reply.server_timing.is_none());
|
||||
assert!(reply.one_way.is_none());
|
||||
@@ -167,7 +164,7 @@ fn strict_open_rejects_changed_compatibility_params_from_server() {
|
||||
config.server_addr = server.addr.to_string();
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
assert!(matches!(
|
||||
client.open(irtt_client::ClientTimestamp::now()),
|
||||
client.open(),
|
||||
Err(ClientError::NegotiationRejected { .. })
|
||||
));
|
||||
server.join();
|
||||
@@ -252,14 +249,8 @@ fn assert_echo_uses_params(run: &OneProbeRun, params: &Params, hmac: bool) {
|
||||
assert_eq!(sequence, 0);
|
||||
|
||||
match &run.sent {
|
||||
ClientEvent::EchoSent {
|
||||
seq,
|
||||
logical_seq,
|
||||
bytes,
|
||||
..
|
||||
} => {
|
||||
ClientEvent::EchoSent { seq, bytes, .. } => {
|
||||
assert_eq!(*seq, 0);
|
||||
assert_eq!(*logical_seq, 0);
|
||||
assert_eq!(*bytes, echo_packet_len(hmac, params));
|
||||
}
|
||||
other => panic!("expected EchoSent, got {other:?}"),
|
||||
@@ -289,7 +280,6 @@ fn expect_echo_reply(event: &ClientEvent) -> ReplyView<'_> {
|
||||
match event {
|
||||
ClientEvent::EchoReply {
|
||||
seq,
|
||||
logical_seq,
|
||||
rtt,
|
||||
server_timing,
|
||||
one_way,
|
||||
@@ -298,7 +288,6 @@ fn expect_echo_reply(event: &ClientEvent) -> ReplyView<'_> {
|
||||
..
|
||||
} => ReplyView {
|
||||
seq: *seq,
|
||||
logical_seq: *logical_seq,
|
||||
rtt,
|
||||
server_timing: server_timing.as_ref(),
|
||||
one_way: one_way.as_ref(),
|
||||
@@ -379,7 +368,7 @@ fn backend_basic_open_echo_close() {
|
||||
let peer = BackendPeer::start_open_echo(params.clone(), None);
|
||||
let mut client = Client::connect(config_for_params(peer.addr(), ¶ms)).unwrap();
|
||||
|
||||
let outcome = client.open(ClientTimestamp::now()).unwrap();
|
||||
let outcome = client.open().unwrap();
|
||||
assert!(matches!(outcome, irtt_client::OpenOutcome::Started { .. }));
|
||||
|
||||
let sent = client.send_probe().unwrap();
|
||||
@@ -389,7 +378,7 @@ fn backend_basic_open_echo_close() {
|
||||
assert_eq!(events.len(), 1);
|
||||
assert!(matches!(events[0], ClientEvent::EchoReply { .. }));
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -400,7 +389,7 @@ fn backend_ttl_smoke() {
|
||||
config.socket_config.ttl = Some(64);
|
||||
let mut client = Client::connect(config).unwrap();
|
||||
|
||||
let outcome = client.open(ClientTimestamp::now()).unwrap();
|
||||
let outcome = client.open().unwrap();
|
||||
assert!(matches!(outcome, irtt_client::OpenOutcome::Started { .. }));
|
||||
|
||||
let sent = client.send_probe().unwrap();
|
||||
@@ -410,7 +399,7 @@ fn backend_ttl_smoke() {
|
||||
assert_eq!(events.len(), 1);
|
||||
assert!(matches!(events[0], ClientEvent::EchoReply { .. }));
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -420,9 +409,9 @@ fn dscp_configured_open_close_smoke() {
|
||||
let server = start_open_server(params.clone(), None);
|
||||
let mut client = Client::connect(config_for_params(server.addr, ¶ms)).unwrap();
|
||||
|
||||
let outcome = client.open(ClientTimestamp::now()).unwrap();
|
||||
let outcome = client.open().unwrap();
|
||||
assert!(matches!(outcome, irtt_client::OpenOutcome::Started { .. }));
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
server.join();
|
||||
}
|
||||
|
||||
@@ -438,13 +427,13 @@ fn backend_received_stats_smoke() {
|
||||
let peer = BackendPeer::start_open_echo(params.clone(), None);
|
||||
let mut client = Client::connect(config_for_params(peer.addr(), ¶ms)).unwrap();
|
||||
|
||||
client.open(ClientTimestamp::now()).unwrap();
|
||||
client.open().unwrap();
|
||||
client.send_probe().unwrap();
|
||||
let events = client.recv_once().unwrap();
|
||||
assert_eq!(events.len(), 1);
|
||||
assert!(matches!(events[0], ClientEvent::EchoReply { .. }));
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,7 +450,7 @@ fn backend_timestamp_smoke() {
|
||||
let peer = BackendPeer::start_open_echo(params.clone(), None);
|
||||
let mut client = Client::connect(config_for_params(peer.addr(), ¶ms)).unwrap();
|
||||
|
||||
client.open(ClientTimestamp::now()).unwrap();
|
||||
client.open().unwrap();
|
||||
client.send_probe().unwrap();
|
||||
let events = client.recv_once().unwrap();
|
||||
assert_eq!(events.len(), 1);
|
||||
@@ -497,7 +486,7 @@ fn backend_timestamp_smoke() {
|
||||
other => panic!("expected EchoReply, got {other:?}"),
|
||||
}
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,7 +497,7 @@ fn backend_clock_smoke() {
|
||||
let peer = BackendPeer::start_open_echo(params.clone(), None);
|
||||
let mut client = Client::connect(config_for_params(peer.addr(), ¶ms)).unwrap();
|
||||
|
||||
client.open(ClientTimestamp::now()).unwrap();
|
||||
client.open().unwrap();
|
||||
client.send_probe().unwrap();
|
||||
let events = client.recv_once().unwrap();
|
||||
assert_eq!(events.len(), 1);
|
||||
@@ -536,6 +525,6 @@ fn backend_clock_smoke() {
|
||||
other => panic!("expected EchoReply, got {other:?}"),
|
||||
}
|
||||
|
||||
client.close(ClientTimestamp::now()).unwrap();
|
||||
client.close().unwrap();
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
mod support;
|
||||
|
||||
use irtt_client::{
|
||||
Client, ClientConfig, ClientError, ClientEvent, ClientTimestamp, NegotiationPolicy,
|
||||
};
|
||||
use irtt_client::{Client, ClientConfig, ClientError, ClientEvent, NegotiationPolicy};
|
||||
use irtt_proto::{echo_packet_len, Params, TimestampFields};
|
||||
|
||||
use support::{
|
||||
@@ -112,7 +110,7 @@ fn server_fill_strict_rejects_removed_fill() {
|
||||
let server = start_open_server(returned, None);
|
||||
let mut client = Client::connect(config_for_params(server.addr, &requested)).unwrap();
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
client.open(),
|
||||
Err(ClientError::NegotiationRejected { .. })
|
||||
));
|
||||
server.join();
|
||||
@@ -129,7 +127,7 @@ fn server_fill_strict_rejects_different_fill_value() {
|
||||
let server = start_open_server(returned, None);
|
||||
let mut client = Client::connect(config_for_params(server.addr, &requested)).unwrap();
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
client.open(),
|
||||
Err(ClientError::NegotiationRejected { .. })
|
||||
));
|
||||
server.join();
|
||||
@@ -145,7 +143,7 @@ fn server_fill_strict_rejects_unexpected_fill_from_server() {
|
||||
let server = start_open_server(returned, None);
|
||||
let mut client = Client::connect(config_for_params(server.addr, &requested)).unwrap();
|
||||
assert!(matches!(
|
||||
client.open(ClientTimestamp::now()),
|
||||
client.open(),
|
||||
Err(ClientError::NegotiationRejected { .. })
|
||||
));
|
||||
server.join();
|
||||
|
||||
@@ -10,9 +10,7 @@ use std::{
|
||||
time::{Duration, SystemTime},
|
||||
};
|
||||
|
||||
use irtt_client::{
|
||||
Client, ClientConfig, ClientEvent, ClientTimestamp, NegotiatedParams, OpenOutcome, SocketConfig,
|
||||
};
|
||||
use irtt_client::{Client, ClientConfig, ClientEvent, NegotiatedParams, OpenOutcome, SocketConfig};
|
||||
use irtt_proto::{
|
||||
compute_hmac_in_place, echo_packet_len, flags, verify_hmac, Clock, Params, ProtoError,
|
||||
ReceivedStats, ServerFill, StampAt, TimestampFields, HMAC_SIZE, MAGIC, PROTOCOL_VERSION,
|
||||
@@ -216,7 +214,7 @@ where
|
||||
{
|
||||
let server = start_one_probe_server(server_params, timestamps, hmac_key);
|
||||
let mut client = Client::connect(build_config(server.addr)).unwrap();
|
||||
let negotiated = assert_started(client.open(ClientTimestamp::now()).unwrap());
|
||||
let negotiated = assert_started(client.open().unwrap());
|
||||
|
||||
let sent_events = client.send_probe().unwrap();
|
||||
assert_eq!(sent_events.len(), 1);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "irtt-proto"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
description = "IRTT protocol encoding and decoding primitives"
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
@@ -12,7 +12,7 @@ keywords = ["irtt", "networking", "latency", "protocol"]
|
||||
categories = ["network-programming"]
|
||||
|
||||
[dependencies]
|
||||
hmac = "0.12"
|
||||
md-5 = "0.10"
|
||||
subtle = "2"
|
||||
thiserror = "2"
|
||||
hmac = "0.13"
|
||||
md-5 = "0.11"
|
||||
subtle = "2.6.1"
|
||||
thiserror = "2.0.18"
|
||||
@@ -1,4 +1,4 @@
|
||||
use hmac::{Hmac, Mac};
|
||||
use hmac::{Hmac, KeyInit, Mac};
|
||||
use md5::Md5;
|
||||
use subtle::ConstantTimeEq;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "irtt-stats"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
description = "Statistics aggregation for irtt-client events"
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
@@ -74,10 +74,6 @@ impl StatsCollector {
|
||||
}
|
||||
|
||||
pub fn process(&mut self, event: &ClientEvent) -> EventStatsUpdate {
|
||||
self.process_with_update(event)
|
||||
}
|
||||
|
||||
pub fn process_with_update(&mut self, event: &ClientEvent) -> EventStatsUpdate {
|
||||
let Some(window_event) = WindowEvent::from_client_event(event) else {
|
||||
return EventStatsUpdate::default();
|
||||
};
|
||||
@@ -146,8 +142,8 @@ pub struct EventStatsUpdate {
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct IpdvPairUpdate {
|
||||
pub previous_logical_seq: u64,
|
||||
pub current_logical_seq: u64,
|
||||
pub previous_seq: u32,
|
||||
pub current_seq: u32,
|
||||
pub rtt_ipdv: Duration,
|
||||
pub send_ipdv: Option<Duration>,
|
||||
pub receive_ipdv: Option<Duration>,
|
||||
@@ -301,9 +297,9 @@ struct CoreStats {
|
||||
send_delay: MetricU64,
|
||||
receive_delay: MetricU64,
|
||||
server_processing: MetricU64,
|
||||
samples: HashMap<u64, UniqueSample>,
|
||||
sample_order: VecDeque<u64>,
|
||||
ipdv_pairs: HashSet<u64>,
|
||||
samples: HashMap<u32, UniqueSample>,
|
||||
sample_order: VecDeque<u32>,
|
||||
ipdv_pairs: HashSet<u32>,
|
||||
}
|
||||
|
||||
impl CoreStats {
|
||||
@@ -385,7 +381,7 @@ impl CoreStats {
|
||||
self.receive_delay.push(delay);
|
||||
}
|
||||
|
||||
let seq = sample.logical_seq;
|
||||
let seq = sample.seq;
|
||||
if self.samples.insert(seq, sample).is_none() {
|
||||
self.sample_order.push_back(seq);
|
||||
self.enforce_sequence_limit();
|
||||
@@ -434,7 +430,7 @@ impl CoreStats {
|
||||
}
|
||||
}
|
||||
|
||||
fn try_ipdv_pair(&mut self, current_seq: u64) -> Option<IpdvPairUpdate> {
|
||||
fn try_ipdv_pair(&mut self, current_seq: u32) -> Option<IpdvPairUpdate> {
|
||||
let previous_seq = current_seq.checked_sub(1)?;
|
||||
|
||||
if !self.ipdv_pairs.insert(current_seq) {
|
||||
@@ -468,8 +464,8 @@ impl CoreStats {
|
||||
}
|
||||
|
||||
Some(IpdvPairUpdate {
|
||||
previous_logical_seq: previous_seq,
|
||||
current_logical_seq: current_seq,
|
||||
previous_seq,
|
||||
current_seq,
|
||||
rtt_ipdv: Duration::from_nanos(rtt_ipdv),
|
||||
send_ipdv: send_ipdv.map(Duration::from_nanos),
|
||||
receive_ipdv: receive_ipdv.map(Duration::from_nanos),
|
||||
@@ -565,7 +561,7 @@ impl WindowEvent {
|
||||
timer_error_ns: duration_ns_u64(*timer_error),
|
||||
}),
|
||||
ClientEvent::EchoReply {
|
||||
logical_seq,
|
||||
seq,
|
||||
sent_at,
|
||||
received_at,
|
||||
rtt,
|
||||
@@ -578,7 +574,7 @@ impl WindowEvent {
|
||||
at: received_at.mono,
|
||||
is_late: false,
|
||||
sample: Box::new(UniqueSample::new(
|
||||
*logical_seq,
|
||||
*seq,
|
||||
*sent_at,
|
||||
*received_at,
|
||||
*rtt,
|
||||
@@ -589,7 +585,7 @@ impl WindowEvent {
|
||||
)),
|
||||
}),
|
||||
ClientEvent::LateReply {
|
||||
logical_seq: Some(logical_seq),
|
||||
seq,
|
||||
sent_at: Some(sent_at),
|
||||
received_at,
|
||||
rtt: Some(rtt),
|
||||
@@ -602,7 +598,7 @@ impl WindowEvent {
|
||||
at: received_at.mono,
|
||||
is_late: true,
|
||||
sample: Box::new(UniqueSample::new(
|
||||
*logical_seq,
|
||||
*seq,
|
||||
*sent_at,
|
||||
*received_at,
|
||||
*rtt,
|
||||
@@ -619,7 +615,7 @@ impl WindowEvent {
|
||||
at: received_at.mono,
|
||||
}),
|
||||
ClientEvent::EchoLoss { timeout_at, .. } => Some(Self::Loss { at: *timeout_at }),
|
||||
ClientEvent::Warning { .. } => Some(Self::Warning { at: Instant::now() }),
|
||||
ClientEvent::Warning { at, .. } => Some(Self::Warning { at: at.mono }),
|
||||
ClientEvent::SessionStarted { .. }
|
||||
| ClientEvent::NoTestCompleted { .. }
|
||||
| ClientEvent::SessionClosed { .. } => None,
|
||||
@@ -640,7 +636,7 @@ impl WindowEvent {
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
struct UniqueSample {
|
||||
logical_seq: u64,
|
||||
seq: u32,
|
||||
bytes: usize,
|
||||
rtt_primary_ns: i128,
|
||||
rtt_raw_ns: u64,
|
||||
@@ -663,7 +659,7 @@ struct UniqueSample {
|
||||
impl UniqueSample {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn new(
|
||||
logical_seq: u64,
|
||||
seq: u32,
|
||||
sent_at: ClientTimestamp,
|
||||
received_at: ClientTimestamp,
|
||||
rtt: RttSample,
|
||||
@@ -673,7 +669,7 @@ impl UniqueSample {
|
||||
bytes: usize,
|
||||
) -> Self {
|
||||
Self {
|
||||
logical_seq,
|
||||
seq,
|
||||
bytes,
|
||||
rtt_primary_ns: signed_duration_ns(rtt.effective_signed),
|
||||
rtt_raw_ns: duration_ns_u64(rtt.raw),
|
||||
@@ -1074,10 +1070,9 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
fn sent(seq: u32, logical_seq: u64, sent_at: ClientTimestamp) -> ClientEvent {
|
||||
fn sent(seq: u32, sent_at: ClientTimestamp) -> ClientEvent {
|
||||
ClientEvent::EchoSent {
|
||||
seq,
|
||||
logical_seq,
|
||||
remote: "127.0.0.1:2112".parse().unwrap(),
|
||||
scheduled_at: sent_at.mono,
|
||||
sent_at,
|
||||
@@ -1087,24 +1082,23 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
fn reply(logical_seq: u64, raw_ms: u64, effective_ms: i128) -> ClientEvent {
|
||||
let sent_at = ts(logical_seq * 10);
|
||||
fn reply(seq: u32, raw_ms: u64, effective_ms: i128) -> ClientEvent {
|
||||
let sent_at = ts(seq as u64 * 10);
|
||||
let received_at = ClientTimestamp {
|
||||
mono: sent_at.mono + Duration::from_millis(raw_ms),
|
||||
wall: sent_at.wall + Duration::from_millis(raw_ms),
|
||||
};
|
||||
ClientEvent::EchoReply {
|
||||
seq: logical_seq as u32,
|
||||
logical_seq,
|
||||
seq,
|
||||
remote: "127.0.0.1:2112".parse().unwrap(),
|
||||
sent_at,
|
||||
received_at,
|
||||
rtt: rtt(raw_ms, effective_ms),
|
||||
server_timing: Some(ServerTiming {
|
||||
receive_wall_ns: Some(system_time_ns(sent_at.wall).unwrap() as i64 + 1_000_000),
|
||||
receive_mono_ns: Some(logical_seq as i64 * 10_000_000 + 1_000_000),
|
||||
receive_mono_ns: Some(seq as i64 * 10_000_000 + 1_000_000),
|
||||
send_wall_ns: Some(system_time_ns(sent_at.wall).unwrap() as i64 + 2_000_000),
|
||||
send_mono_ns: Some(logical_seq as i64 * 10_000_000 + 2_000_000),
|
||||
send_mono_ns: Some(seq as i64 * 10_000_000 + 2_000_000),
|
||||
midpoint_wall_ns: None,
|
||||
midpoint_mono_ns: None,
|
||||
processing: Some(Duration::from_millis(1)),
|
||||
@@ -1114,7 +1108,7 @@ mod tests {
|
||||
server_to_client: Some(Duration::from_millis(2)),
|
||||
}),
|
||||
received_stats: Some(ReceivedStatsSample {
|
||||
count: Some((logical_seq + 1) as u32),
|
||||
count: Some(seq + 1),
|
||||
window: Some(0xff),
|
||||
}),
|
||||
bytes: 64,
|
||||
@@ -1122,7 +1116,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
fn late_reply(logical_seq: u64, raw_ms: u64, effective_ms: i128) -> ClientEvent {
|
||||
fn late_reply(seq: u32, raw_ms: u64, effective_ms: i128) -> ClientEvent {
|
||||
let ClientEvent::EchoReply {
|
||||
seq,
|
||||
remote,
|
||||
@@ -1135,13 +1129,12 @@ mod tests {
|
||||
bytes,
|
||||
packet_meta,
|
||||
..
|
||||
} = reply(logical_seq, raw_ms, effective_ms)
|
||||
} = reply(seq, raw_ms, effective_ms)
|
||||
else {
|
||||
unreachable!();
|
||||
};
|
||||
ClientEvent::LateReply {
|
||||
seq,
|
||||
logical_seq: Some(logical_seq),
|
||||
highest_seen: seq + 1,
|
||||
remote,
|
||||
sent_at: Some(sent_at),
|
||||
@@ -1191,7 +1184,7 @@ mod tests {
|
||||
#[test]
|
||||
fn continuous_mode_bounds_sequence_tracking() {
|
||||
let mut collector = StatsCollector::new(StatsConfig::continuous());
|
||||
for seq in 0..(CONTINUOUS_SEQUENCE_LIMIT as u64 + 8) {
|
||||
for seq in 0..(CONTINUOUS_SEQUENCE_LIMIT as u32 + 8) {
|
||||
collector.process(&reply(seq, 10, 10));
|
||||
}
|
||||
|
||||
@@ -1219,8 +1212,8 @@ mod tests {
|
||||
#[test]
|
||||
fn late_unique_counts_and_duplicates_do_not_update_measurements() {
|
||||
let mut collector = StatsCollector::new(StatsConfig::finite());
|
||||
collector.process(&sent(0, 0, ts(0)));
|
||||
collector.process(&sent(1, 1, ts(10)));
|
||||
collector.process(&sent(0, ts(0)));
|
||||
collector.process(&sent(1, ts(10)));
|
||||
collector.process(&reply(1, 10, 9));
|
||||
collector.process(&late_reply(0, 20, 19));
|
||||
collector.process(&ClientEvent::DuplicateReply {
|
||||
@@ -1244,11 +1237,10 @@ mod tests {
|
||||
#[test]
|
||||
fn final_loss_uses_sent_minus_unique_replies_not_echo_loss_events() {
|
||||
let mut collector = StatsCollector::new(StatsConfig::finite());
|
||||
collector.process(&sent(0, 0, ts(0)));
|
||||
collector.process(&sent(1, 1, ts(10)));
|
||||
collector.process(&sent(0, ts(0)));
|
||||
collector.process(&sent(1, ts(10)));
|
||||
collector.process(&ClientEvent::EchoLoss {
|
||||
seq: 0,
|
||||
logical_seq: 0,
|
||||
sent_at: ts(0),
|
||||
timeout_at: Instant::now(),
|
||||
});
|
||||
@@ -1267,14 +1259,14 @@ mod tests {
|
||||
|
||||
fn assert_one_ipdv_pair(
|
||||
update: &EventStatsUpdate,
|
||||
previous_logical_seq: u64,
|
||||
current_logical_seq: u64,
|
||||
previous_seq: u32,
|
||||
current_seq: u32,
|
||||
rtt_ipdv: Duration,
|
||||
) -> &IpdvPairUpdate {
|
||||
assert_eq!(update.ipdv_pairs.len(), 1, "{update:?}");
|
||||
let pair = &update.ipdv_pairs[0];
|
||||
assert_eq!(pair.previous_logical_seq, previous_logical_seq);
|
||||
assert_eq!(pair.current_logical_seq, current_logical_seq);
|
||||
assert_eq!(pair.previous_seq, previous_seq);
|
||||
assert_eq!(pair.current_seq, current_seq);
|
||||
assert_eq!(pair.rtt_ipdv, rtt_ipdv);
|
||||
pair
|
||||
}
|
||||
@@ -1344,12 +1336,12 @@ mod tests {
|
||||
assert!(fill.contributed_sample);
|
||||
assert_eq!(fill.ipdv_pairs.len(), 2);
|
||||
|
||||
assert_eq!(fill.ipdv_pairs[0].previous_logical_seq, 0);
|
||||
assert_eq!(fill.ipdv_pairs[0].current_logical_seq, 1);
|
||||
assert_eq!(fill.ipdv_pairs[0].previous_seq, 0);
|
||||
assert_eq!(fill.ipdv_pairs[0].current_seq, 1);
|
||||
assert_eq!(fill.ipdv_pairs[0].rtt_ipdv, Duration::from_millis(3));
|
||||
|
||||
assert_eq!(fill.ipdv_pairs[1].previous_logical_seq, 1);
|
||||
assert_eq!(fill.ipdv_pairs[1].current_logical_seq, 2);
|
||||
assert_eq!(fill.ipdv_pairs[1].previous_seq, 1);
|
||||
assert_eq!(fill.ipdv_pairs[1].current_seq, 2);
|
||||
assert_eq!(fill.ipdv_pairs[1].rtt_ipdv, Duration::from_millis(7));
|
||||
|
||||
let snapshot = collector.cumulative();
|
||||
@@ -1363,7 +1355,6 @@ mod tests {
|
||||
collector.process(&reply(0, 10, 9));
|
||||
collector.process(&ClientEvent::LateReply {
|
||||
seq: 9,
|
||||
logical_seq: None,
|
||||
highest_seen: 10,
|
||||
remote: "127.0.0.1:2112".parse().unwrap(),
|
||||
sent_at: None,
|
||||
@@ -1389,7 +1380,7 @@ mod tests {
|
||||
rolling_count: Some(2),
|
||||
rolling_time: None,
|
||||
});
|
||||
collector.process(&sent(0, 0, ts(0)));
|
||||
collector.process(&sent(0, ts(0)));
|
||||
collector.process(&reply(0, 10, 10));
|
||||
collector.process(&reply(1, 20, 20));
|
||||
|
||||
@@ -1406,9 +1397,9 @@ mod tests {
|
||||
rolling_count: None,
|
||||
rolling_time: Some(Duration::from_millis(15)),
|
||||
});
|
||||
collector.process(&sent(0, 0, ts(0)));
|
||||
collector.process(&sent(1, 1, ts(10)));
|
||||
collector.process(&sent(2, 2, ts(30)));
|
||||
collector.process(&sent(0, ts(0)));
|
||||
collector.process(&sent(1, ts(10)));
|
||||
collector.process(&sent(2, ts(30)));
|
||||
|
||||
let rolling = collector.rolling_time().unwrap();
|
||||
assert_eq!(rolling.packets.packets_sent, 1);
|
||||
@@ -1420,7 +1411,7 @@ mod tests {
|
||||
assert_eq!(empty.loss.packet_loss_percent, 0.0);
|
||||
|
||||
let mut collector = StatsCollector::new(StatsConfig::finite());
|
||||
collector.process(&sent(0, 0, ts(0)));
|
||||
collector.process(&sent(0, ts(0)));
|
||||
let all_lost = collector.summary();
|
||||
assert_eq!(all_lost.loss.lost_packets, 1);
|
||||
assert_eq!(all_lost.loss.packet_loss_percent, 100.0);
|
||||
@@ -1429,8 +1420,8 @@ mod tests {
|
||||
#[test]
|
||||
fn directional_loss_uses_server_received_count_when_available() {
|
||||
let mut collector = StatsCollector::new(StatsConfig::finite());
|
||||
collector.process(&sent(0, 0, ts(0)));
|
||||
collector.process(&sent(1, 1, ts(10)));
|
||||
collector.process(&sent(0, ts(0)));
|
||||
collector.process(&sent(1, ts(10)));
|
||||
collector.process(&reply(0, 10, 10));
|
||||
|
||||
let loss = collector.summary().loss;
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
# cargo-deny policy for irtt-rs.
|
||||
#
|
||||
# Goals:
|
||||
# - Check the full dependency graph with all features enabled.
|
||||
# - Fail on known vulnerable/yanked crates.
|
||||
# - Keep accepted licenses narrow and explicit.
|
||||
# - Warn on duplicate crate versions for now.
|
||||
# - Deny unexpected registries or git dependencies.
|
||||
# - If git dependencies are ever allowed, require exact commit pins.
|
||||
|
||||
[graph]
|
||||
all-features = true
|
||||
no-default-features = false
|
||||
targets = []
|
||||
|
||||
[output]
|
||||
feature-depth = 1
|
||||
|
||||
[advisories]
|
||||
# Yanked crates are usually not an immediate vuln, but they are almost never
|
||||
# something we want to keep resolving in a public crate.
|
||||
yanked = "deny"
|
||||
|
||||
# Unmaintained advisories are useful, but failing on every transitive
|
||||
# unmaintained crate can become dependency-tree hostage negotiation.
|
||||
# Direct/workspace dependencies should still be treated seriously.
|
||||
unmaintained = "workspace"
|
||||
|
||||
# Keep this explicit. cargo-deny's current default is also workspace, but this
|
||||
# makes the policy obvious.
|
||||
unsound = "workspace"
|
||||
|
||||
ignore = [
|
||||
# Example:
|
||||
# { id = "RUSTSEC-0000-0000", reason = "Not reachable: explain why." },
|
||||
# { crate = "some-yanked-crate@1.2.3", reason = "Temporary until upstream releases a replacement." },
|
||||
]
|
||||
|
||||
[licenses]
|
||||
confidence-threshold = 0.8
|
||||
|
||||
allow = [
|
||||
"MIT",
|
||||
"Apache-2.0",
|
||||
"Unicode-3.0",
|
||||
"BSD-3-Clause",
|
||||
]
|
||||
|
||||
exceptions = [
|
||||
# Example:
|
||||
# { crate = "some-crate", allow = ["BSD-2-Clause"] },
|
||||
]
|
||||
|
||||
[licenses.private]
|
||||
ignore = false
|
||||
registries = []
|
||||
|
||||
[bans]
|
||||
# Keep as warn initially. Making this deny too early is how you end up doing
|
||||
# dependency bonsai instead of actual work.
|
||||
multiple-versions = "warn"
|
||||
|
||||
# Consider changing this to "deny" later once you've confirmed nothing relies
|
||||
# on wildcard requirements.
|
||||
wildcards = "allow"
|
||||
|
||||
highlight = "all"
|
||||
|
||||
workspace-default-features = "allow"
|
||||
external-default-features = "allow"
|
||||
|
||||
allow = []
|
||||
|
||||
deny = [
|
||||
# Example:
|
||||
# { crate = "openssl", reason = "Prefer rustls where TLS is needed." },
|
||||
]
|
||||
|
||||
skip = [
|
||||
# Example:
|
||||
# { crate = "windows-sys@0.52.0", reason = "Transitive duplicate; waiting on upstream." },
|
||||
]
|
||||
|
||||
skip-tree = [
|
||||
# Example:
|
||||
# { crate = "some-large-transitive-root@1.2.3", reason = "Temporary duplicate tree exception." },
|
||||
]
|
||||
|
||||
[sources]
|
||||
# Unknown dependency sources should fail. If we need a git patch later,
|
||||
# we add it explicitly and remove it again when upstream releases.
|
||||
unknown-registry = "deny"
|
||||
unknown-git = "deny"
|
||||
|
||||
# If git dependencies are ever allowed, require exact commit pins.
|
||||
# cargo-deny's docs list "rev" as the most specific git source requirement.
|
||||
required-git-spec = "rev"
|
||||
|
||||
# crates.io registry. cargo-deny's docs say this is also the default when
|
||||
# allow-registry is omitted, but keeping it explicit is fine.
|
||||
allow-registry = [
|
||||
"https://github.com/rust-lang/crates.io-index",
|
||||
]
|
||||
|
||||
allow-git = []
|
||||
|
||||
[sources.allow-org]
|
||||
github = []
|
||||
gitlab = []
|
||||
bitbucket = []
|
||||
@@ -0,0 +1,13 @@
|
||||
[workspace]
|
||||
members = ["cargo:."]
|
||||
|
||||
# Config for 'dist'
|
||||
[dist]
|
||||
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
|
||||
cargo-dist-version = "0.31.0"
|
||||
# CI backends to support
|
||||
ci = "github"
|
||||
# The installers to generate for each app
|
||||
installers = []
|
||||
# Target platforms to build apps for (Rust target-triple syntax)
|
||||
targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]
|
||||
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
|
||||
"extends": ["config:recommended", "helpers:pinGitHubActionDigests"],
|
||||
|
||||
"timezone": "Asia/Jakarta",
|
||||
"schedule": ["before 10am on monday"],
|
||||
|
||||
"dependencyDashboard": true,
|
||||
"dependencyDashboardTitle": "Renovate Dashboard",
|
||||
|
||||
"semanticCommits": "enabled",
|
||||
"semanticCommitType": "chore",
|
||||
"semanticCommitScope": "deps",
|
||||
|
||||
"prConcurrentLimit": 4,
|
||||
"prHourlyLimit": 1,
|
||||
|
||||
"rebaseWhen": "conflicted",
|
||||
"rangeStrategy": "bump",
|
||||
|
||||
"labels": ["dependencies"],
|
||||
|
||||
"lockFileMaintenance": {
|
||||
"enabled": true,
|
||||
"schedule": ["before 10am on monday"],
|
||||
"commitMessageAction": "maintain",
|
||||
"commitMessageTopic": "Cargo lockfile"
|
||||
},
|
||||
|
||||
"packageRules": [
|
||||
{
|
||||
"description": "Never automerge Cargo updates by default",
|
||||
"matchManagers": ["cargo"],
|
||||
"automerge": false
|
||||
},
|
||||
{
|
||||
"description": "Group RustCrypto updates together",
|
||||
"matchManagers": ["cargo"],
|
||||
"matchPackageNames": ["hmac", "md-5"],
|
||||
"groupName": "RustCrypto dependencies",
|
||||
"commitMessageTopic": "RustCrypto dependencies"
|
||||
},
|
||||
{
|
||||
"description": "Keep socket/platform dependencies together but reviewed",
|
||||
"matchManagers": ["cargo"],
|
||||
"matchPackageNames": ["socket2", "libc"],
|
||||
"groupName": "socket dependencies",
|
||||
"commitMessageTopic": "socket dependencies"
|
||||
},
|
||||
{
|
||||
"description": "Group GitHub Actions updates",
|
||||
"matchManagers": ["github-actions"],
|
||||
"groupName": "GitHub Actions",
|
||||
"commitMessageTopic": "GitHub Actions"
|
||||
},
|
||||
{
|
||||
"description": "Automerge patch and minor GitHub Actions updates",
|
||||
"matchManagers": ["github-actions"],
|
||||
"matchUpdateTypes": ["patch", "minor"],
|
||||
"automerge": true,
|
||||
"platformAutomerge": true
|
||||
},
|
||||
{
|
||||
"description": "Never automerge major updates",
|
||||
"matchUpdateTypes": ["major"],
|
||||
"automerge": false
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user