Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: server was timing out response from the proxy instead of the request from the client. #104

Merged
merged 1 commit into from
Apr 4, 2020

Conversation

notsure2
Copy link
Contributor

@notsure2 notsure2 commented Apr 4, 2020

This fixes a very annoying subtle bug, where the timeout was flipped on the client side in case of TCP only. So in case of a server resource that replies with empty TCP ACKs when receiving input (eg: idle SSH session sending SSH null packets to keep the connection alive), cloak was timing out the connection and killing it.

@cbeuw
Copy link
Owner

cbeuw commented Apr 4, 2020

The original behaviour was that the stream times out when the proxy client hasn't sent any data to Cloak for a period of time (i.e. nothing was read from localConn). When the server is not sending anything to the stream, Cloak client doesn't time it out because there's no timeout on reading from stream

@cbeuw
Copy link
Owner

cbeuw commented Apr 4, 2020

The scenario you mentioned may affect the server side:

go util.Pipe(localConn, newStream, 0)
go util.Pipe(newStream, localConn, sta.Timeout)

Because nothing is read from the proxy server program through localConn, Cloak closes that stream

@notsure2 notsure2 changed the title Fix: client was timing out the response of the cloak server instead of the request of the client. Fix: server was timing out response from the proxy instead of the request from the client. Apr 4, 2020
@notsure2
Copy link
Contributor Author

notsure2 commented Apr 4, 2020

@cbeuw You are correct, I got confused because Pipe is dst, src, timeout instead of src, dst, timeout.
Please check now :-)

@cbeuw cbeuw merged commit 35236b2 into cbeuw:master Apr 4, 2020
@notsure2 notsure2 deleted the premature-tcp-close branch April 4, 2020 15:05
@notsure2 notsure2 restored the premature-tcp-close branch April 4, 2020 15:06
@notsure2 notsure2 deleted the premature-tcp-close branch April 4, 2020 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants