Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
  • Loading branch information
slandelle committed Jan 29, 2018
1 parent 050471d commit 330f2d5
Showing 1 changed file with 7 additions and 4 deletions.
Expand Up @@ -28,6 +28,7 @@
import io.netty.handler.codec.http.websocketx.extensions.compression.WebSocketClientCompressionHandler;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.proxy.ProxyHandler;
import io.netty.handler.proxy.Socks4ProxyHandler;
import io.netty.handler.proxy.Socks5ProxyHandler;
import io.netty.handler.ssl.SslHandler;
Expand Down Expand Up @@ -380,9 +381,9 @@ public SslHandler addSslHandler(ChannelPipeline pipeline, Uri uri, String virtua

SslHandler sslHandler = createSslHandler(peerHost, peerPort);
if (hasSocksProxyHandler)
pipeline.addAfter(ChannelManager.SOCKS_HANDLER, ChannelManager.SSL_HANDLER, sslHandler);
pipeline.addAfter(SOCKS_HANDLER, SSL_HANDLER, sslHandler);
else
pipeline.addFirst(ChannelManager.SSL_HANDLER, sslHandler);
pipeline.addFirst(SSL_HANDLER, sslHandler);
return sslHandler;
}

Expand All @@ -409,18 +410,20 @@ public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
@Override
protected void initChannel(Channel channel) throws Exception {
InetSocketAddress proxyAddress = new InetSocketAddress(whenProxyAddress.get(), proxy.getPort());
ProxyHandler socksProxyHandler;
switch (proxy.getProxyType()) {
case SOCKS_V4:
channel.pipeline().addFirst(SOCKS_HANDLER, new Socks4ProxyHandler(proxyAddress));
socksProxyHandler = new Socks4ProxyHandler(proxyAddress);
break;

case SOCKS_V5:
channel.pipeline().addFirst(SOCKS_HANDLER, new Socks5ProxyHandler(proxyAddress));
socksProxyHandler = new Socks5ProxyHandler(proxyAddress);
break;

default:
throw new IllegalArgumentException("Only SOCKS4 and SOCKS5 supported at the moment.");
}
channel.pipeline().addFirst(SOCKS_HANDLER, socksProxyHandler);
}
});
promise.setSuccess(socksBootstrap);
Expand Down

0 comments on commit 330f2d5

Please sign in to comment.