summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/users.h6
-rw-r--r--src/configreader.cpp4
-rw-r--r--src/modules/m_conn_umodes.cpp61
-rw-r--r--src/modules/m_ident.cpp23
-rw-r--r--src/users.cpp8
5 files changed, 35 insertions, 67 deletions
diff --git a/include/users.h b/include/users.h
index a898d5813..fbeba1bb9 100644
--- a/include/users.h
+++ b/include/users.h
@@ -59,11 +59,13 @@ enum RegistrationState {
/* Required forward declaration */
class Channel;
class UserResolver;
+class ConfigTag;
/** Holds information relevent to <connect allow> and <connect deny> tags in the config file.
*/
struct CoreExport ConnectClass : public refcountbase
{
+ reference<ConfigTag> config;
/** Type of line, either CC_ALLOW or CC_DENY
*/
char type;
@@ -129,10 +131,10 @@ struct CoreExport ConnectClass : public refcountbase
/** Create a new connect class with no settings.
*/
- ConnectClass(char type, const std::string& mask);
+ ConnectClass(ConfigTag* tag, char type, const std::string& mask);
/** Create a new connect class with inherited settings.
*/
- ConnectClass(char type, const std::string& mask, const ConnectClass& parent);
+ ConnectClass(ConfigTag* tag, char type, const std::string& mask, const ConnectClass& parent);
/** Update the settings in this block to match the given block */
void Update(const ConnectClass* newSettings);
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 6157b4d4b..10fea3eff 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -389,8 +389,8 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
throw CoreException("Two connect classes cannot have the same mask (" + mask + ")");
ConnectClass* me = parent ?
- new ConnectClass(type, mask, *parent) :
- new ConnectClass(type, mask);
+ new ConnectClass(tag, type, mask, *parent) :
+ new ConnectClass(tag, type, mask);
if (!name.empty())
me->name = name;
diff --git a/src/modules/m_conn_umodes.cpp b/src/modules/m_conn_umodes.cpp
index 2ad8ab876..0fcd73fe9 100644
--- a/src/modules/m_conn_umodes.cpp
+++ b/src/modules/m_conn_umodes.cpp
@@ -17,14 +17,8 @@
class ModuleModesOnConnect : public Module
{
- private:
-
- ConfigReader *Conf;
-
public:
ModuleModesOnConnect() {
-
- Conf = new ConfigReader;
Implementation eventlist[] = { I_OnUserConnect, I_OnRehash };
ServerInstance->Modules->Attach(eventlist, this, 2);
// for things like +x on connect, important, otherwise we have to resort to config order (bleh) -- w00t
@@ -32,15 +26,8 @@ class ModuleModesOnConnect : public Module
}
- virtual void OnRehash(User* user)
- {
- delete Conf;
- Conf = new ConfigReader;
- }
-
virtual ~ModuleModesOnConnect()
{
- delete Conf;
}
virtual Version GetVersion()
@@ -59,41 +46,33 @@ class ModuleModesOnConnect : public Module
sizeof(ServerInstance->Config->DisabledUModes));
memset(ServerInstance->Config->DisabledUModes, 0, 64);
- for (int j = 0; j < Conf->Enumerate("connect"); j++)
+ ConfigTag* tag = user->MyClass->config;
+ std::string ThisModes = tag->getString("modes");
+ if (!ThisModes.empty())
{
- std::string hostn = Conf->ReadValue("connect","allow",j);
- /* XXX: Fixme: does not respect port, limit, etc */
- if ((InspIRCd::MatchCIDR(user->GetIPString(),hostn, ascii_case_insensitive_map)) || (InspIRCd::Match(user->host,hostn, ascii_case_insensitive_map)))
- {
- std::string ThisModes = Conf->ReadValue("connect","modes",j);
- if (!ThisModes.empty())
- {
- std::string buf;
- std::stringstream ss(ThisModes);
-
- std::vector<std::string> tokens;
+ std::string buf;
+ std::stringstream ss(ThisModes);
- // split ThisUserModes into modes and mode params
- while (ss >> buf)
- tokens.push_back(buf);
+ std::vector<std::string> tokens;
- std::vector<std::string> modes;
- modes.push_back(user->nick);
- modes.push_back(tokens[0]);
+ // split ThisUserModes into modes and mode params
+ while (ss >> buf)
+ tokens.push_back(buf);
- if (tokens.size() > 1)
- {
- // process mode params
- for (unsigned int k = 1; k < tokens.size(); k++)
- {
- modes.push_back(tokens[k]);
- }
- }
+ std::vector<std::string> modes;
+ modes.push_back(user->nick);
+ modes.push_back(tokens[0]);
- ServerInstance->Parser->CallHandler("MODE", modes, user);
+ if (tokens.size() > 1)
+ {
+ // process mode params
+ for (unsigned int k = 1; k < tokens.size(); k++)
+ {
+ modes.push_back(tokens[k]);
}
- break;
}
+
+ ServerInstance->Parser->CallHandler("MODE", modes, user);
}
memcpy(ServerInstance->Config->DisabledUModes, save, 64);
diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp
index 0ba9e6e3a..56fa47db8 100644
--- a/src/modules/m_ident.cpp
+++ b/src/modules/m_ident.cpp
@@ -276,12 +276,10 @@ class IdentRequestSocket : public EventHandler
class ModuleIdent : public Module
{
int RequestTimeout;
- ConfigReader *Conf;
SimpleExtItem<IdentRequestSocket> ext;
public:
ModuleIdent() : ext("ident_socket", this)
{
- Conf = new ConfigReader;
OnRehash(NULL);
Implementation eventlist[] = { I_OnRehash, I_OnUserRegister, I_OnCheckReady, I_OnUserDisconnect };
ServerInstance->Modules->Attach(eventlist, this, 4);
@@ -289,7 +287,6 @@ class ModuleIdent : public Module
~ModuleIdent()
{
- delete Conf;
}
virtual Version GetVersion()
@@ -299,28 +296,18 @@ class ModuleIdent : public Module
virtual void OnRehash(User *user)
{
- delete Conf;
- Conf = new ConfigReader;
+ ConfigReader Conf;
- RequestTimeout = Conf->ReadInteger("ident", "timeout", 0, true);
+ RequestTimeout = Conf.ReadInteger("ident", "timeout", 0, true);
if (!RequestTimeout)
RequestTimeout = 5;
}
virtual ModResult OnUserRegister(User *user)
{
- for (int j = 0; j < Conf->Enumerate("connect"); j++)
- {
- std::string hostn = Conf->ReadValue("connect","allow",j);
- /* XXX: Fixme: does not respect port, limit, etc */
- if ((InspIRCd::MatchCIDR(user->GetIPString(),hostn, ascii_case_insensitive_map)) || (InspIRCd::Match(user->host,hostn, ascii_case_insensitive_map)))
- {
- bool useident = Conf->ReadFlag("connect", "useident", "yes", j);
-
- if (!useident)
- return MOD_RES_PASSTHRU;
- }
- }
+ ConfigTag* tag = user->MyClass->config;
+ if (!tag->getBool("useident", true))
+ return MOD_RES_PASSTHRU;
/* User::ident is currently the username field from USER; with m_ident loaded, that
* should be preceded by a ~. The field is actually IdentMax+2 characters wide. */
diff --git a/src/users.cpp b/src/users.cpp
index 4b6686977..324edbfdb 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1801,15 +1801,15 @@ const std::string FakeUser::GetFullRealHost()
return nick;
}
-ConnectClass::ConnectClass(char t, const std::string& mask)
- : type(t), name("unnamed"), registration_timeout(0), host(mask),
+ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask)
+ : config(tag), type(t), name("unnamed"), registration_timeout(0), host(mask),
pingtime(0), pass(""), hash(""), softsendqmax(0), hardsendqmax(0),
recvqmax(0), maxlocal(0), maxglobal(0), maxchans(0), port(0), limit(0)
{
}
-ConnectClass::ConnectClass(char t, const std::string& mask, const ConnectClass& parent)
- : type(t), name("unnamed"),
+ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask, const ConnectClass& parent)
+ : config(tag), type(t), name("unnamed"),
registration_timeout(parent.registration_timeout), host(mask),
pingtime(parent.pingtime), pass(parent.pass), hash(parent.hash),
softsendqmax(parent.softsendqmax), hardsendqmax(parent.hardsendqmax),