mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +03:00
[FIX] Исправление порядка NettyIpForwardHandler
This commit is contained in:
parent
77566cbd30
commit
09cae122d1
2 changed files with 4 additions and 3 deletions
|
@ -44,10 +44,10 @@ public void initChannel(NioSocketChannel ch) {
|
||||||
//p.addLast(new LoggingHandler(LogLevel.INFO));
|
//p.addLast(new LoggingHandler(LogLevel.INFO));
|
||||||
pipeline.addLast(new HttpServerCodec());
|
pipeline.addLast(new HttpServerCodec());
|
||||||
pipeline.addLast(new HttpObjectAggregator(65536));
|
pipeline.addLast(new HttpObjectAggregator(65536));
|
||||||
|
if (LaunchServer.server.config.netty.ipForwarding) pipeline.addLast(new NettyIpForwardHandler(context));
|
||||||
pipeline.addLast(new WebSocketServerCompressionHandler());
|
pipeline.addLast(new WebSocketServerCompressionHandler());
|
||||||
pipeline.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, null, true));
|
pipeline.addLast(new WebSocketServerProtocolHandler(WEBSOCKET_PATH, null, true));
|
||||||
if (LaunchServer.server.config.netty.fileServerEnabled) pipeline.addLast(new FileServerHandler(LaunchServer.server.updatesDir, true));
|
if (LaunchServer.server.config.netty.fileServerEnabled) pipeline.addLast(new FileServerHandler(LaunchServer.server.updatesDir, true));
|
||||||
if (LaunchServer.server.config.netty.ipForwarding) pipeline.addLast(new NettyIpForwardHandler(context));
|
|
||||||
pipeline.addLast(new WebSocketFrameHandler(context));
|
pipeline.addLast(new WebSocketFrameHandler(context));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||||
import io.netty.handler.codec.http.DefaultHttpRequest;
|
import io.netty.handler.codec.http.DefaultHttpRequest;
|
||||||
import io.netty.handler.codec.http.HttpHeaders;
|
import io.netty.handler.codec.http.HttpHeaders;
|
||||||
|
import io.netty.handler.codec.http.HttpRequest;
|
||||||
import ru.gravit.utils.helper.LogHelper;
|
import ru.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
public class NettyIpForwardHandler extends ChannelInboundHandlerAdapter {
|
public class NettyIpForwardHandler extends ChannelInboundHandlerAdapter {
|
||||||
|
@ -19,9 +20,9 @@ public NettyIpForwardHandler(NettyConnectContext context) {
|
||||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||||
//super.channelRead(ctx, msg);
|
//super.channelRead(ctx, msg);
|
||||||
if(context.ip != null) return;
|
if(context.ip != null) return;
|
||||||
if(msg instanceof DefaultHttpRequest)
|
if(msg instanceof HttpRequest)
|
||||||
{
|
{
|
||||||
DefaultHttpRequest http = (DefaultHttpRequest) msg;
|
HttpRequest http = (HttpRequest) msg;
|
||||||
HttpHeaders headers = http.headers();
|
HttpHeaders headers = http.headers();
|
||||||
String realIP = null;
|
String realIP = null;
|
||||||
if(headers.contains("X-Forwarded-For"))
|
if(headers.contains("X-Forwarded-For"))
|
||||||
|
|
Loading…
Reference in a new issue