Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@cargo-llvm-cov
- run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
- name: Upload coverage to Codecov
Expand Down
59 changes: 15 additions & 44 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: test on freebsd
runs-on: macos-12
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: test on freebsd
uses: vmactions/freebsd-vm@v0
with:
Expand Down Expand Up @@ -44,65 +44,36 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- uses: Swatinem/rust-cache@v1
- uses: actions-rs/cargo@v1
with:
command: build
args: --all-targets
- uses: actions-rs/cargo@v1
with:
command: test
- uses: actions-rs/cargo@v1
- run: cargo build --all-targets
- run: cargo test
- run: cargo test --manifest-path fuzz/Cargo.toml
if: ${{ matrix.rust }} == "stable"
with:
command: test
args: --manifest-path fuzz/Cargo.toml

msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.63.0
override: true
- uses: actions/checkout@v3
- uses: dtolnay/[email protected]
- uses: Swatinem/rust-cache@v1
- uses: actions-rs/cargo@v1
with:
command: check
args: --lib --all-features -p quinn-udp -p quinn-proto -p quinn
- run: cargo check --lib --all-features -p quinn-udp -p quinn-proto -p quinn

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v1
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets -- -D warnings
- uses: actions-rs/toolchain@v1
- run: cargo fmt --all -- --check
- run: cargo clippy --all-targets -- -D warnings
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
override: true
components: clippy
- name: doc
run: cargo doc --no-deps --document-private-items
Expand All @@ -116,5 +87,5 @@ jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v1
7 changes: 6 additions & 1 deletion quinn-proto/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,12 @@ impl Endpoint {
})
}

/// Unconditionally reject future incoming connections
/// Reject new incoming connections without affecting existing connections
///
/// Convenience short-hand for using
/// [`set_server_config`](Self::set_server_config) to update
/// [`concurrent_connections`](ServerConfig::concurrent_connections) to
/// zero.
pub fn reject_new_connections(&mut self) {
if let Some(config) = self.server_config.as_mut() {
Arc::make_mut(config).concurrent_connections(0);
Expand Down
13 changes: 13 additions & 0 deletions quinn-proto/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2196,3 +2196,16 @@ fn stream_chunks(mut recv: RecvStream) -> Vec<u8> {

buf
}

#[test]
fn reject_new_connections() {
let _guard = subscribe();
let mut pair = Pair::default();
pair.server.reject_new_connections();

// The server should now reject incoming connections.
let client_ch = pair.begin_connect(client_config());
pair.drive();
pair.server.assert_no_accept();
assert!(pair.client.connections.get(&client_ch).unwrap().is_closed());
}
18 changes: 8 additions & 10 deletions quinn/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ impl Connecting {

inner.inner.local_ip()
}

/// The peer's UDP address.
///
/// Will panic if called after `poll` has returned `Ready`.
pub fn remote_address(&self) -> SocketAddr {
let conn_ref: &ConnectionRef = self.conn.as_ref().expect("used after yielding Ready");
conn_ref.state.lock("remote_address").inner.remote_address()
}
}

impl Future for Connecting {
Expand All @@ -178,16 +186,6 @@ impl Future for Connecting {
}
}

impl Connecting {
/// The peer's UDP address.
///
/// Will panic if called after `poll` has returned `Ready`.
pub fn remote_address(&self) -> SocketAddr {
let conn_ref: &ConnectionRef = self.conn.as_ref().expect("used after yielding Ready");
conn_ref.state.lock("remote_address").inner.remote_address()
}
}

/// Future that completes when a connection is fully established
///
/// For clients, the resulting value indicates if 0-RTT was accepted. For servers, the resulting
Expand Down
15 changes: 15 additions & 0 deletions quinn/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,21 @@ impl Endpoint {
self.inner.state.lock().unwrap().socket.local_addr()
}

/// Reject new incoming connections without affecting existing connections
///
/// Convenience short-hand for using
/// [`set_server_config`](Self::set_server_config) to update
/// [`concurrent_connections`](ServerConfig::concurrent_connections) to
/// zero.
pub fn reject_new_connections(&self) {
self.inner
.state
.lock()
.unwrap()
.inner
.reject_new_connections();
}

/// Close all of this endpoint's connections immediately and cease accepting new connections.
///
/// See [`Connection::close()`] for details.
Expand Down
6 changes: 4 additions & 2 deletions quinn/src/send_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ impl SendStream {
.poll(cx)
.map(|x| x.unwrap())
{
Poll::Ready(None) => Poll::Ready(Ok(())),
Poll::Ready(Some(e)) => Poll::Ready(Err(e)),
Poll::Ready(x) => {
self.finishing = None;
Poll::Ready(x.map_or(Ok(()), Err))
}
Poll::Pending => {
// To ensure that finished streams can be detected even after the connection is
// closed, we must only check for connection errors after determining that the
Expand Down