Linux下成功安装和配置Sock5代理的过程

来源:赛迪网 作者:sixth
   

1.首先从网络上找到 socks5-v1.0r11.tar.gz ,还有一个是补丁包,那个包没有下,所以有什么用我不知道。

2.讲socks5-v1.0r11.tar.gz解压倒文件夹,利用下面这个命令,其实这几步网络上的资源很丰富,但我这里力求详细和全面。

解压上述压缩包,执行tar xvzf socks5-v1.0r11.tar.gz

解压缩后在目录下产生一个 socks5-v.1.0r11的目录。

3.进入该目录,运行./configure .这一步我顺利通过。

4.接着运行make,在编译的过程中遇到了问题,让我花了好长时间,在编译clients/ftp/ftp.c文件时,在command函数处出现问题,提示说arargs方法在gcc4.1.2中已经过时,不能用了。但是网上我没有找到可用的解决方法。所以只有自己解决,具体问题是varargs.h和stdarg.h的不兼容,就是说在处理不确定个数的参数的时候方法不同,现在的gcc已经用了stdarg方法,已经不用ararg的方法。两者的差异在于,va_start()函数的参数个数不同,格式也不一样,下面我同时列给出我修改的代码和原来的代码:

 

原来的代码:

 

 

#include 
....
int command(va_alist) va_dcl {
va_list ap;
char *fmt;
int r;
Sig_t oldintr;

abrtflag = 0;
if (debug) {
printf("---> ");
va_start(ap);
fmt = va_arg(ap, char *);
if (strncmp("PASS ", fmt, 5) == 0)
printf("PASS XXXX");
else 
vfprintf(stdout, fmt, ap);
va_end(ap);
printf("\n");
fflush(stdout);
}
if (cout == NULL) {
perror ("No control connection for command");
code = -1;
return (0);
}
oldintr = Signal(SIGINT, cmdabort);
va_start(ap);
fmt = va_arg(ap, char *);
vfprintf(cout, fmt, ap);
va_end(ap);
fflush(cout);
cpend = 1;
r = getreply(!strcmp(fmt, "QUIT"));
Signal(SIGINT, oldintr);
if (abrtflag) {
kill(getpid(),SIGINT);
}
return(r);
}

 

修改过的代码:

 

 

//#include 
#include 


....
/*VARARGS*/
int command(const char *args,...) {
va_list ap;
char *fmt;
int r;
Sig_t oldintr;

abrtflag = 0;
if (cout == NULL) {
perror ("No control connection for command");
code = -1;
return (0);
}
oldintr = Signal(SIGINT, cmdabort);
fmt = args;
va_start(ap,args);
// fmt = va_arg(ap, char *);
vfprintf(cout, fmt, ap);
va_end(ap);
fflush(cout);
cpend = 1;
r = getreply(!strcmp(fmt, "QUIT"));
Signal(SIGINT, oldintr);
if (abrtflag) {
kill(getpid(),SIGINT);
}
return(r);
}

 

这个函数修改过以后,后面还有一个文件clients/telnet/commands.c中的call()函数也要做类是的修改。

 

这里我推介大家看看有关va_start(),va_end的文章;想更深层的可以看看标准c语言中的va函数的用法。

 

 

5.当编译完全通过以后,运行make install 。

 

此时可以说工作已经完成了一半,接下来就是要建立以个配置文件sock5.conf,关于这个配置文件倒是比较简单,网络上别的资源也很多,在此就不累述。

 

6.本以为已经没有什么问题了,却发现运行程序时又出现问题了。刚开始我是使用socks5 -f -s 能运行,但是在另外一台机子上用qq程序进行登录测试,显示代理服务器正常,但是无法传输数据,显示如下:

 

 

socks5 -f -s
02650: Socks5 starting at Wed Jan 16 17:03:49 2008 in normal mode
02650: Bind failed for 0.0.0.0:1080: Address already in use
02650: Accept: Failed to make listening socket
[root@Linux_lxk ~]# socks5 -f -s
02651: Socks5 starting at Wed Jan 16 17:03:52 2008 in normal mode
02651: Bind failed for 0.0.0.0:1080: Address already in use
02651: Accept: Failed to make listening socket
[root@Linux_lxk ~]# socks5 -f -s
02652: Socks5 starting at Wed Jan 16 17:04:12 2008 in normal mode
02652: Bind failed for 0.0.0.0:1080: Address already in use
02652: Accept: Failed to make listening socket
[root@Linux_lxk ~]# stopsocks -kill
[root@Linux_lxk ~]# socks5 -f -s
02657: Socks5 starting at Wed Jan 16 17:04:29 2008 in normal mode
02658: UDP Proxy Request: (192.168.151.17:1502) for user 
02658: UDP Proxy Established: (192.168.151.17:1500) for user 
02658: UDP Proxy Termination: (192.168.151.17:1500) for user ; 0 bytes out 0 bytes in
02666: UDP Proxy Request: (192.168.151.17:1529) for user 
02666: UDP Proxy Established: (192.168.151.17:1526) for user 
02668: TCP Connection Request: Connect (192.168.151.17:1536 to 219.133.49.10:80) for user 
02668: TCP Connection Terminated: Abnormal (192.168.151.17:1536 to 219.133.49.10:80) for user : 
0 bytes out, 0 bytes in
02670: TCP Connection Request: Connect (192.168.151.17:1540 to 219.133.38.31:80) for user 
02670: TCP Connection Terminated: Abnormal (192.168.151.17:1540 to 219.133.38.31:80) for user : 
0 bytes out, 0 bytes in
02669: TCP Connection Request: Connect (192.168.151.17:1539 to 58.60.14.180:80) for user 
02669: TCP Connection Terminated: Abnormal (192.168.151.17:1539 to 58.60.14.180:80) for user : 
0 bytes out, 0 bytes in
02671: TCP Connection Request: Connect (192.168.151.17:1541 to 219.133.60.149:80) for user 
02671: TCP Connection Terminated: Abnormal (192.168.151.17:1541 to 219.133.60.149:80) for user : 
0 bytes out, 0 bytes in
02672: TCP Connection Request: Connect (192.168.151.17:1542 to 121.14.74.247:80) for user 
02672: TCP Connection Terminated: Abnormal (192.168.151.17:1542 to 121.14.74.247:80) for user : 
0 bytes out, 0 bytes in
02673: TCP Connection Request: Connect (192.168.151.17:1543 to 58.60.15.34:80) for user 
02673: TCP Connection Terminated: Abnormal (192.168.151.17:1543 to 58.60.15.34:80) for user : 
0 bytes out, 0 bytes in
02674: TCP Connection Request: Connect (192.168.151.17:1544 to 58.251.62.17:80) for user 
02674: TCP Connection Terminated: Abnormal (192.168.151.17:1544 to 58.251.62.17:80) for user :
 0 bytes out, 0 bytes in
02675: TCP Connection Request: Connect (192.168.151.17:1545 to 219.133.48.108:80) for user 
02675: TCP Connection Terminated: Abnormal (192.168.151.17:1545 to 219.133.48.108:80) for user : 
0 bytes out, 0 bytes in
02676: UDP Proxy Request: (192.168.151.17:1548) for user 
02676: UDP Proxy Established: (192.168.151.17:1546) for user 
02678: TCP Connection Request: Connect (192.168.151.17:1550 to 222.213.0.136:8000) for user 
02678: TCP Connection Terminated: Abnormal (192.168.151.17:1550 to 222.213.0.136:8000) for user : 
0 bytes out, 0 bytes in

 

进行了好几次重复都不行,具体问题在哪里还没找到。后来看到网上有人提议说利用这个命令可以试一下:socks5 -p -f,测试成功。

(责任编辑:A6)


时间:2008-01-29 11:34 来源:赛迪网 作者:sixth 原文链接

好文,顶一下
(0)
0%
文章真差,踩一下
(0)
0%
------分隔线----------------------------


把开源带在你的身边-精美linux小纪念品
无觅相关文章插件,快速提升流量