|
|
|
@ -64,16 +64,13 @@ public class ProxyServerContainer implements Container, ConfigChangedListener { |
|
|
|
|
@Override |
|
|
|
|
public void start() { |
|
|
|
|
ServerBootstrap bootstrap = new ServerBootstrap(); |
|
|
|
|
bootstrap.group(serverBossGroup, serverWorkerGroup).channel(NioServerSocketChannel.class) |
|
|
|
|
.childHandler(new ChannelInitializer<SocketChannel>() { |
|
|
|
|
bootstrap.group(serverBossGroup, serverWorkerGroup).channel(NioServerSocketChannel.class).childHandler(new ChannelInitializer<SocketChannel>() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void initChannel(SocketChannel ch) throws Exception { |
|
|
|
|
ch.pipeline().addLast(new ProxyMessageDecoder(MAX_FRAME_LENGTH, LENGTH_FIELD_OFFSET, |
|
|
|
|
LENGTH_FIELD_LENGTH, LENGTH_ADJUSTMENT, INITIAL_BYTES_TO_STRIP)); |
|
|
|
|
ch.pipeline().addLast(new ProxyMessageDecoder(MAX_FRAME_LENGTH, LENGTH_FIELD_OFFSET, LENGTH_FIELD_LENGTH, LENGTH_ADJUSTMENT, INITIAL_BYTES_TO_STRIP)); |
|
|
|
|
ch.pipeline().addLast(new ProxyMessageEncoder()); |
|
|
|
|
ch.pipeline().addLast(new IdleCheckHandler(IdleCheckHandler.READ_IDLE_TIME, |
|
|
|
|
IdleCheckHandler.WRITE_IDLE_TIME, 0)); |
|
|
|
|
ch.pipeline().addLast(new IdleCheckHandler(IdleCheckHandler.READ_IDLE_TIME, IdleCheckHandler.WRITE_IDLE_TIME, 0)); |
|
|
|
|
ch.pipeline().addLast(new ServerChannelHandler()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -97,20 +94,16 @@ public class ProxyServerContainer implements Container, ConfigChangedListener { |
|
|
|
|
|
|
|
|
|
private void initializeSSLTCPTransport(String host, int port, final SSLContext sslContext) { |
|
|
|
|
ServerBootstrap b = new ServerBootstrap(); |
|
|
|
|
b.group(serverBossGroup, serverWorkerGroup).channel(NioServerSocketChannel.class) |
|
|
|
|
.childHandler(new ChannelInitializer<SocketChannel>() { |
|
|
|
|
b.group(serverBossGroup, serverWorkerGroup).channel(NioServerSocketChannel.class).childHandler(new ChannelInitializer<SocketChannel>() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void initChannel(SocketChannel ch) throws Exception { |
|
|
|
|
ChannelPipeline pipeline = ch.pipeline(); |
|
|
|
|
try { |
|
|
|
|
pipeline.addLast("ssl", createSslHandler(sslContext, |
|
|
|
|
Config.getInstance().getBooleanValue("server.ssl.needsClientAuth", false))); |
|
|
|
|
ch.pipeline().addLast(new ProxyMessageDecoder(MAX_FRAME_LENGTH, LENGTH_FIELD_OFFSET, |
|
|
|
|
LENGTH_FIELD_LENGTH, LENGTH_ADJUSTMENT, INITIAL_BYTES_TO_STRIP)); |
|
|
|
|
pipeline.addLast("ssl", createSslHandler(sslContext, Config.getInstance().getBooleanValue("server.ssl.needsClientAuth", false))); |
|
|
|
|
ch.pipeline().addLast(new ProxyMessageDecoder(MAX_FRAME_LENGTH, LENGTH_FIELD_OFFSET, LENGTH_FIELD_LENGTH, LENGTH_ADJUSTMENT, INITIAL_BYTES_TO_STRIP)); |
|
|
|
|
ch.pipeline().addLast(new ProxyMessageEncoder()); |
|
|
|
|
ch.pipeline().addLast(new IdleCheckHandler(IdleCheckHandler.READ_IDLE_TIME, |
|
|
|
|
IdleCheckHandler.WRITE_IDLE_TIME, 0)); |
|
|
|
|
ch.pipeline().addLast(new IdleCheckHandler(IdleCheckHandler.READ_IDLE_TIME, IdleCheckHandler.WRITE_IDLE_TIME, 0)); |
|
|
|
|
ch.pipeline().addLast(new ServerChannelHandler()); |
|
|
|
|
} catch (Throwable th) { |
|
|
|
|
logger.error("Severe error during pipeline creation", th); |
|
|
|
@ -131,12 +124,10 @@ public class ProxyServerContainer implements Container, ConfigChangedListener { |
|
|
|
|
|
|
|
|
|
private void startUserPort() { |
|
|
|
|
ServerBootstrap bootstrap = new ServerBootstrap(); |
|
|
|
|
bootstrap.group(serverBossGroup, serverWorkerGroup).channel(NioServerSocketChannel.class) |
|
|
|
|
.childHandler(new ChannelInitializer<SocketChannel>() { |
|
|
|
|
bootstrap.group(serverBossGroup, serverWorkerGroup).channel(NioServerSocketChannel.class).childHandler(new ChannelInitializer<SocketChannel>() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void initChannel(SocketChannel ch) throws Exception { |
|
|
|
|
ch.pipeline().addLast(new IdleCheckHandler(IdleCheckHandler.USER_CHANNEL_READ_IDLE_TIME, 0, 0)); |
|
|
|
|
ch.pipeline().addFirst(new BytesMetricsHandler()); |
|
|
|
|
ch.pipeline().addLast(new UserChannelHandler()); |
|
|
|
|
} |
|
|
|
|