Remove ipv6 scope from forwarded addresses
Affects forwarding when epoll enabled
This commit is contained in:
@@ -51,6 +51,7 @@ import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
||||
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
||||
import net.md_5.bungee.protocol.packet.SetCompression;
|
||||
import net.md_5.bungee.protocol.packet.ViewDistance;
|
||||
import net.md_5.bungee.util.AddressUtil;
|
||||
import net.md_5.bungee.util.BufUtil;
|
||||
import net.md_5.bungee.util.QuietException;
|
||||
|
||||
@@ -102,7 +103,7 @@ public class ServerConnector extends PacketHandler
|
||||
|
||||
if ( BungeeCord.getInstance().config.isIpForward() && user.getSocketAddress() instanceof InetSocketAddress )
|
||||
{
|
||||
String newHost = copiedHandshake.getHost() + "\00" + user.getAddress().getHostString() + "\00" + user.getUUID();
|
||||
String newHost = copiedHandshake.getHost() + "\00" + AddressUtil.sanitizeAddress( user.getAddress() ) + "\00" + user.getUUID();
|
||||
|
||||
LoginResult profile = user.getPendingConnection().getLoginProfile();
|
||||
if ( profile != null && profile.getProperties() != null && profile.getProperties().length > 0 )
|
||||
|
26
proxy/src/main/java/net/md_5/bungee/util/AddressUtil.java
Normal file
26
proxy/src/main/java/net/md_5/bungee/util/AddressUtil.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package net.md_5.bungee.util;
|
||||
|
||||
import java.net.Inet6Address;
|
||||
import java.net.InetSocketAddress;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class AddressUtil
|
||||
{
|
||||
|
||||
public static String sanitizeAddress(InetSocketAddress addr)
|
||||
{
|
||||
String string = addr.getHostString();
|
||||
|
||||
// Remove IPv6 scope if present
|
||||
if ( addr.getAddress() instanceof Inet6Address )
|
||||
{
|
||||
int strip = string.indexOf( '%' );
|
||||
return ( strip == -1 ) ? string : string.substring( 0, strip );
|
||||
} else
|
||||
{
|
||||
return string;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user