导读:
前几天MSN老上不去,我还以为是公司做了防火墙限制.于是把去年这个时候写得一个代理程序改了改,拿出来用.结果发现MSN是微软的问题,鄙视啊……
写得比较急,这个只支持TCP代理,UDP的我没写,MSN用不上.这个代码可以随意修改分发,不过最好能给我一份.
这是头文件:
-
-
-
-
-
-
-
-
-
-
-
- #ifndef SOCKS5_H
- #define SOCKS5_H
- #define VERSION 0x05
- #define CONNECT 0x01
- #define IPV4 0x01
- #define DOMAIN 0x03
- #define IPV6 0x04
- typedef struct _method_select_response
- {
- char version;
- char select_method;
- } METHOD_SELECT_RESPONSE;
- typedef struct _method_select_request
- {
- char version;
- char number_methods;
- char methods[255];
- } METHOD_SELECT_REQUEST;
- typedef struct _AUTH_RESPONSE
- {
- char version;
- char result;
- } AUTH_RESPONSE;
- typedef struct _AUTH_REQUEST
- {
- char version;
- char name_len;
- char name[255];
- char pwd_len;
- char pwd[255];
- } AUTH_REQUEST;
- typedef struct _SOCKS5_RESPONSE
- {
- char version;
- char reply;
- char reserved;
- char address_type;
- char address_port[1];
- }SOCKS5_RESPONSE;
- typedef struct _SOCKS5_REQUEST
- {
- char version;
- char cmd;
- char reserved;
- char address_type;
- }SOCKS5_REQUEST;
- #endif
- 主程序来了:
-
-
-
-
-
-
-
-
-
-
-
-
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include
- #include "Socks5.h"
- #define MAX_USER 10
- #define BUFF_SIZE 1024
- #define AUTH_CODE 0x02
- #define TIME_OUT 6000000
- #define USER_NAME "yunshu"
- #define PASS_WORD "ph4nt0m"
-
- int SelectMethod( int sock )
- {
- char recv_buffer[BUFF_SIZE] = { 0 };
- char reply_buffer[2] = { 0 };
- METHOD_SELECT_REQUEST *method_request;
- METHOD_SELECT_RESPONSE *method_response;
-
-
- int ret = recv( sock, recv_buffer, BUFF_SIZE, 0 );
- if( ret <= 0 )
- {
- pthread_detach( work_thread );
- }
- }
- }
|