diff options
author | Adam <Adam@anope.org> | 2010-12-21 15:57:57 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-12-24 20:06:25 -0500 |
commit | a2a6708f1a2b36bb5a769005efd6869ca5a4036a (patch) | |
tree | 714204a7a74fd3679cec1ce7f2a1c185a8c8930f /src | |
parent | faf1e3710ef2d86c6b4a562814d6cfaa064723a9 (diff) |
Allow hostmasks to be in uplink:host
(cherry picked from commit 18377ac9fd36065bfd791b5cea51de9ae1d2b11d)
Diffstat (limited to 'src')
-rw-r--r-- | src/dns.cpp | 33 | ||||
-rw-r--r-- | src/init.cpp | 19 | ||||
-rw-r--r-- | src/main.cpp | 4 |
3 files changed, 44 insertions, 12 deletions
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 9cb589653..f2e354e98 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -61,19 +61,16 @@ void introduce_user(const Anope::string &user) { User *u = it->second; - 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 c87b0a7fc..3ceb20675 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -361,10 +361,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) { |