2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013, 2017-2018 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2012-2014, 2016 Attila Molnar <attilamolnar@hush.com>
6 * Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
7 * Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
8 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
9 * Copyright (C) 2007-2009 Robin Burchell <robin+git@viroteck.net>
10 * Copyright (C) 2007-2008 Dennis Friis <peavey@inspircd.org>
11 * Copyright (C) 2007 Craig Edwards <brain@inspircd.org>
13 * This file is part of InspIRCd. InspIRCd is free software: you can
14 * redistribute it and/or modify it under the terms of the GNU General Public
15 * License as published by the Free Software Foundation, version 2.
17 * This program is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 class CommandUserip : public Command
34 CommandUserip(Module* Creator) : Command(Creator,"USERIP", 1)
36 syntax = "<nick> [<nick>]+";
39 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
43 bool checked_privs = false;
44 bool has_privs = false;
46 for (size_t i = 0; i < parameters.size(); i++)
48 User *u = ServerInstance->FindNickOnly(parameters[i]);
49 if ((u) && (u->registered == REG_ALL))
51 // Anyone may query their own IP
56 // Do not trigger the insufficient privileges message more than once
58 has_privs = user->HasPrivPermission("users/auspex");
60 user->WriteNumeric(ERR_NOPRIVILEGES, "Permission Denied - You do not have the required operator privileges");
67 retbuf = retbuf + u->nick + (u->IsOper() ? "*" : "") + "=";
72 retbuf += u->ident + "@" + u->GetIPString() + " ";
78 user->WriteNumeric(RPL_USERIP, retbuf);
84 class ModuleUserIP : public Module
93 void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
98 Version GetVersion() CXX11_OVERRIDE
100 return Version("Adds the /USERIP command which allows users to find out the IP address of one or more connected users.", VF_VENDOR);
104 MODULE_INIT(ModuleUserIP)