Skip to content

Commit

Permalink
Merge branch 'use-split_at_checked'
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Jul 26, 2024
2 parents a3b1bf9 + f9cc1b4 commit f3708b0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- os: ubuntu-latest
# MSRV. Not considered breaking when this has to be bumped.
# But update `rust-version` in `Cargo.toml`
rust: 1.77.0
rust: 1.80.0
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0"
description = "Tunnel UDP traffic inside a TCP stream. Each datagram is prefixed with a 16 bit unsigned integer containing the length"
repository = "https://github.com/mullvad/udp-over-tcp"
edition = "2021"
rust-version = "1.77.0"
rust-version = "1.80.0"
publish = false

[[bin]]
Expand Down
7 changes: 1 addition & 6 deletions src/forward_traffic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,7 @@ fn split_first_datagram(buffer: &[u8]) -> Option<(&[u8], &[u8])> {
let (header, tail) = buffer.split_first_chunk::<HEADER_LEN>()?;
let datagram_len = usize::from(u16::from_be_bytes(*header));

// TODO: These two get calls (and thus double bounds check) can be replaced with
// `split_at_checked` when stabilized: https://github.com/rust-lang/rust/issues/119128
let datagram_data = tail.get(..datagram_len)?;
let tail = tail.get(datagram_len..)?;

Some((datagram_data, tail))
tail.split_at_checked(datagram_len)
}

/// Reads datagrams from `udp_in` and writes them (with the 16 bit header containing the length)
Expand Down

0 comments on commit f3708b0

Please sign in to comment.