From c8c23158a4ff74822d6c7d201dc53d879e3d91e8 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 22 Apr 2011 03:16:11 -0400 Subject: Moved the core pseudo clients out into their own modules --- include/anope.h | 26 ++--- include/bots.h | 6 ++ include/channels.h | 33 +------ include/config.h | 56 ++++------- include/extern.h | 89 +---------------- include/logger.h | 2 +- include/modules.h | 75 +++++---------- include/oper.h | 231 ++++++++++++++++++++++++++++++++++++++++++++ include/operserv.h | 250 ------------------------------------------------ include/regchannel.h | 5 + include/services.h | 70 ++++---------- include/sysconf.h.cmake | 2 - 12 files changed, 324 insertions(+), 521 deletions(-) create mode 100644 include/oper.h delete mode 100644 include/operserv.h (limited to 'include') diff --git a/include/anope.h b/include/anope.h index 4f116c37e..7aa505661 100644 --- a/include/anope.h +++ b/include/anope.h @@ -468,7 +468,21 @@ class dynamic_reference : public dynamic_reference_base this->invalid = false; this->ref = NULL; } - return this->ref; + return this->ref != NULL; + } + + virtual inline operator T*() + { + if (this->operator bool()) + return this->ref; + return NULL; + } + + virtual inline T *operator->() + { + if (this->operator bool()) + return this->ref; + return NULL; } virtual inline void operator=(T *newref) @@ -484,16 +498,6 @@ class dynamic_reference : public dynamic_reference_base if (this->ref) this->ref->AddReference(this); } - - virtual inline T *operator->() - { - return this->ref; - } - - virtual inline T *operator*() - { - return this->ref; - } }; #endif // ANOPE_H diff --git a/include/bots.h b/include/bots.h index bcbbc83d7..7316f074e 100644 --- a/include/bots.h +++ b/include/bots.h @@ -90,6 +90,12 @@ class CoreExport BotInfo : public User, public Flags * @param reason The reason we're parting */ void Part(Channel *c, const Anope::string &reason = ""); + + /** Called when a user messages this bot + * @param u The user + * @param message The users' message + */ + virtual void OnMessage(User *u, const Anope::string &message); }; #endif // BOTS_H diff --git a/include/channels.h b/include/channels.h index d0f899794..5d18a381f 100644 --- a/include/channels.h +++ b/include/channels.h @@ -12,38 +12,9 @@ typedef Anope::insensitive_map channel_map; extern CoreExport channel_map ChannelList; -struct UserData -{ - UserData() - { - Clear(); - } - - virtual ~UserData() { } - - void Clear() - { - last_use = last_start = Anope::CurTime; - lines = times = 0; - lastline.clear(); - } - - /* Data validity */ - time_t last_use; - - /* for flood kicker */ - int16 lines; - time_t last_start; - - /* for repeat kicker */ - Anope::string lastline; - int16 times; -}; - -struct UserContainer +struct UserContainer : public Extensible { User *user; - UserData ud; ChannelStatus *Status; UserContainer(User *u) : user(u) { } @@ -93,8 +64,6 @@ class CoreExport Channel : public Extensible, public Flags Anope::string topic_setter; /* Who set the topic */ time_t topic_time; /* When the topic was set*/ - std::list bd; - time_t server_modetime; /* Time of last server MODE */ time_t chanserv_modetime; /* Time of last check_modes() */ int16 server_modecount; /* Number of server MODEs this second */ diff --git a/include/config.h b/include/config.h index 5cba79587..666649253 100644 --- a/include/config.h +++ b/include/config.h @@ -167,7 +167,7 @@ template<> class ValueContainer : public ValueContainerBase return; } *val = new char[s]; - strlcpy(*val, newval, s); + memcpy(*val, newval, s); } }; @@ -264,7 +264,6 @@ bool ValidateHostServ(ServerConfig *config, const Anope::string &tag, const Anop bool ValidateLimitSessions(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data); bool ValidateOperServ(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data); bool ValidateGlobal(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data); -bool ValidateDefCon(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data); bool ValidateNickLen(ServerConfig *, const Anope::string &, const Anope::string &, ValueItem &data); bool ValidateMail(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data); bool ValidateGlobalOnCycle(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data); @@ -435,7 +434,7 @@ class CoreExport ServerConfig /* OperServ name */ Anope::string s_OperServ; /* Global name */ - Anope::string s_GlobalNoticer; + Anope::string s_Global; /* NickServs realname */ Anope::string desc_NickServ; /* ChanServ realname */ @@ -447,18 +446,26 @@ class CoreExport ServerConfig /* OperServ realname */ Anope::string desc_OperServ; /* Global realname */ - Anope::string desc_GlobalNoticer; + Anope::string desc_Global; /* HostServ Name */ Anope::string s_HostServ; /* HostServ realname */ Anope::string desc_HostServ; + /* Core HostServ modules */ + Anope::string HostCoreModules; /* Filename for the PID file */ Anope::string PIDFilename; /* MOTD filename */ Anope::string MOTDFilename; + /* Core MemoServ Modules */ + Anope::string MemoCoreModules; + /* Core OperServ Modules */ + Anope::string OperCoreModules; + /* Core Global Modules */ + Anope::string GlobalCoreModules; /* True if its ok to not be able to save backs */ bool NoBackupOkay; /* Do password checking when new people register */ @@ -578,6 +585,8 @@ class CoreExport ServerConfig bool NSStrictPrivileges; /* Use email to verify new users registering */ bool NSEmailReg; + /* Core NickServ modules */ + Anope::string NickCoreModules; /* Set the proper channel modes on users when they identify */ bool NSModeOnID; /* Add the users hostnask their access list when they register */ @@ -585,6 +594,8 @@ class CoreExport ServerConfig /* Maximum number of channels on AJoin */ unsigned AJoinMax; + /* Core ChanServ modules */ + Anope::string ChanCoreModules; /* Default flags for newly registered channels */ Flags CSDefFlags; /* Max number of channels a user can own */ @@ -621,7 +632,9 @@ class CoreExport ServerConfig /* Who can use memos reciepts */ unsigned MSMemoReceipt; - /* Defai;t BotServ flags */ + /* Core BotServ modules */ + Anope::string BotCoreModules; + /* Default BotServ flags */ Flags BSDefFlags; /* How long before botserv forgets a user. This is used for flood kickers etc */ time_t BSKeepData; @@ -710,39 +723,6 @@ class CoreExport ServerConfig std::list EncModuleList; /* Database modules */ std::list DBModuleList; - /* HostServ Core Modules */ - std::list HostServCoreModules; - /* MemoServ Core Modules */ - std::list MemoServCoreModules; - /* BotServ Core Modules */ - std::list BotServCoreModules; - /* OperServ Core Modules */ - std::list OperServCoreModules; - /* NickServ Core Modules */ - std::list NickServCoreModules; - /* ChanServ Core Modules */ - std::list ChanServCoreModules; - - /* Default defcon level */ - int DefConLevel; - /* Timeout before defcon is reset */ - time_t DefConTimeOut; - /* Session limiit to use when using defcon */ - unsigned DefConSessionLimit; - /* How long to add akills for defcon */ - time_t DefConAKILL; - /* Chan modes for defcon */ - Anope::string DefConChanModes; - /* Should we global on defcon */ - bool GlobalOnDefcon; - /* Should we send DefconMessage aswell? */ - bool GlobalOnDefconMore; - /* Message to send when defcon is off */ - Anope::string DefConOffMessage; - /* Message to send when defcon is on*/ - Anope::string DefconMessage; - /* Reason to akill clients for defcon */ - Anope::string DefConAkillReason; /* The socket engine in use */ Anope::string SocketEngine; diff --git a/include/extern.h b/include/extern.h index 0b29c0d03..6ec3310e9 100644 --- a/include/extern.h +++ b/include/extern.h @@ -31,35 +31,15 @@ E void kill_user(const Anope::string &source, User *user, const Anope::string &r E bool bad_password(User *u); E void common_unban(ChannelInfo *ci, User *u, bool full = false); -E BotInfo *BotServ; -E BotInfo *ChanServ; -E BotInfo *Global; -E BotInfo *HostServ; -E BotInfo *MemoServ; -E BotInfo *NickServ; -E BotInfo *OperServ; - /**** botserv.c ****/ -E void get_botserv_stats(long *nrec, long *memuse); -E void bs_init(); -E void botchanmsgs(User *u, ChannelInfo *ci, const Anope::string &buf); E BotInfo *findbot(const Anope::string &nick); -/** Finds a pseudoclient, given a UID. Useful for TS6 protocol modules. - * @param uid The UID to search for - * @return The pseudoclient structure, or NULL if one could not be found - */ -E Anope::string normalizeBuffer(const Anope::string &); - -E void check_ban(ChannelInfo *ci, User *u, int ttbtype); -E void bot_kick(ChannelInfo *ci, User *u, const char *message, ...); E void bot_raw_ban(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason); E void bot_raw_kick(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason); /**** channels.c ****/ -E void get_channel_stats(long *nrec, long *memuse); E Channel *findchan(const Anope::string &chan); @@ -75,27 +55,14 @@ E void MassChannelModes(BotInfo *bi, const Anope::string &modes); E void chan_set_correct_modes(User *user, Channel *c, int give_modes); -inline BotInfo *whosends(ChannelInfo *ci) -{ - if (!ci || !ci->bi || !ci->c || !ci->botflags.HasFlag(BS_SYMBIOSIS) || !ci->c->FindUser(ci->bi)) - return ChanServ ? ChanServ : NickServ; - return ci->bi; -} - /**** chanserv.c ****/ E LevelInfo levelinfo[]; -E void get_chanserv_stats(long *nrec, long *memuse); E void reset_levels(ChannelInfo *ci); -E void cs_init(); -E void expire_chans(); -E void cs_remove_nick(NickCore *nc); E void check_modes(Channel *c); -E int check_valid_admin(User *user, Channel *chan, int servermode); -E int check_valid_op(User *user, Channel *chan, int servermode); E ChannelInfo *cs_findchan(const Anope::string &chan); E int check_access(User *user, ChannelInfo *ci, int what); @@ -111,17 +78,11 @@ E Anope::string get_mlock_modes(ChannelInfo *ci, int complete); E ConfigurationFile services_conf; E ServerConfig *Config; -/* hostserv.c */ -E void do_on_id(User *u); -E void HostServSyncVhosts(NickAlias *na); - /**** encrypt.c ****/ E int enc_encrypt(const Anope::string &src, Anope::string &dest); E int enc_decrypt(const Anope::string &src, Anope::string &dest); /**** hostserv.c ****/ -E void get_hostserv_stats(long *nrec, long *memuse); -E void hostserv_init(); /**** init.c ****/ @@ -146,9 +107,6 @@ E void PopLanguage(); E const char *anope_gettext(const char *string); E void SyntaxError(CommandSource &source, const Anope::string &command, const Anope::string &message); -/*** logger.cpp ***/ -E void InitLogChannels(ServerConfig *); - /**** main.c ****/ E Anope::string services_dir; @@ -169,7 +127,6 @@ E time_t start_time; E ConnectionSocket *UplinkSock; E void save_databases(); -E void expire_all(); E void sighandler(int signum); E void do_restart_services(); @@ -184,14 +141,6 @@ class CoreExport UplinkSocket : public ConnectionSocket bool Read(const Anope::string &buf); }; -/**** memoserv.c ****/ - -E void ms_init(); -E void rsend_notify(CommandSource &source, Memo *m, const Anope::string &chan); -E void check_memos(User *u); -E MemoInfo *getmemoinfo(const Anope::string &name, bool &ischan, bool &isforbid); -E void memo_send(CommandSource &source, const Anope::string &name, const Anope::string &text, int z); - /**** messages.cpp ****/ E void init_core_messages(); @@ -225,12 +174,6 @@ E bool OnError(const Anope::string &, const std::vector &); E bool IsFile(const Anope::string &filename); E int toupper(char); E int tolower(char); -#ifndef HAVE_STRLCPY -E size_t strlcpy(char *, const char *, size_t); -#endif -#ifndef HAVE_STRLCAT -E size_t strlcat(char *, const char *, size_t); -#endif E time_t dotime(const Anope::string &s); E Anope::string duration(time_t seconds); @@ -260,6 +203,7 @@ E std::vector BuildStringVector(const Anope::string &, char = ' ' E bool str_is_wildcard(const Anope::string &str); E bool str_is_pure_wildcard(const Anope::string &str); +E Anope::string normalizeBuffer(const Anope::string &); /**** modes.cpp ****/ /* Number of generic modes we support */ @@ -269,15 +213,9 @@ E void SetDefaultMLock(ServerConfig *config); /**** nickserv.c ****/ -E void get_aliases_stats(long &count, long &mem); -E void get_core_stats(long &count, long &mem); E void change_core_display(NickCore *nc); E void change_core_display(NickCore *nc, const Anope::string &newdisplay); -E int do_setmodes(User *u); -E void ns_init(); -E int validate_user(User *u); -E void expire_nicks(); E NickAlias *findnick(const Anope::string &nick); E NickCore *findcore(const Anope::string &nick); E bool is_on_access(const User *u, const NickCore *nc); @@ -292,24 +230,6 @@ E void send_cmd(const Anope::string &source, const char *fmt, ...) FORMAT(printf E void notice_server(const Anope::string &source, const Server *s, const char *fmt, ...) FORMAT(printf, 3, 4); -/**** sessions.c ****/ - -E std::vector exceptions; - -E void get_session_stats(long &count, long &mem); -E void get_exception_stats(long &count, long &mem); - -E void add_session(User *u); -E void del_session(User *u); - -E void expire_exceptions(); - -E Session *findsession(const Anope::string &host); - -E Exception *find_host_exception(const Anope::string &host); -E Exception *find_hostip_exception(const Anope::string &host, const Anope::string &hostip); -E int exception_add(User *u, const Anope::string &mask, unsigned limit, const Anope::string &reason, const Anope::string &who, time_t expires); - /**** sockets.cpp ****/ E SocketEngineBase *SocketEngine; @@ -323,8 +243,6 @@ E int32 opcnt; E uint32 maxusercnt, usercnt; E time_t maxusertime; -E void get_user_stats(long &count, long &mem); - E User *finduser(const Anope::string &nick); E User *do_nick(const Anope::string &source, const Anope::string &nick, const Anope::string &username, const Anope::string &host, const Anope::string &server, const Anope::string &realname, time_t ts, const Anope::string &ip, const Anope::string &vhost, const Anope::string &uid, const Anope::string &modes); @@ -342,9 +260,4 @@ E Anope::string create_mask(User *u); E void b64_encode(const Anope::string &src, Anope::string &target); E void b64_decode(const Anope::string &src, Anope::string &target); -#ifdef _WIN32 -E Anope::string GetWindowsVersion(); -E bool SupportedWindowsVersion(); -#endif - #endif /* EXTERN_H */ diff --git a/include/logger.h b/include/logger.h index 6d134c227..cb3d00d6a 100644 --- a/include/logger.h +++ b/include/logger.h @@ -39,7 +39,7 @@ class CoreExport Log std::stringstream buf; - Log(LogType type = LOG_NORMAL, const Anope::string &category = "", BotInfo *bi = Global); + Log(LogType type = LOG_NORMAL, const Anope::string &category = "", BotInfo *bi = NULL); /* LOG_COMMAND/OVERRIDE/ADMIN */ Log(LogType type, User *u, Command *c, ChannelInfo *ci = NULL); diff --git a/include/modules.h b/include/modules.h index 51a550316..badb59616 100644 --- a/include/modules.h +++ b/include/modules.h @@ -314,9 +314,8 @@ class CoreExport Module : public Extensible virtual void OnUserKicked(Channel *c, User *target, const Anope::string &source, const Anope::string &kickmsg) { } /** Called when Services' configuration has been loaded. - * @param startup True if Services is starting for the first time, false otherwise. */ - virtual void OnReload(bool startup) {} + virtual void OnReload() { } /** Called before a bot is assigned to a channel. * @param sender The user assigning the bot @@ -333,20 +332,11 @@ class CoreExport Module : public Extensible */ virtual EventReturn OnBotUnAssign(User *sender, ChannelInfo *ci) { return EVENT_CONTINUE; } - /** Called after a user has been introduced, but before any type - * of checking has been done (akills, defcon, s*lines, etc) - * return EVENT_STOP here to allow the user to get by untouched, - * or kill them then return EVENT_STOP to tell Anope the user no - * longer exists - * @param u The user - * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to stop processing - */ - virtual EventReturn OnPreUserConnect(User *u) { return EVENT_CONTINUE; } - /** Called when a new user connects to the network. * @param u The connecting user. + * @param exempt set to true/is true if the user should be excepted from bans etc */ - virtual void OnUserConnect(User *u) { } + virtual void OnUserConnect(dynamic_reference &u, bool &exempt) { } /** Called when a new server connects to the network. * @param s The server that has connected to the network @@ -523,16 +513,6 @@ class CoreExport Module : public Extensible */ virtual void OnServerDisconnect() { } - /** Called before the database expire routines are called - * Note: Code that is in seperate expiry routines should just be done - * when we save the DB, theres no need to have both - */ - virtual void OnPreDatabaseExpire() { } - - /** Called when the database expire routines are called - */ - virtual void OnDatabaseExpire() { } - /** Called when the flatfile dbs are being written * @param Write A callback to the function used to insert a line into the database */ @@ -639,11 +619,10 @@ class CoreExport Module : public Extensible virtual void OnDefconLevel(int level) { } /** Called before an akill is added - * @param u The user adding the akill * @param ak The akill * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it */ - virtual EventReturn OnAddAkill(User *u, XLine *ak) { return EVENT_CONTINUE; } + virtual EventReturn OnAddAkill(XLine *ak) { return EVENT_CONTINUE; } /** Called before an akill is deleted * @param u The user removing the akill @@ -652,11 +631,10 @@ class CoreExport Module : public Extensible virtual void OnDelAkill(User *u, XLine *ak) { } /** Called after an exception has been added - * @param u The user who added it * @param ex The exception * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it */ - virtual EventReturn OnExceptionAdd(User *u, Exception *ex) { return EVENT_CONTINUE; } + virtual EventReturn OnExceptionAdd(Exception *ex) { return EVENT_CONTINUE; } /** Called before an exception is deleted * @param u The user who is deleting it @@ -665,12 +643,11 @@ class CoreExport Module : public Extensible virtual void OnExceptionDel(User *u, Exception *ex) { } /** Called before a XLine is added - * @param u The user adding the XLine * @param sx The XLine * @param Type The type of XLine this is * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it */ - virtual EventReturn OnAddXLine(User *u, XLine *x, XLineType Type) { return EVENT_CONTINUE; } + virtual EventReturn OnAddXLine(XLine *x, XLineType Type) { return EVENT_CONTINUE; } /** Called before a XLine is deleted * @param u The user deleting the XLine @@ -932,12 +909,22 @@ class CoreExport Module : public Extensible */ virtual EventReturn OnCheckAuthentication(User *u, Command *c, const std::vector ¶ms, const Anope::string &account, const Anope::string &password) { return EVENT_CONTINUE; } + /** Called when a user does /ns update + * @param u The user + */ + virtual void OnNickUpdate(User *u) { } + /** Called when we get informed about a users SSL fingerprint * when we call this, the fingerprint should already be stored in the user struct * @param u pointer to the user */ virtual void OnFingerprint(User *u) { } + /** Called when a user becomes (un)away + * @param message The message, is .empty() if unaway + */ + virtual void OnUserAway(User *u, const Anope::string &message) { } + /** Called when a vhost is deleted * @param na The nickalias of the vhost */ @@ -949,18 +936,12 @@ class CoreExport Module : public Extensible virtual void OnSetVhost(NickAlias *na) { } /** Called when a memo is sent - * @param u The user sending the memo - * @param nc The nickcore of who the memo was sent to - * @param m The memo - */ - virtual void OnMemoSend(User *u, NickCore *nc, Memo *m) { } - - /** Called when a memo is sent - * @param u The user sending the memo - * @param ci The channel the memo was sent to + * @param source The source of the memo + * @param target The target of the memo + * @param mi Memo info for target * @param m The memo */ - virtual void OnMemoSend(User *u, ChannelInfo *ci, Memo *m) { } + virtual void OnMemoSend(const Anope::string &source, const Anope::string &target, MemoInfo *mi, Memo *m) { } /** Called when a memo is deleted * @param nc The nickcore of the memo being deleted @@ -1064,10 +1045,8 @@ class CoreExport Module : public Extensible * @param u The source of the message * @param ci The channel * @param msg The message - * @param Allow set to false to make the flood kickers halt - * @return MOD_STOP to stop processing completely */ - virtual EventReturn OnPrivmsg(User *u, ChannelInfo *ci, Anope::string &msg, bool &Allow) { return EVENT_CONTINUE; } + virtual void OnPrivmsg(User *u, ChannelInfo *ci, Anope::string &msg) { } /** Called when any object is destroyed * @param b The object @@ -1087,6 +1066,7 @@ enum Implementation I_OnNickClearAccess, I_OnNickAddAccess, I_OnNickEraseAccess, I_OnNickClearCert, I_OnNickAddCert, I_OnNickEraseCert, I_OnNickInfo, I_OnFindNick, I_OnFindCore, I_OnCheckAuthentication, + I_OnNickUpdate, /* ChanServ */ I_OnChanForbidden, I_OnChanSuspend, I_OnChanDrop, I_OnPreChanExpire, I_OnChanExpire, I_OnAccessAdd, I_OnAccessChange, @@ -1105,8 +1085,8 @@ enum Implementation I_OnMemoSend, I_OnMemoDel, /* Users */ - I_OnPreUserConnect, I_OnUserConnect, I_OnUserNickChange, I_OnUserQuit, I_OnUserLogoff, I_OnPreJoinChannel, - I_OnJoinChannel, I_OnPrePartChannel, I_OnPartChannel, I_OnFingerprint, + I_OnUserConnect, I_OnUserNickChange, I_OnUserQuit, I_OnUserLogoff, I_OnPreJoinChannel, + I_OnJoinChannel, I_OnPrePartChannel, I_OnPartChannel, I_OnFingerprint, I_OnUserAway, /* OperServ */ I_OnDefconLevel, I_OnAddAkill, I_OnDelAkill, I_OnExceptionAdd, I_OnExceptionDel, @@ -1114,7 +1094,6 @@ enum Implementation /* Database */ I_OnPostLoadDatabases, I_OnSaveDatabase, I_OnLoadDatabase, - I_OnDatabaseExpire, I_OnDatabaseWrite, I_OnDatabaseRead, I_OnDatabaseReadMetadata, I_OnDatabaseWriteMetadata, /* Modules */ @@ -1122,7 +1101,7 @@ enum Implementation /* Other */ I_OnReload, I_OnPreServerConnect, I_OnNewServer, I_OnServerConnect, I_OnPreUplinkSync, I_OnServerDisconnect, I_OnPreCommandRun, - I_OnPreCommand, I_OnPostCommand, I_OnPreDatabaseExpire, I_OnPreRestart, I_OnRestart, I_OnPreShutdown, I_OnShutdown, I_OnSignal, + I_OnPreCommand, I_OnPostCommand, I_OnPreRestart, I_OnRestart, I_OnPreShutdown, I_OnShutdown, I_OnSignal, I_OnServerQuit, I_OnTopicUpdated, I_OnEncrypt, I_OnDecrypt, I_OnChannelModeSet, I_OnChannelModeUnset, I_OnUserModeSet, I_OnUserModeUnset, I_OnChannelModeAdd, I_OnUserModeAdd, @@ -1293,10 +1272,6 @@ class service_reference : public dynamic_reference { } - virtual ~service_reference() - { - } - operator bool() { if (this->invalid) diff --git a/include/oper.h b/include/oper.h new file mode 100644 index 000000000..cebd079ca --- /dev/null +++ b/include/oper.h @@ -0,0 +1,231 @@ +/* OperServ support + * + * (C) 2008-2011 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +#ifndef OPER_H +#define OPER_H + +extern CoreExport std::vector News; + +class XLineManager; +extern CoreExport XLineManager *SGLine; +extern CoreExport XLineManager *SZLine; +extern CoreExport XLineManager *SQLine; +extern CoreExport XLineManager *SNLine; + +enum XLineType +{ + X_SNLINE, + X_SQLINE, + X_SZLINE +}; + +class CoreExport XLine +{ + public: + Anope::string Mask; + Anope::string By; + time_t Created; + time_t Expires; + Anope::string Reason; + + XLine(const Anope::string &mask, const Anope::string &reason = ""); + + XLine(const Anope::string &mask, const Anope::string &by, const time_t expires, const Anope::string &reason); + + Anope::string GetNick() const; + Anope::string GetUser() const; + Anope::string GetHost() const; +}; + +class CoreExport XLineManager +{ + private: + /* List of XLine managers we check users against in XLineManager::CheckAll */ + static std::list XLineManagers; + + protected: + /* List of XLines in this XLineManager */ + std::vector XLines; + public: + /** Constructor + */ + XLineManager(); + + /** Destructor + */ + virtual ~XLineManager(); + + /** Register a XLineManager, places it in XLineManagers for use in XLineManager::CheckAll + * It is important XLineManagers are registered in the proper order. Eg, if you had one akilling + * clients and one handing them free olines, you would want the akilling one first. This way if a client + * matches an entry on both of the XLineManagers, they would be akilled. + * @param xlm THe XLineManager + */ + static void RegisterXLineManager(XLineManager *xlm); + + /** Unregister a XLineManager + * @param xlm The XLineManager + */ + static void UnregisterXLineManager(XLineManager *xlm); + + /** Check a user against all known XLineManagers + * Wparam u The user + * @return A pair of the XLineManager the user was found in and the XLine they matched, both may be NULL for no match + */ + static std::pair CheckAll(User *u); + + /** Get the number of XLines in this XLineManager + * @return The number of XLines + */ + size_t GetCount() const; + + /** Get the XLine vector + * @return The vector + */ + const std::vector &GetList() const; + + /** Add an entry to this XLineManager + * @param x The entry + */ + void AddXLine(XLine *x); + + /** Delete an entry from this XLineManager + * @param x The entry + * @return true if the entry was found and deleted, else false + */ + bool DelXLine(XLine *x); + + /** Gets an entry by index + * @param index The index + * @return The XLine, or NULL if the index is out of bounds + */ + XLine *GetEntry(unsigned index); + + /** Clear the XLine vector + */ + void Clear(); + + /** Add an entry to this XLine Manager + * @param mask The mask of the XLine + * @param creator The creator of the XLine + * @param expires When this should expire + * @param reaosn The reason + * @return A pointer to the XLine + */ + virtual XLine *Add(const Anope::string &mask, const Anope::string &creator, time_t expires, const Anope::string &reason); + + private: + /** Delete an XLine, eg, remove it from the IRCd. + * @param x The xline + */ + virtual void Del(XLine *x); + + public: + /** Checks if a mask can/should be added to the XLineManager + * @param mask The mask + * @param expires When the mask would expire + * @return A pair of int and XLine*. + * 1 - Mask already exists + * 2 - Mask already exists, but the expiry time was changed + * 3 - Mask is already covered by another mask + * In each case the XLine it matches/is covered by is returned in XLine* + */ + std::pair CanAdd(const Anope::string &mask, time_t expires); + + /** Checks if this list has an entry + * @param mask The mask + * @return The XLine the user matches, or NULL + */ + XLine *HasEntry(const Anope::string &mask); + + /** Check a user against all of the xlines in this XLineManager + * @param u The user + * @return The xline the user marches, if any. Also calls OnMatch() + */ + virtual XLine *Check(User *u); + + /** Called when a user matches a xline in this XLineManager + * @param u The user + * @param x The XLine they match + */ + virtual void OnMatch(User *u, XLine *x); + + /** Called when an XLine expires + * @param x The xline + */ + virtual void OnExpire(XLine *x); + + /** Called to send an XLine to the IRCd + * @param u The user, if we know it + * @param x The xline + */ + virtual void Send(User *u, XLine *x) = 0; +}; + +/* This is for AKILLS */ +class SGLineManager : public XLineManager +{ + public: + XLine *Add(const Anope::string &mask, const Anope::string &creator, time_t expires, const Anope::string &reason); + + void Del(XLine *x); + + void OnMatch(User *u, XLine *x); + + void OnExpire(XLine *x); + + void Send(User *u, XLine *x); +}; + +class SNLineManager : public XLineManager +{ + public: + XLine *Add(const Anope::string &mask, const Anope::string &creator, time_t expires, const Anope::string &reason); + + void Del(XLine *x); + + void OnMatch(User *u, XLine *x); + + void OnExpire(XLine *x); + + void Send(User *u, XLine *x); + + XLine *Check(User *u); +}; + +class SQLineManager : public XLineManager +{ + public: + XLine *Add(const Anope::string &mask, const Anope::string &creator, time_t expires, const Anope::string &reason); + + void Del(XLine *x); + + void OnMatch(User *u, XLine *x); + + void OnExpire(XLine *x); + + void Send(User *u, XLine *x); + + static bool Check(Channel *c); +}; + +class SZLineManager : public XLineManager +{ + public: + XLine *Add(const Anope::string &mask, const Anope::string &creator, time_t expires, const Anope::string &reason); + + void Del(XLine *x); + + void OnMatch(User *u, XLine *x); + + void OnExpire(XLine *x); + + void Send(User *u, XLine *x); +}; + +#endif // OPER_H diff --git a/include/operserv.h b/include/operserv.h deleted file mode 100644 index f039b6107..000000000 --- a/include/operserv.h +++ /dev/null @@ -1,250 +0,0 @@ -/* OperServ support - * - * (C) 2008-2011 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#ifndef OPERSERV_H -#define OPERSERV_H - -extern CoreExport std::vector News; -extern CoreExport std::vector > DefCon; -extern CoreExport bool DefConModesSet; -extern CoreExport Flags DefConModesOn; -extern CoreExport Flags DefConModesOff; -extern CoreExport std::map DefConModesOnParams; - -class XLineManager; -extern CoreExport XLineManager *SGLine; -extern CoreExport XLineManager *SZLine; -extern CoreExport XLineManager *SQLine; -extern CoreExport XLineManager *SNLine; - -extern CoreExport bool SetDefConParam(ChannelModeName, const Anope::string &); -extern CoreExport bool GetDefConParam(ChannelModeName, Anope::string &); -extern CoreExport void UnsetDefConParam(ChannelModeName); -extern CoreExport bool CheckDefCon(DefconLevel Level); -extern CoreExport bool CheckDefCon(int level, DefconLevel Level); -extern CoreExport void AddDefCon(int level, DefconLevel Level); -extern CoreExport void DelDefCon(int level, DefconLevel Level); - -extern CoreExport void os_init(); - -extern CoreExport void oper_global(const Anope::string &nick, const char *fmt, ...); -extern CoreExport void server_global(const Server *s, const Anope::string &message); - -enum XLineType -{ - X_SNLINE, - X_SQLINE, - X_SZLINE -}; - -class CoreExport XLine -{ - public: - Anope::string Mask; - Anope::string By; - time_t Created; - time_t Expires; - Anope::string Reason; - - XLine(const Anope::string &mask, const Anope::string &reason = ""); - - XLine(const Anope::string &mask, const Anope::string &by, const time_t expires, const Anope::string &reason); - - Anope::string GetNick() const; - Anope::string GetUser() const; - Anope::string GetHost() const; -}; - -class CoreExport XLineManager -{ - private: - /* List of XLine managers we check users against in XLineManager::CheckAll */ - static std::list XLineManagers; - - protected: - /* List of XLines in this XLineManager */ - std::vector XLines; - public: - /** Constructor - */ - XLineManager(); - - /** Destructor - */ - virtual ~XLineManager(); - - /** Register a XLineManager, places it in XLineManagers for use in XLineManager::CheckAll - * It is important XLineManagers are registered in the proper order. Eg, if you had one akilling - * clients and one handing them free olines, you would want the akilling one first. This way if a client - * matches an entry on both of the XLineManagers, they would be akilled. - * @param xlm THe XLineManager - */ - static void RegisterXLineManager(XLineManager *xlm); - - /** Unregister a XLineManager - * @param xlm The XLineManager - */ - static void UnregisterXLineManager(XLineManager *xlm); - - /** Check a user against all known XLineManagers - * Wparam u The user - * @return A pair of the XLineManager the user was found in and the XLine they matched, both may be NULL for no match - */ - static std::pair CheckAll(User *u); - - /** Get the number of XLines in this XLineManager - * @return The number of XLines - */ - size_t GetCount() const; - - /** Get the XLine vector - * @return The vector - */ - const std::vector &GetList() const; - - /** Add an entry to this XLineManager - * @param x The entry - */ - void AddXLine(XLine *x); - - /** Delete an entry from this XLineManager - * @param x The entry - * @return true if the entry was found and deleted, else false - */ - bool DelXLine(XLine *x); - - /** Gets an entry by index - * @param index The index - * @return The XLine, or NULL if the index is out of bounds - */ - XLine *GetEntry(unsigned index); - - /** Clear the XLine vector - */ - void Clear(); - - /** Add an entry to this XLine Manager - * @param bi The bot error replies should be sent from - * @param u The user adding the XLine - * @param mask The mask of the XLine - * @param expires When this should expire - * @param reaosn The reason - * @return A pointer to the XLine - */ - virtual XLine *Add(BotInfo *bi, User *u, const Anope::string &mask, time_t expires, const Anope::string &reason); - - private: - /** Delete an XLine, eg, remove it from the IRCd. - * @param x The xline - */ - virtual void Del(XLine *x); - - public: - /** Checks if a mask can/should be added to the XLineManager - * @param mask The mask - * @param expires When the mask would expire - * @return A pair of int and XLine*. - * 1 - Mask already exists - * 2 - Mask already exists, but the expiry time was changed - * 3 - Mask is already covered by another mask - * In each case the XLine it matches/is covered by is returned in XLine* - */ - std::pair CanAdd(const Anope::string &mask, time_t expires); - - /** Checks if this list has an entry - * @param mask The mask - * @return The XLine the user matches, or NULL - */ - XLine *HasEntry(const Anope::string &mask); - - /** Check a user against all of the xlines in this XLineManager - * @param u The user - * @return The xline the user marches, if any. Also calls OnMatch() - */ - virtual XLine *Check(User *u); - - /** Called when a user matches a xline in this XLineManager - * @param u The user - * @param x The XLine they match - */ - virtual void OnMatch(User *u, XLine *x); - - /** Called when an XLine expires - * @param x The xline - */ - virtual void OnExpire(XLine *x); - - /** Called to send an XLine to the IRCd - * @param u The user, if we know it - * @param x The xline - */ - virtual void Send(User *u, XLine *x) = 0; -}; - -/* This is for AKILLS */ -class SGLineManager : public XLineManager -{ - public: - XLine *Add(BotInfo *bi, User *u, const Anope::string &mask, time_t expires, const Anope::string &reason); - - void Del(XLine *x); - - void OnMatch(User *u, XLine *x); - - void OnExpire(XLine *x); - - void Send(User *u, XLine *x); -}; - -class SNLineManager : public XLineManager -{ - public: - XLine *Add(BotInfo *bi, User *u, const Anope::string &mask, time_t expires, const Anope::string &reason); - - void Del(XLine *x); - - void OnMatch(User *u, XLine *x); - - void OnExpire(XLine *x); - - void Send(User *u, XLine *x); - - XLine *Check(User *u); -}; - -class SQLineManager : public XLineManager -{ - public: - XLine *Add(BotInfo *bi, User *u, const Anope::string &mask, time_t expires, const Anope::string &reason); - - void Del(XLine *x); - - void OnMatch(User *u, XLine *x); - - void OnExpire(XLine *x); - - void Send(User *u, XLine *x); - - static bool Check(Channel *c); -}; - -class SZLineManager : public XLineManager -{ - public: - XLine *Add(BotInfo *bi, User *u, const Anope::string &mask, time_t expires, const Anope::string &reason); - - void Del(XLine *x); - - void OnMatch(User *u, XLine *x); - - void OnExpire(XLine *x); - - void Send(User *u, XLine *x); -}; - -#endif // OPERSERV_H diff --git a/include/regchannel.h b/include/regchannel.h index 6f9a52fdc..a3112cfbc 100644 --- a/include/regchannel.h +++ b/include/regchannel.h @@ -175,6 +175,11 @@ class CoreExport ChannelInfo : public Extensible, public Flags class Flags const Anope::string *Flag_Strings; public: + Flags() : Flag_Strings(NULL) { } Flags(const Anope::string *flag_strings) : Flag_Strings(flag_strings) { } /** Add a flag to this item @@ -409,7 +410,6 @@ class ChannelInfo; class Channel; class Server; class Entry; -struct Session; #include "threadengine.h" #include "opertype.h" @@ -454,13 +454,11 @@ enum MemoFlag /* Memo is unread */ MF_UNREAD, /* Sender requests a receipt */ - MF_RECEIPT, - /* Memo is a notification of receipt */ - MF_NOTIFYS + MF_RECEIPT }; const Anope::string MemoFlagStrings[] = { - "MF_UNREAD", "MF_RECEIPT", "MF_NOTIFYS", "" + "MF_UNREAD", "MF_RECEIPT", "" }; /* Memo info structures. Since both nicknames and channels can have memos, @@ -486,6 +484,23 @@ struct CoreExport MemoInfo bool HasIgnore(User *u); }; +struct Session +{ + Anope::string host; /* Host of the session */ + unsigned count; /* Number of clients with this host */ + unsigned hits; /* Number of subsequent kills for a host */ +}; + +struct Exception +{ + Anope::string mask; /* Hosts to which this exception applies */ + unsigned limit; /* Session limit for exception */ + Anope::string who; /* Nick of person who added the exception */ + Anope::string reason; /* Reason for exception's addition */ + time_t time; /* When this exception was added */ + time_t expires; /* Time when it expires. 0 == no expiry */ +}; + /*************************************************************************/ class CoreExport HostInfo @@ -703,13 +718,6 @@ enum #include "account.h" #include "bots.h" -struct BanData -{ - Anope::string mask; /* Since a nick is unsure and a User structure is unsafe */ - time_t last_use; /* Since time is the only way to check whether it's still useful */ - int16 ttb[TTB_SIZE]; -}; - struct LevelInfo { int what; @@ -801,43 +809,7 @@ struct MailInfo /*************************************************************************/ -struct Exception -{ - Anope::string mask; /* Hosts to which this exception applies */ - unsigned limit; /* Session limit for exception */ - Anope::string who; /* Nick of person who added the exception */ - Anope::string reason; /* Reason for exception's addition */ - time_t time; /* When this exception was added */ - time_t expires; /* Time when it expires. 0 == no expiry */ -}; - -/*************************************************************************/ - -extern CoreExport Anope::map SessionList; - -struct Session -{ - Anope::string host; - unsigned count; /* Number of clients with this host */ - unsigned hits; /* Number of subsequent kills for a host */ -}; - -/*************************************************************************/ - /* Defcon */ -enum DefconLevel -{ - DEFCON_NO_NEW_CHANNELS, - DEFCON_NO_NEW_NICKS, - DEFCON_NO_MLOCK_CHANGE, - DEFCON_FORCE_CHAN_MODES, - DEFCON_REDUCE_SESSION, - DEFCON_NO_NEW_CLIENTS, - DEFCON_OPER_ONLY, - DEFCON_SILENT_OPER_ONLY, - DEFCON_AKILL_NEW_CLIENTS, - DEFCON_NO_NEW_MEMOS -}; /*************************************************************************/ @@ -863,7 +835,7 @@ class ConfigurationFile; #include "extern.h" #include "language.h" -#include "operserv.h" +#include "oper.h" #include "mail.h" #include "servers.h" #include "logger.h" diff --git a/include/sysconf.h.cmake b/include/sysconf.h.cmake index 78150a82d..68f3f74e6 100644 --- a/include/sysconf.h.cmake +++ b/include/sysconf.h.cmake @@ -12,8 +12,6 @@ #cmakedefine HAVE_STRCASECMP 1 #cmakedefine HAVE_STRICMP 1 #cmakedefine HAVE_STRINGS_H 1 -#cmakedefine HAVE_STRLCAT 1 -#cmakedefine HAVE_STRLCPY 1 #cmakedefine HAVE_UMASK 1 #cmakedefine HAVE_EVENTFD 1 #cmakedefine GETTEXT_FOUND 1 -- cgit