linux平台socks5代理Socks5 proxy for Linux platformA few days ago, MSN couldn't get up. I thought the company hadfirewall restrictions. So this time last year wrote a proxyprogram changed to change, use it out. It turned out that MSNwas because of Microsoft' s problems and despised ah. . . . . .Because the writing is more urgent, this only supports TCP agent,UDP I did not write, because MSN can not use. This code can bemodified and distributed at will, but you'd better give me one.This is the head file:
///////////////////////////////////////////////////////////
////////////////////////////////////////////////////
/ / Socks5 proxy header file defines the related data packetstructure
/ / version 0. 1, author Yun Shu
//January 9, 2007 at 1 : 15 in the morning, GF home for 11 days.In January 25, 2008 this year, GF/ changes, always beside me,haha
/ /
/ / reference:
/ / http://www.rfc-editor.org/rfc/rfc1928. txt
/ / http://www.rfc-editor.org/rfc/rfc1929. txt
///////////////////////////////////////////////////////////
////////////////////////////////////////////////////
#ifndef SOCKS5_H
#def ine SOCKS5_H
#def ine VERSION 0x05
#def ine CONNECT 0x01
#def ine IPV4 0x01
#define DOMAIN 0x03
#def ine IPV6 0x04
Typedef struct_method_select_response // negotiation methodof server response
{
Char version; / / server supported versions of Socks, 0x04 or0x05
Char select_method; / / server selection method, 0x00 foranonymous 0x02 password authentication
} METHOD_S ELECT_RES PONSE;
Typedef struct _method_select_request / / server requestconsultation method
{
Char version; / / client support version of 0x04 or 0x05Char number_methods; / / the number of client support methodChar methods[255] ; / / type methods supported by the client,up to 255, 0x00 anonymous 0x02 password authentication} METHOD_S ELECT_REQUES T;
Typedef struct_AUTH_RESPONSE//user password authenticationserver response
{
Char version; / / version, here is 0x01 constant
Char result; / / server authentication results, 0x00 issuccessful, others are failed
} AU TH_RES PON SE;
Typedef struct_AUTH_REQUEST/ /user password authenticationclient request
{
Char version; / / version, here is 0x01 constant
Char name_len; / / the third field name length, a byte, thelength is 0xff
Char name[255] ; / / username
Char pwd_len; / / the fourth field length, a byte, the lengthis 0xff
Char pwd[255] ; / / password
} AUTH_REQUES T;
Typedef struct_SOCKS5_RESPONSE/ / connect host, Socks proxyserver response
{
Char version; / / server supported versions of Socks, 0x04 or0x05
Char reply; //proxy server to connect to host the 0x00 successChar reserved; / / keep constant, 0x00
Char address_type; //Socks proxy server address binding type,IP V4 0x01, IP V6 0x04, the domain name is 0x03
Char address_port[1] ; // if address_type for the domain name,
where the first byte length for the domain name, followed bythe domain name itself, 0 characters at the end, after thedomain name for Socks proxy server port binding
}SOCKS5_RESPONSE;
Typedef struct _SOCKS5_REQUEST / / client request to connectto host
{
Char version;
/ / client support version of Socks, 0x04 or 0x05
Char CMD; //CONNECT cl ient command, 0x01, BIND 0x02, UDP 0x03,is 0x01
Char reserved; / / keep constant, 0x00
Char address_type; / / client requests the real host addresstype, IP V4 0x00, IP V6 0x04, char domain name is 0x03address_port[1] ; // if address_type for the domain name, herethe first byte length of the domain, followed by the domain nameitself, 0 characters at the end, the domain name after the realhost binding port
}SOCKS 5_REQUE ST;
#endif
Here comes the main program:
///////////////////////////////////////////////////////////
////////////////////////////////////////////////////
/ / Socks5 procedures, only support TCP proxy
/ / version 0. 1, author Yun Shu
//January 9, 2007 at 1 : 15 in the morning, GF home for 11 days.In January 25, 2008 this year, GF/ changes, always beside me,haha
/ /
/ / reference:
/ / http://www.rfc-editor.org/rfc/rfc1928. txt
/ / http://www.rfc-editor.org/rfc/rfc1929. txt
/ / compiler:
-o Socks5 -O2 Socks5.c -lpthread / GCC (RedHat AS5)
///////////////////////////////////////////////////////////
////////////////////////////////////////////////////
#include <stdio.h>
#include <netinet/in.h>#include <netdb.h>
#include <sys/time.h>#include <sys/types.h>#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <pthread.h>#include <errno.h>
#include <string.h>
#include <sys/socket.h>#include <arpa/inet.h>#include "Socks5.h""#define MAX_USER 10
#define BUFF_SIZE 1024
#def ine AUTH_CODE 0x02
#def ine TIME_OUT 6000000
#def ine USER_NAME "Yunshu""
#def ine PASS_WORD "ph4nt0m""
Auth method / / Select, return 0 if success, -1 if failedInt SelectMethod (int sock)
{
Char recv_buffer[BUFF_SIZE] = {0} ;
Char reply_buffer[2] = {0} ;
METHOD_SELECT_REQUEST *me tho d_reques t;
METHOD_SELECT_RESPONSE *method_response;
R ecv / / METHOD_SELECT_REQUE ST
Int, RET = recv (sock, recv_buffer, BUFF_SIZE, 0) ;
If (RET 0)
{
PERROR ("recv error") ;
Close (sock) ;
Return -1;
}
//printf (SelectMethod: , recv,%d, bytes\n, RET) ;
If client request a wrong version / or a wrong number_methodMethod_request = (METHOD_SELECT_REQUEST *) recv_buf fer;Method_response = (METHOD_SELECT_RESPONSE *) rep ly_buf fer;Method_response->version = VERSION;
Not Socks5 / / if
If ( (int) method_request->version = = VERSION)
{
Method_response->select_method = 0xff;
Send (sock, method_response, s i zeof (METHOD_SELECT_RESPONSE) ,
0) ;
Close (sock) ;
Return -1;
每每进入第四季度,我们就可以看到各大云服务商的促销力度是一年中最大的。一来是年底的促销节日活动比较多,二来是商家希望最后一个季度冲刺业绩。这不还没有到第四季度,我们看到有些商家已经蠢蠢欲动的开始筹备活动。比如素有低价VPS收割机之称的Virmach商家居然还没有到黑色星期五就有发布黑五促销活动。Virmach 商家有十多个数据中心,价格是便宜的,但是机器稳定性和速度肯定我们也是有数的,要不这么低的...
我们在去年12月分享过Hosteons新上AMD Ryzen9 3900X CPU及DDR4内存、NVMe硬盘的高性能VPS产品的消息,目前商家再次发布了产品更新信息,暂停新开100M带宽KVM套餐,新订单转而升级为新的Budget KVM VPS(SSD)系列,带宽为1Gbps端口,且配置大幅升级,目前100M带宽仅保留OpenVZ架构产品可新订购,所有原有主机不变,用户一直续费一直可用。Bud...
vollcloud怎么样?vollcloud LLC创立于2020年,是一家以互联网基础业务服务为主的 技术型企业,运营全球数据中心业务。VoLLcloud LLC针对新老用户推出全场年付产品7折促销优惠,共30个,机会难得,所有产品支持3日内无条件退款,同时提供产品免费体验。目前所有产品中,“镇店之宝”产品性价比高,适用大部分用户基础应用,卖的也是最好,同时,在这里感谢新老用户的支持和信任,我们...