Make SocksServer example compatible with curl --socks5-hostname

Motivation:

Socks5 proxy supports resolve domain at the server side. When testing
with curl, the SocksServer in example package only works for proxy
request with IP, not with domain name (`--socks5` vs
`--socks5-hostname`). As curl is widely used, it should work with
the example provided.

Modifications:

Passing address and port to the Socks5CommandResponse, so that it
works for curl.

Result:

`curl --socks5-hostname` works as expected.
This commit is contained in:
tsu 2016-08-13 19:58:28 +08:00 committed by Norman Maurer
parent 00deb2efd5
commit 3a4d30df4e

View File

@ -102,7 +102,10 @@ public final class SocksServerConnectHandler extends SimpleChannelInboundHandler
if (future.isSuccess()) {
ChannelFuture responseFuture =
ctx.channel().writeAndFlush(new DefaultSocks5CommandResponse(
Socks5CommandStatus.SUCCESS, request.dstAddrType()));
Socks5CommandStatus.SUCCESS,
request.dstAddrType(),
request.dstAddr(),
request.dstPort()));
responseFuture.addListener(new ChannelFutureListener() {
@Override