Skip to content

Commit

Permalink
Remove nugatory EC_TTL_EXPIRED error before idle connection closes.
Browse files Browse the repository at this point in the history
In the case where connect_socks_target() succeeds, the proxy client receives
an EC_SUCCESS message and the client thread passes control to copyloop(),
which then proxies application-layer data. If both the client and remote
connections are idle for too long, the call to poll() inside copyloop()
returns zero, giving microsocks the opportunity to reap the inactive
connection.

Before closing the idle connection an EC_TTL_EXPIRED message is returned to
the client. Since the client has already previously received EC_SUCCESS, it
believes it is receiving application-layer data from the proxied target. This
causes the user to receive a false \x05\x06\x00\x01\x00\x00\x00\x00\x00\x00
data sequence before the connection is closed.

This commit removes the call to send_error() that returns the EC_TTL_EXPIRED
message for an idle connection. An EC_TTL_EXPIRED error can still correctly be
returned in the case where the initial socket() call to the remote address
returns ETIMEDOUT.

Fixes issue #53.
  • Loading branch information
bschofield authored and rofl0r committed Feb 1, 2022
1 parent 2702f85 commit 375e5a6
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion sockssrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ static void copyloop(int fd1, int fd2) {
when a connection is really unused. */
switch(poll(fds, 2, 60*15*1000)) {
case 0:
send_error(fd1, EC_TTL_EXPIRED);
return;
case -1:
if(errno == EINTR || errno == EAGAIN) continue;
Expand Down

0 comments on commit 375e5a6

Please sign in to comment.