unrealircd

- supernets unrealircd source & configuration
git clone git://git.acid.vegas/unrealircd.git
Log | Files | Refs | Archive | README | LICENSE

privacy.c (1852B)

      1 /*
      2  * Privacy - hide channels in /WHOIS (User mode +p)
      3  * (C) Copyright 2000-.. Bram Matthys (Syzop) and the UnrealIRCd team
      4  *
      5  * This program is free software; you can redistribute it and/or modify
      6  * it under the terms of the GNU General Public License as published by
      7  * the Free Software Foundation; either version 1, or (at your option)
      8  * any later version.
      9  *
     10  * This program is distributed in the hope that it will be useful,
     11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  * GNU General Public License for more details.
     14  *
     15  * You should have received a copy of the GNU General Public License
     16  * along with this program; if not, write to the Free Software
     17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18  */
     19 
     20 #include "unrealircd.h"
     21 
     22 #define IsPrivacy(client)    (client->umodes & UMODE_PRIVACY)
     23 
     24 /* Module header */
     25 ModuleHeader MOD_HEADER
     26   = {
     27 	"usermodes/privacy",
     28 	"4.2",
     29 	"User Mode +p",
     30 	"UnrealIRCd Team",
     31 	"unrealircd-6",
     32     };
     33 
     34 /* Global variables */
     35 long UMODE_PRIVACY = 0L;
     36 
     37 /* Forward declarations */
     38 int privacy_see_channel_in_whois(Client *client, Client *target, Channel *channel);
     39                     
     40 MOD_INIT()
     41 {
     42 	UmodeAdd(modinfo->handle, 'p', UMODE_GLOBAL, 0, umode_allow_all, &UMODE_PRIVACY);
     43 	
     44 	HookAdd(modinfo->handle, HOOKTYPE_SEE_CHANNEL_IN_WHOIS, 0, privacy_see_channel_in_whois);
     45 	
     46 	MARK_AS_OFFICIAL_MODULE(modinfo);
     47 	return MOD_SUCCESS;
     48 }
     49 
     50 MOD_LOAD()
     51 {
     52 	return MOD_SUCCESS;
     53 }
     54 
     55 MOD_UNLOAD()
     56 {
     57 	return MOD_SUCCESS;
     58 }
     59 
     60 /* This hides channels in /WHOIS output, unless the requestor is in the same channel
     61  * or some IRCOp is overriding.
     62  */
     63 int privacy_see_channel_in_whois(Client *client, Client *target, Channel *channel)
     64 {
     65 	if (IsPrivacy(target) && !IsMember(client, channel))
     66 		return EX_DENY;
     67 	
     68 	return EX_ALLOW;
     69 }