From 6be43952eb6088a3f0c9a04ede96707e720203e3 Mon Sep 17 00:00:00 2001 From: Noah van der Aa Date: Sat, 23 Sep 2023 21:37:26 +0200 Subject: [PATCH] Migrate paper log ips option to new server.properties option --- patches/server/0005-Paper-config-files.patch | 71 +++++++++++++++++-- .../server/0018-Rewrite-chunk-system.patch | 2 +- .../0091-Configurable-RCON-IP-address.patch | 2 +- ...4-Hide-sync-chunk-writes-behind-flag.patch | 2 +- .../0853-Configurable-chat-thread-limit.patch | 4 +- ...sing-logs-for-log-ips-config-option.patch} | 15 +--- 6 files changed, 70 insertions(+), 26 deletions(-) rename patches/server/{1024-Support-Paper-ip-address-config-add-missing-logs.patch => 1024-Add-missing-logs-for-log-ips-config-option.patch} (75%) diff --git a/patches/server/0005-Paper-config-files.patch b/patches/server/0005-Paper-config-files.patch index 947a0ecbba..e964f31054 100644 --- a/patches/server/0005-Paper-config-files.patch +++ b/patches/server/0005-Paper-config-files.patch @@ -11,6 +11,7 @@ public org.spigotmc.SpigotWorldConfig getInt(Ljava/lang/String;)I public org.spigotmc.SpigotWorldConfig getInt(Ljava/lang/String;I)I public org.spigotmc.SpigotWorldConfig getList(Ljava/lang/String;Ljava/lang/Object;)Ljava/util/List; public org.spigotmc.SpigotWorldConfig getString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; +public net.minecraft.server.dedicated.DedicatedServerProperties reload(Lnet/minecraft/core/RegistryAccess;Ljava/util/Properties;Ljoptsimple/OptionSet;)Lnet/minecraft/server/dedicated/DedicatedServerProperties; public net.minecraft.world.level.NaturalSpawner SPAWNING_CATEGORIES diff --git a/build.gradle.kts b/build.gradle.kts @@ -440,10 +441,10 @@ index 0000000000000000000000000000000000000000..9ef6712c70fcd8912a79f3f61e351aac +} diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java new file mode 100644 -index 0000000000000000000000000000000000000000..4b3bb5fad1d80c9baea20ca224663b1ebc2b83e9 +index 0000000000000000000000000000000000000000..dcfc085d355410723dbeef369579e1875a7a997b --- /dev/null +++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -@@ -0,0 +1,294 @@ +@@ -0,0 +1,293 @@ +package io.papermc.paper.configuration; + +import co.aikar.timings.MinecraftTimings; @@ -466,7 +467,7 @@ index 0000000000000000000000000000000000000000..4b3bb5fad1d80c9baea20ca224663b1e + +@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"}) +public class GlobalConfiguration extends ConfigurationPart { -+ static final int CURRENT_VERSION = 28; ++ static final int CURRENT_VERSION = 29; + private static GlobalConfiguration instance; + public static GlobalConfiguration get() { + return instance; @@ -611,7 +612,6 @@ index 0000000000000000000000000000000000000000..4b3bb5fad1d80c9baea20ca224663b1e + public Logging logging; + + public class Logging extends ConfigurationPart { -+ public boolean logPlayerIpAddresses = true; + public boolean deobfuscateStacktraces = true; + } + @@ -951,10 +951,10 @@ index 0000000000000000000000000000000000000000..69add4a7f1147015806bc9b63a8340d1 +} diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java new file mode 100644 -index 0000000000000000000000000000000000000000..2d3068b7748032342edd81e6ea4a7c08988fb28d +index 0000000000000000000000000000000000000000..9b5c2abaa28fa60cedd9f0111e5eb018f93a0561 --- /dev/null +++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -@@ -0,0 +1,445 @@ +@@ -0,0 +1,450 @@ +package io.papermc.paper.configuration; + +import com.google.common.base.Suppliers; @@ -974,6 +974,7 @@ index 0000000000000000000000000000000000000000..2d3068b7748032342edd81e6ea4a7c08 +import io.papermc.paper.configuration.serializer.registry.RegistryValueSerializer; +import io.papermc.paper.configuration.transformation.Transformations; +import io.papermc.paper.configuration.transformation.global.LegacyPaperConfig; ++import io.papermc.paper.configuration.transformation.global.versioned.V29_LogIPs; +import io.papermc.paper.configuration.transformation.world.FeatureSeedsGeneration; +import io.papermc.paper.configuration.transformation.world.LegacyPaperWorldConfig; +import io.papermc.paper.configuration.transformation.world.versioned.V29_ZeroWorldHeight; @@ -1212,8 +1213,12 @@ index 0000000000000000000000000000000000000000..2d3068b7748032342edd81e6ea4a7c08 + for (NodePath path : RemovedConfigurations.REMOVED_GLOBAL_PATHS) { + builder.addAction(path, TransformAction.remove()); + } -+ // ADD FUTURE TRANSFORMS TO builder HERE + builder.build().apply(node); ++ ++ final ConfigurationTransformation.VersionedBuilder versionedBuilder = Transformations.versionedBuilder(); ++ V29_LogIPs.apply(versionedBuilder); ++ // ADD FUTURE VERSIONED TRANSFORMS TO versionedBuilder HERE ++ versionedBuilder.build().apply(node); + } + + private static final List DEFAULT_AWARE_TRANSFORMATIONS = List.of(FeatureSeedsGeneration::apply); @@ -3373,6 +3378,58 @@ index 0000000000000000000000000000000000000000..ef0e834c164b0ccc1a61b349348e6799 + }); + } +} +diff --git a/src/main/java/io/papermc/paper/configuration/transformation/global/versioned/V29_LogIPs.java b/src/main/java/io/papermc/paper/configuration/transformation/global/versioned/V29_LogIPs.java +new file mode 100644 +index 0000000000000000000000000000000000000000..f250ea5acd2edce924ee52b8ec16a23261f5e90d +--- /dev/null ++++ b/src/main/java/io/papermc/paper/configuration/transformation/global/versioned/V29_LogIPs.java +@@ -0,0 +1,46 @@ ++package io.papermc.paper.configuration.transformation.global.versioned; ++ ++import net.minecraft.server.MinecraftServer; ++import net.minecraft.server.dedicated.DedicatedServer; ++import org.checkerframework.checker.nullness.qual.Nullable; ++import org.spongepowered.configurate.ConfigurateException; ++import org.spongepowered.configurate.ConfigurationNode; ++import org.spongepowered.configurate.NodePath; ++import org.spongepowered.configurate.transformation.ConfigurationTransformation; ++import org.spongepowered.configurate.transformation.TransformAction; ++ ++import java.util.Properties; ++ ++import static org.spongepowered.configurate.NodePath.path; ++ ++public class V29_LogIPs implements TransformAction { ++ ++ private static final int VERSION = 29; ++ private static final NodePath PATH = path("logging", "log-player-ip-addresses"); ++ private static final V29_LogIPs INSTANCE = new V29_LogIPs(); ++ ++ private V29_LogIPs() { ++ } ++ ++ public static void apply(ConfigurationTransformation.VersionedBuilder builder) { ++ builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build()); ++ } ++ ++ @Nullable ++ @Override ++ public Object[] visitPath(final NodePath path, final ConfigurationNode value) throws ConfigurateException { ++ DedicatedServer server = ((DedicatedServer) MinecraftServer.getServer()); ++ ++ boolean val = value.getBoolean(server.settings.getProperties().logIPs); ++ server.settings.update((config) -> { ++ Properties newProps = new Properties(config.properties); ++ newProps.setProperty("log-ips", String.valueOf(val)); ++ return config.reload(server.registryAccess(), newProps, server.options); ++ }); ++ ++ value.raw(null); ++ ++ return null; ++ } ++ ++} diff --git a/src/main/java/io/papermc/paper/configuration/transformation/world/FeatureSeedsGeneration.java b/src/main/java/io/papermc/paper/configuration/transformation/world/FeatureSeedsGeneration.java new file mode 100644 index 0000000000000000000000000000000000000000..1326aae8f95ab11f840abdee0c8c7a557705fd73 diff --git a/patches/server/0018-Rewrite-chunk-system.patch b/patches/server/0018-Rewrite-chunk-system.patch index 0a009c7e9a..9b478f4d59 100644 --- a/patches/server/0018-Rewrite-chunk-system.patch +++ b/patches/server/0018-Rewrite-chunk-system.patch @@ -15753,7 +15753,7 @@ index 0000000000000000000000000000000000000000..962d3cae6340fc11607b59355e291629 + +} diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -index 4b3bb5fad1d80c9baea20ca224663b1ebc2b83e9..3a5abb89d3742a6f38799c183a098947686e16ab 100644 +index dcfc085d355410723dbeef369579e1875a7a997b..8f82d5e1e263035eb23d878ffdc70c445933a207 100644 --- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java @@ -25,6 +25,45 @@ public class GlobalConfiguration extends ConfigurationPart { diff --git a/patches/server/0091-Configurable-RCON-IP-address.patch b/patches/server/0091-Configurable-RCON-IP-address.patch index c8903112c2..4036fa039e 100644 --- a/patches/server/0091-Configurable-RCON-IP-address.patch +++ b/patches/server/0091-Configurable-RCON-IP-address.patch @@ -9,7 +9,7 @@ For servers with multiple IP's, ability to bind to a specific interface. public net.minecraft.server.dedicated.Settings getStringRaw(Ljava/lang/String;)Ljava/lang/String; diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java -index dc274aa4757f7426fb494528f6e62cc4ede7455c..97e9a3e567a53c21aff8c525259b9dd83f222ebf 100644 +index 20d02405b8e6476b11a8c8518c9a3949d3df11a4..bdf520c32847658fefaf2bde33bac16ea807002f 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java @@ -109,6 +109,8 @@ public class DedicatedServerProperties extends Settings Date: Sat, 23 Sep 2023 01:49:39 -0400 -Subject: [PATCH] Support Paper ip address config + add missing logs +Subject: [PATCH] Add missing logs for log-ips config option -diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index dbccbcb9b44e4efacdf53c2d161115cc20b36cff..18348d01003c8b3299ae3d5292fd9e50f9153cce 100644 ---- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -643,7 +643,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - - @Override - public boolean logIPs() { -- return this.getProperties().logIPs; -+ return this.getProperties().logIPs && io.papermc.paper.configuration.GlobalConfiguration.get().logging.logPlayerIpAddresses; // Paper - } - - protected boolean convertOldUsers() { diff --git a/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java b/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java index d4f5a98a0b1ca9f2a8baa6e0b27353df94d1f333..8f4a964a0863b1be834c1ea1e3d49092516f9258 100644 --- a/src/main/java/net/minecraft/server/network/LegacyQueryHandler.java