2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.netconf.tcp;
11 import java.net.InetSocketAddress;
12 import org.opendaylight.netconf.tcp.netty.ProxyServer;
13 import org.opendaylight.netconf.util.NetconfConfiguration;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
18 * Opens TCP port specified in config.ini, creates bridge between this port and local netconf server.
20 public class NetconfTCPProvider {
21 private static final Logger LOG = LoggerFactory.getLogger(NetconfTCPProvider.class);
23 private final NetconfConfiguration netconfConfiguration;
24 private ProxyServer proxyServer;
26 public NetconfTCPProvider(final NetconfConfiguration netconfConfiguration) {
27 this.netconfConfiguration = netconfConfiguration;
30 // Called via blueprint
31 @SuppressWarnings("unused")
33 final InetSocketAddress address = netconfConfiguration.getTcpServerAddress();
35 if (address.getAddress().isAnyLocalAddress()) {
36 LOG.warn("Unprotected netconf TCP address is configured to ANY "
37 + "local address. This is a security risk. Consider "
38 + "changing tcp-address in netconf.cfg to 127.0.0.1");
40 LOG.info("Starting TCP netconf server at {}", address);
41 proxyServer = new ProxyServer(address, NetconfConfiguration.NETCONF_LOCAL_ADDRESS);
44 // Called via blueprint
45 @SuppressWarnings("unused")
46 public void destroy() {
47 if (proxyServer != null) {