Skip to content

Commit 49d8ac9

Browse files
committed
accept proper RFC1929 auth subnegotiation version field
this was wrongly fixed in 06c20ed instead of reverting we now accept the correct version (version field containing 1) plus the incorrect version (5) given by some proxyservers in the wild. curl accepts both forms too. closing #224 addressing #221
1 parent bb30d86 commit 49d8ac9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/core.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,15 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
350350

351351
if(2 != read_n_bytes(sock, in, 2))
352352
goto err;
353-
if(in[0] != 5 || in[1] != 0) {
354-
if(in[0] != 5)
355-
goto err;
356-
else
357-
return BLOCKED;
358-
}
353+
/* according to RFC 1929 the version field for the user/pass auth sub-
354+
negotiation should be 1, which is kinda counter-intuitive, so there
355+
are some socks5 proxies that return 5 instead. other programs like
356+
curl work fine when the version is 5, so let's do the same and accept
357+
either of them. */
358+
if(!(in[0] == 5 || in[0] == 1))
359+
goto err;
360+
if(in[1] != 0)
361+
return BLOCKED;
359362
}
360363
int buff_iter = 0;
361364
buff[buff_iter++] = 5; // version

0 commit comments

Comments
 (0)