Skip to content

fix: auto-detect active network interface for Android e2e PCAP mode#976

Merged
cfc4n merged 4 commits into
masterfrom
copilot/fix-android-e2e-error
Apr 6, 2026
Merged

fix: auto-detect active network interface for Android e2e PCAP mode#976
cfc4n merged 4 commits into
masterfrom
copilot/fix-android-e2e-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 5, 2026

  • Extend pcapng fix to gotls module (previous session)
  • Fix shell script set -euo pipefail issues in android_tls_e2e_test.sh: add || true to grep pipelines inside command substitutions
  • Rename detectActiveInterfacefirstUpNonLoopbackInterface in both openssl/config_iface.go and gotls/config_iface.go (and all callers/tests) — name now accurately reflects behavior
  • Fix TestIfaceHasAddr_Loopback to actually assert when lo is UP but ifaceHasAddr returns false (both test files)
  • All tests pass (go test ./internal/... ./pkg/... ./cli/...)

On Android emulators, wlan0 may exist but have no IP addresses.
The emulator typically uses eth0 or similar for networking.

Changes:
- internal/probe/openssl/config_iface.go: new shared helpers
  ifaceHasAddr() and detectActiveInterface()
- internal/probe/openssl/config_ecandroid.go: setDefaultIfname() now
  tries wlan0 first then falls back to any active interface
- internal/probe/openssl/config_linux.go: same improvement
- internal/probe/openssl/config_iface_test.go: unit tests
- test/e2e/android/android_tls_e2e_test.sh: improved interface
  detection with address validation and fallback
- .github/agents/pr-agent.md: add golangci-lint requirement

Agent-Logs-Url: https://github.com/gojue/ecapture/sessions/a22a638a-4203-4005-b9ef-e52aeb6bfadc

Co-authored-by: cfc4n <709947+cfc4n@users.noreply.github.com>
@cfc4n cfc4n marked this pull request as ready for review April 5, 2026 16:00
Copilot AI review requested due to automatic review settings April 5, 2026 16:00
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. fix bug fix PR labels Apr 5, 2026
The gotls module also supports pcap/pcapng capture mode and had the
same hardcoded wlan0 issue. Added setDefaultIfname() with the same
auto-detection logic (try wlan0, fall back to any active interface).

Changes:
- internal/probe/gotls/config_iface.go: new shared helpers and
  setDefaultIfname() for gotls
- internal/probe/gotls/config_iface_test.go: unit tests
- internal/probe/gotls/config.go: call setDefaultIfname() before
  Ifname empty check in pcap mode validation

Agent-Logs-Url: https://github.com/gojue/ecapture/sessions/6dba5e55-b311-48f1-a5aa-50456916da2c

Co-authored-by: cfc4n <709947+cfc4n@users.noreply.github.com>
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 Android E2E TLS PCAP mode failures caused by hardcoding wlan0 on emulators where wlan0 exists but has no assigned IP, by adding interface auto-detection in both the OpenSSL probe config and the Android E2E test script.

Changes:

  • Add OpenSSL config helpers to detect an UP, non-loopback interface with at least one address, and use them as a fallback when wlan0 is unusable.
  • Update Android TLS E2E PCAP mode to validate the chosen interface has an IPv4 address and fall back to another UP interface when needed.
  • Update PR agent guidance to require running golangci-lint run ./... before submitting Go changes.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
test/e2e/android/android_tls_e2e_test.sh Adds device-side interface selection/validation for PCAP mode with fallback logic.
internal/probe/openssl/config_linux.go Updates default interface selection to try wlan0, then auto-detect a usable interface.
internal/probe/openssl/config_iface.go Introduces helper functions for interface/address detection.
internal/probe/openssl/config_iface_test.go Adds basic tests for the new interface detection helpers.
.github/agents/pr-agent.md Documents mandatory golangci-lint verification for Go changes.

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

Comment thread test/e2e/android/android_tls_e2e_test.sh Outdated
Comment thread test/e2e/android/android_tls_e2e_test.sh Outdated
Comment thread test/e2e/android/android_tls_e2e_test.sh Outdated
Comment thread internal/probe/openssl/config_linux.go
Comment thread internal/probe/openssl/config_iface.go Outdated
Comment thread internal/probe/openssl/config_iface_test.go Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 5, 2026

✅ E2E Test Results: PASSED

Test Run: #24005225914

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 e9cf2fb

…n naming, and test assertions

1. Shell script (android_tls_e2e_test.sh): Add '|| true' to grep pipelines
   inside command substitutions so that set -euo pipefail does not abort
   the script when grep finds no matches.

2. Rename detectActiveInterface -> firstUpNonLoopbackInterface in both
   openssl/config_iface.go and gotls/config_iface.go (plus all callers
   and tests). The new name accurately describes what the function does:
   it returns the first non-loopback UP interface with an address, which
   is not necessarily the default-route interface.

3. Fix TestIfaceHasAddr_Loopback in both test files to actually assert
   (t.Error) when lo is UP but ifaceHasAddr returns false, instead of
   unconditionally passing. Skip is now limited to when lo is truly
   unavailable or down.

Agent-Logs-Url: https://github.com/gojue/ecapture/sessions/bd7f6066-2a67-4381-8311-0d2a5607a3d7

Co-authored-by: cfc4n <709947+cfc4n@users.noreply.github.com>
Copilot finished work on behalf of cfc4n April 5, 2026 16:19
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 5, 2026

✅ E2E Test Results: PASSED

Test Run: #24005450557

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 5902dc8

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 Apr 6, 2026
@cfc4n cfc4n merged commit 10352d4 into master Apr 6, 2026
12 checks passed
@cfc4n cfc4n deleted the copilot/fix-android-e2e-error branch April 6, 2026 03:25
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:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants