Skip to content

Commit 94fc29a

Browse files
committed
remove HAProxy handling
1 parent 9b42045 commit 94fc29a

8 files changed

Lines changed: 11 additions & 835 deletions

File tree

core/src/main/java/org/geysermc/geyser/network/GeyserServerInitializer.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,6 @@ protected void preInitChannel(Channel channel) throws Exception {
6363
@Override
6464
public void initSession(@NonNull BedrockServerSession bedrockServerSession) {
6565
try {
66-
if (this.geyser.getGeyserServer().getProxiedAddresses() != null) {
67-
InetSocketAddress address = this.geyser.getGeyserServer().getProxiedAddresses().get((InetSocketAddress) bedrockServerSession.getSocketAddress());
68-
if (address != null) {
69-
((GeyserBedrockPeer) bedrockServerSession.getPeer()).setProxiedAddress(address);
70-
}
71-
}
72-
7366
bedrockServerSession.setLogging(this.geyser.config().debugMode());
7467
GeyserSession session = new GeyserSession(this.geyser, bedrockServerSession, this.eventLoopGroup.next());
7568

core/src/main/java/org/geysermc/geyser/network/UpstreamPacketHandler.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,6 @@ public PacketSignal handle(LoginPacket loginPacket) {
200200
}
201201
receivedLoginPacket = true;
202202

203-
if (geyser.getSessionManager().reachedMaxConnectionsPerAddress(session)) {
204-
session.disconnect("Too many connections are originating from this location!");
205-
return PacketSignal.HANDLED;
206-
}
207-
208203
LoginEncryptionUtils.encryptPlayerConnection(session, loginPacket);
209204

210205
if (session.isClosed()) {

core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@
5454
import org.geysermc.geyser.network.GameProtocol;
5555
import org.geysermc.geyser.network.GeyserServerInitializer;
5656
import org.geysermc.geyser.network.netty.handler.RakConnectionRequestHandler;
57-
import org.geysermc.geyser.network.netty.handler.RakGeyserRateLimiter;
5857
import org.geysermc.geyser.network.netty.handler.RakPingHandler;
59-
import org.geysermc.geyser.network.netty.proxy.ProxyServerHandler;
6058
import org.geysermc.geyser.ping.GeyserPingInfo;
6159
import org.geysermc.geyser.ping.IGeyserPingPassthrough;
6260
import org.geysermc.geyser.skin.SkinProvider;
@@ -107,8 +105,6 @@ public final class GeyserServer {
107105
private final ServerBootstrap bootstrap;
108106
private EventLoopGroup playerGroup;
109107

110-
@Getter
111-
private final ExpiringMap<InetSocketAddress, InetSocketAddress> proxiedAddresses;
112108
private int listenCount;
113109

114110
private ChannelFuture[] bootstrapFutures;
@@ -136,14 +132,6 @@ public GeyserServer(GeyserImpl geyser, int threadCount) {
136132
this.listenCount = 1;
137133
}
138134

139-
if (this.geyser.config().advanced().bedrock().useHaproxyProtocol() || this.geyser.config().advanced().bedrock().useWaterdogpeForwarding()) {
140-
this.proxiedAddresses = ExpiringMap.builder()
141-
.expiration(30 + 1, TimeUnit.MINUTES)
142-
.expirationPolicy(ExpirationPolicy.ACCESSED).build();
143-
} else {
144-
this.proxiedAddresses = null;
145-
}
146-
147135
this.broadcastPort = geyser.config().advanced().bedrock().broadcastPort();
148136
}
149137

@@ -171,19 +159,9 @@ private void modifyHandlers(ChannelFuture future) {
171159
.addFirst(RakConnectionRequestHandler.NAME, new RakConnectionRequestHandler(this))
172160
.addAfter(RakServerOfflineHandler.NAME, RakPingHandler.NAME, new RakPingHandler(this));
173161

174-
// Add proxy handler
175-
boolean isProxyProtocol = this.geyser.config().advanced().bedrock().useHaproxyProtocol();
176-
if (isProxyProtocol) {
177-
channel.pipeline().addFirst("proxy-protocol-decoder", new ProxyServerHandler());
178-
}
179-
180-
boolean isWhitelistedProxyProtocol = isProxyProtocol && !this.geyser.config().advanced().bedrock().haproxyProtocolWhitelistedIps().isEmpty();
181-
if (Boolean.parseBoolean(System.getProperty("Geyser.RakRateLimitingDisabled", "false")) || isWhitelistedProxyProtocol) {
162+
if (Boolean.parseBoolean(System.getProperty("Geyser.RakRateLimitingDisabled", "false"))) {
182163
// We would already block any non-whitelisted IP addresses in onConnectionRequest so we can remove the rate limiter
183164
channel.pipeline().remove(RakServerRateLimiter.NAME);
184-
} else {
185-
// Use our own rate limiter to allow multiple players from the same IP
186-
channel.pipeline().replace(RakServerRateLimiter.NAME, RakGeyserRateLimiter.NAME, new RakGeyserRateLimiter(channel));
187165
}
188166
});
189167
}
@@ -228,6 +206,9 @@ private ServerBootstrap createBootstrap() {
228206

229207
this.geyser.getLogger().debug("Setting MTU to " + this.geyser.config().advanced().bedrock().mtu());
230208

209+
int rakMaxConnectionPerIp = positivePropOrDefault("Geyser.RakPacketLimit", 10);
210+
this.geyser.getLogger().debug("Setting RakNet max connection per ip " + rakMaxConnectionPerIp);
211+
231212
int rakPacketLimit = positivePropOrDefault("Geyser.RakPacketLimit", DEFAULT_PACKET_LIMIT);
232213
this.geyser.getLogger().debug("Setting RakNet packet limit to " + rakPacketLimit);
233214

@@ -245,9 +226,11 @@ private ServerBootstrap createBootstrap() {
245226
.group(group, childGroup)
246227
.option(RakChannelOption.RAK_HANDLE_PING, true)
247228
.option(RakChannelOption.RAK_MAX_MTU, this.geyser.config().advanced().bedrock().mtu())
229+
.option(RakChannelOption.RAK_MAX_CONNECTIONS, rakMaxConnectionPerIp)
248230
.option(RakChannelOption.RAK_PACKET_LIMIT, rakPacketLimit)
249231
.option(RakChannelOption.RAK_GLOBAL_PACKET_LIMIT, rakGlobalPacketLimit)
250232
.option(RakChannelOption.RAK_SERVER_COOKIE_MODE, rakSendCookie ? RakServerCookieMode.ACTIVE : RakServerCookieMode.INVALID)
233+
.option(RakChannelOption.PROXY_PROTOCOL, this.geyser.config().advanced().bedrock().useHaproxyProtocol())
251234
.childHandler(serverInitializer);
252235
}
253236

@@ -268,20 +251,11 @@ public boolean onConnectionRequest(InetSocketAddress inetSocketAddress) {
268251
}
269252
}
270253

271-
String ip;
272-
if (geyser.config().logPlayerIpAddresses()) {
273-
if (this.proxiedAddresses != null) {
274-
ip = this.proxiedAddresses.getOrDefault(inetSocketAddress, inetSocketAddress).toString();
275-
} else {
276-
ip = inetSocketAddress.toString();
277-
}
278-
} else {
279-
ip = "<IP address withheld>";
280-
}
254+
String ip = geyser.config().logPlayerIpAddresses() ? inetSocketAddress.toString() : "<IP address withheld>";
281255

282256
ConnectionRequestEvent requestEvent = new ConnectionRequestEvent(
283-
inetSocketAddress,
284-
this.proxiedAddresses != null ? this.proxiedAddresses.get(inetSocketAddress) : null
257+
inetSocketAddress,
258+
null // TODO
285259
);
286260
geyser.eventBus().fire(requestEvent);
287261
if (requestEvent.isCancelled()) {
@@ -297,16 +271,7 @@ public boolean onConnectionRequest(InetSocketAddress inetSocketAddress) {
297271

298272
public BedrockPong onQuery(Channel channel, InetSocketAddress inetSocketAddress) {
299273
if (geyser.config().debugMode() && PRINT_DEBUG_PINGS) {
300-
String ip;
301-
if (geyser.config().logPlayerIpAddresses()) {
302-
if (this.proxiedAddresses != null) {
303-
ip = this.proxiedAddresses.getOrDefault(inetSocketAddress, inetSocketAddress).toString();
304-
} else {
305-
ip = inetSocketAddress.toString();
306-
}
307-
} else {
308-
ip = "<IP address withheld>";
309-
}
274+
String ip = geyser.config().logPlayerIpAddresses() ? inetSocketAddress.toString() : "<IP address withheld>";
310275
geyser.getLogger().debug(GeyserLocale.getLocaleStringLog("geyser.network.pinged", ip));
311276
}
312277

core/src/main/java/org/geysermc/geyser/network/netty/handler/RakGeyserRateLimiter.java

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)