Skip to content

Commit 330f2d5

Browse files
committed
nit
1 parent 050471d commit 330f2d5

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

client/src/main/java/org/asynchttpclient/netty/channel/ChannelManager.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import io.netty.handler.codec.http.websocketx.extensions.compression.WebSocketClientCompressionHandler;
2929
import io.netty.handler.logging.LogLevel;
3030
import io.netty.handler.logging.LoggingHandler;
31+
import io.netty.handler.proxy.ProxyHandler;
3132
import io.netty.handler.proxy.Socks4ProxyHandler;
3233
import io.netty.handler.proxy.Socks5ProxyHandler;
3334
import io.netty.handler.ssl.SslHandler;
@@ -380,9 +381,9 @@ public SslHandler addSslHandler(ChannelPipeline pipeline, Uri uri, String virtua
380381

381382
SslHandler sslHandler = createSslHandler(peerHost, peerPort);
382383
if (hasSocksProxyHandler)
383-
pipeline.addAfter(ChannelManager.SOCKS_HANDLER, ChannelManager.SSL_HANDLER, sslHandler);
384+
pipeline.addAfter(SOCKS_HANDLER, SSL_HANDLER, sslHandler);
384385
else
385-
pipeline.addFirst(ChannelManager.SSL_HANDLER, sslHandler);
386+
pipeline.addFirst(SSL_HANDLER, sslHandler);
386387
return sslHandler;
387388
}
388389

@@ -409,18 +410,20 @@ public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
409410
@Override
410411
protected void initChannel(Channel channel) throws Exception {
411412
InetSocketAddress proxyAddress = new InetSocketAddress(whenProxyAddress.get(), proxy.getPort());
413+
ProxyHandler socksProxyHandler;
412414
switch (proxy.getProxyType()) {
413415
case SOCKS_V4:
414-
channel.pipeline().addFirst(SOCKS_HANDLER, new Socks4ProxyHandler(proxyAddress));
416+
socksProxyHandler = new Socks4ProxyHandler(proxyAddress);
415417
break;
416418

417419
case SOCKS_V5:
418-
channel.pipeline().addFirst(SOCKS_HANDLER, new Socks5ProxyHandler(proxyAddress));
420+
socksProxyHandler = new Socks5ProxyHandler(proxyAddress);
419421
break;
420422

421423
default:
422424
throw new IllegalArgumentException("Only SOCKS4 and SOCKS5 supported at the moment.");
423425
}
426+
channel.pipeline().addFirst(SOCKS_HANDLER, socksProxyHandler);
424427
}
425428
});
426429
promise.setSuccess(socksBootstrap);

0 commit comments

Comments
 (0)