Skip to content

Commit

Permalink
Merge branch 'main' into 0rtt-tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
larseggert committed Aug 9, 2024
2 parents 76944b5 + 9c54b4a commit 92f07f9
Show file tree
Hide file tree
Showing 44 changed files with 609 additions and 352 deletions.
2 changes: 1 addition & 1 deletion .github/actions/pr-comment-data-export/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ runs:
echo "${{ inputs.log-url }}" > comment-data/log-url
fi
- if: github.event_name == 'pull_request'
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
with:
name: ${{ inputs.name }}
path: comment-data
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/quic-interop-runner/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ runs:
done
shell: bash

- uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
- uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
id: upload-logs
with:
name: '${{ inputs.client }} vs. ${{ inputs.server }} logs'
Expand All @@ -97,7 +97,7 @@ runs:
mv result.json.tmp result.json
shell: bash

- uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
- uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
with:
name: '${{ inputs.client }} vs. ${{ inputs.server }} results'
path: |
Expand Down
9 changes: 8 additions & 1 deletion .github/actions/rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ inputs:
tools:
description: 'Additional Rust tools to install'
default: ''
token:
description: 'A Github PAT'
required: true

runs:
using: composite
Expand Down Expand Up @@ -41,12 +44,16 @@ runs:
- name: Install cargo-quickinstall
shell: bash
if: inputs.tools != ''
env:
GITHUB_TOKEN: ${{ inputs.token }}
run: cargo +${{ inputs.version }} install cargo-quickinstall

- name: Install Rust tools
shell: bash
if: inputs.tools != ''
run: cargo +${{ inputs.version }} quickinstall --no-binstall $(echo ${{ inputs.tools }} | tr -d ",")
env:
GITHUB_TOKEN: ${{ inputs.token }}
run: cargo +${{ inputs.version }} quickinstall $(echo ${{ inputs.tools }} | tr -d ",")

# sccache slows CI down, so we leave it disabled.
# Leaving the steps below commented out, so we can re-evaluate enabling it later.
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
with:
version: $TOOLCHAIN
tools: hyperfine
token: ${{ secrets.GITHUB_TOKEN }}

- name: Get minimum NSS version
id: nss-version
Expand Down Expand Up @@ -237,7 +238,7 @@ jobs:

- name: Export perf data
id: export
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
with:
name: ${{ github.event.repository.name }}-${{ github.sha }}
path: |
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
version: ${{ matrix.rust-toolchain }}
components: rustfmt, clippy, llvm-tools-preview
tools: cargo-llvm-cov, cargo-nextest, cargo-hack, cargo-fuzz, cargo-machete
token: ${{ secrets.GITHUB_TOKEN }}

- name: Get minimum NSS version
id: nss-version
Expand Down Expand Up @@ -129,6 +130,8 @@ jobs:
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
if: matrix.type == 'debug' && matrix.rust-toolchain == 'stable'

bench:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/firefox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ jobs:
- name: Export binary
id: upload
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
with:
name: ${{ runner.os }}-${{ env.FIREFOX }}-${{ matrix.type }}.tgz
path: ${{ env.FIREFOX }}.tar
Expand All @@ -122,7 +122,7 @@ jobs:
- run: echo "${{ steps.upload.outputs.artifact-url }}" >> artifact

- name: Export artifact URL
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
with:
name: artifact-${{ runner.os }}-${{ env.FIREFOX }}-${{ matrix.type }}
path: artifact
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/mutants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
uses: ./.github/actions/rust
with:
tools: cargo-mutants
token: ${{ secrets.GITHUB_TOKEN }}

- name: Find incremental mutants
if: github.event_name == 'pull_request'
Expand Down Expand Up @@ -63,7 +64,7 @@ jobs:
} > "$GITHUB_STEP_SUMMARY"
- name: Archive mutants.out
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
if: always()
with:
name: mutants.out
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/qns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
packages: write
steps:
- uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
- uses: docker/setup-buildx-action@aa33708b10e362ff993539393ff100fa93ed6a27 # v3.5.0
- uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
- uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
platforms: 'linux/amd64'
outputs: type=docker,dest=/tmp/${{ env.LATEST }}.tar

- uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
- uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
with:
name: '${{ env.LATEST }} Docker image'
path: /tmp/${{ env.LATEST }}.tar
Expand Down Expand Up @@ -186,13 +186,15 @@ jobs:
fi
jq < "$RUN/result.json" '
. as $data |
.results[][].result //= "failed" |
{
results: [.results[] | group_by(.result)[] | {(.[0].result): [.[] | .abbr]}] |
add
} |
. + {log_url: $data.log_url}
' > "$RUN/$ROLE.grouped.json"
for ROLE in client server; do
[ ! -e "$RUN/$ROLE.grouped.json" ] && continue
for GROUP in $(jq -r < "$RUN/$ROLE.grouped.json" '.results | keys[]'); do
RESULT=$(jq < "$RUN/$ROLE.grouped.json" -r '.results.'"$GROUP"'[]' | fmt -w 1000)
LOG=$(jq -r < "$RUN/$ROLE.grouped.json" -r '.log_url')
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ description = "Neqo, the Mozilla implementation of QUIC in Rust."
keywords = ["quic", "http3", "neqo", "mozilla", "ietf", "firefox"]
categories = ["network-programming", "web-programming"]
readme = "README.md"
version = "0.8.1"
version = "0.8.2"
# Keep in sync with `.rustfmt.toml` `edition`.
edition = "2021"
license = "MIT OR Apache-2.0"
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ Compile Gecko as usual with
Note: Using newer Neqo code with Gecko may also require changes (likely to `neqo_glue`) if
something has changed.
### Connect with Firefox to local neqo-server
1. Run `neqo-server` via `cargo run --bin neqo-server -- 'localhost:12345' --db ./test-fixture/db`.
2. On Firefox, set `about:config` preference `network.http.http3.alt-svc-mapping-for-testing` to `localhost;h3=":12345"`.
3. Optionally enable logging via `about:logging` or profiling via https://profiler.firefox.com/.
4. Navigate to https://localhost:12345 and accept self-signed certificate.
[NSS]: https://hg.mozilla.org/projects/nss
[NSPR]: https://hg.mozilla.org/projects/nspr
[GYP]: https://github.com/nodejs/gyp-next
Expand Down
62 changes: 30 additions & 32 deletions neqo-bin/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ use futures::{
future::{select, Either},
FutureExt, TryFutureExt,
};
use neqo_common::{self as common, qdebug, qerror, qinfo, qlog::NeqoQlog, qwarn, Datagram, Role};
use neqo_common::{qdebug, qerror, qinfo, qlog::NeqoQlog, qwarn, Datagram, Role};
use neqo_crypto::{
constants::{TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256},
init, Cipher, ResumptionToken,
};
use neqo_http3::Output;
use neqo_transport::{AppError, CloseReason, ConnectionId, Version};
use qlog::{events::EventImportance, streamer::QlogStreamer};
use tokio::time::Sleep;
use url::{Origin, Url};

Expand All @@ -46,7 +45,7 @@ pub enum Error {
ArgumentError(&'static str),
Http3Error(neqo_http3::Error),
IoError(io::Error),
QlogError,
QlogError(qlog::Error),
TransportError(neqo_transport::Error),
ApplicationError(neqo_transport::AppError),
CryptoError(neqo_crypto::Error),
Expand All @@ -71,8 +70,8 @@ impl From<neqo_http3::Error> for Error {
}

impl From<qlog::Error> for Error {
fn from(_err: qlog::Error) -> Self {
Self::QlogError
fn from(err: qlog::Error) -> Self {
Self::QlogError(err)
}
}

Expand Down Expand Up @@ -174,7 +173,7 @@ pub struct Args {

impl Args {
#[must_use]
#[cfg(feature = "bench")]
#[cfg(any(test, feature = "bench"))]
#[allow(clippy::missing_panics_doc)]
pub fn new(requests: &[u64]) -> Self {
use std::str::FromStr;
Expand Down Expand Up @@ -277,6 +276,11 @@ impl Args {
_ => exit(127),
}
}

#[cfg(any(test, feature = "bench"))]
pub fn set_qlog_dir(&mut self, dir: PathBuf) {
self.shared.qlog_dir = Some(dir);
}
}

fn get_output_file(
Expand Down Expand Up @@ -453,32 +457,26 @@ impl<'a, H: Handler> Runner<'a, H> {
}

fn qlog_new(args: &Args, hostname: &str, cid: &ConnectionId) -> Res<NeqoQlog> {
if let Some(qlog_dir) = &args.shared.qlog_dir {
let mut qlog_path = qlog_dir.clone();
let filename = format!("{hostname}-{cid}.sqlog");
qlog_path.push(filename);

let f = OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(&qlog_path)?;

let streamer = QlogStreamer::new(
qlog::QLOG_VERSION.to_string(),
Some("Example qlog".to_string()),
Some("Example qlog description".to_string()),
None,
std::time::Instant::now(),
common::qlog::new_trace(Role::Client),
EventImportance::Base,
Box::new(f),
);

Ok(NeqoQlog::enabled(streamer, qlog_path)?)
} else {
Ok(NeqoQlog::disabled())
}
let Some(qlog_dir) = args.shared.qlog_dir.clone() else {
return Ok(NeqoQlog::disabled());
};

// hostname might be an IPv6 address, e.g. `[::1]`. `:` is an invalid
// Windows file name character.
#[cfg(windows)]
let hostname: String = hostname
.chars()
.map(|c| if c == ':' { '_' } else { c })
.collect();

NeqoQlog::enabled_with_file(
qlog_dir,
Role::Client,
Some("Example qlog".to_string()),
Some("Example qlog description".to_string()),
format!("{hostname}-{cid}"),
)
.map_err(Error::QlogError)
}

pub async fn client(mut args: Args) -> Res<()> {
Expand Down
74 changes: 72 additions & 2 deletions neqo-bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub struct SharedArgs {
pub quic_parameters: QuicParameters,
}

#[cfg(feature = "bench")]
#[cfg(any(test, feature = "bench"))]
impl Default for SharedArgs {
fn default() -> Self {
Self {
Expand Down Expand Up @@ -132,7 +132,7 @@ pub struct QuicParameters {
pub preferred_address_v6: Option<String>,
}

#[cfg(feature = "bench")]
#[cfg(any(test, feature = "bench"))]
impl Default for QuicParameters {
fn default() -> Self {
Self {
Expand Down Expand Up @@ -252,3 +252,73 @@ impl Display for Error {
}

impl std::error::Error for Error {}

#[cfg(test)]
mod tests {
use std::{fs, path::PathBuf, str::FromStr, time::SystemTime};

use crate::{client, server};

struct TempDir {
path: PathBuf,
}

impl TempDir {
fn new() -> Self {
let mut dir = std::env::temp_dir();
dir.push(format!(
"neqo-bin-test-{}",
SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_secs()
));
fs::create_dir(&dir).unwrap();
Self { path: dir }
}

fn path(&self) -> PathBuf {
self.path.clone()
}
}

impl Drop for TempDir {
fn drop(&mut self) {
if self.path.exists() {
fs::remove_dir_all(&self.path).unwrap();
}
}
}

#[tokio::test]
async fn write_qlog_file() {
neqo_crypto::init_db(PathBuf::from_str("../test-fixture/db").unwrap()).unwrap();

let temp_dir = TempDir::new();

let mut client_args = client::Args::new(&[1]);
client_args.set_qlog_dir(temp_dir.path());
let mut server_args = server::Args::default();
server_args.set_qlog_dir(temp_dir.path());

let client = client::client(client_args);
let server = Box::pin(server::server(server_args));
tokio::select! {
_ = client => {}
res = server => panic!("expect server not to terminate: {res:?}"),
};

// Verify that the directory contains two non-empty files
let entries: Vec<_> = fs::read_dir(temp_dir.path())
.unwrap()
.filter_map(Result::ok)
.collect();
assert_eq!(entries.len(), 2, "expect 2 files in the directory");

for entry in entries {
let metadata = entry.metadata().unwrap();
assert!(metadata.is_file(), "expect a file, found something else");
assert!(metadata.len() > 0, "expect file not be empty");
}
}
}
Loading

0 comments on commit 92f07f9

Please sign in to comment.