Remove reverse tunnel when proxy is deactivated #85
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[ISSUE]
In the current codebase, a reverse tunnel is established (on real devices only) during the Wi-Fi proxy configuration:
However, this reverse tunnel is never cleared, causing it to remain active on the device even after the session ends. This leads to an accumulation of "zombie" tunnels, as shown in the
adb reverse --listoutput below:This list will continue to grow until the device is physically reconnected or the ADB server is restarted. This can eventually lead to port conflicts or connectivity issues in subsequent test sessions.
[SOLUTION]
Implement a new function
removeReverseTunnelinadb.tsto remove the specific reverse tunnel matching the TCP port used during setup.Integrate this cleanup logic into the
deleteSessionandonUnexpectedShutdownhooks inplugin.tsto ensure the device environment is restored to its original state, regardless of the test outcome.