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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Unreleased: mitmproxy_rs next

- Preserve OS error details when UDP and WireGuard servers fail to start.
- `Stream.is_closing()` now returns `True` once the server or UDP client task has shut down.

## 20 July 2026: mitmproxy_rs 0.12.11

Expand Down
25 changes: 23 additions & 2 deletions mitmproxy-rs/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ impl Stream {
}
}

/// Check whether this stream is being closed.
/// Check whether this stream is being closed or the server has been shut down.
fn is_closing(&self) -> bool {
match self.state {
StreamState::Open => false,
StreamState::Open => self.command_tx.is_closed(),
StreamState::HalfClosed | StreamState::Closed => true,
}
}
Expand Down Expand Up @@ -207,3 +207,24 @@ impl Drop for Stream {
self.close().ok();
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn is_closing_when_server_shut_down() {
let (command_tx, command_rx) = mpsc::unbounded_channel();
let stream = Stream {
connection_id: ConnectionId::unassigned_udp(),
state: StreamState::Open,
command_tx,
peername: "127.0.0.1:1234".parse().unwrap(),
sockname: "127.0.0.1:4321".parse().unwrap(),
tunnel_info: TunnelInfo::None,
};
assert!(!stream.is_closing());
drop(command_rx);
assert!(stream.is_closing());
}
}
Loading