private void sendConnectCommand(ChannelHandlerContext ctx) throws Exception { InetSocketAddress raddr = destinationAddress(); Socks5AddressType addrType; String rhost; if (raddr.isUnresolved()) { addrType = Socks5AddressType.DOMAIN; rhost = raddr.getHostString(); } else { rhost = raddr.getAddress().getHostAddress(); if (NetUtil.isValidIpV4Address(rhost)) { addrType = Socks5AddressType.IPv4; } else if (NetUtil.isValidIpV6Address(rhost)) { addrType = Socks5AddressType.IPv6; } else { throw new ProxyConnectException( exceptionMessage("unknown address type: " + StringUtil.simpleClassName(rhost))); } } ctx.pipeline().replace(decoderName, decoderName, new Socks5CommandResponseDecoder()); sendToProxyServer(new DefaultSocks5CommandRequest(Socks5CommandType.CONNECT, addrType, rhost, raddr.getPort())); } }
@Override protected Future<?> execute() { InetSocketAddress destinationAddress = unresolvedAddressFor(serverHostAndPort); DefaultSocks5CommandRequest connectRequest = new DefaultSocks5CommandRequest( Socks5CommandType.CONNECT, Socks5AddressType.DOMAIN, destinationAddress.getHostString(), destinationAddress.getPort()); addFirstOrReplaceHandler(SOCKS_DECODER_NAME, new Socks5CommandResponseDecoder()); return writeToChannel(connectRequest); }
private void sendConnectCommand(ChannelHandlerContext ctx) throws Exception { InetSocketAddress raddr = destinationAddress(); Socks5AddressType addrType; String rhost; if (raddr.isUnresolved()) { addrType = Socks5AddressType.DOMAIN; rhost = raddr.getHostString(); } else { rhost = raddr.getAddress().getHostAddress(); if (NetUtil.isValidIpV4Address(rhost)) { addrType = Socks5AddressType.IPv4; } else if (NetUtil.isValidIpV6Address(rhost)) { addrType = Socks5AddressType.IPv6; } else { throw new ProxyConnectException( exceptionMessage("unknown address type: " + StringUtil.simpleClassName(rhost))); } } ctx.pipeline().replace(decoderName, decoderName, new Socks5CommandResponseDecoder()); sendToProxyServer(new DefaultSocks5CommandRequest(Socks5CommandType.CONNECT, addrType, rhost, raddr.getPort())); } }
private void sendConnectCommand(ChannelHandlerContext ctx) throws Exception { InetSocketAddress raddr = destinationAddress(); Socks5AddressType addrType; String rhost; if (raddr.isUnresolved()) { addrType = Socks5AddressType.DOMAIN; rhost = raddr.getHostString(); } else { rhost = raddr.getAddress().getHostAddress(); if (NetUtil.isValidIpV4Address(rhost)) { addrType = Socks5AddressType.IPv4; } else if (NetUtil.isValidIpV6Address(rhost)) { addrType = Socks5AddressType.IPv6; } else { throw new ProxyConnectException( exceptionMessage("unknown address type: " + StringUtil.simpleClassName(rhost))); } } ctx.pipeline().replace(decoderName, decoderName, new Socks5CommandResponseDecoder()); sendToProxyServer(new DefaultSocks5CommandRequest(Socks5CommandType.CONNECT, addrType, rhost, raddr.getPort())); } }