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 src/Fluxzy.Core.Pcap/OutOfProcessCaptureContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public void Flush()

lock (this) {
_writer.Write((byte) MessageType.Flush);
_writer.Flush();
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/Fluxzy/Commands/StartCommandBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,11 @@ public async Task Run(InvocationContext invocationContext, CancellationToken pro
var uaParserProvider = parseUserAgent ? new UaParserUserAgentInfoProvider() : null;
var systemProxyManager = new SystemProxyRegistrationManager(new NativeProxySetterManager().Get());

await using var scope = new ProxyScope(() => new FluxzyNetOutOfProcessHost(), a => new OutOfProcessCaptureContext(a));
// Scope owns the out-of-proc capture subprocess lifetime. It must be disposed
// BEFORE PackDirectoryToFile runs so the subprocess closes its pcapng FileStreams
// and flushes all buffered packet data to disk; otherwise small captures can sit
// in the 4 KB FileStream buffer and the packager's Length==0 skip drops them.
await using (var scope = new ProxyScope(() => new FluxzyNetOutOfProcessHost(), a => new OutOfProcessCaptureContext(a))) {

if (!ValidateSetting(invocationContext, proxyStartUpSetting)) {
invocationContext.ExitCode = 1;
Expand Down Expand Up @@ -390,6 +394,8 @@ public async Task Run(InvocationContext invocationContext, CancellationToken pro
}
}

} // scope dispose: subprocess exits, pcapng FileStreams closed + flushed

invocationContext.Console.Out.WriteLine("Proxy ended, gracefully");

if (outFileInfo != null) {
Expand Down
3 changes: 2 additions & 1 deletion test/Fluxzy.Tests/Cli/CliTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ protected async Task Run_Cli_Output(string proto, CaptureType rawCap,
if (rawCap != CaptureType.None)
{
var rawCapStream = archiveReader.GetRawCaptureStream(connection.Id);
Assert.True(await rawCapStream!.DrainAsync(disposeStream: true) > 0);
Assert.NotNull(rawCapStream);
Assert.True(await rawCapStream.DrainAsync(disposeStream: true) > 0);
}

if (rule)
Expand Down
Loading