]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Implement user mode "x": hostname cloaking (closes: #102)
authorAlexander Barton <alex@barton.de>
Tue, 17 Aug 2010 19:05:06 +0000 (21:05 +0200)
committerAlexander Barton <alex@barton.de>
Tue, 17 Aug 2010 19:05:06 +0000 (21:05 +0200)
When a client has user mode "x" set, its real hostname is cloaked
by substituting it with the server name (as configured in ngircd.conf).

Restricted clients (user mode "r") aren't allowed to change mode "x".

Please note that hostname cloaking is only in effect in server-client
communication! The server still uses the real hostname for its own
logging and for all server-server communication -- therefore all servers
in the network must support user mode "x" to prevent older servers
from leaking the real hostname of a cloaked client!

src/ngircd/defines.h
src/ngircd/irc-mode.c

index 579d5521d02772afcf76e65a8ca132c521d98b0f..01b60373bbc044153e8c742eab470a7a188318ae 100644 (file)
@@ -80,7 +80,7 @@
 #define RECONNECT_DELAY 3              /* Time to delay re-connect attempts
                                           in seconds. */
 
-#define USERMODES "aciorsw           /* Supported user modes. */
+#define USERMODES "aciorswx"           /* Supported user modes. */
 #define CHANMODES "biIklmnoPstvz"      /* Supported channel modes. */
 
 #define CONNECTED true                 /* Internal status codes. */
index 45defeb2b833f4933c24277b6fad077064b37536..df464a7dba7efca0058cdede4d18ec8090a7eeea 100644 (file)
@@ -185,6 +185,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
                                                        ERR_NOPRIVILEGES_MSG,
                                                        Client_ID(Origin));
                                break;
+
                        case 'o': /* IRC operator (only unsettable!) */
                                if(( ! set ) || ( Client_Type( Client ) == CLIENT_SERVER ))
                                {
@@ -199,6 +200,15 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
                                else ok = IRC_WriteStrClient( Origin, ERR_RESTRICTED_MSG, Client_ID( Origin ));
                                break;
 
+                       case 'x': /* Cloak hostname */
+                               if (Client_HasMode(Client, 'r'))
+                                       IRC_WriteStrClient(Origin,
+                                                          ERR_RESTRICTED_MSG,
+                                                          Client_ID(Origin));
+                               else
+                                       x[0] = 'x';
+                               break;
+
                        default:
                                Log( LOG_DEBUG, "Unknown mode \"%c%c\" from \"%s\"!?", set ? '+' : '-', *mode_ptr, Client_ID( Origin ));
                                if( Client_Type( Client ) != CLIENT_SERVER ) ok = IRC_WriteStrClient( Origin, ERR_UMODEUNKNOWNFLAG2_MSG, Client_ID( Origin ), set ? '+' : '-', *mode_ptr );