1.首先从网络上找到socks5-v1.0r11.tar.gz,还有一个是补丁包,那个包没有下,所以有什么用我不知道。
2.讲socks5-v1.0r11.tar.gz解压倒文件夹,利用下面这个命令,其实这几步网络上的资源很丰富,但我这里力求详细和全面。
解压上述压缩包,执行tarxvzfsocks5-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....intcommand(va_alist)va_dcl{va_listap;char*fmt;intr;Sig_toldintr;abrtflag=0;if(debug){printf("--->");va_start(ap);fmt=va_arg(ap,char*);if(strncmp("PASS",fmt,5)==0)printf("PASSXXXX");elsevfprintf(stdout,fmt,ap);va_end(ap);printf("\n");fflush(stdout);}if(cout==NULL){perror("Nocontrolconnectionforcommand");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*/intcommand(constchar*args,...){va_listap;char*fmt;intr;Sig_toldintr;abrtflag=0;if(cout==NULL){perror("Nocontrolconnectionforcommand");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.当编译完全通过以后,运行makeinstall.
此时可以说工作已经完成了一半,接下来就是要建立以个配置文件sock5.conf,关于这个配置文件倒是比较简单,网络上别的资源也很多,在此就不累述。
6.本以为已经没有什么问题了,却发现运行程序时又出现问题了。刚开始我是使用socks5-f-s能运行,但是在另外一台机子上用qq程序进行登录测试,显示代理服务器正常,但是无法传输数据,显示如下:
socks5-f-s02650:Socks5startingatWedJan1617:03:492008innormalmode02650:Bindfailedfor0.0.0.0:1080:Addressalreadyinuse02650:Accept:Failedtomakelisteningsocket[root@Linux_lxk~]#socks5-f-s02651:Socks5startingatWedJan1617:03:522008innormalmode02651:Bindfailedfor0.0.0.0:1080:Addressalreadyinuse02651:Accept:Failedtomakelisteningsocket[root@Linux_lxk~]#socks5-f-s02652:Socks5startingatWedJan1617:04:122008innormalmode02652:Bindfailedfor0.0.0.0:1080:Addressalreadyinuse02652:Accept:Failedtomakelisteningsocket[root@Linux_lxk~]#stopsocks-kill[root@Linux_lxk~]#socks5-f-s02657:Socks5startingatWedJan1617:04:292008innormalmode02658:UDPProxyRequest:(192.168.151.17:1502)foruser02658:UDPProxyEstablished:(192.168.151.17:1500)foruser02658:UDPProxyTermination:(192.168.151.17:1500)foruser;0bytesout0bytesin02666:UDPProxyRequest:(192.168.151.17:1529)foruser02666:UDPProxyEstablished:(192.168.151.17:1526)foruser02668:TCPConnectionRequest:Connect(192.168.151.17:1536to219.133.49.10:80)foruser02668:TCPConnectionTerminated:Abnormal(192.168.151.17:1536to219.133.49.10:80)foruser:0bytesout,0bytesin02670:TCPConnectionRequest:Connect(192.168.151.17:1540to219.133.38.31:80)foruser02670:TCPConnectionTerminated:Abnormal(192.168.151.17:1540to219.133.38.31:80)foruser:0bytesout,0bytesin02669:TCPConnectionRequest:Connect(192.168.151.17:1539to58.60.14.180:80)foruser02669:TCPConnectionTerminated:Abnormal(192.168.151.17:1539to58.60.14.180:80)foruser:0bytesout,0bytesin02671:TCPConnectionRequest:Connect(192.168.151.17:1541to219.133.60.149:80)foruser02671:TCPConnectionTerminated:Abnormal(192.168.151.17:1541to219.133.60.149:80)foruser:0bytesout,0bytesin02672:TCPConnectionRequest:Connect(192.168.151.17:1542to121.14.74.247:80)foruser02672:TCPConnectionTerminated:Abnormal(192.168.151.17:1542to121.14.74.247:80)foruser:0bytesout,0bytesin02673:TCPConnectionRequest:Connect(192.168.151.17:1543to58.60.15.34:80)foruser02673:TCPConnectionTerminated:Abnormal(192.168.151.17:1543to58.60.15.34:80)foruser:0bytesout,0bytesin02674:TCPConnectionRequest:Connect(192.168.151.17:1544to58.251.62.17:80)foruser02674:TCPConnectionTerminated:Abnormal(192.168.151.17:1544to58.251.62.17:80)foruser:0bytesout,0bytesin02675:TCPConnectionRequest:Connect(192.168.151.17:1545to219.133.48.108:80)foruser02675:TCPConnectionTerminated:Abnormal(192.168.151.17:1545to219.133.48.108:80)foruser:0bytesout,0bytesin02676:UDPProxyRequest:(192.168.151.17:1548)foruser02676:UDPProxyEstablished:(192.168.151.17:1546)foruser02678:TCPConnectionRequest:Connect(192.168.151.17:1550to222.213.0.136:8000)foruser02678:TCPConnectionTerminated:Abnormal(192.168.151.17:1550to222.213.0.136:8000)foruser:0bytesout,0bytesin
进行了好几次重复都不行,具体问题在哪里还没找到。后来看到网上有人提议说利用这个命令可以试一下:socks5-p-f,测试成功。