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