if(!d_checkinterval)
return true;
- if(time(0) - d_lastcheck < d_checkinterval)
+ if(time(nullptr) - d_lastcheck < d_checkinterval)
return true;
if(d_filename.empty())
if(d_filename.empty() || stat(d_filename.c_str(),&buf)<0)
return 0;
- d_lastcheck=time(0);
+ d_lastcheck=time(nullptr);
return buf.st_ctime;
}
{
BB2DomainInfo bbd;
if(safeGetBBDomainInfo(domain_id, &bbd)) {
- bbd.d_lastcheck=time(0);
+ bbd.d_lastcheck=time(nullptr);
safePutBBDomainInfo(bbd);
}
}
}
catch(...){}
sd.serial=soadata.serial;
- if(sd.last_check+soadata.refresh < (unsigned int)time(0))
+ if(sd.last_check+soadata.refresh < (unsigned int)time(nullptr))
unfreshDomains->push_back(std::move(sd));
}
}
Bind2Backend::Bind2Backend(const string &suffix, bool loadZones)
{
- d_getAllDomainMetadataQuery_stmt = NULL;
- d_getDomainMetadataQuery_stmt = NULL;
- d_deleteDomainMetadataQuery_stmt = NULL;
- d_insertDomainMetadataQuery_stmt = NULL;
- d_getDomainKeysQuery_stmt = NULL;
- d_deleteDomainKeyQuery_stmt = NULL;
- d_insertDomainKeyQuery_stmt = NULL;
- d_GetLastInsertedKeyIdQuery_stmt = NULL;
- d_activateDomainKeyQuery_stmt = NULL;
- d_deactivateDomainKeyQuery_stmt = NULL;
- d_getTSIGKeyQuery_stmt = NULL;
- d_setTSIGKeyQuery_stmt = NULL;
- d_deleteTSIGKeyQuery_stmt = NULL;
- d_getTSIGKeysQuery_stmt = NULL;
+ d_getAllDomainMetadataQuery_stmt = nullptr;
+ d_getDomainMetadataQuery_stmt = nullptr;
+ d_deleteDomainMetadataQuery_stmt = nullptr;
+ d_insertDomainMetadataQuery_stmt = nullptr;
+ d_getDomainKeysQuery_stmt = nullptr;
+ d_deleteDomainKeyQuery_stmt = nullptr;
+ d_insertDomainKeyQuery_stmt = nullptr;
+ d_GetLastInsertedKeyIdQuery_stmt = nullptr;
+ d_activateDomainKeyQuery_stmt = nullptr;
+ d_deactivateDomainKeyQuery_stmt = nullptr;
+ d_getTSIGKeyQuery_stmt = nullptr;
+ d_setTSIGKeyQuery_stmt = nullptr;
+ d_deleteTSIGKeyQuery_stmt = nullptr;
+ d_getTSIGKeysQuery_stmt = nullptr;
setArgPrefix("bind"+suffix);
d_logprefix="[bind"+suffix+"backend]";
d_query = query;
d_paridx = d_fnum = d_resnum = d_residx = 0;
d_parnum = nparams;
- d_req_bind = d_res_bind = NULL;
- d_stmt = NULL;
+ d_req_bind = d_res_bind = nullptr;
+ d_stmt = nullptr;
if (query.empty()) {
return;
return;
}
- if ((d_stmt = mysql_stmt_init(d_db))==NULL)
+ if ((d_stmt = mysql_stmt_init(d_db))==nullptr)
throw SSqlException("Could not initialize mysql statement, out of memory: " + d_query);
if (mysql_stmt_prepare(d_stmt, d_query.c_str(), d_query.size()) != 0) {
d_prepared = false;
if (d_stmt)
mysql_stmt_close(d_stmt);
- d_stmt = NULL;
+ d_stmt = nullptr;
if (d_req_bind) {
for(int i=0;i<d_parnum;i++) {
if (d_req_bind[i].buffer) delete [] (char*)d_req_bind[i].buffer;
if (d_req_bind[i].length) delete [] d_req_bind[i].length;
}
delete [] d_req_bind;
- d_req_bind = NULL;
+ d_req_bind = nullptr;
}
if (d_res_bind) {
for(int i=0;i<d_fnum;i++) {
if (d_res_bind[i].is_null) delete [] d_res_bind[i].is_null;
}
delete [] d_res_bind;
- d_res_bind = NULL;
+ d_res_bind = nullptr;
}
d_paridx = d_fnum = d_resnum = d_residx = 0;
}
mysql_options(&d_db, MYSQL_READ_DEFAULT_GROUP, d_group.c_str());
- if (!mysql_real_connect(&d_db, d_host.empty() ? NULL : d_host.c_str(),
- d_user.empty() ? NULL : d_user.c_str(),
- d_password.empty() ? NULL : d_password.c_str(),
- d_database.empty() ? NULL : d_database.c_str(),
+ if (!mysql_real_connect(&d_db, d_host.empty() ? nullptr : d_host.c_str(),
+ d_user.empty() ? nullptr : d_user.c_str(),
+ d_password.empty() ? nullptr : d_password.c_str(),
+ d_database.empty() ? nullptr : d_database.c_str(),
d_port,
- d_msocket.empty() ? NULL : d_msocket.c_str(),
+ d_msocket.empty() ? nullptr : d_msocket.c_str(),
(d_clientSSL ? CLIENT_SSL : 0) | CLIENT_MULTI_RESULTS)) {
if (retry == 0)
*/
void PipeBackend::cleanup()
{
- d_coproc.reset(0);
+ d_coproc.reset(nullptr);
d_regex.reset();
d_regexstr = string();
d_abiVersion = 0;
}
catch(...) {
g_log<<Logger::Error<<kBackendId<<" Unable to instantiate a pipebackend!"<<endl;
- return 0;
+ return nullptr;
}
}
{
mode_t mode;
const char *cptr_orig;
- char *cptr_ret = NULL;
+ char *cptr_ret = nullptr;
if(!parmIsset(arg))
throw ArgException(string("Undefined but needed argument: '")+arg+"'");
{
gid_t gid;
const char *cptr_orig;
- char *cptr_ret = NULL;
+ char *cptr_ret = nullptr;
if(!parmIsset(arg))
throw ArgException(string("Undefined but needed argument: '")+arg+"'");
if (gid == 0 && cptr_ret == cptr_orig) {
// try to resolve
struct group *group = getgrnam(params[arg].c_str());
- if (group == NULL)
+ if (group == nullptr)
throw ArgException("'" + arg + string("' contains invalid group"));
gid = group->gr_gid;
}
{
uid_t uid;
const char *cptr_orig;
- char *cptr_ret = NULL;
+ char *cptr_ret = nullptr;
if(!parmIsset(arg))
throw ArgException(string("Undefined but needed argument: '")+arg+"'");
if (uid == 0 && cptr_ret == cptr_orig) {
// try to resolve
struct passwd *pwent = getpwnam(params[arg].c_str());
- if (pwent == NULL)
+ if (pwent == nullptr)
throw ArgException("'" + arg + string("' contains invalid group"));
uid = pwent->pw_uid;
}
{
int retval;
const char *cptr_orig;
- char *cptr_ret = NULL;
+ char *cptr_ret = nullptr;
if(!parmIsset(arg))
throw ArgException(string("Undefined but needed argument: '")+arg+"'");
{
double retval;
const char *cptr_orig;
- char *cptr_ret = NULL;
+ char *cptr_ret = nullptr;
if(!parmIsset(arg))
throw ArgException(string("Undefined but needed argument: '")+arg+"'");
}
struct dirent *ent;
- while ((ent = readdir(dir)) != NULL) {
+ while ((ent = readdir(dir)) != nullptr) {
if (ent->d_name[0] == '.')
continue; // skip any dots
if (boost::ends_with(ent->d_name, ".conf")) {
string msg;
vector<string> entries = S.getEntries();
ostringstream str;
- time_t now=time(0);
+ time_t now=time(nullptr);
for(const string& entry : entries) {
str<<namespace_name<<'.'<<hostname<<'.'<<instance_name<<'.'<<entry<<' '<<S.read(entry)<<' '<<now<<"\r\n";
}
d_trc.d_algoName = tt.algo + DNSName("sig-alg.reg.int");
else
d_trc.d_algoName = tt.algo;
- d_trc.d_time = time(0);
+ d_trc.d_time = time(nullptr);
d_trc.d_fudge = 300;
d_trc.d_origID=ntohs(pw.getHeader()->id);
d_trc.d_eRcode=0;
d_SearchRecordsQuery = getArg("search-records-query");
d_SearchCommentsQuery = getArg("search-comments-query");
- d_query_stmt = NULL;
- d_NoIdQuery_stmt = NULL;
- d_IdQuery_stmt = NULL;
- d_ANYNoIdQuery_stmt = NULL;
- d_ANYIdQuery_stmt = NULL;
- d_listQuery_stmt = NULL;
- d_listSubZoneQuery_stmt = NULL;
- d_InfoOfDomainsZoneQuery_stmt = NULL;
- d_InfoOfAllSlaveDomainsQuery_stmt = NULL;
- d_SuperMasterInfoQuery_stmt = NULL;
- d_GetSuperMasterIPs_stmt = NULL;
- d_AddSuperMaster_stmt = NULL;
- d_InsertZoneQuery_stmt = NULL;
- d_InsertRecordQuery_stmt = NULL;
- d_InsertEmptyNonTerminalOrderQuery_stmt = NULL;
- d_UpdateMasterOfZoneQuery_stmt = NULL;
- d_UpdateKindOfZoneQuery_stmt = NULL;
- d_UpdateSerialOfZoneQuery_stmt = NULL;
- d_UpdateLastCheckofZoneQuery_stmt = NULL;
- d_UpdateAccountOfZoneQuery_stmt = NULL;
- d_InfoOfAllMasterDomainsQuery_stmt = NULL;
- d_DeleteDomainQuery_stmt = NULL;
- d_DeleteZoneQuery_stmt = NULL;
- d_DeleteRRSetQuery_stmt = NULL;
- d_DeleteNamesQuery_stmt = NULL;
- d_firstOrderQuery_stmt = NULL;
- d_beforeOrderQuery_stmt = NULL;
- d_afterOrderQuery_stmt = NULL;
- d_lastOrderQuery_stmt = NULL;
- d_updateOrderNameAndAuthQuery_stmt = NULL;
- d_updateOrderNameAndAuthTypeQuery_stmt = NULL;
- d_nullifyOrderNameAndUpdateAuthQuery_stmt = NULL;
- d_nullifyOrderNameAndUpdateAuthTypeQuery_stmt = NULL;
- d_RemoveEmptyNonTerminalsFromZoneQuery_stmt = NULL;
- d_DeleteEmptyNonTerminalQuery_stmt = NULL;
- d_AddDomainKeyQuery_stmt = NULL;
- d_GetLastInsertedKeyIdQuery_stmt = NULL;
- d_ListDomainKeysQuery_stmt = NULL;
- d_GetAllDomainMetadataQuery_stmt = NULL;
- d_GetDomainMetadataQuery_stmt = NULL;
- d_ClearDomainMetadataQuery_stmt = NULL;
- d_ClearDomainAllMetadataQuery_stmt = NULL;
- d_SetDomainMetadataQuery_stmt = NULL;
- d_RemoveDomainKeyQuery_stmt = NULL;
- d_ActivateDomainKeyQuery_stmt = NULL;
- d_DeactivateDomainKeyQuery_stmt = NULL;
- d_PublishDomainKeyQuery_stmt = NULL;
- d_UnpublishDomainKeyQuery_stmt = NULL;
- d_ClearDomainAllKeysQuery_stmt = NULL;
- d_getTSIGKeyQuery_stmt = NULL;
- d_setTSIGKeyQuery_stmt = NULL;
- d_deleteTSIGKeyQuery_stmt = NULL;
- d_getTSIGKeysQuery_stmt = NULL;
- d_getAllDomainsQuery_stmt = NULL;
- d_ListCommentsQuery_stmt = NULL;
- d_InsertCommentQuery_stmt = NULL;
- d_DeleteCommentRRsetQuery_stmt = NULL;
- d_DeleteCommentsQuery_stmt = NULL;
- d_SearchRecordsQuery_stmt = NULL;
- d_SearchCommentsQuery_stmt = NULL;
+ d_query_stmt = nullptr;
+ d_NoIdQuery_stmt = nullptr;
+ d_IdQuery_stmt = nullptr;
+ d_ANYNoIdQuery_stmt = nullptr;
+ d_ANYIdQuery_stmt = nullptr;
+ d_listQuery_stmt = nullptr;
+ d_listSubZoneQuery_stmt = nullptr;
+ d_InfoOfDomainsZoneQuery_stmt = nullptr;
+ d_InfoOfAllSlaveDomainsQuery_stmt = nullptr;
+ d_SuperMasterInfoQuery_stmt = nullptr;
+ d_GetSuperMasterIPs_stmt = nullptr;
+ d_AddSuperMaster_stmt = nullptr;
+ d_InsertZoneQuery_stmt = nullptr;
+ d_InsertRecordQuery_stmt = nullptr;
+ d_InsertEmptyNonTerminalOrderQuery_stmt = nullptr;
+ d_UpdateMasterOfZoneQuery_stmt = nullptr;
+ d_UpdateKindOfZoneQuery_stmt = nullptr;
+ d_UpdateSerialOfZoneQuery_stmt = nullptr;
+ d_UpdateLastCheckofZoneQuery_stmt = nullptr;
+ d_UpdateAccountOfZoneQuery_stmt = nullptr;
+ d_InfoOfAllMasterDomainsQuery_stmt = nullptr;
+ d_DeleteDomainQuery_stmt = nullptr;
+ d_DeleteZoneQuery_stmt = nullptr;
+ d_DeleteRRSetQuery_stmt = nullptr;
+ d_DeleteNamesQuery_stmt = nullptr;
+ d_firstOrderQuery_stmt = nullptr;
+ d_beforeOrderQuery_stmt = nullptr;
+ d_afterOrderQuery_stmt = nullptr;
+ d_lastOrderQuery_stmt = nullptr;
+ d_updateOrderNameAndAuthQuery_stmt = nullptr;
+ d_updateOrderNameAndAuthTypeQuery_stmt = nullptr;
+ d_nullifyOrderNameAndUpdateAuthQuery_stmt = nullptr;
+ d_nullifyOrderNameAndUpdateAuthTypeQuery_stmt = nullptr;
+ d_RemoveEmptyNonTerminalsFromZoneQuery_stmt = nullptr;
+ d_DeleteEmptyNonTerminalQuery_stmt = nullptr;
+ d_AddDomainKeyQuery_stmt = nullptr;
+ d_GetLastInsertedKeyIdQuery_stmt = nullptr;
+ d_ListDomainKeysQuery_stmt = nullptr;
+ d_GetAllDomainMetadataQuery_stmt = nullptr;
+ d_GetDomainMetadataQuery_stmt = nullptr;
+ d_ClearDomainMetadataQuery_stmt = nullptr;
+ d_ClearDomainAllMetadataQuery_stmt = nullptr;
+ d_SetDomainMetadataQuery_stmt = nullptr;
+ d_RemoveDomainKeyQuery_stmt = nullptr;
+ d_ActivateDomainKeyQuery_stmt = nullptr;
+ d_DeactivateDomainKeyQuery_stmt = nullptr;
+ d_PublishDomainKeyQuery_stmt = nullptr;
+ d_UnpublishDomainKeyQuery_stmt = nullptr;
+ d_ClearDomainAllKeysQuery_stmt = nullptr;
+ d_getTSIGKeyQuery_stmt = nullptr;
+ d_setTSIGKeyQuery_stmt = nullptr;
+ d_deleteTSIGKeyQuery_stmt = nullptr;
+ d_getTSIGKeysQuery_stmt = nullptr;
+ d_getAllDomainsQuery_stmt = nullptr;
+ d_ListCommentsQuery_stmt = nullptr;
+ d_InsertCommentQuery_stmt = nullptr;
+ d_DeleteCommentRRsetQuery_stmt = nullptr;
+ d_DeleteCommentsQuery_stmt = nullptr;
+ d_SearchRecordsQuery_stmt = nullptr;
+ d_SearchCommentsQuery_stmt = nullptr;
}
void GSQLBackend::setNotified(uint32_t domain_id, uint32_t serial)
reconnectIfNeeded();
d_UpdateLastCheckofZoneQuery_stmt->
- bind("last_check", time(0))->
+ bind("last_check", time(nullptr))->
bind("domain_id", domain_id)->
execute()->
reset();
} catch (SSqlException &e) {
throw PDNSException("GSQLBackend get: "+e.txtReason());
}
- d_query_stmt = NULL;
+ d_query_stmt = nullptr;
return false;
}
} catch(SSqlException &e) {
throw PDNSException("GSQLBackend comment get: "+e.txtReason());
}
- d_query_stmt = NULL;
+ d_query_stmt = nullptr;
return false;
}
::arg().setDefaults();
}
-static time_t s_start=time(0);
+static time_t s_start=time(nullptr);
static uint64_t uptimeOfProcess(const std::string& str)
{
- return time(0) - s_start;
+ return time(nullptr) - s_start;
}
static uint64_t getSysUserTimeMsec(const std::string& str)
tick = min (tick, d_tickinterval);
- next=time(0)+tick;
+ next=time(nullptr)+tick;
- while(time(0) < next) {
+ while(time(nullptr) < next) {
rc=d_any_sem.tryWait();
if(rc) {
DNSSECKeeper::keyset_t DNSSECKeeper::getKeys(const DNSName& zone, bool useCache)
{
static int ttl = ::arg().asNum("dnssec-key-cache-ttl");
- unsigned int now = time(0);
+ unsigned int now = time(nullptr);
if(!((++s_ops) % 100000)) {
cleanup();
void DNSSECKeeper::cleanup()
{
struct timeval now;
- Utility::gettimeofday(&now, 0);
+ Utility::gettimeofday(&now, nullptr);
if(now.tv_sec - s_last_prune > (time_t)(30)) {
{
throw std::range_error("Invalid label position during decompression ("+std::to_string(newpos)+ " < "+std::to_string(minOffset)+")");
if (++depth > 100)
throw std::range_error("Abort label decompression after 100 redirects");
- packetParser((const char*)opos, len, newpos, true, 0, 0, 0, depth, minOffset);
+ packetParser((const char*)opos, len, newpos, true, nullptr, nullptr, nullptr, depth, minOffset);
} else
throw std::range_error("Found a forward reference during label decompression");
pos++;
{
unsigned int consumed;
try {
- DNSName dn((const char*) d_content.data(), d_content.size(), d_pos, true /* uncompress */, 0 /* qtype */, 0 /* qclass */, &consumed, sizeof(dnsheader));
+ DNSName dn((const char*) d_content.data(), d_content.size(), d_pos, true /* uncompress */, nullptr /* qtype */, nullptr /* qclass */, &consumed, sizeof(dnsheader));
d_pos+=consumed;
return dn;
ce.id = r->d.id;
ce.remote = r->d_remote;
ce.outsock = r->getSocket();
- ce.created = time( NULL );
+ ce.created = time( nullptr );
ce.qtype = r->qtype.getCode();
ce.qname = target;
ce.anyLocal = r->d_anyLocal;
if(i==d_conntrack.end()) {
return n;
}
- else if(i->second.created<time(0)-60) {
+ else if(i->second.created<time(nullptr)-60) {
if(i->second.created) {
g_log<<Logger::Warning<<"Recursive query for remote "<<
i->second.remote.toStringWithPort()<<" with internal id "<<n<<
msgh.msg_iovlen = 1;
msgh.msg_name = (struct sockaddr*)&i->second.remote;
msgh.msg_namelen = i->second.remote.getSocklen();
- msgh.msg_control=NULL;
+ msgh.msg_control=nullptr;
if(i->second.anyLocal) {
addCMsgSrcAddr(&msgh, &cbuf, i->second.anyLocal.get_ptr(), 0);
#ifdef HAVE_LUA_RECORDS
LUARecordContent::report();
#endif
- DNSRecordContent::regist(QClass::IN, QType::ANY, 0, 0, "ANY");
- DNSRecordContent::regist(QClass::IN, QType::AXFR, 0, 0, "AXFR");
- DNSRecordContent::regist(QClass::IN, QType::IXFR, 0, 0, "IXFR");
+ DNSRecordContent::regist(QClass::IN, QType::ANY, nullptr, nullptr, "ANY");
+ DNSRecordContent::regist(QClass::IN, QType::AXFR, nullptr, nullptr, "AXFR");
+ DNSRecordContent::regist(QClass::IN, QType::IXFR, nullptr, nullptr, "IXFR");
}
void reportOtherTypes()
{
}
}
- return 0;
+ return nullptr;
}
/**
uint32_t getStartOfWeek()
{
- uint32_t now = time(0);
+ uint32_t now = time(nullptr);
now -= (now % (7*86400));
return now;
}
}
unsigned char* out = HMAC(md_type, reinterpret_cast<const unsigned char*>(key.c_str()), key.size(), reinterpret_cast<const unsigned char*>(text.c_str()), text.size(), hash, &outlen);
- if (out == NULL || outlen == 0) {
+ if (out == nullptr || outlen == 0) {
throw PDNSException("HMAC computation failed");
}
(*g_signatureCount)++;
if(doCache) {
/* we add some jitter here so not all your slaves start pruning their caches at the very same millisecond */
- int weekno = (time(0) - dns_random(3600)) / (86400*7); // we just spent milliseconds doing a signature, microsecond more won't kill us
+ int weekno = (time(nullptr) - dns_random(3600)) / (86400*7); // we just spent milliseconds doing a signature, microsecond more won't kill us
const static int maxcachesize=::arg().asNum("max-signature-cache-entries", INT_MAX);
WriteLock l(&g_signatures_lock);
string DLUptimeHandler(const vector<string>&parts, Utility::pid_t ppid)
{
ostringstream os;
- os<<humanDuration(time(0)-s_starttime);
+ os<<humanDuration(time(nullptr)-s_starttime);
return os.str();
}
string DLSettingsHandler(const vector<string>&parts, Utility::pid_t ppid)
{
- static const char *whitelist[]={"query-logging",0};
+ static const char *whitelist[]={"query-logging",nullptr};
const char **p;
if(parts.size()!=3) {
/* extract all EDNS0 options from a pointer on the beginning rdLen of the OPT RR */
int getEDNSOptions(const char* optRR, const size_t len, EDNSOptionViewMap& options)
{
- assert(optRR != NULL);
+ assert(optRR != nullptr);
size_t pos = 0;
if (len < DNS_RDLENGTH_SIZE)
return EINVAL;
{
#ifdef SO_TIMESTAMP
struct cmsghdr *cmsg;
- for (cmsg = CMSG_FIRSTHDR(msgh); cmsg != NULL; cmsg = CMSG_NXTHDR(msgh,cmsg)) {
+ for (cmsg = CMSG_FIRSTHDR(msgh); cmsg != nullptr; cmsg = CMSG_NXTHDR(msgh,cmsg)) {
if ((cmsg->cmsg_level == SOL_SOCKET) && (cmsg->cmsg_type == SO_TIMESTAMP || cmsg->cmsg_type == SCM_TIMESTAMP) &&
CMSG_LEN(sizeof(*tv)) == cmsg->cmsg_len) {
memcpy(tv, CMSG_DATA(cmsg), sizeof(*tv));
#else
const struct cmsghdr* cmsg;
#endif
- for (cmsg = CMSG_FIRSTHDR(msgh); cmsg != NULL; cmsg = CMSG_NXTHDR(const_cast<struct msghdr*>(msgh), const_cast<struct cmsghdr*>(cmsg))) {
+ for (cmsg = CMSG_FIRSTHDR(msgh); cmsg != nullptr; cmsg = CMSG_NXTHDR(const_cast<struct msghdr*>(msgh), const_cast<struct cmsghdr*>(cmsg))) {
#if defined(IP_PKTINFO)
if ((cmsg->cmsg_level == IPPROTO_IP) && (cmsg->cmsg_type == IP_PKTINFO)) {
struct in_pktinfo *i = (struct in_pktinfo *) CMSG_DATA(cmsg);
addCMsgSrcAddr(&msgh, &cbuf, &from, 0);
}
else {
- msgh.msg_control=NULL;
+ msgh.msg_control=nullptr;
}
return sendmsg(sock, &msgh, flags);
}
} catch(PDNSException& pe) {
throw std::runtime_error("TSIG algorithm '"+tt.algo.toLogString()+"' is unknown.");
}
- trc.d_time = time((time_t*)NULL);
+ trc.d_time = time((time_t*)nullptr);
trc.d_fudge = 300;
trc.d_origID=ntohs(pw.getHeader()->id);
trc.d_eRcode=0;
}
void AuthLua4::postLoad() {
- d_update_policy = d_lw->readVariable<boost::optional<luacall_update_policy_t>>("updatepolicy").get_value_or(0);
- d_axfr_filter = d_lw->readVariable<boost::optional<luacall_axfr_filter_t>>("axfrfilter").get_value_or(0);
- d_prequery = d_lw->readVariable<boost::optional<luacall_prequery_t>>("prequery").get_value_or(0);
+ d_update_policy = d_lw->readVariable<boost::optional<luacall_update_policy_t>>("updatepolicy").get_value_or(nullptr);
+ d_axfr_filter = d_lw->readVariable<boost::optional<luacall_axfr_filter_t>>("axfrfilter").get_value_or(nullptr);
+ d_prequery = d_lw->readVariable<boost::optional<luacall_prequery_t>>("prequery").get_value_or(nullptr);
}
bool AuthLua4::axfrfilter(const ComboAddress& remote, const DNSName& zone, const DNSResourceRecord& in, vector<DNSResourceRecord>& out) {
luacall_axfr_filter_t::result_type ret;
int rcode;
- if (d_axfr_filter == NULL) return false;
+ if (d_axfr_filter == nullptr) return false;
ret = d_axfr_filter(remote, zone, in);
rcode = std::get<0>(ret);
trc.d_algoName = DNSName(tsigalgorithm.toStringNoDot() + ".sig-alg.reg.int.");
else
trc.d_algoName = tsigalgorithm;
- trc.d_time = time(0);
+ trc.d_time = time(nullptr);
trc.d_fudge = 300;
trc.d_origID=ntohs(id);
trc.d_eRcode=0;
void CommunicatorClass::drillHole(const DNSName &domain, const string &ip)
{
std::lock_guard<std::mutex> l(d_holelock);
- d_holes[make_pair(domain,ip)]=time(0);
+ d_holes[make_pair(domain,ip)]=time(nullptr);
}
bool CommunicatorClass::justNotified(const DNSName &domain, const string &ip)
if(d_holes.find(make_pair(domain,ip))==d_holes.end()) // no hole
return false;
- if(d_holes[make_pair(domain,ip)]>time(0)-900) // recent hole
+ if(d_holes[make_pair(domain,ip)]>time(nullptr)-900) // recent hole
return true;
// do we want to purge this? XXX FIXME
time_t start = 0;
int remainingTime = totalTimeout;
if (totalTimeout) {
- start = time(NULL);
+ start = time(nullptr);
}
do {
}
if (totalTimeout) {
- time_t now = time(NULL);
+ time_t now = time(nullptr);
int elapsed = now - start;
if (elapsed >= remainingTime) {
throw runtime_error("Timeout while reading data");
hints.ai_flags = AI_NUMERICHOST;
// getaddrinfo has anomalous return codes, anything nonzero is an error, positive or negative
- if (getaddrinfo(ourAddr.c_str(), 0, &hints, &res) != 0) {
+ if (getaddrinfo(ourAddr.c_str(), nullptr, &hints, &res) != 0) {
return -1;
}
// Note that cmsgbuf should be aligned the same as a struct cmsghdr
void addCMsgSrcAddr(struct msghdr* msgh, cmsgbuf_aligned* cmsgbuf, const ComboAddress* source, int itfIndex)
{
- struct cmsghdr *cmsg = NULL;
+ struct cmsghdr *cmsg = nullptr;
if(source->sin4.sin_family == AF_INET6) {
struct in6_pktinfo *pkt;
const char * cstr = str.c_str();
struct passwd * pwd = getpwnam(cstr);
- if (pwd == NULL) {
+ if (pwd == nullptr) {
long long val;
try {
const char * cstr = str.c_str();
struct group * grp = getgrnam(cstr);
- if (grp == NULL) {
+ if (grp == nullptr) {
long long val;
try {
fillMSGHdr(&msgh, &iov, &cbuf, 0, (char*)buffer.c_str(), buffer.length(), &p.d_remote);
- msgh.msg_control=NULL;
+ msgh.msg_control=nullptr;
if(p.d_anyLocal) {
addCMsgSrcAddr(&msgh, &cbuf, p.d_anyLocal.get_ptr(), 0);
}
string fname= ::arg()["lua-prequery-script"];
if(fname.empty())
{
- d_pdl = NULL;
+ d_pdl = nullptr;
}
else
{
fname = ::arg()["lua-dnsupdate-policy-script"];
if (fname.empty())
{
- d_update_policy_lua = NULL;
+ d_update_policy_lua = nullptr;
}
else
{
g_log<<Logger::Error<<"Received an answer (non-query) packet from "<<p.getRemote()<<", dropping"<<endl;
S.inc("corrupt-packets");
S.ringAccount("remotes-corrupt", p.d_remote);
- return 0;
+ return nullptr;
}
if(p.d.tc) { // truncated query. MOADNSParser would silently parse this packet in an incomplete way.
g_log<<Logger::Error<<"Received truncated query packet from "<<p.getRemote()<<", dropping"<<endl;
S.inc("corrupt-packets");
S.ringAccount("remotes-corrupt", p.d_remote);
- return 0;
+ return nullptr;
}
if (p.hasEDNS() && p.getEDNSVersion() > 0) {
r->setOpcode(Opcode::Notify);
return r;
}
- return 0;
+ return nullptr;
}
g_log<<Logger::Error<<"Received an unknown opcode "<<p.d.opcode<<" from "<<p.getRemote()<<" for "<<p.qdomain<<endl;
}
// this TRUMPS a cname!
- if(d_dnssec && p.qtype.getCode() == QType::NSEC && !d_dk.getNSEC3PARAM(d_sd.qname, 0)) {
+ if(d_dnssec && p.qtype.getCode() == QType::NSEC && !d_dk.getNSEC3PARAM(d_sd.qname, nullptr)) {
addNSEC(p, r, target, DNSName(), 5);
if (!r->isEmpty())
goto sendit;
if(!haveAlias.empty() && (!weDone || p.qtype.getCode() == QType::ANY)) {
DLOG(g_log<<Logger::Warning<<"Found nothing that matched for '"<<target<<"', but did get alias to '"<<haveAlias<<"', referring"<<endl);
DP->completePacket(r, haveAlias, target, aliasScopeMask);
- return 0;
+ return nullptr;
}
return result;
}
-static int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone, const vector<DNSResourceRecord>* suppliedrecords=0)
+static int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone, const vector<DNSResourceRecord>* suppliedrecords=nullptr)
{
uint64_t numerrors=0, numwarnings=0;
}
DNSBackend *src,*tgt;
- src = tgt = NULL;
+ src = tgt = nullptr;
for(DNSBackend *b : BackendMakers().all()) {
if (b->getPrefix() == cmds[1]) src = b;
}
DNSBackend *db;
- db = NULL;
+ db = nullptr;
for(DNSBackend *b : BackendMakers().all()) {
if (b->getPrefix() == cmds[1]) db = b;
val.copy(tmpbuf,16);
- if (inet_ntop(AF_INET6, tmpbuf, addrbuf, sizeof addrbuf) == NULL)
+ if (inet_ntop(AF_INET6, tmpbuf, addrbuf, sizeof addrbuf) == nullptr)
throw RecordTextException("Unable to convert to ipv6 address");
d_string += std::string(addrbuf);
g_log<<Logger::Critical<<"Unable to associate a file pointer with pipe: "<<stringerror()<<endl;
exit(1);
}
- setbuf(g_fp,0); // no buffering please, confuses select
+ setbuf(g_fp,nullptr); // no buffering please, confuses select
if(!(pid=fork())) { // child
signal(SIGTERM, SIG_DFL);
for(n=1;n<argc;n++) {
newargv[n]=argv[n];
}
- newargv[n]=0;
+ newargv[n]=nullptr;
g_log<<Logger::Error<<"Guardian is launching an instance"<<endl;
close(g_fd1[1]);
g_guardian_lock.lock();
close(g_fd1[1]);
fclose(g_fp);
- g_fp=0;
+ g_fp=nullptr;
if(WIFEXITED(status)) {
int ret=WEXITSTATUS(status);
reportAllTypes(); // init MOADNSParser
s_programname="pdns";
- s_starttime=time(0);
+ s_starttime=time(nullptr);
#if defined(__GLIBC__) && !defined(__UCLIBC__)
signal(SIGSEGV,tbhandler);
trc.d_algoName = tsigalgorithm + DNSName("sig-alg.reg.int");
else
trc.d_algoName = tsigalgorithm;
- trc.d_time = time(0);
+ trc.d_time = time(nullptr);
trc.d_fudge = 300;
trc.d_origID=ntohs(randomid);
trc.d_eRcode=0;
g_log<<Logger::Info<<msgPrefix<<"Processing started."<<endl;
// if there is policy, we delegate all checks to it
- if (this->d_update_policy_lua == NULL) {
+ if (this->d_update_policy_lua == nullptr) {
// Check permissions - IP based
vector<string> allowedRanges;
}
DomainInfo di;
- di.backend=0;
+ di.backend=nullptr;
if(!B.getDomainInfo(p.qdomain, di) || !di.backend) {
g_log<<Logger::Error<<msgPrefix<<"Can't determine backend for domain '"<<p.qdomain<<"' (or backend does not support DNS update operation)"<<endl;
return RCode::NotAuth;
const DNSRecord *rr = &d_answer.first;
if (rr->d_place == DNSResourceRecord::AUTHORITY) {
/* see if it's permitted by policy */
- if (this->d_update_policy_lua != NULL) {
+ if (this->d_update_policy_lua != nullptr) {
if (this->d_update_policy_lua->updatePolicy(rr->d_name, QType(rr->d_type), di.zone, p) == false) {
g_log<<Logger::Warning<<msgPrefix<<"Refusing update for " << rr->d_name << "/" << QType(rr->d_type).getName() << ": Not permitted by policy"<<endl;
continue;
return;
struct timeval now;
- gettimeofday(&now, 0);
+ gettimeofday(&now, nullptr);
string pkgv(PACKAGEVERSION);
string version = "auth-" + pkgv;
return (old_serial + (inception / (7*86400)));
}
else if(pdns_iequals(kind,"EPOCH")) {
- return time(0);
+ return time(nullptr);
}
else if(pdns_iequals(kind,"INCEPTION-EPOCH")) {
uint32_t inception = getStartOfWeek();
return old_serial + 1;
}
else if (pdns_iequals(increaseKind, "EPOCH")) {
- return time(0);
+ return time(nullptr);
}
else if (pdns_iequals(increaseKind, "DEFAULT")) {
- time_t now = time(0);
+ time_t now = time(nullptr);
uint32_t new_serial = localtime_format_YYYYMMDDSS(now, 1);
if (new_serial <= old_serial) {
new_serial = old_serial + 1;
UeberBackend B; // fresh UeberBackend
DomainInfo di;
- di.backend=0;
+ di.backend=nullptr;
// bool transaction=false;
try {
DNSSECKeeper dk (&B); // reuse our UeberBackend copy for DNSSECKeeper
DNSRecord drsoa;
drsoa.d_content = std::make_shared<SOARecordContent>(g_rootdnsname, g_rootdnsname, st);
- auto deltas = getIXFRDeltas(remote, domain, drsoa, tt, laddr.sin4.sin_family ? &laddr : 0, ((size_t) ::arg().asNum("xfr-max-received-mbytes")) * 1024 * 1024);
+ auto deltas = getIXFRDeltas(remote, domain, drsoa, tt, laddr.sin4.sin_family ? &laddr : nullptr, ((size_t) ::arg().asNum("xfr-max-received-mbytes")) * 1024 * 1024);
zs.numDeltas=deltas.size();
// cout<<"Got "<<deltas.size()<<" deltas from serial "<<di.serial<<", applying.."<<endl;
{
uint16_t axfr_timeout=::arg().asNum("axfr-fetch-timeout");
vector<DNSResourceRecord> rrs;
- AXFRRetriever retriever(raddr, domain, tt, (laddr.sin4.sin_family == 0) ? NULL : &laddr, ((size_t) ::arg().asNum("xfr-max-received-mbytes")) * 1024 * 1024, axfr_timeout);
+ AXFRRetriever retriever(raddr, domain, tt, (laddr.sin4.sin_family == 0) ? nullptr : &laddr, ((size_t) ::arg().asNum("xfr-max-received-mbytes")) * 1024 * 1024, axfr_timeout);
Resolver::res_t recs;
bool first=true;
bool firstNSEC3{true};
UeberBackend B; // fresh UeberBackend
DomainInfo di;
- di.backend=0;
+ di.backend=nullptr;
bool transaction=false;
try {
DNSSECKeeper dk (&B); // reuse our UeberBackend copy for DNSSECKeeper
// still succeed, we would constantly try to AXFR the zone. To avoid this, we add the zone to the list of
// failed slave-checks. This will suspend slave-checks (and subsequent AXFR) for this zone for some time.
uint64_t newCount = 1;
- time_t now = time(0);
+ time_t now = time(nullptr);
const auto failedEntry = d_failedSlaveRefresh.find(domain);
if (failedEntry != d_failedSlaveRefresh.end())
newCount = d_failedSlaveRefresh[domain].first + 1;
{
std::lock_guard<std::mutex> l(d_lock);
DomainInfo ours = di;
- ours.backend = 0;
+ ours.backend = nullptr;
// When adding a check, if the remote addr from which notification was
// received is a master, clear all other masters so we can be sure the
{
std::lock_guard<std::mutex> l(d_lock);
domains_by_name_t& nameindex=boost::multi_index::get<IDTag>(d_suckdomains);
- time_t now = time(0);
+ time_t now = time(nullptr);
for(DomainInfo& di : rdomains) {
const auto failed = d_failedSlaveRefresh.find(di.zone);
g_log<<Logger::Info<<"Received serial number updates for "<<ssr.d_freshness.size()<<" zone"<<addS(ssr.d_freshness.size())<<endl;
}
- time_t now = time(0);
+ time_t now = time(nullptr);
for(auto& val : sdomains) {
DomainInfo& di(val.di);
// If our di comes from packethandler (caused by incoming NOTIFY), di.backend will not be filled out,
{
exists(key);
unsigned long tmp=*d_stats[key];
- d_stats[key]=0;
+ d_stats[key]=nullptr;
return tmp;
}
time_t start = 0;
unsigned int remainingTotal = totalTimeout;
if (totalTimeout) {
- start = time(NULL);
+ start = time(nullptr);
}
while(bytes) {
ret=read(fd, ptr, bytes);
ptr += ret;
bytes -= ret;
if (totalTimeout) {
- time_t now = time(NULL);
+ time_t now = time(nullptr);
unsigned int elapsed = now - start;
if (elapsed >= remainingTotal) {
throw NetworkError("Timeout while reading data");
static bool maxConnectionDurationReached(unsigned int maxConnectionDuration, time_t start, unsigned int& remainingTime)
{
if (maxConnectionDuration) {
- time_t elapsed = time(NULL) - start;
+ time_t elapsed = time(nullptr) - start;
if (elapsed >= maxConnectionDuration) {
return true;
}
size_t transactions = 0;
time_t start = 0;
if (d_maxConnectionDuration) {
- start = time(NULL);
+ start = time(nullptr);
}
if(getpeername(fd, (struct sockaddr *)&remote, &remotelen) < 0) {
tkey_out->d_error = 0;
tkey_out->d_mode = tkey_in.d_mode;
tkey_out->d_algo = tkey_in.d_algo;
- tkey_out->d_inception = time((time_t*)NULL);
+ tkey_out->d_inception = time((time_t*)nullptr);
tkey_out->d_expiration = tkey_out->d_inception+15;
if (tkey_in.d_mode == 3) { // establish context
void *dlib=dlopen(name.c_str(), RTLD_NOW);
- if(dlib == NULL) {
+ if(dlib == nullptr) {
g_log<<Logger::Error <<"Unable to load module '"<<name<<"': "<<dlerror() << endl;
return false;
}
{
// g_log<<Logger::Warning<<"Handle instances: "<<instances<<endl;
++instances;
- parent=NULL;
- d_hinterBackend=NULL;
- pkt_p=NULL;
+ parent=nullptr;
+ d_hinterBackend=nullptr;
+ pkt_p=nullptr;
i=0;
zoneId = -1;
}
return ret;
}
- ret = select(sock + 1, NULL, &set, NULL, &timeout);
+ ret = select(sock + 1, nullptr, &set, nullptr, &timeout);
setBlocking(sock);
return ret;
ts.tv_sec = usec / 1000000;
ts.tv_nsec = (usec % 1000000) * 1000;
// POSIX.1 recommends using nanosleep instead of usleep
- ::nanosleep(&ts, NULL);
+ ::nanosleep(&ts, nullptr);
}
struct passwd *pw=getpwuid(uid);
if(!pw) {
g_log<<Logger::Warning<<"Unable to determine user name for uid "<<uid<<endl;
- if (setgroups(0, NULL)<0) {
+ if (setgroups(0, nullptr)<0) {
g_log<<Logger::Critical<<"Unable to drop supplementary gids: "<<stringerror()<<endl;
exit(1);
}
// Returns the current time.
int Utility::gettimeofday( struct timeval *tv, void *tz )
{
- return ::gettimeofday(tv,0);
+ return ::gettimeofday(tv,nullptr);
}
// Sets the random seed.
void Utility::srandom()
{
struct timeval tv;
- gettimeofday(&tv, 0);
+ gettimeofday(&tv, nullptr);
::srandom(tv.tv_sec ^ tv.tv_usec ^ getpid());
}
g_log<<Logger::Error<<logprefix<<"HTTP Exception: "<<e.reason<<endl;
}
catch(std::exception &e) {
- if(strstr(e.what(), "timeout")==0)
+ if(strstr(e.what(), "timeout")==nullptr)
g_log<<Logger::Error<<logprefix<<"HTTP STL Exception: "<<e.what()<<endl;
}
catch(...) {
ret<<"<div class=\"headr columns\"></div></div>";
ret<<"<div class=\"row\"><div class=\"all columns\">";
- time_t passed=time(0)-s_starttime;
+ time_t passed=time(nullptr)-s_starttime;
ret<<"<p>Uptime: "<<
humanDuration(passed)<<
}
// add uptime
- out["uptime"] = std::to_string(time(0) - s_starttime);
+ out["uptime"] = std::to_string(time(nullptr) - s_starttime);
}
boost::optional<uint64_t> productServerStatisticsFetch(const std::string& name)
c.qname = qname;
c.qtype = qtype;
- time_t now = time(0);
+ time_t now = time(nullptr);
for (auto comment : container["comments"].array_items()) {
c.modified_at = intFromJson(comment, "modified_at", now);
c.content = stringFromJson(comment, "content");
cout<<"BEGIN TRANSACTION;"<<endl;
}
-static void emitDomain(const DNSName& domain, const vector<ComboAddress> *masters = 0) {
+static void emitDomain(const DNSName& domain, const vector<ComboAddress> *masters = nullptr) {
string iDomain = domain.toStringRootDot();
if(!::arg().mustDo("slave")) {
cout<<"insert into domains (name,type) values ("<<toLower(sqlstr(iDomain))<<",'NATIVE');"<<endl;
else
{
string mstrs;
- if (masters != 0 && ! masters->empty()) {
+ if (masters != nullptr && ! masters->empty()) {
for(const auto& mstr : *masters) {
mstrs.append(mstr.toStringWithPortExcept(53));
mstrs.append(1, ' ');
" from domains where name="<<toLower(sqlstr(zname))<<";\n";
if(!recordcomment.empty()) {
- cout<<"insert into comments (domain_id,name,type,modified_at, comment) select id, "<<toLower(sqlstr(stripDot(qname)))<<", "<<sqlstr(qtype)<<", "<<time(0)<<", "<<sqlstr(recordcomment)<<" from domains where name="<<toLower(sqlstr(zname))<<";\n";
+ cout<<"insert into comments (domain_id,name,type,modified_at, comment) select id, "<<toLower(sqlstr(stripDot(qname)))<<", "<<sqlstr(qtype)<<", "<<time(nullptr)<<", "<<sqlstr(recordcomment)<<" from domains where name="<<toLower(sqlstr(zname))<<";\n";
}
}