repo: ngircd
action: commit
revision: 
path_from: 
revision_from: 40e3daf560799df1d16629b35078979583cb4349:
path_to: 
revision_to: 
git.thebackupbox.net
ngircd
git clone git://git.thebackupbox.net/ngircd
commit 40e3daf560799df1d16629b35078979583cb4349
Author: Alexander Barton 
Date:   Mon Nov 5 23:49:12 2012 +0100

    Generate "METADATA host" commands on "MODE +/-x"

    Use "METADATA host" commands to let servers supporting this command
    know which (possibly cloaked) hostname is in effect for a specific
    client. This prevents "double cloaking" of hostnames and even cloaked
    hostnames are in sync on all servers supporting "METADATA" now.

diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c
index ce4044d0bf7b154401e10096af47abed1911550b..
index ..1cf19afc2bf437f19a2887509e12851c932a7951 100644
--- a/src/ngircd/irc-mode.c
+++ b/src/ngircd/irc-mode.c
@@ -36,6 +36,8 @@
 #include "irc-mode.h"


+static void Announce_Client_Hostname PARAMS((CLIENT *Origin, CLIENT *Client));
+
 static bool Client_Mode PARAMS((CLIENT *Client, REQUEST *Req, CLIENT *Origin,
 				CLIENT *Target));
 static bool Channel_Mode PARAMS((CLIENT *Client, REQUEST *Req, CLIENT *Origin,
@@ -367,9 +369,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
 						  Client_ID(Target),
 						  the_modes);
 			if (send_RPL_HOSTHIDDEN_MSG)
-				IRC_WriteStrClient(Client, RPL_HOSTHIDDEN_MSG,
-						   Client_ID(Client),
-						   Client_HostnameCloaked(Client));
+				Announce_Client_Hostname(Origin, Client);
 		}
 		LogDebug("%s \"%s\": Mode change, now \"%s\".",
 			 Client_TypeText(Target), Client_Mask(Target),
@@ -381,6 +381,27 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
 } /* Client_Mode */


+/**
+ * Announce changed client hostname in the network.
+ *
+ * @param Client The client of which the hostname changed.
+ */
+static void
+Announce_Client_Hostname(CLIENT *Origin, CLIENT *Client)
+{
+	assert(Client != NULL);
+
+	/* Inform the client itself */
+	IRC_WriteStrClient(Client, RPL_HOSTHIDDEN_MSG, Client_ID(Client),
+			   Client_HostnameCloaked(Client));
+
+	/* Inform other servers in the network */
+	IRC_WriteStrServersPrefixFlag(Origin, Client_ThisServer(), 'M',
+				      "METADATA %s host :%s", Client_ID(Client),
+				      Client_HostnameCloaked(Client));
+}
+
+
 static bool
 Channel_Mode_Answer_Request(CLIENT *Origin, CHANNEL *Channel)
 {

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