repo: ngircd
action: commit
revision: 
path_from: 
revision_from: 21467c76f15a7773695ce3a37c7c843cb4682ac2:
path_to: 
revision_to: 
git.thebackupbox.net
ngircd
git clone git://git.thebackupbox.net/ngircd
commit 21467c76f15a7773695ce3a37c7c843cb4682ac2
Author: Alexander Barton 
Date:   Tue Aug 28 23:28:56 2012 +0200

    Introduce numeric RPL_HOSTHIDDEN_MSG(396)

    This numeric is sent to the client each time it changes its displayed
    hostname using "MODE +/-x", and if "CloakHost" is set right after the
    MOTD has been sent.

diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c
index f5139d07ebed78c68953bc56b19ed04424b9c884..
index ..6ec184a7caca3011eecae4697683fbaa4a4bbd77 100644
--- a/src/ngircd/irc-info.c
+++ b/src/ngircd/irc-info.c
@@ -1483,7 +1483,15 @@ Show_MOTD_Sendline(CLIENT *Client, const char *msg)
 static bool
 Show_MOTD_End(CLIENT *Client)
 {
-	return IRC_WriteStrClient( Client, RPL_ENDOFMOTD_MSG, Client_ID( Client ));
+	if (!IRC_WriteStrClient(Client, RPL_ENDOFMOTD_MSG, Client_ID(Client)))
+		return DISCONNECTED;
+
+	if (*Conf_CloakHost)
+		return IRC_WriteStrClient(Client, RPL_HOSTHIDDEN_MSG,
+					  Client_ID(Client),
+					  Client_Hostname(Client));
+
+	return CONNECTED;
 }

 #ifdef SSL_SUPPORT
diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c
index dc37ad00c83ed5dee4dbc047a6e8b1ce234484ff..
index ..71557201d8d938f4a5ff65416f50eb487f78333d 100644
--- a/src/ngircd/irc-mode.c
+++ b/src/ngircd/irc-mode.c
@@ -138,6 +138,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
 {
 	char the_modes[COMMAND_LEN], x[2], *mode_ptr;
 	bool ok, set;
+	bool send_RPL_HOSTHIDDEN_MSG = false;
 	int mode_arg;
 	size_t len;

@@ -279,6 +280,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
 							Client_ID(Origin));
 			else
 				x[0] = 'x';
+				send_RPL_HOSTHIDDEN_MSG = true;
 			break;
 		default:
 			if (Client_Type(Client) != CLIENT_SERVER) {
@@ -348,6 +350,10 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
 						  "MODE %s :%s",
 						  Client_ID(Target),
 						  the_modes);
+			if (send_RPL_HOSTHIDDEN_MSG)
+				IRC_WriteStrClient(Client, RPL_HOSTHIDDEN_MSG,
+						   Client_ID(Client),
+						   Client_HostnameCloaked(Client));
 		}
 		LogDebug("%s \"%s\": Mode change, now \"%s\".",
 			 Client_TypeText(Target), Client_Mask(Target),
diff --git a/src/ngircd/messages.h b/src/ngircd/messages.h
index 2cfd45dbf2529e1c54695bff07bd87f91b7e962a..
index ..4f3a397b2647eabc6fd6ed21f9aa31d776df69e9 100644
--- a/src/ngircd/messages.h
+++ b/src/ngircd/messages.h
@@ -96,6 +96,7 @@
 #define RPL_YOUREOPER_MSG		"381 %s :You are now an IRC Operator"
 #define RPL_YOURESERVICE_MSG		"383 %s :You are service %s"
 #define RPL_TIME_MSG			"391 %s %s :%s"
+#define RPL_HOSTHIDDEN_MSG		"396 %s %s :is your displayed hostname now"

 #define ERR_NOSUCHNICK_MSG		"401 %s %s :No such nick or channel name"
 #define ERR_NOSUCHSERVER_MSG		"402 %s %s :No such server"

-----END OF PAGE-----