Added API to get player ha proxy address

This commit is contained in:
nostalfinals
2024-04-08 23:24:38 +08:00
parent d5b93a0167
commit 445e9a65fb
3 changed files with 36 additions and 19 deletions

View File

@@ -29,7 +29,7 @@
@Nullable
private volatile PacketListener disconnectListener;
@Nullable
@@ -114,7 +119,41 @@
@@ -114,7 +119,42 @@
private volatile DisconnectionDetails delayedDisconnect;
@Nullable
BandwidthDebugMonitor bandwidthDebugMonitor;
@@ -67,11 +67,12 @@
+ this.stopReadingPackets = true;
+ }
+ // Paper end - packet limiter
+ @Nullable public SocketAddress haProxyAddress; // Paper - Add API to get player's proxy address
+
public Connection(PacketFlow side) {
this.receiving = side;
}
@@ -123,6 +162,9 @@
@@ -123,6 +163,9 @@
super.channelActive(channelhandlercontext);
this.channel = channelhandlercontext.channel();
this.address = this.channel.remoteAddress();
@@ -81,7 +82,7 @@
if (this.delayedDisconnect != null) {
this.disconnect(this.delayedDisconnect);
}
@@ -134,6 +176,21 @@
@@ -134,6 +177,21 @@
}
public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) {
@@ -103,7 +104,7 @@
if (throwable instanceof SkipPacketException) {
Connection.LOGGER.debug("Skipping packet due to errors", throwable.getCause());
} else {
@@ -141,8 +198,10 @@
@@ -141,8 +199,10 @@
this.handlingFault = true;
if (this.channel.isOpen()) {
@@ -114,7 +115,7 @@
this.disconnect((Component) Component.translatable("disconnect.timeout"));
} else {
MutableComponent ichatmutablecomponent = Component.translatable("disconnect.genericReason", "Internal Exception: " + String.valueOf(throwable));
@@ -155,6 +214,7 @@
@@ -155,6 +215,7 @@
disconnectiondetails = new DisconnectionDetails(ichatmutablecomponent);
}
@@ -122,7 +123,7 @@
if (flag) {
Connection.LOGGER.debug("Failed to sent packet", throwable);
if (this.getSending() == PacketFlow.CLIENTBOUND) {
@@ -176,6 +236,7 @@
@@ -176,6 +237,7 @@
}
}
@@ -130,7 +131,7 @@
}
protected void channelRead0(ChannelHandlerContext channelhandlercontext, Packet<?> packet) {
@@ -185,11 +246,61 @@
@@ -185,11 +247,61 @@
if (packetlistener == null) {
throw new IllegalStateException("Received a packet before the packet listener was initialized");
} else {
@@ -192,7 +193,7 @@
} catch (RejectedExecutionException rejectedexecutionexception) {
this.disconnect((Component) Component.translatable("multiplayer.disconnect.server_shutdown"));
} catch (ClassCastException classcastexception) {
@@ -205,7 +316,7 @@
@@ -205,7 +317,7 @@
}
private static <T extends PacketListener> void genericsFtw(Packet<T> packet, PacketListener listener) {
@@ -201,7 +202,7 @@
}
private void validateListener(ProtocolInfo<?> state, PacketListener listener) {
@@ -418,12 +529,26 @@
@@ -418,12 +530,26 @@
}
}
@@ -228,7 +229,7 @@
}
if (!this.isConnected() && !this.disconnectionHandled) {
@@ -431,7 +556,7 @@
@@ -431,7 +557,7 @@
}
if (this.channel != null) {
@@ -237,7 +238,7 @@
}
if (this.tickCount++ % 20 == 0) {
@@ -464,12 +589,15 @@
@@ -464,12 +590,15 @@
}
public void disconnect(DisconnectionDetails disconnectionInfo) {
@@ -254,7 +255,7 @@
this.disconnectionDetails = disconnectionInfo;
}
@@ -537,7 +665,7 @@
@@ -537,7 +666,7 @@
}
public void configurePacketHandler(ChannelPipeline pipeline) {
@@ -263,7 +264,7 @@
public void write(ChannelHandlerContext channelhandlercontext, Object object, ChannelPromise channelpromise) throws Exception {
super.write(channelhandlercontext, object, channelpromise);
}
@@ -633,6 +761,7 @@
@@ -633,6 +762,7 @@
} else {
this.channel.pipeline().addAfter("prepender", "compress", new CompressionEncoder(compressionThreshold));
}
@@ -271,7 +272,7 @@
} else {
if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder) {
this.channel.pipeline().remove("decompress");
@@ -641,6 +770,7 @@
@@ -641,6 +771,7 @@
if (this.channel.pipeline().get("compress") instanceof CompressionEncoder) {
this.channel.pipeline().remove("compress");
}
@@ -279,7 +280,7 @@
}
}
@@ -660,7 +790,28 @@
@@ -660,7 +791,28 @@
});
packetlistener1.onDisconnect(disconnectiondetails);