Skip to content

Fix ecaptureQ remote mode: wire event writer to probe dispatcher#964

Merged
cfc4n merged 6 commits intomasterfrom
copilot/fix-ecaptureq-windows-remote-connection
Mar 28, 2026
Merged

Fix ecaptureQ remote mode: wire event writer to probe dispatcher#964
cfc4n merged 6 commits intomasterfrom
copilot/fix-ecaptureq-windows-remote-connection

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

  • 分析现有E2E测试结构和CI工作流
  • 创建 test/e2e/ecaptureq_e2e_test.sh E2E测试脚本(模仿 tls_e2e_test.sh 风格)
  • 在 Makefile 中添加 e2e-ecaptureq 目标
  • 将 ecaptureQ E2E 测试集成到 e2e-advanced 目标中
  • 更新 .github/workflows/e2e.yml 添加 ecaptureq_client 构建步骤和测试说明
  • 验证脚本语法和构建
  • 代码审查通过(无相关问题)
  • 安全扫描通过(无告警)
Original prompt

This section details on the original issue you should resolve

<issue_title>Windows 客户端远程模式连接 Android 上的 ecapture 实例无法收到包</issue_title>
<issue_description>Windows 电脑和 Android 手机在同一局域网。

尝试过如下版本:
ecaptureQ 版本:0.3.0/0.2.2/0.2.1
ecapture 版本:2.0.1/2.0.0

Android 上 ecapture 可以正常启动,并且能抓到包,但是在 Windows 的 ecaptureQ 客户端配置好远程 ecapture ws 地址后无法显示任何包(更换多个端口均无法显示)

Image

Android 上 ecapture 启动命令如下:

Image

ecaptureQ 客户端配置如下:

Image

反复点击 stop start 按钮,ecapture 会有连接的提示

New WebSocket connection from http://localhost/readPump: starting to read messages from WebSocket connection

Image</issue_description>

<agent_instructions>这个问题,大概是因为重构了ecapture代码导致,你可以对比v1.5.2 和 2.0.1版本的差异,用来快速定位问题。
eCapture 和eCaptureQ 的通讯协议在根目录下的protobuf目录中。不过,我判断问题是出在2.0.* 重构后,在指定CLI 参数 --ecaptureq=xxxxx后, Writer 或 Handler 部分设置错误</agent_instructions>

Comments on the Issue (you are @copilot in this section)


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI and others added 2 commits March 25, 2026 13:16
When --ecaptureq flag is specified, events from eBPF probes were not being
sent to the ecaptureQ WebSocket server. The ecaptureQEventWriter was defined
but never instantiated or connected to the event dispatch pipeline.

Changes:
- Add GetEventWriter/SetEventWriter to domain.Configuration interface
- Create IOWriterAdapter to wrap io.Writer as OutputWriter
- Modify ecaptureQEventWriter to encode events as protobuf LogEntry
- In runProbe(), create ecaptureQEventWriter and set on probe config
- In BaseProbe.Initialize(), register additional TextHandler for ecaptureQ

Co-authored-by: cfc4n <709947+cfc4n@users.noreply.github.com>
Agent-Logs-Url: https://github.com/gojue/ecapture/sessions/21b7ed29-95c2-44c1-9d2f-2cfc798a7da7
Copilot AI changed the title [WIP] Fix Windows client remote mode not receiving packets from Android ecapture Fix ecaptureQ remote mode: wire event writer to probe dispatcher Mar 25, 2026
Copilot AI requested a review from cfc4n March 25, 2026 13:21
Copilot stopped work on behalf of cfc4n due to an error March 25, 2026 13:52
…ng to server, replace handler instead of adding alongside

1. cli/cmd/ecaptureq.go: Reverted Write() to simple pass-through (like pre-refactoring)
2. pkg/ecaptureq/server.go: Moved protobuf encoding into WriteEvent() (consistent with WriteLog())
3. internal/probe/base/base_probe.go: When --ecaptureq EventWriter is set, use it as the ONLY
   text handler (replaces file/socket handler, avoiding conflict)

Co-authored-by: cfc4n <709947+cfc4n@users.noreply.github.com>
Agent-Logs-Url: https://github.com/gojue/ecapture/sessions/bd7d5c23-7f1d-4f64-b6de-ae9a88f604d2
@cfc4n cfc4n marked this pull request as ready for review March 27, 2026 14:05
Copilot AI review requested due to automatic review settings March 27, 2026 14:05
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. fix bug fix PR labels Mar 27, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes ecaptureQ remote mode by ensuring probe-dispatched events are routed through the ecaptureQ WebSocket server using the protobuf LogEntry event protocol, rather than being written to the default file/socket output path.

Changes:

  • Encode events as protobuf LogEntry (EVENT) in Server.WriteEvent() and broadcast to connected WebSocket clients.
  • Wire a pre-configured io.Writer event sink from CLI (--ecaptureq) into probe initialization so it replaces the default text output writer.
  • Introduce an io.Writerwriters.OutputWriter adapter and extend configuration interfaces/implementations to carry the event writer.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/ecaptureq/server.go Moves event protobuf encoding into WriteEvent() and broadcasts encoded messages.
internal/probe/base/base_probe.go Uses cfg.GetEventWriter() (when present) as the sole text output writer for event dispatch.
internal/output/writers/iowriter_adapter.go Adds an adapter to wrap io.Writer as an OutputWriter.
internal/domain/configuration.go Extends the Configuration interface with GetEventWriter/SetEventWriter.
internal/config/base_config.go Stores EventWriter io.Writer (non-JSON) and implements the new interface methods.
cli/cmd/root.go In --ecaptureq mode, sets the probe config’s event writer to the ecaptureQ event writer.
cli/cmd/ecaptureq.go Adjusts ecaptureQEventWriter.Write to use a pointer receiver.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown

✅ E2E Test Results: PASSED

Test Run: #23544996141

Tests Executed:

  • TLS/OpenSSL Module (curl → github.com)
  • GnuTLS Module (wget/curl → github.com)
  • GoTLS Module (Go client → github.com)

✅ All e2e tests passed successfully! The TLS capture functionality is working correctly.


Automated e2e test results for commit 3f77697

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Mar 28, 2026
@github-actions
Copy link
Copy Markdown

✅ E2E Test Results: PASSED

Test Run: #23685328652

Tests Executed:

  • TLS/OpenSSL Module (curl → github.com)
  • GnuTLS Module (wget/curl → github.com)
  • GoTLS Module (Go client → github.com)
  • ecaptureQ Module (WebSocket event streaming)

✅ All e2e tests passed successfully! The TLS capture functionality is working correctly.


Automated e2e test results for commit 39057e4

Copy link
Copy Markdown
Member

@cfc4n cfc4n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 28, 2026
@cfc4n cfc4n merged commit 3b4b1b0 into master Mar 28, 2026
11 of 12 checks passed
@cfc4n cfc4n deleted the copilot/fix-ecaptureq-windows-remote-connection branch March 28, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix bug fix PR lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows 客户端远程模式连接 Android 上的 ecapture 实例无法收到包

3 participants