aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/inspircd.h9
-rw-r--r--src/coremods/core_dns.cpp2
-rw-r--r--src/helperfuncs.cpp4
3 files changed, 11 insertions, 4 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index edba04d24..3ad291909 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -390,9 +390,16 @@ class CoreExport InspIRCd
/** Determines whether a hostname is valid according to RFC 5891 rules.
* @param host The hostname to validate.
+ * @param allowsimple Whether to allow simple hostnames (e.g. localhost).
* @return True if the hostname is valid; otherwise, false.
*/
- static bool IsHost(const std::string& host);
+ static bool IsHost2(const std::string& host, bool allowsimple);
+
+ /** Determines whether a hostname is valid according to RFC 5891 rules.
+ * @param host The hostname to validate.
+ * @return True if the hostname is valid; otherwise, false.
+ */
+ inline static bool IsHost(const std::string& host) { return IsHost2(host, false); }
/** Return true if str looks like a server ID
* @param sid string to check against
diff --git a/src/coremods/core_dns.cpp b/src/coremods/core_dns.cpp
index 9330c173f..55f3ea6a4 100644
--- a/src/coremods/core_dns.cpp
+++ b/src/coremods/core_dns.cpp
@@ -192,7 +192,7 @@ class Packet : public Query
case QUERY_PTR:
{
record.rdata = this->UnpackName(input, input_size, pos);
- if (!InspIRCd::IsHost(record.rdata))
+ if (!InspIRCd::IsHost2(record.rdata, true))
throw Exception("Invalid name"); // XXX: Causes the request to time out
break;
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index f2b023f81..0b5681d0e 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -273,7 +273,7 @@ bool InspIRCd::DefaultIsIdent(const std::string& n)
return true;
}
-bool InspIRCd::IsHost(const std::string& host)
+bool InspIRCd::IsHost2(const std::string& host, bool allowsimple)
{
// Hostnames must be non-empty and shorter than the maximum hostname length.
if (host.empty() || host.length() > ServerInstance->Config->Limits.MaxHost)
@@ -329,7 +329,7 @@ bool InspIRCd::IsHost(const std::string& host)
// Whilst simple hostnames (e.g. localhost) are valid we do not allow the server to use
// them to prevent issues with clients that differentiate between short client and server
// prefixes by checking whether the nickname contains a dot.
- return numdots;
+ return numdots || allowsimple;
}
bool InspIRCd::IsSID(const std::string &str)