org.littleshoot.proxy.ChainedProxyAdapter Java Examples
The following examples show how to use
org.littleshoot.proxy.ChainedProxyAdapter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProxyToServerConnection.java From g4proxy with Apache License 2.0 | 5 votes |
/** * Set up our connection parameters based on server address and chained * proxies. * * @throws UnknownHostException when unable to resolve the hostname to an IP address */ private void setupConnectionParameters() throws UnknownHostException { if (chainedProxy != null && chainedProxy != ChainedProxyAdapter.FALLBACK_TO_DIRECT_CONNECTION) { this.transportProtocol = chainedProxy.getTransportProtocol(); this.remoteAddress = chainedProxy.getChainedProxyAddress(); this.localAddress = chainedProxy.getLocalAddress(); } else { this.transportProtocol = TransportProtocol.TCP; // Report DNS resolution to HttpFilters this.remoteAddress = this.currentFilters.proxyToServerResolutionStarted(serverHostAndPort); // save the hostname and port of the unresolved address in hostAndPort, in case name resolution fails String hostAndPort = null; try { if (this.remoteAddress == null) { hostAndPort = serverHostAndPort; this.remoteAddress = addressFor(serverHostAndPort, proxyServer); } else if (this.remoteAddress.isUnresolved()) { // filter returned an unresolved address, so resolve it using the proxy server's resolver hostAndPort = HostAndPort.fromParts(this.remoteAddress.getHostName(), this.remoteAddress.getPort()).toString(); this.remoteAddress = proxyServer.getServerResolver().resolve(this.remoteAddress.getHostName(), this.remoteAddress.getPort()); } } catch (UnknownHostException e) { // unable to resolve the hostname to an IP address. notify the filters of the failure before allowing the // exception to bubble up. this.currentFilters.proxyToServerResolutionFailed(hostAndPort); throw e; } this.currentFilters.proxyToServerResolutionSucceeded(serverHostAndPort, this.remoteAddress); this.localAddress = proxyServer.getLocalAddress(); } }
Example #2
Source File: ProxyToServerConnection.java From yfs with Apache License 2.0 | 5 votes |
/** * Set up our connection parameters based on server address and chained * proxies. * * @throws UnknownHostException when unable to resolve the hostname to an IP address */ private void setupConnectionParameters() throws UnknownHostException { if (chainedProxy != null && chainedProxy != ChainedProxyAdapter.FALLBACK_TO_DIRECT_CONNECTION) { this.transportProtocol = chainedProxy.getTransportProtocol(); this.remoteAddress = chainedProxy.getChainedProxyAddress(); this.localAddress = chainedProxy.getLocalAddress(); } else { this.transportProtocol = TransportProtocol.TCP; // Report DNS resolution to HttpFilters this.remoteAddress = this.currentFilters.proxyToServerResolutionStarted(serverHostAndPort); // save the hostname and port of the unresolved address in hostAndPort, in case name resolution fails String hostAndPort = null; try { if (this.remoteAddress == null) { hostAndPort = serverHostAndPort; this.remoteAddress = addressFor(serverHostAndPort, proxyServer); } else if (this.remoteAddress.isUnresolved()) { // filter returned an unresolved address, so resolve it using the proxy server's resolver hostAndPort = HostAndPort.fromParts(this.remoteAddress.getHostName(), this.remoteAddress.getPort()).toString(); this.remoteAddress = proxyServer.getServerResolver().resolve(this.remoteAddress.getHostName(), this.remoteAddress.getPort()); } } catch (UnknownHostException e) { // unable to resolve the hostname to an IP address. notify the filters of the failure before allowing the // exception to bubble up. this.currentFilters.proxyToServerResolutionFailed(hostAndPort); throw e; } this.currentFilters.proxyToServerResolutionSucceeded(serverHostAndPort, this.remoteAddress); this.localAddress = proxyServer.getLocalAddress(); } }
Example #3
Source File: ProxyToServerConnection.java From PowerTunnel with MIT License | 4 votes |
/** * Set up our connection parameters based on server address and chained * proxies. * * @throws UnknownHostException when unable to resolve the hostname to an IP address */ private void setupConnectionParameters() throws UnknownHostException { if (chainedProxy != null && chainedProxy != ChainedProxyAdapter.FALLBACK_TO_DIRECT_CONNECTION) { this.transportProtocol = chainedProxy.getTransportProtocol(); this.chainedProxyType = chainedProxy.getChainedProxyType(); this.localAddress = chainedProxy.getLocalAddress(); this.remoteAddress = chainedProxy.getChainedProxyAddress(); this.remoteAddressResolver = DefaultAddressResolverGroup.INSTANCE; this.username = chainedProxy.getUsername(); this.password = chainedProxy.getPassword(); } else { this.transportProtocol = TransportProtocol.TCP; this.chainedProxyType = ChainedProxyType.HTTP; this.username = null; this.password = null; // Report DNS resolution to HttpFilters this.remoteAddress = this.currentFilters.proxyToServerResolutionStarted(serverHostAndPort); // save the hostname and port of the unresolved address in hostAndPort, in case name resolution fails String hostAndPort = null; try { if (this.remoteAddress == null) { hostAndPort = serverHostAndPort; this.remoteAddress = addressFor(serverHostAndPort, proxyServer); } else if (this.remoteAddress.isUnresolved()) { // filter returned an unresolved address, so resolve it using the proxy server's resolver hostAndPort = HostAndPort.fromParts(this.remoteAddress.getHostName(), this.remoteAddress.getPort()).toString(); this.remoteAddress = proxyServer.getServerResolver().resolve(this.remoteAddress.getHostName(), this.remoteAddress.getPort()); } } catch (UnknownHostException e) { // unable to resolve the hostname to an IP address. notify the filters of the failure before allowing the // exception to bubble up. this.currentFilters.proxyToServerResolutionFailed(hostAndPort); throw e; } this.currentFilters.proxyToServerResolutionSucceeded(serverHostAndPort, this.remoteAddress); this.localAddress = proxyServer.getLocalAddress(); } }