Skip to content

Commit

Permalink
Replace PacketHandler with UeberBackend where possible
Browse files Browse the repository at this point in the history
Makes reasoning about PacketHandler usage easier.
  • Loading branch information
zeha committed Feb 21, 2015
1 parent 5a85152 commit c4b0d0c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
12 changes: 6 additions & 6 deletions pdns/dynhandler.cc
Expand Up @@ -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())
Expand Down Expand Up @@ -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) {
Expand All @@ -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";
}
Expand Down
6 changes: 3 additions & 3 deletions pdns/mastercommunicator.cc
Expand Up @@ -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);

Expand Down
14 changes: 6 additions & 8 deletions pdns/slavecommunicator.cc
Expand Up @@ -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;
}
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit c4b0d0c

Please sign in to comment.