summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-08-19 16:27:38 -0400
committerAdam <Adam@anope.org>2010-08-19 16:27:38 -0400
commit931b0777fbd961a4ca961ddfa763af92dcce946c (patch)
treeb49fd2d5ee2d2299e933a3561be6e81ffcb3664e
parentb180d5f975b3fd9a096a712adf9589c360831f72 (diff)
Changed the svid system back to using user timestamps for IRCds limited to just usermode +d. This allows us to keep people logged in once again when Anope is restarted.
-rw-r--r--include/users.h11
-rw-r--r--modules/protocol/bahamut.cpp26
-rw-r--r--modules/protocol/inspircd11.cpp16
-rw-r--r--modules/protocol/inspircd12.cpp11
-rw-r--r--modules/protocol/inspircd20.cpp11
-rw-r--r--modules/protocol/ratbox.cpp14
-rw-r--r--modules/protocol/unreal32.cpp42
-rw-r--r--src/users.cpp50
8 files changed, 69 insertions, 112 deletions
diff --git a/include/users.h b/include/users.h
index 636b3ce6d..78d83c062 100644
--- a/include/users.h
+++ b/include/users.h
@@ -155,17 +155,6 @@ class CoreExport User : public Extensible
*/
void Collide(NickAlias *na);
- /** Check if the user should become identified because
- * their svid matches the one stored in their nickcore
- * @param svid Services id
- */
- void CheckAuthenticationToken(const Anope::string &svid);
-
- /** Auto identify the user to the given accountname.
- * @param account Display nick of account
- */
- void AutoID(const Anope::string &account);
-
/** Login the user to a NickCore
* @param core The account the user is useing
*/
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index 32579f50d..572b91367 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -279,16 +279,10 @@ class BahamutIRCdProto : public IRCDProto
if (!u->Account())
return;
- srand(time(NULL));
- Anope::string svidbuf = stringify(rand());
-
- u->Account()->Shrink("authenticationtoken");
- u->Account()->Extend("authenticationtoken", new ExtensibleItemRegular<Anope::string>(svidbuf));
-
- BotInfo *bi = NickServ;
- u->SetMode(bi, UMODE_REGISTERED);
- ircdproto->SendMode(bi, u, "+d %s", svidbuf.c_str());
+ u->SetMode(NickServ, UMODE_REGISTERED);
+ ircdproto->SendMode(NickServ, u, "+d %d", u->timestamp);
}
+
} ircd_proto;
/* EVENT: SJOIN */
@@ -476,12 +470,16 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av)
user = do_nick(source, av[0], av[4], av[5], av[6], av[9], Anope::string(av[2]).is_number_only() ? convertTo<time_t>(av[2]) : 0, Anope::string(av[8]).is_number_only() ? convertTo<uint32>(av[8]) : 0, "", "");
if (user)
{
- /* Check to see if the user should be identified because their
- * services id matches the one in their nickcore
- */
- user->CheckAuthenticationToken(av[7]);
-
UserSetInternalModes(user, 1, &av[3]);
+
+ NickAlias *na;
+ if (user->timestamp == convertTo<time_t>(av[7]) && (na = findnick(user->nick)))
+ {
+ user->Login(na->nc);
+ user->SetMode(NickServ, CMODE_REGISTERED);
+ }
+ else
+ validate_user(user);
}
}
else
diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp
index 31ea2ae19..c06b74501 100644
--- a/modules/protocol/inspircd11.cpp
+++ b/modules/protocol/inspircd11.cpp
@@ -277,7 +277,6 @@ class InspIRCdProto : public IRCDProto
void SetAutoIdentificationToken(User *u)
{
-
if (!u->Account())
return;
@@ -288,6 +287,7 @@ class InspIRCdProto : public IRCDProto
u->SetMode(NickServ, UMODE_REGISTERED);
}
+
} ircd_proto;
int anope_event_ftopic(const Anope::string &source, int ac, const char **av)
@@ -734,13 +734,19 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av)
if (user)
{
user->hostip = av[6];
- /* InspIRCd1.1 has no user mode +d so we
- * use nick timestamp to check for auth - Adam
- */
- user->CheckAuthenticationToken(av[0]);
UserSetInternalModes(user, 1, &av[5]);
user->SetCloakedHost(av[3]);
+
+ NickAlias *na = findnick(user->nick);
+ Anope::string svidbuf;
+ if (na && na->nc->GetExtRegular("authenticationtoken", svidbuf) && svidbuf == av[0])
+ {
+ user->Login(na->nc);
+ user->SetMode(NickServ, UMODE_REGISTERED);
+ }
+ else
+ validate_user(user);
}
}
}
diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp
index 4a4ef9a00..a78ead0a8 100644
--- a/modules/protocol/inspircd12.cpp
+++ b/modules/protocol/inspircd12.cpp
@@ -855,15 +855,16 @@ int anope_event_whois(const Anope::string &source, int ac, const char **av)
int anope_event_metadata(const Anope::string &source, int ac, const char **av)
{
- User *u;
-
if (ac < 3)
return MOD_CONT;
else if (!strcmp(av[1], "accountname"))
{
- if ((u = finduser(av[0])))
- /* Identify the user for this account - Adam */
- u->AutoID(av[2]);
+ User *u = finduser(av[0]);
+ NickCore *nc = findcore(av[2]);
+ if (u && nc)
+ {
+ u->Login(nc);
+ }
}
return MOD_CONT;
diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp
index 0a1a9eee6..c55bc7020 100644
--- a/modules/protocol/inspircd20.cpp
+++ b/modules/protocol/inspircd20.cpp
@@ -852,15 +852,16 @@ int anope_event_whois(const Anope::string &source, int ac, const char **av)
int anope_event_metadata(const Anope::string &source, int ac, const char **av)
{
- User *u;
-
if (ac < 3)
return MOD_CONT;
else if (!strcmp(av[1], "accountname"))
{
- if ((u = finduser(av[0])))
- /* Identify the user for this account - Adam */
- u->AutoID(av[2]);
+ User *u = finduser(av[0]);
+ NickCore *nc = findcore(av[2]);
+ if (u && nc)
+ {
+ u->Login(nc);
+ }
}
return MOD_CONT;
diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp
index 59abc7bc8..8db46a3d5 100644
--- a/modules/protocol/ratbox.cpp
+++ b/modules/protocol/ratbox.cpp
@@ -437,12 +437,16 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av)
user = do_nick("", av[0], av[4], av[5], s->GetName(), av[8], Anope::string(av[2]).is_number_only() ? convertTo<time_t>(av[2]) : 0, 0, "*", av[7]);
if (user)
{
- /* No usermode +d on ratbox so we use
- * nick timestamp to check for auth - Adam
- */
- user->CheckAuthenticationToken(av[2]);
-
UserSetInternalModes(user, 1, &av[3]);
+
+ NickAlias *na = findnick(user->nick);
+ Anope::string svidbuf;
+ if (na && na->nc->GetExtRegular("authenticationtoken", svidbuf) && svidbuf == av[2])
+ {
+ user->Login(na->nc);
+ }
+ else
+ validate_user(user);
}
}
else if (ac == 2)
diff --git a/modules/protocol/unreal32.cpp b/modules/protocol/unreal32.cpp
index ed840aa3e..1e18e92f9 100644
--- a/modules/protocol/unreal32.cpp
+++ b/modules/protocol/unreal32.cpp
@@ -384,19 +384,11 @@ class UnrealIRCdProto : public IRCDProto
void SetAutoIdentificationToken(User *u)
{
-
if (!u->Account())
return;
- srand(time(NULL));
- Anope::string svidbuf = stringify(rand());
-
- u->Account()->Shrink("authenticationtoken");
- u->Account()->Extend("authenticationtoken", new ExtensibleItemRegular<Anope::string>(svidbuf));
-
- BotInfo *bi = NickServ;
- u->SetMode(bi, UMODE_REGISTERED);
- ircdproto->SendMode(bi, u, "+d %s", svidbuf.c_str());
+ u->SetMode(NickServ, UMODE_REGISTERED);
+ ircdproto->SendMode(NickServ, u, "+d %d", u->timestamp);
}
void SendUnregisteredNick(const User *u)
@@ -874,12 +866,17 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av)
user = do_nick(source, av[0], av[3], av[4], av[5], av[10], Anope::string(av[2]).is_number_only() ? convertTo<time_t>(av[2]) : 0, ntohl(decode_ip(av[9])), av[8], "");
if (user)
{
- /* Check to see if the user should be identified because their
- * services id matches the one in their nickcore
- */
- user->CheckAuthenticationToken(av[6]);
-
UserSetInternalModes(user, 1, &av[7]);
+
+ NickAlias *na = findnick(user->nick);
+
+ if (na && user->timestamp == convertTo<time_t>(av[6]))
+ {
+ user->Login(na->nc);
+ user->SetMode(NickServ, UMODE_REGISTERED);
+ }
+ else
+ validate_user(user);
}
}
else
@@ -888,12 +885,17 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av)
user = do_nick(source, av[0], av[3], av[4], av[5], av[9], Anope::string(av[2]).is_number_only() ? convertTo<time_t>(av[2]) : 0, 0, av[8], "");
if (user)
{
- /* Check to see if the user should be identified because their
- * services id matches the one in their nickcore
- */
- user->CheckAuthenticationToken(av[6]);
-
UserSetInternalModes(user, 1, &av[7]);
+
+ NickAlias *na = findnick(user->nick);
+
+ if (na && user->timestamp == convertTo<time_t>(av[6]))
+ {
+ user->Login(na->nc);
+ user->SetMode(NickServ, UMODE_REGISTERED);
+ }
+ else
+ validate_user(user);
}
}
}
diff --git a/src/users.cpp b/src/users.cpp
index 75596124c..91ba45d0c 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -327,53 +327,6 @@ void User::Collide(NickAlias *na)
kill_user(Config->s_NickServ, this->nick, "Services nickname-enforcer kill");
}
-/** Check if the user should become identified because
- * their svid matches the one stored in their nickcore
- * @param svid Services id
- */
-void User::CheckAuthenticationToken(const Anope::string &svid)
-{
- NickAlias *na;
-
- if ((na = findnick(this->nick)))
- {
- Anope::string c;
- if (na->nc && na->nc->GetExtRegular("authenticationtoken", c))
- {
- if (!svid.empty() && !c.empty() && svid.equals_cs(c))
- /* Users authentication token matches so they should become identified */
- this->Login(na->nc);
- }
- }
-
- validate_user(this);
-}
-
-/** Auto identify the user to the given accountname.
- * @param account Display nick of account
- */
-void User::AutoID(const Anope::string &account)
-{
- NickCore *core = findcore(account);
-
- if (core)
- {
- this->Login(core);
-
- NickAlias *na = findnick(this->nick);
- if (na && na->nc == core)
- {
- na->last_realname = this->realname;
- na->last_seen = time(NULL);
- this->SetMode(NickServ, UMODE_REGISTERED);
- this->UpdateHost();
- check_memos(this);
-
- FOREACH_MOD(I_OnNickIdentify, OnNickIdentify(this));
- }
- }
-}
-
/** Login the user to a NickCore
* @param core The account the user is useing
*/
@@ -382,6 +335,9 @@ void User::Login(NickCore *core)
this->Logout();
this->nc = core;
core->Users.push_back(this);
+
+ this->UpdateHost();
+ check_memos(this);
}
/** Logout the user