Re-added a way to send Floodgate data over the wire (for e.g. standalone)

This commit is contained in:
Tim203 2023-10-13 16:47:55 +02:00
parent dab61ac41a
commit 4a673b6879
No known key found for this signature in database
2 changed files with 21 additions and 1 deletions

View file

@ -67,6 +67,7 @@ import org.geysermc.geyser.extension.GeyserExtensionManager;
import org.geysermc.geyser.floodgate.FloodgateProvider; import org.geysermc.geyser.floodgate.FloodgateProvider;
import org.geysermc.geyser.floodgate.IntegratedFloodgateProvider; import org.geysermc.geyser.floodgate.IntegratedFloodgateProvider;
import org.geysermc.geyser.floodgate.NoFloodgateProvider; import org.geysermc.geyser.floodgate.NoFloodgateProvider;
import org.geysermc.geyser.floodgate.ProxyFloodgateProvider;
import org.geysermc.geyser.level.WorldManager; import org.geysermc.geyser.level.WorldManager;
import org.geysermc.geyser.network.netty.GeyserServer; import org.geysermc.geyser.network.netty.GeyserServer;
import org.geysermc.geyser.registry.BlockRegistries; import org.geysermc.geyser.registry.BlockRegistries;
@ -168,7 +169,11 @@ public class GeyserImpl implements GeyserApi {
this.floodgateProvider = new IntegratedFloodgateProvider(floodgatePlatform); this.floodgateProvider = new IntegratedFloodgateProvider(floodgatePlatform);
// this.floodgateProvider = new ProxyFloodgateProvider(floodgatePlatform); // this.floodgateProvider = new ProxyFloodgateProvider(floodgatePlatform);
} else { } else {
this.floodgateProvider = new NoFloodgateProvider(); if (bootstrap.getGeyserConfig().getRemote().authType() == AuthType.FLOODGATE) {
this.floodgateProvider = new ProxyFloodgateProvider(bootstrap.getConfigFolder());
} else {
this.floodgateProvider = new NoFloodgateProvider();
}
Geyser.set(this); Geyser.set(this);
} }

View file

@ -26,8 +26,14 @@
package org.geysermc.geyser.floodgate; package org.geysermc.geyser.floodgate;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import lombok.SneakyThrows;
import org.geysermc.floodgate.core.FloodgatePlatform; import org.geysermc.floodgate.core.FloodgatePlatform;
import org.geysermc.floodgate.core.connection.standalone.codec.FloodgateConnectionCodec;
import org.geysermc.floodgate.core.crypto.DataCodecType;
import org.geysermc.floodgate.core.crypto.FloodgateDataCodec; import org.geysermc.floodgate.core.crypto.FloodgateDataCodec;
import org.geysermc.floodgate.core.crypto.FloodgateFormatCodec;
import org.geysermc.floodgate.core.crypto.topping.Base64Topping;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
//todo Floodgate should be responsible for forwarding its messages //todo Floodgate should be responsible for forwarding its messages
@ -38,6 +44,15 @@ public final class ProxyFloodgateProvider implements FloodgateProvider {
dataCodec = platform.getBean(FloodgateDataCodec.class); dataCodec = platform.getBean(FloodgateDataCodec.class);
} }
@SneakyThrows
public ProxyFloodgateProvider(Path dataDirectory) {
//todo use what the platform provides without enabling Floodgate
dataCodec = new FloodgateDataCodec(
new FloodgateFormatCodec(DataCodecType.AES, new Base64Topping(), dataDirectory),
new FloodgateConnectionCodec()
);
}
@Override @Override
public void onSkinUpload(GeyserSession session, String value, String signature) { public void onSkinUpload(GeyserSession session, String value, String signature) {
byte[] bytes = (value + '\0' + signature) byte[] bytes = (value + '\0' + signature)