mirror of
https://github.com/anope/anope.git
synced 2026-07-05 16:43:12 +02:00
Move users to a basic class.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1187 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
@@ -945,6 +945,7 @@ E void expire_requests(void);
|
||||
EI int ns_do_register(User * u);
|
||||
E int delnick(NickAlias * na);
|
||||
E NickAlias *findnick(const char *nick);
|
||||
E NickAlias *findnick(const std::string &nick);
|
||||
E NickCore *findcore(const char *nick);
|
||||
E void clean_ns_timeouts(NickAlias * na);
|
||||
E void nsStartNickTracking(User * u);
|
||||
|
||||
+8
-48
@@ -212,10 +212,16 @@ extern int shutdown(int, int);
|
||||
#include "slist.h"
|
||||
#include "events.h"
|
||||
|
||||
/* pull in the various bits of STL to pull in */
|
||||
#include <string>
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* forward declarations, mostly used by older code */
|
||||
class User;
|
||||
|
||||
|
||||
typedef struct server_ Server;
|
||||
typedef struct user_ User;
|
||||
typedef struct channel_ Channel;
|
||||
typedef struct c_elist EList;
|
||||
typedef struct c_elist_entry Entry;
|
||||
@@ -833,54 +839,8 @@ struct server_ {
|
||||
#define SERVER_JUPED 0x0002
|
||||
|
||||
/*************************************************************************/
|
||||
struct u_chanlist {
|
||||
struct u_chanlist *next, *prev;
|
||||
Channel *chan;
|
||||
int16 status; /* Associated flags; see CSTATUS_* below. */
|
||||
};
|
||||
|
||||
struct u_chaninfolist {
|
||||
struct u_chaninfolist *next, *prev;
|
||||
ChannelInfo *chan;
|
||||
};
|
||||
|
||||
/* Online user and channel data. */
|
||||
struct user_ {
|
||||
User *next, *prev;
|
||||
|
||||
char nick[NICKMAX];
|
||||
|
||||
char *username; /* ident */
|
||||
char *host; /* User's real hostname */
|
||||
char *hostip; /* User's IP number */
|
||||
char *vhost; /* User's virtual hostname */
|
||||
char *vident; /* User's virtual ident */
|
||||
char *realname; /* Realname */
|
||||
Server *server; /* Server user is connected to */
|
||||
char *nickTrack; /* Nick Tracking */
|
||||
time_t timestamp; /* Timestamp of the nick */
|
||||
time_t my_signon; /* When did _we_ see the user? */
|
||||
uint32 svid; /* Services ID */
|
||||
uint32 mode; /* See below */
|
||||
char *uid; /* Univeral ID */
|
||||
|
||||
NickAlias *na;
|
||||
|
||||
ModuleData *moduleData; /* defined for it, it should allow the module Add/Get */
|
||||
|
||||
int isSuperAdmin; /* is SuperAdmin on or off? */
|
||||
|
||||
struct u_chanlist *chans; /* Channels user has joined */
|
||||
struct u_chaninfolist *founder_chans; /* Channels user has identified for */
|
||||
|
||||
short invalid_pw_count; /* # of invalid password attempts */
|
||||
time_t invalid_pw_time; /* Time of last invalid password */
|
||||
|
||||
time_t lastmemosend; /* Last time MS SEND command used */
|
||||
time_t lastnickreg; /* Last time NS REGISTER cmd used */
|
||||
time_t lastmail; /* Last time this user sent a mail */
|
||||
};
|
||||
|
||||
#include "users.h"
|
||||
|
||||
|
||||
struct cbmode_ {
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Robin Burchell <w00t@inspircd.org>
|
||||
* Copyright (C) 2008 Anope Team <info@anope.org>
|
||||
*
|
||||
* Please read COPYING and README for further details.
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
struct u_chanlist {
|
||||
struct u_chanlist *next, *prev;
|
||||
Channel *chan;
|
||||
int16 status; /* Associated flags; see CSTATUS_* below. */
|
||||
};
|
||||
|
||||
struct u_chaninfolist {
|
||||
struct u_chaninfolist *next, *prev;
|
||||
ChannelInfo *chan;
|
||||
};
|
||||
|
||||
/* Online user and channel data. */
|
||||
class User
|
||||
{
|
||||
public: // XXX: exposing a tiny bit too much
|
||||
User *next, *prev;
|
||||
|
||||
char nick[NICKMAX];
|
||||
|
||||
char *username; /* ident */
|
||||
char *host; /* User's real hostname */
|
||||
char *hostip; /* User's IP number */
|
||||
char *vhost; /* User's virtual hostname */
|
||||
char *vident; /* User's virtual ident */
|
||||
char *realname; /* Realname */
|
||||
Server *server; /* Server user is connected to */
|
||||
char *nickTrack; /* Nick Tracking */
|
||||
time_t timestamp; /* Timestamp of the nick */
|
||||
time_t my_signon; /* When did _we_ see the user? */
|
||||
uint32 svid; /* Services ID */
|
||||
uint32 mode; /* See below */
|
||||
char *uid; /* Univeral ID */
|
||||
|
||||
NickAlias *na;
|
||||
|
||||
ModuleData *moduleData; /* defined for it, it should allow the module Add/Get */
|
||||
|
||||
int isSuperAdmin; /* is SuperAdmin on or off? */
|
||||
|
||||
struct u_chanlist *chans; /* Channels user has joined */
|
||||
struct u_chaninfolist *founder_chans; /* Channels user has identified for */
|
||||
|
||||
short invalid_pw_count; /* # of invalid password attempts */
|
||||
time_t invalid_pw_time; /* Time of last invalid password */
|
||||
|
||||
time_t lastmemosend; /* Last time MS SEND command used */
|
||||
time_t lastnickreg; /* Last time NS REGISTER cmd used */
|
||||
time_t lastmail; /* Last time this user sent a mail */
|
||||
|
||||
|
||||
/****************************************************************/
|
||||
|
||||
/** Create a new user object, initialising necessary fields and
|
||||
* adds it to the hash
|
||||
*
|
||||
* @parameter nick The nickname of the user account.
|
||||
*/
|
||||
User(const std::string &nick);
|
||||
};
|
||||
|
||||
@@ -1230,6 +1230,11 @@ NickAlias *findnick(const char *nick)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
NickAlias *findnick(const std::string &nick)
|
||||
{
|
||||
return findnick(nick.c_str());
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Return the NickCore structure for the given nick, or NULL if the core
|
||||
|
||||
+36
-29
@@ -27,38 +27,45 @@ time_t maxusertime;
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
/* Allocate a new User structure, fill in basic values, link it to the
|
||||
* overall list, and return it. Always successful.
|
||||
*/
|
||||
|
||||
static User *new_user(const char *nick)
|
||||
User::User(const std::string &nick)
|
||||
{
|
||||
User *user, **list;
|
||||
User **list;
|
||||
// XXX: we could do well to steal CoreException from insp
|
||||
if (!nick.empty())
|
||||
throw "what the craq, empty nick passed to constructor";
|
||||
|
||||
user = (User *)scalloc(sizeof(User), 1);
|
||||
if (!nick)
|
||||
nick = "";
|
||||
strscpy(user->nick, nick, NICKMAX);
|
||||
list = &userlist[HASH(user->nick)];
|
||||
user->next = *list;
|
||||
if (*list)
|
||||
(*list)->prev = user;
|
||||
*list = user;
|
||||
user->na = findnick(nick);
|
||||
if (user->na)
|
||||
user->na->u = user;
|
||||
usercnt++;
|
||||
if (usercnt > maxusercnt) {
|
||||
maxusercnt = usercnt;
|
||||
maxusertime = time(NULL);
|
||||
if (LogMaxUsers)
|
||||
alog("user: New maximum user count: %d", maxusercnt);
|
||||
}
|
||||
user->isSuperAdmin = 0; /* always set SuperAdmin to 0 for new users */
|
||||
user->nickTrack = NULL; /* ensure no default tracking nick */
|
||||
return user;
|
||||
// XXX: we should also duplicate-check here.
|
||||
|
||||
strscpy(this->nick, nick.c_str(), NICKMAX);
|
||||
list = &userlist[HASH(this->nick)];
|
||||
this->next = *list;
|
||||
|
||||
if (*list)
|
||||
(*list)->prev = this;
|
||||
|
||||
*list = this;
|
||||
|
||||
this->na = findnick(nick);
|
||||
|
||||
if (this->na)
|
||||
this->na->u = this;
|
||||
|
||||
usercnt++;
|
||||
|
||||
if (usercnt > maxusercnt)
|
||||
{
|
||||
maxusercnt = usercnt;
|
||||
maxusertime = time(NULL);
|
||||
if (LogMaxUsers)
|
||||
alog("user: New maximum user count: %d", maxusercnt);
|
||||
}
|
||||
|
||||
this->isSuperAdmin = 0; /* always set SuperAdmin to 0 for new users */
|
||||
this->nickTrack = NULL; /* ensure no default tracking nick */
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
/* Change the nickname of a user, and move pointers as necessary. */
|
||||
@@ -614,7 +621,7 @@ User *do_nick(const char *source, char *nick, char *username, char *host,
|
||||
return NULL;
|
||||
|
||||
/* Allocate User structure and fill it in. */
|
||||
user = new_user(nick);
|
||||
user = new User(nick);
|
||||
user->username = sstrdup(username);
|
||||
user->host = sstrdup(host);
|
||||
user->server = findserver(servlist, server);
|
||||
|
||||
Reference in New Issue
Block a user