mirror of
https://github.com/anope/anope.git
synced 2026-06-29 07:56:39 +02:00
Fixed bug #1187 - Fixed releasing enforcer clients on TS6 IRCds
This commit is contained in:
@@ -224,4 +224,51 @@ class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END
|
||||
void ClearAccess();
|
||||
};
|
||||
|
||||
/** Timer for colliding nicks to force people off of nicknames
|
||||
*/
|
||||
class NickServCollide : public Timer
|
||||
{
|
||||
dynamic_reference<User> u;
|
||||
Anope::string nick;
|
||||
|
||||
public:
|
||||
/** Default constructor
|
||||
* @param nick The nick we're colliding
|
||||
* @param delay How long to delay before kicking the user off the nick
|
||||
*/
|
||||
NickServCollide(User *user, time_t delay);
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
virtual ~NickServCollide();
|
||||
|
||||
/** Called when the delay is up
|
||||
* @param t The current time
|
||||
*/
|
||||
void Tick(time_t t);
|
||||
};
|
||||
|
||||
/** Timers for releasing nicks to be available for use
|
||||
*/
|
||||
class NickServRelease : public User, public Timer
|
||||
{
|
||||
Anope::string nick;
|
||||
|
||||
public:
|
||||
/** Default constructor
|
||||
* @param na The nick
|
||||
* @param delay The delay before the nick is released
|
||||
*/
|
||||
NickServRelease(NickAlias *na, time_t delay);
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
virtual ~NickServRelease();
|
||||
|
||||
/** Called when the delay is up
|
||||
* @param t The current time
|
||||
*/
|
||||
void Tick(time_t t);
|
||||
};
|
||||
|
||||
#endif // ACCOUNT_H
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include "hashcomp.h"
|
||||
|
||||
struct Message;
|
||||
@@ -396,4 +397,81 @@ class spacesepstream : public sepstream
|
||||
spacesepstream(const Anope::string &source) : sepstream(source, ' ') { }
|
||||
};
|
||||
|
||||
/** The base class that most classes in Anope inherit from
|
||||
*/
|
||||
class dynamic_reference_base;
|
||||
class CoreExport Base
|
||||
{
|
||||
/* References to this base class */
|
||||
std::set<dynamic_reference_base *> References;
|
||||
public:
|
||||
Base();
|
||||
virtual ~Base();
|
||||
void AddReference(dynamic_reference_base *r);
|
||||
void DelReference(dynamic_reference_base *r);
|
||||
};
|
||||
|
||||
class dynamic_reference_base : public virtual Base
|
||||
{
|
||||
protected:
|
||||
bool invalid;
|
||||
public:
|
||||
dynamic_reference_base() : invalid(false) { }
|
||||
virtual ~dynamic_reference_base() { }
|
||||
inline void Invalidate() { this->invalid = true; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class dynamic_reference : public dynamic_reference_base
|
||||
{
|
||||
protected:
|
||||
T *ref;
|
||||
public:
|
||||
dynamic_reference(T *obj) : ref(obj)
|
||||
{
|
||||
if (ref)
|
||||
ref->AddReference(this);
|
||||
}
|
||||
|
||||
virtual ~dynamic_reference()
|
||||
{
|
||||
if (this->invalid)
|
||||
{
|
||||
this->invalid = false;
|
||||
this->ref = NULL;
|
||||
}
|
||||
else if (ref)
|
||||
ref->DelReference(this);
|
||||
}
|
||||
|
||||
virtual operator bool()
|
||||
{
|
||||
if (this->invalid)
|
||||
{
|
||||
this->invalid = false;
|
||||
this->ref = NULL;
|
||||
}
|
||||
return this->ref;
|
||||
}
|
||||
|
||||
virtual inline void operator=(T *newref)
|
||||
{
|
||||
if (this->invalid)
|
||||
{
|
||||
this->invalid = false;
|
||||
this->ref = NULL;
|
||||
}
|
||||
else if (this->ref)
|
||||
this->ref->DelReference(this);
|
||||
this->ref = newref;
|
||||
if (this->ref)
|
||||
this->ref->AddReference(this);
|
||||
}
|
||||
|
||||
virtual inline T *operator->()
|
||||
{
|
||||
return this->ref;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // ANOPE_H
|
||||
|
||||
@@ -265,8 +265,6 @@ E uint32 getrandom32();
|
||||
|
||||
E char *str_signed(unsigned char *str);
|
||||
|
||||
E void ntoa(struct in_addr addr, char *ipaddr, int len);
|
||||
|
||||
E std::list<Anope::string> BuildStringList(const Anope::string &, char = ' ');
|
||||
E std::vector<Anope::string> BuildStringVector(const Anope::string &, char = ' ');
|
||||
|
||||
|
||||
@@ -1261,69 +1261,6 @@ class Service : public virtual Base
|
||||
virtual ~Service();
|
||||
};
|
||||
|
||||
class dynamic_reference_base : public virtual Base
|
||||
{
|
||||
protected:
|
||||
bool invalid;
|
||||
public:
|
||||
dynamic_reference_base() : invalid(false) { }
|
||||
virtual ~dynamic_reference_base() { }
|
||||
inline void Invalidate() { this->invalid = true; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class dynamic_reference : public dynamic_reference_base
|
||||
{
|
||||
protected:
|
||||
T *ref;
|
||||
public:
|
||||
dynamic_reference(T *obj) : ref(obj)
|
||||
{
|
||||
if (ref)
|
||||
ref->AddReference(this);
|
||||
}
|
||||
|
||||
virtual ~dynamic_reference()
|
||||
{
|
||||
if (this->invalid)
|
||||
{
|
||||
this->invalid = false;
|
||||
this->ref = NULL;
|
||||
}
|
||||
else if (ref)
|
||||
ref->DelReference(this);
|
||||
}
|
||||
|
||||
virtual operator bool()
|
||||
{
|
||||
if (this->invalid)
|
||||
{
|
||||
this->invalid = false;
|
||||
this->ref = NULL;
|
||||
}
|
||||
return this->ref;
|
||||
}
|
||||
|
||||
virtual inline void operator=(T *newref)
|
||||
{
|
||||
if (this->invalid)
|
||||
{
|
||||
this->invalid = false;
|
||||
this->ref = NULL;
|
||||
}
|
||||
else if (this->ref)
|
||||
this->ref->DelReference(this);
|
||||
this->ref = newref;
|
||||
if (this->ref)
|
||||
this->ref->AddReference(this);
|
||||
}
|
||||
|
||||
virtual inline T *operator->()
|
||||
{
|
||||
return this->ref;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class service_reference : public dynamic_reference<T>
|
||||
{
|
||||
|
||||
+7
-81
@@ -194,21 +194,6 @@ extern "C" void __pfnBkCheck() {}
|
||||
|
||||
#include "anope.h"
|
||||
|
||||
class dynamic_reference_base;
|
||||
|
||||
/** The base class that most classes in Anope inherit from
|
||||
*/
|
||||
class CoreExport Base
|
||||
{
|
||||
/* References to this base class */
|
||||
std::set<dynamic_reference_base *> References;
|
||||
public:
|
||||
Base();
|
||||
virtual ~Base();
|
||||
void AddReference(dynamic_reference_base *r);
|
||||
void DelReference(dynamic_reference_base *r);
|
||||
};
|
||||
|
||||
/** This class can be used on its own to represent an exception, or derived to represent a module-specific exception.
|
||||
* When a module whishes to abort, e.g. within a constructor, it should throw an exception using ModuleException or
|
||||
* a class derived from ModuleException. If a module throws an exception during its constructor, the module will not
|
||||
@@ -423,6 +408,9 @@ template<typename T> inline T convertTo(const Anope::string &s, bool failIfLefto
|
||||
/*************************************************************************/
|
||||
|
||||
class User;
|
||||
class NickCore;
|
||||
class NickAlias;
|
||||
class NickRequest;
|
||||
class BotInfo;
|
||||
class ChannelInfo;
|
||||
class Channel;
|
||||
@@ -553,11 +541,6 @@ class CoreExport HostInfo
|
||||
const time_t GetTime() const;
|
||||
};
|
||||
|
||||
// For NickServ
|
||||
#include "account.h"
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
enum AccessLevel
|
||||
{
|
||||
/* Note that these two levels also serve as exclusive boundaries for valid
|
||||
@@ -755,6 +738,7 @@ struct LevelInfo
|
||||
*/
|
||||
|
||||
#include "users.h"
|
||||
#include "account.h"
|
||||
#include "bots.h"
|
||||
|
||||
struct BanData
|
||||
@@ -956,7 +940,7 @@ class CoreExport IRCDProto
|
||||
virtual void SendMessageInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf);
|
||||
virtual void SendNoticeInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &msg);
|
||||
virtual void SendPrivmsgInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf);
|
||||
virtual void SendQuitInternal(const BotInfo *bi, const Anope::string &buf);
|
||||
virtual void SendQuitInternal(const User *u, const Anope::string &buf);
|
||||
virtual void SendPartInternal(const BotInfo *bi, const Channel *chan, const Anope::string &buf);
|
||||
virtual void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf);
|
||||
virtual void SendCTCPInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf);
|
||||
@@ -973,7 +957,7 @@ class CoreExport IRCDProto
|
||||
virtual void SendSVSMode(const User *, int, const char **) = 0;
|
||||
virtual void SendMode(const BotInfo *bi, const Channel *dest, const char *fmt, ...);
|
||||
virtual void SendMode(const BotInfo *bi, const User *u, const char *fmt, ...);
|
||||
virtual void SendClientIntroduction(const Anope::string &, const Anope::string &, const Anope::string &, const Anope::string &, const Anope::string &, const Anope::string &uid) = 0;
|
||||
virtual void SendClientIntroduction(const User *u, const Anope::string &) = 0;
|
||||
virtual void SendKick(const BotInfo *bi, const Channel *chan, const User *user, const char *fmt, ...);
|
||||
virtual void SendNoticeChanops(const BotInfo *bi, const Channel *dest, const char *fmt, ...);
|
||||
virtual void SendMessage(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
|
||||
@@ -983,13 +967,7 @@ class CoreExport IRCDProto
|
||||
virtual void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg);
|
||||
virtual void SendGlobalPrivmsg(const BotInfo *bi, const Server *desc, const Anope::string &msg);
|
||||
|
||||
/** XXX: This is a hack for NickServ enforcers. It is deprecated.
|
||||
* If I catch any developer using this in new code, I will RIP YOUR BALLS OFF.
|
||||
* Thanks.
|
||||
* -- w00t
|
||||
*/
|
||||
virtual void SendQuit(const Anope::string &nick, const Anope::string &) MARK_DEPRECATED;
|
||||
virtual void SendQuit(const BotInfo *bi, const char *fmt, ...);
|
||||
virtual void SendQuit(const User *u, const char *fmt, ...);
|
||||
virtual void SendPing(const Anope::string &servname, const Anope::string &who);
|
||||
virtual void SendPong(const Anope::string &servname, const Anope::string &who);
|
||||
virtual void SendJoin(const BotInfo *, const Anope::string &, time_t) = 0;
|
||||
@@ -1055,58 +1033,6 @@ struct Uplink
|
||||
Uplink(const Anope::string &_host, int _port, const Anope::string &_password, bool _ipv6) : host(_host), port(_port), password(_password), ipv6(_ipv6) { }
|
||||
};
|
||||
|
||||
/** Timer for colliding nicks to force people off of nicknames
|
||||
*/
|
||||
class NickServCollide : public Timer
|
||||
{
|
||||
/* The nick */
|
||||
Anope::string nick;
|
||||
|
||||
public:
|
||||
/** Default constructor
|
||||
* @param _nick The nick were colliding
|
||||
* @param delay How long to delay before kicking the user off the nick
|
||||
*/
|
||||
NickServCollide(const Anope::string &_nick, time_t delay);
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
virtual ~NickServCollide();
|
||||
|
||||
/** Called when the delay is up
|
||||
* @param t The current time
|
||||
*/
|
||||
void Tick(time_t t);
|
||||
};
|
||||
|
||||
/** Timers for releasing nicks to be available for use
|
||||
*/
|
||||
class NickServRelease : public Timer
|
||||
{
|
||||
/* The nick */
|
||||
Anope::string nick;
|
||||
|
||||
public:
|
||||
/* The uid of the services enforcer client (used for TS6 ircds) */
|
||||
Anope::string uid;
|
||||
|
||||
/** Default constructor
|
||||
* @param _nick The nick
|
||||
* @param _uid the uid of the enforcer, if any
|
||||
* @param delay The delay before the nick is released
|
||||
*/
|
||||
NickServRelease(const Anope::string &_nick, const Anope::string &_uid, time_t delay);
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
virtual ~NickServRelease();
|
||||
|
||||
/** Called when the delay is up
|
||||
* @param t The current time
|
||||
*/
|
||||
void Tick(time_t t);
|
||||
};
|
||||
|
||||
/** A timer used to keep the BotServ bot/ChanServ in the channel
|
||||
* after kicking the last user in a channel
|
||||
*/
|
||||
|
||||
@@ -256,7 +256,7 @@ class CommandBSBot : public Command
|
||||
|
||||
if (!user.empty())
|
||||
{
|
||||
ircdproto->SendClientIntroduction(bi->nick, bi->GetIdent(), bi->host, bi->realname, ircd->pseudoclient_mode, bi->GetUID());
|
||||
ircdproto->SendClientIntroduction(bi, ircd->pseudoclient_mode);
|
||||
XLine x(bi->nick, "Reserved for services");
|
||||
ircdproto->SendSQLine(&x);
|
||||
bi->RejoinAll();
|
||||
|
||||
@@ -54,6 +54,9 @@ class ModuleDNSBL : public Module
|
||||
public:
|
||||
ModuleDNSBL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
this->SetType(SUPPORTED);
|
||||
|
||||
OnReload(false);
|
||||
|
||||
Implementation i[] = { I_OnReload, I_OnPreUserConnect };
|
||||
|
||||
@@ -258,10 +258,10 @@ class BahamutIRCdProto : public IRCDProto
|
||||
send_cmd(source->nick, "KICK %s %s", chan->name.c_str(), user->nick.c_str());
|
||||
}
|
||||
|
||||
void SendClientIntroduction(const Anope::string &nick, const Anope::string &user, const Anope::string &host, const Anope::string &real, const Anope::string &modes, const Anope::string &)
|
||||
void SendClientIntroduction(const User *u, const Anope::string &modes)
|
||||
{
|
||||
EnforceQlinedNick(nick, Config->s_BotServ);
|
||||
send_cmd("", "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick.c_str(), static_cast<long>(time(NULL)), modes.c_str(), user.c_str(), host.c_str(), Config->ServerName.c_str(), real.c_str());
|
||||
EnforceQlinedNick(u->nick, Config->s_BotServ);
|
||||
send_cmd("", "NICK %s 1 %ld %s %s %s %s 0 0 :%s", u->nick.c_str(), u->timestamp, modes.c_str(), u->GetIdent().c_str(), u->host.c_str(), u->server->GetName().c_str(), u->realname.c_str());
|
||||
}
|
||||
|
||||
/* SVSMODE +d */
|
||||
|
||||
@@ -146,10 +146,10 @@ class InspIRCdProto : public IRCDProto
|
||||
send_cmd(bi ? bi->nick : Config->ServerName, "MODE %s %s", u->nick.c_str(), buf.c_str());
|
||||
}
|
||||
|
||||
void SendClientIntroduction(const Anope::string &nick, const Anope::string &user, const Anope::string &host, const Anope::string &real, const Anope::string &modes, const Anope::string &)
|
||||
void SendClientIntroduction(const User *u, const Anope::string &modes)
|
||||
{
|
||||
send_cmd(Config->ServerName, "NICK %ld %s %s %s %s %s 0.0.0.0 :%s", static_cast<long>(time(NULL)), nick.c_str(), host.c_str(), host.c_str(), user.c_str(), modes.c_str(), real.c_str());
|
||||
send_cmd(nick, "OPERTYPE Service");
|
||||
send_cmd(Config->ServerName, "NICK %ld %s %s %s %s %s 0.0.0.0 :%s", u->timestamp, u->nick.c_str(), u->host.c_str(), u->host.c_str(), u->GetIdent().c_str(), modes.c_str(), u->realname.c_str());
|
||||
send_cmd(u->nick, "OPERTYPE Service");
|
||||
}
|
||||
|
||||
void SendKickInternal(const BotInfo *source, const Channel *chan, const User *user, const Anope::string &buf)
|
||||
|
||||
@@ -75,10 +75,8 @@ void inspircd_cmd_chghost(const Anope::string &nick, const Anope::string &vhost)
|
||||
int anope_event_idle(const Anope::string &source, int ac, const char **av)
|
||||
{
|
||||
BotInfo *bi = findbot(av[0]);
|
||||
if (!bi)
|
||||
return MOD_CONT;
|
||||
|
||||
send_cmd(bi->GetUID(), "IDLE %s %ld %ld", source.c_str(), static_cast<long>(start_time), static_cast<long>(time(NULL) - bi->lastmsg));
|
||||
send_cmd(bi ? bi->GetUID() : av[0], "IDLE %s %ld %ld", source.c_str(), static_cast<long>(start_time), bi ? (static_cast<long>(time(NULL) - bi->lastmsg)) : 0);
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
@@ -149,9 +147,9 @@ class InspIRCdProto : public IRCDProto
|
||||
send_cmd(bi ? bi->GetUID() : TS6SID, "MODE %s %s", u->GetUID().c_str(), buf.c_str());
|
||||
}
|
||||
|
||||
void SendClientIntroduction(const Anope::string &nick, const Anope::string &user, const Anope::string &host, const Anope::string &real, const Anope::string &modes, const Anope::string &uid)
|
||||
void SendClientIntroduction(const User *u, const Anope::string &modes)
|
||||
{
|
||||
send_cmd(TS6SID, "UID %s %ld %s %s %s %s 0.0.0.0 %ld %s :%s", uid.c_str(), static_cast<long>(time(NULL)), nick.c_str(), host.c_str(), host.c_str(), user.c_str(), static_cast<long>(time(NULL)), modes.c_str(), real.c_str());
|
||||
send_cmd(TS6SID, "UID %s %ld %s %s %s %s 0.0.0.0 %ld %s :%s", u->GetUID().c_str(), u->timestamp, u->nick.c_str(), u->host.c_str(), u->host.c_str(), u->GetIdent().c_str(), u->my_signon, modes.c_str(), u->realname.c_str());
|
||||
}
|
||||
|
||||
void SendKickInternal(const BotInfo *source, const Channel *chan, const User *user, const Anope::string &buf)
|
||||
|
||||
@@ -73,10 +73,8 @@ void inspircd_cmd_chghost(const Anope::string &nick, const Anope::string &vhost)
|
||||
int anope_event_idle(const Anope::string &source, int ac, const char **av)
|
||||
{
|
||||
BotInfo *bi = findbot(av[0]);
|
||||
if (!bi)
|
||||
return MOD_CONT;
|
||||
|
||||
send_cmd(bi->GetUID(), "IDLE %s %ld %ld", source.c_str(), static_cast<long>(start_time), static_cast<long>(time(NULL) - bi->lastmsg));
|
||||
send_cmd(bi ? bi->GetUID() : av[0], "IDLE %s %ld %ld", source.c_str(), static_cast<long>(start_time), bi ? (static_cast<long>(time(NULL) - bi->lastmsg)) : 0);
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
@@ -147,9 +145,9 @@ class InspIRCdProto : public IRCDProto
|
||||
send_cmd(bi ? bi->GetUID() : TS6SID, "MODE %s %s", u->GetUID().c_str(), buf.c_str());
|
||||
}
|
||||
|
||||
void SendClientIntroduction(const Anope::string &nick, const Anope::string &user, const Anope::string &host, const Anope::string &real, const Anope::string &modes, const Anope::string &uid)
|
||||
void SendClientIntroduction(const User *u, const Anope::string &modes)
|
||||
{
|
||||
send_cmd(TS6SID, "UID %s %ld %s %s %s %s 0.0.0.0 %ld %s :%s", uid.c_str(), static_cast<long>(time(NULL)), nick.c_str(), host.c_str(), host.c_str(), user.c_str(), static_cast<long>(time(NULL)), modes.c_str(), real.c_str());
|
||||
send_cmd(TS6SID, "UID %s %ld %s %s %s %s 0.0.0.0 %ld %s :%s", u->GetUID().c_str(), u->timestamp, u->nick.c_str(), u->host.c_str(), u->host.c_str(), u->GetIdent().c_str(), u->my_signon, modes.c_str(), u->realname.c_str());
|
||||
}
|
||||
|
||||
void SendKickInternal(const BotInfo *source, const Channel *chan, const User *user, const Anope::string &buf)
|
||||
|
||||
@@ -175,10 +175,10 @@ class RatboxProto : public IRCDProto
|
||||
ratbox_cmd_svinfo();
|
||||
}
|
||||
|
||||
void SendClientIntroduction(const Anope::string &nick, const Anope::string &user, const Anope::string &host, const Anope::string &real, const Anope::string &modes, const Anope::string &uid)
|
||||
void SendClientIntroduction(const User *u, const Anope::string &modes)
|
||||
{
|
||||
EnforceQlinedNick(nick, "");
|
||||
send_cmd(TS6SID, "UID %s 1 %ld %s %s %s 0 %s :%s", nick.c_str(), static_cast<long>(time(NULL)), modes.c_str(), user.c_str(), host.c_str(), uid.c_str(), real.c_str());
|
||||
EnforceQlinedNick(u->nick, "");
|
||||
send_cmd(TS6SID, "UID %s 1 %ld %s %s %s 0 %s :%s", u->nick.c_str(), u->timestamp, modes.c_str(), u->GetIdent().c_str(), u->host.c_str(), u->GetUID().c_str(), u->realname.c_str());
|
||||
}
|
||||
|
||||
void SendPartInternal(const BotInfo *bi, const Channel *chan, const Anope::string &buf)
|
||||
@@ -223,15 +223,6 @@ class RatboxProto : public IRCDProto
|
||||
send_cmd("", "NOTICE @%s :%s", dest->name.c_str(), buf.c_str());
|
||||
}
|
||||
|
||||
/* QUIT */
|
||||
void SendQuitInternal(BotInfo *bi, const Anope::string &buf)
|
||||
{
|
||||
if (!buf.empty())
|
||||
send_cmd(bi->GetUID(), "QUIT :%s", buf.c_str());
|
||||
else
|
||||
send_cmd(bi->GetUID(), "QUIT");
|
||||
}
|
||||
|
||||
/* INVITE */
|
||||
void SendInvite(BotInfo *source, const Anope::string &chan, const Anope::string &nick)
|
||||
{
|
||||
|
||||
@@ -171,10 +171,10 @@ class UnrealIRCdProto : public IRCDProto
|
||||
send_cmd(bi ? bi->nick : Config->ServerName, "v %s %s", u->nick.c_str(), buf.c_str());
|
||||
}
|
||||
|
||||
void SendClientIntroduction(const Anope::string &nick, const Anope::string &user, const Anope::string &host, const Anope::string &real, const Anope::string &modes, const Anope::string &)
|
||||
void SendClientIntroduction(const User *u, const Anope::string &modes)
|
||||
{
|
||||
EnforceQlinedNick(nick, Config->ServerName);
|
||||
send_cmd("", "& %s 1 %ld %s %s %s 0 %s %s * :%s", nick.c_str(), static_cast<long>(time(NULL)), user.c_str(), host.c_str(), Config->ServerName.c_str(), modes.c_str(), host.c_str(), real.c_str());
|
||||
EnforceQlinedNick(u->nick, Config->ServerName);
|
||||
send_cmd("", "& %s 1 %ld %s %s %s 0 %s %s * :%s", u->nick.c_str(), u->timestamp, u->GetIdent().c_str(), u->host.c_str(), Config->ServerName.c_str(), modes.c_str(), u->host.c_str(), u->realname.c_str());
|
||||
}
|
||||
|
||||
void SendKickInternal(const BotInfo *source, const Channel *chan, const User *user, const Anope::string &buf)
|
||||
|
||||
+2
-2
@@ -51,9 +51,9 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A
|
||||
BotListByUID[this->uid] = this;
|
||||
|
||||
// If we're synchronised with the uplink already, send the bot.
|
||||
if (Me && !Me->GetLinks().empty() && Me->GetLinks().front()->IsSynced())
|
||||
if (Me && Me->IsSynced())
|
||||
{
|
||||
ircdproto->SendClientIntroduction(this->nick, this->GetIdent(), this->host, this->realname, ircd->pseudoclient_mode, this->uid);
|
||||
ircdproto->SendClientIntroduction(this, ircd->pseudoclient_mode);
|
||||
XLine x(this->nick, "Reserved for services");
|
||||
ircdproto->SendSQLine(&x);
|
||||
}
|
||||
|
||||
+13
-8
@@ -42,19 +42,24 @@ void introduce_user(const Anope::string &user)
|
||||
}
|
||||
|
||||
/* We make the bots go online */
|
||||
for (botinfo_map::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
|
||||
for (user_map::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ++it)
|
||||
{
|
||||
BotInfo *bi = it->second;
|
||||
User *u = it->second;
|
||||
|
||||
if (user.empty() || bi->nick.equals_ci(user))
|
||||
if (user.empty() || u->nick.equals_ci(user))
|
||||
{
|
||||
ircdproto->SendClientIntroduction(bi->nick, bi->GetIdent(), bi->host, bi->realname, ircd->pseudoclient_mode, bi->GetUID());
|
||||
XLine x(bi->nick, "Reserved for services");
|
||||
ircdproto->SendSQLine(&x);
|
||||
ircdproto->SendClientIntroduction(u, ircd->pseudoclient_mode);
|
||||
|
||||
for (UChannelList::const_iterator cit = bi->chans.begin(), cit_end = bi->chans.end(); cit != cit_end; ++cit)
|
||||
BotInfo *bi = findbot(u->nick);
|
||||
if (bi)
|
||||
{
|
||||
ircdproto->SendJoin(bi, *cit);
|
||||
XLine x(bi->nick, "Reserved for services");
|
||||
ircdproto->SendSQLine(&x);
|
||||
|
||||
for (UChannelList::const_iterator cit = bi->chans.begin(), cit_end = bi->chans.end(); cit != cit_end; ++cit)
|
||||
{
|
||||
ircdproto->SendJoin(bi, *cit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-9
@@ -281,7 +281,7 @@ int m_whois(const Anope::string &source, const Anope::string &who)
|
||||
{
|
||||
if (!source.empty() && !who.empty())
|
||||
{
|
||||
NickAlias *na;
|
||||
User *u;
|
||||
BotInfo *bi = findbot(who);
|
||||
if (bi)
|
||||
{
|
||||
@@ -291,15 +291,11 @@ int m_whois(const Anope::string &source, const Anope::string &who)
|
||||
ircdproto->SendNumeric(Config->ServerName, 317, source, "%s %ld %ld :seconds idle, signon time", bi->nick.c_str(), time(NULL) - bi->lastmsg, start_time);
|
||||
ircdproto->SendNumeric(Config->ServerName, 318, source, "%s :End of /WHOIS list.", who.c_str());
|
||||
}
|
||||
else if (!ircd->svshold && (na = findnick(who)) && na->HasFlag(NS_HELD))
|
||||
else if (!ircd->svshold && (u = finduser(who)) && u->server == Me)
|
||||
{
|
||||
/* We have a nick enforcer client here that we need to respond to.
|
||||
* We can't just say it doesn't exist here, even tho it does for
|
||||
* other servers :) -GD
|
||||
*/
|
||||
ircdproto->SendNumeric(Config->ServerName, 311, source, "%s %s %s * :Services Enforcer", na->nick.c_str(), Config->NSEnforcerUser.c_str(), Config->NSEnforcerHost.c_str());
|
||||
ircdproto->SendNumeric(Config->ServerName, 312, source, "%s %s :%s", na->nick.c_str(), Config->ServerName.c_str(), Config->ServerDesc.c_str());
|
||||
ircdproto->SendNumeric(Config->ServerName, 318, source, "%s :End of /WHOIS list.", who.c_str());
|
||||
ircdproto->SendNumeric(Config->ServerName, 311, source, "%s %s %s * :%s", u->nick.c_str(), u->GetIdent().c_str(), u->host.c_str(), u->realname.c_str());
|
||||
ircdproto->SendNumeric(Config->ServerName, 312, source, "%s %s :%s", u->nick.c_str(), Config->ServerName.c_str(), Config->ServerDesc.c_str());
|
||||
ircdproto->SendNumeric(Config->ServerName, 318, source, "%s :End of /WHOIS list.", u->nick.c_str());
|
||||
}
|
||||
else
|
||||
ircdproto->SendNumeric(Config->ServerName, 401, source, "%s :No such service.", who.c_str());
|
||||
|
||||
@@ -865,14 +865,6 @@ char *str_signed(unsigned char *str)
|
||||
return nstr;
|
||||
}
|
||||
|
||||
/* Equivalent to inet_ntoa */
|
||||
|
||||
void ntoa(struct in_addr addr, char *ipaddr, int len)
|
||||
{
|
||||
unsigned char *bytes = reinterpret_cast<unsigned char *>(&addr.s_addr);
|
||||
snprintf(ipaddr, len, "%u.%u.%u.%u", bytes[0], bytes[1], bytes[2], bytes[3]);
|
||||
}
|
||||
|
||||
/*
|
||||
* strlcat and strlcpy were ripped from openssh 2.5.1p2
|
||||
* They had the following Copyright info:
|
||||
|
||||
+8
-5
@@ -112,7 +112,13 @@ void NickAlias::Release()
|
||||
if (ircd->svshold)
|
||||
ircdproto->SendSVSHoldDel(this->nick);
|
||||
else
|
||||
ircdproto->SendQuit(this->nick, "");
|
||||
{
|
||||
User *u = finduser(this->nick);
|
||||
if (u && u->server == Me)
|
||||
{
|
||||
delete u;
|
||||
}
|
||||
}
|
||||
|
||||
this->UnsetFlag(NS_HELD);
|
||||
}
|
||||
@@ -133,10 +139,7 @@ void NickAlias::OnCancel(User *)
|
||||
ircdproto->SendSVSHold(this->nick);
|
||||
else
|
||||
{
|
||||
Anope::string uid = ircd->ts6 ? ts6_uid_retrieve() : "";
|
||||
|
||||
ircdproto->SendClientIntroduction(this->nick, Config->NSEnforcerUser, Config->NSEnforcerHost, "Services Enforcer", "+", uid);
|
||||
new NickServRelease(this->nick, uid, Config->NSReleaseTimeout);
|
||||
new NickServRelease(this, Config->NSReleaseTimeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+21
-14
@@ -23,10 +23,10 @@ typedef std::map<Anope::string, NickServRelease *> nickservreleases_map;
|
||||
static nickservcollides_map NickServCollides;
|
||||
static nickservreleases_map NickServReleases;
|
||||
|
||||
NickServCollide::NickServCollide(const Anope::string &_nick, time_t delay) : Timer(delay), nick(_nick)
|
||||
NickServCollide::NickServCollide(User *user, time_t delay) : Timer(delay), u(user), nick(u->nick)
|
||||
{
|
||||
/* Erase the current collide and use the new one */
|
||||
nickservcollides_map::iterator nit = NickServCollides.find(this->nick);
|
||||
nickservcollides_map::iterator nit = NickServCollides.find(user->nick);
|
||||
if (nit != NickServCollides.end())
|
||||
delete nit->second;
|
||||
|
||||
@@ -40,36 +40,43 @@ NickServCollide::~NickServCollide()
|
||||
|
||||
void NickServCollide::Tick(time_t ctime)
|
||||
{
|
||||
if (!u)
|
||||
return;
|
||||
/* If they identified or don't exist anymore, don't kill them. */
|
||||
User *u = finduser(this->nick);
|
||||
NickAlias *na = findnick(this->nick);
|
||||
if (!u || !na || u->Account() == na->nc || u->my_signon > this->GetSetTime())
|
||||
NickAlias *na = findnick(u->nick);
|
||||
if (!na || u->Account() == na->nc || u->my_signon > this->GetSetTime())
|
||||
return;
|
||||
|
||||
u->Collide(na);
|
||||
}
|
||||
|
||||
NickServRelease::NickServRelease(const Anope::string &_nick, const Anope::string &_uid, time_t delay) : Timer(delay), nick(_nick), uid(_uid)
|
||||
NickServRelease::NickServRelease(NickAlias *na, time_t delay) : User(na->nick, Config->NSEnforcerUser, Config->NSEnforcerHost, ts6_uid_retrieve()), Timer(delay), nick(na->nick)
|
||||
{
|
||||
this->realname = "Services Enforcer";
|
||||
this->server = Me;
|
||||
|
||||
/* Erase the current release timer and use the new one */
|
||||
nickservreleases_map::iterator nit = NickServReleases.find(this->nick);
|
||||
if (nit != NickServReleases.end())
|
||||
delete nit->second;
|
||||
|
||||
NickServReleases.insert(std::make_pair(nick, this));
|
||||
NickServReleases.insert(std::make_pair(this->nick, this));
|
||||
|
||||
ircdproto->SendClientIntroduction(this, "+");
|
||||
}
|
||||
|
||||
NickServRelease::~NickServRelease()
|
||||
{
|
||||
NickServReleases.erase(this->nick);
|
||||
|
||||
ircdproto->SendQuit(debug_cast<User *>(this), NULL);
|
||||
}
|
||||
|
||||
void NickServRelease::Tick(time_t ctime)
|
||||
void NickServRelease::Tick(time_t)
|
||||
{
|
||||
NickAlias *na = findnick(this->nick);
|
||||
|
||||
if (na)
|
||||
na->Release();
|
||||
/* Do not do anything here,
|
||||
* The timer manager will delete this timer which will do the necessary cleanup
|
||||
*/
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
@@ -218,12 +225,12 @@ int validate_user(User *u)
|
||||
else if (na->nc->HasFlag(NI_KILL_QUICK))
|
||||
{
|
||||
notice_lang(Config->s_NickServ, u, FORCENICKCHANGE_IN_20_SECONDS);
|
||||
new NickServCollide(na->nick, 20);
|
||||
new NickServCollide(u, 20);
|
||||
}
|
||||
else
|
||||
{
|
||||
notice_lang(Config->s_NickServ, u, FORCENICKCHANGE_IN_1_MINUTE);
|
||||
new NickServCollide(na->nick, 60);
|
||||
new NickServCollide(u, 60);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-10
@@ -18,12 +18,12 @@ void IRCDProto::SendPrivmsgInternal(const BotInfo *bi, const Anope::string &dest
|
||||
send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "PRIVMSG %s :%s", dest.c_str(), buf.c_str());
|
||||
}
|
||||
|
||||
void IRCDProto::SendQuitInternal(const BotInfo *bi, const Anope::string &buf)
|
||||
void IRCDProto::SendQuitInternal(const User *u, const Anope::string &buf)
|
||||
{
|
||||
if (!buf.empty())
|
||||
send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "QUIT :%s", buf.c_str());
|
||||
send_cmd(ircd->ts6 ? u->GetUID() : u->nick, "QUIT :%s", buf.c_str());
|
||||
else
|
||||
send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "QUIT");
|
||||
send_cmd(ircd->ts6 ? u->GetUID() : u->nick, "QUIT");
|
||||
}
|
||||
|
||||
void IRCDProto::SendPartInternal(const BotInfo *bi, const Channel *chan, const Anope::string &buf)
|
||||
@@ -160,19 +160,14 @@ void IRCDProto::SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const A
|
||||
send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "PRIVMSG %s%s :%s", ircd->globaltldprefix, dest->GetName().c_str(), msg.c_str());
|
||||
}
|
||||
|
||||
void IRCDProto::SendQuit(const Anope::string &nick, const Anope::string &)
|
||||
{
|
||||
send_cmd(nick, "QUIT");
|
||||
}
|
||||
|
||||
void IRCDProto::SendQuit(const BotInfo *bi, const char *fmt, ...)
|
||||
void IRCDProto::SendQuit(const User *u, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buf[BUFSIZE] = "";
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buf, BUFSIZE - 1, fmt, args);
|
||||
va_end(args);
|
||||
SendQuitInternal(bi, buf);
|
||||
SendQuitInternal(u, buf);
|
||||
}
|
||||
|
||||
void IRCDProto::SendPing(const Anope::string &servname, const Anope::string &who)
|
||||
|
||||
+2
-1
@@ -36,8 +36,9 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope:
|
||||
/* we used to do this by calloc, no more. */
|
||||
server = NULL;
|
||||
nc = NULL;
|
||||
invalid_pw_count = timestamp = my_signon = invalid_pw_time = lastmemosend = lastnickreg = lastmail = 0;
|
||||
invalid_pw_count = invalid_pw_time = lastmemosend = lastnickreg = lastmail = 0;
|
||||
OnAccess = false;
|
||||
timestamp = my_signon = time(NULL);
|
||||
|
||||
this->nick = snick;
|
||||
this->ident = sident;
|
||||
|
||||
Reference in New Issue
Block a user