summaryrefslogtreecommitdiff
path: root/modules/m_dns.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/m_dns.cpp')
-rw-r--r--modules/m_dns.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/modules/m_dns.cpp b/modules/m_dns.cpp
index dfe44516a..a4c2f21ac 100644
--- a/modules/m_dns.cpp
+++ b/modules/m_dns.cpp
@@ -106,7 +106,7 @@ class Packet : public Query
return name;
}
-
+
Question UnpackQuestion(const unsigned char *input, unsigned short input_size, unsigned short &pos)
{
Question question;
@@ -202,7 +202,7 @@ class Packet : public Query
unsigned short id;
/* Flags on the packet */
unsigned short flags;
-
+
Packet(Manager *m, sockaddrs *a) : manager(m), id(0), flags(0)
{
if (a)
@@ -238,7 +238,7 @@ class Packet : public Query
for (unsigned i = 0; i < qdcount; ++i)
this->questions.push_back(this->UnpackQuestion(input, len, packet_pos));
-
+
for (unsigned i = 0; i < ancount; ++i)
this->answers.push_back(this->UnpackResourceRecord(input, len, packet_pos));
@@ -253,7 +253,7 @@ class Packet : public Query
{
if (output_size < HEADER_LENGTH)
throw SocketException("Unable to pack packet");
-
+
unsigned short pos = 0;
output[pos++] = this->id >> 8;
@@ -416,7 +416,7 @@ class Packet : public Query
l = htonl(manager->GetSerial());
memcpy(&output[pos], &l, 4);
pos += 4;
-
+
l = htonl(refresh); // Refresh
memcpy(&output[pos], &l, 4);
pos += 4;
@@ -442,7 +442,7 @@ class Packet : public Query
break;
}
}
-
+
return pos;
}
};
@@ -461,7 +461,7 @@ namespace DNS
class TCPSocket : public ListenSocket
{
Manager *manager;
-
+
public:
/* A TCP client */
class Client : public ClientSocket, public Timer, public ReplySocket
@@ -470,7 +470,7 @@ class TCPSocket : public ListenSocket
Packet *packet;
unsigned char packet_buffer[524];
int length;
-
+
public:
Client(Manager *m, TCPSocket *l, int fd, const sockaddrs &addr) : Socket(fd, l->IsIPv6()), ClientSocket(l, addr), Timer(5),
manager(m), packet(NULL), length(0)
@@ -483,7 +483,7 @@ class TCPSocket : public ListenSocket
Log(LOG_DEBUG_2) << "Resolver: Exiting client from " << clientaddr.addr();
delete packet;
}
-
+
/* Times out after a few seconds */
void Tick(time_t) override { }
@@ -543,13 +543,13 @@ class TCPSocket : public ListenSocket
};
TCPSocket(Manager *m, const Anope::string &ip, int port) : Socket(-1, ip.find(':') != Anope::string::npos), ListenSocket(ip, port, ip.find(':') != Anope::string::npos), manager(m) { }
-
+
ClientSocket *OnAccept(int fd, const sockaddrs &addr) override
{
return new Client(this->manager, this, fd, addr);
}
};
-
+
/* Listens for UDP requests */
class UDPSocket : public ReplySocket
{
@@ -564,15 +564,15 @@ class UDPSocket : public ReplySocket
for (unsigned i = 0; i < packets.size(); ++i)
delete packets[i];
}
-
+
void Reply(Packet *p) override
{
packets.push_back(p);
SocketEngine::Change(this, true, SF_WRITABLE);
}
-
+
std::deque<Packet *>& GetPackets() { return packets; }
-
+
bool ProcessRead() override
{
Log(LOG_DEBUG_2) << "Resolver: Reading from DNS UDP socket";
@@ -583,7 +583,7 @@ class UDPSocket : public ReplySocket
int length = recvfrom(this->GetFD(), reinterpret_cast<char *>(&packet_buffer), sizeof(packet_buffer), 0, &from_server.sa, &x);
return this->manager->HandlePacket(this, packet_buffer, length, &from_server);
}
-
+
bool ProcessWrite() override
{
Log(LOG_DEBUG_2) << "Resolver: Writing to DNS UDP socket";
@@ -606,7 +606,7 @@ class UDPSocket : public ReplySocket
if (packets.empty())
SocketEngine::Change(this, false, SF_WRITABLE);
-
+
return true;
}
};
@@ -672,7 +672,7 @@ class MyManager : public Manager, public Timer
delete tcpsock;
for (std::map<unsigned short, Request *>::iterator it = this->requests.begin(), it_end = this->requests.end(); it != it_end;)
- {
+ {
Request *request = it->second;
++it;
@@ -750,7 +750,7 @@ class MyManager : public Manager, public Timer
this->requests[req->id] = req;
req->SetSecs(timeout);
-
+
Packet *p = new Packet(this, &this->addrs);
p->flags = QUERYFLAGS_RD;
p->id = req->id;
@@ -911,7 +911,7 @@ class MyManager : public Manager, public Timer
request->OnLookupComplete(&recv_packet);
this->AddCache(recv_packet);
}
-
+
delete request;
return true;
}
@@ -972,7 +972,7 @@ class MyManager : public Manager, public Timer
this->cache.erase(it);
}
}
-
+
private:
/** Add a record to the dns cache
* @param r The record
@@ -1000,7 +1000,7 @@ class MyManager : public Manager, public Timer
return false;
}
-
+
};
class ModuleDNS : public Module