You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current implementation of the connect detour always waits for the other side to accept before it returns, while most applications nowadays set the socket to non blocking, then connect should immediately return with EINPROGRESS error code, indicating that the connect is in progress.
We can improve our implementation to check if socket is non blocking, and if it is, we setup the mirror listen socket, but don't accept until agent returns the result, to reproduce similar behavior (as much as possible).
The text was updated successfully, but these errors were encountered:
It would be a bit tricky to implement it this way. The usual flow is to call connect and expect EINPROGRESS, then use poll to wait for result. getsockopt can also be used to get connected/error state of the socket. We'd have to asynchronously let the layer know that the listener is ready (which doesn't fit well into our request-response model and lack of background threads :X)
A simpler solution would be to follow the usual TCP proxy pattern - eagerly accept connection, kill it if we fail to connect to the real peer
Why is it tricky though?
Layer sends ConnectRequest
intProxy responds ConnectInProgress
layer continues
Intproxy accepts connection only after connection is really made on the remote side, if not returns error
We can improve our implementation to check if socket is non blocking, and if it is, we setup the mirror listen socket, but don't accept until agent returns the result
Current implementation of the connect detour always waits for the other side to accept before it returns, while most applications nowadays set the socket to non blocking, then connect should immediately return with EINPROGRESS error code, indicating that the connect is in progress.
We can improve our implementation to check if socket is non blocking, and if it is, we setup the mirror listen socket, but don't accept until agent returns the result, to reproduce similar behavior (as much as possible).
The text was updated successfully, but these errors were encountered: