From 72b26043b2f1729a2d183b01310747303fe385fd Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 18 Apr 2014 02:21:06 -0400 Subject: Remove unused event. Mark some oper only usermodes as oper only. Fix reading SID in TS6_SID_Retrieve --- include/modules.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'include') diff --git a/include/modules.h b/include/modules.h index 0d121089a..90dd23807 100644 --- a/include/modules.h +++ b/include/modules.h @@ -719,11 +719,6 @@ class CoreExport Module : public Extensible */ virtual void OnNickDrop(CommandSource &source, NickAlias *na) { throw NotImplementedException(); } - /** Called when a nick is forbidden - * @param na The nick alias of the forbidden nick - */ - virtual void OnNickForbidden(NickAlias *na) { throw NotImplementedException(); } - /** Called when a user groups their nick * @param u The user grouping * @param target The target they're grouping to @@ -1094,7 +1089,7 @@ enum Implementation I_OnPreUserLogoff, I_OnPostUserLogoff, I_OnBotCreate, I_OnBotChange, I_OnBotDelete, I_OnAccessDel, I_OnAccessAdd, I_OnAccessClear, I_OnLevelChange, I_OnChanDrop, I_OnChanRegistered, I_OnChanSuspend, I_OnChanUnsuspend, I_OnCreateChan, I_OnDelChan, I_OnChannelCreate, I_OnChannelDelete, I_OnAkickAdd, I_OnAkickDel, I_OnCheckKick, - I_OnChanInfo, I_OnCheckPriv, I_OnGroupCheckPriv, I_OnNickDrop, I_OnNickForbidden, I_OnNickGroup, I_OnNickIdentify, + I_OnChanInfo, I_OnCheckPriv, I_OnGroupCheckPriv, I_OnNickDrop, I_OnNickGroup, I_OnNickIdentify, I_OnUserLogin, I_OnNickLogout, I_OnNickRegister, I_OnNickSuspend, I_OnNickUnsuspended, I_OnDelNick, I_OnNickCoreCreate, I_OnDelCore, I_OnChangeCoreDisplay, I_OnNickClearAccess, I_OnNickAddAccess, I_OnNickEraseAccess, I_OnNickClearCert, I_OnNickAddCert, I_OnNickEraseCert, I_OnNickInfo, I_OnBotInfo, I_OnCheckAuthentication, I_OnNickUpdate, -- cgit From 6a03eb69ebbe773f1d4139ff88d74ecdb2b0af4b Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 25 Apr 2014 16:51:06 -0400 Subject: Add "virtual mode" support This allows fully tracking extbans and other modes set by a different underlying mode, such as InspIRCd's namedmodes Add two configuration options to cs_ban to configure which mode is set and whether or not to kick banned users. Add default "mute" fantasy command to botserv.example.conf --- include/channels.h | 3 ++- include/config.h | 2 ++ include/modes.h | 41 ++++++++++++++++++++++++++++++++++------- 3 files changed, 38 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/channels.h b/include/channels.h index 27119adf4..cc30d2030 100644 --- a/include/channels.h +++ b/include/channels.h @@ -276,10 +276,11 @@ class CoreExport Channel : public Base, public Extensible /** Unbans a user from this channel. * @param u The user to unban + * @param mode The mode to unban * @param full Whether or not to match using the user's real host and IP * @return whether or not a ban was removed */ - bool Unban(User *u, bool full = false); + bool Unban(User *u, const Anope::string &mode, bool full = false); /** Check whether a user is permitted to be on this channel * @param u The user diff --git a/include/config.h b/include/config.h index 86a7dce78..019564680 100644 --- a/include/config.h +++ b/include/config.h @@ -138,6 +138,8 @@ namespace Configuration Block *GetModule(const Anope::string &name); BotInfo *GetClient(const Anope::string &name); + + Block *GetCommand(CommandSource &); }; struct Uplink diff --git a/include/modes.h b/include/modes.h index 8f67959e8..3ba54c439 100644 --- a/include/modes.h +++ b/include/modes.h @@ -96,6 +96,9 @@ class CoreExport UserModeParam : public UserMode class CoreExport ChannelMode : public Mode { public: + /* channel modes that can posssibly unwrap this mode */ + std::vector listeners; + /** constructor * @param name The mode name * @param mc The mode char @@ -103,6 +106,18 @@ class CoreExport ChannelMode : public Mode ChannelMode(const Anope::string &name, char mc); bool CanSet(User *u) const anope_override; + + /** 'wrap' this channel mode and param to the underlying mode and param + */ + virtual ChannelMode *Wrap(Anope::string ¶m); + + /** 'unwrap' this mode to our internal representation + */ + ChannelMode *Unwrap(Anope::string ¶m); + + /** called when a mode is being unwrapped, and is asking us if we can unwrap it + */ + virtual ChannelMode *Unwrap(ChannelMode *, Anope::string ¶m); }; /** This is a mode for lists, eg b/e/I. These modes should inherit from this @@ -186,6 +201,25 @@ class CoreExport ChannelModeStatus : public ChannelMode ChannelModeStatus(const Anope::string &name, char mc, char msymbol, short mlevel); }; +/** A virtual mode. This mode doesn't natively exist on the IRCd (like extbans), + * but we still have a representation for it. + */ +template +class ChannelModeVirtual : public T +{ + Anope::string base; + ChannelMode *basech; + + public: + ChannelModeVirtual(const Anope::string &mname, const Anope::string &basename); + + ~ChannelModeVirtual(); + + ChannelMode *Wrap(Anope::string ¶m) anope_override; + + ChannelMode *Unwrap(ChannelMode *cm, Anope::string ¶m) = 0; +}; + /* The status a user has on a channel (+v, +h, +o) etc */ class CoreExport ChannelStatus { @@ -257,13 +291,6 @@ class CoreExport ChannelModeNoone : public ChannelMode */ class CoreExport ModeManager { - protected: - /* Array of all modes Anope knows about. Modes are in this array at position - * modechar. Additionally, status modes are in this array (again) at statuschar. - */ - static std::vector ChannelModes; - static std::vector UserModes; - public: /* Number of generic channel and user modes we are tracking */ -- cgit From 3abb18721bf969157110ad4bb8e4b3ea26dde8e8 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 26 Apr 2014 17:21:33 -0400 Subject: Accept non server sources for SQUIT --- include/messages.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/messages.h b/include/messages.h index e805903b3..3bf096d7c 100644 --- a/include/messages.h +++ b/include/messages.h @@ -131,7 +131,7 @@ namespace Message struct CoreExport SQuit : IRCDMessage { - SQuit(Module *creator, const Anope::string &mname = "SQUIT") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + SQuit(Module *creator, const Anope::string &mname = "SQUIT") : IRCDMessage(creator, mname, 2) { } void Run(MessageSource &source, const std::vector ¶ms) anope_override; }; -- cgit From d79dd0b7d705e8f18ae0d6494a8bc65c2b0c2819 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 1 May 2014 18:38:17 -0400 Subject: Pass password to nick register event so modules like m_ldap_authentication can create the respective account using the decrypted password which might not always be available --- include/modules.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/modules.h b/include/modules.h index 90dd23807..6f7803cff 100644 --- a/include/modules.h +++ b/include/modules.h @@ -743,8 +743,9 @@ class CoreExport Module : public Extensible /** Called when a nick is registered * @param user The user registering the nick, of any * @param The nick + * @param pass The password of the newly registered nick */ - virtual void OnNickRegister(User *user, NickAlias *na) { throw NotImplementedException(); } + virtual void OnNickRegister(User *user, NickAlias *na, const Anope::string &pass) { throw NotImplementedException(); } /** Called when a nick is suspended * @param na The nick alias -- cgit From 63b02b8c97e73d5a1fc7005e9693a954179ded0d Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 13 May 2014 22:57:53 -0400 Subject: Sanitize nuh masks more to prevent the other side from rewriting them, which screws with our internal tracking of them --- include/modes.h | 10 ++++++---- include/protocol.h | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/modes.h b/include/modes.h index 3ba54c439..d1dc4624e 100644 --- a/include/modes.h +++ b/include/modes.h @@ -88,7 +88,7 @@ class CoreExport UserModeParam : public UserMode * @param value The param * @return true or false */ - virtual bool IsValid(const Anope::string &value) const { return true; } + virtual bool IsValid(Anope::string &value) const { return true; } }; /** This class is a channel mode, all channel modes use this/inherit from this @@ -135,7 +135,7 @@ class CoreExport ChannelModeList : public ChannelMode * @param mask The mask * @return true for yes, false for no */ - virtual bool IsValid(const Anope::string &mask) const { return true; } + virtual bool IsValid(Anope::string &mask) const; /** Checks if mask affects user * Should only be used for extbans or other weird ircd-specific things. @@ -177,7 +177,7 @@ class CoreExport ChannelModeParam : public ChannelMode * @param value The param * @return true for yes, false for no */ - virtual bool IsValid(const Anope::string &value) const { return true; } + virtual bool IsValid(Anope::string &value) const { return true; } }; /** This is a mode that is a channel status, eg +v/h/o/a/q. @@ -259,7 +259,7 @@ class CoreExport ChannelModeKey : public ChannelModeParam public: ChannelModeKey(char mc) : ChannelModeParam("KEY", mc) { } - bool IsValid(const Anope::string &value) const anope_override; + bool IsValid(Anope::string &value) const anope_override; }; /** This class is used for oper only channel modes @@ -404,6 +404,8 @@ class CoreExport Entry */ const Anope::string GetMask() const; + const Anope::string GetNUHMask() const; + /** Check if this entry matches a user * @param u The user * @param full True to match against a users real host and IP diff --git a/include/protocol.h b/include/protocol.h index 8f4f2ea58..48520ca43 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -232,6 +232,8 @@ class CoreExport IRCDProto : public Service * Defaults to Config->ListSize */ virtual unsigned GetMaxListFor(Channel *c); + + virtual Anope::string NormalizeMask(const Anope::string &mask); }; class CoreExport MessageSource -- cgit From df321a118e7dd44dcd3a389f8ee75e9ff915b55e Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 14 May 2014 19:10:23 -0400 Subject: Fix access lists showing the wrong mask if the display nick for a group expires but the group still exists. This can cause access entries for nicks to not be deleted whenever the nicks are deleted. --- include/access.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/access.h b/include/access.h index 57229abab..323dc814d 100644 --- a/include/access.h +++ b/include/access.h @@ -74,6 +74,10 @@ class CoreExport AccessProvider : public Service /* Represents one entry of an access list on a channel. */ class CoreExport ChanAccess : public Serializable { + Anope::string mask; + /* account this access entry is for, if any */ + Serialize::Reference nc; + public: typedef std::multimap Set; /* shows the 'path' taken to determine if an access entry matches a user @@ -86,9 +90,6 @@ class CoreExport ChanAccess : public Serializable AccessProvider *provider; /* Channel this access entry is on */ Serialize::Reference ci; - /* account this access entry is for, if any */ - Serialize::Reference nc; - Anope::string mask; Anope::string creator; time_t last_seen; time_t created; @@ -96,6 +97,10 @@ class CoreExport ChanAccess : public Serializable ChanAccess(AccessProvider *p); virtual ~ChanAccess(); + void SetMask(const Anope::string &mask, ChannelInfo *ci); + const Anope::string &Mask() const; + NickCore *GetAccount() const; + void Serialize(Serialize::Data &data) const anope_override; static Serializable* Unserialize(Serializable *obj, Serialize::Data &); -- cgit From 20ce170024779aebbc1462146905c976836a552f Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 20 May 2014 12:19:26 -0400 Subject: Show account names in log messages --- include/logger.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/logger.h b/include/logger.h index 31fd4f627..e065e79bd 100644 --- a/include/logger.h +++ b/include/logger.h @@ -96,6 +96,11 @@ class CoreExport Log ~Log(); + private: + Anope::string FormatSource() const; + Anope::string FormatCommand() const; + + public: Anope::string BuildPrefix() const; template Log &operator<<(T val) -- cgit From 866f3f32ab3713e9867747f150df3698e456744e Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 20 May 2014 21:10:49 -0400 Subject: Speed up akill xline checks Cache xline nick, user, host, etc instead of rebuilding it everytime its requested. Store users ip in sockaddr form and not string form to prevent having to rebuild sockaddrs when checking xlines. Also do not try to convert empty config values in Config::Get as this can be rather common if a non string configuration value is not set, and the cost of the ConvertException is great. --- include/config.h | 15 +++++++-------- include/modules/os_session.h | 2 +- include/sockets.h | 5 ++--- include/users.h | 3 ++- include/xline.h | 13 ++++++++----- 5 files changed, 20 insertions(+), 18 deletions(-) (limited to 'include') diff --git a/include/config.h b/include/config.h index 019564680..b132c5d2d 100644 --- a/include/config.h +++ b/include/config.h @@ -51,14 +51,13 @@ namespace Configuration template T Get(const Anope::string &tag, const Anope::string &def) const { const Anope::string &value = this->Get(tag, def); - try - { - return convertTo(value); - } - catch (const ConvertException &) - { - return T(); - } + if (!value.empty()) + try + { + return convertTo(value); + } + catch (const ConvertException &) { } + return T(); } bool Set(const Anope::string &tag, const Anope::string &value); diff --git a/include/modules/os_session.h b/include/modules/os_session.h index 65f1c6f75..957fe6043 100644 --- a/include/modules/os_session.h +++ b/include/modules/os_session.h @@ -7,7 +7,7 @@ struct Session unsigned count; /* Number of clients with this host */ unsigned hits; /* Number of subsequent kills for a host */ - Session(const Anope::string &ip, int len) : addr(ip, len), count(1), hits(0) { } + Session(const sockaddrs &ip, int len) : addr(ip, len), count(1), hits(0) { } }; struct Exception : Serializable diff --git a/include/sockets.h b/include/sockets.h index 0dfa5d9d0..ca61f7efc 100644 --- a/include/sockets.h +++ b/include/sockets.h @@ -59,7 +59,7 @@ union CoreExport sockaddrs /** Check if this sockaddr has data in it */ - bool operator()() const; + bool valid() const; /** Compares with sockaddr with another. Compares address type, port, and address * @return true if they are the same @@ -82,8 +82,6 @@ union CoreExport sockaddrs * @throws A socket exception if given an invalid structure */ void ntop(int type, const void *src); - - bool valid() const; }; class CoreExport cidr @@ -94,6 +92,7 @@ class CoreExport cidr public: cidr(const Anope::string &ip); cidr(const Anope::string &ip, unsigned char len); + cidr(const sockaddrs &ip, unsigned char len); Anope::string mask() const; bool match(const sockaddrs &other); bool valid() const; diff --git a/include/users.h b/include/users.h index 73c373938..04d1606a4 100644 --- a/include/users.h +++ b/include/users.h @@ -20,6 +20,7 @@ #include "serialize.h" #include "commands.h" #include "account.h" +#include "sockets.h" typedef Anope::hash_map user_map; @@ -71,7 +72,7 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe /* SSL Fingerprint */ Anope::string fingerprint; /* User's IP */ - Anope::string ip; + sockaddrs ip; /* Server user is connected to */ Server *server; /* When the user signed on. Set on connect and never modified. */ diff --git a/include/xline.h b/include/xline.h index fa3f5ba6c..2eae08dc8 100644 --- a/include/xline.h +++ b/include/xline.h @@ -12,12 +12,15 @@ #include "serialize.h" #include "service.h" +#include "sockets.h" /* An Xline, eg, anything added with operserv/akill, or any of the operserv/sxline commands */ class CoreExport XLine : public Serializable { - void InitRegex(); + void Init(); + Anope::string nick, user, host, real; public: + cidr *c; Anope::string mask; Regex *regex; Anope::string by; @@ -32,10 +35,10 @@ class CoreExport XLine : public Serializable XLine(const Anope::string &mask, const Anope::string &by, const time_t expires, const Anope::string &reason, const Anope::string &uid = ""); ~XLine(); - Anope::string GetNick() const; - Anope::string GetUser() const; - Anope::string GetHost() const; - Anope::string GetReal() const; + const Anope::string &GetNick() const; + const Anope::string &GetUser() const; + const Anope::string &GetHost() const; + const Anope::string &GetReal() const; Anope::string GetReason() const; -- cgit From f627a3bacd0d058e94260dac1555790cafd9a926 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 21 May 2014 08:50:40 -0400 Subject: Core prep for p10 stuff --- include/messages.h | 2 +- include/protocol.h | 9 +++++++++ include/servers.h | 4 ---- 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/messages.h b/include/messages.h index 3bf096d7c..7b22a6ef4 100644 --- a/include/messages.h +++ b/include/messages.h @@ -82,7 +82,7 @@ namespace Message struct CoreExport Mode : IRCDMessage { - Mode(Module *creator, const Anope::string &mname = "MODE") : IRCDMessage(creator, mname, 2) { } + Mode(Module *creator, const Anope::string &mname = "MODE") : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } void Run(MessageSource &source, const std::vector ¶ms) anope_override; }; diff --git a/include/protocol.h b/include/protocol.h index 48520ca43..216adb6cb 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -40,6 +40,9 @@ class CoreExport IRCDProto : public Service virtual void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf); const Anope::string &GetProtocolName(); + virtual void Parse(const Anope::string &, Anope::string &, Anope::string &, std::vector &); + virtual Anope::string Format(const Anope::string &source, const Anope::string &message); + /* Modes used by default by our clients */ Anope::string DefaultPseudoclientModes; /* Can we force change a users's nick? */ @@ -64,11 +67,17 @@ class CoreExport IRCDProto : public Service bool CanCertFP; /* Whether this IRCd requires unique IDs for each user or server. See TS6/P10. */ bool RequiresID; + /* If this IRCd has unique ids, whether the IDs and nicknames are ambiguous */ + bool AmbiguousID; /* The maximum number of modes we are allowed to set with one MODE command */ unsigned MaxModes; /* The maximum number of bytes a line may have */ unsigned MaxLine; + /* Retrieves the next free UID or SID */ + virtual Anope::string UID_Retrieve(); + virtual Anope::string SID_Retrieve(); + /** Sets the server in NOOP mode. If NOOP mode is enabled, no users * will be able to oper on the server. * @param s The server diff --git a/include/servers.h b/include/servers.h index 7a2a594f1..054b881df 100644 --- a/include/servers.h +++ b/include/servers.h @@ -23,10 +23,6 @@ extern CoreExport Server *Me; namespace Servers { - /* Retrieves the next free TS6 UID or SID */ - extern CoreExport const Anope::string TS6_UID_Retrieve(); - extern CoreExport const Anope::string TS6_SID_Retrieve(); - /* Gets our uplink. Note we don't actually have an "uplink", this is just * the only server whose uplink *is* Me that is not a juped server. * @return Our uplink, or NULL if not uplinked to anything -- cgit From f20bac996da46556a821c1b0244a202e652fe247 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 30 May 2014 15:45:57 -0400 Subject: Fix Windows build and update library names to the newer ones. Also fix crash on Windows when unloading a module because it threw an exception. --- include/modes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/modes.h b/include/modes.h index d1dc4624e..9c5916c0f 100644 --- a/include/modes.h +++ b/include/modes.h @@ -205,7 +205,7 @@ class CoreExport ChannelModeStatus : public ChannelMode * but we still have a representation for it. */ template -class ChannelModeVirtual : public T +class CoreExport ChannelModeVirtual : public T { Anope::string base; ChannelMode *basech; -- cgit From 54e98f017c95feec8265d7e5c1d0b29fc5c716ea Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 31 May 2014 21:17:46 -0400 Subject: Always log when the uplink socket errors, and give possibly helpful advise --- include/uplink.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/uplink.h b/include/uplink.h index c7e3e1ccf..cc124fef1 100644 --- a/include/uplink.h +++ b/include/uplink.h @@ -25,6 +25,7 @@ namespace Uplink class UplinkSocket : public ConnectionSocket, public BufferedSocket { public: + bool error; UplinkSocket(); ~UplinkSocket(); bool ProcessRead() anope_override; -- cgit