summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dns.cpp40
-rw-r--r--src/modules/extra/m_pgsql.cpp4
-rw-r--r--src/modules/m_cgiirc.cpp2
-rw-r--r--src/modules/m_dnsbl.cpp2
-rw-r--r--src/modules/m_http_client.cpp2
-rw-r--r--src/modules/m_spanningtree.cpp4
-rw-r--r--src/modules/m_testcommand.cpp4
-rw-r--r--src/users.cpp2
8 files changed, 32 insertions, 28 deletions
diff --git a/src/dns.cpp b/src/dns.cpp
index 5d830d0de..d2f08a6e0 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -94,6 +94,7 @@ class DNSRequest
QueryType type; /* Request type */
insp_inaddr myserver; /* DNS server address*/
DNS* dnsobj; /* DNS caller (where we get our FD from) */
+ unsigned long ttl; /* Time to live */
DNSRequest(InspIRCd* Instance, DNS* dns, insp_inaddr server, int id);
~DNSRequest();
@@ -576,7 +577,7 @@ DNSResult DNS::GetResult()
{
/* Nope - something screwed up. */
ServerInstance->Log(DEBUG,"Whole header not read!");
- return std::make_pair(-1,"");
+ return DNSResult(-1,"",0);
}
/* Check wether the reply came from a different DNS
@@ -604,7 +605,7 @@ DNSResult DNS::GetResult()
if ((port_from != DNS::QUERY_PORT) || (strcasecmp(ipaddr_from, ServerInstance->Config->DNSServer)))
{
ServerInstance->Log(DEBUG,"port %d is not 53, or %s is not %s",port_from, ipaddr_from, ServerInstance->Config->DNSServer);
- return std::make_pair(-1,"");
+ return DNSResult(-1,"",0);
}
}
@@ -622,7 +623,7 @@ DNSResult DNS::GetResult()
{
/* Somehow we got a DNS response for a request we never made... */
ServerInstance->Log(DEBUG,"DNS: got a response for a query we didnt send with fd=%d queryid=%d",this->GetFd(),this_id);
- return std::make_pair(-1,"");
+ return DNSResult(-1,"",0);
}
else
{
@@ -648,10 +649,11 @@ DNSResult DNS::GetResult()
* Put the error message in the second field.
*/
delete req;
- return std::make_pair(this_id | ERROR_MASK, data.second);
+ return DNSResult(this_id | ERROR_MASK, data.second, 0);
}
else
{
+ unsigned long ttl = req->ttl;
char formatted[128];
/* Forward lookups come back as binary data. We must format them into ascii */
@@ -713,7 +715,7 @@ DNSResult DNS::GetResult()
/* Build the reply with the id and hostname/ip in it */
delete req;
- return std::make_pair(this_id,resultstr);
+ return DNSResult(this_id,resultstr,ttl);
}
}
@@ -811,6 +813,8 @@ DNSInfo DNSRequest::ResultIsReady(DNSHeader &header, int length)
if (rr.rdlength > 1023)
return std::make_pair((unsigned char*)NULL,"Resource record too large");
+ this->ttl = rr.ttl;
+
switch (rr.type)
{
case DNS_QUERY_CNAME:
@@ -957,36 +961,36 @@ void DNS::HandleEvent(EventType et, int errornum)
/* Fetch the id and result of the next available packet */
DNSResult res = this->GetResult();
/* Is there a usable request id? */
- if (res.first != -1)
+ if (res.id != -1)
{
/* Its an error reply */
- if (res.first & ERROR_MASK)
+ if (res.id & ERROR_MASK)
{
/* Mask off the error bit */
- res.first -= ERROR_MASK;
+ res.id -= ERROR_MASK;
/* Marshall the error to the correct class */
- ServerInstance->Log(DEBUG,"Error available, id=%d",res.first);
- if (Classes[res.first])
+ ServerInstance->Log(DEBUG,"Error available, id=%d",res.id);
+ if (Classes[res.id])
{
if (ServerInstance && ServerInstance->stats)
ServerInstance->stats->statsDnsBad++;
- Classes[res.first]->OnError(RESOLVER_NXDOMAIN, res.second);
- delete Classes[res.first];
- Classes[res.first] = NULL;
+ Classes[res.id]->OnError(RESOLVER_NXDOMAIN, res.result);
+ delete Classes[res.id];
+ Classes[res.id] = NULL;
}
}
else
{
/* It is a non-error result */
- ServerInstance->Log(DEBUG,"Result available, id=%d",res.first);
+ ServerInstance->Log(DEBUG,"Result available, id=%d",res.id);
/* Marshall the result to the correct class */
- if (Classes[res.first])
+ if (Classes[res.id])
{
if (ServerInstance && ServerInstance->stats)
ServerInstance->stats->statsDnsGood++;
- Classes[res.first]->OnLookupComplete(res.second);
- delete Classes[res.first];
- Classes[res.first] = NULL;
+ Classes[res.id]->OnLookupComplete(res.result, res.ttl);
+ delete Classes[res.id];
+ Classes[res.id] = NULL;
}
}
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp
index b596244a6..79630d416 100644
--- a/src/modules/extra/m_pgsql.cpp
+++ b/src/modules/extra/m_pgsql.cpp
@@ -95,7 +95,7 @@ class SQLresolver : public Resolver
{
}
- virtual void OnLookupComplete(const std::string &result);
+ virtual void OnLookupComplete(const std::string &result, unsigned int ttl);
virtual void OnError(ResolverError e, const std::string &errormessage)
{
@@ -1240,7 +1240,7 @@ public:
/* move this here to use AddConn, rather that than having the whole
* module above SQLConn, since this is buggin me right now :/
*/
-void SQLresolver::OnLookupComplete(const std::string &result)
+void SQLresolver::OnLookupComplete(const std::string &result, unsigned int ttl)
{
host.ip = result;
((ModulePgSQL*)mod)->AddConn(host);
diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp
index 93593ed23..dc11ccf96 100644
--- a/src/modules/m_cgiirc.cpp
+++ b/src/modules/m_cgiirc.cpp
@@ -54,7 +54,7 @@ class CGIResolver : public Resolver
CGIResolver(Module* me, InspIRCd* ServerInstance, bool NotifyOpers, const std::string &source, bool forward, userrec* u, int userfd, const std::string &type)
: Resolver(ServerInstance, source, forward ? DNS_QUERY_FORWARD : DNS_QUERY_REVERSE, me), typ(type), theirfd(userfd), them(u), notify(NotifyOpers) { }
- virtual void OnLookupComplete(const std::string &result)
+ virtual void OnLookupComplete(const std::string &result, unsigned int ttl)
{
/* Check the user still exists */
if ((them) && (them == ServerInstance->SE->GetRef(theirfd)))
diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp
index 4b4a36309..91bfa5131 100644
--- a/src/modules/m_dnsbl.cpp
+++ b/src/modules/m_dnsbl.cpp
@@ -54,7 +54,7 @@ class DNSBLResolver : public Resolver
ConfEntry = conf;
}
- virtual void OnLookupComplete(const std::string &result)
+ virtual void OnLookupComplete(const std::string &result, unsigned int ttl)
{
/* Check the user still exists */
if ((them) && (them == ServerInstance->SE->GetRef(theirfd)))
diff --git a/src/modules/m_http_client.cpp b/src/modules/m_http_client.cpp
index 9fdd75b14..0ca302ef6 100644
--- a/src/modules/m_http_client.cpp
+++ b/src/modules/m_http_client.cpp
@@ -60,7 +60,7 @@ class HTTPResolver : public Resolver
{
}
- void OnLookupComplete(const string &result)
+ void OnLookupComplete(const string &result, unsigned int ttl)
{
socket->Connect(result);
}
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index 623a62622..359196990 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -3719,7 +3719,7 @@ class ServernameResolver : public Resolver
/* Nothing in here, folks */
}
- void OnLookupComplete(const std::string &result)
+ void OnLookupComplete(const std::string &result, unsigned int ttl)
{
/* Initiate the connection, now that we have an IP to use.
* Passing a hostname directly to InspSocket causes it to
@@ -3768,7 +3768,7 @@ class SecurityIPResolver : public Resolver
{
}
- void OnLookupComplete(const std::string &result)
+ void OnLookupComplete(const std::string &result, unsigned int ttl)
{
ServerInstance->Log(DEBUG,"Security IP cache: Adding IP address '%s' for Link '%s'",result.c_str(),MyLink.Name.c_str());
Utils->ValidIPs.push_back(result);
diff --git a/src/modules/m_testcommand.cpp b/src/modules/m_testcommand.cpp
index 5e7fed341..640fd898e 100644
--- a/src/modules/m_testcommand.cpp
+++ b/src/modules/m_testcommand.cpp
@@ -31,9 +31,9 @@ class MyV6Resolver : public Resolver
fw = forward;
}
- virtual void OnLookupComplete(const std::string &result)
+ virtual void OnLookupComplete(const std::string &result, unsigned int ttl)
{
- ServerInstance->Log(DEBUG,"*** RESOLVER COMPLETED %s LOOKUP, IP IS: '%s'",fw ? "FORWARD" : "REVERSE", result.c_str());
+ ServerInstance->Log(DEBUG,"*** RESOLVER COMPLETED %s LOOKUP, IP IS: '%s' TTL=%lu",fw ? "FORWARD" : "REVERSE", result.c_str(), ttl);
}
virtual void OnError(ResolverError e, const std::string &errormessage)
diff --git a/src/users.cpp b/src/users.cpp
index c01c4e4b6..7ed3d2d40 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -166,7 +166,7 @@ UserResolver::UserResolver(InspIRCd* Instance, userrec* user, std::string to_res
this->bound_fd = user->GetFd();
}
-void UserResolver::OnLookupComplete(const std::string &result)
+void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl)
{
if ((!this->fwd) && (ServerInstance->SE->GetRef(this->bound_fd) == this->bound_user))
{