boost::format fmt("%-24s %8d %8d %-10s %-20s %s\n");
g_outputBuffer = (fmt % "What" % "Seconds" % "Blocks" % "Warning" % "Action" % "Reason").str();
for(const auto& e: slow) {
- if(now < e->second.until)
- g_outputBuffer+= (fmt % e->first.toString() % (e->second.until.tv_sec - now.tv_sec) % e->second.blocks % (e->second.warning ? "true" : "false") % DNSAction::typeToString(e->second.action != DNSAction::Action::None ? e->second.action : g_dynBlockAction) % e->second.reason).str();
+ if(now < e.second.until)
+ g_outputBuffer+= (fmt % e.first.toString() % (e.second.until.tv_sec - now.tv_sec) % e.second.blocks % (e.second.warning ? "true" : "false") % DNSAction::typeToString(e.second.action != DNSAction::Action::None ? e.second.action : g_dynBlockAction) % e.second.reason).str();
}
auto slow2 = g_dynblockSMT.getCopy();
slow2.visit([&now, &fmt](const SuffixMatchTree<DynBlock>& node) {
struct timespec now;
gettime(&now);
for(const auto& e: *nmg) {
- if(now < e->second.until ) {
+ if(now < e.second.until ) {
Json::object thing{
- {"reason", e->second.reason},
- {"seconds", (double)(e->second.until.tv_sec - now.tv_sec)},
- {"blocks", (double)e->second.blocks},
- {"action", DNSAction::typeToString(e->second.action != DNSAction::Action::None ? e->second.action : g_dynBlockAction) },
- {"warning", e->second.warning }
+ {"reason", e.second.reason},
+ {"seconds", (double)(e.second.until.tv_sec - now.tv_sec)},
+ {"blocks", (double)e.second.blocks},
+ {"action", DNSAction::typeToString(e.second.action != DNSAction::Action::None ? e.second.action : g_dynBlockAction) },
+ {"warning", e.second.warning }
};
- obj.insert({e->first.toString(), thing});
+ obj.insert({e.first.toString(), thing});
}
}
}
for (const auto pair : d_qpolAddr) {
- dumpAddrPolicy(fp, pair->first, DNSName("rpz-client-ip.") + d_domain, pair->second);
+ dumpAddrPolicy(fp, pair.first, DNSName("rpz-client-ip.") + d_domain, pair.second);
}
for (const auto pair : d_propolNSAddr) {
- dumpAddrPolicy(fp, pair->first, DNSName("rpz-nsip.") + d_domain, pair->second);
+ dumpAddrPolicy(fp, pair.first, DNSName("rpz-nsip.") + d_domain, pair.second);
}
for (const auto pair : d_postpolAddr) {
- dumpAddrPolicy(fp, pair->first, DNSName("rpz-ip.") + d_domain, pair->second);
+ dumpAddrPolicy(fp, pair.first, DNSName("rpz-ip.") + d_domain, pair.second);
}
}
public:
class Iterator {
public:
- typedef node_type* value_type;
- typedef node_type* reference;
- typedef void pointer;
+ typedef node_type value_type;
+ typedef node_type& reference;
+ typedef node_type* pointer;
typedef std::forward_iterator_tag iterator_category;
typedef size_type difference_type;
throw std::logic_error(
"NetmaskTree::Iterator::operator*: iterator is invalid");
}
+ return d_node->node;
+ }
+
+ pointer operator->()
+ {
+ if (d_node == nullptr) {
+ throw std::logic_error(
+ "NetmaskTree::Iterator::operator->: iterator is invalid");
+ }
return &d_node->node;
}
for(auto iter = tree.begin(); iter != tree.end(); ++iter) {
if(iter != tree.begin())
str <<", ";
- if(!((*iter)->second))
+ if(!(iter->second))
str<<"!";
- str<<(*iter)->first.toString();
+ str<<iter->first.toString();
}
return str.str();
}
void toStringVector(vector<string>* vec) const
{
for(auto iter = tree.begin(); iter != tree.end(); ++iter) {
- vec->push_back(((*iter)->second ? "" : "!") + (*iter)->first.toString());
+ vec->push_back((iter->second ? "" : "!") + iter->first.toString());
}
}
auto place = d_sortlist.lookup(formask);
if(place && place->first == formask) {
for(const auto& o : place->second.d_orders)
- order = std::max(order, o->second); // aki, shouldn't this be o.second?
+ order = std::max(order, o.second);
}
return order;
BOOST_CHECK_EQUAL(std::distance(masks_set1.begin(), masks_set1.end()),
std::distance(masks_set2.begin(), masks_set2.end()));
for (auto entry: masks_set1) {
- Netmask mask = entry->first.getNormalized();
+ Netmask mask = entry.first.getNormalized();
BOOST_CHECK(masks_set2.find(mask) != masks_set2.end());
}
BOOST_CHECK_EQUAL(std::distance(masks_set1_cp1.begin(), masks_set1_cp1.end()),
std::distance(masks_set2.begin(), masks_set2.end()));
for (auto entry: masks_set1_cp1) {
- Netmask mask = entry->first.getNormalized();
+ Netmask mask = entry.first.getNormalized();
BOOST_CHECK(masks_set2.find(mask) != masks_set2.end());
}
BOOST_CHECK_EQUAL(std::distance(masks_set1_cp2.begin(), masks_set1_cp2.end()),
std::distance(masks_set2.begin(), masks_set2.end()));
for (auto entry: masks_set1_cp2) {
- Netmask mask = entry->first.getNormalized();
+ Netmask mask = entry.first.getNormalized();
BOOST_CHECK(masks_set2.find(mask) != masks_set2.end());
}
BOOST_CHECK_EQUAL(std::distance(masks_set1_cp3.begin(), masks_set1_cp3.end()),
std::distance(masks_set2.begin(), masks_set2.end()));
for (auto entry: masks_set1_cp3) {
- Netmask mask = entry->first.getNormalized();
+ Netmask mask = entry.first.getNormalized();
BOOST_CHECK(masks_set2.find(mask) != masks_set2.end());
}
}
// copy contents to an std::set
- std::set<NetmaskTree<int>::node_type *> masks_set1_cp4(masks_set1_cp3.begin(), masks_set1_cp3.end());
+ std::set<NetmaskTree<int>::node_type> masks_set1_cp4(masks_set1_cp3.begin(), masks_set1_cp3.end());
// check set equality
BOOST_CHECK_EQUAL(masks_set1_cp4.size(), masks_set2.size());
for (auto entry: masks_set1_cp4) {
- Netmask mask = entry->first.getNormalized();
+ Netmask mask = entry.first.getNormalized();
BOOST_CHECK(masks_set2.find(mask) != masks_set2.end());
}
Netmask maskl = mask.getNormalized();
bool found = false;
for (auto entry: masks_set1_cp4) {
- Netmask maskr = entry->first.getNormalized();
+ Netmask maskr = entry.first.getNormalized();
if (maskl == maskr)
found = true;
BOOST_CHECK_EQUAL(std::distance(masks_set1_cp5.begin(), masks_set1_cp5.end()),
std::distance(masks_set2.begin(), masks_set2.end()));
for (auto entry: masks_set1_cp5) {
- Netmask mask = entry->first.getNormalized();
+ Netmask mask = entry.first.getNormalized();
BOOST_CHECK(masks_set2.find(mask) != masks_set2.end());
}