Feature Request: Invalidate IP entry in rate-limiter before transfer
Information
Drop IP from Velocity rate-limiter before transferring (1.20.5) players again to the same server, probably make it an option.
Reason
A usual configuration of the rate-limiter is about 5 seconds. Sonar verifies the client much quicker. Manually removing the IP from cache before transferring might allow not to disable or lower rate-limits and still be convenient for players.
Additional information
These are "internals". Sample code for any Velocity plugin with access to proxy module, not actually tested:
import com.github.benmanes.caffeine.cache.Cache;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.event.proxy.ProxyReloadEvent;
import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.util.ratelimit.CaffeineCacheRatelimiter;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.net.InetAddress;
public class Sample {
private final MethodHandle cacheGetter;
private Cache<InetAddress, Long> cache;
public Sample() throws NoSuchFieldException, IllegalAccessException {
this.cacheGetter = MethodHandles.privateLookupIn(CaffeineCacheRatelimiter.class, MethodHandles.lookup())
.findGetter(CaffeineCacheRatelimiter.class, "expiringCache", Cache.class);
this.loadCache();
}
public void dropFromCache(InetAddress address) {
if (this.cache == null) return; // Not tested for races
this.cache.invalidate(address);
}
@Subscribe
public void proxyInitializeEvent(ProxyInitializeEvent event) {
this.loadCache();
}
@Subscribe
public void proxyReloadEvent(ProxyReloadEvent event) {
this.loadCache();
}
private void loadCache() {
try {
VelocityServer server = ...; // Obtain from plugin
if (!(server.getIpAttemptLimiter() instanceof CaffeineCacheRatelimiter limiter)) {
this.cache = null;
return;
}
this.cache = (Cache<InetAddress, Long>) this.cacheGetter.invoke(limiter);
} catch (Throwable e) {
this.cache = null;
// Handle errors here
}
}
}
wtf edit: if these comments above will be deleted, this is what i'm writing "wtf" about.
Drop IP from Velocity rate-limiter before transferring (1.20.5) players [...]
Good idea, but I'd have to implement this for BungeeCord and Bukkit as well, not just Velocity.
I hope nobody clicked on the link WSA1k posted. If you did, reset your PC :sweat:
I hope nobody clicked on the link
WSA1kposted. If you did, reset your PC 😓
It's good to report every account like that
It's good to report every account like that
Yeah, I did report them to GitHub. One of the accounts was already banned afaik.
Planned for 2.2.0
This will be addressed in Sonar 3.0.0.
More information: https://jonesdev.xyz/discord (or https://patreon.com/jonesdev) for previews, polls, and news.