]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/client.c
Merge branch 'move-connection-password' of git://arthur.barton.de/ngircd-alex
[ngircd-alex.git] / src / ngircd / client.c
index e203cdd0e79df243089066d09a80eedec5355a46..0d2d4147345046b87f7f3c6e46fd018749f4da36 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2010 Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2012 Alexander Barton (alex@barton.de)
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -331,9 +331,15 @@ Client_SetHostname( CLIENT *Client, const char *Hostname )
        assert(Hostname != NULL);
 
        if (strlen(Conf_CloakHost)) {
+               char cloak[GETID_LEN];
+
+               strlcpy(cloak, Hostname, GETID_LEN);
+               strlcat(cloak, Conf_CloakHostSalt, GETID_LEN);
+               snprintf(cloak, GETID_LEN, Conf_CloakHost, Hash(cloak));
+
                LogDebug("Updating hostname of \"%s\": \"%s\" -> \"%s\"",
-                        Client_ID(Client), Client->host, Conf_CloakHost);
-               strlcpy(Client->host, Conf_CloakHost, sizeof(Client->host));
+                       Client_ID(Client), Client->host, cloak);
+               strlcpy(Client->host, cloak, sizeof(Client->host));
        } else {
                LogDebug("Updating hostname of \"%s\": \"%s\" -> \"%s\"",
                         Client_ID(Client), Client->host, Hostname);
@@ -434,18 +440,6 @@ Client_SetFlags( CLIENT *Client, const char *Flags )
 } /* Client_SetFlags */
 
 
-GLOBAL void
-Client_SetPassword( CLIENT *Client, const char *Pwd )
-{
-       /* set password sent by client */
-
-       assert( Client != NULL );
-       assert( Pwd != NULL );
-
-       strlcpy(Client->pwd, Pwd, sizeof(Client->pwd));
-} /* Client_SetPassword */
-
-
 GLOBAL void
 Client_SetAway( CLIENT *Client, const char *Txt )
 {
@@ -708,14 +702,6 @@ Client_HostnameCloaked(CLIENT *Client)
 } /* Client_HostnameCloaked */
 
 
-GLOBAL char *
-Client_Password( CLIENT *Client )
-{
-       assert( Client != NULL );
-       return Client->pwd;
-} /* Client_Password */
-
-
 GLOBAL char *
 Client_Modes( CLIENT *Client )
 {
@@ -817,17 +803,25 @@ GLOBAL char *
 Client_MaskCloaked(CLIENT *Client)
 {
        static char Mask_Buffer[GETID_LEN];
+       char Cloak_Buffer[GETID_LEN];
 
        assert (Client != NULL);
 
        /* Is the client using cloaking at all? */
        if (!Client_HasMode(Client, 'x'))
-           return Client_Mask(Client);
+               return Client_Mask(Client);
+
+       if(*Conf_CloakHostModeX) {
+               strlcpy(Cloak_Buffer, Client->host, GETID_LEN);
+               strlcat(Cloak_Buffer, Conf_CloakHostSalt, GETID_LEN);
+               snprintf(Cloak_Buffer, GETID_LEN, Conf_CloakHostModeX, Hash(Cloak_Buffer));
+       } else {
+               strncpy(Cloak_Buffer, Client_ID(Client->introducer), GETID_LEN);
+       }
 
        snprintf(Mask_Buffer, GETID_LEN, "%s!%s@%s",
-                Client->id, Client->user,
-                *Conf_CloakHostModeX ? Conf_CloakHostModeX
-                                     : Client_ID(Client->introducer));
+               Client->id, Client->user, Cloak_Buffer);
+
        return Mask_Buffer;
 } /* Client_MaskCloaked */
 
@@ -891,6 +885,16 @@ Client_CheckNick(CLIENT *Client, char *Nick)
                return false;
        }
 
+       if (Client_Type(Client) != CLIENT_SERVER
+           && Client_Type(Client) != CLIENT_SERVICE) {
+               /* Make sure that this isn't a restricted/forbidden nick name */
+               if (Conf_NickIsBlocked(Nick)) {
+                       IRC_WriteStrClient(Client, ERR_FORBIDDENNICKNAME_MSG,
+                                          Client_ID(Client), Nick);
+                       return false;
+               }
+       }
+
        /* Nickname already registered? */
        if (Client_Search(Nick)) {
                IRC_WriteStrClient(Client, ERR_NICKNAMEINUSE_MSG,
@@ -1161,7 +1165,7 @@ Client_Introduce(CLIENT *From, CLIENT *Client, int Type)
        Client_SetType(Client, Type);
 
        if (From) {
-               if (Conf_IsService(Conf_GetServer(Client_Conn(From)),
+               if (Conf_NickIsService(Conf_GetServer(Client_Conn(From)),
                                   Client_ID(Client)))
                        Client_SetType(Client, CLIENT_SERVICE);
                LogDebug("%s \"%s\" (+%s) registered (via %s, on %s, %d hop%s).",