diff --git a/data/example.conf b/data/example.conf index 7dc9c1685..65d94ad5f 100644 --- a/data/example.conf +++ b/data/example.conf @@ -201,23 +201,6 @@ serverinfo */ networkinfo { - /* - * If set, Services will output log messages to the given channel. This - * directive is optional. - * - * IMPORTANT: This can be a security risk, so make certain this channel is - * sufficiently protected from normal access. - */ - #logchannel = "#services" - - /* - * If set, Services will output all BotServ chatter to the defined logchannel - * above. It shows all uses of BotServ ACT and SAY commands. Note that there - * is no logging to the log file. Only works if logchannel is also defined. - * This directive is optional. - */ - #logbot = yes - /* * This is the name of the network that Services will be running on. */ @@ -475,13 +458,6 @@ options */ #dumpcore = yes - /* - * If set, Anope will log user connections, disconnections, and nickname - * changes. You may have to do so in case you ever need to transmit user - * information to your local authorities. This directive is optional. - */ - #logusers = yes - /* * If set, Services will only show /stats o to IRC Operators. This directive * is optional. @@ -546,12 +522,6 @@ options */ ulineservers = "stats.your.network" - /* - * If set, Services will start logging to the log channel immediatly on startup. - * This directive is optional, and has no effect if logchannel is not defined. - */ - #enablelogchannel = yes - /* * Default modes for mode lock, these are set on newly registered channels. */ @@ -580,6 +550,80 @@ options hideprivilegedcommands = no } +/* + * [RECOMMENDED] Logging Configuration + * + * This section is used for configuring what is logged and where it is logged to. + * You may have multiple log blocks if you wish. Remember to properly secure any + * channels you choose to have Anope log to! + */ +log +{ + /* + * Target(s) to log to. If it starts with a # it is assumed to be a channel, otherwise + * it will log to a file. + */ + target = "services.log" + /* Log to both services.log and the channel #services */ + //target = "services.log #services" + + /* + * The source(s) to only accept log messages from. Leave commented to allow all sources. + * This can be a users name, a channel name, one of our clients (eg, OperServ), or a server name. + */ + //source = "" + + /* + * The number of days to keep logfiles, only useful if you are logging to a file. + * Set to 0 to never delete old logfiles. + * + * Note that Anope must run 24 hours a day for this feature to work correctly. + */ + logage = 7 + + /* + * What types of log messages should be logged by this block. There are nine general categories: + * + * admin - Execution of admin commands (OperServ, etc). + * override - A services operator using their powers to execute a command they couldn't normally. + * commands - Execution of general commands. + * servers - Server actions, linking, squitting, etc. + * channels - Actions in channels such as joins, parts, kicks, etc. + * users - User actions such as connecting, disconnecting, changing name, etc. + * normal - Miscelanious messages. + * rawio - Logs raw input and output from services + * debug - Debug messages (log files can become VERY large from this). + * + * These options determin what messages from the categories should be logged. Wildcards are accepted, and + * you can also negate values with a ~. For example, "operserv/* ~operserv/akill" would log all operserv + * messages except for operserv/akill. + * + * Valid admin, override, and command options are: + * pesudo-serv/commandname (eg, operserv/akill, chanserv/set) + * + * Valid server options are: + * connect, quit, sync + * + * Valid channel options are: + * create, destroy, join, part, kick, leave, mode + * + * Valid user options are: + * connect, disconnect, quit, nick, ident, host, mode, maxusers + * + * Normal and debug are simple yes/no answers, there are no types for them. + * + * Note that modules may add their own values to these options. + */ + admin = "operserv/*" + override = "chanserv/* nickserv/* memoserv/set botserv/* ~botserv/set" + commands = "~operserv/* *" + servers = "*" + //channels = "~mode *" + users = "connect disconnect nick" + normal = yes + rawio = no + debug = no +} /* * [RECOMMENDED] Oper Access Config @@ -594,7 +638,7 @@ options * * Available privileges: * botserv/administration - Can perform certain BotServ administrative tasks - * chanserv/access/modify - Can modify channel access lists + * chanserv/access/modify - Can modify channel access and akick lists * chanserv/auspex - Can see any information with /chanserv info * chanserv/no-register-limit - May register an unlimited number of channels and nicknames * chanserv/set - Can modify the settings of any channel (incl. changing of the owner and password!) @@ -1301,12 +1345,6 @@ operserv */ #superadmin = yes - /* - * If set, causes Services to write a message to the log every time a new user maximum is set. - * This directive is optional. - */ - logmaxusers = yes - /* * These define the default expiration times for, respectively, AKILLs, CHANKILLs, SNLINEs, * SQLINEs, and SZLINEs. diff --git a/docs/Changes.conf b/docs/Changes.conf index 404a06bc2..01227d8b2 100644 --- a/docs/Changes.conf +++ b/docs/Changes.conf @@ -11,6 +11,7 @@ opertype:commands added nickserv/saset/* and chanserv/saset/* options:socketengine added to choose what socket engine to use module:cs_set_misc and module:ns_set_misc added to replace the old set url/icq/email modules options:hideprivilegedcommands added to hide privileged commands from normal users +log block added to customize logging ** MODIFIED CONFIGURATION DIRECTIVES ** opertype:commands changed operserv/sgline to opserv/snline @@ -21,6 +22,7 @@ operserv:notifications ossgline changed ossnline ** DELETED CONFIGURATION DIRECTIVES ** serverinfo:helpchannel removed because it has been readded in m_helpchan +networkinfo:logchannel, logbot, logusers, logmaxusers, and logchannel removed because of the log block Anope Version 1.9.2 -------------------- diff --git a/include/bots.h b/include/bots.h index f6b8d2e14..0a84cce71 100644 --- a/include/bots.h +++ b/include/bots.h @@ -23,6 +23,8 @@ enum BotFlag { BI_BEGIN, + /* This bot is a core bot. NickServ, ChanServ, etc */ + BI_CORE, /* This bot can only be assigned by IRCops */ BI_PRIVATE, diff --git a/include/channels.h b/include/channels.h index 8c5d83c5d..7a02b3d6b 100644 --- a/include/channels.h +++ b/include/channels.h @@ -57,7 +57,9 @@ enum ChannelFlags /* Channel still exists when emptied */ CH_PERSIST, /* If set the channel is syncing users (channel was just created) and it should not be deleted */ - CH_SYNCING + CH_SYNCING, + /* Is a services log channel */ + CH_LOGCHAN }; class CoreExport Channel : public Extensible, public Flags diff --git a/include/config.h b/include/config.h index 8313f94d6..5d605aca5 100644 --- a/include/config.h +++ b/include/config.h @@ -465,8 +465,6 @@ class ServerConfig /* The hostname if services clients */ Anope::string ServiceHost; - /* Log channel */ - Anope::string LogChannel; /* Name of the network were on */ Anope::string NetworkName; /* The max legnth of nicks */ @@ -544,8 +542,6 @@ class ServerConfig bool UseStrictPrivMsg; /* Dump a core file if we crash */ bool DumpCore; - /* Log users connecting/existing/changing nicks */ - bool LogUsers; /* Number of seconds between consecutive uses of the REGISTER command * Not to be confused with NSRegDelay */ unsigned NickRegDelay; @@ -555,6 +551,8 @@ class ServerConfig Anope::string MLock; /* Default botmodes on channels, defaults to ao */ Anope::string BotModes; + /* THe actual modes */ + std::vector BotModeList; /* How many times to try and reconnect to the uplink before giving up */ unsigned MaxRetries; /* How long to wait between connection attempts */ @@ -562,6 +560,9 @@ class ServerConfig /* If services should hide unprivileged commands */ bool HidePrivilegedCommands; + /* A vector of our logfile options */ + std::vector LogInfos; + /* Services can use email */ bool UseMail; /* Path to the sendmail executable */ @@ -684,10 +685,6 @@ class ServerConfig Anope::string GlobalOnCycleUP; /* Super admin is allowed */ bool SuperAdmin; - /* Log things said through ACT/SAY */ - bool LogBot; - /* Log when new user max is reached */ - bool LogMaxUsers; /* Default expiry time for akills */ time_t AutokillExpiry; /* Default expiry time for chan kills */ diff --git a/include/extern.h b/include/extern.h index 4dc6cb4ba..dc4582478 100644 --- a/include/extern.h +++ b/include/extern.h @@ -153,8 +153,7 @@ E void hostserv_init(); E void introduce_user(const Anope::string &user); E bool GetCommandLineArgument(const Anope::string &name, char shortname = 0); E bool GetCommandLineArgument(const Anope::string &name, char shortname, Anope::string ¶m); -E int init_primary(int ac, char **av); -E int init_secondary(int ac, char **av); +E void Init(int ac, char **av); E Uplink *uplink_server; /**** ircd.c ****/ @@ -177,13 +176,8 @@ E const char *getstring(const NickCore *nc, int index); E const char *getstring(const User *nc, int index); E const char *getstring(int index); -/**** log.c ****/ - -E int open_log(); -E void close_log(); -E void log_perror(const char *fmt, ...) FORMAT(printf, 1, 2); -E void fatal(const char *fmt, ...) FORMAT(printf, 1, 2); -E void fatal_perror(const char *fmt, ...) FORMAT(printf, 1, 2); +/*** logger.cpp ***/ +E void InitLogChannels(ServerConfig *); /**** main.c ****/ @@ -193,7 +187,6 @@ E Anope::string services_dir; E Anope::string log_filename; E int debug; E bool readonly; -E bool LogChan; E bool nofork; E bool nothird; E bool noexpire; @@ -297,8 +290,6 @@ E unsigned GenericChannelModes, GenericUserModes; E Flags DefMLockOn; E Flags DefMLockOff; E std::map DefMLockParams; -/* Modes to set on bots when they join the channel */ -E std::list BotModes; E void SetDefaultMLock(ServerConfig *config); /**** nickserv.c ****/ diff --git a/include/logger.h b/include/logger.h new file mode 100644 index 000000000..79a582503 --- /dev/null +++ b/include/logger.h @@ -0,0 +1,100 @@ +#ifndef LOGGER_H +#define LOGGER_H + +enum LogType +{ + LOG_ADMIN, + LOG_OVERRIDE, + LOG_COMMAND, + LOG_SERVER, + LOG_CHANNEL, + LOG_USER, + LOG_NORMAL, + LOG_TERMINAL, + LOG_RAWIO, + LOG_DEBUG, + LOG_DEBUG_2, + LOG_DEBUG_3, + LOG_DEBUG_4 +}; + +struct LogFile +{ + Anope::string filename; + + public: + std::ofstream stream; + + LogFile(const Anope::string &name); + Anope::string GetName() const; +}; + +class CoreExport Log +{ + public: + BotInfo *bi; + LogType Type; + Anope::string Category; + std::list Sources; + + std::stringstream buf; + + Log(LogType type = LOG_NORMAL, const Anope::string &category = "", BotInfo *bi = Global); + + /* LOG_COMMAND/OVERRIDE/ADMIN */ + Log(LogType type, User *u, Command *c, ChannelInfo *ci = NULL); + + /* LOG_CHANNEL */ + Log(User *u, Channel *c, const Anope::string &category = ""); + + /* LOG_USER */ + explicit Log(User *u, const Anope::string &category = ""); + + /* LOG_SERVER */ + Log(Server *s, const Anope::string &category = ""); + + Log(BotInfo *b, const Anope::string &category = ""); + + ~Log(); + + template Log &operator<<(T val) + { + this->buf << val; + return *this; + } +}; + +class CoreExport LogInfo +{ + public: + std::list Targets; + std::map Logfiles; + std::list Sources; + int LogAge; + std::list Admin; + std::list Override; + std::list Commands; + std::list Servers; + std::list Users; + std::list Channels; + bool Normal; + bool RawIO; + bool Debug; + + LogInfo(int logage, bool normal, bool rawio, bool debug); + + ~LogInfo(); + + void AddType(std::list &list, const Anope::string &type); + + bool HasType(std::list &list, const Anope::string &type) const; + + std::list &GetList(LogType type); + + bool HasType(LogType Type); + + void ProcessMessage(const Log *l); +}; + +#endif // LOGGER_H + diff --git a/include/modules.h b/include/modules.h index 0d279c6c0..ebe56df48 100644 --- a/include/modules.h +++ b/include/modules.h @@ -66,7 +66,7 @@ if (true) \ } \ catch (const ModuleException &modexcept) \ { \ - Alog() << "Exception caught: " << modexcept.GetReason(); \ + Log() << "Exception caught: " << modexcept.GetReason(); \ } \ _i = safei; \ } \ @@ -98,7 +98,7 @@ if (true) \ } \ catch (const ModuleException &modexcept) \ { \ - Alog() << "Exception caught: " << modexcept.GetReason(); \ + Log() << "Exception caught: " << modexcept.GetReason(); \ } \ _i = safei; \ } \ diff --git a/include/services.h b/include/services.h index 2cda56a31..a0c701b95 100644 --- a/include/services.h +++ b/include/services.h @@ -181,6 +181,7 @@ extern "C" void __pfnBkCheck() {} /* Pull in the various bits of STL */ #include +#include #include #include #include @@ -253,6 +254,14 @@ class CoreException : public std::exception } }; +class FatalException : public CoreException +{ + public: + FatalException(const Anope::string &reason = "") : CoreException(reason) { } + + virtual ~FatalException() throw() { } +}; + class ModuleException : public CoreException { public: @@ -939,6 +948,7 @@ class ServerConfig; #include "operserv.h" #include "mail.h" #include "servers.h" +#include "logger.h" #include "config.h" class CoreExport IRCDProto @@ -1039,10 +1049,6 @@ class CoreExport IRCDProto virtual void SetAutoIdentificationToken(User *u) { } }; -class IRCDTS6Proto : public IRCDProto -{ -}; - /*************************************************************************/ struct Uplink @@ -1055,33 +1061,6 @@ struct Uplink Uplink(const Anope::string &_host, int _port, const Anope::string &_password, bool _ipv6) : host(_host), port(_port), password(_password), ipv6(_ipv6) { } }; -enum LogLevel -{ - LOG_NORMAL, - LOG_TERMINAL, - LOG_DEBUG, - LOG_DEBUG_2, - LOG_DEBUG_3, - LOG_DEBUG_4 -}; - -class CoreExport Alog -{ - private: - std::stringstream buf; - LogLevel Level; - public: - Alog(LogLevel val = LOG_NORMAL); - ~Alog(); - template Alog &operator<<(T val) - { - buf << val; - return *this; - } -}; - -/*************************************************************************/ - #include "timers.h" /** Timer for colliding nicks to force people off of nicknames diff --git a/include/users.h b/include/users.h index 40e98b114..e65068f33 100644 --- a/include/users.h +++ b/include/users.h @@ -76,10 +76,12 @@ class CoreExport User : public Extensible /** Create a new user object, initialising necessary fields and * adds it to the hash * - * @param nick The nickname of the user. - * @param uid The unique identifier of the user. + * @param snick The nickname of the user. + * @param sident The username of the user + * @param shost The hostname of the user + * @param suid The unique identifier of the user. */ - User(const Anope::string &nick, const Anope::string &uid); + User(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &suid); /** Destroy a user. */ diff --git a/modules/core/bs_act.cpp b/modules/core/bs_act.cpp index 34251cbb2..d52dbdb78 100644 --- a/modules/core/bs_act.cpp +++ b/modules/core/bs_act.cpp @@ -49,8 +49,10 @@ class CommandBSAct : public Command ircdproto->SendAction(ci->bi, ci->name, "%s", message.c_str()); ci->bi->lastmsg = time(NULL); - if (Config->LogBot && !Config->LogChannel.empty() && LogChan && !debug && findchan(Config->LogChannel)) - ircdproto->SendPrivmsg(ci->bi, Config->LogChannel, "ACT %s %s %s", u->nick.c_str(), ci->name.c_str(), message.c_str()); + + // XXX Need to be able to find if someone is overriding this. + Log(LOG_COMMAND, u, this, ci) << message; + return MOD_CONT; } diff --git a/modules/core/bs_assign.cpp b/modules/core/bs_assign.cpp index b1242c857..97b23c0ef 100644 --- a/modules/core/bs_assign.cpp +++ b/modules/core/bs_assign.cpp @@ -59,6 +59,9 @@ class CommandBSAssign : public Command return MOD_CONT; } + bool override = !check_access(u, ci, CA_ASSIGN); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "for " << bi->nick; + bi->Assign(u, ci); notice_lang(Config->s_BotServ, u, BOT_ASSIGN_ASSIGNED, bi->nick.c_str(), ci->name.c_str()); return MOD_CONT; diff --git a/modules/core/bs_badwords.cpp b/modules/core/bs_badwords.cpp index 46b38bf1d..c02ff6570 100644 --- a/modules/core/bs_badwords.cpp +++ b/modules/core/bs_badwords.cpp @@ -53,10 +53,14 @@ class BadwordsDelCallback : public NumberList { User *u; ChannelInfo *ci; + Command *c; unsigned Deleted; + bool override; public: - BadwordsDelCallback(User *_u, ChannelInfo *_ci, const Anope::string &list) : NumberList(list, true), u(_u), ci(_ci), Deleted(0) + BadwordsDelCallback(User *_u, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), u(_u), ci(_ci), c(_c), Deleted(0), override(false) { + if (!check_access(u, ci, CA_BADWORDS) && u->Account()->HasPriv("botserv/administration")) + this->override = true; } ~BadwordsDelCallback() @@ -74,6 +78,7 @@ class BadwordsDelCallback : public NumberList if (Number > ci->GetBadWordCount()) return; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, c, ci) << "DEL " << ci->GetBadWord(Number -1 )->word; ++Deleted; ci->EraseBadWord(Number - 1); } @@ -84,6 +89,9 @@ class CommandBSBadwords : public Command private: CommandReturn DoList(User *u, ChannelInfo *ci, const Anope::string &word) { + bool override = !check_access(u, ci, CA_BADWORDS); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "LIST"; + if (!ci->GetBadWordCount()) notice_lang(Config->s_BotServ, u, BOT_BADWORDS_LIST_EMPTY, ci->name.c_str()); else if (!word.empty() && word.find_first_not_of("1234567890,-") == Anope::string::npos) @@ -156,6 +164,8 @@ class CommandBSBadwords : public Command } } + bool override = !check_access(u, ci, CA_BADWORDS); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "ADD " << realword; ci->AddBadWord(realword, type); notice_lang(Config->s_BotServ, u, BOT_BADWORDS_ADDED, realword.c_str(), ci->name.c_str()); @@ -168,7 +178,7 @@ class CommandBSBadwords : public Command /* Special case: is it a number/list? Only do search if it isn't. */ if (!word.empty() && isdigit(word[0]) && word.find_first_not_of("1234567890,-") == Anope::string::npos) { - BadwordsDelCallback list(u, ci, word); + BadwordsDelCallback list(u, ci, this, word); list.Process(); } else @@ -190,6 +200,8 @@ class CommandBSBadwords : public Command return MOD_CONT; } + bool override = !check_access(u, ci, CA_BADWORDS); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "DEL " << badword->word; ci->EraseBadWord(i); notice_lang(Config->s_BotServ, u, BOT_BADWORDS_DELETED, badword->word.c_str(), ci->name.c_str()); @@ -200,6 +212,9 @@ class CommandBSBadwords : public Command CommandReturn DoClear(User *u, ChannelInfo *ci) { + bool override = !check_access(u, ci, CA_BADWORDS); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "CLEAR"; + ci->ClearBadWords(); notice_lang(Config->s_BotServ, u, BOT_BADWORDS_CLEAR); return MOD_CONT; diff --git a/modules/core/bs_bot.cpp b/modules/core/bs_bot.cpp index f001c81a4..5c96ac70c 100644 --- a/modules/core/bs_bot.cpp +++ b/modules/core/bs_bot.cpp @@ -95,10 +95,13 @@ class CommandBSBot : public Command if (!(bi = new BotInfo(nick, user, host, real))) { + // XXX this cant happen? notice_lang(Config->s_BotServ, u, BOT_BOT_CREATION_FAILED); return MOD_CONT; } + Log(LOG_ADMIN, u, this) << "ADD " << bi->GetMask() << " " << bi->realname; + notice_lang(Config->s_BotServ, u, BOT_BOT_ADDED, bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str()); FOREACH_MOD(I_OnBotCreate, OnBotCreate(bi)); @@ -260,6 +263,7 @@ class CommandBSBot : public Command } notice_lang(Config->s_BotServ, u, BOT_BOT_CHANGED, oldnick.c_str(), bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str()); + Log(LOG_ADMIN, u, this) << "CHANGE " << oldnick << " to " << bi->GetMask() << " " << bi->realname; FOREACH_MOD(I_OnBotChange, OnBotChange(bi)); return MOD_CONT; @@ -294,6 +298,8 @@ class CommandBSBot : public Command XLine x(bi->nick); ircdproto->SendSQLineDel(&x); + Log(LOG_ADMIN, u, this) << "DEL " << bi->nick; + delete bi; notice_lang(Config->s_BotServ, u, BOT_BOT_DELETED, nick.c_str()); return MOD_CONT; diff --git a/modules/core/bs_kick.cpp b/modules/core/bs_kick.cpp index 849efb7d0..2ed3c8639 100644 --- a/modules/core/bs_kick.cpp +++ b/modules/core/bs_kick.cpp @@ -42,6 +42,9 @@ class CommandBSKick : public Command notice_help(Config->s_BotServ, u, BOT_NOT_ASSIGNED); else { + bool override = !check_access(u, ci, CA_SET); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << option << " " << value; + if (option.equals_ci("BADWORDS")) { if (value.equals_ci("ON")) @@ -54,7 +57,7 @@ class CommandBSKick : public Command if (!error.empty() || ci->ttb[TTB_BADWORDS] < 0) { /* leaving the debug behind since we might want to know what these are */ - Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_BADWORDS]; + Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_BADWORDS]; /* reset the value back to 0 - TSL */ ci->ttb[TTB_BADWORDS] = 0; notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str()); @@ -85,7 +88,7 @@ class CommandBSKick : public Command ci->ttb[TTB_BOLDS] = convertTo(ttb, error, false); if (!error.empty() || ci->ttb[TTB_BOLDS] < 0) { - Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_BOLDS]; + Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_BOLDS]; ci->ttb[TTB_BOLDS] = 0; notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; @@ -118,7 +121,7 @@ class CommandBSKick : public Command ci->ttb[TTB_CAPS] = convertTo(ttb, error, false); if (!error.empty() || ci->ttb[TTB_CAPS] < 0) { - Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_CAPS]; + Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_CAPS]; ci->ttb[TTB_CAPS] = 0; notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; @@ -163,7 +166,7 @@ class CommandBSKick : public Command ci->ttb[TTB_COLORS] = convertTo(ttb, error, false); if (!error.empty() || ci->ttb[TTB_COLORS] < 0) { - Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_COLORS]; + Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_COLORS]; ci->ttb[TTB_COLORS] = 0; notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; @@ -196,7 +199,7 @@ class CommandBSKick : public Command ci->ttb[TTB_FLOOD] = convertTo(ttb, error, false); if (!error.empty() || ci->ttb[TTB_FLOOD] < 0) { - Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_FLOOD]; + Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_FLOOD]; ci->ttb[TTB_FLOOD] = 0; notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; @@ -243,7 +246,7 @@ class CommandBSKick : public Command ci->ttb[TTB_REPEAT] = convertTo(ttb, error, false); if (!error.empty() || ci->ttb[TTB_REPEAT] < 0) { - Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_REPEAT]; + Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_REPEAT]; ci->ttb[TTB_REPEAT] = 0; notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; @@ -281,7 +284,7 @@ class CommandBSKick : public Command ci->ttb[TTB_REVERSES] = convertTo(ttb, error, false); if (!error.empty() || ci->ttb[TTB_REVERSES] < 0) { - Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_REVERSES]; + Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_REVERSES]; ci->ttb[TTB_REVERSES] = 0; notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; @@ -311,7 +314,7 @@ class CommandBSKick : public Command ci->ttb[TTB_UNDERLINES] = convertTo(ttb, error, false); if (!error.empty() || ci->ttb[TTB_UNDERLINES] < 0) { - Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_UNDERLINES]; + Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_UNDERLINES]; ci->ttb[TTB_UNDERLINES] = 0; notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; @@ -341,7 +344,7 @@ class CommandBSKick : public Command ci->ttb[TTB_ITALICS] = convertTo(ttb, error, false); if (!error.empty() || ci->ttb[TTB_ITALICS] < 0) { - Alog(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_ITALICS]; + Log(LOG_DEBUG) << "remainder of ttb " << error << " ttb " << ci->ttb[TTB_ITALICS]; ci->ttb[TTB_ITALICS] = 0; notice_lang(Config->s_BotServ, u, BOT_KICK_BAD_TTB, ttb.c_str()); return MOD_CONT; diff --git a/modules/core/bs_say.cpp b/modules/core/bs_say.cpp index 1b799c415..916cf8fca 100644 --- a/modules/core/bs_say.cpp +++ b/modules/core/bs_say.cpp @@ -55,8 +55,10 @@ class CommandBSSay : public Command ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", text.c_str()); ci->bi->lastmsg = time(NULL); - if (Config->LogBot && !Config->LogChannel.empty() && LogChan && !debug && findchan(Config->LogChannel)) - ircdproto->SendPrivmsg(ci->bi, Config->LogChannel, "SAY %s %s %s", u->nick.c_str(), ci->name.c_str(), text.c_str()); + + // XXX need a way to find if someone is overriding this + Log(LOG_COMMAND, u, this, ci) << text; + return MOD_CONT; } diff --git a/modules/core/bs_set.cpp b/modules/core/bs_set.cpp index 87a15cf66..0ee46a0d5 100644 --- a/modules/core/bs_set.cpp +++ b/modules/core/bs_set.cpp @@ -64,6 +64,9 @@ class CommandBSSet : public Command notice_lang(Config->s_BotServ, u, ACCESS_DENIED); else { + bool override = !check_access(u, ci, CA_SET); + Log(override ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << option << value; + if (option.equals_ci("DONTKICKOPS")) { if (value.equals_ci("ON")) diff --git a/modules/core/bs_unassign.cpp b/modules/core/bs_unassign.cpp index bde37f78e..6b6b28fe9 100644 --- a/modules/core/bs_unassign.cpp +++ b/modules/core/bs_unassign.cpp @@ -36,6 +36,9 @@ class CommandBSUnassign : public Command notice_help(Config->s_BotServ, u, BOT_UNASSIGN_PERSISTANT_CHAN); else { + bool override = !check_access(u, ci, CA_ASSIGN); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "for " << ci->bi->nick; + ci->bi->UnAssign(u, ci); notice_lang(Config->s_BotServ, u, BOT_UNASSIGN_UNASSIGNED, ci->name.c_str()); } diff --git a/modules/core/cs_access.cpp b/modules/core/cs_access.cpp index 5fea57486..c6714cf05 100644 --- a/modules/core/cs_access.cpp +++ b/modules/core/cs_access.cpp @@ -108,12 +108,16 @@ class AccessDelCallback : public NumberList { User *u; ChannelInfo *ci; + Command *c; unsigned Deleted; Anope::string Nicks; bool Denied; + bool override; public: - AccessDelCallback(User *_u, ChannelInfo *_ci, const Anope::string &numlist) : NumberList(numlist, true), u(_u), ci(_ci), Deleted(0), Denied(false) + AccessDelCallback(User *_u, ChannelInfo *_ci, Command *_c, const Anope::string &numlist) : NumberList(numlist, true), u(_u), ci(_ci), c(_c), Deleted(0), Denied(false) { + if (!check_access(u, ci, CA_ACCESS_CHANGE) && u->Account()->HasPriv("chanserv/access/modify")) + this->override = true; } ~AccessDelCallback() @@ -124,7 +128,7 @@ class AccessDelCallback : public NumberList notice_lang(Config->s_ChanServ, u, CHAN_ACCESS_NO_MATCH, ci->name.c_str()); else { - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " (level " << get_access(u, ci) << ") deleted access of user" << (Deleted == 1 ? " " : "s ") << Nicks << " on " << ci->name; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, c, ci) << "for user" << (Deleted == 1 ? " " : "s ") << Nicks; if (Deleted == 1) notice_lang(Config->s_ChanServ, u, CHAN_ACCESS_DELETED_ONE, ci->name.c_str()); @@ -183,6 +187,8 @@ class CommandCSAccess : public Command return MOD_CONT; } + bool override = !check_access(u, ci, CA_ACCESS_CHANGE) || level >= ulev; + NickAlias *na = findnick(nick); if (!na) { @@ -214,7 +220,7 @@ class CommandCSAccess : public Command FOREACH_MOD(I_OnAccessChange, OnAccessChange(ci, u, na->nc, level)); - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " (level " << ulev << ") set access level " << access->level << " to " << na->nick << " (group " << nc->display << ") on channel " << ci->name; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "ADD " << na->nick << "(group: " << nc->display << ") as level " << ulev; notice_lang(Config->s_ChanServ, u, CHAN_ACCESS_LEVEL_CHANGED, nc->display.c_str(), ci->name.c_str(), level); return MOD_CONT; } @@ -229,7 +235,7 @@ class CommandCSAccess : public Command FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, u, nc, level)); - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " (level " << ulev << ") set access level " << level << " to " << na->nick << " (group " << nc->display << ") on channel " << ci->name; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "ADD " << na->nick << "(group: " << nc->display << ") as level " << ulev; notice_lang(Config->s_ChanServ, u, CHAN_ACCESS_ADDED, nc->display.c_str(), ci->name.c_str(), level); return MOD_CONT; @@ -243,7 +249,7 @@ class CommandCSAccess : public Command notice_lang(Config->s_ChanServ, u, CHAN_ACCESS_LIST_EMPTY, ci->name.c_str()); else if (isdigit(nick[0]) && nick.find_first_not_of("1234567890,-") == Anope::string::npos) { - AccessDelCallback list(u, ci, nick); + AccessDelCallback list(u, ci, this, nick); list.Process(); } else @@ -274,7 +280,9 @@ class CommandCSAccess : public Command else { notice_lang(Config->s_ChanServ, u, CHAN_ACCESS_DELETED, access->nc->display.c_str(), ci->name.c_str()); - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " (level " << get_access(u, ci) << ") deleted access of " << na->nick << " (group " << access->nc->display << ") on " << ci->name; + bool override = !check_access(u, ci, CA_ACCESS_CHANGE); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "DEL " << na->nick << "(group: " << access->nc->display << ") from level " << access->level; + FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, u, na->nc)); ci->EraseAccess(i); @@ -375,7 +383,9 @@ class CommandCSAccess : public Command FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, u)); notice_lang(Config->s_ChanServ, u, CHAN_ACCESS_CLEAR, ci->name.c_str()); - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " (level " << get_access(u, ci) << " cleared access list on " << ci->name; + + bool override = !IsFounder(u, ci); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "CLEAR"; } return MOD_CONT; @@ -471,7 +481,10 @@ class CommandCSLevels : public Command { ci->levels[levelinfo[i].what] = level; FOREACH_MOD(I_OnLevelChange, OnLevelChange(u, ci, i, level)); - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " set level " << levelinfo[i].name << " on channel " << ci->name << " to " << level; + + bool override = !check_access(u, ci, CA_FOUNDER); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "SET " << levelinfo[i].name << " to " << level; + if (level == ACCESS_FOUNDER) notice_lang(Config->s_ChanServ, u, CHAN_LEVELS_CHANGED_FOUNDER, levelinfo[i].name.c_str(), ci->name.c_str()); else @@ -498,7 +511,9 @@ class CommandCSLevels : public Command ci->levels[levelinfo[i].what] = ACCESS_INVALID; FOREACH_MOD(I_OnLevelChange, OnLevelChange(u, ci, i, levelinfo[i].what)); - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " disabled level " << levelinfo[i].name << " on channel " << ci->name; + bool override = !check_access(u, ci, CA_FOUNDER); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "DISABLE " << levelinfo[i].name; + notice_lang(Config->s_ChanServ, u, CHAN_LEVELS_DISABLED, levelinfo[i].name.c_str(), ci->name.c_str()); return MOD_CONT; } @@ -547,7 +562,10 @@ class CommandCSLevels : public Command { reset_levels(ci); FOREACH_MOD(I_OnLevelChange, OnLevelChange(u, ci, -1, 0)); - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " reset levels definitions on channel " << ci->name; + + bool override = !check_access(u, ci, CA_FOUNDER); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "RESET"; + notice_lang(Config->s_ChanServ, u, CHAN_LEVELS_RESET, ci->name.c_str()); return MOD_CONT; } diff --git a/modules/core/cs_akick.cpp b/modules/core/cs_akick.cpp index c3d3c77b5..5df1a9038 100644 --- a/modules/core/cs_akick.cpp +++ b/modules/core/cs_akick.cpp @@ -138,14 +138,18 @@ class AkickDelCallback : public NumberList { User *u; ChannelInfo *ci; + Command *c; unsigned Deleted; public: - AkickDelCallback(User *_u, ChannelInfo *_ci, const Anope::string &list) : NumberList(list, true), u(_u), ci(_ci), Deleted(0) + AkickDelCallback(User *_u, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), u(_u), ci(_ci), c(_c), Deleted(0) { } ~AkickDelCallback() { + bool override = !check_access(u, ci, CA_AKICK); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, c, ci) << "DEL on " << Deleted << " users"; + if (!Deleted) notice_lang(Config->s_ChanServ, u, CHAN_AKICK_NO_MATCH, ci->name.c_str()); else if (Deleted == 1) @@ -266,6 +270,9 @@ class CommandCSAKick : public Command else akick = ci->AddAkick(u->nick, mask, reason); + bool override = !check_access(u, ci, CA_AKICK); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "ADD " << mask << ": " << reason; + FOREACH_MOD(I_OnAkickAdd, OnAkickAdd(u, ci, akick)); notice_lang(Config->s_ChanServ, u, CHAN_AKICK_ADDED, mask.c_str(), ci->name.c_str()); @@ -306,6 +313,9 @@ class CommandCSAKick : public Command return; } + bool override = !check_access(u, ci, CA_AKICK); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "STICK " << akick->mask; + akick->SetFlag(AK_STUCK); notice_lang(Config->s_ChanServ, u, CHAN_AKICK_STUCK, akick->mask.c_str(), ci->name.c_str()); @@ -346,6 +356,9 @@ class CommandCSAKick : public Command return; } + bool override = !check_access(u, ci, CA_AKICK); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "UNSTICK " << akick->mask; + akick->UnsetFlag(AK_STUCK); notice_lang(Config->s_ChanServ, u, CHAN_AKICK_UNSTUCK, akick->mask.c_str(), ci->name.c_str()); } @@ -365,7 +378,7 @@ class CommandCSAKick : public Command /* Special case: is it a number/list? Only do search if it isn't. */ if (isdigit(mask[0]) && mask.find_first_not_of("1234567890,-") == Anope::string::npos) { - AkickDelCallback list(u, ci, mask); + AkickDelCallback list(u, ci, this, mask); list.Process(); } else @@ -387,6 +400,9 @@ class CommandCSAKick : public Command return; } + bool override = !check_access(u, ci, CA_AKICK); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "DEL " << mask; + ci->EraseAkick(i); notice_lang(Config->s_ChanServ, u, CHAN_AKICK_DELETED, mask.c_str(), ci->name.c_str()); @@ -397,6 +413,9 @@ class CommandCSAKick : public Command { Anope::string mask = params.size() > 2 ? params[2] : ""; + bool override = !check_access(u, ci, CA_AKICK); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "LIST"; + if (!ci->GetAkickCount()) { notice_lang(Config->s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); @@ -442,6 +461,9 @@ class CommandCSAKick : public Command { Anope::string mask = params.size() > 2 ? params[2] : ""; + bool override = !check_access(u, ci, CA_AKICK); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "VIEW"; + if (!ci->GetAkickCount()) { notice_lang(Config->s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); @@ -502,11 +524,17 @@ class CommandCSAKick : public Command ++count; } + bool override = !check_access(u, ci, CA_AKICK); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "ENFORCE, affects " << count << " users"; + notice_lang(Config->s_ChanServ, u, CHAN_AKICK_ENFORCE_DONE, ci->name.c_str(), count); } void DoClear(User *u, ChannelInfo *ci) { + bool override = !check_access(u, ci, CA_AKICK); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "CLEAR"; + ci->ClearAkick(); notice_lang(Config->s_ChanServ, u, CHAN_AKICK_CLEAR, ci->name.c_str()); } diff --git a/modules/core/cs_ban.cpp b/modules/core/cs_ban.cpp index 500db20f5..fcc11d393 100644 --- a/modules/core/cs_ban.cpp +++ b/modules/core/cs_ban.cpp @@ -56,8 +56,11 @@ class CommandCSBan : public Command else { Anope::string mask; - get_idealban(ci, u2, mask); + + // XXX need a way to detect if someone is overriding + Log(LOG_COMMAND, u, this, ci) << "for " << mask; + c->SetMode(NULL, CMODE_BAN, mask); /* We still allow host banning while not allowing to kick */ diff --git a/modules/core/cs_clear.cpp b/modules/core/cs_clear.cpp index 42a9bd53a..1fa61fc56 100644 --- a/modules/core/cs_clear.cpp +++ b/modules/core/cs_clear.cpp @@ -34,9 +34,13 @@ class CommandCSClear : public Command ChannelMode *halfop = ModeManager::FindChannelModeByName(CMODE_HALFOP); ChannelMode *voice = ModeManager::FindChannelModeByName(CMODE_VOICE); + if (c) + // XXX + Log(LOG_COMMAND, u, this, ci) << what; + if (!c) notice_lang(Config->s_ChanServ, u, CHAN_X_NOT_IN_USE, chan.c_str()); - else if (!u || !check_access(u, ci, CA_CLEAR)) + else if (!check_access(u, ci, CA_CLEAR)) notice_lang(Config->s_ChanServ, u, ACCESS_DENIED); else if (what.equals_ci("bans")) { diff --git a/modules/core/cs_drop.cpp b/modules/core/cs_drop.cpp index 608fe3664..4ac066927 100644 --- a/modules/core/cs_drop.cpp +++ b/modules/core/cs_drop.cpp @@ -53,8 +53,6 @@ class CommandCSDrop : public Command return MOD_CONT; } - int level = get_access(u, ci); - if (ci->c && ModeManager::FindChannelModeByName(CMODE_REGISTERED)) ci->c->RemoveMode(NULL, CMODE_REGISTERED, "", false); @@ -64,16 +62,13 @@ class CommandCSDrop : public Command ircdproto->SendSQLineDel(&x); } - Alog() << Config->s_ChanServ << ": Channel " << ci->name << " dropped by " << u->GetMask() << " (founder: " << (ci->founder ? ci->founder->display : "(none)") << ")"; + bool override = (ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !check_access(u, ci, CA_FOUNDER)); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "founder: " << (ci->founder ? ci->founder->display : "none"); + if (override) + ircdproto->SendGlobops(ChanServ, "\2%s\2 used DROP on channel \2%s\2", u->nick.c_str(), ci->name.c_str()); delete ci; - /* We must make sure that the Services admin has not normally the right to - * drop the channel before issuing the wallops. - */ - if (Config->WallDrop && (level < ACCESS_FOUNDER || (!IsFounder(u, ci) && ci->HasFlag(CI_SECUREFOUNDER)))) - ircdproto->SendGlobops(ChanServ, "\2%s\2 used DROP on channel \2%s\2", u->nick.c_str(), chan.c_str()); - notice_lang(Config->s_ChanServ, u, CHAN_DROPPED, chan.c_str()); FOREACH_MOD(I_OnChanDrop, OnChanDrop(chan)); diff --git a/modules/core/cs_forbid.cpp b/modules/core/cs_forbid.cpp index 09fddd091..706d5e4a8 100644 --- a/modules/core/cs_forbid.cpp +++ b/modules/core/cs_forbid.cpp @@ -53,7 +53,8 @@ class CommandCSForbid : public Command ci = new ChannelInfo(chan); if (!ci) { - Alog() << Config->s_ChanServ << ": Valid FORBID for " << ci->name << " by " << u->nick << " failed"; + // this cant happen? + //Alog() << Config->s_ChanServ << ": Valid FORBID for " << ci->name << " by " << u->nick << " failed"; notice_lang(Config->s_ChanServ, u, CHAN_FORBID_FAILED, chan.c_str()); return MOD_CONT; } @@ -80,16 +81,16 @@ class CommandCSForbid : public Command } } - if (Config->WallForbid) - ircdproto->SendGlobops(ChanServ, "\2%s\2 used FORBID on channel \2%s\2", u->nick.c_str(), ci->name.c_str()); - if (ircd->chansqline) { XLine x(chan, "Forbidden"); ircdproto->SendSQLine(&x); } - Alog() << Config->s_ChanServ << ": " << u->nick << " set FORBID for channel " << ci->name; + if (Config->WallForbid) + ircdproto->SendGlobops(ChanServ, "\2%s\2 used FORBID on channel \2%s\2", u->nick.c_str(), ci->name.c_str()); + Log(LOG_ADMIN, u, this, ci) << (!ci->forbidreason.empty() ? ci->forbidreason : "No reason"); + notice_lang(Config->s_ChanServ, u, CHAN_FORBID_SUCCEEDED, chan.c_str()); FOREACH_MOD(I_OnChanForbidden, OnChanForbidden(ci)); diff --git a/modules/core/cs_getkey.cpp b/modules/core/cs_getkey.cpp index c39000ea3..a3e80b424 100644 --- a/modules/core/cs_getkey.cpp +++ b/modules/core/cs_getkey.cpp @@ -40,6 +40,9 @@ class CommandCSGetKey : public Command return MOD_CONT; } + bool override = !check_access(u, ci, CA_GETKEY); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci); + notice_lang(Config->s_ChanServ, u, CHAN_GETKEY_KEY, chan.c_str(), key.c_str()); return MOD_CONT; } diff --git a/modules/core/cs_invite.cpp b/modules/core/cs_invite.cpp index 926375b3e..c841627a9 100644 --- a/modules/core/cs_invite.cpp +++ b/modules/core/cs_invite.cpp @@ -35,7 +35,7 @@ class CommandCSInvite : public Command ci = c->ci; - if (!u || !check_access(u, ci, CA_INVITE)) + if (!check_access(u, ci, CA_INVITE)) { notice_lang(Config->s_ChanServ, u, ACCESS_DENIED); return MOD_CONT; @@ -52,6 +52,9 @@ class CommandCSInvite : public Command } } + // XXX need a check for override... + Log(LOG_COMMAND, u, this, ci) << "for " << u2->nick; + if (c->FindUser(u2)) notice_lang(Config->s_ChanServ, u, CHAN_INVITE_ALREADY_IN, c->name.c_str()); else diff --git a/modules/core/cs_kick.cpp b/modules/core/cs_kick.cpp index 06f0004b8..4deb19b13 100644 --- a/modules/core/cs_kick.cpp +++ b/modules/core/cs_kick.cpp @@ -51,6 +51,9 @@ class CommandCSKick : public Command notice_lang(Config->s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick.c_str(), c->name.c_str()); else { + // XXX + Log(LOG_COMMAND, u, this, ci) << "for " << u2->nick; + if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !check_access(u, ci, CA_SIGNKICK))) ci->c->Kick(whosends(ci), u2, "%s (%s)", reason.c_str(), u->nick.c_str()); else diff --git a/modules/core/cs_modes.cpp b/modules/core/cs_modes.cpp index 274c7e5af..54bc09d11 100644 --- a/modules/core/cs_modes.cpp +++ b/modules/core/cs_modes.cpp @@ -15,6 +15,7 @@ /** do_util: not a command, but does the job of others * @param u The user doing the command + * @param com The command calling this function * @param cm A channel mode class * @param chan The channel its being set on * @param nick The nick the modes being set on @@ -24,22 +25,14 @@ * @param name The name, eg "OP" or "HALFOP" * @param notice Flag required on a channel to send a notice */ -static CommandReturn do_util(User *u, ChannelMode *cm, const Anope::string &chan, const Anope::string &nick, bool set, int level, int levelself, const Anope::string &name, ChannelInfoFlag notice) +static CommandReturn do_util(User *u, Command *com, ChannelMode *cm, const Anope::string &chan, const Anope::string &nick, bool set, int level, int levelself, const Anope::string &name, ChannelInfoFlag notice) { Channel *c = findchan(chan); - ChannelInfo *ci; + ChannelInfo *ci = c ? c->ci : NULL; User *u2; - Anope::string realnick = nick; - int is_same; - - if (realnick.empty()) - realnick = u->nick; - - is_same = u->nick.equals_cs(realnick) ? 1 : u->nick.equals_ci(realnick); - - if (c) - ci = c->ci; + Anope::string realnick = (!nick.empty() ? nick : u->nick); + bool is_same = u->nick.equals_ci(realnick); if (!c) notice_lang(Config->s_ChanServ, u, CHAN_X_NOT_IN_USE, chan.c_str()); @@ -60,6 +53,7 @@ static CommandReturn do_util(User *u, ChannelMode *cm, const Anope::string &chan else c->RemoveMode(NULL, cm, u2->nick); + Log(LOG_COMMAND, u, com, ci) << "for " << u2->nick; if (notice && ci->HasFlag(notice)) ircdproto->SendMessage(whosends(ci), c->name, "%s command used for %s by %s", name.c_str(), u2->nick.c_str(), u->nick.c_str()); } @@ -78,7 +72,7 @@ class CommandCSOp : public Command { ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_OP); - return do_util(u, cm, !params.empty() ? params[0] : "", params.size() > 1 ? params[1] : "", true, CA_OPDEOP, CA_OPDEOPME, "OP", CI_OPNOTICE); + return do_util(u, this, cm, params[0], params.size() > 1 ? params[1] : "", true, CA_OPDEOP, CA_OPDEOPME, "OP", CI_OPNOTICE); } bool OnHelp(User *u, const Anope::string &subcommand) @@ -109,7 +103,7 @@ class CommandCSDeOp : public Command { ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_OP); - return do_util(u, cm, !params.empty() ? params[0] : "", params.size() > 1 ? params[1] : "", false, CA_OPDEOP, CA_OPDEOPME, "DEOP", CI_OPNOTICE); + return do_util(u, this, cm, params[0], params.size() > 1 ? params[1] : "", false, CA_OPDEOP, CA_OPDEOPME, "DEOP", CI_OPNOTICE); } bool OnHelp(User *u, const Anope::string &subcommand) @@ -140,7 +134,7 @@ class CommandCSVoice : public Command { ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_VOICE); - return do_util(u, cm, !params.empty() ? params[0] : "", params.size() > 1 ? params[1] : "", true, CA_VOICE, CA_VOICEME, "VOICE", CI_BEGIN); + return do_util(u, this, cm, params[0], params.size() > 1 ? params[1] : "", true, CA_VOICE, CA_VOICEME, "VOICE", CI_BEGIN); } bool OnHelp(User *u, const Anope::string &subcommand) @@ -171,7 +165,7 @@ class CommandCSDeVoice : public Command { ChannelMode *cm = ModeManager::FindChannelModeByName(CMODE_VOICE); - return do_util(u, cm, !params.empty() ? params[0] : "", params.size() > 1 ? params[1] : "", false, CA_VOICE, CA_VOICEME, "DEVOICE", CI_BEGIN); + return do_util(u, this, cm, params[0], params.size() > 1 ? params[1] : "", false, CA_VOICE, CA_VOICEME, "DEVOICE", CI_BEGIN); } bool OnHelp(User *u, const Anope::string &subcommand) @@ -207,7 +201,7 @@ class CommandCSHalfOp : public Command return MOD_CONT; } - return do_util(u, cm, !params.empty() ? params[0] : "", params.size() > 1 ? params[1] : "", true, CA_HALFOP, CA_HALFOPME, "HALFOP", CI_BEGIN); + return do_util(u, this, cm, params[0], params.size() > 1 ? params[1] : "", true, CA_HALFOP, CA_HALFOPME, "HALFOP", CI_BEGIN); } bool OnHelp(User *u, const Anope::string &subcommand) @@ -241,7 +235,7 @@ class CommandCSDeHalfOp : public Command if (!cm) return MOD_CONT; - return do_util(u, cm, !params.empty() ? params[0] : "", params.size() > 1 ? params[1] : "", false, CA_HALFOP, CA_HALFOPME, "DEHALFOP", CI_BEGIN); + return do_util(u, this, cm, params[0], params.size() > 1 ? params[1] : "", false, CA_HALFOP, CA_HALFOPME, "DEHALFOP", CI_BEGIN); } bool OnHelp(User *u, const Anope::string &subcommand) @@ -275,7 +269,7 @@ class CommandCSProtect : public Command if (!cm) return MOD_CONT; - return do_util(u, cm, !params.empty() ? params[0] : "", params.size() > 1 ? params[1] : "", true, CA_PROTECT, CA_PROTECTME, "PROTECT", CI_BEGIN); + return do_util(u, this, cm, params[0], params.size() > 1 ? params[1] : "", true, CA_PROTECT, CA_PROTECTME, "PROTECT", CI_BEGIN); } bool OnHelp(User *u, const Anope::string &subcommand) @@ -309,7 +303,7 @@ class CommandCSDeProtect : public Command if (!cm) return MOD_CONT; - return do_util(u, cm, !params.empty() ? params[0] : "", params.size() > 1 ? params[1] : "", false, CA_PROTECT, CA_PROTECTME, "DEPROTECT", CI_BEGIN); + return do_util(u, this, cm, params[0], params.size() > 1 ? params[1] : "", false, CA_PROTECT, CA_PROTECTME, "DEPROTECT", CI_BEGIN); } bool OnHelp(User *u, const Anope::string &subcommand) @@ -343,7 +337,7 @@ class CommandCSOwner : public Command if (!cm) return MOD_CONT; - return do_util(u, cm, !params.empty() ? params[0] : "", params.size() > 1 ? params[1] : "", true, CA_OWNER, CA_OWNERME, "OWNER", CI_BEGIN); + return do_util(u, this, cm, params[0], params.size() > 1 ? params[1] : "", true, CA_OWNER, CA_OWNERME, "OWNER", CI_BEGIN); } bool OnHelp(User *u, const Anope::string &subcommand) @@ -377,7 +371,7 @@ class CommandCSDeOwner : public Command if (!cm) return MOD_CONT; - return do_util(u, cm, !params.empty() ? params[0] : "", params.size() > 1 ? params[1] : "", false, CA_OWNER, CA_OWNERME, "DEOWNER", CI_BEGIN); + return do_util(u, this, cm, params[0], params.size() > 1 ? params[1] : "", false, CA_OWNER, CA_OWNERME, "DEOWNER", CI_BEGIN); } bool OnHelp(User *u, const Anope::string &subcommand) diff --git a/modules/core/cs_register.cpp b/modules/core/cs_register.cpp index 70a436fa5..545f3f5a1 100644 --- a/modules/core/cs_register.cpp +++ b/modules/core/cs_register.cpp @@ -49,16 +49,12 @@ class CommandCSRegister : public Command notice_lang(Config->s_ChanServ, u, u->Account()->channelcount > Config->CSMaxReg ? CHAN_EXCEEDED_CHANNEL_LIMIT : CHAN_REACHED_CHANNEL_LIMIT, Config->CSMaxReg); else if (!(ci = new ChannelInfo(chan))) { - Alog() << Config->s_ChanServ << ": makechan() failed for REGISTER " << chan; + // not possible ? + //Alog() << Config->s_ChanServ << ": makechan() failed for REGISTER " << chan; notice_lang(Config->s_ChanServ, u, CHAN_REGISTRATION_FAILED); } else { - if (c) - { - c->ci = ci; - ci->c = c; - } ci->founder = u->Account(); ci->desc = desc; @@ -73,7 +69,7 @@ class CommandCSRegister : public Command ci->bi = NULL; ++ci->founder->channelcount; - Alog() << Config->s_ChanServ << ": Channel '" << chan << "' registered by " << u->GetMask(); + Log(LOG_COMMAND, u, this, ci); notice_lang(Config->s_ChanServ, u, CHAN_REGISTERED, chan.c_str(), u->nick.c_str()); /* Implement new mode lock */ diff --git a/modules/core/cs_saset.cpp b/modules/core/cs_saset.cpp index 61ae2f299..923848e7a 100644 --- a/modules/core/cs_saset.cpp +++ b/modules/core/cs_saset.cpp @@ -40,9 +40,11 @@ class CommandCSSASet : public Command if (c) { - Anope::string cmdparams = cs_findchan(params[0])->name; + ChannelInfo *ci = cs_findchan(params[0]); + Anope::string cmdparams = ci->name; for (std::vector::const_iterator it = params.begin() + 2, it_end = params.end(); it != it_end; ++it) cmdparams += " " + *it; + Log(LOG_ADMIN, u, this, ci) << params[1] << " " << cmdparams; mod_run_cmd(ChanServ, u, c, params[1], cmdparams); } else diff --git a/modules/core/cs_set.cpp b/modules/core/cs_set.cpp index dd2063ffe..ede39c3c7 100644 --- a/modules/core/cs_set.cpp +++ b/modules/core/cs_set.cpp @@ -45,7 +45,8 @@ class CommandCSSet : public Command if (c) { - Anope::string cmdparams = cs_findchan(params[0])->name; + ChannelInfo *ci = cs_findchan(params[0]); + Anope::string cmdparams = ci->name; for (std::vector::const_iterator it = params.begin() + 2, it_end = params.end(); it != it_end; ++it) cmdparams += " " + *it; mod_run_cmd(ChanServ, u, c, params[1], cmdparams); diff --git a/modules/core/cs_set_founder.cpp b/modules/core/cs_set_founder.cpp index b6af6220a..ee955d590 100644 --- a/modules/core/cs_set_founder.cpp +++ b/modules/core/cs_set_founder.cpp @@ -53,7 +53,7 @@ class CommandCSSetFounder : public Command return MOD_CONT; } - Alog() << Config->s_ChanServ << ": Changing founder of " << ci->name << " from " << ci->founder->display << " to " << nc->display << " by " << u->GetMask(); + Log(!this->permission.empty() ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << "to change the founder to " << nc->display; /* Founder and successor must not be the same group */ if (nc == ci->successor) diff --git a/modules/core/cs_set_successor.cpp b/modules/core/cs_set_successor.cpp index 7478651c4..b4e0972c6 100644 --- a/modules/core/cs_set_successor.cpp +++ b/modules/core/cs_set_successor.cpp @@ -58,7 +58,7 @@ class CommandCSSetSuccessor : public Command else nc = NULL; - Alog() << Config->s_ChanServ << ": Changing successor of " << ci->name << " from " << (ci->successor ? ci->successor->display : "none") << " to " << (nc ? nc->display : "none") << " by " << u->GetMask(); + Log(!this->permission.empty() ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << "to change the successor from " << (ci->successor ? ci->successor->display : "none") << " to " << (nc ? nc->display : "none"); ci->successor = nc; diff --git a/modules/core/cs_set_xop.cpp b/modules/core/cs_set_xop.cpp index 18e4df76d..e08b014a1 100644 --- a/modules/core/cs_set_xop.cpp +++ b/modules/core/cs_set_xop.cpp @@ -64,14 +64,14 @@ class CommandCSSetXOP : public Command ci->SetFlag(CI_XOP); } - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " enabled XOP for " << ci->name; + Log(LOG_COMMAND, u, this, ci) << "to enable XOP"; notice_lang(Config->s_ChanServ, u, CHAN_SET_XOP_ON, ci->name.c_str()); } else if (params[1].equals_ci("OFF")) { ci->UnsetFlag(CI_XOP); - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " disabled XOP for " << ci->name; + Log(LOG_COMMAND, u, this, ci) << "to disable XOP"; notice_lang(Config->s_ChanServ, u, CHAN_SET_XOP_OFF, ci->name.c_str()); } else diff --git a/modules/core/cs_suspend.cpp b/modules/core/cs_suspend.cpp index 7af933a69..055b8b0e7 100644 --- a/modules/core/cs_suspend.cpp +++ b/modules/core/cs_suspend.cpp @@ -74,14 +74,15 @@ class CommandCSSuspend : public Command if (Config->WallForbid) ircdproto->SendGlobops(ChanServ, "\2%s\2 used SUSPEND on channel \2%s\2", u->nick.c_str(), ci->name.c_str()); - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " set SUSPEND for channel " << ci->name; + Log(LOG_ADMIN, u, this, ci) << (!reason.empty() ? reason : "No reason"); notice_lang(Config->s_ChanServ, u, CHAN_SUSPEND_SUCCEEDED, chan.c_str()); FOREACH_MOD(I_OnChanSuspend, OnChanSuspend(ci)); } else { - Alog() << Config->s_ChanServ << ": Valid SUSPEND for " << ci->name << " by " << u->GetMask() << " failed"; + // cant happen? + //Alog() << Config->s_ChanServ << ": Valid SUSPEND for " << ci->name << " by " << u->GetMask() << " failed"; notice_lang(Config->s_ChanServ, u, CHAN_SUSPEND_FAILED, chan.c_str()); } return MOD_CONT; @@ -134,6 +135,8 @@ class CommandCSUnSuspend : public Command if (ci) { + Log(LOG_ADMIN, u, this, ci) << " was suspended for: " << (!ci->forbidreason.empty() ? ci->forbidreason : "No reason"); + ci->UnsetFlag(CI_SUSPENDED); ci->forbidreason.clear(); ci->forbidby.clear(); @@ -141,14 +144,14 @@ class CommandCSUnSuspend : public Command if (Config->WallForbid) ircdproto->SendGlobops(ChanServ, "\2%s\2 used UNSUSPEND on channel \2%s\2", u->nick.c_str(), ci->name.c_str()); - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " set UNSUSPEND for channel " << ci->name; notice_lang(Config->s_ChanServ, u, CHAN_UNSUSPEND_SUCCEEDED, chan.c_str()); FOREACH_MOD(I_OnChanUnsuspend, OnChanUnsuspend(ci)); } else { - Alog() << Config->s_ChanServ << ": Valid UNSUSPEND for " << chan << " by " << u->nick << " failed"; + // cant happen ? + //Alog() << Config->s_ChanServ << ": Valid UNSUSPEND for " << chan << " by " << u->nick << " failed"; notice_lang(Config->s_ChanServ, u, CHAN_UNSUSPEND_FAILED, chan.c_str()); } return MOD_CONT; diff --git a/modules/core/cs_topic.cpp b/modules/core/cs_topic.cpp index 5a421e272..ebd09b385 100644 --- a/modules/core/cs_topic.cpp +++ b/modules/core/cs_topic.cpp @@ -25,11 +25,8 @@ class CommandCSTopic : public Command Anope::string chan = params[0]; Anope::string topic = params.size() > 1 ? params[1] : ""; - Channel *c; - ChannelInfo *ci; - - if ((c = findchan(chan))) - ci = c->ci; + ChannelInfo *ci = cs_findchan(params[0]); + Channel *c = ci->c; if (!c) notice_lang(Config->s_ChanServ, u, CHAN_X_NOT_IN_USE, chan.c_str()); @@ -48,9 +45,10 @@ class CommandCSTopic : public Command else c->topic_time = ci->last_topic_time; - if (!check_access(u, ci, CA_TOPIC)) - Alog() << Config->s_NickServ << ": " << u->GetMask() << " changed topic of " << c->name << " as services admin."; - if (ircd->join2set && whosends(ci) == ChanServ) + bool override = !check_access(u, ci, CA_TOPIC); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to change the topic to " << (!topic.empty() ? topic : "No topic"); + + if (ircd->join2set && whosends(ci) == ChanServ) // XXX what if the service bot is chanserv? { ChanServ->Join(c); ircdproto->SendMode(NULL, c, "+o %s", Config->s_ChanServ.c_str()); // XXX diff --git a/modules/core/cs_xop.cpp b/modules/core/cs_xop.cpp index 973febf0a..4ebec6926 100644 --- a/modules/core/cs_xop.cpp +++ b/modules/core/cs_xop.cpp @@ -150,11 +150,13 @@ class XOPDelCallback : public NumberList { User *u; ChannelInfo *ci; + Command *c; int *messages; unsigned Deleted; Anope::string Nicks; + bool override; public: - XOPDelCallback(User *_u, ChannelInfo *_ci, int *_messages, const Anope::string &numlist) : NumberList(numlist, true), u(_u), ci(_ci), messages(_messages), Deleted(0) + XOPDelCallback(User *_u, Command *_c, ChannelInfo *_ci, int *_messages, bool _override, const Anope::string &numlist) : NumberList(numlist, true), u(_u), ci(_ci), c(_c), messages(_messages), Deleted(0), override(_override) { } @@ -164,7 +166,7 @@ class XOPDelCallback : public NumberList notice_lang(Config->s_ChanServ, u, messages[XOP_NO_MATCH], ci->name.c_str()); else { - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " (level " << get_access(u, ci) << ") deleted access of users " << Nicks << " on " << ci->name; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, c, ci) << "deleted access of users " << Nicks; if (Deleted == 1) notice_lang(Config->s_ChanServ, u, messages[XOP_DELETED_ONE], ci->name.c_str()); @@ -263,7 +265,8 @@ class XOPBase : public Command access->creator = u->nick; } - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " (level " << ulev << ") " << (change ? "changed" : "set") << " access level " << level << " to " << na->nick << " (group " << nc->display << ") on channel " << ci->name; + bool override = (level >= ulev || ulev < ACCESS_AOP || (access && access->level > ulev)); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "ADD " << na->nick << " (group: " << nc->display << ") as level " << level; if (!change) { @@ -313,7 +316,8 @@ class XOPBase : public Command /* Special case: is it a number/list? Only do search if it isn't. */ if (isdigit(nick[0]) && nick.find_first_not_of("1234567890,-") == Anope::string::npos) { - XOPDelCallback list(u, ci, messages, nick); + bool override = level >= ulev || ulev < ACCESS_AOP; + XOPDelCallback list(u, this, ci, messages, override, nick); list.Process(); } else @@ -325,7 +329,6 @@ class XOPBase : public Command return MOD_CONT; } NickCore *nc = na->nc; - unsigned i, end; for (i = 0, end = ci->GetAccessCount(); i < end; ++i) { @@ -345,7 +348,8 @@ class XOPBase : public Command notice_lang(Config->s_ChanServ, u, ACCESS_DENIED); else { - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " (level " << get_access(u, ci) << ") deleted access of user " << access->nc->display << " on " << ci->name; + bool override = ulev <= access->level; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "DEL " << access->nc->display; notice_lang(Config->s_ChanServ, u, messages[XOP_DELETED], access->nc->display.c_str(), ci->name.c_str()); @@ -368,6 +372,9 @@ class XOPBase : public Command return MOD_CONT; } + bool override = !get_access(u, ci); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci); + if (!ci->GetAccessCount()) { notice_lang(Config->s_ChanServ, u, messages[XOP_LIST_EMPTY], ci->name.c_str()); @@ -426,6 +433,9 @@ class XOPBase : public Command return MOD_CONT; } + bool override = !check_access(u, ci, CA_FOUNDER); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "CLEAR level " << level; + for (unsigned i = ci->GetAccessCount(); i > 0; --i) { ChanAccess *access = ci->GetAccess(i - 1); diff --git a/modules/core/db_plain.cpp b/modules/core/db_plain.cpp index b05a1f896..6ac61ba11 100644 --- a/modules/core/db_plain.cpp +++ b/modules/core/db_plain.cpp @@ -46,7 +46,7 @@ static void ReadDatabase(Module *m = NULL) if (!db.is_open()) { - Alog() << "Unable to open " << DatabaseFile << " for reading!"; + Log() << "Unable to open " << DatabaseFile << " for reading!"; return; } @@ -132,7 +132,7 @@ static void ReadDatabase(Module *m = NULL) } catch (const DatabaseException &ex) { - Alog() << "[db_plain]: " << ex.GetReason(); + Log() << "[db_plain]: " << ex.GetReason(); } } else if (Type == MD_NA && na) @@ -146,7 +146,7 @@ static void ReadDatabase(Module *m = NULL) } catch (const DatabaseException &ex) { - Alog() << "[db_plain]: " << ex.GetReason(); + Log() << "[db_plain]: " << ex.GetReason(); } } else if (Type == MD_NR && nr) @@ -160,7 +160,7 @@ static void ReadDatabase(Module *m = NULL) } catch (const DatabaseException &ex) { - Alog() << "[db_plain]: " << ex.GetReason(); + Log() << "[db_plain]: " << ex.GetReason(); } } else if (Type == MD_BI && bi) @@ -174,7 +174,7 @@ static void ReadDatabase(Module *m = NULL) } catch (const DatabaseException &ex) { - Alog() << "[db_plain]: " << ex.GetReason(); + Log() << "[db_plain]: " << ex.GetReason(); } } else if (Type == MD_CH && ci) @@ -188,7 +188,7 @@ static void ReadDatabase(Module *m = NULL) } catch (const DatabaseException &ex) { - Alog() << "[db_plain]: " << ex.GetReason(); + Log() << "[db_plain]: " << ex.GetReason(); if (!ci->founder) { delete ci; @@ -362,7 +362,7 @@ static void LoadNickCore(const std::vector ¶ms) nc->pass = params[1]; - Alog(LOG_DEBUG_2) << "[db_plain]: Loaded NickCore " << nc->display; + Log(LOG_DEBUG_2) << "[db_plain]: Loaded NickCore " << nc->display; } static void LoadNickAlias(const std::vector ¶ms) @@ -370,7 +370,7 @@ static void LoadNickAlias(const std::vector ¶ms) NickCore *nc = findcore(params[0]); if (!nc) { - Alog() << "[db_plain]: Unable to find core " << params[0]; + Log() << "[db_plain]: Unable to find core " << params[0]; return; } @@ -380,7 +380,7 @@ static void LoadNickAlias(const std::vector ¶ms) na->last_seen = params[3].is_pos_number_only() ? convertTo(params[3]) : 0; - Alog(LOG_DEBUG_2) << "[db_plain}: Loaded nickalias for " << na->nick; + Log(LOG_DEBUG_2) << "[db_plain}: Loaded nickalias for " << na->nick; } static void LoadNickRequest(const std::vector ¶ms) @@ -391,21 +391,20 @@ static void LoadNickRequest(const std::vector ¶ms) nr->email = params[3]; nr->requested = params[4].is_pos_number_only() ? convertTo(params[4]) : 0; - Alog(LOG_DEBUG_2) << "[db_plain]: Loaded nickrequest for " << nr->nick; + Log(LOG_DEBUG_2) << "[db_plain]: Loaded nickrequest for " << nr->nick; } static void LoadBotInfo(const std::vector ¶ms) { BotInfo *bi = findbot(params[0]); if (!bi) - bi = new BotInfo(params[0]); - bi->SetIdent(params[1]); - bi->host = params[2]; + bi = new BotInfo(params[0], params[1], params[2]); + bi->created = params[3].is_pos_number_only() ? convertTo(params[3]) : 0; bi->chancount = params[4].is_pos_number_only() ? convertTo(params[4]) : 0; bi->realname = params[5]; - Alog(LOG_DEBUG_2) << "[db_plain]: Loaded botinfo for " << bi->nick; + Log(LOG_DEBUG_2) << "[db_plain]: Loaded botinfo for " << bi->nick; } static void LoadChanInfo(const std::vector ¶ms) @@ -421,7 +420,7 @@ static void LoadChanInfo(const std::vector ¶ms) ci->last_used = params[2].is_pos_number_only() ? convertTo(params[2]) : 0; - Alog(LOG_DEBUG_2) << "[db_plain]: loaded channel " << ci->name; + Log(LOG_DEBUG_2) << "[db_plain]: loaded channel " << ci->name; } static void LoadOperInfo(const std::vector ¶ms) @@ -533,11 +532,11 @@ class DBPlain : public Module if (IsFile(newname)) return; - Alog(LOG_DEBUG) << "db_plain: Attemping to rename " << DatabaseFile << " to " << newname; + Log(LOG_DEBUG) << "db_plain: Attemping to rename " << DatabaseFile << " to " << newname; if (rename(DatabaseFile.c_str(), newname.c_str())) { ircdproto->SendGlobops(OperServ, "Unable to backup database!"); - Alog() << "Unable to back up database!"; + Log() << "Unable to back up database!"; if (!Config->NoBackupOkay) quitting = true; diff --git a/modules/core/enc_md5.cpp b/modules/core/enc_md5.cpp index e75c7afeb..b3a826c23 100644 --- a/modules/core/enc_md5.cpp +++ b/modules/core/enc_md5.cpp @@ -336,7 +336,7 @@ class EMD5 : public Module MD5Final(reinterpret_cast(digest), &context); buf += Anope::Hex(digest, 16); - Alog(LOG_DEBUG_2) << "(enc_md5) hashed password from [" << src << "] to [" << buf << "]"; + Log(LOG_DEBUG_2) << "(enc_md5) hashed password from [" << src << "] to [" << buf << "]"; dest = buf; return EVENT_ALLOW; } diff --git a/modules/core/enc_none.cpp b/modules/core/enc_none.cpp index 445dcb767..f27df4f1b 100644 --- a/modules/core/enc_none.cpp +++ b/modules/core/enc_none.cpp @@ -28,7 +28,7 @@ class ENone : public Module Anope::string cpass; b64_encode(src, cpass); buf += cpass; - Alog(LOG_DEBUG_2) << "(enc_none) hashed password from [" << src << "] to [" << buf << "]"; + Log(LOG_DEBUG_2) << "(enc_none) hashed password from [" << src << "] to [" << buf << "]"; dest = buf; return EVENT_ALLOW; } diff --git a/modules/core/enc_old.cpp b/modules/core/enc_old.cpp index 6a100fd85..2103426c1 100644 --- a/modules/core/enc_old.cpp +++ b/modules/core/enc_old.cpp @@ -346,7 +346,7 @@ class EOld : public Module digest2[i / 2] = XTOI(digest[i]) << 4 | XTOI(digest[i + 1]); buf += Anope::Hex(digest2, 16); - Alog(LOG_DEBUG_2) << "(enc_old) hashed password from [" << src << "] to [" << buf << "]"; + Log(LOG_DEBUG_2) << "(enc_old) hashed password from [" << src << "] to [" << buf << "]"; dest = buf; return EVENT_ALLOW; } diff --git a/modules/core/enc_sha1.cpp b/modules/core/enc_sha1.cpp index 28175fd3f..8dc3b57ab 100644 --- a/modules/core/enc_sha1.cpp +++ b/modules/core/enc_sha1.cpp @@ -190,7 +190,7 @@ class ESHA1 : public Module SHA1Final(reinterpret_cast(digest), &context); buf += Anope::Hex(digest, 20); - Alog(LOG_DEBUG_2) << "(enc_sha1) hashed password from [" << src << "] to [" << buf << "]"; + Log(LOG_DEBUG_2) << "(enc_sha1) hashed password from [" << src << "] to [" << buf << "]"; dest = buf; return EVENT_ALLOW; } diff --git a/modules/core/enc_sha256.cpp b/modules/core/enc_sha256.cpp index 16a26a77b..6dbfc3eed 100644 --- a/modules/core/enc_sha256.cpp +++ b/modules/core/enc_sha256.cpp @@ -275,7 +275,7 @@ class ESHA256 : public Module SHA256Final(&ctx, reinterpret_cast(digest)); digest[SHA256_DIGEST_SIZE] = '\0'; buf << "sha256:" << Anope::Hex(digest, SHA256_DIGEST_SIZE) << ":" << GetIVString(); - Alog(LOG_DEBUG_2) << "(enc_sha256) hashed password from [" << src << "] to [" << buf.str() << " ]"; + Log(LOG_DEBUG_2) << "(enc_sha256) hashed password from [" << src << "] to [" << buf.str() << " ]"; dest = buf.str(); return EVENT_ALLOW; } diff --git a/modules/core/hs_del.cpp b/modules/core/hs_del.cpp index 4ef8d8424..9f3794c25 100644 --- a/modules/core/hs_del.cpp +++ b/modules/core/hs_del.cpp @@ -31,7 +31,7 @@ class CommandHSDel : public Command notice_lang(Config->s_HostServ, u, NICK_X_FORBIDDEN, nick.c_str()); return MOD_CONT; } - Alog() << "vHost for user \2" << nick << "\2 deleted by oper \2" << u->nick << "\2"; + Log(LOG_ADMIN, u, this) << "for user " << na->nick; FOREACH_MOD(I_OnDeleteVhost, OnDeleteVhost(na)); na->hostinfo.RemoveVhost(); notice_lang(Config->s_HostServ, u, HOST_DEL, nick.c_str()); diff --git a/modules/core/hs_delall.cpp b/modules/core/hs_delall.cpp index 301f14473..ca4d804a3 100644 --- a/modules/core/hs_delall.cpp +++ b/modules/core/hs_delall.cpp @@ -38,7 +38,7 @@ class CommandHSDelAll : public Command na = *it; na->hostinfo.RemoveVhost(); } - Alog() << "vHosts for all nicks in group \2" << nc->display << "\2 deleted by oper \2" << u->nick << "\2"; + Log(LOG_ADMIN, u, this) << "for all nicks in group " << nc->display; notice_lang(Config->s_HostServ, u, HOST_DELALL, nc->display.c_str()); } else diff --git a/modules/core/hs_off.cpp b/modules/core/hs_off.cpp index ef7039aeb..1338f14b3 100644 --- a/modules/core/hs_off.cpp +++ b/modules/core/hs_off.cpp @@ -29,6 +29,7 @@ class CommandHSOff : public Command else { ircdproto->SendVhostDel(u); + Log(LOG_COMMAND, u, this) << "to disable their vhost"; notice_lang(Config->s_HostServ, u, HOST_OFF); } diff --git a/modules/core/hs_on.cpp b/modules/core/hs_on.cpp index b94f22264..a57b8d8f2 100644 --- a/modules/core/hs_on.cpp +++ b/modules/core/hs_on.cpp @@ -29,6 +29,7 @@ class CommandHSOn : public Command notice_lang(Config->s_HostServ, u, HOST_IDENT_ACTIVATED, na->hostinfo.GetIdent().c_str(), na->hostinfo.GetHost().c_str()); else notice_lang(Config->s_HostServ, u, HOST_ACTIVATED, na->hostinfo.GetHost().c_str()); + Log(LOG_COMMAND, u, this) << "to enable their vhost of " << (!na->hostinfo.GetIdent().empty() ? na->hostinfo.GetIdent() + "@" : "") << na->hostinfo.GetHost(); ircdproto->SendVhost(u, na->hostinfo.GetIdent(), na->hostinfo.GetHost()); if (ircd->vhost) u->vhost = na->hostinfo.GetHost(); diff --git a/modules/core/hs_set.cpp b/modules/core/hs_set.cpp index 8ee6a8723..68407790a 100644 --- a/modules/core/hs_set.cpp +++ b/modules/core/hs_set.cpp @@ -81,7 +81,8 @@ class CommandHSSet : public Command notice_lang(Config->s_HostServ, u, NICK_X_FORBIDDEN, nick.c_str()); return MOD_CONT; } - Alog() << "vHost for user \2" << nick << "\2 set to \2" << (!vIdent.empty() && ircd->vident ? vIdent : "") << (!vIdent.empty() && ircd->vident ? "@" : "") << hostmask << " \2 by oper \2" << u->nick << "\2"; + + Log(LOG_ADMIN, u, this) << "to set the vhost of " << na->nick << " to " << (!vIdent.empty() ? vIdent + "@" : "") << hostmask; na->hostinfo.SetVhost(vIdent, hostmask, u->nick); FOREACH_MOD(I_OnSetVhost, OnSetVhost(na)); diff --git a/modules/core/hs_setall.cpp b/modules/core/hs_setall.cpp index 3ace182fd..bea594da6 100644 --- a/modules/core/hs_setall.cpp +++ b/modules/core/hs_setall.cpp @@ -86,7 +86,7 @@ class CommandHSSetAll : public Command tmp_time = time(NULL); - Alog() << "vHost for all nicks in group \2" << nick << "\2 set to \2" << (!vIdent.empty() && ircd->vident ? vIdent : "") << (!vIdent.empty() && ircd->vident ? "@" : "") << hostmask << " \2 by oper \2" << u->nick << "\2"; + Log(LOG_ADMIN, u, this) << "to set the vhost for all nicks in group " << na->nc->display << " to " << (!vIdent.empty() ? vIdent + "@" : "") << hostmask; na->hostinfo.SetVhost(vIdent, hostmask, u->nick); HostServSyncVhosts(na); diff --git a/modules/core/ms_rsend.cpp b/modules/core/ms_rsend.cpp index 03c643c11..6ed6b3b03 100644 --- a/modules/core/ms_rsend.cpp +++ b/modules/core/ms_rsend.cpp @@ -47,7 +47,7 @@ class CommandMSRSend : public Command else { /* rsend has been disabled */ - Alog(LOG_DEBUG) << "MSMemoReceipt is set misconfigured to " << Config->MSMemoReceipt; + Log() << "MSMemoReceipt is set misconfigured to " << Config->MSMemoReceipt; notice_lang(Config->s_MemoServ, u, MEMO_RSEND_DISABLED); } diff --git a/modules/core/ns_drop.cpp b/modules/core/ns_drop.cpp index 497a375f1..4180bf0e6 100644 --- a/modules/core/ns_drop.cpp +++ b/modules/core/ns_drop.cpp @@ -42,7 +42,7 @@ class CommandNSDrop : public Command { if (Config->WallDrop) ircdproto->SendGlobops(NickServ, "\2%s\2 used DROP on \2%s\2", u->nick.c_str(), nick.c_str()); - Alog() << Config->s_NickServ << ": " << u->GetMask() << " dropped nickname " << nr->nick << " (e-mail: " << nr->email << ")"; + Log(LOG_ADMIN, u, this) << "to drop nickname " << nr->nick << " (email: " << nr->email << ")"; delete nr; notice_lang(Config->s_NickServ, u, NICK_X_DROPPED, nick.c_str()); } @@ -73,7 +73,7 @@ class CommandNSDrop : public Command ircdproto->SendSQLineDel(&x); } - Alog() << Config->s_NickServ << ": " << u->GetMask() << " dropped nickname " << na->nick << " (group " << na->nc->display << ") (e-mail: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")"; + Log(!is_mine ? LOG_OVERRIDE : LOG_COMMAND, u, this) << "to drop nickname " << na->nick << " (group: " << na->nc->display << ") (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")"; delete na; FOREACH_MOD(I_OnNickDrop, OnNickDrop(!my_nick.empty() ? my_nick : nick)); diff --git a/modules/core/ns_forbid.cpp b/modules/core/ns_forbid.cpp index f10b1f04e..e7c3162a2 100644 --- a/modules/core/ns_forbid.cpp +++ b/modules/core/ns_forbid.cpp @@ -76,14 +76,15 @@ class CommandNSForbid : public Command if (Config->WallForbid) ircdproto->SendGlobops(NickServ, "\2%s\2 used FORBID on \2%s\2", u->nick.c_str(), nick.c_str()); - Alog() << Config->s_NickServ << ": " << u->nick << " set FORBID for nick " << nick; + Log(LOG_ADMIN, u, this) << "to forbid nick " << nick; notice_lang(Config->s_NickServ, u, NICK_FORBID_SUCCEEDED, nick.c_str()); FOREACH_MOD(I_OnNickForbidden, OnNickForbidden(na)); } else { - Alog() << Config->s_NickServ << ": Valid FORBID for " << nick << " by " << u->nick << " failed"; + // XXX cant happen ? + //Alog() << Config->s_NickServ << ": Valid FORBID for " << nick << " by " << u->nick << " failed"; notice_lang(Config->s_NickServ, u, NICK_FORBID_FAILED, nick.c_str()); } return MOD_CONT; diff --git a/modules/core/ns_getemail.cpp b/modules/core/ns_getemail.cpp index dbfb91562..1d8afcad1 100644 --- a/modules/core/ns_getemail.cpp +++ b/modules/core/ns_getemail.cpp @@ -29,7 +29,7 @@ class CommandNSGetEMail : public Command Anope::string email = params[0]; int j = 0; - Alog() << Config->s_NickServ << ": " << u->GetMask() << " used GETEMAIL on " << email; + Log(LOG_ADMIN, u, this) << "on " << email; for (nickcore_map::const_iterator it = NickCoreList.begin(), it_end = NickCoreList.end(); it != it_end; ++it) { diff --git a/modules/core/ns_getpass.cpp b/modules/core/ns_getpass.cpp index e4f196d23..a2d288cbc 100644 --- a/modules/core/ns_getpass.cpp +++ b/modules/core/ns_getpass.cpp @@ -31,7 +31,7 @@ class CommandNSGetPass : public Command { if ((nr = findrequestnick(nick))) { - Alog() << Config->s_NickServ << ": " << u->GetMask() << " used GETPASS on " << nick; + Log(LOG_ADMIN, u, this) << "for " << nr->nick; if (Config->WallGetpass) ircdproto->SendGlobops(NickServ, "\2%s\2 used GETPASS on \2%s\2", u->nick.c_str(), nick.c_str()); notice_lang(Config->s_NickServ, u, NICK_GETPASS_PASSCODE_IS, nick.c_str(), nr->passcode.c_str()); @@ -47,7 +47,7 @@ class CommandNSGetPass : public Command { if (enc_decrypt(na->nc->pass, tmp_pass) == 1) { - Alog() << Config->s_NickServ << ": " << u->GetMask() << " used GETPASS on " << nick; + Log(LOG_ADMIN, u, this) << "for " << nick; if (Config->WallGetpass) ircdproto->SendGlobops(NickServ, "\2%s\2 used GETPASS on \2%s\2", u->nick.c_str(), nick.c_str()); notice_lang(Config->s_NickServ, u, NICK_GETPASS_PASSWORD_IS, nick.c_str(), tmp_pass.c_str()); diff --git a/modules/core/ns_ghost.cpp b/modules/core/ns_ghost.cpp index 9c19b0af7..a4f1b5f8f 100644 --- a/modules/core/ns_ghost.cpp +++ b/modules/core/ns_ghost.cpp @@ -42,6 +42,7 @@ class CommandNSGhost : public Command int res = enc_check_password(pass, na->nc->pass); if (res == 1) { + Log(LOG_COMMAND, u, this) << "for " << nick; Anope::string buf = "GHOST command used by " + u->nick; kill_user(Config->s_NickServ, nick, buf); notice_lang(Config->s_NickServ, u, NICK_GHOST_KILLED, nick.c_str()); @@ -51,7 +52,7 @@ class CommandNSGhost : public Command notice_lang(Config->s_NickServ, u, ACCESS_DENIED); if (!res) { - Alog() << Config->s_NickServ << ": GHOST: invalid password for " << nick << " by " << u->GetMask(); + Log(LOG_COMMAND, u, this) << "invalid password for " << nick; if (bad_password(u)) return MOD_STOP; } @@ -61,6 +62,7 @@ class CommandNSGhost : public Command { if (u->Account() == na->nc || (!na->nc->HasFlag(NI_SECURE) && is_on_access(u, na->nc))) { + Log(LOG_COMMAND, u, this) << "for " << nick; Anope::string buf = "GHOST command used by " + u->nick; kill_user(Config->s_NickServ, nick, buf); notice_lang(Config->s_NickServ, u, NICK_GHOST_KILLED, nick.c_str()); diff --git a/modules/core/ns_group.cpp b/modules/core/ns_group.cpp index 915915af3..22fad9b3c 100644 --- a/modules/core/ns_group.cpp +++ b/modules/core/ns_group.cpp @@ -61,12 +61,12 @@ class CommandNSGroup : public Command notice_lang(Config->s_NickServ, u, NICK_GROUP_PLEASE_WAIT, (Config->NSRegDelay + u->lastnickreg) - time(NULL)); else if (u->Account() && u->Account()->HasFlag(NI_SUSPENDED)) { - Alog() << Config->s_NickServ << ": " << u->GetMask() << " tried to use GROUP from SUSPENDED nick " << target->nick; + //Alog() << Config->s_NickServ << ": " << u->GetMask() << " tried to use GROUP from SUSPENDED nick " << target->nick; notice_lang(Config->s_NickServ, u, NICK_X_SUSPENDED, u->nick.c_str()); } else if (target && target->nc->HasFlag(NI_SUSPENDED)) { - Alog() << Config->s_NickServ << ": " << u->GetMask() << " tried to use GROUP for SUSPENDED nick " << target->nick; + Log(LOG_COMMAND, u, this) << "tried to use GROUP for SUSPENDED nick " << target->nick; notice_lang(Config->s_NickServ, u, NICK_X_SUSPENDED, target->nick.c_str()); } else if (target->HasFlag(NS_FORBIDDEN)) @@ -82,7 +82,7 @@ class CommandNSGroup : public Command int res = enc_check_password(pass, target->nc->pass); if (res == -1) { - Alog() << Config->s_NickServ << ": Failed GROUP for " << u->GetMask() << " (invalid password)"; + Log(LOG_COMMAND, u, this) << "failed group for " << na->nick << " (invalid password)"; notice_lang(Config->s_NickServ, u, PASSWORD_INCORRECT); if (bad_password(u)) return MOD_STOP; @@ -119,8 +119,7 @@ class CommandNSGroup : public Command FOREACH_MOD(I_OnNickGroup, OnNickGroup(u, target)); ircdproto->SetAutoIdentificationToken(u); - Alog() << Config->s_NickServ << ": " << u->GetMask() << " makes " << u->nick << " join group of " << target->nick << " (" << target->nc->display << ") (e-mail: " << - (!target->nc->email.empty() ? target->nc->email : "none") << ")"; + Log(LOG_COMMAND, u, this) << "makes " << u->nick << " join group of " << target->nick << " (" << target->nc->display << ") (email: " << (!target->nc->email.empty() ? target->nc->email : "none") << ")"; notice_lang(Config->s_NickServ, u, NICK_GROUP_JOINED, target->nick.c_str()); u->lastnickreg = time(NULL); @@ -129,7 +128,8 @@ class CommandNSGroup : public Command } else { - Alog() << Config->s_NickServ << ": makealias(" << u->nick << ") failed"; + // XXX not possible? + //Alog() << Config->s_NickServ << ": makealias(" << u->nick << ") failed"; notice_lang(Config->s_NickServ, u, NICK_GROUP_FAILED); } } diff --git a/modules/core/ns_identify.cpp b/modules/core/ns_identify.cpp index 6746a6e02..c365de116 100644 --- a/modules/core/ns_identify.cpp +++ b/modules/core/ns_identify.cpp @@ -50,7 +50,7 @@ class CommandNSIdentify : public Command res = enc_check_password(pass, na->nc->pass); if (!res) { - Alog() << Config->s_NickServ << ": Failed IDENTIFY for " << u->nick << "!" << u->GetIdent() << "@" << u->host; + Log(LOG_COMMAND, u, this) << "failed to identify"; notice_lang(Config->s_NickServ, u, PASSWORD_INCORRECT); if (bad_password(u)) return MOD_STOP; @@ -60,7 +60,7 @@ class CommandNSIdentify : public Command else { if (u->IsIdentified()) - Alog() << Config->s_NickServ << ": " << u->GetMask() << " logged out of account " << u->Account()->display; + Log(LOG_COMMAND, "nickserv/identify") << "logged out of account " << u->Account()->display; na->last_realname = u->realname; na->last_seen = time(NULL); @@ -73,7 +73,7 @@ class CommandNSIdentify : public Command FOREACH_MOD(I_OnNickIdentify, OnNickIdentify(u)); - Alog() << Config->s_NickServ << ": " << u->GetMask() << " identified for account " << u->Account()->display; + Log(LOG_COMMAND, u, this) << "identified for account " << u->Account()->display; notice_lang(Config->s_NickServ, u, NICK_IDENTIFY_SUCCEEDED); if (ircd->vhost) do_on_id(u); diff --git a/modules/core/ns_logout.cpp b/modules/core/ns_logout.cpp index 7d0d69254..7d09f9111 100644 --- a/modules/core/ns_logout.cpp +++ b/modules/core/ns_logout.cpp @@ -38,7 +38,7 @@ class CommandNSLogout : public Command validate_user(u2); u2->isSuperAdmin = 0; /* Dont let people logout and remain a SuperAdmin */ - Alog() << Config->s_NickServ << ": " << u->GetMask() << " logged out nickname " << u2->nick; + Log(LOG_COMMAND, u, this) << "to logout " << u2->nick; /* Remove founder status from this user in all channels */ if (!nick.empty()) diff --git a/modules/core/ns_recover.cpp b/modules/core/ns_recover.cpp index e2f4befdf..868a7f69e 100644 --- a/modules/core/ns_recover.cpp +++ b/modules/core/ns_recover.cpp @@ -57,7 +57,7 @@ class CommandNSRecover : public Command notice_lang(Config->s_NickServ, u, ACCESS_DENIED); if (!res) { - Alog() << Config->s_NickServ << ": RECOVER: invalid password for " << nick << " by " << u->GetMask(); + Log(LOG_COMMAND, u, this) << "with invalid password for " << nick; if (bad_password(u)) return MOD_STOP; } diff --git a/modules/core/ns_register.cpp b/modules/core/ns_register.cpp index eb126a791..48a869bb8 100644 --- a/modules/core/ns_register.cpp +++ b/modules/core/ns_register.cpp @@ -24,7 +24,8 @@ class CommandNSConfirm : public Command if (!na) { - Alog() << Config->s_NickServ << ": makenick(" << u->nick << ") failed"; + // XXX + //Alog() << Config->s_NickServ << ": makenick(" << u->nick << ") failed"; notice_lang(Config->s_NickServ, u, NICK_REGISTRATION_FAILED); return MOD_CONT; } @@ -57,7 +58,7 @@ class CommandNSConfirm : public Command if (!force) { u->Login(na->nc); - Alog() << Config->s_NickServ << ": '" << u->nick << "' registered by " << u->GetIdent() << "@" << u->host << " (e-mail: " << (!nr->email.empty() ? nr->email : "none") << ")"; + Log(LOG_COMMAND, u, this) << "to register " << u->nick << " (email: " << (!nr->email.empty() ? nr->email : "none") << ")"; if (Config->NSAddAccessOnReg) notice_lang(Config->s_NickServ, u, NICK_REGISTERED, u->nick.c_str(), na->nc->GetAccess(0).c_str()); else @@ -74,7 +75,7 @@ class CommandNSConfirm : public Command } else { - Alog() << Config->s_NickServ << ": '" << nr->nick << "' confirmed by " << u->GetMask() << " (email: " << (!nr->email.empty() ? nr->email : "none") << " )"; + Log(LOG_COMMAND, u, this) << "to confirm " << u->nick << " (email: " << (!nr->email.empty() ? nr->email : "none") << ")"; notice_lang(Config->s_NickServ, u, NICK_FORCE_REG, nr->nick.c_str()); User *user = finduser(nr->nick); /* Delrequest must be called before validate_user */ @@ -250,7 +251,8 @@ class CommandNSRegister : public CommandNSConfirm /* i.e. there's already such a nick regged */ if (na->HasFlag(NS_FORBIDDEN)) { - Alog() << Config->s_NickServ << ": " << u->GetIdent() << "@" << u->host << " tried to register FORBIDden nick " << u->nick; + // XXX + //Alog() << Config->s_NickServ << ": " << u->GetIdent() << "@" << u->host << " tried to register FORBIDden nick " << u->nick; notice_lang(Config->s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick.c_str()); } else @@ -278,11 +280,11 @@ class CommandNSRegister : public CommandNSConfirm if (SendRegmail(u, nr)) { notice_lang(Config->s_NickServ, u, NICK_ENTER_REG_CODE, email.c_str(), Config->s_NickServ.c_str()); - Alog() << Config->s_NickServ << ": sent registration verification code to " << nr->email; + Log(LOG_COMMAND, u, this) << "send registration verification code to " << nr->email; } else { - Alog() << Config->s_NickServ << ": Unable to send registration verification mail"; + Log(LOG_COMMAND, u, this) << "unable to send registration verification mail"; notice_lang(Config->s_NickServ, u, NICK_REG_UNABLE); delete nr; return MOD_CONT; @@ -342,11 +344,11 @@ class CommandNSResend : public Command { nr->lastmail = time(NULL); notice_lang(Config->s_NickServ, u, NICK_REG_RESENT, nr->email.c_str()); - Alog() << Config->s_NickServ << ": re-sent registration verification code for " << nr->nick << " to " << nr->email; + Log(LOG_COMMAND, u, this) << "resend registration verification code for " << nr->nick; } else { - Alog() << Config->s_NickServ << ": Unable to re-send registration verification mail for " << nr->nick; + Log(LOG_COMMAND, u, this) << "unable to resend registration verification code for " << nr->nick; return MOD_CONT; } } diff --git a/modules/core/ns_release.cpp b/modules/core/ns_release.cpp index bb455d23e..1fe340758 100644 --- a/modules/core/ns_release.cpp +++ b/modules/core/ns_release.cpp @@ -40,7 +40,7 @@ class CommandNSRelease : public Command int res = enc_check_password(pass, na->nc->pass); if (res == 1) { - na->Release(); + Log(LOG_COMMAND, u, this) << "released " << na->nick; notice_lang(Config->s_NickServ, u, NICK_RELEASED); } else @@ -48,7 +48,7 @@ class CommandNSRelease : public Command notice_lang(Config->s_NickServ, u, ACCESS_DENIED); if (!res) { - Alog() << Config->s_NickServ << ": RELEASE: invalid password for " << nick << " by " << u->GetMask(); + Log(LOG_COMMAND, u, this) << "invalid password for " << nick; if (bad_password(u)) return MOD_STOP; } diff --git a/modules/core/ns_resetpass.cpp b/modules/core/ns_resetpass.cpp index bae4eb1b2..05c0b5e6b 100644 --- a/modules/core/ns_resetpass.cpp +++ b/modules/core/ns_resetpass.cpp @@ -36,7 +36,7 @@ class CommandNSResetPass : public Command { if (SendResetEmail(u, na)) { - Alog() << Config->s_NickServ << ": " << u->GetMask() << " used RESETPASS on " << na->nick << " (" << na->nc->display << ")"; + Log(LOG_COMMAND, u, this) << "for " << na->nick << " (group: " << na->nc->display << ")"; notice_lang(Config->s_NickServ, u, NICK_RESETPASS_COMPLETE, na->nick.c_str()); } } @@ -111,7 +111,7 @@ class NSResetPass : public Module ircdproto->SetAutoIdentificationToken(u); FOREACH_MOD(I_OnNickIdentify, OnNickIdentify(u)); - Alog() << Config->s_NickServ << ": " << u->GetMask() << " used CONFIRM with RESETPASS to forcefully identify to " << na->nick; + Log(LOG_COMMAND, u, &commandnsresetpass) << "confirmed RESETPASS to forcefully identify to " << na->nick; notice_lang(Config->s_NickServ, u, NICK_CONFIRM_SUCCESS, Config->s_NickServ.c_str()); if (ircd->vhost) @@ -122,7 +122,7 @@ class NSResetPass : public Module } else { - Alog() << Config->s_NickServ << ": Invalid CONFIRM passcode for " << na->nick << " from " << u->GetMask(); + Log(LOG_COMMAND, u, &commandnsresetpass) << "invalid confirm passcode for " << na->nick; notice_lang(Config->s_NickServ, u, NICK_CONFIRM_INVALID); bad_password(u); } diff --git a/modules/core/ns_saset.cpp b/modules/core/ns_saset.cpp index 73cb706b9..c6494d292 100644 --- a/modules/core/ns_saset.cpp +++ b/modules/core/ns_saset.cpp @@ -55,6 +55,7 @@ class CommandNSSASet : public Command Anope::string cmdparams = na->nc->display; for (std::vector::const_iterator it = params.begin() + 2; it != params.end(); ++it) cmdparams += " " + *it; + Log(LOG_ADMIN, u, this) << params[1] << " " << cmdparams; mod_run_cmd(NickServ, u, c, params[1], cmdparams); } else @@ -192,7 +193,8 @@ class CommandNSSASetPassword : public Command if (enc_encrypt(params[1], nc->pass)) { - Alog() << Config->s_NickServ << ": Failed to encrypt password for " << nc->display << " (saset)"; + // XXX + //Alog() << Config->s_NickServ << ": Failed to encrypt password for " << nc->display << " (saset)"; notice_lang(Config->s_NickServ, u, NICK_SASET_PASSWORD_FAILED, nc->display.c_str()); return MOD_CONT; } @@ -203,8 +205,6 @@ class CommandNSSASetPassword : public Command else notice_lang(Config->s_NickServ, u, NICK_SASET_PASSWORD_CHANGED, nc->display.c_str()); - Alog() << Config->s_NickServ << ": " << u->GetMask() << " used SASET PASSWORD on " << nc->display << " (e-mail: "<< (!nc->email.empty() ? nc->email : "none") << ")"; - if (Config->WallSetpass) ircdproto->SendGlobops(NickServ, "\2%s\2 used SASET PASSWORD on \2%s\2", u->nick.c_str(), nc->display.c_str()); diff --git a/modules/core/ns_sendpass.cpp b/modules/core/ns_sendpass.cpp index e5695e37e..f437e4a9e 100644 --- a/modules/core/ns_sendpass.cpp +++ b/modules/core/ns_sendpass.cpp @@ -40,7 +40,7 @@ class CommandNSSendPass : public Command { if (SendPassMail(u, na, tmp_pass)) { - Alog() << Config->s_NickServ << ": " << u->GetMask() << " used SENDPASS on " << nick; + Log(Config->RestrictMail ? LOG_ADMIN : LOG_COMMAND, u, this) << "for " << na->nick; notice_lang(Config->s_NickServ, u, NICK_SENDPASS_OK, nick.c_str()); } } diff --git a/modules/core/ns_set.cpp b/modules/core/ns_set.cpp index fde4d6cb5..2eb7c6a19 100644 --- a/modules/core/ns_set.cpp +++ b/modules/core/ns_set.cpp @@ -175,7 +175,8 @@ class CommandNSSetPassword : public Command if (enc_encrypt(param, u->Account()->pass) < 0) { - Alog() << Config->s_NickServ << ": Failed to encrypt password for " << u->Account()->display << " (set)"; + // XXX ? + //Alog() << Config->s_NickServ << ": Failed to encrypt password for " << u->Account()->display << " (set)"; notice_lang(Config->s_NickServ, u, NICK_SASET_PASSWORD_FAILED); return MOD_CONT; } @@ -186,7 +187,6 @@ class CommandNSSetPassword : public Command else notice_lang(Config->s_NickServ, u, NICK_SASET_PASSWORD_CHANGED, u->Account()->display.c_str()); - Alog() << Config->s_NickServ << ": " << u->GetMask() << " (e-mail: " << (!u->Account()->email.empty() ? u->Account()->email : "none") << ") changed its password."; return MOD_CONT; } diff --git a/modules/core/ns_set_email.cpp b/modules/core/ns_set_email.cpp index d8471e2db..9820d9632 100644 --- a/modules/core/ns_set_email.cpp +++ b/modules/core/ns_set_email.cpp @@ -44,8 +44,6 @@ class CommandNSSetEmail : public Command return MOD_CONT; } - Alog() << Config->s_NickServ << ": " << u->GetMask() << " (e-mail: " << (!u->Account()->email.empty() ? u->Account()->email : "none") << ") changed the e-mail of " << nc->display << " to " << (!param.empty() ? param : "none"); - if (!param.empty()) { nc->email = param; diff --git a/modules/core/ns_suspend.cpp b/modules/core/ns_suspend.cpp index ff5de7768..488ed4f04 100644 --- a/modules/core/ns_suspend.cpp +++ b/modules/core/ns_suspend.cpp @@ -76,7 +76,7 @@ class CommandNSSuspend : public Command if (Config->WallForbid) ircdproto->SendGlobops(NickServ, "\2%s\2 used SUSPEND on \2%s\2", u->nick.c_str(), nick.c_str()); - Alog() << Config->s_NickServ << ": " << u->nick << " set SUSPEND for nick " << nick; + Log(LOG_ADMIN, u, this) << "for " << nick << " (" << (!reason.empty() ? reason : "No reason") << ")"; notice_lang(Config->s_NickServ, u, NICK_SUSPEND_SUCCEEDED, nick.c_str()); FOREACH_MOD(I_OnNickSuspended, OnNickSuspend(na)); @@ -142,7 +142,7 @@ class CommandNSUnSuspend : public Command if (Config->WallForbid) ircdproto->SendGlobops(NickServ, "\2%s\2 used UNSUSPEND on \2%s\2", u->nick.c_str(), nick.c_str()); - Alog() << Config->s_NickServ << ": " << u->nick << " set UNSUSPEND for nick " << nick; + Log(LOG_ADMIN, u, this) << "for " << na->nick; notice_lang(Config->s_NickServ, u, NICK_UNSUSPEND_SUCCEEDED, nick.c_str()); FOREACH_MOD(I_OnNickUnsuspended, OnNickUnsuspended(na)); diff --git a/modules/core/os_defcon.cpp b/modules/core/os_defcon.cpp index e52b25269..009d34dda 100644 --- a/modules/core/os_defcon.cpp +++ b/modules/core/os_defcon.cpp @@ -32,7 +32,7 @@ class DefConTimeout : public Timer { Config->DefConLevel = level; FOREACH_MOD(I_OnDefconLevel, OnDefconLevel(level)); - Alog() << "Defcon level timeout, returning to lvl " << level; + Log(OperServ, "operserv/defcon") << "Defcon level timeout, returning to level " << level; ircdproto->SendGlobops(OperServ, getstring(OPER_DEFCON_WALL), Config->s_OperServ.c_str(), level); if (Config->GlobalOnDefcon) @@ -92,7 +92,7 @@ class CommandOSDefcon : public Command notice_lang(Config->s_OperServ, u, OPER_DEFCON_CHANGED, Config->DefConLevel); defcon_sendlvls(u); - Alog() << "Defcon level changed to " << newLevel << " by Oper " << u->nick; + Log(LOG_ADMIN, u, this) << "to change defcon level to " << newLevel; ircdproto->SendGlobops(OperServ, getstring(OPER_DEFCON_WALL), u->nick.c_str(), newLevel); /* Global notice the user what is happening. Also any Message that the Admin would like to add. Set in config file. */ @@ -157,7 +157,7 @@ class OSDefcon : public Module { if (CheckDefCon(DEFCON_AKILL_NEW_CLIENTS)) { - Alog() << "DEFCON: adding akill for *@" << u->host; + Log(OperServ, "operserv/defcon") << "DEFCON: adding akill for *@" << u->host; XLine *x = SGLine->Add(NULL, NULL, "*@" + u->host, time(NULL) + Config->DefConAKILL, !Config->DefConAkillReason.empty() ? Config->DefConAkillReason : "DEFCON AKILL"); if (x) x->By = Config->s_OperServ; @@ -352,7 +352,7 @@ void runDefCon() { if (Config->DefConChanModes[0] == '+' || Config->DefConChanModes[0] == '-') { - Alog() << "DEFCON: setting " << Config->DefConChanModes << " on all channels"; + Log(OperServ, "operserv/defcon") << "DEFCON: setting " << Config->DefConChanModes << " on all channels"; DefConModesSet = true; MassChannelModes(OperServ, Config->DefConChanModes); } @@ -368,7 +368,7 @@ void runDefCon() Anope::string newmodes = defconReverseModes(Config->DefConChanModes); if (!newmodes.empty()) { - Alog() << "DEFCON: setting " << newmodes << " on all channels"; + Log(OperServ, "operserv/defcon") << "DEFCON: setting " << newmodes << " on all channels"; MassChannelModes(OperServ, newmodes); } } @@ -420,7 +420,7 @@ void defconParseModeString(const Anope::string &str) { if (cm->Type == MODE_STATUS || cm->Type == MODE_LIST || !cm->CanSet(NULL)) { - Alog() << "DefConChanModes mode character '" << mode << "' cannot be locked"; + Log() << "DefConChanModes mode character '" << mode << "' cannot be locked"; continue; } else if (add) @@ -434,7 +434,7 @@ void defconParseModeString(const Anope::string &str) if (!ss.GetToken(param)) { - Alog() << "DefConChanModes mode character '" << mode << "' has no parameter while one is expected"; + Log() << "DefConChanModes mode character '" << mode << "' has no parameter while one is expected"; continue; } @@ -462,7 +462,7 @@ void defconParseModeString(const Anope::string &str) { DefConModesOn.UnsetFlag(CMODE_REDIRECT); - Alog() << "DefConChanModes must lock mode +l as well to lock mode +L"; + Log() << "DefConChanModes must lock mode +l as well to lock mode +L"; } /* Some ircd we can't set NOKNOCK without INVITE */ @@ -470,7 +470,7 @@ void defconParseModeString(const Anope::string &str) if (ircd->knock_needs_i && (cm = ModeManager::FindChannelModeByName(CMODE_NOKNOCK)) && DefConModesOn.HasFlag(cm->Name) && !DefConModesOn.HasFlag(CMODE_INVITE)) { DefConModesOn.UnsetFlag(CMODE_NOKNOCK); - Alog() << "DefConChanModes must lock mode +i as well to lock mode +K"; + Log() << "DefConChanModes must lock mode +i as well to lock mode +K"; } } diff --git a/modules/core/os_ignore.cpp b/modules/core/os_ignore.cpp index d62b3221a..05ac57c9b 100644 --- a/modules/core/os_ignore.cpp +++ b/modules/core/os_ignore.cpp @@ -170,7 +170,7 @@ class OSIgnore : public Module { if ((*ign)->time && (*ign)->time <= now) { - Alog(LOG_DEBUG) << "[os_ignore] Expiring ignore entry " << (*ign)->mask; + Log(LOG_DEBUG) << "[os_ignore] Expiring ignore entry " << (*ign)->mask; delete *ign; ign = ignore.erase(ign); } diff --git a/modules/core/os_modunload.cpp b/modules/core/os_modunload.cpp index ceea0c658..801714a16 100644 --- a/modules/core/os_modunload.cpp +++ b/modules/core/os_modunload.cpp @@ -32,7 +32,7 @@ class CommandOSModUnLoad : public Command return MOD_CONT; } - Alog() << "Trying to unload module [" << mname << "]"; + Log() << "Trying to unload module [" << mname << "]"; status = ModuleManager::UnloadModule(m, u); diff --git a/modules/core/os_news.cpp b/modules/core/os_news.cpp index c12f66756..8b286eebb 100644 --- a/modules/core/os_news.cpp +++ b/modules/core/os_news.cpp @@ -90,10 +90,7 @@ static void DisplayNews(User *u, NewsType Type) else if (Type == NEWS_RANDOM) msg = NEWS_RANDOM_TEXT; else - { - Alog() << "news: Invalid type (" << Type << ") to display_news()"; - return; - } + throw CoreException("news: Invalid type (" + stringify(Type) + ") to display_news()"); unsigned displayed = 0; bool NewsExists = false; @@ -277,10 +274,7 @@ class NewsBase : public Command msgs = findmsgs(type, type_name); if (!msgs) - { - Alog() << "news: Invalid type to do_news()"; - return MOD_CONT; - } + throw CoreException("news: Invalid type to do_news()"); if (cmd.equals_ci("LIST")) return this->DoList(u, type, msgs); diff --git a/modules/core/os_reload.cpp b/modules/core/os_reload.cpp index 4344efcff..21b719db9 100644 --- a/modules/core/os_reload.cpp +++ b/modules/core/os_reload.cpp @@ -31,7 +31,7 @@ class CommandOSReload : public Command } catch (const ConfigException &ex) { - Alog() << "Error reloading configuration file: " << ex.GetReason(); + Log() << "Error reloading configuration file: " << ex.GetReason(); } notice_lang(Config->s_OperServ, u, OPER_RELOAD); diff --git a/modules/core/os_set.cpp b/modules/core/os_set.cpp index 377dddfcf..f8790623f 100644 --- a/modules/core/os_set.cpp +++ b/modules/core/os_set.cpp @@ -18,14 +18,14 @@ class CommandOSSet : public Command private: CommandReturn DoList(User *u) { + Log(LOG_ADMIN, u, this); + int index; index = allow_ignore ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF; notice_lang(Config->s_OperServ, u, index, "IGNORE"); index = readonly ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF; notice_lang(Config->s_OperServ, u, index, "READONLY"); - index = LogChan ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF; - notice_lang(Config->s_OperServ, u, index, "LOGCHAN"); index = debug ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF; notice_lang(Config->s_OperServ, u, index, "DEBUG"); index = noexpire ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF; @@ -46,11 +46,13 @@ class CommandOSSet : public Command if (setting.equals_ci("ON")) { + Log(LOG_ADMIN, u, this) << "IGNORE ON"; allow_ignore = 1; notice_lang(Config->s_OperServ, u, OPER_SET_IGNORE_ON); } else if (setting.equals_ci("OFF")) { + Log(LOG_ADMIN, u, this) << "IGNORE OFF"; allow_ignore = 0; notice_lang(Config->s_OperServ, u, OPER_SET_IGNORE_OFF); } @@ -73,15 +75,13 @@ class CommandOSSet : public Command if (setting.equals_ci("ON")) { readonly = true; - Alog() << "Read-only mode activated"; - close_log(); + Log(LOG_ADMIN, u, this) << "READONLY ON"; notice_lang(Config->s_OperServ, u, OPER_SET_READONLY_ON); } else if (setting.equals_ci("OFF")) { readonly = false; - open_log(); - Alog() << "Read-only mode deactivated"; + Log(LOG_ADMIN, u, this) << "READONLY OFF"; notice_lang(Config->s_OperServ, u, OPER_SET_READONLY_OFF); } else @@ -90,52 +90,6 @@ class CommandOSSet : public Command return MOD_CONT; } - CommandReturn DoSetLogChan(User *u, const std::vector ¶ms) - { - Anope::string setting = params.size() > 1 ? params[1] : ""; - Channel *c; - - if (setting.empty()) - { - this->OnSyntaxError(u, "LOGCHAN"); - return MOD_CONT; - } - - /* Unlike the other SET commands where only stricmp is necessary, - * we also have to ensure that Config->LogChannel is defined or we can't - * send to it. - * - * -jester - */ - if (!Config->LogChannel.empty() && setting.equals_ci("ON")) - { - if (ircd->join2msg) - { - c = findchan(Config->LogChannel); - if (c) - Global->Join(c); - else - Global->Join(Config->LogChannel); - } - LogChan = true; - Alog() << "Now sending log messages to " << Config->LogChannel; - notice_lang(Config->s_OperServ, u, OPER_SET_LOGCHAN_ON, Config->LogChannel.c_str()); - } - else if (!Config->LogChannel.empty() && setting.equals_ci("OFF")) - { - Alog() << "No longer sending log messages to a channel"; - c = findchan(Config->LogChannel); - if (ircd->join2msg && c) - Global->Part(c); - LogChan = false; - notice_lang(Config->s_OperServ, u, OPER_SET_LOGCHAN_OFF); - } - else - notice_lang(Config->s_OperServ, u, OPER_SET_LOGCHAN_ERROR); - - return MOD_CONT; - } - CommandReturn DoSetSuperAdmin(User *u, const std::vector ¶ms) { Anope::string setting = params.size() > 1 ? params[1] : ""; @@ -157,14 +111,14 @@ class CommandOSSet : public Command { u->isSuperAdmin = 1; notice_lang(Config->s_OperServ, u, OPER_SUPER_ADMIN_ON); - Alog() << Config->s_OperServ << ": " << u->nick << " is a SuperAdmin"; + Log(LOG_ADMIN, u, this) << "SUPERADMIN ON"; ircdproto->SendGlobops(OperServ, getstring(OPER_SUPER_ADMIN_WALL_ON), u->nick.c_str()); } else if (setting.equals_ci("OFF")) { u->isSuperAdmin = 0; notice_lang(Config->s_OperServ, u, OPER_SUPER_ADMIN_OFF); - Alog() << Config->s_OperServ << ": " << u->nick << " is no longer a SuperAdmin"; + Log(LOG_ADMIN, u, this) << "SUPERADMIN OFF"; ircdproto->SendGlobops(OperServ, getstring(OPER_SUPER_ADMIN_WALL_OFF), u->nick.c_str()); } else @@ -186,19 +140,19 @@ class CommandOSSet : public Command if (setting.equals_ci("ON")) { debug = 1; - Alog() << "Debug mode activated"; + Log(LOG_ADMIN, u, this) << "DEBUG ON"; notice_lang(Config->s_OperServ, u, OPER_SET_DEBUG_ON); } else if (setting.equals_ci("OFF") || (setting[0] == '0' && setting.is_number_only() && !convertTo(setting))) { - Alog() << "Debug mode deactivated"; + Log(LOG_ADMIN, u, this) << "DEBUG OFF"; debug = 0; notice_lang(Config->s_OperServ, u, OPER_SET_DEBUG_OFF); } else if (setting.is_number_only() && convertTo(setting) > 0) { debug = convertTo(setting); - Alog() << "Debug mode activated (level " << debug << ")"; + Log(LOG_ADMIN, u, this) << "DEBUG " << debug; notice_lang(Config->s_OperServ, u, OPER_SET_DEBUG_LEVEL, debug); } else @@ -220,13 +174,13 @@ class CommandOSSet : public Command if (setting.equals_ci("ON")) { noexpire = true; - Alog() << "No expire mode activated"; + Log(LOG_ADMIN, u, this) << "NOEXPIRE ON"; notice_lang(Config->s_OperServ, u, OPER_SET_NOEXPIRE_ON); } else if (setting.equals_ci("OFF")) { noexpire = false; - Alog() << "No expire mode deactivated"; + Log(LOG_ADMIN, u, this) << "NOEXPIRE OFF"; notice_lang(Config->s_OperServ, u, OPER_SET_NOEXPIRE_OFF); } else @@ -249,8 +203,6 @@ class CommandOSSet : public Command return this->DoSetIgnore(u, params); else if (option.equals_ci("READONLY")) return this->DoSetReadOnly(u, params); - else if (option.equals_ci("LOGCHAN")) - return this->DoSetLogChan(u, params); else if (option.equals_ci("SUPERADMIN")) return this->DoSetSuperAdmin(u, params); else if (option.equals_ci("DEBUG")) @@ -270,8 +222,6 @@ class CommandOSSet : public Command notice_help(Config->s_OperServ, u, OPER_HELP_SET_LIST); else if (subcommand.equals_ci("READONLY")) notice_help(Config->s_OperServ, u, OPER_HELP_SET_READONLY); - else if (subcommand.equals_ci("LOGCHAN")) - notice_help(Config->s_OperServ, u, OPER_HELP_SET_LOGCHAN); else if (subcommand.equals_ci("DEBUG")) notice_help(Config->s_OperServ, u, OPER_HELP_SET_DEBUG); else if (subcommand.equals_ci("NOEXPIRE")) diff --git a/modules/core/ss_main.cpp b/modules/core/ss_main.cpp index 1b7188781..0e68a2795 100644 --- a/modules/core/ss_main.cpp +++ b/modules/core/ss_main.cpp @@ -41,10 +41,10 @@ class SSMain : public Module statserv = findbot("StatServ"); if (!statserv) { - Alog() << "Creating SS"; + Log() << "Creating SS"; statserv = new BotInfo("StatServ", Config->ServiceUser, Config->ServiceHost, "Stats Service"); } - Alog() << "Done creating SS"; + Log() << "Done creating SS"; this->AddCommand(statserv, &commandsshelp); } diff --git a/modules/extra/cs_appendtopic.cpp b/modules/extra/cs_appendtopic.cpp index 3da548cf2..387c55f73 100644 --- a/modules/extra/cs_appendtopic.cpp +++ b/modules/extra/cs_appendtopic.cpp @@ -95,7 +95,7 @@ class CommandCSAppendTopic : public Command c->topic_time = ci->last_topic_time; if (!check_access(u, ci, CA_TOPIC)) - Alog() << Config->s_ChanServ << ": " << u->GetMask() << " changed topic of " << c->name << " as services admin."; + Log(LOG_OVERRIDE, u, this, ci) << "changed topic to " << topic; if (ircd->join2set && whosends(ci) == ChanServ) { ChanServ->Join(c); diff --git a/modules/extra/cs_enforce.cpp b/modules/extra/cs_enforce.cpp index 1f2472e47..5541aa5ca 100644 --- a/modules/extra/cs_enforce.cpp +++ b/modules/extra/cs_enforce.cpp @@ -60,8 +60,6 @@ class CommandCSEnforce : public Command if (!(ci = c->ci)) return; - Alog(LOG_DEBUG) << "[cs_enforce] Enforcing SECUREOPS on " << c->name; - /* Dirty hack to allow chan_set_correct_modes to work ok. * We pretend like SECUREOPS is on so it doesn't ignore that * part of the code. This way we can enforce SECUREOPS even @@ -94,8 +92,6 @@ class CommandCSEnforce : public Command if (!(ci = c->ci)) return; - Alog(LOG_DEBUG) << "[cs_enforce] Enforcing RESTRICTED on " << c->name; - old_nojoin_level = ci->levels[CA_NOJOIN]; if (ci->levels[CA_NOJOIN] < 0) ci->levels[CA_NOJOIN] = 0; @@ -124,8 +120,6 @@ class CommandCSEnforce : public Command if (!(ci = c->ci)) return; - Alog(LOG_DEBUG) << "[cs_enforce] Enforcing mode +R on " << c->name; - for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ) { UserContainer *uc = *it++; diff --git a/modules/extra/cs_set_misc.cpp b/modules/extra/cs_set_misc.cpp index b52eb525e..8b4395043 100644 --- a/modules/extra/cs_set_misc.cpp +++ b/modules/extra/cs_set_misc.cpp @@ -151,7 +151,7 @@ class CSSetMisc : public Module CommandInfo *info = new CommandInfo(cname, desc, showhidden); if (!this->Commands.insert(std::make_pair(cname, info)).second) { - Alog() << "cs_set_misc: Warning, unable to add duplicate entry " << cname; + Log() << "cs_set_misc: Warning, unable to add duplicate entry " << cname; delete info; continue; } diff --git a/modules/extra/db_mysql.cpp b/modules/extra/db_mysql.cpp index c09c2c336..4920e9b00 100644 --- a/modules/extra/db_mysql.cpp +++ b/modules/extra/db_mysql.cpp @@ -405,7 +405,7 @@ class DBMySQL : public Module { if (!SQL) { - Alog() << "Error, unable to find service reference for SQL, is m_mysql loaded and configured properly?"; + Log() << "Error, unable to find service reference for SQL, is m_mysql loaded and configured properly?"; return EVENT_CONTINUE; } @@ -442,7 +442,7 @@ class DBMySQL : public Module NickCore *nc = findcore(r.Get(i, "display")); if (!nc) { - Alog() << "MySQL: Got NickCore access entry for nonexistant core " << r.Get(i, "display"); + Log() << "MySQL: Got NickCore access entry for nonexistant core " << r.Get(i, "display"); continue; } @@ -455,7 +455,7 @@ class DBMySQL : public Module NickCore *nc = findcore(r.Get(i, "display")); if (!nc) { - Alog() << "MySQL: Got NickCore access entry for nonexistant core " << r.Get(i, "display"); + Log() << "MySQL: Got NickCore access entry for nonexistant core " << r.Get(i, "display"); continue; } @@ -470,7 +470,7 @@ class DBMySQL : public Module NickCore *nc = findcore(r.Get(i, "display")); if (!nc) { - Alog() << "MySQL: Got NickAlias for nick " << r.Get(i, "nick") << " with nonexistant core " << r.Get(i, "display"); + Log() << "MySQL: Got NickAlias for nick " << r.Get(i, "nick") << " with nonexistant core " << r.Get(i, "display"); continue; } @@ -502,7 +502,7 @@ class DBMySQL : public Module NickAlias *na = findnick(r.Get(i, "nick")); if (!na) { - Alog() << "MySQL: Got metadata for nonexistant nick " << r.Get(i, "nick"); + Log() << "MySQL: Got metadata for nonexistant nick " << r.Get(i, "nick"); continue; } @@ -516,9 +516,7 @@ class DBMySQL : public Module { BotInfo *bi = findbot(r.Get(i, "nick")); if (!bi) - bi = new BotInfo(r.Get(i, "nick")); - bi->SetIdent(r.Get(i, "user")); - bi->host = r.Get(i, "host"); + bi = new BotInfo(r.Get(i, "nick"), r.Get(i, "user"), r.Get(i, "host")); bi->realname = r.Get(i, "rname"); bi->created = r.Get(i, "created").is_pos_number_only() ? convertTo(r.Get(i, "creeated")) : time(NULL); @@ -543,7 +541,7 @@ class DBMySQL : public Module BotInfo *bi = findbot(r.Get(i, "botname")); if (!bi) { - Alog() << "MySQL: BotInfo metadata for nonexistant bot " << r.Get(i, "botname"); + Log() << "MySQL: BotInfo metadata for nonexistant bot " << r.Get(i, "botname"); continue; } @@ -562,7 +560,7 @@ class DBMySQL : public Module nc = findcore(r.Get(i, "founder")); if (!nc) { - Alog() << "MySQL: Channel " << r.Get(i, "name") << " with nonexistant founder " << r.Get(i, "founder"); + Log() << "MySQL: Channel " << r.Get(i, "name") << " with nonexistant founder " << r.Get(i, "founder"); continue; } @@ -664,7 +662,7 @@ class DBMySQL : public Module ChannelInfo *ci = cs_findchan(r.Get(i, "channel")); if (!ci) { - Alog() << "MySQL: Channel ttb for nonexistant channel " << r.Get(i, "channel"); + Log() << "MySQL: Channel ttb for nonexistant channel " << r.Get(i, "channel"); continue; } @@ -677,7 +675,7 @@ class DBMySQL : public Module ChannelInfo *ci = cs_findchan(r.Get(i, "channel")); if (!ci) { - Alog() << "MySQL: Channel badwords entry for nonexistant channel " << r.Get(i, "channel"); + Log() << "MySQL: Channel badwords entry for nonexistant channel " << r.Get(i, "channel"); continue; } @@ -697,14 +695,14 @@ class DBMySQL : public Module ChannelInfo *ci = cs_findchan(r.Get(i, "channel")); if (!ci) { - Alog() << "MySQL: Channel access entry for nonexistant channel " << r.Get(i, "channel"); + Log() << "MySQL: Channel access entry for nonexistant channel " << r.Get(i, "channel"); continue; } NickCore *nc = findcore(r.Get(i, "display")); if (!nc) { - Alog() << "MySQL: Channel access entry for " << ci->name << " with nonexistant nick " << r.Get(i, "display"); + Log() << "MySQL: Channel access entry for " << ci->name << " with nonexistant nick " << r.Get(i, "display"); continue; } @@ -717,7 +715,7 @@ class DBMySQL : public Module ChannelInfo *ci = cs_findchan(r.Get(i, "channel")); if (!ci) { - Alog() << "MySQL: Channel access entry for nonexistant channel " << r.Get(i, "channel"); + Log() << "MySQL: Channel access entry for nonexistant channel " << r.Get(i, "channel"); continue; } @@ -750,7 +748,7 @@ class DBMySQL : public Module ChannelInfo *ci = cs_findchan(r.Get(i, "channel")); if (!ci) { - Alog() << "MySQL: Channel level entry for nonexistant channel " << r.Get(i, "channel"); + Log() << "MySQL: Channel level entry for nonexistant channel " << r.Get(i, "channel"); continue; } @@ -763,7 +761,7 @@ class DBMySQL : public Module ChannelInfo *ci = cs_findchan(r.Get(i, "channel")); if (!ci) { - Alog() << "MySQL: Channel metadata for nonexistant channel " << r.Get(i, "channel"); + Log() << "MySQL: Channel metadata for nonexistant channel " << r.Get(i, "channel"); continue; } @@ -1379,15 +1377,15 @@ class DBMySQL : public Module void MySQLInterface::OnResult(const SQLResult &r) { - Alog(LOG_DEBUG) << "MySQL successfully executed query: " << r.GetQuery(); + Log(LOG_DEBUG) << "MySQL successfully executed query: " << r.GetQuery(); } void MySQLInterface::OnError(const SQLResult &r) { if (!r.GetQuery().empty()) - Alog(LOG_DEBUG) << "Error executing query " << r.GetQuery() << ": " << r.GetError(); + Log(LOG_DEBUG) << "Error executing query " << r.GetQuery() << ": " << r.GetError(); else - Alog(LOG_DEBUG) << "Error executing query: " << r.GetError(); + Log(LOG_DEBUG) << "Error executing query: " << r.GetError(); } diff --git a/modules/extra/hs_request.cpp b/modules/extra/hs_request.cpp index cb23b0e11..9b1218113 100644 --- a/modules/extra/hs_request.cpp +++ b/modules/extra/hs_request.cpp @@ -139,7 +139,7 @@ class CommandHSRequest : public Command me->NoticeLang(Config->s_HostServ, u, LNG_REQUESTED); req_send_memos(u, vIdent, hostmask); - Alog() << "New vHost Requested by " << nick; + Log(LOG_COMMAND, u, this, NULL) << "to request new vhost " << (!vIdent.empty() ? vIdent + "@" : "") << hostmask; } else notice_lang(Config->s_HostServ, u, HOST_NOREG, nick.c_str()); @@ -185,14 +185,14 @@ class CommandHSActivate : public Command if (it != Requests.end()) { na->hostinfo.SetVhost(it->second->ident, it->second->host, u->nick, it->second->time); - delete it->second; - Requests.erase(it); if (HSRequestMemoUser) my_memo_lang(u, na->nick, 2, LNG_ACTIVATE_MEMO); - me->NoticeLang(Config->s_HostServ, u, LNG_ACTIVATED, nick.c_str()); - Alog() << "Host Request for " << nick << " activated by " << u->nick; + me->NoticeLang(Config->s_HostServ, u, LNG_ACTIVATED, na->nick.c_str()); + Log(LOG_COMMAND, u, this, NULL) << "for " << na->nick << " for vhost " << (!it->second->ident.empty() ? it->second->ident + "@" : "") << it->second->host; + delete it->second; + Requests.erase(it); } else me->NoticeLang(Config->s_HostServ, u, LNG_NO_REQUEST, nick.c_str()); @@ -252,7 +252,7 @@ class CommandHSReject : public Command } me->NoticeLang(Config->s_HostServ, u, LNG_REJECTED, nick.c_str()); - Alog() << "Host Request for " << nick << " rejected by " << u->nick << " (" << (!reason.empty() ? reason : "") << ")"; + Log(LOG_COMMAND, u, this, NULL) << "to reject vhost for " << nick << " (" << (!reason.empty() ? reason : "") << ")"; } else me->NoticeLang(Config->s_HostServ, u, LNG_NO_REQUEST, nick.c_str()); @@ -737,7 +737,7 @@ void my_memo_lang(User *u, const Anope::string &name, int z, int number, ...) free(buf); // XXX } else - Alog() << me->name << ": INVALID language string call, language: [" << lang << "], String [" << number << "]"; + Log() << me->name << ": INVALID language string call, language: [" << lang << "], String [" << number << "]"; } void req_send_memos(User *u, const Anope::string &vIdent, const Anope::string &vHost) @@ -794,7 +794,7 @@ void my_load_config() HSRequestMemoOper = config.ReadFlag("hs_request", "memooper", "no", 0); HSRequestMemoSetters = config.ReadFlag("hs_request", "memosetters", "no", 0); - Alog(LOG_DEBUG) << "[hs_request] Set config vars: MemoUser=" << HSRequestMemoUser << " MemoOper=" << HSRequestMemoOper << " MemoSetters=" << HSRequestMemoSetters; + Log(LOG_DEBUG) << "[hs_request] Set config vars: MemoUser=" << HSRequestMemoUser << " MemoOper=" << HSRequestMemoOper << " MemoSetters=" << HSRequestMemoSetters; } MODULE_INIT(HSRequest) diff --git a/modules/extra/m_mysql.cpp b/modules/extra/m_mysql.cpp index 289273493..f641aa655 100644 --- a/modules/extra/m_mysql.cpp +++ b/modules/extra/m_mysql.cpp @@ -58,7 +58,7 @@ class MySQLResult : public SQLResult if (!num_fields) return; - Alog(LOG_DEBUG) << "SQL query returned " << num_fields << " fields"; + Log(LOG_DEBUG) << "SQL query returned " << num_fields << " fields"; for (MYSQL_ROW row; (row = mysql_fetch_row(res));) { @@ -70,7 +70,7 @@ class MySQLResult : public SQLResult for (unsigned field_count = 0; field_count < num_fields; ++field_count) { - Alog(LOG_DEBUG) << "Field count " << field_count << " name is: " << (fields[field_count].name ? fields[field_count].name : "") << ", data is: " << (row[field_count] ? row[field_count] : ""); + Log(LOG_DEBUG) << "Field count " << field_count << " name is: " << (fields[field_count].name ? fields[field_count].name : "") << ", data is: " << (row[field_count] ? row[field_count] : ""); Anope::string column = (fields[field_count].name ? fields[field_count].name : ""); Anope::string data = (row[field_count] ? row[field_count] : ""); @@ -211,7 +211,7 @@ class ModuleSQL : public Module if (i == num) { - Alog() << "MySQL: Removing server connection " << cname; + Log(LOG_NORMAL, "mysql") << "MySQL: Removing server connection " << cname; delete s; this->MySQLServices.erase(cname); @@ -235,11 +235,11 @@ class ModuleSQL : public Module MySQLService *ss = new MySQLService(this, connname, database, server, user, password, port); this->MySQLServices.insert(std::make_pair(connname, ss)); - Alog() << "MySQL: Sucessfully connected to server " << connname << " (" << server << ")"; + Log(LOG_NORMAL, "mysql") << "MySQL: Sucessfully connected to server " << connname << " (" << server << ")"; } catch (const SQLException &ex) { - Alog() << "MySQL: " << ex.GetReason(); + Log(LOG_NORMAL, "mysql") << "MySQL: " << ex.GetReason(); } } } diff --git a/modules/extra/m_ssl.cpp b/modules/extra/m_ssl.cpp index 397facd7d..5e081c193 100644 --- a/modules/extra/m_ssl.cpp +++ b/modules/extra/m_ssl.cpp @@ -84,7 +84,7 @@ class SSLModule : public Module } } else - Alog() << "m_ssl: No certificate file found"; + Log() << "m_ssl: No certificate file found"; if (IsFile(KEYFILE)) { @@ -102,7 +102,7 @@ class SSLModule : public Module throw ModuleException("Error loading private key - file not found"); } else - Alog() << "m_ssl: No private key found"; + Log() << "m_ssl: No private key found"; } this->SetAuthor("Anope"); @@ -129,11 +129,11 @@ class SSLModule : public Module try { new SSLSocket(u->host, u->port, Config->LocalHost, u->ipv6); - Alog() << "Connected to Server " << Number << " (" << u->host << ":" << u->port << ")"; + Log() << "Connected to Server " << Number << " (" << u->host << ":" << u->port << ")"; } catch (const SocketException &ex) { - Alog() << "Unable to connect with SSL to server" << Number << " (" << u->host << ":" << u->port << "), " << ex.GetReason(); + Log() << "Unable to connect with SSL to server" << Number << " (" << u->host << ":" << u->port << "), " << ex.GetReason(); } return EVENT_ALLOW; diff --git a/modules/extra/ns_maxemail.cpp b/modules/extra/ns_maxemail.cpp index a82798916..26ee9a96d 100644 --- a/modules/extra/ns_maxemail.cpp +++ b/modules/extra/ns_maxemail.cpp @@ -163,7 +163,7 @@ void my_load_config() { ConfigReader config; NSEmailMax = config.ReadInteger("ns_maxemail", "maxemails", "0", 0, false); - Alog(LOG_DEBUG) << "[ns_maxemail] NSEmailMax set to " << NSEmailMax; + Log(LOG_DEBUG) << "[ns_maxemail] NSEmailMax set to " << NSEmailMax; } MODULE_INIT(NSMaxEmail) diff --git a/modules/extra/ns_set_misc.cpp b/modules/extra/ns_set_misc.cpp index 2d31c6b63..2d267f2c4 100644 --- a/modules/extra/ns_set_misc.cpp +++ b/modules/extra/ns_set_misc.cpp @@ -168,7 +168,7 @@ class NSSetMisc : public Module CommandInfo *info = new CommandInfo(cname, desc, showhidden); if (!this->Commands.insert(std::make_pair(cname, info)).second) { - Alog() << "ns_set_misc: Warning, unable to add duplicate entry " << cname; + Log() << "ns_set_misc: Warning, unable to add duplicate entry " << cname; delete info; continue; } diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index 5ac8ff065..5c9a35032 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -342,7 +342,7 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av) { User *u = finduser(source); if (!u) - Alog(LOG_DEBUG) << "SJOIN for nonexistant user " << source << " on " << c->name; + Log(LOG_DEBUG) << "SJOIN for nonexistant user " << source << " on " << c->name; else { EventReturn MOD_RESULT; @@ -380,7 +380,7 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av) ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); if (!cm) { - Alog() << "Receeved unknown mode prefix " << buf[0] << " in SJOIN string"; + Log() << "Receeved unknown mode prefix " << buf[0] << " in SJOIN string"; continue; } @@ -391,7 +391,7 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av) User *u = finduser(buf); if (!u) { - Alog(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << c->name; + Log(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << c->name; continue; } @@ -662,7 +662,7 @@ int anope_event_ping(const Anope::string &source, int ac, const char **av) int anope_event_error(const Anope::string &source, int ac, const char **av) { if (ac >= 1) - Alog(LOG_DEBUG) << av[0]; + Log(LOG_DEBUG) << av[0]; return MOD_CONT; } diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp index 453be6965..20b347899 100644 --- a/modules/protocol/inspircd11.cpp +++ b/modules/protocol/inspircd11.cpp @@ -392,7 +392,7 @@ int anope_event_fmode(const Anope::string &source, int ac, const char **av) { newav[o] = av[n]; ++o; - Alog(LOG_DEBUG) << "Param: " << newav[o - 1]; + Log(LOG_DEBUG) << "Param: " << newav[o - 1]; } ++n; } @@ -438,7 +438,7 @@ int anope_event_fjoin(const Anope::string &source, int ac, const char **av) if (!cm) { - Alog() << "Received unknown mode prefix " << buf[0] << " in FJOIN string"; + Log() << "Received unknown mode prefix " << buf[0] << " in FJOIN string"; buf.erase(buf.begin()); continue; } @@ -451,7 +451,7 @@ int anope_event_fjoin(const Anope::string &source, int ac, const char **av) User *u = finduser(buf); if (!u) { - Alog(LOG_DEBUG) << "FJOIN for nonexistant user " << buf << " on " << c->name; + Log(LOG_DEBUG) << "FJOIN for nonexistant user " << buf << " on " << c->name; continue; } @@ -526,7 +526,7 @@ int anope_event_topic(const Anope::string &source, int ac, const char **av) if (!c) { - Alog(LOG_DEBUG) << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0]; + Log(LOG_DEBUG) << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0]; return MOD_CONT; } @@ -628,7 +628,7 @@ int anope_event_setname(const Anope::string &source, int ac, const char **av) u = finduser(source); if (!u) { - Alog(LOG_DEBUG) << "SETNAME for nonexistent user " << source; + Log(LOG_DEBUG) << "SETNAME for nonexistent user " << source; return MOD_CONT; } @@ -646,7 +646,7 @@ int anope_event_chgname(const Anope::string &source, int ac, const char **av) u = finduser(source); if (!u) { - Alog(LOG_DEBUG) << "FNAME for nonexistent user " << source; + Log(LOG_DEBUG) << "FNAME for nonexistent user " << source; return MOD_CONT; } @@ -664,7 +664,7 @@ int anope_event_setident(const Anope::string &source, int ac, const char **av) u = finduser(source); if (!u) { - Alog(LOG_DEBUG) << "SETIDENT for nonexistent user " << source; + Log(LOG_DEBUG) << "SETIDENT for nonexistent user " << source; return MOD_CONT; } @@ -682,7 +682,7 @@ int anope_event_chgident(const Anope::string &source, int ac, const char **av) u = finduser(av[0]); if (!u) { - Alog(LOG_DEBUG) << "CHGIDENT for nonexistent user " << av[0]; + Log(LOG_DEBUG) << "CHGIDENT for nonexistent user " << av[0]; return MOD_CONT; } @@ -700,7 +700,7 @@ int anope_event_sethost(const Anope::string &source, int ac, const char **av) u = finduser(source); if (!u) { - Alog(LOG_DEBUG) << "SETHOST for nonexistent user " << source; + Log(LOG_DEBUG) << "SETHOST for nonexistent user " << source; return MOD_CONT; } @@ -755,7 +755,7 @@ int anope_event_chghost(const Anope::string &source, int ac, const char **av) u = finduser(source); if (!u) { - Alog(LOG_DEBUG) << "FHOST for nonexistent user " << source; + Log(LOG_DEBUG) << "FHOST for nonexistent user " << source; return MOD_CONT; } diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index 987590034..30d4f3600 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -417,7 +417,7 @@ int anope_event_fmode(const Anope::string &source, int ac, const char **av) { newav[o] = av[n]; ++o; - Alog(LOG_DEBUG) << "Param: " << newav[o - 1]; + Log(LOG_DEBUG) << "Param: " << newav[o - 1]; } ++n; } @@ -476,7 +476,7 @@ int anope_event_fjoin(const Anope::string &source, int ac, const char **av) ChannelMode *cm = ModeManager::FindChannelModeByChar(buf[0]); if (!cm) { - Alog() << "Receeved unknown mode prefix " << buf[0] << " in FJOIN string"; + Log() << "Receeved unknown mode prefix " << buf[0] << " in FJOIN string"; buf.erase(buf.begin()); continue; } @@ -490,7 +490,7 @@ int anope_event_fjoin(const Anope::string &source, int ac, const char **av) User *u = finduser(buf); if (!u) { - Alog(LOG_DEBUG) << "FJOIN for nonexistant user " << buf << " on " << c->name; + Log(LOG_DEBUG) << "FJOIN for nonexistant user " << buf << " on " << c->name; continue; } @@ -575,7 +575,7 @@ int anope_event_topic(const Anope::string &source, int ac, const char **av) if (!c) { - Alog(LOG_DEBUG) << "debug: TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0]; + Log(LOG_DEBUG) << "debug: TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0]; return MOD_CONT; } @@ -660,7 +660,7 @@ int anope_event_setname(const Anope::string &source, int ac, const char **av) u = finduser(source); if (!u) { - Alog(LOG_DEBUG) << "SETNAME for nonexistent user " << source; + Log(LOG_DEBUG) << "SETNAME for nonexistent user " << source; return MOD_CONT; } @@ -675,7 +675,7 @@ int anope_event_chgname(const Anope::string &source, int ac, const char **av) u = finduser(source); if (!u) { - Alog(LOG_DEBUG) << "FNAME for nonexistent user " << source; + Log(LOG_DEBUG) << "FNAME for nonexistent user " << source; return MOD_CONT; } @@ -690,7 +690,7 @@ int anope_event_setident(const Anope::string &source, int ac, const char **av) u = finduser(source); if (!u) { - Alog(LOG_DEBUG) << "SETIDENT for nonexistent user " << source; + Log(LOG_DEBUG) << "SETIDENT for nonexistent user " << source; return MOD_CONT; } @@ -705,7 +705,7 @@ int anope_event_chgident(const Anope::string &source, int ac, const char **av) u = finduser(av[0]); if (!u) { - Alog(LOG_DEBUG) << "CHGIDENT for nonexistent user " << av[0]; + Log(LOG_DEBUG) << "CHGIDENT for nonexistent user " << av[0]; return MOD_CONT; } @@ -720,7 +720,7 @@ int anope_event_sethost(const Anope::string &source, int ac, const char **av) u = finduser(source); if (!u) { - Alog(LOG_DEBUG) << "SETHOST for nonexistent user " << source; + Log(LOG_DEBUG) << "SETHOST for nonexistent user " << source; return MOD_CONT; } @@ -791,7 +791,7 @@ int anope_event_chghost(const Anope::string &source, int ac, const char **av) u = finduser(source); if (!u) { - Alog(LOG_DEBUG) << "FHOST for nonexistent user " << source; + Log(LOG_DEBUG) << "FHOST for nonexistent user " << source; return MOD_CONT; } @@ -1206,7 +1206,7 @@ int anope_event_endburst(const Anope::string &source, int ac, const char **av) u->RemoveMode(NickServ, UMODE_REGISTERED); } - Alog() << "Processed ENDBURST for " << s->GetName(); + Log(LOG_DEBUG) << "Processed ENDBURST for " << s->GetName(); s->Sync(true); return MOD_CONT; diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index 54c30d8df..1b6a582c0 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -415,7 +415,7 @@ int anope_event_fmode(const Anope::string &source, int ac, const char **av) { newav[o] = av[n]; ++o; - Alog(LOG_DEBUG) << "Param: " << newav[o - 1]; + Log(LOG_DEBUG) << "Param: " << newav[o - 1]; } ++n; } @@ -474,7 +474,7 @@ int anope_event_fjoin(const Anope::string &source, int ac, const char **av) ChannelMode *cm = ModeManager::FindChannelModeByChar(buf[0]); if (!cm) { - Alog() << "Recieved unknown mode prefix " << buf[0] << " in FJOIN string"; + Log() << "Recieved unknown mode prefix " << buf[0] << " in FJOIN string"; buf.erase(buf.begin()); continue; } @@ -488,7 +488,7 @@ int anope_event_fjoin(const Anope::string &source, int ac, const char **av) User *u = finduser(buf); if (!u) { - Alog(LOG_DEBUG) << "FJOIN for nonexistant user " << buf << " on " << c->name; + Log(LOG_DEBUG) << "FJOIN for nonexistant user " << buf << " on " << c->name; continue; } @@ -573,7 +573,7 @@ int anope_event_topic(const Anope::string &source, int ac, const char **av) if (!c) { - Alog(LOG_DEBUG) << "debug: TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0]; + Log(LOG_DEBUG) << "debug: TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0]; return MOD_CONT; } @@ -658,7 +658,7 @@ int anope_event_setname(const Anope::string &source, int ac, const char **av) u = finduser(source); if (!u) { - Alog(LOG_DEBUG) << "SETNAME for nonexistent user " << source; + Log(LOG_DEBUG) << "SETNAME for nonexistent user " << source; return MOD_CONT; } @@ -673,7 +673,7 @@ int anope_event_chgname(const Anope::string &source, int ac, const char **av) u = finduser(source); if (!u) { - Alog(LOG_DEBUG) << "FNAME for nonexistent user " << source; + Log(LOG_DEBUG) << "FNAME for nonexistent user " << source; return MOD_CONT; } @@ -688,7 +688,7 @@ int anope_event_setident(const Anope::string &source, int ac, const char **av) u = finduser(source); if (!u) { - Alog(LOG_DEBUG) << "SETIDENT for nonexistent user " << source; + Log(LOG_DEBUG) << "SETIDENT for nonexistent user " << source; return MOD_CONT; } @@ -702,7 +702,7 @@ int anope_event_chgident(const Anope::string &source, int ac, const char **av) if (!u) { - Alog(LOG_DEBUG) << "FIDENT for nonexistent user " << source; + Log(LOG_DEBUG) << "FIDENT for nonexistent user " << source; return MOD_CONT; } @@ -717,7 +717,7 @@ int anope_event_sethost(const Anope::string &source, int ac, const char **av) u = finduser(source); if (!u) { - Alog(LOG_DEBUG) << "SETHOST for nonexistent user " << source; + Log(LOG_DEBUG) << "SETHOST for nonexistent user " << source; return MOD_CONT; } @@ -788,7 +788,7 @@ int anope_event_chghost(const Anope::string &source, int ac, const char **av) u = finduser(source); if (!u) { - Alog(LOG_DEBUG) << "FHOST for nonexistent user " << source; + Log(LOG_DEBUG) << "FHOST for nonexistent user " << source; return MOD_CONT; } @@ -974,7 +974,7 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av) if (cm) ModeManager::AddChannelMode(cm); else - Alog() << "Unrecognized mode string in CAPAB CHANMODES: " << capab; + Log() << "Unrecognized mode string in CAPAB CHANMODES: " << capab; } } else if (!strcasecmp(av[0], "USERMODES")) @@ -1030,7 +1030,7 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av) if (um) ModeManager::AddUserMode(um); else - Alog() << "Unrecognized mode string in CAPAB USERMODES: " << capab; + Log() << "Unrecognized mode string in CAPAB USERMODES: " << capab; } } else if (!strcasecmp(av[0], "MODULES")) @@ -1179,7 +1179,7 @@ int anope_event_endburst(const Anope::string &source, int ac, const char **av) u->RemoveMode(NickServ, UMODE_REGISTERED); } - Alog() << "Processed ENDBURST for " << s->GetName(); + Log(LOG_DEBUG) << "Processed ENDBURST for " << s->GetName(); s->Sync(true); return MOD_CONT; diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index dc039682e..b45f1121a 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -102,7 +102,7 @@ void ratbox_cmd_pass(const Anope::string &pass) send_cmd("", "PASS %s TS 6 :%s", pass.c_str(), TS6SID.c_str()); } -class RatboxProto : public IRCDTS6Proto +class RatboxProto : public IRCDProto { void SendGlobopsInternal(BotInfo *source, const Anope::string &buf) { @@ -327,7 +327,7 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av) ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); if (!cm) { - Alog() << "Received unknown mode prefix " << buf[0] << " in SJOIN string"; + Log() << "Received unknown mode prefix " << buf[0] << " in SJOIN string"; continue; } @@ -338,7 +338,7 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av) User *u = finduser(buf); if (!u) { - Alog(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << c->name; + Log(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << c->name; continue; } @@ -443,7 +443,7 @@ int anope_event_topic(const Anope::string &source, int ac, const char **av) if (!c) { - Alog(LOG_DEBUG) << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0]; + Log(LOG_DEBUG) << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0]; return MOD_CONT; } @@ -487,7 +487,7 @@ int anope_event_tburst(const Anope::string &source, int ac, const char **av) if (!c) { - Alog(LOG_DEBUG) << "debug: TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0]; + Log(LOG_DEBUG) << "debug: TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0]; return MOD_CONT; } @@ -721,7 +721,7 @@ int anope_event_bmask(const Anope::string &source, int ac, const char **av) int anope_event_error(const Anope::string &source, int ac, const char **av) { if (ac >= 1) - Alog(LOG_DEBUG) << av[0]; + Log(LOG_DEBUG) << av[0]; return MOD_CONT; } diff --git a/modules/protocol/unreal32.cpp b/modules/protocol/unreal32.cpp index cb1949cb7..5304e9d83 100644 --- a/modules/protocol/unreal32.cpp +++ b/modules/protocol/unreal32.cpp @@ -735,7 +735,7 @@ int anope_event_setname(const Anope::string &source, int ac, const char **av) u = finduser(source); if (!u) { - Alog(LOG_DEBUG) << "SETNAME for nonexistent user " << source; + Log(LOG_DEBUG) << "SETNAME for nonexistent user " << source; return MOD_CONT; } @@ -753,7 +753,7 @@ int anope_event_chgname(const Anope::string &source, int ac, const char **av) u = finduser(av[0]); if (!u) { - Alog(LOG_DEBUG) << "CHGNAME for nonexistent user " << av[0]; + Log(LOG_DEBUG) << "CHGNAME for nonexistent user " << av[0]; return MOD_CONT; } @@ -771,7 +771,7 @@ int anope_event_setident(const Anope::string &source, int ac, const char **av) u = finduser(source); if (!u) { - Alog(LOG_DEBUG) << "SETIDENT for nonexistent user " << source; + Log(LOG_DEBUG) << "SETIDENT for nonexistent user " << source; return MOD_CONT; } @@ -789,7 +789,7 @@ int anope_event_chgident(const Anope::string &source, int ac, const char **av) u = finduser(av[0]); if (!u) { - Alog(LOG_DEBUG) << "CHGIDENT for nonexistent user " << av[0]; + Log(LOG_DEBUG) << "CHGIDENT for nonexistent user " << av[0]; return MOD_CONT; } @@ -807,7 +807,7 @@ int anope_event_sethost(const Anope::string &source, int ac, const char **av) u = finduser(source); if (!u) { - Alog(LOG_DEBUG) << "SETHOST for nonexistent user " << source; + Log(LOG_DEBUG) << "SETHOST for nonexistent user " << source; return MOD_CONT; } @@ -920,7 +920,7 @@ int anope_event_chghost(const Anope::string &source, int ac, const char **av) u = finduser(av[0]); if (!u) { - Alog(LOG_DEBUG) << "debug: CHGHOST for nonexistent user " << av[0]; + Log(LOG_DEBUG) << "debug: CHGHOST for nonexistent user " << av[0]; return MOD_CONT; } @@ -972,9 +972,9 @@ int anope_event_error(const Anope::string &source, int ac, const char **av) { if (av[0]) { - Alog(LOG_DEBUG) << av[0]; + Log(LOG_DEBUG) << av[0]; if (strstr(av[0], "No matching link configuration")) - Alog() << "Error: Your IRCD's link block may not be setup correctly, please check unrealircd.conf"; + Log() << "Error: Your IRCD's link block may not be setup correctly, please check unrealircd.conf"; } return MOD_CONT; } @@ -1063,7 +1063,7 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av) ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); if (!cm) { - Alog() << "Received unknown mode prefix " << buf[0] << " in SJOIN string"; + Log() << "Received unknown mode prefix " << buf[0] << " in SJOIN string"; continue; } @@ -1074,7 +1074,7 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av) User *u = finduser(buf); if (!u) { - Alog(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << c->name; + Log(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << c->name; continue; } diff --git a/modules/socketengines/m_socketengine_epoll.cpp b/modules/socketengines/m_socketengine_epoll.cpp index 9fadb22a1..4b38fc657 100644 --- a/modules/socketengines/m_socketengine_epoll.cpp +++ b/modules/socketengines/m_socketengine_epoll.cpp @@ -20,7 +20,7 @@ class SocketEngineEPoll : public SocketEngineBase if (max <= 0) { - Alog() << "Can't determine maximum number of open sockets"; + Log() << "Can't determine maximum number of open sockets"; throw ModuleException("Can't determine maximum number of open sockets"); } @@ -28,7 +28,7 @@ class SocketEngineEPoll : public SocketEngineBase if (EngineHandle == -1) { - Alog() << "Could not initialize epoll socket engine: " << strerror(errno); + Log() << "Could not initialize epoll socket engine: " << strerror(errno); throw ModuleException(Anope::string("Could not initialize epoll socket engine: ") + strerror(errno)); } @@ -52,7 +52,7 @@ class SocketEngineEPoll : public SocketEngineBase if (epoll_ctl(EngineHandle, EPOLL_CTL_ADD, ev.data.fd, &ev) == -1) { - Alog() << "Unable to add fd " << ev.data.fd << " to socketengine epoll: " << strerror(errno); + Log() << "Unable to add fd " << ev.data.fd << " to socketengine epoll: " << strerror(errno); return; } @@ -71,7 +71,7 @@ class SocketEngineEPoll : public SocketEngineBase if (epoll_ctl(EngineHandle, EPOLL_CTL_DEL, ev.data.fd, &ev) == -1) { - Alog() << "Unable to delete fd " << ev.data.fd << " from socketengine epoll: " << strerror(errno); + Log() << "Unable to delete fd " << ev.data.fd << " from socketengine epoll: " << strerror(errno); return; } @@ -90,7 +90,7 @@ class SocketEngineEPoll : public SocketEngineBase ev.data.fd = s->GetSock(); if (epoll_ctl(EngineHandle, EPOLL_CTL_MOD, ev.data.fd, &ev) == -1) - Alog() << "Unable to mark fd " << ev.data.fd << " as writable in socketengine epoll: " << strerror(errno); + Log() << "Unable to mark fd " << ev.data.fd << " as writable in socketengine epoll: " << strerror(errno); } void ClearWriteable(Socket *s) @@ -103,7 +103,7 @@ class SocketEngineEPoll : public SocketEngineBase ev.data.fd = s->GetSock(); if (epoll_ctl(EngineHandle, EPOLL_CTL_MOD, ev.data.fd, &ev) == -1) - Alog() << "Unable to mark fd " << ev.data.fd << " as unwritable in socketengine epoll: " << strerror(errno); + Log() << "Unable to mark fd " << ev.data.fd << " as unwritable in socketengine epoll: " << strerror(errno); } void Process() @@ -112,7 +112,7 @@ class SocketEngineEPoll : public SocketEngineBase if (total == -1) { - Alog() << "SockEngine::Process(): error " << strerror(errno); + Log() << "SockEngine::Process(): error " << strerror(errno); return; } diff --git a/modules/socketengines/m_socketengine_select.cpp b/modules/socketengines/m_socketengine_select.cpp index 72b851780..eb5ddab1a 100644 --- a/modules/socketengines/m_socketengine_select.cpp +++ b/modules/socketengines/m_socketengine_select.cpp @@ -65,7 +65,7 @@ class SocketEngineSelect : public SocketEngineBase #ifdef WIN32 errno = WSAGetLastError(); #endif - Alog() << "SockEngine::Process(): error" << strerror(errno); + Log() << "SockEngine::Process(): error" << strerror(errno); } else if (sresult) { diff --git a/src/bots.cpp b/src/bots.cpp index d63f6787f..e6124e135 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -20,16 +20,15 @@ BotInfo *MemoServ = NULL; BotInfo *NickServ = NULL; BotInfo *OperServ = NULL; -BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal) : User(nnick, ts6_uid_retrieve()) +BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal) : User(nnick, nuser, nhost, ts6_uid_retrieve()) { - this->ident = nuser; - this->host = nhost; this->realname = nreal; this->server = Me; this->chancount = 0; this->lastmsg = this->created = time(NULL); + this->SetFlag(BI_CORE); if (!Config->s_ChanServ.empty() && nnick.equals_ci(Config->s_ChanServ)) ChanServ = this; else if (!Config->s_BotServ.empty() && nnick.equals_ci(Config->s_BotServ)) @@ -44,6 +43,8 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A NickServ = this; else if (!Config->s_GlobalNoticer.empty() && nnick.equals_ci(Config->s_GlobalNoticer)) Global = this; + else + this->UnsetFlag(BI_CORE); BotListByNick[this->nick] = this; if (!this->uid.empty()) @@ -168,16 +169,16 @@ void BotInfo::Join(Channel *c, bool update_ts) c->JoinUser(this); ChannelContainer *cc = this->FindChannel(c); - for (std::list::iterator it = BotModes.begin(), it_end = BotModes.end(); it != it_end; ++it) + for (int i = 0; i < Config->BotModeList.size(); ++i) { if (!update_ts) { - c->SetMode(this, *it, this->nick, false); + c->SetMode(this, Config->BotModeList[i], this->nick, false); } else { - cc->Status->SetFlag((*it)->Name); - c->SetModeInternal(*it, this->nick, false); + cc->Status->SetFlag(Config->BotModeList[i]->Name); + c->SetModeInternal(Config->BotModeList[i], this->nick, false); } } if (!update_ts) diff --git a/src/channels.cpp b/src/channels.cpp index aa2e0affc..506dbfc7d 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -37,6 +37,8 @@ Channel::Channel(const Anope::string &name, time_t ts) this->ci = cs_findchan(this->name); if (this->ci) this->ci->c = this; + + Log(NULL, this, "create"); FOREACH_MOD(I_OnChannelCreate, OnChannelCreate(this)); } @@ -49,7 +51,7 @@ Channel::~Channel() FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this)); - Alog(LOG_DEBUG) << "Deleting channel " << this->name; + Log(NULL, this, "destroy"); for (bd = this->bd; bd; bd = next) { @@ -114,7 +116,7 @@ void Channel::Sync() void Channel::JoinUser(User *user) { - Alog(LOG_DEBUG) << user->nick << " joins " << this->name; + Log(user, this, "join"); ChannelStatus *Status = new ChannelStatus(); ChannelContainer *cc = new ChannelContainer(this); @@ -128,7 +130,7 @@ void Channel::JoinUser(User *user) bool update_ts = false; if (this->ci && this->ci->HasFlag(CI_PERSIST) && this->creation_time > this->ci->time_registered) { - Alog(LOG_DEBUG) << "Changing TS of " << this->name << " from " << this->creation_time << " to " << this->ci->time_registered; + Log(LOG_DEBUG) << "Changing TS of " << this->name << " from " << this->creation_time << " to " << this->ci->time_registered; this->creation_time = this->ci->time_registered; update_ts = true; } @@ -188,13 +190,13 @@ void Channel::DeleteUser(User *user) if (this->ci) update_cs_lastseen(user, this->ci); - Alog(LOG_DEBUG) << user->nick << " leaves " << this->name; + Log(user, this, "leaves"); CUserList::iterator cit, cit_end = this->users.end(); for (cit = this->users.begin(); (*cit)->user != user && cit != cit_end; ++cit); if (cit == cit_end) { - Alog(LOG_DEBUG) << "Channel::DeleteUser() tried to delete nonexistant user " << user->nick << " from channel " << this->name; + Log(LOG_DEBUG) << "Channel::DeleteUser() tried to delete nonexistant user " << user->nick << " from channel " << this->name; return; } @@ -206,7 +208,7 @@ void Channel::DeleteUser(User *user) for (uit = user->chans.begin(); (*uit)->chan != this && uit != uit_end; ++uit); if (uit == uit_end) { - Alog(LOG_DEBUG) << "Channel::DeleteUser() tried to delete nonexistant channel " << this->name << " from " << user->nick << "'s channel list"; + Log(LOG_DEBUG) << "Channel::DeleteUser() tried to delete nonexistant channel " << this->name << " from " << user->nick << "'s channel list"; return; } @@ -310,7 +312,7 @@ void Channel::SetModeInternal(ChannelMode *cm, const Anope::string ¶m, bool { if (param.empty()) { - Alog() << "Channel::SetModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name; + Log() << "Channel::SetModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name; return; } @@ -321,11 +323,11 @@ void Channel::SetModeInternal(ChannelMode *cm, const Anope::string ¶m, bool if (!u) { - Alog(LOG_DEBUG) << "MODE " << this->name << " +" << cm->ModeChar << " for nonexistant user " << param; + Log() << "MODE " << this->name << " +" << cm->ModeChar << " for nonexistant user " << param; return; } - Alog(LOG_DEBUG) << "Setting +" << cm->ModeChar << " on " << this->name << " for " << u->nick; + Log(LOG_DEBUG) << "Setting +" << cm->ModeChar << " on " << this->name << " for " << u->nick; /* Set the status on the user */ ChannelContainer *cc = u->FindChannel(this); @@ -342,7 +344,7 @@ void Channel::SetModeInternal(ChannelMode *cm, const Anope::string ¶m, bool { if (param.empty()) { - Alog() << "Channel::SetModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name; + Log() << "Channel::SetModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name; return; } @@ -357,7 +359,7 @@ void Channel::SetModeInternal(ChannelMode *cm, const Anope::string ¶m, bool { if (cm->Type != MODE_PARAM) { - Alog() << "Channel::SetModeInternal() mode " << cm->ModeChar << " for " << this->name << " with a paramater, but its not a param mode"; + Log() << "Channel::SetModeInternal() mode " << cm->ModeChar << " for " << this->name << " with a paramater, but its not a param mode"; return; } @@ -437,7 +439,7 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const Anope::string ¶m, bo { if (param.empty()) { - Alog() << "Channel::RemoveModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name; + Log() << "Channel::RemoveModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name; return; } @@ -449,17 +451,17 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const Anope::string ¶m, bo /* Reset modes on bots if we're supposed to */ if (bi) { - if (std::find(BotModes.begin(), BotModes.end(), cm) != BotModes.end()) + if (std::find(Config->BotModeList.begin(), Config->BotModeList.end(), cm) != Config->BotModeList.end()) this->SetMode(bi, cm, bi->nick); } if (!u) { - Alog() << "Channel::RemoveModeInternal() MODE " << this->name << "-" << cm->ModeChar << " for nonexistant user " << param; + Log() << "Channel::RemoveModeInternal() MODE " << this->name << "-" << cm->ModeChar << " for nonexistant user " << param; return; } - Alog(LOG_DEBUG) << "Setting -" << cm->ModeChar << " on " << this->name << " for " << u->nick; + Log(LOG_DEBUG) << "Setting -" << cm->ModeChar << " on " << this->name << " for " << u->nick; /* Remove the status on the user */ ChannelContainer *cc = u->FindChannel(this); @@ -473,7 +475,7 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const Anope::string ¶m, bo { if (param.empty()) { - Alog() << "Channel::RemoveModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name; + Log() << "Channel::RemoveModeInternal() mode " << cm->ModeChar << " with no parameter for channel " << this->name; return; } @@ -904,11 +906,11 @@ void ChanSetInternalModes(Channel *c, int ac, const char **av) c->RemoveModeInternal(cm, av[j]); } else - Alog() << "warning: ChanSetInternalModes() recieved more modes requiring params than params, modes: " << merge_args(ac, av) << ", ac: " << ac << ", j: " << j; + Log() << "warning: ChanSetInternalModes() recieved more modes requiring params than params, modes: " << merge_args(ac, av) << ", ac: " << ac << ", j: " << j; } if (j + k + 1 < ac) - Alog() << "warning: ChanSetInternalModes() recieved more params than modes requiring them, modes: " << merge_args(ac, av) << ", ac: " << ac << ", j: " << j << " k: " << k; + Log() << "warning: ChanSetInternalModes() recieved more params than modes requiring them, modes: " << merge_args(ac, av) << ", ac: " << ac << ", j: " << j << " k: " << k; } /** Kick a user from a channel internally @@ -924,11 +926,11 @@ void Channel::KickInternal(const Anope::string &source, const Anope::string &nic User *user = bi ? bi : finduser(nick); if (!user) { - Alog(LOG_DEBUG) << "Channel::KickInternal got a nonexistent user " << nick << " on " << this->name << ": " << reason; + Log() << "Channel::KickInternal got a nonexistent user " << nick << " on " << this->name << ": " << reason; return; } - Alog(LOG_DEBUG) << "Channel::KickInternal kicking " << user->nick << " from " << this->name; + Log(user, this, "kick") << "by " << source << " (" << reason << ")"; Anope::string chname = this->name; @@ -938,7 +940,7 @@ void Channel::KickInternal(const Anope::string &source, const Anope::string &nic this->DeleteUser(user); } else - Alog(LOG_DEBUG) << "Channel::KickInternal got kick for user " << user->nick << " who isn't on channel " << this->name << " ?"; + Log() << "Channel::KickInternal got kick for user " << user->nick << " who isn't on channel " << this->name << " ?"; /* Bots get rejoined */ if (bi) @@ -1113,7 +1115,7 @@ void do_join(const Anope::string &source, int ac, const char **av) user = finduser(source); if (!user) { - Alog(LOG_DEBUG) << "JOIN from nonexistent user " << source << ": " << merge_args(ac, av); + Log() << "JOIN from nonexistent user " << source << ": " << merge_args(ac, av); return; } @@ -1150,7 +1152,7 @@ void do_join(const Anope::string &source, int ac, const char **av) /* Their time is older, we lose */ if (chan->creation_time > ts) { - Alog(LOG_DEBUG) << "Recieved an older TS " << chan->name << " in JOIN, changing from " << chan->creation_time << " to " << ts; + Log(LOG_DEBUG) << "Recieved an older TS " << chan->name << " in JOIN, changing from " << chan->creation_time << " to " << ts; chan->creation_time = ts; chan->Reset(); @@ -1188,7 +1190,7 @@ void do_kick(const Anope::string &source, int ac, const char **av) Channel *c = findchan(av[0]); if (!c) { - Alog(LOG_DEBUG) << "Recieved kick for nonexistant channel " << av[0]; + Log() << "Recieved kick for nonexistant channel " << av[0]; return; } @@ -1210,7 +1212,7 @@ void do_part(const Anope::string &source, int ac, const char **av) User *user = finduser(source); if (!user) { - Alog(LOG_DEBUG) << "PART from nonexistent user " << source << ": " << merge_args(ac, av); + Log() << "PART from nonexistent user " << source << ": " << merge_args(ac, av); return; } @@ -1221,17 +1223,17 @@ void do_part(const Anope::string &source, int ac, const char **av) Channel *c = findchan(buf); if (!c) - Alog(LOG_DEBUG) << "Recieved PART from " << user->nick << " for nonexistant channel " << buf; - - if (user->FindChannel(c)) + Log() << "Recieved PART from " << user->nick << " for nonexistant channel " << buf; + else if (user->FindChannel(c)) { + Log(user, c, "part") << "Reason: " << (av[1] ? av[1] : "No reason"); FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(user, c)); Anope::string ChannelName = c->name; c->DeleteUser(user); FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, findchan(ChannelName), ChannelName, av[1] ? av[1] : "")); } else - Alog(LOG_DEBUG) << "Recieved PART from " << user->nick << " for " << c->name << ", but " << user->nick << " isn't in " << c->name << "?"; + Log() << "Recieved PART from " << user->nick << " for " << c->name << ", but " << user->nick << " isn't in " << c->name << "?"; } } @@ -1264,7 +1266,7 @@ void do_cmode(const Anope::string &source, int ac, const char **av) ++av; } else - Alog() << "TSMODE enabled but MODE has no valid TS"; + Log() << "TSMODE enabled but MODE has no valid TS"; } /* :42XAAAAAO TMODE 1106409026 #ircops +b *!*@*.aol.com */ @@ -1281,7 +1283,7 @@ void do_cmode(const Anope::string &source, int ac, const char **av) { ci = cs_findchan(av[0]); if (!ci || ci->HasFlag(CI_FORBIDDEN)) - Alog(LOG_DEBUG) << "MODE " << merge_args(ac - 1, av + 1) << " for nonexistant channel " << av[0]; + Log(LOG_DEBUG) << "MODE " << merge_args(ac - 1, av + 1) << " for nonexistant channel " << av[0]; } return; } @@ -1298,6 +1300,10 @@ void do_cmode(const Anope::string &source, int ac, const char **av) --ac; ++av; + + User *u = finduser(source); + if (u) + Log(u, c, "mode") << merge_args(ac, av); ChanSetInternalModes(c, ac, av); } @@ -1313,7 +1319,7 @@ void do_topic(const Anope::string &source, int ac, const char **av) if (!c) { - Alog(LOG_DEBUG) << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0]; + Log() << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0]; return; } @@ -1380,7 +1386,7 @@ void chan_set_correct_modes(User *user, Channel *c, int give_modes) if (ci->HasFlag(CI_FORBIDDEN) || c->name[0] == '+') return; - Alog(LOG_DEBUG) << "Setting correct user modes for " << user->nick << " on " << c->name << " (" << (give_modes ? "" : "not ") << "giving modes)"; + Log(LOG_DEBUG) << "Setting correct user modes for " << user->nick << " on " << c->name << " (" << (give_modes ? "" : "not ") << "giving modes)"; if (give_modes && !get_ignore(user->nick) && (!user->Account() || user->Account()->HasFlag(NI_AUTOOP))) { diff --git a/src/chanserv.cpp b/src/chanserv.cpp index c80de4c75..b6df9d8cd 100644 --- a/src/chanserv.cpp +++ b/src/chanserv.cpp @@ -252,7 +252,7 @@ void check_modes(Channel *c) if (!c) { - Alog(LOG_DEBUG) << "check_modes called with NULL values"; + Log() << "check_modes called with NULL values"; return; } @@ -263,7 +263,7 @@ void check_modes(Channel *c) if (c->server_modecount >= 3 && c->chanserv_modecount >= 3) { ircdproto->SendGlobops(NULL, "Warning: unable to set modes on channel %s. Are your servers' U:lines configured correctly?", c->name.c_str()); - Alog() << Config->s_ChanServ << ": Bouncy modes on channel " << c->name; + Log() << "Bouncy modes on channel " << c->name; c->bouncy_modes = 1; return; } @@ -497,7 +497,7 @@ int check_topiclock(Channel *c, time_t topic_time) if (!c) { - Alog(LOG_DEBUG) << "check_topiclock called with NULL values"; + Log() << "check_topiclock called with NULL values"; return 0; } @@ -572,7 +572,7 @@ void expire_chans() continue; Anope::string chname = ci->name; - Alog() << "Expiring channel " << ci->name << " (founder: " << (ci->founder ? ci->founder->display : "(none)") << " )"; + Log(LOG_NORMAL, "chanserv/expire") << "Expiring channel " << ci->name << " (founder: " << (ci->founder ? ci->founder->display : "(none)") << " )"; delete ci; FOREACH_MOD(I_OnChanExpire, OnChanExpire(chname)); } @@ -599,13 +599,13 @@ void cs_remove_nick(const NickCore *nc) NickCore *nc2 = ci->successor; if (!nc2->IsServicesOper() && Config->CSMaxReg && nc2->channelcount >= Config->CSMaxReg) { - Alog() << Config->s_ChanServ << ": Successor (" << nc2->display << " ) of " << ci->name << " owns too many channels, deleting channel", + Log(LOG_NORMAL, "chanserv/expire") << "Successor (" << nc2->display << " ) of " << ci->name << " owns too many channels, deleting channel", delete ci; continue; } else { - Alog() << Config->s_ChanServ << ": Transferring foundership of " << ci->name << " from deleted nick " << nc->display << " to successor " << nc2->display; + Log(LOG_NORMAL, "chanserv/expire") << "Transferring foundership of " << ci->name << " from deleted nick " << nc->display << " to successor " << nc2->display; ci->founder = nc2; ci->successor = NULL; ++nc2->channelcount; @@ -613,7 +613,7 @@ void cs_remove_nick(const NickCore *nc) } else { - Alog() << Config->s_ChanServ << ": Deleting channel " << ci->name << "owned by deleted nick " << nc->display; + Log(LOG_NORMAL, "chanserv/expire") << "Deleting channel " << ci->name << "owned by deleted nick " << nc->display; if (ModeManager::FindChannelModeByName(CMODE_REGISTERED)) { @@ -712,7 +712,7 @@ void reset_levels(ChannelInfo *ci) if (!ci) { - Alog(LOG_DEBUG) << "reset_levels() called with NULL values"; + Log() << "reset_levels() called with NULL values"; return; } diff --git a/src/commands.cpp b/src/commands.cpp index 26ca76e65..bbf2a5233 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -58,7 +58,7 @@ void mod_run_cmd(BotInfo *bi, User *u, Command *c, const Anope::string &command, if (!c->HasFlag(CFLAG_ALLOW_UNREGISTERED) && !u->IsIdentified()) { notice_lang(bi->nick, u, NICK_IDENTIFY_REQUIRED, Config->s_NickServ.c_str()); - Alog() << "Access denied for unregistered user " << u->nick << " with service " << bi->nick << " and command " << command; + Log(LOG_COMMAND, "denied", bi) << "Access denied for unregistered user " << u->GetMask() << " with command " << command; return; } @@ -103,13 +103,13 @@ void mod_run_cmd(BotInfo *bi, User *u, Command *c, const Anope::string &command, if (ci->HasFlag(CI_FORBIDDEN) && !c->HasFlag(CFLAG_ALLOW_FORBIDDEN)) { notice_lang(bi->nick, u, CHAN_X_FORBIDDEN, ci->name.c_str()); - Alog() << "Access denied for user " << u->nick << " with service " << bi->nick << " and command " << command << " because of FORBIDDEN channel " << ci->name; + Log(LOG_COMMAND, "denied", bi) << "Access denied for user " << u->GetMask() << " with command " << command << " because of FORBIDDEN channel " << ci->name; return; } else if (ci->HasFlag(CI_SUSPENDED) && !c->HasFlag(CFLAG_ALLOW_SUSPENDED)) { notice_lang(bi->nick, u, CHAN_X_FORBIDDEN, ci->name.c_str()); - Alog() << "Access denied for user " << u->nick << " with service " << bi->nick <<" and command " << command << " because of SUSPENDED channel " << ci->name; + Log(LOG_COMMAND, "denied", bi) << "Access denied for user " << u->GetMask() << " with command " << command << " because of SUSPENDED channel " << ci->name; return; } } @@ -131,7 +131,7 @@ void mod_run_cmd(BotInfo *bi, User *u, Command *c, const Anope::string &command, if (!c->permission.empty() && !u->Account()->HasCommand(c->permission)) { notice_lang(bi->nick, u, ACCESS_DENIED); - Alog() << "Access denied for user " << u->nick << " with service " << bi->nick << " and command " << command; + Log(LOG_COMMAND, "denied", bi) << "Access denied for user " << u->GetMask() << " with command " << command; return; } diff --git a/src/config.cpp b/src/config.cpp index 0dfc9702e..48563b0c5 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -82,7 +82,7 @@ ServerConfig::ServerConfig() : errstr(""), config_data() else if (option.equals_ci("msg")) { if (!this->UsePrivmsg) - Alog() << "msg in can only be used when UsePrivmsg is set"; + Log() << "msg in can only be used when UsePrivmsg is set"; else this->NSDefFlags.SetFlag(NI_MSG); } @@ -262,7 +262,7 @@ ServerConfig::ServerConfig() : errstr(""), config_data() /* Check the user keys */ if (this->UserKey1 == this->UserKey2 || this->UserKey1 == this->UserKey3 || this->UserKey3 == this->UserKey2) - Alog() << "Every UserKey must be different. It's for YOUR safety! Remember that!"; + Log() << "Every UserKey must be different. It's for YOUR safety! Remember that!"; /** * Check all DEFCON dependiencies... @@ -349,10 +349,6 @@ ServerConfig::ServerConfig() : errstr(""), config_data() } SetDefaultMLock(this); - - /* Disable the log channel if its defined in the conf, but not enabled */ - if (this->LogChannel.empty() && LogChan) - LogChan = false; } bool ServerConfig::CheckOnce(const Anope::string &tag) @@ -614,13 +610,13 @@ bool ValidateNickLen(ServerConfig *, const Anope::string &, const Anope::string int nicklen = data.GetInteger(); if (!nicklen) { - Alog() << "You have not defined the directive. It is strongly"; - Alog() << "adviced that you do configure this correctly in your services.conf"; + Log() << "You have not defined the directive. It is strongly"; + Log() << "adviced that you do configure this correctly in your services.conf"; data.Set(31); } else if (nicklen < 1) { - Alog() << " has an invalid value; setting to 31"; + Log() << " has an invalid value; setting to 31"; data.Set(31); } return true; @@ -645,7 +641,7 @@ bool ValidateGlobalOnCycle(ServerConfig *config, const Anope::string &tag, const { if (data.GetValue().empty()) { - Alog() << "<" << tag << ":" << value << "> was undefined, disabling "; + Log() << "<" << tag << ":" << value << "> was undefined, disabling "; config->GlobalOnCycle = false; } } @@ -733,7 +729,7 @@ static bool DoOperType(ServerConfig *config, const Anope::string &, const Anope: { if ((*it)->GetName().equals_ci(tok)) { - Alog() << "Inheriting commands and privs from " << (*it)->GetName() << " to " << ot->GetName(); + Log() << "Inheriting commands and privs from " << (*it)->GetName() << " to " << ot->GetName(); ot->Inherits(*it); break; } @@ -797,7 +793,7 @@ static bool DoneOpers(ServerConfig *config, const Anope::string &) OperType *ot = *tit; if (ot->GetName().equals_ci(type)) { - Alog() << "Tied oper " << na->nc->display << " to type " << type; + Log() << "Tied oper " << na->nc->display << " to type " << type; na->nc->ot = ot; } } @@ -833,6 +829,91 @@ bool DoneModules(ServerConfig *, const Anope::string &) return true; } +bool InitLogs(ServerConfig *config, const Anope::string &) +{ + for (unsigned i = 0; i < config->LogInfos.size(); ++i) + { + LogInfo *l = config->LogInfos[i]; + + for (std::list::const_iterator sit = l->Targets.begin(), sit_end = l->Targets.end(); sit != sit_end; ++sit) + { + const Anope::string &target = *sit; + + if (target[0] == '#') + { + Channel *c = findchan(target); + if (c && c->HasFlag(CH_LOGCHAN)) + { + for (CUserList::const_iterator cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end; ++cit) + { + UserContainer *uc = *cit; + BotInfo *bi = findbot(uc->user->nick); + + if (bi && bi->HasFlag(BI_CORE)) + { + bi->Part(c, "Reloading"); + } + } + + c->UnsetFlag(CH_PERSIST); + c->UnsetFlag(CH_LOGCHAN); + if (c->users.empty()) + delete c; + } + } + } + + delete config->LogInfos[i]; + } + config->LogInfos.clear(); + + return true; +} + +bool DoLogs(ServerConfig *config, const Anope::string &, const Anope::string *, ValueList &values, int *) +{ + //{"target", "source", "logage", "admin", "override", "commands", "servers", "channels", "users", "normal", "rawio", "debug"}, + Anope::string targets = values[0].GetValue(); + ValueItem vi(targets); + if (!ValidateNotEmpty(config, "log", "target", vi)) + throw ConfigException("One or more values in your configuration file failed to validate. Please see your log for more information."); + + Anope::string source = values[1].GetValue(); + int logage = values[2].GetInteger(); + Anope::string admin = values[3].GetValue(); + Anope::string override = values[4].GetValue(); + Anope::string commands = values[5].GetValue(); + Anope::string servers = values[6].GetValue(); + Anope::string channels = values[7].GetValue(); + Anope::string users = values[8].GetValue(); + bool normal = values[9].GetBool(); + bool rawio = values[10].GetBool(); + bool ldebug = values[11].GetBool(); + + LogInfo *l = new LogInfo(logage, normal, rawio, ldebug); + l->Targets = BuildStringList(targets); + l->Sources = BuildStringList(source); + l->Admin = BuildStringList(admin); + l->Override = BuildStringList(override); + l->Commands = BuildStringList(commands); + l->Servers = BuildStringList(servers); + l->Channels = BuildStringList(channels); + l->Users = BuildStringList(users); + + config->LogInfos.push_back(l); + + return true; +} + +bool DoneLogs(ServerConfig *config, const Anope::string &) +{ + InitLogChannels(config); + + Log() << "Loaded " << config->LogInfos.size() << " log blocks"; + + return true; +} + void ServerConfig::Read() { errstr.clear(); @@ -902,8 +983,6 @@ void ServerConfig::Read() {"serverinfo", "hostname", "", new ValueContainerString(&this->ServiceHost), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, {"serverinfo", "pid", "services.pid", new ValueContainerString(&this->PIDFilename), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, {"serverinfo", "motd", "services.motd", new ValueContainerString(&this->MOTDFilename), DT_STRING, ValidateNotEmpty}, - {"networkinfo", "logchannel", "", new ValueContainerString(&this->LogChannel), DT_STRING, NoValidation}, - {"networkinfo", "logbot", "no", new ValueContainerBool(&this->LogBot), DT_BOOLEAN, NoValidation}, {"networkinfo", "networkname", "", new ValueContainerString(&this->NetworkName), DT_STRING, ValidateNotEmpty}, {"networkinfo", "nicklen", "0", new ValueContainerUInt(&this->NickLen), DT_UINTEGER | DT_NORELOAD, ValidateNickLen}, {"networkinfo", "userlen", "10", new ValueContainerUInt(&this->UserLen), DT_UINTEGER | DT_NORELOAD, NoValidation}, @@ -930,7 +1009,6 @@ void ServerConfig::Read() {"options", "useprivmsg", "no", new ValueContainerBool(&this->UsePrivmsg), DT_BOOLEAN, NoValidation}, {"options", "usestrictprivmsg", "no", new ValueContainerBool(&this->UseStrictPrivMsg), DT_BOOLEAN, NoValidation}, {"options", "dumpcore", "yes", new ValueContainerBool(&this->DumpCore), DT_BOOLEAN | DT_NORELOAD, NoValidation}, - {"options", "logusers", "no", new ValueContainerBool(&this->LogUsers), DT_BOOLEAN, NoValidation}, {"options", "hidestatso", "no", new ValueContainerBool(&this->HideStatsO), DT_BOOLEAN, NoValidation}, {"options", "globaloncycle", "no", new ValueContainerBool(&this->GlobalOnCycle), DT_BOOLEAN, NoValidation}, {"options", "globaloncycledown", "", new ValueContainerString(&this->GlobalOnCycleMessage), DT_STRING, ValidateGlobalOnCycle}, @@ -940,7 +1018,6 @@ void ServerConfig::Read() {"options", "restrictopernicks", "no", new ValueContainerBool(&this->RestrictOperNicks), DT_BOOLEAN, NoValidation}, {"options", "newscount", "3", new ValueContainerUInt(&this->NewsCount), DT_UINTEGER, NoValidation}, {"options", "ulineservers", "", new ValueContainerString(&UlineServers), DT_STRING, NoValidation}, - {"options", "enablelogchannel", "no", new ValueContainerBool(&LogChan), DT_BOOLEAN, NoValidation}, {"options", "mlock", "+nrt", new ValueContainerString(&this->MLock), DT_STRING, NoValidation}, {"options", "botmodes", "", new ValueContainerString(&this->BotModes), DT_STRING, NoValidation}, {"options", "maxretries", "10", new ValueContainerUInt(&this->MaxRetries), DT_UINTEGER, NoValidation}, @@ -1017,7 +1094,6 @@ void ServerConfig::Read() {"operserv", "globaldescription", "Global Noticer", new ValueContainerString(&this->desc_GlobalNoticer), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, {"operserv", "modules", "", new ValueContainerString(&OperCoreModules), DT_STRING, NoValidation}, {"operserv", "superadmin", "no", new ValueContainerBool(&this->SuperAdmin), DT_BOOLEAN, NoValidation}, - {"operserv", "logmaxusers", "no", new ValueContainerBool(&this->LogMaxUsers), DT_BOOLEAN, NoValidation}, {"operserv", "autokillexpiry", "0", new ValueContainerTime(&this->AutokillExpiry), DT_TIME, ValidateNotZero}, {"operserv", "chankillexpiry", "0", new ValueContainerTime(&this->ChankillExpiry), DT_TIME, ValidateNotZero}, {"operserv", "snlineexpiry", "0", new ValueContainerTime(&this->SNLineExpiry), DT_TIME, ValidateNotZero}, @@ -1067,6 +1143,11 @@ void ServerConfig::Read() {"", ""}, {DT_CHARPTR}, InitModules, DoModule, DoneModules}, + {"log", + {"target", "source", "logage", "admin", "override", "commands", "servers", "channels", "users", "normal", "rawio", "debug", ""}, + {"", "", "7", "", "", "", "", "", "", "", "no", "no", ""}, + {DT_STRING, DT_STRING, DT_INTEGER, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_STRING, DT_BOOLEAN, DT_BOOLEAN, DT_BOOLEAN}, + InitLogs, DoLogs, DoneLogs}, {"opertype", {"name", "inherits", "commands", "privs", ""}, {"", "", "", "", ""}, @@ -1339,10 +1420,10 @@ void ServerConfig::Read() } throw ConfigException(ce); } - Alog(LOG_DEBUG) << "End config"; + Log(LOG_DEBUG) << "End config"; for (int Index = 0; !Once[Index].empty(); ++Index) CheckOnce(Once[Index]); - Alog() << "Done reading configuration file."; + Log() << "Done reading configuration file."; } bool ServerConfig::LoadConf(ConfigDataHash &target, const Anope::string &filename) @@ -1358,7 +1439,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const Anope::string &filenam errstr << "File " << filename << " could not be opened." << std::endl; return false; } - Alog(LOG_DEBUG) << "Start to read conf " << filename; + Log(LOG_DEBUG) << "Start to read conf " << filename; // Start reading characters... while (getline(conf, line.str())) { @@ -1462,7 +1543,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const Anope::string &filenam return false; } // this is the same as the below section for testing if itemname is non-empty after the loop, but done inside it to allow the above construct - Alog(LOG_DEBUG) << "ln "<< linenumber << " EOL: s='" << section << "' '" << itemname << "' set to '" << wordbuffer << "'"; + Log(LOG_DEBUG) << "ln "<< linenumber << " EOL: s='" << section << "' '" << itemname << "' set to '" << wordbuffer << "'"; sectiondata.push_back(KeyVal(itemname, wordbuffer)); wordbuffer.clear(); itemname.clear(); @@ -1504,7 +1585,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const Anope::string &filenam errstr << "Item without value: " << filename << ":" << linenumber << std::endl; return false; } - Alog(LOG_DEBUG) << "ln " << linenumber << " EOL: s='" << section << "' '" << itemname << "' set to '" << wordbuffer << "'"; + Log(LOG_DEBUG) << "ln " << linenumber << " EOL: s='" << section << "' '" << itemname << "' set to '" << wordbuffer << "'"; sectiondata.push_back(KeyVal(itemname, wordbuffer)); wordbuffer.clear(); itemname.clear(); @@ -1555,7 +1636,7 @@ bool ServerConfig::ConfValue(ConfigDataHash &target, const Anope::string &tag, c { if (!allow_linefeeds && j->second.find('\n') != Anope::string::npos) { - Alog(LOG_DEBUG) << "Value of <" << tag << ":" << var << "> contains a linefeed, and linefeeds in this value are not permitted -- stripped to spaces."; + Log(LOG_DEBUG) << "Value of <" << tag << ":" << var << "> contains a linefeed, and linefeeds in this value are not permitted -- stripped to spaces."; j->second.replace_all_cs("\n", " "); } else diff --git a/src/encrypt.cpp b/src/encrypt.cpp index 0121c0c4a..57c120301 100644 --- a/src/encrypt.cpp +++ b/src/encrypt.cpp @@ -38,7 +38,7 @@ int enc_decrypt(const Anope::string &src, Anope::string &dest) size_t pos = src.find(':'); if (pos == Anope::string::npos) { - Alog() << "Error: enc_decrypt() called with invalid password string (" << src << ")"; + Log() << "Error: enc_decrypt() called with invalid password string (" << src << ")"; return -1; } Anope::string hashm(src.begin(), src.begin() + pos); @@ -62,7 +62,7 @@ int enc_check_password(Anope::string &plaintext, Anope::string &password) size_t pos = password.find(':'); if (pos == Anope::string::npos) { - Alog() << "Error: enc_check_password() called with invalid password string (" << password << ")"; + Log() << "Error: enc_check_password() called with invalid password string (" << password << ")"; return 0; } Anope::string hashm(password.begin(), password.begin() + pos); diff --git a/src/init.cpp b/src/init.cpp index d3476a490..5b6d22445 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -25,7 +25,7 @@ void introduce_user(const Anope::string &user) time_t now = time(NULL); static time_t lasttime = now - 4; if (lasttime >= now - 3) - fatal("introduce_user loop detected"); + throw FatalException("introduce_user loop detected"); lasttime = now; if (user.empty()) @@ -54,6 +54,8 @@ void introduce_user(const Anope::string &user) /* Load MLock from the database now that we know what modes exist */ for (registered_channel_map::iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it) it->second->LoadMLock(); + /* Setup log chanels */ + InitLogChannels(Config); } } @@ -81,7 +83,7 @@ static int set_group() } else { - Alog() << "Unknown run group '" << RUNGROUP << "'"; + Log() << "Unknown run group '" << RUNGROUP << "'"; return -1; } #endif @@ -182,7 +184,7 @@ static void write_pidfile() atexit(remove_pidfile); } else - log_perror("Warning: cannot write to PID file %s", Config->PIDFilename.c_str()); + throw FatalException("Can not write to PID file " + Config->PIDFilename); } /*************************************************************************/ @@ -191,7 +193,7 @@ static void write_pidfile() int openlog_failed = 0, openlog_errno = 0; -int init_primary(int ac, char **av) +void Init(int ac, char **av) { int started_from_term = isatty(0) && isatty(1) && isatty(2); @@ -200,38 +202,38 @@ int init_primary(int ac, char **av) umask(DEFUMASK); #endif if (set_group() < 0) - return -1; + throw FatalException("set_group() fail"); /* Parse command line arguments */ ParseCommandLineArguments(ac, av); if (GetCommandLineArgument("version", 'v')) { - Alog(LOG_TERMINAL) << "Anope-" << Anope::Version() << " -- " << Anope::Build(); - return -1; + Log(LOG_TERMINAL) << "Anope-" << Anope::Version() << " -- " << Anope::Build(); + throw FatalException(); } if (GetCommandLineArgument("help", 'h')) { - Alog(LOG_TERMINAL) << "Anope-" << Anope::Version() << " -- " << Anope::Build(); - Alog(LOG_TERMINAL) << "Anope IRC Services (http://www.anope.org)"; - Alog(LOG_TERMINAL) << "Usage ./" << SERVICES_BIN << " [options] ..."; - Alog(LOG_TERMINAL) << "-c, --config=filename.conf"; - Alog(LOG_TERMINAL) << "-d, --debug[=level]"; - Alog(LOG_TERMINAL) << " --dir=services_directory"; - Alog(LOG_TERMINAL) << "-h, --help"; - Alog(LOG_TERMINAL) << " --log=log_filename"; - Alog(LOG_TERMINAL) << "-e, --noexpire"; - Alog(LOG_TERMINAL) << "-n, --nofork"; - Alog(LOG_TERMINAL) << " --nothird"; - Alog(LOG_TERMINAL) << " --protocoldebug"; - Alog(LOG_TERMINAL) << "-r, --readonly"; - Alog(LOG_TERMINAL) << "-s, --support"; - Alog(LOG_TERMINAL) << "-v, --version"; - Alog(LOG_TERMINAL) << ""; - Alog(LOG_TERMINAL) << "Further support is available from http://www.anope.org"; - Alog(LOG_TERMINAL) << "Or visit us on IRC at irc.anope.org #anope"; - return -1; + Log(LOG_TERMINAL) << "Anope-" << Anope::Version() << " -- " << Anope::Build(); + Log(LOG_TERMINAL) << "Anope IRC Services (http://www.anope.org)"; + Log(LOG_TERMINAL) << "Usage ./" << SERVICES_BIN << " [options] ..."; + Log(LOG_TERMINAL) << "-c, --config=filename.conf"; + Log(LOG_TERMINAL) << "-d, --debug[=level]"; + Log(LOG_TERMINAL) << " --dir=services_directory"; + Log(LOG_TERMINAL) << "-h, --help"; + Log(LOG_TERMINAL) << " --log=log_filename"; + Log(LOG_TERMINAL) << "-e, --noexpire"; + Log(LOG_TERMINAL) << "-n, --nofork"; + Log(LOG_TERMINAL) << " --nothird"; + Log(LOG_TERMINAL) << " --protocoldebug"; + Log(LOG_TERMINAL) << "-r, --readonly"; + Log(LOG_TERMINAL) << "-s, --support"; + Log(LOG_TERMINAL) << "-v, --version"; + Log(LOG_TERMINAL) << ""; + Log(LOG_TERMINAL) << "Further support is available from http://www.anope.org"; + Log(LOG_TERMINAL) << "Or visit us on IRC at irc.anope.org #anope"; + throw FatalException(); } if (GetCommandLineArgument("nofork", 'n')) @@ -264,10 +266,7 @@ int init_primary(int ac, char **av) if (level > 0) debug = level; else - { - Alog(LOG_TERMINAL) << "Invalid option given to --debug"; - return -1; - } + throw FatalException("Invalid option given to --debug"); } else ++debug; @@ -276,49 +275,36 @@ int init_primary(int ac, char **av) if (GetCommandLineArgument("config", 'c', Arg)) { if (Arg.empty()) - { - Alog(LOG_TERMINAL) << "The --config option requires a file name"; - return -1; - } + throw FatalException("The --config option requires a file name"); services_conf = Arg; } if (GetCommandLineArgument("dir", 0, Arg)) { if (Arg.empty()) - { - Alog(LOG_TERMINAL) << "The --dir option requires a directory name"; - return -1; - } + throw FatalException("The --dir option requires a directory name"); services_dir = Arg; } if (GetCommandLineArgument("log", 0, Arg)) { if (Arg.empty()) - { - Alog(LOG_TERMINAL) << "The --log option requires a file name"; - return -1; - } + throw FatalException("The --log option requires a file name"); log_filename = Arg; } /* Chdir to Services data directory. */ if (chdir(services_dir.c_str()) < 0) { - fprintf(stderr, "chdir(%s): %s\n", services_dir.c_str(), strerror(errno)); - return -1; + throw FatalException("Unable to chdir to " + services_dir + ": " + Anope::string(strerror(errno))); } - /* Open logfile, and complain if we didn't. */ - if (open_log() < 0) - { - openlog_errno = errno; - if (started_from_term) - fprintf(stderr, "Warning: unable to open log file %s: %s\n", log_filename.c_str(), strerror(errno)); - else - openlog_failed = 1; - } + Log(LOG_TERMINAL) << "Anope " << Anope::Version() << ", " << Anope::Build(); +#ifdef _WIN32 + Log(LOG_TERMINAL) << "Using configuration file " << services_dir << "\\" << services_conf; +#else + Log(LOG_TERMINAL) << "Using configuration file " << services_dir << "/" << services_conf; +#endif /* Read configuration file; exit if there are problems. */ try @@ -327,17 +313,17 @@ int init_primary(int ac, char **av) } catch (const ConfigException &ex) { - Alog(LOG_TERMINAL) << ex.GetReason(); - Alog(LOG_TERMINAL) << "*** Support resources: Read through the services.conf self-contained"; - Alog(LOG_TERMINAL) << "*** documentation. Read the documentation files found in the 'docs'"; - Alog(LOG_TERMINAL) << "*** folder. Visit our portal located at http://www.anope.org/. Join"; - Alog(LOG_TERMINAL) << "*** our support channel on /server irc.anope.org channel #anope."; - return -1; + Log(LOG_TERMINAL) << ex.GetReason(); + Log(LOG_TERMINAL) << "*** Support resources: Read through the services.conf self-contained"; + Log(LOG_TERMINAL) << "*** documentation. Read the documentation files found in the 'docs'"; + Log(LOG_TERMINAL) << "*** folder. Visit our portal located at http://www.anope.org/. Join"; + Log(LOG_TERMINAL) << "*** our support channel on /server irc.anope.org channel #anope."; + throw FatalException("Configuration file failed to validate"); } /* Add IRCD Protocol Module; exit if there are errors */ if (protocol_module_init()) - return -1; + throw FatalException("Unable to load protocol module"); /* Create me */ Me = new Server(NULL, Config->ServerName, 0, Config->ServerDesc, Config->Numeric); @@ -377,19 +363,7 @@ int init_primary(int ac, char **av) /* Load the socket engine */ if (ModuleManager::LoadModule(Config->SocketEngine, NULL)) - { - Alog(LOG_TERMINAL) << "Unable to load socket engine " << Config->SocketEngine; - return -1; - } - - return 0; -} - -int init_secondary(int ac, char **av) -{ -#ifndef _WIN32 - int started_from_term = isatty(0) && isatty(1) && isatty(2); -#endif + throw FatalException("Unable to load socket engine " + Config->SocketEngine); /* Add Core MSG handles */ moduleAddMsgs(); @@ -399,15 +373,13 @@ int init_secondary(int ac, char **av) { int i; if ((i = fork()) < 0) - { - perror("fork()"); - return -1; - } + throw FatalException("Unable to fork"); else if (i != 0) { - Alog(LOG_TERMINAL) << "PID " << i; + Log(LOG_TERMINAL) << "PID " << i; exit(0); } + if (started_from_term) { close(0); @@ -415,22 +387,15 @@ int init_secondary(int ac, char **av) close(2); } if (setpgid(0, 0) < 0) - { - perror("setpgid()"); - return -1; - } + throw FatalException("Unable to setpgid()"); } #else if (!SupportedWindowsVersion()) - { - Alog() << GetWindowsVersion() << " is not a supported version of Windows"; - - return -1; - } + throw FatalException(GetWindowsVersion() + " is not a supported version of Windows"); if (!nofork) { - Alog(LOG_TERMINAL) << "PID " << GetCurrentProcessId(); - Alog() << "Launching Anope into the background"; + Log(LOG_TERMINAL) << "PID " << GetCurrentProcessId(); + Log() << "Launching Anope into the background"; FreeConsole(); } #endif @@ -439,13 +404,9 @@ int init_secondary(int ac, char **av) write_pidfile(); /* Announce ourselves to the logfile. */ - Alog() << "Anope " << Anope::Version() << " (ircd protocol: " << version_protocol << ") starting up" << (debug || readonly ? " (options:" : "") << (debug ? " debug" : "") << (readonly ? " readonly" : "") << (debug || readonly ? ")" : ""); + Log() << "Anope " << Anope::Version() << " (ircd protocol: " << version_protocol << ") starting up" << (debug || readonly ? " (options:" : "") << (debug ? " debug" : "") << (readonly ? " readonly" : "") << (debug || readonly ? ")" : ""); start_time = time(NULL); - /* If in read-only mode, close the logfile again. */ - if (readonly) - close_log(); - /* Set signal handlers. Catch certain signals to let us do things or * panic as necessary, and ignore all others. */ @@ -457,7 +418,7 @@ int init_secondary(int ac, char **av) /* Initialize multi-language support */ lang_init(); - Alog(LOG_DEBUG) << "Loaded languages"; + Log(LOG_DEBUG) << "Loaded languages"; /* Initialize subservices */ ns_init(); @@ -476,14 +437,12 @@ int init_secondary(int ac, char **av) add_entropy_userkeys(); /* Load up databases */ - Alog() << "Loading databases..."; + Log() << "Loading databases..."; EventReturn MOD_RESULT; FOREACH_RESULT(I_OnLoadDatabase, OnLoadDatabase()); - Alog() << "Databases loaded"; + Log() << "Databases loaded"; FOREACH_MOD(I_OnPostLoadDatabases, OnPostLoadDatabases()); - - return 0; } /*************************************************************************/ diff --git a/src/language.cpp b/src/language.cpp index 32f96b461..9d629f599 100644 --- a/src/language.cpp +++ b/src/language.cpp @@ -65,7 +65,7 @@ static void load_lang(int index, const char *filename) FILE *f; int32 num, i; - Alog(LOG_DEBUG) << "Loading language " << index << " from file `languages/" << filename << "'"; + Log(LOG_DEBUG) << "Loading language " << index << " from file `languages/" << filename << "'"; snprintf(buf, sizeof(buf), "languages/%s", filename); #ifndef _WIN32 const char *mode = "r"; @@ -74,16 +74,15 @@ static void load_lang(int index, const char *filename) #endif if (!(f = fopen(buf, mode))) { - log_perror("Failed to load language %d (%s)", index, filename); - return; + throw CoreException("Failed to load language " + stringify(index) + " (" + stringify(filename) + ")"); } else if (read_int32(&num, f) < 0) { - Alog() << "Failed to read number of strings for language " << index << "(" << filename << ")"; + Log() << "Failed to read number of strings for language " << index << "(" << filename << ")"; return; } else if (num != NUM_STRINGS) - Alog() << "Warning: Bad number of strings (" << num << " , wanted " << NUM_STRINGS << ") for language " << index << " (" << filename << ")"; + Log() << "Warning: Bad number of strings (" << num << " , wanted " << NUM_STRINGS << ") for language " << index << " (" << filename << ")"; langtexts[index] = static_cast(scalloc(sizeof(char *), NUM_STRINGS)); if (num > NUM_STRINGS) num = NUM_STRINGS; @@ -93,7 +92,7 @@ static void load_lang(int index, const char *filename) fseek(f, i * 8 + 4, SEEK_SET); if (read_int32(&pos, f) < 0 || read_int32(&len, f) < 0) { - Alog() << "Failed to read entry " << i << " in language " << index << " (" << filename << ") TOC"; + Log() << "Failed to read entry " << i << " in language " << index << " (" << filename << ") TOC"; while (--i >= 0) { if (langtexts[index][i]) @@ -107,7 +106,7 @@ static void load_lang(int index, const char *filename) langtexts[index][i] = NULL; else if (len >= 65536) { - Alog() << "Entry " << i << " in language " << index << " (" << filename << ") is too long (over 64k) -- corrupt TOC?"; + Log() << "Entry " << i << " in language " << index << " (" << filename << ") is too long (over 64k) -- corrupt TOC?"; while (--i >= 0) { if (langtexts[index][i]) @@ -119,7 +118,7 @@ static void load_lang(int index, const char *filename) } else if (len < 0) { - Alog() << "Entry " << i << " in language " << index << " (" << filename << ") has negative length -- corrupt TOC?"; + Log() << "Entry " << i << " in language " << index << " (" << filename << ") has negative length -- corrupt TOC?"; while (--i >= 0) { if (langtexts[index][i]) @@ -135,7 +134,7 @@ static void load_lang(int index, const char *filename) fseek(f, pos, SEEK_SET); if (fread(langtexts[index][i], 1, len, f) != len) { - Alog() << "Failed to read string " << i << " in language " << index << "(" << filename << ")"; + Log() << "Failed to read string " << i << " in language " << index << "(" << filename << ")"; while (--i >= 0) { if (langtexts[index][i]) @@ -225,7 +224,7 @@ void lang_init() Config->NSDefLanguage = DEF_LANGUAGE; if (!langtexts[DEF_LANGUAGE]) - fatal("Unable to load default language"); + throw CoreException("Unable to load default language"); for (i = 0; i < NUM_LANGS; ++i) { if (!langtexts[i]) diff --git a/src/log.cpp b/src/log.cpp deleted file mode 100644 index 62fa29600..000000000 --- a/src/log.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* Logging routines. - * - * (C) 2003-2010 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - */ - -#include "services.h" - -static FILE *logfile; - -static int curday = 0; - -/*************************************************************************/ - -static int get_logname(Anope::string &name, struct tm *tm) -{ - char timestamp[32]; - time_t t; - - if (!tm) - { - time(&t); - tm = localtime(&t); - } - - /* fix bug 577 */ - strftime(timestamp, sizeof(timestamp), "%Y%m%d", tm); - name = Anope::string("logs/") + timestamp + "." + log_filename; - curday = tm->tm_yday; - - return 1; -} - -/*************************************************************************/ - -static void remove_log() -{ - time_t t; - struct tm tm; - - Anope::string name; - - if (!Config->KeepLogs) - return; - - time(&t); - t -= (60 * 60 * 24 * Config->KeepLogs); - tm = *localtime(&t); - - /* removed if from here cause get_logchan is always 1 */ - get_logname(name, &tm); - DeleteFile(name.c_str()); -} - -/*************************************************************************/ - -static void checkday() -{ - time_t t; - struct tm tm; - - time(&t); - tm = *localtime(&t); - - if (curday != tm.tm_yday) - { - close_log(); - remove_log(); - open_log(); - } -} - -/*************************************************************************/ - -/* Open the log file. Return -1 if the log file could not be opened, else - * return 0. */ - -int open_log() -{ - Anope::string name; - - if (logfile) - return 0; - - /* if removed again.. get_logname is always 1 */ - get_logname(name, NULL); - logfile = fopen(name.c_str(), "a"); - - if (logfile) - setbuf(logfile, NULL); - return logfile ? 0 : -1; -} - -/*************************************************************************/ - -/* Close the log file. */ - -void close_log() -{ - if (!logfile) - return; - fclose(logfile); - logfile = NULL; -} - -/*************************************************************************/ - -/* added cause this is used over and over in the code */ -Anope::string log_gettimestamp() -{ - time_t t; - struct tm tm; - char tbuf[256]; - - time(&t); - tm = *localtime(&t); -#if HAVE_GETTIMEOFDAY - if (debug) - { - char *s; - struct timeval tv; - gettimeofday(&tv, NULL); - strftime(tbuf, sizeof(tbuf) - 1, "[%b %d %H:%M:%S", &tm); - s = tbuf + strlen(tbuf); - s += snprintf(s, sizeof(tbuf) - (s - tbuf), ".%06d", static_cast(tv.tv_usec)); - strftime(s, sizeof(tbuf) - (s - tbuf) - 1, " %Y]", &tm); - } - else -#endif - strftime(tbuf, sizeof(tbuf) - 1, "[%b %d %H:%M:%S %Y]", &tm); - return tbuf; -} - -/*************************************************************************/ - -/* Like alog(), but tack a ": " and a system error message (as returned by - * strerror()) onto the end. - */ - -void log_perror(const char *fmt, ...) -{ - va_list args; - int errno_save = errno; - char str[BUFSIZE]; - - checkday(); - - if (!fmt) - return; - - va_start(args, fmt); - vsnprintf(str, sizeof(str), fmt, args); - va_end(args); - - Anope::string buf = log_gettimestamp(); - - if (logfile) - fprintf(logfile, "%s %s : %s\n", buf.c_str(), str, strerror(errno_save)); - if (nofork) - fprintf(stderr, "%s %s : %s\n", buf.c_str(), str, strerror(errno_save)); - errno = errno_save; -} - -/*************************************************************************/ - -/* We've hit something we can't recover from. Let people know what - * happened, then go down. - */ - -void fatal(const char *fmt, ...) -{ - va_list args; - char buf2[4096]; - - checkday(); - - if (!fmt) - return; - - va_start(args, fmt); - vsnprintf(buf2, sizeof(buf2), fmt, args); - va_end(args); - - Anope::string buf = log_gettimestamp(); - - if (logfile) - fprintf(logfile, "%s FATAL: %s\n", buf.c_str(), buf2); - if (nofork) - fprintf(stderr, "%s FATAL: %s\n", buf.c_str(), buf2); - if (UplinkSock) - ircdproto->SendGlobops(NULL, "FATAL ERROR! %s", buf2); - - /* one of the many places this needs to be called from */ - ModuleRunTimeDirCleanUp(); - - exit(1); -} - -/*************************************************************************/ - -/* Same thing, but do it like perror(). */ - -void fatal_perror(const char *fmt, ...) -{ - va_list args; - char buf2[4096]; - int errno_save = errno; - - checkday(); - - if (!fmt) - return; - - va_start(args, fmt); - vsnprintf(buf2, sizeof(buf2), fmt, args); - va_end(args); - - Anope::string buf = log_gettimestamp(); - - if (logfile) - fprintf(logfile, "%s FATAL: %s: %s\n", buf.c_str(), buf2, strerror(errno_save)); - if (nofork) - fprintf(stderr, "%s FATAL: %s: %s\n", buf.c_str(), buf2, strerror(errno_save)); - if (UplinkSock) - ircdproto->SendGlobops(NULL, "FATAL ERROR! %s: %s", buf2, strerror(errno_save)); - - /* one of the many places this needs to be called from */ - ModuleRunTimeDirCleanUp(); - - exit(1); -} - -Alog::Alog(LogLevel val) : Level(val) -{ - if (Level >= LOG_DEBUG) - buf << "Debug: "; -} - -Alog::~Alog() -{ - if (Level >= LOG_DEBUG && (Level - LOG_DEBUG + 1) > debug) - return; - - int errno_save = errno; - - checkday(); - - Anope::string tbuf = log_gettimestamp(); - - if (logfile) - fprintf(logfile, "%s %s\n", tbuf.c_str(), buf.str().c_str()); - if (nofork) - std::cout << tbuf << " " << buf.str() << std::endl; - else if (Level == LOG_TERMINAL) // XXX dont use this yet unless you know we're at terminal and not daemonized - std::cout << buf.str() << std::endl; - if (Config && !Config->LogChannel.empty() && LogChan && !debug && findchan(Config->LogChannel)) - ircdproto->SendPrivmsg(Global, Config->LogChannel, "%s", buf.str().c_str()); - errno = errno_save; -} diff --git a/src/logger.cpp b/src/logger.cpp new file mode 100644 index 000000000..14e5f6d1e --- /dev/null +++ b/src/logger.cpp @@ -0,0 +1,399 @@ +/* Logging routines. + * + * (C) 2003-2010 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + +#include "services.h" + +void InitLogChannels(ServerConfig *config) +{ + for (unsigned i = 0; i < config->LogInfos.size(); ++i) + { + LogInfo *l = config->LogInfos[i]; + + for (std::list::const_iterator sit = l->Targets.begin(), sit_end = l->Targets.end(); sit != sit_end; ++sit) + { + const Anope::string &target = *sit; + + if (target[0] == '#') + { + Channel *c = findchan(target); + if (!c) + c = new Channel(target); + c->SetFlag(CH_LOGCHAN); + c->SetFlag(CH_PERSIST); + + for (botinfo_map::const_iterator bit = BotListByNick.begin(), bit_end = BotListByNick.end(); bit != bit_end; ++bit) + { + BotInfo *bi = bit->second; + + if (bi->HasFlag(BI_CORE) && !c->FindUser(bi)) + { + bi->Join(c); + for (unsigned j = 0; j < config->BotModeList.size(); ++j) + c->SetMode(OperServ, config->BotModeList[j], bi->nick, false); + } + } + } + } + } +} + +static Anope::string GetTimeStamp() +{ + char tbuf[256]; + time_t t; + + if (time(&t) < 0) + throw CoreException("time() failed"); + tm tm = *localtime(&t); +#if HAVE_GETTIMEOFDAY + if (debug) + { + char *s; + struct timeval tv; + gettimeofday(&tv, NULL); + strftime(tbuf, sizeof(tbuf) - 1, "[%b %d %H:%M:%S", &tm); + s = tbuf + strlen(tbuf); + s += snprintf(s, sizeof(tbuf) - (s - tbuf), ".%06d", static_cast(tv.tv_usec)); + strftime(s, sizeof(tbuf) - (s - tbuf) - 1, " %Y]", &tm); + } + else +#endif + strftime(tbuf, sizeof(tbuf) - 1, "[%b %d %H:%M:%S %Y]", &tm); + + return tbuf; +} + +static Anope::string GetLogDate(time_t t = time(NULL)) +{ + char timestamp[32]; + + time(&t); + tm *tm = localtime(&t); + + strftime(timestamp, sizeof(timestamp), "%Y%m%d", tm); + + return timestamp; +} + +static inline Anope::string CreateLogName(const Anope::string &file, time_t time = time(NULL)) +{ + return "logs/" + file + "." + GetLogDate(time); +} + +LogFile::LogFile(const Anope::string &name) : filename(name), stream(name.c_str(), std::ios_base::out) +{ +} + +Anope::string LogFile::GetName() const +{ + return this->filename; +} + +Log::Log(LogType type, const Anope::string &category, BotInfo *b) : bi(b), Type(type), Category(category) +{ + if (b) + this->Sources.push_back(b->nick); +} + +Log::Log(LogType type, User *u, Command *c, ChannelInfo *ci) : Type(type) +{ + if (!u || !c) + throw CoreException("Invalid pointers passed to Log::Log"); + + if (type != LOG_COMMAND && type != LOG_OVERRIDE && type != LOG_ADMIN) + throw CoreException("This constructor does not support this log type"); + + this->bi = c->service ? c->service : Global; + this->Category = (c->service ? c->service->nick + "/" : "") + c->name; + this->Sources.push_back(this->bi->nick); + this->Sources.push_back(u->nick); + this->Sources.push_back(c->name); + if (ci) + this->Sources.push_back(ci->name); + + if (type == LOG_ADMIN) + buf << "ADMIN: "; + else if (type == LOG_OVERRIDE) + buf << "OVERRIDE: "; + else + buf << "COMMAND: "; + buf << u->GetMask() << " used " << c->name << " "; + if (ci) + buf << "on " << ci->name << " "; +} + +Log::Log(User *u, Channel *c, const Anope::string &category) : Type(LOG_CHANNEL) +{ + if (!c) + throw CoreException("Invalid pointers passed to Log::Log"); + + this->bi = whosends(c->ci); + this->Category = category; + if (this->bi) + this->Sources.push_back(this->bi->nick); + if (u) + this->Sources.push_back(u->nick); + this->Sources.push_back(c->name); + + buf << "CHANNEL: "; + if (u) + buf << u->GetMask() << " " << this->Category << " " << c->name << " "; + else + buf << this->Category << " " << c->name << " "; +} + +Log::Log(User *u, const Anope::string &category) : bi(Global), Type(LOG_USER), Category(category) +{ + if (!u) + throw CoreException("Invalid pointers passed to Log::Log"); + + if (this->bi) + this->Sources.push_back(this->bi->nick); + this->Sources.push_back(u->nick); + + buf << "USERS: " << u->GetMask() << " "; +} + +Log::Log(Server *s, const Anope::string &category) : bi(OperServ), Type(LOG_SERVER), Category(category) +{ + if (!s) + throw CoreException("Invalid pointer passed to Log::Log"); + + if (this->bi) + this->Sources.push_back(this->bi->nick); + this->Sources.push_back(s->GetName()); + + buf << "SERVER: " << s->GetName() << " (" << s->GetDescription() << ") "; +} + +Log::Log(BotInfo *b, const Anope::string &category) : bi(b), Type(LOG_USER), Category(category) +{ + if (!b) + throw CoreException("Invalid opinter passed to Log::Log"); + + this->Sources.push_back(bi->nick); +} + +Log::~Log() +{ + if (nofork && debug && this->Type >= LOG_NORMAL && this->Type <= LOG_DEBUG + debug - 1) + std::cout << GetTimeStamp() << " Debug: " << this->buf.str() << std::endl; + else if (this->Type == LOG_TERMINAL) + std::cout << this->buf.str() << std::endl; + for (unsigned i = 0; Config && i < Config->LogInfos.size(); ++i) + { + LogInfo *l = Config->LogInfos[i]; + l->ProcessMessage(this); + } +} + +LogInfo::LogInfo(int logage, bool normal, bool rawio, bool ldebug) : LogAge(logage), Normal(normal), RawIO(rawio), Debug(ldebug) +{ +} + +LogInfo::~LogInfo() +{ + for (std::map::iterator it = this->Logfiles.begin(), it_end = this->Logfiles.end(); it != it_end; ++it) + { + LogFile *f = it->second; + + if (f && f->stream.is_open()) + f->stream.close(); + delete f; + } + this->Logfiles.clear(); +} + +void LogInfo::AddType(std::list &list, const Anope::string &type) +{ + for (std::list::iterator it = list.begin(), it_end = list.end(); it != it_end; ++it) + { + if (Anope::Match(type, *it)) + { + Log() << "Log: Type " << type << " is already covered by " << *it; + return; + } + } + + list.push_back(type); +} + +bool LogInfo::HasType(std::list &list, const Anope::string &type) const +{ + for (std::list::iterator it = list.begin(), it_end = list.end(); it != it_end; ++it) + { + Anope::string cat = *it; + bool inverse = false; + if (cat[0] == '~') + { + cat.erase(cat.begin()); + inverse = true; + } + if (Anope::Match(type, cat)) + { + return !inverse; + } + } + + return false; +} + +std::list &LogInfo::GetList(LogType type) +{ + static std::list empty; + + switch (type) + { + case LOG_ADMIN: + case LOG_OVERRIDE: + case LOG_COMMAND: + return this->Commands; + case LOG_SERVER: + return this->Servers; + case LOG_CHANNEL: + return this->Channels; + case LOG_USER: + return this->Users; + default: + return empty; + } +} + +bool LogInfo::HasType(LogType type) +{ + switch (type) + { + case LOG_ADMIN: + case LOG_OVERRIDE: + case LOG_COMMAND: + case LOG_SERVER: + case LOG_CHANNEL: + case LOG_USER: + return !this->GetList(type).empty(); + case LOG_NORMAL: + return this->Normal; + case LOG_TERMINAL: + return true; + case LOG_RAWIO: + return this->RawIO; + case LOG_DEBUG: + return this->Debug; + // LOG_DEBUG_[234] + default: + break; + } + + return false; +} + +void LogInfo::ProcessMessage(const Log *l) +{ + static time_t lastwarn = time(NULL); + + if (!l) + throw CoreException("Bad values passed to LogInfo::ProcessMessages"); + + if (!this->HasType(l->Type)) + return; + else if (!l->Category.empty() && !this->HasType(this->GetList(l->Type), l->Category)) + return; + + if (!this->Sources.empty()) + { + bool log = false; + for (std::list::const_iterator it = this->Sources.begin(), it_end = this->Sources.end(); it != it_end; ++it) + { + if (std::find(l->Sources.begin(), l->Sources.end(), *it) != l->Sources.end()) + { + log = true; + break; + } + } + if (!log) + return; + } + + for (std::list::iterator it = this->Targets.begin(), it_end = this->Targets.end(); it != it_end; ++it) + { + const Anope::string &target = *it; + + if (target[0] == '#') + { + if (UplinkSock && !debug && Me && Me->IsSynced()) + { + Channel *c = findchan(target); + if (!c || !l->bi) + continue; + ircdproto->SendPrivmsg(l->bi, c->name, "%s", l->buf.str().c_str()); + } + } + else + { + LogFile *log = NULL; + std::map::iterator lit = this->Logfiles.find(target); + if (lit != this->Logfiles.end()) + { + log = lit->second; + if (log && log->GetName() != CreateLogName(target)) + { + delete log; + log = new LogFile(CreateLogName(target)); + + if (this->LogAge) + { + Anope::string oldlog = CreateLogName(target, time(NULL) - 86400 * this->LogAge); + if (IsFile(oldlog)) + { + DeleteFile(oldlog.c_str()); + Log(LOG_DEBUG) << "Deleted old logfile " << oldlog; + } + } + } + if (!log || !log->stream.is_open()) + { + time_t now = time(NULL); + if (log && lastwarn + 300 > now) + { + lastwarn = now; + Log() << "Unable to open logfile " << log->GetName(); + } + delete log; + log = NULL; + this->Logfiles.erase(lit); + continue; + } + } + else if (lit == this->Logfiles.end()) + { + log = new LogFile(CreateLogName(target)); + + if (!log->stream.is_open()) + { + time_t now = time(NULL); + if (lastwarn + 300 > now) + { + lastwarn = now; + Log() << "Unable to open logfile " << log->GetName(); + delete log; + log = NULL; + continue; + } + } + + this->Logfiles[target] = log; + } + + if (log) + log->stream << GetTimeStamp() << " " << l->buf.str() << std::endl; + } + } +} + diff --git a/src/mail.cpp b/src/mail.cpp index 354c7e2e7..666355b0a 100644 --- a/src/mail.cpp +++ b/src/mail.cpp @@ -4,9 +4,9 @@ MailThread::~MailThread() { if (Success) - Alog() << "Successfully delivered mail for " << MailTo << " (" << Addr << ")"; + Log() << "Successfully delivered mail for " << MailTo << " (" << Addr << ")"; else - Alog() << "Error delivering mail for " << MailTo << " (" << Addr << ")"; + Log() << "Error delivering mail for " << MailTo << " (" << Addr << ")"; } void MailThread::Run() diff --git a/src/main.cpp b/src/main.cpp index bcb67b6fa..79dcd3b00 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,7 +43,6 @@ Anope::string orig_cwd; /* Original current working directory */ Anope::string log_filename = "services.log"; /* -log filename */ int debug = 0; /* -debug */ bool readonly = false; /* -readonly */ -bool LogChan = false; /* -logchan */ bool nofork = false; /* -nofork */ bool nothird = false; /* -nothrid */ bool noexpire = false; /* -noexpire */ @@ -138,7 +137,7 @@ extern void expire_all() FOREACH_MOD(I_OnPreDatabaseExpire, OnPreDatabaseExpire()); - Alog(LOG_DEBUG) << "Running expire routines"; + Log(LOG_DEBUG) << "Running expire routines"; expire_nicks(); expire_chans(); expire_requests(); @@ -156,7 +155,7 @@ void save_databases() EventReturn MOD_RESULT; FOREACH_RESULT(I_OnSaveDatabase, OnSaveDatabase()); - Alog(LOG_DEBUG) << "Saving FFF databases"; + Log(LOG_DEBUG) << "Saving databases"; } /*************************************************************************/ @@ -169,7 +168,7 @@ void do_restart_services() expire_all(); save_databases(); } - Alog() << "Restarting"; + Log() << "Restarting"; FOREACH_MOD(I_OnPreRestart, OnPreRestart()); @@ -188,15 +187,12 @@ void do_restart_services() ircdproto->SendSquit(Config->ServerName, quitmsg); SocketEngine->Process(); delete UplinkSock; - close_log(); ModuleManager::UnloadAll(); chdir(binary_dir.c_str()); execve(services_bin.c_str(), my_av, my_envp); if (!readonly) { - open_log(); - log_perror("Restart failed"); - close_log(); + throw FatalException("Restart failed"); } FOREACH_MOD(I_OnRestart, OnRestart()); @@ -214,7 +210,7 @@ static void services_shutdown() if (quitmsg.empty()) quitmsg = "Terminating, reason unknown"; - Alog() << quitmsg; + Log() << quitmsg; if (started && UplinkSock) { /* Send a quit for all of our bots */ @@ -259,7 +255,7 @@ void sighandler(int signum) #ifndef _WIN32 if (signum == SIGHUP) { - Alog() << "Received SIGHUP: Saving Databases & Rehash Configuration"; + Log() << "Received SIGHUP: Saving Databases & Rehash Configuration"; expire_all(); save_databases(); @@ -273,7 +269,7 @@ void sighandler(int signum) } catch (const ConfigException &ex) { - Alog() << "Error reloading configuration file: " << ex.GetReason(); + Log() << "Error reloading configuration file: " << ex.GetReason(); } return; @@ -287,7 +283,7 @@ void sighandler(int signum) signal(SIGHUP, SIG_IGN); #endif - Alog() << "Received SIGTERM, exiting."; + Log() << "Received SIGTERM, exiting."; expire_all(); save_databases(); @@ -300,7 +296,7 @@ void sighandler(int signum) if (nofork) { signal(SIGINT, SIG_IGN); - Alog() << "Received SIGINT, exiting."; + Log() << "Received SIGINT, exiting."; expire_all(); save_databases(); quitmsg = "Shutting down on SIGINT"; @@ -323,7 +319,7 @@ void sighandler(int signum) if (isatty(2)) fprintf(stderr, "%s\n", quitmsg.c_str()); else - Alog() << quitmsg; + Log() << quitmsg; exit(1); } @@ -398,11 +394,11 @@ static bool Connect() } catch (const SocketException &ex) { - Alog() << "Unable to connect to server" << servernum << " (" << uplink_server->host << ":" << uplink_server->port << "), " << ex.GetReason(); + Log() << "Unable to connect to server" << servernum << " (" << uplink_server->host << ":" << uplink_server->port << "), " << ex.GetReason(); continue; } - Alog() << "Connected to Server " << servernum << " (" << uplink_server->host << ":" << uplink_server->port << ")"; + Log() << "Connected to Server " << servernum << " (" << uplink_server->host << ":" << uplink_server->port << ")"; return true; } @@ -417,175 +413,175 @@ static bool Connect() int main(int ac, char **av, char **envp) { - my_av = av; - my_envp = envp; + try + { + my_av = av; + my_envp = envp; - char cwd[PATH_MAX] = ""; + char cwd[PATH_MAX] = ""; #ifdef _WIN32 - GetCurrentDirectory(PATH_MAX, cwd); + GetCurrentDirectory(PATH_MAX, cwd); #else - getcwd(cwd, PATH_MAX); + getcwd(cwd, PATH_MAX); #endif - orig_cwd = cwd; + orig_cwd = cwd; #ifndef _WIN32 - /* If we're root, issue a warning now */ - if (!getuid() && !getgid()) - { - fprintf(stderr, "WARNING: You are currently running Anope as the root superuser. Anope does not\n"); - fprintf(stderr, " require root privileges to run, and it is discouraged that you run Anope\n"); - fprintf(stderr, " as the root superuser.\n"); - } + /* If we're root, issue a warning now */ + if (!getuid() && !getgid()) + { + fprintf(stderr, "WARNING: You are currently running Anope as the root superuser. Anope does not\n"); + fprintf(stderr, " require root privileges to run, and it is discouraged that you run Anope\n"); + fprintf(stderr, " as the root superuser.\n"); + } #endif - binary_dir = GetFullProgDir(av[0]); - if (binary_dir[binary_dir.length() - 1] == '.') - binary_dir = binary_dir.substr(0, binary_dir.length() - 2); + binary_dir = GetFullProgDir(av[0]); + if (binary_dir[binary_dir.length() - 1] == '.') + binary_dir = binary_dir.substr(0, binary_dir.length() - 2); #ifdef _WIN32 - Anope::string::size_type n = binary_dir.rfind('\\'); - services_dir = binary_dir.substr(0, n) + "\\data"; + Anope::string::size_type n = binary_dir.rfind('\\'); + services_dir = binary_dir.substr(0, n) + "\\data"; #else - Anope::string::size_type n = binary_dir.rfind('/'); - services_dir = binary_dir.substr(0, n) + "/data"; + Anope::string::size_type n = binary_dir.rfind('/'); + services_dir = binary_dir.substr(0, n) + "/data"; #endif - /* Clean out the module runtime directory prior to running, just in case files were left behind during a previous run */ - ModuleRunTimeDirCleanUp(); + /* Clean out the module runtime directory prior to running, just in case files were left behind during a previous run */ + ModuleRunTimeDirCleanUp(); - /* General initialization first */ - int i = init_primary(ac, av); - if (i) - return i; + /* General initialization first */ + Init(ac, av); - Alog(LOG_TERMINAL) << "Anope " << Anope::Version() << ", " << Anope::Build(); -#ifdef _WIN32 - Alog(LOG_TERMINAL) << "Using configuration file " << services_dir << "\\" << services_conf; -#else - Alog(LOG_TERMINAL) << "Using configuration file " << services_dir << "/" << services_conf; -#endif + /* If the first connect fails give up, don't sit endlessly trying to reconnect */ + if (!Connect()) + { + Log() << "Can't connect to any servers"; + return 0; + } - /* Initialization stuff. */ - i = init_secondary(ac, av); - if (i) - return i; + ircdproto->SendConnect(); + FOREACH_MOD(I_OnServerConnect, OnServerConnect()); - /* If the first connect fails give up, don't sit endlessly trying to reconnect */ - if (!Connect()) - fatal_perror("Can't connect to any servers"); - - ircdproto->SendConnect(); - FOREACH_MOD(I_OnServerConnect, OnServerConnect()); - - started = true; + started = true; #ifndef _WIN32 - if (Config->DumpCore) - { - rlimit rl; - if (getrlimit(RLIMIT_CORE, &rl) == -1) - Alog() << "Failed to getrlimit()!"; - else + if (Config->DumpCore) { - rl.rlim_cur = rl.rlim_max; - if (setrlimit(RLIMIT_CORE, &rl) == -1) - Alog() << "setrlimit() failed, cannot increase coredump size"; + rlimit rl; + if (getrlimit(RLIMIT_CORE, &rl) == -1) + Log() << "Failed to getrlimit()!"; + else + { + rl.rlim_cur = rl.rlim_max; + if (setrlimit(RLIMIT_CORE, &rl) == -1) + Log() << "setrlimit() failed, cannot increase coredump size"; + } } - } #endif - /* Set up timers */ - time_t last_check = time(NULL); - ExpireTimer expireTimer(Config->ExpireTimeout, last_check); - UpdateTimer updateTimer(Config->UpdateTimeout, last_check); + /* Set up timers */ + time_t last_check = time(NULL); + ExpireTimer expireTimer(Config->ExpireTimeout, last_check); + UpdateTimer updateTimer(Config->UpdateTimeout, last_check); - /*** Main loop. ***/ - while (!quitting) - { - while (!quitting && UplinkSock) + /*** Main loop. ***/ + while (!quitting) { - time_t t = time(NULL); - - Alog(LOG_DEBUG_2) << "Top of main loop"; - - if (!readonly && (save_data || shutting_down)) + while (!quitting && UplinkSock) { - if (!noexpire) - expire_all(); - if (shutting_down) - ircdproto->SendGlobops(NULL, "Updating databases on shutdown, please wait."); - save_databases(); - save_data = false; - } + time_t t = time(NULL); - if (shutting_down) - { - quitting = true; - break; - } + Log(LOG_DEBUG_2) << "Top of main loop"; - if (t - last_check >= Config->TimeoutCheck) - { - TimerManager::TickTimers(t); - last_check = t; - } - - /* Process any modes that need to be (un)set */ - ModeManager::ProcessModes(); - - /* Process the socket engine */ - SocketEngine->Process(); - } - - if (quitting) - /* Disconnect and exit */ - services_shutdown(); - else - { - FOREACH_MOD(I_OnServerDisconnect, OnServerDisconnect()); - - /* Clear all of our users, but not our bots */ - for (user_map::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ) - { - User *u = it->second; - ++it; - - if (!findbot(u->nick)) - delete u; - } - - Me->SetFlag(SERVER_SYNCING); - Me->ClearLinks(); - - unsigned j = 0; - for (; j < (Config->MaxRetries ? Config->MaxRetries : j + 1); ++j) - { - Alog() << "Disconnected from the server, retrying in " << Config->RetryWait << " seconds"; - - sleep(Config->RetryWait); - if (Connect()) + if (!readonly && (save_data || shutting_down)) { - ircdproto->SendConnect(); - FOREACH_MOD(I_OnServerConnect, OnServerConnect()); + if (!noexpire) + expire_all(); + if (shutting_down) + ircdproto->SendGlobops(NULL, "Updating databases on shutdown, please wait."); + save_databases(); + save_data = false; + } + + if (shutting_down) + { + quitting = true; break; } + + if (t - last_check >= Config->TimeoutCheck) + { + TimerManager::TickTimers(t); + last_check = t; + } + + /* Process any modes that need to be (un)set */ + ModeManager::ProcessModes(); + + /* Process the socket engine */ + SocketEngine->Process(); } - if (Config->MaxRetries && j == Config->MaxRetries) + + if (quitting) + /* Disconnect and exit */ + services_shutdown(); + else { - Alog() << "Max connection retry limit exceeded"; - quitting = true; + FOREACH_MOD(I_OnServerDisconnect, OnServerDisconnect()); + + /* Clear all of our users, but not our bots */ + for (user_map::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; ) + { + User *u = it->second; + ++it; + + if (!findbot(u->nick)) + delete u; + } + + Me->SetFlag(SERVER_SYNCING); + Me->ClearLinks(); + + unsigned j = 0; + for (; j < (Config->MaxRetries ? Config->MaxRetries : j + 1); ++j) + { + Log() << "Disconnected from the server, retrying in " << Config->RetryWait << " seconds"; + + sleep(Config->RetryWait); + if (Connect()) + { + ircdproto->SendConnect(); + FOREACH_MOD(I_OnServerConnect, OnServerConnect()); + break; + } + } + if (Config->MaxRetries && j == Config->MaxRetries) + { + Log() << "Max connection retry limit exceeded"; + quitting = true; + } } } } + catch (const FatalException &ex) + { + if (!ex.GetReason().empty()) + Log(LOG_TERMINAL) << ex.GetReason(); + return -1; + } return 0; } -inline Anope::string Anope::Version() +Anope::string Anope::Version() { return stringify(VERSION_MAJOR) + "." + stringify(VERSION_MINOR) + "." + stringify(VERSION_PATCH) + VERSION_EXTRA + " (" + stringify(VERSION_BUILD) + ")"; } -inline Anope::string Anope::Build() +Anope::string Anope::Build() { return "build #" + stringify(BUILD) + ", compiled " + Anope::compiled; } + + diff --git a/src/memoserv.cpp b/src/memoserv.cpp index 0fcf0b6a3..eec5ab7a3 100644 --- a/src/memoserv.cpp +++ b/src/memoserv.cpp @@ -50,7 +50,7 @@ void check_memos(User *u) { if (!u) { - Alog(LOG_DEBUG) << "check_memos called with NULL values"; + Log() << "check_memos called with NULL values"; return; } diff --git a/src/messages.cpp b/src/messages.cpp index d40d06712..72a926618 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -102,7 +102,7 @@ int m_privmsg(const Anope::string &source, const Anope::string &receiver, const if (!u) { - Alog() << message << ": user record for " << source << " not found"; + Log() << message << ": user record for " << source << " not found"; BotInfo *bi = findbot(receiver); if (bi) @@ -129,7 +129,9 @@ int m_privmsg(const Anope::string &source, const Anope::string &receiver, const if (get_ignore(source)) { Anope::string target = myStrGetToken(message, ' ', 0); - Alog() << "Ignored message from " << source << " to " << receiver << " using command " << target; + BotInfo *bi = findbot(target); + if (bi) + Log(bi) << "Ignored message from " << source << " using command " << target; return MOD_CONT; } } @@ -147,7 +149,7 @@ int m_privmsg(const Anope::string &source, const Anope::string &receiver, const } else if (Config->UseStrictPrivMsg) { - Alog(LOG_DEBUG) << "Ignored PRIVMSG without @ from " << source; + Log(LOG_DEBUG) << "Ignored PRIVMSG without @ from " << source; notice_lang(receiver, u, INVALID_TARGET, receiver.c_str(), receiver.c_str(), Config->ServerName.c_str(), receiver.c_str()); return MOD_CONT; } @@ -196,7 +198,7 @@ int m_privmsg(const Anope::string &source, const Anope::string &receiver, const } else { - Alog() << Config->s_OperServ << ": " << u->nick << ": " << message; + Log(OperServ) << u->nick << ": " << message; mod_run_cmd(bi, u, message); } } diff --git a/src/misc.cpp b/src/misc.cpp index 42d56407b..66beff127 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -601,7 +601,7 @@ void EnforceQlinedNick(const Anope::string &nick, const Anope::string &killer) if (u2) { - Alog() << "Killed Q-lined nick: " << u2->GetMask(); + Log() << "Killed Q-lined nick: " << u2->GetMask(); kill_user(killer, u2->nick, "This nick is reserved for Services. Please use a non Q-Lined nick."); } } @@ -834,7 +834,7 @@ Anope::string host_resolve(const Anope::string &host) char ipbuf[16]; ntoa(addr, ipbuf, sizeof(ipbuf)); ipreturn = ipbuf; - Alog(LOG_DEBUG) << "resolved " << host << " to " << ipbuf; + Log(LOG_DEBUG) << "resolved " << host << " to " << ipbuf; } return ipreturn; } diff --git a/src/modes.cpp b/src/modes.cpp index 6c060aed8..da9f22bef 100644 --- a/src/modes.cpp +++ b/src/modes.cpp @@ -33,8 +33,6 @@ Flags DefMLockOn; Flags DefMLockOff; /* Map for default mlocked mode parameters */ std::map DefMLockParams; -/* Modes to set on bots when they join the channel */ -std::list BotModes; /** Parse the mode string from the config file and set the default mlocked modes */ @@ -72,7 +70,7 @@ void SetDefaultMLock(ServerConfig *config) DefMLockParams.insert(std::make_pair(cm->Name, param)); else { - Alog() << "Warning: Got default mlock mode " << cm->ModeChar << " with no param?"; + Log() << "Warning: Got default mlock mode " << cm->ModeChar << " with no param?"; ptr->UnsetFlag(cm->Name); } } @@ -81,13 +79,13 @@ void SetDefaultMLock(ServerConfig *config) } /* Set Bot Modes */ - BotModes.clear(); - for (unsigned i = 0, end_mode = config->BotModes.length(); i < end_mode; ++i) + config->BotModeList.clear(); + for (unsigned i = 0; i < config->BotModes.length(); ++i) { ChannelMode *cm = ModeManager::FindChannelModeByChar(config->BotModes[i]); - if (cm && cm->Type == MODE_STATUS && std::find(BotModes.begin(), BotModes.end(), cm) == BotModes.end()) - BotModes.push_back(debug_cast(cm)); + if (cm && cm->Type == MODE_STATUS && std::find(config->BotModeList.begin(), config->BotModeList.end(), cm) == config->BotModeList.end()) + config->BotModeList.push_back(debug_cast(cm)); } } @@ -282,7 +280,7 @@ void ChannelModeBan::AddMask(Channel *chan, const Anope::string &mask) /* check for NULL values otherwise we will segfault */ if (!chan || mask.empty()) { - Alog(LOG_DEBUG) << "add_ban called with NULL values"; + Log() << "add_ban called with NULL values"; return; } @@ -293,7 +291,7 @@ void ChannelModeBan::AddMask(Channel *chan, const Anope::string &mask) Entry *ban = entry_add(chan->bans, mask); if (!ban) - fatal("Creating new ban entry failed"); + throw CoreException("Creating new ban entry failed"); /* Check whether it matches a botserv bot after adding internally * and parsing it through cidr support. ~ Viper */ @@ -309,7 +307,7 @@ void ChannelModeBan::AddMask(Channel *chan, const Anope::string &mask) } } - Alog(LOG_DEBUG) << "Added ban " << mask << " to channel " << chan->name; + Log(LOG_DEBUG) << "Added ban " << mask << " to channel " << chan->name; } /** Remove a ban from the channel @@ -327,7 +325,7 @@ void ChannelModeBan::DelMask(Channel *chan, const Anope::string &mask) { entry_delete(chan->bans, ban); - Alog(LOG_DEBUG) << "Deleted ban " << mask << " from channel " << chan->name; + Log(LOG_DEBUG) << "Deleted ban " << mask << " from channel " << chan->name; } AutoKick *akick; @@ -343,7 +341,7 @@ void ChannelModeExcept::AddMask(Channel *chan, const Anope::string &mask) { if (!chan || mask.empty()) { - Alog(LOG_DEBUG) << "add_exception called with NULL values"; + Log() << "add_exception called with NULL values"; return; } @@ -354,9 +352,9 @@ void ChannelModeExcept::AddMask(Channel *chan, const Anope::string &mask) Entry *exception = entry_add(chan->excepts, mask); if (!exception) - fatal("Creating new exception entry failed"); + throw CoreException("Creating new exception entry failed"); - Alog(LOG_DEBUG) << "Added except " << mask << " to channel " << chan->name; + Log(LOG_DEBUG) << "Added except " << mask << " to channel " << chan->name; } /** Remove an except from the channel @@ -373,7 +371,7 @@ void ChannelModeExcept::DelMask(Channel *chan, const Anope::string &mask) if (exception) { entry_delete(chan->excepts, exception); - Alog(LOG_DEBUG) << "Deleted except " << mask << " to channel " << chan->name; + Log(LOG_DEBUG) << "Deleted except " << mask << " to channel " << chan->name; } } @@ -385,7 +383,7 @@ void ChannelModeInvex::AddMask(Channel *chan, const Anope::string &mask) { if (!chan || mask.empty()) { - Alog(LOG_DEBUG) << "add_invite called with NULL values"; + Log() << "add_invite called with NULL values"; return; } @@ -396,9 +394,9 @@ void ChannelModeInvex::AddMask(Channel *chan, const Anope::string &mask) Entry *invite = entry_add(chan->invites, mask); if (!invite) - fatal("Creating new exception entry failed"); + throw CoreException("Creating new invex entry failed"); - Alog(LOG_DEBUG) << "Added invite " << mask << " to channel " << chan->name; + Log(LOG_DEBUG) << "Added invite " << mask << " to channel " << chan->name; } @@ -416,7 +414,7 @@ void ChannelModeInvex::DelMask(Channel *chan, const Anope::string &mask) if (invite) { entry_delete(chan->invites, invite); - Alog(LOG_DEBUG) << "Deleted invite " << mask << " to channel " << chan->name; + Log(LOG_DEBUG) << "Deleted invite " << mask << " to channel " << chan->name; } } @@ -611,7 +609,7 @@ bool ModeManager::AddUserMode(UserMode *um) if (um->Name == UMODE_END) { um->Name = static_cast(UMODE_END + ++GenericUserModes); - Alog() << "ModeManager: Added generic support for user mode " << um->ModeChar; + Log() << "ModeManager: Added generic support for user mode " << um->ModeChar; } ModeManager::UserModesByName.insert(std::make_pair(um->Name, um)); ModeManager::Modes.insert(std::make_pair(um->NameAsString, um)); @@ -635,7 +633,7 @@ bool ModeManager::AddChannelMode(ChannelMode *cm) if (cm->Name == CMODE_END) { cm->Name = static_cast(CMODE_END + ++GenericChannelModes); - Alog() << "ModeManager: Added generic support for channel mode " << cm->ModeChar; + Log() << "ModeManager: Added generic support for channel mode " << cm->ModeChar; } ModeManager::ChannelModesByName.insert(std::make_pair(cm->Name, cm)); ModeManager::Modes.insert(std::make_pair(cm->NameAsString, cm)); diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index 49b90ca41..bacf6c8d1 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -51,7 +51,7 @@ static int moduleCopyFile(const Anope::string &name, Anope::string &output) output = tmp_output; free(tmp_output); // XXX - Alog(LOG_DEBUG) << "Runtime module location: " << output; + Log(LOG_DEBUG) << "Runtime module location: " << output; FILE *target; #ifndef _WIN32 @@ -116,7 +116,7 @@ int ModuleManager::LoadModule(const Anope::string &modname, User *u) if (FindModule(modname)) return MOD_ERR_EXISTS; - Alog(LOG_DEBUG) << "trying to load [" << modname << "]"; + Log(LOG_DEBUG) << "trying to load [" << modname << "]"; /* Generate the filename for the temporary copy of the module */ Anope::string pbuf = services_dir + "/modules/runtime/" + modname + ".so.XXXXXX"; @@ -137,7 +137,7 @@ int ModuleManager::LoadModule(const Anope::string &modname, User *u) const char *err; if (!handle && (err = dlerror())) { - Alog() << err; + Log() << err; return MOD_ERR_NOLOAD; } @@ -145,7 +145,7 @@ int ModuleManager::LoadModule(const Anope::string &modname, User *u) Module *(*func)(const Anope::string &, const Anope::string &) = function_cast(dlsym(handle, "AnopeInit")); if (!func && (err = dlerror())) { - Alog() << "No init function found, not an Anope module"; + Log() << "No init function found, not an Anope module"; dlclose(handle); return MOD_ERR_NOLOAD; } @@ -166,7 +166,7 @@ int ModuleManager::LoadModule(const Anope::string &modname, User *u) } catch (const ModuleException &ex) { - Alog() << "Error while loading " << modname << ": " << ex.GetReason(); + Log() << "Error while loading " << modname << ": " << ex.GetReason(); return MOD_STOP; } @@ -176,27 +176,27 @@ int ModuleManager::LoadModule(const Anope::string &modname, User *u) Version v = m->GetVersion(); if (v.GetMajor() < VERSION_MAJOR || (v.GetMajor() == VERSION_MAJOR && v.GetMinor() < VERSION_MINOR)) { - Alog() << "Module " << modname << " is compiled against an older version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << VERSION_MAJOR << "." << VERSION_MINOR; + Log() << "Module " << modname << " is compiled against an older version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << VERSION_MAJOR << "." << VERSION_MINOR; DeleteModule(m); return MOD_STOP; } else if (v.GetMajor() > VERSION_MAJOR || (v.GetMajor() == VERSION_MAJOR && v.GetMinor() > VERSION_MINOR)) { - Alog() << "Module " << modname << " is compiled against a newer version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << VERSION_MAJOR << "." << VERSION_MINOR; + Log() << "Module " << modname << " is compiled against a newer version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << VERSION_MAJOR << "." << VERSION_MINOR; DeleteModule(m); return MOD_STOP; } else if (v.GetBuild() < VERSION_BUILD) - Alog() << "Module " << modname << " is compiled against an older revision of Anope " << v.GetBuild() << ", this is " << VERSION_BUILD; + Log() << "Module " << modname << " is compiled against an older revision of Anope " << v.GetBuild() << ", this is " << VERSION_BUILD; else if (v.GetBuild() > VERSION_BUILD) - Alog() << "Module " << modname << " is compiled against a newer revision of Anope " << v.GetBuild() << ", this is " << VERSION_BUILD; + Log() << "Module " << modname << " is compiled against a newer revision of Anope " << v.GetBuild() << ", this is " << VERSION_BUILD; else if (v.GetBuild() == VERSION_BUILD) - Alog(LOG_DEBUG) << "Module " << modname << " compiled against current version of Anope " << v.GetBuild(); + Log(LOG_DEBUG) << "Module " << modname << " compiled against current version of Anope " << v.GetBuild(); if (m->type == PROTOCOL && IsOneOfModuleTypeLoaded(PROTOCOL)) { DeleteModule(m); - Alog() << "You cannot load two protocol modules"; + Log() << "You cannot load two protocol modules"; return MOD_STOP; } @@ -257,7 +257,7 @@ void ModuleManager::DeleteModule(Module *m) const char *err; if (!destroy_func && (err = dlerror())) { - Alog() << "No destroy function found, chancing delete..."; + Log() << "No destroy function found, chancing delete..."; delete m; /* we just have to chance they haven't overwrote the delete operator then... */ } else @@ -266,7 +266,7 @@ void ModuleManager::DeleteModule(Module *m) if (handle) { if (dlclose(handle)) - Alog() << dlerror(); + Log() << dlerror(); } if (!filename.empty()) diff --git a/src/modules.cpp b/src/modules.cpp index 8f9b6b944..d2c6d7ac3 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -46,7 +46,7 @@ int protocol_module_init() { int ret = 0; - Alog() << "Loading IRCD Protocol Module: [" << Config->IRCDModule << "]"; + Log() << "Loading IRCD Protocol Module: [" << Config->IRCDModule << "]"; ret = ModuleManager::LoadModule(Config->IRCDModule, NULL); if (ret == MOD_ERR_OK) @@ -60,7 +60,7 @@ int protocol_module_init() { if (Config->Numeric.empty()) { - Alog() << "This IRCd protocol requires a server id to be set in Anope's configuration."; + Log() << "This IRCd protocol requires a server id to be set in Anope's configuration."; ret = -1; } } @@ -73,7 +73,7 @@ void Module::InsertLanguage(int langNumber, int ac, const char **av) { int i; - Alog(LOG_DEBUG) << this->name << " Adding " << ac << " texts for language " << langNumber; + Log(LOG_DEBUG) << this->name << " Adding " << ac << " texts for language " << langNumber; if (this->lang[langNumber].argc > 0) this->DeleteLanguage(langNumber); @@ -184,7 +184,7 @@ int Module::AddCommand(BotInfo *bi, Command *c) if (it.second != true) { - Alog() << "Error creating command " << c->name << ". Command already exists!"; + Log() << "Error creating command " << c->name << ". Command already exists!"; return MOD_ERR_EXISTS; } @@ -282,7 +282,7 @@ void Module::NoticeLang(const Anope::string &source, const User *u, int number, va_end(va); } else - Alog() << this->name << ": INVALID language string call, language: [" << mlang << "], String [" << number << "]"; + Log() << this->name << ": INVALID language string call, language: [" << mlang << "], String [" << number << "]"; } const char *Module::GetLangString(User *u, int number) @@ -306,7 +306,7 @@ const char *Module::GetLangString(User *u, int number) */ else { - Alog() << this->name << ": INVALID language string call, language: [" << mlang << "], String [" << number << "]"; + Log() << this->name << ": INVALID language string call, language: [" << mlang << "], String [" << number << "]"; return ""; } } @@ -326,13 +326,13 @@ void ModuleRunTimeDirCleanUp() { Anope::string dirbuf = services_dir + "/modules/runtime"; - Alog(LOG_DEBUG) << "Cleaning out Module run time directory (" << dirbuf << ") - this may take a moment please wait"; + Log(LOG_DEBUG) << "Cleaning out Module run time directory (" << dirbuf << ") - this may take a moment please wait"; #ifndef _WIN32 DIR *dirp = opendir(dirbuf.c_str()); if (!dirp) { - Alog(LOG_DEBUG) << "Cannot open directory (" << dirbuf << ")"; + Log(LOG_DEBUG) << "Cannot open directory (" << dirbuf << ")"; return; } struct dirent *dp; @@ -360,7 +360,7 @@ void ModuleRunTimeDirCleanUp() { Anope::string filebuf = dirbuf + "/" + FileData.cFileName; if (!DeleteFile(filebuf.c_str())) - Alog(LOG_DEBUG) << "Error deleting file " << filebuf << " - GetLastError() reports " << dlerror(); + Log(LOG_DEBUG) << "Error deleting file " << filebuf << " - GetLastError() reports " << dlerror(); } if (!FindNextFile(hList, &FileData)) { @@ -370,11 +370,11 @@ void ModuleRunTimeDirCleanUp() } } else - Alog(LOG_DEBUG) << "Invalid File Handle. GetLastError() reports "<< static_cast(GetLastError()); + Log(LOG_DEBUG) << "Invalid File Handle. GetLastError() reports "<< static_cast(GetLastError()); FindClose(hList); #endif - Alog(LOG_DEBUG) << "Module run time directory has been cleaned out"; + Log(LOG_DEBUG) << "Module run time directory has been cleaned out"; } Version Module::GetVersion() const diff --git a/src/nickalias.cpp b/src/nickalias.cpp index 4eae63138..b02097f19 100644 --- a/src/nickalias.cpp +++ b/src/nickalias.cpp @@ -52,7 +52,7 @@ NickAlias::NickAlias(const Anope::string &nickname, NickCore *nickcore) if (ot->GetName().equals_ci(it->second)) { - Alog() << "Tied oper " << this->nc->display << " to type " << ot->GetName(); + Log() << "Tied oper " << this->nc->display << " to type " << ot->GetName(); this->nc->ot = ot; break; } diff --git a/src/nickcore.cpp b/src/nickcore.cpp index c75493b4a..61130b878 100644 --- a/src/nickcore.cpp +++ b/src/nickcore.cpp @@ -50,7 +50,7 @@ NickCore::~NickCore() NickCoreList.erase(this->display); /* Log .. */ - Alog() << Config->s_NickServ << ": deleting nickname group " << this->display; + Log() << Config->s_NickServ << ": deleting nickname group " << this->display; /* Clear access before deleting display name, we want to be able to use the display name in the clear access event */ this->ClearAccess(); diff --git a/src/nickserv.cpp b/src/nickserv.cpp index 11929ade7..da7b4bc4a 100644 --- a/src/nickserv.cpp +++ b/src/nickserv.cpp @@ -248,7 +248,7 @@ void expire_nicks() User *u = finduser(na->nick); if (u && (na->nc->HasFlag(NI_SECURE) ? u->IsIdentified() : u->IsRecognized())) { - Alog(LOG_DEBUG_2) << "NickServ: updating last seen time for " << na->nick; + Log(LOG_DEBUG_2) << "NickServ: updating last seen time for " << na->nick; na->last_seen = now; continue; } @@ -259,7 +259,7 @@ void expire_nicks() FOREACH_RESULT(I_OnPreNickExpire, OnPreNickExpire(na)); if (MOD_RESULT == EVENT_STOP) continue; - Alog() << "Expiring nickname " << na->nick << " (group: " << na->nc->display << ") (e-mail: " << (na->nc->email.empty() ? "none" : na->nc->email) << ")"; + Log() << "Expiring nickname " << na->nick << " (group: " << na->nc->display << ") (e-mail: " << (na->nc->email.empty() ? "none" : na->nc->email) << ")"; FOREACH_MOD(I_OnNickExpire, OnNickExpire(na)); delete na; } @@ -277,7 +277,7 @@ void expire_requests() if (Config->NSRExpire && now - nr->requested >= Config->NSRExpire) { - Alog() << "Request for nick " << nr->nick << " expiring"; + Log() << "Request for nick " << nr->nick << " expiring"; delete nr; } } @@ -356,7 +356,7 @@ void change_core_display(NickCore *nc, const Anope::string &newdisplay) { /* Log ... */ FOREACH_MOD(I_OnChangeCoreDisplay, OnChangeCoreDisplay(nc, newdisplay)); - Alog() << Config->s_NickServ << ": changing " << nc->display << " nickname group display to " << newdisplay; + Log() << Config->s_NickServ << ": changing " << nc->display << " nickname group display to " << newdisplay; /* Remove the core from the list */ NickCoreList.erase(nc->display); diff --git a/src/process.cpp b/src/process.cpp index d2bcec226..8c5ff71fc 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -76,7 +76,7 @@ void add_ignore(const Anope::string &nick, time_t delta) newign->mask = mask; newign->time = delta ? now + delta : 0; ignore.push_front(newign); - Alog(LOG_DEBUG) << "Added new ignore entry for " << mask; + Log(LOG_DEBUG) << "Added new ignore entry for " << mask; } } @@ -137,13 +137,13 @@ IgnoreData *get_ignore(const Anope::string &nick) /* Check whether the entry has timed out */ if (ign != ign_end && (*ign)->time && (*ign)->time <= now) { - Alog(LOG_DEBUG) << "Expiring ignore entry " << (*ign)->mask; + Log(LOG_DEBUG) << "Expiring ignore entry " << (*ign)->mask; delete *ign; ignore.erase(ign); ign = ign_end = ignore.end(); } - if (ign != ign_end && debug) - Alog(LOG_DEBUG) << "Found ignore entry (" << (*ign)->mask << ") for " << nick; + if (ign != ign_end) + Log(LOG_DEBUG) << "Found ignore entry (" << (*ign)->mask << ") for " << nick; return ign == ign_end ? NULL : *ign; } @@ -189,7 +189,7 @@ int delete_ignore(const Anope::string &nick) /* No matching ignore found. */ if (ign == ign_end) return 0; - Alog(LOG_DEBUG) << "Deleting ignore entry " << (*ign)->mask; + Log(LOG_DEBUG) << "Deleting ignore entry " << (*ign)->mask; /* Delete the entry and all references to it. */ delete *ign; ignore.erase(ign); @@ -208,7 +208,7 @@ int clear_ignores() return 0; for (std::list::iterator ign = ignore.begin(), ign_end = ignore.end(); ign != ign_end; ++ign) { - Alog(LOG_DEBUG) << "Deleting ignore entry " << (*ign)->mask; + Log(LOG_DEBUG) << "Deleting ignore entry " << (*ign)->mask; delete *ign; } int deleted = ignore.size(); @@ -278,7 +278,7 @@ void process(const Anope::string &buffer) const char **av; /* If debugging, log the buffer */ - Alog(LOG_DEBUG) << "Received: " << buffer; + Log(LOG_RAWIO) << "Received: " << buffer; /* First make a copy of the buffer so we have the original in case we * crash - in that case, we want to know what we crashed on. */ @@ -315,17 +315,17 @@ void process(const Anope::string &buffer) if (protocoldebug) { if (*source) - Alog() << "Source " << source; + Log() << "Source " << source; if (*cmd) - Alog() << "Token " << cmd; + Log() << "Token " << cmd; if (ac) { int i; for (i = 0; i < ac; ++i) - Alog() << "av[" << i << "] = " << av[i]; + Log() << "av[" << i << "] = " << av[i]; } else - Alog() << "av[0] = NULL"; + Log() << "av[0] = NULL"; } /* Do something with the message. */ @@ -344,7 +344,7 @@ void process(const Anope::string &buffer) } } else - Alog(LOG_DEBUG) << "unknown message from server (" << buffer << ")"; + Log(LOG_DEBUG) << "unknown message from server (" << buffer << ")"; /* Free argument list we created */ free(av); diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 393054acf..f22d3388f 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -24,7 +24,9 @@ ChannelInfo::ChannelInfo(const Anope::string &chname) this->founder = this->successor = NULL; this->last_topic_time = 0; this->levels = NULL; - this->c = NULL; + this->c = findchan(chname); + if (this->c) + this->c->ci = this; this->capsmin = this->capspercent = 0; this->floodlines = this->floodsecs = 0; this->repeattimes = 0; @@ -68,7 +70,7 @@ ChannelInfo::~ChannelInfo() FOREACH_MOD(I_OnDelChan, OnDelChan(this)); - Alog(LOG_DEBUG) << "Deleting channel " << this->name; + Log(LOG_DEBUG) << "Deleting channel " << this->name; if (this->c) { @@ -575,7 +577,7 @@ bool ChannelInfo::CheckKick(User *user) if ((autokick->HasFlag(AK_ISNICK) && autokick->nc == nc) || (!autokick->HasFlag(AK_ISNICK) && match_usermask(autokick->mask, user))) { - Alog(LOG_DEBUG_2) << user->nick << " matched akick " << (autokick->HasFlag(AK_ISNICK) ? autokick->nc->display : autokick->mask); + Log(LOG_DEBUG_2) << user->nick << " matched akick " << (autokick->HasFlag(AK_ISNICK) ? autokick->nc->display : autokick->mask); autokick->last_used = time(NULL); if (autokick->HasFlag(AK_ISNICK)) get_idealban(this, user, mask); @@ -598,7 +600,7 @@ bool ChannelInfo::CheckKick(User *user) if (!do_kick) return false; - Alog(LOG_DEBUG) << "Autokicking "<< user->GetMask() << " from " << this->name; + Log(LOG_DEBUG) << "Autokicking "<< user->GetMask() << " from " << this->name; /* If the channel isn't syncing and doesn't have any users, join ChanServ * Note that the user AND POSSIBLY the botserv bot exist here diff --git a/src/send.cpp b/src/send.cpp index 62f1b8ec5..453131f51 100644 --- a/src/send.cpp +++ b/src/send.cpp @@ -33,21 +33,21 @@ void send_cmd(const Anope::string &source, const char *fmt, ...) if (!UplinkSock) { if (!source.empty()) - Alog(LOG_DEBUG) << "Attemtped to send \"" << source << " " << buf << "\" with UplinkSock NULL"; + Log(LOG_DEBUG) << "Attemtped to send \"" << source << " " << buf << "\" with UplinkSock NULL"; else - Alog(LOG_DEBUG) << "Attemtped to send \"" << buf << "\" with UplinkSock NULL"; + Log(LOG_DEBUG) << "Attemtped to send \"" << buf << "\" with UplinkSock NULL"; return; } if (!source.empty()) { UplinkSock->Write(":%s %s", source.c_str(), buf); - Alog(LOG_DEBUG) << "Sent: :" << source << " " << buf; + Log(LOG_RAWIO) << "Sent: :" << source << " " << buf; } else { UplinkSock->Write("%s", buf); - Alog(LOG_DEBUG) << "Sent: "<< buf; + Log(LOG_RAWIO) << "Sent: "<< buf; } va_end(args); diff --git a/src/servers.cpp b/src/servers.cpp index 75f5b9249..d817ee94f 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -60,7 +60,7 @@ Server::Server(Server *uplink, const Anope::string &name, unsigned hops, const A { SetFlag(SERVER_SYNCING); - Alog(LOG_DEBUG) << "Creating " << this->GetName() << " (" << this->GetSID() << ") uplinked to " << (this->UplinkServer ? this->UplinkServer->GetName() : "no uplink"); + Log(this, "connect") << "uplinked to " << (this->UplinkServer ? this->UplinkServer->GetName() : "no uplink") << " connected to the network"; /* Add this server to our uplinks leaf list */ if (this->UplinkServer) @@ -72,10 +72,6 @@ Server::Server(Server *uplink, const Anope::string &name, unsigned hops, const A { /* Bring in our pseudo-clients */ introduce_user(""); - - /* And some IRCds needs Global joined in the logchan */ - if (LogChan && ircd->join2msg) - Global->Join(Config->LogChannel); } } } @@ -84,7 +80,7 @@ Server::Server(Server *uplink, const Anope::string &name, unsigned hops, const A */ Server::~Server() { - Alog(LOG_DEBUG) << "Deleting server " << this->GetName() << " (" << this->GetSID() << ") uplinked to " << (this->UplinkServer ? this->UplinkServer->GetName() : "no uplink"); + Log(this, "quit") << "quit from " << (this->UplinkServer ? this->UplinkServer->GetName() : "no uplink") << " for " << this->QReason; if (Capab.HasFlag(CAPAB_NOQUIT) || Capab.HasFlag(CAPAB_QS)) { @@ -108,7 +104,7 @@ Server::~Server() } } - Alog(LOG_DEBUG) << "Finished removing all users for " << this->GetName(); + Log(LOG_DEBUG) << "Finished removing all users for " << this->GetName(); } if (this->UplinkServer) @@ -190,7 +186,7 @@ void Server::AddLink(Server *s) { this->Links.push_back(s); - Alog() << "Server " << s->GetName() << " introduced from " << this->GetName(); + Log(this, "connect") << "introduced " << s->GetName(); } /** Delinks a server from this server @@ -210,7 +206,7 @@ void Server::DelLink(Server *s) } } - Alog() << "Server " << s->GetName() << " quit from " << this->GetName(); + Log(this, "quit") << "quit " << s->GetName(); } /** Remov all links from this server @@ -245,7 +241,7 @@ void Server::Sync(bool SyncLinks) Me->UnsetFlag(SERVER_SYNCING); } - Alog() << "Server " << this->GetName() << " is done syncing"; + Log(this, "sync") << "is done syncing"; FOREACH_MOD(I_OnServerSync, OnServerSync(this)); @@ -285,7 +281,7 @@ bool Server::IsULined() const */ Server *Server::Find(const Anope::string &name, Server *s) { - Alog(LOG_DEBUG) << "Server::Find called for " << name; + Log(LOG_DEBUG) << "Server::Find called for " << name; if (!s) s = Me; @@ -300,7 +296,7 @@ Server *Server::Find(const Anope::string &name, Server *s) if (serv->GetName().equals_cs(name) || serv->GetSID().equals_cs(name)) return serv; - Alog(LOG_DEBUG) << "Server::Find checking " << serv->GetName() << " server tree for " << name; + Log(LOG_DEBUG) << "Server::Find checking " << serv->GetName() << " server tree for " << name; Server *server = Server::Find(name, serv); if (server) return server; @@ -324,9 +320,9 @@ Server *Server::Find(const Anope::string &name, Server *s) void do_server(const Anope::string &source, const Anope::string &servername, unsigned int hops, const Anope::string &descript, const Anope::string &numeric) { if (source.empty()) - Alog(LOG_DEBUG) << "Server " << servername << " introduced"; + Log(LOG_DEBUG) << "Server " << servername << " introduced"; else - Alog(LOG_DEBUG) << "Server introduced (" << servername << ")" << " from " << source; + Log(LOG_DEBUG) << "Server introduced (" << servername << ")" << " from " << source; Server *s = NULL; @@ -366,7 +362,7 @@ void do_squit(const Anope::string &source, int ac, const char **av) if (!s) { - Alog() << "SQUIT for nonexistent server (" << av[0] << ")!!"; + Log() << "SQUIT for nonexistent server (" << av[0] << ")!!"; return; } @@ -386,7 +382,7 @@ void do_squit(const Anope::string &source, int ac, const char **av) if (s->GetUplink() == Me && Capab.HasFlag(CAPAB_UNCONNECT)) { - Alog(LOG_DEBUG) << "Sending UNCONNECT SQUIT for " << s->GetName(); + Log(LOG_DEBUG) << "Sending UNCONNECT SQUIT for " << s->GetName(); /* need to fix */ ircdproto->SendSquit(s->GetName(), buf); } @@ -459,7 +455,6 @@ const char *ts6_uid_retrieve() { if (!ircd->ts6) { - Alog(LOG_DEBUG) << "ts6_uid_retrieve(): TS6 not supported on this ircd"; return ""; } @@ -525,7 +520,6 @@ const char *ts6_sid_retrieve() { if (!ircd->ts6) { - Alog(LOG_DEBUG) << "ts6_sid_retrieve(): TS6 not supported on this ircd"; return ""; } diff --git a/src/sessions.cpp b/src/sessions.cpp index 893a45858..6d3571d85 100644 --- a/src/sessions.cpp +++ b/src/sessions.cpp @@ -168,17 +168,17 @@ void del_session(const Anope::string &host) { if (!Config->LimitSessions) { - Alog(LOG_DEBUG) << "del_session called when LimitSessions is disabled"; + Log(LOG_DEBUG) << "del_session called when LimitSessions is disabled"; return; } if (host.empty()) { - Alog(LOG_DEBUG) << "del_session called with NULL values"; + Log(LOG_DEBUG) << "del_session called with NULL values"; return; } - Alog(LOG_DEBUG_2) << "del_session() called"; + Log(LOG_DEBUG_2) << "del_session() called"; Session *session = findsession(host); @@ -187,7 +187,7 @@ void del_session(const Anope::string &host) if (debug) { ircdproto->SendGlobops(OperServ, "WARNING: Tried to delete non-existant session: \2%s", host.c_str()); - Alog(LOG_DEBUG) << "session: Tried to delete non-existant session: " << host; + Log() << "session: Tried to delete non-existant session: " << host; } return; } @@ -200,11 +200,11 @@ void del_session(const Anope::string &host) SessionList.erase(session->host); - Alog(LOG_DEBUG_2) << "del_session(): free session structure"; + Log(LOG_DEBUG_2) << "del_session(): free session structure"; delete session; - Alog(LOG_DEBUG_2) << "del_session() done"; + Log(LOG_DEBUG_2) << "del_session() done"; } /*************************************************************************/ diff --git a/src/sockets.cpp b/src/sockets.cpp index 646ee261f..7dcdde678 100644 --- a/src/sockets.cpp +++ b/src/sockets.cpp @@ -19,7 +19,7 @@ SocketEngineBase::SocketEngineBase() { #ifdef _WIN32 if (WSAStartup(MAKEWORD(2, 0), &wsa)) - Alog() << "Failed to initialize WinSock library"; + Log() << "Failed to initialize WinSock library"; #endif } diff --git a/src/users.cpp b/src/users.cpp index 91ba45d0c..3713d102e 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -26,10 +26,10 @@ time_t maxusertime; /*************************************************************************/ /*************************************************************************/ -User::User(const Anope::string &snick, const Anope::string &suid) +User::User(const Anope::string &snick, const Anope::string &sident, const Anope::string &shost, const Anope::string &suid) { - if (snick.empty()) - throw CoreException("what the craq, empty nick passed to constructor"); + if (snick.empty() || sident.empty() || shost.empty()) + throw CoreException("Bad args passed to User::User"); // XXX: we should also duplicate-check here. @@ -40,7 +40,10 @@ User::User(const Anope::string &snick, const Anope::string &suid) OnAccess = false; this->nick = snick; + this->ident = sident; + this->host = shost; this->uid = suid; + this->isSuperAdmin = 0; UserListByNick[snick] = this; if (!suid.empty()) @@ -54,11 +57,8 @@ User::User(const Anope::string &snick, const Anope::string &suid) { maxusercnt = usercnt; maxusertime = time(NULL); - if (Config->LogMaxUsers) - Alog() << "user: New maximum user count: "<< maxusercnt; + Log(this, "maxusers") << "connected - new maximum user count: " << maxusercnt; } - - this->isSuperAdmin = 0; /* always set SuperAdmin to 0 for new users */ } void User::SetNewNick(const Anope::string &newnick) @@ -67,7 +67,7 @@ void User::SetNewNick(const Anope::string &newnick) if (newnick.empty()) throw CoreException("User::SetNewNick() got a bad argument"); - Alog(LOG_DEBUG) << this->nick << " changed nick to " << newnick; + Log(this, "nick") << "changed nick to " << newnick; UserListByNick.erase(this->nick); @@ -88,7 +88,7 @@ void User::SetDisplayedHost(const Anope::string &shost) this->vhost = shost; - Alog(LOG_DEBUG) << this->nick << " changed vhost to " << shost; + Log(this, "host") << "changed vhost to " << shost; this->UpdateHost(); } @@ -116,7 +116,7 @@ void User::SetCloakedHost(const Anope::string &newhost) chost = newhost; - Alog(LOG_DEBUG) << this->nick << " changed cloaked host to " << newhost; + Log(this, "host") << "changed cloaked host to " << newhost; this->UpdateHost(); } @@ -138,7 +138,7 @@ void User::SetVIdent(const Anope::string &sident) { this->vident = sident; - Alog(LOG_DEBUG) << this->nick << " changed vident to " << sident; + Log(this, "ident") << "changed vident to " << sident; this->UpdateHost(); } @@ -155,7 +155,7 @@ void User::SetIdent(const Anope::string &sident) { this->ident = sident; - Alog(LOG_DEBUG) << this->nick << " changed real ident to " << sident; + Log(this, "ident") << "changed real ident to " << sident; this->UpdateHost(); } @@ -181,22 +181,17 @@ void User::SetRealname(const Anope::string &srealname) if (na && (this->IsIdentified(true) || this->IsRecognized(true))) na->last_realname = srealname; - Alog(LOG_DEBUG) << this->nick << " changed realname to " << srealname; + Log(this, "realname") << "changed realname to " << srealname; } User::~User() { - Alog(LOG_DEBUG_2) << "User::~User() called"; + Log(LOG_DEBUG_2) << "User::~User() called"; + + Log(this, "disconnect") << " (" << this->realname << ") " << "disconnected from the network (" << this->server->GetName() << ")"; this->Logout(); - if (Config->LogUsers) - { - Anope::string srealname = normalizeBuffer(this->realname); - - Alog() << "LOGUSERS: " << this->nick << " (" << this->GetIdent() << "@" << this->host << (ircd->vhost ? " => " : "") << (ircd->vhost ? this->GetDisplayedHost() : "") << ") (" << srealname << ") left the network (" << this->server->GetName() << ")."; - } - FOREACH_MOD(I_OnUserLogoff, OnUserLogoff(this)); --usercnt; @@ -218,7 +213,7 @@ User::~User() if (na) na->OnCancel(this); - Alog(LOG_DEBUG_2) << "User::~User() done"; + Log(LOG_DEBUG_2) << "User::~User() done"; } void User::SendMessage(const Anope::string &source, const char *fmt, ...) const @@ -659,20 +654,13 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop char ipbuf[16]; struct in_addr addr; - if (ircd->nickvhost) + if (ircd->nickvhost && !vhost2.empty() && vhost2.equals_cs("*")) { - if (!vhost2.empty()) - { - if (vhost2.equals_cs("*")) - { - vhost2.clear(); - Alog(LOG_DEBUG) << "new user with no vhost in NICK command: " << nick; - } - } + vhost2.clear(); } /* This is a new user; create a User structure for it. */ - Alog(LOG_DEBUG) << "new user: " << nick; + Log(LOG_DEBUG) << "new user: " << nick; if (ircd->nickip) { @@ -682,31 +670,8 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop Server *serv = Server::Find(server); - if (Config->LogUsers) - { - /** - * Ugly swap routine for Flop's bug :) XXX - **/ - Anope::string logrealname = realname; - if (!logrealname.empty()) - { - size_t tmp; - while ((tmp = logrealname.find('%')) != Anope::string::npos) - logrealname[tmp] = '-'; - } - logrealname = normalizeBuffer(logrealname); - - /** - * End of ugly swap - **/ - Alog() << "LOGUSERS: " << nick << " (" << username << "@" << host << (ircd->nickvhost && !vhost2.empty() ? " => " : "") << (ircd->nickvhost && !vhost2.empty() ? vhost2 : "") << ") (" << logrealname << ") " - << (ircd->nickip ? "[" : "") << (ircd->nickip ? ipbuf : "") << (ircd->nickip ? "]" : "") << " connected to the network (" << serv->GetName() << ")."; - } - /* Allocate User structure and fill it in. */ - user = new User(nick, !uid.empty() ? uid : ""); - user->SetIdent(username); - user->host = host; + user = new User(nick, username, host, uid); user->server = serv; user->realname = realname; user->timestamp = ts; @@ -721,6 +686,8 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop else user->hostip = ""; + Log(user, "connect") << (ircd->nickvhost && !vhost2.empty() ? Anope::string("(") + vhost2 + ")" : "") << ") (" << user->realname << ") " << (ircd->nickip ? Anope::string("[") + ipbuf + "] " : "") << "connected to the network (" << serv->GetName() << ")"; + EventReturn MOD_RESULT; FOREACH_RESULT(I_OnPreUserConnect, OnPreUserConnect(user)); if (MOD_RESULT == EVENT_STOP) @@ -744,18 +711,12 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop if (!user) { - Alog() << "user: NICK from nonexistent nick " << source; + Log() << "user: NICK from nonexistent nick " << source; return NULL; } user->isSuperAdmin = 0; /* Dont let people nick change and stay SuperAdmins */ - Alog(LOG_DEBUG) << source << " changes nick to " << nick; - if (Config->LogUsers) - { - Anope::string logrealname = normalizeBuffer(user->realname); - Alog() << "LOGUSERS: " << user->nick << " (" << user->GetIdent() << "@" << user->host << (ircd->vhost ? " => " : "") << (ircd->vhost ? user->GetDisplayedHost() : "") << ") (" << logrealname << ") changed nick to " - << nick << " (" << user->server->GetName() << ")."; - } + Log(user, "nick") << " " << (ircd->vhost ? " => " : "") << (ircd->vhost ? user->GetDisplayedHost() : "") << ") (" << user->realname << ") changed nick to " << nick; user->timestamp = ts; @@ -793,7 +754,7 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop user->UpdateHost(); do_on_id(user); ircdproto->SetAutoIdentificationToken(user); - Alog() << Config->s_NickServ << ": " << user->GetMask() << " automatically identified for group " << user->Account()->display; + Log() << Config->s_NickServ << ": " << user->GetMask() << " automatically identified for group " << user->Account()->display; } if (ircd->sqline) @@ -819,7 +780,7 @@ void do_umode(const Anope::string &source, int ac, const char **av) User *user = finduser(av[0]); if (!user) { - Alog() << "user: MODE "<< av[1] << " for nonexistent nick "<< av[0] << ":" << merge_args(ac, av); + Log() << "user: MODE "<< av[1] << " for nonexistent nick "<< av[0] << ":" << merge_args(ac, av); return; } @@ -837,10 +798,11 @@ void do_quit(const Anope::string &source, int ac, const char **av) User *user = finduser(source); if (!user) { - Alog() << "user: QUIT from nonexistent user " << source << ":" << merge_args(ac, av); + Log() << "user: QUIT from nonexistent user " << source << ":" << merge_args(ac, av); return; } - Alog(LOG_DEBUG) << source << " quits"; + + Log(user, "quit") << "for " << (*av[0] ? av[0] : "no reason"); NickAlias *na = findnick(user->nick); if (na && !na->HasFlag(NS_FORBIDDEN) && !na->nc->HasFlag(NI_SUSPENDED) && (user->IsRecognized() || user->IsIdentified(true))) @@ -864,10 +826,11 @@ void do_kill(const Anope::string &nick, const Anope::string &msg) User *user = finduser(nick); if (!user) { - Alog(LOG_DEBUG) << "KILL of nonexistent nick: " << nick; + Log() << "KILL of nonexistent nick: " << nick; return; } - Alog(LOG_DEBUG) << nick << " killed"; + + Log(user, "killed") << "for " << msg; NickAlias *na = findnick(user->nick); if (na && !na->HasFlag(NS_FORBIDDEN) && !na->nc->HasFlag(NI_SUSPENDED) && (user->IsRecognized() || user->IsIdentified(true))) @@ -997,7 +960,7 @@ void UserSetInternalModes(User *user, int ac, const char **av) if (!user || !modes) return; - Alog(LOG_DEBUG) << "Changing user modes for " << user->nick << " to " << merge_args(ac, av); + Log(user, "mode") << "changes modes to " << merge_args(ac, av); for (; *modes; ++modes) { @@ -1042,9 +1005,14 @@ void UserSetInternalModes(User *user, int ac, const char **av) ++opcnt; if (Config->WallOper) ircdproto->SendGlobops(OperServ, "\2%s\2 is now an IRC operator.", user->nick.c_str()); + Log(OperServ) << user->nick << " is now an IRC operator"; } else + { --opcnt; + + Log(OperServ) << user->nick << " is no longer an IRC operator"; + } break; case UMODE_REGISTERED: if (add && !user->IsIdentified())