mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-11-16 07:15:14 +01:00
cca83dfaf6
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing BungeeCord Changes: a3ab2bf5 Update checkstyle adee7bd2 Source jar does not need to fork build 7bd8a027 Always print remote IP in InitialHandler 0cf27a09 Update scriptus bf673c5d Add pretty colours to console log levels 2235a323 Optimize ColouredWriter slightly 1dee0490 Don't send/construct redundant kick messages e9ba95b9 Don't log full CorruptedFrameException d3bd7852 #2762: Work correctly with disabled timeout 3ce4132c Switch keepalive queue to ArrayDeque ce2dcaf7 #2763: Fix .DS_Store entry in .gitignore cf72c3a7 Show slow event times in milliseconds cd7a3ab2 #2758: Improve server list ping response where remote ping failed 0a4b9b49 #2752: Configurable connect and ping timeouts
112 lines
4.0 KiB
Diff
112 lines
4.0 KiB
Diff
From 1f2f759843f42eea8962ed3a0bb6be82bd17022c Mon Sep 17 00:00:00 2001
|
|
From: Johannes Donath <johannesd@torchmind.com>
|
|
Date: Sat, 4 Jul 2015 06:31:33 +0200
|
|
Subject: [PATCH] Add basic support for configurable tab-complete throttling
|
|
|
|
|
|
diff --git a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
|
index 6495e7f2..b6845bc4 100644
|
|
--- a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
|
+++ b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
|
@@ -130,4 +130,21 @@ public interface ProxyConfig
|
|
// Waterfall Options
|
|
//
|
|
|
|
+ // Throttling options
|
|
+
|
|
+ /**
|
|
+ * How often tab-complete packets can be sent.
|
|
+ * <br>
|
|
+ * Values in milliseconds.
|
|
+ *
|
|
+ * @return how often tab-complete packets can be sent in milliseconds
|
|
+ */
|
|
+ int getTabThrottle();
|
|
+
|
|
+ /**
|
|
+ * Should we disable the tab completion limit for 1.13+ clients
|
|
+ *
|
|
+ * @return should we disable the tab completion limit for 1.13+ clients
|
|
+ */
|
|
+ boolean isDisableModernTabLimiter();
|
|
}
|
|
diff --git a/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java b/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
|
index 741ebfde..91743f01 100644
|
|
--- a/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
|
+++ b/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
|
@@ -7,11 +7,37 @@ import java.io.File;
|
|
|
|
public class WaterfallConfiguration extends Configuration {
|
|
|
|
+ /*
|
|
+ * Throttling options
|
|
+ * Helps prevent players from overloading the servers behind us
|
|
+ */
|
|
+
|
|
+ /**
|
|
+ * How often players are allowed to send tab throttle.
|
|
+ * Value in milliseconds.
|
|
+ * <p/>
|
|
+ * Default is one packet per second.
|
|
+ */
|
|
+ private int tabThrottle = 1000;
|
|
+ private boolean disableModernTabLimiter = true;
|
|
+
|
|
@Override
|
|
public void load() {
|
|
super.load();
|
|
YamlConfig config = new YamlConfig(new File("waterfall.yml"));
|
|
config.load(false); // Load, but no permissions
|
|
+ // Throttling options
|
|
+ tabThrottle = config.getInt("throttling.tab_complete", tabThrottle);
|
|
+ disableModernTabLimiter = config.getBoolean("disable_modern_tab_limiter", disableModernTabLimiter);
|
|
}
|
|
|
|
+ @Override
|
|
+ public int getTabThrottle() {
|
|
+ return tabThrottle;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isDisableModernTabLimiter() {
|
|
+ return disableModernTabLimiter;
|
|
+ }
|
|
}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
|
|
index 6b888c85..c7e1a621 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
|
|
@@ -38,6 +38,8 @@ public class UpstreamBridge extends PacketHandler
|
|
private final ProxyServer bungee;
|
|
private final UserConnection con;
|
|
|
|
+ private long lastTabCompletion = -1;
|
|
+
|
|
public UpstreamBridge(ProxyServer bungee, UserConnection con)
|
|
{
|
|
this.bungee = bungee;
|
|
@@ -156,6 +158,20 @@ public class UpstreamBridge extends PacketHandler
|
|
@Override
|
|
public void handle(TabCompleteRequest tabComplete) throws Exception
|
|
{
|
|
+ // Waterfall start - tab limiter
|
|
+ if ( bungee.getConfig().getTabThrottle() > 0 &&
|
|
+ ( con.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13
|
|
+ && !bungee.getConfig().isDisableModernTabLimiter()))
|
|
+ {
|
|
+ long now = System.currentTimeMillis();
|
|
+ if ( lastTabCompletion > 0 && (now - lastTabCompletion) <= bungee.getConfig().getTabThrottle() )
|
|
+ {
|
|
+ throw CancelSendSignal.INSTANCE;
|
|
+ }
|
|
+ lastTabCompletion = now;
|
|
+ }
|
|
+
|
|
+ // Waterfall end - tab limiter
|
|
List<String> suggestions = new ArrayList<>();
|
|
|
|
if ( tabComplete.getCursor().startsWith( "/" ) )
|
|
--
|
|
2.25.0
|
|
|