summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/modules.h10
-rw-r--r--include/users.h15
-rw-r--r--src/configreader.cpp3
-rw-r--r--src/modules.cpp1
-rw-r--r--src/stats.cpp5
-rw-r--r--src/users.cpp44
6 files changed, 30 insertions, 48 deletions
diff --git a/include/modules.h b/include/modules.h
index bb9a55dbf..25c57cb61 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -97,7 +97,7 @@ struct ModResult {
/** If you change the module API in any way, increment this value.
* This MUST be a pure integer, with no parenthesis
*/
-#define API_VERSION 137
+#define API_VERSION 138
/**
* This #define allows us to call a method in all
@@ -325,7 +325,7 @@ enum Implementation
I_OnPostTopicChange, I_OnEvent, I_OnGlobalOper, I_OnPostConnect, I_OnAddBan,
I_OnDelBan, I_OnChangeLocalUserGECOS, I_OnUserRegister, I_OnChannelPreDelete, I_OnChannelDelete,
I_OnPostOper, I_OnSyncNetwork, I_OnSetAway, I_OnUserList, I_OnPostCommand, I_OnPostJoin,
- I_OnWhoisLine, I_OnBuildNeighborList, I_OnGarbageCollect,
+ I_OnWhoisLine, I_OnBuildNeighborList, I_OnGarbageCollect, I_OnSetConnectClass,
I_OnText, I_OnPassCompare, I_OnRunTestSuite, I_OnNamesListItem, I_OnNumeric, I_OnHookIO,
I_OnPreRehash, I_OnModuleRehash, I_OnSendWhoLine, I_OnChangeIdent, I_OnChannelRestrictionApply,
I_END
@@ -1255,6 +1255,12 @@ class CoreExport Module : public classbase, public usecountbase
*/
virtual void OnGarbageCollect();
+ /** Called when a user's connect class is being matched
+ * @return MOD_RES_ALLOW to force the class to match, MOD_RES_DENY to forbid it, or
+ * MOD_RES_PASSTHRU to allow normal matching (by host/port).
+ */
+ virtual ModResult OnSetConnectClass(LocalUser* user, ConnectClass* myclass);
+
/** Add test suite hooks here. These are used for testing functionality of a module
* via the --testsuite debugging parameter.
*/
diff --git a/include/users.h b/include/users.h
index 5c3fd9a43..6b891d7da 100644
--- a/include/users.h
+++ b/include/users.h
@@ -92,14 +92,6 @@ struct CoreExport ConnectClass : public refcountbase
*/
unsigned int pingtime;
- /** (Optional) Password for this line
- */
- std::string pass;
-
- /** (Optional) Hash Method for this line
- */
- std::string hash;
-
/** Maximum size of sendq for users in this class (bytes)
* Users cannot send commands if they go over this limit
*/
@@ -133,10 +125,6 @@ struct CoreExport ConnectClass : public refcountbase
*/
unsigned int maxchans;
- /** Port number this connect class applies to
- */
- int port;
-
/** How many users may be in this connect class before they are refused?
* (0 = no limit = default)
*/
@@ -152,11 +140,8 @@ struct CoreExport ConnectClass : public refcountbase
/** Update the settings in this block to match the given block */
void Update(const ConnectClass* newSettings);
-
const std::string& GetName() { return name; }
- const std::string& GetPass() { return pass; }
const std::string& GetHost() { return host; }
- const int GetPort() { return port; }
/** Returns the registration timeout
*/
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 183e78a12..b34c3ecca 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -361,8 +361,6 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
me->name = name;
- tag->readString("password", me->pass);
- tag->readString("hash", me->hash);
me->registration_timeout = tag->getInt("timeout", me->registration_timeout);
me->pingtime = tag->getInt("pingfreq", me->pingtime);
std::string sendq;
@@ -384,7 +382,6 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
me->fakelag = tag->getBool("fakelag", me->fakelag);
me->maxlocal = tag->getInt("localmax", me->maxlocal);
me->maxglobal = tag->getInt("globalmax", me->maxglobal);
- me->port = tag->getInt("port", me->port);
me->maxchans = tag->getInt("maxchans", me->maxchans);
me->limit = tag->getInt("limit", me->limit);
diff --git a/src/modules.cpp b/src/modules.cpp
index 9186e38be..558923332 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -155,6 +155,7 @@ ModResult Module::OnUserList(User*, Channel*) { return MOD_RES_PASSTHRU; }
ModResult Module::OnWhoisLine(User*, User*, int&, std::string&) { return MOD_RES_PASSTHRU; }
void Module::OnBuildNeighborList(User*, UserChanList&, std::map<User*,bool>&) { }
void Module::OnGarbageCollect() { }
+ModResult Module::OnSetConnectClass(LocalUser* user, ConnectClass* myclass) { return MOD_RES_PASSTHRU; }
void Module::OnText(User*, void*, int, const std::string&, char, CUList&) { }
void Module::OnRunTestSuite() { }
void Module::OnNamesListItem(User*, Membership*, std::string&, std::string&) { }
diff --git a/src/stats.cpp b/src/stats.cpp
index df41d26da..fb4e5e7a5 100644
--- a/src/stats.cpp
+++ b/src/stats.cpp
@@ -80,10 +80,7 @@ void InspIRCd::DoStats(char statschar, User* user, string_list &results)
else
res << c->host;
- if (c->port)
- res << ' ' << c->port << ' ';
- else
- res << " * ";
+ res << ' ' << c->config->getString("port", "*") << ' ';
res << c->GetRecvqMax() << ' ' << c->GetSendqSoftMax() << ' ' << c->GetSendqHardMax()
<< ' ' << c->GetCommandRate() << ' ' << c->GetPenaltyThreshold();
diff --git a/src/users.cpp b/src/users.cpp
index 2cc26c158..1392af075 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -806,9 +806,9 @@ void LocalUser::FullConnect()
/* Check the password, if one is required by the user's connect class.
* This CANNOT be in CheckClass(), because that is called prior to PASS as well!
*/
- if (!MyClass->pass.empty())
+ if (!MyClass->config->getString("pass").empty())
{
- if (ServerInstance->PassCompare(this, MyClass->pass.c_str(), password.c_str(), MyClass->hash.c_str()))
+ if (ServerInstance->PassCompare(this, MyClass->config->getString("pass"), password, MyClass->config->getString("hash")))
{
ServerInstance->Users->QuitUser(this, "Invalid password");
return;
@@ -1603,18 +1603,19 @@ void LocalUser::SetClass(const std::string &explicit_name)
{
ConnectClass* c = *i;
- if (c->type == CC_ALLOW)
- {
- ServerInstance->Logs->Log("CONNECTCLASS", DEBUG, "ALLOW %s %d %s", c->host.c_str(), c->GetPort(), c->GetName().c_str());
- }
- else if (c->type == CC_DENY)
+ ModResult MOD_RESULT;
+ FIRST_MOD_RESULT(OnSetConnectClass, MOD_RESULT, (this,c));
+ if (MOD_RESULT == MOD_RES_DENY)
+ continue;
+ if (MOD_RESULT == MOD_RES_ALLOW)
{
- ServerInstance->Logs->Log("CONNECTCLASS", DEBUG, "DENY %s %d %s", c->GetHost().c_str(), c->GetPort(), c->GetName().c_str());
+ ServerInstance->Logs->Log("CONNECTCLASS", DEBUG, "Class forced by module to %s", c->GetName().c_str());
+ found = c;
+ break;
}
- else
- {
+
+ if (c->type == CC_NAMED)
continue;
- }
/* check if host matches.. */
if (c->GetHost().length() && !InspIRCd::MatchCIDR(this->GetIPString(), c->GetHost(), NULL) &&
@@ -1635,16 +1636,14 @@ void LocalUser::SetClass(const std::string &explicit_name)
}
/* if it requires a port ... */
- if (c->GetPort())
+ int port = c->config->getInt("port");
+ if (port)
{
- ServerInstance->Logs->Log("CONNECTCLASS", DEBUG, "Requires port (%d)", c->GetPort());
+ ServerInstance->Logs->Log("CONNECTCLASS", DEBUG, "Requires port (%d)", port);
/* and our port doesn't match, fail. */
- if (this->GetServerPort() != c->GetPort())
- {
- ServerInstance->Logs->Log("CONNECTCLASS", DEBUG, "Port match failed (%d)", this->GetServerPort());
+ if (this->GetServerPort() != port)
continue;
- }
}
/* we stop at the first class that meets ALL critera. */
@@ -1705,19 +1704,18 @@ const std::string& FakeUser::GetFullRealHost()
ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask)
: config(tag), type(t), fakelag(true), name("unnamed"), registration_timeout(0), host(mask),
- pingtime(0), pass(""), hash(""), softsendqmax(0), hardsendqmax(0), recvqmax(0),
- penaltythreshold(0), commandrate(0), maxlocal(0), maxglobal(0), maxchans(0), port(0), limit(0)
+ pingtime(0), softsendqmax(0), hardsendqmax(0), recvqmax(0),
+ penaltythreshold(0), commandrate(0), maxlocal(0), maxglobal(0), maxchans(0), limit(0)
{
}
ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask, const ConnectClass& parent)
: config(tag), type(t), fakelag(parent.fakelag), name("unnamed"),
registration_timeout(parent.registration_timeout), host(mask), pingtime(parent.pingtime),
- pass(parent.pass), hash(parent.hash), softsendqmax(parent.softsendqmax),
- hardsendqmax(parent.hardsendqmax), recvqmax(parent.recvqmax),
+ softsendqmax(parent.softsendqmax), hardsendqmax(parent.hardsendqmax), recvqmax(parent.recvqmax),
penaltythreshold(parent.penaltythreshold), commandrate(parent.commandrate),
maxlocal(parent.maxlocal), maxglobal(parent.maxglobal), maxchans(parent.maxchans),
- port(parent.port), limit(parent.limit)
+ limit(parent.limit)
{
}
@@ -1727,8 +1725,6 @@ void ConnectClass::Update(const ConnectClass* src)
registration_timeout = src->registration_timeout;
host = src->host;
pingtime = src->pingtime;
- pass = src->pass;
- hash = src->hash;
softsendqmax = src->softsendqmax;
hardsendqmax = src->hardsendqmax;
recvqmax = src->recvqmax;