Module: ngircd.git Branch: master Commit: 40e3daf560799df1d16629b35078979583cb4349 URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=40e3d...
Author: Alexander Barton alex@barton.de 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.
---
src/ngircd/irc-mode.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c index ce4044d..1cf19af 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) {