diff --git a/pom.xml b/pom.xml
index edc32d6..b35e6c8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -45,7 +45,7 @@
io.netty.incubator
netty-incubator-codec-native-quic
- 0.0.57.Final
+ 0.0.59.Final
linux-x86_64
diff --git a/src/main/java/org/nethergames/proxytransport/integration/CustomClientEventHandler.java b/src/main/java/org/nethergames/proxytransport/integration/CustomClientEventHandler.java
index d8e9415..66ee26a 100644
--- a/src/main/java/org/nethergames/proxytransport/integration/CustomClientEventHandler.java
+++ b/src/main/java/org/nethergames/proxytransport/integration/CustomClientEventHandler.java
@@ -1,7 +1,9 @@
package org.nethergames.proxytransport.integration;
import dev.waterdog.waterdogpe.network.connection.client.ClientConnection;
+import dev.waterdog.waterdogpe.network.connection.handler.ReconnectReason;
import dev.waterdog.waterdogpe.player.ProxiedPlayer;
+import dev.waterdog.waterdogpe.utils.types.TranslationContainer;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
@@ -27,9 +29,14 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E
return;
}
- this.player.getLogger().warning("[" + connection.getSocketAddress() + "|" + this.player.getName() + "] - Exception in connection caught", cause);
- this.player.onDownstreamTimeout(this.connection.getServerInfo());
-
+ this.player.getLogger().warning("[" + connection.getSocketAddress() + "|" + this.player.getName() + "] - exception caught", cause);
this.connection.disconnect();
+
+ TranslationContainer msg = new TranslationContainer("waterdog.downstream.down", this.connection.getServerInfo().getServerName(), cause.getMessage());
+ if (this.player.sendToFallback(this.connection.getServerInfo(), ReconnectReason.EXCEPTION, cause.getMessage())) {
+ this.player.sendMessage(msg);
+ } else {
+ this.player.disconnect(msg);
+ }
}
}
\ No newline at end of file
diff --git a/src/main/java/org/nethergames/proxytransport/integration/QuicTransportServerInfo.java b/src/main/java/org/nethergames/proxytransport/integration/QuicTransportServerInfo.java
index 536a954..fba29d0 100644
--- a/src/main/java/org/nethergames/proxytransport/integration/QuicTransportServerInfo.java
+++ b/src/main/java/org/nethergames/proxytransport/integration/QuicTransportServerInfo.java
@@ -1,5 +1,6 @@
package org.nethergames.proxytransport.integration;
+import dev.waterdog.waterdogpe.logger.MainLogger;
import dev.waterdog.waterdogpe.network.connection.client.ClientConnection;
import dev.waterdog.waterdogpe.network.serverinfo.ServerInfo;
import dev.waterdog.waterdogpe.network.serverinfo.ServerInfoType;
@@ -51,8 +52,9 @@ public Future createConnection(ProxiedPlayer proxiedPlayer) {
EventLoop eventLoop = proxiedPlayer.getProxy().getWorkerEventLoopGroup().next();
Promise promise = eventLoop.newPromise();
- this.createServerConnection(eventLoop, this.getAddress()).addListener((Future future) -> {
+ this.createServerConnection(eventLoop, proxiedPlayer.getLogger(), this.getAddress()).addListener((Future future) -> {
if (future.isSuccess()) {
+ proxiedPlayer.getLogger().debug("Creating stream for " + this.getServerName() + " server");
QuicChannel quicChannel = future.getNow();
quicChannel.createStream(QuicStreamType.BIDIRECTIONAL, new TransportChannelInitializer(proxiedPlayer, this, promise)).addListener((Future streamFuture) -> {
@@ -69,13 +71,15 @@ public Future createConnection(ProxiedPlayer proxiedPlayer) {
return promise;
}
- private Future createServerConnection(EventLoopGroup eventLoopGroup, InetSocketAddress address) {
+ private Future createServerConnection(EventLoopGroup eventLoopGroup, MainLogger logger, InetSocketAddress address) {
EventLoop eventLoop = eventLoopGroup.next();
if (this.serverConnections.containsKey(address)) {
+ logger.info("Reusing connection to " + address + " for " + this.getServerName() + " server");
return this.serverConnections.get(address);
}
+ logger.info("Creating connection to " + address + " for " + this.getServerName() + " server");
Promise promise = eventLoop.newPromise();
this.serverConnections.put(address, promise);
@@ -96,25 +100,35 @@ private Future createServerConnection(EventLoopGroup eventLoopGroup
QuicChannel.newBootstrap(channelFuture.channel())
.streamHandler(new ChannelInboundHandlerAdapter() {
@Override
- public void channelActive(ChannelHandlerContext ctx) {
+ public void channelActive(ChannelHandlerContext ctx) throws Exception {
ctx.close();
}
})
.remoteAddress(address)
+ .option(QuicChannelOption.QLOG, new QLogConfiguration("/" + this.getServerName() + "-" + System.currentTimeMillis() + ".qlog", this.getServerName(), this.getServerName()))
.connect().addListener((Future quicChannelFuture) -> {
if (quicChannelFuture.isSuccess()) {
+ logger.debug("Connection to " + address + " for " + this.getServerName() + " server established");
+
QuicChannel quicChannel = quicChannelFuture.getNow();
- quicChannel.closeFuture().addListener(f -> serverConnections.remove(address));
+ quicChannel.closeFuture().addListener(f -> {
+ logger.debug("Connection to " + address + " for " + this.getServerName() + " server closed");
+ this.serverConnections.remove(address);
+ });
promise.trySuccess(quicChannel);
} else {
+ logger.warning("Connection to " + address + " for " + this.getServerName() + " server failed");
+
promise.tryFailure(quicChannelFuture.cause());
channelFuture.channel().close();
+ this.serverConnections.remove(address);
}
});
} else {
promise.tryFailure(channelFuture.cause());
channelFuture.channel().close();
+ this.serverConnections.remove(address);
}
});