Skip to content

Remove libpcap dependency and add Windows support - #210

Merged
andrewkroh merged 1 commit into
elastic:mainfrom
andrewkroh:fix/remove-libpcap-dependency
Aug 4, 2026
Merged

Remove libpcap dependency and add Windows support#210
andrewkroh merged 1 commit into
elastic:mainfrom
andrewkroh:fix/remove-libpcap-dependency

Conversation

@andrewkroh

Copy link
Copy Markdown
Member

Proposed commit message

Remove libpcap dependency and add Windows support

stream needed libpcap and cgo solely to read capture files offline, so
`go install github.com/elastic/stream@latest` failed on any machine
without libpcap and a C toolchain. Windows was hit hardest because Go
disables cgo there by default.

Replace pcap.OpenOffline with gopacket's pure Go pcapgo readers,
dispatching on the file magic to choose the pcap or pcapng reader and
decompressing gzipped captures explicitly. stream now builds with
CGO_ENABLED=0 everywhere, so libpcap is gone from the Dockerfile, the
Buildkite pipeline, and the GitHub workflows.

Windows also failed to compile because root.go used unix.SignalNum.
Move the signal name lookup behind a build tag: Unix keeps the full
set, while Windows recognizes SIGINT and SIGTERM, the only signals the
Go runtime emulates there.

Read packets in an explicit loop instead of PacketSource.Packets(),
which retries unrecognized errors in a 5ms loop and so would hang
stream indefinitely on a corrupt capture. Truncated captures are still
tolerated with a warning.

Build the published image FROM scratch now that the binary is static,
copying only the CA bundle from the builder. This drops the image from
70.5MB to 56.6MB.

Add a cross-build workflow covering six platforms plus ubuntu, windows
and macos test runs so none of this regresses unnoticed.

Validated by diffing old and new payload extraction across 55 capture
files against libpcap 1.10.5: classic pcap matches byte for byte, and
no file that libpcap could read fails with pcapgo.

stream needed libpcap and cgo solely to read capture files offline, so
`go install github.com/elastic/stream@latest` failed on any machine
without libpcap and a C toolchain. Windows was hit hardest because Go
disables cgo there by default.

Replace pcap.OpenOffline with gopacket's pure Go pcapgo readers,
dispatching on the file magic to choose the pcap or pcapng reader and
decompressing gzipped captures explicitly. stream now builds with
CGO_ENABLED=0 everywhere, so libpcap is gone from the Dockerfile, the
Buildkite pipeline, and the GitHub workflows.

Windows also failed to compile because root.go used unix.SignalNum.
Move the signal name lookup behind a build tag: Unix keeps the full
set, while Windows recognizes SIGINT and SIGTERM, the only signals the
Go runtime emulates there.

Read packets in an explicit loop instead of PacketSource.Packets(),
which retries unrecognized errors in a 5ms loop and so would hang
stream indefinitely on a corrupt capture. Truncated captures are still
tolerated with a warning.

Build the published image FROM scratch now that the binary is static,
copying only the CA bundle from the builder. This drops the image from
70.5MB to 56.6MB.

Add a cross-build workflow covering six platforms plus ubuntu, windows
and macos test runs so none of this regresses unnoticed.

Validated by diffing old and new payload extraction across 55 capture
files against libpcap 1.10.5: classic pcap matches byte for byte, and
no file that libpcap could read fails with pcapgo.
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

💚 Build Succeeded

andrewkroh added a commit to elastic/integration-skills that referenced this pull request Aug 4, 2026
`go install github.com/elastic/stream/cmd/stream@latest` fails because
that package does not exist. stream's main package sits at the module
root, so the correct path is `github.com/elastic/stream@latest`. This
was reported by a Windows user who could not install stream.

`stream -version` is wrong for the same block: version is a subcommand
rather than a flag, so the flag form fails with "unknown shorthand
flag: 'v' in -version".

Relates: elastic/stream#210 (fixes the windows build)
@andrewkroh
andrewkroh merged commit e9467f1 into elastic:main Aug 4, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Team:Security-Service Integrations Team:Security-Service Integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants