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

Do not track plugin channels registered per-player on the proxy #591

Merged
merged 3 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,8 @@ public boolean handle(PluginMessage packet) {
return true;
}

// We need to specially handle REGISTER and UNREGISTER packets. Later on, we'll write them to
// the client.
if (PluginMessageUtil.isRegister(packet)) {
serverConn.getPlayer().getKnownChannels().addAll(PluginMessageUtil.getChannels(packet));
return false;
} else if (PluginMessageUtil.isUnregister(packet)) {
serverConn.getPlayer().getKnownChannels().removeAll(PluginMessageUtil.getChannels(packet));
// Register and unregister packets are simply forwarded to the server as-is.
if (PluginMessageUtil.isRegister(packet) || PluginMessageUtil.isUnregister(packet)) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,6 @@ public boolean handle(PluginMessage packet) {
return true;
}

if (PluginMessageUtil.isRegister(packet)) {
serverConn.getPlayer().getKnownChannels().addAll(PluginMessageUtil.getChannels(packet));
} else if (PluginMessageUtil.isUnregister(packet)) {
serverConn.getPlayer().getKnownChannels().removeAll(PluginMessageUtil.getChannels(packet));
}

// We always need to handle plugin messages, for Forge compatibility.
if (serverConn.getPhase().handle(serverConn, serverConn.getPlayer(), packet)) {
// Handled, but check the server connection phase.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public void activated() {
if (!channels.isEmpty()) {
PluginMessage register = constructChannelsPacket(player.getProtocolVersion(), channels);
player.getConnection().write(register);
player.getKnownChannels().addAll(channels);
}
}

Expand Down Expand Up @@ -223,7 +222,6 @@ public boolean handle(PluginMessage packet) {
+ "ready. Channel: {}. Packet discarded.", packet.getChannel());
} else if (PluginMessageUtil.isRegister(packet)) {
List<String> channels = PluginMessageUtil.getChannels(packet);
player.getKnownChannels().addAll(channels);
List<ChannelIdentifier> channelIdentifiers = new ArrayList<>();
for (String channel : channels) {
try {
Expand All @@ -236,7 +234,6 @@ public boolean handle(PluginMessage packet) {
ImmutableList.copyOf(channelIdentifiers)));
backendConn.write(packet.retain());
} else if (PluginMessageUtil.isUnregister(packet)) {
player.getKnownChannels().removeAll(PluginMessageUtil.getChannels(packet));
backendConn.write(packet.retain());
} else if (PluginMessageUtil.isMcBrand(packet)) {
String brand = PluginMessageUtil.readBrandMessage(packet.content());
Expand Down Expand Up @@ -404,12 +401,6 @@ public void handleBackendJoinGame(JoinGame joinGame, VelocityServerConnection de
}
serverBossBars.clear();

// Tell the server about this client's plugin message channels.
ProtocolVersion serverVersion = serverMc.getProtocolVersion();
if (!player.getKnownChannels().isEmpty()) {
serverMc.delayedWrite(constructChannelsPacket(serverVersion, player.getKnownChannels()));
}

// If we had plugin messages queued during login/FML handshake, send them now.
PluginMessage pm;
while ((pm = loginPluginMessages.poll()) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,10 @@
import com.velocitypowered.proxy.tablist.VelocityTabListLegacy;
import com.velocitypowered.proxy.util.ClosestLocaleMatcher;
import com.velocitypowered.proxy.util.DurationUtils;
import com.velocitypowered.proxy.util.collect.CappedSet;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import java.net.InetSocketAddress;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -107,7 +105,6 @@

public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {

private static final int MAX_PLUGIN_CHANNELS = 1024;
private static final PlainComponentSerializer PASS_THRU_TRANSLATE = new PlainComponentSerializer(
c -> "", TranslatableComponent::key);
static final PermissionProvider DEFAULT_PERMISSIONS = s -> PermissionFunction.ALWAYS_UNDEFINED;
Expand All @@ -134,7 +131,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
private final VelocityTabList tabList;
private final VelocityServer server;
private ClientConnectionPhase connectionPhase;
private final Collection<String> knownChannels;
private final CompletableFuture<Void> teardownFuture = new CompletableFuture<>();
private @MonotonicNonNull List<String> serversToTry = null;
private @MonotonicNonNull Boolean previousResourceResponse;
Expand All @@ -157,7 +153,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
this.virtualHost = virtualHost;
this.permissionFunction = PermissionFunction.ALWAYS_UNDEFINED;
this.connectionPhase = connection.getType().getInitialClientPhase();
this.knownChannels = CappedSet.create(MAX_PLUGIN_CHANNELS);
this.onlineMode = onlineMode;

if (connection.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
Expand Down Expand Up @@ -1021,14 +1016,6 @@ public void setPhase(ClientConnectionPhase connectionPhase) {
this.connectionPhase = connectionPhase;
}

/**
* Return all the plugin message channels "known" to the client.
* @return the channels
*/
public Collection<String> getKnownChannels() {
return knownChannels;
}

private class IdentityImpl implements Identity {
@Override
public @NonNull UUID uuid() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ public boolean handle(PluginMessage packet) {
return true;
}

if (PluginMessageUtil.isRegister(packet)) {
player.getKnownChannels().addAll(PluginMessageUtil.getChannels(packet));
} else if (PluginMessageUtil.isUnregister(packet)) {
player.getKnownChannels().removeAll(PluginMessageUtil.getChannels(packet));
} else if (BungeeCordMessageResponder.isBungeeCordMessage(packet)) {
if (BungeeCordMessageResponder.isBungeeCordMessage(packet)) {
return true;
}
serverConn.ensureConnected().write(packet.retain());
Expand Down

This file was deleted.

This file was deleted.