了解 Socks5 协议
我是socks5的新手,但我正在尝试通过创建socks5服务器来学习。
我通过阅读 RFC 1928 获得了大量有关 SocksV5 的信息。
它解释了必须发送到客户端和服务器的数据包,以便建立到服务器的连接、请求远程连接和绑定。它还解释了如何使用很棒的 UDP。
我不明白的是建立连接后会发生什么。
例如,
Client: <sends method identifiers>
Server: <responds with the method identifier to use>
...authentication is complete....
Client: Sends a connection request to 192.168.1.1:2321
Server: Acknowledges Packet
Server: Acknowledges successful connection to 192.168.1.1:2321
Client: ????
从客户端发送到服务器以实际将数据转发到目的地的数据包的格式是什么?
假设客户端要求代理服务器建立 3 个连接。当客户端想要将数据转发到连接 1 时,必须有一个协议来执行此操作。否则,服务器如何知道将其发送到哪个连接?我在 RFC 文档中找不到任何信息。
我想另一个问题是,这可能吗?客户端是否可以请求多个连接,还是必须一次建立一个连接,或者为要转发的每个连接建立一个到服务器的单独套接字连接?
感谢您的帮助!
I'm a total newbie with socks5, but I'm trying learn by creating a socks5 server.
I've gotten a great deal of information about SocksV5 from reading RFC 1928.
It explains the packets which must be sent to the client and server in order to establish a connection to the server, request remote connections, and binding. It also explains how to use UDP which is great.
What I don't understand is what happens after the connection has been established.
For example,
Client: <sends method identifiers>
Server: <responds with the method identifier to use>
...authentication is complete....
Client: Sends a connection request to 192.168.1.1:2321
Server: Acknowledges Packet
Server: Acknowledges successful connection to 192.168.1.1:2321
Client: ????
What is the format of the packet that is sent from the client to the server to actually forward data to the destination?
Lets say the client asks the proxy server to establish 3 connections. When the client wants to forward data to connection 1, there must be a protocol for doing so. Otherwise, how will the server know which connection to send it to? I can't find any information in the RFC documents.
I guess the other question is, is this possible? Can the client request multiple connections or must it do them one at a time or establish a separate socket connection to the server for each connection it wants forwarded out?
Thanks for the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
再次仔细阅读 RFC,它确实告诉您您的要求。
客户端必须为要与之交换数据的每个目标服务器与 SOCKS 代理建立单独的 TCP 连接,无论该数据是 TCP 还是 UDP。
如果客户端正在与目标服务器交换 TCP 数据,则在代理发送成功回复后,它只需通过与代理建立的同一连接读取/发送所需的任何 TCP 数据。
如果客户端与目标服务器交换 UDP 数据,则与代理的 TCP 连接用于建立关联的 UDP 中继,然后代理使用该中继来回转发 UDP 数据。客户端使用 TCP 连接告诉代理将入站 UDP 数据包发送到何处,代理的成功回复告诉客户端将出站 UDP 数据包发送到何处。只要客户端和代理之间的 TCP 连接处于活动状态,UDP 中继就会处于活动状态。
无论哪种方式,一旦建立了必要的参数,代理就会透明地处理客户端和目标服务器之间的所有转发。
Read the RFC again more carefully, it does tell you what you are asking for.
The client must establish a separate TCP connection with the SOCKS proxy for each target server it wants to exchange data with, whether that data is TCP or UDP.
If the client is exchanging TCP data with the target server, it simply reads/sends whatever TCP data it wants over the same connection it has established with the proxy, after the proxy has sent its success reply.
If the client is exchanging UDP data with the target server, the TCP connection with the proxy is used to establish an associated UDP relay that the proxy then uses to forward UDP data back and forth. The client uses the TCP connection to tell the proxy where to send inbound UDP packets to, and the proxy's success reply tells the client where to send outbound UDP packets to. The UDP relay is active as long as the TCP connection between the client and proxy is active.
Either way, the proxy handles all forwarding between the client and target server transparently once the necessary parameters have been established.