Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send offline uuid to client and server if ip-forward is disabled #3656

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions proxy/src/main/java/net/md_5/bungee/ServerConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void connected(ChannelWrapper channel) throws Exception
channel.write( copiedHandshake );

channel.setProtocol( Protocol.LOGIN );
channel.write( new LoginRequest( user.getName(), null, user.getUniqueId() ) );
channel.write( new LoginRequest( user.getName(), null, user.getRewriteId() ) );
}

@Override
Expand Down Expand Up @@ -365,7 +365,7 @@ private void cutThrough(ServerConnection server)
} else
{
LoginResult loginProfile = user.getPendingConnection().getLoginProfile();
user.unsafe().sendPacket( new LoginSuccess( user.getUniqueId(), user.getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) );
user.unsafe().sendPacket( new LoginSuccess( user.getRewriteId(), user.getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) );
user.getCh().setEncodeProtocol( Protocol.CONFIGURATION );
}
}
Expand Down
5 changes: 5 additions & 0 deletions proxy/src/main/java/net/md_5/bungee/UserConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -796,4 +796,9 @@ public void transfer(String host, int port)

unsafe().sendPacket( new Transfer( host, port ) );
}

public UUID getRewriteId()
{
return getPendingConnection().getRewriteId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ public void sendPacket(DefinedPacket packet)
@Getter
private UUID offlineId;
@Getter
private UUID rewriteId;
@Getter
private LoginResult loginProfile;
@Getter
private boolean legacy;
Expand Down Expand Up @@ -557,6 +559,8 @@ private void finish()
uniqueId = offlineId;
}

rewriteId = bungee.config.isIpForward() ? uniqueId : offlineId;

if ( BungeeCord.getInstance().config.isEnforceSecureProfile() )
{
if ( getVersion() >= ProtocolConstants.MINECRAFT_1_19_1 && getVersion() < ProtocolConstants.MINECRAFT_1_19_3 )
Expand Down Expand Up @@ -635,7 +639,7 @@ public void run()

if ( getVersion() < ProtocolConstants.MINECRAFT_1_20_2 )
{
unsafe.sendPacket( new LoginSuccess( getUniqueId(), getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) );
unsafe.sendPacket( new LoginSuccess( getRewriteId(), getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) );
ch.setProtocol( Protocol.GAME );
}
finish2();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void disconnected(ChannelWrapper channel) throws Exception
PlayerListItem oldPacket = new PlayerListItem();
oldPacket.setAction( PlayerListItem.Action.REMOVE_PLAYER );
PlayerListItem.Item item = new PlayerListItem.Item();
item.setUuid( con.getUniqueId() );
item.setUuid( con.getRewriteId() );
oldPacket.setItems( new PlayerListItem.Item[]
{
item
Expand All @@ -94,7 +94,7 @@ public void disconnected(ChannelWrapper channel) throws Exception
PlayerListItemRemove newPacket = new PlayerListItemRemove();
newPacket.setUuids( new UUID[]
{
con.getUniqueId()
con.getRewriteId()
} );

for ( ProxiedPlayer player : con.getServer().getInfo().getPlayers() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId)
DefinedPacket.readVarInt( packet ); // Entity ID
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
UUID uuid = DefinedPacket.readUUID( packet );
ProxiedPlayer player;
UserConnection player;
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
{
int previous = packet.writerIndex();
packet.readerIndex( readerIndex );
packet.writerIndex( readerIndex + packetIdLength + idLength );
DefinedPacket.writeUUID( player.getUniqueId(), packet );
DefinedPacket.writeUUID( player.getRewriteId(), packet );
packet.writerIndex( previous );
}
break;
Expand Down Expand Up @@ -164,7 +164,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
int packetId = DefinedPacket.readVarInt( packet );
int packetIdLength = packet.readerIndex() - readerIndex;

if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ )
{
UUID uuid = DefinedPacket.readUUID( packet );
ProxiedPlayer player;
Expand All @@ -173,7 +173,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
int previous = packet.writerIndex();
packet.readerIndex( readerIndex );
packet.writerIndex( readerIndex + packetIdLength );
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
packet.writerIndex( previous );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId)
DefinedPacket.readVarInt( packet ); // Entity ID
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
UUID uuid = DefinedPacket.readUUID( packet );
ProxiedPlayer player;
UserConnection player;
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
{
int previous = packet.writerIndex();
packet.readerIndex( readerIndex );
packet.writerIndex( readerIndex + packetIdLength + idLength );
DefinedPacket.writeUUID( player.getUniqueId(), packet );
DefinedPacket.writeUUID( player.getRewriteId(), packet );
packet.writerIndex( previous );
}
break;
Expand Down Expand Up @@ -165,7 +165,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
int packetId = DefinedPacket.readVarInt( packet );
int packetIdLength = packet.readerIndex() - readerIndex;

if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ )
{
UUID uuid = DefinedPacket.readUUID( packet );
ProxiedPlayer player;
Expand All @@ -174,7 +174,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
int previous = packet.writerIndex();
packet.readerIndex( readerIndex );
packet.writerIndex( readerIndex + packetIdLength );
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
packet.writerIndex( previous );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId)
DefinedPacket.readVarInt( packet ); // Entity ID
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
UUID uuid = DefinedPacket.readUUID( packet );
ProxiedPlayer player;
UserConnection player;
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
{
int previous = packet.writerIndex();
packet.readerIndex( readerIndex );
packet.writerIndex( readerIndex + packetIdLength + idLength );
DefinedPacket.writeUUID( player.getUniqueId(), packet );
DefinedPacket.writeUUID( player.getRewriteId(), packet );
packet.writerIndex( previous );
}
break;
Expand Down Expand Up @@ -165,7 +165,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
int packetId = DefinedPacket.readVarInt( packet );
int packetIdLength = packet.readerIndex() - readerIndex;

if ( packetId == 0x1E /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
if ( packetId == 0x1E /* Spectate : PacketPlayInSpectate */ )
{
UUID uuid = DefinedPacket.readUUID( packet );
ProxiedPlayer player;
Expand All @@ -174,7 +174,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
int previous = packet.writerIndex();
packet.readerIndex( readerIndex );
packet.writerIndex( readerIndex + packetIdLength );
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
packet.writerIndex( previous );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId)
DefinedPacket.readVarInt( packet ); // Entity ID
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
UUID uuid = DefinedPacket.readUUID( packet );
ProxiedPlayer player;
UserConnection player;
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
{
int previous = packet.writerIndex();
packet.readerIndex( readerIndex );
packet.writerIndex( readerIndex + packetIdLength + idLength );
DefinedPacket.writeUUID( player.getUniqueId(), packet );
DefinedPacket.writeUUID( player.getRewriteId(), packet );
packet.writerIndex( previous );
}
break;
Expand Down Expand Up @@ -165,7 +165,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
int packetId = DefinedPacket.readVarInt( packet );
int packetIdLength = packet.readerIndex() - readerIndex;

if ( packetId == 0x1E /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
if ( packetId == 0x1E /* Spectate : PacketPlayInSpectate */ )
{
UUID uuid = DefinedPacket.readUUID( packet );
ProxiedPlayer player;
Expand All @@ -174,7 +174,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
int previous = packet.writerIndex();
packet.readerIndex( readerIndex );
packet.writerIndex( readerIndex + packetIdLength );
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
packet.writerIndex( previous );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protoco
DefinedPacket.readVarInt( packet ); // Entity ID
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
UUID uuid = DefinedPacket.readUUID( packet );
ProxiedPlayer player;
UserConnection player;
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
{
int previous = packet.writerIndex();
packet.readerIndex( readerIndex );
packet.writerIndex( readerIndex + packetIdLength + idLength );
DefinedPacket.writeUUID( player.getUniqueId(), packet );
DefinedPacket.writeUUID( player.getRewriteId(), packet );
packet.writerIndex( previous );
}
break;
Expand Down Expand Up @@ -165,7 +165,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
int packetId = DefinedPacket.readVarInt( packet );
int packetIdLength = packet.readerIndex() - readerIndex;

if ( packetId == 0x28 /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
if ( packetId == 0x28 /* Spectate : PacketPlayInSpectate */ )
{
UUID uuid = DefinedPacket.readUUID( packet );
ProxiedPlayer player;
Expand All @@ -174,7 +174,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
int previous = packet.writerIndex();
packet.readerIndex( readerIndex );
packet.writerIndex( readerIndex + packetIdLength );
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
packet.writerIndex( previous );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protoco
DefinedPacket.readVarInt( packet ); // Entity ID
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
UUID uuid = DefinedPacket.readUUID( packet );
ProxiedPlayer player;
UserConnection player;
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
{
int previous = packet.writerIndex();
packet.readerIndex( readerIndex );
packet.writerIndex( readerIndex + packetIdLength + idLength );
DefinedPacket.writeUUID( player.getUniqueId(), packet );
DefinedPacket.writeUUID( player.getRewriteId(), packet );
packet.writerIndex( previous );
}
break;
Expand Down Expand Up @@ -169,7 +169,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
int packetId = DefinedPacket.readVarInt( packet );
int packetIdLength = packet.readerIndex() - readerIndex;

if ( packetId == 0x2B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
if ( packetId == 0x2B /* Spectate : PacketPlayInSpectate */ )
{
UUID uuid = DefinedPacket.readUUID( packet );
ProxiedPlayer player;
Expand All @@ -178,7 +178,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
int previous = packet.writerIndex();
packet.readerIndex( readerIndex );
packet.writerIndex( readerIndex + packetIdLength );
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
packet.writerIndex( previous );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protoco
DefinedPacket.readVarInt( packet ); // Entity ID
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
UUID uuid = DefinedPacket.readUUID( packet );
ProxiedPlayer player;
UserConnection player;
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
{
int previous = packet.writerIndex();
packet.readerIndex( readerIndex );
packet.writerIndex( readerIndex + packetIdLength + idLength );
DefinedPacket.writeUUID( player.getUniqueId(), packet );
DefinedPacket.writeUUID( player.getRewriteId(), packet );
packet.writerIndex( previous );
}
break;
Expand Down Expand Up @@ -169,7 +169,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
int packetId = DefinedPacket.readVarInt( packet );
int packetIdLength = packet.readerIndex() - readerIndex;

if ( packetId == 0x2B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
if ( packetId == 0x2B /* Spectate : PacketPlayInSpectate */ )
{
UUID uuid = DefinedPacket.readUUID( packet );
ProxiedPlayer player;
Expand All @@ -178,7 +178,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
int previous = packet.writerIndex();
packet.readerIndex( readerIndex );
packet.writerIndex( readerIndex + packetIdLength );
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
packet.writerIndex( previous );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protoco
DefinedPacket.readVarInt( packet ); // Entity ID
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
UUID uuid = DefinedPacket.readUUID( packet );
ProxiedPlayer player;
UserConnection player;
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
{
int previous = packet.writerIndex();
packet.readerIndex( readerIndex );
packet.writerIndex( readerIndex + packetIdLength + idLength );
DefinedPacket.writeUUID( player.getUniqueId(), packet );
DefinedPacket.writeUUID( player.getRewriteId(), packet );
packet.writerIndex( previous );
}
break;
Expand Down Expand Up @@ -169,7 +169,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
int packetId = DefinedPacket.readVarInt( packet );
int packetIdLength = packet.readerIndex() - readerIndex;

if ( packetId == 0x2C /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
if ( packetId == 0x2C /* Spectate : PacketPlayInSpectate */ )
{
UUID uuid = DefinedPacket.readUUID( packet );
ProxiedPlayer player;
Expand All @@ -178,7 +178,7 @@ public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
int previous = packet.writerIndex();
packet.readerIndex( readerIndex );
packet.writerIndex( readerIndex + packetIdLength );
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
packet.writerIndex( previous );
}
}
Expand Down
Loading