summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-12-10 16:29:49 -0500
committerAdam <Adam@anope.org>2010-12-12 19:37:04 -0500
commiteb138a02d61f0cd0a51083ea3c682e2a6b5c24fd (patch)
tree5ca0b3257557a05bcae39d7321ab5504dde8217b /modules
parent2a4d0e3e898f1ee2395b5e83198d68a5e646a640 (diff)
Do not validate users during netburst until after the server is done syncing
Diffstat (limited to 'modules')
-rw-r--r--modules/protocol/inspircd-ts6.h2
-rw-r--r--modules/protocol/inspircd12.cpp75
-rw-r--r--modules/protocol/inspircd20.cpp113
-rw-r--r--modules/protocol/plexus.cpp37
4 files changed, 80 insertions, 147 deletions
diff --git a/modules/protocol/inspircd-ts6.h b/modules/protocol/inspircd-ts6.h
index 1859fff08..4146e27fc 100644
--- a/modules/protocol/inspircd-ts6.h
+++ b/modules/protocol/inspircd-ts6.h
@@ -271,6 +271,8 @@ class InspircdIRCdMessage : public IRCdMessage
return true;
}
+ virtual bool OnUID(const Anope::string &source, const std::vector<Anope::string> &params) = 0;
+
bool OnNick(const Anope::string &source, const std::vector<Anope::string> &params)
{
do_nick(source, params[0], "", "", "", "", 0, "", "", "", "");
diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp
index 62df416b1..0561b5e87 100644
--- a/modules/protocol/inspircd12.cpp
+++ b/modules/protocol/inspircd12.cpp
@@ -52,9 +52,6 @@ static bool has_servicesmod = false;
static bool has_svsholdmod = false;
static bool has_hidechansmod = false;
-/* Previously introduced user during burst */
-static User *prev_u_intro = NULL;
-
/* CHGHOST */
void inspircd_cmd_chghost(const Anope::string &nick, const Anope::string &vhost)
{
@@ -250,40 +247,15 @@ bool event_sethost(const Anope::string &source, const std::vector<Anope::string>
bool event_uid(const Anope::string &source, const std::vector<Anope::string> &params)
{
- User *user;
Server *s = Server::Find(source);
time_t ts = convertTo<time_t>(params[1]);
- /* Check if the previously introduced user was Id'd for the nickgroup of the nick he s currently using.
- * If not, validate the user. ~ Viper*/
- user = prev_u_intro;
- prev_u_intro = NULL;
- if (user && !user->server->IsSynced())
- {
- NickAlias *na = findnick(user->nick);
-
- if (!na || na->nc != user->Account())
- {
- validate_user(user);
- if (user->HasMode(UMODE_REGISTERED))
- user->RemoveMode(NickServ, UMODE_REGISTERED);
- }
- else
- /* Set them +r (to negate a possible -r on the stack) */
- user->SetMode(NickServ, UMODE_REGISTERED);
- }
-
Anope::string modes = params[8];
for (unsigned i = 9; i < params.size() - 1; ++i)
modes += " " + params[i];
- user = do_nick("", params[2], params[5], params[3], s->GetName(), params[params.size() - 1], ts, params[6], params[4], params[0], modes);
- if (user)
- {
- if (!user->server->IsSynced())
- prev_u_intro = user;
- else
- validate_user(user);
- }
+ User *user = do_nick("", params[2], params[5], params[3], s->GetName(), params[params.size() - 1], ts, params[6], params[4], params[0], modes);
+ if (user && user->server->IsSynced())
+ validate_user(user);
return true;
}
@@ -316,10 +288,13 @@ bool event_metadata(const Anope::string &source, const std::vector<Anope::string
if (params[1].equals_cs("accountname"))
{
User *u = finduser(params[0]);
+ NickAlias *user_na = u ? findnick(u->nick) : NULL;
NickCore *nc = findcore(params[2]);
if (u && nc)
{
u->Login(nc);
+ if (user_na && user_na->nc == nc)
+ u->SetMode(NickServ, UMODE_REGISTERED);
}
}
@@ -347,28 +322,16 @@ bool event_metadata(const Anope::string &source, const std::vector<Anope::string
bool event_endburst(const Anope::string &source, const std::vector<Anope::string> &params)
{
- User *u = prev_u_intro;
Server *s = Server::Find(source);
if (!s)
throw CoreException("Got ENDBURST without a source");
- /* Check if the previously introduced user was Id'd for the nickgroup of the nick he s currently using.
- * If not, validate the user. ~ Viper*/
- prev_u_intro = NULL;
- if (u && !u->server->IsSynced())
+ for (patricia_tree<User *>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
{
- NickAlias *na = findnick(u->nick);
-
- if (!na || na->nc != u->Account())
- {
+ User *u = *it;
+ if (u->server == s && !u->IsIdentified())
validate_user(u);
- if (u->HasMode(UMODE_REGISTERED))
- u->RemoveMode(NickServ, UMODE_REGISTERED);
- }
- else
- /* Set them +r (to negate a possible -r on the stack) */
- u->SetMode(NickServ, UMODE_REGISTERED);
}
Log(LOG_DEBUG) << "Processed ENDBURST for " << s->GetName();
@@ -380,6 +343,21 @@ bool event_endburst(const Anope::string &source, const std::vector<Anope::string
class Inspircd12IRCdMessage : public InspircdIRCdMessage
{
public:
+ bool OnUID(const Anope::string &source, const std::vector<Anope::string> &params)
+ {
+ Server *s = Server::Find(source);
+ time_t ts = convertTo<time_t>(params[1]);
+
+ Anope::string modes = params[8];
+ for (unsigned i = 9; i < params.size() - 1; ++i)
+ modes += " " + params[i];
+ User *user = do_nick("", params[2], params[5], params[3], s->GetName(), params[params.size() - 1], ts, params[6], params[4], params[0], modes);
+ if (user && user->server->IsSynced())
+ validate_user(user);
+
+ return true;
+ }
+
bool OnCapab(const Anope::string &source, const std::vector<Anope::string> &params)
{
if (params[0].equals_cs("START"))
@@ -726,8 +704,7 @@ bool ChannelModeFlood::IsValid(const Anope::string &value) const
class ProtoInspIRCd : public Module
{
- Message message_endburst,
- message_uid, message_time,
+ Message message_endburst, message_time,
message_rsquit, message_svsmode, message_fhost,
message_chgident, message_fname, message_sethost, message_setident, message_setname, message_fjoin, message_fmode,
message_ftopic, message_opertype, message_idle, message_metadata;
@@ -737,7 +714,7 @@ class ProtoInspIRCd : public Module
public:
ProtoInspIRCd(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator),
- message_endburst("ENDBURST", event_endburst), message_uid("UID", event_uid),
+ message_endburst("ENDBURST", event_endburst),
message_time("TIME", event_time), message_rsquit("RSQUIT", event_rsquit),
message_svsmode("SVSMODE", OnMode), message_fhost("FHOST", event_chghost),
message_chgident("CHGIDENT", event_chgident), message_fname("FNAME", event_chgname),
diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp
index 20e622092..ff6a0688b 100644
--- a/modules/protocol/inspircd20.cpp
+++ b/modules/protocol/inspircd20.cpp
@@ -51,9 +51,6 @@ IRCDVar myIrcd[] = {
static bool has_servicesmod = false;
static bool has_svsholdmod = false;
-/* Previously introduced user during burst */
-static User *prev_u_intro = NULL;
-
/* CHGHOST */
void inspircd_cmd_chghost(const Anope::string &nick, const Anope::string &vhost)
{
@@ -250,60 +247,6 @@ bool event_sethost(const Anope::string &source, const std::vector<Anope::string>
return true;
}
-/*
- * [Nov 03 22:09:58.176252 2009] debug: Received: :964 UID 964AAAAAC 1225746297 w00t2 localhost testnet.user w00t 127.0.0.1 1225746302 +iosw +ACGJKLNOQcdfgjklnoqtx :Robin Burchell <w00t@inspircd.org>
- * 0: uid
- * 1: ts
- * 2: nick
- * 3: host
- * 4: dhost
- * 5: ident
- * 6: ip
- * 7: signon
- * 8+: modes and params -- IMPORTANT, some modes (e.g. +s) may have parameters. So don't assume a fixed position of realname!
- * last: realname
- */
-
-bool event_uid(const Anope::string &source, const std::vector<Anope::string> &params)
-{
- User *user;
- Server *s = Server::Find(source);
- time_t ts = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : 0;
-
- /* Check if the previously introduced user was Id'd for the nickgroup of the nick he s currently using.
- * If not, validate the user. ~ Viper*/
- user = prev_u_intro;
- prev_u_intro = NULL;
- if (user && !user->server->IsSynced())
- {
- NickAlias *na = findnick(user->nick);
-
- if (!na || na->nc != user->Account())
- {
- validate_user(user);
- if (user->HasMode(UMODE_REGISTERED))
- user->RemoveMode(NickServ, UMODE_REGISTERED);
- }
- else
- /* Set them +r (to negate a possible -r on the stack) */
- user->SetMode(NickServ, UMODE_REGISTERED);
- }
-
- Anope::string modes = params[8];
- for (unsigned i = 9; i < params.size() - 1; ++i)
- modes += Anope::string(" ") + params[i];
- user = do_nick("", params[2], params[5], params[3], s->GetName(), params[params.size() - 1], ts, params[6], params[4], params[0], modes);
- if (user)
- {
- if (!user->server->IsSynced())
- prev_u_intro = user;
- else
- validate_user(user);
- }
-
- return true;
-}
-
bool event_chghost(const Anope::string &source, const std::vector<Anope::string> &params)
{
User *u = finduser(source);
@@ -331,10 +274,13 @@ bool event_metadata(const Anope::string &source, const std::vector<Anope::string
else if (params[1].equals_cs("accountname"))
{
User *u = finduser(params[0]);
+ NickAlias *user_na = u ? findnick(u->nick) : NULL;
NickCore *nc = findcore(params[2]);
if (u && nc)
{
u->Login(nc);
+ if (user_na && user_na->nc == nc)
+ u->SetMode(NickServ, UMODE_REGISTERED);
}
}
@@ -362,28 +308,16 @@ bool event_metadata(const Anope::string &source, const std::vector<Anope::string
bool event_endburst(const Anope::string &source, const std::vector<Anope::string> &params)
{
- User *u = prev_u_intro;
Server *s = Server::Find(source);
if (!s)
throw CoreException("Got ENDBURST without a source");
- /* Check if the previously introduced user was Id'd for the nickgroup of the nick he s currently using.
- * If not, validate the user. ~ Viper*/
- prev_u_intro = NULL;
- if (u && !u->server->IsSynced())
+ for (patricia_tree<User *>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
{
- NickAlias *na = findnick(u->nick);
-
- if (!na || na->nc != u->Account())
- {
+ User *u = *it;
+ if (u->server == s && !u->IsIdentified())
validate_user(u);
- if (u->HasMode(UMODE_REGISTERED))
- u->RemoveMode(NickServ, UMODE_REGISTERED);
- }
- else
- /* Set them +r (to negate a possible -r on the stack) */
- u->SetMode(NickServ, UMODE_REGISTERED);
}
Log(LOG_DEBUG) << "Processed ENDBURST for " << s->GetName();
@@ -395,6 +329,34 @@ bool event_endburst(const Anope::string &source, const std::vector<Anope::string
class Inspircd20IRCdMessage : public InspircdIRCdMessage
{
public:
+ /*
+ * [Nov 03 22:09:58.176252 2009] debug: Received: :964 UID 964AAAAAC 1225746297 w00t2 localhost testnet.user w00t 127.0.0.1 1225746302 +iosw +ACGJKLNOQcdfgjklnoqtx :Robin Burchell <w00t@inspircd.org>
+ * 0: uid
+ * 1: ts
+ * 2: nick
+ * 3: host
+ * 4: dhost
+ * 5: ident
+ * 6: ip
+ * 7: signon
+ * 8+: modes and params -- IMPORTANT, some modes (e.g. +s) may have parameters. So don't assume a fixed position of realname!
+ * last: realname
+ */
+ bool OnUID(const Anope::string &source, const std::vector<Anope::string> &params)
+ {
+ Server *s = Server::Find(source);
+ time_t ts = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : 0;
+
+ Anope::string modes = params[8];
+ for (unsigned i = 9; i < params.size() - 1; ++i)
+ modes += Anope::string(" ") + params[i];
+ User *user = do_nick("", params[2], params[5], params[3], s->GetName(), params[params.size() - 1], ts, params[6], params[4], params[0], modes);
+ if (user && user->server->IsSynced())
+ validate_user(user);
+
+ return true;
+ }
+
bool OnCapab(const Anope::string &source, const std::vector<Anope::string> &params)
{
if (params[0].equals_cs("START"))
@@ -701,6 +663,8 @@ class Inspircd20IRCdMessage : public InspircdIRCdMessage
}
IRCdMessage::OnCapab(source, params);
+
+ return true;
}
};
@@ -715,8 +679,7 @@ bool ChannelModeFlood::IsValid(const Anope::string &value) const
class ProtoInspIRCd : public Module
{
- Message message_endburst,
- message_uid, message_time,
+ Message message_endburst, message_time,
message_rsquit, message_svsmode, message_fhost,
message_chgident, message_fname, message_sethost, message_setident, message_setname, message_fjoin, message_fmode,
message_ftopic, message_opertype, message_idle, message_metadata;
@@ -725,7 +688,7 @@ class ProtoInspIRCd : public Module
Inspircd20IRCdMessage ircd_message;
public:
ProtoInspIRCd(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator),
- message_endburst("ENDBURST", event_endburst), message_uid("UID", event_uid),
+ message_endburst("ENDBURST", event_endburst),
message_time("TIME", event_time), message_rsquit("RSQUIT", event_rsquit),
message_svsmode("SVSMODE", OnMode), message_fhost("FHOST", event_chghost),
message_chgident("FIDENT", event_chgident), message_fname("FNAME", event_chgname),
diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp
index 6bceadf64..9b12627eb 100644
--- a/modules/protocol/plexus.cpp
+++ b/modules/protocol/plexus.cpp
@@ -248,18 +248,6 @@ class PlexusProto : public IRCDProto
{
send_cmd(bi->GetUID(), "ENCAP * TOPIC %s %s %lu :%s", c->name.c_str(), c->topic_setter.c_str(), static_cast<unsigned long>(c->topic_time + 1), c->topic.c_str());
}
-
- void SetAutoIdentificationToken(User *u)
- {
-
- if (!u->Account())
- return;
-
- Anope::string svidbuf = stringify(u->timestamp);
-
- u->Account()->Shrink("authenticationtoken");
- u->Account()->Extend("authenticationtoken", new ExtensibleItemRegular<Anope::string>(svidbuf));
- }
};
class PlexusIRCdMessage : public IRCdMessage
@@ -302,17 +290,8 @@ class PlexusIRCdMessage : public IRCdMessage
{
/* Source is always the server */
User *user = do_nick("", params[0], params[4], params[9], source, params[10], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, params[6], params[5], params[7], params[3]);
- if (user)
- {
- NickAlias *na = findnick(user->nick);
- Anope::string svidbuf;
- if (na && na->nc->GetExtRegular("authenticationtoken", svidbuf) && svidbuf == params[8])
- {
- user->Login(na->nc);
- }
- else
- validate_user(user);
- }
+ if (user && user->server->IsSynced())
+ validate_user(user);
return true;
}
@@ -571,10 +550,13 @@ bool event_encap(const Anope::string &source, const std::vector<Anope::string> &
if (params[1].equals_cs("SU"))
{
User *u = finduser(params[2]);
+ NickAlias *user_na = findnick(params[2]);
NickCore *nc = findcore(params[3]);
if (u && nc)
{
u->Login(nc);
+ if (user_na && user_na->nc == nc)
+ u->SetMode(NickServ, UMODE_REGISTERED);
}
}
/*
@@ -600,7 +582,16 @@ bool event_eob(const Anope::string &source, const std::vector<Anope::string> &pa
{
Server *s = Server::Find(source);
if (s)
+ {
s->Sync(true);
+ for (patricia_tree<User *>::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
+ {
+ User *u = *it;
+ if (u->server == s && !u->IsIdentified())
+ validate_user(u);
+ }
+ }
+
return true;
}