}
this->Cleanup();
- throw AhuException("DB2Backend Failed to Start");
+ throw PDNSException("DB2Backend Failed to Start");
}
L << Logger::Warning << kBackendName << " Connection succeeded" << endl;
// Rethrow for the nameserver
//
- throw AhuException("Execute failed");
+ throw PDNSException("Execute failed");
}
}
catch (DB2Exception& theException)
{
- throw AhuException("List failed");
+ throw PDNSException("List failed");
}
return theResult;
// Rethrow for the nameserver
//
- throw AhuException("Fetch failed");
+ throw PDNSException("Fetch failed");
}
return theResult;
// Rethrow for the nameserver
//
- throw AhuException("GetSOA failed");
+ throw PDNSException("GetSOA failed");
}
return theResult;
void GeoBackend::loadZoneName() {
zoneName = getArg("zone");
if (zoneName.empty())
- throw AhuException("zone parameter must be set");
+ throw PDNSException("zone parameter must be set");
}
void GeoBackend::loadTTLValues() {
return;
if (values.size() != 2)
- throw AhuException("Invalid number of soa-values specified in configuration");
+ throw PDNSException("Invalid number of soa-values specified in configuration");
soaMasterServer = values[0];
soaHostmaster = values[1];
string filename = getArg("ip-map-zonefile");
if (filename.empty())
- throw AhuException("No IP map zonefile specified in configuration");
+ throw PDNSException("No IP map zonefile specified in configuration");
// Stat file to see if it has changed since last read
struct stat stbuf;
if (stat(filename.c_str(), &stbuf) != 0 || !S_ISREG(stbuf.st_mode)) {
const string errormsg = "stat() failed, or " + filename + " is no regular file.";
if (lastDiscoverTime == 0) // We have no older map, bail out
- throw AhuException(errormsg);
+ throw PDNSException(errormsg);
else {
// Log, but continue
L << Logger::Error << logprefix << errormsg;
std::ifstream ifs(filename.c_str(), std::ios::in);
if (!ifs)
- throw AhuException("Unable to open IP map zonefile for read: " + stringerror());
+ throw PDNSException("Unable to open IP map zonefile for read: " + stringerror());
L << Logger::Info << logprefix << "Parsing IP map zonefile" << endl;
mapcount++;
}
else
- throw AhuException("duplicate georecord " + gr->qname + ", skipping");
+ throw PDNSException("duplicate georecord " + gr->qname + ", skipping");
}
- catch(AhuException &e) {
+ catch(PDNSException &e) {
L << Logger::Error << logprefix << "Error occured while reading director file "
<< gr->directorfile << ": " << e.reason << endl;
delete gr;
std::ifstream ifs(gr.directorfile.c_str(), std::ios::in);
if (!ifs)
- throw AhuException("Error opening file.");
+ throw PDNSException("Error opening file.");
string line;
while(getline(ifs, line)) {
gr.qname.resize(gr.qname.size()-1);
// Check whether zoneName is a prefix of this FQDN
if (gr.qname.rfind(zoneName) == string::npos)
- throw AhuException("georecord " + gr.qname + " is out of zone " + zoneName);
+ throw PDNSException("georecord " + gr.qname + " is out of zone " + zoneName);
}
continue;
}
// Do some checks on the validness of this director map / georecord
if (gr.qname.empty())
- throw AhuException("$RECORD line empty or missing, georecord qname unknown");
+ throw PDNSException("$RECORD line empty or missing, georecord qname unknown");
if (gr.dirmap.count(0) == 0)
- throw AhuException("No default (0) director map entry");
+ throw PDNSException("No default (0) director map entry");
}
catch(SSqlException &e) {
L<<Logger::Error<<mode<<" Connection failed: "<<e.txtReason()<<endl;
- throw AhuException("Unable to launch "+mode+" connection: "+e.txtReason());
+ throw PDNSException("Unable to launch "+mode+" connection: "+e.txtReason());
}
L<<Logger::Info<<mode<<" Connection successful. Connected to database '"<<getArg("dbname")<<"' on '"<<getArg("host")<<"'."<<endl;
}
catch( SSqlException & e )
{
L<<Logger::Error<< mode << " Connection failed: " << e.txtReason() << std::endl;
- throw AhuException( "Unable to launch " + mode + " connection: " + e.txtReason());
+ throw PDNSException( "Unable to launch " + mode + " connection: " + e.txtReason());
}
L << Logger::Warning << mode << " Connection successful" << std::endl;
catch(SSqlException &e) {
L<<Logger::Error<<mode<<" Connection failed: "<<e.txtReason()<<endl;
- throw AhuException("Unable to launch "+mode+" connection: "+e.txtReason());
+ throw PDNSException("Unable to launch "+mode+" connection: "+e.txtReason());
}
L<<Logger::Warning<<mode<<" Connection successful"<<endl;
}
catch(SSqlException &e) {
L<<Logger::Error<<mode<<" Connection failed: "<<e.txtReason()<<endl;
- throw AhuException("Unable to launch "+mode+" connection: "+e.txtReason());
+ throw PDNSException("Unable to launch "+mode+" connection: "+e.txtReason());
}
L<<Logger::Info<<mode<<" Connection successful. Connected to database '"<<getArg("dbname")<<"' on '"<<getArg("host")<<"'."<<endl;
}
catch( SSqlException & e )
{
L << Logger::Error << mode << ": connection failed: " << e.txtReason() << std::endl;
- throw AhuException( "Unable to launch " + mode + " connection: " + e.txtReason());
+ throw PDNSException( "Unable to launch " + mode + " connection: " + e.txtReason());
}
L << Logger::Info << mode << ": connection to '"<<getArg("database")<<"' successful" << std::endl;
}
if( m_pldap != NULL ) { delete( m_pldap ); }
- throw( AhuException( "Unable to connect to ldap server" ) );
+ throw( PDNSException( "Unable to connect to ldap server" ) );
}
catch( LDAPException &le )
{
L << Logger::Error << m_myname << " Unable to get zone " + target + " from LDAP directory: " << le.what() << endl;
- throw( AhuException( "LDAP server unreachable" ) ); // try to reconnect to another server
+ throw( PDNSException( "LDAP server unreachable" ) ); // try to reconnect to another server
}
catch( std::exception &e )
{
catch( LDAPException &le )
{
L << Logger::Error << m_myname << " Unable to search LDAP directory: " << le.what() << endl;
- throw( AhuException( "LDAP server unreachable" ) ); // try to reconnect to another server
+ throw( PDNSException( "LDAP server unreachable" ) ); // try to reconnect to another server
}
catch( std::exception &e )
{
catch( LDAPException &le )
{
L << Logger::Error << m_myname << " Search failed: " << le.what() << endl;
- throw( AhuException( "LDAP server unreachable" ) ); // try to reconnect to another server
+ throw( PDNSException( "LDAP server unreachable" ) ); // try to reconnect to another server
}
catch( std::exception &e )
{
catch(LUAException &e) {
L<<Logger::Error<<backend_name<<"Error: "<<e.what<<endl;
- throw AhuException(e.what);
+ throw PDNSException(e.what);
}
}
}
catch(SSqlException &e) {
L<<Logger::Error<<backendName<<" Connection failed: "<<e.txtReason()<<endl;
- throw AhuException(backendName+"Unable to launch connection: "+e.txtReason());
+ throw PDNSException(backendName+"Unable to launch connection: "+e.txtReason());
}
d_rrtable=getArg("rr-table");
try {
d_db->doQuery(query);
} catch (SSqlException &e) {
- throw AhuException("Query failed: "+e.txtReason());
+ throw PDNSException("Query failed: "+e.txtReason());
}
}
this->Query(query);
if(!d_db->getRow(rrow)) {
- throw AhuException("lookup() passed zoneId = "+zoneIdStr+" but no such zone!");
+ throw PDNSException("lookup() passed zoneId = "+zoneIdStr+" but no such zone!");
}
found = true;
stringtok( m_hosts[WRITE], getArg( "host-write" ), ", " );
}
- if( !connectTo( m_hosts[READ], READ ) ) { throw( AhuException( "Fatal: Connecting to server for reading failed" ) ); }
- if( !connectTo( m_hosts[WRITE], WRITE ) ) { throw( AhuException( "Fatal: Connecting to server for writing failed" ) ); }
+ if( !connectTo( m_hosts[READ], READ ) ) { throw( PDNSException( "Fatal: Connecting to server for reading failed" ) ); }
+ if( !connectTo( m_hosts[WRITE], WRITE ) ) { throw( PDNSException( "Fatal: Connecting to server for writing failed" ) ); }
}
catch( std::exception& e )
{
L.log( m_myname + " OdbxBackend(): Caught STL exception - " + e.what(), Logger::Error );
- throw( AhuException( "Fatal: STL exception" ) );
+ throw( PDNSException( "Fatal: STL exception" ) );
}
}
if( err < 0 )
{
L.log( m_myname + " getRecord: Unable to get next result - " + string( odbx_error( m_handle[type], err ) ), Logger::Error );
- throw( AhuException( "Error: odbx_result() failed" ) );
+ throw( PDNSException( "Error: odbx_result() failed" ) );
}
if( m_result != NULL )
if( ( err = odbx_row_fetch( m_result ) ) < 0 )
{
L.log( m_myname + " getRecord: Unable to get next row - " + string( odbx_error( m_handle[type], err ) ), Logger::Error );
- throw( AhuException( "Error: odbx_row_fetch() failed" ) );
+ throw( PDNSException( "Error: odbx_row_fetch() failed" ) );
}
if( err > 0 )
signal(SIGPIPE, SIG_IGN);
if(access(argv[0],X_OK)) // check before fork so we can throw
- throw AhuException("Command '"+string(argv[0])+"' cannot be executed: "+stringerror());
+ throw PDNSException("Command '"+string(argv[0])+"' cannot be executed: "+stringerror());
if(pipe(d_fd1)<0 || pipe(d_fd2)<0)
- throw AhuException("Unable to open pipe for coprocess: "+string(strerror(errno)));
+ throw PDNSException("Unable to open pipe for coprocess: "+string(strerror(errno)));
if((d_pid=fork())<0)
- throw AhuException("Unable to fork for coprocess: "+stringerror());
+ throw PDNSException("Unable to fork for coprocess: "+stringerror());
else if(d_pid>0) { // parent speaking
close(d_fd1[0]);
Utility::setCloseOnExec(d_fd1[1]);
close(d_fd2[1]);
Utility::setCloseOnExec(d_fd2[0]);
if(!(d_fp=fdopen(d_fd2[0],"r")))
- throw AhuException("Unable to associate a file pointer with pipe: "+stringerror());
+ throw PDNSException("Unable to associate a file pointer with pipe: "+stringerror());
setbuf(d_fp,0); // no buffering please, confuses select
}
else if(!d_pid) { // child
int status;
int ret=waitpid(d_pid, &status, WNOHANG);
if(ret<0)
- throw AhuException("Unable to ascertain status of coprocess "+itoa(d_pid)+" from "+itoa(getpid())+": "+string(strerror(errno)));
+ throw PDNSException("Unable to ascertain status of coprocess "+itoa(d_pid)+" from "+itoa(getpid())+": "+string(strerror(errno)));
else if(ret) {
if(WIFEXITED(status)) {
int ret=WEXITSTATUS(status);
- throw AhuException("Coprocess exited with code "+itoa(ret));
+ throw PDNSException("Coprocess exited with code "+itoa(ret));
}
if(WIFSIGNALED(status)) {
int sig=WTERMSIG(status);
reason+=". Dumped core";
#endif
- throw AhuException(reason);
+ throw PDNSException(reason);
}
}
}
while(sent<line.size()) {
bytes=write(d_fd1[1],line.c_str()+sent,line.length()-sent);
if(bytes<0)
- throw AhuException("Writing to coprocess failed: "+string(strerror(errno)));
+ throw PDNSException("Writing to coprocess failed: "+string(strerror(errno)));
sent+=bytes;
}
FD_SET(fileno(d_fp),&rds);
int ret=select(fileno(d_fp)+1,&rds,0,0,&tv);
if(ret<0)
- throw AhuException("Error waiting on data from coprocess: "+stringerror());
+ throw PDNSException("Error waiting on data from coprocess: "+stringerror());
if(!ret)
- throw AhuException("Timeout waiting for data from coprocess");
+ throw PDNSException("Timeout waiting for data from coprocess");
}
if(!stringfgets(d_fp, receive))
- throw AhuException("Child closed pipe");
+ throw PDNSException("Child closed pipe");
trim_right(receive);
}
{
d_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if(d_fd < 0)
- throw AhuException("Unable to create UNIX domain socket: "+string(strerror(errno)));
+ throw PDNSException("Unable to create UNIX domain socket: "+string(strerror(errno)));
struct sockaddr_un remote;
memset(&remote, 0, sizeof(remote));
cp.sendReceive("www.trilab.com", reply);
cout<<"Answered: '"<<reply<<"'"<<endl;
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
cerr<<ae.reason<<endl;
}
d_cp->send(line);
return;
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
delete d_cp;
d_cp=0;
throw;
d_cp->receive(line);
return;
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
L<<Logger::Warning<<kBackendId<<" unable to receive data from coprocess. "<<ae.reason<<endl;
delete d_cp;
d_cp=0;
d_coproc->send(query.str());
}
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
L<<Logger::Error<<kBackendId<<" Error from coprocess: "<<ae.reason<<endl;
throw; // hop
}
d_coproc->send(query.str());
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
L<<Logger::Error<<kBackendId<<" Error from coprocess: "<<ae.reason<<endl;
throw;
}
stringtok(parts,line,"\t");
if(parts.empty()) {
L<<Logger::Error<<kBackendId<<" coprocess returned emtpy line in query for "<<d_qname<<endl;
- throw AhuException("Format error communicating with coprocess");
+ throw PDNSException("Format error communicating with coprocess");
}
else if(parts[0]=="FAIL") {
throw DBException("coprocess returned a FAIL");
else if(parts[0]=="DATA") { // yay
if(parts.size() < 7 + extraFields) {
L<<Logger::Error<<kBackendId<<" coprocess returned incomplete or empty line in data section for query for "<<d_qname<<endl;
- throw AhuException("Format error communicating with coprocess in data section");
+ throw PDNSException("Format error communicating with coprocess in data section");
// now what?
}
else {
if(parts.size()< 8 + extraFields) {
L<<Logger::Error<<kBackendId<<" coprocess returned incomplete MX/SRV line in data section for query for "<<d_qname<<endl;
- throw AhuException("Format error communicating with coprocess in data section of MX/SRV record");
+ throw PDNSException("Format error communicating with coprocess in data section of MX/SRV record");
}
r.priority=atoi(parts[6+extraFields].c_str());
break;
}
else
- throw AhuException("Coprocess backend sent incorrect response '"+line+"'");
+ throw PDNSException("Coprocess backend sent incorrect response '"+line+"'");
}
return true;
}
PipeConnector::PipeConnector(std::map<std::string,std::string> options) {
if (options.count("command") == 0) {
L<<Logger::Error<<"Cannot find 'command' option in connection string"<<endl;
- throw new AhuException();
+ throw new PDNSException();
}
this->command = options.find("command")->second;
this->options = options;
signal(SIGPIPE, SIG_IGN);
if(access(argv[0],X_OK)) // check before fork so we can throw
- throw AhuException("Command '"+string(argv[0])+"' cannot be executed: "+stringerror());
+ throw PDNSException("Command '"+string(argv[0])+"' cannot be executed: "+stringerror());
if(pipe(d_fd1)<0 || pipe(d_fd2)<0)
- throw AhuException("Unable to open pipe for coprocess: "+string(strerror(errno)));
+ throw PDNSException("Unable to open pipe for coprocess: "+string(strerror(errno)));
if((d_pid=fork())<0)
- throw AhuException("Unable to fork for coprocess: "+stringerror());
+ throw PDNSException("Unable to fork for coprocess: "+stringerror());
else if(d_pid>0) { // parent speaking
close(d_fd1[0]);
Utility::setCloseOnExec(d_fd1[1]);
close(d_fd2[1]);
Utility::setCloseOnExec(d_fd2[0]);
if(!(d_fp=fdopen(d_fd2[0],"r")))
- throw AhuException("Unable to associate a file pointer with pipe: "+stringerror());
+ throw PDNSException("Unable to associate a file pointer with pipe: "+stringerror());
setbuf(d_fp,0); // no buffering please, confuses select
}
else if(!d_pid) { // child
while(sent<line.size()) {
bytes=write(d_fd1[1],line.c_str()+sent,line.length()-sent);
if(bytes<0)
- throw AhuException("Writing to coprocess failed: "+std::string(strerror(errno)));
+ throw PDNSException("Writing to coprocess failed: "+std::string(strerror(errno)));
sent+=bytes;
}
FD_SET(fileno(d_fp),&rds);
int ret=select(fileno(d_fp)+1,&rds,0,0,&tv);
if(ret<0)
- throw AhuException("Error waiting on data from coprocess: "+stringerror());
+ throw PDNSException("Error waiting on data from coprocess: "+stringerror());
if(!ret)
- throw AhuException("Timeout waiting for data from coprocess");
+ throw PDNSException("Timeout waiting for data from coprocess");
}
if(!stringfgets(d_fp, receive))
- throw AhuException("Child closed pipe");
+ throw PDNSException("Child closed pipe");
s_output.append(receive);
rapidjson::StringStream ss(s_output.c_str());
int status;
int ret=waitpid(d_pid, &status, WNOHANG);
if(ret<0)
- throw AhuException("Unable to ascertain status of coprocess "+itoa(d_pid)+" from "+itoa(getpid())+": "+string(strerror(errno)));
+ throw PDNSException("Unable to ascertain status of coprocess "+itoa(d_pid)+" from "+itoa(getpid())+": "+string(strerror(errno)));
else if(ret) {
if(WIFEXITED(status)) {
int ret=WEXITSTATUS(status);
- throw AhuException("Coprocess exited with code "+itoa(ret));
+ throw PDNSException("Coprocess exited with code "+itoa(ret));
}
if(WIFSIGNALED(status)) {
int sig=WTERMSIG(status);
reason+=". Dumped core";
#endif
- throw AhuException(reason);
+ throw PDNSException(reason);
}
}
return true;
bool RemoteBackend::send(rapidjson::Document &value) {
try {
return connector->send(value);
- } catch (AhuException &ex) {
+ } catch (PDNSException &ex) {
L<<Logger::Error<<"Exception caught when sending: "<<ex.reason<<std::endl;
} catch (...) {
L<<Logger::Error<<"Exception caught when sending"<<std::endl;
bool RemoteBackend::recv(rapidjson::Document &value) {
try {
return connector->recv(value);
- } catch (AhuException &ex) {
+ } catch (PDNSException &ex) {
L<<Logger::Error<<"Exception caught when receiving: "<<ex.reason<<std::endl;
} catch (...) {
L<<Logger::Error<<"Exception caught when receiving"<<std::endl;;
size_t pos;
pos = d_connstr.find_first_of(":");
if (pos == std::string::npos)
- throw AhuException("Invalid connection string: malformed");
+ throw PDNSException("Invalid connection string: malformed");
type = d_connstr.substr(0, pos);
opts = d_connstr.substr(pos+1);
#ifdef REMOTEBACKEND_HTTP
this->connector = new HTTPConnector(options);
#else
- throw AhuException("Invalid connection string: http connector support not enabled. Recompile with --enable-remotebackend-http");
+ throw PDNSException("Invalid connection string: http connector support not enabled. Recompile with --enable-remotebackend-http");
#endif
} else if (type == "pipe") {
this->connector = new PipeConnector(options);
} else {
- throw AhuException("Invalid connection string: unknown connector");
+ throw PDNSException("Invalid connection string: unknown connector");
}
return -1;
rapidjson::Value parameters;
if (d_index != -1)
- throw AhuException("Attempt to lookup while one running");
+ throw PDNSException("Attempt to lookup while one running");
query.SetObject();
JSON_ADD_MEMBER(query, "method", "lookup", query.GetAllocator())
rapidjson::Value parameters;
if (d_index != -1)
- throw AhuException("Attempt to lookup while one running");
+ throw PDNSException("Attempt to lookup while one running");
query.SetObject();
JSON_ADD_MEMBER(query, "method", "list", query.GetAllocator());
// make sure we got zone & kind
if (!answer["result"].HasMember("zone")) {
L<<Logger::Error<<kBackendId<<"Missing zone in getDomainInfo return value"<<endl;
- throw AhuException();
+ throw PDNSException();
}
value = -1;
// parse return value. we need at least zone,serial,kind
if (boost::iequals(tmp, "0") || boost::iequals(tmp, "false")) return false;
}
std::cerr << value.GetType() << endl;
- throw new AhuException("Cannot convert rapidjson value into boolean");
+ throw new PDNSException("Cannot convert rapidjson value into boolean");
}
bool Connector::getBool(rapidjson::Value &value) {
std::string tmp = value.GetString();
return boost::lexical_cast<int>(tmp);
}
- throw new AhuException("Cannot convert rapidjson value into integer");
+ throw new PDNSException("Cannot convert rapidjson value into integer");
}
unsigned int RemoteBackend::getUInt(rapidjson::Value &value) {
std::string tmp = value.GetString();
return boost::lexical_cast<unsigned int>(tmp);
}
- throw new AhuException("Cannot convert rapidjson value into integer");
+ throw new PDNSException("Cannot convert rapidjson value into integer");
}
int64_t RemoteBackend::getInt64(rapidjson::Value &value) {
std::string tmp = value.GetString();
return boost::lexical_cast<int64_t>(tmp);
}
- throw new AhuException("Cannot convert rapidjson value into integer");
+ throw new PDNSException("Cannot convert rapidjson value into integer");
}
std::string RemoteBackend::getString(rapidjson::Value &value) {
if (value.IsInt64()) return boost::lexical_cast<std::string>(value.GetInt64());
if (value.IsInt()) return boost::lexical_cast<std::string>(value.GetInt());
if (value.IsDouble()) return boost::lexical_cast<std::string>(value.GetDouble());
- throw new AhuException("Cannot convert rapidjson value into std::string");
+ throw new PDNSException("Cannot convert rapidjson value into std::string");
}
double RemoteBackend::getDouble(rapidjson::Value &value) {
std::string tmp = value.GetString();
return boost::lexical_cast<double>(tmp);
}
- throw new AhuException("Cannot convert rapidjson value into double");
+ throw new PDNSException("Cannot convert rapidjson value into double");
}
DNSBackend *RemoteBackend::maker()
::arg().set("remote-connection-string")="http:url=http://localhost:62434/dns";
::arg().set("remote-dnssec")="yes";
be = BackendMakers().all()[0];
- } catch (AhuException &ex) {
+ } catch (PDNSException &ex) {
BOOST_TEST_MESSAGE("Cannot start remotebackend: " << ex.reason );
};
}
::arg().set("remote-connection-string")="http:url=http://localhost:62434/dns/endpoint.json,post=1,post_json=1";
::arg().set("remote-dnssec")="yes";
be = BackendMakers().all()[0];
- } catch (AhuException &ex) {
+ } catch (PDNSException &ex) {
BOOST_TEST_MESSAGE("Cannot start remotebackend: " << ex.reason );
};
}
SOARecordContent::report();
NSRecordContent::report();
ARecordContent::report();
- } catch (AhuException &ex) {
+ } catch (PDNSException &ex) {
BOOST_TEST_MESSAGE("Cannot start remotebackend: " << ex.reason );
};
}
::arg().set("remote-connection-string")="http:url=http://localhost:62434/dns,post=1";
::arg().set("remote-dnssec")="yes";
be = BackendMakers().all()[0];
- } catch (AhuException &ex) {
+ } catch (PDNSException &ex) {
BOOST_TEST_MESSAGE("Cannot start remotebackend: " << ex.reason );
};
}
SOARecordContent::report();
NSRecordContent::report();
ARecordContent::report();
- } catch (AhuException &ex) {
+ } catch (PDNSException &ex) {
BOOST_TEST_MESSAGE("Cannot start remotebackend: " << ex.reason );
};
}
UnixsocketConnector::UnixsocketConnector(std::map<std::string,std::string> options) {
if (options.count("path") == 0) {
L<<Logger::Error<<"Cannot find 'path' option in connection string"<<endl;
- throw new AhuException();
+ throw new PDNSException();
}
this->timeout = 2000;
if (options.find("timeout") != options.end()) {
if (d_fd < 0)
{
L<<Logger::Error<<"Failed to open cdb database file '"<<cdbfile<<"'. Error: "<<stringerror()<<endl;
- throw new AhuException("Failed to open cdb database file '"+cdbfile+"'. Error: " + stringerror());
+ throw new PDNSException("Failed to open cdb database file '"+cdbfile+"'. Error: " + stringerror());
}
int cdbinit = cdb_init(&d_cdb, d_fd);
if (cdbinit < 0)
{
L<<Logger::Error<<"Failed to initialize cdb structure. ErrorNr: '"<<cdbinit<<endl;
- throw new AhuException("Failed to initialize cdb structure.");
+ throw new PDNSException("Failed to initialize cdb structure.");
}
}
void TinyDNSBackend::setNotified(uint32_t id, uint32_t serial) {
Lock l(&s_domainInfoLock);
if (!s_domainInfo.count(d_suffix)) {
- throw new AhuException("Can't get list of domains to set the serial.");
+ throw new PDNSException("Can't get list of domains to set the serial.");
}
TDI_t *domains = &s_domainInfo[d_suffix];
TDIById_t& domain_index = domains->get<tag_domainid>();
}
catch(XDBException &e) {
L<<Logger::Error<<"[XDBBackend] Error: "<<e.what<<endl;
- throw AhuException(e.what);
+ throw PDNSException(e.what);
}
L<<Logger::Error<<"[XDBBackend] Open"<<endl;
}
#include "namespaces.hh"
//! Generic Exception thrown
-class AhuException
+class PDNSException
{
public:
- AhuException(){reason="Unspecified";};
- AhuException(string r){reason=r;};
+ PDNSException(){reason="Unspecified";};
+ PDNSException(string r){reason=r;};
string reason; //! Print this to tell the user what went wrong
};
-class TimeoutException : public AhuException
+class TimeoutException : public PDNSException
{};
#endif
#include "namespaces.hh"
-typedef AhuException ArgException;
+typedef PDNSException ArgException;
/** This class helps parsing argc and argv into a map of parameters. We have 3 kinds of formats:
else if(bdr.qname.length() > bb2.d_name.length() && dottedEndsOn(bdr.qname, bb2.d_name))
bdr.qname.resize(bdr.qname.length() - (bb2.d_name.length() + 1));
else
- throw AhuException("Trying to insert non-zone data, name='"+bdr.qname+"', qtype="+qtype.getName()+", zone='"+bb2.d_name+"'");
+ throw PDNSException("Trying to insert non-zone data, name='"+bdr.qname+"', qtype="+qtype.getName()+", zone='"+bb2.d_name+"'");
bdr.qname.swap(bdr.qname);
try {
BP.parse(getArg("config"));
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
L<<Logger::Error<<"Error parsing bind configuration: "<<ae.reason<<endl;
throw;
}
// s_stage->id_zone_map[bbd->d_id].d_records->swap(*s_staging_zone_map[bbd->d_id].d_records);
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
ostringstream msg;
msg<<" error at "+nowTime()+" parsing '"<<i->name<<"' from file '"<<i->filename<<"': "<<ae.reason;
bbd->d_status="parsed into memory at "+nowTime();
L<<Logger::Warning<<"Zone '"<<bbd->d_name<<"' ("<<bbd->d_filename<<") reloaded"<<endl;
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
ostringstream msg;
msg<<" error at "+nowTime()+" parsing '"<<bbd->d_name<<"' from file '"<<bbd->d_filename<<"': "<<ae.reason;
bbd->d_status=msg.str();
db.doCommand(statement);
}
catch(SSqlException& se) {
- throw AhuException("Error creating database in BIND backend: "+se.txtReason());
+ throw PDNSException("Error creating database in BIND backend: "+se.txtReason());
}
}
}
}
catch(SSqlException& se) {
- throw AhuException("Error accessing DNSSEC database in BIND backend: "+se.txtReason());
+ throw PDNSException("Error accessing DNSSEC database in BIND backend: "+se.txtReason());
}
return true;
}
d_dnssecdb->doCommand((fmt2 % d_dnssecdb->escape(name) % d_dnssecdb->escape(kind) % d_dnssecdb->escape(meta.begin()->c_str())).str());
}
catch(SSqlException& se) {
- throw AhuException("Error accessing DNSSEC database in BIND backend: "+se.txtReason());
+ throw PDNSException("Error accessing DNSSEC database in BIND backend: "+se.txtReason());
}
return true;
}
}
catch(SSqlException& se) {
- throw AhuException("Error accessing DNSSEC database in BIND backend: "+se.txtReason());
+ throw PDNSException("Error accessing DNSSEC database in BIND backend: "+se.txtReason());
}
return true;
d_dnssecdb->doCommand((fmt % d_dnssecdb->escape(name) % key.flags % key.active % d_dnssecdb->escape(key.content)).str());
}
catch(SSqlException& se) {
- throw AhuException("Error accessing DNSSEC database in BIND backend: "+se.txtReason());
+ throw PDNSException("Error accessing DNSSEC database in BIND backend: "+se.txtReason());
}
return true;
d_dnssecdb->doCommand((fmt % d_dnssecdb->escape(name) % id).str());
}
catch(SSqlException& se) {
- throw AhuException("Error accessing DNSSEC database in BIND backend: "+se.txtReason());
+ throw PDNSException("Error accessing DNSSEC database in BIND backend: "+se.txtReason());
}
return true;
d_dnssecdb->doCommand((fmt % d_dnssecdb->escape(name) % id).str());
}
catch(SSqlException& se) {
- throw AhuException("Error accessing DNSSEC database in BIND backend: "+se.txtReason());
+ throw PDNSException("Error accessing DNSSEC database in BIND backend: "+se.txtReason());
}
return true;
d_dnssecdb->doQuery( (fmt % d_dnssecdb->escape(name)).str());
}
catch (SSqlException &e) {
- throw AhuException("BindBackend unable to retrieve named TSIG key: "+e.txtReason());
+ throw PDNSException("BindBackend unable to retrieve named TSIG key: "+e.txtReason());
}
SSql::row_t row;
else
cerr<<endl<<ae.what()<<endl;
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
if(!::arg().mustDo("on-error-resume-next"))
throw;
else
cerr<<num_domainsdone<<" domains were fully parsed, containing "<<g_numRecords<<" records\n";
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
cerr<<"\nFatal error: "<<ae.reason<<endl;
return 0;
}
callback(0, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority);
}
}
- catch( AhuException &ae )
+ catch( PDNSException &ae )
{
cerr << "Fatal error: " << ae.reason << endl;
if( !args.mustDo( "resume" ) )
callback(0, rr.qname, rr.qtype.getName(), rr.content, rr.ttl, rr.priority);
}
}
- catch( AhuException &ae )
+ catch( PDNSException &ae )
{
cerr << "Fatal error: " << ae.reason << endl;
return 1;
else
cerr<<endl<<ae.what()<<endl;
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
if(!::arg().mustDo("on-error-resume-next"))
throw;
else
cerr<<num_domainsdone<<" domains were fully parsed, containing "<<g_numRecords<<" records\n";
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
cerr<<"\nFatal error: "<<ae.reason<<endl;
return 0;
}
d_db->doCommand(output);
}
catch(SSqlException &e) {
- throw AhuException("GSQLBackend unable to refresh domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to refresh domain_id "+itoa(domain_id)+": "+e.txtReason());
}
}
d_db->doCommand(output);
}
catch (SSqlException &e) {
- throw AhuException("GSQLBackend unable to refresh domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to refresh domain_id "+itoa(domain_id)+": "+e.txtReason());
}
}
d_db->doQuery(output, d_result);
}
catch (SSqlException &e) {
- throw AhuException("GSQLBackend unable to retrieve list of master domains: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to retrieve list of master domains: "+e.txtReason());
}
if(d_result.empty())
d_db->doQuery(output,d_result);
}
catch(SSqlException &e) {
- throw AhuException("GSQLBackend unable to retrieve information about a domain: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to retrieve information about a domain: "+e.txtReason());
}
int numanswers=d_result.size();
else
di.serial=sd.serial;
}
- catch(AhuException &ae){
+ catch(PDNSException &ae){
L<<Logger::Error<<"Error retrieving serial for '"<<domain<<"': "<<ae.reason<<endl;
}
d_db->doQuery(d_InfoOfAllSlaveDomainsQuery, d_result);
}
catch (SSqlException &e) {
- throw AhuException("GSQLBackend unable to retrieve list of slave domains: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to retrieve list of slave domains: "+e.txtReason());
}
vector<DomainInfo> allSlaves;
d_db->doQuery(d_InfoOfAllMasterDomainsQuery,d_result);
}
catch(SSqlException &e) {
- throw AhuException("GSQLBackend unable to retrieve list of master domains: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to retrieve list of master domains: "+e.txtReason());
}
vector<DomainInfo> allMasters;
d_db->doCommand(output);
}
catch(SSqlException &e) {
- throw AhuException("GSQLBackend unable to update ordername/auth for domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to update ordername/auth for domain_id "+itoa(domain_id)+": "+e.txtReason());
}
return true;
}
d_db->doCommand(output);
}
catch(SSqlException &e) {
- throw AhuException("GSQLBackend unable to nullify ordername and update auth for domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to nullify ordername and update auth for domain_id "+itoa(domain_id)+": "+e.txtReason());
}
return true;
}
d_db->doCommand(output);
}
catch(SSqlException &e) {
- throw AhuException("GSQLBackend unable to nullify ordername/auth for domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to nullify ordername/auth for domain_id "+itoa(domain_id)+": "+e.txtReason());
}
return true;
}
d_db->doCommand(output);
}
catch(SSqlException &e) {
- throw AhuException("GSQLBackend unable to set auth on DS record "+qname+" for domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to set auth on DS record "+qname+" for domain_id "+itoa(domain_id)+": "+e.txtReason());
}
return true;
}
d_db->doCommand(output);
}
catch (SSqlException &e) {
- throw AhuException("GSQLBackend unable to delete empty non-terminal records from domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to delete empty non-terminal records from domain_id "+itoa(domain_id)+": "+e.txtReason());
return false;
}
}
d_db->doCommand(output);
}
catch (SSqlException &e) {
- throw AhuException("GSQLBackend unable to delete empty non-terminal rr "+qname+" from domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to delete empty non-terminal rr "+qname+" from domain_id "+itoa(domain_id)+": "+e.txtReason());
return false;
}
}
d_db->doCommand(output);
}
catch (SSqlException &e) {
- throw AhuException("GSQLBackend unable to insert empty non-terminal rr "+qname+" in domain_id "+itoa(domain_id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to insert empty non-terminal rr "+qname+" in domain_id "+itoa(domain_id)+": "+e.txtReason());
return false;
}
}
d_db->doQuery(output);
}
catch(SSqlException &e) {
- throw AhuException("GSQLBackend unable to find before/after (after) for domain_id "+itoa(id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to find before/after (after) for domain_id "+itoa(id)+": "+e.txtReason());
}
while(d_db->getRow(row)) {
after=row[0];
d_db->doQuery(output);
}
catch(SSqlException &e) {
- throw AhuException("GSQLBackend unable to find before/after (first) for domain_id "+itoa(id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to find before/after (first) for domain_id "+itoa(id)+": "+e.txtReason());
}
while(d_db->getRow(row)) {
after=row[0];
d_db->doQuery(output);
}
catch(SSqlException &e) {
- throw AhuException("GSQLBackend unable to find before/after (before) for domain_id "+itoa(id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to find before/after (before) for domain_id "+itoa(id)+": "+e.txtReason());
}
while(d_db->getRow(row)) {
before=row[0];
d_db->doQuery(output);
}
catch(SSqlException &e) {
- throw AhuException("GSQLBackend unable to find before/after (last) for domain_id "+itoa(id)+": "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to find before/after (last) for domain_id "+itoa(id)+": "+e.txtReason());
}
while(d_db->getRow(row)) {
before=row[0];
d_db->doCommand(output);
}
catch (SSqlException &e) {
- throw AhuException("GSQLBackend unable to store key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to store key: "+e.txtReason());
}
return 1; // XXX FIXME, no idea how to get the id
}
d_db->doCommand(output);
}
catch (SSqlException &e) {
- throw AhuException("GSQLBackend unable to activate key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to activate key: "+e.txtReason());
}
return true;
}
d_db->doCommand(output);
}
catch (SSqlException &e) {
- throw AhuException("GSQLBackend unable to deactivate key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to deactivate key: "+e.txtReason());
}
return true;
}
d_db->doCommand(output);
}
catch (SSqlException &e) {
- throw AhuException("GSQLBackend unable to remove key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to remove key: "+e.txtReason());
}
return true;
}
d_db->doQuery(output);
}
catch (SSqlException &e) {
- throw AhuException("GSQLBackend unable to retrieve named TSIG key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to retrieve named TSIG key: "+e.txtReason());
}
SSql::row_t row;
d_db->doQuery(output);
}
catch (SSqlException &e) {
- throw AhuException("GSQLBackend unable to list keys: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to list keys: "+e.txtReason());
}
SSql::row_t row;
d_db->doQuery(output);
}
catch (SSqlException &e) {
- throw AhuException("GSQLBackend unable to list metadata: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to list metadata: "+e.txtReason());
}
SSql::row_t row;
d_db->doCommand(output);
}
catch (SSqlException &e) {
- throw AhuException("GSQLBackend unable to store metadata key: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to store metadata key: "+e.txtReason());
}
return true;
d_db->doQuery(output);
}
catch(SSqlException &e) {
- throw AhuException(e.txtReason());
+ throw PDNSException(e.txtReason());
}
d_qname=qname;
d_db->doQuery(output);
}
catch(SSqlException &e) {
- throw AhuException("GSQLBackend list query: "+e.txtReason());
+ throw PDNSException("GSQLBackend list query: "+e.txtReason());
}
d_qname="";
d_db->doQuery(output, d_result);
}
catch (SSqlException &e) {
- throw AhuException("GSQLBackend unable to search for a domain: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to search for a domain: "+e.txtReason());
}
if(!d_result.empty()) {
d_db->doCommand(output);
}
catch(SSqlException &e) {
- throw AhuException("Database error trying to insert new slave '"+domain+"': "+ e.txtReason());
+ throw PDNSException("Database error trying to insert new slave '"+domain+"': "+ e.txtReason());
}
return true;
}
d_db->doQuery(d_getAllDomainsQuery.c_str());
}
catch (SSqlException &e) {
- throw AhuException("Database error trying to retrieve all domains:" + e.txtReason());
+ throw PDNSException("Database error trying to retrieve all domains:" + e.txtReason());
}
SSql::row_t row;
d_db->doCommand(output.c_str());
}
catch (SSqlException &e) {
- throw AhuException("GSQLBackend unable to feed record: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to feed record: "+e.txtReason());
}
return true; // XXX FIXME this API should not return 'true' I think -ahu
}
d_db->doCommand(output.c_str());
}
catch (SSqlException &e) {
- throw AhuException("GSQLBackend unable to feed empty non-terminal: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to feed empty non-terminal: "+e.txtReason());
}
}
return true;
d_db->doCommand(output.c_str());
}
catch (SSqlException &e) {
- throw AhuException("GSQLBackend unable to feed empty non-terminal: "+e.txtReason());
+ throw PDNSException("GSQLBackend unable to feed empty non-terminal: "+e.txtReason());
}
}
return true;
d_db->doCommand(output);
}
catch (SSqlException &e) {
- throw AhuException("Database failed to start transaction: "+e.txtReason());
+ throw PDNSException("Database failed to start transaction: "+e.txtReason());
}
return true;
d_db->doCommand("commit");
}
catch (SSqlException &e) {
- throw AhuException("Database failed to commit transaction: "+e.txtReason());
+ throw PDNSException("Database failed to commit transaction: "+e.txtReason());
}
return true;
}
d_db->doCommand("rollback");
}
catch(SSqlException &e) {
- throw AhuException("Database failed to abort transaction: "+string(e.txtReason()));
+ throw PDNSException("Database failed to abort transaction: "+string(e.txtReason()));
}
return true;
}
}
}
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
L<<Logger::Error<<"Exiting because communicator thread died with error: "<<ae.reason<<endl;
Utility::sleep(1);
exit(0);
a=b->question(q); // a can be NULL!
delete q;
}
- catch(const AhuException &e) {
+ catch(const PDNSException &e) {
L<<Logger::Error<<"Backend error: "<<e.reason<<endl;
delete b;
return 0;
delete b;
}
- catch(const AhuException &AE) {
+ catch(const PDNSException &AE) {
L<<Logger::Error<<Logger::NTLog<<"Distributor caught fatal exception: "<<AE.reason<<endl;
}
catch(...) {
try {
a=b->question(q); // a can be NULL!
}
- catch(const AhuException &e) {
+ catch(const PDNSException &e) {
L<<Logger::Error<<"Backend error: "<<e.reason<<endl;
delete b;
b=0;
{
vector<DNSBackend *>ret;
if(d_instances.empty())
- throw AhuException("No database backends configured for launch, unable to function");
+ throw PDNSException("No database backends configured for launch, unable to function");
try {
for(vector<pair<string,string> >::const_iterator i=d_instances.begin();i!=d_instances.end();++i) {
else
made = d_repository[i->first]->make(i->second);
if(!made)
- throw AhuException("Unable to launch backend '"+i->first+"'");
+ throw PDNSException("Unable to launch backend '"+i->first+"'");
ret.push_back(made);
}
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
L<<Logger::Error<<"Caught an exception instantiating a backend: "<<ae.reason<<endl;
L<<Logger::Error<<"Cleaning up"<<endl;
for(vector<DNSBackend *>::const_iterator i=ret.begin();i!=ret.end();++i)
issues should lead to DBExceptions.
More serious errors, which may indicate that the database connection is hosed, or a configuration error occurred, should
- lead to the throwing of an AhuException. This exception will fall straight through the UeberBackend and the PacketHandler
+ lead to the throwing of an PDNSException. This exception will fall straight through the UeberBackend and the PacketHandler
and be caught by the Distributor, which will delete your DNSBackend instance and spawn a new one.
*/
class DNSBackend
extern BackendMakerClass &BackendMakers();
//! Exception that can be thrown by a DNSBackend to indicate a failure
-class DBException : public AhuException
+class DBException : public PDNSException
{
public:
- DBException(const string &reason) : AhuException(reason){}
+ DBException(const string &reason) : PDNSException(reason){}
};
{
errlog("Fatal: %s", e.what());
}
-catch(AhuException &ae)
+catch(PDNSException &ae)
{
errlog("Fatal: %s", ae.reason);
}
ComboAddress remaddr(remote, 53);
if((d_sock=socket(remaddr.sin4.sin_family, SOCK_DGRAM,0))<0)
- throw AhuException(string("socket: ")+strerror(errno));
+ throw PDNSException(string("socket: ")+strerror(errno));
ComboAddress local;
if(remaddr.sin4.sin_family==AF_INET)
if(n==10) {
Utility::closesocket(d_sock);
d_sock=-1;
- throw AhuException(string("binding dnsproxy socket: ")+strerror(errno));
+ throw PDNSException(string("binding dnsproxy socket: ")+strerror(errno));
}
if(connect(d_sock, (sockaddr *)&remaddr, remaddr.getSocklen())<0)
- throw AhuException("Unable to UDP connect to remote nameserver "+remaddr.toStringWithPort()+": "+stringerror());
+ throw PDNSException("Unable to UDP connect to remote nameserver "+remaddr.toStringWithPort()+": "+stringerror());
d_xor=Utility::random()&0xffff;
L<<Logger::Error<<"DNS Proxy launched, local port "<<ntohs(local.sin4.sin_port)<<", remote "<<remaddr.toStringWithPort()<<endl;
}
}
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
L<<Logger::Error<<"Fatal error in DNS proxy: "<<ae.reason<<endl;
}
catch(std::exception &e) {
}
if(sock.read((char *) &len, 2) != 2)
- throw AhuException("tcp read failed");
+ throw PDNSException("tcp read failed");
len=ntohs(len);
char *creply = new char[len];
while(n<len) {
numread=sock.read(creply+n, len-n);
if(numread<0)
- throw AhuException("tcp read failed");
+ throw PDNSException("tcp read failed");
n+=numread;
}
P.getBackend()->rediscover(&status);
return status;
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
return ae.reason;
}
int tmp=1;
if(setsockopt(d_s,SOL_SOCKET,SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0)
- throw AhuException(string("Setsockopt failed on control socket: ")+strerror(errno));
+ throw PDNSException(string("Setsockopt failed on control socket: ")+strerror(errno));
if(bind(d_s, local, len) < 0) {
if (family == AF_UNIX)
else {
if(isatty(0))
if(write(1, "% ", 2) !=2)
- throw AhuException("Writing to console: "+stringerror());
+ throw PDNSException("Writing to console: "+stringerror());
if((len=read(0, &mesg[0], mesg.size())) < 0)
- throw AhuException("Reading from the control pipe: "+stringerror());
+ throw PDNSException("Reading from the control pipe: "+stringerror());
else if(len==0)
- throw AhuException("Guardian exited - going down as well");
+ throw PDNSException("Guardian exited - going down as well");
if(len == (int)mesg.size()) {
- throw AhuException("Line on control console was too long");
+ throw PDNSException("Line on control console was too long");
}
mesg[len]=0;
}
sendLine((*(s_funcdb[parts[0]].func))(parts,d_ppid));
}
}
- catch(AhuException &AE)
+ catch(PDNSException &AE)
{
L<<Logger::Error<<"Fatal error in control listener: "<<AE.reason<<endl;
}
cout<<resp<<endl;
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
cerr<<"Fatal error: "<<ae.reason<<endl;
return 1;
}
Utility::setCloseOnExec(d_s);
if(d_s<0) {
- throw AhuException(string("socket")+strerror(errno));
+ throw PDNSException(string("socket")+strerror(errno));
}
memset(&d_local,0,sizeof(d_local));
strcpy(d_local.sun_path,localname.c_str());
if(mkstemp(d_local.sun_path)<0)
- throw AhuException("Unable to generate local temporary file: "+string(strerror(errno)));
+ throw PDNSException("Unable to generate local temporary file: "+string(strerror(errno)));
unlink(d_local.sun_path);
if(bind(d_s, (sockaddr*)&d_local,sizeof(d_local))<0) {
unlink(d_local.sun_path);
- throw AhuException("Unable to bind to local temporary file: "+string(strerror(errno)));
+ throw PDNSException("Unable to bind to local temporary file: "+string(strerror(errno)));
}
if(chmod(d_local.sun_path,0666)<0) { // make sure that pdns can reply!
strcpy(d_remote.sun_path,fname.c_str());
if(connect(d_s,(sockaddr*)&d_remote,sizeof(d_remote))<0) {
unlink(d_local.sun_path);
- throw AhuException("Unable to connect to remote '"+fname+"': "+string(strerror(errno)));
+ throw PDNSException("Unable to connect to remote '"+fname+"': "+string(strerror(errno)));
}
}
Utility::setCloseOnExec(d_s);
if(d_s<0) {
- throw AhuException(string("socket")+strerror(errno));
+ throw PDNSException(string("socket")+strerror(errno));
}
if(connect(d_s, (sockaddr*)&remote, remote.getSocklen())<0) {
close(d_s);
- throw AhuException("Unable to connect to remote '"+remote.toStringWithPort()+"': "+string(strerror(errno)));
+ throw PDNSException("Unable to connect to remote '"+remote.toStringWithPort()+"': "+string(strerror(errno)));
}
string login=secret+"\n";
for(;;) {
retlen=recv(d_s,buffer,sizeof(buffer),0);
if(retlen<0)
- throw AhuException("Error from remote: "+string(strerror(errno)));
+ throw PDNSException("Error from remote: "+string(strerror(errno)));
answer.append(buffer,retlen);
if(retlen!=sizeof(buffer))
if(makeIPv4sockaddr(str, &sin4)) {
sin6.sin6_family = AF_INET6;
if(makeIPv6sockaddr(str, &sin6) < 0)
- throw AhuException("Unable to convert presentation address '"+ str +"'");
+ throw PDNSException("Unable to convert presentation address '"+ str +"'");
}
if(!sin4.sin_port) // 'str' overrides port!
ComboAddress mapToIPv4() const
{
if(!isMappedIPv4())
- throw AhuException("ComboAddress can't map non-mapped IPv6 address back to IPv4");
+ throw PDNSException("ComboAddress can't map non-mapped IPv6 address back to IPv4");
ComboAddress ret;
ret.sin4.sin_family=AF_INET;
ret.sin4.sin_port=sin4.sin_port;
};
/** This exception is thrown by the Netmask class and by extension by the NetmaskGroup class */
-class NetmaskException: public AhuException
+class NetmaskException: public PDNSException
{
public:
- NetmaskException(const string &a) : AhuException(a) {}
+ NetmaskException(const string &a) : PDNSException(a) {}
};
inline ComboAddress makeComboAddress(const string& str)
if(g_singleThreaded)
return;
if((errno=pthread_mutex_lock(d_lock)))
- throw AhuException("error acquiring lock: "+stringerror());
+ throw PDNSException("error acquiring lock: "+stringerror());
}
~Lock()
{
return;
if((errno=pthread_rwlock_wrlock(d_lock))) {
- throw AhuException("error acquiring rwlock wrlock: "+stringerror());
+ throw PDNSException("error acquiring rwlock wrlock: "+stringerror());
}
}
~WriteLock()
d_havelock=false;
if((errno=pthread_rwlock_trywrlock(d_lock)) && errno!=EBUSY)
- throw AhuException("error acquiring rwlock tryrwlock: "+stringerror());
+ throw PDNSException("error acquiring rwlock tryrwlock: "+stringerror());
d_havelock=(errno==0);
}
~TryWriteLock()
}
if((errno=pthread_rwlock_tryrdlock(d_lock)) && errno!=EBUSY)
- throw AhuException("error acquiring rwlock tryrdlock: "+stringerror());
+ throw PDNSException("error acquiring rwlock tryrdlock: "+stringerror());
d_havelock=(errno==0);
}
~TryReadLock()
return;
if((errno=pthread_rwlock_rdlock(d_lock)))
- throw AhuException("error acquiring rwlock tryrwlock: "+stringerror());
+ throw PDNSException("error acquiring rwlock tryrwlock: "+stringerror());
}
~ReadLock()
{
int arecvfrom(char *data, int len, int flags, const ComboAddress& ip, int *d_len, uint16_t id,
const string& domain, uint16_t, int fd, struct timeval* now);
-class LWResException : public AhuException
+class LWResException : public PDNSException
{
public:
- LWResException(const string &reason) : AhuException(reason){}
+ LWResException(const string &reason) : PDNSException(reason){}
};
//! LWRes class
vector<string>parts;
stringtok(parts,descr,":");
if(parts.empty())
- throw AhuException("Unable to parse '"+descr+"' as a service");
+ throw PDNSException("Unable to parse '"+descr+"' as a service");
st.host=parts[0];
if(parts.size()>1)
st.port=atoi(parts[1].c_str());
{
string::size_type pos=descr.find(']');
if(pos == string::npos)
- throw AhuException("Unable to parse '"+descr+"' as an IPv6 service");
+ throw PDNSException("Unable to parse '"+descr+"' as an IPv6 service");
st.host=descr.substr(1, pos-1);
if(pos + 2 < descr.length())
void parseService(const string &descr, ServiceTuple &st)
{
if(descr.empty())
- throw AhuException("Unable to parse '"+descr+"' as a service");
+ throw PDNSException("Unable to parse '"+descr+"' as a service");
vector<string> parts;
stringtok(parts, descr, ":");
Regex::Regex(const string &expr)
{
if(regcomp(&d_preg, expr.c_str(), REG_ICASE|REG_NOSUB|REG_EXTENDED))
- throw AhuException("Regular expression did not compile");
+ throw PDNSException("Regular expression did not compile");
}
\section overview High level overview
The Distributor contains a configurable number of PacketHandler instances, each in its own thread, for connection pooling.
- PacketHandler instances are recycled of they let escape an AhuException.
+ PacketHandler instances are recycled of they let escape an PDNSException.
The PacketHandler implements the RFC1034 algorithm and converts question packets into DNSBackend queries.
stringtok(locals,::arg()["local-address"]," ,");
if(locals.empty())
- throw AhuException("No local address specified");
+ throw PDNSException("No local address specified");
int s;
for(vector<string>::const_iterator i=locals.begin();i!=locals.end();++i) {
s=socket(AF_INET,SOCK_DGRAM,0);
if(s<0)
- throw AhuException("Unable to acquire a UDP socket: "+string(strerror(errno)));
+ throw PDNSException("Unable to acquire a UDP socket: "+string(strerror(errno)));
Utility::setCloseOnExec(s);
if(!Utility::setNonBlocking(s))
- throw AhuException("Unable to set UDP socket to non-blocking: "+stringerror());
+ throw PDNSException("Unable to set UDP socket to non-blocking: "+stringerror());
memset(&locala,0,sizeof(locala));
locala.sin4.sin_family=AF_INET;
}
locala=ComboAddress(localname, ::arg().asNum("local-port"));
if(locala.sin4.sin_family != AF_INET)
- throw AhuException("Attempting to bind IPv4 socket to IPv6 address");
+ throw PDNSException("Attempting to bind IPv4 socket to IPv6 address");
g_localaddresses.push_back(locala);
if(::bind(s, (sockaddr*)&locala, locala.getSocklen()) < 0) {
L<<Logger::Error<<"binding UDP socket to '"+locala.toStringWithPort()+": "<<strerror(errno)<<endl;
- throw AhuException("Unable to bind to UDP socket");
+ throw PDNSException("Unable to bind to UDP socket");
}
d_sockets.push_back(s);
L<<Logger::Error<<"UDP server bound to "<<locala.toStringWithPort()<<endl;
s=socket(AF_INET6,SOCK_DGRAM,0);
if(s<0)
- throw AhuException("Unable to acquire a UDPv6 socket: "+string(strerror(errno)));
+ throw PDNSException("Unable to acquire a UDPv6 socket: "+string(strerror(errno)));
Utility::setCloseOnExec(s);
if(!Utility::setNonBlocking(s))
- throw AhuException("Unable to set UDPv6 socket to non-blocking: "+stringerror());
+ throw PDNSException("Unable to set UDPv6 socket to non-blocking: "+stringerror());
ComboAddress locala(localname, ::arg().asNum("local-port"));
g_localaddresses.push_back(locala);
if(::bind(s, (sockaddr*)&locala, sizeof(locala))<0) {
L<<Logger::Error<<"binding to UDP ipv6 socket: "<<strerror(errno)<<endl;
- throw AhuException("Unable to bind to UDP ipv6 socket");
+ throw PDNSException("Unable to bind to UDP ipv6 socket");
}
d_sockets.push_back(s);
struct pollfd pfd;
}
}
if(sock==-1)
- throw AhuException("poll betrayed us! (should not happen)");
+ throw PDNSException("poll betrayed us! (should not happen)");
DLOG(L<<"Received a packet " << len <<" bytes long from "<< remote.toString()<<endl);
{
syslogFmt(boost::format("Fatal: %s") % e.what());
}
-catch(AhuException& e)
+catch(PDNSException& e)
{
syslogFmt(boost::format("Fatal: %s") % e.reason);
}
uint16_t len;
len = htons(packet.size());
if(sock.write((char *) &len, 2) != 2)
- throw AhuException("tcp write failed");
+ throw PDNSException("tcp write failed");
sock.writen(string((char*)&*packet.begin(), (char*)&*packet.end()));
if(sock.read((char *) &len, 2) != 2)
- throw AhuException("tcp read failed");
+ throw PDNSException("tcp read failed");
len=ntohs(len);
char *creply = new char[len];
while(n<len) {
numread=sock.read(creply+n, len-n);
if(numread<0)
- throw AhuException("tcp read failed");
+ throw PDNSException("tcp read failed");
n+=numread;
}
try {
db->createSlaveDomain(p->getRemote(),p->qdomain,account);
}
- catch(AhuException& ae) {
+ catch(PDNSException& ae) {
L<<Logger::Error<<"Database error trying to create "<<p->qdomain<<" for potential supermaster "<<p->getRemote()<<": "<<ae.reason<<endl;
return RCode::ServFail;
}
S.inc("servfail-packets");
S.ringAccount("servfail-queries",p->qdomain);
}
- catch(AhuException &e) {
+ catch(PDNSException &e) {
L<<Logger::Error<<"Backend reported permanent error which prevented lookup ("+e.reason+") sending out servfail"<<endl;
throw; // we WANT to die at this point
}
{
socks_t::iterator i=d_socks.find(fd);
if(i==d_socks.end()) {
- throw AhuException("Trying to return a socket (fd="+lexical_cast<string>(fd)+") not in the pool");
+ throw PDNSException("Trying to return a socket (fd="+lexical_cast<string>(fd)+") not in the pool");
}
returnSocketLocked(i);
}
void returnSocketLocked(socks_t::iterator& i)
{
if(i==d_socks.end()) {
- throw AhuException("Trying to return a socket not in the pool");
+ throw PDNSException("Trying to return a socket not in the pool");
}
try {
t_fdm->removeReadFD(*i);
return ret;
if(ret<0)
- throw AhuException("Making a socket for resolver (family = "+lexical_cast<string>(family)+"): "+stringerror());
+ throw PDNSException("Making a socket for resolver (family = "+lexical_cast<string>(family)+"): "+stringerror());
Utility::setCloseOnExec(ret);
break;
}
if(!tries)
- throw AhuException("Resolver binding to local query client socket: "+stringerror());
+ throw PDNSException("Resolver binding to local query client socket: "+stringerror());
Utility::setNonBlocking(ret);
return ret;
delete dc;
dc=0;
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
L<<Logger::Error<<"startDoResolve problem"<<loginfo<<": "<<ae.reason<<endl;
delete dc;
}
stringtok(locals,::arg()["local-address"]," ,");
if(locals.empty())
- throw AhuException("No local address specified");
+ throw PDNSException("No local address specified");
for(vector<string>::const_iterator i=locals.begin();i!=locals.end();++i) {
ServiceTuple st;
if(!IpToU32(st.host, (uint32_t*)&sin.sin4.sin_addr.s_addr)) {
sin.sin6.sin6_family = AF_INET6;
if(makeIPv6sockaddr(st.host, &sin.sin6) < 0)
- throw AhuException("Unable to resolve local address for TCP server on '"+ st.host +"'");
+ throw PDNSException("Unable to resolve local address for TCP server on '"+ st.host +"'");
}
fd=socket(sin.sin6.sin6_family, SOCK_STREAM, 0);
Utility::setCloseOnExec(fd);
if(fd<0)
- throw AhuException("Making a TCP server socket for resolver: "+stringerror());
+ throw PDNSException("Making a TCP server socket for resolver: "+stringerror());
int tmp=1;
if(setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0) {
sin.sin4.sin_port = htons(st.port);
int socklen=sin.sin4.sin_family==AF_INET ? sizeof(sin.sin4) : sizeof(sin.sin6);
if (::bind(fd, (struct sockaddr *)&sin, socklen )<0)
- throw AhuException("Binding TCP server socket for "+ st.host +": "+stringerror());
+ throw PDNSException("Binding TCP server socket for "+ st.host +": "+stringerror());
Utility::setNonBlocking(fd);
setSocketSendBuffer(fd, 65000);
stringtok(locals,::arg()["local-address"]," ,");
if(locals.empty())
- throw AhuException("No local address specified");
+ throw PDNSException("No local address specified");
if(::arg()["local-address"]=="0.0.0.0") {
L<<Logger::Warning<<"It is advised to bind to explicit addresses with the --local-address option"<<endl;
if(!IpToU32(st.host.c_str() , (uint32_t*)&sin.sin4.sin_addr.s_addr)) {
sin.sin6.sin6_family = AF_INET6;
if(makeIPv6sockaddr(st.host, &sin.sin6) < 0)
- throw AhuException("Unable to resolve local address for UDP server on '"+ st.host +"'");
+ throw PDNSException("Unable to resolve local address for UDP server on '"+ st.host +"'");
}
int fd=socket(sin.sin4.sin_family, SOCK_DGRAM, 0);
Utility::setCloseOnExec(fd);
if(fd < 0) {
- throw AhuException("Making a UDP server socket for resolver: "+netstringerror());
+ throw PDNSException("Making a UDP server socket for resolver: "+netstringerror());
}
setSocketReceiveBuffer(fd, 200000);
int socklen=sin.sin4.sin_family==AF_INET ? sizeof(sin.sin4) : sizeof(sin.sin6);
if (::bind(fd, (struct sockaddr *)&sin, socklen)<0)
- throw AhuException("Resolver binding to server socket on port "+ lexical_cast<string>(st.port) +" for "+ st.host+": "+stringerror());
+ throw PDNSException("Resolver binding to server socket on port "+ lexical_cast<string>(st.port) +" for "+ st.host+": "+stringerror());
Utility::setNonBlocking(fd);
L<<Logger::Error<<"Failed to update . records, RCODE="<<res<<endl;
}
}
-catch(AhuException& ae)
+catch(PDNSException& ae)
{
L<<Logger::Error<<"Fatal error: "<<ae.reason<<endl;
throw;
catch(std::exception& e) {
L<<Logger::Error<<"Error dealing with control socket request: "<<e.what()<<endl;
}
- catch(AhuException& ae) {
+ catch(PDNSException& ae) {
L<<Logger::Error<<"Error dealing with control socket request: "<<ae.reason<<endl;
}
}
return new string("ok\n");
}
}
-catch(AhuException& ae)
+catch(PDNSException& ae)
{
return new string(ae.reason+"\n");
}
}
}
}
-catch(AhuException &ae) {
+catch(PDNSException &ae) {
L<<Logger::Error<<"Exception: "<<ae.reason<<endl;
return 0;
}
#endif
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
L<<Logger::Error<<"Exception: "<<ae.reason<<endl;
ret=EXIT_FAILURE;
}
try {
Bind2Backend::createDNSSECDB(cmds[1]);
}
- catch (AhuException& ae) {
+ catch (PDNSException& ae) {
cerr<<"Error: "<<ae.reason<<endl;
return 1;
}
}
return 0;
}
-catch(AhuException& ae) {
+catch(PDNSException& ae) {
cerr<<"Error: "<<ae.reason<<endl;
}
catch(std::exception& e) {
L << Logger::Info << Logger::NTLog << "PowerDNS " << VERSION << " (C) 2001-2003 PowerDNS.COM BV (" << __DATE__ ", " __TIME__<< ") starting up" << endl;
mainthread();
}
- catch(AhuException &AE) {
+ catch(PDNSException &AE) {
if(!PDNSService::isRunningAsService())
cerr<<"Exiting because: "<<AE.reason<<endl;
L<<Logger::Error<<Logger::NTLog<<"Exiting because: "<<AE.reason<<endl;
Utility::setCloseOnExec(d_fd);
if(d_fd < 0)
- throw AhuException("Creating UNIX domain socket: "+string(strerror(errno)));
+ throw PDNSException("Creating UNIX domain socket: "+string(strerror(errno)));
int tmp=1;
if(setsockopt(d_fd, SOL_SOCKET, SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0)
- throw AhuException(string("Setsockopt failed: ")+strerror(errno));
+ throw PDNSException(string("Setsockopt failed: ")+strerror(errno));
int err=unlink(fname.c_str());
if(err < 0 && errno!=ENOENT)
- throw AhuException("Can't remove (previous) controlsocket '"+fname+"': "+string(strerror(errno)) + " (try --socket-dir)");
+ throw PDNSException("Can't remove (previous) controlsocket '"+fname+"': "+string(strerror(errno)) + " (try --socket-dir)");
memset(&d_local,0,sizeof(d_local));
d_local.sun_family=AF_UNIX;
strcpy(d_local.sun_path, fname.c_str());
if(bind(d_fd, (sockaddr*)&d_local,sizeof(d_local))<0)
- throw AhuException("Unable to bind to controlsocket '"+fname+"': "+string(strerror(errno)));
+ throw PDNSException("Unable to bind to controlsocket '"+fname+"': "+string(strerror(errno)));
return d_fd;
}
Utility::setCloseOnExec(d_fd);
if(d_fd < 0)
- throw AhuException("Creating UNIX domain socket: "+string(strerror(errno)));
+ throw PDNSException("Creating UNIX domain socket: "+string(strerror(errno)));
int tmp=1;
if(setsockopt(d_fd, SOL_SOCKET, SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0) {
close(d_fd);
d_fd=-1;
- throw AhuException(string("Setsockopt failed: ")+strerror(errno));
+ throw PDNSException(string("Setsockopt failed: ")+strerror(errno));
}
string localname=path+"/lsockXXXXXX";
close(d_fd);
d_fd=-1;
d_local.sun_path[0]=0;
- throw AhuException("Unable to generate local temporary file in directory '"+path+"': "+string(strerror(errno)));
+ throw PDNSException("Unable to generate local temporary file in directory '"+path+"': "+string(strerror(errno)));
}
d_local.sun_family=AF_UNIX;
int err=unlink(d_local.sun_path);
if(err < 0 && errno!=ENOENT)
- throw AhuException("Unable to remove local controlsocket: "+string(strerror(errno)));
+ throw PDNSException("Unable to remove local controlsocket: "+string(strerror(errno)));
if(bind(d_fd, (sockaddr*)&d_local,sizeof(d_local))<0) {
unlink(d_local.sun_path);
close(d_fd);
d_fd=-1;
- throw AhuException("Unable to bind to local temporary file: "+string(strerror(errno)));
+ throw PDNSException("Unable to bind to local temporary file: "+string(strerror(errno)));
}
if(chmod(d_local.sun_path,0666)<0) { // make sure that pdns can reply!
unlink(d_local.sun_path);
- throw AhuException("Unable to chmnod local temporary socket: "+string(strerror(errno)));
+ throw PDNSException("Unable to chmnod local temporary socket: "+string(strerror(errno)));
}
memset(&remote,0,sizeof(remote));
strcpy(remote.sun_path,(path+"/"+fname).c_str());
if(::connect(d_fd, (sockaddr*)&remote, sizeof(remote)) < 0) {
unlink(d_local.sun_path);
- throw AhuException("Unable to connect to remote '"+path+fname+"': "+string(strerror(errno)));
+ throw PDNSException("Unable to connect to remote '"+path+fname+"': "+string(strerror(errno)));
}
}
strcpy(remoteaddr.sun_path, remote->c_str());
if(::sendto(d_fd, msg.c_str(), msg.length(), 0, (struct sockaddr*) &remoteaddr, sizeof(remoteaddr) ) < 0)
- throw AhuException("Unable to send message over control channel '"+*remote+"': "+string(strerror(errno)));
+ throw PDNSException("Unable to send message over control channel '"+*remote+"': "+string(strerror(errno)));
}
else if(::send(d_fd, msg.c_str(), msg.length(), 0) < 0)
- throw AhuException("Unable to send message over control channel: "+string(strerror(errno)));
+ throw PDNSException("Unable to send message over control channel: "+string(strerror(errno)));
}
string RecursorControlChannel::recv(std::string* remote, unsigned int timeout)
socklen_t addrlen=sizeof(remoteaddr);
if((waitForData(d_fd, timeout, 0 ) != 1) || (len=::recvfrom(d_fd, buffer, sizeof(buffer), 0, (struct sockaddr*)&remoteaddr, &addrlen)) < 0)
- throw AhuException("Unable to receive message over control channel: "+string(strerror(errno)));
+ throw PDNSException("Unable to receive message over control channel: "+string(strerror(errno)));
if(remote)
*remote=remoteaddr.sun_path;
L<<Logger::Error<<"reloading ACLs failed (Exception: "<<e.what()<<")"<<endl;
return e.what() + string("\n");
}
- catch(AhuException& ae)
+ catch(PDNSException& ae)
{
- L<<Logger::Error<<"reloading ACLs failed (AhuException: "<<ae.reason<<")"<<endl;
+ L<<Logger::Error<<"reloading ACLs failed (PDNSException: "<<ae.reason<<")"<<endl;
return ae.reason + string("\n");
}
return "ok\n";
cout<<receive;
return 0;
}
-catch(AhuException& ae)
+catch(PDNSException& ae)
{
cerr<<"Fatal: "<<ae.reason<<"\n";
return 1;
try {
writen2(g_fd1[1],line.c_str(),line.size()+1);
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
return "Error communicating with instance: "+ae.reason;
}
char mesg[512];
try {
mainthread();
}
- catch(AhuException &AE) {
+ catch(PDNSException &AE) {
if(!::arg().mustDo("daemon"))
cerr<<"Exiting because: "<<AE.reason<<endl;
L<<Logger::Error<<"Exiting because: "<<AE.reason<<endl;
catch(std::exception& e) {
L<<Logger::Error<<"Had error reloading zones, keeping original data: "<<e.what()<<endl;
}
- catch(AhuException& ae) {
+ catch(PDNSException& ae) {
L<<Logger::Error<<"Encountered error reloading zones, keeping original data: "<<ae.reason<<endl;
}
catch(...) {
}
catch(std::exception &e) {
delete newMap;
- throw AhuException("Error parsing record '"+rr.qname+"' of type "+rr.qtype.getName()+" in zone '"+headers.first+"' from file '"+headers.second+"': "+e.what());
+ throw PDNSException("Error parsing record '"+rr.qname+"' of type "+rr.qtype.getName()+" in zone '"+headers.first+"' from file '"+headers.second+"': "+e.what());
}
catch(...) {
delete newMap;
- throw AhuException("Error parsing record '"+rr.qname+"' of type "+rr.qtype.getName()+" in zone '"+headers.first+"' from file '"+headers.second+"'");
+ throw PDNSException("Error parsing record '"+rr.qname+"' of type "+rr.qtype.getName()+" in zone '"+headers.first+"' from file '"+headers.second+"'");
}
ad.d_records.insert(rr);
if(!rfp) {
delete newMap;
- throw AhuException("Error opening forward-zones-file '"+::arg()["forward-zones-file"]+"': "+stringerror());
+ throw PDNSException("Error opening forward-zones-file '"+::arg()["forward-zones-file"]+"': "+stringerror());
}
shared_ptr<FILE> fp=shared_ptr<FILE>(rfp, fclose);
ad.d_rdForward = false;
if(domain.empty()) {
delete newMap;
- throw AhuException("Error parsing line "+lexical_cast<string>(linenum)+" of " +::arg()["forward-zones-file"]);
+ throw PDNSException("Error parsing line "+lexical_cast<string>(linenum)+" of " +::arg()["forward-zones-file"]);
}
try {
}
catch(...) {
delete newMap;
- throw AhuException("Conversion error parsing line "+lexical_cast<string>(linenum)+" of " +::arg()["forward-zones-file"]);
+ throw PDNSException("Conversion error parsing line "+lexical_cast<string>(linenum)+" of " +::arg()["forward-zones-file"]);
}
(*newMap)[toCanonic("", domain)]=ad;
if(!tries) {
Utility::closesocket(sock);
- throw AhuException("Resolver binding to local UDP socket on "+ourLocal.toString()+": "+stringerror());
+ throw PDNSException("Resolver binding to local UDP socket on "+ourLocal.toString()+": "+stringerror());
}
}
else {
// cerr<<"letting kernel pick TCP port"<<endl;
ourLocal.sin4.sin_port = 0;
if(::bind(sock, (struct sockaddr *)&ourLocal, ourLocal.getSocklen()) < 0)
- throw AhuException("Resolver binding to local TCP socket on "+ourLocal.toString()+": "+stringerror());
+ throw PDNSException("Resolver binding to local TCP socket on "+ourLocal.toString()+": "+stringerror());
}
return sock;
}
#include "namespaces.hh"
#include "dnsbackend.hh"
-class ResolverException : public AhuException
+class ResolverException : public PDNSException
{
public:
- ResolverException(const string &reason) : AhuException(reason){}
+ ResolverException(const string &reason) : PDNSException(reason){}
};
// make an IPv4 or IPv6 query socket
uint16_t len;
len = htons(packet.size());
if(sock.write((char *) &len, 2) != 2)
- throw AhuException("tcp write failed");
+ throw PDNSException("tcp write failed");
sock.writen(string((char*)&*packet.begin(), (char*)&*packet.end()));
if(sock.read((char *) &len, 2) != 2)
- throw AhuException("tcp read failed");
+ throw PDNSException("tcp read failed");
len=ntohs(len);
char *creply = new char[len];
while(n<len) {
numread=sock.read(creply+n, len-n);
if(numread<0)
- throw AhuException("tcp read failed");
+ throw PDNSException("tcp read failed");
n+=numread;
}
#include "iputils.hh"
#include "ahuexception.hh"
-class SessionException: public AhuException
+class SessionException: public PDNSException
{
public:
- SessionException(const string &reason) : AhuException(reason){}
+ SessionException(const string &reason) : PDNSException(reason){}
};
class SessionTimeoutException: public SessionException
di.backend->abortTransaction();
}
}
- catch(AhuException &ae) {
- L<<Logger::Error<<"Unable to AXFR zone '"+domain+"' from remote '"<<remote<<"' (AhuException): "<<ae.reason<<endl;
+ catch(PDNSException &ae) {
+ L<<Logger::Error<<"Unable to AXFR zone '"+domain+"' from remote '"<<remote<<"' (PDNSException): "<<ae.reason<<endl;
if(di.backend && !first) {
L<<Logger::Error<<"Aborting possible open transaction for domain '"<<domain<<"' AXFR"<<endl;
di.backend->abortTransaction();
dni.dnssecOk, dni.tsigkeyname, dni.tsigalgname, dni.tsigsecret)
);
}
- catch(AhuException& e) {
+ catch(PDNSException& e) {
throw runtime_error("While attempting to query freshness of '"+dni.di.zone+"': "+e.reason);
}
}
catch(std::exception& e) {
L<<Logger::Error<<"While checking domain freshness: " << e.what()<<endl;
}
- catch(AhuException &re) {
+ catch(PDNSException &re) {
L<<Logger::Error<<"While checking domain freshness: " << re.reason<<endl;
}
}
if(!d_stats.count(key))
{
unlock(); // it's the details that count
- throw AhuException("Trying to deposit into unknown StatBag key '"+key+"'");
+ throw PDNSException("Trying to deposit into unknown StatBag key '"+key+"'");
}
}
try {
s_P=new PacketHandler;
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
L<<Logger::Error<<Logger::NTLog<<"TCP server is unable to launch backends - will try again when questions come in"<<endl;
L<<Logger::Error<<"TCP server is unable to launch backends - will try again when questions come in: "<<ae.reason<<endl;
}
return 0;
}
-// throws AhuException if things didn't go according to plan, returns 0 if really 0 bytes were read
+// throws PDNSException if things didn't go according to plan, returns 0 if really 0 bytes were read
int readnWithTimeout(int fd, void* buffer, unsigned int n, bool throwOnEOF=true)
{
unsigned int bytes=n;
L<<Logger::Error<<"TCP Connection Thread unable to answer a question because of a backend error, cycling"<<endl;
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
Lock l(&s_plock);
delete s_P;
s_P = 0; // on next call, backend will be recycled
stringtok(locals6,::arg()["local-ipv6"]," ,");
if(locals.empty() && locals6.empty())
- throw AhuException("No local address specified");
+ throw PDNSException("No local address specified");
vector<string> parts;
stringtok( parts, ::arg()["allow-axfr-ips"], ", \t" ); // is this IP on the guestlist?
int s=socket(AF_INET,SOCK_STREAM,0);
if(s<0)
- throw AhuException("Unable to acquire TCP socket: "+stringerror());
+ throw PDNSException("Unable to acquire TCP socket: "+stringerror());
Utility::setCloseOnExec(s);
if(::bind(s, (sockaddr*)&local, local.getSocklen())<0) {
L<<Logger::Error<<"binding to TCP socket: "<<strerror(errno)<<endl;
- throw AhuException("Unable to bind to TCP socket");
+ throw PDNSException("Unable to bind to TCP socket");
}
listen(s,128);
int s=socket(AF_INET6,SOCK_STREAM,0);
if(s<0)
- throw AhuException("Unable to acquire TCPv6 socket: "+stringerror());
+ throw PDNSException("Unable to acquire TCPv6 socket: "+stringerror());
Utility::setCloseOnExec(s);
}
if(bind(s, (const sockaddr*)&local, local.getSocklen())<0) {
L<<Logger::Error<<"binding to TCP socket: "<<strerror(errno)<<endl;
- throw AhuException("Unable to bind to TCPv6 socket");
+ throw PDNSException("Unable to bind to TCPv6 socket");
}
listen(s,128);
}
}
}
- catch(AhuException &AE) {
+ catch(PDNSException &AE) {
L<<Logger::Error<<"TCP Nameserver thread dying because of fatal error: "<<AE.reason<<endl;
}
catch(...) {
cerr<<"Fatal: "<<e.what()<<endl;
return 1;
}
-catch(AhuException& ae)
+catch(PDNSException& ae)
{
cerr<<"Fatal 2: "<<ae.reason<<endl;
return 1;
{
if(stale) {
L<<Logger::Error<<"Stale ueberbackend received question, signalling that we want to be recycled"<<endl;
- throw AhuException("We are stale, please recycle");
+ throw PDNSException("We are stale, please recycle");
}
DLOG(L<<"UeberBackend received question for "<<qtype.getName()<<" of "<<qname<<endl);
if(!backends.size()) {
L<<Logger::Error<<Logger::NTLog<<"No database backends available - unable to answer questions."<<endl;
stale=true; // please recycle us!
- throw AhuException("We are stale, please recycle");
+ throw PDNSException("We are stale, please recycle");
}
else {
d_question.qtype=qtype;
Semaphore::Semaphore(unsigned int value)
{
if (value > SEM_VALUE_MAX) {
- throw AhuException("Cannot create semaphore: value too large");
+ throw PDNSException("Cannot create semaphore: value too large");
}
// Initialize
if (pthread_mutex_init(&m_lock, NULL) != 0) {
- throw AhuException("Cannot create semaphore: cannot allocate mutex");
+ throw PDNSException("Cannot create semaphore: cannot allocate mutex");
}
if (pthread_cond_init(&m_gtzero, NULL) != 0) {
pthread_mutex_destroy(&m_lock);
- throw AhuException("Cannot create semaphore: cannot allocate condition");
+ throw PDNSException("Cannot create semaphore: cannot allocate condition");
}
m_count = (uint32_t) value;
if(ret < 0 && errno == ECONNRESET) // see ticket 192, odd BSD behaviour
return 0;
if(ret < 0)
- throw AhuException("Error closing socket: "+stringerror());
+ throw PDNSException("Error closing socket: "+stringerror());
return ret;
}
DWORD bytesRead;
if ( !ConnectNamedPipe( m_pipeHandle, NULL ))
- throw AhuException( "Reading from named pipe failed." );
+ throw PDNSException( "Reading from named pipe failed." );
if ( !ReadFile( m_pipeHandle, mesg, sizeof( mesg ), &bytesRead, NULL ))
- throw AhuException( "Reading from named pipe failed." );
+ throw PDNSException( "Reading from named pipe failed." );
return mesg;
}
sendLine((*d_funcdb[parts[0]])(parts,d_ppid));
}
}
- catch(AhuException &AE)
+ catch(PDNSException &AE)
{
L<<Logger::Error<<"Fatal: "<<AE.reason<<endl;
}
cout<<resp<<endl;
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
cerr<<"Fatal error: "<<ae.reason<<endl;
return 1;
}
m_pipeHandle = CreateFile( pipename.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL );
if ( m_pipeHandle == INVALID_HANDLE_VALUE )
- throw AhuException( "Could not create named pipe (are you on Windows NT, 2000 or XP? 98 doesn't work!)" );
+ throw PDNSException( "Could not create named pipe (are you on Windows NT, 2000 or XP? 98 doesn't work!)" );
}
DynMessenger::~DynMessenger()
delete R;
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
L<<Logger::Error<<"startDoResolve problem: "<<ae.reason<<endl;
}
catch(...) {
Utility::setCloseOnExec(d_clientsock);
if(d_clientsock<0)
- throw AhuException("Making a socket for resolver: "+stringerror());
+ throw PDNSException("Making a socket for resolver: "+stringerror());
struct sockaddr_in sin;
memset((char *)&sin,0, sizeof(sin));
}
if(!tries)
- throw AhuException("Resolver binding to local socket: "+stringerror());
+ throw PDNSException("Resolver binding to local socket: "+stringerror());
}
void makeTCPServerSocket()
Utility::setCloseOnExec(d_tcpserversock);
if(d_tcpserversock<0)
- throw AhuException("Making a server socket for resolver: "+stringerror());
+ throw PDNSException("Making a server socket for resolver: "+stringerror());
struct sockaddr_in sin;
memset((char *)&sin,0, sizeof(sin));
}
else {
if(!IpToU32(arg()["local-address"], &sin.sin_addr.s_addr))
- throw AhuException("Unable to resolve local address");
+ throw PDNSException("Unable to resolve local address");
}
sin.sin_port = htons(arg().asNum("local-port"));
if (bind(d_tcpserversock, (struct sockaddr *)&sin, sizeof(sin))<0)
- throw AhuException("TCP Resolver binding to server socket: "+stringerror());
+ throw PDNSException("TCP Resolver binding to server socket: "+stringerror());
int tmp=1;
if(setsockopt(d_tcpserversock,SOL_SOCKET,SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0) {
d_serversock=socket(AF_INET, SOCK_DGRAM,0);
Utility::setCloseOnExec(d_serversock);
if(d_serversock<0)
- throw AhuException("Making a server socket for resolver: "+stringerror());
+ throw PDNSException("Making a server socket for resolver: "+stringerror());
struct sockaddr_in sin;
memset((char *)&sin,0, sizeof(sin));
else {
if(!IpToU32(arg()["local-address"], &sin.sin_addr.s_addr))
- throw AhuException("Unable to resolve local address");
+ throw PDNSException("Unable to resolve local address");
}
sin.sin_port = htons(arg().asNum("local-port"));
if (bind(d_serversock, (struct sockaddr *)&sin, sizeof(sin))<0)
- throw AhuException("Resolver binding to server socket: "+stringerror());
+ throw PDNSException("Resolver binding to server socket: "+stringerror());
L<<Logger::Error<<"Incoming query source port: "<<arg().asNum("local-port")<<endl;
}
int selret = select( fdmax + 1, &readfds, NULL, NULL, &tv );
if(selret<=0)
if (selret == -1 && errno!=EINTR)
- throw AhuException("Select returned: "+stringerror());
+ throw PDNSException("Select returned: "+stringerror());
else
continue;
}
}
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
L<<Logger::Error<<"Exception: "<<ae.reason<<endl;
}
catch(std::exception &e) {
RecursorService::instance()->start( argc, argv, arg().mustDo( "ntservice" ));
}
- catch(AhuException &ae) {
+ catch(PDNSException &ae) {
L<<Logger::Error<<"Exception: "<<ae.reason<<endl;
}
catch(std::exception &e) {