<type>xml</type>
<classifier>features</classifier>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-tcp</artifactId>
- <version>${project.version}</version>
- </dependency>
</dependencies>
</project>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>netconf-tcp</artifactId>
+ <artifactId>mdsal-netconf-tcp</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<relativePath>../netconf-parent</relativePath>
</parent>
- <groupId>org.opendaylight.netconf</groupId>
<artifactId>mdsal-netconf-tcp</artifactId>
<version>1.6.0-SNAPSHOT</version>
<name>${project.artifactId}</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>netconf-tcp</artifactId>
+ <artifactId>netconf-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>netconf-util</artifactId>
</dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Embed-Dependency>netconf-tcp</Embed-Dependency>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
private final ChannelFuture tcpServer;
- public NetconfNorthboundTcpServer(final NetconfServerDispatcher netconfServerDispatcher,
- final String address,
- final String port) {
- InetSocketAddress inetAddress = getInetAddress(address, port);
+ public NetconfNorthboundTcpServer(final NetconfServerDispatcher netconfServerDispatcher, final String address,
+ final String port) {
+ final InetSocketAddress inetAddress = getInetAddress(address, port);
tcpServer = netconfServerDispatcher.createServer(inetAddress);
tcpServer.addListener(future -> {
if (future.isDone() && future.isSuccess()) {
}
private static InetSocketAddress getInetAddress(final String bindingAddress, final String portNumber) {
- IpAddress ipAddress = IpAddressBuilder.getDefaultInstance(bindingAddress);
+ final IpAddress ipAddress = IpAddressBuilder.getDefaultInstance(bindingAddress);
final InetAddress inetAd = IetfInetUtil.INSTANCE.inetAddressFor(ipAddress);
return new InetSocketAddress(inetAd, Integer.parseInt(portNumber));
}
<artifactId>netconf-ssh</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-tcp</artifactId>
- <version>${project.version}</version>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netconf-testtool</artifactId>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- ~
- ~ This program and the accompanying materials are made available under the
- ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
- ~ and is available at http://www.eclipse.org/legal/epl-v10.html
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-parent</artifactId>
- <version>1.6.0-SNAPSHOT</version>
- <relativePath>../netconf-parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-tcp</artifactId>
- <version>1.6.0-SNAPSHOT</version>
- <name>${project.artifactId}</name>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-api</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>mockito-configuration</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- </dependencies>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netconf.tcp;
-
-import java.net.InetSocketAddress;
-import org.opendaylight.netconf.tcp.netty.ProxyServer;
-import org.opendaylight.netconf.util.NetconfConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Opens TCP port specified in config.ini, creates bridge between this port and local netconf server.
- */
-public class NetconfTCPProvider {
- private static final Logger LOG = LoggerFactory.getLogger(NetconfTCPProvider.class);
-
- private final NetconfConfiguration netconfConfiguration;
- private ProxyServer proxyServer;
-
- public NetconfTCPProvider(final NetconfConfiguration netconfConfiguration) {
- this.netconfConfiguration = netconfConfiguration;
- }
-
- // Called via blueprint
- @SuppressWarnings("unused")
- public void init() {
- final InetSocketAddress address = netconfConfiguration.getTcpServerAddress();
-
- if (address.getAddress().isAnyLocalAddress()) {
- LOG.warn("Unprotected netconf TCP address is configured to ANY "
- + "local address. This is a security risk. Consider "
- + "changing tcp-address in netconf.cfg to 127.0.0.1");
- }
- LOG.info("Starting TCP netconf server at {}", address);
- proxyServer = new ProxyServer(address, NetconfConfiguration.NETCONF_LOCAL_ADDRESS);
- }
-
- // Called via blueprint
- @SuppressWarnings("unused")
- public void destroy() {
- if (proxyServer != null) {
- proxyServer.close();
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.netconf.tcp.netty;
-
-import static com.google.common.base.Preconditions.checkState;
-
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-class ProxyClientHandler extends ChannelInboundHandlerAdapter {
- private static final Logger LOG = LoggerFactory.getLogger(ProxyClientHandler.class);
-
- private final ChannelHandlerContext remoteCtx;
- private ChannelHandlerContext localCtx;
-
- ProxyClientHandler(ChannelHandlerContext remoteCtx) {
- this.remoteCtx = remoteCtx;
- }
-
- @Override
- public void channelActive(ChannelHandlerContext ctx) {
- checkState(this.localCtx == null);
- LOG.trace("Client channel active");
- this.localCtx = ctx;
- }
-
- @Override
- public void channelRead(ChannelHandlerContext ctx, Object msg) {
- LOG.trace("Forwarding message");
- remoteCtx.write(msg);
- }
-
- @Override
- public void channelReadComplete(ChannelHandlerContext ctx) {
- LOG.trace("Flushing remote ctx");
- remoteCtx.flush();
- }
-
- @Override
- public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
- // Close the connection when an exception is raised.
- LOG.warn("Unexpected exception from downstream", cause);
- checkState(this.localCtx.equals(ctx));
- ctx.close();
- }
-
- // called both when local or remote connection dies
- @Override
- public void channelInactive(ChannelHandlerContext ctx) {
- LOG.trace("channelInactive() called, closing remote client ctx");
- remoteCtx.close();
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netconf.tcp.netty;
-
-import io.netty.bootstrap.Bootstrap;
-import io.netty.bootstrap.ServerBootstrap;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.EventLoopGroup;
-import io.netty.channel.local.LocalAddress;
-import io.netty.channel.local.LocalChannel;
-import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.SocketChannel;
-import io.netty.channel.socket.nio.NioServerSocketChannel;
-import io.netty.handler.logging.LogLevel;
-import io.netty.handler.logging.LoggingHandler;
-import java.net.InetSocketAddress;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ProxyServer implements AutoCloseable {
- private static final Logger LOG = LoggerFactory.getLogger(ProxyServer.class);
-
- private final EventLoopGroup bossGroup = new NioEventLoopGroup();
- private final EventLoopGroup workerGroup = new NioEventLoopGroup();
- private final ChannelFuture channelFuture;
-
- @SuppressWarnings("checkstyle:IllegalCatch")
- public ProxyServer(InetSocketAddress address, final LocalAddress localAddress) {
- // Configure the server.
- final Bootstrap clientBootstrap = new Bootstrap();
- clientBootstrap.group(bossGroup).channel(LocalChannel.class);
-
- ServerBootstrap serverBootstrap = new ServerBootstrap();
- serverBootstrap.group(bossGroup, workerGroup)
- .channel(NioServerSocketChannel.class)
- .handler(new LoggingHandler(LogLevel.DEBUG))
- .childHandler(new ChannelInitializer<SocketChannel>() {
- @Override
- public void initChannel(SocketChannel ch) {
- ch.pipeline().addLast(new ProxyServerHandler(clientBootstrap, localAddress));
- }
- });
-
- // Start the server.
- try {
- channelFuture = serverBootstrap.bind(address).syncUninterruptibly();
- } catch (Throwable throwable) {
- // sync() re-throws exceptions declared as Throwable, so the compiler doesn't see them
- LOG.error("Error while binding to address {}", address, throwable);
- throw throwable;
- }
- }
-
- @Override
- public void close() {
- channelFuture.channel().close();
- bossGroup.shutdownGracefully();
- workerGroup.shutdownGracefully();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.netconf.tcp.netty;
-
-import io.netty.bootstrap.Bootstrap;
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.local.LocalAddress;
-import io.netty.channel.local.LocalChannel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ProxyServerHandler extends ChannelInboundHandlerAdapter {
- private static final Logger LOG = LoggerFactory.getLogger(ProxyServerHandler.class);
- private final Bootstrap clientBootstrap;
- private final LocalAddress localAddress;
-
- private Channel clientChannel;
-
- public ProxyServerHandler(Bootstrap clientBootstrap, LocalAddress localAddress) {
- this.clientBootstrap = clientBootstrap;
- this.localAddress = localAddress;
- }
-
- @Override
- public void channelActive(ChannelHandlerContext remoteCtx) {
- final ProxyClientHandler clientHandler = new ProxyClientHandler(remoteCtx);
- clientBootstrap.handler(new ChannelInitializer<LocalChannel>() {
- @Override
- public void initChannel(LocalChannel ch) {
- ch.pipeline().addLast(clientHandler);
- }
- });
- ChannelFuture clientChannelFuture = clientBootstrap.connect(localAddress).awaitUninterruptibly();
- clientChannel = clientChannelFuture.channel();
- }
-
- @Override
- public void channelInactive(ChannelHandlerContext ctx) {
- LOG.trace("channelInactive - closing client channel");
- clientChannel.close();
- }
-
- @Override
- public void channelRead(ChannelHandlerContext ctx, final Object msg) {
- LOG.trace("Writing to client channel");
- clientChannel.write(msg);
- }
-
- @Override
- public void channelReadComplete(ChannelHandlerContext ctx) {
- LOG.trace("Flushing client channel");
- clientChannel.flush();
- }
-
- @Override
- public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
- // Close the connection when an exception is raised.
- LOG.warn("Unexpected exception from downstream.", cause);
- ctx.close();
- }
-}
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2017 Inocybe Technologies Inc. and others. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
- odl:use-default-for-reference-types="true">
-
- <reference id="netconfConfiguration"
- interface="org.opendaylight.netconf.util.NetconfConfiguration" />
-
- <bean id="netconfTcpProvider" class="org.opendaylight.netconf.tcp.NetconfTCPProvider"
- init-method="init" destroy-method="destroy">
- <argument ref="netconfConfiguration" />
- </bean>
-
-</blueprint>
<module>netconf-netty-util</module>
<module>netconf-mapping-api</module>
<module>netconf-client</module>
- <module>netconf-tcp</module>
<module>netconf-auth</module>
<module>aaa-authn-odl-plugin</module>
<module>netconf-notifications-impl</module>