Reputation: 397
I need to know the remote address at the server side. I tried bellow ways and failed:
QuicStreamChannel.remoteAddress()
returns QuicStreamAddress
, which cannot be casted to InetSocketAddress
. QuicStreamAddress
or QuicConnectionAddress
does not contain remote IP address or port at all.io.netty.buffer.PooledUnsafeDirectByteBuf
cannot be cast to class io.netty.channel.socket.DatagramPacket
so I cannot use DatagramPacket.sender()
to get the sender address.(QuicChannel) (ctx.channel().parent())).sslEngine().getPeerHost()
-- this returns null.Upvotes: 0
Views: 286
Reputation: 23557
You want to intercept QuicConnectionEvent
s. These events contain the address. Be aware that the address can change (in this case a new event is fired).
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());
}
}
};
Upvotes: 1