From ffc31d243b27116c7e4f306a488ceb35a5cff85d Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 20 Sep 2023 02:14:17 +0200 Subject: [PATCH] Fix ServerFactoryManagerConfigurator-less createSshServer() We need to tell the server that we support the NETCONF subsystem, achieve that through sharing codepaths. JIRA: NETCONF-1106 Change-Id: I94ff50ea1963a40b9fd4eae9afdc3f45f8e20564 Signed-off-by: Robert Varga --- .../netconf/server/NetconfServerFactoryImpl.java | 15 ++++----------- .../netconf/server/api/NetconfServerFactory.java | 8 ++++++-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/NetconfServerFactoryImpl.java b/protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/NetconfServerFactoryImpl.java index a27c260100..d0b68c484a 100644 --- a/protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/NetconfServerFactoryImpl.java +++ b/protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/NetconfServerFactoryImpl.java @@ -16,7 +16,6 @@ import io.netty.util.concurrent.DefaultPromise; import io.netty.util.concurrent.EventExecutor; import io.netty.util.concurrent.GlobalEventExecutor; import java.util.List; -import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.netconf.server.api.NetconfServerFactory; import org.opendaylight.netconf.shaded.sshd.server.SshServer; @@ -54,22 +53,12 @@ public final class NetconfServerFactoryImpl implements NetconfServerFactory { transportChannelListener = new ChannelInitializerListener(channelInitializer, executor); } - @NonNull protected ServerBootstrap createBootstrap() { - return NettyTransportSupport.newServerBootstrap().group(parentGroup, workerGroup); - } - @Override public ListenableFuture createTcpServer(final TcpServerGrouping params) throws UnsupportedConfigurationException { return TCPServer.listen(transportChannelListener, createBootstrap(), params); } - @Override - public ListenableFuture createSshServer(final TcpServerGrouping tcpParams, - final SshServerGrouping sshParams) throws UnsupportedConfigurationException { - return SSHServer.listen(EMPTY_LISTENER, createBootstrap(), tcpParams, sshParams); - } - @Override public ListenableFuture createSshServer(final TcpServerGrouping tcpParams, final SshServerGrouping sshParams, final ServerFactoryManagerConfigurator configurator) @@ -86,6 +75,10 @@ public final class NetconfServerFactoryImpl implements NetconfServerFactory { }); } + private ServerBootstrap createBootstrap() { + return NettyTransportSupport.newServerBootstrap().group(parentGroup, workerGroup); + } + private record ChannelInitializerListener( @Nullable ServerChannelInitializer channelInitializer, @Nullable EventExecutor executor) implements TransportChannelListener { diff --git a/protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/api/NetconfServerFactory.java b/protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/api/NetconfServerFactory.java index 1e7de53abf..ac72bd8e6e 100644 --- a/protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/api/NetconfServerFactory.java +++ b/protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/api/NetconfServerFactory.java @@ -7,6 +7,8 @@ */ package org.opendaylight.netconf.server.api; +import static java.util.Objects.requireNonNull; + import com.google.common.util.concurrent.ListenableFuture; import org.opendaylight.netconf.transport.api.UnsupportedConfigurationException; import org.opendaylight.netconf.transport.ssh.SSHServer; @@ -38,8 +40,10 @@ public interface NetconfServerFactory { * @throws UnsupportedConfigurationException if server cannot be started using given configuration * @throws NullPointerException if either tcpParams or sshParams is null */ - ListenableFuture createSshServer(TcpServerGrouping tcpParams, SshServerGrouping sshParams) - throws UnsupportedConfigurationException; + default ListenableFuture createSshServer(final TcpServerGrouping tcpParams, + final SshServerGrouping sshParams) throws UnsupportedConfigurationException { + return createSshServer(tcpParams, requireNonNull(sshParams), null); + } /** * Build SSH Netconf server with integration support. -- 2.36.6