-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
*
- * InspIRCd: (C) 2002-2010 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
+ * Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
+ * Copyright (C) 2007-2009 Robin Burchell <robin+git@viroteck.net>
+ * Copyright (C) 2006-2009 Dennis Friis <peavey@inspircd.org>
+ * Copyright (C) 2006-2008 Craig Edwards <craigedwards@brainbox.cc>
+ * Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
+ * Copyright (C) 2006 Oliver Lupton <oliverlupton@gmail.com>
*
- * This program is free but copyrighted software; see
- * the file COPYING for details.
+ * This file is part of InspIRCd. InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
*
- * ---------------------------------------------------
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
#include "inspircd.h"
#include <fstream>
#include "xline.h"
#include "exitcodes.h"
#include "commands/cmd_whowas.h"
#include "configparser.h"
+#include <iostream>
+#ifdef _WIN32
+#include <Iphlpapi.h>
+#pragma comment(lib, "Iphlpapi.lib")
+#endif
ServerConfig::ServerConfig()
{
return true;
}
-#ifdef WINDOWS
-// Note: the windows validator is in win32wrapper.cpp
-void FindDNS(std::string& server);
-#else
static void FindDNS(std::string& server)
{
if (!server.empty())
return;
+#ifdef _WIN32
+ // attempt to look up their nameserver from the system
+ ServerInstance->Logs->Log("CONFIG",DEFAULT,"WARNING: <dns:server> not defined, attempting to find a working server in the system settings...");
+
+ PFIXED_INFO pFixedInfo;
+ DWORD dwBufferSize = sizeof(FIXED_INFO);
+ pFixedInfo = (PFIXED_INFO) HeapAlloc(GetProcessHeap(), 0, sizeof(FIXED_INFO));
+
+ if(pFixedInfo)
+ {
+ if (GetNetworkParams(pFixedInfo, &dwBufferSize) == ERROR_BUFFER_OVERFLOW) {
+ HeapFree(GetProcessHeap(), 0, pFixedInfo);
+ pFixedInfo = (PFIXED_INFO) HeapAlloc(GetProcessHeap(), 0, dwBufferSize);
+ }
+
+ if(pFixedInfo) {
+ if (GetNetworkParams(pFixedInfo, &dwBufferSize) == NO_ERROR)
+ server = pFixedInfo->DnsServerList.IpAddress.String;
+
+ HeapFree(GetProcessHeap(), 0, pFixedInfo);
+ }
+
+ if(!server.empty())
+ {
+ ServerInstance->Logs->Log("CONFIG",DEFAULT,"<dns:server> set to '%s' as first active resolver in the system settings.", server.c_str());
+ return;
+ }
+ }
+ ServerInstance->Logs->Log("CONFIG",DEFAULT,"No viable nameserver found! Defaulting to nameserver '127.0.0.1'!");
+#else
// attempt to look up their nameserver from /etc/resolv.conf
ServerInstance->Logs->Log("CONFIG",DEFAULT,"WARNING: <dns:server> not defined, attempting to find working server in /etc/resolv.conf...");
}
ServerInstance->Logs->Log("CONFIG",DEFAULT,"/etc/resolv.conf contains no viable nameserver entries! Defaulting to nameserver '127.0.0.1'!");
+#endif
server = "127.0.0.1";
}
-#endif
static void ReadXLine(ServerConfig* conf, const std::string& tag, const std::string& key, XLineFactory* make)
{
throw CoreException("Two connect classes with name \"" + name + "\" defined!");
names[name] = i;
- ConnectClass* me = parent ?
+ ConnectClass* me = parent ?
new ConnectClass(tag, type, mask, *parent) :
new ConnectClass(tag, type, mask);
{"options", "somaxconn", "has been moved to <performance:somaxconn> as of 1.2a3"},
{"options", "netbuffersize", "has been moved to <performance:netbuffersize> as of 1.2a3"},
{"options", "maxwho", "has been moved to <performance:maxwho> as of 1.2a3"},
- {"options", "loglevel", "1.2 does not use the loglevel value. Please define <log> tags instead."},
+ {"options", "loglevel", "1.2+ does not use the loglevel value. Please define <log> tags instead."},
{"die", "value", "you need to reread your config"},
+ {"bind", "transport", "has been moved to <bind:ssl> as of 2.0a1"},
+ {"link", "transport", "has been moved to <link:ssl> as of 2.0a1"},
+ {"link", "autoconnect", "2.0+ does not use the autoconnect value. Please define <autoconnect> tags instead."},
};
void ServerConfig::Fill()
Limits.MaxAway = ConfValue("limits")->getInt("maxaway", 200);
InvBypassModes = options->getBool("invitebypassmodes", true);
NoSnoticeStack = options->getBool("nosnoticestack", false);
+ WelcomeNotice = options->getBool("welcomenotice", true);
range(SoftLimit, 10, ServerInstance->SE->GetMaxFds(), ServerInstance->SE->GetMaxFds(), "<performance:softlimit>");
range(MaxConn, 0, SOMAXCONN, SOMAXCONN, "<performance:somaxconn>");
ReadXLine(this, "exception", "host", ServerInstance->XLines->GetFactory("E"));
memset(DisabledUModes, 0, sizeof(DisabledUModes));
- for (const unsigned char* p = (const unsigned char*)ConfValue("disabled")->getString("usermodes").c_str(); *p; ++p)
+ std::string modes = ConfValue("disabled")->getString("usermodes");
+ for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p)
{
- if (*p < 'A' || *p > ('A' + 64)) throw CoreException(std::string("Invalid usermode ")+(char)*p+" was found.");
+ // Complain when the character is not a-z or A-Z
+ if ((*p < 'A') || (*p > 'z') || ((*p < 'a') && (*p > 'Z')))
+ throw CoreException("Invalid usermode " + std::string(1, *p) + " was found.");
DisabledUModes[*p - 'A'] = 1;
}
memset(DisabledCModes, 0, sizeof(DisabledCModes));
- for (const unsigned char* p = (const unsigned char*)ConfValue("disabled")->getString("chanmodes").c_str(); *p; ++p)
+ modes = ConfValue("disabled")->getString("chanmodes");
+ for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p)
{
- if (*p < 'A' || *p > ('A' + 64)) throw CoreException(std::string("Invalid chanmode ")+(char)*p+" was found.");
+ if ((*p < 'A') || (*p > 'z') || ((*p < 'a') && (*p > 'Z')))
+ throw CoreException("Invalid chanmode " + std::string(1, *p) + " was found.");
DisabledCModes[*p - 'A'] = 1;
}
memset(HideModeLists, 0, sizeof(HideModeLists));
- for (const unsigned char* p = (const unsigned char*)ConfValue("security")->getString("hidemodes").c_str(); *p; ++p)
- HideModeLists[*p] = true;
+ modes = ConfValue("security")->getString("hidemodes");
+ for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p)
+ HideModeLists[(unsigned char) *p] = true;
std::string v = security->getString("announceinvites");
OperSpyWhois = SPYWHOIS_SINGLEMSG;
else
OperSpyWhois = SPYWHOIS_NONE;
-
- Limits.Finalise();
}
// WARNING: it is not safe to use most of the codebase in this function, as it
for (int Index = 0; Index * sizeof(Deprecated) < sizeof(ChangedConfig); Index++)
{
std::string dummy;
- if (ConfValue(ChangedConfig[Index].tag)->readString(ChangedConfig[Index].value, dummy, true))
- errstr << "Your configuration contains a deprecated value: <"
- << ChangedConfig[Index].tag << ":" << ChangedConfig[Index].value << "> - " << ChangedConfig[Index].reason
- << " (at " << ConfValue(ChangedConfig[Index].tag)->getTagLocation() << ")\n";
+ ConfigTagList tags = ConfTags(ChangedConfig[Index].tag);
+ for(ConfigIter i = tags.first; i != tags.second; ++i)
+ {
+ if (i->second->readString(ChangedConfig[Index].value, dummy, true))
+ errstr << "Your configuration contains a deprecated value: <"
+ << ChangedConfig[Index].tag << ":" << ChangedConfig[Index].value << "> - " << ChangedConfig[Index].reason
+ << " (at " << i->second->getTagLocation() << ")\n";
+ }
}
Fill();
continue;
// On startup, print out to console (still attached at this point)
if (!old)
- printf("%s\n", line.c_str());
+ std::cout << line << std::endl;
// If a user is rehashing, tell them directly
if (user)
user->SendText(":%s NOTICE %s :*** %s", ServerInstance->Config->ServerName.c_str(), user->nick.c_str(), line.c_str());
errstr.clear();
errstr.str(std::string());
+ // Re-parse our MOTD and RULES files for colors -- Justasic
+ for (ClassVector::const_iterator it = this->Classes.begin(), it_end = this->Classes.end(); it != it_end; ++it)
+ {
+ ConfigTag *tag = (*it)->config;
+ // Make sure our connection class allows motd colors
+ if(!tag->getBool("allowmotdcolors"))
+ continue;
+
+ ConfigFileCache::iterator file = this->Files.find(tag->getString("motd", "motd"));
+ if (file != this->Files.end())
+ InspIRCd::ProcessColors(file->second);
+
+ file = this->Files.find(tag->getString("rules", "rules"));
+ if (file != this->Files.end())
+ InspIRCd::ProcessColors(file->second);
+ }
+
/* No old configuration -> initial boot, nothing more to do here */
if (!old)
{
return;
}
+
// If there were errors processing configuration, don't touch modules.
if (!valid)
return;
return (p != name ? ++p : p);
}
-std::string ServerConfig::GetSID()
+const std::string& ServerConfig::GetSID()
{
return sid;
}
* thoroughly!!!
*/
ServerInstance->XLines->CheckELines();
- ServerInstance->XLines->CheckELines();
ServerInstance->XLines->ApplyLines();
ServerInstance->Res->Rehash();
ServerInstance->ResetMaxBans();