-void ServerConfig::Update005()
-{
- std::stringstream out(data005);
- std::string token;
- std::string line5;
- int token_counter = 0;
- isupport.clear();
- while (out >> token)
- {
- line5 = line5 + token + " ";
- token_counter++;
- if (token_counter >= 13)
- {
- char buf[MAXBUF];
- snprintf(buf, MAXBUF, "%s:are supported by this server", line5.c_str());
- isupport.push_back(buf);
- line5.clear();
- token_counter = 0;
- }
- }
- if (!line5.empty())
- {
- char buf[MAXBUF];
- snprintf(buf, MAXBUF, "%s:are supported by this server", line5.c_str());
- isupport.push_back(buf);
- }
-}
-
-void ServerConfig::Send005(User* user)
-{
- for (std::vector<std::string>::iterator line = ServerInstance->Config->isupport.begin(); line != ServerInstance->Config->isupport.end(); line++)
- user->WriteNumeric(RPL_ISUPPORT, "%s %s", user->nick.c_str(), line->c_str());
-}
-
-static void ReqRead(ServerConfig* src, const std::string& tag, const std::string& key, std::string& dest)
-{
- ConfigTag* t = src->ConfValue(tag);
- if (!t || !t->readString(key, dest))
- throw CoreException("You must specify a value for <" + tag + ":" + key + ">");
-}
-
-template<typename T, typename V>
-static void range(T& value, V min, V max, V def, const char* msg)
-{
- if (value >= (T)min && value <= (T)max)
- return;
- ServerInstance->Logs->Log("CONFIG", DEFAULT,
- "WARNING: %s value of %ld is not between %ld and %ld; set to %ld.",
- msg, (long)value, (long)min, (long)max, (long)def);
- value = def;
-}
-
-
-/* NOTE: Before anyone asks why we're not using inet_pton for this, it is because inet_pton and friends do not return so much detail,
- * even in strerror(errno). They just return 'yes' or 'no' to an address without such detail as to whats WRONG with the address.
- * Because ircd users arent as technical as they used to be (;)) we are going to give more of a useful error message.
- */
-static void ValidIP(const std::string& ip, const std::string& key)
-{
- const char* p = ip.c_str();
- int num_dots = 0;
- int num_seps = 0;
- int not_numbers = false;
- int not_hex = false;
-
- if (*p)
- {
- if (*p == '.')
- throw CoreException("The value of "+key+" is not an IP address");
-
- for (const char* ptr = p; *ptr; ++ptr)
- {
- if (*ptr != ':' && *ptr != '.')
- {
- if (*ptr < '0' || *ptr > '9')
- not_numbers = true;
- if ((*ptr < '0' || *ptr > '9') && (toupper(*ptr) < 'A' || toupper(*ptr) > 'F'))
- not_hex = true;
- }
- switch (*ptr)
- {
- case ' ':
- throw CoreException("The value of "+key+" is not an IP address");
- case '.':
- num_dots++;
- break;
- case ':':
- num_seps++;
- break;
- }
- }
-
- if (num_dots > 3)
- throw CoreException("The value of "+key+" is an IPv4 address with too many fields!");
-
- if (num_seps > 8)
- throw CoreException("The value of "+key+" is an IPv6 address with too many fields!");
-
- if (num_seps == 0 && num_dots < 3)
- throw CoreException("The value of "+key+" looks to be a malformed IPv4 address");
-
- if (num_seps == 0 && num_dots == 3 && not_numbers)
- throw CoreException("The value of "+key+" contains non-numeric characters in an IPv4 address");
-
- if (num_seps != 0 && not_hex)
- throw CoreException("The value of "+key+" contains non-hexdecimal characters in an IPv6 address");
-
- if (num_seps != 0 && num_dots != 3 && num_dots != 0)
- throw CoreException("The value of "+key+" is a malformed IPv6 4in6 address");
- }
-}
-