diff options
| author | 2019-03-30 22:06:19 +0000 | |
|---|---|---|
| committer | 2019-03-30 22:06:19 +0000 | |
| commit | 1fff2f7f87fa0e69494fe45902cfa315204d1e43 (patch) | |
| tree | b4f3eac01dc458cc7f3ab5b43a57c44d06044bed /include | |
| parent | Remove the flashpolicyd module. (diff) | |
| parent | Rename OnClientProtocolPopulateTags to OnPopulateTags. (diff) | |
Merge branch 'insp3' into master.
Diffstat (limited to 'include')
| -rw-r--r-- | include/clientprotocol.h | 2 | ||||
| -rw-r--r-- | include/event.h | 2 | ||||
| -rw-r--r-- | include/flat_map.h | 24 | ||||
| -rw-r--r-- | include/inspircd.h | 6 | ||||
| -rw-r--r-- | include/iohook.h | 2 | ||||
| -rw-r--r-- | include/modules/ctctags.h | 135 | ||||
| -rw-r--r-- | include/modules/ircv3.h | 2 | ||||
| -rw-r--r-- | include/modules/who.h | 11 | ||||
| -rw-r--r-- | include/xline.h | 7 |
9 files changed, 172 insertions, 19 deletions
diff --git a/include/clientprotocol.h b/include/clientprotocol.h index ec033e166..44896a3a3 100644 --- a/include/clientprotocol.h +++ b/include/clientprotocol.h @@ -537,7 +537,7 @@ class ClientProtocol::MessageTagProvider : public Events::ModuleEventListener * The default implementation does nothing. * @param msg Message to be populated with tags. */ - virtual void OnClientProtocolPopulateTags(ClientProtocol::Message& msg) + virtual void OnPopulateTags(ClientProtocol::Message& msg) { } diff --git a/include/event.h b/include/event.h index 0251ec4ac..a042c6a11 100644 --- a/include/event.h +++ b/include/event.h @@ -39,7 +39,7 @@ class Events::ModuleEventProvider : public ServiceProvider, private dynamic_refe bool operator()(ModuleEventListener* one, ModuleEventListener* two) const; }; - typedef insp::flat_multiset<ModuleEventListener*, Comp> SubscriberList; + typedef insp::flat_multiset<ModuleEventListener*, Comp, std::less<ModuleEventListener*> > SubscriberList; /** Constructor * @param mod Module providing the event(s) diff --git a/include/flat_map.h b/include/flat_map.h index bef1404e4..62815168b 100644 --- a/include/flat_map.h +++ b/include/flat_map.h @@ -200,10 +200,10 @@ class flat_map_base } // namespace detail -template <typename T, typename Comp = std::less<T> > -class flat_set : public detail::flat_map_base<T, Comp> +template <typename T, typename Comp = std::less<T>, typename ElementComp = Comp> +class flat_set : public detail::flat_map_base<T, Comp, T, ElementComp> { - typedef detail::flat_map_base<T, Comp> base_t; + typedef detail::flat_map_base<T, Comp, T, ElementComp> base_t; public: typedef typename base_t::iterator iterator; @@ -240,10 +240,10 @@ class flat_set : public detail::flat_map_base<T, Comp> } }; -template <typename T, typename Comp = std::less<T> > -class flat_multiset : public detail::flat_map_base<T, Comp> +template <typename T, typename Comp = std::less<T>, typename ElementComp = Comp> +class flat_multiset : public detail::flat_map_base<T, Comp, T, ElementComp> { - typedef detail::flat_map_base<T, Comp> base_t; + typedef detail::flat_map_base<T, Comp, T, ElementComp> base_t; public: typedef typename base_t::iterator iterator; @@ -280,10 +280,10 @@ class flat_multiset : public detail::flat_map_base<T, Comp> } }; -template <typename T, typename U, typename Comp = std::less<T> > -class flat_map : public detail::flat_map_base<std::pair<T, U>, Comp, T, detail::map_pair_compare<std::pair<T, U>, Comp> > +template <typename T, typename U, typename Comp = std::less<T>, typename ElementComp = Comp > +class flat_map : public detail::flat_map_base<std::pair<T, U>, Comp, T, detail::map_pair_compare<std::pair<T, U>, ElementComp> > { - typedef detail::flat_map_base<std::pair<T, U>, Comp, T, detail::map_pair_compare<std::pair<T, U>, Comp> > base_t; + typedef detail::flat_map_base<std::pair<T, U>, Comp, T, detail::map_pair_compare<std::pair<T, U>, ElementComp> > base_t; public: typedef typename base_t::iterator iterator; @@ -333,10 +333,10 @@ class flat_map : public detail::flat_map_base<std::pair<T, U>, Comp, T, detail:: } }; -template <typename T, typename U, typename Comp = std::less<T> > -class flat_multimap : public detail::flat_map_base<std::pair<T, U>, Comp, T, detail::map_pair_compare<std::pair<T, U>, Comp> > +template <typename T, typename U, typename Comp = std::less<T>, typename ElementComp = Comp > +class flat_multimap : public detail::flat_map_base<std::pair<T, U>, Comp, T, detail::map_pair_compare<std::pair<T, U>, ElementComp> > { - typedef detail::flat_map_base<std::pair<T, U>, Comp, T, detail::map_pair_compare<std::pair<T, U>, Comp> > base_t; + typedef detail::flat_map_base<std::pair<T, U>, Comp, T, detail::map_pair_compare<std::pair<T, U>, ElementComp> > base_t; public: typedef typename base_t::iterator iterator; diff --git a/include/inspircd.h b/include/inspircd.h index 1cbc3f2c2..dd3195039 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -509,6 +509,12 @@ class CoreExport InspIRCd */ static bool IsValidDuration(const std::string& str); + /** Return a duration in seconds as a human-readable string. + * @param duration The duration in seconds to convert to a human-readable string. + * @return A string representing the given duration. + */ + static std::string DurationString(time_t duration); + /** Attempt to compare a password to a string from the config file. * This will be passed to handling modules which will compare the data * against possible hashed equivalents in the input string. diff --git a/include/iohook.h b/include/iohook.h index 9ca17d77e..85404b09c 100644 --- a/include/iohook.h +++ b/include/iohook.h @@ -49,7 +49,7 @@ class IOHookProvider : public refcountbase, public ServiceProvider */ bool IsMiddle() const { return middlehook; } - /** Called when the provider should hook an incoming connection and act as being on the server side of the connection. + /** Called when the provider should hook an incoming connection and act as being on the server-side of the connection. * This occurs when a bind block has a hook configured and the listener accepts a connection. * @param sock Socket to hook * @param client Client IP address and port diff --git a/include/modules/ctctags.h b/include/modules/ctctags.h new file mode 100644 index 000000000..d8798de54 --- /dev/null +++ b/include/modules/ctctags.h @@ -0,0 +1,135 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2019 Peter Powell <petpow@saberuk.com> + * + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +#pragma once + +#include "event.h" + +namespace CTCTags +{ + class EventListener; + class TagMessage; + class TagMessageDetails; +} + +class CTCTags::TagMessage : public ClientProtocol::Message +{ + public: + TagMessage(User* source, const Channel* targetchan, const ClientProtocol::TagMap& Tags) + : ClientProtocol::Message("TAGMSG", source) + { + PushParamRef(targetchan->name); + AddTags(Tags); + SetSideEffect(true); + } + + TagMessage(User* source, const User* targetuser, const ClientProtocol::TagMap& Tags) + : ClientProtocol::Message("TAGMSG", source) + { + if (targetuser->registered & REG_NICK) + PushParamRef(targetuser->nick); + else + PushParam("*"); + AddTags(Tags); + SetSideEffect(true); + } + + TagMessage(User* source, const char* targetstr, const ClientProtocol::TagMap& Tags) + : ClientProtocol::Message("TAGMSG", source) + { + PushParam(targetstr); + AddTags(Tags); + SetSideEffect(true); + } +}; + +class CTCTags::TagMessageDetails +{ + public: + /** Whether to echo the tags at all. */ + bool echo; + + /* Whether to send the original tags back to clients with echo-message support. */ + bool echo_original; + + /** The users who are exempted from receiving this message. */ + CUList exemptions; + + /** IRCv3 message tags sent to the server by the user. */ + const ClientProtocol::TagMap tags_in; + + /** IRCv3 message tags sent out to users who get this message. */ + ClientProtocol::TagMap tags_out; + + TagMessageDetails(const ClientProtocol::TagMap& tags) + : echo(true) + , echo_original(false) + , tags_in(tags) + { + } +}; + +class CTCTags::EventListener + : public Events::ModuleEventListener +{ + protected: + EventListener(Module* mod, unsigned int eventprio = DefaultPriority) + : ModuleEventListener(mod, "event/tagmsg", eventprio) + { + } + + public: + /** Called before a user sends a tag message to a channel, a user, or a server glob mask. + * @param user The user sending the message. + * @param target The target of the message. This can either be a channel, a user, or a server + * glob mask. + * @param details Details about the message such as the message tags or whether to echo. See the + * TagMessageDetails class for more information. + * @return MOD_RES_ALLOW to explicitly allow the message, MOD_RES_DENY to explicitly deny the + * message, or MOD_RES_PASSTHRU to let another module handle the event. + */ + virtual ModResult OnUserPreTagMessage(User* user, const MessageTarget& target, TagMessageDetails& details) { return MOD_RES_PASSTHRU; } + + /** Called immediately after a user sends a tag message to a channel, a user, or a server glob mask. + * @param user The user sending the message. + * @param target The target of the message. This can either be a channel, a user, or a server + * glob mask. + * @param details Details about the message such as the message tags or whether to echo. See the + * TagMessageDetails class for more information. + */ + virtual void OnUserPostTagMessage(User* user, const MessageTarget& target, const TagMessageDetails& details) { } + + /** Called immediately before a user sends a tag message to a channel, a user, or a server glob mask. + * @param user The user sending the message. + * @param target The target of the message. This can either be a channel, a user, or a server + * glob mask. + * @param details Details about the message such as the message tags or whether to echo. See the + * TagMessageDetails class for more information. + */ + virtual void OnUserTagMessage(User* user, const MessageTarget& target, const TagMessageDetails& details) { } + + /** Called when a tag message sent by a user to a channel, a user, or a server glob mask is blocked. + * @param user The user sending the message. + * @param target The target of the message. This can either be a channel, a user, or a server + * glob mask. + * @param details Details about the message such as the message tags or whether to echo. See the + * TagMessageDetails class for more information. + */ + virtual void OnUserTagMessageBlocked(User* user, const MessageTarget& target, const TagMessageDetails& details) { } +}; diff --git a/include/modules/ircv3.h b/include/modules/ircv3.h index c6f3e503a..53b1dc2b6 100644 --- a/include/modules/ircv3.h +++ b/include/modules/ircv3.h @@ -75,7 +75,7 @@ class IRCv3::CapTag : public ClientProtocol::MessageTagProvider return cap.get(user); } - void OnClientProtocolPopulateTags(ClientProtocol::Message& msg) override + void OnPopulateTags(ClientProtocol::Message& msg) override { T& tag = static_cast<T&>(*this); const std::string* const val = tag.GetValue(msg); diff --git a/include/modules/who.h b/include/modules/who.h index 4fcbe5f91..983cece46 100644 --- a/include/modules/who.h +++ b/include/modules/who.h @@ -71,6 +71,17 @@ class Who::Request /** A user specified label for the WHOX response. */ std::string whox_querytype; + /** Get the index in the response parameters for the different data fields + * + * The fields 'r' (realname) and 'd' (hops) will always be missing in a non-WHOX + * query, because WHOX splits them to 2 fields, where old WHO has them as one. + * + * @param flag The field name to look for + * @param out The index will be stored in this value + * @return True if the field is available, false otherwise + */ + virtual bool GetFieldIndex(char flag, size_t& out) const = 0; + protected: Request() : fuzzy_match(false) diff --git a/include/xline.h b/include/xline.h index 2688ac134..819e8bb43 100644 --- a/include/xline.h +++ b/include/xline.h @@ -515,8 +515,9 @@ class CoreExport XLineManager /** Expire a line given two iterators which identify it in the main map. * @param container Iterator to the first level of entries the map * @param item Iterator to the second level of entries in the map + * @param silent If true, doesn't send an expiry SNOTICE. */ - void ExpireLine(ContainerIter container, LookupIter item); + void ExpireLine(ContainerIter container, LookupIter item, bool silent = false); /** Apply any new lines that are pending to be applied. * This will only apply lines in the pending_lines list, to save on @@ -533,6 +534,6 @@ class CoreExport XLineManager */ void InvokeStats(const std::string& type, unsigned int numeric, Stats::Context& stats); - /** Clears any XLines which were added by the server configuration. */ - void ClearConfigLines(); + /** Expire X-lines which were added by the server configuration and have been removed. */ + void ExpireRemovedConfigLines(const std::string& type, const insp::flat_set<std::string>& configlines); }; |
