From 5db276eb52db0f77b0c0aa50ecd6948164cdc4f1 Mon Sep 17 00:00:00 2001 From: Adrian Antkowiak Date: Sun, 11 Jul 2021 01:06:51 +0200 Subject: [PATCH] #3147: HAProxyMessage.sourceAddress() can be null .sourceAddress() is null when send-proxy-v2 & check option is used --- .../java/net/md_5/bungee/netty/HandlerBoss.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java index 270545f2..f8d6becd 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java @@ -83,14 +83,17 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter HAProxyMessage proxy = (HAProxyMessage) msg; try { - InetSocketAddress newAddress = new InetSocketAddress( proxy.sourceAddress(), proxy.sourcePort() ); - - ProxyServer.getInstance().getLogger().log( Level.FINE, "Set remote address via PROXY {0} -> {1}", new Object[] + if ( proxy.sourceAddress() != null ) { - channel.getRemoteAddress(), newAddress - } ); + InetSocketAddress newAddress = new InetSocketAddress( proxy.sourceAddress(), proxy.sourcePort() ); - channel.setRemoteAddress( newAddress ); + ProxyServer.getInstance().getLogger().log( Level.FINE, "Set remote address via PROXY {0} -> {1}", new Object[] + { + channel.getRemoteAddress(), newAddress + } ); + + channel.setRemoteAddress( newAddress ); + } } finally { proxy.release();