mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 10:39:02 -04:00
Use string_view in InspIRCd::Is{FQDN,Host,SID}.
This commit is contained in:
parent
83e142fa2f
commit
73a98ce7be
@ -340,20 +340,20 @@ public:
|
||||
* @param host The hostname to validate.
|
||||
* @return True if the hostname is valid; otherwise, false.
|
||||
*/
|
||||
inline static auto IsFQDN(const std::string& host) { return IsHost(host, false); }
|
||||
inline static auto IsFQDN(const std::string_view& host) { return IsHost(host, false); }
|
||||
|
||||
/** 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, bool allowsimple);
|
||||
static bool IsHost(const std::string_view& host, bool allowsimple);
|
||||
|
||||
/** Determines whether the specified string is a server identifier.
|
||||
* @param sid The string to check.
|
||||
* @return True if the specified string is a server identifier; otherwise, false.
|
||||
*/
|
||||
static bool IsSID(const std::string& sid);
|
||||
static bool IsSID(const std::string_view& sid);
|
||||
|
||||
/** Determines whether the specified string is a valid nick!user\@host mask.
|
||||
* @param mask The string to check.
|
||||
|
@ -292,7 +292,7 @@ bool InspIRCd::DefaultIsUser(const std::string_view& n)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InspIRCd::IsHost(const std::string& host, bool allowsimple)
|
||||
bool InspIRCd::IsHost(const std::string_view& host, bool allowsimple)
|
||||
{
|
||||
// Hostnames must be non-empty and shorter than the maximum hostname length.
|
||||
if (host.empty() || host.length() > ServerInstance->Config->Limits.MaxHost)
|
||||
@ -301,10 +301,10 @@ bool InspIRCd::IsHost(const std::string& host, bool allowsimple)
|
||||
unsigned int numdashes = 0;
|
||||
unsigned int numdots = 0;
|
||||
bool seendot = false;
|
||||
const std::string::const_iterator hostend = host.end() - 1;
|
||||
for (std::string::const_iterator iter = host.begin(); iter != host.end(); ++iter)
|
||||
const auto hostend = host.end() - 1;
|
||||
for (auto iter = host.begin(); iter != host.end(); ++iter)
|
||||
{
|
||||
unsigned char chr = static_cast<unsigned char>(*iter);
|
||||
const auto chr = static_cast<unsigned char>(*iter);
|
||||
|
||||
// If the current character is a label separator.
|
||||
if (chr == '.')
|
||||
@ -351,7 +351,7 @@ bool InspIRCd::IsHost(const std::string& host, bool allowsimple)
|
||||
return numdots || allowsimple;
|
||||
}
|
||||
|
||||
bool InspIRCd::IsSID(const std::string& str)
|
||||
bool InspIRCd::IsSID(const std::string_view& str)
|
||||
{
|
||||
/* Returns true if the string given is exactly 3 characters long,
|
||||
* starts with a digit, and the other two characters are A-Z or digits
|
||||
|
Loading…
x
Reference in New Issue
Block a user