]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/client.c
New configuration opion "MorePrivacy" to "censor" some user information
[ngircd-alex.git] / src / ngircd / client.c
index f73a2d1ef0b46242bbeed67a8f0a64608b46ab34..d038fd2481cde6bc01aca29d1669c93fdf01c1ff 100644 (file)
@@ -7,16 +7,17 @@
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
- *
- * Client management.
  */
 
-
 #define __client_c__
 
-
 #include "portab.h"
 
+/**
+ * @file
+ * Client management.
+ */
+
 #include "imp.h"
 #include <assert.h>
 #include <unistd.h>
 
 #include <exp.h>
 
-
 #define GETID_LEN (CLIENT_NICK_LEN-1) + 1 + (CLIENT_USER_LEN-1) + 1 + (CLIENT_HOST_LEN-1) + 1
 
-
 static CLIENT *This_Server, *My_Clients;
 
 static WHOWAS My_Whowas[MAX_WHOWAS];
@@ -93,7 +92,7 @@ Client_Init( void )
        This_Server->hops = 0;
 
        gethostname( This_Server->host, CLIENT_HOST_LEN );
-       if (!Conf_NoDNS) {
+       if (Conf_DNS) {
                h = gethostbyname( This_Server->host );
                if (h) strlcpy(This_Server->host, h->h_name, sizeof(This_Server->host));
        }
@@ -320,7 +319,11 @@ Client_SetHostname( CLIENT *Client, const char *Hostname )
        assert( Client != NULL );
        assert( Hostname != NULL );
 
-       strlcpy( Client->host, Hostname, sizeof( Client->host ));
+       if (strlen(Conf_CloakHost)) {
+               strlcpy( Client->host, Conf_CloakHost, sizeof( Client->host ));
+       } else {
+               strlcpy( Client->host, Hostname, sizeof( Client->host ));
+       }
 } /* Client_SetHostname */
 
 
@@ -332,6 +335,11 @@ Client_SetID( CLIENT *Client, const char *ID )
        
        strlcpy( Client->id, ID, sizeof( Client->id ));
 
+       if (Conf_CloakUserToNick) {
+               strlcpy( Client->user, ID, sizeof( Client->user ));
+               strlcpy( Client->info, ID, sizeof( Client->info ));
+       }
+
        /* Hash */
        Client->hash = Hash( Client->id );
 } /* Client_SetID */
@@ -345,7 +353,9 @@ Client_SetUser( CLIENT *Client, const char *User, bool Idented )
        assert( Client != NULL );
        assert( User != NULL );
 
-       if (Idented) {
+       if (Conf_CloakUserToNick) {
+               strlcpy(Client->user, Client->id, sizeof(Client->user));
+       } else if (Idented) {
                strlcpy(Client->user, User, sizeof(Client->user));
        } else {
                Client->user[0] = '~';
@@ -363,7 +373,8 @@ Client_SetUser( CLIENT *Client, const char *User, bool Idented )
  * @param User User name to set.
  */
 GLOBAL void
-Client_SetOrigUser(CLIENT UNUSED *Client, const char UNUSED *User) {
+Client_SetOrigUser(CLIENT UNUSED *Client, const char UNUSED *User)
+{
        assert(Client != NULL);
        assert(User != NULL);
 
@@ -381,7 +392,10 @@ Client_SetInfo( CLIENT *Client, const char *Info )
        assert( Client != NULL );
        assert( Info != NULL );
 
-       strlcpy(Client->info, Info, sizeof(Client->info));
+       if (Conf_CloakUserToNick)
+               strlcpy(Client->info, Client->id, sizeof(Client->info));
+       else
+               strlcpy(Client->info, Info, sizeof(Client->info));
 } /* Client_SetInfo */
 
 
@@ -552,17 +566,19 @@ Client_Search( const char *Nick )
 } /* Client_Search */
 
 
+/**
+ * Get client structure ("introducer") identfied by a server token.
+ * @return CLIENT structure or NULL if none could be found.
+ */
 GLOBAL CLIENT *
 Client_GetFromToken( CLIENT *Client, int Token )
 {
-       /* Client-Struktur, die den entsprechenden Introducer (=Client)
-        * und das gegebene Token hat, liefern. Wird keine gefunden,
-        * so wird NULL geliefert. */
-
        CLIENT *c;
 
        assert( Client != NULL );
-       assert( Token > 0 );
+
+       if (!Token)
+               return NULL;
 
        c = My_Clients;
        while (c) {
@@ -1274,4 +1290,26 @@ Destroy_UserOrService(CLIENT *Client, const char *Txt, const char *FwdMsg, bool
 } /* Destroy_UserOrService */
 
 
+#ifdef DEBUG
+
+GLOBAL void
+Client_DebugDump(void)
+{
+       CLIENT *c;
+
+       Log(LOG_DEBUG, "Client status:");
+       c = My_Clients;
+       while (c) {
+               Log(LOG_DEBUG,
+                   " - %s: type=%d, host=%s, user=%s, conn=%d, start=%ld, flags=%s",
+                   Client_ID(c), Client_Type(c), Client_Hostname(c),
+                   Client_User(c), Client_Conn(c), Client_StartTime(c),
+                   Client_Flags(c));
+               c = (CLIENT *)c->next;
+       }
+} /* Client_DumpClients */
+
+#endif
+
+
 /* -eof- */