} /* 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 )
{
/**
* Get potentially cloaked hostname of a client.
+ *
* If the client has not enabled cloaking, the real hostname is used.
+ * Please note that this function uses a global static buffer, so you can't
+ * nest invocations without overwriting earlier results!
+ *
* @param Client Pointer to client structure
* @return Pointer to client hostname
*/
GLOBAL char *
Client_HostnameCloaked(CLIENT *Client)
{
+ static char Cloak_Buffer[CLIENT_HOST_LEN];
+
assert(Client != NULL);
- if (Client_HasMode(Client, 'x'))
- return Client_ID(Client->introducer);
- else
+
+ /* Client isn't cloaked at all, return real hostname: */
+ if (!Client_HasMode(Client, 'x'))
return Client_Hostname(Client);
-} /* Client_HostnameCloaked */
+ /* Client has received METADATA command, so it got the eventually
+ * cloaked hostname set correctly and this server doesn't need
+ * to cloak it on its own: */
+ if (strchr(Client_Flags(Client), 'M'))
+ return Client_Hostname(Client);
-GLOBAL char *
-Client_Password( CLIENT *Client )
-{
- assert( Client != NULL );
- return Client->pwd;
-} /* Client_Password */
+ /* Do simple mapping to the server ID? */
+ if (!*Conf_CloakHostModeX)
+ return Client_ID(Client->introducer);
+
+ strlcpy(Cloak_Buffer, Client->host, CLIENT_HOST_LEN);
+ strlcat(Cloak_Buffer, Conf_CloakHostSalt, CLIENT_HOST_LEN);
+
+ snprintf(Cloak_Buffer, CLIENT_HOST_LEN, Conf_CloakHostModeX,
+ Hash(Cloak_Buffer));
+
+ return Cloak_Buffer;
+} /* Client_HostnameCloaked */
GLOBAL char *
/**
* Return ID of a client with cloaked hostname: "client!user@server-name"
+ *
* This client ID is used for IRC prefixes, for example.
* Please note that this function uses a global static buffer, so you can't
* nest invocations without overwriting earlier results!
* If the client has not enabled cloaking, the real hostname is used.
+ *
* @param Client Pointer to client structure
* @return Pointer to global buffer containing the client ID
*/
Client_MaskCloaked(CLIENT *Client)
{
static char Mask_Buffer[GETID_LEN];
- char Cloak_Buffer[GETID_LEN];
assert (Client != NULL);
if (!Client_HasMode(Client, 'x'))
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, Cloak_Buffer);
+ snprintf(Mask_Buffer, GETID_LEN, "%s!%s@%s", Client->id, Client->user,
+ Client_HostnameCloaked(Client));
return Mask_Buffer;
} /* Client_MaskCloaked */
* the appropriate error messages.
*
* @param Client Client that wants to change the nickname.
- * @param Nick New nick name.
+ * @param Nick New nickname.
* @returns true if nickname is valid, false otherwise.
*/
GLOBAL bool
if (Client_Type(Client) != CLIENT_SERVER
&& Client_Type(Client) != CLIENT_SERVICE) {
- /* Make sure that this isn't a restricted/forbidden nick name */
+ /* Make sure that this isn't a restricted/forbidden nickname */
if (Conf_NickIsBlocked(Nick)) {
IRC_WriteStrClient(Client, ERR_FORBIDDENNICKNAME_MSG,
Client_ID(Client), Nick);