From 608124ca23a63fd34e0ebb3d263919f4e0052585 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Fri, 27 Nov 2015 10:34:11 +0100 Subject: [PATCH] move everything to getMDP(), first step in abstracting to be able to talk to SyncRes too --- pdns/toysdig.cc | 97 ++++--------------------------------------------- 1 file changed, 7 insertions(+), 90 deletions(-) diff --git a/pdns/toysdig.cc b/pdns/toysdig.cc index 032f79f03..d7944261b 100644 --- a/pdns/toysdig.cc +++ b/pdns/toysdig.cc @@ -275,7 +275,7 @@ cspmap_t harvestCSPFromMDP(const MOADNSParser& mdp) return cspmap; } -static vState getKeysFor(TCPResolver& tr, const DNSName& zone, keyset_t &keyset) +static vState getKeysFor(const ComboAddress& dest, const DNSName& zone, keyset_t &keyset) { vector labels = zone.getRawLabels(); vState state; @@ -308,9 +308,9 @@ static vState getKeysFor(TCPResolver& tr, const DNSName& zone, keyset_t &keyset) // we can trust that dsmap has valid DS records for qname cerr<<"got DS for ["<d_answers.begin(); i!=mdp->d_answers.end(); ++i) { if(i->first.d_name != qname) continue; @@ -436,9 +436,9 @@ static vState getKeysFor(TCPResolver& tr, const DNSName& zone, keyset_t &keyset) toSign.clear(); toSignTags.clear(); - MOADNSParser mdp(tr.query(qname, QType::DS)); + auto mdp=getMDP(dest, qname, QType::DS); - cspmap_t cspmap=harvestCSPFromMDP(mdp); + cspmap_t cspmap=harvestCSPFromMDP(*mdp); cspmap_t validrrsets; validateWithKeySet(cspmap, validrrsets, validkeys); @@ -486,8 +486,6 @@ try ComboAddress dest(argv[1] + (*argv[1]=='@'), atoi(argv[2])); DNSName qname(argv[3]); uint16_t qtype=DNSRecordContent::TypeToNumber(argv[4]); - TCPResolver tr(dest); - cout<<"digraph oneshot {"<d_signer<<"/"<d_tag<d_signer, keys); + vState state = getKeysFor(dest, sig->d_signer, keys); cerr<<"! state = "< packet; - - DNSPacketWriter pw(packet, qname, qtype); - pw.getHeader()->rd=1; - pw.getHeader()->cd=1; - pw.getHeader()->id=getpid(); - pw.addOpt(1800, 0, EDNSOpts::DNSSECOK); - pw.commit(); - - sock.send(string((char*)&*packet.begin(), (char*)&*packet.end())); - string resp; - sock.read(resp); - MOADNSParser mdp(resp); - - struct ContentPair { - vector content; - vector> signatures; - }; - - map, ContentPair > records; - - for(const auto& r : mdp.d_answers) { - cout<getZoneRepresentation()<(r.first)) { - records[make_pair(r.first.d_name, rrsig->d_type)].signatures.push_back(rrsig); - } - else if(auto opt = getRR(r.first)) { - continue; - } - - else - records[make_pair(r.first.d_name, r.first.d_type)].content.push_back(r.first); - - } - cout<<"Had "< > toSign; - for(const auto& c : rrset.second.content) - toSign.push_back(c.d_content); - - for(auto& sign : rrset.second.signatures) { - cout<<"Seeing if we can retrieve DNSKEY for "<d_signer<<" with tag "<d_tag<d_signer, sign->d_tag, &trusted); - cout<<"Got "<verify(msg, sign->d_signature)<d_signer<d_signer, QType::DS); - } - } - } - } -} -#endif -- 2.40.0