in dubbo-remoting-extensions/dubbo-remoting-quic/src/main/java/org/apache/dubbo/remoting/transport/quic/QuicNettyServer.java [88:132]
protected void doOpen() throws Throwable {
bossGroup = QuicNettyEventLoopFactory.eventLoopGroup(1, "QuicNettyServerBoss");
final QuicNettyServerHandler nettyServerHandler = new QuicNettyServerHandler(getUrl(), this);
channels = nettyServerHandler.getChannels();
SelfSignedCertificate selfSignedCertificate = new SelfSignedCertificate();
QuicSslContext context = QuicSslContextBuilder.forServer(
selfSignedCertificate.privateKey(), null, selfSignedCertificate.certificate())
.applicationProtocols("http/0.9").build();
bootstrap = new Bootstrap();
io.netty.channel.ChannelHandler codec = new QuicServerCodecBuilder()
.sslContext(context)
.maxIdleTimeout(5000, TimeUnit.MILLISECONDS)
.initialMaxData(10000000)
.initialMaxStreamDataBidirectionalLocal(1000000)
.initialMaxStreamDataBidirectionalRemote(1000000)
.initialMaxStreamsBidirectional(100)
.initialMaxStreamsUnidirectional(100)
.tokenHandler(InsecureQuicTokenHandler.INSTANCE)
.streamHandler(new ChannelInitializer<QuicStreamChannel>() {
@Override
protected void initChannel(QuicStreamChannel ch) {
int idleTimeout = UrlUtils.getIdleTimeout(getUrl());
NettyCodecAdapter adapter = new NettyCodecAdapter(getCodec(), getUrl(), QuicNettyServer.this);
ch.pipeline()
.addLast("decoder", adapter.getDecoder())
.addLast("encoder", adapter.getEncoder())
.addLast("server-idle-handler", new IdleStateHandler(0, 0, idleTimeout, TimeUnit.MILLISECONDS))
.addLast("handler", nettyServerHandler);
}
}).build();
InetSocketAddress address = getBindAddress();
logger.info("bind address:" + address);
ChannelFuture channelFuture = bootstrap.group(bossGroup)
.channel(NioDatagramChannel.class)
.handler(codec)
.bind(address);
channelFuture.addListener((ChannelFutureListener) channelFuture1 -> logger.info("bind finish:" + channelFuture1));
}