summaryrefslogtreecommitdiff
path: root/src/dns.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-01 15:07:02 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-01 15:07:02 +0000
commita64a4665e0a2898ec08cf5996bdbf63c2567310e (patch)
tree06e2058753822e90224c07874bcd31ab376430fd /src/dns.cpp
parent1819d0109b0d3c3cf8c619849f8e67a9ffef57ab (diff)
Remove needless sockaddr[2] allocations, replace with irc::sockets::sockaddrs union
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11574 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/dns.cpp')
-rw-r--r--src/dns.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/dns.cpp b/src/dns.cpp
index 79a2e2473..f088055f8 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -611,22 +611,17 @@ DNSResult DNS::GetResult()
DNSHeader header;
DNSRequest *req;
unsigned char buffer[sizeof(DNSHeader)];
- sockaddr* from = new sockaddr[2];
-#ifdef IPV6
+ irc::sockets::sockaddrs from;
socklen_t x = this->socketfamily == AF_INET ? sizeof(sockaddr_in) : sizeof(sockaddr_in6);
-#else
- socklen_t x = sizeof(sockaddr_in);
-#endif
const char* ipaddr_from;
unsigned short int port_from = 0;
- int length = ServerInstance->SE->RecvFrom(this, (char*)buffer, sizeof(DNSHeader), 0, from, &x);
+ int length = ServerInstance->SE->RecvFrom(this, (char*)buffer, sizeof(DNSHeader), 0, &from.sa, &x);
/* Did we get the whole header? */
if (length < 12)
{
/* Nope - something screwed up. */
- delete[] from;
return DNSResult(-1,"",0,"");
}
@@ -643,18 +638,16 @@ DNSResult DNS::GetResult()
char nbuf[MAXBUF];
if (this->socketfamily == AF_INET6)
{
- ipaddr_from = inet_ntop(AF_INET6, &((sockaddr_in6*)from)->sin6_addr, nbuf, sizeof(nbuf));
- port_from = ntohs(((sockaddr_in6*)from)->sin6_port);
+ ipaddr_from = inet_ntop(AF_INET6, &from.in6.sin6_addr, nbuf, sizeof(nbuf));
+ port_from = ntohs(from.in6.sin6_port);
}
else
#endif
{
- ipaddr_from = inet_ntoa(((sockaddr_in*)from)->sin_addr);
- port_from = ntohs(((sockaddr_in*)from)->sin_port);
+ ipaddr_from = inet_ntoa(from.in4.sin_addr);
+ port_from = ntohs(from.in4.sin_port);
}
- delete[] from;
-
/* We cant perform this security check if you're using 4in6.
* Tough luck to you, choose one or't other!
*/