Skip to content

Commit 228f3e2

Browse files
cristeigabrielaRazz4780scottillogicalScott Schulthessgememma
authored
merge master into windows-support-poc (#3444)
* Add e2e test for passthrough mirroring and stealing (#3427) * Added more mirroring tests * Enable passthrough mirroring in OSS test * Fix namespace names * Clippy * Docs * HTTP1 is easier * Now it works * unwraps -> expects * Fix lingering agent (#3437) * Fixed TcpStealerTask exit condition * Style * Changelog * E2E test * Fix test? * Move the test to 'cleanup' module * ?? * Fix test * 3.152.1 (#3438) * Fix typo in istio ambient message (#3439) * Fix typo in istio ambient message Fix typo in "! mirrord detected an ambient Istio service mesh butthe agent is not configured to run in a privileged SecurityContext.Please set `agent.privileged = true`, otherwise the agent will not be able to start." * add changelog entry --------- Co-authored-by: Scott Schulthess <[email protected]> * Enable passthrough mirroring by default in OSS (#3440) * Adjustment made * Changelog * Fix test * Fix config doc * Add mirrord newsletter command and periodic invitations to the newsletter (#3434) * Count user sessions and suggest newsletter signup after setup * implement persistent session count store * mirrord newsletter command * Change message content * Add changelog * Fix lint, nicer run count comparison * Apply suggestions * Fix output-dependent e2e test --------- Co-authored-by: Michał Smolarek <[email protected]> Co-authored-by: Scott Schulthess <[email protected]> Co-authored-by: Scott Schulthess <[email protected]> Co-authored-by: Gemma <[email protected]>
1 parent bd3c2f2 commit 228f3e2

27 files changed

+669
-110
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ This project uses [*towncrier*](https://towncrier.readthedocs.io/) and the chang
88

99
<!-- towncrier release notes start -->
1010

11+
## [3.152.1](https://github.com/metalbear-co/mirrord/tree/3.152.1) - 2025-07-22
12+
13+
14+
### Fixed
15+
16+
- Agent communication port now uses the `SO_REUSEADDR` flag, fixing cases where agent
17+
port is reused in a fast consecutive manner and fails.
18+
- Fixed a bug where mirrord-agents were lingering after all client connections
19+
were gone.
20+
21+
22+
### Internal
23+
24+
- Added more traffic mirroring tests.
25+
1126
## [3.152.0](https://github.com/metalbear-co/mirrord/tree/3.152.0) - 2025-07-18
1227

1328

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ resolver = "2"
77

88
# latest commits on rustls suppress certificate verification
99
[workspace.package]
10-
version = "3.152.0"
10+
version = "3.152.1"
1111
edition = "2021"
1212
license = "MIT"
1313
readme = "README.md"
@@ -160,6 +160,9 @@ x509-parser = "0.17"
160160
# Used by `agent`, `auth`, `tls-util`, `tests`
161161
pem = "3"
162162

163+
# Used by `cli`, `auth`
164+
home = "0.5"
165+
163166
[workspace.lints.rustdoc]
164167
private_intra_doc_links = "allow"
165168

changelog.d/+agent-reuse-addr.fixed.md

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Passthrough mirroring is now enabled by default, unless mirrord for Teams is used.

changelog.d/+istio-msg-typo.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fixed a bug where mirrord would display a typo when using istio ambient
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added the `mirrord newsletter` command, which opens the sign-up page in the browser.

mirrord-schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@
465465
},
466466
"passthrough_mirroring": {
467467
"title": "agent.passthrough_mirroring {#agent-passthrough_mirroring}",
468-
"description": "Enables an alternative implementation of traffic mirroring, based on iptables redirects.\n\nWhen used with `agent.flush_connections`, it might fix issues with mirroring non HTTP/1 traffic.\n\nWhen this is set, `network_interface` setting is ignored.\n\nDefaults to `false`.",
468+
"description": "Enables an implementation of traffic mirroring based on iptables redirects.\n\nWhen used with `agent.flush_connections`, it might fix issues with mirroring non HTTP/1 traffic.\n\nWhen this is set, `network_interface` setting is ignored.\n\nDefaults to `false` in mirrord for Teams. Otherwise, defaults to `true`.",
469469
"type": [
470470
"boolean",
471471
"null"

mirrord/agent/src/entrypoint.rs

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,19 @@ enum BackgroundTask<Command> {
204204
Disabled,
205205
}
206206

207+
impl<Command> BackgroundTask<Command> {
208+
/// Waits for the task to finish, and returns its result.
209+
///
210+
/// If the task is [`BackgroundTask::Disabled`], returns [`Ok`].
211+
async fn wait(self) -> Result<(), AgentError> {
212+
let Self::Running(status, channel) = self else {
213+
return Ok(());
214+
};
215+
std::mem::drop(channel);
216+
status.wait().await
217+
}
218+
}
219+
207220
impl<Command> Clone for BackgroundTask<Command> {
208221
fn clone(&self) -> Self {
209222
match self {
@@ -730,7 +743,11 @@ async fn start_agent(args: Args) -> AgentResult<()> {
730743
)
731744
.await?;
732745
(
733-
setup::start_stealer(&state.network_runtime, steal_handle),
746+
setup::start_stealer(
747+
&state.network_runtime,
748+
steal_handle,
749+
cancellation_token.clone(),
750+
),
734751
passthrough_mirroring_enabled.then_some(mirror_handle),
735752
)
736753
}
@@ -825,28 +842,16 @@ async fn start_agent(args: Args) -> AgentResult<()> {
825842
..
826843
} = bg_tasks;
827844

828-
tokio::join!(
829-
async move {
830-
if let BackgroundTask::Running(status, _) = sniffer {
831-
if let Err(error) = status.wait().await {
832-
error!("start_agent -> {error}");
833-
}
834-
}
835-
},
836-
async move {
837-
if let BackgroundTask::Running(status, _) = stealer {
838-
if let Err(error) = status.wait().await {
839-
error!("start_agent -> {error}");
840-
}
841-
}
842-
},
843-
async move {
844-
if let BackgroundTask::Running(status, _) = dns {
845-
if let Err(error) = status.wait().await {
846-
error!("start_agent -> {error}");
847-
}
848-
}
849-
},
845+
let _ = tokio::join!(
846+
sniffer.wait().inspect_err(|error| {
847+
error!(%error, "start_agent -> Sniffer task failed");
848+
}),
849+
stealer.wait().inspect_err(|error| {
850+
error!(%error, "start_agent -> Stealer task failed");
851+
}),
852+
dns.wait().inspect_err(|error| {
853+
error!(%error, "start_agent -> DNS task failed");
854+
}),
850855
);
851856

852857
trace!("start_agent -> Agent shutdown");

mirrord/agent/src/entrypoint/setup.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,12 @@ pub(super) async fn start_sniffer(
8787
pub(super) fn start_stealer(
8888
runtime: &BgTaskRuntime,
8989
steal_handle: StealHandle,
90+
cancellation_token: CancellationToken,
9091
) -> BackgroundTask<StealerCommand> {
9192
let (command_tx, command_rx) = mpsc::channel::<StealerCommand>(1000);
9293

9394
let task_status = runtime
94-
.spawn(TcpStealerTask::new(command_rx, steal_handle).run())
95+
.spawn(TcpStealerTask::new(command_rx, steal_handle).run(cancellation_token))
9596
.into_status("TcpStealerTask");
9697

9798
BackgroundTask::Running(task_status, command_tx)

mirrord/agent/src/incoming/task.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ where
222222
let result = tokio::select! {
223223
result = requests.next() => result,
224224
_ = token.cancelled() => {
225+
tracing::debug!(
226+
connection = ?conn.info,
227+
"Gracefully shutting down a redirected HTTP connection",
228+
);
225229
requests.graceful_shutdown();
226230
continue;
227231
},
@@ -300,6 +304,10 @@ where
300304

301305
match self.ports.entry(port) {
302306
Entry::Vacant(e) => {
307+
tracing::debug!(
308+
from_port = port,
309+
"Creating a new port redirection for a mirroring client"
310+
);
303311
self.redirector.add_redirection(port).await?;
304312
e.insert_entry(PortState {
305313
steal_tx: None,
@@ -326,6 +334,10 @@ where
326334

327335
match self.ports.entry(port) {
328336
Entry::Vacant(e) => {
337+
tracing::debug!(
338+
from_port = port,
339+
"Creating a new port redirection for a stealing client"
340+
);
329341
self.redirector.add_redirection(port).await?;
330342
e.insert_entry(PortState {
331343
steal_tx: Some(conn_tx.clone()),

0 commit comments

Comments
 (0)