5454import org .geysermc .geyser .network .GameProtocol ;
5555import org .geysermc .geyser .network .GeyserServerInitializer ;
5656import org .geysermc .geyser .network .netty .handler .RakConnectionRequestHandler ;
57- import org .geysermc .geyser .network .netty .handler .RakGeyserRateLimiter ;
5857import org .geysermc .geyser .network .netty .handler .RakPingHandler ;
59- import org .geysermc .geyser .network .netty .proxy .ProxyServerHandler ;
6058import org .geysermc .geyser .ping .GeyserPingInfo ;
6159import org .geysermc .geyser .ping .IGeyserPingPassthrough ;
6260import 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
0 commit comments