Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/rofl0r/proxychains-ng.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrofl0r <retnyg@gmx.net>2015-06-13 21:02:11 +0300
committerrofl0r <retnyg@gmx.net>2015-06-13 21:02:11 +0300
commit49adb6ce29504565b979aaddb1bc62d3999a17c6 (patch)
treeee206fede780b768e55861e4291e8ea664ed3398
parentc7fa7bf86a951bd37c3c0f93f7322fc8602c2acc (diff)
simplify socks5 buffer setup code
-rw-r--r--src/core.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/core.c b/src/core.c
index a17aada..8c5b470 100644
--- a/src/core.c
+++ b/src/core.c
@@ -313,20 +313,13 @@ static int tunnel_to(int sock, ip_type ip, unsigned short port, proxy_type pt, c
}
break;
case SOCKS5_TYPE:{
- if(user) {
- buff[0] = 5; //version
- buff[1] = 2; //nomber of methods
- buff[2] = 0; // no auth method
- buff[3] = 2; /// auth method -> username / password
- if(4 != write_n_bytes(sock, (char *) buff, 4))
- goto err;
- } else {
- buff[0] = 5; //version
- buff[1] = 1; //nomber of methods
- buff[2] = 0; // no auth method
- if(3 != write_n_bytes(sock, (char *) buff, 3))
- goto err;
- }
+ int n_methods = user ? 2 : 1;
+ buff[0] = 5; // version
+ buff[1] = n_methods ; // number of methods
+ buff[2] = 0; // no auth method
+ if(user) buff[3] = 2; /// auth method -> username / password
+ if(2+n_methods != write_n_bytes(sock, (char *) buff, 2+n_methods))
+ goto err;
if(2 != read_n_bytes(sock, (char *) buff, 2))
goto err;