mirror of
https://github.com/anope/anope.git
synced 2026-06-28 13:16:38 +02:00
Allow hostmasks to be in uplink:host
(cherry picked from commit 18377ac9fd)
This commit is contained in:
@@ -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
|
||||
|
||||
+33
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+8
-11
@@ -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);
|
||||
|
||||
BotInfo *bi = findbot(u->nick);
|
||||
if (bi)
|
||||
{
|
||||
ircdproto->SendClientIntroduction(u, ircd->pseudoclient_mode);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user