#include "tdnssec.hh" #include using namespace std; void addDSToDelegation(DNSMessageWriter& response, const DNSNode* passedZonecut, const DNSName& zonename) { auto iter = passedZonecut->rrsets.find(DNSType::DS); if( iter != passedZonecut->rrsets.end()) { cout<<"\tDNSSEC OK query delegation, found a DS at "<<(passedZonecut->getName() + zonename)<second; response.putRR(DNSSection::Authority, passedZonecut->getName() + zonename, rrset.ttl, rrset.contents[0]); cout<<"\tAdding signatures for DS (have "<getName()+zonename, rrset.ttl, sig); } } } void addNoErrorDNSSEC(DNSMessageWriter& response, const DNSNode* node, const RRSet& rrset, const DNSName& zonename) { cout<<"\tAdding signatures for SOA (have "<rrsets.count(DNSType::NSEC)) { const auto& nsecrr = *node->rrsets.find(DNSType::NSEC); cout<<"\tAdding NSEC & signatures (have "<getName()+zonename, rrset.ttl, nsecrr.second.contents[0]); for(const auto& sig : nsecrr.second.signatures) { response.putRR(DNSSection::Authority, node->getName()+zonename, rrset.ttl, sig); } } } void addSignatures(DNSMessageWriter& response, const RRSet& rrset, const DNSName& lastnode, const DNSNode* passedWcard, const DNSName& zonename) { for(const auto& sig : rrset.signatures) { response.putRR(DNSSection::Answer, lastnode+zonename, rrset.ttl, sig); } if(passedWcard) { cout<<"\tAdding the wildcard NSEC at "<getName()<rrsets.find(DNSType::NSEC); if(nseciter != passedWcard->rrsets.end()) { response.putRR(DNSSection::Authority, passedWcard->getName()+zonename, nseciter->second.ttl, nseciter->second.contents[0]); for(const auto& sig : nseciter->second.signatures) { response.putRR(DNSSection::Authority, passedWcard->getName()+zonename, nseciter->second.ttl, sig); } } } } void addNXDOMAINDNSSEC(DNSMessageWriter& response, const RRSet& rrset, const DNSName& qname, const DNSNode* node, const DNSNode* passedZonecut, const DNSName& zonename) { for(const auto& sig : rrset.signatures) { response.putRR(DNSSection::Authority, passedZonecut->getName()+zonename, rrset.ttl, sig); } cout<<"\tAt the last node, we have "<< node->children.size()<< " children\n"; cout<<"\tLast node left "<children.lower_bound(qname.back()); cout<<"\tplace: "<getName()<prev(); for(;;) { if(!prev) { cout<<"\tNSEC should maybe loop? there is no previous???"<getName()<rrsets.count(DNSType::NSEC)) { cout<<"\tCould not find NSEC record at "<getName()<<", it is an ENT, going back further"<rrsets.find(DNSType::NSEC); cout<<"\tAdding NSEC & signatures (have "<second.signatures.size()<<")"<getName()+zonename, nsecrr->second.ttl, nsecrr->second.contents[0]); for(const auto& sig : nsecrr->second.signatures) { response.putRR(DNSSection::Authority, prev->getName()+zonename, nsecrr->second.ttl, sig); } }