From 6fe866b425c84bd2626c45fc648b7517ceb2af94 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Tue, 4 Aug 2015 14:51:01 +0300 Subject: [PATCH] use DNSName for tsig keyname --- pdns/dnspacket.cc | 2 +- pdns/dnspacket.hh | 2 -- pdns/mastercommunicator.cc | 6 +++--- pdns/packethandler.cc | 8 ++++---- pdns/packethandler.hh | 4 ++-- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/pdns/dnspacket.cc b/pdns/dnspacket.cc index 949da4b04..5b144e6c0 100644 --- a/pdns/dnspacket.cc +++ b/pdns/dnspacket.cc @@ -697,6 +697,6 @@ bool checkForCorrectTSIG(const DNSPacket* q, UeberBackend* B, DNSName* keyname, return result; } -const string& DNSPacket::getTSIGKeyname() const { +const DNSName& DNSPacket::getTSIGKeyname() const { return d_tsigkeyname; } diff --git a/pdns/dnspacket.hh b/pdns/dnspacket.hh index 0755851e7..efa030c6b 100644 --- a/pdns/dnspacket.hh +++ b/pdns/dnspacket.hh @@ -146,11 +146,9 @@ public: string d_peer_principal; const DNSName& getTSIGKeyname() const; - ComboAddress d_remote; uint16_t qclass; //!< class of the question - should always be INternet 2 struct dnsheader d; //!< dnsheader at the start of the databuffer 12 - uint16_t qclass; //!< class of the question - should always be INternet 2 QType qtype; //!< type of the question 2 TSIGRecordContent d_trc; //72 diff --git a/pdns/mastercommunicator.cc b/pdns/mastercommunicator.cc index 7b4183b69..f726ffb7e 100644 --- a/pdns/mastercommunicator.cc +++ b/pdns/mastercommunicator.cc @@ -220,13 +220,13 @@ void CommunicatorClass::sendNotification(int sock, const DNSName& domain, const { UeberBackend B; vector meta; - string tsigkeyname; - string tsigalgorithm; + DNSName tsigkeyname; + DNSName tsigalgorithm; string tsigsecret64; string tsigsecret; if (B.getDomainMetadata(domain, "TSIG-ALLOW-AXFR", meta) && meta.size() > 0) { - tsigkeyname = meta[0]; + tsigkeyname.toStringNoDot() = meta[0]; } vector packet; diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index 6e8e45692..49da72777 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -765,7 +765,7 @@ How MySQLBackend would implement this: */ -int PacketHandler::trySuperMaster(DNSPacket *p, const string& tsigkeyname) +int PacketHandler::trySuperMaster(DNSPacket *p, const DNSName& tsigkeyname) { if(p->d_tcp) { @@ -781,7 +781,7 @@ int PacketHandler::trySuperMaster(DNSPacket *p, const string& tsigkeyname) } } -int PacketHandler::trySuperMasterSynchronous(DNSPacket *p, const string& tsigkeyname) +int PacketHandler::trySuperMasterSynchronous(DNSPacket *p, const DNSName& tsigkeyname) { Resolver::res_t nsset; try { @@ -821,7 +821,7 @@ int PacketHandler::trySuperMasterSynchronous(DNSPacket *p, const string& tsigkey db->createSlaveDomain(p->getRemote(), p->qdomain, nameserver, account); if (tsigkeyname.empty() == false) { vector meta; - meta.push_back(tsigkeyname); + meta.push_back(tsigkeyname.toStringNoDot()); db->setDomainMetadata(p->qdomain, "AXFR-MASTER-TSIG", meta); } } @@ -868,7 +868,7 @@ int PacketHandler::processNotify(DNSPacket *p) meta.clear(); if (B.getDomainMetadata(p->qdomain,"AXFR-MASTER-TSIG",meta) && meta.size() > 0) { - if (!p->d_havetsig || meta[0] != p->getTSIGKeyname()) { + if (!p->d_havetsig || meta[0] != p->getTSIGKeyname().toStringNoDot()) { L<qdomain<<" from "<getRemote()<<": expected TSIG key '"<getTSIGKeyname()<<"'"<