@Override public ProxyProvider build() { return new ProxyProvider(this); } }
@Override public String toString() { return "ProxyProvider{" + asDetailedString() + "}"; }
MonoHttpConnect(Bootstrap bootstrap, HttpClientConfiguration configuration, TcpClient tcpClient, @Nullable SslProvider sslProvider) { this.bootstrap = bootstrap; this.configuration = configuration; this.sslProvider = sslProvider; this.tcpClient = tcpClient; this.proxyProvider = ProxyProvider.findProxySupport(bootstrap); }
@Override public int hashCode() { return Objects.hash(username, getPasswordValue(), getAddress().get(), getNonProxyHosts(), getType()); }
@Override public int hashCode() { return Objects.hash(username, password, getAddress(), getNonProxyHosts(), getType()); }
TcpClientProxy(TcpClient client, Consumer<? super ProxyProvider.TypeSpec> proxyOptions) { super(client); Objects.requireNonNull(proxyOptions, "proxyOptions"); ProxyProvider.Build builder = (ProxyProvider.Build) ProxyProvider.builder(); proxyOptions.accept(builder); this.proxyProvider = builder.build(); }
@Override public void accept(ConnectionObserver connectionObserver, Channel channel) { if (proxyProvider.shouldProxy(bootstrap.config() .remoteAddress())) { ChannelPipeline pipeline = channel.pipeline(); pipeline.addFirst(NettyPipeline.ProxyHandler, proxyProvider.newProxyHandler()); if (TcpUtils.log.isDebugEnabled()) { pipeline.addFirst(new LoggingHandler("reactor.netty.proxy")); } } } }
/** * Should proxy the given address * * @param address the address to test * * @return true if of type {@link InetSocketAddress} and hostname candidate to proxy */ public boolean shouldProxy(SocketAddress address) { SocketAddress addr = address; if (address instanceof TcpUtils.SocketAddressSupplier) { addr = ((TcpUtils.SocketAddressSupplier) address).get(); } return addr instanceof InetSocketAddress && shouldProxy(((InetSocketAddress) addr).getHostString()); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ProxyProvider that = (ProxyProvider) o; return Objects.equals(username, that.username) && Objects.equals(getPasswordValue(), that.getPasswordValue()) && Objects.equals(getAddress().get(), that.getAddress().get()) && Objects.equals(getNonProxyHosts(), that.getNonProxyHosts()) && getType() == that.getType(); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ProxyProvider that = (ProxyProvider) o; return Objects.equals(username, that.username) && Objects.equals(password, that.password) && Objects.equals(getAddress(), that.getAddress()) && Objects.equals(getNonProxyHosts(), that.getNonProxyHosts()) && getType() == that.getType(); }
TcpClientProxy(TcpClient client, Consumer<? super ProxyProvider.TypeSpec> proxyOptions) { super(client); Objects.requireNonNull(proxyOptions, "proxyOptions"); ProxyProvider.Build builder = (ProxyProvider.Build) ProxyProvider.builder(); proxyOptions.accept(builder); this.proxyProvider = builder.build(); }
@Override public void accept(ConnectionObserver connectionObserver, Channel channel) { if (proxyProvider.shouldProxy(bootstrap.config() .remoteAddress())) { ChannelPipeline pipeline = channel.pipeline(); pipeline.addFirst(NettyPipeline.ProxyHandler, proxyProvider.newProxyHandler()); if (TcpUtils.log.isDebugEnabled()) { pipeline.addFirst(new LoggingHandler("reactor.netty.proxy")); } } } }
/** * Should proxy the given address * * @param address the address to test * * @return true if of type {@link InetSocketAddress} and hostname candidate to proxy */ public boolean shouldProxy(SocketAddress address) { SocketAddress addr = address; if (address instanceof TcpUtils.SocketAddressSupplier) { addr = ((TcpUtils.SocketAddressSupplier) address).get(); } return addr instanceof InetSocketAddress && shouldProxy(((InetSocketAddress) addr).getHostString()); }
private ProxyProvider createNoAuthProxy(InetSocketAddress address) { return ProxyProvider .builder() .type(ProxyProvider.Proxy.SOCKS5) .address(address) .build(); } }
@Override public SocketAddress get() { SocketAddress address = activeURI.getRemoteAddress(); if (proxyProvider != null && !proxyProvider.shouldProxy(address) && address instanceof InetSocketAddress) { address = InetSocketAddressUtil.replaceWithResolved((InetSocketAddress) address); } return address; }
@Override public ProxyProvider build() { return new ProxyProvider(this); } }
MonoHttpConnect(Bootstrap bootstrap, HttpClientConfiguration configuration, TcpClient tcpClient, @Nullable SslProvider sslProvider) { this.bootstrap = bootstrap; this.configuration = configuration; this.sslProvider = sslProvider; this.tcpClient = tcpClient; this.proxyProvider = ProxyProvider.findProxySupport(bootstrap); }
@Override public String toString() { return "ProxyProvider{" + asDetailedString() + "}"; }
private ProxyProvider createProxy(InetSocketAddress address, Function<String, String> passwordFunc) { return ProxyProvider .builder() .type(ProxyProvider.Proxy.SOCKS5) .address(address) .username("netty") .password(passwordFunc) .build(); }
@Override public SocketAddress get() { SocketAddress address = activeURI.getRemoteAddress(); if (proxyProvider != null && !proxyProvider.shouldProxy(address) && address instanceof InetSocketAddress) { address = InetSocketAddressUtil.replaceWithResolved((InetSocketAddress) address); } return address; }