summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/channels.h3
-rw-r--r--include/config.h17
-rw-r--r--include/logger.h5
-rw-r--r--include/messages.h4
-rw-r--r--include/modes.h51
-rw-r--r--include/modules/chanserv.h48
-rw-r--r--include/modules/nickserv.h3
-rw-r--r--include/modules/os_session.h2
-rw-r--r--include/protocol.h11
-rw-r--r--include/servers.h4
-rw-r--r--include/sockets.h5
-rw-r--r--include/uplink.h1
-rw-r--r--include/users.h3
-rw-r--r--include/xline.h13
14 files changed, 130 insertions, 40 deletions
diff --git a/include/channels.h b/include/channels.h
index 3deadce5b..f27edcee6 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 ccb7bcdf1..efb0ecfba 100644
--- a/include/config.h
+++ b/include/config.h
@@ -48,14 +48,13 @@ namespace Configuration
template<typename T> T Get(const Anope::string &tag, const Anope::string &def) const
{
const Anope::string &value = this->Get<const Anope::string>(tag, def);
- try
- {
- return convertTo<T>(value);
- }
- catch (const ConvertException &)
- {
- return T();
- }
+ if (!value.empty())
+ try
+ {
+ return convertTo<T>(value);
+ }
+ catch (const ConvertException &) { }
+ return T();
}
bool Set(const Anope::string &tag, const Anope::string &value);
@@ -139,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/logger.h b/include/logger.h
index 8ed316e94..db348d0a3 100644
--- a/include/logger.h
+++ b/include/logger.h
@@ -95,6 +95,11 @@ class CoreExport Log
~Log();
+ private:
+ Anope::string FormatSource() const;
+ Anope::string FormatCommand() const;
+
+ public:
Anope::string BuildPrefix() const;
template<typename T> Log &operator<<(T val)
diff --git a/include/messages.h b/include/messages.h
index 58d32aaf5..1d1c784ca 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<Anope::string> &params) override;
};
@@ -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<Anope::string> &params) override;
};
diff --git a/include/modes.h b/include/modes.h
index e13470669..1858da5e4 100644
--- a/include/modes.h
+++ b/include/modes.h
@@ -87,7 +87,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
@@ -95,6 +95,9 @@ class CoreExport UserModeParam : public UserMode
class CoreExport ChannelMode : public Mode
{
public:
+ /* channel modes that can posssibly unwrap this mode */
+ std::vector<ChannelMode *> listeners;
+
/** constructor
* @param name The mode name
* @param mc The mode char
@@ -102,6 +105,18 @@ class CoreExport ChannelMode : public Mode
ChannelMode(const Anope::string &name, char mc);
bool CanSet(User *u) const override;
+
+ /** 'wrap' this channel mode and param to the underlying mode and param
+ */
+ virtual ChannelMode *Wrap(Anope::string &param);
+
+ /** 'unwrap' this mode to our internal representation
+ */
+ ChannelMode *Unwrap(Anope::string &param);
+
+ /** called when a mode is being unwrapped, and is asking us if we can unwrap it
+ */
+ virtual ChannelMode *Unwrap(ChannelMode *, Anope::string &param);
};
/** This is a mode for lists, eg b/e/I. These modes should inherit from this
@@ -119,7 +134,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.
@@ -161,7 +176,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.
@@ -185,6 +200,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<typename T>
+class CoreExport ChannelModeVirtual : public T
+{
+ Anope::string base;
+ ChannelMode *basech;
+
+ public:
+ ChannelModeVirtual(const Anope::string &mname, const Anope::string &basename);
+
+ ~ChannelModeVirtual();
+
+ ChannelMode *Wrap(Anope::string &param) override;
+
+ ChannelMode *Unwrap(ChannelMode *cm, Anope::string &param) = 0;
+};
+
/* The status a user has on a channel (+v, +h, +o) etc */
class CoreExport ChannelStatus
{
@@ -224,7 +258,7 @@ class CoreExport ChannelModeKey : public ChannelModeParam
public:
ChannelModeKey(char mc) : ChannelModeParam("KEY", mc) { }
- bool IsValid(const Anope::string &value) const override;
+ bool IsValid(Anope::string &value) const override;
};
/** This class is used for oper only channel modes
@@ -256,13 +290,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<ChannelMode *> ChannelModes;
- static std::vector<UserMode *> UserModes;
-
public:
/* Number of generic channel and user modes we are tracking */
@@ -376,6 +403,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/modules/chanserv.h b/include/modules/chanserv.h
index 9170ea2d2..c5e677407 100644
--- a/include/modules/chanserv.h
+++ b/include/modules/chanserv.h
@@ -365,6 +365,10 @@ namespace ChanServ
/* 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<NickServ::Account> nc;
+
public:
typedef std::multimap<const ChanAccess *, const ChanAccess *> Set;
/* shows the 'path' taken to determine if an access entry matches a user
@@ -377,9 +381,6 @@ namespace ChanServ
AccessProvider *provider;
/* Channel this access entry is on */
Serialize::Reference<Channel> ci;
- /* account this access entry is for, if any */
- Serialize::Reference<NickServ::Account> nc;
- Anope::string mask;
Anope::string creator;
time_t last_seen;
time_t created;
@@ -391,6 +392,47 @@ namespace ChanServ
service->Destruct(this);
}
+ void SetMask(const Anope::string &mask, Channel *c)
+ {
+ if (nc != NULL)
+ nc->RemoveChannelReference(this->ci);
+ else if (!this->mask.empty())
+ {
+ Channel *targc = ChanServ::Find(this->mask);
+ if (targc)
+ targc->RemoveChannelReference(this->ci->name);
+ }
+
+ ci = c;
+ this->mask.clear();
+ nc = NULL;
+
+ const NickServ::Nick *na = NickServ::FindNick(mask);
+ if (na != NULL)
+ {
+ nc = na->nc;
+ nc->AddChannelReference(ci);
+ }
+ else
+ {
+ this->mask = mask;
+
+ Channel *targci = ChanServ::Find(mask);
+ if (targci != NULL)
+ targci->AddChannelReference(ci->name);
+ }
+ }
+
+ const Anope::string &Mask() const
+ {
+ if (nc)
+ return nc->display;
+ else
+ return mask;
+ }
+
+ NickServ::Account *GetAccount() const { return nc; }
+
void Serialize(Serialize::Data &data) const override
{
service->Serialize(this, data);
diff --git a/include/modules/nickserv.h b/include/modules/nickserv.h
index a55786ffb..0430276fe 100644
--- a/include/modules/nickserv.h
+++ b/include/modules/nickserv.h
@@ -82,8 +82,9 @@ namespace NickServ
/** Called when a nick is registered
* @param user The user registering the nick, of any
* @param The nick
+ * @param password The password of the nick
*/
- virtual void OnNickRegister(User *user, Nick *na) anope_abstract;
+ virtual void OnNickRegister(User *user, Nick *na, const Anope::string &password) anope_abstract;
};
static EventHandlersReference<NickRegister> OnNickRegister("OnNickRegister");
diff --git a/include/modules/os_session.h b/include/modules/os_session.h
index 54be44545..89b063104 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/protocol.h b/include/protocol.h
index 280d2c7dc..1ca2e8d34 100644
--- a/include/protocol.h
+++ b/include/protocol.h
@@ -39,6 +39,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<Anope::string> &);
+ 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? */
@@ -63,11 +66,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
@@ -231,6 +240,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
diff --git a/include/servers.h b/include/servers.h
index 743dc5d9c..1fc51f258 100644
--- a/include/servers.h
+++ b/include/servers.h
@@ -22,10 +22,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
diff --git a/include/sockets.h b/include/sockets.h
index 37357c1cc..a0e310885 100644
--- a/include/sockets.h
+++ b/include/sockets.h
@@ -58,7 +58,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
@@ -81,8 +81,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
@@ -93,6 +91,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/uplink.h b/include/uplink.h
index 95f924093..c86cd721f 100644
--- a/include/uplink.h
+++ b/include/uplink.h
@@ -24,6 +24,7 @@ namespace Uplink
class UplinkSocket : public ConnectionSocket, public BufferedSocket
{
public:
+ bool error;
UplinkSocket();
~UplinkSocket();
bool ProcessRead() override;
diff --git a/include/users.h b/include/users.h
index 972fa2ac0..fe714b4a4 100644
--- a/include/users.h
+++ b/include/users.h
@@ -18,6 +18,7 @@
#include "extensible.h"
#include "serialize.h"
#include "commands.h"
+#include "sockets.h"
typedef Anope::hash_map<User *> user_map;
@@ -69,7 +70,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 6d6db1dbf..e31142b9f 100644
--- a/include/xline.h
+++ b/include/xline.h
@@ -11,12 +11,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;
std::regex *regex;
Anope::string by;
@@ -31,10 +34,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;