Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated dependencies #3

Merged
merged 7 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 22 additions & 47 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,29 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install toolchain with rustfmt
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Run rustfmt
run: cargo fmt --all -- --check

audit:
name: Job audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Run audit
uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

clippy:
name: Job clippy
needs: rustfmt
runs-on: ubuntu-latest
steps:
- name: Install toolchain with clippy
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Run clippy
uses: actions-rs/clippy-check@v1
uses: giraffate/clippy-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features ---all-targets -- --deny warnings -A clippy::unknown-clippy-lints
reporter: 'github-pr-check'
github_token: ${{ secrets.GITHUB_TOKEN }}
clippy_flags: --deny warnings -A clippy::unknown-clippy-lints

tests:
name: Job tests
Expand All @@ -61,43 +50,29 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Install toolchain ${{ matrix.rust_channel }} on ${{ matrix.os }}
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_channel }}
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --no-default-features --features "${{ matrix.features }}"
run: cargo test --no-default-features --features "${{ matrix.features }}"

code-coverage:
name: Job code coverage
needs: tests
runs-on: ubuntu-latest
steps:
- name: Intall toolchain nightly on ubuntu-latest
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- uses: actions/checkout@v2
- name: Download and unpack grcov
run: curl -L "$URL" | tar jxf -
env:
URL: '/~https://github.com/mozilla/grcov/releases/latest/download/grcov-linux-x86_64.tar.bz2'
- name: Run cargo test
uses: actions-rs/cargo@v1
uses: dtolnay/rust-toolchain@stable
with:
command: test
args: --all-features
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
- name: Convert gcno and gcda files into lcov
run: ./grcov --llvm target/debug -s . -t lcov -o lcov.info --ignore-not-existing --ignore "tests/*" --ignore "examples/*" --ignore "/*" --excl-line "^ *#\["
- name: Upload coverage
uses: codecov/codecov-action@v1
components: llvm-tools-preview
- uses: actions/checkout@v4
- name: cargo install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: cargo llvm-cov
run: cargo llvm-cov --all-features --lcov --output-path lcov.info
- name: Upload to codecov.io
uses: codecov/codecov-action@v4
with:
file: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: OS,RUST
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ keywords = ["doh", "dns", "stamps", "dnscrypt"]
categories = ["parser-implementations", "encoding"]

[dependencies]
base64 = "~0.13.0"
bitflags = "~1.2.1"
thiserror = "~1.0.23"
trust-dns-resolver = { version = "~0.20.0", optional = true }
base64 = "0.22"
bitflags = "2"
thiserror = "1"
trust-dns-resolver = { version = "0.20", optional = true }

[features]
default = []
Expand Down
4 changes: 2 additions & 2 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
Addr, AnonymizedDnsCryptRelay, DecodeError, DecodeResult, DnsCrypt, DnsOverHttps, DnsOverTls,
DnsPlain, DnsStamp, DnsStampType, ObliviousDoHTarget, Props,
};
use base64::{decode_config, URL_SAFE_NO_PAD};
use base64::{prelude::BASE64_URL_SAFE_NO_PAD, Engine};
use std::{
convert::{TryFrom, TryInto},
mem::size_of,
Expand Down Expand Up @@ -213,7 +213,7 @@ fn decode_props(buf: &[u8], offset: &mut usize) -> DecodeResult<Props> {
/// Decode a Base64 encoded `&str` with a prefix `"sdns://"` to `std::vec::Vec<u8>`.
fn decode_base64(stamp: &str) -> DecodeResult<Vec<u8>> {
if let Some(base64) = stamp.strip_prefix("sdns://") {
Ok(decode_config(base64, URL_SAFE_NO_PAD)?)
Ok(BASE64_URL_SAFE_NO_PAD.decode(base64)?)
} else {
Err(DecodeError::InvalidInput {
cause: "sdns:// prefix not present".to_string(),
Expand Down
8 changes: 4 additions & 4 deletions src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
Addr, AnonymizedDnsCryptRelay, DnsCrypt, DnsOverHttps, DnsOverTls, DnsPlain, DnsStamp,
DnsStampType, EncodeError, EncodeResult, ObliviousDoHTarget, Props,
};
use base64::{encode_config, URL_SAFE_NO_PAD};
use base64::{prelude::BASE64_URL_SAFE_NO_PAD, Engine};
use std::net::{IpAddr, SocketAddr};

/// Encode a `crate::DnsStampType` into a `std::vec::Vec<u8>`.
Expand All @@ -21,7 +21,7 @@ fn encode_props(buffer: &mut Vec<u8>, props: &Props) {
fn encode_bytes(buffer: &mut Vec<u8>, bytes: impl AsRef<[u8]>) -> EncodeResult<()> {
let bytes = bytes.as_ref();
let len = bytes.len();
if len <= std::u8::MAX as usize {
if len <= u8::MAX as usize {
buffer.push(len as u8);
buffer.extend(bytes);
Ok(())
Expand Down Expand Up @@ -115,7 +115,7 @@ fn encode_pk(buffer: &mut Vec<u8>, pk: &[u8; 32]) -> EncodeResult<()> {
/// [`VLP()`]: https://dnscrypt.info/stamps-specifications#common-definitions
fn encode_vlp<T: AsRef<[u8]>>(buffer: &mut Vec<u8>, vlp: &[T]) -> EncodeResult<()> {
if vlp.is_empty() {
encode_bytes(buffer, &[])
encode_bytes(buffer, [])
} else {
let len = vlp.len();
if let Some(array) = vlp.get(..(len - 1)) {
Expand Down Expand Up @@ -157,7 +157,7 @@ fn encode_bootstrap_ipi(buffer: &mut Vec<u8>, bootstrap_ipi: &[IpAddr]) -> Encod

/// Encode `[u8]` slice with Base64 and prepand `"sdns://"`.
fn encode_base64(buffer: &[u8]) -> String {
format!("sdns://{}", encode_config(buffer, URL_SAFE_NO_PAD))
format!("sdns://{}", BASE64_URL_SAFE_NO_PAD.encode(buffer))
}

/// Encode a `crate::DnsPlain` into a `std::vec::Vec<u8>` as `crate::DnsStampType::Plain`.
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
non_upper_case_globals
)]
#![allow(clippy::cognitive_complexity)]
#![deny(broken_intra_doc_links)]
#![doc(test(
no_crate_inject,
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
Expand All @@ -31,6 +30,7 @@ bitflags! {
/// Represent the [`props`].
///
/// [`props`]: https://dnscrypt.info/stamps-specifications#dnscrypt-stamps
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Props: u64 {
/// If this flag is present then the server supports [DNSSEC].
///
Expand Down
2 changes: 1 addition & 1 deletion tests/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn parse_fail_three() {
let stamp = "sdns://A";
assert_eq!(
stamp.parse::<DnsStamp>(),
Err(DecodeError::Base64Error(Base64Error::InvalidLength))
Err(DecodeError::Base64Error(Base64Error::InvalidLength(1)))
)
}

Expand Down
Loading