[FIX] Исправление порядка NettyIpForwardHandler

This commit is contained in:
Gravit 2019-05-09 21:16:55 +07:00
parent 77566cbd30
commit 09cae122d1
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
2 changed files with 4 additions and 3 deletions

View file

@ -44,10 +44,10 @@ public void initChannel(NioSocketChannel ch) {
//p.addLast(new LoggingHandler(LogLevel.INFO));
pipeline.addLast(new HttpServerCodec());
pipeline.addLast(new HttpObjectAggregator(65536));
if (LaunchServer.server.config.netty.ipForwarding) pipeline.addLast(new NettyIpForwardHandler(context));
pipeline.addLast(new WebSocketServerCompressionHandler());
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.ipForwarding) pipeline.addLast(new NettyIpForwardHandler(context));
pipeline.addLast(new WebSocketFrameHandler(context));
}
});

View file

@ -5,6 +5,7 @@
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.codec.http.DefaultHttpRequest;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpRequest;
import ru.gravit.utils.helper.LogHelper;
public class NettyIpForwardHandler extends ChannelInboundHandlerAdapter {
@ -19,9 +20,9 @@ public NettyIpForwardHandler(NettyConnectContext context) {
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
//super.channelRead(ctx, msg);
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();
String realIP = null;
if(headers.contains("X-Forwarded-For"))