mirror of
https://github.com/anope/anope.git
synced 2026-06-28 23:46:39 +02:00
Moved alot of stuff to constructors and destructors, instead of having functions everywhere to create and destroy objects
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2639 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
+21
-9
@@ -69,13 +69,10 @@ enum NickCoreFlag
|
||||
class NickRequest
|
||||
{
|
||||
public:
|
||||
NickRequest()
|
||||
{
|
||||
next = prev = NULL;
|
||||
nick = passcode = email = NULL;
|
||||
*password = 0;
|
||||
requested = lastmail = 0;
|
||||
}
|
||||
NickRequest(const std::string &nickname);
|
||||
|
||||
~NickRequest();
|
||||
|
||||
NickRequest *next, *prev;
|
||||
char *nick;
|
||||
char *passcode;
|
||||
@@ -90,7 +87,15 @@ class NickCore;
|
||||
class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag>
|
||||
{
|
||||
public:
|
||||
NickAlias();
|
||||
/** Default constructor
|
||||
* @param nickname The nick
|
||||
* @param nickcore The nickcofe for this nick
|
||||
*/
|
||||
NickAlias(const std::string &nickname, NickCore *nickcore);
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
~NickAlias();
|
||||
|
||||
NickAlias *next, *prev;
|
||||
char *nick; /* Nickname */
|
||||
@@ -105,7 +110,14 @@ class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag>
|
||||
class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag>
|
||||
{
|
||||
public:
|
||||
NickCore();
|
||||
/** Default constructor
|
||||
* @param display The display nick
|
||||
*/
|
||||
NickCore(const std::string &nickdisplay);
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
~NickCore();
|
||||
|
||||
NickCore *next, *prev;
|
||||
|
||||
|
||||
@@ -73,8 +73,6 @@ E void bot_raw_mode(User * requester, ChannelInfo * ci, const char *mode, char *
|
||||
E Channel *chanlist[1024];
|
||||
|
||||
E void chan_adduser2(User * user, Channel * c);
|
||||
E void chan_delete(Channel * c);
|
||||
E Channel *chan_create(const char *chan, time_t ts);
|
||||
E Channel *join_user_update(User * user, Channel * chan, const char *name, time_t chants);
|
||||
|
||||
E void get_channel_stats(long *nrec, long *memuse);
|
||||
@@ -132,7 +130,6 @@ E LevelInfo levelinfo[];
|
||||
|
||||
E void get_chanserv_stats(long *nrec, long *memuse);
|
||||
|
||||
E int delchan(ChannelInfo * ci);
|
||||
E void alpha_insert_chan(ChannelInfo * ci);
|
||||
E void reset_levels(ChannelInfo * ci);
|
||||
E void cs_init();
|
||||
@@ -167,7 +164,6 @@ E void stick_mask(ChannelInfo * ci, AutoKick * akick);
|
||||
E void stick_all(ChannelInfo * ci);
|
||||
|
||||
E int levelinfo_maxwidth;
|
||||
E ChannelInfo *makechan(const char *chan);
|
||||
E char *get_mlock_modes(ChannelInfo * ci, int complete);
|
||||
|
||||
/**** compat.c ****/
|
||||
@@ -605,7 +601,6 @@ E NickAlias *nalists[1024];
|
||||
E NickCore *nclists[1024];
|
||||
E NickRequest *nrlists[1024];
|
||||
E NickRequest *findrequestnick(const char *nick);
|
||||
E int delnickrequest(NickRequest * nr);
|
||||
E unsigned int guestnum;
|
||||
E void insert_requestnick(NickRequest * nr);
|
||||
E void alpha_insert_alias(NickAlias * na);
|
||||
@@ -632,7 +627,6 @@ E int nick_identified(User * u);
|
||||
E void expire_nicks();
|
||||
E void expire_requests();
|
||||
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);
|
||||
|
||||
+11
-1
@@ -69,7 +69,17 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag>
|
||||
std::bitset<128> mlock_off; /* Modes mlocked off */
|
||||
|
||||
public:
|
||||
ChannelInfo();
|
||||
// XXX Hack for defcon, though this really isn't needed now and should be destroyed
|
||||
ChannelInfo() { }
|
||||
|
||||
/** Default constructor
|
||||
* @param chname The channel name
|
||||
*/
|
||||
ChannelInfo(const std::string &chname);
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
~ChannelInfo();
|
||||
|
||||
ChannelInfo *next, *prev;
|
||||
char name[CHANMAX];
|
||||
|
||||
+77
-5
@@ -946,12 +946,15 @@ class CoreExport Channel : public Extensible
|
||||
std::map<ChannelModeName, std::string> Params;
|
||||
|
||||
public:
|
||||
Channel() { }
|
||||
/** Default constructor
|
||||
* @param name The channel name
|
||||
* @param ts The time the channel was created
|
||||
*/
|
||||
Channel(const std::string &name, time_t ts = time(NULL));
|
||||
|
||||
~Channel()
|
||||
{
|
||||
Params.clear();
|
||||
}
|
||||
/** Default destructor
|
||||
*/
|
||||
~Channel();
|
||||
|
||||
Channel *next, *prev;
|
||||
char name[CHANMAX];
|
||||
@@ -1784,4 +1787,73 @@ E std::list<std::pair<std::string, std::string> > svsopers_in_config;
|
||||
*/
|
||||
E std::list<OperType *> MyOperTypes;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "timers.h"
|
||||
|
||||
/** Timer for colliding nicks to force people off of nicknames
|
||||
*/
|
||||
class NickServCollide : public Timer
|
||||
{
|
||||
public:
|
||||
/* NickAlias of the nick who were kicking off */
|
||||
NickAlias *na;
|
||||
/* Return for the std::map::insert */
|
||||
std::pair<std::map<NickAlias *, NickServCollide *>::iterator, bool> it;
|
||||
|
||||
/** Default constructor
|
||||
* @param nickalias The nick alias were kicking off
|
||||
* @param delay How long to delay before kicking the user off the nick
|
||||
*/
|
||||
NickServCollide(NickAlias *nickalias, time_t delay);
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
~NickServCollide();
|
||||
|
||||
/** Called when the delay is up
|
||||
* @param t The current time
|
||||
*/
|
||||
void Tick(time_t t);
|
||||
|
||||
/** Clear all timers for a nick
|
||||
* @param na The nick to remove the timers for
|
||||
*/
|
||||
static void ClearTimers(NickAlias *na);
|
||||
};
|
||||
|
||||
/** Timers for releasing nicks to be available for use
|
||||
*/
|
||||
class NickServRelease : public Timer
|
||||
{
|
||||
public:
|
||||
/* The nick */
|
||||
NickAlias *na;
|
||||
/* The uid of the services enforcer client (used for TS6 ircds) */
|
||||
std::string uid;
|
||||
/* Return for std::map::insert */
|
||||
std::pair<std::map<NickAlias *, NickServRelease *>::iterator, bool> it;
|
||||
|
||||
/** Default constructor
|
||||
* @param nickalias The nick
|
||||
* @param delay The delay before the nick is released
|
||||
*/
|
||||
NickServRelease(NickAlias *nickalias, time_t delay);
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
~NickServRelease();
|
||||
|
||||
/** Called when the delay is up
|
||||
* @param t The current time
|
||||
*/
|
||||
void Tick(time_t t);
|
||||
|
||||
/** Clear all timers for a nick
|
||||
* @param na The nick to remove the timers for
|
||||
* @param dorelase true to actually call release(), false to just remove the timers
|
||||
*/
|
||||
static void ClearTimers(NickAlias *na, bool dorelease = false);
|
||||
};
|
||||
|
||||
#endif /* SERVICES_H */
|
||||
|
||||
+104
-123
@@ -22,6 +22,107 @@ Channel *chanlist[1024];
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/** Default constructor
|
||||
* @param name The channel name
|
||||
* @param ts The time the channel was created
|
||||
*/
|
||||
Channel::Channel(const std::string &name, time_t ts)
|
||||
{
|
||||
Channel **list;
|
||||
|
||||
if (name.empty())
|
||||
throw CoreException("A channel without a name ?");
|
||||
|
||||
strscpy(this->name, name.c_str(), sizeof(this->name));
|
||||
list = &chanlist[HASH(this->name)];
|
||||
this->prev = NULL;
|
||||
this->next = *list;
|
||||
if (*list)
|
||||
(*list)->prev = this;
|
||||
*list = this;
|
||||
|
||||
this->creation_time = ts;
|
||||
this->topic = NULL;
|
||||
*this->topic_setter = 0;
|
||||
this->bans = this->excepts = this->invites = NULL;
|
||||
this->users = NULL;
|
||||
this->usercount = 0;
|
||||
this->bd = NULL;
|
||||
this->server_modetime = this->chanserv_modetime = 0;
|
||||
this->server_modecount = this->chanserv_modecount = this->bouncy_modes = this->topic_sync = 0;
|
||||
|
||||
this->ci = cs_findchan(this->name);
|
||||
if (this->ci)
|
||||
{
|
||||
this->ci->c = this;
|
||||
|
||||
check_modes(this);
|
||||
stick_all(this->ci);
|
||||
}
|
||||
|
||||
if (serv_uplink && is_sync(serv_uplink) && (!(this->topic_sync)))
|
||||
restore_topic(name.c_str());
|
||||
|
||||
FOREACH_MOD(I_OnChannelCreate, OnChannelCreate(this));
|
||||
}
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
Channel::~Channel()
|
||||
{
|
||||
BanData *bd, *next;
|
||||
|
||||
FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this));
|
||||
|
||||
if (debug)
|
||||
alog("debug: Deleting channel %s", this->name);
|
||||
|
||||
for (bd = this->bd; bd; bd = next)
|
||||
{
|
||||
if (bd->mask)
|
||||
delete [] bd->mask;
|
||||
next = bd->next;
|
||||
delete bd;
|
||||
}
|
||||
|
||||
if (this->ci)
|
||||
this->ci->c = NULL;
|
||||
|
||||
if (this->topic)
|
||||
delete [] this->topic;
|
||||
|
||||
if (this->bans && this->bans->count)
|
||||
{
|
||||
while (this->bans->entries)
|
||||
entry_delete(this->bans, this->bans->entries);
|
||||
}
|
||||
|
||||
if (ModeManager::FindChannelModeByName(CMODE_EXCEPT))
|
||||
{
|
||||
if (this->excepts && this->excepts->count)
|
||||
{
|
||||
while (this->excepts->entries)
|
||||
entry_delete(this->excepts, this->excepts->entries);
|
||||
}
|
||||
}
|
||||
|
||||
if (ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE))
|
||||
{
|
||||
if (this->invites && this->invites->count)
|
||||
{
|
||||
while (this->invites->entries)
|
||||
entry_delete(this->invites, this->invites->entries);
|
||||
}
|
||||
}
|
||||
|
||||
if (this->next)
|
||||
this->next->prev = this->prev;
|
||||
if (this->prev)
|
||||
this->prev->next = this->next;
|
||||
else
|
||||
chanlist[HASH(this->name)] = this->next;
|
||||
}
|
||||
|
||||
/**
|
||||
* See if a channel has a mode
|
||||
* @param Name The mode name
|
||||
@@ -77,7 +178,7 @@ void Channel::RemoveMode(ChannelModeName Name)
|
||||
if (s_BotServ && ci->bi && usercount == BSMinUsers - 1)
|
||||
ircdproto->SendPart(ci->bi, name, NULL);
|
||||
if (!users)
|
||||
chan_delete(this);
|
||||
delete this;
|
||||
}
|
||||
|
||||
FOREACH_MOD(I_OnChannelModeUnset, OnChannelModeUnset(this, Name));
|
||||
@@ -348,7 +449,7 @@ void chan_deluser(User * user, Channel * c)
|
||||
ircdproto->SendPart(c->ci->bi, c->name, NULL);
|
||||
|
||||
if (!c->users)
|
||||
chan_delete(c);
|
||||
delete c;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
@@ -1866,126 +1967,6 @@ void chan_adduser2(User * user, Channel * c)
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* This creates the channel structure (was originally in
|
||||
chan_adduser, but splitted to make it more efficient to use for
|
||||
SJOINs). */
|
||||
|
||||
Channel *chan_create(const char *chan, time_t ts)
|
||||
{
|
||||
Channel *c;
|
||||
Channel **list;
|
||||
|
||||
if (debug)
|
||||
alog("debug: Creating channel %s", chan);
|
||||
c = new Channel;
|
||||
strscpy(c->name, chan, sizeof(c->name));
|
||||
list = &chanlist[HASH(c->name)];
|
||||
c->prev = NULL;
|
||||
c->next = *list;
|
||||
if (*list)
|
||||
(*list)->prev = c;
|
||||
*list = c;
|
||||
c->creation_time = ts;
|
||||
c->topic = NULL;
|
||||
*c->topic_setter = 0;
|
||||
c->topic_time = 0;
|
||||
c->bans = c->excepts = c->invites = NULL;
|
||||
c->users = NULL;
|
||||
c->usercount = 0;
|
||||
c->bd = NULL;
|
||||
c->server_modetime = c->chanserv_modetime = 0;
|
||||
c->server_modecount = c->chanserv_modecount = c->bouncy_modes = c->topic_sync = 0;
|
||||
/* Store ChannelInfo pointer in channel record */
|
||||
c->ci = cs_findchan(chan);
|
||||
if (c->ci)
|
||||
c->ci->c = c;
|
||||
/* Restore locked modes and saved topic */
|
||||
if (c->ci) {
|
||||
check_modes(c);
|
||||
stick_all(c->ci);
|
||||
}
|
||||
|
||||
if (serv_uplink && is_sync(serv_uplink) && (!(c->topic_sync))) {
|
||||
restore_topic(chan);
|
||||
}
|
||||
|
||||
/* A channel set as persistant when it was not created has just
|
||||
* been created, mark it as persistant
|
||||
*/
|
||||
ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_PERM);
|
||||
if (cm && c->ci && c->ci->HasFlag(CI_PERSIST) && !c->HasMode(CMODE_PERM))
|
||||
{
|
||||
ircdproto->SendMode(whosends(c->ci), c->name, "+%c", cm->ModeChar);
|
||||
c->SetMode(CMODE_PERM);
|
||||
}
|
||||
|
||||
FOREACH_MOD(I_OnChannelCreate, OnChannelCreate(c));
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* This destroys the channel structure, freeing everything in it. */
|
||||
|
||||
void chan_delete(Channel * c)
|
||||
{
|
||||
BanData *bd, *next;
|
||||
|
||||
FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(c));
|
||||
|
||||
if (debug)
|
||||
alog("debug: Deleting channel %s", c->name);
|
||||
|
||||
for (bd = c->bd; bd; bd = next) {
|
||||
if (bd->mask)
|
||||
delete [] bd->mask;
|
||||
next = bd->next;
|
||||
delete bd;
|
||||
}
|
||||
|
||||
if (c->ci)
|
||||
c->ci->c = NULL;
|
||||
|
||||
if (c->topic)
|
||||
delete [] c->topic;
|
||||
|
||||
if (c->bans && c->bans->count) {
|
||||
while (c->bans->entries) {
|
||||
entry_delete(c->bans, c->bans->entries);
|
||||
}
|
||||
}
|
||||
|
||||
if (ModeManager::FindChannelModeByName(CMODE_EXCEPT))
|
||||
{
|
||||
if (c->excepts && c->excepts->count) {
|
||||
while (c->excepts->entries) {
|
||||
entry_delete(c->excepts, c->excepts->entries);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE))
|
||||
{
|
||||
if (c->invites && c->invites->count) {
|
||||
while (c->invites->entries) {
|
||||
entry_delete(c->invites, c->invites->entries);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (c->next)
|
||||
c->next->prev = c->prev;
|
||||
if (c->prev)
|
||||
c->prev->next = c->next;
|
||||
else
|
||||
chanlist[HASH(c->name)] = c->next;
|
||||
|
||||
delete c;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
Channel *join_user_update(User * user, Channel * chan, const char *name,
|
||||
time_t chants)
|
||||
{
|
||||
@@ -1993,7 +1974,7 @@ Channel *join_user_update(User * user, Channel * chan, const char *name,
|
||||
|
||||
/* If it's a new channel, so we need to create it first. */
|
||||
if (!chan)
|
||||
chan = chan_create(name, chants);
|
||||
chan = new Channel(name, chants);
|
||||
else
|
||||
{
|
||||
// Check chants against 0, as not every ircd sends JOIN with a TS.
|
||||
|
||||
+7
-141
@@ -347,12 +347,13 @@ void load_cs_dbase()
|
||||
while ((c = getc_db(f)) != 0) {
|
||||
if (c != 1)
|
||||
fatal("Invalid format in %s", ChanDBName);
|
||||
ci = new ChannelInfo();
|
||||
char channame[CHANMAX];
|
||||
SAFE(read = read_buffer(channame, f));
|
||||
ci = new ChannelInfo(channame);
|
||||
*last = ci;
|
||||
last = &ci->next;
|
||||
ci->prev = prev;
|
||||
prev = ci;
|
||||
SAFE(read = read_buffer(ci->name, f));
|
||||
SAFE(read_string(&s, f));
|
||||
if (s) {
|
||||
ci->founder = findcore(s);
|
||||
@@ -596,7 +597,7 @@ void load_cs_dbase()
|
||||
if (!(ci->HasFlag(CI_FORBIDDEN)) && !ci->founder) {
|
||||
alog("%s: database load: Deleting founderless channel %s",
|
||||
s_ChanServ, ci->name);
|
||||
delchan(ci);
|
||||
delete ci;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -1439,7 +1440,7 @@ void expire_chans()
|
||||
char *chname = sstrdup(ci->name);
|
||||
alog("Expiring channel %s (founder: %s)", ci->name,
|
||||
(ci->founder ? ci->founder->display : "(none)"));
|
||||
delchan(ci);
|
||||
delete ci;
|
||||
FOREACH_MOD(I_OnChanExpire, OnChanExpire(chname));
|
||||
delete [] chname;
|
||||
}
|
||||
@@ -1466,7 +1467,7 @@ void cs_remove_nick(const NickCore * nc)
|
||||
NickCore *nc2 = ci->successor;
|
||||
if (!nc2->IsServicesOper() && CSMaxReg && nc2->channelcount >= CSMaxReg) {
|
||||
alog("%s: Successor (%s) of %s owns too many channels, " "deleting channel", s_ChanServ, nc2->display, ci->name);
|
||||
delchan(ci);
|
||||
delete ci;
|
||||
continue;
|
||||
} else {
|
||||
alog("%s: Transferring foundership of %s from deleted " "nick %s to successor %s", s_ChanServ, ci->name, nc->display, nc2->display);
|
||||
@@ -1487,7 +1488,7 @@ void cs_remove_nick(const NickCore * nc)
|
||||
}
|
||||
}
|
||||
|
||||
delchan(ci);
|
||||
delete ci;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -1609,141 +1610,6 @@ void alpha_insert_chan(ChannelInfo * ci)
|
||||
ptr->prev = ci;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Add a channel to the database. Returns a pointer to the new ChannelInfo
|
||||
* structure if the channel was successfully registered, NULL otherwise.
|
||||
* Assumes channel does not already exist. */
|
||||
|
||||
ChannelInfo *makechan(const char *chan)
|
||||
{
|
||||
int i;
|
||||
ChannelInfo *ci;
|
||||
|
||||
ci = new ChannelInfo();
|
||||
strscpy(ci->name, chan, CHANMAX);
|
||||
ci->time_registered = time(NULL);
|
||||
reset_levels(ci);
|
||||
ci->ttb = new int16[2 * TTB_SIZE];
|
||||
for (i = 0; i < TTB_SIZE; i++)
|
||||
ci->ttb[i] = 0;
|
||||
alpha_insert_chan(ci);
|
||||
return ci;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Remove a channel from the ChanServ database. Return 1 on success, 0
|
||||
* otherwise. */
|
||||
|
||||
int delchan(ChannelInfo * ci)
|
||||
{
|
||||
unsigned i;
|
||||
NickCore *nc;
|
||||
|
||||
if (!ci) {
|
||||
if (debug) {
|
||||
alog("debug: delchan called with NULL values");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
FOREACH_MOD(I_OnDelChan, OnDelChan(ci));
|
||||
|
||||
nc = ci->founder;
|
||||
|
||||
if (debug >= 2) {
|
||||
alog("debug: delchan removing %s", ci->name);
|
||||
}
|
||||
|
||||
if (ci->bi) {
|
||||
ci->bi->chancount--;
|
||||
}
|
||||
|
||||
if (debug >= 2) {
|
||||
alog("debug: delchan top of removing the bot");
|
||||
}
|
||||
if (ci->c) {
|
||||
if (ci->bi && ci->c->usercount >= BSMinUsers) {
|
||||
ircdproto->SendPart(ci->bi, ci->c->name, NULL);
|
||||
}
|
||||
ci->c->ci = NULL;
|
||||
}
|
||||
if (debug >= 2) {
|
||||
alog("debug: delchan() Bot has been removed moving on");
|
||||
}
|
||||
|
||||
if (ci->next)
|
||||
ci->next->prev = ci->prev;
|
||||
if (ci->prev)
|
||||
ci->prev->next = ci->next;
|
||||
else
|
||||
chanlists[static_cast<unsigned char>(tolower(ci->name[1]))] = ci->next;
|
||||
if (ci->desc)
|
||||
delete [] ci->desc;
|
||||
if (ci->url)
|
||||
delete [] ci->url;
|
||||
if (ci->email)
|
||||
delete [] ci->email;
|
||||
if (ci->entry_message)
|
||||
delete [] ci->entry_message;
|
||||
|
||||
if (ci->last_topic)
|
||||
delete [] ci->last_topic;
|
||||
if (ci->forbidby)
|
||||
delete [] ci->forbidby;
|
||||
if (ci->forbidreason)
|
||||
delete [] ci->forbidreason;
|
||||
ci->ClearAkick();
|
||||
if (ci->levels)
|
||||
delete [] ci->levels;
|
||||
if (debug >= 2) {
|
||||
alog("debug: delchan() top of the memo list");
|
||||
}
|
||||
if (!ci->memos.memos.empty()) {
|
||||
for (i = 0; i < ci->memos.memos.size(); ++i) {
|
||||
if (ci->memos.memos[i]->text)
|
||||
delete [] ci->memos.memos[i]->text;
|
||||
delete ci->memos.memos[i];
|
||||
}
|
||||
ci->memos.memos.clear();
|
||||
}
|
||||
if (debug >= 2) {
|
||||
alog("debug: delchan() done with the memo list");
|
||||
}
|
||||
if (ci->ttb)
|
||||
delete [] ci->ttb;
|
||||
|
||||
if (debug >= 2) {
|
||||
alog("debug: delchan() top of the badword list");
|
||||
}
|
||||
for (i = 0; i < ci->bwcount; i++) {
|
||||
if (ci->badwords[i].word)
|
||||
delete [] ci->badwords[i].word;
|
||||
}
|
||||
if (ci->badwords)
|
||||
free(ci->badwords);
|
||||
if (debug >= 2) {
|
||||
alog("debug: delchan() done with the badword list");
|
||||
}
|
||||
|
||||
|
||||
if (debug >= 2) {
|
||||
alog("debug: delchan() calling on moduleCleanStruct()");
|
||||
}
|
||||
|
||||
delete ci;
|
||||
if (nc)
|
||||
nc->channelcount--;
|
||||
|
||||
if (debug >= 2) {
|
||||
alog("debug: delchan() all done");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Reset channel access level values to their default state. */
|
||||
|
||||
void reset_levels(ChannelInfo * ci)
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ class CommandCSDrop : public Command
|
||||
s_ChanServ, ci->name, u->nick, u->GetIdent().c_str(),
|
||||
u->host, (ci->founder ? ci->founder->display : "(none)"));
|
||||
|
||||
delchan(ci);
|
||||
delete ci;
|
||||
|
||||
/* We must make sure that the Services admin has not normally the right to
|
||||
* drop the channel before issuing the wallops.
|
||||
|
||||
@@ -50,9 +50,9 @@ class CommandCSForbid : public Command
|
||||
}
|
||||
|
||||
if ((ci = cs_findchan(chan)) != NULL)
|
||||
delchan(ci);
|
||||
delete ci;
|
||||
|
||||
ci = makechan(chan);
|
||||
ci = new ChannelInfo(chan);
|
||||
if (!ci)
|
||||
{
|
||||
alog("%s: Valid FORBID for %s by %s failed", s_ChanServ, ci->name, u->nick);
|
||||
|
||||
@@ -53,7 +53,7 @@ class CommandCSRegister : public Command
|
||||
notice_lang(s_ChanServ, u, CHAN_MUST_BE_CHANOP);
|
||||
else if (CSMaxReg && u->nc->channelcount >= CSMaxReg && !u->nc->HasPriv("chanserv/no-register-limit"))
|
||||
notice_lang(s_ChanServ, u, u->nc->channelcount > CSMaxReg ? CHAN_EXCEEDED_CHANNEL_LIMIT : CHAN_REACHED_CHANNEL_LIMIT, CSMaxReg);
|
||||
else if (!(ci = makechan(chan)))
|
||||
else if (!(ci = new ChannelInfo(chan)))
|
||||
{
|
||||
alog("%s: makechan() failed for REGISTER %s", s_ChanServ, chan);
|
||||
notice_lang(s_ChanServ, u, CHAN_REGISTRATION_FAILED);
|
||||
|
||||
+2
-2
@@ -511,7 +511,7 @@ class CommandCSSet : public Command
|
||||
/* Channel doesn't exist, create it internally */
|
||||
if (!ci->c)
|
||||
{
|
||||
chan_create(ci->name, time(NULL));
|
||||
new Channel(ci->name);
|
||||
if (ci->bi)
|
||||
bot_join(ci);
|
||||
}
|
||||
@@ -553,7 +553,7 @@ class CommandCSSet : public Command
|
||||
if (s_BotServ && ci->bi && ci->c->usercount == BSMinUsers - 1)
|
||||
ircdproto->SendPart(ci->bi, ci->c->name, NULL);
|
||||
if (!ci->c->users)
|
||||
chan_delete(ci->c);
|
||||
delete ci->c;
|
||||
|
||||
/* No channel mode, no BotServ, but using ChanServ as the botserv bot
|
||||
* which was assigned when persist was set on
|
||||
|
||||
+2
-2
@@ -45,7 +45,7 @@ class CommandNSDrop : public Command
|
||||
if (WallDrop)
|
||||
ircdproto->SendGlobops(s_NickServ, "\2%s\2 used DROP on \2%s\2", u->nick, nick);
|
||||
alog("%s: %s!%s@%s dropped nickname %s (e-mail: %s)", s_NickServ, u->nick, u->GetIdent().c_str(), u->host, nr->nick, nr->email);
|
||||
delnickrequest(nr);
|
||||
delete nr;
|
||||
notice_lang(s_NickServ, u, NICK_X_DROPPED, nick);
|
||||
}
|
||||
else
|
||||
@@ -73,7 +73,7 @@ class CommandNSDrop : public Command
|
||||
ircdproto->SendSQLineDel(na->nick);
|
||||
|
||||
alog("%s: %s!%s@%s dropped nickname %s (group %s) (e-mail: %s)", s_NickServ, u->nick, u->GetIdent().c_str(), u->host, na->nick, na->nc->display, na->nc->email ? na->nc->email : "none");
|
||||
delnick(na);
|
||||
delete na;
|
||||
|
||||
FOREACH_MOD(I_OnNickDrop, OnNickDrop(my_nick ? my_nick : nick));
|
||||
|
||||
|
||||
+2
-25
@@ -15,8 +15,6 @@
|
||||
|
||||
#include "module.h"
|
||||
|
||||
NickAlias *makenick(const char *nick);
|
||||
|
||||
class CommandNSForbid : public Command
|
||||
{
|
||||
public:
|
||||
@@ -50,9 +48,9 @@ class CommandNSForbid : public Command
|
||||
notice_lang(s_NickServ, u, ACCESS_DENIED);
|
||||
return MOD_CONT;
|
||||
}
|
||||
delnick(na);
|
||||
delete na;
|
||||
}
|
||||
na = makenick(nick);
|
||||
na = new NickAlias(nick, new NickCore(nick));
|
||||
if (na)
|
||||
{
|
||||
na->SetFlag(NS_FORBIDDEN);
|
||||
@@ -119,25 +117,4 @@ class NSForbid : public Module
|
||||
}
|
||||
};
|
||||
|
||||
NickAlias *makenick(const char *nick)
|
||||
{
|
||||
NickAlias *na;
|
||||
NickCore *nc;
|
||||
|
||||
/* First make the core */
|
||||
nc = new NickCore();
|
||||
nc->display = sstrdup(nick);
|
||||
slist_init(&nc->aliases);
|
||||
insert_core(nc);
|
||||
alog("%s: group %s has been created", s_NickServ, nc->display);
|
||||
|
||||
/* Then make the alias */
|
||||
na = new NickAlias;
|
||||
na->nick = sstrdup(nick);
|
||||
na->nc = nc;
|
||||
slist_add(&nc->aliases, na);
|
||||
alpha_insert_alias(na);
|
||||
return na;
|
||||
}
|
||||
|
||||
MODULE_INIT(NSForbid)
|
||||
|
||||
+3
-18
@@ -15,8 +15,6 @@
|
||||
|
||||
#include "module.h"
|
||||
|
||||
NickAlias *makealias(const char *nick, NickCore *nc);
|
||||
|
||||
class CommandNSGroup : public Command
|
||||
{
|
||||
public:
|
||||
@@ -96,7 +94,7 @@ class CommandNSGroup : public Command
|
||||
* If not, check that it is valid.
|
||||
*/
|
||||
if (findnick(u->nick))
|
||||
delnick(findnick(u->nick));
|
||||
delete findnick(u->nick);
|
||||
else
|
||||
{
|
||||
int prefixlen = strlen(NSGuestNickPrefix);
|
||||
@@ -108,7 +106,8 @@ class CommandNSGroup : public Command
|
||||
return MOD_CONT;
|
||||
}
|
||||
}
|
||||
na = makealias(u->nick, target->nc);
|
||||
|
||||
na = new NickAlias(u->nick, target->nc);
|
||||
|
||||
if (na)
|
||||
{
|
||||
@@ -230,18 +229,4 @@ class NSGroup : public Module
|
||||
}
|
||||
};
|
||||
|
||||
/* Creates a new alias in NickServ database. */
|
||||
NickAlias *makealias(const char *nick, NickCore *nc)
|
||||
{
|
||||
NickAlias *na;
|
||||
|
||||
/* Just need to make the alias */
|
||||
na = new NickAlias;
|
||||
na->nick = sstrdup(nick);
|
||||
na->nc = nc;
|
||||
slist_add(&nc->aliases, na);
|
||||
alpha_insert_alias(na);
|
||||
return na;
|
||||
}
|
||||
|
||||
MODULE_INIT(NSGroup)
|
||||
|
||||
+5
-41
@@ -15,8 +15,6 @@
|
||||
|
||||
#include "module.h"
|
||||
|
||||
NickRequest *makerequest(const char *nick);
|
||||
NickAlias *makenick(const char *nick);
|
||||
int do_sendregmail(User *u, NickRequest *nr);
|
||||
|
||||
class CommandNSConfirm : public Command
|
||||
@@ -24,8 +22,7 @@ class CommandNSConfirm : public Command
|
||||
protected:
|
||||
CommandReturn ActuallyConfirmNick(User *u, NickRequest *nr, bool force)
|
||||
{
|
||||
NickAlias *na;
|
||||
na = makenick(nr->nick);
|
||||
NickAlias *na = new NickAlias(nr->nick, new NickCore(nr->nick));
|
||||
|
||||
if (!na)
|
||||
{
|
||||
@@ -69,7 +66,7 @@ class CommandNSConfirm : public Command
|
||||
notice_lang(s_NickServ, u, NICK_REGISTERED, u->nick, na->nc->GetAccess(0).c_str());
|
||||
else
|
||||
notice_lang(s_NickServ, u, NICK_REGISTERED_NO_MASK, u->nick);
|
||||
delnickrequest(nr);
|
||||
delete nr;
|
||||
|
||||
ircdproto->SendAccountLogin(u, u->nc);
|
||||
ircdproto->SetAutoIdentificationToken(u);
|
||||
@@ -87,7 +84,7 @@ class CommandNSConfirm : public Command
|
||||
|
||||
User *user = finduser(nr->nick);
|
||||
/* Delrequest must be called before validate_user */
|
||||
delnickrequest(nr);
|
||||
delete nr;
|
||||
if (user)
|
||||
{
|
||||
validate_user(user);
|
||||
@@ -268,7 +265,7 @@ class CommandNSRegister : public CommandNSConfirm
|
||||
for (idx = 0; idx < 9; ++idx)
|
||||
passcode[idx] = chars[1 + static_cast<int>((static_cast<float>(max - min)) * getrandom16() / 65536.0) + min];
|
||||
passcode[idx] = '\0';
|
||||
nr = makerequest(u->nick);
|
||||
nr = new NickRequest(u->nick);
|
||||
nr->passcode = sstrdup(passcode);
|
||||
strscpy(nr->password, pass, PASSMAX);
|
||||
enc_encrypt_in_place(nr->password, PASSMAX);
|
||||
@@ -287,7 +284,7 @@ class CommandNSRegister : public CommandNSConfirm
|
||||
{
|
||||
alog("%s: Unable to send registration verification mail", s_NickServ);
|
||||
notice_lang(s_NickServ, u, NICK_REG_UNABLE);
|
||||
delnickrequest(nr); /* Delete the NickRequest if we couldnt send the mail */
|
||||
delete nr;
|
||||
return MOD_CONT;
|
||||
}
|
||||
}
|
||||
@@ -387,39 +384,6 @@ class NSRegister : public Module
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
NickRequest *makerequest(const char *nick)
|
||||
{
|
||||
NickRequest *nr;
|
||||
|
||||
nr = new NickRequest;
|
||||
nr->nick = sstrdup(nick);
|
||||
insert_requestnick(nr);
|
||||
alog("%s: Nick %s has been requested", s_NickServ, nr->nick);
|
||||
return nr;
|
||||
}
|
||||
|
||||
/* Creates a full new nick (alias + core) in NickServ database. */
|
||||
NickAlias *makenick(const char *nick)
|
||||
{
|
||||
NickAlias *na;
|
||||
NickCore *nc;
|
||||
|
||||
/* First make the core */
|
||||
nc = new NickCore();
|
||||
nc->display = sstrdup(nick);
|
||||
slist_init(&nc->aliases);
|
||||
insert_core(nc);
|
||||
alog("%s: group %s has been created", s_NickServ, nc->display);
|
||||
|
||||
/* Then make the alias */
|
||||
na = new NickAlias;
|
||||
na->nick = sstrdup(nick);
|
||||
na->nc = nc;
|
||||
slist_add(&nc->aliases, na);
|
||||
alpha_insert_alias(na);
|
||||
return na;
|
||||
}
|
||||
|
||||
int do_sendregmail(User *u, NickRequest *nr)
|
||||
{
|
||||
MailInfo *mail = NULL;
|
||||
|
||||
+103
-2
@@ -1,10 +1,111 @@
|
||||
#include "services.h"
|
||||
#include "modules.h"
|
||||
|
||||
NickAlias::NickAlias()
|
||||
#define HASH(nick) ((tolower((nick)[0])&31)<<5 | (tolower((nick)[1])&31))
|
||||
|
||||
NickRequest::NickRequest(const std::string &nickname)
|
||||
{
|
||||
if (nickname.empty())
|
||||
throw CoreException("Empty nick passed to NickRequest constructor");
|
||||
|
||||
next = prev = NULL;
|
||||
passcode = email = NULL;
|
||||
*password = 0;
|
||||
requested = lastmail = 0;
|
||||
|
||||
this->nick = sstrdup(nickname.c_str());
|
||||
insert_requestnick(this); // till this is destroyed / redone in STL
|
||||
}
|
||||
|
||||
NickRequest::~NickRequest()
|
||||
{
|
||||
FOREACH_MOD(I_OnDelNickRequest, OnDelNickRequest(this));
|
||||
|
||||
nrlists[HASH(this->nick)] = this->next;
|
||||
if (this->nick)
|
||||
delete [] this->nick;
|
||||
if (this->passcode)
|
||||
delete [] this->passcode;
|
||||
if (this->email)
|
||||
delete [] this->email;
|
||||
}
|
||||
|
||||
/** Default constructor
|
||||
* @param nick The nick
|
||||
* @param nickcore The nickcofe for this nick
|
||||
*/
|
||||
NickAlias::NickAlias(const std::string &nickname, NickCore *nickcore)
|
||||
{
|
||||
if (nickname.empty())
|
||||
throw CoreException("Empty nick passed to NickAlias constructor");
|
||||
else if (!nickcore)
|
||||
throw CoreException("Empty nickcore passed to NickAlias constructor");
|
||||
|
||||
next = prev = NULL;
|
||||
nick = last_quit = last_realname = last_usermask = NULL;
|
||||
time_registered = last_seen = 0;
|
||||
nc = NULL;
|
||||
|
||||
this->nick = sstrdup(nickname.c_str());
|
||||
this->nc = nickcore;
|
||||
slist_add(&nc->aliases, this);
|
||||
alpha_insert_alias(this);
|
||||
}
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
NickAlias::~NickAlias()
|
||||
{
|
||||
User *u = NULL;
|
||||
|
||||
/* First thing to do: remove any timeout belonging to the nick we're deleting */
|
||||
NickServCollide::ClearTimers(this);
|
||||
NickServRelease::ClearTimers(this, true);
|
||||
|
||||
FOREACH_MOD(I_OnDelNick, OnDelNick(this));
|
||||
|
||||
/* Second thing to do: look for an user using the alias
|
||||
* being deleted, and make appropriate changes */
|
||||
if ((u = finduser(this->nick)))
|
||||
{
|
||||
if (ircd->modeonunreg)
|
||||
common_svsmode(finduser(this->nick), ircd->modeonunreg, "1");
|
||||
u->nc = NULL;
|
||||
}
|
||||
|
||||
delHostCore(this->nick); /* delete any vHost's for this nick */
|
||||
|
||||
/* Accept nicks that have no core, because of database load functions */
|
||||
if (this->nc)
|
||||
{
|
||||
/* Next: see if our core is still useful. */
|
||||
slist_remove(&this->nc->aliases, this);
|
||||
if (this->nc->aliases.count == 0)
|
||||
{
|
||||
delete this->nc;
|
||||
this->nc = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Display updating stuff */
|
||||
if (!stricmp(this->nick, this->nc->display))
|
||||
change_core_display(this->nc);
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove us from the aliases list */
|
||||
if (this->next)
|
||||
this->next->prev = this->prev;
|
||||
if (this->prev)
|
||||
this->prev->next = this->next;
|
||||
else
|
||||
nalists[HASH(this->nick)] = this->next;
|
||||
|
||||
delete [] this->nick;
|
||||
if (this->last_usermask)
|
||||
delete [] this->last_usermask;
|
||||
if (this->last_realname)
|
||||
delete [] this->last_realname;
|
||||
if (this->last_quit)
|
||||
delete [] this->last_quit;
|
||||
}
|
||||
|
||||
|
||||
+74
-1
@@ -1,8 +1,16 @@
|
||||
#include "services.h"
|
||||
#include "pseudo.h"
|
||||
|
||||
NickCore::NickCore()
|
||||
#define HASH(nick) ((tolower((nick)[0])&31)<<5 | (tolower((nick)[1])&31))
|
||||
|
||||
/** Default constructor
|
||||
* @param display The display nick
|
||||
*/
|
||||
NickCore::NickCore(const std::string &coredisplay)
|
||||
{
|
||||
if (coredisplay.empty())
|
||||
throw CoreException("Empty display passed to NickCore constructor");
|
||||
|
||||
next = prev = NULL;
|
||||
display = email = greet = url = NULL;
|
||||
ot = NULL;
|
||||
@@ -11,12 +19,77 @@ NickCore::NickCore()
|
||||
language = channelcount = 0;
|
||||
lastmail = 0;
|
||||
|
||||
this->display = sstrdup(coredisplay.c_str());
|
||||
slist_init(&this->aliases);
|
||||
insert_core(this); // till hashing is redone..
|
||||
|
||||
/* Set default nick core flags */
|
||||
for (size_t t = NI_BEGIN + 1; t != NI_END; ++t)
|
||||
if (NSDefFlags.HasFlag((NickCoreFlag)t))
|
||||
SetFlag((NickCoreFlag)t);
|
||||
}
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
NickCore::~NickCore()
|
||||
{
|
||||
FOREACH_MOD(I_OnDelCore, OnDelCore(this));
|
||||
|
||||
/* Clean up this nick core from any users online using it
|
||||
* (ones that /nick but remain unidentified)
|
||||
*/
|
||||
User *user;
|
||||
for (int i = 0; i < 1024; ++i)
|
||||
{
|
||||
for (user = userlist[i]; user; user = user->next)
|
||||
{
|
||||
if (user->nc && user->nc == this)
|
||||
{
|
||||
ircdproto->SendAccountLogout(user, user->nc);
|
||||
user->nc = NULL;
|
||||
FOREACH_MOD(I_OnNickLogout, OnNickLogout(user));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (Hopefully complete) cleanup */
|
||||
cs_remove_nick(this);
|
||||
|
||||
/* Remove the core from the list */
|
||||
if (this->next)
|
||||
this->next->prev = this->prev;
|
||||
if (this->prev)
|
||||
this->prev->next = this->next;
|
||||
else
|
||||
nclists[HASH(this->display)] = this->next;
|
||||
|
||||
/* Log .. */
|
||||
alog("%s: deleting nickname group %s", s_NickServ, this->display);
|
||||
|
||||
/* Now we can safely free it. */
|
||||
delete [] this->display;
|
||||
|
||||
if (this->email)
|
||||
delete [] this->email;
|
||||
if (this->greet)
|
||||
delete [] this->greet;
|
||||
if (this->url)
|
||||
delete [] this->url;
|
||||
|
||||
this->ClearAccess();
|
||||
|
||||
if (!this->memos.memos.empty())
|
||||
{
|
||||
for (unsigned i = 0; i < this->memos.memos.size(); ++i)
|
||||
{
|
||||
if (this->memos.memos[i]->text)
|
||||
delete [] this->memos.memos[i]->text;
|
||||
delete this->memos.memos[i];
|
||||
}
|
||||
this->memos.memos.clear();
|
||||
}
|
||||
}
|
||||
|
||||
bool NickCore::HasCommand(const std::string &cmdstr) const
|
||||
{
|
||||
if (!this->ot)
|
||||
|
||||
+93
-267
@@ -31,124 +31,106 @@ unsigned int guestnum; /* Current guest number */
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
class NickServCollide;
|
||||
class NickServRelease;
|
||||
|
||||
static std::map<NickAlias *, NickServCollide *> NickServCollides;
|
||||
static std::map<NickAlias *, NickServRelease *> NickServReleases;
|
||||
|
||||
class NickServCollide : public Timer
|
||||
NickServCollide::NickServCollide(NickAlias *nickalias, time_t delay) : Timer(delay), na(nickalias)
|
||||
{
|
||||
public:
|
||||
NickAlias *na;
|
||||
std::pair<std::map<NickAlias *, NickServCollide *>::iterator, bool> it;
|
||||
|
||||
NickServCollide(NickAlias *nickalias, time_t delay) : Timer(delay), na(nickalias)
|
||||
/* Erase the current collide and use the new one */
|
||||
std::map<NickAlias *, NickServCollide *>::iterator nit = NickServCollides.find(nickalias);
|
||||
if (nit != NickServCollides.end())
|
||||
{
|
||||
/* Erase the current collide and use the new one */
|
||||
std::map<NickAlias *, NickServCollide *>::iterator nit = NickServCollides.find(nickalias);
|
||||
if (nit != NickServCollides.end())
|
||||
{
|
||||
TimerManager::DelTimer(nit->second);
|
||||
}
|
||||
|
||||
it = NickServCollides.insert(std::make_pair(nickalias, this));
|
||||
TimerManager::DelTimer(nit->second);
|
||||
}
|
||||
|
||||
~NickServCollide()
|
||||
{
|
||||
if (it.second)
|
||||
{
|
||||
NickServCollides.erase(it.first);
|
||||
}
|
||||
}
|
||||
it = NickServCollides.insert(std::make_pair(nickalias, this));
|
||||
}
|
||||
|
||||
void Tick(time_t ctime)
|
||||
{
|
||||
/* If they identified or don't exist anymore, don't kill them. */
|
||||
User *u = finduser(na->nick);
|
||||
if (!u || u->nc == na->nc || u->my_signon > this->GetSetTime())
|
||||
return;
|
||||
|
||||
/* The RELEASE timeout will always add to the beginning of the
|
||||
* list, so we won't see it. Which is fine because it can't be
|
||||
* triggered yet anyway. */
|
||||
collide(na, 1);
|
||||
}
|
||||
|
||||
static void ClearTimers(NickAlias *na)
|
||||
{
|
||||
std::map<NickAlias *, NickServCollide *>::iterator i = NickServCollides.find(na);
|
||||
NickServCollide *t;
|
||||
|
||||
if (i != NickServCollides.end())
|
||||
{
|
||||
t = i->second;
|
||||
|
||||
TimerManager::DelTimer(t);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class NickServRelease : public Timer
|
||||
NickServCollide::~NickServCollide()
|
||||
{
|
||||
public:
|
||||
NickAlias *na;
|
||||
std::string uid;
|
||||
std::pair<std::map<NickAlias *, NickServRelease *>::iterator, bool> it;
|
||||
|
||||
NickServRelease(NickAlias *nickalias, time_t delay) : Timer(delay), na(nickalias)
|
||||
if (it.second)
|
||||
{
|
||||
/* Erase the current release timer and use the new one */
|
||||
std::map<NickAlias *, NickServRelease *>::iterator nit = NickServReleases.find(nickalias);
|
||||
if (nit != NickServReleases.end())
|
||||
{
|
||||
TimerManager::DelTimer(nit->second);
|
||||
}
|
||||
NickServCollides.erase(it.first);
|
||||
}
|
||||
}
|
||||
|
||||
it = NickServReleases.insert(std::make_pair(nickalias, this));
|
||||
void NickServCollide::Tick(time_t ctime)
|
||||
{
|
||||
/* If they identified or don't exist anymore, don't kill them. */
|
||||
User *u = finduser(na->nick);
|
||||
if (!u || u->nc == na->nc || u->my_signon > this->GetSetTime())
|
||||
return;
|
||||
|
||||
/* The RELEASE timeout will always add to the beginning of the
|
||||
* list, so we won't see it. Which is fine because it can't be
|
||||
* triggered yet anyway. */
|
||||
collide(na, 1);
|
||||
}
|
||||
|
||||
void NickServCollide::ClearTimers(NickAlias *na)
|
||||
{
|
||||
std::map<NickAlias *, NickServCollide *>::iterator i = NickServCollides.find(na);
|
||||
NickServCollide *t;
|
||||
|
||||
if (i != NickServCollides.end())
|
||||
{
|
||||
t = i->second;
|
||||
|
||||
TimerManager::DelTimer(t);
|
||||
}
|
||||
}
|
||||
|
||||
NickServRelease::NickServRelease(NickAlias *nickalias, time_t delay) : Timer(delay), na(nickalias)
|
||||
{
|
||||
/* Erase the current release timer and use the new one */
|
||||
std::map<NickAlias *, NickServRelease *>::iterator nit = NickServReleases.find(nickalias);
|
||||
if (nit != NickServReleases.end())
|
||||
{
|
||||
TimerManager::DelTimer(nit->second);
|
||||
}
|
||||
|
||||
~NickServRelease()
|
||||
{
|
||||
if (it.second)
|
||||
{
|
||||
NickServReleases.erase(it.first);
|
||||
}
|
||||
}
|
||||
it = NickServReleases.insert(std::make_pair(nickalias, this));
|
||||
}
|
||||
|
||||
void Tick(time_t ctime)
|
||||
NickServRelease::~NickServRelease()
|
||||
{
|
||||
if (it.second)
|
||||
{
|
||||
if (ircd->svshold)
|
||||
{
|
||||
ircdproto->SendSVSHoldDel(na->nick);
|
||||
}
|
||||
NickServReleases.erase(it.first);
|
||||
}
|
||||
}
|
||||
|
||||
void NickServRelease::Tick(time_t ctime)
|
||||
{
|
||||
if (ircd->svshold)
|
||||
{
|
||||
ircdproto->SendSVSHoldDel(na->nick);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ircd->ts6 && !uid.empty())
|
||||
ircdproto->SendQuit(uid.c_str(), NULL);
|
||||
else
|
||||
{
|
||||
if (ircd->ts6 && !uid.empty())
|
||||
ircdproto->SendQuit(uid.c_str(), NULL);
|
||||
else
|
||||
ircdproto->SendQuit(na->nick, NULL);
|
||||
}
|
||||
na->UnsetFlag(NS_KILL_HELD);
|
||||
ircdproto->SendQuit(na->nick, NULL);
|
||||
}
|
||||
na->UnsetFlag(NS_KILL_HELD);
|
||||
}
|
||||
|
||||
static void ClearTimers(NickAlias *na, bool dorelease = false)
|
||||
void NickServRelease::ClearTimers(NickAlias *na, bool dorelease)
|
||||
{
|
||||
std::map<NickAlias *, NickServRelease *>::iterator i = NickServReleases.find(na);
|
||||
NickServRelease *t;
|
||||
|
||||
if (i != NickServReleases.end())
|
||||
{
|
||||
std::map<NickAlias *, NickServRelease *>::iterator i = NickServReleases.find(na);
|
||||
NickServRelease *t;
|
||||
t = i->second;
|
||||
|
||||
if (i != NickServReleases.end())
|
||||
{
|
||||
t = i->second;
|
||||
if (dorelease)
|
||||
release(na, 1);
|
||||
|
||||
if (dorelease)
|
||||
release(na, 1);
|
||||
|
||||
TimerManager::DelTimer(t);
|
||||
}
|
||||
TimerManager::DelTimer(t);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
/* *INDENT-OFF* */
|
||||
@@ -308,8 +290,12 @@ void load_ns_req_db()
|
||||
{
|
||||
if (c != 1)
|
||||
fatal("Invalid format in %s", PreNickDBName);
|
||||
nr = new NickRequest;
|
||||
SAFE(read_string(&nr->nick, f));
|
||||
|
||||
char *s;
|
||||
SAFE(read_string(&s, f));
|
||||
nr = new NickRequest(s);
|
||||
delete [] s;
|
||||
|
||||
SAFE(read_string(&nr->passcode, f));
|
||||
if (ver < 2)
|
||||
{
|
||||
@@ -365,7 +351,9 @@ void load_ns_dbase()
|
||||
if (c != 1)
|
||||
fatal("Invalid format in %s", NickDBName);
|
||||
|
||||
nc = new NickCore();
|
||||
SAFE(read_string(&s, f));
|
||||
nc = new NickCore(s);
|
||||
delete [] s;
|
||||
*nclast = nc;
|
||||
nclast = &nc->next;
|
||||
nc->prev = ncprev;
|
||||
@@ -373,7 +361,6 @@ void load_ns_dbase()
|
||||
|
||||
slist_init(&nc->aliases);
|
||||
|
||||
SAFE(read_string(&nc->display, f));
|
||||
SAFE(read_buffer(nc->pass, f));
|
||||
|
||||
SAFE(read_string(&nc->email, f));
|
||||
@@ -438,9 +425,9 @@ void load_ns_dbase()
|
||||
if (c != 1)
|
||||
fatal("Invalid format in %s", NickDBName);
|
||||
|
||||
na = new NickAlias();
|
||||
|
||||
SAFE(read_string(&na->nick, f));
|
||||
SAFE(read_string(&s, f));
|
||||
na = new NickAlias(s, nclists[0]); // XXXXXXXX
|
||||
delete [] s;
|
||||
|
||||
SAFE(read_string(&na->last_usermask, f));
|
||||
SAFE(read_string(&na->last_realname, f));
|
||||
@@ -491,7 +478,7 @@ void load_ns_dbase()
|
||||
if (!na->nc)
|
||||
{
|
||||
alog("%s: while loading database: %s has no core! We delete it.", s_NickServ, na->nick);
|
||||
delnick(na);
|
||||
delete na;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -810,7 +797,7 @@ void expire_nicks()
|
||||
na->nick, na->nc->display,
|
||||
(na->nc->email ? na->nc->email : "none"));
|
||||
tmpnick = sstrdup(na->nick);
|
||||
delnick(na);
|
||||
delete na;
|
||||
FOREACH_MOD(I_OnNickExpire, OnNickExpire(tmpnick));
|
||||
delete [] tmpnick;
|
||||
}
|
||||
@@ -831,7 +818,7 @@ void expire_requests()
|
||||
if (NSRExpire && now - nr->requested >= NSRExpire)
|
||||
{
|
||||
alog("Request for nick %s expiring", nr->nick);
|
||||
delnickrequest(nr);
|
||||
delete nr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1128,167 +1115,6 @@ void change_core_display(NickCore * nc)
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Deletes the core. This must be called only when there is no more
|
||||
* aliases for it, because no cleanup is done.
|
||||
* This function removes all references to the core as well.
|
||||
*/
|
||||
|
||||
static int delcore(NickCore * nc)
|
||||
{
|
||||
unsigned i;
|
||||
User *user;
|
||||
|
||||
FOREACH_MOD(I_OnDelCore, OnDelCore(nc));
|
||||
|
||||
/* Clean up this nick core from any users online using it
|
||||
* (ones that /nick but remain unidentified)
|
||||
*/
|
||||
for (i = 0; i < 1024; ++i)
|
||||
{
|
||||
for (user = userlist[i]; user; user = user->next)
|
||||
{
|
||||
if (user->nc && user->nc == nc)
|
||||
{
|
||||
ircdproto->SendAccountLogout(user, user->nc);
|
||||
user->nc = NULL;
|
||||
FOREACH_MOD(I_OnNickLogout, OnNickLogout(user));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (Hopefully complete) cleanup */
|
||||
cs_remove_nick(nc);
|
||||
|
||||
/* Remove the core from the list */
|
||||
if (nc->next)
|
||||
nc->next->prev = nc->prev;
|
||||
if (nc->prev)
|
||||
nc->prev->next = nc->next;
|
||||
else
|
||||
nclists[HASH(nc->display)] = nc->next;
|
||||
|
||||
/* Log .. */
|
||||
alog("%s: deleting nickname group %s", s_NickServ, nc->display);
|
||||
|
||||
/* Now we can safely free it. */
|
||||
delete [] nc->display;
|
||||
|
||||
if (nc->email)
|
||||
delete [] nc->email;
|
||||
if (nc->greet)
|
||||
delete [] nc->greet;
|
||||
if (nc->url)
|
||||
delete [] nc->url;
|
||||
|
||||
nc->ClearAccess();
|
||||
|
||||
if (!nc->memos.memos.empty())
|
||||
{
|
||||
for (i = 0; i < nc->memos.memos.size(); ++i)
|
||||
{
|
||||
if (nc->memos.memos[i]->text)
|
||||
delete [] nc->memos.memos[i]->text;
|
||||
delete nc->memos.memos[i];
|
||||
}
|
||||
nc->memos.memos.clear();
|
||||
}
|
||||
|
||||
delete nc;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
int delnickrequest(NickRequest * nr)
|
||||
{
|
||||
if (nr)
|
||||
{
|
||||
FOREACH_MOD(I_OnDelNickRequest, OnDelNickRequest(nr));
|
||||
nrlists[HASH(nr->nick)] = nr->next;
|
||||
if (nr->nick)
|
||||
delete [] nr->nick;
|
||||
if (nr->passcode)
|
||||
delete [] nr->passcode;
|
||||
if (nr->email)
|
||||
delete [] nr->email;
|
||||
delete nr;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Deletes an alias. The core will also be deleted if it has no more
|
||||
* nicks attached to it. Easy but powerful.
|
||||
* Well, we must also take care that the nick being deleted is not
|
||||
* the core display, and if so, change it to the next alias in the list,
|
||||
* otherwise weird things will happen.
|
||||
* Returns 1 on success, 0 otherwise.
|
||||
*/
|
||||
|
||||
int delnick(NickAlias * na)
|
||||
{
|
||||
User *u = NULL;
|
||||
/* First thing to do: remove any timeout belonging to the nick we're deleting */
|
||||
NickServCollide::ClearTimers(na);
|
||||
NickServRelease::ClearTimers(na, true);
|
||||
|
||||
FOREACH_MOD(I_OnDelNick, OnDelNick(na));
|
||||
|
||||
/* Second thing to do: look for an user using the alias
|
||||
* being deleted, and make appropriate changes */
|
||||
if ((u = finduser(na->nick)))
|
||||
{
|
||||
if (ircd->modeonunreg)
|
||||
common_svsmode(finduser(na->nick), ircd->modeonunreg, "1");
|
||||
u->nc = NULL;
|
||||
}
|
||||
|
||||
delHostCore(na->nick); /* delete any vHost's for this nick */
|
||||
|
||||
/* Accept nicks that have no core, because of database load functions */
|
||||
if (na->nc)
|
||||
{
|
||||
/* Next: see if our core is still useful. */
|
||||
slist_remove(&na->nc->aliases, na);
|
||||
if (na->nc->aliases.count == 0)
|
||||
{
|
||||
if (!delcore(na->nc))
|
||||
return 0;
|
||||
na->nc = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Display updating stuff */
|
||||
if (!stricmp(na->nick, na->nc->display))
|
||||
change_core_display(na->nc);
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove us from the aliases list */
|
||||
if (na->next)
|
||||
na->next->prev = na->prev;
|
||||
if (na->prev)
|
||||
na->prev->next = na->next;
|
||||
else
|
||||
nalists[HASH(na->nick)] = na->next;
|
||||
|
||||
delete [] na->nick;
|
||||
if (na->last_usermask)
|
||||
delete [] na->last_usermask;
|
||||
if (na->last_realname)
|
||||
delete [] na->last_realname;
|
||||
if (na->last_quit)
|
||||
delete [] na->last_quit;
|
||||
|
||||
delete na;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
/* Collide a nick.
|
||||
*
|
||||
* When connected to a network using DALnet servers, version 4.4.15 and above,
|
||||
|
||||
+90
-3
@@ -13,9 +13,16 @@
|
||||
*/
|
||||
|
||||
#include "services.h"
|
||||
#include "modules.h"
|
||||
|
||||
ChannelInfo::ChannelInfo()
|
||||
/** Default constructor
|
||||
* @param chname The channel name
|
||||
*/
|
||||
ChannelInfo::ChannelInfo(const std::string &chname)
|
||||
{
|
||||
if (chname.empty())
|
||||
throw CoreException("Empty channel passed to ChannelInfo constructor");
|
||||
|
||||
next = prev = NULL;
|
||||
name[0] = last_topic_setter[0] = '\0';
|
||||
founder = successor = NULL;
|
||||
@@ -24,14 +31,14 @@ ChannelInfo::ChannelInfo()
|
||||
levels = NULL;
|
||||
entry_message = NULL;
|
||||
c = NULL;
|
||||
bi = NULL;
|
||||
ttb = NULL;
|
||||
bwcount = 0;
|
||||
badwords = NULL;
|
||||
capsmin = capspercent = 0;
|
||||
floodlines = floodsecs = 0;
|
||||
repeattimes = 0;
|
||||
|
||||
strscpy(this->name, chname.c_str(), CHANMAX);
|
||||
|
||||
/* If ircd doesn't exist, this is from DB load and mlock is set later */
|
||||
if (ircd)
|
||||
mlock_on = ircd->DefMLock;
|
||||
@@ -50,6 +57,86 @@ ChannelInfo::ChannelInfo()
|
||||
bantype = CSDefBantype;
|
||||
memos.memomax = MSMaxMemos;
|
||||
last_used = time_registered = time(NULL);
|
||||
|
||||
this->ttb = new int16[2 * TTB_SIZE];
|
||||
for (int i = 0; i < TTB_SIZE; i++)
|
||||
this->ttb[i] = 0;
|
||||
|
||||
reset_levels(this);
|
||||
alpha_insert_chan(this);
|
||||
}
|
||||
|
||||
/** Default destructor, cleans up the channel complete and removes it from the internal list
|
||||
*/
|
||||
ChannelInfo::~ChannelInfo()
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
FOREACH_MOD(I_OnDelChan, OnDelChan(this));
|
||||
|
||||
if (debug)
|
||||
alog("debug: Deleting channel %s", this->name);
|
||||
|
||||
if (this->bi)
|
||||
this->bi->chancount--;
|
||||
|
||||
if (this->c)
|
||||
{
|
||||
if (this->bi && this->c->usercount >= BSMinUsers)
|
||||
ircdproto->SendPart(this->bi, this->c->name, NULL);
|
||||
this->c->ci = NULL;
|
||||
}
|
||||
|
||||
if (this->next)
|
||||
this->next->prev = this->prev;
|
||||
if (this->prev)
|
||||
this->prev->next = this->next;
|
||||
else
|
||||
chanlists[static_cast<unsigned char>(tolower(this->name[1]))] = this->next;
|
||||
if (this->desc)
|
||||
delete [] this->desc;
|
||||
if (this->url)
|
||||
delete [] this->url;
|
||||
if (this->email)
|
||||
delete [] this->email;
|
||||
if (this->entry_message)
|
||||
delete [] this->entry_message;
|
||||
|
||||
if (this->last_topic)
|
||||
delete [] this->last_topic;
|
||||
if (this->forbidby)
|
||||
delete [] this->forbidby;
|
||||
if (this->forbidreason)
|
||||
delete [] this->forbidreason;
|
||||
this->ClearAkick();
|
||||
if (this->levels)
|
||||
delete [] this->levels;
|
||||
|
||||
if (!this->memos.memos.empty())
|
||||
{
|
||||
for (i = 0; i < this->memos.memos.size(); ++i)
|
||||
{
|
||||
if (this->memos.memos[i]->text)
|
||||
delete [] this->memos.memos[i]->text;
|
||||
delete this->memos.memos[i];
|
||||
}
|
||||
this->memos.memos.clear();
|
||||
}
|
||||
|
||||
if (this->ttb)
|
||||
delete [] this->ttb;
|
||||
|
||||
for (i = 0; i < this->bwcount; i++)
|
||||
{
|
||||
if (this->badwords[i].word)
|
||||
delete [] this->badwords[i].word;
|
||||
}
|
||||
|
||||
if (this->badwords)
|
||||
free(this->badwords);
|
||||
|
||||
if (this->founder)
|
||||
this->founder->channelcount--;
|
||||
}
|
||||
|
||||
/** Add an entry to the channel access list
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "timers.h"
|
||||
#include "services.h"
|
||||
|
||||
std::vector<Timer *> TimerManager::Timers;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user