#include "configreader.h"
#include "socket.h"
-using irc::sockets::insp_sockaddr;
using irc::sockets::insp_inaddr;
using irc::sockets::insp_ntoa;
using irc::sockets::insp_aton;
/** Start lookup of an IP address to a hostname */
int DNS::GetNameForce(const char *ip, ForceProtocol fp)
{
- ServerInstance->Log(DEBUG,"GetNameForce: %s", ip);
char query[128];
DNSHeader h;
int id;
in6_addr i;
if (inet_pton(AF_INET6, ip, &i) > 0)
{
- ServerInstance->Log(DEBUG,"Resolve to ipv6");
DNS::MakeIP6Int(query, &i);
}
else
in_addr i;
if (inet_aton(ip, &i))
{
- ServerInstance->Log(DEBUG,"Resolve to ipv4");
unsigned char* c = (unsigned char*)&i.s_addr;
sprintf(query,"%d.%d.%d.%d.in-addr.arpa",c[3],c[2],c[1],c[0]);
}
#else
socklen_t x = sizeof(sockaddr_in);
#endif
- char nbuf[MAXBUF];
const char* ipaddr_from;
unsigned short int port_from = 0;
int length = recvfrom(this->GetFd(),buffer,sizeof(DNSHeader),0,from,&x);
- ServerInstance->Log(DEBUG,"Recv %d.", length);
-
/* Did we get the whole header? */
if (length < 12)
{
* -- Thanks jilles for pointing this one out.
*/
#ifdef IPV6
+ char nbuf[MAXBUF];
if (this->socketfamily == AF_INET6)
{
ipaddr_from = inet_ntop(AF_INET6, &((sockaddr_in6*)from)->sin6_addr, nbuf, sizeof(nbuf));
{
if ((port_from != DNS::QUERY_PORT) || (strcasecmp(ipaddr_from, ServerInstance->Config->DNSServer)))
{
- ServerInstance->Log(DEBUG,"Doesnt match security: port_from=%d ipaddr_from=%s",port_from,ipaddr_from);
return DNSResult(-1,"",0,"");
}
}
/** Process a socket read event */
void DNS::HandleEvent(EventType et, int errornum)
{
- ServerInstance->Log(DEBUG,"Marshall dns reads");
/* Fetch the id and result of the next available packet */
DNSResult res = this->GetResult();
/* Is there a usable request id? */