face: Remove unnecessary use of DNS resolver in (Udp|Tcp|WebSocket)Factory
Change-Id: Idbc743fe4c7d567a09acccef98fe6de26f8295f0
Refs: #2422
diff --git a/daemon/face/tcp-factory.cpp b/daemon/face/tcp-factory.cpp
index 0a152b1..dc7e369 100644
--- a/daemon/face/tcp-factory.cpp
+++ b/daemon/face/tcp-factory.cpp
@@ -27,7 +27,6 @@
#include "core/logger.hpp"
#include "core/network-interface.hpp"
#include "core/global-io.hpp"
-#include <ndn-cxx/util/dns.hpp>
NFD_LOG_INIT("TcpFactory");
@@ -109,10 +108,10 @@
}
shared_ptr<TcpChannel>
-TcpFactory::createChannel(const std::string& localHost, const std::string& localPort)
+TcpFactory::createChannel(const std::string& localIp, const std::string& localPort)
{
- tcp::Endpoint endpoint(ndn::dns::syncResolve(localHost, getGlobalIoService()),
- boost::lexical_cast<uint16_t>(localPort));
+ using namespace boost::asio::ip;
+ tcp::Endpoint endpoint(address::from_string(localIp), boost::lexical_cast<uint16_t>(localPort));
return createChannel(endpoint);
}
diff --git a/daemon/face/tcp-factory.hpp b/daemon/face/tcp-factory.hpp
index e50bf66..c577854 100644
--- a/daemon/face/tcp-factory.hpp
+++ b/daemon/face/tcp-factory.hpp
@@ -67,17 +67,15 @@
createChannel(const tcp::Endpoint& localEndpoint);
/**
- * \brief Create TCP-based channel using specified host and port number
+ * \brief Create TCP-based channel using specified IP address and port number
*
- * This method will attempt to resolve the provided host and port numbers
- * and will throw TcpFactory::Error when channel cannot be created.
- *
- * Note that this call will **BLOCK** until resolution is done or failed.
+ * This method is just a helper that converts a string representation of localIp and port to
+ * tcp::Endpoint and calls the other createChannel overload.
*
* \throws TcpFactory::Error or std::runtime_error
*/
shared_ptr<TcpChannel>
- createChannel(const std::string& localHost, const std::string& localPort);
+ createChannel(const std::string& localIp, const std::string& localPort);
// from Factory
diff --git a/daemon/face/udp-factory.cpp b/daemon/face/udp-factory.cpp
index 4ef4e17..fcf1343 100644
--- a/daemon/face/udp-factory.cpp
+++ b/daemon/face/udp-factory.cpp
@@ -26,7 +26,6 @@
#include "udp-factory.hpp"
#include "core/global-io.hpp"
#include "core/network-interface.hpp"
-#include <ndn-cxx/util/dns.hpp>
#if defined(__linux__)
#include <sys/socket.h>
@@ -136,13 +135,13 @@
}
shared_ptr<UdpChannel>
-UdpFactory::createChannel(const std::string& localHost,
+UdpFactory::createChannel(const std::string& localIp,
const std::string& localPort,
const time::seconds& timeout)
{
- udp::Endpoint endPoint(ndn::dns::syncResolve(localHost, getGlobalIoService()),
- boost::lexical_cast<uint16_t>(localPort));
- return createChannel(endPoint, timeout);
+ using namespace boost::asio::ip;
+ udp::Endpoint endpoint(address::from_string(localIp), boost::lexical_cast<uint16_t>(localPort));
+ return createChannel(endpoint, timeout);
}
shared_ptr<MulticastUdpFace>
@@ -253,10 +252,11 @@
const std::string& multicastPort,
const std::string& networkInterfaceName /* "" */)
{
- udp::Endpoint localEndpoint(ndn::dns::syncResolve(localIp, getGlobalIoService()),
+ using namespace boost::asio::ip;
+ udp::Endpoint localEndpoint(address::from_string(localIp),
boost::lexical_cast<uint16_t>(multicastPort));
- udp::Endpoint multicastEndpoint(ndn::dns::syncResolve(multicastIp, getGlobalIoService()),
+ udp::Endpoint multicastEndpoint(address::from_string(multicastIp),
boost::lexical_cast<uint16_t>(multicastPort));
return createMulticastFace(localEndpoint, multicastEndpoint, networkInterfaceName);
diff --git a/daemon/face/udp-factory.hpp b/daemon/face/udp-factory.hpp
index db4760b..cfbd077 100644
--- a/daemon/face/udp-factory.hpp
+++ b/daemon/face/udp-factory.hpp
@@ -85,12 +85,10 @@
const time::seconds& timeout = time::seconds(600));
/**
- * \brief Create UDP-based channel using specified host and port number
+ * \brief Create UDP-based channel using specified IP address and port number
*
- * This method will attempt to resolve the provided host and port numbers
- * and will throw UdpFactory::Error when channel cannot be created.
- *
- * Note that this call will **BLOCK** until resolution is done or failed.
+ * This method is just a helper that converts a string representation of localIp and port to
+ * udp::Endpoint and calls the other createChannel overload.
*
* If localHost is a IPv6 address of a specific device, it must be in the form:
* ip address%interface name
@@ -101,7 +99,7 @@
* \throws UdpFactory::Error
*/
shared_ptr<UdpChannel>
- createChannel(const std::string& localHost,
+ createChannel(const std::string& localIp,
const std::string& localPort,
const time::seconds& timeout = time::seconds(600));
diff --git a/daemon/face/websocket-factory.cpp b/daemon/face/websocket-factory.cpp
index 49f28b0..d4c8d3f 100644
--- a/daemon/face/websocket-factory.cpp
+++ b/daemon/face/websocket-factory.cpp
@@ -24,7 +24,6 @@
*/
#include "websocket-factory.hpp"
-#include <ndn-cxx/util/dns.hpp>
namespace nfd {
@@ -51,11 +50,10 @@
}
shared_ptr<WebSocketChannel>
-WebSocketFactory::createChannel(const std::string& host, const std::string& port)
+WebSocketFactory::createChannel(const std::string& localIp, const std::string& port)
{
- ip::tcp::endpoint tcpEndpoint(ndn::dns::syncResolve(host, getGlobalIoService()),
- boost::lexical_cast<uint16_t>(port));
- websocket::Endpoint endpoint(tcpEndpoint.address(), tcpEndpoint.port());
+ using namespace boost::asio::ip;
+ websocket::Endpoint endpoint(address::from_string(localIp), boost::lexical_cast<uint16_t>(port));
return createChannel(endpoint);
}
diff --git a/daemon/face/websocket-factory.hpp b/daemon/face/websocket-factory.hpp
index d3a6324..eec0e60 100644
--- a/daemon/face/websocket-factory.hpp
+++ b/daemon/face/websocket-factory.hpp
@@ -70,12 +70,15 @@
createChannel(const websocket::Endpoint& localEndpoint);
/**
- * \brief Create WebSocket-based channel using specified ip address and port number
+ * \brief Create WebSocket-based channel using specified IP address and port number
+ *
+ * This method is just a helper that converts a string representation of localIp and port to
+ * websocket::Endpoint and calls the other createChannel overload.
*
* \throws WebSocketFactory::Error
*/
shared_ptr<WebSocketChannel>
- createChannel(const std::string& ipAddress, const std::string& port);
+ createChannel(const std::string& localIp, const std::string& port);
// from Factory
virtual void