summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDukePyrolator <DukePyrolator@anope.org>2012-10-24 05:12:47 +0200
committerDukePyrolator <DukePyrolator@anope.org>2012-10-24 05:12:47 +0200
commitef5c6684c71fda6837f4d217d4f61bb418523047 (patch)
tree599dffcd828fc4a4213a7a2d2b17a449ed3c6e77
parente0438e3a7ee3b7737f5138e7f43157b07479c824 (diff)
parent04632bd381796dd90742bbc6ccd38905d4de25be (diff)
Merge branch '1.9' of ssh://anope.git.sourceforge.net/gitroot/anope/anope into 1.9
-rw-r--r--data/example.conf3
-rw-r--r--include/config.h3
-rw-r--r--include/dns.h2
-rw-r--r--include/modules.h3
-rw-r--r--modules/commands/os_dns.cpp37
-rw-r--r--src/config.cpp3
-rw-r--r--src/dns.cpp11
-rw-r--r--src/nickcore.cpp2
-rw-r--r--src/regchannel.cpp2
9 files changed, 41 insertions, 25 deletions
diff --git a/data/example.conf b/data/example.conf
index 6680c6bad..8330eeb78 100644
--- a/data/example.conf
+++ b/data/example.conf
@@ -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
}
diff --git a/include/config.h b/include/config.h
index 947daa3e5..5851247e8 100644
--- a/include/config.h
+++ b/include/config.h
@@ -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 */
diff --git a/include/dns.h b/include/dns.h
index 062fed26f..bb57945f3 100644
--- a/include/dns.h
+++ b/include/dns.h
@@ -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();
diff --git a/include/modules.h b/include/modules.h
index 3827e9234..cdaf53fc0 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -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.
diff --git a/modules/commands/os_dns.cpp b/modules/commands/os_dns.cpp
index 5a4e3e1c3..d1c20f0a4 100644
--- a/modules/commands/os_dns.cpp
+++ b/modules/commands/os_dns.cpp
@@ -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);
}
};
diff --git a/src/config.cpp b/src/config.cpp
index 6347754fb..6dc19e83a 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -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},
diff --git a/src/dns.cpp b/src/dns.cpp
index 519e02b8f..7c62b594a 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -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;
}
diff --git a/src/nickcore.cpp b/src/nickcore.cpp
index 5d9950a4e..71d117de1 100644
--- a/src/nickcore.cpp
+++ b/src/nickcore.cpp
@@ -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");
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index e7bea1c83..f402b5820 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -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)
{