about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorLucentW <LucentW@users.noreply.github.com>2015-04-27 23:20:32 +0200
committerLucentW <LucentW@users.noreply.github.com>2015-04-29 14:04:06 +0200
commit21767c968d5799ce153f860db6c119eb4b7f9518 (patch)
treee780933ef078ea5cd9cea9988ff0664c3ced565e /src
parentc5da48368569383d064a2325ab3b99d10287a085 (diff)
downloadngircd-21767c968d5799ce153f860db6c119eb4b7f9518.tar.gz
ngircd-21767c968d5799ce153f860db6c119eb4b7f9518.zip
Implement +I (private channel list on whois)
Implements enhancement requested in issue #179
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/defines.h2
-rw-r--r--src/ngircd/irc-info.c70
-rw-r--r--src/ngircd/irc-mode.c1
3 files changed, 38 insertions, 35 deletions
diff --git a/src/ngircd/defines.h b/src/ngircd/defines.h
index 456c4c93..ff849bbe 100644
--- a/src/ngircd/defines.h
+++ b/src/ngircd/defines.h
@@ -177,7 +177,7 @@
 #endif
 
 /** Supported user modes. */
-#define USERMODES "abBcCFioqrRswx"
+#define USERMODES "abBcCFiIoqrRswx"
 
 /** Supported channel modes. */
 #define CHANMODES "abehiIklmMnoOPqQrRstvVz"
diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c
index 61c6239c..e261b7f6 100644
--- a/src/ngircd/irc-info.c
+++ b/src/ngircd/irc-info.c
@@ -313,48 +313,50 @@ IRC_WHOIS_SendReply(CLIENT *Client, CLIENT *from, CLIENT *c)
 				Client_Info(Client_Introducer(c))))
 		return DISCONNECTED;
 
-	/* Channels */
-	snprintf(str, sizeof(str), RPL_WHOISCHANNELS_MSG,
-		 Client_ID(from), Client_ID(c));
-	cl2chan = Channel_FirstChannelOf(c);
-	while (cl2chan) {
-		chan = Channel_GetChannel(cl2chan);
-		assert(chan != NULL);
-
-		/* next */
-		cl2chan = Channel_NextChannelOf(c, cl2chan);
-
-		/* Secret channel? */
-		if (Channel_HasMode(chan, 's')
-		    && !Channel_IsMemberOf(chan, Client))
-			continue;
+	/* Channels, show only if client has no +I or if from is oper */
+	if(!(Client_HasMode(c, 'I')) || Client_HasMode(from, 'o'))  {
+		snprintf(str, sizeof(str), RPL_WHOISCHANNELS_MSG,
+			 Client_ID(from), Client_ID(c));
+		cl2chan = Channel_FirstChannelOf(c);
+		while (cl2chan) {
+			chan = Channel_GetChannel(cl2chan);
+			assert(chan != NULL);
+
+			/* next */
+			cl2chan = Channel_NextChannelOf(c, cl2chan);
+
+			/* Secret channel? */
+			if (Channel_HasMode(chan, 's')
+				&& !Channel_IsMemberOf(chan, Client))
+				continue;
 
-		/* Local channel and request is not from a user? */
-		if (Client_Type(Client) == CLIENT_SERVER
-		    && Channel_IsLocal(chan))
-			continue;
+			/* Local channel and request is not from a user? */
+			if (Client_Type(Client) == CLIENT_SERVER
+				&& Channel_IsLocal(chan))
+				continue;
 
-		/* Concatenate channel names */
-		if (str[strlen(str) - 1] != ':')
-			strlcat(str, " ", sizeof(str));
+			/* Concatenate channel names */
+			if (str[strlen(str) - 1] != ':')
+				strlcat(str, " ", sizeof(str));
 
-		who_flags_qualifier(Client, Channel_UserModes(chan, c),
-				    str, sizeof(str));
-		strlcat(str, Channel_Name(chan), sizeof(str));
+			who_flags_qualifier(Client, Channel_UserModes(chan, c),
+						str, sizeof(str));
+			strlcat(str, Channel_Name(chan), sizeof(str));
 
-		if (strlen(str) > (COMMAND_LEN - CHANNEL_NAME_LEN - 4)) {
-			/* Line becomes too long: send it! */
+			if (strlen(str) > (COMMAND_LEN - CHANNEL_NAME_LEN - 4)) {
+				/* Line becomes too long: send it! */
+				if (!IRC_WriteStrClient(Client, "%s", str))
+					return DISCONNECTED;
+				snprintf(str, sizeof(str), RPL_WHOISCHANNELS_MSG,
+					 Client_ID(from), Client_ID(c));
+			}
+		}
+		if(str[strlen(str) - 1] != ':') {
+			/* There is data left to send: */
 			if (!IRC_WriteStrClient(Client, "%s", str))
 				return DISCONNECTED;
-			snprintf(str, sizeof(str), RPL_WHOISCHANNELS_MSG,
-				 Client_ID(from), Client_ID(c));
 		}
 	}
-	if(str[strlen(str) - 1] != ':') {
-		/* There is data left to send: */
-		if (!IRC_WriteStrClient(Client, "%s", str))
-			return DISCONNECTED;
-	}
 
 	/* IRC-Services? */
 	if (Client_Type(c) == CLIENT_SERVICE &&
diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c
index cde573bf..ec7d53c4 100644
--- a/src/ngircd/irc-mode.c
+++ b/src/ngircd/irc-mode.c
@@ -206,6 +206,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
 		case 'b': /* Block private msgs */
 		case 'C': /* Only messages from clients sharing a channel */
 		case 'i': /* Invisible */
+		case 'I': /* Hide channel list from WHOIS */
 		case 's': /* Server messages */
 		case 'w': /* Wallops messages */
 			x[0] = *mode_ptr;