歡迎您光臨本站 註冊首頁

Linux下成功安裝和配置Sock5代理的過程

←手機掃碼閱讀     火星人 @ 2014-03-12 , reply:0
   

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)



[火星人 ] Linux下成功安裝和配置Sock5代理的過程已經有495次圍觀

http://coctec.com/docs/net/show-post-68297.html