Permalink
Browse files

Replace PacketHandler with UeberBackend where possible

Makes reasoning about PacketHandler usage easier.
  • Loading branch information...
1 parent 5a85152 commit c4b0d0caf6dfd06423652bb0c0c5f98843aabc09 @zeha zeha committed Feb 15, 2015
Showing with 15 additions and 17 deletions.
  1. +6 −6 pdns/dynhandler.cc
  2. +3 −3 pdns/mastercommunicator.cc
  3. +6 −8 pdns/slavecommunicator.cc
View
@@ -230,8 +230,8 @@ string DLNotifyRetrieveHandler(const vector<string>&parts, Utility::pid_t ppid)
const string& domain=parts[1];
DomainInfo di;
- PacketHandler P;
- if(!P.getBackend()->getDomainInfo(domain, di))
+ UeberBackend B;
+ if(!B.getDomainInfo(domain, di))
return "Domain '"+domain+"' unknown";
if(di.masters.empty())
@@ -299,11 +299,11 @@ string DLNotifyHandler(const vector<string>&parts, Utility::pid_t ppid)
string DLRediscoverHandler(const vector<string>&parts, Utility::pid_t ppid)
{
- PacketHandler P;
+ UeberBackend B;
try {
L<<Logger::Error<<"Rediscovery was requested"<<endl;
string status="Ok";
- P.getBackend()->rediscover(&status);
+ B.rediscover(&status);
return status;
}
catch(PDNSException &ae) {
@@ -314,8 +314,8 @@ string DLRediscoverHandler(const vector<string>&parts, Utility::pid_t ppid)
string DLReloadHandler(const vector<string>&parts, Utility::pid_t ppid)
{
- PacketHandler P;
- P.getBackend()->reload();
+ UeberBackend B;
+ B.reload();
L<<Logger::Error<<"Reload was requested"<<endl;
return "Ok";
}
@@ -99,12 +99,12 @@ void CommunicatorClass::queueNotifyDomain(const string &domain, DNSBackend *B)
bool CommunicatorClass::notifyDomain(const string &domain)
{
DomainInfo di;
- PacketHandler P;
- if(!P.getBackend()->getDomainInfo(domain, di)) {
+ UeberBackend B;
+ if(!B.getDomainInfo(domain, di)) {
L<<Logger::Error<<"No such domain '"<<domain<<"' in our database"<<endl;
return false;
}
- queueNotifyDomain(domain, P.getBackend());
+ queueNotifyDomain(domain, &B);
// call backend and tell them we sent out the notification - even though that is premature
di.backend->setNotified(di.id, di.serial);
@@ -65,17 +65,15 @@ void CommunicatorClass::addSuckRequest(const string &domain, const string &maste
void CommunicatorClass::suck(const string &domain,const string &remote)
{
L<<Logger::Error<<"Initiating transfer of '"<<domain<<"' from remote '"<<remote<<"'"<<endl;
- PacketHandler P; // fresh UeberBackend
+ UeberBackend B; // fresh UeberBackend
DomainInfo di;
di.backend=0;
bool transaction=false;
try {
- UeberBackend *B=dynamic_cast<UeberBackend *>(P.getBackend()); // copy of the same UeberBackend
- DNSSECKeeper dk (B); // reuse our UeberBackend copy for DNSSECKeeper
+ DNSSECKeeper dk (&B); // reuse our UeberBackend copy for DNSSECKeeper
-
- if(!B->getDomainInfo(domain, di) || !di.backend) { // di.backend and B are mostly identical
+ if(!B.getDomainInfo(domain, di) || !di.backend) { // di.backend and B are mostly identical
L<<Logger::Error<<"Can't determine backend for domain '"<<domain<<"'"<<endl;
return;
}
@@ -85,7 +83,7 @@ void CommunicatorClass::suck(const string &domain,const string &remote)
string tsigkeyname, tsigalgorithm, tsigsecret;
if(dk.getTSIGForAccess(domain, remote, &tsigkeyname)) {
string tsigsecret64;
- if(B->getTSIGKey(tsigkeyname, &tsigalgorithm, &tsigsecret64)) {
+ if(B.getTSIGKey(tsigkeyname, &tsigalgorithm, &tsigsecret64)) {
B64Decode(tsigsecret64, tsigsecret);
} else {
L<<Logger::Error<<"TSIG key '"<<tsigkeyname<<"' for domain '"<<domain<<"' not found"<<endl;
@@ -96,7 +94,7 @@ void CommunicatorClass::suck(const string &domain,const string &remote)
scoped_ptr<AuthLua> pdl;
vector<string> scripts;
- if(B->getDomainMetadata(domain, "LUA-AXFR-SCRIPT", scripts) && !scripts.empty()) {
+ if(B.getDomainMetadata(domain, "LUA-AXFR-SCRIPT", scripts) && !scripts.empty()) {
try {
pdl.reset(new AuthLua(scripts[0]));
L<<Logger::Info<<"Loaded Lua script '"<<scripts[0]<<"' to edit the incoming AXFR of '"<<domain<<"'"<<endl;
@@ -110,7 +108,7 @@ void CommunicatorClass::suck(const string &domain,const string &remote)
vector<string> localaddr;
ComboAddress laddr;
- if(B->getDomainMetadata(domain, "AXFR-SOURCE", localaddr) && !localaddr.empty()) {
+ if(B.getDomainMetadata(domain, "AXFR-SOURCE", localaddr) && !localaddr.empty()) {
try {
laddr = ComboAddress(localaddr[0]);
L<<Logger::Info<<"AXFR source for domain '"<<domain<<"' set to "<<localaddr[0]<<endl;

0 comments on commit c4b0d0c

Please sign in to comment.