Commit Diff


commit - 490c9d04d71433982b848c032acee546e2d411f2
commit + 4ef172d60331611ddb4d96ba33266998eb7ae505
blob - 13929d531c19168bdda5c38fda4d171fa614a561
blob + 13891598022b7b51646f338b92e3fe45daa7b910
--- ChangeLog
+++ ChangeLog
@@ -12,6 +12,7 @@
 
 ngIRCd CVSHEAD
 
+  - Implemented support for "secret channels" (channel mode "s").
   - New configuration option "Mask" for [Operator] sections to limit OPER
     commands to ussers with a specific IRC mask. Patch from Florian Westphal.
   - Write "error file" (/tmp/ngircd-XXX.err) only if compiled with debug
@@ -588,4 +589,4 @@ ngIRCd 0.0.1, 31.12.2001
 
 
 -- 
-$Id: ChangeLog,v 1.262 2005/03/02 16:07:30 alex Exp $
+$Id: ChangeLog,v 1.263 2005/03/02 16:35:10 alex Exp $
blob - 4778cd7d38295bc3e7f6369b870da4cc4ca5a748
blob + 6a49e1496acfcb7e918c759ec05619602b8a8c07
--- NEWS
+++ NEWS
@@ -1,7 +1,7 @@
 
                      ngIRCd - Next Generation IRC Server
 
-                      (c)2001-2004 by Alexander Barton,
+                        (c)2001-2005 Alexander Barton,
                     alex@barton.de, http://www.barton.de/
 
                ngIRCd is free software and published under the
@@ -12,6 +12,7 @@
 
 ngIRCd CVSHEAD
 
+  - Implemented support for "secret channels" (channel mode "s").
   - New configuration option "Mask" for [Operator] sections to limit OPER
     commands to ussers with a specific IRC mask. Patch from Florian Westphal.
   - New configuration variable "PidFile", section "[Global]": if defined,
@@ -200,4 +201,4 @@ ngIRCd 0.0.1, 31.12.2001
 
 
 -- 
-$Id: NEWS,v 1.69 2005/03/02 16:07:30 alex Exp $
+$Id: NEWS,v 1.70 2005/03/02 16:35:10 alex Exp $
blob - 12558ef37589a82a4db5d2eb28044d31b0c9367d
blob + 7d6ff21de25b43bcb80ab762618cb7220508770e
--- src/ngircd/defines.h
+++ src/ngircd/defines.h
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: defines.h,v 1.49 2005/02/04 14:24:21 alex Exp $
+ * $Id: defines.h,v 1.50 2005/03/02 16:35:11 alex Exp $
  *
  * Global defines of ngIRCd.
  */
@@ -49,7 +49,7 @@
 #define CLIENT_FLAGS_LEN 100		/* max. length of client flags */
 
 #define CHANNEL_NAME_LEN 51		/* max. length of a channel name, see. RFC 2812, 1.3 */
-#define CHANNEL_MODE_LEN 8		/* max. length of channel modes */
+#define CHANNEL_MODE_LEN 9		/* max. length of channel modes */
 #define CHANNEL_TOPIC_LEN 128		/* max. length of a channel topic */
 
 #define COMMAND_LEN 513			/* max. IRC command length, see. RFC 2812, 3.2 */
@@ -74,7 +74,7 @@
 #define RECONNECT_DELAY 3		/* time to delay re-connect attempts (seconds) */
 
 #define USERMODES "aios"		/* supported user modes */
-#define CHANMODES "biklImnoPtv"		/* supported channel modes */
+#define CHANMODES "biklImnoPstv"	/* supported channel modes */
 
 #define CONNECTED TRUE			/* internal status codes */
 #define DISCONNECTED FALSE
blob - 79be000568b476f1f1c871488f5ffbdba9a443d9
blob + a37fca96adabd7243b6302f7b6327d6aa6f428f1
--- src/ngircd/irc-channel.c
+++ src/ngircd/irc-channel.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-channel.c,v 1.27 2004/04/09 20:46:48 alex Exp $";
+static char UNUSED id[] = "$Id: irc-channel.c,v 1.28 2005/03/02 16:35:11 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -349,15 +349,19 @@ IRC_LIST( CLIENT *Client, REQUEST *Req )
 	
 	while( pattern )
 	{
-		/* alle Channel durchgehen */
+		/* Loop through all the channels */
 		chan = Channel_First( );
 		while( chan )
 		{
-			/* Passt die Suchmaske auf diesen Channel? */
+			/* Check search pattern */
 			if( Match( pattern, Channel_Name( chan )))
 			{
-				/* Treffer! */
-				if( ! IRC_WriteStrClient( from, RPL_LIST_MSG, from, Channel_Name( chan ), Channel_MemberCount( chan ), Channel_Topic( chan ))) return DISCONNECTED;
+				/* Gotcha! */
+				if( ! strchr( Channel_Modes( chan ), 's' ) ||
+				    Channel_IsMemberOf( chan, from ))
+				{
+					if( ! IRC_WriteStrClient( from, RPL_LIST_MSG, from, Channel_Name( chan ), Channel_MemberCount( chan ), Channel_Topic( chan ))) return DISCONNECTED;
+				}
 			}
 			chan = Channel_Next( chan );
 		}
blob - 0d7246f82f389e437ca90c1efd422fedb6e73492
blob + 3811ea73d406c7b429eaee389b575bdc78a0a726
--- src/ngircd/irc-info.c
+++ src/ngircd/irc-info.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-info.c,v 1.26 2005/02/09 09:52:58 alex Exp $";
+static char UNUSED id[] = "$Id: irc-info.c,v 1.27 2005/03/02 16:35:11 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -543,7 +543,7 @@ IRC_WHO( CLIENT *Client, REQUEST *Req )
 	BOOLEAN ok, only_ops;
 	CHAR flags[8], *ptr;
 	CL2CHAN *cl2chan;
-	CHANNEL *chan;
+	CHANNEL *chan, *cn;
 	CLIENT *c;
 
 	assert( Client != NULL );
@@ -591,14 +591,25 @@ IRC_WHO( CLIENT *Client, REQUEST *Req )
 
 			if( ok && (( ! only_ops ) || ( strchr( Client_Modes( c ), 'o' ))))
 			{
-				/* Flags zusammenbasteln */
+				/* Get flags */
 				strcpy( flags, "H" );
 				if( strchr( Client_Modes( c ), 'o' )) strlcat( flags, "*", sizeof( flags ));
 
-				/* ausgeben */
+				/* Search suitable channel */
 				cl2chan = Channel_FirstChannelOf( c );
-				if( cl2chan ) ptr = Channel_Name( Channel_GetChannel( cl2chan ));
-				else ptr = "*";
+				while( cl2chan )
+				{
+					cn = Channel_GetChannel( cl2chan );
+					if( Channel_IsMemberOf( cn, Client ) ||
+					    ! strchr( Channel_Modes( cn ), 's' ))
+					{
+						ptr = Channel_Name( cn );
+						break;
+					}
+					cl2chan = Channel_NextChannelOf( c, cl2chan );
+				}
+				if( ! cl2chan ) ptr = "*";
+
 				if( ! IRC_WriteStrClient( Client, RPL_WHOREPLY_MSG, Client_ID( Client ), ptr, Client_User( c ), Client_Hostname( c ), Client_ID( Client_Introducer( c )), Client_ID( c ), flags, Client_Hops( c ), Client_Info( c ))) return DISCONNECTED;
 			}
 		}
@@ -662,6 +673,12 @@ IRC_WHOIS( CLIENT *Client, REQUEST *Req )
 	{
 		chan = Channel_GetChannel( cl2chan );
 		assert( chan != NULL );
+
+		/* next */
+		cl2chan = Channel_NextChannelOf( c, cl2chan );
+
+		/* Secret channel? */
+		if( strchr( Channel_Modes( chan ), 's' ) && ! Channel_IsMemberOf( chan, Client )) continue;
 
 		/* Concatenate channel names */
 		if( str[strlen( str ) - 1] != ':' ) strlcat( str, " ", sizeof( str ));
@@ -675,9 +692,6 @@ IRC_WHOIS( CLIENT *Client, REQUEST *Req )
 			if( ! IRC_WriteStrClient( Client, "%s", str )) return DISCONNECTED;
 			snprintf( str, sizeof( str ), RPL_WHOISCHANNELS_MSG, Client_ID( from ), Client_ID( c ));
 		}
-
-		/* next */
-		cl2chan = Channel_NextChannelOf( c, cl2chan );
 	}
 	if( str[strlen( str ) - 1] != ':')
 	{
@@ -822,6 +836,9 @@ IRC_Send_NAMES( CLIENT *Client, CHANNEL *Chan )
 	if( Channel_IsMemberOf( Chan, Client )) is_member = TRUE;
 	else is_member = FALSE;
 
+	/* Secret channel? */
+	if( ! is_member && strchr( Channel_Modes( Chan ), 's' )) return CONNECTED;
+
 	/* Alle Mitglieder suchen */
 	snprintf( str, sizeof( str ), RPL_NAMREPLY_MSG, Client_ID( Client ), "=", Channel_Name( Chan ));
 	cl2chan = Channel_FirstMember( Chan );
@@ -875,6 +892,9 @@ IRC_Send_WHO( CLIENT *Client, CHANNEL *Chan, BOOLEAN O
 	if( Channel_IsMemberOf( Chan, Client )) is_member = TRUE;
 	else is_member = FALSE;
 
+	/* Secret channel? */
+	if( ! is_member && strchr( Channel_Modes( Chan ), 's' )) return CONNECTED;
+
 	/* Alle Mitglieder suchen */
 	cl2chan = Channel_FirstMember( Chan );
 	while( cl2chan )
blob - bbecca98c3901e56aa224647936dc9b80be0e62d
blob + 368185f6e3be86f78aa204a8311a0dd44adf3b88
--- src/ngircd/irc-mode.c
+++ src/ngircd/irc-mode.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-mode.c,v 1.36 2005/02/27 20:09:44 alex Exp $";
+static char UNUSED id[] = "$Id: irc-mode.c,v 1.37 2005/03/02 16:35:11 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -362,6 +362,7 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Or
 			case 'i': /* Invite only */
 			case 'm': /* Moderated */
 			case 'n': /* Only members can write */
+			case 's': /* Secret channel */
 			case 't': /* Topic locked */
 				if( modeok ) x[0] = *mode_ptr;
 				else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));