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.osgi.framework.InvalidSyntaxException;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
19 * Opens TCP port specified in config.ini, creates bridge between this port and local netconf server.
21 public class NetconfTCPProvider {
22 private static final Logger LOG = LoggerFactory.getLogger(NetconfTCPProvider.class);
24 private final NetconfConfiguration netconfConfiguration;
25 private ProxyServer proxyServer;
27 public NetconfTCPProvider(final NetconfConfiguration netconfConfiguration) {
28 this.netconfConfiguration = netconfConfiguration;
31 // Called via blueprint
32 @SuppressWarnings("unused")
33 public void init() throws InvalidSyntaxException {
34 final InetSocketAddress address = netconfConfiguration.getTcpServerAddress();
36 if (address.getAddress().isAnyLocalAddress()) {
37 LOG.warn("Unprotected netconf TCP address is configured to ANY "
38 + "local address. This is a security risk. Consider "
39 + "changing tcp-address in netconf.cfg to 127.0.0.1");
41 LOG.info("Starting TCP netconf server at {}", address);
42 proxyServer = new ProxyServer(address, NetconfConfiguration.NETCONF_LOCAL_ADDRESS);
45 // Called via blueprint
46 @SuppressWarnings("unused")
47 public void destroy() {
48 if (proxyServer != null) {