SOCKS5 Agent Service

Source: Internet
Author: User
Tags bind requires rfc ftp protocol

Vacation time to SOCKS5 agent of the RfC all read, some experience dare not to enjoy, here write to everyone together comment comments, if there are errors please put forward.

The following assumes the use of TCP connection methods. First you need to establish a connection with the proxy server, there is no complicated, simple connect (ServerIP, ServerPort) on it. After a successful connection, you need to send a command word using Send () to determine if validation is required, and the following is the command Word format in the RfC:

Project Version Number of ways Connection mode ...
Project length 1 1 1-255 ...

First, the "version" is fixed to X "socks version 5", the number of ways tells the server how to submit a few connection method requests, as for the connection method can have more than one. The following is a list of ways:

Connection mode Meaning
X ' 00 ' No verification, direct continuation
X ' 01 ' GSSAPI
X ' 02 ' User name/password required
X ' to X ' 7F ' IANA assigned
X ' to X ' FE ' Keep the way, you can choose their own flexibility
X ' FF ' Does not contain the way that meets the requirements

Next comes the server's response:

Project Version Allowed connection mode
Project length 1 1

The version does not have to say, still fixed is X "05", The allowed connection is in the many connections you submit, by the server to choose an acceptable, and then return, if not, then the return is X "FF." One of the most common uses is the X "00" and the X "02". The difference between them is that the X "02" method requires sending a username/password, and the process of verifying the pass is no different from the X "00" approach.

After the client recognizes that the server returns X "02", the following format validation string is sent:

Project VER User name length User name Password length Password
Project length 1 1 1-255 1 1-255

Note: The ver here is different from the top, and the fixed is X "01". The maximum username/password length is 255.

Return results after server-side validation:

Project VER Validation results
Project length 1 1

The result of the verification is X "00", it means that the validation is passed, otherwise it is ...

The next procedure is to send the request command word:

Project Version Command word Keep Address Type Address Port
Project length 1 1 X "00" 1 Not fixed 2

Version fixed X "05", the command word is divided into three kinds: CONNECT x "", BIND X "", UDP X "03". Connect is a common TCP connection; bind requires your client to support accepting server connection requests (FTP protocol is a typical example); UDP is a special case, I haven't fully understood ... The retention item is fixed to X "00".

There are three kinds of address types: X "01", X "03", X "04", respectively corresponding to IP-V4, DomainName, IP-V6, and the next address length varies depending on the address type. The length of the IP-V4 is 4 bits, the length of the domainname varies according to the actual situation, but the first bit of the address is set to the length of the domain name string, and the IP-V6 is 16 bits.

The port length is fixed two bits, there is nothing to say.

And the server returns a similar format for the content

Project Version return value Keep Address Type Address (BND) Port
Project length 1 1 X "00" 1 Not fixed 2

The return value may be one of the following values:

"
join way meaning
x '
Destination network unreachable
x ' x ' modified ' address format does not support
x ' to X ' F F ' "> reserved

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.