private ChannelFuture connect(Request request, Uri uri, ProxyServer proxy, boolean useProxy, Bootstrap bootstrap, AsyncHandler<?> asyncHandler) throws UnknownHostException { InetSocketAddress remoteAddress = remoteAddress(request, uri, proxy, useProxy); if (asyncHandler instanceof AsyncHandlerExtensions) AsyncHandlerExtensions.class.cast(asyncHandler).onDnsResolved(remoteAddress.getAddress()); if (request.getLocalAddress() != null) return bootstrap.connect(remoteAddress, new InetSocketAddress(request.getLocalAddress(), 0)); else return bootstrap.connect(remoteAddress); }
private ChannelFuture connect(Request request, Uri uri, ProxyServer proxy, boolean useProxy, ClientBootstrap bootstrap, AsyncHandler<?> asyncHandler) throws UnknownHostException { InetSocketAddress remoteAddress = remoteAddress(request, uri, proxy, useProxy); if (asyncHandler instanceof AsyncHandlerExtensions) AsyncHandlerExtensions.class.cast(asyncHandler).onDnsResolved(remoteAddress.getAddress()); if (request.getLocalAddress() != null) return bootstrap.connect(remoteAddress, new InetSocketAddress(request.getLocalAddress(), 0)); else return bootstrap.connect(remoteAddress); }
public ChannelConnector(Request request, ProxyServer proxy, boolean useProxy, AsyncHandler<?> asyncHandler) throws UnknownHostException { this.asyncHandlerExtensions = asyncHandler instanceof AsyncHandlerExtensions ? (AsyncHandlerExtensions) asyncHandler : null; NameResolution[] resolutions; Uri uri = request.getUri(); int port = uri.getExplicitPort(); if (request.getInetAddress() != null) { resolutions = new NameResolution[] { new NameResolution(request.getInetAddress()) }; } else if (!useProxy || ignoreProxy(proxy, uri.getHost())) { resolutions = request.getNameResolver().resolve(uri.getHost()); } else { resolutions = request.getNameResolver().resolve(proxy.getHost()); port = uri.isSecured() ? proxy.getSecuredPort(): proxy.getPort(); } if (asyncHandlerExtensions != null) asyncHandlerExtensions.onDnsResolved(resolutions); remoteAddresses = new InetSocketAddress[resolutions.length]; for (int i = 0; i < resolutions.length; i ++) { remoteAddresses[i] = new InetSocketAddress(resolutions[i].address, port); } if (request.getLocalAddress() != null) { localAddress = new InetSocketAddress(request.getLocalAddress(), 0); } else { localAddress = null; } }