summaryrefslogtreecommitdiff
path: root/src/dns.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-10-01 21:01:49 -0400
committerAdam <Adam@anope.org>2010-10-01 21:01:49 -0400
commitd44f7971b129aa7ba80999f16f17b8c7499686e1 (patch)
treea86d08c3e641ed6b499b53b3bbb74e2a7f5b0dfb /src/dns.cpp
parent70056dd4689eeab4f7a9b31a921e0d7e40d5ed0d (diff)
Rewrote some of the socket code to allow m_ssl to be a service.
This allows modules (xmlrpc) to create and accept SSL connections. Also fixed unloading m_mysql at certain times and made the threading engine always work correctly on Windows.
Diffstat (limited to 'src/dns.cpp')
-rw-r--r--src/dns.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/dns.cpp b/src/dns.cpp
index 30624aeca..9f99a5b49 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -12,7 +12,10 @@ DNSRequest::DNSRequest(const Anope::string &addr, QueryType qt, bool cache, Modu
if (!DNSEngine)
DNSEngine = new DNSManager();
if (!DNSEngine->sock)
- DNSEngine->sock = new DNSSocket(Config->NameServer, DNSManager::DNSPort);
+ {
+ DNSEngine->sock = new DNSSocket();
+ DNSEngine->sock->Connect(Config->NameServer, DNSManager::DNSPort);
+ }
if (DNSEngine->packets.size() == 65535)
throw SocketException("DNS queue full");
@@ -197,7 +200,7 @@ inline DNSRecord::DNSRecord()
this->created = Anope::CurTime;
}
-DNSSocket::DNSSocket(const Anope::string &TargetHost, int Port) : ClientSocket(TargetHost, Port, "", false, SOCK_DGRAM)
+DNSSocket::DNSSocket() : ConnectionSocket(false, SOCK_DGRAM)
{
}
@@ -209,13 +212,13 @@ DNSSocket::~DNSSocket()
int DNSSocket::SendTo(const unsigned char *buf, size_t len) const
{
- return sendto(this->GetSock(), buf, len, 0, &this->conaddrs.sa, this->conaddrs.size());
+ return sendto(this->GetFD(), buf, len, 0, &this->conaddr.sa, this->conaddr.size());
}
int DNSSocket::RecvFrom(char *buf, size_t len, sockaddrs &addrs) const
{
socklen_t x = sizeof(addrs);
- return recvfrom(this->GetSock(), buf, len, 0, &addrs.sa, &x);
+ return recvfrom(this->GetFD(), buf, len, 0, &addrs.sa, &x);
}
bool DNSSocket::ProcessRead()
@@ -229,9 +232,9 @@ bool DNSSocket::ProcessRead()
if (length < 0)
return false;
- if (this->conaddrs != from_server)
+ if (this->conaddr != from_server)
{
- Log(LOG_DEBUG_2) << "Resolver: Received an answer from the wrong nameserver, Bad NAT or DNS forging attempt? '" << this->conaddrs.addr() << "' != '" << from_server.addr() << "'";
+ Log(LOG_DEBUG_2) << "Resolver: Received an answer from the wrong nameserver, Bad NAT or DNS forging attempt? '" << this->conaddr.addr() << "' != '" << from_server.addr() << "'";
return true;
}