Compare commits
53
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8822adc400 | ||
|
|
8c923f373d | ||
|
|
8267089733 | ||
|
|
6ad41931a1 | ||
|
|
b94742c62a | ||
|
|
7e8213556f | ||
|
|
df7e9ffbab | ||
|
|
68b34a587f | ||
|
|
b7bbed6e5e | ||
|
|
0e2e2f9d38 | ||
|
|
e80940ba6d | ||
|
|
480976b666 | ||
|
|
ac349a1897 | ||
|
|
a925e60f36 | ||
|
|
c7b283d761 | ||
|
|
89c7d75947 | ||
|
|
afedfbeb65 | ||
|
|
f51ff19f04 | ||
|
|
60fdea4dff | ||
|
|
3016f4b887 | ||
|
|
52a5ab2dfe | ||
|
|
fca0967563 | ||
|
|
b7b66fc1f4 | ||
|
|
305a182001 | ||
|
|
64e002c0d0 | ||
|
|
817cc304e6 | ||
|
|
e27bab1944 | ||
|
|
fbb971b47d | ||
|
|
3fbc96b15f | ||
|
|
c199d63c93 | ||
|
|
2afa1bba35 | ||
|
|
d03effd600 | ||
|
|
6103d2dae4 | ||
|
|
efe9eff036 | ||
|
|
bb94b42d24 | ||
|
|
de8d7e3aeb | ||
|
|
746636b59a | ||
|
|
83e02c6e1c | ||
|
|
6d4849899e | ||
|
|
7254aa5cf9 | ||
|
|
5b0854920d | ||
|
|
4c9fe15201 | ||
|
|
5872f40d3e | ||
|
|
8fb051d48f | ||
|
|
a0535357c7 | ||
|
|
91d773c77e | ||
|
|
083d464067 | ||
|
|
f0eae4b2ce | ||
|
|
a6067910ad | ||
|
|
ffd7b0beb7 | ||
|
|
377fb3be2d | ||
|
|
d765bef002 | ||
|
|
86b13f948e |
No files matched your search
@@ -0,0 +1,114 @@
|
|||||||
|
name: Build binaries
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
branches: [master]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
env:
|
||||||
|
CARGO_TERM_COLOR: always
|
||||||
|
# Measure before stripping; the packaged copy is stripped below.
|
||||||
|
CARGO_PROFILE_RELEASE_STRIP: none
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build (${{ matrix.target }})
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 60
|
||||||
|
env:
|
||||||
|
TARGET: ${{ matrix.target }}
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
# Supported by Gitea 28; bound concurrent cross-build memory use.
|
||||||
|
max-parallel: 2
|
||||||
|
matrix:
|
||||||
|
target:
|
||||||
|
- x86_64-musl
|
||||||
|
- i686-musl
|
||||||
|
- arm-musleabi
|
||||||
|
- arm-musleabihf
|
||||||
|
- armv7-musleabi
|
||||||
|
- armv7-musleabihf
|
||||||
|
- aarch64-musl
|
||||||
|
- mips-musl
|
||||||
|
- mipsel-musl
|
||||||
|
- mips64-muslabi64
|
||||||
|
- mips64el-muslabi64
|
||||||
|
- riscv64gc-musl
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: builtin:checkout
|
||||||
|
|
||||||
|
- name: Configure Rust directories
|
||||||
|
# Cross remote's symlink traversal skips hidden directories under /root.
|
||||||
|
run: |
|
||||||
|
echo "CARGO_HOME=$RUNNER_TEMP/cargo" >> "$GITHUB_ENV"
|
||||||
|
echo "RUSTUP_HOME=$RUNNER_TEMP/rustup" >> "$GITHUB_ENV"
|
||||||
|
echo "$RUNNER_TEMP/cargo/bin" >> "$GITHUB_PATH"
|
||||||
|
|
||||||
|
- name: Install Rust toolchain
|
||||||
|
uses: actions-rust-lang/setup-rust-toolchain@ecabd13d1c56bd1345c230e542e9144811ad706f # v2
|
||||||
|
with:
|
||||||
|
toolchain: ${{ startsWith(matrix.target, 'mips') && 'nightly' || 'stable' }}
|
||||||
|
cache: false
|
||||||
|
build-warnings: warn
|
||||||
|
|
||||||
|
- name: Install cross and binary tools
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y --no-install-recommends binutils llvm
|
||||||
|
cargo install --git https://github.com/cross-rs/cross --locked cross
|
||||||
|
echo "RUST_TARGET=${TARGET%-*}-unknown-linux-${TARGET#*-}" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Build release binary
|
||||||
|
env:
|
||||||
|
# MIPS build-std lacks Rust's bundled CRT objects; use the cross GCC copies.
|
||||||
|
RUSTFLAGS: ${{ startsWith(matrix.target, 'mips') && '-C target-feature=+crt-static -C link-self-contained=no' || '-C target-feature=+crt-static' }}
|
||||||
|
# Copy toolchains and sources instead of translating nested bind mounts.
|
||||||
|
CROSS_REMOTE: "true"
|
||||||
|
# Cross's per-artifact JSON capture hides compiler diagnostics.
|
||||||
|
CROSS_REMOTE_COPY_FULL_TARGET_DIR: ${{ startsWith(matrix.target, 'mips') && 'true' || 'false' }}
|
||||||
|
run: |
|
||||||
|
cross build --release --locked --target "$RUST_TARGET"
|
||||||
|
|
||||||
|
- name: Verify, package, and summarize binary
|
||||||
|
run: |
|
||||||
|
binary="target/${RUST_TARGET}/release/sqm-autorate-rust"
|
||||||
|
readelf --program-headers "$binary" > /tmp/program-headers.txt
|
||||||
|
readelf --dynamic "$binary" > /tmp/dynamic-section.txt
|
||||||
|
if grep -q INTERP /tmp/program-headers.txt || grep -q NEEDED /tmp/dynamic-section.txt; then
|
||||||
|
echo "Binary is not statically linked" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
mkdir -p dist
|
||||||
|
stripped="dist/sqm-autorate-rust-${TARGET}"
|
||||||
|
artifact="${stripped}.tar.gz"
|
||||||
|
cp "$binary" "$stripped"
|
||||||
|
llvm-strip --strip-all "$stripped"
|
||||||
|
# Tar preserves executable permissions when downloading the artifact.
|
||||||
|
tar -czf "$artifact" -C dist "sqm-autorate-rust-${TARGET}"
|
||||||
|
|
||||||
|
size() {
|
||||||
|
stat -c %s "$1" | numfmt --to=iec-i --suffix=B --format='%.1f'
|
||||||
|
}
|
||||||
|
{
|
||||||
|
echo '| Target | Unstripped | Stripped | Compressed |'
|
||||||
|
echo '|:--|--:|--:|--:|'
|
||||||
|
printf '| %s | %s | %s | %s |\n' \
|
||||||
|
"$TARGET" "$(size "$binary")" "$(size "$stripped")" "$(size "$artifact")"
|
||||||
|
} >> "$GITHUB_STEP_SUMMARY"
|
||||||
|
|
||||||
|
- name: Upload binary
|
||||||
|
# Use the v3 artifact protocol supported by Gitea.
|
||||||
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||||
|
with:
|
||||||
|
name: sqm-autorate-rust-${{ matrix.target }}
|
||||||
|
path: dist/sqm-autorate-rust-${{ matrix.target }}.tar.gz
|
||||||
|
if-no-files-found: error
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
name: Rust CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
pull_request:
|
||||||
|
branches: [master]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
env:
|
||||||
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
fmt:
|
||||||
|
name: cargo fmt
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Install Rust toolchain
|
||||||
|
uses: actions-rust-lang/setup-rust-toolchain@ecabd13d1c56bd1345c230e542e9144811ad706f # v2
|
||||||
|
with:
|
||||||
|
components: rustfmt
|
||||||
|
cache: false
|
||||||
|
- name: Check formatting
|
||||||
|
run: cargo fmt --all -- --check
|
||||||
|
|
||||||
|
clippy:
|
||||||
|
name: cargo clippy
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 20
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Install Rust toolchain
|
||||||
|
uses: actions-rust-lang/setup-rust-toolchain@ecabd13d1c56bd1345c230e542e9144811ad706f # v2
|
||||||
|
with:
|
||||||
|
components: clippy
|
||||||
|
cache: false
|
||||||
|
- name: Run clippy with all features
|
||||||
|
run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
|
||||||
|
- name: Run clippy without default features
|
||||||
|
run: cargo clippy --workspace --all-targets --no-default-features --features toml --locked -- -D warnings
|
||||||
|
|
||||||
|
verify:
|
||||||
|
name: cargo ${{ matrix.task }} (${{ matrix.target }})
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 30
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- task: check
|
||||||
|
target: x86_64-unknown-linux-gnu
|
||||||
|
musl: false
|
||||||
|
- task: test
|
||||||
|
target: x86_64-unknown-linux-gnu
|
||||||
|
musl: false
|
||||||
|
- task: check
|
||||||
|
target: x86_64-unknown-linux-musl
|
||||||
|
musl: true
|
||||||
|
- task: test
|
||||||
|
target: x86_64-unknown-linux-musl
|
||||||
|
musl: true
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Install musl toolchain
|
||||||
|
if: matrix.musl
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install --no-install-recommends musl-tools
|
||||||
|
- name: Install Rust toolchain
|
||||||
|
uses: actions-rust-lang/setup-rust-toolchain@ecabd13d1c56bd1345c230e542e9144811ad706f # v2
|
||||||
|
with:
|
||||||
|
target: ${{ matrix.target }}
|
||||||
|
cache: false
|
||||||
|
- name: Run ${{ matrix.task }} with all features
|
||||||
|
run: cargo ${{ matrix.task }} --workspace --all-targets --all-features --target ${{ matrix.target }} --locked
|
||||||
|
- name: Run ${{ matrix.task }} without default features
|
||||||
|
run: cargo ${{ matrix.task }} --workspace --all-targets --no-default-features --features toml --target ${{ matrix.target }} --locked
|
||||||
|
|
||||||
|
docs:
|
||||||
|
name: cargo doc
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 20
|
||||||
|
env:
|
||||||
|
RUSTDOCFLAGS: -D warnings
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Install Rust toolchain
|
||||||
|
uses: actions-rust-lang/setup-rust-toolchain@ecabd13d1c56bd1345c230e542e9144811ad706f # v2
|
||||||
|
with:
|
||||||
|
cache: false
|
||||||
|
- name: Check documentation
|
||||||
|
run: cargo doc --workspace --all-features --no-deps --locked
|
||||||
|
- name: Run doctests
|
||||||
|
run: cargo test --workspace --doc --all-features --locked
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
name: Supply chain
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
pull_request:
|
||||||
|
branches: [master]
|
||||||
|
schedule:
|
||||||
|
- cron: "41 2 * * 1"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
env:
|
||||||
|
ACTIONLINT_VERSION: 1.7.7
|
||||||
|
CARGO_DENY_VERSION: 0.20.2
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
cargo-deny:
|
||||||
|
name: cargo-deny ${{ matrix.checks }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 15
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- checks: advisories
|
||||||
|
continue-on-error: true
|
||||||
|
- checks: bans licenses sources
|
||||||
|
continue-on-error: false
|
||||||
|
continue-on-error: ${{ matrix.continue-on-error }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Install cargo-deny
|
||||||
|
run: cargo install cargo-deny --version "${CARGO_DENY_VERSION}" --locked
|
||||||
|
- name: Run cargo-deny
|
||||||
|
run: cargo deny --manifest-path Cargo.toml --all-features check ${{ matrix.checks }}
|
||||||
|
|
||||||
|
actionlint:
|
||||||
|
name: actionlint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Install actionlint
|
||||||
|
run: go install "github.com/rhysd/actionlint/cmd/actionlint@v${ACTIONLINT_VERSION}"
|
||||||
|
- name: Check workflow syntax
|
||||||
|
# actionlint does not recognize Gitea's built-in checkout action.
|
||||||
|
run: |
|
||||||
|
"$(go env GOPATH)/bin/actionlint" \
|
||||||
|
-ignore 'specifying action "builtin:checkout" in invalid format' \
|
||||||
|
.gitea/workflows/build.yml \
|
||||||
|
.gitea/workflows/ci.yml \
|
||||||
|
.gitea/workflows/supply-chain.yml \
|
||||||
|
.github/workflows/actions-security.yml \
|
||||||
|
.github/workflows/ci-arm.yml \
|
||||||
|
.github/workflows/devskim.yml \
|
||||||
|
.github/workflows/osv-scanner.yml \
|
||||||
|
.github/workflows/rust-clippy.yml
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
name: GitHub Actions Security
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
pull_request:
|
||||||
|
branches: [master]
|
||||||
|
schedule:
|
||||||
|
- cron: "11 3 * * 1"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
zizmor:
|
||||||
|
name: zizmor
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
actions: read
|
||||||
|
security-events: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Run zizmor
|
||||||
|
uses: zizmorcore/zizmor-action@cc914d7f3750a2d13d75c7f184a1060aa0e9d482 # v0.6.4
|
||||||
|
with:
|
||||||
|
persona: regular
|
||||||
|
inputs: |
|
||||||
|
.github/workflows
|
||||||
|
.gitea/workflows
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
name: Build
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ "master" ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ "master" ]
|
|
||||||
|
|
||||||
env:
|
|
||||||
CARGO_TERM_COLOR: always
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v7
|
|
||||||
- name: Install Mold
|
|
||||||
run: sudo apt install mold
|
|
||||||
- name: Build
|
|
||||||
run: cargo build --verbose
|
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
name: Rust ARM CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
pull_request:
|
||||||
|
branches: [master]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
env:
|
||||||
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
verify:
|
||||||
|
name: cargo ${{ matrix.task }} (${{ matrix.target }})
|
||||||
|
runs-on: ubuntu-24.04-arm
|
||||||
|
timeout-minutes: 30
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- task: check
|
||||||
|
target: aarch64-unknown-linux-gnu
|
||||||
|
musl: false
|
||||||
|
- task: test
|
||||||
|
target: aarch64-unknown-linux-gnu
|
||||||
|
musl: false
|
||||||
|
- task: check
|
||||||
|
target: aarch64-unknown-linux-musl
|
||||||
|
musl: true
|
||||||
|
- task: test
|
||||||
|
target: aarch64-unknown-linux-musl
|
||||||
|
musl: true
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Install musl toolchain
|
||||||
|
if: matrix.musl
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install --no-install-recommends musl-tools
|
||||||
|
- name: Install Rust toolchain
|
||||||
|
uses: actions-rust-lang/setup-rust-toolchain@ecabd13d1c56bd1345c230e542e9144811ad706f # v2
|
||||||
|
with:
|
||||||
|
target: ${{ matrix.target }}
|
||||||
|
cache: false
|
||||||
|
- name: Run ${{ matrix.task }} with all features
|
||||||
|
run: cargo ${{ matrix.task }} --workspace --all-targets --all-features --target ${{ matrix.target }} --locked
|
||||||
|
- name: Run ${{ matrix.task }} without default features
|
||||||
|
run: cargo ${{ matrix.task }} --workspace --all-targets --no-default-features --features toml --target ${{ matrix.target }} --locked
|
||||||
@@ -1,33 +1,29 @@
|
|||||||
# This workflow uses actions that are not certified by GitHub.
|
# This workflow uploads SARIF results to GitHub Code Scanning.
|
||||||
# They are provided by a third-party and are governed by
|
|
||||||
# separate terms of service, privacy policy, and support
|
|
||||||
# documentation.
|
|
||||||
|
|
||||||
name: DevSkim
|
name: DevSkim
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "master" ]
|
branches: [master]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "master" ]
|
branches: [master]
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '18 0 * * 4'
|
- cron: '18 0 * * 4'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
name: DevSkim
|
name: DevSkim
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
actions: read
|
|
||||||
contents: read
|
contents: read
|
||||||
security-events: write
|
security-events: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v7
|
uses: actions/checkout@v7
|
||||||
|
|
||||||
- name: Run DevSkim scanner
|
- name: Run DevSkim scanner
|
||||||
uses: microsoft/DevSkim-Action@v1
|
uses: microsoft/DevSkim-Action@v1
|
||||||
|
|
||||||
- name: Upload DevSkim scan results to GitHub Security tab
|
- name: Upload DevSkim scan results to GitHub Security tab
|
||||||
uses: github/codeql-action/upload-sarif@v4
|
uses: github/codeql-action/upload-sarif@v4
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -1,55 +1,34 @@
|
|||||||
# Copyright 2023 Google LLC
|
# Copyright 2023 Google LLC
|
||||||
#
|
# Licensed under the Apache License, Version 2.0.
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
name: OSV-Scanner Scheduled Scan
|
name: OSV-Scanner
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: ["master", "v1"]
|
branches: [master, v1]
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "12 12 * * 1"
|
- cron: "12 12 * * 1"
|
||||||
push:
|
push:
|
||||||
branches: ["master", "v1"]
|
branches: [master, v1]
|
||||||
|
|
||||||
# Restrict jobs in this workflow to have no permissions by default; permissions
|
|
||||||
# should be granted per job as needed using a dedicated `permissions` block
|
|
||||||
permissions: {}
|
permissions: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
scan-scheduled:
|
scan-scheduled:
|
||||||
permissions:
|
permissions:
|
||||||
contents: read # to fetch code (actions/checkout)
|
contents: read
|
||||||
security-events: write # for uploading SARIF files
|
security-events: write
|
||||||
actions: read
|
actions: read
|
||||||
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
|
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
|
||||||
# If you want to copy this config, highly suggest pinning this version to a release rather than tracking the main branch
|
uses: google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@v2.7.0
|
||||||
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@v2.5.0"
|
|
||||||
with:
|
with:
|
||||||
# Just scan the root directory and docs, since everything else is fixtures
|
scan-args: ./
|
||||||
scan-args: |-
|
|
||||||
./
|
|
||||||
./docs/
|
|
||||||
scan-pr:
|
scan-pr:
|
||||||
permissions:
|
permissions:
|
||||||
contents: read # to fetch code (actions/checkout)
|
contents: read
|
||||||
security-events: write # for uploading SARIF files
|
security-events: write
|
||||||
actions: read
|
actions: read
|
||||||
if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
|
if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
|
||||||
# If you want to copy this config, highly suggest pinning this version to a release rather than tracking the main branch
|
uses: google/osv-scanner-action/.github/workflows/osv-scanner-reusable-pr.yml@v2.7.0
|
||||||
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable-pr.yml@v2.5.0"
|
|
||||||
with:
|
with:
|
||||||
# Just scan the root directory and docs, since everything else is fixtures
|
scan-args: ./
|
||||||
scan-args: |-
|
|
||||||
./
|
|
||||||
./docs/
|
|
||||||
@@ -1,55 +1,61 @@
|
|||||||
# This workflow uses actions that are not certified by GitHub.
|
name: Clippy SARIF
|
||||||
# They are provided by a third-party and are governed by
|
|
||||||
# separate terms of service, privacy policy, and support
|
|
||||||
# documentation.
|
|
||||||
# rust-clippy is a tool that runs a bunch of lints to catch common
|
|
||||||
# mistakes in your Rust code and help improve your Rust code.
|
|
||||||
# More details at https://github.com/rust-lang/rust-clippy
|
|
||||||
# and https://rust-lang.github.io/rust-clippy/
|
|
||||||
|
|
||||||
name: rust-clippy analyze
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "master" ]
|
branches: [master]
|
||||||
pull_request:
|
|
||||||
# The branches below must be a subset of the branches above
|
|
||||||
branches: [ "master" ]
|
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '28 20 * * 3'
|
- cron: "17 12 * * 4"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
actions: read
|
||||||
|
|
||||||
|
env:
|
||||||
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
rust-clippy-analyze:
|
clippy-sarif:
|
||||||
name: Run rust-clippy analyzing
|
name: Clippy SARIF
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
timeout-minutes: 25
|
||||||
contents: read
|
|
||||||
security-events: write
|
|
||||||
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout
|
||||||
uses: actions/checkout@v7
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
- name: Install Rust toolchain
|
- name: Install Rust toolchain
|
||||||
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #@v1
|
uses: actions-rust-lang/setup-rust-toolchain@ecabd13d1c56bd1345c230e542e9144811ad706f # v2
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
|
||||||
toolchain: stable
|
|
||||||
components: clippy
|
components: clippy
|
||||||
override: true
|
cache: false
|
||||||
|
- name: Install SARIF tools
|
||||||
- name: Install required cargo
|
run: cargo install --locked clippy-sarif sarif-fmt
|
||||||
run: cargo install clippy-sarif sarif-fmt
|
- name: Run Clippy and generate SARIF
|
||||||
|
id: clippy
|
||||||
- name: Run rust-clippy
|
shell: bash
|
||||||
run:
|
run: |
|
||||||
cargo clippy
|
set +e
|
||||||
--all-features
|
cargo clippy \
|
||||||
--message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
|
--workspace \
|
||||||
continue-on-error: true
|
--all-targets \
|
||||||
|
--all-features \
|
||||||
- name: Upload analysis results to GitHub
|
--locked \
|
||||||
uses: github/codeql-action/upload-sarif@v4
|
--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@24c54180a607b1449ed407dd24f251e4e9147c8d # v4
|
||||||
|
if: always()
|
||||||
with:
|
with:
|
||||||
sarif_file: rust-clippy-results.sarif
|
sarif_file: rust-clippy-results.sarif
|
||||||
|
category: clippy
|
||||||
wait-for-processing: true
|
wait-for-processing: true
|
||||||
|
- name: Fail if Clippy failed
|
||||||
|
if: steps.clippy.outputs.exit_code != '0'
|
||||||
|
run: exit 1
|
||||||
Generated
+254
-90
@@ -4,9 +4,9 @@ version = 4
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aho-corasick"
|
name = "aho-corasick"
|
||||||
version = "1.1.4"
|
version = "1.1.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
|
checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
@@ -17,6 +17,23 @@ version = "1.0.104"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
|
checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-trait"
|
||||||
|
version = "0.1.92"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 3.0.9",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "autocfg"
|
||||||
|
version = "1.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bindgen"
|
name = "bindgen"
|
||||||
version = "0.72.1"
|
version = "0.72.1"
|
||||||
@@ -39,9 +56,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "2.13.1"
|
version = "2.13.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da"
|
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bumpalo"
|
name = "bumpalo"
|
||||||
@@ -50,10 +67,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
|
checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "bytes"
|
||||||
version = "1.3.0"
|
version = "1.12.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c89588d05638b5b4594a3348a2d6c20277e43a7f5c5202b05cc56888475a47b8"
|
checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cc"
|
||||||
|
version = "1.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6651c9ed80effdc7db0ff72512157f901af5e3549e341e24b1dd4887d836d838"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"find-msvc-tools",
|
"find-msvc-tools",
|
||||||
"shlex 2.0.1",
|
"shlex 2.0.1",
|
||||||
@@ -70,15 +93,21 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
version = "1.0.4"
|
version = "1.0.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg_aliases"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clang-sys"
|
name = "clang-sys"
|
||||||
version = "1.8.1"
|
version = "1.9.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
|
checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glob",
|
"glob",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -96,9 +125,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "config"
|
name = "config"
|
||||||
version = "0.15.25"
|
version = "0.15.27"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b85f248a4de22d204ceabc6299d89d2c70fbd7f09fea53c06c852369652d8139"
|
checksum = "38e9fbc53afcec54441422f1c596cd054655b32e70e1cbac956651b7b175a404"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"pathdiff",
|
"pathdiff",
|
||||||
"serde_core",
|
"serde_core",
|
||||||
@@ -129,9 +158,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "either"
|
name = "either"
|
||||||
version = "1.16.0"
|
version = "1.19.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e"
|
checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "equivalent"
|
name = "equivalent"
|
||||||
@@ -160,9 +189,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "find-msvc-tools"
|
name = "find-msvc-tools"
|
||||||
version = "0.1.9"
|
version = "0.1.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
|
checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flume"
|
name = "flume"
|
||||||
@@ -171,9 +200,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "5e139bc46ca777eb5efaf62df0ab8cc5fd400866427e56c68b22e414e53bd3be"
|
checksum = "5e139bc46ca777eb5efaf62df0ab8cc5fd400866427e56c68b22e414e53bd3be"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fastrand",
|
"fastrand",
|
||||||
|
"futures-core",
|
||||||
|
"futures-sink",
|
||||||
"spin",
|
"spin",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-core"
|
||||||
|
version = "0.3.34"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-sink"
|
||||||
|
version = "0.3.34"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "getrandom"
|
name = "getrandom"
|
||||||
version = "0.4.3"
|
version = "0.4.3"
|
||||||
@@ -189,9 +232,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glob"
|
name = "glob"
|
||||||
version = "0.3.3"
|
version = "0.3.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
|
checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
@@ -201,18 +244,22 @@ checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icmp-socket2"
|
name = "icmp-socket2"
|
||||||
version = "0.6.0"
|
version = "0.6.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "86fc005b72eb9dbc1df87318cf906a415d4f4c0d5eea42849b29dd710cdf670d"
|
checksum = "816dc56a4f7f76e42b0616818600b05528cd346cb3843276e82df982d5c3ee26"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"async-trait",
|
||||||
|
"nix",
|
||||||
"socket2",
|
"socket2",
|
||||||
|
"thiserror",
|
||||||
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "2.14.0"
|
version = "2.14.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"
|
checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"equivalent",
|
"equivalent",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
@@ -235,9 +282,9 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "js-sys"
|
name = "js-sys"
|
||||||
version = "0.3.103"
|
version = "0.3.106"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "53b44bfcdb3f8d5837a46dae1ca9660a837176eee74a28b229bc626816589102"
|
checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
@@ -245,9 +292,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.189"
|
version = "0.2.190"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
|
checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libloading"
|
name = "libloading"
|
||||||
@@ -262,7 +309,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "libuci-sys"
|
name = "libuci-sys"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
source = "git+https://github.com/Lochnair/rust-uci.git?rev=fcfedd204fb76928ef617bf9631b041c816e03d4#fcfedd204fb76928ef617bf9631b041c816e03d4"
|
source = "git+https://github.com/Lochnair/rust-uci.git?rev=6835397f4f4ba8b69e75e727105186865c357417#6835397f4f4ba8b69e75e727105186865c357417"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bindgen",
|
"bindgen",
|
||||||
"cc",
|
"cc",
|
||||||
@@ -286,20 +333,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.33"
|
version = "0.4.34"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad"
|
checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "maybe-async"
|
|
||||||
version = "0.2.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "746873a384ad60adc5db74471dfaba74bd278afbdcfd81db93fafcdfc8b5ca0c"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.119",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
@@ -307,6 +343,15 @@ version = "2.8.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memoffset"
|
||||||
|
version = "0.9.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "minimal-lexical"
|
name = "minimal-lexical"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
@@ -314,20 +359,44 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "netlink-bindings"
|
name = "mio"
|
||||||
version = "0.3.3"
|
version = "1.2.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "114816d03a633cef7cfa951721dafbda16bb1ff6af83393ee568ec2d4e4ded2d"
|
checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"wasi",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "netlink-bindings"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "15c68f271f059945bc6fb55d210e78c1ceb2d3eac00d18fe9b0806ade81e8a21"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "netlink-socket2"
|
name = "netlink-socket2"
|
||||||
version = "0.3.3"
|
version = "0.3.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "11193969f046efafdc9d8670d395a6ddcf9b806169f504e520a35dc95cab3241"
|
checksum = "0951d4d6a5131a59af90a26fcecd4e366e8fcee3a38880ba58705e479f5bd8c3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"maybe-async",
|
|
||||||
"netlink-bindings",
|
"netlink-bindings",
|
||||||
|
"strip-async",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nix"
|
||||||
|
version = "0.31.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"cfg-if",
|
||||||
|
"cfg_aliases",
|
||||||
|
"libc",
|
||||||
|
"memoffset",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -346,12 +415,41 @@ version = "1.21.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parking_lot"
|
||||||
|
version = "0.12.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a"
|
||||||
|
dependencies = [
|
||||||
|
"lock_api",
|
||||||
|
"parking_lot_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parking_lot_core"
|
||||||
|
version = "0.9.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"redox_syscall",
|
||||||
|
"smallvec",
|
||||||
|
"windows-link",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pathdiff"
|
name = "pathdiff"
|
||||||
version = "0.2.3"
|
version = "0.2.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3"
|
checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pin-project-lite"
|
||||||
|
version = "0.2.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "prettyplease"
|
name = "prettyplease"
|
||||||
version = "0.2.37"
|
version = "0.2.37"
|
||||||
@@ -386,6 +484,15 @@ version = "6.0.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "redox_syscall"
|
||||||
|
version = "0.5.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.13.1"
|
version = "1.13.1"
|
||||||
@@ -400,9 +507,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-automata"
|
name = "regex-automata"
|
||||||
version = "0.4.16"
|
version = "0.4.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8fcfdb36bda0c880c5931cdc7a2bcdc8ba4556847b9d912bca70bc94708711ad"
|
checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
@@ -418,7 +525,7 @@ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "rust-uci"
|
name = "rust-uci"
|
||||||
version = "0.1.6"
|
version = "0.1.6"
|
||||||
source = "git+https://github.com/Lochnair/rust-uci.git?rev=fcfedd204fb76928ef617bf9631b041c816e03d4#fcfedd204fb76928ef617bf9631b041c816e03d4"
|
source = "git+https://github.com/Lochnair/rust-uci.git?rev=6835397f4f4ba8b69e75e727105186865c357417#6835397f4f4ba8b69e75e727105186865c357417"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"libuci-sys",
|
"libuci-sys",
|
||||||
@@ -434,9 +541,9 @@ checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustix"
|
name = "rustix"
|
||||||
version = "1.1.4"
|
version = "1.1.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190"
|
checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"errno",
|
"errno",
|
||||||
@@ -490,14 +597,14 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 3.0.3",
|
"syn 3.0.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.151"
|
version = "1.0.154"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"
|
checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"memchr",
|
"memchr",
|
||||||
@@ -508,9 +615,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_spanned"
|
name = "serde_spanned"
|
||||||
version = "1.1.1"
|
version = "1.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26"
|
checksum = "4e7523beb55eece201a2356bee0bbca0d1ab466c14c07703b2e0ee6d42cb0c2c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_core",
|
"serde_core",
|
||||||
]
|
]
|
||||||
@@ -527,6 +634,22 @@ version = "2.0.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "signal-hook-registry"
|
||||||
|
version = "1.4.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"
|
||||||
|
dependencies = [
|
||||||
|
"errno",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "smallvec"
|
||||||
|
version = "1.16.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5b3dc8af474f516a851ff4bd12db780f948b9250ad37211e4eec0bccea54e01b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "socket2"
|
name = "socket2"
|
||||||
version = "0.6.5"
|
version = "0.6.5"
|
||||||
@@ -564,9 +687,16 @@ dependencies = [
|
|||||||
"rustix",
|
"rustix",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
"tokio",
|
||||||
"uci-derive",
|
"uci-derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strip-async"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "85ec932792e62b2d3936163eacbd2e09984453bcd114f665c1e1694e36ff59c9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.119"
|
version = "2.0.119"
|
||||||
@@ -580,9 +710,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "3.0.3"
|
version = "3.0.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3"
|
checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -590,10 +720,10 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "target-triple"
|
name = "target-tuple"
|
||||||
version = "1.0.1"
|
version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c3a6bfce3d99adfa72d24750a61f782f3036a81e7f86d8841ee1326deaebd171"
|
checksum = "876fef147edbcbddc8ac5cbbba92c7b86519e314e86638596c09673b2ed01e7f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "termcolor"
|
name = "termcolor"
|
||||||
@@ -606,29 +736,57 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "2.0.19"
|
version = "2.0.21"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "09a43598840e33d5b0331f38c5e30d13bb11c11210a4b58f0d9b18a5a5eefcd9"
|
checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "2.0.19"
|
version = "2.0.21"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "43cbfe0cf76104d42a574802844187e84a305e531ed54455f11fbde0f10541cd"
|
checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 3.0.3",
|
"syn 3.0.9",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tokio"
|
||||||
|
version = "1.53.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ce3335fa71841cda333a58d7615b03901380ecf09d59b3296d21f8bbac0dde4e"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"libc",
|
||||||
|
"mio",
|
||||||
|
"parking_lot",
|
||||||
|
"pin-project-lite",
|
||||||
|
"signal-hook-registry",
|
||||||
|
"socket2",
|
||||||
|
"tokio-macros",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tokio-macros"
|
||||||
|
version = "2.7.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 3.0.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml"
|
name = "toml"
|
||||||
version = "1.1.3+spec-1.1.0"
|
version = "1.1.8+spec-1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "53c96ecdfa941c8fc4fcaed14f99ada8ebed502eef533015095a07e3301d4c3c"
|
checksum = "20489e00e4d8741d6be680764cc12e270655e375a20d1011e844a9c3379e678d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"serde_core",
|
"serde_core",
|
||||||
@@ -641,39 +799,39 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml_datetime"
|
name = "toml_datetime"
|
||||||
version = "1.1.1+spec-1.1.0"
|
version = "1.1.2+spec-1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7"
|
checksum = "2b86d767906c6c42421dcba507eb9d203e779497710a47782a224bb871653053"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_core",
|
"serde_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml_parser"
|
name = "toml_parser"
|
||||||
version = "1.1.2+spec-1.1.0"
|
version = "1.1.5+spec-1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a2abe9b86193656635d2411dc43050282ca48aa31c2451210f4202550afb7526"
|
checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"winnow",
|
"winnow",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toml_writer"
|
name = "toml_writer"
|
||||||
version = "1.1.2+spec-1.1.0"
|
version = "1.1.3+spec-1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2"
|
checksum = "06bdbd8cfc056b8d2e2e85f29b56a3bdbecb527cef81eb39e3e7b98af4652770"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "trybuild"
|
name = "trybuild"
|
||||||
version = "1.0.120"
|
version = "1.0.122"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1e605bf6b39357663d8ba4e984f8be8da8df6bb32e81031d6889024ea8fd68e4"
|
checksum = "62db9c92d704393fbf2132041720cc80b689f2d3f28521015c2ac866223c11b8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glob",
|
"glob",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"target-triple",
|
"target-tuple",
|
||||||
"termcolor",
|
"termcolor",
|
||||||
"toml",
|
"toml",
|
||||||
]
|
]
|
||||||
@@ -684,21 +842,27 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 3.0.3",
|
"syn 3.0.9",
|
||||||
"trybuild",
|
"trybuild",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.24"
|
version = "1.0.27"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.11.1+wasi-snapshot-preview1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen"
|
name = "wasm-bindgen"
|
||||||
version = "0.2.126"
|
version = "0.2.129"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4b067c0c11094aef6b7a801c1e34a26affafdf3d051dba08456b868789aaf9a4"
|
checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
@@ -709,9 +873,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro"
|
name = "wasm-bindgen-macro"
|
||||||
version = "0.2.126"
|
version = "0.2.129"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "167ce5e579f6bcf889c4f7175a8a5a585de84e8ff93976ce393efa5f2837aab1"
|
checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"wasm-bindgen-macro-support",
|
"wasm-bindgen-macro-support",
|
||||||
@@ -719,22 +883,22 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro-support"
|
name = "wasm-bindgen-macro-support"
|
||||||
version = "0.2.126"
|
version = "0.2.129"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f3997c7839262f4ef12cf90b818d6340c18e80f263f1a94bf157d0ec4420380e"
|
checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.119",
|
"syn 3.0.9",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-shared"
|
name = "wasm-bindgen-shared"
|
||||||
version = "0.2.126"
|
version = "0.2.129"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dc1b4cb0cc549fcf58d7dfc081778139b3d283a081644e833e84682ad71cea24"
|
checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|||||||
+11
-10
@@ -20,15 +20,16 @@ strip = "symbols"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
icmp-socket2 = "0.6.0"
|
config = { version = "0.15.27", default-features = false }
|
||||||
fastrand = "2"
|
|
||||||
rustix = { version = "1.1", features = ["fs", "system", "thread", "time"] }
|
|
||||||
thiserror = "2.0"
|
|
||||||
libc = "0.2"
|
|
||||||
flume = { version = "0.12.0", default-features = false, features = ["eventual-fairness", "select"] }
|
|
||||||
config = { version = "0.15.25", default-features = false }
|
|
||||||
csv = "1.4.0"
|
csv = "1.4.0"
|
||||||
|
fastrand = "2"
|
||||||
|
flume = { version = "0.12.0", default-features = false, features = ["async", "eventual-fairness", "select"] }
|
||||||
|
icmp-socket2 = { version = "0.6.4", features = ["tokio"] }
|
||||||
|
libc = "0.2"
|
||||||
|
rustix = { version = "1.1", features = ["fs", "system", "thread", "time"] }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
thiserror = "2.0"
|
||||||
|
tokio = { version = "1", features = ["full"] }
|
||||||
uci-derive = { path = "crates/uci-derive" }
|
uci-derive = { path = "crates/uci-derive" }
|
||||||
|
|
||||||
[dependencies.log]
|
[dependencies.log]
|
||||||
@@ -36,11 +37,11 @@ features = ["std"]
|
|||||||
version = "0.4"
|
version = "0.4"
|
||||||
|
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
netlink-bindings = { version = "0.3.3", features = ["rt-link", "tc"] }
|
netlink-bindings = { version = "0.3.5", features = ["rt-link", "tc"] }
|
||||||
netlink-socket2 = { version = "0.3.3" }
|
netlink-socket2 = { version = "0.3.5" }
|
||||||
|
|
||||||
[target.'cfg(unix)'.dependencies]
|
[target.'cfg(unix)'.dependencies]
|
||||||
rust-uci = { git = "https://github.com/Lochnair/rust-uci.git", rev = "fcfedd204fb76928ef617bf9631b041c816e03d4", optional = true, default-features = false, }
|
rust-uci = { git = "https://github.com/Lochnair/rust-uci.git", rev = "6835397f4f4ba8b69e75e727105186865c357417", optional = true, default-features = false }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["toml", "uci-vendored"]
|
default = ["toml", "uci-vendored"]
|
||||||
|
|||||||
+37
@@ -1,3 +1,40 @@
|
|||||||
[target.x86_64-unknown-freebsd]
|
[target.x86_64-unknown-freebsd]
|
||||||
image.name = "ghcr.io/cross-rs/x86_64-unknown-freebsd:local"
|
image.name = "ghcr.io/cross-rs/x86_64-unknown-freebsd:local"
|
||||||
image.toolchain = ["linux/arm64=aarch64-unknown-linux-gnu"]
|
image.toolchain = ["linux/arm64=aarch64-unknown-linux-gnu"]
|
||||||
|
|
||||||
|
[build]
|
||||||
|
# Vendored UCI searches CMAKE_LIBRARY_PATH for libubox built outside the sysroot.
|
||||||
|
pre-build = [
|
||||||
|
"apt-get update && apt-get install -y --no-install-recommends pkg-config",
|
||||||
|
'echo "set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)" >> /opt/toolchain.cmake',
|
||||||
|
# Rust's musl std links -lunwind; MIPS cross GCC supplies the unwinder as libgcc_eh.a.
|
||||||
|
'''
|
||||||
|
for cc in /usr/local/bin/mips*-gcc; do
|
||||||
|
[ -x "$cc" ] || continue
|
||||||
|
archive=$("$cc" -print-file-name=libgcc_eh.a)
|
||||||
|
test -f "$archive" || exit 1
|
||||||
|
ln -sf libgcc_eh.a "$(dirname "$archive")/libunwind.a"
|
||||||
|
done
|
||||||
|
''',
|
||||||
|
]
|
||||||
|
|
||||||
|
# This target's image was added after the cross 0.2.5 release.
|
||||||
|
[target.riscv64gc-unknown-linux-musl]
|
||||||
|
image = "ghcr.io/cross-rs/riscv64gc-unknown-linux-musl:main"
|
||||||
|
|
||||||
|
# MIPS images exist but are excluded from cross's automatic image selection.
|
||||||
|
[target.mips-unknown-linux-musl]
|
||||||
|
image = "ghcr.io/cross-rs/mips-unknown-linux-musl:main"
|
||||||
|
build-std = ["std", "panic_abort"]
|
||||||
|
|
||||||
|
[target.mipsel-unknown-linux-musl]
|
||||||
|
image = "ghcr.io/cross-rs/mipsel-unknown-linux-musl:main"
|
||||||
|
build-std = ["std", "panic_abort"]
|
||||||
|
|
||||||
|
[target.mips64-unknown-linux-muslabi64]
|
||||||
|
image = "ghcr.io/cross-rs/mips64-unknown-linux-muslabi64:main"
|
||||||
|
build-std = ["std", "panic_abort"]
|
||||||
|
|
||||||
|
[target.mips64el-unknown-linux-muslabi64]
|
||||||
|
image = "ghcr.io/cross-rs/mips64el-unknown-linux-muslabi64:main"
|
||||||
|
build-std = ["std", "panic_abort"]
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
# cargo-deny policy for sqm-autorate-rust.
|
||||||
|
# Keep published dependency sources and license terms explicit while allowing
|
||||||
|
# advisory reports to be reviewed without blocking unrelated changes.
|
||||||
|
|
||||||
|
[graph]
|
||||||
|
all-features = true
|
||||||
|
no-default-features = false
|
||||||
|
targets = []
|
||||||
|
|
||||||
|
[output]
|
||||||
|
feature-depth = 1
|
||||||
|
|
||||||
|
[advisories]
|
||||||
|
yanked = "deny"
|
||||||
|
unmaintained = "workspace"
|
||||||
|
unsound = "workspace"
|
||||||
|
ignore = []
|
||||||
|
|
||||||
|
[licenses]
|
||||||
|
confidence-threshold = 0.8
|
||||||
|
allow = [
|
||||||
|
"Apache-2.0",
|
||||||
|
"BSD-2-Clause",
|
||||||
|
"BSD-3-Clause",
|
||||||
|
"CC0-1.0",
|
||||||
|
"ISC",
|
||||||
|
"MIT",
|
||||||
|
"MPL-2.0",
|
||||||
|
"Unicode-3.0",
|
||||||
|
"Zlib",
|
||||||
|
]
|
||||||
|
|
||||||
|
[bans]
|
||||||
|
multiple-versions = "warn"
|
||||||
|
wildcards = "allow"
|
||||||
|
highlight = "all"
|
||||||
|
workspace-default-features = "allow"
|
||||||
|
external-default-features = "allow"
|
||||||
|
|
||||||
|
[sources]
|
||||||
|
unknown-registry = "deny"
|
||||||
|
unknown-git = "deny"
|
||||||
|
required-git-spec = "rev"
|
||||||
|
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
|
||||||
|
allow-git = ["https://github.com/Lochnair/rust-uci"]
|
||||||
|
|
||||||
|
[sources.allow-org]
|
||||||
|
github = []
|
||||||
|
gitlab = []
|
||||||
|
bitbucket = []
|
||||||
+14
-1
@@ -2,5 +2,18 @@
|
|||||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
"extends": [
|
"extends": [
|
||||||
"config:recommended"
|
"config:recommended"
|
||||||
|
],
|
||||||
|
"packageRules": [
|
||||||
|
{
|
||||||
|
"description": "Keep netlink-bindings and netlink-socket2 updates together",
|
||||||
|
"matchManagers": [
|
||||||
|
"cargo"
|
||||||
|
],
|
||||||
|
"matchPackageNames": [
|
||||||
|
"netlink-bindings",
|
||||||
|
"netlink-socket2"
|
||||||
|
],
|
||||||
|
"groupName": "netlink dependencies"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
+61
-25
@@ -6,8 +6,8 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use crate::SHUTDOWN;
|
use crate::SHUTDOWN;
|
||||||
|
use crate::measurement::model::{MeasurementEvent, MeasurementObservation};
|
||||||
use crate::metrics::{Metric, MetricsSender};
|
use crate::metrics::{Metric, MetricsSender};
|
||||||
use crate::pinger::PingReply;
|
|
||||||
use crate::settings::Settings;
|
use crate::settings::Settings;
|
||||||
use flume::{Receiver, Sender};
|
use flume::{Receiver, Sender};
|
||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
@@ -29,10 +29,16 @@ pub struct EwmaStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl EwmaStats {
|
impl EwmaStats {
|
||||||
fn from_reply(reply: &PingReply) -> Self {
|
fn from_reply(reply: &MeasurementObservation) -> Self {
|
||||||
Self {
|
Self {
|
||||||
down: reply.down_time,
|
down: reply
|
||||||
up: reply.up_time,
|
.one_way
|
||||||
|
.map(|o| o.downlink.as_nanos() as f64 / 1000000.0)
|
||||||
|
.unwrap_or(reply.rtt_ms() / 2.0),
|
||||||
|
up: reply
|
||||||
|
.one_way
|
||||||
|
.map(|o| o.uplink.as_nanos() as f64 / 1000000.0)
|
||||||
|
.unwrap_or(reply.rtt_ms() / 2.0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,11 +79,12 @@ pub struct Baseliner {
|
|||||||
pub settings: Settings,
|
pub settings: Settings,
|
||||||
pub reselect_trigger: Sender<bool>,
|
pub reselect_trigger: Sender<bool>,
|
||||||
pub start_time: Instant,
|
pub start_time: Instant,
|
||||||
pub stats_rx: Receiver<PingReply>,
|
pub stats_rx: Receiver<MeasurementEvent>,
|
||||||
pub control_tx: Sender<ControlSnapshot>,
|
pub control_tx: Sender<ControlSnapshot>,
|
||||||
pub selection_tx: Option<Sender<ControlSnapshot>>,
|
pub selection_tx: Option<Sender<ControlSnapshot>>,
|
||||||
pub baseline_metrics: MetricsSender,
|
pub baseline_metrics: MetricsSender,
|
||||||
pub event_metrics: MetricsSender,
|
pub event_metrics: MetricsSender,
|
||||||
|
pub ping_metrics: MetricsSender,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ewma_factor(tick: f64, dur: f64) -> f64 {
|
fn ewma_factor(tick: f64, dur: f64) -> f64 {
|
||||||
@@ -115,19 +122,19 @@ fn update_reflector_state(
|
|||||||
|
|
||||||
fn process_reply(
|
fn process_reply(
|
||||||
reflectors: &mut HashMap<IpAddr, ReflectorState>,
|
reflectors: &mut HashMap<IpAddr, ReflectorState>,
|
||||||
reply: &PingReply,
|
reply: &MeasurementObservation,
|
||||||
start_time: Instant,
|
start_time: Instant,
|
||||||
slow_factor: f64,
|
slow_factor: f64,
|
||||||
fast_factor: f64,
|
fast_factor: f64,
|
||||||
) -> (ReflectorState, bool) {
|
) -> (ReflectorState, bool) {
|
||||||
let sample = EwmaStats::from_reply(reply);
|
let sample = EwmaStats::from_reply(reply);
|
||||||
let state = reflectors
|
let state = reflectors
|
||||||
.entry(reply.reflector)
|
.entry(reply.stream.peer)
|
||||||
.or_insert_with(|| ReflectorState::new(sample, reply.last_receive_time_s));
|
.or_insert_with(|| ReflectorState::new(sample, reply.observed_at));
|
||||||
let anomaly = update_reflector_state(
|
let anomaly = update_reflector_state(
|
||||||
state,
|
state,
|
||||||
sample,
|
sample,
|
||||||
reply.last_receive_time_s,
|
reply.observed_at,
|
||||||
start_time,
|
start_time,
|
||||||
slow_factor,
|
slow_factor,
|
||||||
fast_factor,
|
fast_factor,
|
||||||
@@ -165,8 +172,14 @@ impl Baseliner {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let reply = self.stats_rx.recv()?;
|
let event = self.stats_rx.recv()?;
|
||||||
let reflector = reply.reflector;
|
|
||||||
|
let reply = match event {
|
||||||
|
MeasurementEvent::Observation(reply) => reply,
|
||||||
|
MeasurementEvent::Loss(_) => continue,
|
||||||
|
};
|
||||||
|
|
||||||
|
let reflector = reply.stream.peer;
|
||||||
let (state, anomaly) = process_reply(
|
let (state, anomaly) = process_reply(
|
||||||
&mut reflectors,
|
&mut reflectors,
|
||||||
&reply,
|
&reply,
|
||||||
@@ -189,6 +202,20 @@ impl Baseliner {
|
|||||||
let _ = self.reselect_trigger.try_send(true);
|
let _ = self.reselect_trigger.try_send(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.ping_metrics.send(Metric::Ping {
|
||||||
|
reflector,
|
||||||
|
measurement_type: reply.stream.source,
|
||||||
|
rtt: reply.rtt_ms(),
|
||||||
|
up_time: reply
|
||||||
|
.one_way
|
||||||
|
.map(|o| o.uplink.as_nanos() as f64 / 1000000.0)
|
||||||
|
.unwrap_or(reply.rtt_ms() / 2.0),
|
||||||
|
down_time: reply
|
||||||
|
.one_way
|
||||||
|
.map(|o| o.downlink.as_nanos() as f64 / 1000000.0)
|
||||||
|
.unwrap_or(reply.rtt_ms() / 2.0),
|
||||||
|
});
|
||||||
|
|
||||||
self.baseline_metrics.send(Metric::Baseline {
|
self.baseline_metrics.send(Metric::Baseline {
|
||||||
reflector,
|
reflector,
|
||||||
baseline_up_ewma: state.baseline.up,
|
baseline_up_ewma: state.baseline.up,
|
||||||
@@ -218,7 +245,10 @@ impl Baseliner {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::settings::MeasurementType;
|
use crate::measurement::model::{
|
||||||
|
MeasurementSource, MeasurementStream, MeasurementStreamId, OneWayClock, OneWayLatency,
|
||||||
|
SignedDuration,
|
||||||
|
};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
fn state(
|
fn state(
|
||||||
@@ -245,19 +275,25 @@ mod tests {
|
|||||||
EwmaStats { down, up }
|
EwmaStats { down, up }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reply(reflector: IpAddr, down_time: f64, up_time: f64, received_at: Instant) -> PingReply {
|
fn reply(
|
||||||
PingReply {
|
reflector: IpAddr,
|
||||||
reflector,
|
down_time: f64,
|
||||||
measurement_type: MeasurementType::Icmp,
|
up_time: f64,
|
||||||
seq: 0,
|
received_at: Instant,
|
||||||
rtt: down_time + up_time,
|
) -> MeasurementObservation {
|
||||||
current_time: 0,
|
MeasurementObservation {
|
||||||
down_time,
|
stream: MeasurementStream {
|
||||||
up_time,
|
id: MeasurementStreamId(0),
|
||||||
originate_timestamp: 0,
|
peer: reflector,
|
||||||
receive_timestamp: 0,
|
source: MeasurementSource::IcmpEcho,
|
||||||
transmit_timestamp: 0,
|
},
|
||||||
last_receive_time_s: received_at,
|
started_at: received_at,
|
||||||
|
observed_at: received_at,
|
||||||
|
one_way: Some(OneWayLatency {
|
||||||
|
uplink: SignedDuration::from_millis(up_time as i64),
|
||||||
|
downlink: SignedDuration::from_millis(down_time as i64),
|
||||||
|
clock: OneWayClock::Uncalibrated,
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
use std::{collections::HashMap, net::IpAddr, time::Duration};
|
||||||
|
|
||||||
|
use flume::{Receiver, SendError, Sender};
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
use crate::measurement::{
|
||||||
|
icmp::IcmpBinding,
|
||||||
|
model::{MeasurementSource, MeasurementStream, MeasurementStreamId, ProbeSchedule},
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum ControllerError {
|
||||||
|
#[error("ICMP channel error")]
|
||||||
|
IcmpChannelError(#[from] SendError<Vec<IcmpBinding>>),
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Controller {
|
||||||
|
reflector_rx: Receiver<Vec<IpAddr>>,
|
||||||
|
icmp_binding_tx: Sender<Vec<IcmpBinding>>,
|
||||||
|
|
||||||
|
source: MeasurementSource,
|
||||||
|
period: Duration,
|
||||||
|
|
||||||
|
next_stream_id: u64,
|
||||||
|
stream_ids: HashMap<(IpAddr, MeasurementSource), MeasurementStreamId>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Controller {
|
||||||
|
pub fn new(
|
||||||
|
reflector_rx: Receiver<Vec<IpAddr>>,
|
||||||
|
icmp_binding_tx: Sender<Vec<IcmpBinding>>,
|
||||||
|
) -> Self {
|
||||||
|
Self {
|
||||||
|
reflector_rx,
|
||||||
|
icmp_binding_tx,
|
||||||
|
source: MeasurementSource::IcmpTimestamp,
|
||||||
|
period: Duration::from_millis(500),
|
||||||
|
next_stream_id: 0,
|
||||||
|
stream_ids: HashMap::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn run(mut self, initial_reflectors: Vec<IpAddr>) -> Result<(), ControllerError> {
|
||||||
|
self.update_reflectors(initial_reflectors).await?;
|
||||||
|
|
||||||
|
while let Ok(reflectors) = self.reflector_rx.recv_async().await {
|
||||||
|
self.update_reflectors(reflectors).await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn stream_for(&mut self, peer: IpAddr) -> MeasurementStream {
|
||||||
|
let key = (peer, self.source);
|
||||||
|
|
||||||
|
let id = *self.stream_ids.entry(key).or_insert_with(|| {
|
||||||
|
let id = MeasurementStreamId(self.next_stream_id);
|
||||||
|
self.next_stream_id += 1;
|
||||||
|
id
|
||||||
|
});
|
||||||
|
|
||||||
|
MeasurementStream {
|
||||||
|
id,
|
||||||
|
peer,
|
||||||
|
source: self.source,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update_reflectors(&mut self, reflectors: Vec<IpAddr>) -> Result<(), ControllerError> {
|
||||||
|
let count = reflectors.len();
|
||||||
|
|
||||||
|
let bindings = reflectors
|
||||||
|
.into_iter()
|
||||||
|
.enumerate()
|
||||||
|
.map(|(index, peer)| {
|
||||||
|
let stream = self.stream_for(peer);
|
||||||
|
|
||||||
|
IcmpBinding::new(
|
||||||
|
stream,
|
||||||
|
ProbeSchedule {
|
||||||
|
period: self.period,
|
||||||
|
offset: evenly_spaced_offset(self.period, index, count),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
self.icmp_binding_tx
|
||||||
|
.send_async(bindings)
|
||||||
|
.await
|
||||||
|
.map_err(|e| ControllerError::IcmpChannelError(e))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn evenly_spaced_offset(period: Duration, index: usize, count: usize) -> Duration {
|
||||||
|
let nanos = period.as_nanos() * index as u128 / count as u128;
|
||||||
|
|
||||||
|
Duration::new(
|
||||||
|
(nanos / 1_000_000_000) as u64,
|
||||||
|
(nanos % 1_000_000_000) as u32,
|
||||||
|
)
|
||||||
|
}
|
||||||
+4
-5
@@ -2,10 +2,9 @@
|
|||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use log::{Level, LevelFilter, Metadata, Record, SetLoggerError};
|
use log::{Level, Metadata, Record, SetLoggerError};
|
||||||
use rustix::time::ClockId;
|
|
||||||
|
|
||||||
use crate::time::Time;
|
use crate::time::{ClockSample, Realtime};
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct SimpleLogger {
|
pub struct SimpleLogger {
|
||||||
@@ -19,7 +18,7 @@ impl log::Log for SimpleLogger {
|
|||||||
|
|
||||||
fn log(&self, record: &Record) {
|
fn log(&self, record: &Record) {
|
||||||
if self.enabled(record.metadata()) {
|
if self.enabled(record.metadata()) {
|
||||||
let now = Time::new(ClockId::Realtime);
|
let now = ClockSample::<Realtime>::now();
|
||||||
println!(
|
println!(
|
||||||
"{} {:5} {}:{}: {}",
|
"{} {:5} {}:{}: {}",
|
||||||
now.as_secs_f64(),
|
now.as_secs_f64(),
|
||||||
@@ -36,5 +35,5 @@ impl log::Log for SimpleLogger {
|
|||||||
|
|
||||||
pub fn init(level: Level) -> Result<(), SetLoggerError> {
|
pub fn init(level: Level) -> Result<(), SetLoggerError> {
|
||||||
log::set_boxed_logger(Box::new(SimpleLogger { level }))
|
log::set_boxed_logger(Box::new(SimpleLogger { level }))
|
||||||
.map(|()| log::set_max_level(LevelFilter::Trace))
|
.map(|()| log::set_max_level(level.to_level_filter()))
|
||||||
}
|
}
|
||||||
+80
-159
@@ -8,11 +8,10 @@
|
|||||||
extern crate core;
|
extern crate core;
|
||||||
|
|
||||||
mod baseliner;
|
mod baseliner;
|
||||||
|
mod controller;
|
||||||
mod log;
|
mod log;
|
||||||
|
mod measurement;
|
||||||
mod metrics;
|
mod metrics;
|
||||||
mod pinger;
|
|
||||||
mod pinger_icmp;
|
|
||||||
mod pinger_icmp_ts;
|
|
||||||
mod platform;
|
mod platform;
|
||||||
mod ratecontroller;
|
mod ratecontroller;
|
||||||
mod reflector_selector;
|
mod reflector_selector;
|
||||||
@@ -21,36 +20,29 @@ mod time;
|
|||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
use crate::baseliner::Baseliner;
|
use crate::baseliner::Baseliner;
|
||||||
|
use crate::controller::Controller;
|
||||||
|
use crate::measurement::icmp::IcmpEngine;
|
||||||
use crate::metrics::{Metric, Metrics, MetricsSender};
|
use crate::metrics::{Metric, Metrics, MetricsSender};
|
||||||
use crate::pinger::{InFlightProbeCache, PingListener, PingSender};
|
|
||||||
use crate::pinger_icmp::{PingerICMPEchoListener, PingerICMPEchoSender};
|
|
||||||
use crate::pinger_icmp_ts::{PingerICMPTimestampListener, PingerICMPTimestampSender};
|
|
||||||
use crate::platform::{TrafficControlBackend, traffic_control_backend, warn_platform_limitations};
|
use crate::platform::{TrafficControlBackend, traffic_control_backend, warn_platform_limitations};
|
||||||
use crate::ratecontroller::Ratecontroller;
|
use crate::ratecontroller::Ratecontroller;
|
||||||
use crate::reflector_selector::ReflectorSelector;
|
use crate::reflector_selector::ReflectorSelector;
|
||||||
use crate::settings::MeasurementType;
|
|
||||||
use crate::settings::Settings;
|
use crate::settings::Settings;
|
||||||
use ::log::{debug, info, warn};
|
use crate::util::RwLockExt;
|
||||||
|
use ::log::{info, warn};
|
||||||
use flume::RecvTimeoutError;
|
use flume::RecvTimeoutError;
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
|
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
|
||||||
use std::sync::{Arc, Mutex, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
use std::thread::sleep;
|
use std::thread;
|
||||||
|
use std::thread::{JoinHandle, sleep};
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
use std::{process, thread};
|
|
||||||
|
|
||||||
struct ReflectorSetup {
|
struct ReflectorSetup {
|
||||||
peers: Arc<RwLock<Vec<IpAddr>>>,
|
peers: Arc<RwLock<Vec<IpAddr>>>,
|
||||||
pool: Vec<IpAddr>,
|
pool: Vec<IpAddr>,
|
||||||
reselection_enabled: bool,
|
reselection_enabled: bool,
|
||||||
active_count: usize,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type PingListenerBox = Box<dyn PingListener + Send>;
|
|
||||||
type PingSenderBox = Box<dyn PingSender + Send>;
|
|
||||||
|
|
||||||
pub static SHUTDOWN: AtomicBool = AtomicBool::new(false);
|
pub static SHUTDOWN: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
||||||
extern "C" fn signal_handler(_: libc::c_int) {
|
extern "C" fn signal_handler(_: libc::c_int) {
|
||||||
@@ -58,47 +50,6 @@ extern "C" fn signal_handler(_: libc::c_int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
const RESELECTION_CANDIDATE_BURST: usize = 20;
|
|
||||||
const INFLIGHT_CAPACITY_DUPLICATE_FACTOR: usize = 2;
|
|
||||||
const INFLIGHT_CAPACITY_MIN: usize = 256;
|
|
||||||
|
|
||||||
fn compute_inflight_probe_capacity(
|
|
||||||
settings: &Settings,
|
|
||||||
active_reflector_count: usize,
|
|
||||||
reselection_enabled: bool,
|
|
||||||
) -> usize {
|
|
||||||
let tick_interval_ms = (settings.advanced_settings.tick_interval * 1000.0).max(1.0);
|
|
||||||
let expected_path_delay_ms = (settings.advanced_settings.download_delay_ms
|
|
||||||
+ settings.advanced_settings.upload_delay_ms)
|
|
||||||
.max(10.0);
|
|
||||||
// Keep enough room for severe queueing events while still adapting to configured delay budgets.
|
|
||||||
let max_rtt_ms = (expected_path_delay_ms * 20.0).clamp(1000.0, 10000.0);
|
|
||||||
|
|
||||||
let burst_reflector_count = if reselection_enabled {
|
|
||||||
active_reflector_count + RESELECTION_CANDIDATE_BURST
|
|
||||||
} else {
|
|
||||||
active_reflector_count
|
|
||||||
};
|
|
||||||
let probes_per_reflector = (max_rtt_ms / tick_interval_ms).ceil() as usize;
|
|
||||||
|
|
||||||
(burst_reflector_count
|
|
||||||
.saturating_mul(probes_per_reflector)
|
|
||||||
.saturating_mul(INFLIGHT_CAPACITY_DUPLICATE_FACTOR))
|
|
||||||
.max(INFLIGHT_CAPACITY_MIN)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn create_pinger(measurement_type: MeasurementType) -> (PingListenerBox, PingSenderBox) {
|
|
||||||
match measurement_type {
|
|
||||||
MeasurementType::Icmp => (
|
|
||||||
Box::new(PingerICMPEchoListener {}),
|
|
||||||
Box::new(PingerICMPEchoSender {}),
|
|
||||||
),
|
|
||||||
MeasurementType::IcmpTimestamps => (
|
|
||||||
Box::new(PingerICMPTimestampListener {}),
|
|
||||||
Box::new(PingerICMPTimestampSender {}),
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn initialize_shaper<T: TrafficControlBackend>(
|
fn initialize_shaper<T: TrafficControlBackend>(
|
||||||
settings: &Settings,
|
settings: &Settings,
|
||||||
@@ -155,11 +106,6 @@ fn install_signal_handlers() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn probe_identifier() -> u16 {
|
|
||||||
// The ICMP identifier is only two bytes.
|
|
||||||
(process::id() & 0xffff) as u16
|
|
||||||
}
|
|
||||||
|
|
||||||
fn restore_shaper<T: TrafficControlBackend>(
|
fn restore_shaper<T: TrafficControlBackend>(
|
||||||
settings: &Settings,
|
settings: &Settings,
|
||||||
traffic_control: &mut T,
|
traffic_control: &mut T,
|
||||||
@@ -212,17 +158,52 @@ fn setup_reflectors(settings: &Settings) -> anyhow::Result<ReflectorSetup> {
|
|||||||
peers: Arc::new(RwLock::new(default_reflectors.to_vec())),
|
peers: Arc::new(RwLock::new(default_reflectors.to_vec())),
|
||||||
pool,
|
pool,
|
||||||
reselection_enabled,
|
reselection_enabled,
|
||||||
active_count: default_reflectors
|
|
||||||
.len()
|
|
||||||
.max(settings.advanced_settings.num_reflectors as usize),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn spawn_task<F, E>(
|
||||||
|
rt: &tokio::runtime::Runtime,
|
||||||
|
error_tx: &flume::Sender<anyhow::Error>,
|
||||||
|
task: F,
|
||||||
|
) -> tokio::task::JoinHandle<()>
|
||||||
|
where
|
||||||
|
F: Future<Output = Result<(), E>> + Send + 'static,
|
||||||
|
E: Into<anyhow::Error> + Send + 'static,
|
||||||
|
{
|
||||||
|
let error_tx = error_tx.clone();
|
||||||
|
|
||||||
|
rt.spawn(async move {
|
||||||
|
if let Err(error) = task.await {
|
||||||
|
let _ = error_tx.send(error.into());
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn spawn_worker<F>(
|
||||||
|
name: &str,
|
||||||
|
error_tx: &flume::Sender<anyhow::Error>,
|
||||||
|
worker: F,
|
||||||
|
) -> anyhow::Result<JoinHandle<()>>
|
||||||
|
where
|
||||||
|
F: FnOnce() -> anyhow::Result<()> + Send + 'static,
|
||||||
|
{
|
||||||
|
let error_tx = error_tx.clone();
|
||||||
|
|
||||||
|
thread::Builder::new()
|
||||||
|
.name(name.to_owned())
|
||||||
|
.spawn(move || {
|
||||||
|
if let Err(error) = worker() {
|
||||||
|
let _ = error_tx.send(error);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.map_err(|e| anyhow::anyhow!(e))
|
||||||
|
}
|
||||||
|
|
||||||
fn wait_for_exit(error_rx: &flume::Receiver<anyhow::Error>) -> anyhow::Result<()> {
|
fn wait_for_exit(error_rx: &flume::Receiver<anyhow::Error>) -> anyhow::Result<()> {
|
||||||
loop {
|
loop {
|
||||||
match error_rx.recv_timeout(Duration::from_secs(1)) {
|
match error_rx.recv_timeout(Duration::from_secs(1)) {
|
||||||
Ok(error) => {
|
Ok(error) => {
|
||||||
return Err(anyhow::anyhow!("thread exited with error: {error}"));
|
return Err(anyhow::anyhow!("worker exited with error: {error}"));
|
||||||
}
|
}
|
||||||
Err(RecvTimeoutError::Disconnected) => {
|
Err(RecvTimeoutError::Disconnected) => {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -238,30 +219,45 @@ fn wait_for_exit(error_rx: &flume::Receiver<anyhow::Error>) -> anyhow::Result<()
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run(settings: &Settings) -> anyhow::Result<()> {
|
fn run(settings: &Settings) -> anyhow::Result<()> {
|
||||||
|
let rt = tokio::runtime::Runtime::new()?;
|
||||||
|
|
||||||
if settings.advanced_settings.dry_run {
|
if settings.advanced_settings.dry_run {
|
||||||
info!("*** MONITORING MODE ACTIVE — qdisc rates will NOT be changed ***");
|
info!("*** MONITORING MODE ACTIVE — qdisc rates will NOT be changed ***");
|
||||||
}
|
}
|
||||||
|
|
||||||
let start_time = Instant::now();
|
let start_time = Instant::now();
|
||||||
let probe_id = probe_identifier();
|
|
||||||
|
|
||||||
let ReflectorSetup {
|
let ReflectorSetup {
|
||||||
peers: reflector_peers,
|
peers: reflector_peers,
|
||||||
pool: reflector_pool,
|
pool: reflector_pool,
|
||||||
reselection_enabled,
|
reselection_enabled,
|
||||||
active_count: active_reflector_count,
|
|
||||||
} = setup_reflectors(settings)?;
|
} = setup_reflectors(settings)?;
|
||||||
|
|
||||||
let (baseliner_stats_tx, baseliner_stats_rx) = flume::unbounded();
|
|
||||||
let (control_snapshot_tx, control_snapshot_rx) = flume::unbounded();
|
let (control_snapshot_tx, control_snapshot_rx) = flume::unbounded();
|
||||||
|
let (error_tx, error_rx) = flume::unbounded::<anyhow::Error>();
|
||||||
|
let (icmp_binding_tx, icmp_binding_rx) = flume::unbounded();
|
||||||
|
let (measurement_tx, measurement_rx) = flume::unbounded();
|
||||||
|
let (reflector_tx, reflector_rx) = flume::unbounded();
|
||||||
|
let (reselect_tx, reselect_rx) = flume::bounded(1);
|
||||||
let (selection_snapshot_tx, selection_snapshot_rx) = if reselection_enabled {
|
let (selection_snapshot_tx, selection_snapshot_rx) = if reselection_enabled {
|
||||||
let (tx, rx) = flume::unbounded();
|
let (tx, rx) = flume::unbounded();
|
||||||
(Some(tx), Some(rx))
|
(Some(tx), Some(rx))
|
||||||
} else {
|
} else {
|
||||||
(None, None)
|
(None, None)
|
||||||
};
|
};
|
||||||
let (error_tx, error_rx) = flume::unbounded::<anyhow::Error>();
|
|
||||||
let (reselect_tx, reselect_rx) = flume::bounded(1);
|
let controller = Controller::new(reflector_rx, icmp_binding_tx);
|
||||||
|
let engine = {
|
||||||
|
let _guard = rt.enter();
|
||||||
|
IcmpEngine::new(
|
||||||
|
start_time,
|
||||||
|
&settings.network,
|
||||||
|
measurement_tx,
|
||||||
|
icmp_binding_rx,
|
||||||
|
)?
|
||||||
|
};
|
||||||
|
|
||||||
|
spawn_task(&rt, &error_tx, engine.run());
|
||||||
|
|
||||||
let dropped = Arc::new(AtomicU32::new(0));
|
let dropped = Arc::new(AtomicU32::new(0));
|
||||||
|
|
||||||
@@ -272,14 +268,7 @@ fn run(settings: &Settings) -> anyhow::Result<()> {
|
|||||||
metrics_rx: rx,
|
metrics_rx: rx,
|
||||||
metrics_dropped: Arc::clone(&dropped),
|
metrics_dropped: Arc::clone(&dropped),
|
||||||
};
|
};
|
||||||
let err_tx = error_tx.clone();
|
let handle = spawn_worker("metrics", &error_tx, move || metrics.run())?;
|
||||||
let handle = thread::Builder::new()
|
|
||||||
.name("metrics".to_string())
|
|
||||||
.spawn(move || {
|
|
||||||
if let Err(error) = metrics.run() {
|
|
||||||
let _ = err_tx.send(error);
|
|
||||||
}
|
|
||||||
})?;
|
|
||||||
(Some(tx), Some(handle))
|
(Some(tx), Some(handle))
|
||||||
} else {
|
} else {
|
||||||
(None, None)
|
(None, None)
|
||||||
@@ -309,82 +298,27 @@ fn run(settings: &Settings) -> anyhow::Result<()> {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
let (mut ping_listener, mut ping_sender) =
|
|
||||||
create_pinger(settings.advanced_settings.measurement_type);
|
|
||||||
|
|
||||||
let inflight_probe_capacity =
|
|
||||||
compute_inflight_probe_capacity(settings, active_reflector_count, reselection_enabled);
|
|
||||||
info!(
|
|
||||||
"In-flight probe cache capacity: {} (active_reflectors={}, reselection_enabled={}, tick_interval_s={})",
|
|
||||||
inflight_probe_capacity,
|
|
||||||
active_reflector_count,
|
|
||||||
reselection_enabled,
|
|
||||||
settings.advanced_settings.tick_interval
|
|
||||||
);
|
|
||||||
|
|
||||||
let inflight: InFlightProbeCache =
|
|
||||||
Arc::new(Mutex::new(HashMap::with_capacity(inflight_probe_capacity)));
|
|
||||||
|
|
||||||
let baseliner = Baseliner {
|
let baseliner = Baseliner {
|
||||||
settings: settings.clone(),
|
settings: settings.clone(),
|
||||||
reselect_trigger: reselect_tx.clone(),
|
reselect_trigger: reselect_tx.clone(),
|
||||||
start_time,
|
start_time,
|
||||||
stats_rx: baseliner_stats_rx,
|
stats_rx: measurement_rx,
|
||||||
control_tx: control_snapshot_tx,
|
control_tx: control_snapshot_tx,
|
||||||
selection_tx: selection_snapshot_tx,
|
selection_tx: selection_snapshot_tx,
|
||||||
baseline_metrics,
|
baseline_metrics,
|
||||||
event_metrics: event_metrics.clone(),
|
event_metrics: event_metrics.clone(),
|
||||||
|
ping_metrics,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut main_traffic_control = traffic_control_backend();
|
let mut main_traffic_control = traffic_control_backend();
|
||||||
let (down_shaper, up_shaper) = initialize_shaper(settings, &mut main_traffic_control)?;
|
let (down_shaper, up_shaper) = initialize_shaper(settings, &mut main_traffic_control)?;
|
||||||
|
|
||||||
let err_tx = error_tx.clone();
|
spawn_worker("baseliner", &error_tx, move || baseliner.run())?;
|
||||||
let listener_peers = Arc::clone(&reflector_peers);
|
spawn_task(
|
||||||
let listener_inflight = Arc::clone(&inflight);
|
&rt,
|
||||||
let measurement_type = settings.advanced_settings.measurement_type;
|
&error_tx,
|
||||||
thread::Builder::new()
|
controller.run(reflector_peers.read_anyhow()?.clone()),
|
||||||
.name("receiver".to_string())
|
);
|
||||||
.spawn(move || {
|
|
||||||
if let Err(error) = ping_listener.listen(
|
|
||||||
probe_id,
|
|
||||||
measurement_type,
|
|
||||||
listener_peers,
|
|
||||||
listener_inflight,
|
|
||||||
baseliner_stats_tx,
|
|
||||||
ping_metrics,
|
|
||||||
) {
|
|
||||||
let _ = err_tx.send(error);
|
|
||||||
}
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let err_tx = error_tx.clone();
|
|
||||||
thread::Builder::new()
|
|
||||||
.name("baseliner".to_string())
|
|
||||||
.spawn(move || {
|
|
||||||
if let Err(error) = baseliner.run() {
|
|
||||||
let _ = err_tx.send(error);
|
|
||||||
}
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let err_tx = error_tx.clone();
|
|
||||||
let sender_peers = Arc::clone(&reflector_peers);
|
|
||||||
let sender_inflight = Arc::clone(&inflight);
|
|
||||||
let measurement_type = settings.advanced_settings.measurement_type;
|
|
||||||
let tick_interval = settings.advanced_settings.tick_interval;
|
|
||||||
thread::Builder::new()
|
|
||||||
.name("sender".to_string())
|
|
||||||
.spawn(move || {
|
|
||||||
if let Err(error) = ping_sender.send(
|
|
||||||
probe_id,
|
|
||||||
measurement_type,
|
|
||||||
sender_peers,
|
|
||||||
sender_inflight,
|
|
||||||
tick_interval,
|
|
||||||
) {
|
|
||||||
let _ = err_tx.send(error);
|
|
||||||
}
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let main_event_metrics = event_metrics.clone();
|
let main_event_metrics = event_metrics.clone();
|
||||||
|
|
||||||
@@ -397,15 +331,9 @@ fn run(settings: &Settings) -> anyhow::Result<()> {
|
|||||||
reflector_pool,
|
reflector_pool,
|
||||||
trigger_channel: reselect_rx,
|
trigger_channel: reselect_rx,
|
||||||
metrics: event_metrics,
|
metrics: event_metrics,
|
||||||
|
reflector_tx,
|
||||||
};
|
};
|
||||||
let err_tx = error_tx.clone();
|
spawn_worker("reselection", &error_tx, move || reflector_selector.run())?;
|
||||||
thread::Builder::new()
|
|
||||||
.name("reselection".to_string())
|
|
||||||
.spawn(move || {
|
|
||||||
if let Err(error) = reflector_selector.run() {
|
|
||||||
let _ = err_tx.send(error);
|
|
||||||
}
|
|
||||||
})?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Give the baseliner time to collect initial samples before adjusting rates.
|
// Give the baseliner time to collect initial samples before adjusting rates.
|
||||||
@@ -419,14 +347,7 @@ fn run(settings: &Settings) -> anyhow::Result<()> {
|
|||||||
rate_metrics,
|
rate_metrics,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let err_tx = error_tx.clone();
|
spawn_worker("ratecontroller", &error_tx, move || ratecontroller.run())?;
|
||||||
thread::Builder::new()
|
|
||||||
.name("ratecontroller".to_string())
|
|
||||||
.spawn(move || {
|
|
||||||
if let Err(error) = ratecontroller.run() {
|
|
||||||
let _ = err_tx.send(error);
|
|
||||||
}
|
|
||||||
})?;
|
|
||||||
|
|
||||||
// Drop the original sender so the channel disconnects if all workers exit cleanly.
|
// Drop the original sender so the channel disconnects if all workers exit cleanly.
|
||||||
drop(error_tx);
|
drop(error_tx);
|
||||||
|
|||||||
@@ -0,0 +1,505 @@
|
|||||||
|
use std::{
|
||||||
|
collections::{HashMap, HashSet},
|
||||||
|
io,
|
||||||
|
net::IpAddr,
|
||||||
|
time::{Duration, Instant, SystemTime},
|
||||||
|
};
|
||||||
|
|
||||||
|
use flume::{Receiver, Sender};
|
||||||
|
use icmp_socket2::{
|
||||||
|
AsyncIcmpSocket, IcmpSocket4, Icmpv4Message, Icmpv4Packet,
|
||||||
|
packet::{IcmpPacketBuildError, WithEchoRequest, WithTimestampRequest},
|
||||||
|
tokio::AsyncIcmpV4Socket,
|
||||||
|
};
|
||||||
|
use log::debug;
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
measurement::model::{
|
||||||
|
MeasurementEvent, MeasurementLoss, MeasurementObservation, MeasurementSource,
|
||||||
|
MeasurementStream, MeasurementStreamId, OneWayClock, OneWayLatency, ProbeSchedule,
|
||||||
|
SignedDuration,
|
||||||
|
},
|
||||||
|
settings::NetworkSettings,
|
||||||
|
time::{ClockSample, Realtime},
|
||||||
|
};
|
||||||
|
|
||||||
|
pub struct IcmpBinding {
|
||||||
|
pub stream: MeasurementStream,
|
||||||
|
pub schedule: ProbeSchedule,
|
||||||
|
|
||||||
|
next_probe_at: Instant,
|
||||||
|
next_sequence: u16,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IcmpBinding {
|
||||||
|
pub fn new(stream: MeasurementStream, schedule: ProbeSchedule) -> Self {
|
||||||
|
Self {
|
||||||
|
stream,
|
||||||
|
schedule,
|
||||||
|
next_probe_at: Instant::now(),
|
||||||
|
next_sequence: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum IcmpError {
|
||||||
|
#[error("I/O error")]
|
||||||
|
Io(#[from] io::Error),
|
||||||
|
|
||||||
|
#[error("failed to build ICMP packet")]
|
||||||
|
PacketBuild(#[from] IcmpPacketBuildError),
|
||||||
|
|
||||||
|
#[error("invalid ICMP packet: {0}")]
|
||||||
|
InvalidPacket(String),
|
||||||
|
|
||||||
|
#[error("unsupported measurement source: {0:?}")]
|
||||||
|
UnsupportedSource(MeasurementSource),
|
||||||
|
|
||||||
|
#[error("probe interval must be non-zero for stream {0:?}")]
|
||||||
|
InvalidInterval(MeasurementStreamId),
|
||||||
|
|
||||||
|
#[error("probe offset must be less than the period for stream {0:?}")]
|
||||||
|
InvalidOffset(MeasurementStreamId),
|
||||||
|
|
||||||
|
#[error(
|
||||||
|
"no matching probe found for peer {:?}, source: {:?}, sequence: {}",
|
||||||
|
.0.0,
|
||||||
|
.0.1,
|
||||||
|
.0.2
|
||||||
|
)]
|
||||||
|
NoMatchingProbe(InFlightProbeKey),
|
||||||
|
|
||||||
|
#[error("wrong identifier: expected {expected}, found {found}")]
|
||||||
|
WrongIdentifier { expected: u16, found: u16 },
|
||||||
|
|
||||||
|
#[error("unsupported ICMP peer address: {0}")]
|
||||||
|
UnsupportedPeer(IpAddr),
|
||||||
|
|
||||||
|
#[error("event channel closed")]
|
||||||
|
EventChannelClosed,
|
||||||
|
|
||||||
|
#[error("binding channel closed")]
|
||||||
|
BindingChannelClosed,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
struct InFlightProbe {
|
||||||
|
stream: MeasurementStream,
|
||||||
|
sent_at: Instant,
|
||||||
|
}
|
||||||
|
|
||||||
|
type InFlightProbeKey = (IpAddr, MeasurementSource, u16);
|
||||||
|
type InFlightProbes = HashMap<InFlightProbeKey, InFlightProbe>;
|
||||||
|
|
||||||
|
pub struct IcmpEngine {
|
||||||
|
socket: AsyncIcmpV4Socket,
|
||||||
|
|
||||||
|
identifier: u16,
|
||||||
|
|
||||||
|
bindings: HashMap<MeasurementStreamId, IcmpBinding>,
|
||||||
|
inflight: HashMap<InFlightProbeKey, InFlightProbe>,
|
||||||
|
|
||||||
|
origin: Instant,
|
||||||
|
|
||||||
|
binding_rx: Receiver<Vec<IcmpBinding>>,
|
||||||
|
observation_tx: Sender<MeasurementEvent>,
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn wait_for_deadline(deadline: Option<Instant>) {
|
||||||
|
match deadline {
|
||||||
|
Some(deadline) => {
|
||||||
|
tokio::time::sleep_until(tokio::time::Instant::from_std(deadline)).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
None => {
|
||||||
|
std::future::pending::<()>().await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IcmpEngine {
|
||||||
|
pub fn new(
|
||||||
|
origin: Instant,
|
||||||
|
#[allow(unused)] settings: &NetworkSettings,
|
||||||
|
observation_tx: Sender<MeasurementEvent>,
|
||||||
|
binding_rx: Receiver<Vec<IcmpBinding>>,
|
||||||
|
) -> Result<Self, IcmpError> {
|
||||||
|
#[allow(unused_mut)]
|
||||||
|
let mut socket = IcmpSocket4::new()?;
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
|
||||||
|
if let Some(device) = &settings.measurement_bind_device {
|
||||||
|
icmp_socket2::IcmpSocket::bind_device(&mut socket, device)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
|
||||||
|
if let Some(mark) = settings.measurement_mark {
|
||||||
|
icmp_socket2::IcmpSocket::set_mark(&mut socket, mark)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "freebsd")]
|
||||||
|
if let Some(fib) = settings.measurement_fib {
|
||||||
|
icmp_socket2::IcmpSocket::set_fib(&mut socket, fib)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.enable_receive_metadata()?;
|
||||||
|
let identifier = (std::process::id() & 0xffff) as u16;
|
||||||
|
let inflight: InFlightProbes = HashMap::new();
|
||||||
|
|
||||||
|
Ok(Self {
|
||||||
|
socket: socket.into_tokio()?,
|
||||||
|
identifier,
|
||||||
|
bindings: HashMap::new(),
|
||||||
|
inflight,
|
||||||
|
origin,
|
||||||
|
binding_rx,
|
||||||
|
observation_tx,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_bindings(&mut self, desired: Vec<IcmpBinding>) -> Result<(), IcmpError> {
|
||||||
|
// Validate the complete desired state before mutating anything.
|
||||||
|
for binding in &desired {
|
||||||
|
if binding.schedule.period.is_zero() {
|
||||||
|
return Err(IcmpError::InvalidInterval(binding.stream.id));
|
||||||
|
}
|
||||||
|
|
||||||
|
if binding.schedule.offset >= binding.schedule.period {
|
||||||
|
return Err(IcmpError::InvalidOffset(binding.stream.id));
|
||||||
|
}
|
||||||
|
|
||||||
|
if !matches!(
|
||||||
|
binding.stream.source,
|
||||||
|
MeasurementSource::IcmpEcho | MeasurementSource::IcmpTimestamp
|
||||||
|
) {
|
||||||
|
return Err(IcmpError::UnsupportedSource(binding.stream.source));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let now = Instant::now();
|
||||||
|
let desired_ids = desired
|
||||||
|
.iter()
|
||||||
|
.map(|binding| binding.stream.id)
|
||||||
|
.collect::<HashSet<_>>();
|
||||||
|
|
||||||
|
// Remove bindings that are no longer desired.
|
||||||
|
self.bindings.retain(|id, _| desired_ids.contains(id));
|
||||||
|
self.inflight
|
||||||
|
.retain(|_, probe| desired_ids.contains(&probe.stream.id));
|
||||||
|
|
||||||
|
for desired in desired {
|
||||||
|
match self.bindings.get_mut(&desired.stream.id) {
|
||||||
|
Some(current) if current.schedule == desired.schedule => {
|
||||||
|
// Same schedule, so leave next_probe_at alone.
|
||||||
|
current.stream = desired.stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(current) => {
|
||||||
|
// Same stream, but its schedule changed. Rejoin the new grid.
|
||||||
|
current.stream = desired.stream;
|
||||||
|
current.schedule = desired.schedule;
|
||||||
|
current.next_probe_at = desired.schedule.next_probe_at(self.origin, now);
|
||||||
|
}
|
||||||
|
|
||||||
|
None => {
|
||||||
|
// New stream. Join its configured schedule at the next
|
||||||
|
// occurrence after now.
|
||||||
|
let mut binding = desired;
|
||||||
|
binding.next_probe_at = binding.schedule.next_probe_at(self.origin, now);
|
||||||
|
|
||||||
|
self.bindings.insert(binding.stream.id, binding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn send_due_probes(&mut self, now: Instant) -> Result<(), IcmpError> {
|
||||||
|
let due = self
|
||||||
|
.bindings
|
||||||
|
.iter()
|
||||||
|
.filter_map(|(&stream_id, binding)| (binding.next_probe_at <= now).then_some(stream_id))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
for stream_id in due {
|
||||||
|
self.send_probe(stream_id).await?;
|
||||||
|
|
||||||
|
let binding = self
|
||||||
|
.bindings
|
||||||
|
.get_mut(&stream_id)
|
||||||
|
.expect("due binding disappeared");
|
||||||
|
|
||||||
|
binding.next_probe_at = binding.schedule.next_probe_at(self.origin, now);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn send_probe(&mut self, stream_id: MeasurementStreamId) -> Result<(), IcmpError> {
|
||||||
|
let (stream, sequence) = {
|
||||||
|
let binding = self
|
||||||
|
.bindings
|
||||||
|
.get_mut(&stream_id)
|
||||||
|
.expect("binding disappeared");
|
||||||
|
|
||||||
|
let sequence = binding.next_sequence;
|
||||||
|
binding.next_sequence = binding.next_sequence.wrapping_add(1);
|
||||||
|
|
||||||
|
(binding.stream, sequence)
|
||||||
|
};
|
||||||
|
|
||||||
|
let IpAddr::V4(peer) = stream.peer else {
|
||||||
|
return Err(IcmpError::UnsupportedPeer(stream.peer));
|
||||||
|
};
|
||||||
|
|
||||||
|
let packet = match stream.source {
|
||||||
|
MeasurementSource::IcmpEcho => {
|
||||||
|
Icmpv4Packet::with_echo_request(self.identifier, sequence, Vec::new())?
|
||||||
|
}
|
||||||
|
MeasurementSource::IcmpTimestamp => {
|
||||||
|
let originate = ClockSample::<Realtime>::now().as_time_since_midnight() as u32;
|
||||||
|
Icmpv4Packet::with_timestamp_request(self.identifier, sequence, originate, 0, 0)?
|
||||||
|
}
|
||||||
|
source => return Err(IcmpError::UnsupportedSource(source)),
|
||||||
|
};
|
||||||
|
|
||||||
|
let sent_at = Instant::now();
|
||||||
|
let key = (stream.peer, stream.source, sequence);
|
||||||
|
|
||||||
|
self.socket.send_to(peer, packet).await?;
|
||||||
|
self.inflight.insert(key, InFlightProbe { stream, sent_at });
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn next_deadline(&self) -> Option<Instant> {
|
||||||
|
self.bindings
|
||||||
|
.values()
|
||||||
|
.map(|binding| binding.next_probe_at)
|
||||||
|
.min()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_reply(
|
||||||
|
&mut self,
|
||||||
|
packet: Icmpv4Packet,
|
||||||
|
peer: IpAddr,
|
||||||
|
observed_at: Instant,
|
||||||
|
kernel_rx_timestamp: Option<SystemTime>,
|
||||||
|
) -> Result<MeasurementObservation, IcmpError> {
|
||||||
|
match packet.message {
|
||||||
|
Icmpv4Message::EchoReply {
|
||||||
|
identifier,
|
||||||
|
sequence,
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
if identifier != self.identifier {
|
||||||
|
return Err(IcmpError::WrongIdentifier {
|
||||||
|
expected: self.identifier,
|
||||||
|
found: identifier,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let key = (peer, MeasurementSource::IcmpEcho, sequence);
|
||||||
|
let probe = self
|
||||||
|
.inflight
|
||||||
|
.remove(&key)
|
||||||
|
.ok_or(IcmpError::NoMatchingProbe(key))?;
|
||||||
|
|
||||||
|
debug!(
|
||||||
|
"ICMP engine > Type: {:4} | Reflector IP: {:>15} | Seq: {:5} | Current time: {:8} | Originate: {:>8} | Received time: {:>8} | Transmit time: {:>8} | RTT: {:8.3} ms | UL time: {:>8} | DL time: {:>8}",
|
||||||
|
"ICMP",
|
||||||
|
peer,
|
||||||
|
sequence,
|
||||||
|
ClockSample::<Realtime>::now().as_time_since_midnight(),
|
||||||
|
"N/A",
|
||||||
|
"N/A",
|
||||||
|
"N/A",
|
||||||
|
observed_at.duration_since(probe.sent_at).as_secs_f64() * 1_000.0,
|
||||||
|
"N/A",
|
||||||
|
"N/A",
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(MeasurementObservation {
|
||||||
|
stream: probe.stream,
|
||||||
|
started_at: probe.sent_at,
|
||||||
|
observed_at,
|
||||||
|
one_way: None,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Icmpv4Message::TimestampReply {
|
||||||
|
identifier,
|
||||||
|
sequence,
|
||||||
|
originate,
|
||||||
|
receive,
|
||||||
|
transmit,
|
||||||
|
} => {
|
||||||
|
if identifier != self.identifier {
|
||||||
|
return Err(IcmpError::WrongIdentifier {
|
||||||
|
expected: self.identifier,
|
||||||
|
found: identifier,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if originate >= MS_PER_DAY as u32
|
||||||
|
|| receive >= MS_PER_DAY as u32
|
||||||
|
|| transmit >= MS_PER_DAY as u32
|
||||||
|
{
|
||||||
|
return Err(IcmpError::InvalidPacket(
|
||||||
|
"non-standard RFC 792 timestamp".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
let key = (peer, MeasurementSource::IcmpTimestamp, sequence);
|
||||||
|
let probe = self
|
||||||
|
.inflight
|
||||||
|
.remove(&key)
|
||||||
|
.ok_or(IcmpError::NoMatchingProbe(key))?;
|
||||||
|
|
||||||
|
let now_ms = if let Some(timestamp) = kernel_rx_timestamp {
|
||||||
|
ClockSample::<Realtime>::from(timestamp).as_time_since_midnight()
|
||||||
|
} else {
|
||||||
|
ClockSample::<Realtime>::now().as_time_since_midnight()
|
||||||
|
};
|
||||||
|
|
||||||
|
let uplink_ms = timestamp_delta(receive as i64, originate as i64);
|
||||||
|
let downlink_ms = timestamp_delta(now_ms, transmit as i64);
|
||||||
|
|
||||||
|
debug!(
|
||||||
|
"ICMP engine > Type: {:4} | Reflector IP: {:>15} | Seq: {:5} | Current time: {:8} | Originate: {:8} | Received time: {:8} | Transmit time: {:8} | RTT: {:8.3} ms | UL time: {:5} ms | DL time: {:5} ms",
|
||||||
|
"ICMP",
|
||||||
|
peer,
|
||||||
|
sequence,
|
||||||
|
now_ms,
|
||||||
|
originate,
|
||||||
|
receive,
|
||||||
|
transmit,
|
||||||
|
observed_at.duration_since(probe.sent_at).as_secs_f64() * 1_000.0,
|
||||||
|
uplink_ms,
|
||||||
|
downlink_ms,
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(MeasurementObservation {
|
||||||
|
stream: probe.stream,
|
||||||
|
started_at: probe.sent_at,
|
||||||
|
observed_at,
|
||||||
|
one_way: Some(OneWayLatency {
|
||||||
|
uplink: SignedDuration::from_millis(uplink_ms),
|
||||||
|
downlink: SignedDuration::from_millis(downlink_ms),
|
||||||
|
clock: OneWayClock::Uncalibrated,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
_ => Err(IcmpError::InvalidPacket(
|
||||||
|
"unsupported ICMP message type".to_string(),
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn expire_inflight(&mut self, now: Instant) -> Result<(), IcmpError> {
|
||||||
|
const PROBE_TIMEOUT: Duration = Duration::from_secs(30);
|
||||||
|
|
||||||
|
let expired = {
|
||||||
|
let mut expired = Vec::new();
|
||||||
|
|
||||||
|
self.inflight.retain(|_, probe| {
|
||||||
|
if now.saturating_duration_since(probe.sent_at) >= PROBE_TIMEOUT {
|
||||||
|
expired.push(*probe);
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expired
|
||||||
|
};
|
||||||
|
|
||||||
|
for probe in expired {
|
||||||
|
self.observation_tx
|
||||||
|
.send_async(MeasurementEvent::Loss(MeasurementLoss {
|
||||||
|
stream: probe.stream,
|
||||||
|
started_at: probe.sent_at,
|
||||||
|
detected_at: now,
|
||||||
|
}))
|
||||||
|
.await
|
||||||
|
.map_err(|_| IcmpError::EventChannelClosed)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn run(mut self) -> Result<(), IcmpError> {
|
||||||
|
const HOUSEKEEPING_INTERVAL: Duration = Duration::from_millis(500);
|
||||||
|
|
||||||
|
let mut housekeeping = tokio::time::interval_at(
|
||||||
|
tokio::time::Instant::now() + HOUSEKEEPING_INTERVAL,
|
||||||
|
HOUSEKEEPING_INTERVAL,
|
||||||
|
);
|
||||||
|
|
||||||
|
housekeeping.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
|
||||||
|
|
||||||
|
loop {
|
||||||
|
let deadline = self.next_deadline();
|
||||||
|
|
||||||
|
tokio::select! {
|
||||||
|
bindings = self.binding_rx.recv_async() => {
|
||||||
|
let bindings = bindings
|
||||||
|
.map_err(|_| IcmpError::BindingChannelClosed)?;
|
||||||
|
|
||||||
|
self.set_bindings(bindings)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = wait_for_deadline(deadline) => {
|
||||||
|
self.send_due_probes(Instant::now()).await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = self.socket.rcv_from_with_meta() => {
|
||||||
|
let result = result?;
|
||||||
|
|
||||||
|
match self.handle_reply(
|
||||||
|
result.packet,
|
||||||
|
result.peer.as_socket().unwrap().ip(),
|
||||||
|
result.received_at,
|
||||||
|
result.kernel_rx_timestamp,
|
||||||
|
) {
|
||||||
|
Ok(observation) => {
|
||||||
|
self.observation_tx
|
||||||
|
.send_async(MeasurementEvent::Observation(observation))
|
||||||
|
.await
|
||||||
|
.map_err(|_| IcmpError::EventChannelClosed)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Err(
|
||||||
|
IcmpError::WrongIdentifier { .. }
|
||||||
|
| IcmpError::NoMatchingProbe { .. }
|
||||||
|
| IcmpError::InvalidPacket(_),
|
||||||
|
) => {
|
||||||
|
// Not ours, malformed, or late.
|
||||||
|
}
|
||||||
|
|
||||||
|
Err(err) => return Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = housekeeping.tick() => {
|
||||||
|
self.expire_inflight(Instant::now()).await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const MS_PER_DAY: i64 = 86_400_000;
|
||||||
|
|
||||||
|
fn timestamp_delta(later: i64, earlier: i64) -> i64 {
|
||||||
|
let delta = later - earlier;
|
||||||
|
if delta < -MS_PER_DAY / 2 {
|
||||||
|
delta + MS_PER_DAY
|
||||||
|
} else if delta > MS_PER_DAY / 2 {
|
||||||
|
delta - MS_PER_DAY
|
||||||
|
} else {
|
||||||
|
delta
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
pub(crate) mod icmp;
|
||||||
|
pub(crate) mod model;
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
use std::fmt::{self, Display};
|
||||||
|
use std::{
|
||||||
|
net::IpAddr,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
pub struct MeasurementStreamId(pub u64);
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
pub enum MeasurementSource {
|
||||||
|
IcmpEcho,
|
||||||
|
IcmpTimestamp,
|
||||||
|
Irtt,
|
||||||
|
TcpSeqAck,
|
||||||
|
TcpTimestamp,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for MeasurementSource {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match self {
|
||||||
|
MeasurementSource::IcmpEcho => write!(f, "icmp"),
|
||||||
|
MeasurementSource::IcmpTimestamp => write!(f, "icmp-timestamps"),
|
||||||
|
MeasurementSource::Irtt => write!(f, "irtt"),
|
||||||
|
MeasurementSource::TcpSeqAck => write!(f, "tcp-seqack"),
|
||||||
|
MeasurementSource::TcpTimestamp => write!(f, "tcp-timestamp"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
pub struct MeasurementStream {
|
||||||
|
pub id: MeasurementStreamId,
|
||||||
|
pub peer: IpAddr,
|
||||||
|
pub source: MeasurementSource,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
pub enum OneWayClock {
|
||||||
|
Uncalibrated,
|
||||||
|
Calibrated,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
pub struct ProbeSchedule {
|
||||||
|
pub period: Duration,
|
||||||
|
pub offset: Duration,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ProbeSchedule {
|
||||||
|
pub(crate) fn next_probe_at(&self, origin: Instant, now: Instant) -> Instant {
|
||||||
|
const NANOS_PER_SEC: u128 = 1_000_000_000;
|
||||||
|
|
||||||
|
let first = origin + self.offset;
|
||||||
|
|
||||||
|
if now < first {
|
||||||
|
return first;
|
||||||
|
}
|
||||||
|
|
||||||
|
let elapsed_ns = now.duration_since(first).as_nanos();
|
||||||
|
let period_ns = self.period.as_nanos();
|
||||||
|
let remainder = elapsed_ns % period_ns;
|
||||||
|
|
||||||
|
let until_next = if remainder == 0 {
|
||||||
|
period_ns
|
||||||
|
} else {
|
||||||
|
period_ns - remainder
|
||||||
|
};
|
||||||
|
|
||||||
|
let until_next = Duration::new(
|
||||||
|
(until_next / NANOS_PER_SEC) as u64,
|
||||||
|
(until_next % NANOS_PER_SEC) as u32,
|
||||||
|
);
|
||||||
|
|
||||||
|
now + until_next
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
|
pub struct SignedDuration {
|
||||||
|
nanos: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
impl SignedDuration {
|
||||||
|
pub const fn from_nanos(nanos: i64) -> Self {
|
||||||
|
Self { nanos }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const fn from_millis(millis: i64) -> Self {
|
||||||
|
Self {
|
||||||
|
nanos: millis * 1_000_000,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const fn as_nanos(self) -> i64 {
|
||||||
|
self.nanos
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn as_secs_f64(self) -> f64 {
|
||||||
|
self.nanos as f64 / 1_000_000_000.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
pub struct OneWayLatency {
|
||||||
|
pub uplink: SignedDuration,
|
||||||
|
pub downlink: SignedDuration,
|
||||||
|
pub clock: OneWayClock,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
pub struct MeasurementObservation {
|
||||||
|
pub stream: MeasurementStream,
|
||||||
|
|
||||||
|
/// Local monotonic time at which measurement started.
|
||||||
|
pub started_at: Instant,
|
||||||
|
|
||||||
|
/// Local monotonic time at which the result was observed.
|
||||||
|
pub observed_at: Instant,
|
||||||
|
|
||||||
|
/// Directional timing, when the measurement mechanism can provide it.
|
||||||
|
pub one_way: Option<OneWayLatency>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MeasurementObservation {
|
||||||
|
pub fn rtt(&self) -> Duration {
|
||||||
|
self.observed_at.duration_since(self.started_at)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn rtt_ms(&self) -> f64 {
|
||||||
|
self.rtt().as_secs_f64() * 1000.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub struct MeasurementLoss {
|
||||||
|
pub stream: MeasurementStream,
|
||||||
|
pub started_at: Instant,
|
||||||
|
pub detected_at: Instant,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub enum MeasurementEvent {
|
||||||
|
Observation(MeasurementObservation),
|
||||||
|
Loss(MeasurementLoss),
|
||||||
|
}
|
||||||
+6
-6
@@ -2,12 +2,12 @@
|
|||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
|
use crate::measurement::model::MeasurementSource;
|
||||||
|
use crate::settings::ObservabilityProtocol;
|
||||||
use crate::settings::Settings;
|
use crate::settings::Settings;
|
||||||
use crate::settings::{MeasurementType, ObservabilityProtocol};
|
use crate::time::{ClockSample, Realtime};
|
||||||
use crate::time::Time;
|
|
||||||
use flume::{Receiver, RecvTimeoutError, Sender};
|
use flume::{Receiver, RecvTimeoutError, Sender};
|
||||||
use log::{error, info, warn};
|
use log::{error, info, warn};
|
||||||
use rustix::time::ClockId;
|
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::net::{IpAddr, TcpStream, UdpSocket};
|
use std::net::{IpAddr, TcpStream, UdpSocket};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -94,7 +94,7 @@ impl Transport {
|
|||||||
pub enum Metric {
|
pub enum Metric {
|
||||||
Ping {
|
Ping {
|
||||||
reflector: IpAddr,
|
reflector: IpAddr,
|
||||||
measurement_type: MeasurementType,
|
measurement_type: MeasurementSource,
|
||||||
rtt: f64,
|
rtt: f64,
|
||||||
up_time: f64,
|
up_time: f64,
|
||||||
down_time: f64,
|
down_time: f64,
|
||||||
@@ -148,7 +148,7 @@ impl MetricsSender {
|
|||||||
|
|
||||||
pub fn send(&self, metric: Metric) {
|
pub fn send(&self, metric: Metric) {
|
||||||
if let Some(ref tx) = self.tx {
|
if let Some(ref tx) = self.tx {
|
||||||
let ts = Time::new(ClockId::Realtime).as_nanos();
|
let ts = ClockSample::<Realtime>::now().as_nanos();
|
||||||
if tx.try_send((metric, ts)).is_err() {
|
if tx.try_send((metric, ts)).is_err() {
|
||||||
self.dropped.fetch_add(1, Ordering::Relaxed);
|
self.dropped.fetch_add(1, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
@@ -197,7 +197,7 @@ impl Metrics {
|
|||||||
Err(RecvTimeoutError::Timeout) => {
|
Err(RecvTimeoutError::Timeout) => {
|
||||||
let dropped = self.metrics_dropped.swap(0, Ordering::Relaxed);
|
let dropped = self.metrics_dropped.swap(0, Ordering::Relaxed);
|
||||||
if dropped > 0 {
|
if dropped > 0 {
|
||||||
let ts = Time::new(ClockId::Realtime).as_nanos();
|
let ts = ClockSample::<Realtime>::now().as_nanos();
|
||||||
batch.push((Metric::Dropped { count: dropped }, ts));
|
batch.push((Metric::Dropped { count: dropped }, ts));
|
||||||
}
|
}
|
||||||
if !batch.is_empty() {
|
if !batch.is_empty() {
|
||||||
|
|||||||
-214
@@ -1,214 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2022-Present Charles Corrigan mailto:chas-iot@runegate.org (github @chas-iot)
|
|
||||||
// SPDX-FileCopyrightText: 2022-Present Daniel Lakeland mailto:dlakelan@street-artists.org (github @dlakelan)
|
|
||||||
// SPDX-FileCopyrightText: 2022-Present Mark Baker mailto:mark@vpost.net (github @Fail-Safe)
|
|
||||||
// SPDX-FileCopyrightText: 2022-Present Nils Andreas Svee mailto:contact@lochnair.net (github @Lochnair)
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
|
||||||
|
|
||||||
use crate::MeasurementType;
|
|
||||||
use crate::SHUTDOWN;
|
|
||||||
use crate::metrics::{Metric, MetricsSender};
|
|
||||||
use crate::util::{MutexExt, RwLockExt};
|
|
||||||
use flume::Sender;
|
|
||||||
use icmp_socket2::socket::IcmpSocket;
|
|
||||||
use icmp_socket2::{IcmpSocket4, Icmpv4Packet};
|
|
||||||
use log::{debug, info, warn};
|
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::net::{IpAddr, Ipv4Addr};
|
|
||||||
use std::sync::atomic::Ordering;
|
|
||||||
use std::sync::{Arc, Mutex, RwLock};
|
|
||||||
use std::time::{Duration, Instant};
|
|
||||||
use std::{io, thread};
|
|
||||||
use thiserror::Error;
|
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
|
||||||
pub enum PingError {
|
|
||||||
#[error("Couldn't parse number")]
|
|
||||||
InvalidNumber(#[from] io::Error),
|
|
||||||
#[error("Error parsing packet")]
|
|
||||||
InvalidPacket(String),
|
|
||||||
#[error("Invalid packet type")]
|
|
||||||
InvalidType(String),
|
|
||||||
#[error("Wrong ICMP identifier (expected {expected:?}, found {found:?})")]
|
|
||||||
WrongID { expected: u16, found: u16 },
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct PingReply {
|
|
||||||
pub reflector: IpAddr,
|
|
||||||
pub measurement_type: MeasurementType,
|
|
||||||
pub seq: u16,
|
|
||||||
pub rtt: f64,
|
|
||||||
pub current_time: i64,
|
|
||||||
pub down_time: f64,
|
|
||||||
pub up_time: f64,
|
|
||||||
pub originate_timestamp: i64,
|
|
||||||
pub receive_timestamp: i64,
|
|
||||||
pub transmit_timestamp: i64,
|
|
||||||
pub last_receive_time_s: Instant,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
|
||||||
pub struct InFlightProbe {
|
|
||||||
pub sent_at: Instant,
|
|
||||||
pub originate_timestamp: i64,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type InFlightProbeKey = (IpAddr, MeasurementType, u16);
|
|
||||||
pub type InFlightProbeCache = Arc<Mutex<HashMap<InFlightProbeKey, InFlightProbe>>>;
|
|
||||||
const INFLIGHT_PROBE_TTL: Duration = Duration::from_secs(30);
|
|
||||||
|
|
||||||
fn open_socket(type_: MeasurementType) -> io::Result<IcmpSocket4> {
|
|
||||||
match type_ {
|
|
||||||
MeasurementType::Icmp | MeasurementType::IcmpTimestamps => IcmpSocket4::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait PingListener {
|
|
||||||
fn listen(
|
|
||||||
&mut self,
|
|
||||||
id: u16,
|
|
||||||
type_: MeasurementType,
|
|
||||||
reflectors_lock: Arc<RwLock<Vec<IpAddr>>>,
|
|
||||||
inflight: InFlightProbeCache,
|
|
||||||
stats_tx: Sender<PingReply>,
|
|
||||||
ping_metrics: MetricsSender,
|
|
||||||
) -> anyhow::Result<()> {
|
|
||||||
let socket = &mut open_socket(type_)?;
|
|
||||||
|
|
||||||
loop {
|
|
||||||
if SHUTDOWN.load(Ordering::Relaxed) {
|
|
||||||
info!("Ping listener shutting down");
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
let (pkt, sender) = match socket.rcv_from() {
|
|
||||||
Ok(val) => val,
|
|
||||||
Err(_) => continue,
|
|
||||||
};
|
|
||||||
|
|
||||||
let addr: IpAddr = sender.as_socket().unwrap().ip();
|
|
||||||
|
|
||||||
let reflectors = reflectors_lock.read_anyhow()?;
|
|
||||||
if !reflectors.contains(&addr) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let reply = match self.parse_packet(id, addr, type_, pkt) {
|
|
||||||
Ok(val) => val,
|
|
||||||
Err(_) => {
|
|
||||||
// parse_packet will throw an error if it's an unknown protocol etc.
|
|
||||||
// so just quietly move on
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let key = (addr, type_, reply.seq);
|
|
||||||
let Some(probe) = inflight.lock_anyhow()?.remove(&key) else {
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
if reply.originate_timestamp != probe.originate_timestamp {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ping_metrics.send(Metric::Ping {
|
|
||||||
reflector: reply.reflector,
|
|
||||||
measurement_type: reply.measurement_type,
|
|
||||||
rtt: reply.rtt,
|
|
||||||
up_time: reply.up_time,
|
|
||||||
down_time: reply.down_time,
|
|
||||||
});
|
|
||||||
|
|
||||||
debug!(
|
|
||||||
"Type: {:4} | Reflector IP: {:>15} | Seq: {:5} | Current time: {:8} | Originate: {:8} | Received time: {:8} | Transmit time : {:8} | RTT: {:8} | UL time: {:5} | DL time: {:5}",
|
|
||||||
"ICMP",
|
|
||||||
addr.to_string(),
|
|
||||||
reply.seq,
|
|
||||||
reply.current_time,
|
|
||||||
reply.originate_timestamp,
|
|
||||||
reply.receive_timestamp,
|
|
||||||
reply.transmit_timestamp,
|
|
||||||
reply.rtt,
|
|
||||||
reply.up_time,
|
|
||||||
reply.down_time
|
|
||||||
);
|
|
||||||
if let Err(e) = stats_tx.send(reply) {
|
|
||||||
warn!("Stats channel closed, stopping listener: {}", e);
|
|
||||||
break Ok(());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse_packet(
|
|
||||||
&self,
|
|
||||||
id: u16,
|
|
||||||
reflector: IpAddr,
|
|
||||||
measurement_type: MeasurementType,
|
|
||||||
pkt: Icmpv4Packet,
|
|
||||||
) -> Result<PingReply, PingError>;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait PingSender {
|
|
||||||
fn send(
|
|
||||||
&mut self,
|
|
||||||
id: u16,
|
|
||||||
type_: MeasurementType,
|
|
||||||
reflectors_lock: Arc<RwLock<Vec<IpAddr>>>,
|
|
||||||
inflight: InFlightProbeCache,
|
|
||||||
tick_interval: f64,
|
|
||||||
) -> anyhow::Result<()> {
|
|
||||||
let mut socket = open_socket(type_)?;
|
|
||||||
|
|
||||||
let mut seq: u16 = 0;
|
|
||||||
let tick_duration_ms: u16 = (tick_interval * 1000.0) as u16;
|
|
||||||
|
|
||||||
loop {
|
|
||||||
if SHUTDOWN.load(Ordering::Relaxed) {
|
|
||||||
info!("Ping sender shutting down");
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
// Clone the reflectors vec and drop the read lock immediately —
|
|
||||||
// holding it for the entire tick would starve the reflector selector's write lock.
|
|
||||||
let reflectors_unlocked = reflectors_lock.read_anyhow()?;
|
|
||||||
let reflectors = reflectors_unlocked.clone();
|
|
||||||
drop(reflectors_unlocked);
|
|
||||||
|
|
||||||
if reflectors.is_empty() {
|
|
||||||
thread::sleep(Duration::from_millis(tick_duration_ms as u64));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
inflight
|
|
||||||
.lock_anyhow()?
|
|
||||||
.retain(|_, probe| probe.sent_at.elapsed() < INFLIGHT_PROBE_TTL);
|
|
||||||
|
|
||||||
let sleep_duration =
|
|
||||||
Duration::from_millis((tick_duration_ms / reflectors.len() as u16) as u64);
|
|
||||||
|
|
||||||
for reflector in reflectors.iter() {
|
|
||||||
let addr: Ipv4Addr = match reflector {
|
|
||||||
IpAddr::V4(ipv4) => *ipv4,
|
|
||||||
IpAddr::V6(_) => unimplemented!(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let (packet, originate_timestamp) = self.craft_packet(id, seq);
|
|
||||||
let sent_at = Instant::now();
|
|
||||||
let key = (*reflector, type_, seq);
|
|
||||||
inflight.lock_anyhow()?.insert(
|
|
||||||
key,
|
|
||||||
InFlightProbe {
|
|
||||||
sent_at,
|
|
||||||
originate_timestamp,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
if let Err(e) = socket.send_to(addr, packet) {
|
|
||||||
inflight.lock_anyhow()?.remove(&key);
|
|
||||||
return Err(e.into());
|
|
||||||
}
|
|
||||||
thread::sleep(sleep_duration);
|
|
||||||
}
|
|
||||||
|
|
||||||
seq = seq.wrapping_add(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn craft_packet(&self, id: u16, seq: u16) -> (icmp_socket2::packet::Icmpv4Packet, i64);
|
|
||||||
}
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2022-Present Charles Corrigan mailto:chas-iot@runegate.org (github @chas-iot)
|
|
||||||
// SPDX-FileCopyrightText: 2022-Present Daniel Lakeland mailto:dlakelan@street-artists.org (github @dlakelan)
|
|
||||||
// SPDX-FileCopyrightText: 2022-Present Mark Baker mailto:mark@vpost.net (github @Fail-Safe)
|
|
||||||
// SPDX-FileCopyrightText: 2022-Present Nils Andreas Svee mailto:contact@lochnair.net (github @Lochnair)
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
|
||||||
|
|
||||||
use std::net::IpAddr;
|
|
||||||
use std::time::Instant;
|
|
||||||
|
|
||||||
use crate::pinger::{PingError, PingListener, PingReply, PingSender};
|
|
||||||
use crate::settings::MeasurementType;
|
|
||||||
use crate::time::Time;
|
|
||||||
use icmp_socket2::Icmpv4Message;
|
|
||||||
use icmp_socket2::Icmpv4Packet;
|
|
||||||
use icmp_socket2::packet::WithEchoRequest;
|
|
||||||
use rustix::time::ClockId;
|
|
||||||
|
|
||||||
pub struct PingerICMPEchoListener {}
|
|
||||||
|
|
||||||
pub struct PingerICMPEchoSender {}
|
|
||||||
|
|
||||||
impl PingListener for PingerICMPEchoListener {
|
|
||||||
// Result: RTT, down time, up time
|
|
||||||
fn parse_packet(
|
|
||||||
&self,
|
|
||||||
id: u16,
|
|
||||||
reflector: IpAddr,
|
|
||||||
measurement_type: MeasurementType,
|
|
||||||
pkt: Icmpv4Packet,
|
|
||||||
) -> Result<PingReply, PingError> {
|
|
||||||
match pkt.typ {
|
|
||||||
0 => {
|
|
||||||
if let Icmpv4Message::EchoReply {
|
|
||||||
identifier,
|
|
||||||
sequence,
|
|
||||||
payload,
|
|
||||||
} = pkt.message
|
|
||||||
{
|
|
||||||
if identifier != id {
|
|
||||||
return Err(PingError::WrongID {
|
|
||||||
expected: id,
|
|
||||||
found: identifier,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let time_sent = match payload.as_slice().try_into() {
|
|
||||||
Ok(bytes) => u64::from_be_bytes(bytes) as i64,
|
|
||||||
Err(_) => {
|
|
||||||
return Err(PingError::InvalidPacket(format!(
|
|
||||||
"Expected 8 bytes payload, but found {}",
|
|
||||||
payload.len()
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let clock = Time::new(ClockId::Monotonic);
|
|
||||||
let time_ms = clock.to_milliseconds() as i64;
|
|
||||||
|
|
||||||
let rtt = (time_ms - time_sent) as f64;
|
|
||||||
Ok(PingReply {
|
|
||||||
reflector,
|
|
||||||
measurement_type,
|
|
||||||
seq: sequence,
|
|
||||||
rtt,
|
|
||||||
current_time: time_ms,
|
|
||||||
down_time: (rtt / 2.0) as f64,
|
|
||||||
up_time: (rtt / 2.0) as f64,
|
|
||||||
originate_timestamp: time_sent,
|
|
||||||
receive_timestamp: 0,
|
|
||||||
transmit_timestamp: 0,
|
|
||||||
last_receive_time_s: Instant::now(),
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
Err(PingError::InvalidPacket(format!(
|
|
||||||
"Packet had type {:?}, but did not match the structure",
|
|
||||||
pkt.typ
|
|
||||||
)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
type_ => Err(PingError::InvalidType(format!("{:?}", type_))),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PingSender for PingerICMPEchoSender {
|
|
||||||
fn craft_packet(&self, id: u16, seq: u16) -> (Icmpv4Packet, i64) {
|
|
||||||
let clock = Time::new(ClockId::Monotonic);
|
|
||||||
let time_ms = clock.to_milliseconds();
|
|
||||||
let payload = time_ms.to_be_bytes().to_vec();
|
|
||||||
|
|
||||||
(
|
|
||||||
Icmpv4Packet::with_echo_request(id, seq, payload).unwrap(),
|
|
||||||
time_ms as i64,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2022-Present Charles Corrigan mailto:chas-iot@runegate.org (github @chas-iot)
|
|
||||||
// SPDX-FileCopyrightText: 2022-Present Daniel Lakeland mailto:dlakelan@street-artists.org (github @dlakelan)
|
|
||||||
// SPDX-FileCopyrightText: 2022-Present Mark Baker mailto:mark@vpost.net (github @Fail-Safe)
|
|
||||||
// SPDX-FileCopyrightText: 2022-Present Nils Andreas Svee mailto:contact@lochnair.net (github @Lochnair)
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
|
||||||
|
|
||||||
use crate::pinger::{PingError, PingListener, PingReply, PingSender};
|
|
||||||
use crate::settings::MeasurementType;
|
|
||||||
use crate::time::Time;
|
|
||||||
use icmp_socket2::Icmpv4Message;
|
|
||||||
use icmp_socket2::Icmpv4Packet;
|
|
||||||
use icmp_socket2::packet::WithTimestampRequest;
|
|
||||||
use rustix::time::ClockId;
|
|
||||||
use std::net::IpAddr;
|
|
||||||
use std::time::Instant;
|
|
||||||
|
|
||||||
pub struct PingerICMPTimestampListener {}
|
|
||||||
|
|
||||||
pub struct PingerICMPTimestampSender {}
|
|
||||||
|
|
||||||
impl PingListener for PingerICMPTimestampListener {
|
|
||||||
// Result: RTT, down time, up time
|
|
||||||
fn parse_packet(
|
|
||||||
&self,
|
|
||||||
id: u16,
|
|
||||||
reflector: IpAddr,
|
|
||||||
measurement_type: MeasurementType,
|
|
||||||
pkt: Icmpv4Packet,
|
|
||||||
) -> Result<PingReply, PingError> {
|
|
||||||
match pkt.typ {
|
|
||||||
// 14 = Timestamp reply
|
|
||||||
14 => {
|
|
||||||
if let Icmpv4Message::TimestampReply {
|
|
||||||
identifier,
|
|
||||||
sequence,
|
|
||||||
originate,
|
|
||||||
receive,
|
|
||||||
transmit,
|
|
||||||
} = pkt.message
|
|
||||||
{
|
|
||||||
if identifier != id {
|
|
||||||
return Err(PingError::WrongID {
|
|
||||||
expected: id,
|
|
||||||
found: identifier,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let time_now = Time::new(ClockId::Realtime);
|
|
||||||
let time_since_midnight = time_now.get_time_since_midnight();
|
|
||||||
|
|
||||||
let rtt = (time_since_midnight - originate as i64) as f64;
|
|
||||||
let dl_time = (time_since_midnight - transmit as i64) as f64;
|
|
||||||
let ul_time = (receive as i64 - originate as i64) as f64;
|
|
||||||
|
|
||||||
Ok(PingReply {
|
|
||||||
reflector,
|
|
||||||
measurement_type,
|
|
||||||
seq: sequence,
|
|
||||||
rtt,
|
|
||||||
current_time: time_since_midnight,
|
|
||||||
down_time: dl_time,
|
|
||||||
up_time: ul_time,
|
|
||||||
originate_timestamp: originate as i64,
|
|
||||||
receive_timestamp: receive as i64,
|
|
||||||
transmit_timestamp: transmit as i64,
|
|
||||||
last_receive_time_s: Instant::now(),
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
Err(PingError::InvalidPacket(format!(
|
|
||||||
"Packet had type {:?}, but did not match the structure",
|
|
||||||
pkt.typ
|
|
||||||
)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
type_ => Err(PingError::InvalidType(format!("{:?}", type_))),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PingSender for PingerICMPTimestampSender {
|
|
||||||
fn craft_packet(&self, id: u16, seq: u16) -> (Icmpv4Packet, i64) {
|
|
||||||
let time_since_midnight = Time::new(ClockId::Realtime).get_time_since_midnight();
|
|
||||||
(
|
|
||||||
Icmpv4Packet::with_timestamp_request(id, seq, time_since_midnight as u32, 0, 0)
|
|
||||||
.unwrap(),
|
|
||||||
time_since_midnight as i64,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -42,9 +42,6 @@ mod linux;
|
|||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
mod macos;
|
mod macos;
|
||||||
|
|
||||||
#[cfg(unix)]
|
|
||||||
pub mod unix;
|
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "freebsd", target_os = "linux", target_os = "macos")))]
|
#[cfg(not(any(target_os = "freebsd", target_os = "linux", target_os = "macos")))]
|
||||||
mod unsupported;
|
mod unsupported;
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
#[cfg(feature = "uci")]
|
|
||||||
pub mod uci;
|
|
||||||
@@ -13,11 +13,10 @@ use crate::platform::{
|
|||||||
interface_stats_provider, traffic_control_backend,
|
interface_stats_provider, traffic_control_backend,
|
||||||
};
|
};
|
||||||
use crate::settings::Settings;
|
use crate::settings::Settings;
|
||||||
use crate::time::Time;
|
use crate::time::{ClockSample, Realtime};
|
||||||
use crate::util::{ArcRwLock, RwLockExt};
|
use crate::util::{ArcRwLock, RwLockExt};
|
||||||
use flume::{Receiver, Sender};
|
use flume::{Receiver, Sender};
|
||||||
use log::{debug, info, warn};
|
use log::{debug, info, warn};
|
||||||
use rustix::time::ClockId;
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
@@ -409,7 +408,7 @@ impl<S: InterfaceStatsProvider, T: TrafficControlBackend> Ratecontroller<S, T> {
|
|||||||
self.state_dl.current_rate = self.state_dl.next_rate;
|
self.state_dl.current_rate = self.state_dl.next_rate;
|
||||||
self.state_ul.current_rate = self.state_ul.next_rate;
|
self.state_ul.current_rate = self.state_ul.next_rate;
|
||||||
|
|
||||||
let stats_time = Time::new(ClockId::Realtime);
|
let stats_time = ClockSample::<Realtime>::now();
|
||||||
debug!(
|
debug!(
|
||||||
"{},{},{},{},{},{},{},{}",
|
"{},{},{},{},{},{},{},{}",
|
||||||
stats_time.secs(),
|
stats_time.secs(),
|
||||||
@@ -459,7 +458,7 @@ impl<S: InterfaceStatsProvider, T: TrafficControlBackend> Ratecontroller<S, T> {
|
|||||||
&& now_t.duration_since(lastdump_t).as_secs_f64() > 300.0
|
&& now_t.duration_since(lastdump_t).as_secs_f64() > 300.0
|
||||||
{
|
{
|
||||||
for i in 0..self.settings.advanced_settings.speed_hist_size as usize {
|
for i in 0..self.settings.advanced_settings.speed_hist_size as usize {
|
||||||
let hist_time = Time::new(ClockId::Realtime);
|
let hist_time = ClockSample::<Realtime>::now();
|
||||||
if let Err(e) = fd.write_all(
|
if let Err(e) = fd.write_all(
|
||||||
format!(
|
format!(
|
||||||
"{},{},{},{}\n",
|
"{},{},{},{}\n",
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use crate::baseliner::ControlSnapshot;
|
|||||||
use crate::metrics::{Metric, MetricsSender};
|
use crate::metrics::{Metric, MetricsSender};
|
||||||
use crate::settings::Settings;
|
use crate::settings::Settings;
|
||||||
use crate::util::RwLockExt;
|
use crate::util::RwLockExt;
|
||||||
use flume::{Receiver, RecvError, RecvTimeoutError, Selector};
|
use flume::{Receiver, RecvError, RecvTimeoutError, Selector, Sender};
|
||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
@@ -108,6 +108,7 @@ pub struct ReflectorSelector {
|
|||||||
pub settings: Settings,
|
pub settings: Settings,
|
||||||
pub snapshot_rx: Receiver<ControlSnapshot>,
|
pub snapshot_rx: Receiver<ControlSnapshot>,
|
||||||
pub reflector_peers_lock: Arc<RwLock<Vec<IpAddr>>>,
|
pub reflector_peers_lock: Arc<RwLock<Vec<IpAddr>>>,
|
||||||
|
pub reflector_tx: Sender<Vec<IpAddr>>,
|
||||||
pub reflector_pool: Vec<IpAddr>,
|
pub reflector_pool: Vec<IpAddr>,
|
||||||
pub trigger_channel: Receiver<bool>,
|
pub trigger_channel: Receiver<bool>,
|
||||||
pub metrics: MetricsSender,
|
pub metrics: MetricsSender,
|
||||||
@@ -186,6 +187,7 @@ impl ReflectorSelector {
|
|||||||
// Clone next_peers because we need it again after the baseline sleep
|
// Clone next_peers because we need it again after the baseline sleep
|
||||||
// to iterate over candidates for RTT measurement.
|
// to iterate over candidates for RTT measurement.
|
||||||
*reflectors_peers = next_peers.clone();
|
*reflectors_peers = next_peers.clone();
|
||||||
|
self.reflector_tx.send(next_peers.clone())?;
|
||||||
|
|
||||||
// Drop the MutexGuard explicitly, as Rust won't unlock the mutex by default
|
// Drop the MutexGuard explicitly, as Rust won't unlock the mutex by default
|
||||||
// until the guard goes out of scope
|
// until the guard goes out of scope
|
||||||
@@ -251,6 +253,7 @@ impl ReflectorSelector {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.reflector_tx.send(new_peers.clone())?;
|
||||||
*reflectors_peers = new_peers;
|
*reflectors_peers = new_peers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-4
@@ -11,11 +11,14 @@ use std::net::IpAddr;
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use uci_derive::{UciConfig, UciSection};
|
use uci_derive::{UciConfig, UciSection};
|
||||||
|
|
||||||
pub(crate) mod uci_schema;
|
#[cfg(all(feature = "uci", unix))]
|
||||||
mod validation;
|
use crate::settings::uci::UciSource;
|
||||||
|
|
||||||
#[cfg(all(feature = "uci", unix))]
|
#[cfg(all(feature = "uci", unix))]
|
||||||
use crate::platform::unix::uci::UciSource;
|
pub mod uci;
|
||||||
|
|
||||||
|
pub(crate) mod uci_schema;
|
||||||
|
mod validation;
|
||||||
|
|
||||||
struct FlexiBool(bool);
|
struct FlexiBool(bool);
|
||||||
|
|
||||||
@@ -192,7 +195,10 @@ impl Settings {
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
match (record.ip_version, record.reflector_ip) {
|
match (record.ip_version, record.reflector_ip) {
|
||||||
(4, IpAddr::V4(_)) | (6, IpAddr::V6(_)) => {}
|
(4, IpAddr::V4(_)) => {}
|
||||||
|
(6, address @ IpAddr::V6(_)) => {
|
||||||
|
bail!("reflector {address} is IPv6; only IPv4 reflectors are supported");
|
||||||
|
}
|
||||||
(version, address) => {
|
(version, address) => {
|
||||||
bail!("reflector {address} has inconsistent IP version {version}");
|
bail!("reflector {address} has inconsistent IP version {version}");
|
||||||
}
|
}
|
||||||
@@ -215,6 +221,13 @@ pub(crate) struct NetworkSettings {
|
|||||||
pub(crate) upload_base_kbits: f64,
|
pub(crate) upload_base_kbits: f64,
|
||||||
#[serde(default = "default_min_percent")]
|
#[serde(default = "default_min_percent")]
|
||||||
pub(crate) upload_min_percent: f64,
|
pub(crate) upload_min_percent: f64,
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub(crate) measurement_bind_device: Option<String>,
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub(crate) measurement_mark: Option<u32>,
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub(crate) measurement_fib: Option<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NetworkSettings {
|
impl NetworkSettings {
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ impl Source for UciSource {
|
|||||||
let (_uci, packages) = match resolved {
|
let (_uci, packages) = match resolved {
|
||||||
Ok(resolved) => resolved,
|
Ok(resolved) => resolved,
|
||||||
|
|
||||||
Err(_) if !self.required => {
|
Err(SourceError::NotFound(_)) if !self.required => {
|
||||||
return Ok(Map::new());
|
return Ok(Map::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,3 +285,29 @@ impl Source for UciSource {
|
|||||||
Ok(values)
|
Ok(values)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use crate::settings::Settings;
|
||||||
|
use std::fs;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn malformed_optional_package_is_an_error() {
|
||||||
|
let root = std::env::temp_dir().join(format!("sqma-uci-{}", std::process::id()));
|
||||||
|
let config_dir = root.join("config");
|
||||||
|
let save_dir = root.join("save");
|
||||||
|
fs::create_dir_all(&config_dir).unwrap();
|
||||||
|
fs::create_dir_all(&save_dir).unwrap();
|
||||||
|
let config_file = config_dir.join("sqm-autorate-rust");
|
||||||
|
fs::write(&config_file, "config network 'unterminated\n").unwrap();
|
||||||
|
|
||||||
|
let source = UciSource::from_schema::<Settings>()
|
||||||
|
.with_directories(&config_dir, &save_dir)
|
||||||
|
.required(false);
|
||||||
|
let result = source.collect();
|
||||||
|
|
||||||
|
fs::remove_dir_all(root).unwrap();
|
||||||
|
assert!(result.is_err());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -153,7 +153,12 @@ impl NetworkSettings {
|
|||||||
if download_base_valid && download_percent_valid {
|
if download_base_valid && download_percent_valid {
|
||||||
let minimum = self.download_min_kbits();
|
let minimum = self.download_min_kbits();
|
||||||
|
|
||||||
if minimum < WARN_DOWNLOAD_MIN_KBITS {
|
if minimum < 1.0 {
|
||||||
|
report.error(
|
||||||
|
"network.download_min_percent",
|
||||||
|
"minimum download rate floors to zero",
|
||||||
|
);
|
||||||
|
} else if minimum < WARN_DOWNLOAD_MIN_KBITS {
|
||||||
report.warning(
|
report.warning(
|
||||||
"network.download_min_percent",
|
"network.download_min_percent",
|
||||||
format!(
|
format!(
|
||||||
@@ -168,7 +173,12 @@ impl NetworkSettings {
|
|||||||
if upload_base_valid && upload_percent_valid {
|
if upload_base_valid && upload_percent_valid {
|
||||||
let minimum = self.upload_min_kbits();
|
let minimum = self.upload_min_kbits();
|
||||||
|
|
||||||
if minimum < WARN_UPLOAD_MIN_KBITS {
|
if minimum < 1.0 {
|
||||||
|
report.error(
|
||||||
|
"network.upload_min_percent",
|
||||||
|
"minimum upload rate floors to zero",
|
||||||
|
);
|
||||||
|
} else if minimum < WARN_UPLOAD_MIN_KBITS {
|
||||||
report.warning(
|
report.warning(
|
||||||
"network.upload_min_percent",
|
"network.upload_min_percent",
|
||||||
format!(
|
format!(
|
||||||
@@ -376,3 +386,41 @@ fn validate_percent(report: &mut ValidationReport, path: &'static str, value: f6
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
fn network(download_base_kbits: f64, upload_base_kbits: f64) -> NetworkSettings {
|
||||||
|
NetworkSettings {
|
||||||
|
download_interface: "ifb0".into(),
|
||||||
|
upload_interface: "eth0".into(),
|
||||||
|
download_base_kbits,
|
||||||
|
download_min_percent: 1.0,
|
||||||
|
upload_base_kbits,
|
||||||
|
upload_min_percent: 1.0,
|
||||||
|
measurement_bind_device: None,
|
||||||
|
measurement_mark: None,
|
||||||
|
measurement_fib: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn minimum_rates_that_floor_to_zero_are_errors_for_both_directions() {
|
||||||
|
let mut report = ValidationReport::default();
|
||||||
|
network(50.0, 50.0).validate(&mut report);
|
||||||
|
let error = report.finish().unwrap_err().to_string();
|
||||||
|
|
||||||
|
assert!(error.contains("network.download_min_percent"));
|
||||||
|
assert!(error.contains("network.upload_min_percent"));
|
||||||
|
assert!(error.contains("floors to zero"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn representable_low_minimum_rates_remain_warnings() {
|
||||||
|
let mut report = ValidationReport::default();
|
||||||
|
network(10_000.0, 10_000.0).validate(&mut report);
|
||||||
|
|
||||||
|
assert!(report.finish().is_ok());
|
||||||
|
}
|
||||||
|
}
|
||||||
+49
-11
@@ -2,27 +2,45 @@
|
|||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use rustix::fs::Timespec;
|
use std::{
|
||||||
|
marker::PhantomData,
|
||||||
|
time::{SystemTime, UNIX_EPOCH},
|
||||||
|
};
|
||||||
|
|
||||||
use rustix::time::{ClockId, clock_gettime};
|
use rustix::time::{ClockId, clock_gettime};
|
||||||
|
|
||||||
pub struct Time {
|
pub trait Clock {
|
||||||
time_s: u64,
|
const ID: ClockId;
|
||||||
time_ns: u64,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Time {
|
pub enum Realtime {}
|
||||||
pub fn new(id: ClockId) -> Self {
|
pub enum Monotonic {}
|
||||||
let time: Timespec = clock_gettime(id);
|
|
||||||
|
impl Clock for Realtime {
|
||||||
|
const ID: ClockId = ClockId::Realtime;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Clock for Monotonic {
|
||||||
|
const ID: ClockId = ClockId::Monotonic;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ClockSample<C> {
|
||||||
|
time_s: u64,
|
||||||
|
time_ns: u64,
|
||||||
|
_clock: PhantomData<C>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C: Clock> ClockSample<C> {
|
||||||
|
pub fn now() -> Self {
|
||||||
|
let time = clock_gettime(C::ID);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
time_s: time.tv_sec as u64,
|
time_s: time.tv_sec as u64,
|
||||||
time_ns: time.tv_nsec as u64,
|
time_ns: time.tv_nsec as u64,
|
||||||
|
_clock: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_time_since_midnight(&self) -> i64 {
|
|
||||||
(self.time_s as i64 % 86400 * 1000) + (self.time_ns as i64 / 1000000)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn secs(&self) -> u64 {
|
pub fn secs(&self) -> u64 {
|
||||||
self.time_s
|
self.time_s
|
||||||
}
|
}
|
||||||
@@ -43,3 +61,23 @@ impl Time {
|
|||||||
(self.time_s * 1000) + (self.time_ns / 1000000)
|
(self.time_s * 1000) + (self.time_ns / 1000000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ClockSample<Realtime> {
|
||||||
|
pub fn as_time_since_midnight(&self) -> i64 {
|
||||||
|
(self.time_s as i64 % 86_400 * 1000) + self.time_ns as i64 / 1_000_000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<SystemTime> for ClockSample<Realtime> {
|
||||||
|
fn from(time: SystemTime) -> Self {
|
||||||
|
let duration = time
|
||||||
|
.duration_since(UNIX_EPOCH)
|
||||||
|
.expect("realtime timestamp predates Unix epoch");
|
||||||
|
|
||||||
|
Self {
|
||||||
|
time_s: duration.as_secs(),
|
||||||
|
time_ns: u64::from(duration.subsec_nanos()),
|
||||||
|
_clock: PhantomData,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user