X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcoremods%2Fcore_mode.cpp;h=55ca4bdb088a97eaf7c8d03aaa9980ac6c090f38;hb=55a0a6ab66739fae65d123fadff1a31d96999c16;hp=fa20a690262e50744f5b600a69ef260803e83c5f;hpb=0f2341e76eb54fb38b97305609db9f025331d002;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/coremods/core_mode.cpp b/src/coremods/core_mode.cpp index fa20a6902..55ca4bdb0 100644 --- a/src/coremods/core_mode.cpp +++ b/src/coremods/core_mode.cpp @@ -1,10 +1,11 @@ /* * InspIRCd -- Internet Relay Chat Daemon * - * Copyright (C) 2014 Attila Molnar - * Copyright (C) 2009-2010 Daniel De Graaf - * Copyright (C) 2006-2008 Robin Burchell - * Copyright (C) 2004-2008 Craig Edwards + * Copyright (C) 2019 linuxdaemon + * Copyright (C) 2019 Robby + * Copyright (C) 2018-2020 Sadie Powell + * Copyright (C) 2017 B00mX0r + * Copyright (C) 2014, 2016 Attila Molnar * * 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 @@ -24,8 +25,11 @@ class CommandMode : public Command { + private: unsigned int sent[256]; unsigned int seq; + ChanModeReference secretmode; + ChanModeReference privatemode; /** Show the list of one or more list modes to a user. * @param user User to send to. @@ -41,6 +45,18 @@ class CommandMode : public Command */ void DisplayCurrentModes(User* user, User* targetuser, Channel* targetchannel); + bool CanSeeChan(User* user, Channel* chan) + { + // A user can always see the channel modes if they are: + // (1) In the channel. + // (2) An oper with the channels/auspex privilege. + if (chan->HasUser(user) || user->HasPrivPermission("channels/auspex")) + return true; + + // Otherwise, they can only see the modes when the channel is not +p or +s. + return !chan->IsModeSet(secretmode) && !chan->IsModeSet(privatemode); + } + public: /** Constructor for mode. */ @@ -59,6 +75,8 @@ class CommandMode : public Command CommandMode::CommandMode(Module* parent) : Command(parent, "MODE", 1) , seq(0) + , secretmode(creator, "secret") + , privatemode(creator, "private") { syntax = " [[(+|-)] []]"; memset(&sent, 0, sizeof(sent)); @@ -77,7 +95,7 @@ CmdResult CommandMode::Handle(User* user, const Params& parameters) targetuser = ServerInstance->FindNick(target); } - if ((!targetchannel) && (!targetuser)) + if ((!targetchannel || !CanSeeChan(user, targetchannel)) && (!targetuser)) { if (target[0] == '#') user->WriteNumeric(Numerics::NoSuchChannel(target)); @@ -267,6 +285,12 @@ class CoreModMode : public Module { } + void On005Numeric(std::map& tokens) CXX11_OVERRIDE + { + tokens["CHANMODES"] = ServerInstance->Modes->GiveModeList(MODETYPE_CHANNEL); + tokens["USERMODES"] = ServerInstance->Modes->GiveModeList(MODETYPE_USER); + } + Version GetVersion() CXX11_OVERRIDE { return Version("Provides the MODE command", VF_VENDOR|VF_CORE);