- // TODO(HONEYCOMB-414): the logic below is very similar to
- // org.opendaylight.netconf.ssh.NetconfNorthboundSshServer (introduced in Carbon), so consider reusing it
- // (requires fixing hardcoded private key path).
- final InetAddress sshBindingAddress = InetAddresses.forString(cfgAttributes.netconfSshBindingAddress.get());
- final InetSocketAddress bindingAddress =
- new InetSocketAddress(sshBindingAddress, cfgAttributes.netconfSshBindingPort.get());
-
- LocalAddress localAddress = new LocalAddress(cfgAttributes.netconfSshBindingPort.toString());
- ChannelFuture localServer = dispatcher.createLocalServer(localAddress);
-
- final SshProxyServer sshProxyServer = new SshProxyServer(pool, nettyThreadgroup, GlobalEventExecutor.INSTANCE);
-
- final SshProxyServerConfigurationBuilder sshConfigBuilder = new SshProxyServerConfigurationBuilder();
- sshConfigBuilder.setBindingAddress(bindingAddress);
- sshConfigBuilder.setLocalAddress(localAddress);
- // Only simple authProvider checking ConfigAttributes, checking the config file
- sshConfigBuilder.setAuthenticator(new SimplelAuthProvider(credentialsCfg));
- sshConfigBuilder.setIdleTimeout(Integer.MAX_VALUE);
- sshConfigBuilder.setKeyPairProvider(new PEMGeneratorHostKeyProvider(DEFAULT_PRIVATE_KEY_PATH,
- DEFAULT_ALGORITHM, DEFAULT_KEY_SIZE));
-
- localServer.addListener(new SshServerBinder(sshProxyServer, sshConfigBuilder, bindingAddress));
-
- return new NetconfSshServer(localServer, sshProxyServer);
- }
-
- public static final class NetconfSshServer {
- private ChannelFuture localServer;
- private SshProxyServer sshProxyServer;
-
- NetconfSshServer(final ChannelFuture localServer,
- final SshProxyServer sshProxyServer) {
- this.localServer = localServer;
- this.sshProxyServer = sshProxyServer;
- }
-
- public Object getLocalServer() {
- return localServer;
- }
-
- public Object getSshProxyServer() {
- return sshProxyServer;
- }
+ final NetconfNorthboundSshServer netconfServer = new NetconfNorthboundSshServer(dispatcher, nettyThreadgroup,
+ GlobalEventExecutor.INSTANCE, cfgAttributes.netconfSshBindingAddress.get(),
+ cfgAttributes.netconfSshBindingPort.get().toString(), new SimplelAuthProvider(credentialsCfg));
+ shutdownHandler.register("netconf-northbound-ssh-server", netconfServer::close);
+ return netconfServer;