mirror of
https://github.com/anope/anope.git
synced 2026-07-03 23:03:12 +02:00
Merge branch '1.9' of ssh://anope.git.sourceforge.net/gitroot/anope/anope into 1.9
This commit is contained in:
+2
-1
@@ -1056,12 +1056,13 @@ dns
|
||||
timeout = 5
|
||||
|
||||
/*
|
||||
* The port services use to listen for DNS queries.
|
||||
* The IP and port services use to listen for DNS queries.
|
||||
* Note that ports less than 1024 are privileged on UNIX/Linux systems, and
|
||||
* require Anope to be started as root. If you do this, it is recommended you
|
||||
* set options:user and options:group so Anope can change users after binding
|
||||
* to this port.
|
||||
*/
|
||||
ip = "0.0.0.0"
|
||||
port = 53
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -500,7 +500,8 @@ class CoreExport ServerConfig
|
||||
Anope::string NameServer;
|
||||
/* Time before a DNS query is considered dead */
|
||||
time_t DNSTimeout;
|
||||
/* The port DNS queries come in on */
|
||||
/* The IP/port DNS queries come in on */
|
||||
Anope::string DNSIP;
|
||||
int DNSPort;
|
||||
|
||||
/* Prefix of guest nicks when a user gets forced off of a nick */
|
||||
|
||||
+1
-1
@@ -162,7 +162,7 @@ class CoreExport DNSManager : public Timer, public Socket
|
||||
sockaddrs addrs;
|
||||
std::map<unsigned short, DNSRequest *> requests;
|
||||
|
||||
DNSManager(const Anope::string &nameserver, int port);
|
||||
DNSManager(const Anope::string &nameserver, const Anope::string &ip, int port);
|
||||
|
||||
~DNSManager();
|
||||
|
||||
|
||||
+2
-1
@@ -919,8 +919,9 @@ class CoreExport Module : public Extensible
|
||||
|
||||
/** Called when a DNS request (question) is recieved.
|
||||
* @param req The dns request
|
||||
* @param reply The reply that will be sent
|
||||
*/
|
||||
virtual void OnDnsRequest(DNSPacket &req) { }
|
||||
virtual void OnDnsRequest(DNSPacket &req, DNSPacket *reply) { }
|
||||
|
||||
/** Called when a channels modes are being checked to see if they are allowed,
|
||||
* mostly to ensure mlock/+r are set.
|
||||
|
||||
+22
-15
@@ -490,15 +490,14 @@ class ModuleDNS : public Module
|
||||
}
|
||||
}
|
||||
|
||||
void OnDnsRequest(DNSPacket &req) anope_override
|
||||
void OnDnsRequest(DNSPacket &req, DNSPacket *packet) anope_override
|
||||
{
|
||||
if (req.questions.empty())
|
||||
return;
|
||||
/* Currently we reply to any QR */
|
||||
/* Currently we reply to any QR for A/AAAA */
|
||||
const Question& q = req.questions[0];
|
||||
|
||||
DNSPacket *packet = new DNSPacket(req);
|
||||
packet->flags |= DNS_QUERYFLAGS_QR; /* This is a reponse */
|
||||
if (q.type != DNS_QUERY_A && q.type != DNS_QUERY_AAAA)
|
||||
return;
|
||||
|
||||
for (unsigned i = 0; i < dns_servers.size(); ++i)
|
||||
{
|
||||
@@ -508,10 +507,15 @@ class ModuleDNS : public Module
|
||||
|
||||
for (unsigned j = 0; j < s->GetIPs().size(); ++j)
|
||||
{
|
||||
ResourceRecord rr(q.name, s->GetIPs()[j].find(':') != Anope::string::npos ? DNS_QUERY_AAAA : DNS_QUERY_A);
|
||||
rr.ttl = this->ttl;
|
||||
rr.rdata = s->GetIPs()[j];
|
||||
packet->answers.push_back(rr);
|
||||
QueryType q_type = s->GetIPs()[j].find(':') != Anope::string::npos ? DNS_QUERY_AAAA : DNS_QUERY_A;
|
||||
|
||||
if (q_type == q.type)
|
||||
{
|
||||
ResourceRecord rr(q.name, q_type);
|
||||
rr.ttl = this->ttl;
|
||||
rr.rdata = s->GetIPs()[j];
|
||||
packet->answers.push_back(rr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -531,10 +535,15 @@ class ModuleDNS : public Module
|
||||
|
||||
for (unsigned j = 0; j < s->GetIPs().size(); ++j)
|
||||
{
|
||||
ResourceRecord rr(q.name, s->GetIPs()[j].find(':') != Anope::string::npos ? DNS_QUERY_AAAA : DNS_QUERY_A);
|
||||
rr.ttl = this->ttl;
|
||||
rr.rdata = s->GetIPs()[j];
|
||||
packet->answers.push_back(rr);
|
||||
QueryType q_type = s->GetIPs()[j].find(':') != Anope::string::npos ? DNS_QUERY_AAAA : DNS_QUERY_A;
|
||||
|
||||
if (q_type == q.type)
|
||||
{
|
||||
ResourceRecord rr(q.name, q_type);
|
||||
rr.ttl = this->ttl;
|
||||
rr.rdata = s->GetIPs()[j];
|
||||
packet->answers.push_back(rr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,8 +553,6 @@ class ModuleDNS : public Module
|
||||
/* Send back an empty answer anyway */
|
||||
}
|
||||
}
|
||||
|
||||
DNSEngine->SendPacket(packet);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+2
-1
@@ -210,7 +210,7 @@ ServerConfig::ServerConfig() : config_data(), NSDefFlags(NickCoreFlagStrings), C
|
||||
}
|
||||
if (DNSEngine)
|
||||
DNSEngine->SetFlag(SF_DEAD);
|
||||
DNSEngine = new DNSManager(this->NameServer, this->DNSPort);
|
||||
DNSEngine = new DNSManager(this->NameServer, this->DNSIP, this->DNSPort);
|
||||
|
||||
if (this->CaseMap == "ascii")
|
||||
Anope::casemap = std::locale(std::locale(), new Anope::ascii_ctype<char>());
|
||||
@@ -1302,6 +1302,7 @@ ConfigItems::ConfigItems(ServerConfig *conf)
|
||||
{"mail", "memo_message", "", new ValueContainerString(&conf->MailMemoMessage), DT_STRING | DT_ALLOW_NEWLINE, ValidateMail},
|
||||
{"dns", "nameserver", "127.0.0.1", new ValueContainerString(&conf->NameServer), DT_STRING, NoValidation},
|
||||
{"dns", "timeout", "5", new ValueContainerTime(&conf->DNSTimeout), DT_TIME, NoValidation},
|
||||
{"dns", "ip", "0.0.0.0", new ValueContainerString(&conf->DNSIP), DT_STRING, NoValidation},
|
||||
{"dns", "port", "53", new ValueContainerInt(&conf->DNSPort), DT_INTEGER, NoValidation},
|
||||
{"chanserv", "name", "", new ValueContainerString(&conf->ChanServ), DT_STRING, NoValidation},
|
||||
{"chanserv", "defaults", "keeptopic secure securefounder signkick", new ValueContainerString(&CSDefaults), DT_STRING, ValidateChanServ},
|
||||
|
||||
+8
-3
@@ -462,12 +462,12 @@ unsigned short DNSPacket::Pack(unsigned char *output, unsigned short output_size
|
||||
return pos;
|
||||
}
|
||||
|
||||
DNSManager::DNSManager(const Anope::string &nameserver, int port) : Timer(300, Anope::CurTime, true), Socket(-1, nameserver.find(':') != Anope::string::npos, SOCK_DGRAM)
|
||||
DNSManager::DNSManager(const Anope::string &nameserver, const Anope::string &ip, int port) : Timer(300, Anope::CurTime, true), Socket(-1, nameserver.find(':') != Anope::string::npos, SOCK_DGRAM)
|
||||
{
|
||||
this->addrs.pton(this->IPv6 ? AF_INET6 : AF_INET, nameserver, port);
|
||||
try
|
||||
{
|
||||
this->Bind("0.0.0.0", port);
|
||||
this->Bind(ip, port);
|
||||
}
|
||||
catch (const SocketException &ex)
|
||||
{
|
||||
@@ -525,7 +525,12 @@ bool DNSManager::ProcessRead()
|
||||
|
||||
if (!(recv_packet.flags & DNS_QUERYFLAGS_QR))
|
||||
{
|
||||
FOREACH_MOD(I_OnDnsRequest, OnDnsRequest(recv_packet));
|
||||
DNSPacket *packet = new DNSPacket(recv_packet);
|
||||
packet->flags |= DNS_QUERYFLAGS_QR; /* This is a reponse */
|
||||
|
||||
FOREACH_MOD(I_OnDnsRequest, OnDnsRequest(recv_packet, packet));
|
||||
|
||||
DNSEngine->SendPacket(packet);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ serialize_checker<nickcore_map> NickCoreList("NickCore");
|
||||
/** Default constructor
|
||||
* @param display The display nick
|
||||
*/
|
||||
NickCore::NickCore(const Anope::string &coredisplay) : Serializable("NickCore"), Flags<NickCoreFlag, NI_END>(NickCoreFlagStrings)
|
||||
NickCore::NickCore(const Anope::string &coredisplay) : Serializable("NickCore"), Flags<NickCoreFlag, NI_END>(NickCoreFlagStrings)
|
||||
{
|
||||
if (coredisplay.empty())
|
||||
throw CoreException("Empty display passed to NickCore constructor");
|
||||
|
||||
+1
-1
@@ -274,7 +274,7 @@ ChannelInfo::ChannelInfo(const Anope::string &chname) : Serializable("ChannelInf
|
||||
/** Copy constructor
|
||||
* @param ci The ChannelInfo to copy settings to
|
||||
*/
|
||||
ChannelInfo::ChannelInfo(const ChannelInfo &ci) : Flags<ChannelInfoFlag, CI_END>(ChannelInfoFlagStrings), Serializable("ChannelInfo"),
|
||||
ChannelInfo::ChannelInfo(const ChannelInfo &ci) : Serializable("ChannelInfo"), Flags<ChannelInfoFlag, CI_END>(ChannelInfoFlagStrings),
|
||||
access("ChanAccess"), akick("AutoKick"),
|
||||
badwords("BadWord"), mode_locks("ModeLock"), log_settings("LogSetting"), botflags(BotServFlagStrings)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user