netty-incubator-codec-quic:如何获取远程地址?

netty-incubator-codec-quic: How to get remoteAddress?

我需要知道服务器端的远程地址。我尝试了以下方法但失败了:

  1. QuicStreamChannel.remoteAddress() returns QuicStreamAddress,无法转换为 InetSocketAddressQuicStreamAddressQuicConnectionAddress 根本不包含远程 IP 地址或端口。
  2. class io.netty.buffer.PooledUnsafeDirectByteBuf 无法转换为 class io.netty.channel.socket.DatagramPacket 所以我无法使用 DatagramPacket.sender() 获取发件人地址。
  3. (QuicChannel) (ctx.channel().parent())).sslEngine().getPeerHost() -- 这个 returns 空。

您想拦截 QuicConnectionEvents。这些事件包含地址。请注意地址可能会更改(在这种情况下会触发新事件)。

new ChannelInboundHandlerAdapter() {

    @Override
    public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
        if (evt instanceof QuicConnectionEvent) {
            QuicConnectionEvent event = (QuicConnectionEvent) evt;
            System.out.println(event.newAddress());
        }
    }
};