summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDukePyrolator <DukePyrolator@anope.org>2010-12-22 07:05:40 +0100
committerDukePyrolator <DukePyrolator@anope.org>2010-12-22 07:05:40 +0100
commit184e7b3f64beb104e2d676048fc5bf485c5ad743 (patch)
tree13aefec932d42365c50649b008c00612ec2e8d86
parent184e14ea83412489921367614d63a7c24df3827d (diff)
parent18377ac9fd36065bfd791b5cea51de9ae1d2b11d (diff)
Merge branch '1.9' of ssh://anope.git.sourceforge.net/gitroot/anope/anope into 1.9
-rw-r--r--include/dns.h6
-rw-r--r--src/dns.cpp33
-rw-r--r--src/init.cpp19
-rw-r--r--src/main.cpp4
4 files changed, 50 insertions, 12 deletions
diff --git a/include/dns.h b/include/dns.h
index 653229b6f..c95cc64de 100644
--- a/include/dns.h
+++ b/include/dns.h
@@ -174,6 +174,12 @@ class DNSManager : public Timer
void Tick(time_t now);
void Cleanup(Module *mod);
+
+ /** Does a BLOCKING DNS query and returns the first IP.
+ * Only use this if you know what you are doing. Unless you specifically
+ * need a blocking query use the DNSRequest system
+ */
+ static DNSRecord BlockingQuery(const Anope::string &mask, QueryType qt);
};
/** A DNS timeout, one is made for every DNS request to detect timeouts
diff --git a/src/dns.cpp b/src/dns.cpp
index b37a0bde6..e5a2c3098 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -608,3 +608,36 @@ void DNSRequestTimeout::Tick(time_t)
delete this->request;
}
+DNSRecord DNSManager::BlockingQuery(const Anope::string &mask, QueryType qt)
+{
+ DNSRecord result(mask);
+ addrinfo *addrresult, hints;
+
+ result.result = mask;
+ result.type = qt;
+
+ int type = AF_UNSPEC;
+ if (qt == DNS_QUERY_A)
+ type = AF_INET;
+ else if (qt == DNS_QUERY_AAAA)
+ type = AF_INET6;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = type;
+
+ if (getaddrinfo(mask.c_str(), NULL, &hints, &addrresult) == 0)
+ {
+ sockaddrs addr;
+ memcpy(&addr, addrresult->ai_addr, addrresult->ai_addrlen);
+ try
+ {
+ result.result = addr.addr();
+ }
+ catch (const SocketException &) { }
+
+ freeaddrinfo(addrresult);
+ }
+
+ return result;
+}
+
diff --git a/src/init.cpp b/src/init.cpp
index 3fb8f55a4..54d3e3bdb 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -61,19 +61,16 @@ void introduce_user(const Anope::string &user)
{
User *u = *it;
- if (u->nick.equals_ci(user))
- {
- ircdproto->SendClientIntroduction(u, ircd->pseudoclient_mode);
+ ircdproto->SendClientIntroduction(u, ircd->pseudoclient_mode);
- BotInfo *bi = findbot(u->nick);
- if (bi)
- {
- XLine x(bi->nick, "Reserved for services");
- ircdproto->SendSQLine(&x);
+ BotInfo *bi = findbot(u->nick);
+ if (bi)
+ {
+ XLine x(bi->nick, "Reserved for services");
+ ircdproto->SendSQLine(&x);
- for (UChannelList::const_iterator cit = bi->chans.begin(), cit_end = bi->chans.end(); cit != cit_end; ++cit)
- ircdproto->SendJoin(bi, *cit);
- }
+ for (UChannelList::const_iterator cit = bi->chans.begin(), cit_end = bi->chans.end(); cit != cit_end; ++cit)
+ ircdproto->SendJoin(bi, *cit);
}
}
diff --git a/src/main.cpp b/src/main.cpp
index 180af0729..c3c5b0eec 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -365,10 +365,12 @@ static bool Connect()
return true;
}
+ DNSRecord req = DNSManager::BlockingQuery(uplink_server->host, uplink_server->ipv6 ? DNS_QUERY_AAAA : DNS_QUERY_A);
+
try
{
new UplinkSocket(uplink_server->ipv6);
- UplinkSock->Connect(uplink_server->host, uplink_server->port, Config->LocalHost);
+ UplinkSock->Connect(req.result, uplink_server->port, Config->LocalHost);
}
catch (const SocketException &ex)
{