为什么socks5协议的server reply可以使用dummy values?
Why server reply of socks5 protocol can use dummy values?
我对socks5协议的握手过程一头雾水。根据RFC1928第5页:
In the reply to a CONNECT, BND.PORT contains the port number that the
server assigned to connect to the target host, while BND.ADDR
contains the associated IP address. The supplied BND.ADDR is often
different from the IP address that the client uses to reach the SOCKS
server, since such servers are often multi-homed. It is expected
that the SOCKS server will use DST.ADDR and DST.PORT, and the
client-side source address and port in evaluating the CONNECT
request.
看来BND.ADDR
和BND.PORT
是多余的,没用的。并且根据文章How Socks 5 Works:
- IPv4 Address: 00 00 00 00 (I don't know why this is zeroes, but since the proxy will do the DNS resolution and fetch the page, there is no real need for the local host to know the IP address of the destination machine at all, so this is apparently just dummy data.)
- Port number: 00 00 (Apparently also a dummy value)
和the implementation of shadowsocks:
self._write_to_sock((b'\x05\x00\x00\x01'
b'\x00\x00\x00\x00\x10\x10'),
self._local_sock)
好像都提示socks5服务器回复中的BND.ADDR
和BND.PORT
不重要
那么,为什么存在BND.ADDR
和BND.PORT
这两个冗余字段?
据我了解涉及的对象有4个:
- SOCKS5 客户端
- SOCKS5 服务器
- 中继服务器
- 目标服务器
SOCKS5协议只涉及SOCKS5客户端和SOCKS5服务器。真正的代理过程发生在 SOCKS5 客户端、中继服务器和目标服务器之间。
# SOCKS5 protocol
SOCKS5 client <--> SOCKS5 server
# proxy process
SOCKS5 client <--> relay server <--> target server
BND.ADDR
和BND.PORT
用来告诉SOCKS5客户端中继服务器在哪里。但在大多数情况下,SOCKS5 服务器是中继服务器(即负责代理),因此返回 BND.ADDR
全零将告诉 SOCKS5 客户端连接到作为中继服务器的 SOCKS5 服务器。
我对socks5协议的握手过程一头雾水。根据RFC1928第5页:
In the reply to a CONNECT, BND.PORT contains the port number that the server assigned to connect to the target host, while BND.ADDR contains the associated IP address. The supplied BND.ADDR is often different from the IP address that the client uses to reach the SOCKS server, since such servers are often multi-homed. It is expected that the SOCKS server will use DST.ADDR and DST.PORT, and the client-side source address and port in evaluating the CONNECT request.
看来BND.ADDR
和BND.PORT
是多余的,没用的。并且根据文章How Socks 5 Works:
- IPv4 Address: 00 00 00 00 (I don't know why this is zeroes, but since the proxy will do the DNS resolution and fetch the page, there is no real need for the local host to know the IP address of the destination machine at all, so this is apparently just dummy data.)
- Port number: 00 00 (Apparently also a dummy value)
和the implementation of shadowsocks:
self._write_to_sock((b'\x05\x00\x00\x01' b'\x00\x00\x00\x00\x10\x10'), self._local_sock)
好像都提示socks5服务器回复中的BND.ADDR
和BND.PORT
不重要
那么,为什么存在BND.ADDR
和BND.PORT
这两个冗余字段?
据我了解涉及的对象有4个:
- SOCKS5 客户端
- SOCKS5 服务器
- 中继服务器
- 目标服务器
SOCKS5协议只涉及SOCKS5客户端和SOCKS5服务器。真正的代理过程发生在 SOCKS5 客户端、中继服务器和目标服务器之间。
# SOCKS5 protocol
SOCKS5 client <--> SOCKS5 server
# proxy process
SOCKS5 client <--> relay server <--> target server
BND.ADDR
和BND.PORT
用来告诉SOCKS5客户端中继服务器在哪里。但在大多数情况下,SOCKS5 服务器是中继服务器(即负责代理),因此返回 BND.ADDR
全零将告诉 SOCKS5 客户端连接到作为中继服务器的 SOCKS5 服务器。