tools: delete nfdId from 'nfdc status' output
refs #4089
Change-Id: I95f8a4346b2c4601acdc63daac20259b076a1d7e
diff --git a/tests/tools/nfdc/forwarder-general-module.t.cpp b/tests/tools/nfdc/forwarder-general-module.t.cpp
index f97d36d..b621bb4 100644
--- a/tests/tools/nfdc/forwarder-general-module.t.cpp
+++ b/tests/tools/nfdc/forwarder-general-module.t.cpp
@@ -24,10 +24,11 @@
*/
#include "nfdc/forwarder-general-module.hpp"
-#include <ndn-cxx/security/signing-helpers.hpp>
#include "status-fixture.hpp"
+#include <ndn-cxx/security/signing-helpers.hpp>
+
namespace nfd {
namespace tools {
namespace nfdc {
@@ -36,38 +37,8 @@
BOOST_AUTO_TEST_SUITE(Nfdc)
BOOST_FIXTURE_TEST_SUITE(TestForwarderGeneralModule, StatusFixture<ForwarderGeneralModule>)
-// class MakeNfdIdCollector
-// {
-// public:
-// unique_ptr<NfdIdCollector>
-// operator()(Face&, KeyChain&) const
-// {
-// return make_unique<NfdIdCollector>(make_unique<ValidatorNull>());
-// };
-// };
-
-class ForwarderGeneralStatusFixture : public StatusFixture<ForwarderGeneralModule>
-{
-protected:
- ForwarderGeneralStatusFixture()
- {
- // module.setNfdIdCollector(*validator);
-
- BOOST_REQUIRE(this->addIdentity("/nfd-status/test-nfdid",
- ndn::EcKeyParams(name::Component("KEYID"))));
- }
-
-private:
- void
- signDatasetReply(Data& data) override
- {
- m_keyChain.sign(data, ndn::security::signingByIdentity("/nfd-status/test-nfdid"));
- }
-};
-
const std::string STATUS_XML = stripXmlSpaces(R"XML(
<generalStatus>
- <nfdId>/nfdId-unavailable</nfdId>
<version>0.4.1-1-g704430c</version>
<startTime>2016-06-24T15:13:46.856000</startTime>
<currentTime>2016-07-17T17:55:54.109000</currentTime>
@@ -94,7 +65,6 @@
const std::string STATUS_TEXT = std::string(R"TEXT(
General NFD status:
- nfdId=/nfdId-unavailable
version=0.4.1-1-g704430c
startTime=20160624T151346.856000
currentTime=20160717T175554.109000
@@ -112,7 +82,7 @@
nOutNacks=26762
)TEXT").substr(1);
-BOOST_FIXTURE_TEST_CASE(Status, ForwarderGeneralStatusFixture)
+BOOST_AUTO_TEST_CASE(Status)
{
this->fetchStatus();
ForwarderStatus payload;
diff --git a/tools/nfd-status-http-server-files/nfd-status.xsl b/tools/nfd-status-http-server-files/nfd-status.xsl
index 92a0488..843e4f2 100644
--- a/tools/nfd-status-http-server-files/nfd-status.xsl
+++ b/tools/nfd-status-http-server-files/nfd-status.xsl
@@ -22,7 +22,7 @@
<xsl:variable name="version">
<xsl:apply-templates select="nfd:nfdStatus/nfd:generalStatus/nfd:version"/>
</xsl:variable>
- <span class="grey">Powered by </span><a target="_blank" href="http://named-data.net/doc/NFD/"><span class="green">NFD version <xsl:value-of select="$version"/></span></a><span class="grey">.</span>
+ <span class="grey">Powered by </span><a target="_blank" href="https://named-data.net/doc/NFD/"><span class="green">NFD version <xsl:value-of select="$version"/></span></a><span class="grey">.</span>
</footer>
</body>
</html>
@@ -73,7 +73,6 @@
<table class="item-list">
<thead>
<tr>
- <th>NFD ID</th>
<th>Version</th>
<th>Start time</th>
<th>Current time</th>
@@ -93,7 +92,6 @@
</thead>
<tbody>
<tr class="center">
- <td><xsl:apply-templates select="nfd:nfdId"/></td>
<td><xsl:value-of select="nfd:version"/></td>
<td><xsl:call-template name="formatDate"><xsl:with-param name="date" select="nfd:startTime" /></xsl:call-template></td>
<td><xsl:call-template name="formatDate"><xsl:with-param name="date" select="nfd:currentTime" /></xsl:call-template></td>
diff --git a/tools/nfdc/forwarder-general-module.cpp b/tools/nfdc/forwarder-general-module.cpp
index ee3e0af..e490892 100644
--- a/tools/nfdc/forwarder-general-module.cpp
+++ b/tools/nfdc/forwarder-general-module.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
@@ -30,11 +30,6 @@
namespace tools {
namespace nfdc {
-ForwarderGeneralModule::ForwarderGeneralModule()
- : m_nfdIdCollector(nullptr)
-{
-}
-
void
ForwarderGeneralModule::fetchStatus(Controller& controller,
const function<void()>& onSuccess,
@@ -55,30 +50,17 @@
return status.getCurrentTimestamp() - status.getStartTimestamp();
}
-const Name&
-ForwarderGeneralModule::getNfdId() const
-{
- if (m_nfdIdCollector != nullptr && m_nfdIdCollector->hasNfdId()) {
- return m_nfdIdCollector->getNfdId();
- }
-
- static Name unavailable("/nfdId-unavailable");
- return unavailable;
-}
-
void
ForwarderGeneralModule::formatStatusXml(std::ostream& os) const
{
- this->formatItemXml(os, m_status, this->getNfdId());
+ this->formatItemXml(os, m_status);
}
void
-ForwarderGeneralModule::formatItemXml(std::ostream& os, const ForwarderStatus& item,
- const Name& nfdId) const
+ForwarderGeneralModule::formatItemXml(std::ostream& os, const ForwarderStatus& item) const
{
os << "<generalStatus>";
- os << "<nfdId>" << nfdId << "</nfdId>";
os << "<version>" << xml::Text{item.getNfdVersion()} << "</version>";
os << "<startTime>" << xml::formatTimestamp(item.getStartTimestamp()) << "</startTime>";
os << "<currentTime>" << xml::formatTimestamp(item.getCurrentTimestamp()) << "</currentTime>";
@@ -110,14 +92,12 @@
ForwarderGeneralModule::formatStatusText(std::ostream& os) const
{
os << "General NFD status:\n";
- this->formatItemText(os, m_status, this->getNfdId());
+ this->formatItemText(os, m_status);
}
void
-ForwarderGeneralModule::formatItemText(std::ostream& os, const ForwarderStatus& item,
- const Name& nfdId) const
+ForwarderGeneralModule::formatItemText(std::ostream& os, const ForwarderStatus& item) const
{
- os << " nfdId=" << nfdId << "\n";
os << " version=" << item.getNfdVersion() << "\n";
os << " startTime=" << text::formatTimestamp(item.getStartTimestamp()) << "\n";
os << " currentTime=" << text::formatTimestamp(item.getCurrentTimestamp()) << "\n";
@@ -137,54 +117,6 @@
os << " nOutNacks=" << item.getNOutNacks() << "\n";
}
-NfdIdCollector::NfdIdCollector(unique_ptr<ndn::Validator> inner)
- : m_inner(std::move(inner))
- , m_hasNfdId(false)
-{
- BOOST_ASSERT(m_inner != nullptr);
-}
-
-const Name&
-NfdIdCollector::getNfdId() const
-{
- if (!m_hasNfdId) {
- BOOST_THROW_EXCEPTION(std::runtime_error("NfdId is unavailable"));
- }
-
- return m_nfdId;
-}
-
-void
-NfdIdCollector::checkPolicy(const Data& data, int nSteps,
- const ndn::OnDataValidated& accept,
- const ndn::OnDataValidationFailed& reject,
- std::vector<shared_ptr<ndn::ValidationRequest>>& nextSteps)
-{
- ndn::OnDataValidated accepted = [this, accept] (const shared_ptr<const Data>& data) {
- accept(data); // pass the Data to Validator user's validated callback
-
- if (m_hasNfdId) {
- return;
- }
-
- const ndn::Signature& sig = data->getSignature();
- if (!sig.hasKeyLocator()) {
- return;
- }
-
- const ndn::KeyLocator& kl = sig.getKeyLocator();
- if (kl.getType() != ndn::KeyLocator::KeyLocator_Name) {
- return;
- }
-
- m_nfdId = kl.getName();
- m_hasNfdId = true;
- };
-
- BOOST_ASSERT(nSteps == 0);
- m_inner->validate(data, accepted, reject);
-}
-
} // namespace nfdc
} // namespace tools
} // namespace nfd
diff --git a/tools/nfdc/forwarder-general-module.hpp b/tools/nfdc/forwarder-general-module.hpp
index 9fc6a68..4d65c83 100644
--- a/tools/nfdc/forwarder-general-module.hpp
+++ b/tools/nfdc/forwarder-general-module.hpp
@@ -27,7 +27,6 @@
#define NFD_TOOLS_NFDC_FORWARDER_GENERAL_MODULE_HPP
#include "module.hpp"
-#include <ndn-cxx/security/validator.hpp>
namespace nfd {
namespace tools {
@@ -35,16 +34,12 @@
using ndn::nfd::ForwarderStatus;
-class NfdIdCollector;
-
/** \brief provides access to NFD forwarder general status
* \sa https://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus
*/
class ForwarderGeneralModule : public Module, noncopyable
{
public:
- ForwarderGeneralModule();
-
void
fetchStatus(Controller& controller,
const function<void()>& onSuccess,
@@ -52,21 +47,14 @@
const CommandOptions& options) override;
void
- setNfdIdCollector(const NfdIdCollector& nfdIdCollector)
- {
- m_nfdIdCollector = &nfdIdCollector;
- }
-
- void
formatStatusXml(std::ostream& os) const override;
/** \brief format a single status item as XML
* \param os output stream
* \param item status item
- * \param nfdId NFD's signing certificate name
*/
void
- formatItemXml(std::ostream& os, const ForwarderStatus& item, const Name& nfdId) const;
+ formatItemXml(std::ostream& os, const ForwarderStatus& item) const;
void
formatStatusText(std::ostream& os) const override;
@@ -74,67 +62,14 @@
/** \brief format a single status item as text
* \param os output stream
* \param item status item
- * \param nfdId NFD's signing certificate name
*/
void
- formatItemText(std::ostream& os, const ForwarderStatus& item, const Name& nfdId) const;
+ formatItemText(std::ostream& os, const ForwarderStatus& item) const;
private:
- const Name&
- getNfdId() const;
-
-private:
- const NfdIdCollector* m_nfdIdCollector;
ForwarderStatus m_status;
};
-
-/** \brief a validator that can collect NFD's signing certificate name
- *
- * This validator redirects all validation requests to an inner validator.
- * For the first Data packet accepted by the inner validator that has a Name in KeyLocator,
- * this Name is collected as NFD's signing certificate name.
- *
- * \todo #4089 re-implement as v2 ValidationPolicy
- */
-class NfdIdCollector : public ndn::Validator
-{
-public:
- explicit
- NfdIdCollector(unique_ptr<ndn::Validator> inner);
-
- bool
- hasNfdId() const
- {
- return m_hasNfdId;
- }
-
- const Name&
- getNfdId() const;
-
-protected:
- void
- checkPolicy(const Interest& interest, int nSteps,
- const ndn::OnInterestValidated& accept,
- const ndn::OnInterestValidationFailed& reject,
- std::vector<shared_ptr<ndn::ValidationRequest>>& nextSteps) override
- {
- BOOST_ASSERT(nSteps == 0);
- m_inner->validate(interest, accept, reject);
- }
-
- void
- checkPolicy(const Data& data, int nSteps,
- const ndn::OnDataValidated& accept,
- const ndn::OnDataValidationFailed& reject,
- std::vector<shared_ptr<ndn::ValidationRequest>>& nextSteps) override;
-
-private:
- unique_ptr<ndn::Validator> m_inner;
- bool m_hasNfdId;
- Name m_nfdId;
-};
-
} // namespace nfdc
} // namespace tools
} // namespace nfd
diff --git a/tools/nfdc/status.cpp b/tools/nfdc/status.cpp
index 529ee82..01222c8 100644
--- a/tools/nfdc/status.cpp
+++ b/tools/nfdc/status.cpp
@@ -40,17 +40,10 @@
void
reportStatus(ExecuteContext& ctx, const StatusReportOptions& options)
{
- unique_ptr<ndn::security::v2::Validator> validator = make_unique<ndn::security::v2::ValidatorNull>();
- CommandOptions ctrlOptions;
-
StatusReport report;
if (options.wantForwarderGeneral) {
- // auto nfdIdCollector = make_unique<NfdIdCollector>(std::move(validator));
- auto forwarderGeneralModule = make_unique<ForwarderGeneralModule>();
- // forwarderGeneralModule->setNfdIdCollector(*nfdIdCollector);
- report.sections.push_back(std::move(forwarderGeneralModule));
- // validator = std::move(nfdIdCollector);
+ report.sections.push_back(make_unique<ForwarderGeneralModule>());
}
if (options.wantChannels) {
@@ -73,7 +66,9 @@
report.sections.push_back(make_unique<StrategyChoiceModule>());
}
- uint32_t code = report.collect(ctx.face, ctx.keyChain, *validator, ctrlOptions);
+ uint32_t code = report.collect(ctx.face, ctx.keyChain,
+ ndn::security::v2::getAcceptAllValidator(),
+ CommandOptions());
if (code != 0) {
ctx.exitCode = 1;
// Give a simple error code for end user.