fix: auto-detect active network interface for Android e2e PCAP mode#976
Conversation
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>
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>
There was a problem hiding this comment.
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
wlan0is 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.
Agent-Logs-Url: https://github.com/gojue/ecapture/sessions/6dba5e55-b311-48f1-a5aa-50456916da2c Co-authored-by: cfc4n <709947+cfc4n@users.noreply.github.com>
✅ E2E Test Results: PASSEDTest Run: #24005225914 Tests Executed:
✅ 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>
✅ E2E Test Results: PASSEDTest Run: #24005450557 Tests Executed:
✅ All e2e tests passed successfully! The TLS capture functionality is working correctly. Automated e2e test results for commit 5902dc8 |
set -euo pipefailissues inandroid_tls_e2e_test.sh: add|| trueto grep pipelines inside command substitutionsdetectActiveInterface→firstUpNonLoopbackInterfacein bothopenssl/config_iface.goandgotls/config_iface.go(and all callers/tests) — name now accurately reflects behaviorTestIfaceHasAddr_Loopbackto actually assert when lo is UP but ifaceHasAddr returns false (both test files)go test ./internal/... ./pkg/... ./cli/...)