Skip to content

Commit

Permalink
Merge pull request #126 from expressvpn/CVPN-1585-no-data-frames-befo…
Browse files Browse the repository at this point in the history
…re-online

lightway-core: Ignore `wire::Frame::Data{Frag}` until `State::Online`
  • Loading branch information
xv-ian-c authored Nov 14, 2024
2 parents 939cb5a + a9dcf11 commit 649b581
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lightway-core/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1334,13 +1334,21 @@ impl<AppState: Send> Connection<AppState> {
}

fn handle_outside_data_packet(&mut self, data: wire::Data) -> ConnectionResult<()> {
if !matches!(self.state, State::Online) {
return Err(ConnectionError::InvalidState);
}

// into_owned should be a NOP here since
// `wire::Data::try_from_wire` produced a `Cow::Owned`
// variant.
self.handle_outside_data_bytes(data.data.into_owned())
}

fn handle_outside_data_fragment(&mut self, frag: wire::DataFrag) -> ConnectionResult<()> {
if !matches!(self.state, State::Online) {
return Err(ConnectionError::InvalidState);
}

match self.fragment_map.add_fragment(frag) {
FragmentMapResult::Complete(data) => {
self.handle_outside_data_bytes(data)?;
Expand Down

0 comments on commit 649b581

Please sign in to comment.