feat: optional reverse TCP tunnel for WDA in NAT-restricted environments#1128
Open
dankefox wants to merge 1 commit intoappium:masterfrom
Open
feat: optional reverse TCP tunnel for WDA in NAT-restricted environments#1128dankefox wants to merge 1 commit intoappium:masterfrom
dankefox wants to merge 1 commit intoappium:masterfrom
Conversation
Add opt-in reverse TCP tunnel mode that allows WDA to actively connect outbound to an external relay server, enabling remote control in environments where inbound connections to the iOS device are not feasible (symmetric NAT, multi-layer firewalls, corporate VPNs, etc.). Controlled via environment variables (disabled by default): - WDA_RELAY_HOST: relay server address - WDA_RELAY_PORT: relay server port (default 8201) When not configured, WDA behavior is completely unchanged. Includes: - FBConfiguration: relay host/port accessors from env vars - FBWebServer: reverse tunnel client with auto-reconnect - Scripts/wda-relay-server.js: example Node.js relay server
|
| @@ -0,0 +1,122 @@ | |||
| #!/usr/bin/env node | |||
There was a problem hiding this comment.
I don't find this script useful.
consider adding an end-to-end test instead
|
|
||
| #pragma mark - Reverse TCP Tunnel | ||
|
|
||
| - (void)startReverseTunnel |
There was a problem hiding this comment.
this functionality must be extracted to a separate module and covered by integration tests
| } | ||
| } | ||
|
|
||
| [[[NSURLSession sharedSession] dataTaskWithRequest:localReq |
There was a problem hiding this comment.
this method is too complicated. Consider splitting it to smaller parts
| return true; | ||
| }); | ||
|
|
||
| if (bodyLen == 0 || bodyLen > 10 * 1024 * 1024) { |
|
I'm not sure why to reinvent a custom protocol if the project already uses CocoaHTTPServer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Add an optional reverse TCP tunnel mode that allows WDA to actively connect outbound to an external relay server. This enables remote control of iOS devices in network environments where inbound connections to port 8100 are not feasible.
Problem
WDA defaults to listening on port 8100 for inbound HTTP connections. However, in many real-world environments, inbound connections to the iOS device are blocked or unreachable:
In these scenarios, the standard
http://<device-ip>:8100approach simply does not work.Solution
Instead of requiring the client to connect in to WDA, this PR lets WDA connect out to a relay server. The relay bridges HTTP clients on one side and the WDA reverse connection on the other.
How it works
WDA_RELAY_HOSTand optionallyWDA_RELAY_PORT(default: 8201) as environment variables when launching WDAWhen not configured
Zero impact. If
WDA_RELAY_HOSTis not set, the feature is completely inactive. No code paths are touched, no connections are made, existing behavior is identical.Changes
FBConfiguration.h/mrelayHostandrelayPortaccessors reading fromWDA_RELAY_HOST/WDA_RELAY_PORTenv varsFBWebServer.mnw_connection), with auto-reconnect on failureScripts/wda-relay-server.jsUsage
Design decisions
USE_PORT,USE_IP, andMJPEG_SERVER_PORTpatterns inFBConfigurationnw_connection) for reliable connection managementScripts/for easy adoption, not a required componentTesting
Tested on:
Verified:
/status,/session, tap, swipe, screenshot, and other WDA endpoints all work correctly through the reverse tunnel.