face: process face_system.unix config section in UnixStreamFactory

refs #3904

Change-Id: I8f8772054ece2971758efd0599ef06fd3b778735
diff --git a/daemon/face/face-system.cpp b/daemon/face/face-system.cpp
index 8433a16..b084220 100644
--- a/daemon/face/face-system.cpp
+++ b/daemon/face/face-system.cpp
@@ -51,6 +51,10 @@
 {
   ///\todo #3904 make a registry, and construct instances from registry
   m_factories["tcp"] = make_shared<TcpFactory>();
+
+#ifdef HAVE_UNIX_SOCKETS
+  m_factories["unix"] = make_shared<UnixStreamFactory>();
+#endif // HAVE_UNIX_SOCKETS
 }
 
 std::set<const ProtocolFactory*>
@@ -127,10 +131,7 @@
     ///\todo #3521 nicfaces
 
     ///\todo #3904 process these in protocol factory
-    if (sectionName == "unix") {
-      processSectionUnix(subSection, isDryRun);
-    }
-    else if (sectionName == "udp") {
+    if (sectionName == "udp") {
       processSectionUdp(subSection, isDryRun, context.m_nicList);
     }
     else if (sectionName == "ether") {
@@ -146,45 +147,6 @@
 }
 
 void
-FaceSystem::processSectionUnix(const ConfigSection& configSection, bool isDryRun)
-{
-  // ; the unix section contains settings of Unix stream faces and channels
-  // unix
-  // {
-  //   path /var/run/nfd.sock ; Unix stream listener path
-  // }
-
-#if defined(HAVE_UNIX_SOCKETS)
-  std::string path = "/var/run/nfd.sock";
-
-  for (const auto& i : configSection) {
-    if (i.first == "path") {
-      path = i.second.get_value<std::string>();
-    }
-    else {
-      BOOST_THROW_EXCEPTION(ConfigFile::Error("Unrecognized option \"" +
-                                              i.first + "\" in \"unix\" section"));
-    }
-  }
-
-  if (!isDryRun) {
-    if (m_factoryByScheme.count("unix") > 0) {
-      return;
-    }
-
-    auto factory = make_shared<UnixStreamFactory>();
-    m_factoryByScheme.emplace("unix", factory);
-
-    auto channel = factory->createChannel(path);
-    channel->listen(bind(&FaceTable::add, &m_faceTable, _1), nullptr);
-  }
-#else
-  BOOST_THROW_EXCEPTION(ConfigFile::Error("NFD was compiled without Unix sockets support, "
-                                          "cannot process \"unix\" section"));
-#endif // HAVE_UNIX_SOCKETS
-}
-
-void
 FaceSystem::processSectionUdp(const ConfigSection& configSection, bool isDryRun,
                               const std::vector<NetworkInterfaceInfo>& nicList)
 {