diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/LauncherNettyServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/LauncherNettyServer.java index 3a0f6f0e..ae471ace 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/LauncherNettyServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/LauncherNettyServer.java @@ -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)); } }); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/NettyIpForwardHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/NettyIpForwardHandler.java index 3e907ddd..ab9cb594 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/NettyIpForwardHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/websocket/NettyIpForwardHandler.java @@ -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"))