X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fclient.c;h=d038fd2481cde6bc01aca29d1669c93fdf01c1ff;hp=d53dc969cd47269c65f73314b4b8b55d95de66d2;hb=b80e115f3947eae39aba39d1647f0a81f3d95fa3;hpb=355828e64f6fa07eb96bc6b27eef964b529d8778 diff --git a/src/ngircd/client.c b/src/ngircd/client.c index d53dc969..d038fd24 100644 --- a/src/ngircd/client.c +++ b/src/ngircd/client.c @@ -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 #include @@ -43,10 +44,8 @@ #include - #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) { @@ -1285,7 +1301,7 @@ Client_DebugDump(void) c = My_Clients; while (c) { Log(LOG_DEBUG, - " - %s, type=%d, host=%s, user=%s, conn=%d, start=%ld, flags=%s", + " - %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));