auth-once mode: prevent same addr from being added multiple times
commit959385189cd5019fd7d4848e40bf35d10578d0ed
authorrofl0r <rofl0r@users.noreply.github.com>
Fri, 23 Oct 2020 14:48:36 +0000 (23 15:48 +0100)
committerrofl0r <rofl0r@users.noreply.github.com>
Fri, 23 Oct 2020 14:48:36 +0000 (23 15:48 +0100)
tree80be9a1117bc465a8ed785b1bca43f8d146bf7e6
parent5795a84c4fbd61685690a8cd6d43969efc083614
auth-once mode: prevent same addr from being added multiple times

usually socks5 clients always put the 0 (no-auth) authentication
first, which will automatically make the address pass auth without
checking credentials, however it's possible that the client sends
only username auth method or puts it first in the list, in which
case the old code would add the same ip over and over to the list.

example change for proxychains-ng to trigger the unwanted behaviour:

--- a/src/core.c
+++ b/src/core.c
@@ -314,8 +314,8 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
                        int n_methods = ulen ? 2 : 1;
                        buff[0] = 5;    // version
                        buff[1] = n_methods ;   // number of methods
-                       buff[2] = 0;    // no auth method
-                       if(ulen) buff[3] = 2;    /// auth method -> username / password
+                       buff[2] = 2;
+                       buff[3] = 0;
                        if(2+n_methods != write_n_bytes(sock, (char *) buff, 2+n_methods))
                                goto err;

this testing patch requires that user&pass are supplied in the
proxychains-ng config, otherwise bad things may happen.
sockssrv.c