-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transfer client id on connection open
Whenever a port redirection is enabled (typically through "adb reverse"), connect() will succeed even if the relay server is not listening on the other side of the tunnel. Commit 301867e provided a workaround, assuming that the port forwarding was local: the client attempted to read from the socket with the smallest possible timeout. Since there was nothing to read, a read error indicated that no server was listening on the other side of the tunnel, while the connection was considered ok on timeout. But this does not generally fix the problem. For example, if the relay server is executed remotely and exposed through a SSH local port forwarding, then connect() would still succeed (a server was listening on the other side of the "adb reverse" tunnel) even if the relay server was not listening behind the SSH tunnel. Therefore, modify the protocol between the client and the relay server: when a client connects, the relay server immediately writes its id (an integer) to the TCP socket. The client considers itself connected only once it has received this number. Thus, it will be able to detect connection failure before switching its state to CONNECTED.
- Loading branch information
Showing
3 changed files
with
73 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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